coder-config 0.54.5 → 0.54.6-beta

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.
@@ -589,7 +589,7 @@ Error generating stack: `+L.message+`
589
589
 
590
590
  If you want to hide the \`${r.titleName}\`, you can wrap it with our VisuallyHidden component.
591
591
 
592
- For more information, see https://radix-ui.com/primitives/docs/components/${r.docsSlug}`;return _.useEffect(()=>{e&&(document.getElementById(e)||console.error(s))},[s,e]),null},EL="DialogDescriptionWarning",PL=({contentRef:e,descriptionId:r})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${NC(EL).contentName}}.`;return _.useEffect(()=>{var c;const o=(c=e.current)==null?void 0:c.getAttribute("aria-describedby");r&&o&&(document.getElementById(r)||console.warn(n))},[n,e,r]),null},AL=fC,TL=pC,EC=xC,tx=vC,rx=yC,sx=wC,nx=kC,ix=CC;const vt=AL,RL=EC,PC=_.forwardRef(({className:e,...r},s)=>t.jsx(tx,{ref:s,className:Ee("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...r}));PC.displayName=tx.displayName;const ft=_.forwardRef(({className:e,children:r,...s},n)=>t.jsxs(RL,{children:[t.jsx(PC,{}),t.jsxs(rx,{ref:n,className:Ee("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...s,children:[r,t.jsxs(ix,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[t.jsx(Nn,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ft.displayName=rx.displayName;const mt=({className:e,...r})=>t.jsx("div",{className:Ee("flex flex-col space-y-1.5 text-center sm:text-left",e),...r});mt.displayName="DialogHeader";const St=({className:e,...r})=>t.jsx("div",{className:Ee("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...r});St.displayName="DialogFooter";const pt=_.forwardRef(({className:e,...r},s)=>t.jsx(sx,{ref:s,className:Ee("text-lg font-semibold leading-none tracking-tight",e),...r}));pt.displayName=sx.displayName;const Gt=_.forwardRef(({className:e,...r},s)=>t.jsx(nx,{ref:s,className:Ee("text-sm text-muted-foreground",e),...r}));Gt.displayName=nx.displayName;function ox(e){const r=_.useRef({value:e,previous:e});return _.useMemo(()=>(r.current.value!==e&&(r.current.previous=r.current.value,r.current.value=e),r.current.previous),[e])}function ax(e){const[r,s]=_.useState(void 0);return Ur(()=>{if(e){s({width:e.offsetWidth,height:e.offsetHeight});const n=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const c=o[0];let d,l;if("borderBoxSize"in c){const u=c.borderBoxSize,f=Array.isArray(u)?u[0]:u;d=f.inlineSize,l=f.blockSize}else d=e.offsetWidth,l=e.offsetHeight;s({width:d,height:l})});return n.observe(e,{box:"border-box"}),()=>n.unobserve(e)}else s(void 0)},[e]),r}var uh="Checkbox",[ML]=Ls(uh),[IL,lx]=ML(uh);function DL(e){const{__scopeCheckbox:r,checked:s,children:n,defaultChecked:o,disabled:c,form:d,name:l,onCheckedChange:u,required:f,value:m="on",internal_do_not_use_render:h}=e,[g,w]=Xn({prop:s,defaultProp:o??!1,onChange:u,caller:uh}),[j,k]=_.useState(null),[v,y]=_.useState(null),x=_.useRef(!1),b=j?!!d||!!j.closest("form"):!0,S={checked:g,disabled:c,setChecked:w,control:j,setControl:k,name:l,form:d,value:m,hasConsumerStoppedPropagationRef:x,required:f,defaultChecked:Xi(o)?!1:o,isFormControl:b,bubbleInput:v,setBubbleInput:y};return t.jsx(IL,{scope:r,...S,children:LL(h)?h(S):n})}var AC="CheckboxTrigger",TC=_.forwardRef(({__scopeCheckbox:e,onKeyDown:r,onClick:s,...n},o)=>{const{control:c,value:d,disabled:l,checked:u,required:f,setControl:m,setChecked:h,hasConsumerStoppedPropagationRef:g,isFormControl:w,bubbleInput:j}=lx(AC,e),k=bt(o,m),v=_.useRef(u);return _.useEffect(()=>{const y=c==null?void 0:c.form;if(y){const x=()=>h(v.current);return y.addEventListener("reset",x),()=>y.removeEventListener("reset",x)}},[c,h]),t.jsx(ot.button,{type:"button",role:"checkbox","aria-checked":Xi(u)?"mixed":u,"aria-required":f,"data-state":LC(u),"data-disabled":l?"":void 0,disabled:l,value:d,...n,ref:k,onKeyDown:Be(r,y=>{y.key==="Enter"&&y.preventDefault()}),onClick:Be(s,y=>{h(x=>Xi(x)?!0:!x),j&&w&&(g.current=y.isPropagationStopped(),g.current||y.stopPropagation())})})});TC.displayName=AC;var cx=_.forwardRef((e,r)=>{const{__scopeCheckbox:s,name:n,checked:o,defaultChecked:c,required:d,disabled:l,value:u,onCheckedChange:f,form:m,...h}=e;return t.jsx(DL,{__scopeCheckbox:s,checked:o,defaultChecked:c,disabled:l,required:d,onCheckedChange:f,name:n,form:m,value:u,internal_do_not_use_render:({isFormControl:g})=>t.jsxs(t.Fragment,{children:[t.jsx(TC,{...h,ref:r,__scopeCheckbox:s}),g&&t.jsx(DC,{__scopeCheckbox:s})]})})});cx.displayName=uh;var RC="CheckboxIndicator",MC=_.forwardRef((e,r)=>{const{__scopeCheckbox:s,forceMount:n,...o}=e,c=lx(RC,s);return t.jsx(es,{present:n||Xi(c.checked)||c.checked===!0,children:t.jsx(ot.span,{"data-state":LC(c.checked),"data-disabled":c.disabled?"":void 0,...o,ref:r,style:{pointerEvents:"none",...e.style}})})});MC.displayName=RC;var IC="CheckboxBubbleInput",DC=_.forwardRef(({__scopeCheckbox:e,...r},s)=>{const{control:n,hasConsumerStoppedPropagationRef:o,checked:c,defaultChecked:d,required:l,disabled:u,name:f,value:m,form:h,bubbleInput:g,setBubbleInput:w}=lx(IC,e),j=bt(s,w),k=ox(c),v=ax(n);_.useEffect(()=>{const x=g;if(!x)return;const b=window.HTMLInputElement.prototype,N=Object.getOwnPropertyDescriptor(b,"checked").set,P=!o.current;if(k!==c&&N){const A=new Event("click",{bubbles:P});x.indeterminate=Xi(c),N.call(x,Xi(c)?!1:c),x.dispatchEvent(A)}},[g,k,c,o]);const y=_.useRef(Xi(c)?!1:c);return t.jsx(ot.input,{type:"checkbox","aria-hidden":!0,defaultChecked:d??y.current,required:l,disabled:u,name:f,value:m,form:h,...r,tabIndex:-1,ref:j,style:{...r.style,...v,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});DC.displayName=IC;function LL(e){return typeof e=="function"}function Xi(e){return e==="indeterminate"}function LC(e){return Xi(e)?"indeterminate":e?"checked":"unchecked"}const Fc=_.forwardRef(({className:e,...r},s)=>t.jsx(cx,{ref:s,className:Ee("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...r,children:t.jsx(MC,{className:Ee("flex items-center justify-center text-current"),children:t.jsx(It,{className:"h-4 w-4"})})}));Fc.displayName=cx.displayName;function mw(e){const r=OL(e),s=_.forwardRef((n,o)=>{const{children:c,...d}=n,l=_.Children.toArray(c),u=l.find(BL);if(u){const f=u.props.children,m=l.map(h=>h===u?_.Children.count(f)>1?_.Children.only(null):_.isValidElement(f)?f.props.children:null:h);return t.jsx(r,{...d,ref:o,children:_.isValidElement(f)?_.cloneElement(f,void 0,m):null})}return t.jsx(r,{...d,ref:o,children:c})});return s.displayName=`${e}.Slot`,s}function OL(e){const r=_.forwardRef((s,n)=>{const{children:o,...c}=s;if(_.isValidElement(o)){const d=HL(o),l=$L(c,o.props);return o.type!==_.Fragment&&(l.ref=n?_i(n,d):d),_.cloneElement(o,l)}return _.Children.count(o)>1?_.Children.only(null):null});return r.displayName=`${e}.SlotClone`,r}var FL=Symbol("radix.slottable");function BL(e){return _.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===FL}function $L(e,r){const s={...r};for(const n in r){const o=e[n],c=r[n];/^on[A-Z]/.test(n)?o&&c?s[n]=(...l)=>{const u=c(...l);return o(...l),u}:o&&(s[n]=o):n==="style"?s[n]={...o,...c}:n==="className"&&(s[n]=[o,c].filter(Boolean).join(" "))}return{...e,...s}}function HL(e){var n,o;let r=(n=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:n.get,s=r&&"isReactWarning"in r&&r.isReactWarning;return s?e.ref:(r=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,s=r&&"isReactWarning"in r&&r.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}function dx(e){const r=e+"CollectionProvider",[s,n]=Ls(r),[o,c]=s(r,{collectionRef:{current:null},itemMap:new Map}),d=k=>{const{scope:v,children:y}=k,x=Te.useRef(null),b=Te.useRef(new Map).current;return t.jsx(o,{scope:v,itemMap:b,collectionRef:x,children:y})};d.displayName=r;const l=e+"CollectionSlot",u=mw(l),f=Te.forwardRef((k,v)=>{const{scope:y,children:x}=k,b=c(l,y),S=bt(v,b.collectionRef);return t.jsx(u,{ref:S,children:x})});f.displayName=l;const m=e+"CollectionItemSlot",h="data-radix-collection-item",g=mw(m),w=Te.forwardRef((k,v)=>{const{scope:y,children:x,...b}=k,S=Te.useRef(null),N=bt(v,S),P=c(m,y);return Te.useEffect(()=>(P.itemMap.set(S,{ref:S,...b}),()=>void P.itemMap.delete(S))),t.jsx(g,{[h]:"",ref:N,children:x})});w.displayName=m;function j(k){const v=c(e+"CollectionConsumer",k);return Te.useCallback(()=>{const x=v.collectionRef.current;if(!x)return[];const b=Array.from(x.querySelectorAll(`[${h}]`));return Array.from(v.itemMap.values()).sort((P,A)=>b.indexOf(P.ref.current)-b.indexOf(A.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:d,Slot:f,ItemSlot:w},j,n]}const zL=["top","right","bottom","left"],to=Math.min,Vs=Math.max,Fu=Math.round,au=Math.floor,Kn=e=>({x:e,y:e}),WL={left:"right",right:"left",bottom:"top",top:"bottom"};function Ap(e,r,s){return Vs(e,to(r,s))}function bi(e,r){return typeof e=="function"?e(r):e}function wi(e){return e.split("-")[0]}function ll(e){return e.split("-")[1]}function ux(e){return e==="x"?"y":"x"}function hx(e){return e==="y"?"height":"width"}function Vn(e){const r=e[0];return r==="t"||r==="b"?"y":"x"}function fx(e){return ux(Vn(e))}function UL(e,r,s){s===void 0&&(s=!1);const n=ll(e),o=fx(e),c=hx(o);let d=o==="x"?n===(s?"end":"start")?"right":"left":n==="start"?"bottom":"top";return r.reference[c]>r.floating[c]&&(d=Bu(d)),[d,Bu(d)]}function VL(e){const r=Bu(e);return[Tp(e),r,Tp(r)]}function Tp(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const pw=["left","right"],gw=["right","left"],GL=["top","bottom"],qL=["bottom","top"];function KL(e,r,s){switch(e){case"top":case"bottom":return s?r?gw:pw:r?pw:gw;case"left":case"right":return r?GL:qL;default:return[]}}function YL(e,r,s,n){const o=ll(e);let c=KL(wi(e),s==="start",n);return o&&(c=c.map(d=>d+"-"+o),r&&(c=c.concat(c.map(Tp)))),c}function Bu(e){const r=wi(e);return WL[r]+e.slice(r.length)}function XL(e){return{top:0,right:0,bottom:0,left:0,...e}}function OC(e){return typeof e!="number"?XL(e):{top:e,right:e,bottom:e,left:e}}function $u(e){const{x:r,y:s,width:n,height:o}=e;return{width:n,height:o,top:s,left:r,right:r+n,bottom:s+o,x:r,y:s}}function xw(e,r,s){let{reference:n,floating:o}=e;const c=Vn(r),d=fx(r),l=hx(d),u=wi(r),f=c==="y",m=n.x+n.width/2-o.width/2,h=n.y+n.height/2-o.height/2,g=n[l]/2-o[l]/2;let w;switch(u){case"top":w={x:m,y:n.y-o.height};break;case"bottom":w={x:m,y:n.y+n.height};break;case"right":w={x:n.x+n.width,y:h};break;case"left":w={x:n.x-o.width,y:h};break;default:w={x:n.x,y:n.y}}switch(ll(r)){case"start":w[d]-=g*(s&&f?-1:1);break;case"end":w[d]+=g*(s&&f?-1:1);break}return w}async function JL(e,r){var s;r===void 0&&(r={});const{x:n,y:o,platform:c,rects:d,elements:l,strategy:u}=e,{boundary:f="clippingAncestors",rootBoundary:m="viewport",elementContext:h="floating",altBoundary:g=!1,padding:w=0}=bi(r,e),j=OC(w),v=l[g?h==="floating"?"reference":"floating":h],y=$u(await c.getClippingRect({element:(s=await(c.isElement==null?void 0:c.isElement(v)))==null||s?v:v.contextElement||await(c.getDocumentElement==null?void 0:c.getDocumentElement(l.floating)),boundary:f,rootBoundary:m,strategy:u})),x=h==="floating"?{x:n,y:o,width:d.floating.width,height:d.floating.height}:d.reference,b=await(c.getOffsetParent==null?void 0:c.getOffsetParent(l.floating)),S=await(c.isElement==null?void 0:c.isElement(b))?await(c.getScale==null?void 0:c.getScale(b))||{x:1,y:1}:{x:1,y:1},N=$u(c.convertOffsetParentRelativeRectToViewportRelativeRect?await c.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:x,offsetParent:b,strategy:u}):x);return{top:(y.top-N.top+j.top)/S.y,bottom:(N.bottom-y.bottom+j.bottom)/S.y,left:(y.left-N.left+j.left)/S.x,right:(N.right-y.right+j.right)/S.x}}const QL=50,ZL=async(e,r,s)=>{const{placement:n="bottom",strategy:o="absolute",middleware:c=[],platform:d}=s,l=d.detectOverflow?d:{...d,detectOverflow:JL},u=await(d.isRTL==null?void 0:d.isRTL(r));let f=await d.getElementRects({reference:e,floating:r,strategy:o}),{x:m,y:h}=xw(f,n,u),g=n,w=0;const j={};for(let k=0;k<c.length;k++){const v=c[k];if(!v)continue;const{name:y,fn:x}=v,{x:b,y:S,data:N,reset:P}=await x({x:m,y:h,initialPlacement:n,placement:g,strategy:o,middlewareData:j,rects:f,platform:l,elements:{reference:e,floating:r}});m=b??m,h=S??h,j[y]={...j[y],...N},P&&w<QL&&(w++,typeof P=="object"&&(P.placement&&(g=P.placement),P.rects&&(f=P.rects===!0?await d.getElementRects({reference:e,floating:r,strategy:o}):P.rects),{x:m,y:h}=xw(f,g,u)),k=-1)}return{x:m,y:h,placement:g,strategy:o,middlewareData:j}},eO=e=>({name:"arrow",options:e,async fn(r){const{x:s,y:n,placement:o,rects:c,platform:d,elements:l,middlewareData:u}=r,{element:f,padding:m=0}=bi(e,r)||{};if(f==null)return{};const h=OC(m),g={x:s,y:n},w=fx(o),j=hx(w),k=await d.getDimensions(f),v=w==="y",y=v?"top":"left",x=v?"bottom":"right",b=v?"clientHeight":"clientWidth",S=c.reference[j]+c.reference[w]-g[w]-c.floating[j],N=g[w]-c.reference[w],P=await(d.getOffsetParent==null?void 0:d.getOffsetParent(f));let A=P?P[b]:0;(!A||!await(d.isElement==null?void 0:d.isElement(P)))&&(A=l.floating[b]||c.floating[j]);const E=S/2-N/2,M=A/2-k[j]/2-1,I=to(h[y],M),B=to(h[x],M),U=I,V=A-k[j]-B,Q=A/2-k[j]/2+E,z=Ap(U,Q,V),H=!u.arrow&&ll(o)!=null&&Q!==z&&c.reference[j]/2-(Q<U?I:B)-k[j]/2<0,Y=H?Q<U?Q-U:Q-V:0;return{[w]:g[w]+Y,data:{[w]:z,centerOffset:Q-z-Y,...H&&{alignmentOffset:Y}},reset:H}}}),tO=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(r){var s,n;const{placement:o,middlewareData:c,rects:d,initialPlacement:l,platform:u,elements:f}=r,{mainAxis:m=!0,crossAxis:h=!0,fallbackPlacements:g,fallbackStrategy:w="bestFit",fallbackAxisSideDirection:j="none",flipAlignment:k=!0,...v}=bi(e,r);if((s=c.arrow)!=null&&s.alignmentOffset)return{};const y=wi(o),x=Vn(l),b=wi(l)===l,S=await(u.isRTL==null?void 0:u.isRTL(f.floating)),N=g||(b||!k?[Bu(l)]:VL(l)),P=j!=="none";!g&&P&&N.push(...YL(l,k,j,S));const A=[l,...N],E=await u.detectOverflow(r,v),M=[];let I=((n=c.flip)==null?void 0:n.overflows)||[];if(m&&M.push(E[y]),h){const Q=UL(o,d,S);M.push(E[Q[0]],E[Q[1]])}if(I=[...I,{placement:o,overflows:M}],!M.every(Q=>Q<=0)){var B,U;const Q=(((B=c.flip)==null?void 0:B.index)||0)+1,z=A[Q];if(z&&(!(h==="alignment"?x!==Vn(z):!1)||I.every(K=>Vn(K.placement)===x?K.overflows[0]>0:!0)))return{data:{index:Q,overflows:I},reset:{placement:z}};let H=(U=I.filter(Y=>Y.overflows[0]<=0).sort((Y,K)=>Y.overflows[1]-K.overflows[1])[0])==null?void 0:U.placement;if(!H)switch(w){case"bestFit":{var V;const Y=(V=I.filter(K=>{if(P){const O=Vn(K.placement);return O===x||O==="y"}return!0}).map(K=>[K.placement,K.overflows.filter(O=>O>0).reduce((O,T)=>O+T,0)]).sort((K,O)=>K[1]-O[1])[0])==null?void 0:V[0];Y&&(H=Y);break}case"initialPlacement":H=l;break}if(o!==H)return{reset:{placement:H}}}return{}}}};function vw(e,r){return{top:e.top-r.height,right:e.right-r.width,bottom:e.bottom-r.height,left:e.left-r.width}}function yw(e){return zL.some(r=>e[r]>=0)}const rO=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(r){const{rects:s,platform:n}=r,{strategy:o="referenceHidden",...c}=bi(e,r);switch(o){case"referenceHidden":{const d=await n.detectOverflow(r,{...c,elementContext:"reference"}),l=vw(d,s.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:yw(l)}}}case"escaped":{const d=await n.detectOverflow(r,{...c,altBoundary:!0}),l=vw(d,s.floating);return{data:{escapedOffsets:l,escaped:yw(l)}}}default:return{}}}}},FC=new Set(["left","top"]);async function sO(e,r){const{placement:s,platform:n,elements:o}=e,c=await(n.isRTL==null?void 0:n.isRTL(o.floating)),d=wi(s),l=ll(s),u=Vn(s)==="y",f=FC.has(d)?-1:1,m=c&&u?-1:1,h=bi(r,e);let{mainAxis:g,crossAxis:w,alignmentAxis:j}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return l&&typeof j=="number"&&(w=l==="end"?j*-1:j),u?{x:w*m,y:g*f}:{x:g*f,y:w*m}}const nO=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(r){var s,n;const{x:o,y:c,placement:d,middlewareData:l}=r,u=await sO(r,e);return d===((s=l.offset)==null?void 0:s.placement)&&(n=l.arrow)!=null&&n.alignmentOffset?{}:{x:o+u.x,y:c+u.y,data:{...u,placement:d}}}}},iO=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(r){const{x:s,y:n,placement:o,platform:c}=r,{mainAxis:d=!0,crossAxis:l=!1,limiter:u={fn:y=>{let{x,y:b}=y;return{x,y:b}}},...f}=bi(e,r),m={x:s,y:n},h=await c.detectOverflow(r,f),g=Vn(wi(o)),w=ux(g);let j=m[w],k=m[g];if(d){const y=w==="y"?"top":"left",x=w==="y"?"bottom":"right",b=j+h[y],S=j-h[x];j=Ap(b,j,S)}if(l){const y=g==="y"?"top":"left",x=g==="y"?"bottom":"right",b=k+h[y],S=k-h[x];k=Ap(b,k,S)}const v=u.fn({...r,[w]:j,[g]:k});return{...v,data:{x:v.x-s,y:v.y-n,enabled:{[w]:d,[g]:l}}}}}},oO=function(e){return e===void 0&&(e={}),{options:e,fn(r){const{x:s,y:n,placement:o,rects:c,middlewareData:d}=r,{offset:l=0,mainAxis:u=!0,crossAxis:f=!0}=bi(e,r),m={x:s,y:n},h=Vn(o),g=ux(h);let w=m[g],j=m[h];const k=bi(l,r),v=typeof k=="number"?{mainAxis:k,crossAxis:0}:{mainAxis:0,crossAxis:0,...k};if(u){const b=g==="y"?"height":"width",S=c.reference[g]-c.floating[b]+v.mainAxis,N=c.reference[g]+c.reference[b]-v.mainAxis;w<S?w=S:w>N&&(w=N)}if(f){var y,x;const b=g==="y"?"width":"height",S=FC.has(wi(o)),N=c.reference[h]-c.floating[b]+(S&&((y=d.offset)==null?void 0:y[h])||0)+(S?0:v.crossAxis),P=c.reference[h]+c.reference[b]+(S?0:((x=d.offset)==null?void 0:x[h])||0)-(S?v.crossAxis:0);j<N?j=N:j>P&&(j=P)}return{[g]:w,[h]:j}}}},aO=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(r){var s,n;const{placement:o,rects:c,platform:d,elements:l}=r,{apply:u=()=>{},...f}=bi(e,r),m=await d.detectOverflow(r,f),h=wi(o),g=ll(o),w=Vn(o)==="y",{width:j,height:k}=c.floating;let v,y;h==="top"||h==="bottom"?(v=h,y=g===(await(d.isRTL==null?void 0:d.isRTL(l.floating))?"start":"end")?"left":"right"):(y=h,v=g==="end"?"top":"bottom");const x=k-m.top-m.bottom,b=j-m.left-m.right,S=to(k-m[v],x),N=to(j-m[y],b),P=!r.middlewareData.shift;let A=S,E=N;if((s=r.middlewareData.shift)!=null&&s.enabled.x&&(E=b),(n=r.middlewareData.shift)!=null&&n.enabled.y&&(A=x),P&&!g){const I=Vs(m.left,0),B=Vs(m.right,0),U=Vs(m.top,0),V=Vs(m.bottom,0);w?E=j-2*(I!==0||B!==0?I+B:Vs(m.left,m.right)):A=k-2*(U!==0||V!==0?U+V:Vs(m.top,m.bottom))}await u({...r,availableWidth:E,availableHeight:A});const M=await d.getDimensions(l.floating);return j!==M.width||k!==M.height?{reset:{rects:!0}}:{}}}};function hh(){return typeof window<"u"}function cl(e){return BC(e)?(e.nodeName||"").toLowerCase():"#document"}function Ks(e){var r;return(e==null||(r=e.ownerDocument)==null?void 0:r.defaultView)||window}function ei(e){var r;return(r=(BC(e)?e.ownerDocument:e.document)||window.document)==null?void 0:r.documentElement}function BC(e){return hh()?e instanceof Node||e instanceof Ks(e).Node:!1}function An(e){return hh()?e instanceof Element||e instanceof Ks(e).Element:!1}function ki(e){return hh()?e instanceof HTMLElement||e instanceof Ks(e).HTMLElement:!1}function bw(e){return!hh()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ks(e).ShadowRoot}function Bc(e){const{overflow:r,overflowX:s,overflowY:n,display:o}=Tn(e);return/auto|scroll|overlay|hidden|clip/.test(r+n+s)&&o!=="inline"&&o!=="contents"}function lO(e){return/^(table|td|th)$/.test(cl(e))}function fh(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const cO=/transform|translate|scale|rotate|perspective|filter/,dO=/paint|layout|strict|content/,Ro=e=>!!e&&e!=="none";let Lm;function mx(e){const r=An(e)?Tn(e):e;return Ro(r.transform)||Ro(r.translate)||Ro(r.scale)||Ro(r.rotate)||Ro(r.perspective)||!px()&&(Ro(r.backdropFilter)||Ro(r.filter))||cO.test(r.willChange||"")||dO.test(r.contain||"")}function uO(e){let r=ro(e);for(;ki(r)&&!sl(r);){if(mx(r))return r;if(fh(r))return null;r=ro(r)}return null}function px(){return Lm==null&&(Lm=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Lm}function sl(e){return/^(html|body|#document)$/.test(cl(e))}function Tn(e){return Ks(e).getComputedStyle(e)}function mh(e){return An(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ro(e){if(cl(e)==="html")return e;const r=e.assignedSlot||e.parentNode||bw(e)&&e.host||ei(e);return bw(r)?r.host:r}function $C(e){const r=ro(e);return sl(r)?e.ownerDocument?e.ownerDocument.body:e.body:ki(r)&&Bc(r)?r:$C(r)}function yc(e,r,s){var n;r===void 0&&(r=[]),s===void 0&&(s=!0);const o=$C(e),c=o===((n=e.ownerDocument)==null?void 0:n.body),d=Ks(o);if(c){const l=Rp(d);return r.concat(d,d.visualViewport||[],Bc(o)?o:[],l&&s?yc(l):[])}else return r.concat(o,yc(o,[],s))}function Rp(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function HC(e){const r=Tn(e);let s=parseFloat(r.width)||0,n=parseFloat(r.height)||0;const o=ki(e),c=o?e.offsetWidth:s,d=o?e.offsetHeight:n,l=Fu(s)!==c||Fu(n)!==d;return l&&(s=c,n=d),{width:s,height:n,$:l}}function gx(e){return An(e)?e:e.contextElement}function Ka(e){const r=gx(e);if(!ki(r))return Kn(1);const s=r.getBoundingClientRect(),{width:n,height:o,$:c}=HC(r);let d=(c?Fu(s.width):s.width)/n,l=(c?Fu(s.height):s.height)/o;return(!d||!Number.isFinite(d))&&(d=1),(!l||!Number.isFinite(l))&&(l=1),{x:d,y:l}}const hO=Kn(0);function zC(e){const r=Ks(e);return!px()||!r.visualViewport?hO:{x:r.visualViewport.offsetLeft,y:r.visualViewport.offsetTop}}function fO(e,r,s){return r===void 0&&(r=!1),!s||r&&s!==Ks(e)?!1:r}function zo(e,r,s,n){r===void 0&&(r=!1),s===void 0&&(s=!1);const o=e.getBoundingClientRect(),c=gx(e);let d=Kn(1);r&&(n?An(n)&&(d=Ka(n)):d=Ka(e));const l=fO(c,s,n)?zC(c):Kn(0);let u=(o.left+l.x)/d.x,f=(o.top+l.y)/d.y,m=o.width/d.x,h=o.height/d.y;if(c){const g=Ks(c),w=n&&An(n)?Ks(n):n;let j=g,k=Rp(j);for(;k&&n&&w!==j;){const v=Ka(k),y=k.getBoundingClientRect(),x=Tn(k),b=y.left+(k.clientLeft+parseFloat(x.paddingLeft))*v.x,S=y.top+(k.clientTop+parseFloat(x.paddingTop))*v.y;u*=v.x,f*=v.y,m*=v.x,h*=v.y,u+=b,f+=S,j=Ks(k),k=Rp(j)}}return $u({width:m,height:h,x:u,y:f})}function ph(e,r){const s=mh(e).scrollLeft;return r?r.left+s:zo(ei(e)).left+s}function WC(e,r){const s=e.getBoundingClientRect(),n=s.left+r.scrollLeft-ph(e,s),o=s.top+r.scrollTop;return{x:n,y:o}}function mO(e){let{elements:r,rect:s,offsetParent:n,strategy:o}=e;const c=o==="fixed",d=ei(n),l=r?fh(r.floating):!1;if(n===d||l&&c)return s;let u={scrollLeft:0,scrollTop:0},f=Kn(1);const m=Kn(0),h=ki(n);if((h||!h&&!c)&&((cl(n)!=="body"||Bc(d))&&(u=mh(n)),h)){const w=zo(n);f=Ka(n),m.x=w.x+n.clientLeft,m.y=w.y+n.clientTop}const g=d&&!h&&!c?WC(d,u):Kn(0);return{width:s.width*f.x,height:s.height*f.y,x:s.x*f.x-u.scrollLeft*f.x+m.x+g.x,y:s.y*f.y-u.scrollTop*f.y+m.y+g.y}}function pO(e){return Array.from(e.getClientRects())}function gO(e){const r=ei(e),s=mh(e),n=e.ownerDocument.body,o=Vs(r.scrollWidth,r.clientWidth,n.scrollWidth,n.clientWidth),c=Vs(r.scrollHeight,r.clientHeight,n.scrollHeight,n.clientHeight);let d=-s.scrollLeft+ph(e);const l=-s.scrollTop;return Tn(n).direction==="rtl"&&(d+=Vs(r.clientWidth,n.clientWidth)-o),{width:o,height:c,x:d,y:l}}const ww=25;function xO(e,r){const s=Ks(e),n=ei(e),o=s.visualViewport;let c=n.clientWidth,d=n.clientHeight,l=0,u=0;if(o){c=o.width,d=o.height;const m=px();(!m||m&&r==="fixed")&&(l=o.offsetLeft,u=o.offsetTop)}const f=ph(n);if(f<=0){const m=n.ownerDocument,h=m.body,g=getComputedStyle(h),w=m.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,j=Math.abs(n.clientWidth-h.clientWidth-w);j<=ww&&(c-=j)}else f<=ww&&(c+=f);return{width:c,height:d,x:l,y:u}}function vO(e,r){const s=zo(e,!0,r==="fixed"),n=s.top+e.clientTop,o=s.left+e.clientLeft,c=ki(e)?Ka(e):Kn(1),d=e.clientWidth*c.x,l=e.clientHeight*c.y,u=o*c.x,f=n*c.y;return{width:d,height:l,x:u,y:f}}function _w(e,r,s){let n;if(r==="viewport")n=xO(e,s);else if(r==="document")n=gO(ei(e));else if(An(r))n=vO(r,s);else{const o=zC(e);n={x:r.x-o.x,y:r.y-o.y,width:r.width,height:r.height}}return $u(n)}function UC(e,r){const s=ro(e);return s===r||!An(s)||sl(s)?!1:Tn(s).position==="fixed"||UC(s,r)}function yO(e,r){const s=r.get(e);if(s)return s;let n=yc(e,[],!1).filter(l=>An(l)&&cl(l)!=="body"),o=null;const c=Tn(e).position==="fixed";let d=c?ro(e):e;for(;An(d)&&!sl(d);){const l=Tn(d),u=mx(d);!u&&l.position==="fixed"&&(o=null),(c?!u&&!o:!u&&l.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||Bc(d)&&!u&&UC(e,d))?n=n.filter(m=>m!==d):o=l,d=ro(d)}return r.set(e,n),n}function bO(e){let{element:r,boundary:s,rootBoundary:n,strategy:o}=e;const d=[...s==="clippingAncestors"?fh(r)?[]:yO(r,this._c):[].concat(s),n],l=_w(r,d[0],o);let u=l.top,f=l.right,m=l.bottom,h=l.left;for(let g=1;g<d.length;g++){const w=_w(r,d[g],o);u=Vs(w.top,u),f=to(w.right,f),m=to(w.bottom,m),h=Vs(w.left,h)}return{width:f-h,height:m-u,x:h,y:u}}function wO(e){const{width:r,height:s}=HC(e);return{width:r,height:s}}function _O(e,r,s){const n=ki(r),o=ei(r),c=s==="fixed",d=zo(e,!0,c,r);let l={scrollLeft:0,scrollTop:0};const u=Kn(0);function f(){u.x=ph(o)}if(n||!n&&!c)if((cl(r)!=="body"||Bc(o))&&(l=mh(r)),n){const w=zo(r,!0,c,r);u.x=w.x+r.clientLeft,u.y=w.y+r.clientTop}else o&&f();c&&!n&&o&&f();const m=o&&!n&&!c?WC(o,l):Kn(0),h=d.left+l.scrollLeft-u.x-m.x,g=d.top+l.scrollTop-u.y-m.y;return{x:h,y:g,width:d.width,height:d.height}}function Om(e){return Tn(e).position==="static"}function kw(e,r){if(!ki(e)||Tn(e).position==="fixed")return null;if(r)return r(e);let s=e.offsetParent;return ei(e)===s&&(s=s.ownerDocument.body),s}function VC(e,r){const s=Ks(e);if(fh(e))return s;if(!ki(e)){let o=ro(e);for(;o&&!sl(o);){if(An(o)&&!Om(o))return o;o=ro(o)}return s}let n=kw(e,r);for(;n&&lO(n)&&Om(n);)n=kw(n,r);return n&&sl(n)&&Om(n)&&!mx(n)?s:n||uO(e)||s}const kO=async function(e){const r=this.getOffsetParent||VC,s=this.getDimensions,n=await s(e.floating);return{reference:_O(e.reference,await r(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function SO(e){return Tn(e).direction==="rtl"}const CO={convertOffsetParentRelativeRectToViewportRelativeRect:mO,getDocumentElement:ei,getClippingRect:bO,getOffsetParent:VC,getElementRects:kO,getClientRects:pO,getDimensions:wO,getScale:Ka,isElement:An,isRTL:SO};function GC(e,r){return e.x===r.x&&e.y===r.y&&e.width===r.width&&e.height===r.height}function jO(e,r){let s=null,n;const o=ei(e);function c(){var l;clearTimeout(n),(l=s)==null||l.disconnect(),s=null}function d(l,u){l===void 0&&(l=!1),u===void 0&&(u=1),c();const f=e.getBoundingClientRect(),{left:m,top:h,width:g,height:w}=f;if(l||r(),!g||!w)return;const j=au(h),k=au(o.clientWidth-(m+g)),v=au(o.clientHeight-(h+w)),y=au(m),b={rootMargin:-j+"px "+-k+"px "+-v+"px "+-y+"px",threshold:Vs(0,to(1,u))||1};let S=!0;function N(P){const A=P[0].intersectionRatio;if(A!==u){if(!S)return d();A?d(!1,A):n=setTimeout(()=>{d(!1,1e-7)},1e3)}A===1&&!GC(f,e.getBoundingClientRect())&&d(),S=!1}try{s=new IntersectionObserver(N,{...b,root:o.ownerDocument})}catch{s=new IntersectionObserver(N,b)}s.observe(e)}return d(!0),c}function NO(e,r,s,n){n===void 0&&(n={});const{ancestorScroll:o=!0,ancestorResize:c=!0,elementResize:d=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=n,f=gx(e),m=o||c?[...f?yc(f):[],...r?yc(r):[]]:[];m.forEach(y=>{o&&y.addEventListener("scroll",s,{passive:!0}),c&&y.addEventListener("resize",s)});const h=f&&l?jO(f,s):null;let g=-1,w=null;d&&(w=new ResizeObserver(y=>{let[x]=y;x&&x.target===f&&w&&r&&(w.unobserve(r),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var b;(b=w)==null||b.observe(r)})),s()}),f&&!u&&w.observe(f),r&&w.observe(r));let j,k=u?zo(e):null;u&&v();function v(){const y=zo(e);k&&!GC(k,y)&&s(),k=y,j=requestAnimationFrame(v)}return s(),()=>{var y;m.forEach(x=>{o&&x.removeEventListener("scroll",s),c&&x.removeEventListener("resize",s)}),h==null||h(),(y=w)==null||y.disconnect(),w=null,u&&cancelAnimationFrame(j)}}const EO=nO,PO=iO,AO=tO,TO=aO,RO=rO,Sw=eO,MO=oO,IO=(e,r,s)=>{const n=new Map,o={platform:CO,...s},c={...o.platform,_c:n};return ZL(e,r,{...o,platform:c})};var DO=typeof document<"u",LO=function(){},bu=DO?_.useLayoutEffect:LO;function Hu(e,r){if(e===r)return!0;if(typeof e!=typeof r)return!1;if(typeof e=="function"&&e.toString()===r.toString())return!0;let s,n,o;if(e&&r&&typeof e=="object"){if(Array.isArray(e)){if(s=e.length,s!==r.length)return!1;for(n=s;n--!==0;)if(!Hu(e[n],r[n]))return!1;return!0}if(o=Object.keys(e),s=o.length,s!==Object.keys(r).length)return!1;for(n=s;n--!==0;)if(!{}.hasOwnProperty.call(r,o[n]))return!1;for(n=s;n--!==0;){const c=o[n];if(!(c==="_owner"&&e.$$typeof)&&!Hu(e[c],r[c]))return!1}return!0}return e!==e&&r!==r}function qC(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Cw(e,r){const s=qC(e);return Math.round(r*s)/s}function Fm(e){const r=_.useRef(e);return bu(()=>{r.current=e}),r}function OO(e){e===void 0&&(e={});const{placement:r="bottom",strategy:s="absolute",middleware:n=[],platform:o,elements:{reference:c,floating:d}={},transform:l=!0,whileElementsMounted:u,open:f}=e,[m,h]=_.useState({x:0,y:0,strategy:s,placement:r,middlewareData:{},isPositioned:!1}),[g,w]=_.useState(n);Hu(g,n)||w(n);const[j,k]=_.useState(null),[v,y]=_.useState(null),x=_.useCallback(K=>{K!==P.current&&(P.current=K,k(K))},[]),b=_.useCallback(K=>{K!==A.current&&(A.current=K,y(K))},[]),S=c||j,N=d||v,P=_.useRef(null),A=_.useRef(null),E=_.useRef(m),M=u!=null,I=Fm(u),B=Fm(o),U=Fm(f),V=_.useCallback(()=>{if(!P.current||!A.current)return;const K={placement:r,strategy:s,middleware:g};B.current&&(K.platform=B.current),IO(P.current,A.current,K).then(O=>{const T={...O,isPositioned:U.current!==!1};Q.current&&!Hu(E.current,T)&&(E.current=T,Ec.flushSync(()=>{h(T)}))})},[g,r,s,B,U]);bu(()=>{f===!1&&E.current.isPositioned&&(E.current.isPositioned=!1,h(K=>({...K,isPositioned:!1})))},[f]);const Q=_.useRef(!1);bu(()=>(Q.current=!0,()=>{Q.current=!1}),[]),bu(()=>{if(S&&(P.current=S),N&&(A.current=N),S&&N){if(I.current)return I.current(S,N,V);V()}},[S,N,V,I,M]);const z=_.useMemo(()=>({reference:P,floating:A,setReference:x,setFloating:b}),[x,b]),H=_.useMemo(()=>({reference:S,floating:N}),[S,N]),Y=_.useMemo(()=>{const K={position:s,left:0,top:0};if(!H.floating)return K;const O=Cw(H.floating,m.x),T=Cw(H.floating,m.y);return l?{...K,transform:"translate("+O+"px, "+T+"px)",...qC(H.floating)>=1.5&&{willChange:"transform"}}:{position:s,left:O,top:T}},[s,l,H.floating,m.x,m.y]);return _.useMemo(()=>({...m,update:V,refs:z,elements:H,floatingStyles:Y}),[m,V,z,H,Y])}const FO=e=>{function r(s){return{}.hasOwnProperty.call(s,"current")}return{name:"arrow",options:e,fn(s){const{element:n,padding:o}=typeof e=="function"?e(s):e;return n&&r(n)?n.current!=null?Sw({element:n.current,padding:o}).fn(s):{}:n?Sw({element:n,padding:o}).fn(s):{}}}},BO=(e,r)=>{const s=EO(e);return{name:s.name,fn:s.fn,options:[e,r]}},$O=(e,r)=>{const s=PO(e);return{name:s.name,fn:s.fn,options:[e,r]}},HO=(e,r)=>({fn:MO(e).fn,options:[e,r]}),zO=(e,r)=>{const s=AO(e);return{name:s.name,fn:s.fn,options:[e,r]}},WO=(e,r)=>{const s=TO(e);return{name:s.name,fn:s.fn,options:[e,r]}},UO=(e,r)=>{const s=RO(e);return{name:s.name,fn:s.fn,options:[e,r]}},VO=(e,r)=>{const s=FO(e);return{name:s.name,fn:s.fn,options:[e,r]}};var GO="Arrow",KC=_.forwardRef((e,r)=>{const{children:s,width:n=10,height:o=5,...c}=e;return t.jsx(ot.svg,{...c,ref:r,width:n,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?s:t.jsx("polygon",{points:"0,0 30,0 15,10"})})});KC.displayName=GO;var qO=KC,xx="Popper",[YC,dl]=Ls(xx),[KO,XC]=YC(xx),JC=e=>{const{__scopePopper:r,children:s}=e,[n,o]=_.useState(null);return t.jsx(KO,{scope:r,anchor:n,onAnchorChange:o,children:s})};JC.displayName=xx;var QC="PopperAnchor",ZC=_.forwardRef((e,r)=>{const{__scopePopper:s,virtualRef:n,...o}=e,c=XC(QC,s),d=_.useRef(null),l=bt(r,d),u=_.useRef(null);return _.useEffect(()=>{const f=u.current;u.current=(n==null?void 0:n.current)||d.current,f!==u.current&&c.onAnchorChange(u.current)}),n?null:t.jsx(ot.div,{...o,ref:l})});ZC.displayName=QC;var vx="PopperContent",[YO,XO]=YC(vx),e1=_.forwardRef((e,r)=>{var J,W,le,ae,re,de;const{__scopePopper:s,side:n="bottom",sideOffset:o=0,align:c="center",alignOffset:d=0,arrowPadding:l=0,avoidCollisions:u=!0,collisionBoundary:f=[],collisionPadding:m=0,sticky:h="partial",hideWhenDetached:g=!1,updatePositionStrategy:w="optimized",onPlaced:j,...k}=e,v=XC(vx,s),[y,x]=_.useState(null),b=bt(r,Se=>x(Se)),[S,N]=_.useState(null),P=ax(S),A=(P==null?void 0:P.width)??0,E=(P==null?void 0:P.height)??0,M=n+(c!=="center"?"-"+c:""),I=typeof m=="number"?m:{top:0,right:0,bottom:0,left:0,...m},B=Array.isArray(f)?f:[f],U=B.length>0,V={padding:I,boundary:B.filter(QO),altBoundary:U},{refs:Q,floatingStyles:z,placement:H,isPositioned:Y,middlewareData:K}=OO({strategy:"fixed",placement:M,whileElementsMounted:(...Se)=>NO(...Se,{animationFrame:w==="always"}),elements:{reference:v.anchor},middleware:[BO({mainAxis:o+E,alignmentAxis:d}),u&&$O({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?HO():void 0,...V}),u&&zO({...V}),WO({...V,apply:({elements:Se,rects:Re,availableWidth:Ue,availableHeight:pe})=>{const{width:_e,height:$e}=Re.reference,Ge=Se.floating.style;Ge.setProperty("--radix-popper-available-width",`${Ue}px`),Ge.setProperty("--radix-popper-available-height",`${pe}px`),Ge.setProperty("--radix-popper-anchor-width",`${_e}px`),Ge.setProperty("--radix-popper-anchor-height",`${$e}px`)}}),S&&VO({element:S,padding:l}),ZO({arrowWidth:A,arrowHeight:E}),g&&UO({strategy:"referenceHidden",...V})]}),[O,T]=s1(H),F=Jr(j);Ur(()=>{Y&&(F==null||F())},[Y,F]);const $=(J=K.arrow)==null?void 0:J.x,D=(W=K.arrow)==null?void 0:W.y,X=((le=K.arrow)==null?void 0:le.centerOffset)!==0,[te,fe]=_.useState();return Ur(()=>{y&&fe(window.getComputedStyle(y).zIndex)},[y]),t.jsx("div",{ref:Q.setFloating,"data-radix-popper-content-wrapper":"",style:{...z,transform:Y?z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:te,"--radix-popper-transform-origin":[(ae=K.transformOrigin)==null?void 0:ae.x,(re=K.transformOrigin)==null?void 0:re.y].join(" "),...((de=K.hide)==null?void 0:de.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:t.jsx(YO,{scope:s,placedSide:O,onArrowChange:N,arrowX:$,arrowY:D,shouldHideArrow:X,children:t.jsx(ot.div,{"data-side":O,"data-align":T,...k,ref:b,style:{...k.style,animation:Y?void 0:"none"}})})})});e1.displayName=vx;var t1="PopperArrow",JO={top:"bottom",right:"left",bottom:"top",left:"right"},r1=_.forwardRef(function(r,s){const{__scopePopper:n,...o}=r,c=XO(t1,n),d=JO[c.placedSide];return t.jsx("span",{ref:c.onArrowChange,style:{position:"absolute",left:c.arrowX,top:c.arrowY,[d]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[c.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[c.placedSide],visibility:c.shouldHideArrow?"hidden":void 0},children:t.jsx(qO,{...o,ref:s,style:{...o.style,display:"block"}})})});r1.displayName=t1;function QO(e){return e!==null}var ZO=e=>({name:"transformOrigin",options:e,fn(r){var v,y,x;const{placement:s,rects:n,middlewareData:o}=r,d=((v=o.arrow)==null?void 0:v.centerOffset)!==0,l=d?0:e.arrowWidth,u=d?0:e.arrowHeight,[f,m]=s1(s),h={start:"0%",center:"50%",end:"100%"}[m],g=(((y=o.arrow)==null?void 0:y.x)??0)+l/2,w=(((x=o.arrow)==null?void 0:x.y)??0)+u/2;let j="",k="";return f==="bottom"?(j=d?h:`${g}px`,k=`${-u}px`):f==="top"?(j=d?h:`${g}px`,k=`${n.floating.height+u}px`):f==="right"?(j=`${-u}px`,k=d?h:`${w}px`):f==="left"&&(j=`${n.floating.width+u}px`,k=d?h:`${w}px`),{data:{x:j,y:k}}}});function s1(e){const[r,s="center"]=e.split("-");return[r,s]}var yx=JC,bx=ZC,wx=e1,_x=r1;function e6(e){const r=t6(e),s=_.forwardRef((n,o)=>{const{children:c,...d}=n,l=_.Children.toArray(c),u=l.find(s6);if(u){const f=u.props.children,m=l.map(h=>h===u?_.Children.count(f)>1?_.Children.only(null):_.isValidElement(f)?f.props.children:null:h);return t.jsx(r,{...d,ref:o,children:_.isValidElement(f)?_.cloneElement(f,void 0,m):null})}return t.jsx(r,{...d,ref:o,children:c})});return s.displayName=`${e}.Slot`,s}function t6(e){const r=_.forwardRef((s,n)=>{const{children:o,...c}=s;if(_.isValidElement(o)){const d=i6(o),l=n6(c,o.props);return o.type!==_.Fragment&&(l.ref=n?_i(n,d):d),_.cloneElement(o,l)}return _.Children.count(o)>1?_.Children.only(null):null});return r.displayName=`${e}.SlotClone`,r}var r6=Symbol("radix.slottable");function s6(e){return _.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===r6}function n6(e,r){const s={...r};for(const n in r){const o=e[n],c=r[n];/^on[A-Z]/.test(n)?o&&c?s[n]=(...l)=>{const u=c(...l);return o(...l),u}:o&&(s[n]=o):n==="style"?s[n]={...o,...c}:n==="className"&&(s[n]=[o,c].filter(Boolean).join(" "))}return{...e,...s}}function i6(e){var n,o;let r=(n=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:n.get,s=r&&"isReactWarning"in r&&r.isReactWarning;return s?e.ref:(r=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,s=r&&"isReactWarning"in r&&r.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}var n1=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),o6="VisuallyHidden",i1=_.forwardRef((e,r)=>t.jsx(ot.span,{...e,ref:r,style:{...n1,...e.style}}));i1.displayName=o6;var a6=i1,l6=[" ","Enter","ArrowUp","ArrowDown"],c6=[" ","Enter"],Wo="Select",[gh,xh,d6]=dx(Wo),[ul]=Ls(Wo,[d6,dl]),vh=dl(),[u6,io]=ul(Wo),[h6,f6]=ul(Wo),o1=e=>{const{__scopeSelect:r,children:s,open:n,defaultOpen:o,onOpenChange:c,value:d,defaultValue:l,onValueChange:u,dir:f,name:m,autoComplete:h,disabled:g,required:w,form:j}=e,k=vh(r),[v,y]=_.useState(null),[x,b]=_.useState(null),[S,N]=_.useState(!1),P=Dc(f),[A,E]=Xn({prop:n,defaultProp:o??!1,onChange:c,caller:Wo}),[M,I]=Xn({prop:d,defaultProp:l,onChange:u,caller:Wo}),B=_.useRef(null),U=v?j||!!v.closest("form"):!0,[V,Q]=_.useState(new Set),z=Array.from(V).map(H=>H.props.value).join(";");return t.jsx(yx,{...k,children:t.jsxs(u6,{required:w,scope:r,trigger:v,onTriggerChange:y,valueNode:x,onValueNodeChange:b,valueNodeHasChildren:S,onValueNodeHasChildrenChange:N,contentId:dn(),value:M,onValueChange:I,open:A,onOpenChange:E,dir:P,triggerPointerDownPosRef:B,disabled:g,children:[t.jsx(gh.Provider,{scope:r,children:t.jsx(h6,{scope:e.__scopeSelect,onNativeOptionAdd:_.useCallback(H=>{Q(Y=>new Set(Y).add(H))},[]),onNativeOptionRemove:_.useCallback(H=>{Q(Y=>{const K=new Set(Y);return K.delete(H),K})},[]),children:s})}),U?t.jsxs(A1,{"aria-hidden":!0,required:w,tabIndex:-1,name:m,autoComplete:h,value:M,onChange:H=>I(H.target.value),disabled:g,form:j,children:[M===void 0?t.jsx("option",{value:""}):null,Array.from(V)]},z):null]})})};o1.displayName=Wo;var a1="SelectTrigger",l1=_.forwardRef((e,r)=>{const{__scopeSelect:s,disabled:n=!1,...o}=e,c=vh(s),d=io(a1,s),l=d.disabled||n,u=bt(r,d.onTriggerChange),f=xh(s),m=_.useRef("touch"),[h,g,w]=R1(k=>{const v=f().filter(b=>!b.disabled),y=v.find(b=>b.value===d.value),x=M1(v,k,y);x!==void 0&&d.onValueChange(x.value)}),j=k=>{l||(d.onOpenChange(!0),w()),k&&(d.triggerPointerDownPosRef.current={x:Math.round(k.pageX),y:Math.round(k.pageY)})};return t.jsx(bx,{asChild:!0,...c,children:t.jsx(ot.button,{type:"button",role:"combobox","aria-controls":d.contentId,"aria-expanded":d.open,"aria-required":d.required,"aria-autocomplete":"none",dir:d.dir,"data-state":d.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":T1(d.value)?"":void 0,...o,ref:u,onClick:Be(o.onClick,k=>{k.currentTarget.focus(),m.current!=="mouse"&&j(k)}),onPointerDown:Be(o.onPointerDown,k=>{m.current=k.pointerType;const v=k.target;v.hasPointerCapture(k.pointerId)&&v.releasePointerCapture(k.pointerId),k.button===0&&k.ctrlKey===!1&&k.pointerType==="mouse"&&(j(k),k.preventDefault())}),onKeyDown:Be(o.onKeyDown,k=>{const v=h.current!=="";!(k.ctrlKey||k.altKey||k.metaKey)&&k.key.length===1&&g(k.key),!(v&&k.key===" ")&&l6.includes(k.key)&&(j(),k.preventDefault())})})})});l1.displayName=a1;var c1="SelectValue",d1=_.forwardRef((e,r)=>{const{__scopeSelect:s,className:n,style:o,children:c,placeholder:d="",...l}=e,u=io(c1,s),{onValueNodeHasChildrenChange:f}=u,m=c!==void 0,h=bt(r,u.onValueNodeChange);return Ur(()=>{f(m)},[f,m]),t.jsx(ot.span,{...l,ref:h,style:{pointerEvents:"none"},children:T1(u.value)?t.jsx(t.Fragment,{children:d}):c})});d1.displayName=c1;var m6="SelectIcon",u1=_.forwardRef((e,r)=>{const{__scopeSelect:s,children:n,...o}=e;return t.jsx(ot.span,{"aria-hidden":!0,...o,ref:r,children:n||"▼"})});u1.displayName=m6;var p6="SelectPortal",h1=e=>t.jsx(Oc,{asChild:!0,...e});h1.displayName=p6;var Uo="SelectContent",f1=_.forwardRef((e,r)=>{const s=io(Uo,e.__scopeSelect),[n,o]=_.useState();if(Ur(()=>{o(new DocumentFragment)},[]),!s.open){const c=n;return c?Ec.createPortal(t.jsx(m1,{scope:e.__scopeSelect,children:t.jsx(gh.Slot,{scope:e.__scopeSelect,children:t.jsx("div",{children:e.children})})}),c):null}return t.jsx(p1,{...e,ref:r})});f1.displayName=Uo;var jn=10,[m1,oo]=ul(Uo),g6="SelectContentImpl",x6=e6("SelectContent.RemoveScroll"),p1=_.forwardRef((e,r)=>{const{__scopeSelect:s,position:n="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:c,onPointerDownOutside:d,side:l,sideOffset:u,align:f,alignOffset:m,arrowPadding:h,collisionBoundary:g,collisionPadding:w,sticky:j,hideWhenDetached:k,avoidCollisions:v,...y}=e,x=io(Uo,s),[b,S]=_.useState(null),[N,P]=_.useState(null),A=bt(r,J=>S(J)),[E,M]=_.useState(null),[I,B]=_.useState(null),U=xh(s),[V,Q]=_.useState(!1),z=_.useRef(!1);_.useEffect(()=>{if(b)return Jg(b)},[b]),Xg();const H=_.useCallback(J=>{const[W,...le]=U().map(de=>de.ref.current),[ae]=le.slice(-1),re=document.activeElement;for(const de of J)if(de===re||(de==null||de.scrollIntoView({block:"nearest"}),de===W&&N&&(N.scrollTop=0),de===ae&&N&&(N.scrollTop=N.scrollHeight),de==null||de.focus(),document.activeElement!==re))return},[U,N]),Y=_.useCallback(()=>H([E,b]),[H,E,b]);_.useEffect(()=>{V&&Y()},[V,Y]);const{onOpenChange:K,triggerPointerDownPosRef:O}=x;_.useEffect(()=>{if(b){let J={x:0,y:0};const W=ae=>{var re,de;J={x:Math.abs(Math.round(ae.pageX)-(((re=O.current)==null?void 0:re.x)??0)),y:Math.abs(Math.round(ae.pageY)-(((de=O.current)==null?void 0:de.y)??0))}},le=ae=>{J.x<=10&&J.y<=10?ae.preventDefault():b.contains(ae.target)||K(!1),document.removeEventListener("pointermove",W),O.current=null};return O.current!==null&&(document.addEventListener("pointermove",W),document.addEventListener("pointerup",le,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",W),document.removeEventListener("pointerup",le,{capture:!0})}}},[b,K,O]),_.useEffect(()=>{const J=()=>K(!1);return window.addEventListener("blur",J),window.addEventListener("resize",J),()=>{window.removeEventListener("blur",J),window.removeEventListener("resize",J)}},[K]);const[T,F]=R1(J=>{const W=U().filter(re=>!re.disabled),le=W.find(re=>re.ref.current===document.activeElement),ae=M1(W,J,le);ae&&setTimeout(()=>ae.ref.current.focus())}),$=_.useCallback((J,W,le)=>{const ae=!z.current&&!le;(x.value!==void 0&&x.value===W||ae)&&(M(J),ae&&(z.current=!0))},[x.value]),D=_.useCallback(()=>b==null?void 0:b.focus(),[b]),X=_.useCallback((J,W,le)=>{const ae=!z.current&&!le;(x.value!==void 0&&x.value===W||ae)&&B(J)},[x.value]),te=n==="popper"?Mp:g1,fe=te===Mp?{side:l,sideOffset:u,align:f,alignOffset:m,arrowPadding:h,collisionBoundary:g,collisionPadding:w,sticky:j,hideWhenDetached:k,avoidCollisions:v}:{};return t.jsx(m1,{scope:s,content:b,viewport:N,onViewportChange:P,itemRefCallback:$,selectedItem:E,onItemLeave:D,itemTextRefCallback:X,focusSelectedItem:Y,selectedItemText:I,position:n,isPositioned:V,searchRef:T,children:t.jsx(ch,{as:x6,allowPinchZoom:!0,children:t.jsx(ah,{asChild:!0,trapped:x.open,onMountAutoFocus:J=>{J.preventDefault()},onUnmountAutoFocus:Be(o,J=>{var W;(W=x.trigger)==null||W.focus({preventScroll:!0}),J.preventDefault()}),children:t.jsx(Lc,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:J=>J.preventDefault(),onDismiss:()=>x.onOpenChange(!1),children:t.jsx(te,{role:"listbox",id:x.contentId,"data-state":x.open?"open":"closed",dir:x.dir,onContextMenu:J=>J.preventDefault(),...y,...fe,onPlaced:()=>Q(!0),ref:A,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:Be(y.onKeyDown,J=>{const W=J.ctrlKey||J.altKey||J.metaKey;if(J.key==="Tab"&&J.preventDefault(),!W&&J.key.length===1&&F(J.key),["ArrowUp","ArrowDown","Home","End"].includes(J.key)){let ae=U().filter(re=>!re.disabled).map(re=>re.ref.current);if(["ArrowUp","End"].includes(J.key)&&(ae=ae.slice().reverse()),["ArrowUp","ArrowDown"].includes(J.key)){const re=J.target,de=ae.indexOf(re);ae=ae.slice(de+1)}setTimeout(()=>H(ae)),J.preventDefault()}})})})})})})});p1.displayName=g6;var v6="SelectItemAlignedPosition",g1=_.forwardRef((e,r)=>{const{__scopeSelect:s,onPlaced:n,...o}=e,c=io(Uo,s),d=oo(Uo,s),[l,u]=_.useState(null),[f,m]=_.useState(null),h=bt(r,A=>m(A)),g=xh(s),w=_.useRef(!1),j=_.useRef(!0),{viewport:k,selectedItem:v,selectedItemText:y,focusSelectedItem:x}=d,b=_.useCallback(()=>{if(c.trigger&&c.valueNode&&l&&f&&k&&v&&y){const A=c.trigger.getBoundingClientRect(),E=f.getBoundingClientRect(),M=c.valueNode.getBoundingClientRect(),I=y.getBoundingClientRect();if(c.dir!=="rtl"){const re=I.left-E.left,de=M.left-re,Se=A.left-de,Re=A.width+Se,Ue=Math.max(Re,E.width),pe=window.innerWidth-jn,_e=Np(de,[jn,Math.max(jn,pe-Ue)]);l.style.minWidth=Re+"px",l.style.left=_e+"px"}else{const re=E.right-I.right,de=window.innerWidth-M.right-re,Se=window.innerWidth-A.right-de,Re=A.width+Se,Ue=Math.max(Re,E.width),pe=window.innerWidth-jn,_e=Np(de,[jn,Math.max(jn,pe-Ue)]);l.style.minWidth=Re+"px",l.style.right=_e+"px"}const B=g(),U=window.innerHeight-jn*2,V=k.scrollHeight,Q=window.getComputedStyle(f),z=parseInt(Q.borderTopWidth,10),H=parseInt(Q.paddingTop,10),Y=parseInt(Q.borderBottomWidth,10),K=parseInt(Q.paddingBottom,10),O=z+H+V+K+Y,T=Math.min(v.offsetHeight*5,O),F=window.getComputedStyle(k),$=parseInt(F.paddingTop,10),D=parseInt(F.paddingBottom,10),X=A.top+A.height/2-jn,te=U-X,fe=v.offsetHeight/2,J=v.offsetTop+fe,W=z+H+J,le=O-W;if(W<=X){const re=B.length>0&&v===B[B.length-1].ref.current;l.style.bottom="0px";const de=f.clientHeight-k.offsetTop-k.offsetHeight,Se=Math.max(te,fe+(re?D:0)+de+Y),Re=W+Se;l.style.height=Re+"px"}else{const re=B.length>0&&v===B[0].ref.current;l.style.top="0px";const Se=Math.max(X,z+k.offsetTop+(re?$:0)+fe)+le;l.style.height=Se+"px",k.scrollTop=W-X+k.offsetTop}l.style.margin=`${jn}px 0`,l.style.minHeight=T+"px",l.style.maxHeight=U+"px",n==null||n(),requestAnimationFrame(()=>w.current=!0)}},[g,c.trigger,c.valueNode,l,f,k,v,y,c.dir,n]);Ur(()=>b(),[b]);const[S,N]=_.useState();Ur(()=>{f&&N(window.getComputedStyle(f).zIndex)},[f]);const P=_.useCallback(A=>{A&&j.current===!0&&(b(),x==null||x(),j.current=!1)},[b,x]);return t.jsx(b6,{scope:s,contentWrapper:l,shouldExpandOnScrollRef:w,onScrollButtonChange:P,children:t.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:S},children:t.jsx(ot.div,{...o,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});g1.displayName=v6;var y6="SelectPopperPosition",Mp=_.forwardRef((e,r)=>{const{__scopeSelect:s,align:n="start",collisionPadding:o=jn,...c}=e,d=vh(s);return t.jsx(wx,{...d,...c,ref:r,align:n,collisionPadding:o,style:{boxSizing:"border-box",...c.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Mp.displayName=y6;var[b6,kx]=ul(Uo,{}),Ip="SelectViewport",x1=_.forwardRef((e,r)=>{const{__scopeSelect:s,nonce:n,...o}=e,c=oo(Ip,s),d=kx(Ip,s),l=bt(r,c.onViewportChange),u=_.useRef(0);return t.jsxs(t.Fragment,{children:[t.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:n}),t.jsx(gh.Slot,{scope:s,children:t.jsx(ot.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Be(o.onScroll,f=>{const m=f.currentTarget,{contentWrapper:h,shouldExpandOnScrollRef:g}=d;if(g!=null&&g.current&&h){const w=Math.abs(u.current-m.scrollTop);if(w>0){const j=window.innerHeight-jn*2,k=parseFloat(h.style.minHeight),v=parseFloat(h.style.height),y=Math.max(k,v);if(y<j){const x=y+w,b=Math.min(j,x),S=x-b;h.style.height=b+"px",h.style.bottom==="0px"&&(m.scrollTop=S>0?S:0,h.style.justifyContent="flex-end")}}}u.current=m.scrollTop})})})]})});x1.displayName=Ip;var v1="SelectGroup",[w6,_6]=ul(v1),k6=_.forwardRef((e,r)=>{const{__scopeSelect:s,...n}=e,o=dn();return t.jsx(w6,{scope:s,id:o,children:t.jsx(ot.div,{role:"group","aria-labelledby":o,...n,ref:r})})});k6.displayName=v1;var y1="SelectLabel",b1=_.forwardRef((e,r)=>{const{__scopeSelect:s,...n}=e,o=_6(y1,s);return t.jsx(ot.div,{id:o.id,...n,ref:r})});b1.displayName=y1;var zu="SelectItem",[S6,w1]=ul(zu),_1=_.forwardRef((e,r)=>{const{__scopeSelect:s,value:n,disabled:o=!1,textValue:c,...d}=e,l=io(zu,s),u=oo(zu,s),f=l.value===n,[m,h]=_.useState(c??""),[g,w]=_.useState(!1),j=bt(r,x=>{var b;return(b=u.itemRefCallback)==null?void 0:b.call(u,x,n,o)}),k=dn(),v=_.useRef("touch"),y=()=>{o||(l.onValueChange(n),l.onOpenChange(!1))};if(n==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return t.jsx(S6,{scope:s,value:n,disabled:o,textId:k,isSelected:f,onItemTextChange:_.useCallback(x=>{h(b=>b||((x==null?void 0:x.textContent)??"").trim())},[]),children:t.jsx(gh.ItemSlot,{scope:s,value:n,disabled:o,textValue:m,children:t.jsx(ot.div,{role:"option","aria-labelledby":k,"data-highlighted":g?"":void 0,"aria-selected":f&&g,"data-state":f?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...d,ref:j,onFocus:Be(d.onFocus,()=>w(!0)),onBlur:Be(d.onBlur,()=>w(!1)),onClick:Be(d.onClick,()=>{v.current!=="mouse"&&y()}),onPointerUp:Be(d.onPointerUp,()=>{v.current==="mouse"&&y()}),onPointerDown:Be(d.onPointerDown,x=>{v.current=x.pointerType}),onPointerMove:Be(d.onPointerMove,x=>{var b;v.current=x.pointerType,o?(b=u.onItemLeave)==null||b.call(u):v.current==="mouse"&&x.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Be(d.onPointerLeave,x=>{var b;x.currentTarget===document.activeElement&&((b=u.onItemLeave)==null||b.call(u))}),onKeyDown:Be(d.onKeyDown,x=>{var S;((S=u.searchRef)==null?void 0:S.current)!==""&&x.key===" "||(c6.includes(x.key)&&y(),x.key===" "&&x.preventDefault())})})})})});_1.displayName=zu;var nc="SelectItemText",k1=_.forwardRef((e,r)=>{const{__scopeSelect:s,className:n,style:o,...c}=e,d=io(nc,s),l=oo(nc,s),u=w1(nc,s),f=f6(nc,s),[m,h]=_.useState(null),g=bt(r,y=>h(y),u.onItemTextChange,y=>{var x;return(x=l.itemTextRefCallback)==null?void 0:x.call(l,y,u.value,u.disabled)}),w=m==null?void 0:m.textContent,j=_.useMemo(()=>t.jsx("option",{value:u.value,disabled:u.disabled,children:w},u.value),[u.disabled,u.value,w]),{onNativeOptionAdd:k,onNativeOptionRemove:v}=f;return Ur(()=>(k(j),()=>v(j)),[k,v,j]),t.jsxs(t.Fragment,{children:[t.jsx(ot.span,{id:u.textId,...c,ref:g}),u.isSelected&&d.valueNode&&!d.valueNodeHasChildren?Ec.createPortal(c.children,d.valueNode):null]})});k1.displayName=nc;var S1="SelectItemIndicator",C1=_.forwardRef((e,r)=>{const{__scopeSelect:s,...n}=e;return w1(S1,s).isSelected?t.jsx(ot.span,{"aria-hidden":!0,...n,ref:r}):null});C1.displayName=S1;var Dp="SelectScrollUpButton",j1=_.forwardRef((e,r)=>{const s=oo(Dp,e.__scopeSelect),n=kx(Dp,e.__scopeSelect),[o,c]=_.useState(!1),d=bt(r,n.onScrollButtonChange);return Ur(()=>{if(s.viewport&&s.isPositioned){let l=function(){const f=u.scrollTop>0;c(f)};const u=s.viewport;return l(),u.addEventListener("scroll",l),()=>u.removeEventListener("scroll",l)}},[s.viewport,s.isPositioned]),o?t.jsx(E1,{...e,ref:d,onAutoScroll:()=>{const{viewport:l,selectedItem:u}=s;l&&u&&(l.scrollTop=l.scrollTop-u.offsetHeight)}}):null});j1.displayName=Dp;var Lp="SelectScrollDownButton",N1=_.forwardRef((e,r)=>{const s=oo(Lp,e.__scopeSelect),n=kx(Lp,e.__scopeSelect),[o,c]=_.useState(!1),d=bt(r,n.onScrollButtonChange);return Ur(()=>{if(s.viewport&&s.isPositioned){let l=function(){const f=u.scrollHeight-u.clientHeight,m=Math.ceil(u.scrollTop)<f;c(m)};const u=s.viewport;return l(),u.addEventListener("scroll",l),()=>u.removeEventListener("scroll",l)}},[s.viewport,s.isPositioned]),o?t.jsx(E1,{...e,ref:d,onAutoScroll:()=>{const{viewport:l,selectedItem:u}=s;l&&u&&(l.scrollTop=l.scrollTop+u.offsetHeight)}}):null});N1.displayName=Lp;var E1=_.forwardRef((e,r)=>{const{__scopeSelect:s,onAutoScroll:n,...o}=e,c=oo("SelectScrollButton",s),d=_.useRef(null),l=xh(s),u=_.useCallback(()=>{d.current!==null&&(window.clearInterval(d.current),d.current=null)},[]);return _.useEffect(()=>()=>u(),[u]),Ur(()=>{var m;const f=l().find(h=>h.ref.current===document.activeElement);(m=f==null?void 0:f.ref.current)==null||m.scrollIntoView({block:"nearest"})},[l]),t.jsx(ot.div,{"aria-hidden":!0,...o,ref:r,style:{flexShrink:0,...o.style},onPointerDown:Be(o.onPointerDown,()=>{d.current===null&&(d.current=window.setInterval(n,50))}),onPointerMove:Be(o.onPointerMove,()=>{var f;(f=c.onItemLeave)==null||f.call(c),d.current===null&&(d.current=window.setInterval(n,50))}),onPointerLeave:Be(o.onPointerLeave,()=>{u()})})}),C6="SelectSeparator",P1=_.forwardRef((e,r)=>{const{__scopeSelect:s,...n}=e;return t.jsx(ot.div,{"aria-hidden":!0,...n,ref:r})});P1.displayName=C6;var Op="SelectArrow",j6=_.forwardRef((e,r)=>{const{__scopeSelect:s,...n}=e,o=vh(s),c=io(Op,s),d=oo(Op,s);return c.open&&d.position==="popper"?t.jsx(_x,{...o,...n,ref:r}):null});j6.displayName=Op;var N6="SelectBubbleInput",A1=_.forwardRef(({__scopeSelect:e,value:r,...s},n)=>{const o=_.useRef(null),c=bt(n,o),d=ox(r);return _.useEffect(()=>{const l=o.current;if(!l)return;const u=window.HTMLSelectElement.prototype,m=Object.getOwnPropertyDescriptor(u,"value").set;if(d!==r&&m){const h=new Event("change",{bubbles:!0});m.call(l,r),l.dispatchEvent(h)}},[d,r]),t.jsx(ot.select,{...s,style:{...n1,...s.style},ref:c,defaultValue:r})});A1.displayName=N6;function T1(e){return e===""||e===void 0}function R1(e){const r=Jr(e),s=_.useRef(""),n=_.useRef(0),o=_.useCallback(d=>{const l=s.current+d;r(l),(function u(f){s.current=f,window.clearTimeout(n.current),f!==""&&(n.current=window.setTimeout(()=>u(""),1e3))})(l)},[r]),c=_.useCallback(()=>{s.current="",window.clearTimeout(n.current)},[]);return _.useEffect(()=>()=>window.clearTimeout(n.current),[]),[s,o,c]}function M1(e,r,s){const o=r.length>1&&Array.from(r).every(f=>f===r[0])?r[0]:r,c=s?e.indexOf(s):-1;let d=E6(e,Math.max(c,0));o.length===1&&(d=d.filter(f=>f!==s));const u=d.find(f=>f.textValue.toLowerCase().startsWith(o.toLowerCase()));return u!==s?u:void 0}function E6(e,r){return e.map((s,n)=>e[(r+n)%e.length])}var P6=o1,I1=l1,A6=d1,T6=u1,R6=h1,D1=f1,M6=x1,L1=b1,O1=_1,I6=k1,D6=C1,F1=j1,B1=N1,$1=P1;const ir=P6,or=A6,Qt=_.forwardRef(({className:e,children:r,...s},n)=>t.jsxs(I1,{ref:n,className:Ee("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...s,children:[r,t.jsx(T6,{asChild:!0,children:t.jsx(hr,{className:"h-4 w-4 opacity-50"})})]}));Qt.displayName=I1.displayName;const H1=_.forwardRef(({className:e,...r},s)=>t.jsx(F1,{ref:s,className:Ee("flex cursor-default items-center justify-center py-1",e),...r,children:t.jsx(pS,{className:"h-4 w-4"})}));H1.displayName=F1.displayName;const z1=_.forwardRef(({className:e,...r},s)=>t.jsx(B1,{ref:s,className:Ee("flex cursor-default items-center justify-center py-1",e),...r,children:t.jsx(hr,{className:"h-4 w-4"})}));z1.displayName=B1.displayName;const Zt=_.forwardRef(({className:e,children:r,position:s="popper",...n},o)=>t.jsx(R6,{children:t.jsxs(D1,{ref:o,className:Ee("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:s,...n,children:[t.jsx(H1,{}),t.jsx(M6,{className:Ee("p-1",s==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:r}),t.jsx(z1,{})]})}));Zt.displayName=D1.displayName;const L6=_.forwardRef(({className:e,...r},s)=>t.jsx(L1,{ref:s,className:Ee("px-2 py-1.5 text-sm font-semibold",e),...r}));L6.displayName=L1.displayName;const gt=_.forwardRef(({className:e,children:r,...s},n)=>t.jsxs(O1,{ref:n,className:Ee("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...s,children:[t.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(D6,{children:t.jsx(It,{className:"h-4 w-4"})})}),t.jsx(I6,{children:r})]}));gt.displayName=O1.displayName;const O6=_.forwardRef(({className:e,...r},s)=>t.jsx($1,{ref:s,className:Ee("-mx-1 my-1 h-px bg-muted",e),...r}));O6.displayName=$1.displayName;const Bm={claude:{name:"Claude Code",folder:".claude",color:"text-orange-600",bg:"bg-orange-50",darkBg:"dark:bg-orange-950/30"},gemini:{name:"Gemini CLI",folder:".gemini",color:"text-blue-600",bg:"bg-blue-50",darkBg:"dark:bg-blue-950/30"},antigravity:{name:"Antigravity",folder:".agent",color:"text-purple-600",bg:"bg-purple-50",darkBg:"dark:bg-purple-950/30"}};function F6({open:e,onOpenChange:r,projectDir:s,onSynced:n}){var E,M,I;const[o,c]=_.useState("claude"),[d,l]=_.useState("antigravity"),[u,f]=_.useState(null),[m,h]=_.useState(!1),[g,w]=_.useState(!1),[j,k]=_.useState(new Set);_.useEffect(()=>{e&&s&&v()},[e,o,d,s]),_.useEffect(()=>{e&&k(new Set)},[e]);const v=async()=>{var B;h(!0);try{const U=await he.getSyncPreview(s,o,d);f(U);const V=new Set(((B=U.files)==null?void 0:B.filter(Q=>Q.status==="new"||Q.status==="different").map(Q=>Q.name))||[]);k(V)}catch(U){q.error("Failed to load sync preview: "+U.message),f(null)}finally{h(!1)}},y=()=>{c(d),l(o)},x=B=>{const U=new Set(j);U.has(B)?U.delete(B):U.add(B),k(U)},b=()=>{var B,U;j.size===((B=u==null?void 0:u.files)==null?void 0:B.length)?k(new Set):k(new Set(((U=u==null?void 0:u.files)==null?void 0:U.map(V=>V.name))||[]))},S=async()=>{if(j.size===0){q.error("Please select at least one file to sync");return}w(!0);try{const B=await he.syncRules(s,o,d,Array.from(j));B.success?(q.success(`Synced ${B.synced.length} file(s) to ${Bm[d].name}`),n==null||n(),r(!1)):q.error(B.error||"Sync failed")}catch(B){q.error("Sync failed: "+B.message)}finally{w(!1)}},N=B=>{switch(B){case"new":return t.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-100 text-green-700",children:"New"});case"different":return t.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-yellow-100 text-yellow-700",children:"Modified"});case"identical":return t.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-gray-100 dark:bg-slate-700 text-gray-500 dark:text-slate-400",children:"Same"});default:return null}},P=Bm[o],A=Bm[d];return t.jsx(vt,{open:e,onOpenChange:r,children:t.jsxs(ft,{className:"sm:max-w-lg",children:[t.jsxs(mt,{children:[t.jsxs(pt,{className:"flex items-center gap-2",children:[t.jsx(Dr,{className:"w-5 h-5 text-indigo-500"}),"Sync Rules Between Tools"]}),t.jsx(Gt,{children:"Copy rules from one AI tool's configuration to another."})]}),t.jsxs("div",{className:"space-y-4 py-4",children:[t.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted/50 rounded-lg",children:[t.jsxs("div",{className:"flex-1",children:[t.jsx("label",{className:"text-xs text-muted-foreground mb-1 block",children:"From"}),t.jsxs(ir,{value:o,onValueChange:c,children:[t.jsx(Qt,{className:"w-full",children:t.jsx(or,{})}),t.jsxs(Zt,{children:[t.jsx(gt,{value:"claude",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Vt,{className:"w-3 h-3 text-orange-500"}),"Claude Code"]})}),t.jsx(gt,{value:"gemini",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Vt,{className:"w-3 h-3 text-blue-500"}),"Gemini CLI"]})}),t.jsx(gt,{value:"antigravity",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Vt,{className:"w-3 h-3 text-purple-500"}),"Antigravity"]})})]})]})]}),t.jsx(ne,{variant:"ghost",size:"icon",onClick:y,className:"mt-5",title:"Swap direction",children:t.jsx(Og,{className:"w-4 h-4"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("label",{className:"text-xs text-muted-foreground mb-1 block",children:"To"}),t.jsxs(ir,{value:d,onValueChange:l,children:[t.jsx(Qt,{className:"w-full",children:t.jsx(or,{})}),t.jsxs(Zt,{children:[t.jsx(gt,{value:"claude",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Vt,{className:"w-3 h-3 text-orange-500"}),"Claude Code"]})}),t.jsx(gt,{value:"gemini",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Vt,{className:"w-3 h-3 text-blue-500"}),"Gemini CLI"]})}),t.jsx(gt,{value:"antigravity",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Vt,{className:"w-3 h-3 text-purple-500"}),"Antigravity"]})})]})]})]})]}),t.jsxs("div",{className:"text-xs text-muted-foreground space-y-1",children:[t.jsxs("div",{children:["Source: ",t.jsxs("code",{className:"bg-muted px-1 rounded",children:[P.folder,"/rules/"]})]}),t.jsxs("div",{children:["Target: ",t.jsxs("code",{className:"bg-muted px-1 rounded",children:[A.folder,"/rules/"]})]})]}),t.jsxs("div",{className:"border rounded-lg",children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b bg-muted/30",children:[t.jsx("span",{className:"text-sm font-medium",children:"Rules to Sync"}),((E=u==null?void 0:u.files)==null?void 0:E.length)>0&&t.jsx(ne,{variant:"ghost",size:"sm",onClick:b,className:"h-6 text-xs",children:j.size===u.files.length?"Deselect All":"Select All"})]}),t.jsx("div",{className:"max-h-64 overflow-auto",children:m?t.jsx("div",{className:"flex items-center justify-center py-8",children:t.jsx(Qe,{className:"w-5 h-5 animate-spin text-muted-foreground"})}):u!=null&&u.error?t.jsxs("div",{className:"flex items-center gap-2 p-4 text-sm text-amber-600",children:[t.jsx(Is,{className:"w-4 h-4"}),u.error]}):((M=u==null?void 0:u.files)==null?void 0:M.length)===0?t.jsx("div",{className:"p-4 text-sm text-muted-foreground text-center",children:"No rules found in source folder"}):t.jsx("div",{className:"divide-y",children:(I=u==null?void 0:u.files)==null?void 0:I.map(B=>t.jsxs("label",{className:Ee("flex items-center gap-3 px-3 py-2 cursor-pointer hover:bg-muted/30",j.has(B.name)&&"bg-primary/5"),children:[t.jsx(Fc,{checked:j.has(B.name),onCheckedChange:()=>x(B.name)}),t.jsx(vr,{className:"w-4 h-4 text-purple-500"}),t.jsx("span",{className:"flex-1 text-sm",children:B.name}),N(B.status)]},B.name))})})]}),(u==null?void 0:u.files)&&j.size>0&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:[j.size," file(s) selected for sync"]})]}),t.jsxs(St,{children:[t.jsx(ne,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),t.jsx(ne,{onClick:S,disabled:g||m||j.size===0,children:g?t.jsxs(t.Fragment,{children:[t.jsx(Qe,{className:"w-4 h-4 mr-2 animate-spin"}),"Syncing..."]}):t.jsxs(t.Fragment,{children:[t.jsx(It,{className:"w-4 h-4 mr-2"}),"Sync ",j.size," File(s)"]})})]})]})})}const Oe=_.forwardRef(({className:e,type:r,...s},n)=>t.jsx("input",{type:r,className:Ee("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:n,...s}));Oe.displayName="Input";function Sx({open:e,onOpenChange:r,onSelect:s,type:n="directory",initialPath:o="~",title:c="Select Path"}){const[d,l]=_.useState(""),[u,f]=_.useState([]),[m,h]=_.useState(!1),[g,w]=_.useState(null),[j,k]=_.useState(""),[v,y]=_.useState("");_.useEffect(()=>{e&&x(o)},[e,o]);const x=async A=>{h(!0),w(null);try{const E=await he.browse(A,n);E.error?(w(E.error),E.path&&(l(E.path),y(E.path))):(l(E.path),y(E.path),f(E.items||[]),E.home&&k(E.home))}catch(E){w(E.message)}finally{h(!1)}},b=A=>{A.type==="directory"?x(A.path):n==="file"&&(s(A.path),r(!1))},S=()=>{s(d),r(!1)},N=()=>{v&&x(v)},P=A=>{A.key==="Enter"&&N()};return t.jsx(vt,{open:e,onOpenChange:r,children:t.jsxs(ft,{className:"max-w-lg",children:[t.jsx(mt,{children:t.jsxs(pt,{className:"flex items-center gap-2",children:[n==="directory"?t.jsx(Xr,{className:"w-5 h-5"}):t.jsx(kp,{className:"w-5 h-5"}),c]})}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Oe,{value:v,onChange:A=>y(A.target.value),onKeyDown:P,placeholder:"Enter path...",className:"font-mono text-sm flex-1"}),t.jsx(ne,{variant:"outline",size:"icon",onClick:()=>x(j||"~"),title:"Go to home",children:t.jsx(Hg,{className:"w-4 h-4"})}),t.jsx(ne,{onClick:N,disabled:m,children:"Go"})]}),t.jsx("div",{className:"text-xs text-gray-500 font-mono truncate px-1",children:d}),g&&t.jsx("div",{className:"text-sm text-red-600 bg-red-50 p-2 rounded",children:g}),t.jsx(Js,{className:"h-64 border rounded-lg",children:m?t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsx(Qe,{className:"w-6 h-6 animate-spin text-gray-400"})}):t.jsx("div",{className:"p-1",children:u.length===0?t.jsx("div",{className:"text-sm text-gray-500 p-4 text-center",children:n==="directory"?"No subdirectories":"No files found"}):u.map((A,E)=>t.jsxs("button",{onClick:()=>b(A),className:"w-full flex items-center gap-2 px-3 py-2 text-sm hover:bg-gray-100 dark:hover:bg-slate-800 rounded transition-colors text-left",children:[A.type==="directory"?t.jsx(Xr,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):t.jsx(kp,{className:"w-4 h-4 text-gray-400 flex-shrink-0"}),t.jsx("span",{className:`flex-1 truncate ${A.isParent?"text-gray-500":""}`,children:A.name}),A.type==="directory"&&!A.isParent&&t.jsx(Qr,{className:"w-4 h-4 text-gray-400"})]},E))})})]}),t.jsxs(St,{children:[t.jsx(ne,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),t.jsx(ne,{onClick:S,disabled:!d,children:n==="directory"?"Select Folder":"Select"})]})]})})}var yh="Switch",[B6]=Ls(yh),[$6,H6]=B6(yh),W1=_.forwardRef((e,r)=>{const{__scopeSwitch:s,name:n,checked:o,defaultChecked:c,required:d,disabled:l,value:u="on",onCheckedChange:f,form:m,...h}=e,[g,w]=_.useState(null),j=bt(r,b=>w(b)),k=_.useRef(!1),v=g?m||!!g.closest("form"):!0,[y,x]=Xn({prop:o,defaultProp:c??!1,onChange:f,caller:yh});return t.jsxs($6,{scope:s,checked:y,disabled:l,children:[t.jsx(ot.button,{type:"button",role:"switch","aria-checked":y,"aria-required":d,"data-state":q1(y),"data-disabled":l?"":void 0,disabled:l,value:u,...h,ref:j,onClick:Be(e.onClick,b=>{x(S=>!S),v&&(k.current=b.isPropagationStopped(),k.current||b.stopPropagation())})}),v&&t.jsx(G1,{control:g,bubbles:!k.current,name:n,value:u,checked:y,required:d,disabled:l,form:m,style:{transform:"translateX(-100%)"}})]})});W1.displayName=yh;var U1="SwitchThumb",V1=_.forwardRef((e,r)=>{const{__scopeSwitch:s,...n}=e,o=H6(U1,s);return t.jsx(ot.span,{"data-state":q1(o.checked),"data-disabled":o.disabled?"":void 0,...n,ref:r})});V1.displayName=U1;var z6="SwitchBubbleInput",G1=_.forwardRef(({__scopeSwitch:e,control:r,checked:s,bubbles:n=!0,...o},c)=>{const d=_.useRef(null),l=bt(d,c),u=ox(s),f=ax(r);return _.useEffect(()=>{const m=d.current;if(!m)return;const h=window.HTMLInputElement.prototype,w=Object.getOwnPropertyDescriptor(h,"checked").set;if(u!==s&&w){const j=new Event("click",{bubbles:n});w.call(m,s),m.dispatchEvent(j)}},[u,s,n]),t.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:s,...o,tabIndex:-1,ref:l,style:{...o.style,...f,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});G1.displayName=z6;function q1(e){return e?"checked":"unchecked"}var K1=W1,W6=V1;const xt=_.forwardRef(({className:e,...r},s)=>t.jsx(K1,{className:Ee("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...r,ref:s,children:t.jsx(W6,{className:Ee("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));xt.displayName=K1.displayName;var $m="rovingFocusGroup.onEntryFocus",U6={bubbles:!1,cancelable:!0},$c="RovingFocusGroup",[Fp,Y1,V6]=dx($c),[G6,bh]=Ls($c,[V6]),[q6,K6]=G6($c),X1=_.forwardRef((e,r)=>t.jsx(Fp.Provider,{scope:e.__scopeRovingFocusGroup,children:t.jsx(Fp.Slot,{scope:e.__scopeRovingFocusGroup,children:t.jsx(Y6,{...e,ref:r})})}));X1.displayName=$c;var Y6=_.forwardRef((e,r)=>{const{__scopeRovingFocusGroup:s,orientation:n,loop:o=!1,dir:c,currentTabStopId:d,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:u,onEntryFocus:f,preventScrollOnEntryFocus:m=!1,...h}=e,g=_.useRef(null),w=bt(r,g),j=Dc(c),[k,v]=Xn({prop:d,defaultProp:l??null,onChange:u,caller:$c}),[y,x]=_.useState(!1),b=Jr(f),S=Y1(s),N=_.useRef(!1),[P,A]=_.useState(0);return _.useEffect(()=>{const E=g.current;if(E)return E.addEventListener($m,b),()=>E.removeEventListener($m,b)},[b]),t.jsx(q6,{scope:s,orientation:n,dir:j,loop:o,currentTabStopId:k,onItemFocus:_.useCallback(E=>v(E),[v]),onItemShiftTab:_.useCallback(()=>x(!0),[]),onFocusableItemAdd:_.useCallback(()=>A(E=>E+1),[]),onFocusableItemRemove:_.useCallback(()=>A(E=>E-1),[]),children:t.jsx(ot.div,{tabIndex:y||P===0?-1:0,"data-orientation":n,...h,ref:w,style:{outline:"none",...e.style},onMouseDown:Be(e.onMouseDown,()=>{N.current=!0}),onFocus:Be(e.onFocus,E=>{const M=!N.current;if(E.target===E.currentTarget&&M&&!y){const I=new CustomEvent($m,U6);if(E.currentTarget.dispatchEvent(I),!I.defaultPrevented){const B=S().filter(H=>H.focusable),U=B.find(H=>H.active),V=B.find(H=>H.id===k),z=[U,V,...B].filter(Boolean).map(H=>H.ref.current);Z1(z,m)}}N.current=!1}),onBlur:Be(e.onBlur,()=>x(!1))})})}),J1="RovingFocusGroupItem",Q1=_.forwardRef((e,r)=>{const{__scopeRovingFocusGroup:s,focusable:n=!0,active:o=!1,tabStopId:c,children:d,...l}=e,u=dn(),f=c||u,m=K6(J1,s),h=m.currentTabStopId===f,g=Y1(s),{onFocusableItemAdd:w,onFocusableItemRemove:j,currentTabStopId:k}=m;return _.useEffect(()=>{if(n)return w(),()=>j()},[n,w,j]),t.jsx(Fp.ItemSlot,{scope:s,id:f,focusable:n,active:o,children:t.jsx(ot.span,{tabIndex:h?0:-1,"data-orientation":m.orientation,...l,ref:r,onMouseDown:Be(e.onMouseDown,v=>{n?m.onItemFocus(f):v.preventDefault()}),onFocus:Be(e.onFocus,()=>m.onItemFocus(f)),onKeyDown:Be(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){m.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const y=Q6(v,m.orientation,m.dir);if(y!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let b=g().filter(S=>S.focusable).map(S=>S.ref.current);if(y==="last")b.reverse();else if(y==="prev"||y==="next"){y==="prev"&&b.reverse();const S=b.indexOf(v.currentTarget);b=m.loop?Z6(b,S+1):b.slice(S+1)}setTimeout(()=>Z1(b))}}),children:typeof d=="function"?d({isCurrentTabStop:h,hasTabStop:k!=null}):d})})});Q1.displayName=J1;var X6={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function J6(e,r){return r!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Q6(e,r,s){const n=J6(e.key,s);if(!(r==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(r==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return X6[n]}function Z1(e,r=!1){const s=document.activeElement;for(const n of e)if(n===s||(n.focus({preventScroll:r}),document.activeElement!==s))return}function Z6(e,r){return e.map((s,n)=>e[(r+n)%e.length])}var ej=X1,tj=Q1;function eF(e){const r=tF(e),s=_.forwardRef((n,o)=>{const{children:c,...d}=n,l=_.Children.toArray(c),u=l.find(sF);if(u){const f=u.props.children,m=l.map(h=>h===u?_.Children.count(f)>1?_.Children.only(null):_.isValidElement(f)?f.props.children:null:h);return t.jsx(r,{...d,ref:o,children:_.isValidElement(f)?_.cloneElement(f,void 0,m):null})}return t.jsx(r,{...d,ref:o,children:c})});return s.displayName=`${e}.Slot`,s}function tF(e){const r=_.forwardRef((s,n)=>{const{children:o,...c}=s;if(_.isValidElement(o)){const d=iF(o),l=nF(c,o.props);return o.type!==_.Fragment&&(l.ref=n?_i(n,d):d),_.cloneElement(o,l)}return _.Children.count(o)>1?_.Children.only(null):null});return r.displayName=`${e}.SlotClone`,r}var rF=Symbol("radix.slottable");function sF(e){return _.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===rF}function nF(e,r){const s={...r};for(const n in r){const o=e[n],c=r[n];/^on[A-Z]/.test(n)?o&&c?s[n]=(...l)=>{const u=c(...l);return o(...l),u}:o&&(s[n]=o):n==="style"?s[n]={...o,...c}:n==="className"&&(s[n]=[o,c].filter(Boolean).join(" "))}return{...e,...s}}function iF(e){var n,o;let r=(n=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:n.get,s=r&&"isReactWarning"in r&&r.isReactWarning;return s?e.ref:(r=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,s=r&&"isReactWarning"in r&&r.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}var Bp=["Enter"," "],oF=["ArrowDown","PageUp","Home"],rj=["ArrowUp","PageDown","End"],aF=[...oF,...rj],lF={ltr:[...Bp,"ArrowRight"],rtl:[...Bp,"ArrowLeft"]},cF={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Hc="Menu",[bc,dF,uF]=dx(Hc),[Qo,sj]=Ls(Hc,[uF,dl,bh]),wh=dl(),nj=bh(),[hF,Zo]=Qo(Hc),[fF,zc]=Qo(Hc),ij=e=>{const{__scopeMenu:r,open:s=!1,children:n,dir:o,onOpenChange:c,modal:d=!0}=e,l=wh(r),[u,f]=_.useState(null),m=_.useRef(!1),h=Jr(c),g=Dc(o);return _.useEffect(()=>{const w=()=>{m.current=!0,document.addEventListener("pointerdown",j,{capture:!0,once:!0}),document.addEventListener("pointermove",j,{capture:!0,once:!0})},j=()=>m.current=!1;return document.addEventListener("keydown",w,{capture:!0}),()=>{document.removeEventListener("keydown",w,{capture:!0}),document.removeEventListener("pointerdown",j,{capture:!0}),document.removeEventListener("pointermove",j,{capture:!0})}},[]),t.jsx(yx,{...l,children:t.jsx(hF,{scope:r,open:s,onOpenChange:h,content:u,onContentChange:f,children:t.jsx(fF,{scope:r,onClose:_.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:m,dir:g,modal:d,children:n})})})};ij.displayName=Hc;var mF="MenuAnchor",Cx=_.forwardRef((e,r)=>{const{__scopeMenu:s,...n}=e,o=wh(s);return t.jsx(bx,{...o,...n,ref:r})});Cx.displayName=mF;var jx="MenuPortal",[pF,oj]=Qo(jx,{forceMount:void 0}),aj=e=>{const{__scopeMenu:r,forceMount:s,children:n,container:o}=e,c=Zo(jx,r);return t.jsx(pF,{scope:r,forceMount:s,children:t.jsx(es,{present:s||c.open,children:t.jsx(Oc,{asChild:!0,container:o,children:n})})})};aj.displayName=jx;var un="MenuContent",[gF,Nx]=Qo(un),lj=_.forwardRef((e,r)=>{const s=oj(un,e.__scopeMenu),{forceMount:n=s.forceMount,...o}=e,c=Zo(un,e.__scopeMenu),d=zc(un,e.__scopeMenu);return t.jsx(bc.Provider,{scope:e.__scopeMenu,children:t.jsx(es,{present:n||c.open,children:t.jsx(bc.Slot,{scope:e.__scopeMenu,children:d.modal?t.jsx(xF,{...o,ref:r}):t.jsx(vF,{...o,ref:r})})})})}),xF=_.forwardRef((e,r)=>{const s=Zo(un,e.__scopeMenu),n=_.useRef(null),o=bt(r,n);return _.useEffect(()=>{const c=n.current;if(c)return Jg(c)},[]),t.jsx(Ex,{...e,ref:o,trapFocus:s.open,disableOutsidePointerEvents:s.open,disableOutsideScroll:!0,onFocusOutside:Be(e.onFocusOutside,c=>c.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>s.onOpenChange(!1)})}),vF=_.forwardRef((e,r)=>{const s=Zo(un,e.__scopeMenu);return t.jsx(Ex,{...e,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>s.onOpenChange(!1)})}),yF=eF("MenuContent.ScrollLock"),Ex=_.forwardRef((e,r)=>{const{__scopeMenu:s,loop:n=!1,trapFocus:o,onOpenAutoFocus:c,onCloseAutoFocus:d,disableOutsidePointerEvents:l,onEntryFocus:u,onEscapeKeyDown:f,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:g,onDismiss:w,disableOutsideScroll:j,...k}=e,v=Zo(un,s),y=zc(un,s),x=wh(s),b=nj(s),S=dF(s),[N,P]=_.useState(null),A=_.useRef(null),E=bt(r,A,v.onContentChange),M=_.useRef(0),I=_.useRef(""),B=_.useRef(0),U=_.useRef(null),V=_.useRef("right"),Q=_.useRef(0),z=j?ch:_.Fragment,H=j?{as:yF,allowPinchZoom:!0}:void 0,Y=O=>{var J,W;const T=I.current+O,F=S().filter(le=>!le.disabled),$=document.activeElement,D=(J=F.find(le=>le.ref.current===$))==null?void 0:J.textValue,X=F.map(le=>le.textValue),te=TF(X,T,D),fe=(W=F.find(le=>le.textValue===te))==null?void 0:W.ref.current;(function le(ae){I.current=ae,window.clearTimeout(M.current),ae!==""&&(M.current=window.setTimeout(()=>le(""),1e3))})(T),fe&&setTimeout(()=>fe.focus())};_.useEffect(()=>()=>window.clearTimeout(M.current),[]),Xg();const K=_.useCallback(O=>{var F,$;return V.current===((F=U.current)==null?void 0:F.side)&&MF(O,($=U.current)==null?void 0:$.area)},[]);return t.jsx(gF,{scope:s,searchRef:I,onItemEnter:_.useCallback(O=>{K(O)&&O.preventDefault()},[K]),onItemLeave:_.useCallback(O=>{var T;K(O)||((T=A.current)==null||T.focus(),P(null))},[K]),onTriggerLeave:_.useCallback(O=>{K(O)&&O.preventDefault()},[K]),pointerGraceTimerRef:B,onPointerGraceIntentChange:_.useCallback(O=>{U.current=O},[]),children:t.jsx(z,{...H,children:t.jsx(ah,{asChild:!0,trapped:o,onMountAutoFocus:Be(c,O=>{var T;O.preventDefault(),(T=A.current)==null||T.focus({preventScroll:!0})}),onUnmountAutoFocus:d,children:t.jsx(Lc,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:f,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:g,onDismiss:w,children:t.jsx(ej,{asChild:!0,...b,dir:y.dir,orientation:"vertical",loop:n,currentTabStopId:N,onCurrentTabStopIdChange:P,onEntryFocus:Be(u,O=>{y.isUsingKeyboardRef.current||O.preventDefault()}),preventScrollOnEntryFocus:!0,children:t.jsx(wx,{role:"menu","aria-orientation":"vertical","data-state":Sj(v.open),"data-radix-menu-content":"",dir:y.dir,...x,...k,ref:E,style:{outline:"none",...k.style},onKeyDown:Be(k.onKeyDown,O=>{const F=O.target.closest("[data-radix-menu-content]")===O.currentTarget,$=O.ctrlKey||O.altKey||O.metaKey,D=O.key.length===1;F&&(O.key==="Tab"&&O.preventDefault(),!$&&D&&Y(O.key));const X=A.current;if(O.target!==X||!aF.includes(O.key))return;O.preventDefault();const fe=S().filter(J=>!J.disabled).map(J=>J.ref.current);rj.includes(O.key)&&fe.reverse(),PF(fe)}),onBlur:Be(e.onBlur,O=>{O.currentTarget.contains(O.target)||(window.clearTimeout(M.current),I.current="")}),onPointerMove:Be(e.onPointerMove,wc(O=>{const T=O.target,F=Q.current!==O.clientX;if(O.currentTarget.contains(T)&&F){const $=O.clientX>Q.current?"right":"left";V.current=$,Q.current=O.clientX}}))})})})})})})});lj.displayName=un;var bF="MenuGroup",Px=_.forwardRef((e,r)=>{const{__scopeMenu:s,...n}=e;return t.jsx(ot.div,{role:"group",...n,ref:r})});Px.displayName=bF;var wF="MenuLabel",cj=_.forwardRef((e,r)=>{const{__scopeMenu:s,...n}=e;return t.jsx(ot.div,{...n,ref:r})});cj.displayName=wF;var Wu="MenuItem",jw="menu.itemSelect",_h=_.forwardRef((e,r)=>{const{disabled:s=!1,onSelect:n,...o}=e,c=_.useRef(null),d=zc(Wu,e.__scopeMenu),l=Nx(Wu,e.__scopeMenu),u=bt(r,c),f=_.useRef(!1),m=()=>{const h=c.current;if(!s&&h){const g=new CustomEvent(jw,{bubbles:!0,cancelable:!0});h.addEventListener(jw,w=>n==null?void 0:n(w),{once:!0}),BS(h,g),g.defaultPrevented?f.current=!1:d.onClose()}};return t.jsx(dj,{...o,ref:u,disabled:s,onClick:Be(e.onClick,m),onPointerDown:h=>{var g;(g=e.onPointerDown)==null||g.call(e,h),f.current=!0},onPointerUp:Be(e.onPointerUp,h=>{var g;f.current||(g=h.currentTarget)==null||g.click()}),onKeyDown:Be(e.onKeyDown,h=>{const g=l.searchRef.current!=="";s||g&&h.key===" "||Bp.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});_h.displayName=Wu;var dj=_.forwardRef((e,r)=>{const{__scopeMenu:s,disabled:n=!1,textValue:o,...c}=e,d=Nx(Wu,s),l=nj(s),u=_.useRef(null),f=bt(r,u),[m,h]=_.useState(!1),[g,w]=_.useState("");return _.useEffect(()=>{const j=u.current;j&&w((j.textContent??"").trim())},[c.children]),t.jsx(bc.ItemSlot,{scope:s,disabled:n,textValue:o??g,children:t.jsx(tj,{asChild:!0,...l,focusable:!n,children:t.jsx(ot.div,{role:"menuitem","data-highlighted":m?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...c,ref:f,onPointerMove:Be(e.onPointerMove,wc(j=>{n?d.onItemLeave(j):(d.onItemEnter(j),j.defaultPrevented||j.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Be(e.onPointerLeave,wc(j=>d.onItemLeave(j))),onFocus:Be(e.onFocus,()=>h(!0)),onBlur:Be(e.onBlur,()=>h(!1))})})})}),_F="MenuCheckboxItem",uj=_.forwardRef((e,r)=>{const{checked:s=!1,onCheckedChange:n,...o}=e;return t.jsx(gj,{scope:e.__scopeMenu,checked:s,children:t.jsx(_h,{role:"menuitemcheckbox","aria-checked":Uu(s)?"mixed":s,...o,ref:r,"data-state":Tx(s),onSelect:Be(o.onSelect,()=>n==null?void 0:n(Uu(s)?!0:!s),{checkForDefaultPrevented:!1})})})});uj.displayName=_F;var hj="MenuRadioGroup",[kF,SF]=Qo(hj,{value:void 0,onValueChange:()=>{}}),fj=_.forwardRef((e,r)=>{const{value:s,onValueChange:n,...o}=e,c=Jr(n);return t.jsx(kF,{scope:e.__scopeMenu,value:s,onValueChange:c,children:t.jsx(Px,{...o,ref:r})})});fj.displayName=hj;var mj="MenuRadioItem",pj=_.forwardRef((e,r)=>{const{value:s,...n}=e,o=SF(mj,e.__scopeMenu),c=s===o.value;return t.jsx(gj,{scope:e.__scopeMenu,checked:c,children:t.jsx(_h,{role:"menuitemradio","aria-checked":c,...n,ref:r,"data-state":Tx(c),onSelect:Be(n.onSelect,()=>{var d;return(d=o.onValueChange)==null?void 0:d.call(o,s)},{checkForDefaultPrevented:!1})})})});pj.displayName=mj;var Ax="MenuItemIndicator",[gj,CF]=Qo(Ax,{checked:!1}),xj=_.forwardRef((e,r)=>{const{__scopeMenu:s,forceMount:n,...o}=e,c=CF(Ax,s);return t.jsx(es,{present:n||Uu(c.checked)||c.checked===!0,children:t.jsx(ot.span,{...o,ref:r,"data-state":Tx(c.checked)})})});xj.displayName=Ax;var jF="MenuSeparator",vj=_.forwardRef((e,r)=>{const{__scopeMenu:s,...n}=e;return t.jsx(ot.div,{role:"separator","aria-orientation":"horizontal",...n,ref:r})});vj.displayName=jF;var NF="MenuArrow",yj=_.forwardRef((e,r)=>{const{__scopeMenu:s,...n}=e,o=wh(s);return t.jsx(_x,{...o,...n,ref:r})});yj.displayName=NF;var EF="MenuSub",[yU,bj]=Qo(EF),ic="MenuSubTrigger",wj=_.forwardRef((e,r)=>{const s=Zo(ic,e.__scopeMenu),n=zc(ic,e.__scopeMenu),o=bj(ic,e.__scopeMenu),c=Nx(ic,e.__scopeMenu),d=_.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:u}=c,f={__scopeMenu:e.__scopeMenu},m=_.useCallback(()=>{d.current&&window.clearTimeout(d.current),d.current=null},[]);return _.useEffect(()=>m,[m]),_.useEffect(()=>{const h=l.current;return()=>{window.clearTimeout(h),u(null)}},[l,u]),t.jsx(Cx,{asChild:!0,...f,children:t.jsx(dj,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":o.contentId,"data-state":Sj(s.open),...e,ref:_i(r,o.onTriggerChange),onClick:h=>{var g;(g=e.onClick)==null||g.call(e,h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),s.open||s.onOpenChange(!0))},onPointerMove:Be(e.onPointerMove,wc(h=>{c.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!s.open&&!d.current&&(c.onPointerGraceIntentChange(null),d.current=window.setTimeout(()=>{s.onOpenChange(!0),m()},100))})),onPointerLeave:Be(e.onPointerLeave,wc(h=>{var w,j;m();const g=(w=s.content)==null?void 0:w.getBoundingClientRect();if(g){const k=(j=s.content)==null?void 0:j.dataset.side,v=k==="right",y=v?-5:5,x=g[v?"left":"right"],b=g[v?"right":"left"];c.onPointerGraceIntentChange({area:[{x:h.clientX+y,y:h.clientY},{x,y:g.top},{x:b,y:g.top},{x:b,y:g.bottom},{x,y:g.bottom}],side:k}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>c.onPointerGraceIntentChange(null),300)}else{if(c.onTriggerLeave(h),h.defaultPrevented)return;c.onPointerGraceIntentChange(null)}})),onKeyDown:Be(e.onKeyDown,h=>{var w;const g=c.searchRef.current!=="";e.disabled||g&&h.key===" "||lF[n.dir].includes(h.key)&&(s.onOpenChange(!0),(w=s.content)==null||w.focus(),h.preventDefault())})})})});wj.displayName=ic;var _j="MenuSubContent",kj=_.forwardRef((e,r)=>{const s=oj(un,e.__scopeMenu),{forceMount:n=s.forceMount,...o}=e,c=Zo(un,e.__scopeMenu),d=zc(un,e.__scopeMenu),l=bj(_j,e.__scopeMenu),u=_.useRef(null),f=bt(r,u);return t.jsx(bc.Provider,{scope:e.__scopeMenu,children:t.jsx(es,{present:n||c.open,children:t.jsx(bc.Slot,{scope:e.__scopeMenu,children:t.jsx(Ex,{id:l.contentId,"aria-labelledby":l.triggerId,...o,ref:f,align:"start",side:d.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:m=>{var h;d.isUsingKeyboardRef.current&&((h=u.current)==null||h.focus()),m.preventDefault()},onCloseAutoFocus:m=>m.preventDefault(),onFocusOutside:Be(e.onFocusOutside,m=>{m.target!==l.trigger&&c.onOpenChange(!1)}),onEscapeKeyDown:Be(e.onEscapeKeyDown,m=>{d.onClose(),m.preventDefault()}),onKeyDown:Be(e.onKeyDown,m=>{var w;const h=m.currentTarget.contains(m.target),g=cF[d.dir].includes(m.key);h&&g&&(c.onOpenChange(!1),(w=l.trigger)==null||w.focus(),m.preventDefault())})})})})})});kj.displayName=_j;function Sj(e){return e?"open":"closed"}function Uu(e){return e==="indeterminate"}function Tx(e){return Uu(e)?"indeterminate":e?"checked":"unchecked"}function PF(e){const r=document.activeElement;for(const s of e)if(s===r||(s.focus(),document.activeElement!==r))return}function AF(e,r){return e.map((s,n)=>e[(r+n)%e.length])}function TF(e,r,s){const o=r.length>1&&Array.from(r).every(f=>f===r[0])?r[0]:r,c=s?e.indexOf(s):-1;let d=AF(e,Math.max(c,0));o.length===1&&(d=d.filter(f=>f!==s));const u=d.find(f=>f.toLowerCase().startsWith(o.toLowerCase()));return u!==s?u:void 0}function RF(e,r){const{x:s,y:n}=e;let o=!1;for(let c=0,d=r.length-1;c<r.length;d=c++){const l=r[c],u=r[d],f=l.x,m=l.y,h=u.x,g=u.y;m>n!=g>n&&s<(h-f)*(n-m)/(g-m)+f&&(o=!o)}return o}function MF(e,r){if(!r)return!1;const s={x:e.clientX,y:e.clientY};return RF(s,r)}function wc(e){return r=>r.pointerType==="mouse"?e(r):void 0}var IF=ij,DF=Cx,LF=aj,OF=lj,FF=Px,BF=cj,$F=_h,HF=uj,zF=fj,WF=pj,UF=xj,VF=vj,GF=yj,qF=wj,KF=kj,kh="DropdownMenu",[YF]=Ls(kh,[sj]),_s=sj(),[XF,Cj]=YF(kh),jj=e=>{const{__scopeDropdownMenu:r,children:s,dir:n,open:o,defaultOpen:c,onOpenChange:d,modal:l=!0}=e,u=_s(r),f=_.useRef(null),[m,h]=Xn({prop:o,defaultProp:c??!1,onChange:d,caller:kh});return t.jsx(XF,{scope:r,triggerId:dn(),triggerRef:f,contentId:dn(),open:m,onOpenChange:h,onOpenToggle:_.useCallback(()=>h(g=>!g),[h]),modal:l,children:t.jsx(IF,{...u,open:m,onOpenChange:h,dir:n,modal:l,children:s})})};jj.displayName=kh;var Nj="DropdownMenuTrigger",Ej=_.forwardRef((e,r)=>{const{__scopeDropdownMenu:s,disabled:n=!1,...o}=e,c=Cj(Nj,s),d=_s(s);return t.jsx(DF,{asChild:!0,...d,children:t.jsx(ot.button,{type:"button",id:c.triggerId,"aria-haspopup":"menu","aria-expanded":c.open,"aria-controls":c.open?c.contentId:void 0,"data-state":c.open?"open":"closed","data-disabled":n?"":void 0,disabled:n,...o,ref:_i(r,c.triggerRef),onPointerDown:Be(e.onPointerDown,l=>{!n&&l.button===0&&l.ctrlKey===!1&&(c.onOpenToggle(),c.open||l.preventDefault())}),onKeyDown:Be(e.onKeyDown,l=>{n||(["Enter"," "].includes(l.key)&&c.onOpenToggle(),l.key==="ArrowDown"&&c.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(l.key)&&l.preventDefault())})})})});Ej.displayName=Nj;var JF="DropdownMenuPortal",Pj=e=>{const{__scopeDropdownMenu:r,...s}=e,n=_s(r);return t.jsx(LF,{...n,...s})};Pj.displayName=JF;var Aj="DropdownMenuContent",Tj=_.forwardRef((e,r)=>{const{__scopeDropdownMenu:s,...n}=e,o=Cj(Aj,s),c=_s(s),d=_.useRef(!1);return t.jsx(OF,{id:o.contentId,"aria-labelledby":o.triggerId,...c,...n,ref:r,onCloseAutoFocus:Be(e.onCloseAutoFocus,l=>{var u;d.current||(u=o.triggerRef.current)==null||u.focus(),d.current=!1,l.preventDefault()}),onInteractOutside:Be(e.onInteractOutside,l=>{const u=l.detail.originalEvent,f=u.button===0&&u.ctrlKey===!0,m=u.button===2||f;(!o.modal||m)&&(d.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Tj.displayName=Aj;var QF="DropdownMenuGroup",ZF=_.forwardRef((e,r)=>{const{__scopeDropdownMenu:s,...n}=e,o=_s(s);return t.jsx(FF,{...o,...n,ref:r})});ZF.displayName=QF;var eB="DropdownMenuLabel",Rj=_.forwardRef((e,r)=>{const{__scopeDropdownMenu:s,...n}=e,o=_s(s);return t.jsx(BF,{...o,...n,ref:r})});Rj.displayName=eB;var tB="DropdownMenuItem",Mj=_.forwardRef((e,r)=>{const{__scopeDropdownMenu:s,...n}=e,o=_s(s);return t.jsx($F,{...o,...n,ref:r})});Mj.displayName=tB;var rB="DropdownMenuCheckboxItem",Ij=_.forwardRef((e,r)=>{const{__scopeDropdownMenu:s,...n}=e,o=_s(s);return t.jsx(HF,{...o,...n,ref:r})});Ij.displayName=rB;var sB="DropdownMenuRadioGroup",nB=_.forwardRef((e,r)=>{const{__scopeDropdownMenu:s,...n}=e,o=_s(s);return t.jsx(zF,{...o,...n,ref:r})});nB.displayName=sB;var iB="DropdownMenuRadioItem",Dj=_.forwardRef((e,r)=>{const{__scopeDropdownMenu:s,...n}=e,o=_s(s);return t.jsx(WF,{...o,...n,ref:r})});Dj.displayName=iB;var oB="DropdownMenuItemIndicator",Lj=_.forwardRef((e,r)=>{const{__scopeDropdownMenu:s,...n}=e,o=_s(s);return t.jsx(UF,{...o,...n,ref:r})});Lj.displayName=oB;var aB="DropdownMenuSeparator",Oj=_.forwardRef((e,r)=>{const{__scopeDropdownMenu:s,...n}=e,o=_s(s);return t.jsx(VF,{...o,...n,ref:r})});Oj.displayName=aB;var lB="DropdownMenuArrow",cB=_.forwardRef((e,r)=>{const{__scopeDropdownMenu:s,...n}=e,o=_s(s);return t.jsx(GF,{...o,...n,ref:r})});cB.displayName=lB;var dB="DropdownMenuSubTrigger",Fj=_.forwardRef((e,r)=>{const{__scopeDropdownMenu:s,...n}=e,o=_s(s);return t.jsx(qF,{...o,...n,ref:r})});Fj.displayName=dB;var uB="DropdownMenuSubContent",Bj=_.forwardRef((e,r)=>{const{__scopeDropdownMenu:s,...n}=e,o=_s(s);return t.jsx(KF,{...o,...n,ref:r,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Bj.displayName=uB;var hB=jj,fB=Ej,mB=Pj,$j=Tj,Hj=Rj,zj=Mj,Wj=Ij,Uj=Dj,Vj=Lj,Gj=Oj,qj=Fj,Kj=Bj;const En=hB,Pn=fB,pB=_.forwardRef(({className:e,inset:r,children:s,...n},o)=>t.jsxs(qj,{ref:o,className:Ee("flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",r&&"pl-8",e),...n,children:[s,t.jsx(Qr,{className:"ml-auto"})]}));pB.displayName=qj.displayName;const gB=_.forwardRef(({className:e,...r},s)=>t.jsx(Kj,{ref:s,className:Ee("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...r}));gB.displayName=Kj.displayName;const hn=_.forwardRef(({className:e,sideOffset:r=4,...s},n)=>t.jsx(mB,{children:t.jsx($j,{ref:n,sideOffset:r,className:Ee("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...s})}));hn.displayName=$j.displayName;const jt=_.forwardRef(({className:e,inset:r,...s},n)=>t.jsx(zj,{ref:n,className:Ee("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0",r&&"pl-8",e),...s}));jt.displayName=zj.displayName;const _c=_.forwardRef(({className:e,children:r,checked:s,...n},o)=>t.jsxs(Wj,{ref:o,className:Ee("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:s,...n,children:[t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(Vj,{children:t.jsx(It,{className:"h-4 w-4"})})}),r]}));_c.displayName=Wj.displayName;const xB=_.forwardRef(({className:e,children:r,...s},n)=>t.jsxs(Uj,{ref:n,className:Ee("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...s,children:[t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(Vj,{children:t.jsx(KM,{className:"h-2 w-2 fill-current"})})}),r]}));xB.displayName=Uj.displayName;const kc=_.forwardRef(({className:e,inset:r,...s},n)=>t.jsx(Hj,{ref:n,className:Ee("px-2 py-1.5 text-sm font-semibold",r&&"pl-8",e),...s}));kc.displayName=Hj.displayName;const bs=_.forwardRef(({className:e,...r},s)=>t.jsx(Gj,{ref:s,className:Ee("-mx-1 my-1 h-px bg-muted",e),...r}));bs.displayName=Gj.displayName;const Nw={development:"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",productivity:"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",integration:"bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-400",external:"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400",lsp:"bg-cyan-100 text-cyan-700 dark:bg-cyan-900/30 dark:text-cyan-400",default:"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-400"};function vB({plugin:e,onToggle:r,isToggling:s,projectDir:n}){const o=Nw[e.category]||Nw.default;return e.mcpServers||e.lspServers||e.commands,t.jsxs(Ua.div,{layout:!0,initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:`
592
+ For more information, see https://radix-ui.com/primitives/docs/components/${r.docsSlug}`;return _.useEffect(()=>{e&&(document.getElementById(e)||console.error(s))},[s,e]),null},EL="DialogDescriptionWarning",PL=({contentRef:e,descriptionId:r})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${NC(EL).contentName}}.`;return _.useEffect(()=>{var c;const o=(c=e.current)==null?void 0:c.getAttribute("aria-describedby");r&&o&&(document.getElementById(r)||console.warn(n))},[n,e,r]),null},AL=fC,TL=pC,EC=xC,tx=vC,rx=yC,sx=wC,nx=kC,ix=CC;const vt=AL,RL=EC,PC=_.forwardRef(({className:e,...r},s)=>t.jsx(tx,{ref:s,className:Ee("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...r}));PC.displayName=tx.displayName;const ft=_.forwardRef(({className:e,children:r,...s},n)=>t.jsxs(RL,{children:[t.jsx(PC,{}),t.jsxs(rx,{ref:n,className:Ee("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...s,children:[r,t.jsxs(ix,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[t.jsx(Nn,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));ft.displayName=rx.displayName;const mt=({className:e,...r})=>t.jsx("div",{className:Ee("flex flex-col space-y-1.5 text-center sm:text-left",e),...r});mt.displayName="DialogHeader";const St=({className:e,...r})=>t.jsx("div",{className:Ee("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...r});St.displayName="DialogFooter";const pt=_.forwardRef(({className:e,...r},s)=>t.jsx(sx,{ref:s,className:Ee("text-lg font-semibold leading-none tracking-tight",e),...r}));pt.displayName=sx.displayName;const Gt=_.forwardRef(({className:e,...r},s)=>t.jsx(nx,{ref:s,className:Ee("text-sm text-muted-foreground",e),...r}));Gt.displayName=nx.displayName;function ox(e){const r=_.useRef({value:e,previous:e});return _.useMemo(()=>(r.current.value!==e&&(r.current.previous=r.current.value,r.current.value=e),r.current.previous),[e])}function ax(e){const[r,s]=_.useState(void 0);return Ur(()=>{if(e){s({width:e.offsetWidth,height:e.offsetHeight});const n=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;const c=o[0];let d,l;if("borderBoxSize"in c){const u=c.borderBoxSize,f=Array.isArray(u)?u[0]:u;d=f.inlineSize,l=f.blockSize}else d=e.offsetWidth,l=e.offsetHeight;s({width:d,height:l})});return n.observe(e,{box:"border-box"}),()=>n.unobserve(e)}else s(void 0)},[e]),r}var uh="Checkbox",[ML]=Ls(uh),[IL,lx]=ML(uh);function DL(e){const{__scopeCheckbox:r,checked:s,children:n,defaultChecked:o,disabled:c,form:d,name:l,onCheckedChange:u,required:f,value:m="on",internal_do_not_use_render:h}=e,[g,w]=Xn({prop:s,defaultProp:o??!1,onChange:u,caller:uh}),[j,k]=_.useState(null),[v,y]=_.useState(null),x=_.useRef(!1),b=j?!!d||!!j.closest("form"):!0,S={checked:g,disabled:c,setChecked:w,control:j,setControl:k,name:l,form:d,value:m,hasConsumerStoppedPropagationRef:x,required:f,defaultChecked:Xi(o)?!1:o,isFormControl:b,bubbleInput:v,setBubbleInput:y};return t.jsx(IL,{scope:r,...S,children:LL(h)?h(S):n})}var AC="CheckboxTrigger",TC=_.forwardRef(({__scopeCheckbox:e,onKeyDown:r,onClick:s,...n},o)=>{const{control:c,value:d,disabled:l,checked:u,required:f,setControl:m,setChecked:h,hasConsumerStoppedPropagationRef:g,isFormControl:w,bubbleInput:j}=lx(AC,e),k=bt(o,m),v=_.useRef(u);return _.useEffect(()=>{const y=c==null?void 0:c.form;if(y){const x=()=>h(v.current);return y.addEventListener("reset",x),()=>y.removeEventListener("reset",x)}},[c,h]),t.jsx(ot.button,{type:"button",role:"checkbox","aria-checked":Xi(u)?"mixed":u,"aria-required":f,"data-state":LC(u),"data-disabled":l?"":void 0,disabled:l,value:d,...n,ref:k,onKeyDown:Be(r,y=>{y.key==="Enter"&&y.preventDefault()}),onClick:Be(s,y=>{h(x=>Xi(x)?!0:!x),j&&w&&(g.current=y.isPropagationStopped(),g.current||y.stopPropagation())})})});TC.displayName=AC;var cx=_.forwardRef((e,r)=>{const{__scopeCheckbox:s,name:n,checked:o,defaultChecked:c,required:d,disabled:l,value:u,onCheckedChange:f,form:m,...h}=e;return t.jsx(DL,{__scopeCheckbox:s,checked:o,defaultChecked:c,disabled:l,required:d,onCheckedChange:f,name:n,form:m,value:u,internal_do_not_use_render:({isFormControl:g})=>t.jsxs(t.Fragment,{children:[t.jsx(TC,{...h,ref:r,__scopeCheckbox:s}),g&&t.jsx(DC,{__scopeCheckbox:s})]})})});cx.displayName=uh;var RC="CheckboxIndicator",MC=_.forwardRef((e,r)=>{const{__scopeCheckbox:s,forceMount:n,...o}=e,c=lx(RC,s);return t.jsx(es,{present:n||Xi(c.checked)||c.checked===!0,children:t.jsx(ot.span,{"data-state":LC(c.checked),"data-disabled":c.disabled?"":void 0,...o,ref:r,style:{pointerEvents:"none",...e.style}})})});MC.displayName=RC;var IC="CheckboxBubbleInput",DC=_.forwardRef(({__scopeCheckbox:e,...r},s)=>{const{control:n,hasConsumerStoppedPropagationRef:o,checked:c,defaultChecked:d,required:l,disabled:u,name:f,value:m,form:h,bubbleInput:g,setBubbleInput:w}=lx(IC,e),j=bt(s,w),k=ox(c),v=ax(n);_.useEffect(()=>{const x=g;if(!x)return;const b=window.HTMLInputElement.prototype,N=Object.getOwnPropertyDescriptor(b,"checked").set,P=!o.current;if(k!==c&&N){const A=new Event("click",{bubbles:P});x.indeterminate=Xi(c),N.call(x,Xi(c)?!1:c),x.dispatchEvent(A)}},[g,k,c,o]);const y=_.useRef(Xi(c)?!1:c);return t.jsx(ot.input,{type:"checkbox","aria-hidden":!0,defaultChecked:d??y.current,required:l,disabled:u,name:f,value:m,form:h,...r,tabIndex:-1,ref:j,style:{...r.style,...v,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});DC.displayName=IC;function LL(e){return typeof e=="function"}function Xi(e){return e==="indeterminate"}function LC(e){return Xi(e)?"indeterminate":e?"checked":"unchecked"}const Fc=_.forwardRef(({className:e,...r},s)=>t.jsx(cx,{ref:s,className:Ee("peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...r,children:t.jsx(MC,{className:Ee("flex items-center justify-center text-current"),children:t.jsx(It,{className:"h-4 w-4"})})}));Fc.displayName=cx.displayName;function mw(e){const r=OL(e),s=_.forwardRef((n,o)=>{const{children:c,...d}=n,l=_.Children.toArray(c),u=l.find(BL);if(u){const f=u.props.children,m=l.map(h=>h===u?_.Children.count(f)>1?_.Children.only(null):_.isValidElement(f)?f.props.children:null:h);return t.jsx(r,{...d,ref:o,children:_.isValidElement(f)?_.cloneElement(f,void 0,m):null})}return t.jsx(r,{...d,ref:o,children:c})});return s.displayName=`${e}.Slot`,s}function OL(e){const r=_.forwardRef((s,n)=>{const{children:o,...c}=s;if(_.isValidElement(o)){const d=HL(o),l=$L(c,o.props);return o.type!==_.Fragment&&(l.ref=n?_i(n,d):d),_.cloneElement(o,l)}return _.Children.count(o)>1?_.Children.only(null):null});return r.displayName=`${e}.SlotClone`,r}var FL=Symbol("radix.slottable");function BL(e){return _.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===FL}function $L(e,r){const s={...r};for(const n in r){const o=e[n],c=r[n];/^on[A-Z]/.test(n)?o&&c?s[n]=(...l)=>{const u=c(...l);return o(...l),u}:o&&(s[n]=o):n==="style"?s[n]={...o,...c}:n==="className"&&(s[n]=[o,c].filter(Boolean).join(" "))}return{...e,...s}}function HL(e){var n,o;let r=(n=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:n.get,s=r&&"isReactWarning"in r&&r.isReactWarning;return s?e.ref:(r=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,s=r&&"isReactWarning"in r&&r.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}function dx(e){const r=e+"CollectionProvider",[s,n]=Ls(r),[o,c]=s(r,{collectionRef:{current:null},itemMap:new Map}),d=k=>{const{scope:v,children:y}=k,x=Te.useRef(null),b=Te.useRef(new Map).current;return t.jsx(o,{scope:v,itemMap:b,collectionRef:x,children:y})};d.displayName=r;const l=e+"CollectionSlot",u=mw(l),f=Te.forwardRef((k,v)=>{const{scope:y,children:x}=k,b=c(l,y),S=bt(v,b.collectionRef);return t.jsx(u,{ref:S,children:x})});f.displayName=l;const m=e+"CollectionItemSlot",h="data-radix-collection-item",g=mw(m),w=Te.forwardRef((k,v)=>{const{scope:y,children:x,...b}=k,S=Te.useRef(null),N=bt(v,S),P=c(m,y);return Te.useEffect(()=>(P.itemMap.set(S,{ref:S,...b}),()=>void P.itemMap.delete(S))),t.jsx(g,{[h]:"",ref:N,children:x})});w.displayName=m;function j(k){const v=c(e+"CollectionConsumer",k);return Te.useCallback(()=>{const x=v.collectionRef.current;if(!x)return[];const b=Array.from(x.querySelectorAll(`[${h}]`));return Array.from(v.itemMap.values()).sort((P,A)=>b.indexOf(P.ref.current)-b.indexOf(A.ref.current))},[v.collectionRef,v.itemMap])}return[{Provider:d,Slot:f,ItemSlot:w},j,n]}const zL=["top","right","bottom","left"],to=Math.min,Vs=Math.max,Fu=Math.round,au=Math.floor,Kn=e=>({x:e,y:e}),WL={left:"right",right:"left",bottom:"top",top:"bottom"};function Ap(e,r,s){return Vs(e,to(r,s))}function bi(e,r){return typeof e=="function"?e(r):e}function wi(e){return e.split("-")[0]}function ll(e){return e.split("-")[1]}function ux(e){return e==="x"?"y":"x"}function hx(e){return e==="y"?"height":"width"}function Vn(e){const r=e[0];return r==="t"||r==="b"?"y":"x"}function fx(e){return ux(Vn(e))}function UL(e,r,s){s===void 0&&(s=!1);const n=ll(e),o=fx(e),c=hx(o);let d=o==="x"?n===(s?"end":"start")?"right":"left":n==="start"?"bottom":"top";return r.reference[c]>r.floating[c]&&(d=Bu(d)),[d,Bu(d)]}function VL(e){const r=Bu(e);return[Tp(e),r,Tp(r)]}function Tp(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const pw=["left","right"],gw=["right","left"],GL=["top","bottom"],qL=["bottom","top"];function KL(e,r,s){switch(e){case"top":case"bottom":return s?r?gw:pw:r?pw:gw;case"left":case"right":return r?GL:qL;default:return[]}}function YL(e,r,s,n){const o=ll(e);let c=KL(wi(e),s==="start",n);return o&&(c=c.map(d=>d+"-"+o),r&&(c=c.concat(c.map(Tp)))),c}function Bu(e){const r=wi(e);return WL[r]+e.slice(r.length)}function XL(e){return{top:0,right:0,bottom:0,left:0,...e}}function OC(e){return typeof e!="number"?XL(e):{top:e,right:e,bottom:e,left:e}}function $u(e){const{x:r,y:s,width:n,height:o}=e;return{width:n,height:o,top:s,left:r,right:r+n,bottom:s+o,x:r,y:s}}function xw(e,r,s){let{reference:n,floating:o}=e;const c=Vn(r),d=fx(r),l=hx(d),u=wi(r),f=c==="y",m=n.x+n.width/2-o.width/2,h=n.y+n.height/2-o.height/2,g=n[l]/2-o[l]/2;let w;switch(u){case"top":w={x:m,y:n.y-o.height};break;case"bottom":w={x:m,y:n.y+n.height};break;case"right":w={x:n.x+n.width,y:h};break;case"left":w={x:n.x-o.width,y:h};break;default:w={x:n.x,y:n.y}}switch(ll(r)){case"start":w[d]-=g*(s&&f?-1:1);break;case"end":w[d]+=g*(s&&f?-1:1);break}return w}async function JL(e,r){var s;r===void 0&&(r={});const{x:n,y:o,platform:c,rects:d,elements:l,strategy:u}=e,{boundary:f="clippingAncestors",rootBoundary:m="viewport",elementContext:h="floating",altBoundary:g=!1,padding:w=0}=bi(r,e),j=OC(w),v=l[g?h==="floating"?"reference":"floating":h],y=$u(await c.getClippingRect({element:(s=await(c.isElement==null?void 0:c.isElement(v)))==null||s?v:v.contextElement||await(c.getDocumentElement==null?void 0:c.getDocumentElement(l.floating)),boundary:f,rootBoundary:m,strategy:u})),x=h==="floating"?{x:n,y:o,width:d.floating.width,height:d.floating.height}:d.reference,b=await(c.getOffsetParent==null?void 0:c.getOffsetParent(l.floating)),S=await(c.isElement==null?void 0:c.isElement(b))?await(c.getScale==null?void 0:c.getScale(b))||{x:1,y:1}:{x:1,y:1},N=$u(c.convertOffsetParentRelativeRectToViewportRelativeRect?await c.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:x,offsetParent:b,strategy:u}):x);return{top:(y.top-N.top+j.top)/S.y,bottom:(N.bottom-y.bottom+j.bottom)/S.y,left:(y.left-N.left+j.left)/S.x,right:(N.right-y.right+j.right)/S.x}}const QL=50,ZL=async(e,r,s)=>{const{placement:n="bottom",strategy:o="absolute",middleware:c=[],platform:d}=s,l=d.detectOverflow?d:{...d,detectOverflow:JL},u=await(d.isRTL==null?void 0:d.isRTL(r));let f=await d.getElementRects({reference:e,floating:r,strategy:o}),{x:m,y:h}=xw(f,n,u),g=n,w=0;const j={};for(let k=0;k<c.length;k++){const v=c[k];if(!v)continue;const{name:y,fn:x}=v,{x:b,y:S,data:N,reset:P}=await x({x:m,y:h,initialPlacement:n,placement:g,strategy:o,middlewareData:j,rects:f,platform:l,elements:{reference:e,floating:r}});m=b??m,h=S??h,j[y]={...j[y],...N},P&&w<QL&&(w++,typeof P=="object"&&(P.placement&&(g=P.placement),P.rects&&(f=P.rects===!0?await d.getElementRects({reference:e,floating:r,strategy:o}):P.rects),{x:m,y:h}=xw(f,g,u)),k=-1)}return{x:m,y:h,placement:g,strategy:o,middlewareData:j}},eO=e=>({name:"arrow",options:e,async fn(r){const{x:s,y:n,placement:o,rects:c,platform:d,elements:l,middlewareData:u}=r,{element:f,padding:m=0}=bi(e,r)||{};if(f==null)return{};const h=OC(m),g={x:s,y:n},w=fx(o),j=hx(w),k=await d.getDimensions(f),v=w==="y",y=v?"top":"left",x=v?"bottom":"right",b=v?"clientHeight":"clientWidth",S=c.reference[j]+c.reference[w]-g[w]-c.floating[j],N=g[w]-c.reference[w],P=await(d.getOffsetParent==null?void 0:d.getOffsetParent(f));let A=P?P[b]:0;(!A||!await(d.isElement==null?void 0:d.isElement(P)))&&(A=l.floating[b]||c.floating[j]);const E=S/2-N/2,M=A/2-k[j]/2-1,I=to(h[y],M),B=to(h[x],M),U=I,V=A-k[j]-B,Q=A/2-k[j]/2+E,z=Ap(U,Q,V),H=!u.arrow&&ll(o)!=null&&Q!==z&&c.reference[j]/2-(Q<U?I:B)-k[j]/2<0,Y=H?Q<U?Q-U:Q-V:0;return{[w]:g[w]+Y,data:{[w]:z,centerOffset:Q-z-Y,...H&&{alignmentOffset:Y}},reset:H}}}),tO=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(r){var s,n;const{placement:o,middlewareData:c,rects:d,initialPlacement:l,platform:u,elements:f}=r,{mainAxis:m=!0,crossAxis:h=!0,fallbackPlacements:g,fallbackStrategy:w="bestFit",fallbackAxisSideDirection:j="none",flipAlignment:k=!0,...v}=bi(e,r);if((s=c.arrow)!=null&&s.alignmentOffset)return{};const y=wi(o),x=Vn(l),b=wi(l)===l,S=await(u.isRTL==null?void 0:u.isRTL(f.floating)),N=g||(b||!k?[Bu(l)]:VL(l)),P=j!=="none";!g&&P&&N.push(...YL(l,k,j,S));const A=[l,...N],E=await u.detectOverflow(r,v),M=[];let I=((n=c.flip)==null?void 0:n.overflows)||[];if(m&&M.push(E[y]),h){const Q=UL(o,d,S);M.push(E[Q[0]],E[Q[1]])}if(I=[...I,{placement:o,overflows:M}],!M.every(Q=>Q<=0)){var B,U;const Q=(((B=c.flip)==null?void 0:B.index)||0)+1,z=A[Q];if(z&&(!(h==="alignment"?x!==Vn(z):!1)||I.every(K=>Vn(K.placement)===x?K.overflows[0]>0:!0)))return{data:{index:Q,overflows:I},reset:{placement:z}};let H=(U=I.filter(Y=>Y.overflows[0]<=0).sort((Y,K)=>Y.overflows[1]-K.overflows[1])[0])==null?void 0:U.placement;if(!H)switch(w){case"bestFit":{var V;const Y=(V=I.filter(K=>{if(P){const O=Vn(K.placement);return O===x||O==="y"}return!0}).map(K=>[K.placement,K.overflows.filter(O=>O>0).reduce((O,T)=>O+T,0)]).sort((K,O)=>K[1]-O[1])[0])==null?void 0:V[0];Y&&(H=Y);break}case"initialPlacement":H=l;break}if(o!==H)return{reset:{placement:H}}}return{}}}};function vw(e,r){return{top:e.top-r.height,right:e.right-r.width,bottom:e.bottom-r.height,left:e.left-r.width}}function yw(e){return zL.some(r=>e[r]>=0)}const rO=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(r){const{rects:s,platform:n}=r,{strategy:o="referenceHidden",...c}=bi(e,r);switch(o){case"referenceHidden":{const d=await n.detectOverflow(r,{...c,elementContext:"reference"}),l=vw(d,s.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:yw(l)}}}case"escaped":{const d=await n.detectOverflow(r,{...c,altBoundary:!0}),l=vw(d,s.floating);return{data:{escapedOffsets:l,escaped:yw(l)}}}default:return{}}}}},FC=new Set(["left","top"]);async function sO(e,r){const{placement:s,platform:n,elements:o}=e,c=await(n.isRTL==null?void 0:n.isRTL(o.floating)),d=wi(s),l=ll(s),u=Vn(s)==="y",f=FC.has(d)?-1:1,m=c&&u?-1:1,h=bi(r,e);let{mainAxis:g,crossAxis:w,alignmentAxis:j}=typeof h=="number"?{mainAxis:h,crossAxis:0,alignmentAxis:null}:{mainAxis:h.mainAxis||0,crossAxis:h.crossAxis||0,alignmentAxis:h.alignmentAxis};return l&&typeof j=="number"&&(w=l==="end"?j*-1:j),u?{x:w*m,y:g*f}:{x:g*f,y:w*m}}const nO=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(r){var s,n;const{x:o,y:c,placement:d,middlewareData:l}=r,u=await sO(r,e);return d===((s=l.offset)==null?void 0:s.placement)&&(n=l.arrow)!=null&&n.alignmentOffset?{}:{x:o+u.x,y:c+u.y,data:{...u,placement:d}}}}},iO=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(r){const{x:s,y:n,placement:o,platform:c}=r,{mainAxis:d=!0,crossAxis:l=!1,limiter:u={fn:y=>{let{x,y:b}=y;return{x,y:b}}},...f}=bi(e,r),m={x:s,y:n},h=await c.detectOverflow(r,f),g=Vn(wi(o)),w=ux(g);let j=m[w],k=m[g];if(d){const y=w==="y"?"top":"left",x=w==="y"?"bottom":"right",b=j+h[y],S=j-h[x];j=Ap(b,j,S)}if(l){const y=g==="y"?"top":"left",x=g==="y"?"bottom":"right",b=k+h[y],S=k-h[x];k=Ap(b,k,S)}const v=u.fn({...r,[w]:j,[g]:k});return{...v,data:{x:v.x-s,y:v.y-n,enabled:{[w]:d,[g]:l}}}}}},oO=function(e){return e===void 0&&(e={}),{options:e,fn(r){const{x:s,y:n,placement:o,rects:c,middlewareData:d}=r,{offset:l=0,mainAxis:u=!0,crossAxis:f=!0}=bi(e,r),m={x:s,y:n},h=Vn(o),g=ux(h);let w=m[g],j=m[h];const k=bi(l,r),v=typeof k=="number"?{mainAxis:k,crossAxis:0}:{mainAxis:0,crossAxis:0,...k};if(u){const b=g==="y"?"height":"width",S=c.reference[g]-c.floating[b]+v.mainAxis,N=c.reference[g]+c.reference[b]-v.mainAxis;w<S?w=S:w>N&&(w=N)}if(f){var y,x;const b=g==="y"?"width":"height",S=FC.has(wi(o)),N=c.reference[h]-c.floating[b]+(S&&((y=d.offset)==null?void 0:y[h])||0)+(S?0:v.crossAxis),P=c.reference[h]+c.reference[b]+(S?0:((x=d.offset)==null?void 0:x[h])||0)-(S?v.crossAxis:0);j<N?j=N:j>P&&(j=P)}return{[g]:w,[h]:j}}}},aO=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(r){var s,n;const{placement:o,rects:c,platform:d,elements:l}=r,{apply:u=()=>{},...f}=bi(e,r),m=await d.detectOverflow(r,f),h=wi(o),g=ll(o),w=Vn(o)==="y",{width:j,height:k}=c.floating;let v,y;h==="top"||h==="bottom"?(v=h,y=g===(await(d.isRTL==null?void 0:d.isRTL(l.floating))?"start":"end")?"left":"right"):(y=h,v=g==="end"?"top":"bottom");const x=k-m.top-m.bottom,b=j-m.left-m.right,S=to(k-m[v],x),N=to(j-m[y],b),P=!r.middlewareData.shift;let A=S,E=N;if((s=r.middlewareData.shift)!=null&&s.enabled.x&&(E=b),(n=r.middlewareData.shift)!=null&&n.enabled.y&&(A=x),P&&!g){const I=Vs(m.left,0),B=Vs(m.right,0),U=Vs(m.top,0),V=Vs(m.bottom,0);w?E=j-2*(I!==0||B!==0?I+B:Vs(m.left,m.right)):A=k-2*(U!==0||V!==0?U+V:Vs(m.top,m.bottom))}await u({...r,availableWidth:E,availableHeight:A});const M=await d.getDimensions(l.floating);return j!==M.width||k!==M.height?{reset:{rects:!0}}:{}}}};function hh(){return typeof window<"u"}function cl(e){return BC(e)?(e.nodeName||"").toLowerCase():"#document"}function Ks(e){var r;return(e==null||(r=e.ownerDocument)==null?void 0:r.defaultView)||window}function ei(e){var r;return(r=(BC(e)?e.ownerDocument:e.document)||window.document)==null?void 0:r.documentElement}function BC(e){return hh()?e instanceof Node||e instanceof Ks(e).Node:!1}function An(e){return hh()?e instanceof Element||e instanceof Ks(e).Element:!1}function ki(e){return hh()?e instanceof HTMLElement||e instanceof Ks(e).HTMLElement:!1}function bw(e){return!hh()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Ks(e).ShadowRoot}function Bc(e){const{overflow:r,overflowX:s,overflowY:n,display:o}=Tn(e);return/auto|scroll|overlay|hidden|clip/.test(r+n+s)&&o!=="inline"&&o!=="contents"}function lO(e){return/^(table|td|th)$/.test(cl(e))}function fh(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const cO=/transform|translate|scale|rotate|perspective|filter/,dO=/paint|layout|strict|content/,Ro=e=>!!e&&e!=="none";let Lm;function mx(e){const r=An(e)?Tn(e):e;return Ro(r.transform)||Ro(r.translate)||Ro(r.scale)||Ro(r.rotate)||Ro(r.perspective)||!px()&&(Ro(r.backdropFilter)||Ro(r.filter))||cO.test(r.willChange||"")||dO.test(r.contain||"")}function uO(e){let r=ro(e);for(;ki(r)&&!sl(r);){if(mx(r))return r;if(fh(r))return null;r=ro(r)}return null}function px(){return Lm==null&&(Lm=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Lm}function sl(e){return/^(html|body|#document)$/.test(cl(e))}function Tn(e){return Ks(e).getComputedStyle(e)}function mh(e){return An(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ro(e){if(cl(e)==="html")return e;const r=e.assignedSlot||e.parentNode||bw(e)&&e.host||ei(e);return bw(r)?r.host:r}function $C(e){const r=ro(e);return sl(r)?e.ownerDocument?e.ownerDocument.body:e.body:ki(r)&&Bc(r)?r:$C(r)}function yc(e,r,s){var n;r===void 0&&(r=[]),s===void 0&&(s=!0);const o=$C(e),c=o===((n=e.ownerDocument)==null?void 0:n.body),d=Ks(o);if(c){const l=Rp(d);return r.concat(d,d.visualViewport||[],Bc(o)?o:[],l&&s?yc(l):[])}else return r.concat(o,yc(o,[],s))}function Rp(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function HC(e){const r=Tn(e);let s=parseFloat(r.width)||0,n=parseFloat(r.height)||0;const o=ki(e),c=o?e.offsetWidth:s,d=o?e.offsetHeight:n,l=Fu(s)!==c||Fu(n)!==d;return l&&(s=c,n=d),{width:s,height:n,$:l}}function gx(e){return An(e)?e:e.contextElement}function Ka(e){const r=gx(e);if(!ki(r))return Kn(1);const s=r.getBoundingClientRect(),{width:n,height:o,$:c}=HC(r);let d=(c?Fu(s.width):s.width)/n,l=(c?Fu(s.height):s.height)/o;return(!d||!Number.isFinite(d))&&(d=1),(!l||!Number.isFinite(l))&&(l=1),{x:d,y:l}}const hO=Kn(0);function zC(e){const r=Ks(e);return!px()||!r.visualViewport?hO:{x:r.visualViewport.offsetLeft,y:r.visualViewport.offsetTop}}function fO(e,r,s){return r===void 0&&(r=!1),!s||r&&s!==Ks(e)?!1:r}function zo(e,r,s,n){r===void 0&&(r=!1),s===void 0&&(s=!1);const o=e.getBoundingClientRect(),c=gx(e);let d=Kn(1);r&&(n?An(n)&&(d=Ka(n)):d=Ka(e));const l=fO(c,s,n)?zC(c):Kn(0);let u=(o.left+l.x)/d.x,f=(o.top+l.y)/d.y,m=o.width/d.x,h=o.height/d.y;if(c){const g=Ks(c),w=n&&An(n)?Ks(n):n;let j=g,k=Rp(j);for(;k&&n&&w!==j;){const v=Ka(k),y=k.getBoundingClientRect(),x=Tn(k),b=y.left+(k.clientLeft+parseFloat(x.paddingLeft))*v.x,S=y.top+(k.clientTop+parseFloat(x.paddingTop))*v.y;u*=v.x,f*=v.y,m*=v.x,h*=v.y,u+=b,f+=S,j=Ks(k),k=Rp(j)}}return $u({width:m,height:h,x:u,y:f})}function ph(e,r){const s=mh(e).scrollLeft;return r?r.left+s:zo(ei(e)).left+s}function WC(e,r){const s=e.getBoundingClientRect(),n=s.left+r.scrollLeft-ph(e,s),o=s.top+r.scrollTop;return{x:n,y:o}}function mO(e){let{elements:r,rect:s,offsetParent:n,strategy:o}=e;const c=o==="fixed",d=ei(n),l=r?fh(r.floating):!1;if(n===d||l&&c)return s;let u={scrollLeft:0,scrollTop:0},f=Kn(1);const m=Kn(0),h=ki(n);if((h||!h&&!c)&&((cl(n)!=="body"||Bc(d))&&(u=mh(n)),h)){const w=zo(n);f=Ka(n),m.x=w.x+n.clientLeft,m.y=w.y+n.clientTop}const g=d&&!h&&!c?WC(d,u):Kn(0);return{width:s.width*f.x,height:s.height*f.y,x:s.x*f.x-u.scrollLeft*f.x+m.x+g.x,y:s.y*f.y-u.scrollTop*f.y+m.y+g.y}}function pO(e){return Array.from(e.getClientRects())}function gO(e){const r=ei(e),s=mh(e),n=e.ownerDocument.body,o=Vs(r.scrollWidth,r.clientWidth,n.scrollWidth,n.clientWidth),c=Vs(r.scrollHeight,r.clientHeight,n.scrollHeight,n.clientHeight);let d=-s.scrollLeft+ph(e);const l=-s.scrollTop;return Tn(n).direction==="rtl"&&(d+=Vs(r.clientWidth,n.clientWidth)-o),{width:o,height:c,x:d,y:l}}const ww=25;function xO(e,r){const s=Ks(e),n=ei(e),o=s.visualViewport;let c=n.clientWidth,d=n.clientHeight,l=0,u=0;if(o){c=o.width,d=o.height;const m=px();(!m||m&&r==="fixed")&&(l=o.offsetLeft,u=o.offsetTop)}const f=ph(n);if(f<=0){const m=n.ownerDocument,h=m.body,g=getComputedStyle(h),w=m.compatMode==="CSS1Compat"&&parseFloat(g.marginLeft)+parseFloat(g.marginRight)||0,j=Math.abs(n.clientWidth-h.clientWidth-w);j<=ww&&(c-=j)}else f<=ww&&(c+=f);return{width:c,height:d,x:l,y:u}}function vO(e,r){const s=zo(e,!0,r==="fixed"),n=s.top+e.clientTop,o=s.left+e.clientLeft,c=ki(e)?Ka(e):Kn(1),d=e.clientWidth*c.x,l=e.clientHeight*c.y,u=o*c.x,f=n*c.y;return{width:d,height:l,x:u,y:f}}function _w(e,r,s){let n;if(r==="viewport")n=xO(e,s);else if(r==="document")n=gO(ei(e));else if(An(r))n=vO(r,s);else{const o=zC(e);n={x:r.x-o.x,y:r.y-o.y,width:r.width,height:r.height}}return $u(n)}function UC(e,r){const s=ro(e);return s===r||!An(s)||sl(s)?!1:Tn(s).position==="fixed"||UC(s,r)}function yO(e,r){const s=r.get(e);if(s)return s;let n=yc(e,[],!1).filter(l=>An(l)&&cl(l)!=="body"),o=null;const c=Tn(e).position==="fixed";let d=c?ro(e):e;for(;An(d)&&!sl(d);){const l=Tn(d),u=mx(d);!u&&l.position==="fixed"&&(o=null),(c?!u&&!o:!u&&l.position==="static"&&!!o&&(o.position==="absolute"||o.position==="fixed")||Bc(d)&&!u&&UC(e,d))?n=n.filter(m=>m!==d):o=l,d=ro(d)}return r.set(e,n),n}function bO(e){let{element:r,boundary:s,rootBoundary:n,strategy:o}=e;const d=[...s==="clippingAncestors"?fh(r)?[]:yO(r,this._c):[].concat(s),n],l=_w(r,d[0],o);let u=l.top,f=l.right,m=l.bottom,h=l.left;for(let g=1;g<d.length;g++){const w=_w(r,d[g],o);u=Vs(w.top,u),f=to(w.right,f),m=to(w.bottom,m),h=Vs(w.left,h)}return{width:f-h,height:m-u,x:h,y:u}}function wO(e){const{width:r,height:s}=HC(e);return{width:r,height:s}}function _O(e,r,s){const n=ki(r),o=ei(r),c=s==="fixed",d=zo(e,!0,c,r);let l={scrollLeft:0,scrollTop:0};const u=Kn(0);function f(){u.x=ph(o)}if(n||!n&&!c)if((cl(r)!=="body"||Bc(o))&&(l=mh(r)),n){const w=zo(r,!0,c,r);u.x=w.x+r.clientLeft,u.y=w.y+r.clientTop}else o&&f();c&&!n&&o&&f();const m=o&&!n&&!c?WC(o,l):Kn(0),h=d.left+l.scrollLeft-u.x-m.x,g=d.top+l.scrollTop-u.y-m.y;return{x:h,y:g,width:d.width,height:d.height}}function Om(e){return Tn(e).position==="static"}function kw(e,r){if(!ki(e)||Tn(e).position==="fixed")return null;if(r)return r(e);let s=e.offsetParent;return ei(e)===s&&(s=s.ownerDocument.body),s}function VC(e,r){const s=Ks(e);if(fh(e))return s;if(!ki(e)){let o=ro(e);for(;o&&!sl(o);){if(An(o)&&!Om(o))return o;o=ro(o)}return s}let n=kw(e,r);for(;n&&lO(n)&&Om(n);)n=kw(n,r);return n&&sl(n)&&Om(n)&&!mx(n)?s:n||uO(e)||s}const kO=async function(e){const r=this.getOffsetParent||VC,s=this.getDimensions,n=await s(e.floating);return{reference:_O(e.reference,await r(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function SO(e){return Tn(e).direction==="rtl"}const CO={convertOffsetParentRelativeRectToViewportRelativeRect:mO,getDocumentElement:ei,getClippingRect:bO,getOffsetParent:VC,getElementRects:kO,getClientRects:pO,getDimensions:wO,getScale:Ka,isElement:An,isRTL:SO};function GC(e,r){return e.x===r.x&&e.y===r.y&&e.width===r.width&&e.height===r.height}function jO(e,r){let s=null,n;const o=ei(e);function c(){var l;clearTimeout(n),(l=s)==null||l.disconnect(),s=null}function d(l,u){l===void 0&&(l=!1),u===void 0&&(u=1),c();const f=e.getBoundingClientRect(),{left:m,top:h,width:g,height:w}=f;if(l||r(),!g||!w)return;const j=au(h),k=au(o.clientWidth-(m+g)),v=au(o.clientHeight-(h+w)),y=au(m),b={rootMargin:-j+"px "+-k+"px "+-v+"px "+-y+"px",threshold:Vs(0,to(1,u))||1};let S=!0;function N(P){const A=P[0].intersectionRatio;if(A!==u){if(!S)return d();A?d(!1,A):n=setTimeout(()=>{d(!1,1e-7)},1e3)}A===1&&!GC(f,e.getBoundingClientRect())&&d(),S=!1}try{s=new IntersectionObserver(N,{...b,root:o.ownerDocument})}catch{s=new IntersectionObserver(N,b)}s.observe(e)}return d(!0),c}function NO(e,r,s,n){n===void 0&&(n={});const{ancestorScroll:o=!0,ancestorResize:c=!0,elementResize:d=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=n,f=gx(e),m=o||c?[...f?yc(f):[],...r?yc(r):[]]:[];m.forEach(y=>{o&&y.addEventListener("scroll",s,{passive:!0}),c&&y.addEventListener("resize",s)});const h=f&&l?jO(f,s):null;let g=-1,w=null;d&&(w=new ResizeObserver(y=>{let[x]=y;x&&x.target===f&&w&&r&&(w.unobserve(r),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var b;(b=w)==null||b.observe(r)})),s()}),f&&!u&&w.observe(f),r&&w.observe(r));let j,k=u?zo(e):null;u&&v();function v(){const y=zo(e);k&&!GC(k,y)&&s(),k=y,j=requestAnimationFrame(v)}return s(),()=>{var y;m.forEach(x=>{o&&x.removeEventListener("scroll",s),c&&x.removeEventListener("resize",s)}),h==null||h(),(y=w)==null||y.disconnect(),w=null,u&&cancelAnimationFrame(j)}}const EO=nO,PO=iO,AO=tO,TO=aO,RO=rO,Sw=eO,MO=oO,IO=(e,r,s)=>{const n=new Map,o={platform:CO,...s},c={...o.platform,_c:n};return ZL(e,r,{...o,platform:c})};var DO=typeof document<"u",LO=function(){},bu=DO?_.useLayoutEffect:LO;function Hu(e,r){if(e===r)return!0;if(typeof e!=typeof r)return!1;if(typeof e=="function"&&e.toString()===r.toString())return!0;let s,n,o;if(e&&r&&typeof e=="object"){if(Array.isArray(e)){if(s=e.length,s!==r.length)return!1;for(n=s;n--!==0;)if(!Hu(e[n],r[n]))return!1;return!0}if(o=Object.keys(e),s=o.length,s!==Object.keys(r).length)return!1;for(n=s;n--!==0;)if(!{}.hasOwnProperty.call(r,o[n]))return!1;for(n=s;n--!==0;){const c=o[n];if(!(c==="_owner"&&e.$$typeof)&&!Hu(e[c],r[c]))return!1}return!0}return e!==e&&r!==r}function qC(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Cw(e,r){const s=qC(e);return Math.round(r*s)/s}function Fm(e){const r=_.useRef(e);return bu(()=>{r.current=e}),r}function OO(e){e===void 0&&(e={});const{placement:r="bottom",strategy:s="absolute",middleware:n=[],platform:o,elements:{reference:c,floating:d}={},transform:l=!0,whileElementsMounted:u,open:f}=e,[m,h]=_.useState({x:0,y:0,strategy:s,placement:r,middlewareData:{},isPositioned:!1}),[g,w]=_.useState(n);Hu(g,n)||w(n);const[j,k]=_.useState(null),[v,y]=_.useState(null),x=_.useCallback(K=>{K!==P.current&&(P.current=K,k(K))},[]),b=_.useCallback(K=>{K!==A.current&&(A.current=K,y(K))},[]),S=c||j,N=d||v,P=_.useRef(null),A=_.useRef(null),E=_.useRef(m),M=u!=null,I=Fm(u),B=Fm(o),U=Fm(f),V=_.useCallback(()=>{if(!P.current||!A.current)return;const K={placement:r,strategy:s,middleware:g};B.current&&(K.platform=B.current),IO(P.current,A.current,K).then(O=>{const T={...O,isPositioned:U.current!==!1};Q.current&&!Hu(E.current,T)&&(E.current=T,Ec.flushSync(()=>{h(T)}))})},[g,r,s,B,U]);bu(()=>{f===!1&&E.current.isPositioned&&(E.current.isPositioned=!1,h(K=>({...K,isPositioned:!1})))},[f]);const Q=_.useRef(!1);bu(()=>(Q.current=!0,()=>{Q.current=!1}),[]),bu(()=>{if(S&&(P.current=S),N&&(A.current=N),S&&N){if(I.current)return I.current(S,N,V);V()}},[S,N,V,I,M]);const z=_.useMemo(()=>({reference:P,floating:A,setReference:x,setFloating:b}),[x,b]),H=_.useMemo(()=>({reference:S,floating:N}),[S,N]),Y=_.useMemo(()=>{const K={position:s,left:0,top:0};if(!H.floating)return K;const O=Cw(H.floating,m.x),T=Cw(H.floating,m.y);return l?{...K,transform:"translate("+O+"px, "+T+"px)",...qC(H.floating)>=1.5&&{willChange:"transform"}}:{position:s,left:O,top:T}},[s,l,H.floating,m.x,m.y]);return _.useMemo(()=>({...m,update:V,refs:z,elements:H,floatingStyles:Y}),[m,V,z,H,Y])}const FO=e=>{function r(s){return{}.hasOwnProperty.call(s,"current")}return{name:"arrow",options:e,fn(s){const{element:n,padding:o}=typeof e=="function"?e(s):e;return n&&r(n)?n.current!=null?Sw({element:n.current,padding:o}).fn(s):{}:n?Sw({element:n,padding:o}).fn(s):{}}}},BO=(e,r)=>{const s=EO(e);return{name:s.name,fn:s.fn,options:[e,r]}},$O=(e,r)=>{const s=PO(e);return{name:s.name,fn:s.fn,options:[e,r]}},HO=(e,r)=>({fn:MO(e).fn,options:[e,r]}),zO=(e,r)=>{const s=AO(e);return{name:s.name,fn:s.fn,options:[e,r]}},WO=(e,r)=>{const s=TO(e);return{name:s.name,fn:s.fn,options:[e,r]}},UO=(e,r)=>{const s=RO(e);return{name:s.name,fn:s.fn,options:[e,r]}},VO=(e,r)=>{const s=FO(e);return{name:s.name,fn:s.fn,options:[e,r]}};var GO="Arrow",KC=_.forwardRef((e,r)=>{const{children:s,width:n=10,height:o=5,...c}=e;return t.jsx(ot.svg,{...c,ref:r,width:n,height:o,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?s:t.jsx("polygon",{points:"0,0 30,0 15,10"})})});KC.displayName=GO;var qO=KC,xx="Popper",[YC,dl]=Ls(xx),[KO,XC]=YC(xx),JC=e=>{const{__scopePopper:r,children:s}=e,[n,o]=_.useState(null);return t.jsx(KO,{scope:r,anchor:n,onAnchorChange:o,children:s})};JC.displayName=xx;var QC="PopperAnchor",ZC=_.forwardRef((e,r)=>{const{__scopePopper:s,virtualRef:n,...o}=e,c=XC(QC,s),d=_.useRef(null),l=bt(r,d),u=_.useRef(null);return _.useEffect(()=>{const f=u.current;u.current=(n==null?void 0:n.current)||d.current,f!==u.current&&c.onAnchorChange(u.current)}),n?null:t.jsx(ot.div,{...o,ref:l})});ZC.displayName=QC;var vx="PopperContent",[YO,XO]=YC(vx),e1=_.forwardRef((e,r)=>{var J,W,le,ae,re,de;const{__scopePopper:s,side:n="bottom",sideOffset:o=0,align:c="center",alignOffset:d=0,arrowPadding:l=0,avoidCollisions:u=!0,collisionBoundary:f=[],collisionPadding:m=0,sticky:h="partial",hideWhenDetached:g=!1,updatePositionStrategy:w="optimized",onPlaced:j,...k}=e,v=XC(vx,s),[y,x]=_.useState(null),b=bt(r,Se=>x(Se)),[S,N]=_.useState(null),P=ax(S),A=(P==null?void 0:P.width)??0,E=(P==null?void 0:P.height)??0,M=n+(c!=="center"?"-"+c:""),I=typeof m=="number"?m:{top:0,right:0,bottom:0,left:0,...m},B=Array.isArray(f)?f:[f],U=B.length>0,V={padding:I,boundary:B.filter(QO),altBoundary:U},{refs:Q,floatingStyles:z,placement:H,isPositioned:Y,middlewareData:K}=OO({strategy:"fixed",placement:M,whileElementsMounted:(...Se)=>NO(...Se,{animationFrame:w==="always"}),elements:{reference:v.anchor},middleware:[BO({mainAxis:o+E,alignmentAxis:d}),u&&$O({mainAxis:!0,crossAxis:!1,limiter:h==="partial"?HO():void 0,...V}),u&&zO({...V}),WO({...V,apply:({elements:Se,rects:Re,availableWidth:Ue,availableHeight:pe})=>{const{width:_e,height:$e}=Re.reference,Ge=Se.floating.style;Ge.setProperty("--radix-popper-available-width",`${Ue}px`),Ge.setProperty("--radix-popper-available-height",`${pe}px`),Ge.setProperty("--radix-popper-anchor-width",`${_e}px`),Ge.setProperty("--radix-popper-anchor-height",`${$e}px`)}}),S&&VO({element:S,padding:l}),ZO({arrowWidth:A,arrowHeight:E}),g&&UO({strategy:"referenceHidden",...V})]}),[O,T]=s1(H),F=Jr(j);Ur(()=>{Y&&(F==null||F())},[Y,F]);const $=(J=K.arrow)==null?void 0:J.x,D=(W=K.arrow)==null?void 0:W.y,X=((le=K.arrow)==null?void 0:le.centerOffset)!==0,[te,fe]=_.useState();return Ur(()=>{y&&fe(window.getComputedStyle(y).zIndex)},[y]),t.jsx("div",{ref:Q.setFloating,"data-radix-popper-content-wrapper":"",style:{...z,transform:Y?z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:te,"--radix-popper-transform-origin":[(ae=K.transformOrigin)==null?void 0:ae.x,(re=K.transformOrigin)==null?void 0:re.y].join(" "),...((de=K.hide)==null?void 0:de.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:t.jsx(YO,{scope:s,placedSide:O,onArrowChange:N,arrowX:$,arrowY:D,shouldHideArrow:X,children:t.jsx(ot.div,{"data-side":O,"data-align":T,...k,ref:b,style:{...k.style,animation:Y?void 0:"none"}})})})});e1.displayName=vx;var t1="PopperArrow",JO={top:"bottom",right:"left",bottom:"top",left:"right"},r1=_.forwardRef(function(r,s){const{__scopePopper:n,...o}=r,c=XO(t1,n),d=JO[c.placedSide];return t.jsx("span",{ref:c.onArrowChange,style:{position:"absolute",left:c.arrowX,top:c.arrowY,[d]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[c.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[c.placedSide],visibility:c.shouldHideArrow?"hidden":void 0},children:t.jsx(qO,{...o,ref:s,style:{...o.style,display:"block"}})})});r1.displayName=t1;function QO(e){return e!==null}var ZO=e=>({name:"transformOrigin",options:e,fn(r){var v,y,x;const{placement:s,rects:n,middlewareData:o}=r,d=((v=o.arrow)==null?void 0:v.centerOffset)!==0,l=d?0:e.arrowWidth,u=d?0:e.arrowHeight,[f,m]=s1(s),h={start:"0%",center:"50%",end:"100%"}[m],g=(((y=o.arrow)==null?void 0:y.x)??0)+l/2,w=(((x=o.arrow)==null?void 0:x.y)??0)+u/2;let j="",k="";return f==="bottom"?(j=d?h:`${g}px`,k=`${-u}px`):f==="top"?(j=d?h:`${g}px`,k=`${n.floating.height+u}px`):f==="right"?(j=`${-u}px`,k=d?h:`${w}px`):f==="left"&&(j=`${n.floating.width+u}px`,k=d?h:`${w}px`),{data:{x:j,y:k}}}});function s1(e){const[r,s="center"]=e.split("-");return[r,s]}var yx=JC,bx=ZC,wx=e1,_x=r1;function e6(e){const r=t6(e),s=_.forwardRef((n,o)=>{const{children:c,...d}=n,l=_.Children.toArray(c),u=l.find(s6);if(u){const f=u.props.children,m=l.map(h=>h===u?_.Children.count(f)>1?_.Children.only(null):_.isValidElement(f)?f.props.children:null:h);return t.jsx(r,{...d,ref:o,children:_.isValidElement(f)?_.cloneElement(f,void 0,m):null})}return t.jsx(r,{...d,ref:o,children:c})});return s.displayName=`${e}.Slot`,s}function t6(e){const r=_.forwardRef((s,n)=>{const{children:o,...c}=s;if(_.isValidElement(o)){const d=i6(o),l=n6(c,o.props);return o.type!==_.Fragment&&(l.ref=n?_i(n,d):d),_.cloneElement(o,l)}return _.Children.count(o)>1?_.Children.only(null):null});return r.displayName=`${e}.SlotClone`,r}var r6=Symbol("radix.slottable");function s6(e){return _.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===r6}function n6(e,r){const s={...r};for(const n in r){const o=e[n],c=r[n];/^on[A-Z]/.test(n)?o&&c?s[n]=(...l)=>{const u=c(...l);return o(...l),u}:o&&(s[n]=o):n==="style"?s[n]={...o,...c}:n==="className"&&(s[n]=[o,c].filter(Boolean).join(" "))}return{...e,...s}}function i6(e){var n,o;let r=(n=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:n.get,s=r&&"isReactWarning"in r&&r.isReactWarning;return s?e.ref:(r=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,s=r&&"isReactWarning"in r&&r.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}var n1=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),o6="VisuallyHidden",i1=_.forwardRef((e,r)=>t.jsx(ot.span,{...e,ref:r,style:{...n1,...e.style}}));i1.displayName=o6;var a6=i1,l6=[" ","Enter","ArrowUp","ArrowDown"],c6=[" ","Enter"],Wo="Select",[gh,xh,d6]=dx(Wo),[ul]=Ls(Wo,[d6,dl]),vh=dl(),[u6,io]=ul(Wo),[h6,f6]=ul(Wo),o1=e=>{const{__scopeSelect:r,children:s,open:n,defaultOpen:o,onOpenChange:c,value:d,defaultValue:l,onValueChange:u,dir:f,name:m,autoComplete:h,disabled:g,required:w,form:j}=e,k=vh(r),[v,y]=_.useState(null),[x,b]=_.useState(null),[S,N]=_.useState(!1),P=Dc(f),[A,E]=Xn({prop:n,defaultProp:o??!1,onChange:c,caller:Wo}),[M,I]=Xn({prop:d,defaultProp:l,onChange:u,caller:Wo}),B=_.useRef(null),U=v?j||!!v.closest("form"):!0,[V,Q]=_.useState(new Set),z=Array.from(V).map(H=>H.props.value).join(";");return t.jsx(yx,{...k,children:t.jsxs(u6,{required:w,scope:r,trigger:v,onTriggerChange:y,valueNode:x,onValueNodeChange:b,valueNodeHasChildren:S,onValueNodeHasChildrenChange:N,contentId:dn(),value:M,onValueChange:I,open:A,onOpenChange:E,dir:P,triggerPointerDownPosRef:B,disabled:g,children:[t.jsx(gh.Provider,{scope:r,children:t.jsx(h6,{scope:e.__scopeSelect,onNativeOptionAdd:_.useCallback(H=>{Q(Y=>new Set(Y).add(H))},[]),onNativeOptionRemove:_.useCallback(H=>{Q(Y=>{const K=new Set(Y);return K.delete(H),K})},[]),children:s})}),U?t.jsxs(A1,{"aria-hidden":!0,required:w,tabIndex:-1,name:m,autoComplete:h,value:M,onChange:H=>I(H.target.value),disabled:g,form:j,children:[M===void 0?t.jsx("option",{value:""}):null,Array.from(V)]},z):null]})})};o1.displayName=Wo;var a1="SelectTrigger",l1=_.forwardRef((e,r)=>{const{__scopeSelect:s,disabled:n=!1,...o}=e,c=vh(s),d=io(a1,s),l=d.disabled||n,u=bt(r,d.onTriggerChange),f=xh(s),m=_.useRef("touch"),[h,g,w]=R1(k=>{const v=f().filter(b=>!b.disabled),y=v.find(b=>b.value===d.value),x=M1(v,k,y);x!==void 0&&d.onValueChange(x.value)}),j=k=>{l||(d.onOpenChange(!0),w()),k&&(d.triggerPointerDownPosRef.current={x:Math.round(k.pageX),y:Math.round(k.pageY)})};return t.jsx(bx,{asChild:!0,...c,children:t.jsx(ot.button,{type:"button",role:"combobox","aria-controls":d.contentId,"aria-expanded":d.open,"aria-required":d.required,"aria-autocomplete":"none",dir:d.dir,"data-state":d.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":T1(d.value)?"":void 0,...o,ref:u,onClick:Be(o.onClick,k=>{k.currentTarget.focus(),m.current!=="mouse"&&j(k)}),onPointerDown:Be(o.onPointerDown,k=>{m.current=k.pointerType;const v=k.target;v.hasPointerCapture(k.pointerId)&&v.releasePointerCapture(k.pointerId),k.button===0&&k.ctrlKey===!1&&k.pointerType==="mouse"&&(j(k),k.preventDefault())}),onKeyDown:Be(o.onKeyDown,k=>{const v=h.current!=="";!(k.ctrlKey||k.altKey||k.metaKey)&&k.key.length===1&&g(k.key),!(v&&k.key===" ")&&l6.includes(k.key)&&(j(),k.preventDefault())})})})});l1.displayName=a1;var c1="SelectValue",d1=_.forwardRef((e,r)=>{const{__scopeSelect:s,className:n,style:o,children:c,placeholder:d="",...l}=e,u=io(c1,s),{onValueNodeHasChildrenChange:f}=u,m=c!==void 0,h=bt(r,u.onValueNodeChange);return Ur(()=>{f(m)},[f,m]),t.jsx(ot.span,{...l,ref:h,style:{pointerEvents:"none"},children:T1(u.value)?t.jsx(t.Fragment,{children:d}):c})});d1.displayName=c1;var m6="SelectIcon",u1=_.forwardRef((e,r)=>{const{__scopeSelect:s,children:n,...o}=e;return t.jsx(ot.span,{"aria-hidden":!0,...o,ref:r,children:n||"▼"})});u1.displayName=m6;var p6="SelectPortal",h1=e=>t.jsx(Oc,{asChild:!0,...e});h1.displayName=p6;var Uo="SelectContent",f1=_.forwardRef((e,r)=>{const s=io(Uo,e.__scopeSelect),[n,o]=_.useState();if(Ur(()=>{o(new DocumentFragment)},[]),!s.open){const c=n;return c?Ec.createPortal(t.jsx(m1,{scope:e.__scopeSelect,children:t.jsx(gh.Slot,{scope:e.__scopeSelect,children:t.jsx("div",{children:e.children})})}),c):null}return t.jsx(p1,{...e,ref:r})});f1.displayName=Uo;var jn=10,[m1,oo]=ul(Uo),g6="SelectContentImpl",x6=e6("SelectContent.RemoveScroll"),p1=_.forwardRef((e,r)=>{const{__scopeSelect:s,position:n="item-aligned",onCloseAutoFocus:o,onEscapeKeyDown:c,onPointerDownOutside:d,side:l,sideOffset:u,align:f,alignOffset:m,arrowPadding:h,collisionBoundary:g,collisionPadding:w,sticky:j,hideWhenDetached:k,avoidCollisions:v,...y}=e,x=io(Uo,s),[b,S]=_.useState(null),[N,P]=_.useState(null),A=bt(r,J=>S(J)),[E,M]=_.useState(null),[I,B]=_.useState(null),U=xh(s),[V,Q]=_.useState(!1),z=_.useRef(!1);_.useEffect(()=>{if(b)return Jg(b)},[b]),Xg();const H=_.useCallback(J=>{const[W,...le]=U().map(de=>de.ref.current),[ae]=le.slice(-1),re=document.activeElement;for(const de of J)if(de===re||(de==null||de.scrollIntoView({block:"nearest"}),de===W&&N&&(N.scrollTop=0),de===ae&&N&&(N.scrollTop=N.scrollHeight),de==null||de.focus(),document.activeElement!==re))return},[U,N]),Y=_.useCallback(()=>H([E,b]),[H,E,b]);_.useEffect(()=>{V&&Y()},[V,Y]);const{onOpenChange:K,triggerPointerDownPosRef:O}=x;_.useEffect(()=>{if(b){let J={x:0,y:0};const W=ae=>{var re,de;J={x:Math.abs(Math.round(ae.pageX)-(((re=O.current)==null?void 0:re.x)??0)),y:Math.abs(Math.round(ae.pageY)-(((de=O.current)==null?void 0:de.y)??0))}},le=ae=>{J.x<=10&&J.y<=10?ae.preventDefault():b.contains(ae.target)||K(!1),document.removeEventListener("pointermove",W),O.current=null};return O.current!==null&&(document.addEventListener("pointermove",W),document.addEventListener("pointerup",le,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",W),document.removeEventListener("pointerup",le,{capture:!0})}}},[b,K,O]),_.useEffect(()=>{const J=()=>K(!1);return window.addEventListener("blur",J),window.addEventListener("resize",J),()=>{window.removeEventListener("blur",J),window.removeEventListener("resize",J)}},[K]);const[T,F]=R1(J=>{const W=U().filter(re=>!re.disabled),le=W.find(re=>re.ref.current===document.activeElement),ae=M1(W,J,le);ae&&setTimeout(()=>ae.ref.current.focus())}),$=_.useCallback((J,W,le)=>{const ae=!z.current&&!le;(x.value!==void 0&&x.value===W||ae)&&(M(J),ae&&(z.current=!0))},[x.value]),D=_.useCallback(()=>b==null?void 0:b.focus(),[b]),X=_.useCallback((J,W,le)=>{const ae=!z.current&&!le;(x.value!==void 0&&x.value===W||ae)&&B(J)},[x.value]),te=n==="popper"?Mp:g1,fe=te===Mp?{side:l,sideOffset:u,align:f,alignOffset:m,arrowPadding:h,collisionBoundary:g,collisionPadding:w,sticky:j,hideWhenDetached:k,avoidCollisions:v}:{};return t.jsx(m1,{scope:s,content:b,viewport:N,onViewportChange:P,itemRefCallback:$,selectedItem:E,onItemLeave:D,itemTextRefCallback:X,focusSelectedItem:Y,selectedItemText:I,position:n,isPositioned:V,searchRef:T,children:t.jsx(ch,{as:x6,allowPinchZoom:!0,children:t.jsx(ah,{asChild:!0,trapped:x.open,onMountAutoFocus:J=>{J.preventDefault()},onUnmountAutoFocus:Be(o,J=>{var W;(W=x.trigger)==null||W.focus({preventScroll:!0}),J.preventDefault()}),children:t.jsx(Lc,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:c,onPointerDownOutside:d,onFocusOutside:J=>J.preventDefault(),onDismiss:()=>x.onOpenChange(!1),children:t.jsx(te,{role:"listbox",id:x.contentId,"data-state":x.open?"open":"closed",dir:x.dir,onContextMenu:J=>J.preventDefault(),...y,...fe,onPlaced:()=>Q(!0),ref:A,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:Be(y.onKeyDown,J=>{const W=J.ctrlKey||J.altKey||J.metaKey;if(J.key==="Tab"&&J.preventDefault(),!W&&J.key.length===1&&F(J.key),["ArrowUp","ArrowDown","Home","End"].includes(J.key)){let ae=U().filter(re=>!re.disabled).map(re=>re.ref.current);if(["ArrowUp","End"].includes(J.key)&&(ae=ae.slice().reverse()),["ArrowUp","ArrowDown"].includes(J.key)){const re=J.target,de=ae.indexOf(re);ae=ae.slice(de+1)}setTimeout(()=>H(ae)),J.preventDefault()}})})})})})})});p1.displayName=g6;var v6="SelectItemAlignedPosition",g1=_.forwardRef((e,r)=>{const{__scopeSelect:s,onPlaced:n,...o}=e,c=io(Uo,s),d=oo(Uo,s),[l,u]=_.useState(null),[f,m]=_.useState(null),h=bt(r,A=>m(A)),g=xh(s),w=_.useRef(!1),j=_.useRef(!0),{viewport:k,selectedItem:v,selectedItemText:y,focusSelectedItem:x}=d,b=_.useCallback(()=>{if(c.trigger&&c.valueNode&&l&&f&&k&&v&&y){const A=c.trigger.getBoundingClientRect(),E=f.getBoundingClientRect(),M=c.valueNode.getBoundingClientRect(),I=y.getBoundingClientRect();if(c.dir!=="rtl"){const re=I.left-E.left,de=M.left-re,Se=A.left-de,Re=A.width+Se,Ue=Math.max(Re,E.width),pe=window.innerWidth-jn,_e=Np(de,[jn,Math.max(jn,pe-Ue)]);l.style.minWidth=Re+"px",l.style.left=_e+"px"}else{const re=E.right-I.right,de=window.innerWidth-M.right-re,Se=window.innerWidth-A.right-de,Re=A.width+Se,Ue=Math.max(Re,E.width),pe=window.innerWidth-jn,_e=Np(de,[jn,Math.max(jn,pe-Ue)]);l.style.minWidth=Re+"px",l.style.right=_e+"px"}const B=g(),U=window.innerHeight-jn*2,V=k.scrollHeight,Q=window.getComputedStyle(f),z=parseInt(Q.borderTopWidth,10),H=parseInt(Q.paddingTop,10),Y=parseInt(Q.borderBottomWidth,10),K=parseInt(Q.paddingBottom,10),O=z+H+V+K+Y,T=Math.min(v.offsetHeight*5,O),F=window.getComputedStyle(k),$=parseInt(F.paddingTop,10),D=parseInt(F.paddingBottom,10),X=A.top+A.height/2-jn,te=U-X,fe=v.offsetHeight/2,J=v.offsetTop+fe,W=z+H+J,le=O-W;if(W<=X){const re=B.length>0&&v===B[B.length-1].ref.current;l.style.bottom="0px";const de=f.clientHeight-k.offsetTop-k.offsetHeight,Se=Math.max(te,fe+(re?D:0)+de+Y),Re=W+Se;l.style.height=Re+"px"}else{const re=B.length>0&&v===B[0].ref.current;l.style.top="0px";const Se=Math.max(X,z+k.offsetTop+(re?$:0)+fe)+le;l.style.height=Se+"px",k.scrollTop=W-X+k.offsetTop}l.style.margin=`${jn}px 0`,l.style.minHeight=T+"px",l.style.maxHeight=U+"px",n==null||n(),requestAnimationFrame(()=>w.current=!0)}},[g,c.trigger,c.valueNode,l,f,k,v,y,c.dir,n]);Ur(()=>b(),[b]);const[S,N]=_.useState();Ur(()=>{f&&N(window.getComputedStyle(f).zIndex)},[f]);const P=_.useCallback(A=>{A&&j.current===!0&&(b(),x==null||x(),j.current=!1)},[b,x]);return t.jsx(b6,{scope:s,contentWrapper:l,shouldExpandOnScrollRef:w,onScrollButtonChange:P,children:t.jsx("div",{ref:u,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:S},children:t.jsx(ot.div,{...o,ref:h,style:{boxSizing:"border-box",maxHeight:"100%",...o.style}})})})});g1.displayName=v6;var y6="SelectPopperPosition",Mp=_.forwardRef((e,r)=>{const{__scopeSelect:s,align:n="start",collisionPadding:o=jn,...c}=e,d=vh(s);return t.jsx(wx,{...d,...c,ref:r,align:n,collisionPadding:o,style:{boxSizing:"border-box",...c.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})});Mp.displayName=y6;var[b6,kx]=ul(Uo,{}),Ip="SelectViewport",x1=_.forwardRef((e,r)=>{const{__scopeSelect:s,nonce:n,...o}=e,c=oo(Ip,s),d=kx(Ip,s),l=bt(r,c.onViewportChange),u=_.useRef(0);return t.jsxs(t.Fragment,{children:[t.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:n}),t.jsx(gh.Slot,{scope:s,children:t.jsx(ot.div,{"data-radix-select-viewport":"",role:"presentation",...o,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...o.style},onScroll:Be(o.onScroll,f=>{const m=f.currentTarget,{contentWrapper:h,shouldExpandOnScrollRef:g}=d;if(g!=null&&g.current&&h){const w=Math.abs(u.current-m.scrollTop);if(w>0){const j=window.innerHeight-jn*2,k=parseFloat(h.style.minHeight),v=parseFloat(h.style.height),y=Math.max(k,v);if(y<j){const x=y+w,b=Math.min(j,x),S=x-b;h.style.height=b+"px",h.style.bottom==="0px"&&(m.scrollTop=S>0?S:0,h.style.justifyContent="flex-end")}}}u.current=m.scrollTop})})})]})});x1.displayName=Ip;var v1="SelectGroup",[w6,_6]=ul(v1),k6=_.forwardRef((e,r)=>{const{__scopeSelect:s,...n}=e,o=dn();return t.jsx(w6,{scope:s,id:o,children:t.jsx(ot.div,{role:"group","aria-labelledby":o,...n,ref:r})})});k6.displayName=v1;var y1="SelectLabel",b1=_.forwardRef((e,r)=>{const{__scopeSelect:s,...n}=e,o=_6(y1,s);return t.jsx(ot.div,{id:o.id,...n,ref:r})});b1.displayName=y1;var zu="SelectItem",[S6,w1]=ul(zu),_1=_.forwardRef((e,r)=>{const{__scopeSelect:s,value:n,disabled:o=!1,textValue:c,...d}=e,l=io(zu,s),u=oo(zu,s),f=l.value===n,[m,h]=_.useState(c??""),[g,w]=_.useState(!1),j=bt(r,x=>{var b;return(b=u.itemRefCallback)==null?void 0:b.call(u,x,n,o)}),k=dn(),v=_.useRef("touch"),y=()=>{o||(l.onValueChange(n),l.onOpenChange(!1))};if(n==="")throw new Error("A <Select.Item /> must have a value prop that is not an empty string. This is because the Select value can be set to an empty string to clear the selection and show the placeholder.");return t.jsx(S6,{scope:s,value:n,disabled:o,textId:k,isSelected:f,onItemTextChange:_.useCallback(x=>{h(b=>b||((x==null?void 0:x.textContent)??"").trim())},[]),children:t.jsx(gh.ItemSlot,{scope:s,value:n,disabled:o,textValue:m,children:t.jsx(ot.div,{role:"option","aria-labelledby":k,"data-highlighted":g?"":void 0,"aria-selected":f&&g,"data-state":f?"checked":"unchecked","aria-disabled":o||void 0,"data-disabled":o?"":void 0,tabIndex:o?void 0:-1,...d,ref:j,onFocus:Be(d.onFocus,()=>w(!0)),onBlur:Be(d.onBlur,()=>w(!1)),onClick:Be(d.onClick,()=>{v.current!=="mouse"&&y()}),onPointerUp:Be(d.onPointerUp,()=>{v.current==="mouse"&&y()}),onPointerDown:Be(d.onPointerDown,x=>{v.current=x.pointerType}),onPointerMove:Be(d.onPointerMove,x=>{var b;v.current=x.pointerType,o?(b=u.onItemLeave)==null||b.call(u):v.current==="mouse"&&x.currentTarget.focus({preventScroll:!0})}),onPointerLeave:Be(d.onPointerLeave,x=>{var b;x.currentTarget===document.activeElement&&((b=u.onItemLeave)==null||b.call(u))}),onKeyDown:Be(d.onKeyDown,x=>{var S;((S=u.searchRef)==null?void 0:S.current)!==""&&x.key===" "||(c6.includes(x.key)&&y(),x.key===" "&&x.preventDefault())})})})})});_1.displayName=zu;var nc="SelectItemText",k1=_.forwardRef((e,r)=>{const{__scopeSelect:s,className:n,style:o,...c}=e,d=io(nc,s),l=oo(nc,s),u=w1(nc,s),f=f6(nc,s),[m,h]=_.useState(null),g=bt(r,y=>h(y),u.onItemTextChange,y=>{var x;return(x=l.itemTextRefCallback)==null?void 0:x.call(l,y,u.value,u.disabled)}),w=m==null?void 0:m.textContent,j=_.useMemo(()=>t.jsx("option",{value:u.value,disabled:u.disabled,children:w},u.value),[u.disabled,u.value,w]),{onNativeOptionAdd:k,onNativeOptionRemove:v}=f;return Ur(()=>(k(j),()=>v(j)),[k,v,j]),t.jsxs(t.Fragment,{children:[t.jsx(ot.span,{id:u.textId,...c,ref:g}),u.isSelected&&d.valueNode&&!d.valueNodeHasChildren?Ec.createPortal(c.children,d.valueNode):null]})});k1.displayName=nc;var S1="SelectItemIndicator",C1=_.forwardRef((e,r)=>{const{__scopeSelect:s,...n}=e;return w1(S1,s).isSelected?t.jsx(ot.span,{"aria-hidden":!0,...n,ref:r}):null});C1.displayName=S1;var Dp="SelectScrollUpButton",j1=_.forwardRef((e,r)=>{const s=oo(Dp,e.__scopeSelect),n=kx(Dp,e.__scopeSelect),[o,c]=_.useState(!1),d=bt(r,n.onScrollButtonChange);return Ur(()=>{if(s.viewport&&s.isPositioned){let l=function(){const f=u.scrollTop>0;c(f)};const u=s.viewport;return l(),u.addEventListener("scroll",l),()=>u.removeEventListener("scroll",l)}},[s.viewport,s.isPositioned]),o?t.jsx(E1,{...e,ref:d,onAutoScroll:()=>{const{viewport:l,selectedItem:u}=s;l&&u&&(l.scrollTop=l.scrollTop-u.offsetHeight)}}):null});j1.displayName=Dp;var Lp="SelectScrollDownButton",N1=_.forwardRef((e,r)=>{const s=oo(Lp,e.__scopeSelect),n=kx(Lp,e.__scopeSelect),[o,c]=_.useState(!1),d=bt(r,n.onScrollButtonChange);return Ur(()=>{if(s.viewport&&s.isPositioned){let l=function(){const f=u.scrollHeight-u.clientHeight,m=Math.ceil(u.scrollTop)<f;c(m)};const u=s.viewport;return l(),u.addEventListener("scroll",l),()=>u.removeEventListener("scroll",l)}},[s.viewport,s.isPositioned]),o?t.jsx(E1,{...e,ref:d,onAutoScroll:()=>{const{viewport:l,selectedItem:u}=s;l&&u&&(l.scrollTop=l.scrollTop+u.offsetHeight)}}):null});N1.displayName=Lp;var E1=_.forwardRef((e,r)=>{const{__scopeSelect:s,onAutoScroll:n,...o}=e,c=oo("SelectScrollButton",s),d=_.useRef(null),l=xh(s),u=_.useCallback(()=>{d.current!==null&&(window.clearInterval(d.current),d.current=null)},[]);return _.useEffect(()=>()=>u(),[u]),Ur(()=>{var m;const f=l().find(h=>h.ref.current===document.activeElement);(m=f==null?void 0:f.ref.current)==null||m.scrollIntoView({block:"nearest"})},[l]),t.jsx(ot.div,{"aria-hidden":!0,...o,ref:r,style:{flexShrink:0,...o.style},onPointerDown:Be(o.onPointerDown,()=>{d.current===null&&(d.current=window.setInterval(n,50))}),onPointerMove:Be(o.onPointerMove,()=>{var f;(f=c.onItemLeave)==null||f.call(c),d.current===null&&(d.current=window.setInterval(n,50))}),onPointerLeave:Be(o.onPointerLeave,()=>{u()})})}),C6="SelectSeparator",P1=_.forwardRef((e,r)=>{const{__scopeSelect:s,...n}=e;return t.jsx(ot.div,{"aria-hidden":!0,...n,ref:r})});P1.displayName=C6;var Op="SelectArrow",j6=_.forwardRef((e,r)=>{const{__scopeSelect:s,...n}=e,o=vh(s),c=io(Op,s),d=oo(Op,s);return c.open&&d.position==="popper"?t.jsx(_x,{...o,...n,ref:r}):null});j6.displayName=Op;var N6="SelectBubbleInput",A1=_.forwardRef(({__scopeSelect:e,value:r,...s},n)=>{const o=_.useRef(null),c=bt(n,o),d=ox(r);return _.useEffect(()=>{const l=o.current;if(!l)return;const u=window.HTMLSelectElement.prototype,m=Object.getOwnPropertyDescriptor(u,"value").set;if(d!==r&&m){const h=new Event("change",{bubbles:!0});m.call(l,r),l.dispatchEvent(h)}},[d,r]),t.jsx(ot.select,{...s,style:{...n1,...s.style},ref:c,defaultValue:r})});A1.displayName=N6;function T1(e){return e===""||e===void 0}function R1(e){const r=Jr(e),s=_.useRef(""),n=_.useRef(0),o=_.useCallback(d=>{const l=s.current+d;r(l),(function u(f){s.current=f,window.clearTimeout(n.current),f!==""&&(n.current=window.setTimeout(()=>u(""),1e3))})(l)},[r]),c=_.useCallback(()=>{s.current="",window.clearTimeout(n.current)},[]);return _.useEffect(()=>()=>window.clearTimeout(n.current),[]),[s,o,c]}function M1(e,r,s){const o=r.length>1&&Array.from(r).every(f=>f===r[0])?r[0]:r,c=s?e.indexOf(s):-1;let d=E6(e,Math.max(c,0));o.length===1&&(d=d.filter(f=>f!==s));const u=d.find(f=>f.textValue.toLowerCase().startsWith(o.toLowerCase()));return u!==s?u:void 0}function E6(e,r){return e.map((s,n)=>e[(r+n)%e.length])}var P6=o1,I1=l1,A6=d1,T6=u1,R6=h1,D1=f1,M6=x1,L1=b1,O1=_1,I6=k1,D6=C1,F1=j1,B1=N1,$1=P1;const ir=P6,or=A6,Qt=_.forwardRef(({className:e,children:r,...s},n)=>t.jsxs(I1,{ref:n,className:Ee("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...s,children:[r,t.jsx(T6,{asChild:!0,children:t.jsx(hr,{className:"h-4 w-4 opacity-50"})})]}));Qt.displayName=I1.displayName;const H1=_.forwardRef(({className:e,...r},s)=>t.jsx(F1,{ref:s,className:Ee("flex cursor-default items-center justify-center py-1",e),...r,children:t.jsx(pS,{className:"h-4 w-4"})}));H1.displayName=F1.displayName;const z1=_.forwardRef(({className:e,...r},s)=>t.jsx(B1,{ref:s,className:Ee("flex cursor-default items-center justify-center py-1",e),...r,children:t.jsx(hr,{className:"h-4 w-4"})}));z1.displayName=B1.displayName;const Zt=_.forwardRef(({className:e,children:r,position:s="popper",...n},o)=>t.jsx(R6,{children:t.jsxs(D1,{ref:o,className:Ee("relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",s==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:s,...n,children:[t.jsx(H1,{}),t.jsx(M6,{className:Ee("p-1",s==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:r}),t.jsx(z1,{})]})}));Zt.displayName=D1.displayName;const L6=_.forwardRef(({className:e,...r},s)=>t.jsx(L1,{ref:s,className:Ee("px-2 py-1.5 text-sm font-semibold",e),...r}));L6.displayName=L1.displayName;const gt=_.forwardRef(({className:e,children:r,...s},n)=>t.jsxs(O1,{ref:n,className:Ee("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...s,children:[t.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(D6,{children:t.jsx(It,{className:"h-4 w-4"})})}),t.jsx(I6,{children:r})]}));gt.displayName=O1.displayName;const O6=_.forwardRef(({className:e,...r},s)=>t.jsx($1,{ref:s,className:Ee("-mx-1 my-1 h-px bg-muted",e),...r}));O6.displayName=$1.displayName;const Bm={claude:{name:"Claude Code",folder:".claude",color:"text-orange-600",bg:"bg-orange-50",darkBg:"dark:bg-orange-950/30"},gemini:{name:"Gemini CLI",folder:".gemini",color:"text-blue-600",bg:"bg-blue-50",darkBg:"dark:bg-blue-950/30"},antigravity:{name:"Antigravity",folder:".agent",color:"text-purple-600",bg:"bg-purple-50",darkBg:"dark:bg-purple-950/30"}};function F6({open:e,onOpenChange:r,projectDir:s,onSynced:n}){var E,M,I;const[o,c]=_.useState("claude"),[d,l]=_.useState("antigravity"),[u,f]=_.useState(null),[m,h]=_.useState(!1),[g,w]=_.useState(!1),[j,k]=_.useState(new Set);_.useEffect(()=>{e&&s&&v()},[e,o,d,s]),_.useEffect(()=>{e&&k(new Set)},[e]);const v=async()=>{var B;h(!0);try{const U=await he.getSyncPreview(s,o,d);f(U);const V=new Set(((B=U.files)==null?void 0:B.filter(Q=>Q.status==="new"||Q.status==="different").map(Q=>Q.name))||[]);k(V)}catch(U){q.error("Failed to load sync preview: "+U.message),f(null)}finally{h(!1)}},y=()=>{c(d),l(o)},x=B=>{const U=new Set(j);U.has(B)?U.delete(B):U.add(B),k(U)},b=()=>{var B,U;j.size===((B=u==null?void 0:u.files)==null?void 0:B.length)?k(new Set):k(new Set(((U=u==null?void 0:u.files)==null?void 0:U.map(V=>V.name))||[]))},S=async()=>{if(j.size===0){q.error("Please select at least one file to sync");return}w(!0);try{const B=await he.syncRules(s,o,d,Array.from(j));B.success?(q.success(`Synced ${B.synced.length} file(s) to ${Bm[d].name}`),n==null||n(),r(!1)):q.error(B.error||"Sync failed")}catch(B){q.error("Sync failed: "+B.message)}finally{w(!1)}},N=B=>{switch(B){case"new":return t.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-green-100 text-green-700",children:"New"});case"different":return t.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-yellow-100 text-yellow-700",children:"Modified"});case"identical":return t.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded bg-gray-100 dark:bg-slate-700 text-gray-500 dark:text-slate-400",children:"Same"});default:return null}},P=Bm[o],A=Bm[d];return t.jsx(vt,{open:e,onOpenChange:r,children:t.jsxs(ft,{className:"sm:max-w-lg",children:[t.jsxs(mt,{children:[t.jsxs(pt,{className:"flex items-center gap-2",children:[t.jsx(Dr,{className:"w-5 h-5 text-indigo-500"}),"Sync Rules Between Tools"]}),t.jsx(Gt,{children:"Copy rules from one AI tool's configuration to another."})]}),t.jsxs("div",{className:"space-y-4 py-4",children:[t.jsxs("div",{className:"flex items-center gap-3 p-3 bg-muted/50 rounded-lg",children:[t.jsxs("div",{className:"flex-1",children:[t.jsx("label",{className:"text-xs text-muted-foreground mb-1 block",children:"From"}),t.jsxs(ir,{value:o,onValueChange:c,children:[t.jsx(Qt,{className:"w-full",children:t.jsx(or,{})}),t.jsxs(Zt,{children:[t.jsx(gt,{value:"claude",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Vt,{className:"w-3 h-3 text-orange-500"}),"Claude Code"]})}),t.jsx(gt,{value:"gemini",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Vt,{className:"w-3 h-3 text-blue-500"}),"Gemini CLI"]})}),t.jsx(gt,{value:"antigravity",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Vt,{className:"w-3 h-3 text-purple-500"}),"Antigravity"]})})]})]})]}),t.jsx(ne,{variant:"ghost",size:"icon",onClick:y,className:"mt-5",title:"Swap direction",children:t.jsx(Og,{className:"w-4 h-4"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("label",{className:"text-xs text-muted-foreground mb-1 block",children:"To"}),t.jsxs(ir,{value:d,onValueChange:l,children:[t.jsx(Qt,{className:"w-full",children:t.jsx(or,{})}),t.jsxs(Zt,{children:[t.jsx(gt,{value:"claude",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Vt,{className:"w-3 h-3 text-orange-500"}),"Claude Code"]})}),t.jsx(gt,{value:"gemini",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Vt,{className:"w-3 h-3 text-blue-500"}),"Gemini CLI"]})}),t.jsx(gt,{value:"antigravity",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(Vt,{className:"w-3 h-3 text-purple-500"}),"Antigravity"]})})]})]})]})]}),t.jsxs("div",{className:"text-xs text-muted-foreground space-y-1",children:[t.jsxs("div",{children:["Source: ",t.jsxs("code",{className:"bg-muted px-1 rounded",children:[P.folder,"/rules/"]})]}),t.jsxs("div",{children:["Target: ",t.jsxs("code",{className:"bg-muted px-1 rounded",children:[A.folder,"/rules/"]})]})]}),t.jsxs("div",{className:"border rounded-lg",children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b bg-muted/30",children:[t.jsx("span",{className:"text-sm font-medium",children:"Rules to Sync"}),((E=u==null?void 0:u.files)==null?void 0:E.length)>0&&t.jsx(ne,{variant:"ghost",size:"sm",onClick:b,className:"h-6 text-xs",children:j.size===u.files.length?"Deselect All":"Select All"})]}),t.jsx("div",{className:"max-h-64 overflow-auto",children:m?t.jsx("div",{className:"flex items-center justify-center py-8",children:t.jsx(Qe,{className:"w-5 h-5 animate-spin text-muted-foreground"})}):u!=null&&u.error?t.jsxs("div",{className:"flex items-center gap-2 p-4 text-sm text-amber-600",children:[t.jsx(Is,{className:"w-4 h-4"}),u.error]}):((M=u==null?void 0:u.files)==null?void 0:M.length)===0?t.jsx("div",{className:"p-4 text-sm text-muted-foreground text-center",children:"No rules found in source folder"}):t.jsx("div",{className:"divide-y",children:(I=u==null?void 0:u.files)==null?void 0:I.map(B=>t.jsxs("label",{className:Ee("flex items-center gap-3 px-3 py-2 cursor-pointer hover:bg-muted/30",j.has(B.name)&&"bg-primary/5"),children:[t.jsx(Fc,{checked:j.has(B.name),onCheckedChange:()=>x(B.name)}),t.jsx(vr,{className:"w-4 h-4 text-purple-500"}),t.jsx("span",{className:"flex-1 text-sm",children:B.name}),N(B.status)]},B.name))})})]}),(u==null?void 0:u.files)&&j.size>0&&t.jsxs("p",{className:"text-xs text-muted-foreground",children:[j.size," file(s) selected for sync"]})]}),t.jsxs(St,{children:[t.jsx(ne,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),t.jsx(ne,{onClick:S,disabled:g||m||j.size===0,children:g?t.jsxs(t.Fragment,{children:[t.jsx(Qe,{className:"w-4 h-4 mr-2 animate-spin"}),"Syncing..."]}):t.jsxs(t.Fragment,{children:[t.jsx(It,{className:"w-4 h-4 mr-2"}),"Sync ",j.size," File(s)"]})})]})]})})}const Oe=_.forwardRef(({className:e,type:r,...s},n)=>t.jsx("input",{type:r,className:Ee("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:n,...s}));Oe.displayName="Input";function Sx({open:e,onOpenChange:r,onSelect:s,type:n="directory",initialPath:o="~",title:c="Select Path"}){const[d,l]=_.useState(""),[u,f]=_.useState([]),[m,h]=_.useState(!1),[g,w]=_.useState(null),[j,k]=_.useState(""),[v,y]=_.useState("");_.useEffect(()=>{e&&x(o)},[e,o]);const x=async A=>{h(!0),w(null);try{const E=await he.browse(A,n);E.error?(w(E.error),E.path&&(l(E.path),y(E.path))):(l(E.path),y(E.path),f(E.items||[]),E.home&&k(E.home))}catch(E){w(E.message)}finally{h(!1)}},b=A=>{A.type==="directory"?x(A.path):n==="file"&&(s(A.path),r(!1))},S=()=>{s(d),r(!1)},N=()=>{v&&x(v)},P=A=>{A.key==="Enter"&&N()};return t.jsx(vt,{open:e,onOpenChange:r,children:t.jsxs(ft,{className:"max-w-lg",children:[t.jsx(mt,{children:t.jsxs(pt,{className:"flex items-center gap-2",children:[n==="directory"?t.jsx(Xr,{className:"w-5 h-5"}):t.jsx(kp,{className:"w-5 h-5"}),c]})}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Oe,{value:v,onChange:A=>y(A.target.value),onKeyDown:P,placeholder:"Enter path...",className:"font-mono text-sm flex-1"}),t.jsx(ne,{variant:"outline",size:"icon",onClick:()=>x(j||"~"),title:"Go to home",children:t.jsx(Hg,{className:"w-4 h-4"})}),t.jsx(ne,{onClick:N,disabled:m,children:"Go"})]}),t.jsx("div",{className:"text-xs text-gray-500 font-mono truncate px-1",children:d}),g&&t.jsx("div",{className:"text-sm text-red-600 bg-red-50 p-2 rounded",children:g}),t.jsx(Js,{className:"h-64 border rounded-lg",children:m?t.jsx("div",{className:"flex items-center justify-center h-full",children:t.jsx(Qe,{className:"w-6 h-6 animate-spin text-gray-400"})}):t.jsx("div",{className:"p-1",children:u.length===0?t.jsx("div",{className:"text-sm text-gray-500 p-4 text-center",children:n==="directory"?"No subdirectories":"No files found"}):u.map((A,E)=>t.jsxs("button",{onClick:()=>b(A),className:"w-full flex items-center gap-2 px-3 py-2 text-sm hover:bg-gray-100 dark:hover:bg-slate-800 rounded transition-colors text-left",children:[A.type==="directory"?t.jsx(Xr,{className:"w-4 h-4 text-blue-500 flex-shrink-0"}):t.jsx(kp,{className:"w-4 h-4 text-gray-400 flex-shrink-0"}),t.jsx("span",{className:`flex-1 truncate ${A.isParent?"text-gray-500":""}`,children:A.name}),A.type==="directory"&&!A.isParent&&t.jsx(Qr,{className:"w-4 h-4 text-gray-400"})]},E))})})]}),t.jsxs(St,{children:[t.jsx(ne,{variant:"outline",onClick:()=>r(!1),children:"Cancel"}),t.jsx(ne,{onClick:S,disabled:!d,children:n==="directory"?"Select Folder":"Select"})]})]})})}var yh="Switch",[B6]=Ls(yh),[$6,H6]=B6(yh),W1=_.forwardRef((e,r)=>{const{__scopeSwitch:s,name:n,checked:o,defaultChecked:c,required:d,disabled:l,value:u="on",onCheckedChange:f,form:m,...h}=e,[g,w]=_.useState(null),j=bt(r,b=>w(b)),k=_.useRef(!1),v=g?m||!!g.closest("form"):!0,[y,x]=Xn({prop:o,defaultProp:c??!1,onChange:f,caller:yh});return t.jsxs($6,{scope:s,checked:y,disabled:l,children:[t.jsx(ot.button,{type:"button",role:"switch","aria-checked":y,"aria-required":d,"data-state":q1(y),"data-disabled":l?"":void 0,disabled:l,value:u,...h,ref:j,onClick:Be(e.onClick,b=>{x(S=>!S),v&&(k.current=b.isPropagationStopped(),k.current||b.stopPropagation())})}),v&&t.jsx(G1,{control:g,bubbles:!k.current,name:n,value:u,checked:y,required:d,disabled:l,form:m,style:{transform:"translateX(-100%)"}})]})});W1.displayName=yh;var U1="SwitchThumb",V1=_.forwardRef((e,r)=>{const{__scopeSwitch:s,...n}=e,o=H6(U1,s);return t.jsx(ot.span,{"data-state":q1(o.checked),"data-disabled":o.disabled?"":void 0,...n,ref:r})});V1.displayName=U1;var z6="SwitchBubbleInput",G1=_.forwardRef(({__scopeSwitch:e,control:r,checked:s,bubbles:n=!0,...o},c)=>{const d=_.useRef(null),l=bt(d,c),u=ox(s),f=ax(r);return _.useEffect(()=>{const m=d.current;if(!m)return;const h=window.HTMLInputElement.prototype,w=Object.getOwnPropertyDescriptor(h,"checked").set;if(u!==s&&w){const j=new Event("click",{bubbles:n});w.call(m,s),m.dispatchEvent(j)}},[u,s,n]),t.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:s,...o,tabIndex:-1,ref:l,style:{...o.style,...f,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});G1.displayName=z6;function q1(e){return e?"checked":"unchecked"}var K1=W1,W6=V1;const xt=_.forwardRef(({className:e,...r},s)=>t.jsx(K1,{className:Ee("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...r,ref:s,children:t.jsx(W6,{className:Ee("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));xt.displayName=K1.displayName;var $m="rovingFocusGroup.onEntryFocus",U6={bubbles:!1,cancelable:!0},$c="RovingFocusGroup",[Fp,Y1,V6]=dx($c),[G6,bh]=Ls($c,[V6]),[q6,K6]=G6($c),X1=_.forwardRef((e,r)=>t.jsx(Fp.Provider,{scope:e.__scopeRovingFocusGroup,children:t.jsx(Fp.Slot,{scope:e.__scopeRovingFocusGroup,children:t.jsx(Y6,{...e,ref:r})})}));X1.displayName=$c;var Y6=_.forwardRef((e,r)=>{const{__scopeRovingFocusGroup:s,orientation:n,loop:o=!1,dir:c,currentTabStopId:d,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:u,onEntryFocus:f,preventScrollOnEntryFocus:m=!1,...h}=e,g=_.useRef(null),w=bt(r,g),j=Dc(c),[k,v]=Xn({prop:d,defaultProp:l??null,onChange:u,caller:$c}),[y,x]=_.useState(!1),b=Jr(f),S=Y1(s),N=_.useRef(!1),[P,A]=_.useState(0);return _.useEffect(()=>{const E=g.current;if(E)return E.addEventListener($m,b),()=>E.removeEventListener($m,b)},[b]),t.jsx(q6,{scope:s,orientation:n,dir:j,loop:o,currentTabStopId:k,onItemFocus:_.useCallback(E=>v(E),[v]),onItemShiftTab:_.useCallback(()=>x(!0),[]),onFocusableItemAdd:_.useCallback(()=>A(E=>E+1),[]),onFocusableItemRemove:_.useCallback(()=>A(E=>E-1),[]),children:t.jsx(ot.div,{tabIndex:y||P===0?-1:0,"data-orientation":n,...h,ref:w,style:{outline:"none",...e.style},onMouseDown:Be(e.onMouseDown,()=>{N.current=!0}),onFocus:Be(e.onFocus,E=>{const M=!N.current;if(E.target===E.currentTarget&&M&&!y){const I=new CustomEvent($m,U6);if(E.currentTarget.dispatchEvent(I),!I.defaultPrevented){const B=S().filter(H=>H.focusable),U=B.find(H=>H.active),V=B.find(H=>H.id===k),z=[U,V,...B].filter(Boolean).map(H=>H.ref.current);Z1(z,m)}}N.current=!1}),onBlur:Be(e.onBlur,()=>x(!1))})})}),J1="RovingFocusGroupItem",Q1=_.forwardRef((e,r)=>{const{__scopeRovingFocusGroup:s,focusable:n=!0,active:o=!1,tabStopId:c,children:d,...l}=e,u=dn(),f=c||u,m=K6(J1,s),h=m.currentTabStopId===f,g=Y1(s),{onFocusableItemAdd:w,onFocusableItemRemove:j,currentTabStopId:k}=m;return _.useEffect(()=>{if(n)return w(),()=>j()},[n,w,j]),t.jsx(Fp.ItemSlot,{scope:s,id:f,focusable:n,active:o,children:t.jsx(ot.span,{tabIndex:h?0:-1,"data-orientation":m.orientation,...l,ref:r,onMouseDown:Be(e.onMouseDown,v=>{n?m.onItemFocus(f):v.preventDefault()}),onFocus:Be(e.onFocus,()=>m.onItemFocus(f)),onKeyDown:Be(e.onKeyDown,v=>{if(v.key==="Tab"&&v.shiftKey){m.onItemShiftTab();return}if(v.target!==v.currentTarget)return;const y=Q6(v,m.orientation,m.dir);if(y!==void 0){if(v.metaKey||v.ctrlKey||v.altKey||v.shiftKey)return;v.preventDefault();let b=g().filter(S=>S.focusable).map(S=>S.ref.current);if(y==="last")b.reverse();else if(y==="prev"||y==="next"){y==="prev"&&b.reverse();const S=b.indexOf(v.currentTarget);b=m.loop?Z6(b,S+1):b.slice(S+1)}setTimeout(()=>Z1(b))}}),children:typeof d=="function"?d({isCurrentTabStop:h,hasTabStop:k!=null}):d})})});Q1.displayName=J1;var X6={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function J6(e,r){return r!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function Q6(e,r,s){const n=J6(e.key,s);if(!(r==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(r==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return X6[n]}function Z1(e,r=!1){const s=document.activeElement;for(const n of e)if(n===s||(n.focus({preventScroll:r}),document.activeElement!==s))return}function Z6(e,r){return e.map((s,n)=>e[(r+n)%e.length])}var ej=X1,tj=Q1;function eF(e){const r=tF(e),s=_.forwardRef((n,o)=>{const{children:c,...d}=n,l=_.Children.toArray(c),u=l.find(sF);if(u){const f=u.props.children,m=l.map(h=>h===u?_.Children.count(f)>1?_.Children.only(null):_.isValidElement(f)?f.props.children:null:h);return t.jsx(r,{...d,ref:o,children:_.isValidElement(f)?_.cloneElement(f,void 0,m):null})}return t.jsx(r,{...d,ref:o,children:c})});return s.displayName=`${e}.Slot`,s}function tF(e){const r=_.forwardRef((s,n)=>{const{children:o,...c}=s;if(_.isValidElement(o)){const d=iF(o),l=nF(c,o.props);return o.type!==_.Fragment&&(l.ref=n?_i(n,d):d),_.cloneElement(o,l)}return _.Children.count(o)>1?_.Children.only(null):null});return r.displayName=`${e}.SlotClone`,r}var rF=Symbol("radix.slottable");function sF(e){return _.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===rF}function nF(e,r){const s={...r};for(const n in r){const o=e[n],c=r[n];/^on[A-Z]/.test(n)?o&&c?s[n]=(...l)=>{const u=c(...l);return o(...l),u}:o&&(s[n]=o):n==="style"?s[n]={...o,...c}:n==="className"&&(s[n]=[o,c].filter(Boolean).join(" "))}return{...e,...s}}function iF(e){var n,o;let r=(n=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:n.get,s=r&&"isReactWarning"in r&&r.isReactWarning;return s?e.ref:(r=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,s=r&&"isReactWarning"in r&&r.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}var Bp=["Enter"," "],oF=["ArrowDown","PageUp","Home"],rj=["ArrowUp","PageDown","End"],aF=[...oF,...rj],lF={ltr:[...Bp,"ArrowRight"],rtl:[...Bp,"ArrowLeft"]},cF={ltr:["ArrowLeft"],rtl:["ArrowRight"]},Hc="Menu",[bc,dF,uF]=dx(Hc),[Qo,sj]=Ls(Hc,[uF,dl,bh]),wh=dl(),nj=bh(),[hF,Zo]=Qo(Hc),[fF,zc]=Qo(Hc),ij=e=>{const{__scopeMenu:r,open:s=!1,children:n,dir:o,onOpenChange:c,modal:d=!0}=e,l=wh(r),[u,f]=_.useState(null),m=_.useRef(!1),h=Jr(c),g=Dc(o);return _.useEffect(()=>{const w=()=>{m.current=!0,document.addEventListener("pointerdown",j,{capture:!0,once:!0}),document.addEventListener("pointermove",j,{capture:!0,once:!0})},j=()=>m.current=!1;return document.addEventListener("keydown",w,{capture:!0}),()=>{document.removeEventListener("keydown",w,{capture:!0}),document.removeEventListener("pointerdown",j,{capture:!0}),document.removeEventListener("pointermove",j,{capture:!0})}},[]),t.jsx(yx,{...l,children:t.jsx(hF,{scope:r,open:s,onOpenChange:h,content:u,onContentChange:f,children:t.jsx(fF,{scope:r,onClose:_.useCallback(()=>h(!1),[h]),isUsingKeyboardRef:m,dir:g,modal:d,children:n})})})};ij.displayName=Hc;var mF="MenuAnchor",Cx=_.forwardRef((e,r)=>{const{__scopeMenu:s,...n}=e,o=wh(s);return t.jsx(bx,{...o,...n,ref:r})});Cx.displayName=mF;var jx="MenuPortal",[pF,oj]=Qo(jx,{forceMount:void 0}),aj=e=>{const{__scopeMenu:r,forceMount:s,children:n,container:o}=e,c=Zo(jx,r);return t.jsx(pF,{scope:r,forceMount:s,children:t.jsx(es,{present:s||c.open,children:t.jsx(Oc,{asChild:!0,container:o,children:n})})})};aj.displayName=jx;var un="MenuContent",[gF,Nx]=Qo(un),lj=_.forwardRef((e,r)=>{const s=oj(un,e.__scopeMenu),{forceMount:n=s.forceMount,...o}=e,c=Zo(un,e.__scopeMenu),d=zc(un,e.__scopeMenu);return t.jsx(bc.Provider,{scope:e.__scopeMenu,children:t.jsx(es,{present:n||c.open,children:t.jsx(bc.Slot,{scope:e.__scopeMenu,children:d.modal?t.jsx(xF,{...o,ref:r}):t.jsx(vF,{...o,ref:r})})})})}),xF=_.forwardRef((e,r)=>{const s=Zo(un,e.__scopeMenu),n=_.useRef(null),o=bt(r,n);return _.useEffect(()=>{const c=n.current;if(c)return Jg(c)},[]),t.jsx(Ex,{...e,ref:o,trapFocus:s.open,disableOutsidePointerEvents:s.open,disableOutsideScroll:!0,onFocusOutside:Be(e.onFocusOutside,c=>c.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>s.onOpenChange(!1)})}),vF=_.forwardRef((e,r)=>{const s=Zo(un,e.__scopeMenu);return t.jsx(Ex,{...e,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>s.onOpenChange(!1)})}),yF=eF("MenuContent.ScrollLock"),Ex=_.forwardRef((e,r)=>{const{__scopeMenu:s,loop:n=!1,trapFocus:o,onOpenAutoFocus:c,onCloseAutoFocus:d,disableOutsidePointerEvents:l,onEntryFocus:u,onEscapeKeyDown:f,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:g,onDismiss:w,disableOutsideScroll:j,...k}=e,v=Zo(un,s),y=zc(un,s),x=wh(s),b=nj(s),S=dF(s),[N,P]=_.useState(null),A=_.useRef(null),E=bt(r,A,v.onContentChange),M=_.useRef(0),I=_.useRef(""),B=_.useRef(0),U=_.useRef(null),V=_.useRef("right"),Q=_.useRef(0),z=j?ch:_.Fragment,H=j?{as:yF,allowPinchZoom:!0}:void 0,Y=O=>{var J,W;const T=I.current+O,F=S().filter(le=>!le.disabled),$=document.activeElement,D=(J=F.find(le=>le.ref.current===$))==null?void 0:J.textValue,X=F.map(le=>le.textValue),te=TF(X,T,D),fe=(W=F.find(le=>le.textValue===te))==null?void 0:W.ref.current;(function le(ae){I.current=ae,window.clearTimeout(M.current),ae!==""&&(M.current=window.setTimeout(()=>le(""),1e3))})(T),fe&&setTimeout(()=>fe.focus())};_.useEffect(()=>()=>window.clearTimeout(M.current),[]),Xg();const K=_.useCallback(O=>{var F,$;return V.current===((F=U.current)==null?void 0:F.side)&&MF(O,($=U.current)==null?void 0:$.area)},[]);return t.jsx(gF,{scope:s,searchRef:I,onItemEnter:_.useCallback(O=>{K(O)&&O.preventDefault()},[K]),onItemLeave:_.useCallback(O=>{var T;K(O)||((T=A.current)==null||T.focus(),P(null))},[K]),onTriggerLeave:_.useCallback(O=>{K(O)&&O.preventDefault()},[K]),pointerGraceTimerRef:B,onPointerGraceIntentChange:_.useCallback(O=>{U.current=O},[]),children:t.jsx(z,{...H,children:t.jsx(ah,{asChild:!0,trapped:o,onMountAutoFocus:Be(c,O=>{var T;O.preventDefault(),(T=A.current)==null||T.focus({preventScroll:!0})}),onUnmountAutoFocus:d,children:t.jsx(Lc,{asChild:!0,disableOutsidePointerEvents:l,onEscapeKeyDown:f,onPointerDownOutside:m,onFocusOutside:h,onInteractOutside:g,onDismiss:w,children:t.jsx(ej,{asChild:!0,...b,dir:y.dir,orientation:"vertical",loop:n,currentTabStopId:N,onCurrentTabStopIdChange:P,onEntryFocus:Be(u,O=>{y.isUsingKeyboardRef.current||O.preventDefault()}),preventScrollOnEntryFocus:!0,children:t.jsx(wx,{role:"menu","aria-orientation":"vertical","data-state":Sj(v.open),"data-radix-menu-content":"",dir:y.dir,...x,...k,ref:E,style:{outline:"none",...k.style},onKeyDown:Be(k.onKeyDown,O=>{const F=O.target.closest("[data-radix-menu-content]")===O.currentTarget,$=O.ctrlKey||O.altKey||O.metaKey,D=O.key.length===1;F&&(O.key==="Tab"&&O.preventDefault(),!$&&D&&Y(O.key));const X=A.current;if(O.target!==X||!aF.includes(O.key))return;O.preventDefault();const fe=S().filter(J=>!J.disabled).map(J=>J.ref.current);rj.includes(O.key)&&fe.reverse(),PF(fe)}),onBlur:Be(e.onBlur,O=>{O.currentTarget.contains(O.target)||(window.clearTimeout(M.current),I.current="")}),onPointerMove:Be(e.onPointerMove,wc(O=>{const T=O.target,F=Q.current!==O.clientX;if(O.currentTarget.contains(T)&&F){const $=O.clientX>Q.current?"right":"left";V.current=$,Q.current=O.clientX}}))})})})})})})});lj.displayName=un;var bF="MenuGroup",Px=_.forwardRef((e,r)=>{const{__scopeMenu:s,...n}=e;return t.jsx(ot.div,{role:"group",...n,ref:r})});Px.displayName=bF;var wF="MenuLabel",cj=_.forwardRef((e,r)=>{const{__scopeMenu:s,...n}=e;return t.jsx(ot.div,{...n,ref:r})});cj.displayName=wF;var Wu="MenuItem",jw="menu.itemSelect",_h=_.forwardRef((e,r)=>{const{disabled:s=!1,onSelect:n,...o}=e,c=_.useRef(null),d=zc(Wu,e.__scopeMenu),l=Nx(Wu,e.__scopeMenu),u=bt(r,c),f=_.useRef(!1),m=()=>{const h=c.current;if(!s&&h){const g=new CustomEvent(jw,{bubbles:!0,cancelable:!0});h.addEventListener(jw,w=>n==null?void 0:n(w),{once:!0}),BS(h,g),g.defaultPrevented?f.current=!1:d.onClose()}};return t.jsx(dj,{...o,ref:u,disabled:s,onClick:Be(e.onClick,m),onPointerDown:h=>{var g;(g=e.onPointerDown)==null||g.call(e,h),f.current=!0},onPointerUp:Be(e.onPointerUp,h=>{var g;f.current||(g=h.currentTarget)==null||g.click()}),onKeyDown:Be(e.onKeyDown,h=>{const g=l.searchRef.current!=="";s||g&&h.key===" "||Bp.includes(h.key)&&(h.currentTarget.click(),h.preventDefault())})})});_h.displayName=Wu;var dj=_.forwardRef((e,r)=>{const{__scopeMenu:s,disabled:n=!1,textValue:o,...c}=e,d=Nx(Wu,s),l=nj(s),u=_.useRef(null),f=bt(r,u),[m,h]=_.useState(!1),[g,w]=_.useState("");return _.useEffect(()=>{const j=u.current;j&&w((j.textContent??"").trim())},[c.children]),t.jsx(bc.ItemSlot,{scope:s,disabled:n,textValue:o??g,children:t.jsx(tj,{asChild:!0,...l,focusable:!n,children:t.jsx(ot.div,{role:"menuitem","data-highlighted":m?"":void 0,"aria-disabled":n||void 0,"data-disabled":n?"":void 0,...c,ref:f,onPointerMove:Be(e.onPointerMove,wc(j=>{n?d.onItemLeave(j):(d.onItemEnter(j),j.defaultPrevented||j.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Be(e.onPointerLeave,wc(j=>d.onItemLeave(j))),onFocus:Be(e.onFocus,()=>h(!0)),onBlur:Be(e.onBlur,()=>h(!1))})})})}),_F="MenuCheckboxItem",uj=_.forwardRef((e,r)=>{const{checked:s=!1,onCheckedChange:n,...o}=e;return t.jsx(gj,{scope:e.__scopeMenu,checked:s,children:t.jsx(_h,{role:"menuitemcheckbox","aria-checked":Uu(s)?"mixed":s,...o,ref:r,"data-state":Tx(s),onSelect:Be(o.onSelect,()=>n==null?void 0:n(Uu(s)?!0:!s),{checkForDefaultPrevented:!1})})})});uj.displayName=_F;var hj="MenuRadioGroup",[kF,SF]=Qo(hj,{value:void 0,onValueChange:()=>{}}),fj=_.forwardRef((e,r)=>{const{value:s,onValueChange:n,...o}=e,c=Jr(n);return t.jsx(kF,{scope:e.__scopeMenu,value:s,onValueChange:c,children:t.jsx(Px,{...o,ref:r})})});fj.displayName=hj;var mj="MenuRadioItem",pj=_.forwardRef((e,r)=>{const{value:s,...n}=e,o=SF(mj,e.__scopeMenu),c=s===o.value;return t.jsx(gj,{scope:e.__scopeMenu,checked:c,children:t.jsx(_h,{role:"menuitemradio","aria-checked":c,...n,ref:r,"data-state":Tx(c),onSelect:Be(n.onSelect,()=>{var d;return(d=o.onValueChange)==null?void 0:d.call(o,s)},{checkForDefaultPrevented:!1})})})});pj.displayName=mj;var Ax="MenuItemIndicator",[gj,CF]=Qo(Ax,{checked:!1}),xj=_.forwardRef((e,r)=>{const{__scopeMenu:s,forceMount:n,...o}=e,c=CF(Ax,s);return t.jsx(es,{present:n||Uu(c.checked)||c.checked===!0,children:t.jsx(ot.span,{...o,ref:r,"data-state":Tx(c.checked)})})});xj.displayName=Ax;var jF="MenuSeparator",vj=_.forwardRef((e,r)=>{const{__scopeMenu:s,...n}=e;return t.jsx(ot.div,{role:"separator","aria-orientation":"horizontal",...n,ref:r})});vj.displayName=jF;var NF="MenuArrow",yj=_.forwardRef((e,r)=>{const{__scopeMenu:s,...n}=e,o=wh(s);return t.jsx(_x,{...o,...n,ref:r})});yj.displayName=NF;var EF="MenuSub",[bU,bj]=Qo(EF),ic="MenuSubTrigger",wj=_.forwardRef((e,r)=>{const s=Zo(ic,e.__scopeMenu),n=zc(ic,e.__scopeMenu),o=bj(ic,e.__scopeMenu),c=Nx(ic,e.__scopeMenu),d=_.useRef(null),{pointerGraceTimerRef:l,onPointerGraceIntentChange:u}=c,f={__scopeMenu:e.__scopeMenu},m=_.useCallback(()=>{d.current&&window.clearTimeout(d.current),d.current=null},[]);return _.useEffect(()=>m,[m]),_.useEffect(()=>{const h=l.current;return()=>{window.clearTimeout(h),u(null)}},[l,u]),t.jsx(Cx,{asChild:!0,...f,children:t.jsx(dj,{id:o.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":o.contentId,"data-state":Sj(s.open),...e,ref:_i(r,o.onTriggerChange),onClick:h=>{var g;(g=e.onClick)==null||g.call(e,h),!(e.disabled||h.defaultPrevented)&&(h.currentTarget.focus(),s.open||s.onOpenChange(!0))},onPointerMove:Be(e.onPointerMove,wc(h=>{c.onItemEnter(h),!h.defaultPrevented&&!e.disabled&&!s.open&&!d.current&&(c.onPointerGraceIntentChange(null),d.current=window.setTimeout(()=>{s.onOpenChange(!0),m()},100))})),onPointerLeave:Be(e.onPointerLeave,wc(h=>{var w,j;m();const g=(w=s.content)==null?void 0:w.getBoundingClientRect();if(g){const k=(j=s.content)==null?void 0:j.dataset.side,v=k==="right",y=v?-5:5,x=g[v?"left":"right"],b=g[v?"right":"left"];c.onPointerGraceIntentChange({area:[{x:h.clientX+y,y:h.clientY},{x,y:g.top},{x:b,y:g.top},{x:b,y:g.bottom},{x,y:g.bottom}],side:k}),window.clearTimeout(l.current),l.current=window.setTimeout(()=>c.onPointerGraceIntentChange(null),300)}else{if(c.onTriggerLeave(h),h.defaultPrevented)return;c.onPointerGraceIntentChange(null)}})),onKeyDown:Be(e.onKeyDown,h=>{var w;const g=c.searchRef.current!=="";e.disabled||g&&h.key===" "||lF[n.dir].includes(h.key)&&(s.onOpenChange(!0),(w=s.content)==null||w.focus(),h.preventDefault())})})})});wj.displayName=ic;var _j="MenuSubContent",kj=_.forwardRef((e,r)=>{const s=oj(un,e.__scopeMenu),{forceMount:n=s.forceMount,...o}=e,c=Zo(un,e.__scopeMenu),d=zc(un,e.__scopeMenu),l=bj(_j,e.__scopeMenu),u=_.useRef(null),f=bt(r,u);return t.jsx(bc.Provider,{scope:e.__scopeMenu,children:t.jsx(es,{present:n||c.open,children:t.jsx(bc.Slot,{scope:e.__scopeMenu,children:t.jsx(Ex,{id:l.contentId,"aria-labelledby":l.triggerId,...o,ref:f,align:"start",side:d.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:m=>{var h;d.isUsingKeyboardRef.current&&((h=u.current)==null||h.focus()),m.preventDefault()},onCloseAutoFocus:m=>m.preventDefault(),onFocusOutside:Be(e.onFocusOutside,m=>{m.target!==l.trigger&&c.onOpenChange(!1)}),onEscapeKeyDown:Be(e.onEscapeKeyDown,m=>{d.onClose(),m.preventDefault()}),onKeyDown:Be(e.onKeyDown,m=>{var w;const h=m.currentTarget.contains(m.target),g=cF[d.dir].includes(m.key);h&&g&&(c.onOpenChange(!1),(w=l.trigger)==null||w.focus(),m.preventDefault())})})})})})});kj.displayName=_j;function Sj(e){return e?"open":"closed"}function Uu(e){return e==="indeterminate"}function Tx(e){return Uu(e)?"indeterminate":e?"checked":"unchecked"}function PF(e){const r=document.activeElement;for(const s of e)if(s===r||(s.focus(),document.activeElement!==r))return}function AF(e,r){return e.map((s,n)=>e[(r+n)%e.length])}function TF(e,r,s){const o=r.length>1&&Array.from(r).every(f=>f===r[0])?r[0]:r,c=s?e.indexOf(s):-1;let d=AF(e,Math.max(c,0));o.length===1&&(d=d.filter(f=>f!==s));const u=d.find(f=>f.toLowerCase().startsWith(o.toLowerCase()));return u!==s?u:void 0}function RF(e,r){const{x:s,y:n}=e;let o=!1;for(let c=0,d=r.length-1;c<r.length;d=c++){const l=r[c],u=r[d],f=l.x,m=l.y,h=u.x,g=u.y;m>n!=g>n&&s<(h-f)*(n-m)/(g-m)+f&&(o=!o)}return o}function MF(e,r){if(!r)return!1;const s={x:e.clientX,y:e.clientY};return RF(s,r)}function wc(e){return r=>r.pointerType==="mouse"?e(r):void 0}var IF=ij,DF=Cx,LF=aj,OF=lj,FF=Px,BF=cj,$F=_h,HF=uj,zF=fj,WF=pj,UF=xj,VF=vj,GF=yj,qF=wj,KF=kj,kh="DropdownMenu",[YF]=Ls(kh,[sj]),_s=sj(),[XF,Cj]=YF(kh),jj=e=>{const{__scopeDropdownMenu:r,children:s,dir:n,open:o,defaultOpen:c,onOpenChange:d,modal:l=!0}=e,u=_s(r),f=_.useRef(null),[m,h]=Xn({prop:o,defaultProp:c??!1,onChange:d,caller:kh});return t.jsx(XF,{scope:r,triggerId:dn(),triggerRef:f,contentId:dn(),open:m,onOpenChange:h,onOpenToggle:_.useCallback(()=>h(g=>!g),[h]),modal:l,children:t.jsx(IF,{...u,open:m,onOpenChange:h,dir:n,modal:l,children:s})})};jj.displayName=kh;var Nj="DropdownMenuTrigger",Ej=_.forwardRef((e,r)=>{const{__scopeDropdownMenu:s,disabled:n=!1,...o}=e,c=Cj(Nj,s),d=_s(s);return t.jsx(DF,{asChild:!0,...d,children:t.jsx(ot.button,{type:"button",id:c.triggerId,"aria-haspopup":"menu","aria-expanded":c.open,"aria-controls":c.open?c.contentId:void 0,"data-state":c.open?"open":"closed","data-disabled":n?"":void 0,disabled:n,...o,ref:_i(r,c.triggerRef),onPointerDown:Be(e.onPointerDown,l=>{!n&&l.button===0&&l.ctrlKey===!1&&(c.onOpenToggle(),c.open||l.preventDefault())}),onKeyDown:Be(e.onKeyDown,l=>{n||(["Enter"," "].includes(l.key)&&c.onOpenToggle(),l.key==="ArrowDown"&&c.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(l.key)&&l.preventDefault())})})})});Ej.displayName=Nj;var JF="DropdownMenuPortal",Pj=e=>{const{__scopeDropdownMenu:r,...s}=e,n=_s(r);return t.jsx(LF,{...n,...s})};Pj.displayName=JF;var Aj="DropdownMenuContent",Tj=_.forwardRef((e,r)=>{const{__scopeDropdownMenu:s,...n}=e,o=Cj(Aj,s),c=_s(s),d=_.useRef(!1);return t.jsx(OF,{id:o.contentId,"aria-labelledby":o.triggerId,...c,...n,ref:r,onCloseAutoFocus:Be(e.onCloseAutoFocus,l=>{var u;d.current||(u=o.triggerRef.current)==null||u.focus(),d.current=!1,l.preventDefault()}),onInteractOutside:Be(e.onInteractOutside,l=>{const u=l.detail.originalEvent,f=u.button===0&&u.ctrlKey===!0,m=u.button===2||f;(!o.modal||m)&&(d.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Tj.displayName=Aj;var QF="DropdownMenuGroup",ZF=_.forwardRef((e,r)=>{const{__scopeDropdownMenu:s,...n}=e,o=_s(s);return t.jsx(FF,{...o,...n,ref:r})});ZF.displayName=QF;var eB="DropdownMenuLabel",Rj=_.forwardRef((e,r)=>{const{__scopeDropdownMenu:s,...n}=e,o=_s(s);return t.jsx(BF,{...o,...n,ref:r})});Rj.displayName=eB;var tB="DropdownMenuItem",Mj=_.forwardRef((e,r)=>{const{__scopeDropdownMenu:s,...n}=e,o=_s(s);return t.jsx($F,{...o,...n,ref:r})});Mj.displayName=tB;var rB="DropdownMenuCheckboxItem",Ij=_.forwardRef((e,r)=>{const{__scopeDropdownMenu:s,...n}=e,o=_s(s);return t.jsx(HF,{...o,...n,ref:r})});Ij.displayName=rB;var sB="DropdownMenuRadioGroup",nB=_.forwardRef((e,r)=>{const{__scopeDropdownMenu:s,...n}=e,o=_s(s);return t.jsx(zF,{...o,...n,ref:r})});nB.displayName=sB;var iB="DropdownMenuRadioItem",Dj=_.forwardRef((e,r)=>{const{__scopeDropdownMenu:s,...n}=e,o=_s(s);return t.jsx(WF,{...o,...n,ref:r})});Dj.displayName=iB;var oB="DropdownMenuItemIndicator",Lj=_.forwardRef((e,r)=>{const{__scopeDropdownMenu:s,...n}=e,o=_s(s);return t.jsx(UF,{...o,...n,ref:r})});Lj.displayName=oB;var aB="DropdownMenuSeparator",Oj=_.forwardRef((e,r)=>{const{__scopeDropdownMenu:s,...n}=e,o=_s(s);return t.jsx(VF,{...o,...n,ref:r})});Oj.displayName=aB;var lB="DropdownMenuArrow",cB=_.forwardRef((e,r)=>{const{__scopeDropdownMenu:s,...n}=e,o=_s(s);return t.jsx(GF,{...o,...n,ref:r})});cB.displayName=lB;var dB="DropdownMenuSubTrigger",Fj=_.forwardRef((e,r)=>{const{__scopeDropdownMenu:s,...n}=e,o=_s(s);return t.jsx(qF,{...o,...n,ref:r})});Fj.displayName=dB;var uB="DropdownMenuSubContent",Bj=_.forwardRef((e,r)=>{const{__scopeDropdownMenu:s,...n}=e,o=_s(s);return t.jsx(KF,{...o,...n,ref:r,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});Bj.displayName=uB;var hB=jj,fB=Ej,mB=Pj,$j=Tj,Hj=Rj,zj=Mj,Wj=Ij,Uj=Dj,Vj=Lj,Gj=Oj,qj=Fj,Kj=Bj;const En=hB,Pn=fB,pB=_.forwardRef(({className:e,inset:r,children:s,...n},o)=>t.jsxs(qj,{ref:o,className:Ee("flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",r&&"pl-8",e),...n,children:[s,t.jsx(Qr,{className:"ml-auto"})]}));pB.displayName=qj.displayName;const gB=_.forwardRef(({className:e,...r},s)=>t.jsx(Kj,{ref:s,className:Ee("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...r}));gB.displayName=Kj.displayName;const hn=_.forwardRef(({className:e,sideOffset:r=4,...s},n)=>t.jsx(mB,{children:t.jsx($j,{ref:n,sideOffset:r,className:Ee("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...s})}));hn.displayName=$j.displayName;const jt=_.forwardRef(({className:e,inset:r,...s},n)=>t.jsx(zj,{ref:n,className:Ee("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-4 [&>svg]:shrink-0",r&&"pl-8",e),...s}));jt.displayName=zj.displayName;const _c=_.forwardRef(({className:e,children:r,checked:s,...n},o)=>t.jsxs(Wj,{ref:o,className:Ee("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:s,...n,children:[t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(Vj,{children:t.jsx(It,{className:"h-4 w-4"})})}),r]}));_c.displayName=Wj.displayName;const xB=_.forwardRef(({className:e,children:r,...s},n)=>t.jsxs(Uj,{ref:n,className:Ee("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...s,children:[t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(Vj,{children:t.jsx(KM,{className:"h-2 w-2 fill-current"})})}),r]}));xB.displayName=Uj.displayName;const kc=_.forwardRef(({className:e,inset:r,...s},n)=>t.jsx(Hj,{ref:n,className:Ee("px-2 py-1.5 text-sm font-semibold",r&&"pl-8",e),...s}));kc.displayName=Hj.displayName;const bs=_.forwardRef(({className:e,...r},s)=>t.jsx(Gj,{ref:s,className:Ee("-mx-1 my-1 h-px bg-muted",e),...r}));bs.displayName=Gj.displayName;const Nw={development:"bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",productivity:"bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400",integration:"bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-400",external:"bg-orange-100 text-orange-700 dark:bg-orange-900/30 dark:text-orange-400",lsp:"bg-cyan-100 text-cyan-700 dark:bg-cyan-900/30 dark:text-cyan-400",default:"bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-400"};function vB({plugin:e,onToggle:r,isToggling:s,projectDir:n}){const o=Nw[e.category]||Nw.default;return e.mcpServers||e.lspServers||e.commands,t.jsxs(Ua.div,{layout:!0,initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},className:`
593
593
  relative p-3 rounded-lg border transition-all
594
594
  ${e.installed?"bg-green-50 border-green-200 dark:bg-green-950/20 dark:border-green-800":"bg-white border-gray-200 dark:bg-slate-900 dark:border-slate-700 hover:border-indigo-300 dark:hover:border-indigo-700"}
595
595
  `,children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[t.jsx("h4",{className:"font-medium text-gray-900 dark:text-white truncate",children:e.name}),e.sourceType==="external"&&t.jsx(eo,{className:"w-3 h-3 text-orange-500 flex-shrink-0",title:"Community plugin"})]}),t.jsx("p",{className:"text-xs text-gray-600 dark:text-slate-400 line-clamp-2 mb-2",children:e.description||"No description"}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.category&&t.jsx(qe,{variant:"outline",className:`text-[10px] px-1.5 py-0 ${o}`,children:e.category}),e.lspServers&&t.jsxs(qe,{variant:"outline",className:"text-[10px] px-1.5 py-0 bg-cyan-50 text-cyan-700 dark:bg-cyan-900/30 dark:text-cyan-400",children:[t.jsx(Yn,{className:"w-2.5 h-2.5 mr-0.5"}),"LSP"]}),e.mcpServers&&t.jsxs(qe,{variant:"outline",className:"text-[10px] px-1.5 py-0 bg-blue-50 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400",children:[t.jsx(ws,{className:"w-2.5 h-2.5 mr-0.5"}),"MCP"]}),e.version&&t.jsxs("span",{className:"text-[10px] text-gray-400 dark:text-slate-500",children:["v",e.version]})]})]}),t.jsx("div",{className:"flex-shrink-0",children:t.jsx(xt,{checked:e.installed,onCheckedChange:()=>r(e),disabled:s===e.name,className:"data-[state=checked]:bg-green-600"})})]}),s===e.name&&t.jsx("div",{className:"absolute inset-0 bg-white/80 dark:bg-slate-900/80 rounded-lg flex items-center justify-center",children:t.jsx(Qe,{className:"w-5 h-5 animate-spin text-indigo-600"})})]})}function yB({open:e,onOpenChange:r,projectDir:s,projectName:n}){const[o,c]=_.useState(!0),[d,l]=_.useState({allPlugins:[],categories:[]}),[u,f]=_.useState(""),[m,h]=_.useState("local"),[g,w]=_.useState([]),[j,k]=_.useState(!0),[v,y]=_.useState(!0),[x,b]=_.useState(null),S=async()=>{c(!0);try{const I=await he.getPlugins();l(I)}catch(I){q.error("Failed to load plugins: "+I.message)}finally{c(!1)}};_.useEffect(()=>{e&&(S(),f(""))},[e]);const N=_.useMemo(()=>{let I=d.allPlugins||[];if(u){const B=u.toLowerCase();I=I.filter(U=>{var V,Q;return((V=U.name)==null?void 0:V.toLowerCase().includes(B))||((Q=U.description)==null?void 0:Q.toLowerCase().includes(B))})}return I=I.filter(B=>!(B.sourceType==="external"&&!j||B.sourceType==="internal"&&!v)),g.length>0&&(I=I.filter(B=>g.includes(B.category))),I.sort((B,U)=>B.installed&&!U.installed?-1:!B.installed&&U.installed?1:B.name.localeCompare(U.name)),I},[d.allPlugins,u,j,v,g]),P=I=>{w(B=>B.includes(I)?B.filter(U=>U!==I):[...B,I])},A=async I=>{b(I.name);try{if(I.installed){const B=await he.uninstallPlugin(`${I.name}@${I.marketplace}`);B.success?q.success(`Uninstalled ${I.name}`):q.error(B.error||"Failed to uninstall")}else{const B=await he.installPlugin(I.name,I.marketplace,m,s);B.success?q.success(`Installed ${I.name} (${m})`):q.error(B.error||"Failed to install")}await S()}catch(B){q.error("Operation failed: "+B.message)}finally{b(null)}},E=N.filter(I=>I.installed).length,M=N.filter(I=>!I.installed).length;return t.jsx(vt,{open:e,onOpenChange:r,children:t.jsxs(ft,{className:"max-w-2xl max-h-[85vh] flex flex-col p-0 overflow-hidden",children:[t.jsxs(mt,{className:"px-6 pt-6 pb-4 border-b dark:border-slate-800",children:[t.jsxs(pt,{className:"flex items-center gap-2",children:[t.jsx($o,{className:"w-5 h-5 text-indigo-600"}),"Install Plugins",n&&t.jsx(qe,{variant:"outline",className:"ml-2 font-normal",children:n})]}),t.jsx(Gt,{children:"Enable plugins for enhanced Claude Code capabilities"})]}),t.jsxs("div",{className:"px-6 py-3 border-b dark:border-slate-800 space-y-3 bg-gray-50 dark:bg-slate-900/50",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs("div",{className:"relative flex-1",children:[t.jsx(Ic,{className:"w-4 h-4 absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),t.jsx(Oe,{value:u,onChange:I=>f(I.target.value),placeholder:"Search plugins...",className:"pl-9 h-9 bg-white dark:bg-slate-800"})]}),t.jsxs(ir,{value:m,onValueChange:h,children:[t.jsx(Qt,{className:"w-36 h-9 bg-white dark:bg-slate-800",children:t.jsx(or,{})}),t.jsxs(Zt,{children:[t.jsx(gt,{value:"local",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(fS,{className:"w-3.5 h-3.5"}),"Local (this project)"]})}),t.jsx(gt,{value:"user",children:t.jsxs("span",{className:"flex items-center gap-2",children:[t.jsx(eo,{className:"w-3.5 h-3.5"}),"User (all projects)"]})})]})]})]}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs(En,{children:[t.jsx(Pn,{asChild:!0,children:t.jsxs(ne,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",children:[t.jsx($g,{className:"w-3 h-3"}),"Category",g.length>0&&t.jsx(qe,{variant:"secondary",className:"ml-1 h-4 px-1 text-[10px]",children:g.length}),t.jsx(hr,{className:"w-3 h-3 ml-1"})]})}),t.jsxs(hn,{align:"start",className:"w-48",children:[t.jsx(kc,{className:"text-xs",children:"Categories"}),t.jsx(bs,{}),(d.categories||[]).map(I=>t.jsx(_c,{checked:g.includes(I),onCheckedChange:()=>P(I),children:I},I)),g.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(bs,{}),t.jsx(_c,{checked:!1,onCheckedChange:()=>w([]),children:"Clear all"})]})]})]}),t.jsxs("div",{className:"flex items-center gap-3 ml-auto text-xs",children:[t.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[t.jsx(xt,{checked:v,onCheckedChange:y,className:"h-4 w-7 data-[state=checked]:bg-blue-600"}),t.jsx("span",{className:"text-gray-600 dark:text-slate-400",children:"Anthropic"})]}),t.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[t.jsx(xt,{checked:j,onCheckedChange:k,className:"h-4 w-7 data-[state=checked]:bg-orange-600"}),t.jsx("span",{className:"text-gray-600 dark:text-slate-400",children:"Community"})]})]})]}),t.jsxs("div",{className:"flex items-center gap-4 text-xs text-gray-500 dark:text-slate-500",children:[t.jsxs("span",{className:"flex items-center gap-1",children:[t.jsx(It,{className:"w-3 h-3 text-green-600"}),E," installed"]}),t.jsxs("span",{children:[M," available"]}),t.jsxs("span",{className:"ml-auto",children:[N.length," shown"]})]})]}),t.jsx(Js,{className:"flex-1 min-h-0 px-6 py-4",children:o?t.jsx("div",{className:"flex items-center justify-center py-12",children:t.jsx(Qe,{className:"w-6 h-6 animate-spin text-indigo-600"})}):N.length===0?t.jsxs("div",{className:"text-center py-12 text-gray-500 dark:text-slate-400",children:[t.jsx($o,{className:"w-10 h-10 mx-auto mb-3 opacity-30"}),t.jsx("p",{children:"No plugins found"}),u&&t.jsx(ne,{variant:"link",size:"sm",onClick:()=>f(""),className:"mt-2",children:"Clear search"})]}):t.jsx("div",{className:"grid grid-cols-1 gap-3",children:t.jsx(F_,{mode:"popLayout",children:N.map(I=>t.jsx(vB,{plugin:I,onToggle:A,isToggling:x,projectDir:s},`${I.name}@${I.marketplace}`))})})}),t.jsxs("div",{className:"px-6 py-3 border-t dark:border-slate-800 flex items-center justify-between bg-gray-50 dark:bg-slate-900/50",children:[t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-500",children:"Plugins extend Claude Code with LSP servers, MCP tools, and commands"}),t.jsx(ne,{variant:"outline",size:"sm",onClick:()=>r(!1),children:"Done"})]})]})})}var Hm={exports:{}},Ew;function bB(){return Ew||(Ew=1,(function(e,r){(function(s,n){e.exports=n()})(globalThis,(()=>(()=>{var s={4567:function(d,l,u){var f=this&&this.__decorate||function(x,b,S,N){var P,A=arguments.length,E=A<3?b:N===null?N=Object.getOwnPropertyDescriptor(b,S):N;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(x,b,S,N);else for(var M=x.length-1;M>=0;M--)(P=x[M])&&(E=(A<3?P(E):A>3?P(b,S,E):P(b,S))||E);return A>3&&E&&Object.defineProperty(b,S,E),E},m=this&&this.__param||function(x,b){return function(S,N){b(S,N,x)}};Object.defineProperty(l,"__esModule",{value:!0}),l.AccessibilityManager=void 0;const h=u(9042),g=u(9924),w=u(844),j=u(4725),k=u(2585),v=u(3656);let y=l.AccessibilityManager=class extends w.Disposable{constructor(x,b,S,N){super(),this._terminal=x,this._coreBrowserService=S,this._renderService=N,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let P=0;P<this._terminal.rows;P++)this._rowElements[P]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[P]);if(this._topBoundaryFocusListener=P=>this._handleBoundaryFocus(P,0),this._bottomBoundaryFocusListener=P=>this._handleBoundaryFocus(P,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new g.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((P=>this._handleResize(P.rows)))),this.register(this._terminal.onRender((P=>this._refreshRows(P.start,P.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((P=>this._handleChar(P)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
@@ -639,34 +639,34 @@ Co-Authored-By: AI <ai@example.com>`,className:"font-mono text-sm min-h-[80px]"}
639
639
  `}]}function X9(e,r){const s=r.value?r.value+`
640
640
  `:"",n={},o=r.lang?r.lang.split(/\s+/):[];o.length>0&&(n.className=["language-"+o[0]]);let c={type:"element",tagName:"code",properties:n,children:[{type:"text",value:s}]};return r.meta&&(c.data={meta:r.meta}),e.patch(r,c),c=e.applyData(r,c),c={type:"element",tagName:"pre",properties:{},children:[c]},e.patch(r,c),c}function J9(e,r){const s={type:"element",tagName:"del",properties:{},children:e.all(r)};return e.patch(r,s),e.applyData(r,s)}function Q9(e,r){const s={type:"element",tagName:"em",properties:{},children:e.all(r)};return e.patch(r,s),e.applyData(r,s)}function Z9(e,r){const s=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=String(r.identifier).toUpperCase(),o=ml(n.toLowerCase()),c=e.footnoteOrder.indexOf(n);let d,l=e.footnoteCounts.get(n);l===void 0?(l=0,e.footnoteOrder.push(n),d=e.footnoteOrder.length):d=c+1,l+=1,e.footnoteCounts.set(n,l);const u={type:"element",tagName:"a",properties:{href:"#"+s+"fn-"+o,id:s+"fnref-"+o+(l>1?"-"+l:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(d)}]};e.patch(r,u);const f={type:"element",tagName:"sup",properties:{},children:[u]};return e.patch(r,f),e.applyData(r,f)}function eH(e,r){const s={type:"element",tagName:"h"+r.depth,properties:{},children:e.all(r)};return e.patch(r,s),e.applyData(r,s)}function tH(e,r){if(e.options.allowDangerousHtml){const s={type:"raw",value:r.value};return e.patch(r,s),e.applyData(r,s)}}function o2(e,r){const s=r.referenceType;let n="]";if(s==="collapsed"?n+="[]":s==="full"&&(n+="["+(r.label||r.identifier)+"]"),r.type==="imageReference")return[{type:"text",value:"!["+r.alt+n}];const o=e.all(r),c=o[0];c&&c.type==="text"?c.value="["+c.value:o.unshift({type:"text",value:"["});const d=o[o.length-1];return d&&d.type==="text"?d.value+=n:o.push({type:"text",value:n}),o}function rH(e,r){const s=String(r.identifier).toUpperCase(),n=e.definitionById.get(s);if(!n)return o2(e,r);const o={src:ml(n.url||""),alt:r.alt};n.title!==null&&n.title!==void 0&&(o.title=n.title);const c={type:"element",tagName:"img",properties:o,children:[]};return e.patch(r,c),e.applyData(r,c)}function sH(e,r){const s={src:ml(r.url)};r.alt!==null&&r.alt!==void 0&&(s.alt=r.alt),r.title!==null&&r.title!==void 0&&(s.title=r.title);const n={type:"element",tagName:"img",properties:s,children:[]};return e.patch(r,n),e.applyData(r,n)}function nH(e,r){const s={type:"text",value:r.value.replace(/\r?\n|\r/g," ")};e.patch(r,s);const n={type:"element",tagName:"code",properties:{},children:[s]};return e.patch(r,n),e.applyData(r,n)}function iH(e,r){const s=String(r.identifier).toUpperCase(),n=e.definitionById.get(s);if(!n)return o2(e,r);const o={href:ml(n.url||"")};n.title!==null&&n.title!==void 0&&(o.title=n.title);const c={type:"element",tagName:"a",properties:o,children:e.all(r)};return e.patch(r,c),e.applyData(r,c)}function oH(e,r){const s={href:ml(r.url)};r.title!==null&&r.title!==void 0&&(s.title=r.title);const n={type:"element",tagName:"a",properties:s,children:e.all(r)};return e.patch(r,n),e.applyData(r,n)}function aH(e,r,s){const n=e.all(r),o=s?lH(s):a2(r),c={},d=[];if(typeof r.checked=="boolean"){const m=n[0];let h;m&&m.type==="element"&&m.tagName==="p"?h=m:(h={type:"element",tagName:"p",properties:{},children:[]},n.unshift(h)),h.children.length>0&&h.children.unshift({type:"text",value:" "}),h.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:r.checked,disabled:!0},children:[]}),c.className=["task-list-item"]}let l=-1;for(;++l<n.length;){const m=n[l];(o||l!==0||m.type!=="element"||m.tagName!=="p")&&d.push({type:"text",value:`
641
641
  `}),m.type==="element"&&m.tagName==="p"&&!o?d.push(...m.children):d.push(m)}const u=n[n.length-1];u&&(o||u.type!=="element"||u.tagName!=="p")&&d.push({type:"text",value:`
642
- `});const f={type:"element",tagName:"li",properties:c,children:d};return e.patch(r,f),e.applyData(r,f)}function lH(e){let r=!1;if(e.type==="list"){r=e.spread||!1;const s=e.children;let n=-1;for(;!r&&++n<s.length;)r=a2(s[n])}return r}function a2(e){const r=e.spread;return r??e.children.length>1}function cH(e,r){const s={},n=e.all(r);let o=-1;for(typeof r.start=="number"&&r.start!==1&&(s.start=r.start);++o<n.length;){const d=n[o];if(d.type==="element"&&d.tagName==="li"&&d.properties&&Array.isArray(d.properties.className)&&d.properties.className.includes("task-list-item")){s.className=["contains-task-list"];break}}const c={type:"element",tagName:r.ordered?"ol":"ul",properties:s,children:e.wrap(n,!0)};return e.patch(r,c),e.applyData(r,c)}function dH(e,r){const s={type:"element",tagName:"p",properties:{},children:e.all(r)};return e.patch(r,s),e.applyData(r,s)}function uH(e,r){const s={type:"root",children:e.wrap(e.all(r))};return e.patch(r,s),e.applyData(r,s)}function hH(e,r){const s={type:"element",tagName:"strong",properties:{},children:e.all(r)};return e.patch(r,s),e.applyData(r,s)}function fH(e,r){const s=e.all(r),n=s.shift(),o=[];if(n){const d={type:"element",tagName:"thead",properties:{},children:e.wrap([n],!0)};e.patch(r.children[0],d),o.push(d)}if(s.length>0){const d={type:"element",tagName:"tbody",properties:{},children:e.wrap(s,!0)},l=Hx(r.children[1]),u=HN(r.children[r.children.length-1]);l&&u&&(d.position={start:l,end:u}),o.push(d)}const c={type:"element",tagName:"table",properties:{},children:e.wrap(o,!0)};return e.patch(r,c),e.applyData(r,c)}function mH(e,r,s){const n=s?s.children:void 0,c=(n?n.indexOf(r):1)===0?"th":"td",d=s&&s.type==="table"?s.align:void 0,l=d?d.length:r.children.length;let u=-1;const f=[];for(;++u<l;){const h=r.children[u],g={},w=d?d[u]:void 0;w&&(g.align=w);let j={type:"element",tagName:c,properties:g,children:[]};h&&(j.children=e.all(h),e.patch(h,j),j=e.applyData(h,j)),f.push(j)}const m={type:"element",tagName:"tr",properties:{},children:e.wrap(f,!0)};return e.patch(r,m),e.applyData(r,m)}function pH(e,r){const s={type:"element",tagName:"td",properties:{},children:e.all(r)};return e.patch(r,s),e.applyData(r,s)}const l_=9,c_=32;function gH(e){const r=String(e),s=/\r?\n|\r/g;let n=s.exec(r),o=0;const c=[];for(;n;)c.push(d_(r.slice(o,n.index),o>0,!0),n[0]),o=n.index+n[0].length,n=s.exec(r);return c.push(d_(r.slice(o),o>0,!1)),c.join("")}function d_(e,r,s){let n=0,o=e.length;if(r){let c=e.codePointAt(n);for(;c===l_||c===c_;)n++,c=e.codePointAt(n)}if(s){let c=e.codePointAt(o-1);for(;c===l_||c===c_;)o--,c=e.codePointAt(o-1)}return o>n?e.slice(n,o):""}function xH(e,r){const s={type:"text",value:gH(String(r.value))};return e.patch(r,s),e.applyData(r,s)}function vH(e,r){const s={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(r,s),e.applyData(r,s)}const yH={blockquote:K9,break:Y9,code:X9,delete:J9,emphasis:Q9,footnoteReference:Z9,heading:eH,html:tH,imageReference:rH,image:sH,inlineCode:nH,linkReference:iH,link:oH,listItem:aH,list:cH,paragraph:dH,root:uH,strong:hH,table:fH,tableCell:pH,tableRow:mH,text:xH,thematicBreak:vH,toml:cu,yaml:cu,definition:cu,footnoteDefinition:cu};function cu(){}const l2=-1,Rh=0,hc=1,Vu=2,Kx=3,Yx=4,Xx=5,Jx=6,c2=7,d2=8,u_=typeof self=="object"?self:globalThis,bH=(e,r)=>{const s=(o,c)=>(e.set(c,o),o),n=o=>{if(e.has(o))return e.get(o);const[c,d]=r[o];switch(c){case Rh:case l2:return s(d,o);case hc:{const l=s([],o);for(const u of d)l.push(n(u));return l}case Vu:{const l=s({},o);for(const[u,f]of d)l[n(u)]=n(f);return l}case Kx:return s(new Date(d),o);case Yx:{const{source:l,flags:u}=d;return s(new RegExp(l,u),o)}case Xx:{const l=s(new Map,o);for(const[u,f]of d)l.set(n(u),n(f));return l}case Jx:{const l=s(new Set,o);for(const u of d)l.add(n(u));return l}case c2:{const{name:l,message:u}=d;return s(new u_[l](u),o)}case d2:return s(BigInt(d),o);case"BigInt":return s(Object(BigInt(d)),o);case"ArrayBuffer":return s(new Uint8Array(d).buffer,d);case"DataView":{const{buffer:l}=new Uint8Array(d);return s(new DataView(l),d)}}return s(new u_[c](d),o)};return n},h_=e=>bH(new Map,e)(0),La="",{toString:wH}={},{keys:_H}=Object,ec=e=>{const r=typeof e;if(r!=="object"||!e)return[Rh,r];const s=wH.call(e).slice(8,-1);switch(s){case"Array":return[hc,La];case"Object":return[Vu,La];case"Date":return[Kx,La];case"RegExp":return[Yx,La];case"Map":return[Xx,La];case"Set":return[Jx,La];case"DataView":return[hc,s]}return s.includes("Array")?[hc,s]:s.includes("Error")?[c2,s]:[Vu,s]},du=([e,r])=>e===Rh&&(r==="function"||r==="symbol"),kH=(e,r,s,n)=>{const o=(d,l)=>{const u=n.push(d)-1;return s.set(l,u),u},c=d=>{if(s.has(d))return s.get(d);let[l,u]=ec(d);switch(l){case Rh:{let m=d;switch(u){case"bigint":l=d2,m=d.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+u);m=null;break;case"undefined":return o([l2],d)}return o([l,m],d)}case hc:{if(u){let g=d;return u==="DataView"?g=new Uint8Array(d.buffer):u==="ArrayBuffer"&&(g=new Uint8Array(d)),o([u,[...g]],d)}const m=[],h=o([l,m],d);for(const g of d)m.push(c(g));return h}case Vu:{if(u)switch(u){case"BigInt":return o([u,d.toString()],d);case"Boolean":case"Number":case"String":return o([u,d.valueOf()],d)}if(r&&"toJSON"in d)return c(d.toJSON());const m=[],h=o([l,m],d);for(const g of _H(d))(e||!du(ec(d[g])))&&m.push([c(g),c(d[g])]);return h}case Kx:return o([l,d.toISOString()],d);case Yx:{const{source:m,flags:h}=d;return o([l,{source:m,flags:h}],d)}case Xx:{const m=[],h=o([l,m],d);for(const[g,w]of d)(e||!(du(ec(g))||du(ec(w))))&&m.push([c(g),c(w)]);return h}case Jx:{const m=[],h=o([l,m],d);for(const g of d)(e||!du(ec(g)))&&m.push(c(g));return h}}const{message:f}=d;return o([l,{name:u,message:f}],d)};return c},f_=(e,{json:r,lossy:s}={})=>{const n=[];return kH(!(r||s),!!r,new Map,n)(e),n},Gu=typeof structuredClone=="function"?(e,r)=>r&&("json"in r||"lossy"in r)?h_(f_(e,r)):structuredClone(e):(e,r)=>h_(f_(e,r));function SH(e,r){const s=[{type:"text",value:"↩"}];return r>1&&s.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(r)}]}),s}function CH(e,r){return"Back to reference "+(e+1)+(r>1?"-"+r:"")}function jH(e){const r=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",s=e.options.footnoteBackContent||SH,n=e.options.footnoteBackLabel||CH,o=e.options.footnoteLabel||"Footnotes",c=e.options.footnoteLabelTagName||"h2",d=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[];let u=-1;for(;++u<e.footnoteOrder.length;){const f=e.footnoteById.get(e.footnoteOrder[u]);if(!f)continue;const m=e.all(f),h=String(f.identifier).toUpperCase(),g=ml(h.toLowerCase());let w=0;const j=[],k=e.footnoteCounts.get(h);for(;k!==void 0&&++w<=k;){j.length>0&&j.push({type:"text",value:" "});let x=typeof s=="string"?s:s(u,w);typeof x=="string"&&(x={type:"text",value:x}),j.push({type:"element",tagName:"a",properties:{href:"#"+r+"fnref-"+g+(w>1?"-"+w:""),dataFootnoteBackref:"",ariaLabel:typeof n=="string"?n:n(u,w),className:["data-footnote-backref"]},children:Array.isArray(x)?x:[x]})}const v=m[m.length-1];if(v&&v.type==="element"&&v.tagName==="p"){const x=v.children[v.children.length-1];x&&x.type==="text"?x.value+=" ":v.children.push({type:"text",value:" "}),v.children.push(...j)}else m.push(...j);const y={type:"element",tagName:"li",properties:{id:r+"fn-"+g},children:e.wrap(m,!0)};e.patch(f,y),l.push(y)}if(l.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:c,properties:{...Gu(d),id:"footnote-label"},children:[{type:"text",value:o}]},{type:"text",value:`
642
+ `});const f={type:"element",tagName:"li",properties:c,children:d};return e.patch(r,f),e.applyData(r,f)}function lH(e){let r=!1;if(e.type==="list"){r=e.spread||!1;const s=e.children;let n=-1;for(;!r&&++n<s.length;)r=a2(s[n])}return r}function a2(e){const r=e.spread;return r??e.children.length>1}function cH(e,r){const s={},n=e.all(r);let o=-1;for(typeof r.start=="number"&&r.start!==1&&(s.start=r.start);++o<n.length;){const d=n[o];if(d.type==="element"&&d.tagName==="li"&&d.properties&&Array.isArray(d.properties.className)&&d.properties.className.includes("task-list-item")){s.className=["contains-task-list"];break}}const c={type:"element",tagName:r.ordered?"ol":"ul",properties:s,children:e.wrap(n,!0)};return e.patch(r,c),e.applyData(r,c)}function dH(e,r){const s={type:"element",tagName:"p",properties:{},children:e.all(r)};return e.patch(r,s),e.applyData(r,s)}function uH(e,r){const s={type:"root",children:e.wrap(e.all(r))};return e.patch(r,s),e.applyData(r,s)}function hH(e,r){const s={type:"element",tagName:"strong",properties:{},children:e.all(r)};return e.patch(r,s),e.applyData(r,s)}function fH(e,r){const s=e.all(r),n=s.shift(),o=[];if(n){const d={type:"element",tagName:"thead",properties:{},children:e.wrap([n],!0)};e.patch(r.children[0],d),o.push(d)}if(s.length>0){const d={type:"element",tagName:"tbody",properties:{},children:e.wrap(s,!0)},l=Hx(r.children[1]),u=HN(r.children[r.children.length-1]);l&&u&&(d.position={start:l,end:u}),o.push(d)}const c={type:"element",tagName:"table",properties:{},children:e.wrap(o,!0)};return e.patch(r,c),e.applyData(r,c)}function mH(e,r,s){const n=s?s.children:void 0,c=(n?n.indexOf(r):1)===0?"th":"td",d=s&&s.type==="table"?s.align:void 0,l=d?d.length:r.children.length;let u=-1;const f=[];for(;++u<l;){const h=r.children[u],g={},w=d?d[u]:void 0;w&&(g.align=w);let j={type:"element",tagName:c,properties:g,children:[]};h&&(j.children=e.all(h),e.patch(h,j),j=e.applyData(h,j)),f.push(j)}const m={type:"element",tagName:"tr",properties:{},children:e.wrap(f,!0)};return e.patch(r,m),e.applyData(r,m)}function pH(e,r){const s={type:"element",tagName:"td",properties:{},children:e.all(r)};return e.patch(r,s),e.applyData(r,s)}const l_=9,c_=32;function gH(e){const r=String(e),s=/\r?\n|\r/g;let n=s.exec(r),o=0;const c=[];for(;n;)c.push(d_(r.slice(o,n.index),o>0,!0),n[0]),o=n.index+n[0].length,n=s.exec(r);return c.push(d_(r.slice(o),o>0,!1)),c.join("")}function d_(e,r,s){let n=0,o=e.length;if(r){let c=e.codePointAt(n);for(;c===l_||c===c_;)n++,c=e.codePointAt(n)}if(s){let c=e.codePointAt(o-1);for(;c===l_||c===c_;)o--,c=e.codePointAt(o-1)}return o>n?e.slice(n,o):""}function xH(e,r){const s={type:"text",value:gH(String(r.value))};return e.patch(r,s),e.applyData(r,s)}function vH(e,r){const s={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(r,s),e.applyData(r,s)}const yH={blockquote:K9,break:Y9,code:X9,delete:J9,emphasis:Q9,footnoteReference:Z9,heading:eH,html:tH,imageReference:rH,image:sH,inlineCode:nH,linkReference:iH,link:oH,listItem:aH,list:cH,paragraph:dH,root:uH,strong:hH,table:fH,tableCell:pH,tableRow:mH,text:xH,thematicBreak:vH,toml:cu,yaml:cu,definition:cu,footnoteDefinition:cu};function cu(){}const l2=-1,Rh=0,hc=1,Vu=2,Kx=3,Yx=4,Xx=5,Jx=6,c2=7,d2=8,bH=typeof self=="object"?self:globalThis,u_=(e,r)=>{switch(e){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw new TypeError("unable to deserialize "+e)}return new bH[e](r)},wH=(e,r)=>{const s=(o,c)=>(e.set(c,o),o),n=o=>{if(e.has(o))return e.get(o);const[c,d]=r[o];switch(c){case Rh:case l2:return s(d,o);case hc:{const l=s([],o);for(const u of d)l.push(n(u));return l}case Vu:{const l=s({},o);for(const[u,f]of d)l[n(u)]=n(f);return l}case Kx:return s(new Date(d),o);case Yx:{const{source:l,flags:u}=d;return s(new RegExp(l,u),o)}case Xx:{const l=s(new Map,o);for(const[u,f]of d)l.set(n(u),n(f));return l}case Jx:{const l=s(new Set,o);for(const u of d)l.add(n(u));return l}case c2:{const{name:l,message:u}=d;return s(u_(l,u),o)}case d2:return s(BigInt(d),o);case"BigInt":return s(Object(BigInt(d)),o);case"ArrayBuffer":return s(new Uint8Array(d).buffer,d);case"DataView":{const{buffer:l}=new Uint8Array(d);return s(new DataView(l),d)}}return s(u_(c,d),o)};return n},h_=e=>wH(new Map,e)(0),La="",{toString:_H}={},{keys:kH}=Object,ec=e=>{const r=typeof e;if(r!=="object"||!e)return[Rh,r];const s=_H.call(e).slice(8,-1);switch(s){case"Array":return[hc,La];case"Object":return[Vu,La];case"Date":return[Kx,La];case"RegExp":return[Yx,La];case"Map":return[Xx,La];case"Set":return[Jx,La];case"DataView":return[hc,s]}return s.includes("Array")?[hc,s]:s.includes("Error")?[c2,s]:[Vu,s]},du=([e,r])=>e===Rh&&(r==="function"||r==="symbol"),SH=(e,r,s,n)=>{const o=(d,l)=>{const u=n.push(d)-1;return s.set(l,u),u},c=d=>{if(s.has(d))return s.get(d);let[l,u]=ec(d);switch(l){case Rh:{let m=d;switch(u){case"bigint":l=d2,m=d.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+u);m=null;break;case"undefined":return o([l2],d)}return o([l,m],d)}case hc:{if(u){let g=d;return u==="DataView"?g=new Uint8Array(d.buffer):u==="ArrayBuffer"&&(g=new Uint8Array(d)),o([u,[...g]],d)}const m=[],h=o([l,m],d);for(const g of d)m.push(c(g));return h}case Vu:{if(u)switch(u){case"BigInt":return o([u,d.toString()],d);case"Boolean":case"Number":case"String":return o([u,d.valueOf()],d)}if(r&&"toJSON"in d)return c(d.toJSON());const m=[],h=o([l,m],d);for(const g of kH(d))(e||!du(ec(d[g])))&&m.push([c(g),c(d[g])]);return h}case Kx:return o([l,d.toISOString()],d);case Yx:{const{source:m,flags:h}=d;return o([l,{source:m,flags:h}],d)}case Xx:{const m=[],h=o([l,m],d);for(const[g,w]of d)(e||!(du(ec(g))||du(ec(w))))&&m.push([c(g),c(w)]);return h}case Jx:{const m=[],h=o([l,m],d);for(const g of d)(e||!du(ec(g)))&&m.push(c(g));return h}}const{message:f}=d;return o([l,{name:u,message:f}],d)};return c},f_=(e,{json:r,lossy:s}={})=>{const n=[];return SH(!(r||s),!!r,new Map,n)(e),n},Gu=typeof structuredClone=="function"?(e,r)=>r&&("json"in r||"lossy"in r)?h_(f_(e,r)):structuredClone(e):(e,r)=>h_(f_(e,r));function CH(e,r){const s=[{type:"text",value:"↩"}];return r>1&&s.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(r)}]}),s}function jH(e,r){return"Back to reference "+(e+1)+(r>1?"-"+r:"")}function NH(e){const r=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",s=e.options.footnoteBackContent||CH,n=e.options.footnoteBackLabel||jH,o=e.options.footnoteLabel||"Footnotes",c=e.options.footnoteLabelTagName||"h2",d=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[];let u=-1;for(;++u<e.footnoteOrder.length;){const f=e.footnoteById.get(e.footnoteOrder[u]);if(!f)continue;const m=e.all(f),h=String(f.identifier).toUpperCase(),g=ml(h.toLowerCase());let w=0;const j=[],k=e.footnoteCounts.get(h);for(;k!==void 0&&++w<=k;){j.length>0&&j.push({type:"text",value:" "});let x=typeof s=="string"?s:s(u,w);typeof x=="string"&&(x={type:"text",value:x}),j.push({type:"element",tagName:"a",properties:{href:"#"+r+"fnref-"+g+(w>1?"-"+w:""),dataFootnoteBackref:"",ariaLabel:typeof n=="string"?n:n(u,w),className:["data-footnote-backref"]},children:Array.isArray(x)?x:[x]})}const v=m[m.length-1];if(v&&v.type==="element"&&v.tagName==="p"){const x=v.children[v.children.length-1];x&&x.type==="text"?x.value+=" ":v.children.push({type:"text",value:" "}),v.children.push(...j)}else m.push(...j);const y={type:"element",tagName:"li",properties:{id:r+"fn-"+g},children:e.wrap(m,!0)};e.patch(f,y),l.push(y)}if(l.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:c,properties:{...Gu(d),id:"footnote-label"},children:[{type:"text",value:o}]},{type:"text",value:`
643
643
  `},{type:"element",tagName:"ol",properties:{},children:e.wrap(l,!0)},{type:"text",value:`
644
- `}]}}const u2=(function(e){if(e==null)return AH;if(typeof e=="function")return Mh(e);if(typeof e=="object")return Array.isArray(e)?NH(e):EH(e);if(typeof e=="string")return PH(e);throw new Error("Expected function, string, or object as test")});function NH(e){const r=[];let s=-1;for(;++s<e.length;)r[s]=u2(e[s]);return Mh(n);function n(...o){let c=-1;for(;++c<r.length;)if(r[c].apply(this,o))return!0;return!1}}function EH(e){const r=e;return Mh(s);function s(n){const o=n;let c;for(c in e)if(o[c]!==r[c])return!1;return!0}}function PH(e){return Mh(r);function r(s){return s&&s.type===e}}function Mh(e){return r;function r(s,n,o){return!!(TH(s)&&e.call(this,s,typeof n=="number"?n:void 0,o||void 0))}}function AH(){return!0}function TH(e){return e!==null&&typeof e=="object"&&"type"in e}const h2=[],RH=!0,m_=!1,MH="skip";function IH(e,r,s,n){let o;typeof r=="function"&&typeof s!="function"?(n=s,s=r):o=r;const c=u2(o),d=n?-1:1;l(e,void 0,[])();function l(u,f,m){const h=u&&typeof u=="object"?u:{};if(typeof h.type=="string"){const w=typeof h.tagName=="string"?h.tagName:typeof h.name=="string"?h.name:void 0;Object.defineProperty(g,"name",{value:"node ("+(u.type+(w?"<"+w+">":""))+")"})}return g;function g(){let w=h2,j,k,v;if((!r||c(u,f,m[m.length-1]||void 0))&&(w=DH(s(u,m)),w[0]===m_))return w;if("children"in u&&u.children){const y=u;if(y.children&&w[0]!==MH)for(k=(n?y.children.length:-1)+d,v=m.concat(y);k>-1&&k<y.children.length;){const x=y.children[k];if(j=l(x,k,v)(),j[0]===m_)return j;k=typeof j[1]=="number"?j[1]:k+d}}return w}}}function DH(e){return Array.isArray(e)?e:typeof e=="number"?[RH,e]:e==null?h2:[e]}function f2(e,r,s,n){let o,c,d;typeof r=="function"&&typeof s!="function"?(c=void 0,d=r,o=s):(c=r,d=s,o=n),IH(e,c,l,o);function l(u,f){const m=f[f.length-1],h=m?m.children.indexOf(u):void 0;return d(u,h,m)}}const Xp={}.hasOwnProperty,LH={};function OH(e,r){const s=r||LH,n=new Map,o=new Map,c=new Map,d={...yH,...s.handlers},l={all:f,applyData:BH,definitionById:n,footnoteById:o,footnoteCounts:c,footnoteOrder:[],handlers:d,one:u,options:s,patch:FH,wrap:HH};return f2(e,function(m){if(m.type==="definition"||m.type==="footnoteDefinition"){const h=m.type==="definition"?n:o,g=String(m.identifier).toUpperCase();h.has(g)||h.set(g,m)}}),l;function u(m,h){const g=m.type,w=l.handlers[g];if(Xp.call(l.handlers,g)&&w)return w(l,m,h);if(l.options.passThrough&&l.options.passThrough.includes(g)){if("children"in m){const{children:k,...v}=m,y=Gu(v);return y.children=l.all(m),y}return Gu(m)}return(l.options.unknownHandler||$H)(l,m,h)}function f(m){const h=[];if("children"in m){const g=m.children;let w=-1;for(;++w<g.length;){const j=l.one(g[w],m);if(j){if(w&&g[w-1].type==="break"&&(!Array.isArray(j)&&j.type==="text"&&(j.value=p_(j.value)),!Array.isArray(j)&&j.type==="element")){const k=j.children[0];k&&k.type==="text"&&(k.value=p_(k.value))}Array.isArray(j)?h.push(...j):h.push(j)}}}return h}}function FH(e,r){e.position&&(r.position=w7(e))}function BH(e,r){let s=r;if(e&&e.data){const n=e.data.hName,o=e.data.hChildren,c=e.data.hProperties;if(typeof n=="string")if(s.type==="element")s.tagName=n;else{const d="children"in s?s.children:[s];s={type:"element",tagName:n,properties:{},children:d}}s.type==="element"&&c&&Object.assign(s.properties,Gu(c)),"children"in s&&s.children&&o!==null&&o!==void 0&&(s.children=o)}return s}function $H(e,r){const s=r.data||{},n="value"in r&&!(Xp.call(s,"hProperties")||Xp.call(s,"hChildren"))?{type:"text",value:r.value}:{type:"element",tagName:"div",properties:{},children:e.all(r)};return e.patch(r,n),e.applyData(r,n)}function HH(e,r){const s=[];let n=-1;for(r&&s.push({type:"text",value:`
644
+ `}]}}const u2=(function(e){if(e==null)return TH;if(typeof e=="function")return Mh(e);if(typeof e=="object")return Array.isArray(e)?EH(e):PH(e);if(typeof e=="string")return AH(e);throw new Error("Expected function, string, or object as test")});function EH(e){const r=[];let s=-1;for(;++s<e.length;)r[s]=u2(e[s]);return Mh(n);function n(...o){let c=-1;for(;++c<r.length;)if(r[c].apply(this,o))return!0;return!1}}function PH(e){const r=e;return Mh(s);function s(n){const o=n;let c;for(c in e)if(o[c]!==r[c])return!1;return!0}}function AH(e){return Mh(r);function r(s){return s&&s.type===e}}function Mh(e){return r;function r(s,n,o){return!!(RH(s)&&e.call(this,s,typeof n=="number"?n:void 0,o||void 0))}}function TH(){return!0}function RH(e){return e!==null&&typeof e=="object"&&"type"in e}const h2=[],MH=!0,m_=!1,IH="skip";function DH(e,r,s,n){let o;typeof r=="function"&&typeof s!="function"?(n=s,s=r):o=r;const c=u2(o),d=n?-1:1;l(e,void 0,[])();function l(u,f,m){const h=u&&typeof u=="object"?u:{};if(typeof h.type=="string"){const w=typeof h.tagName=="string"?h.tagName:typeof h.name=="string"?h.name:void 0;Object.defineProperty(g,"name",{value:"node ("+(u.type+(w?"<"+w+">":""))+")"})}return g;function g(){let w=h2,j,k,v;if((!r||c(u,f,m[m.length-1]||void 0))&&(w=LH(s(u,m)),w[0]===m_))return w;if("children"in u&&u.children){const y=u;if(y.children&&w[0]!==IH)for(k=(n?y.children.length:-1)+d,v=m.concat(y);k>-1&&k<y.children.length;){const x=y.children[k];if(j=l(x,k,v)(),j[0]===m_)return j;k=typeof j[1]=="number"?j[1]:k+d}}return w}}}function LH(e){return Array.isArray(e)?e:typeof e=="number"?[MH,e]:e==null?h2:[e]}function f2(e,r,s,n){let o,c,d;typeof r=="function"&&typeof s!="function"?(c=void 0,d=r,o=s):(c=r,d=s,o=n),DH(e,c,l,o);function l(u,f){const m=f[f.length-1],h=m?m.children.indexOf(u):void 0;return d(u,h,m)}}const Xp={}.hasOwnProperty,OH={};function FH(e,r){const s=r||OH,n=new Map,o=new Map,c=new Map,d={...yH,...s.handlers},l={all:f,applyData:$H,definitionById:n,footnoteById:o,footnoteCounts:c,footnoteOrder:[],handlers:d,one:u,options:s,patch:BH,wrap:zH};return f2(e,function(m){if(m.type==="definition"||m.type==="footnoteDefinition"){const h=m.type==="definition"?n:o,g=String(m.identifier).toUpperCase();h.has(g)||h.set(g,m)}}),l;function u(m,h){const g=m.type,w=l.handlers[g];if(Xp.call(l.handlers,g)&&w)return w(l,m,h);if(l.options.passThrough&&l.options.passThrough.includes(g)){if("children"in m){const{children:k,...v}=m,y=Gu(v);return y.children=l.all(m),y}return Gu(m)}return(l.options.unknownHandler||HH)(l,m,h)}function f(m){const h=[];if("children"in m){const g=m.children;let w=-1;for(;++w<g.length;){const j=l.one(g[w],m);if(j){if(w&&g[w-1].type==="break"&&(!Array.isArray(j)&&j.type==="text"&&(j.value=p_(j.value)),!Array.isArray(j)&&j.type==="element")){const k=j.children[0];k&&k.type==="text"&&(k.value=p_(k.value))}Array.isArray(j)?h.push(...j):h.push(j)}}}return h}}function BH(e,r){e.position&&(r.position=w7(e))}function $H(e,r){let s=r;if(e&&e.data){const n=e.data.hName,o=e.data.hChildren,c=e.data.hProperties;if(typeof n=="string")if(s.type==="element")s.tagName=n;else{const d="children"in s?s.children:[s];s={type:"element",tagName:n,properties:{},children:d}}s.type==="element"&&c&&Object.assign(s.properties,Gu(c)),"children"in s&&s.children&&o!==null&&o!==void 0&&(s.children=o)}return s}function HH(e,r){const s=r.data||{},n="value"in r&&!(Xp.call(s,"hProperties")||Xp.call(s,"hChildren"))?{type:"text",value:r.value}:{type:"element",tagName:"div",properties:{},children:e.all(r)};return e.patch(r,n),e.applyData(r,n)}function zH(e,r){const s=[];let n=-1;for(r&&s.push({type:"text",value:`
645
645
  `});++n<e.length;)n&&s.push({type:"text",value:`
646
646
  `}),s.push(e[n]);return r&&e.length>0&&s.push({type:"text",value:`
647
- `}),s}function p_(e){let r=0,s=e.charCodeAt(r);for(;s===9||s===32;)r++,s=e.charCodeAt(r);return e.slice(r)}function g_(e,r){const s=OH(e,r),n=s.one(e,void 0),o=jH(s),c=Array.isArray(n)?{type:"root",children:n}:n||{type:"root",children:[]};return o&&c.children.push({type:"text",value:`
648
- `},o),c}function zH(e,r){return e&&"run"in e?async function(s,n){const o=g_(s,{file:n,...r});await e.run(o,n)}:function(s,n){return g_(s,{file:n,...e||r})}}function x_(e){if(e)throw e}var Jm,v_;function WH(){if(v_)return Jm;v_=1;var e=Object.prototype.hasOwnProperty,r=Object.prototype.toString,s=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=function(f){return typeof Array.isArray=="function"?Array.isArray(f):r.call(f)==="[object Array]"},c=function(f){if(!f||r.call(f)!=="[object Object]")return!1;var m=e.call(f,"constructor"),h=f.constructor&&f.constructor.prototype&&e.call(f.constructor.prototype,"isPrototypeOf");if(f.constructor&&!m&&!h)return!1;var g;for(g in f);return typeof g>"u"||e.call(f,g)},d=function(f,m){s&&m.name==="__proto__"?s(f,m.name,{enumerable:!0,configurable:!0,value:m.newValue,writable:!0}):f[m.name]=m.newValue},l=function(f,m){if(m==="__proto__")if(e.call(f,m)){if(n)return n(f,m).value}else return;return f[m]};return Jm=function u(){var f,m,h,g,w,j,k=arguments[0],v=1,y=arguments.length,x=!1;for(typeof k=="boolean"&&(x=k,k=arguments[1]||{},v=2),(k==null||typeof k!="object"&&typeof k!="function")&&(k={});v<y;++v)if(f=arguments[v],f!=null)for(m in f)h=l(k,m),g=l(f,m),k!==g&&(x&&g&&(c(g)||(w=o(g)))?(w?(w=!1,j=h&&o(h)?h:[]):j=h&&c(h)?h:{},d(k,{name:m,newValue:u(x,j,g)})):typeof g<"u"&&d(k,{name:m,newValue:g}));return k},Jm}var UH=WH();const Qm=Nc(UH);function Jp(e){if(typeof e!="object"||e===null)return!1;const r=Object.getPrototypeOf(e);return(r===null||r===Object.prototype||Object.getPrototypeOf(r)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function VH(){const e=[],r={run:s,use:n};return r;function s(...o){let c=-1;const d=o.pop();if(typeof d!="function")throw new TypeError("Expected function as last argument, not "+d);l(null,...o);function l(u,...f){const m=e[++c];let h=-1;if(u){d(u);return}for(;++h<o.length;)(f[h]===null||f[h]===void 0)&&(f[h]=o[h]);o=f,m?GH(m,l)(...f):d(null,...f)}}function n(o){if(typeof o!="function")throw new TypeError("Expected `middelware` to be a function, not "+o);return e.push(o),r}}function GH(e,r){let s;return n;function n(...d){const l=e.length>d.length;let u;l&&d.push(o);try{u=e.apply(this,d)}catch(f){const m=f;if(l&&s)throw m;return o(m)}l||(u&&u.then&&typeof u.then=="function"?u.then(c,o):u instanceof Error?o(u):c(u))}function o(d,...l){s||(s=!0,r(d,...l))}function c(d){o(null,d)}}const $n={basename:qH,dirname:KH,extname:YH,join:XH,sep:"/"};function qH(e,r){if(r!==void 0&&typeof r!="string")throw new TypeError('"ext" argument must be a string');Gc(e);let s=0,n=-1,o=e.length,c;if(r===void 0||r.length===0||r.length>e.length){for(;o--;)if(e.codePointAt(o)===47){if(c){s=o+1;break}}else n<0&&(c=!0,n=o+1);return n<0?"":e.slice(s,n)}if(r===e)return"";let d=-1,l=r.length-1;for(;o--;)if(e.codePointAt(o)===47){if(c){s=o+1;break}}else d<0&&(c=!0,d=o+1),l>-1&&(e.codePointAt(o)===r.codePointAt(l--)?l<0&&(n=o):(l=-1,n=d));return s===n?n=d:n<0&&(n=e.length),e.slice(s,n)}function KH(e){if(Gc(e),e.length===0)return".";let r=-1,s=e.length,n;for(;--s;)if(e.codePointAt(s)===47){if(n){r=s;break}}else n||(n=!0);return r<0?e.codePointAt(0)===47?"/":".":r===1&&e.codePointAt(0)===47?"//":e.slice(0,r)}function YH(e){Gc(e);let r=e.length,s=-1,n=0,o=-1,c=0,d;for(;r--;){const l=e.codePointAt(r);if(l===47){if(d){n=r+1;break}continue}s<0&&(d=!0,s=r+1),l===46?o<0?o=r:c!==1&&(c=1):o>-1&&(c=-1)}return o<0||s<0||c===0||c===1&&o===s-1&&o===n+1?"":e.slice(o,s)}function XH(...e){let r=-1,s;for(;++r<e.length;)Gc(e[r]),e[r]&&(s=s===void 0?e[r]:s+"/"+e[r]);return s===void 0?".":JH(s)}function JH(e){Gc(e);const r=e.codePointAt(0)===47;let s=QH(e,!r);return s.length===0&&!r&&(s="."),s.length>0&&e.codePointAt(e.length-1)===47&&(s+="/"),r?"/"+s:s}function QH(e,r){let s="",n=0,o=-1,c=0,d=-1,l,u;for(;++d<=e.length;){if(d<e.length)l=e.codePointAt(d);else{if(l===47)break;l=47}if(l===47){if(!(o===d-1||c===1))if(o!==d-1&&c===2){if(s.length<2||n!==2||s.codePointAt(s.length-1)!==46||s.codePointAt(s.length-2)!==46){if(s.length>2){if(u=s.lastIndexOf("/"),u!==s.length-1){u<0?(s="",n=0):(s=s.slice(0,u),n=s.length-1-s.lastIndexOf("/")),o=d,c=0;continue}}else if(s.length>0){s="",n=0,o=d,c=0;continue}}r&&(s=s.length>0?s+"/..":"..",n=2)}else s.length>0?s+="/"+e.slice(o+1,d):s=e.slice(o+1,d),n=d-o-1;o=d,c=0}else l===46&&c>-1?c++:c=-1}return s}function Gc(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const ZH={cwd:ez};function ez(){return"/"}function Qp(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function tz(e){if(typeof e=="string")e=new URL(e);else if(!Qp(e)){const r=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw r.code="ERR_INVALID_ARG_TYPE",r}if(e.protocol!=="file:"){const r=new TypeError("The URL must be of scheme file");throw r.code="ERR_INVALID_URL_SCHEME",r}return rz(e)}function rz(e){if(e.hostname!==""){const n=new TypeError('File URL host must be "localhost" or empty on darwin');throw n.code="ERR_INVALID_FILE_URL_HOST",n}const r=e.pathname;let s=-1;for(;++s<r.length;)if(r.codePointAt(s)===37&&r.codePointAt(s+1)===50){const n=r.codePointAt(s+2);if(n===70||n===102){const o=new TypeError("File URL path must not include encoded / characters");throw o.code="ERR_INVALID_FILE_URL_PATH",o}}return decodeURIComponent(r)}const Zm=["history","path","basename","stem","extname","dirname"];class m2{constructor(r){let s;r?Qp(r)?s={path:r}:typeof r=="string"||sz(r)?s={value:r}:s=r:s={},this.cwd="cwd"in s?"":ZH.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<Zm.length;){const c=Zm[n];c in s&&s[c]!==void 0&&s[c]!==null&&(this[c]=c==="history"?[...s[c]]:s[c])}let o;for(o in s)Zm.includes(o)||(this[o]=s[o])}get basename(){return typeof this.path=="string"?$n.basename(this.path):void 0}set basename(r){tp(r,"basename"),ep(r,"basename"),this.path=$n.join(this.dirname||"",r)}get dirname(){return typeof this.path=="string"?$n.dirname(this.path):void 0}set dirname(r){y_(this.basename,"dirname"),this.path=$n.join(r||"",this.basename)}get extname(){return typeof this.path=="string"?$n.extname(this.path):void 0}set extname(r){if(ep(r,"extname"),y_(this.dirname,"extname"),r){if(r.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(r.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=$n.join(this.dirname,this.stem+(r||""))}get path(){return this.history[this.history.length-1]}set path(r){Qp(r)&&(r=tz(r)),tp(r,"path"),this.path!==r&&this.history.push(r)}get stem(){return typeof this.path=="string"?$n.basename(this.path,this.extname):void 0}set stem(r){tp(r,"stem"),ep(r,"stem"),this.path=$n.join(this.dirname||"",r+(this.extname||""))}fail(r,s,n){const o=this.message(r,s,n);throw o.fatal=!0,o}info(r,s,n){const o=this.message(r,s,n);return o.fatal=void 0,o}message(r,s,n){const o=new ms(r,s,n);return this.path&&(o.name=this.path+":"+o.name,o.file=this.path),o.fatal=!1,this.messages.push(o),o}toString(r){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(r||void 0).decode(this.value)}}function ep(e,r){if(e&&e.includes($n.sep))throw new Error("`"+r+"` cannot be a path: did not expect `"+$n.sep+"`")}function tp(e,r){if(!e)throw new Error("`"+r+"` cannot be empty")}function y_(e,r){if(!e)throw new Error("Setting `"+r+"` requires `path` to be set too")}function sz(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const nz=(function(e){const n=this.constructor.prototype,o=n[e],c=function(){return o.apply(c,arguments)};return Object.setPrototypeOf(c,n),c}),iz={}.hasOwnProperty;class Qx extends nz{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=VH()}copy(){const r=new Qx;let s=-1;for(;++s<this.attachers.length;){const n=this.attachers[s];r.use(...n)}return r.data(Qm(!0,{},this.namespace)),r}data(r,s){return typeof r=="string"?arguments.length===2?(np("data",this.frozen),this.namespace[r]=s,this):iz.call(this.namespace,r)&&this.namespace[r]||void 0:r?(np("data",this.frozen),this.namespace=r,this):this.namespace}freeze(){if(this.frozen)return this;const r=this;for(;++this.freezeIndex<this.attachers.length;){const[s,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);const o=s.call(r,...n);typeof o=="function"&&this.transformers.use(o)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(r){this.freeze();const s=uu(r),n=this.parser||this.Parser;return rp("parse",n),n(String(s),s)}process(r,s){const n=this;return this.freeze(),rp("process",this.parser||this.Parser),sp("process",this.compiler||this.Compiler),s?o(void 0,s):new Promise(o);function o(c,d){const l=uu(r),u=n.parse(l);n.run(u,l,function(m,h,g){if(m||!h||!g)return f(m);const w=h,j=n.stringify(w,g);lz(j)?g.value=j:g.result=j,f(m,g)});function f(m,h){m||!h?d(m):c?c(h):s(void 0,h)}}}processSync(r){let s=!1,n;return this.freeze(),rp("processSync",this.parser||this.Parser),sp("processSync",this.compiler||this.Compiler),this.process(r,o),w_("processSync","process",s),n;function o(c,d){s=!0,x_(c),n=d}}run(r,s,n){b_(r),this.freeze();const o=this.transformers;return!n&&typeof s=="function"&&(n=s,s=void 0),n?c(void 0,n):new Promise(c);function c(d,l){const u=uu(s);o.run(r,u,f);function f(m,h,g){const w=h||r;m?l(m):d?d(w):n(void 0,w,g)}}}runSync(r,s){let n=!1,o;return this.run(r,s,c),w_("runSync","run",n),o;function c(d,l){x_(d),o=l,n=!0}}stringify(r,s){this.freeze();const n=uu(s),o=this.compiler||this.Compiler;return sp("stringify",o),b_(r),o(r,n)}use(r,...s){const n=this.attachers,o=this.namespace;if(np("use",this.frozen),r!=null)if(typeof r=="function")u(r,s);else if(typeof r=="object")Array.isArray(r)?l(r):d(r);else throw new TypeError("Expected usable value, not `"+r+"`");return this;function c(f){if(typeof f=="function")u(f,[]);else if(typeof f=="object")if(Array.isArray(f)){const[m,...h]=f;u(m,h)}else d(f);else throw new TypeError("Expected usable value, not `"+f+"`")}function d(f){if(!("plugins"in f)&&!("settings"in f))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");l(f.plugins),f.settings&&(o.settings=Qm(!0,o.settings,f.settings))}function l(f){let m=-1;if(f!=null)if(Array.isArray(f))for(;++m<f.length;){const h=f[m];c(h)}else throw new TypeError("Expected a list of plugins, not `"+f+"`")}function u(f,m){let h=-1,g=-1;for(;++h<n.length;)if(n[h][0]===f){g=h;break}if(g===-1)n.push([f,...m]);else if(m.length>0){let[w,...j]=m;const k=n[g][1];Jp(k)&&Jp(w)&&(w=Qm(!0,k,w)),n[g]=[f,w,...j]}}}}const oz=new Qx().freeze();function rp(e,r){if(typeof r!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function sp(e,r){if(typeof r!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function np(e,r){if(r)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function b_(e){if(!Jp(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function w_(e,r,s){if(!s)throw new Error("`"+e+"` finished async. Use `"+r+"` instead")}function uu(e){return az(e)?e:new m2(e)}function az(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function lz(e){return typeof e=="string"||cz(e)}function cz(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const dz="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",__=[],k_={allowDangerousHtml:!0},uz=/^(https?|ircs?|mailto|xmpp)$/i,hz=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function fz(e){const r=mz(e),s=pz(e);return gz(r.runSync(r.parse(s),s),e)}function mz(e){const r=e.rehypePlugins||__,s=e.remarkPlugins||__,n=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...k_}:k_;return oz().use(q9).use(s).use(zH,n).use(r)}function pz(e){const r=e.children||"",s=new m2;return typeof r=="string"&&(s.value=r),s}function gz(e,r){const s=r.allowedElements,n=r.allowElement,o=r.components,c=r.disallowedElements,d=r.skipHtml,l=r.unwrapDisallowed,u=r.urlTransform||xz;for(const m of hz)Object.hasOwn(r,m.from)&&(""+m.from+(m.to?"use `"+m.to+"` instead":"remove it")+dz+m.id,void 0);return f2(e,f),j7(e,{Fragment:t.Fragment,components:o,ignoreInvalidStyle:!0,jsx:t.jsx,jsxs:t.jsxs,passKeys:!0,passNode:!0});function f(m,h,g){if(m.type==="raw"&&g&&typeof h=="number")return d?g.children.splice(h,1):g.children[h]={type:"text",value:m.value},h;if(m.type==="element"){let w;for(w in Km)if(Object.hasOwn(Km,w)&&Object.hasOwn(m.properties,w)){const j=m.properties[w],k=Km[w];(k===null||k.includes(m.tagName))&&(m.properties[w]=u(String(j||""),w,m))}}if(m.type==="element"){let w=s?!s.includes(m.tagName):c?c.includes(m.tagName):!1;if(!w&&n&&typeof h=="number"&&(w=!n(m,h,g)),w&&g&&typeof h=="number")return l&&m.children?g.children.splice(h,1,...m.children):g.children.splice(h,1),h}}}function xz(e){const r=e.indexOf(":"),s=e.indexOf("?"),n=e.indexOf("#"),o=e.indexOf("/");return r===-1||o!==-1&&r>o||s!==-1&&r>s||n!==-1&&r>n||uz.test(e.slice(0,r))?e:""}function vz({onConfigChange:e}){var T,F,$;const[r,s]=_.useState(null),[n,o]=_.useState(""),[c,d]=_.useState({open:!1,field:null,type:"directory"}),[l,u]=_.useState(!0),[f,m]=_.useState(!1),[h,g]=_.useState(null),[w,j]=_.useState(!1),[k,v]=_.useState(null),[y,x]=_.useState([]),[b,S]=_.useState({open:!1,content:"",loading:!1}),[N,P]=_.useState({open:!1,feature:null}),[A,E]=_.useState({open:!1});_.useEffect(()=>{z(),M(),I()},[]);const M=async()=>{try{const D=await he.checkVersion();g(D)}catch(D){console.error("Failed to load version info:",D)}},I=async()=>{try{const D=await he.getProject();v(D.dir),B(D.dir)}catch(D){console.error("Failed to load project info:",D)}},B=async D=>{if(D)try{const X=await he.getHiddenSubprojects(D);x(X.hidden||[])}catch(X){console.error("Failed to load hidden sub-projects:",X)}},U=async D=>{if(k)try{const X=await he.unhideSubproject(k,D);X.success?(q.success("Sub-project unhidden"),B(k)):q.error(X.error||"Failed to unhide")}catch(X){q.error("Failed to unhide: "+X.message)}},V=async()=>{if(!(h!=null&&h.updateAvailable)){q.error("No update available");return}j(!0);try{const D=await he.performUpdate({updateMethod:h.updateMethod,sourcePath:h.sourcePath,channel:h.channel});if(D.success){q.success(`Updated to v${D.newVersion}! Restarting server...`);try{await he.restartServer()}catch{}let X=0;const te=setInterval(async()=>{X++;try{await he.checkVersion(),clearInterval(te),q.success("Server restarted! Reloading..."),setTimeout(()=>window.location.reload(),500)}catch{X>30&&(clearInterval(te),q.info("Server restarting. Please refresh the page."),j(!1))}},500)}else q.error("Update failed: "+D.error),j(!1)}catch(D){q.error("Update failed: "+D.message),j(!1)}},Q=async()=>{S(D=>({...D,open:!0,loading:!0}));try{const D=await he.getChangelog();D.success?S(X=>({...X,content:D.content,loading:!1})):(q.error("Failed to load changelog"),S(X=>({...X,open:!1,loading:!1})))}catch(D){q.error("Failed to load changelog: "+D.message),S(X=>({...X,open:!1,loading:!1}))}},z=async()=>{try{u(!0);const D=await he.getConfig();s(D.config),o(D.path)}catch{q.error("Failed to load settings")}finally{u(!1)}},H=async()=>{m(!0);try{await he.saveConfig(r),q.success("Preferences saved!")}catch{q.error("Failed to save preferences")}finally{m(!1)}},Y=(D,X)=>{s(te=>({...te,[D]:X}))},K=(D,X,te)=>{s(fe=>({...fe,[D]:{...fe[D],[X]:te}}))},O=async D=>{const X=(r==null?void 0:r.enabledTools)||["claude"];let te;if(X.includes(D)){if(X.length<=1){q.error("At least one tool must be enabled");return}te=X.filter(J=>J!==D)}else te=[...X,D];const fe={...r,enabledTools:te};s(fe);try{await he.saveConfig(fe),e==null||e(fe);const J={claude:"Claude Code",gemini:"Gemini CLI",antigravity:"Antigravity",codex:"Codex CLI"}[D]||D;q.success(`${J} ${te.includes(D)?"enabled":"disabled"}`)}catch{s(r),q.error("Failed to save preference")}};return l?t.jsx("div",{className:"flex items-center justify-center h-64",children:t.jsx(Qe,{className:"w-8 h-8 animate-spin text-primary"})}):t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-muted flex items-center justify-center",children:t.jsx(wS,{className:"w-5 h-5 text-muted-foreground"})}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"coder-config Preferences"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Tool settings for this configuration manager"})]})]}),t.jsxs("div",{className:"bg-card rounded-xl border border-border p-6 shadow-sm",children:[t.jsxs("div",{className:"flex items-center justify-between mb-6",children:[t.jsx("div",{children:t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Stored in: ",t.jsx("code",{className:"bg-muted px-2 py-0.5 rounded",children:n})]})}),t.jsxs(ne,{onClick:H,disabled:f,children:[f?t.jsx(Qe,{className:"w-4 h-4 mr-2 animate-spin"}):t.jsx(Zr,{className:"w-4 h-4 mr-2"}),"Save"]})]}),t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"border-b border-border pb-6",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(Xr,{className:"w-4 h-4"}),"Directories"]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"MCP Tools Directories"}),t.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Folders containing local MCP tool repositories for discovery"}),t.jsxs("div",{className:"space-y-2",children:[((r==null?void 0:r.toolsDirs)||(r!=null&&r.toolsDir?[r.toolsDir]:[])).map((D,X)=>t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Oe,{value:D||"",onChange:te=>{const fe=[...(r==null?void 0:r.toolsDirs)||(r!=null&&r.toolsDir?[r.toolsDir]:[])];fe[X]=te.target.value,Y("toolsDirs",fe),r!=null&&r.toolsDir&&s(J=>{const{toolsDir:W,...le}=J;return{...le,toolsDirs:fe}})},placeholder:"~/mcp-tools",className:"font-mono flex-1"}),t.jsx(ne,{variant:"outline",size:"icon",onClick:()=>d({open:!0,field:"toolsDirs",type:"directory",index:X}),title:"Browse...",children:t.jsx(Zi,{className:"w-4 h-4"})}),t.jsx(ne,{variant:"outline",size:"icon",onClick:()=>{const fe=((r==null?void 0:r.toolsDirs)||(r!=null&&r.toolsDir?[r.toolsDir]:[])).filter((J,W)=>W!==X);s(J=>{const{toolsDir:W,...le}=J;return{...le,toolsDirs:fe.length>0?fe:void 0}})},title:"Remove",className:"text-destructive hover:text-destructive",children:t.jsx(Nn,{className:"w-4 h-4"})})]},X)),t.jsxs(ne,{variant:"outline",size:"sm",onClick:()=>d({open:!0,field:"toolsDirs",type:"directory",index:-1}),className:"mt-2",children:[t.jsx(fi,{className:"w-4 h-4 mr-2"}),"Add Tools Folder"]})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Global Registry Path"}),t.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Path to the global MCP registry file"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Oe,{value:(r==null?void 0:r.registryPath)||"",onChange:D=>Y("registryPath",D.target.value),placeholder:"~/.claude/registry.json",className:"font-mono flex-1"}),t.jsx(ne,{variant:"outline",size:"icon",onClick:()=>d({open:!0,field:"registryPath",type:"file"}),title:"Browse...",children:t.jsx(Zi,{className:"w-4 h-4"})})]})]})]})]}),t.jsxs("div",{className:"border-b border-border pb-6",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(Z5,{className:"w-4 h-4"}),"User Interface"]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Default Port"}),t.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Port for the web UI server"}),t.jsx(Oe,{type:"number",value:((T=r==null?void 0:r.ui)==null?void 0:T.port)||3333,onChange:D=>K("ui","port",parseInt(D.target.value)||3333),placeholder:"3333",className:"w-32"})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Open Browser on Start"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Automatically open browser when starting the UI"})]}),t.jsx(xt,{checked:((F=r==null?void 0:r.ui)==null?void 0:F.openBrowser)??!0,onCheckedChange:D=>K("ui","openBrowser",D)})]})]})]}),t.jsxs("div",{className:"border-b border-border pb-6",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(MM,{className:"w-4 h-4"}),"AI Assistant"]}),t.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Choose which AI assistant to use for features like MCP creation and tool import."}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg cursor-pointer border-2 transition-colors ${((r==null?void 0:r.aiAssistant)||"claude")==="claude"?"border-orange-500 bg-orange-500/5":"border-transparent bg-muted/50 hover:bg-muted"}`,onClick:()=>Y("aiAssistant","claude"),children:[t.jsx("input",{type:"radio",name:"aiAssistant",value:"claude",checked:((r==null?void 0:r.aiAssistant)||"claude")==="claude",onChange:()=>Y("aiAssistant","claude"),className:"sr-only"}),t.jsx("div",{className:"w-8 h-8 rounded-md bg-orange-500/10 flex items-center justify-center",children:t.jsx(Vt,{className:"w-4 h-4 text-orange-500"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("span",{className:"text-sm font-medium text-foreground",children:"Claude Code"}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Anthropic's AI coding assistant • Command: ",t.jsx("code",{className:"text-xs",children:"claude"})]})]}),((r==null?void 0:r.aiAssistant)||"claude")==="claude"&&t.jsx("div",{className:"w-2 h-2 rounded-full bg-orange-500"})]}),t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg cursor-pointer border-2 transition-colors ${(r==null?void 0:r.aiAssistant)==="gemini"?"border-blue-500 bg-blue-500/5":"border-transparent bg-muted/50 hover:bg-muted"}`,onClick:()=>Y("aiAssistant","gemini"),children:[t.jsx("input",{type:"radio",name:"aiAssistant",value:"gemini",checked:(r==null?void 0:r.aiAssistant)==="gemini",onChange:()=>Y("aiAssistant","gemini"),className:"sr-only"}),t.jsx("div",{className:"w-8 h-8 rounded-md bg-blue-500/10 flex items-center justify-center",children:t.jsx(Ut,{className:"w-4 h-4 text-blue-500"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("span",{className:"text-sm font-medium text-foreground",children:"Gemini CLI"}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Google's AI coding assistant • Command: ",t.jsx("code",{className:"text-xs",children:"gemini"})]})]}),(r==null?void 0:r.aiAssistant)==="gemini"&&t.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-500"})]})]})]}),t.jsxs("div",{className:"border-b border-border pb-6",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(r5,{className:"w-4 h-4"}),"Enabled AI Tools"]}),t.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Select which AI coding tools to generate MCP configurations for. The Apply button will update all enabled tools."}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/50 rounded-lg",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-8 h-8 rounded-md bg-orange-500/10 flex items-center justify-center",children:t.jsx(Vt,{className:"w-4 h-4 text-orange-500"})}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Claude Code"}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Anthropic's AI coding assistant • Output: ",t.jsx("code",{className:"text-xs",children:".mcp.json"})]})]})]}),t.jsx(xt,{checked:((r==null?void 0:r.enabledTools)||["claude"]).includes("claude"),onCheckedChange:()=>O("claude")})]}),t.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/50 rounded-lg",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-8 h-8 rounded-md bg-blue-500/10 flex items-center justify-center",children:t.jsx(Vt,{className:"w-4 h-4 text-blue-500"})}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Gemini CLI"}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Google's terminal AI coding assistant • Output: ",t.jsx("code",{className:"text-xs",children:"~/.gemini/settings.json"})]})]})]}),t.jsx(xt,{checked:((r==null?void 0:r.enabledTools)||["claude"]).includes("gemini"),onCheckedChange:()=>O("gemini")})]}),t.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/50 rounded-lg",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-8 h-8 rounded-md bg-purple-500/10 flex items-center justify-center",children:t.jsx(Vt,{className:"w-4 h-4 text-purple-500"})}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Antigravity"}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Google's AI IDE • Output: ",t.jsx("code",{className:"text-xs",children:"~/.gemini/antigravity/mcp_config.json"})]})]})]}),t.jsx(xt,{checked:((r==null?void 0:r.enabledTools)||["claude"]).includes("antigravity"),onCheckedChange:()=>O("antigravity")})]}),t.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/50 rounded-lg",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-8 h-8 rounded-md bg-green-500/10 flex items-center justify-center",children:t.jsx(Vt,{className:"w-4 h-4 text-green-500"})}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Codex CLI"}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["OpenAI's terminal coding assistant • Output: ",t.jsx("code",{className:"text-xs",children:".codex/mcp.json"})]})]})]}),t.jsx(xt,{checked:((r==null?void 0:r.enabledTools)||["claude"]).includes("codex"),onCheckedChange:()=>O("codex")})]}),t.jsxs("p",{className:"text-xs text-muted-foreground italic",children:["Note: Antigravity does not support environment variable interpolation (",t.jsx("code",{children:"${VAR}"}),"). Variables are resolved to actual values when generating its config."]})]})]}),y.length>0&&t.jsxs("div",{children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(gS,{className:"w-4 h-4"}),"Hidden Sub-projects"]}),t.jsx("div",{className:"space-y-2",children:y.map(D=>t.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/50 rounded-lg",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Xr,{className:"w-4 h-4 text-muted-foreground"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium text-foreground",children:D.name}),t.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:D.dir.replace(k+"/","")})]})]}),t.jsxs(ne,{size:"sm",variant:"outline",onClick:()=>U(D.dir),className:"h-7",children:[t.jsx(Fg,{className:"w-3 h-3 mr-1"}),"Unhide"]})]},D.dir))})]}),t.jsxs("div",{className:"border-b border-border pb-6",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(jm,{className:"w-4 h-4"}),"Experimental Features"]}),t.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"These features are experimental and may change or be removed in future versions."}),t.jsx("div",{className:"space-y-4",children:t.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/50 rounded-lg border border-yellow-500/20",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-8 h-8 rounded-md bg-yellow-500/10 flex items-center justify-center",children:t.jsx(jm,{className:"w-4 h-4 text-yellow-500"})}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Ralph Loops"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Autonomous development loops with Claude Code"})]})]}),t.jsx(xt,{checked:(($=r==null?void 0:r.experimental)==null?void 0:$.ralphLoops)||!1,onCheckedChange:D=>{if(D)P({open:!0,feature:"ralphLoops"});else{const X={...r,experimental:{...r==null?void 0:r.experimental,ralphLoops:!1}};s(X),he.saveConfig(X),e==null||e(X),q.success("Ralph Loops disabled")}}})]})})]}),t.jsxs("div",{children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(vr,{className:"w-4 h-4"}),"About"]}),t.jsxs("div",{className:"bg-muted rounded-lg p-4 space-y-3",children:[t.jsxs("div",{className:"flex justify-between text-sm",children:[t.jsx("span",{className:"text-muted-foreground",children:"Installed Version"}),t.jsx("span",{className:"font-medium font-mono text-foreground",children:(h==null?void 0:h.installedVersion)||"Loading..."})]}),(h==null?void 0:h.updateAvailable)&&t.jsx("div",{className:"p-3 bg-green-500/10 border border-green-500/20 rounded-lg",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium text-green-600 dark:text-green-400",children:"Update Available!"}),t.jsxs("p",{className:"text-xs text-green-600/80 dark:text-green-400/80",children:["Version ",h.latestVersion," via ",h.updateMethod==="npm"?"npm":h.sourcePath]})]}),t.jsxs(ne,{size:"sm",onClick:V,disabled:w,className:"bg-green-600 hover:bg-green-700 text-white",children:[w?t.jsx(Qe,{className:"w-4 h-4 mr-2 animate-spin"}):t.jsx(yi,{className:"w-4 h-4 mr-2"}),"Update Now"]})]})}),!(h!=null&&h.updateAvailable)&&(h==null?void 0:h.latestVersion)&&t.jsxs("div",{className:"flex justify-between text-sm",children:[t.jsx("span",{className:"text-muted-foreground",children:"Latest Version"}),t.jsxs("span",{className:"font-mono text-green-600 dark:text-green-400",children:[h.latestVersion," ✓"]})]}),(h==null?void 0:h.sourcePath)&&!(h!=null&&h.updateAvailable)&&t.jsxs("div",{className:"flex items-center justify-between text-sm",children:[t.jsx("span",{className:"text-muted-foreground",children:"Dev Source"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("code",{className:"text-xs text-muted-foreground",children:h.sourcePath}),t.jsx(ne,{size:"sm",variant:"outline",onClick:V,disabled:w,className:"h-7",children:w?t.jsx(Qe,{className:"w-3 h-3 animate-spin"}):t.jsx(Dr,{className:"w-3 h-3"})})]})]}),t.jsxs("div",{className:"flex justify-between text-sm",children:[t.jsx("span",{className:"text-muted-foreground",children:"Install Location"}),t.jsx("code",{className:"text-xs text-muted-foreground",children:(h==null?void 0:h.installDir)||"~/.coder-config"})]}),t.jsxs("div",{className:"flex items-center justify-between text-sm pt-2",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Auto-Update"}),t.jsx("p",{className:"text-xs text-muted-foreground/70",children:"Automatically install updates when available"})]}),t.jsx(xt,{checked:(r==null?void 0:r.autoUpdate)||!1,onCheckedChange:D=>{Y("autoUpdate",D),he.saveConfig({...r,autoUpdate:D}),q.success(D?"Auto-update enabled":"Auto-update disabled")}})]}),t.jsxs("div",{className:"flex items-center justify-between text-sm pt-2",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Release Channel"}),t.jsx("p",{className:"text-xs text-muted-foreground/70",children:(r==null?void 0:r.releaseChannel)==="beta"?t.jsxs("span",{className:"text-yellow-500 flex items-center gap-1",children:[t.jsx(mi,{className:"w-3 h-3"}),"Beta builds may have bugs"]}):"Stable releases (recommended)"})]}),t.jsxs("select",{value:(r==null?void 0:r.releaseChannel)||"stable",onChange:D=>{const X=D.target.value;X==="beta"?E({open:!0}):(Y("releaseChannel",X),he.saveConfig({...r,releaseChannel:X}),q.success("Switched to stable releases"))},className:"bg-background border border-border rounded px-2 py-1 text-sm",children:[t.jsx("option",{value:"stable",children:"Stable"}),t.jsx("option",{value:"beta",children:"Beta"})]})]}),t.jsxs("div",{className:"border-t border-border pt-3 mt-3 space-y-2",children:[t.jsxs("div",{className:"flex justify-between text-sm",children:[t.jsx("span",{className:"text-muted-foreground",children:"Documentation"}),t.jsx("a",{href:"https://github.com/regression-io/coder-config",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"GitHub"})]}),t.jsxs("div",{className:"flex justify-between text-sm",children:[t.jsx("span",{className:"text-muted-foreground",children:"What's New"}),t.jsxs("button",{onClick:Q,className:"text-primary hover:underline flex items-center gap-1",children:[t.jsx(Tu,{className:"w-3 h-3"}),"Changelog"]})]}),t.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["After updating, restart the server with ",t.jsx("code",{className:"bg-muted-foreground/10 px-1 rounded",children:"coder-config ui"})]})]})]})]})]})]}),t.jsx(Sx,{open:c.open,onOpenChange:D=>d(X=>({...X,open:D})),onSelect:D=>{if(c.field==="toolsDirs"){const X=(r==null?void 0:r.toolsDirs)||(r!=null&&r.toolsDir?[r.toolsDir]:[]);if(c.index===-1)s(te=>{const{toolsDir:fe,...J}=te;return{...J,toolsDirs:[...X,D]}});else{const te=[...X];te[c.index]=D,s(fe=>{const{toolsDir:J,...W}=fe;return{...W,toolsDirs:te}})}}else c.field&&Y(c.field,D)},type:c.type,initialPath:c.field==="toolsDirs"&&c.index>=0?((r==null?void 0:r.toolsDirs)||(r!=null&&r.toolsDir?[r.toolsDir]:[]))[c.index]||"~":(r==null?void 0:r[c.field])||"~",title:c.type==="directory"?"Select Directory":"Select File"}),t.jsx(vt,{open:b.open,onOpenChange:D=>S(X=>({...X,open:D})),children:t.jsxs(ft,{className:"max-w-2xl max-h-[80vh] flex flex-col overflow-hidden",children:[t.jsx(mt,{className:"flex-shrink-0",children:t.jsxs(pt,{className:"flex items-center gap-2",children:[t.jsx(Tu,{className:"w-5 h-5"}),"Changelog"]})}),b.loading?t.jsx("div",{className:"flex items-center justify-center py-12",children:t.jsx(Qe,{className:"w-6 h-6 animate-spin text-primary"})}):t.jsx(Js,{className:"h-[60vh]",children:t.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none pr-4",children:t.jsx(fz,{components:{h1:({children:D})=>t.jsx("h1",{className:"text-xl font-bold text-foreground mb-4",children:D}),h2:({children:D})=>t.jsx("h2",{className:"text-lg font-semibold text-foreground mt-6 mb-3 pb-2 border-b border-border",children:D}),h3:({children:D})=>t.jsx("h3",{className:"text-base font-medium text-foreground mt-4 mb-2",children:D}),p:({children:D})=>t.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:D}),ul:({children:D})=>t.jsx("ul",{className:"text-sm text-muted-foreground list-disc pl-5 mb-3 space-y-1",children:D}),li:({children:D})=>t.jsx("li",{className:"text-sm",children:D}),code:({children:D})=>t.jsx("code",{className:"bg-muted px-1 py-0.5 rounded text-xs font-mono",children:D}),hr:()=>t.jsx("hr",{className:"my-4 border-border"}),strong:({children:D})=>t.jsx("strong",{className:"font-semibold text-foreground",children:D})},children:b.content})})})]})}),t.jsx(vt,{open:N.open,onOpenChange:D=>P(X=>({...X,open:D})),children:t.jsxs(ft,{className:"max-w-md",children:[t.jsxs(mt,{children:[t.jsxs(pt,{className:"flex items-center gap-2 text-yellow-600 dark:text-yellow-400",children:[t.jsx(mi,{className:"w-5 h-5"}),"Experimental Feature Warning"]}),t.jsx(Gt,{className:"pt-2",children:t.jsxs("div",{className:"space-y-3 text-sm text-muted-foreground",children:[t.jsxs("p",{children:[t.jsx("strong",{className:"text-foreground",children:"Ralph Loops"})," is an experimental feature that enables autonomous development loops with Claude Code."]}),t.jsxs("div",{className:"bg-yellow-500/10 border border-yellow-500/20 rounded-lg p-3",children:[t.jsx("p",{className:"text-yellow-700 dark:text-yellow-300 font-medium mb-2",children:"Please be aware:"}),t.jsxs("ul",{className:"list-disc pl-4 space-y-1 text-yellow-600 dark:text-yellow-400",children:[t.jsx("li",{children:"This feature runs Claude autonomously with minimal intervention"}),t.jsx("li",{children:"It may make many API calls and incur costs"}),t.jsx("li",{children:"Always review generated code before committing"}),t.jsx("li",{children:"This feature may change or be removed in future versions"})]})]}),t.jsx("p",{children:"Do you want to enable Ralph Loops?"})]})})]}),t.jsxs(St,{className:"gap-2 sm:gap-0",children:[t.jsx(ne,{variant:"outline",onClick:()=>P({open:!1,feature:null}),children:"Cancel"}),t.jsxs(ne,{variant:"default",className:"bg-yellow-600 hover:bg-yellow-700 text-white",onClick:()=>{const D={...r,experimental:{...r==null?void 0:r.experimental,ralphLoops:!0}};s(D),he.saveConfig(D),e==null||e(D),q.success("Ralph Loops enabled"),P({open:!1,feature:null})},children:[t.jsx(jm,{className:"w-4 h-4 mr-2"}),"Enable Feature"]})]})]})}),t.jsx(vt,{open:A.open,onOpenChange:D=>E({open:D}),children:t.jsxs(ft,{className:"max-w-md",children:[t.jsxs(mt,{children:[t.jsxs(pt,{className:"flex items-center gap-2 text-red-600 dark:text-red-400",children:[t.jsx(mi,{className:"w-5 h-5"}),"Switch to Beta Channel?"]}),t.jsx(Gt,{className:"pt-2",children:t.jsxs("div",{className:"space-y-3 text-sm text-muted-foreground",children:[t.jsxs("p",{children:["You are about to switch to ",t.jsx("strong",{className:"text-foreground",children:"beta releases"}),"."]}),t.jsxs("div",{className:"bg-red-500/10 border border-red-500/20 rounded-lg p-3",children:[t.jsx("p",{className:"text-red-700 dark:text-red-300 font-medium mb-2",children:"Warning:"}),t.jsxs("ul",{className:"list-disc pl-4 space-y-1 text-red-600 dark:text-red-400",children:[t.jsxs("li",{children:[t.jsx("strong",{children:"Things may break"})," - beta releases are not fully tested"]}),t.jsxs("li",{children:[t.jsx("strong",{children:"Data loss possible"})," - bugs could corrupt your configuration"]}),t.jsxs("li",{children:[t.jsx("strong",{children:"Frequent changes"})," - behavior may change unexpectedly"]}),t.jsxs("li",{children:[t.jsx("strong",{children:"No rollback"})," - you'll need to manually downgrade if issues occur"]})]})]}),t.jsx("p",{className:"text-yellow-600 dark:text-yellow-400",children:"Only enable this if you're comfortable debugging issues and reporting bugs."})]})})]}),t.jsxs(St,{className:"gap-2 sm:gap-0",children:[t.jsx(ne,{variant:"outline",onClick:()=>E({open:!1}),children:"Stay on Stable"}),t.jsxs(ne,{variant:"destructive",onClick:()=>{Y("releaseChannel","beta"),he.saveConfig({...r,releaseChannel:"beta"}),q.warning("Switched to beta releases - expect bugs!"),E({open:!1})},children:[t.jsx(mi,{className:"w-4 h-4 mr-2"}),"Switch to Beta"]})]})]})})]})}function yz(){const[e,r]=_.useState(null),[s,n]=_.useState({}),[o,c]=_.useState(!0);_.useEffect(()=>{d()},[]);const d=async()=>{try{c(!0);const[u,f]=await Promise.all([he.getClaudeSettings(),he.getRegistry()]);r(u.settings),n(f.mcpServers||{})}catch(u){console.error("Failed to load Claude settings:",u)}finally{c(!1)}},l=async u=>{try{await he.saveClaudeSettings(u),r(u),q.success("Claude Code settings saved!")}catch(f){q.error("Failed to save settings: "+f.message)}};return o?t.jsx("div",{className:"flex items-center justify-center h-64",children:t.jsx(Qe,{className:"w-8 h-8 animate-spin text-indigo-600"})}):t.jsxs("div",{className:"space-y-6",children:[t.jsx("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 p-6 shadow-sm",children:t.jsx(jN,{settings:e,onSave:l,loading:o,settingsPath:"~/.claude/settings.json",mcpServers:s})}),t.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-4 border border-transparent dark:border-slate-800",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white mb-2",children:"CLI Commands"}),t.jsxs("div",{className:"space-y-1 text-sm text-gray-600 dark:text-slate-400 font-mono",children:[t.jsx("p",{children:"coder-config init # Initialize project"}),t.jsx("p",{children:"coder-config apply # Generate .mcp.json from config"}),t.jsx("p",{children:"coder-config show # Show current project config"})]})]})]})}function bz(){const[e,r]=_.useState(null),[s,n]=_.useState(!0);_.useEffect(()=>{o()},[]);const o=async()=>{try{n(!0);const d=await he.getGeminiSettings();r(d.settings)}catch(d){console.error("Failed to load Gemini settings:",d)}finally{n(!1)}},c=async d=>{try{await he.saveGeminiSettings(d),r(d),q.success("Gemini CLI settings saved!")}catch(l){q.error("Failed to save settings: "+l.message)}};return s?t.jsx("div",{className:"flex items-center justify-center h-64",children:t.jsx(Qe,{className:"w-8 h-8 animate-spin text-blue-600"})}):t.jsxs("div",{className:"space-y-6",children:[t.jsx("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 p-6 shadow-sm",children:t.jsx(NN,{settings:e,onSave:c,loading:s,settingsPath:"~/.gemini/settings.json"})}),t.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-4 border border-transparent dark:border-slate-800",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white mb-2",children:"CLI Commands"}),t.jsxs("div",{className:"space-y-1 text-sm text-gray-600 dark:text-slate-400 font-mono",children:[t.jsx("p",{children:"coder-config apply # Generate settings for all tools"}),t.jsx("p",{children:"coder-config apply --gemini # Generate Gemini settings only"})]})]})]})}const wz=[{id:"off",name:"Off",description:"Never auto-execute; requires allow list"},{id:"auto",name:"Auto",description:"Safety model determines execution"},{id:"turbo",name:"Turbo",description:"Auto-execute unless in deny list",dangerous:!0}],_z=[{id:"always-proceed",name:"Always Proceed",description:"Agent never requests review"},{id:"agent-decides",name:"Agent Decides",description:"Agent determines when review is needed"},{id:"request-review",name:"Request Review",description:"Agent always requests review"}],kz=[{id:"always-proceed",name:"Always Proceed",description:"Maximum autonomy",dangerous:!0},{id:"request-review",name:"Request Review",description:"Ask before browser JavaScript"},{id:"disabled",name:"Disabled",description:"Never run browser JavaScript"}];function Sz({settings:e,onSave:r,loading:s,settingsPath:n}){const[o,c]=_.useState(e||{}),[d,l]=_.useState(!1),[u,f]=_.useState("rich"),[m,h]=_.useState(JSON.stringify(e||{},null,2)),[g,w]=_.useState({open:!1,name:"",json:""}),[j,k]=_.useState({}),v=async()=>{l(!0);try{if(u==="json")try{const A=JSON.parse(m);await r(A),c(A)}catch{q.error("Invalid JSON"),l(!1);return}else await r(o),h(JSON.stringify(o,null,2));q.success("Settings saved")}finally{l(!1)}},y=(A,E)=>{c(M=>({...M,[A]:E}))},x=(A,E)=>(o==null?void 0:o[A])??E,b=o.mcpServers||{},S=()=>{const{name:A,json:E}=g;if(!A.trim()){q.error("Please enter a name for the MCP");return}let M;try{M=JSON.parse(E)}catch{q.error("Invalid JSON configuration");return}if(!M.command){q.error('MCP config must have a "command" field');return}c(I=>({...I,mcpServers:{...I.mcpServers,[A.trim()]:M}})),w({open:!1,name:"",json:""}),q.success(`Added MCP: ${A}`)},N=A=>{c(E=>{const{[A]:M,...I}=E.mcpServers||{};return{...E,mcpServers:I}}),q.success(`Removed MCP: ${A}`)},P=A=>{k(E=>({...E,[A]:!E[A]}))};return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-purple-500/10 flex items-center justify-center",children:t.jsx(Mc,{className:"w-5 h-5 text-purple-500"})}),t.jsxs("div",{children:[t.jsxs("h2",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:["Antigravity Settings",t.jsx(qe,{variant:"outline",className:"text-xs font-normal text-purple-600 border-purple-300 dark:border-purple-700",children:"Google"})]}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Stored in: ",t.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs",children:n})]})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("div",{className:"flex bg-muted rounded-lg p-1",children:[t.jsx("button",{className:`px-3 py-1 text-sm rounded-md transition-colors ${u==="rich"?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>f("rich"),children:"Settings"}),t.jsx("button",{className:`px-3 py-1 text-sm rounded-md transition-colors ${u==="json"?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>{h(JSON.stringify(o,null,2)),f("json")},children:"JSON"})]}),t.jsxs(ne,{onClick:v,disabled:d||s,children:[d?t.jsx(Qe,{className:"w-4 h-4 mr-2 animate-spin"}):t.jsx(Zr,{className:"w-4 h-4 mr-2"}),"Save"]})]})]}),u==="json"?t.jsx("div",{className:"border border-border rounded-lg bg-card overflow-hidden",children:t.jsx(yt,{value:m,onChange:A=>h(A.target.value),className:"font-mono text-sm min-h-[500px] border-0 rounded-none resize-none",placeholder:"{ }"})}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"border border-border rounded-lg p-4 bg-card",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(Qn,{className:"w-4 h-4 text-purple-500"}),"Security Policies"]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Terminal Command Execution"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Control how the agent executes shell commands"})]}),t.jsxs(ir,{value:x("terminalPolicy","auto"),onValueChange:A=>y("terminalPolicy",A),children:[t.jsx(Qt,{className:"w-44",children:t.jsx(or,{})}),t.jsx(Zt,{children:wz.map(A=>t.jsx(gt,{value:A.id,children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{children:A.name}),A.dangerous&&t.jsx(qe,{variant:"destructive",className:"text-xs",children:"Risk"})]})},A.id))})]})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Review Policy"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"When the agent should request human review"})]}),t.jsxs(ir,{value:x("reviewPolicy","agent-decides"),onValueChange:A=>y("reviewPolicy",A),children:[t.jsx(Qt,{className:"w-44",children:t.jsx(or,{})}),t.jsx(Zt,{children:_z.map(A=>t.jsx(gt,{value:A.id,children:A.name},A.id))})]})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"JavaScript Execution"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Control browser JavaScript execution"})]}),t.jsxs(ir,{value:x("jsPolicy","request-review"),onValueChange:A=>y("jsPolicy",A),children:[t.jsx(Qt,{className:"w-44",children:t.jsx(or,{})}),t.jsx(Zt,{children:kz.map(A=>t.jsx(gt,{value:A.id,children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{children:A.name}),A.dangerous&&t.jsx(qe,{variant:"destructive",className:"text-xs",children:"Risk"})]})},A.id))})]})]})]})]}),t.jsxs("div",{className:"border border-border rounded-lg p-4 bg-card",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground flex items-center gap-2",children:[t.jsx(ws,{className:"w-4 h-4 text-purple-500"}),"MCP Servers",t.jsx(qe,{variant:"secondary",className:"text-xs",children:Object.keys(b).length})]}),t.jsxs(ne,{size:"sm",variant:"outline",onClick:()=>w({open:!0,name:"",json:`{
647
+ `}),s}function p_(e){let r=0,s=e.charCodeAt(r);for(;s===9||s===32;)r++,s=e.charCodeAt(r);return e.slice(r)}function g_(e,r){const s=FH(e,r),n=s.one(e,void 0),o=NH(s),c=Array.isArray(n)?{type:"root",children:n}:n||{type:"root",children:[]};return o&&c.children.push({type:"text",value:`
648
+ `},o),c}function WH(e,r){return e&&"run"in e?async function(s,n){const o=g_(s,{file:n,...r});await e.run(o,n)}:function(s,n){return g_(s,{file:n,...e||r})}}function x_(e){if(e)throw e}var Jm,v_;function UH(){if(v_)return Jm;v_=1;var e=Object.prototype.hasOwnProperty,r=Object.prototype.toString,s=Object.defineProperty,n=Object.getOwnPropertyDescriptor,o=function(f){return typeof Array.isArray=="function"?Array.isArray(f):r.call(f)==="[object Array]"},c=function(f){if(!f||r.call(f)!=="[object Object]")return!1;var m=e.call(f,"constructor"),h=f.constructor&&f.constructor.prototype&&e.call(f.constructor.prototype,"isPrototypeOf");if(f.constructor&&!m&&!h)return!1;var g;for(g in f);return typeof g>"u"||e.call(f,g)},d=function(f,m){s&&m.name==="__proto__"?s(f,m.name,{enumerable:!0,configurable:!0,value:m.newValue,writable:!0}):f[m.name]=m.newValue},l=function(f,m){if(m==="__proto__")if(e.call(f,m)){if(n)return n(f,m).value}else return;return f[m]};return Jm=function u(){var f,m,h,g,w,j,k=arguments[0],v=1,y=arguments.length,x=!1;for(typeof k=="boolean"&&(x=k,k=arguments[1]||{},v=2),(k==null||typeof k!="object"&&typeof k!="function")&&(k={});v<y;++v)if(f=arguments[v],f!=null)for(m in f)h=l(k,m),g=l(f,m),k!==g&&(x&&g&&(c(g)||(w=o(g)))?(w?(w=!1,j=h&&o(h)?h:[]):j=h&&c(h)?h:{},d(k,{name:m,newValue:u(x,j,g)})):typeof g<"u"&&d(k,{name:m,newValue:g}));return k},Jm}var VH=UH();const Qm=Nc(VH);function Jp(e){if(typeof e!="object"||e===null)return!1;const r=Object.getPrototypeOf(e);return(r===null||r===Object.prototype||Object.getPrototypeOf(r)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function GH(){const e=[],r={run:s,use:n};return r;function s(...o){let c=-1;const d=o.pop();if(typeof d!="function")throw new TypeError("Expected function as last argument, not "+d);l(null,...o);function l(u,...f){const m=e[++c];let h=-1;if(u){d(u);return}for(;++h<o.length;)(f[h]===null||f[h]===void 0)&&(f[h]=o[h]);o=f,m?qH(m,l)(...f):d(null,...f)}}function n(o){if(typeof o!="function")throw new TypeError("Expected `middelware` to be a function, not "+o);return e.push(o),r}}function qH(e,r){let s;return n;function n(...d){const l=e.length>d.length;let u;l&&d.push(o);try{u=e.apply(this,d)}catch(f){const m=f;if(l&&s)throw m;return o(m)}l||(u&&u.then&&typeof u.then=="function"?u.then(c,o):u instanceof Error?o(u):c(u))}function o(d,...l){s||(s=!0,r(d,...l))}function c(d){o(null,d)}}const $n={basename:KH,dirname:YH,extname:XH,join:JH,sep:"/"};function KH(e,r){if(r!==void 0&&typeof r!="string")throw new TypeError('"ext" argument must be a string');Gc(e);let s=0,n=-1,o=e.length,c;if(r===void 0||r.length===0||r.length>e.length){for(;o--;)if(e.codePointAt(o)===47){if(c){s=o+1;break}}else n<0&&(c=!0,n=o+1);return n<0?"":e.slice(s,n)}if(r===e)return"";let d=-1,l=r.length-1;for(;o--;)if(e.codePointAt(o)===47){if(c){s=o+1;break}}else d<0&&(c=!0,d=o+1),l>-1&&(e.codePointAt(o)===r.codePointAt(l--)?l<0&&(n=o):(l=-1,n=d));return s===n?n=d:n<0&&(n=e.length),e.slice(s,n)}function YH(e){if(Gc(e),e.length===0)return".";let r=-1,s=e.length,n;for(;--s;)if(e.codePointAt(s)===47){if(n){r=s;break}}else n||(n=!0);return r<0?e.codePointAt(0)===47?"/":".":r===1&&e.codePointAt(0)===47?"//":e.slice(0,r)}function XH(e){Gc(e);let r=e.length,s=-1,n=0,o=-1,c=0,d;for(;r--;){const l=e.codePointAt(r);if(l===47){if(d){n=r+1;break}continue}s<0&&(d=!0,s=r+1),l===46?o<0?o=r:c!==1&&(c=1):o>-1&&(c=-1)}return o<0||s<0||c===0||c===1&&o===s-1&&o===n+1?"":e.slice(o,s)}function JH(...e){let r=-1,s;for(;++r<e.length;)Gc(e[r]),e[r]&&(s=s===void 0?e[r]:s+"/"+e[r]);return s===void 0?".":QH(s)}function QH(e){Gc(e);const r=e.codePointAt(0)===47;let s=ZH(e,!r);return s.length===0&&!r&&(s="."),s.length>0&&e.codePointAt(e.length-1)===47&&(s+="/"),r?"/"+s:s}function ZH(e,r){let s="",n=0,o=-1,c=0,d=-1,l,u;for(;++d<=e.length;){if(d<e.length)l=e.codePointAt(d);else{if(l===47)break;l=47}if(l===47){if(!(o===d-1||c===1))if(o!==d-1&&c===2){if(s.length<2||n!==2||s.codePointAt(s.length-1)!==46||s.codePointAt(s.length-2)!==46){if(s.length>2){if(u=s.lastIndexOf("/"),u!==s.length-1){u<0?(s="",n=0):(s=s.slice(0,u),n=s.length-1-s.lastIndexOf("/")),o=d,c=0;continue}}else if(s.length>0){s="",n=0,o=d,c=0;continue}}r&&(s=s.length>0?s+"/..":"..",n=2)}else s.length>0?s+="/"+e.slice(o+1,d):s=e.slice(o+1,d),n=d-o-1;o=d,c=0}else l===46&&c>-1?c++:c=-1}return s}function Gc(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const ez={cwd:tz};function tz(){return"/"}function Qp(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function rz(e){if(typeof e=="string")e=new URL(e);else if(!Qp(e)){const r=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw r.code="ERR_INVALID_ARG_TYPE",r}if(e.protocol!=="file:"){const r=new TypeError("The URL must be of scheme file");throw r.code="ERR_INVALID_URL_SCHEME",r}return sz(e)}function sz(e){if(e.hostname!==""){const n=new TypeError('File URL host must be "localhost" or empty on darwin');throw n.code="ERR_INVALID_FILE_URL_HOST",n}const r=e.pathname;let s=-1;for(;++s<r.length;)if(r.codePointAt(s)===37&&r.codePointAt(s+1)===50){const n=r.codePointAt(s+2);if(n===70||n===102){const o=new TypeError("File URL path must not include encoded / characters");throw o.code="ERR_INVALID_FILE_URL_PATH",o}}return decodeURIComponent(r)}const Zm=["history","path","basename","stem","extname","dirname"];class m2{constructor(r){let s;r?Qp(r)?s={path:r}:typeof r=="string"||nz(r)?s={value:r}:s=r:s={},this.cwd="cwd"in s?"":ez.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<Zm.length;){const c=Zm[n];c in s&&s[c]!==void 0&&s[c]!==null&&(this[c]=c==="history"?[...s[c]]:s[c])}let o;for(o in s)Zm.includes(o)||(this[o]=s[o])}get basename(){return typeof this.path=="string"?$n.basename(this.path):void 0}set basename(r){tp(r,"basename"),ep(r,"basename"),this.path=$n.join(this.dirname||"",r)}get dirname(){return typeof this.path=="string"?$n.dirname(this.path):void 0}set dirname(r){y_(this.basename,"dirname"),this.path=$n.join(r||"",this.basename)}get extname(){return typeof this.path=="string"?$n.extname(this.path):void 0}set extname(r){if(ep(r,"extname"),y_(this.dirname,"extname"),r){if(r.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(r.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=$n.join(this.dirname,this.stem+(r||""))}get path(){return this.history[this.history.length-1]}set path(r){Qp(r)&&(r=rz(r)),tp(r,"path"),this.path!==r&&this.history.push(r)}get stem(){return typeof this.path=="string"?$n.basename(this.path,this.extname):void 0}set stem(r){tp(r,"stem"),ep(r,"stem"),this.path=$n.join(this.dirname||"",r+(this.extname||""))}fail(r,s,n){const o=this.message(r,s,n);throw o.fatal=!0,o}info(r,s,n){const o=this.message(r,s,n);return o.fatal=void 0,o}message(r,s,n){const o=new ms(r,s,n);return this.path&&(o.name=this.path+":"+o.name,o.file=this.path),o.fatal=!1,this.messages.push(o),o}toString(r){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(r||void 0).decode(this.value)}}function ep(e,r){if(e&&e.includes($n.sep))throw new Error("`"+r+"` cannot be a path: did not expect `"+$n.sep+"`")}function tp(e,r){if(!e)throw new Error("`"+r+"` cannot be empty")}function y_(e,r){if(!e)throw new Error("Setting `"+r+"` requires `path` to be set too")}function nz(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const iz=(function(e){const n=this.constructor.prototype,o=n[e],c=function(){return o.apply(c,arguments)};return Object.setPrototypeOf(c,n),c}),oz={}.hasOwnProperty;class Qx extends iz{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=GH()}copy(){const r=new Qx;let s=-1;for(;++s<this.attachers.length;){const n=this.attachers[s];r.use(...n)}return r.data(Qm(!0,{},this.namespace)),r}data(r,s){return typeof r=="string"?arguments.length===2?(np("data",this.frozen),this.namespace[r]=s,this):oz.call(this.namespace,r)&&this.namespace[r]||void 0:r?(np("data",this.frozen),this.namespace=r,this):this.namespace}freeze(){if(this.frozen)return this;const r=this;for(;++this.freezeIndex<this.attachers.length;){const[s,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);const o=s.call(r,...n);typeof o=="function"&&this.transformers.use(o)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(r){this.freeze();const s=uu(r),n=this.parser||this.Parser;return rp("parse",n),n(String(s),s)}process(r,s){const n=this;return this.freeze(),rp("process",this.parser||this.Parser),sp("process",this.compiler||this.Compiler),s?o(void 0,s):new Promise(o);function o(c,d){const l=uu(r),u=n.parse(l);n.run(u,l,function(m,h,g){if(m||!h||!g)return f(m);const w=h,j=n.stringify(w,g);cz(j)?g.value=j:g.result=j,f(m,g)});function f(m,h){m||!h?d(m):c?c(h):s(void 0,h)}}}processSync(r){let s=!1,n;return this.freeze(),rp("processSync",this.parser||this.Parser),sp("processSync",this.compiler||this.Compiler),this.process(r,o),w_("processSync","process",s),n;function o(c,d){s=!0,x_(c),n=d}}run(r,s,n){b_(r),this.freeze();const o=this.transformers;return!n&&typeof s=="function"&&(n=s,s=void 0),n?c(void 0,n):new Promise(c);function c(d,l){const u=uu(s);o.run(r,u,f);function f(m,h,g){const w=h||r;m?l(m):d?d(w):n(void 0,w,g)}}}runSync(r,s){let n=!1,o;return this.run(r,s,c),w_("runSync","run",n),o;function c(d,l){x_(d),o=l,n=!0}}stringify(r,s){this.freeze();const n=uu(s),o=this.compiler||this.Compiler;return sp("stringify",o),b_(r),o(r,n)}use(r,...s){const n=this.attachers,o=this.namespace;if(np("use",this.frozen),r!=null)if(typeof r=="function")u(r,s);else if(typeof r=="object")Array.isArray(r)?l(r):d(r);else throw new TypeError("Expected usable value, not `"+r+"`");return this;function c(f){if(typeof f=="function")u(f,[]);else if(typeof f=="object")if(Array.isArray(f)){const[m,...h]=f;u(m,h)}else d(f);else throw new TypeError("Expected usable value, not `"+f+"`")}function d(f){if(!("plugins"in f)&&!("settings"in f))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");l(f.plugins),f.settings&&(o.settings=Qm(!0,o.settings,f.settings))}function l(f){let m=-1;if(f!=null)if(Array.isArray(f))for(;++m<f.length;){const h=f[m];c(h)}else throw new TypeError("Expected a list of plugins, not `"+f+"`")}function u(f,m){let h=-1,g=-1;for(;++h<n.length;)if(n[h][0]===f){g=h;break}if(g===-1)n.push([f,...m]);else if(m.length>0){let[w,...j]=m;const k=n[g][1];Jp(k)&&Jp(w)&&(w=Qm(!0,k,w)),n[g]=[f,w,...j]}}}}const az=new Qx().freeze();function rp(e,r){if(typeof r!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function sp(e,r){if(typeof r!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function np(e,r){if(r)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function b_(e){if(!Jp(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function w_(e,r,s){if(!s)throw new Error("`"+e+"` finished async. Use `"+r+"` instead")}function uu(e){return lz(e)?e:new m2(e)}function lz(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function cz(e){return typeof e=="string"||dz(e)}function dz(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const uz="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",__=[],k_={allowDangerousHtml:!0},hz=/^(https?|ircs?|mailto|xmpp)$/i,fz=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"className",id:"remove-classname"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function mz(e){const r=pz(e),s=gz(e);return xz(r.runSync(r.parse(s),s),e)}function pz(e){const r=e.rehypePlugins||__,s=e.remarkPlugins||__,n=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...k_}:k_;return az().use(q9).use(s).use(WH,n).use(r)}function gz(e){const r=e.children||"",s=new m2;return typeof r=="string"&&(s.value=r),s}function xz(e,r){const s=r.allowedElements,n=r.allowElement,o=r.components,c=r.disallowedElements,d=r.skipHtml,l=r.unwrapDisallowed,u=r.urlTransform||vz;for(const m of fz)Object.hasOwn(r,m.from)&&(""+m.from+(m.to?"use `"+m.to+"` instead":"remove it")+uz+m.id,void 0);return f2(e,f),j7(e,{Fragment:t.Fragment,components:o,ignoreInvalidStyle:!0,jsx:t.jsx,jsxs:t.jsxs,passKeys:!0,passNode:!0});function f(m,h,g){if(m.type==="raw"&&g&&typeof h=="number")return d?g.children.splice(h,1):g.children[h]={type:"text",value:m.value},h;if(m.type==="element"){let w;for(w in Km)if(Object.hasOwn(Km,w)&&Object.hasOwn(m.properties,w)){const j=m.properties[w],k=Km[w];(k===null||k.includes(m.tagName))&&(m.properties[w]=u(String(j||""),w,m))}}if(m.type==="element"){let w=s?!s.includes(m.tagName):c?c.includes(m.tagName):!1;if(!w&&n&&typeof h=="number"&&(w=!n(m,h,g)),w&&g&&typeof h=="number")return l&&m.children?g.children.splice(h,1,...m.children):g.children.splice(h,1),h}}}function vz(e){const r=e.indexOf(":"),s=e.indexOf("?"),n=e.indexOf("#"),o=e.indexOf("/");return r===-1||o!==-1&&r>o||s!==-1&&r>s||n!==-1&&r>n||hz.test(e.slice(0,r))?e:""}function yz({onConfigChange:e}){var T,F,$;const[r,s]=_.useState(null),[n,o]=_.useState(""),[c,d]=_.useState({open:!1,field:null,type:"directory"}),[l,u]=_.useState(!0),[f,m]=_.useState(!1),[h,g]=_.useState(null),[w,j]=_.useState(!1),[k,v]=_.useState(null),[y,x]=_.useState([]),[b,S]=_.useState({open:!1,content:"",loading:!1}),[N,P]=_.useState({open:!1,feature:null}),[A,E]=_.useState({open:!1});_.useEffect(()=>{z(),M(),I()},[]);const M=async()=>{try{const D=await he.checkVersion();g(D)}catch(D){console.error("Failed to load version info:",D)}},I=async()=>{try{const D=await he.getProject();v(D.dir),B(D.dir)}catch(D){console.error("Failed to load project info:",D)}},B=async D=>{if(D)try{const X=await he.getHiddenSubprojects(D);x(X.hidden||[])}catch(X){console.error("Failed to load hidden sub-projects:",X)}},U=async D=>{if(k)try{const X=await he.unhideSubproject(k,D);X.success?(q.success("Sub-project unhidden"),B(k)):q.error(X.error||"Failed to unhide")}catch(X){q.error("Failed to unhide: "+X.message)}},V=async()=>{if(!(h!=null&&h.updateAvailable)){q.error("No update available");return}j(!0);try{const D=await he.performUpdate({updateMethod:h.updateMethod,sourcePath:h.sourcePath,channel:h.channel});if(D.success){q.success(`Updated to v${D.newVersion}! Restarting server...`);try{await he.restartServer()}catch{}let X=0;const te=setInterval(async()=>{X++;try{await he.checkVersion(),clearInterval(te),q.success("Server restarted! Reloading..."),setTimeout(()=>window.location.reload(),500)}catch{X>30&&(clearInterval(te),q.info("Server restarting. Please refresh the page."),j(!1))}},500)}else q.error("Update failed: "+D.error),j(!1)}catch(D){q.error("Update failed: "+D.message),j(!1)}},Q=async()=>{S(D=>({...D,open:!0,loading:!0}));try{const D=await he.getChangelog();D.success?S(X=>({...X,content:D.content,loading:!1})):(q.error("Failed to load changelog"),S(X=>({...X,open:!1,loading:!1})))}catch(D){q.error("Failed to load changelog: "+D.message),S(X=>({...X,open:!1,loading:!1}))}},z=async()=>{try{u(!0);const D=await he.getConfig();s(D.config),o(D.path)}catch{q.error("Failed to load settings")}finally{u(!1)}},H=async()=>{m(!0);try{await he.saveConfig(r),q.success("Preferences saved!")}catch{q.error("Failed to save preferences")}finally{m(!1)}},Y=(D,X)=>{s(te=>({...te,[D]:X}))},K=(D,X,te)=>{s(fe=>({...fe,[D]:{...fe[D],[X]:te}}))},O=async D=>{const X=(r==null?void 0:r.enabledTools)||["claude"];let te;if(X.includes(D)){if(X.length<=1){q.error("At least one tool must be enabled");return}te=X.filter(J=>J!==D)}else te=[...X,D];const fe={...r,enabledTools:te};s(fe);try{await he.saveConfig(fe),e==null||e(fe);const J={claude:"Claude Code",gemini:"Gemini CLI",antigravity:"Antigravity",codex:"Codex CLI"}[D]||D;q.success(`${J} ${te.includes(D)?"enabled":"disabled"}`)}catch{s(r),q.error("Failed to save preference")}};return l?t.jsx("div",{className:"flex items-center justify-center h-64",children:t.jsx(Qe,{className:"w-8 h-8 animate-spin text-primary"})}):t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-muted flex items-center justify-center",children:t.jsx(wS,{className:"w-5 h-5 text-muted-foreground"})}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-foreground",children:"coder-config Preferences"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Tool settings for this configuration manager"})]})]}),t.jsxs("div",{className:"bg-card rounded-xl border border-border p-6 shadow-sm",children:[t.jsxs("div",{className:"flex items-center justify-between mb-6",children:[t.jsx("div",{children:t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Stored in: ",t.jsx("code",{className:"bg-muted px-2 py-0.5 rounded",children:n})]})}),t.jsxs(ne,{onClick:H,disabled:f,children:[f?t.jsx(Qe,{className:"w-4 h-4 mr-2 animate-spin"}):t.jsx(Zr,{className:"w-4 h-4 mr-2"}),"Save"]})]}),t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"border-b border-border pb-6",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(Xr,{className:"w-4 h-4"}),"Directories"]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"MCP Tools Directories"}),t.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Folders containing local MCP tool repositories for discovery"}),t.jsxs("div",{className:"space-y-2",children:[((r==null?void 0:r.toolsDirs)||(r!=null&&r.toolsDir?[r.toolsDir]:[])).map((D,X)=>t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Oe,{value:D||"",onChange:te=>{const fe=[...(r==null?void 0:r.toolsDirs)||(r!=null&&r.toolsDir?[r.toolsDir]:[])];fe[X]=te.target.value,Y("toolsDirs",fe),r!=null&&r.toolsDir&&s(J=>{const{toolsDir:W,...le}=J;return{...le,toolsDirs:fe}})},placeholder:"~/mcp-tools",className:"font-mono flex-1"}),t.jsx(ne,{variant:"outline",size:"icon",onClick:()=>d({open:!0,field:"toolsDirs",type:"directory",index:X}),title:"Browse...",children:t.jsx(Zi,{className:"w-4 h-4"})}),t.jsx(ne,{variant:"outline",size:"icon",onClick:()=>{const fe=((r==null?void 0:r.toolsDirs)||(r!=null&&r.toolsDir?[r.toolsDir]:[])).filter((J,W)=>W!==X);s(J=>{const{toolsDir:W,...le}=J;return{...le,toolsDirs:fe.length>0?fe:void 0}})},title:"Remove",className:"text-destructive hover:text-destructive",children:t.jsx(Nn,{className:"w-4 h-4"})})]},X)),t.jsxs(ne,{variant:"outline",size:"sm",onClick:()=>d({open:!0,field:"toolsDirs",type:"directory",index:-1}),className:"mt-2",children:[t.jsx(fi,{className:"w-4 h-4 mr-2"}),"Add Tools Folder"]})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Global Registry Path"}),t.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Path to the global MCP registry file"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Oe,{value:(r==null?void 0:r.registryPath)||"",onChange:D=>Y("registryPath",D.target.value),placeholder:"~/.claude/registry.json",className:"font-mono flex-1"}),t.jsx(ne,{variant:"outline",size:"icon",onClick:()=>d({open:!0,field:"registryPath",type:"file"}),title:"Browse...",children:t.jsx(Zi,{className:"w-4 h-4"})})]})]})]})]}),t.jsxs("div",{className:"border-b border-border pb-6",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(Z5,{className:"w-4 h-4"}),"User Interface"]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Default Port"}),t.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Port for the web UI server"}),t.jsx(Oe,{type:"number",value:((T=r==null?void 0:r.ui)==null?void 0:T.port)||3333,onChange:D=>K("ui","port",parseInt(D.target.value)||3333),placeholder:"3333",className:"w-32"})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Open Browser on Start"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Automatically open browser when starting the UI"})]}),t.jsx(xt,{checked:((F=r==null?void 0:r.ui)==null?void 0:F.openBrowser)??!0,onCheckedChange:D=>K("ui","openBrowser",D)})]})]})]}),t.jsxs("div",{className:"border-b border-border pb-6",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(MM,{className:"w-4 h-4"}),"AI Assistant"]}),t.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Choose which AI assistant to use for features like MCP creation and tool import."}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg cursor-pointer border-2 transition-colors ${((r==null?void 0:r.aiAssistant)||"claude")==="claude"?"border-orange-500 bg-orange-500/5":"border-transparent bg-muted/50 hover:bg-muted"}`,onClick:()=>Y("aiAssistant","claude"),children:[t.jsx("input",{type:"radio",name:"aiAssistant",value:"claude",checked:((r==null?void 0:r.aiAssistant)||"claude")==="claude",onChange:()=>Y("aiAssistant","claude"),className:"sr-only"}),t.jsx("div",{className:"w-8 h-8 rounded-md bg-orange-500/10 flex items-center justify-center",children:t.jsx(Vt,{className:"w-4 h-4 text-orange-500"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("span",{className:"text-sm font-medium text-foreground",children:"Claude Code"}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Anthropic's AI coding assistant • Command: ",t.jsx("code",{className:"text-xs",children:"claude"})]})]}),((r==null?void 0:r.aiAssistant)||"claude")==="claude"&&t.jsx("div",{className:"w-2 h-2 rounded-full bg-orange-500"})]}),t.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg cursor-pointer border-2 transition-colors ${(r==null?void 0:r.aiAssistant)==="gemini"?"border-blue-500 bg-blue-500/5":"border-transparent bg-muted/50 hover:bg-muted"}`,onClick:()=>Y("aiAssistant","gemini"),children:[t.jsx("input",{type:"radio",name:"aiAssistant",value:"gemini",checked:(r==null?void 0:r.aiAssistant)==="gemini",onChange:()=>Y("aiAssistant","gemini"),className:"sr-only"}),t.jsx("div",{className:"w-8 h-8 rounded-md bg-blue-500/10 flex items-center justify-center",children:t.jsx(Ut,{className:"w-4 h-4 text-blue-500"})}),t.jsxs("div",{className:"flex-1",children:[t.jsx("span",{className:"text-sm font-medium text-foreground",children:"Gemini CLI"}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Google's AI coding assistant • Command: ",t.jsx("code",{className:"text-xs",children:"gemini"})]})]}),(r==null?void 0:r.aiAssistant)==="gemini"&&t.jsx("div",{className:"w-2 h-2 rounded-full bg-blue-500"})]})]})]}),t.jsxs("div",{className:"border-b border-border pb-6",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(r5,{className:"w-4 h-4"}),"Enabled AI Tools"]}),t.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"Select which AI coding tools to generate MCP configurations for. The Apply button will update all enabled tools."}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/50 rounded-lg",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-8 h-8 rounded-md bg-orange-500/10 flex items-center justify-center",children:t.jsx(Vt,{className:"w-4 h-4 text-orange-500"})}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Claude Code"}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Anthropic's AI coding assistant • Output: ",t.jsx("code",{className:"text-xs",children:".mcp.json"})]})]})]}),t.jsx(xt,{checked:((r==null?void 0:r.enabledTools)||["claude"]).includes("claude"),onCheckedChange:()=>O("claude")})]}),t.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/50 rounded-lg",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-8 h-8 rounded-md bg-blue-500/10 flex items-center justify-center",children:t.jsx(Vt,{className:"w-4 h-4 text-blue-500"})}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Gemini CLI"}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Google's terminal AI coding assistant • Output: ",t.jsx("code",{className:"text-xs",children:"~/.gemini/settings.json"})]})]})]}),t.jsx(xt,{checked:((r==null?void 0:r.enabledTools)||["claude"]).includes("gemini"),onCheckedChange:()=>O("gemini")})]}),t.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/50 rounded-lg",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-8 h-8 rounded-md bg-purple-500/10 flex items-center justify-center",children:t.jsx(Vt,{className:"w-4 h-4 text-purple-500"})}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Antigravity"}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["Google's AI IDE • Output: ",t.jsx("code",{className:"text-xs",children:"~/.gemini/antigravity/mcp_config.json"})]})]})]}),t.jsx(xt,{checked:((r==null?void 0:r.enabledTools)||["claude"]).includes("antigravity"),onCheckedChange:()=>O("antigravity")})]}),t.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/50 rounded-lg",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-8 h-8 rounded-md bg-green-500/10 flex items-center justify-center",children:t.jsx(Vt,{className:"w-4 h-4 text-green-500"})}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Codex CLI"}),t.jsxs("p",{className:"text-xs text-muted-foreground",children:["OpenAI's terminal coding assistant • Output: ",t.jsx("code",{className:"text-xs",children:".codex/mcp.json"})]})]})]}),t.jsx(xt,{checked:((r==null?void 0:r.enabledTools)||["claude"]).includes("codex"),onCheckedChange:()=>O("codex")})]}),t.jsxs("p",{className:"text-xs text-muted-foreground italic",children:["Note: Antigravity does not support environment variable interpolation (",t.jsx("code",{children:"${VAR}"}),"). Variables are resolved to actual values when generating its config."]})]})]}),y.length>0&&t.jsxs("div",{children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(gS,{className:"w-4 h-4"}),"Hidden Sub-projects"]}),t.jsx("div",{className:"space-y-2",children:y.map(D=>t.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/50 rounded-lg",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Xr,{className:"w-4 h-4 text-muted-foreground"}),t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium text-foreground",children:D.name}),t.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:D.dir.replace(k+"/","")})]})]}),t.jsxs(ne,{size:"sm",variant:"outline",onClick:()=>U(D.dir),className:"h-7",children:[t.jsx(Fg,{className:"w-3 h-3 mr-1"}),"Unhide"]})]},D.dir))})]}),t.jsxs("div",{className:"border-b border-border pb-6",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(jm,{className:"w-4 h-4"}),"Experimental Features"]}),t.jsx("p",{className:"text-xs text-muted-foreground mb-4",children:"These features are experimental and may change or be removed in future versions."}),t.jsx("div",{className:"space-y-4",children:t.jsxs("div",{className:"flex items-center justify-between p-3 bg-muted/50 rounded-lg border border-yellow-500/20",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-8 h-8 rounded-md bg-yellow-500/10 flex items-center justify-center",children:t.jsx(jm,{className:"w-4 h-4 text-yellow-500"})}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Ralph Loops"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Autonomous development loops with Claude Code"})]})]}),t.jsx(xt,{checked:(($=r==null?void 0:r.experimental)==null?void 0:$.ralphLoops)||!1,onCheckedChange:D=>{if(D)P({open:!0,feature:"ralphLoops"});else{const X={...r,experimental:{...r==null?void 0:r.experimental,ralphLoops:!1}};s(X),he.saveConfig(X),e==null||e(X),q.success("Ralph Loops disabled")}}})]})})]}),t.jsxs("div",{children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(vr,{className:"w-4 h-4"}),"About"]}),t.jsxs("div",{className:"bg-muted rounded-lg p-4 space-y-3",children:[t.jsxs("div",{className:"flex justify-between text-sm",children:[t.jsx("span",{className:"text-muted-foreground",children:"Installed Version"}),t.jsx("span",{className:"font-medium font-mono text-foreground",children:(h==null?void 0:h.installedVersion)||"Loading..."})]}),(h==null?void 0:h.updateAvailable)&&t.jsx("div",{className:"p-3 bg-green-500/10 border border-green-500/20 rounded-lg",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium text-green-600 dark:text-green-400",children:"Update Available!"}),t.jsxs("p",{className:"text-xs text-green-600/80 dark:text-green-400/80",children:["Version ",h.latestVersion," via ",h.updateMethod==="npm"?"npm":h.sourcePath]})]}),t.jsxs(ne,{size:"sm",onClick:V,disabled:w,className:"bg-green-600 hover:bg-green-700 text-white",children:[w?t.jsx(Qe,{className:"w-4 h-4 mr-2 animate-spin"}):t.jsx(yi,{className:"w-4 h-4 mr-2"}),"Update Now"]})]})}),!(h!=null&&h.updateAvailable)&&(h==null?void 0:h.latestVersion)&&t.jsxs("div",{className:"flex justify-between text-sm",children:[t.jsx("span",{className:"text-muted-foreground",children:"Latest Version"}),t.jsxs("span",{className:"font-mono text-green-600 dark:text-green-400",children:[h.latestVersion," ✓"]})]}),(h==null?void 0:h.sourcePath)&&!(h!=null&&h.updateAvailable)&&t.jsxs("div",{className:"flex items-center justify-between text-sm",children:[t.jsx("span",{className:"text-muted-foreground",children:"Dev Source"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("code",{className:"text-xs text-muted-foreground",children:h.sourcePath}),t.jsx(ne,{size:"sm",variant:"outline",onClick:V,disabled:w,className:"h-7",children:w?t.jsx(Qe,{className:"w-3 h-3 animate-spin"}):t.jsx(Dr,{className:"w-3 h-3"})})]})]}),t.jsxs("div",{className:"flex justify-between text-sm",children:[t.jsx("span",{className:"text-muted-foreground",children:"Install Location"}),t.jsx("code",{className:"text-xs text-muted-foreground",children:(h==null?void 0:h.installDir)||"~/.coder-config"})]}),t.jsxs("div",{className:"flex items-center justify-between text-sm pt-2",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Auto-Update"}),t.jsx("p",{className:"text-xs text-muted-foreground/70",children:"Automatically install updates when available"})]}),t.jsx(xt,{checked:(r==null?void 0:r.autoUpdate)||!1,onCheckedChange:D=>{Y("autoUpdate",D),he.saveConfig({...r,autoUpdate:D}),q.success(D?"Auto-update enabled":"Auto-update disabled")}})]}),t.jsxs("div",{className:"flex items-center justify-between text-sm pt-2",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Release Channel"}),t.jsx("p",{className:"text-xs text-muted-foreground/70",children:(r==null?void 0:r.releaseChannel)==="beta"?t.jsxs("span",{className:"text-yellow-500 flex items-center gap-1",children:[t.jsx(mi,{className:"w-3 h-3"}),"Beta builds may have bugs"]}):"Stable releases (recommended)"})]}),t.jsxs("select",{value:(r==null?void 0:r.releaseChannel)||"stable",onChange:D=>{const X=D.target.value;X==="beta"?E({open:!0}):(Y("releaseChannel",X),he.saveConfig({...r,releaseChannel:X}),q.success("Switched to stable releases"))},className:"bg-background border border-border rounded px-2 py-1 text-sm",children:[t.jsx("option",{value:"stable",children:"Stable"}),t.jsx("option",{value:"beta",children:"Beta"})]})]}),t.jsxs("div",{className:"border-t border-border pt-3 mt-3 space-y-2",children:[t.jsxs("div",{className:"flex justify-between text-sm",children:[t.jsx("span",{className:"text-muted-foreground",children:"Documentation"}),t.jsx("a",{href:"https://github.com/regression-io/coder-config",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"GitHub"})]}),t.jsxs("div",{className:"flex justify-between text-sm",children:[t.jsx("span",{className:"text-muted-foreground",children:"What's New"}),t.jsxs("button",{onClick:Q,className:"text-primary hover:underline flex items-center gap-1",children:[t.jsx(Tu,{className:"w-3 h-3"}),"Changelog"]})]}),t.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["After updating, restart the server with ",t.jsx("code",{className:"bg-muted-foreground/10 px-1 rounded",children:"coder-config ui"})]})]})]})]})]})]}),t.jsx(Sx,{open:c.open,onOpenChange:D=>d(X=>({...X,open:D})),onSelect:D=>{if(c.field==="toolsDirs"){const X=(r==null?void 0:r.toolsDirs)||(r!=null&&r.toolsDir?[r.toolsDir]:[]);if(c.index===-1)s(te=>{const{toolsDir:fe,...J}=te;return{...J,toolsDirs:[...X,D]}});else{const te=[...X];te[c.index]=D,s(fe=>{const{toolsDir:J,...W}=fe;return{...W,toolsDirs:te}})}}else c.field&&Y(c.field,D)},type:c.type,initialPath:c.field==="toolsDirs"&&c.index>=0?((r==null?void 0:r.toolsDirs)||(r!=null&&r.toolsDir?[r.toolsDir]:[]))[c.index]||"~":(r==null?void 0:r[c.field])||"~",title:c.type==="directory"?"Select Directory":"Select File"}),t.jsx(vt,{open:b.open,onOpenChange:D=>S(X=>({...X,open:D})),children:t.jsxs(ft,{className:"max-w-2xl max-h-[80vh] flex flex-col overflow-hidden",children:[t.jsx(mt,{className:"flex-shrink-0",children:t.jsxs(pt,{className:"flex items-center gap-2",children:[t.jsx(Tu,{className:"w-5 h-5"}),"Changelog"]})}),b.loading?t.jsx("div",{className:"flex items-center justify-center py-12",children:t.jsx(Qe,{className:"w-6 h-6 animate-spin text-primary"})}):t.jsx(Js,{className:"h-[60vh]",children:t.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none pr-4",children:t.jsx(mz,{components:{h1:({children:D})=>t.jsx("h1",{className:"text-xl font-bold text-foreground mb-4",children:D}),h2:({children:D})=>t.jsx("h2",{className:"text-lg font-semibold text-foreground mt-6 mb-3 pb-2 border-b border-border",children:D}),h3:({children:D})=>t.jsx("h3",{className:"text-base font-medium text-foreground mt-4 mb-2",children:D}),p:({children:D})=>t.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:D}),ul:({children:D})=>t.jsx("ul",{className:"text-sm text-muted-foreground list-disc pl-5 mb-3 space-y-1",children:D}),li:({children:D})=>t.jsx("li",{className:"text-sm",children:D}),code:({children:D})=>t.jsx("code",{className:"bg-muted px-1 py-0.5 rounded text-xs font-mono",children:D}),hr:()=>t.jsx("hr",{className:"my-4 border-border"}),strong:({children:D})=>t.jsx("strong",{className:"font-semibold text-foreground",children:D})},children:b.content})})})]})}),t.jsx(vt,{open:N.open,onOpenChange:D=>P(X=>({...X,open:D})),children:t.jsxs(ft,{className:"max-w-md",children:[t.jsxs(mt,{children:[t.jsxs(pt,{className:"flex items-center gap-2 text-yellow-600 dark:text-yellow-400",children:[t.jsx(mi,{className:"w-5 h-5"}),"Experimental Feature Warning"]}),t.jsx(Gt,{className:"pt-2",children:t.jsxs("div",{className:"space-y-3 text-sm text-muted-foreground",children:[t.jsxs("p",{children:[t.jsx("strong",{className:"text-foreground",children:"Ralph Loops"})," is an experimental feature that enables autonomous development loops with Claude Code."]}),t.jsxs("div",{className:"bg-yellow-500/10 border border-yellow-500/20 rounded-lg p-3",children:[t.jsx("p",{className:"text-yellow-700 dark:text-yellow-300 font-medium mb-2",children:"Please be aware:"}),t.jsxs("ul",{className:"list-disc pl-4 space-y-1 text-yellow-600 dark:text-yellow-400",children:[t.jsx("li",{children:"This feature runs Claude autonomously with minimal intervention"}),t.jsx("li",{children:"It may make many API calls and incur costs"}),t.jsx("li",{children:"Always review generated code before committing"}),t.jsx("li",{children:"This feature may change or be removed in future versions"})]})]}),t.jsx("p",{children:"Do you want to enable Ralph Loops?"})]})})]}),t.jsxs(St,{className:"gap-2 sm:gap-0",children:[t.jsx(ne,{variant:"outline",onClick:()=>P({open:!1,feature:null}),children:"Cancel"}),t.jsxs(ne,{variant:"default",className:"bg-yellow-600 hover:bg-yellow-700 text-white",onClick:()=>{const D={...r,experimental:{...r==null?void 0:r.experimental,ralphLoops:!0}};s(D),he.saveConfig(D),e==null||e(D),q.success("Ralph Loops enabled"),P({open:!1,feature:null})},children:[t.jsx(jm,{className:"w-4 h-4 mr-2"}),"Enable Feature"]})]})]})}),t.jsx(vt,{open:A.open,onOpenChange:D=>E({open:D}),children:t.jsxs(ft,{className:"max-w-md",children:[t.jsxs(mt,{children:[t.jsxs(pt,{className:"flex items-center gap-2 text-red-600 dark:text-red-400",children:[t.jsx(mi,{className:"w-5 h-5"}),"Switch to Beta Channel?"]}),t.jsx(Gt,{className:"pt-2",children:t.jsxs("div",{className:"space-y-3 text-sm text-muted-foreground",children:[t.jsxs("p",{children:["You are about to switch to ",t.jsx("strong",{className:"text-foreground",children:"beta releases"}),"."]}),t.jsxs("div",{className:"bg-red-500/10 border border-red-500/20 rounded-lg p-3",children:[t.jsx("p",{className:"text-red-700 dark:text-red-300 font-medium mb-2",children:"Warning:"}),t.jsxs("ul",{className:"list-disc pl-4 space-y-1 text-red-600 dark:text-red-400",children:[t.jsxs("li",{children:[t.jsx("strong",{children:"Things may break"})," - beta releases are not fully tested"]}),t.jsxs("li",{children:[t.jsx("strong",{children:"Data loss possible"})," - bugs could corrupt your configuration"]}),t.jsxs("li",{children:[t.jsx("strong",{children:"Frequent changes"})," - behavior may change unexpectedly"]}),t.jsxs("li",{children:[t.jsx("strong",{children:"No rollback"})," - you'll need to manually downgrade if issues occur"]})]})]}),t.jsx("p",{className:"text-yellow-600 dark:text-yellow-400",children:"Only enable this if you're comfortable debugging issues and reporting bugs."})]})})]}),t.jsxs(St,{className:"gap-2 sm:gap-0",children:[t.jsx(ne,{variant:"outline",onClick:()=>E({open:!1}),children:"Stay on Stable"}),t.jsxs(ne,{variant:"destructive",onClick:()=>{Y("releaseChannel","beta"),he.saveConfig({...r,releaseChannel:"beta"}),q.warning("Switched to beta releases - expect bugs!"),E({open:!1})},children:[t.jsx(mi,{className:"w-4 h-4 mr-2"}),"Switch to Beta"]})]})]})})]})}function bz(){const[e,r]=_.useState(null),[s,n]=_.useState({}),[o,c]=_.useState(!0);_.useEffect(()=>{d()},[]);const d=async()=>{try{c(!0);const[u,f]=await Promise.all([he.getClaudeSettings(),he.getRegistry()]);r(u.settings),n(f.mcpServers||{})}catch(u){console.error("Failed to load Claude settings:",u)}finally{c(!1)}},l=async u=>{try{await he.saveClaudeSettings(u),r(u),q.success("Claude Code settings saved!")}catch(f){q.error("Failed to save settings: "+f.message)}};return o?t.jsx("div",{className:"flex items-center justify-center h-64",children:t.jsx(Qe,{className:"w-8 h-8 animate-spin text-indigo-600"})}):t.jsxs("div",{className:"space-y-6",children:[t.jsx("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 p-6 shadow-sm",children:t.jsx(jN,{settings:e,onSave:l,loading:o,settingsPath:"~/.claude/settings.json",mcpServers:s})}),t.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-4 border border-transparent dark:border-slate-800",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white mb-2",children:"CLI Commands"}),t.jsxs("div",{className:"space-y-1 text-sm text-gray-600 dark:text-slate-400 font-mono",children:[t.jsx("p",{children:"coder-config init # Initialize project"}),t.jsx("p",{children:"coder-config apply # Generate .mcp.json from config"}),t.jsx("p",{children:"coder-config show # Show current project config"})]})]})]})}function wz(){const[e,r]=_.useState(null),[s,n]=_.useState(!0);_.useEffect(()=>{o()},[]);const o=async()=>{try{n(!0);const d=await he.getGeminiSettings();r(d.settings)}catch(d){console.error("Failed to load Gemini settings:",d)}finally{n(!1)}},c=async d=>{try{await he.saveGeminiSettings(d),r(d),q.success("Gemini CLI settings saved!")}catch(l){q.error("Failed to save settings: "+l.message)}};return s?t.jsx("div",{className:"flex items-center justify-center h-64",children:t.jsx(Qe,{className:"w-8 h-8 animate-spin text-blue-600"})}):t.jsxs("div",{className:"space-y-6",children:[t.jsx("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 p-6 shadow-sm",children:t.jsx(NN,{settings:e,onSave:c,loading:s,settingsPath:"~/.gemini/settings.json"})}),t.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-4 border border-transparent dark:border-slate-800",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white mb-2",children:"CLI Commands"}),t.jsxs("div",{className:"space-y-1 text-sm text-gray-600 dark:text-slate-400 font-mono",children:[t.jsx("p",{children:"coder-config apply # Generate settings for all tools"}),t.jsx("p",{children:"coder-config apply --gemini # Generate Gemini settings only"})]})]})]})}const _z=[{id:"off",name:"Off",description:"Never auto-execute; requires allow list"},{id:"auto",name:"Auto",description:"Safety model determines execution"},{id:"turbo",name:"Turbo",description:"Auto-execute unless in deny list",dangerous:!0}],kz=[{id:"always-proceed",name:"Always Proceed",description:"Agent never requests review"},{id:"agent-decides",name:"Agent Decides",description:"Agent determines when review is needed"},{id:"request-review",name:"Request Review",description:"Agent always requests review"}],Sz=[{id:"always-proceed",name:"Always Proceed",description:"Maximum autonomy",dangerous:!0},{id:"request-review",name:"Request Review",description:"Ask before browser JavaScript"},{id:"disabled",name:"Disabled",description:"Never run browser JavaScript"}];function Cz({settings:e,onSave:r,loading:s,settingsPath:n}){const[o,c]=_.useState(e||{}),[d,l]=_.useState(!1),[u,f]=_.useState("rich"),[m,h]=_.useState(JSON.stringify(e||{},null,2)),[g,w]=_.useState({open:!1,name:"",json:""}),[j,k]=_.useState({}),v=async()=>{l(!0);try{if(u==="json")try{const A=JSON.parse(m);await r(A),c(A)}catch{q.error("Invalid JSON"),l(!1);return}else await r(o),h(JSON.stringify(o,null,2));q.success("Settings saved")}finally{l(!1)}},y=(A,E)=>{c(M=>({...M,[A]:E}))},x=(A,E)=>(o==null?void 0:o[A])??E,b=o.mcpServers||{},S=()=>{const{name:A,json:E}=g;if(!A.trim()){q.error("Please enter a name for the MCP");return}let M;try{M=JSON.parse(E)}catch{q.error("Invalid JSON configuration");return}if(!M.command){q.error('MCP config must have a "command" field');return}c(I=>({...I,mcpServers:{...I.mcpServers,[A.trim()]:M}})),w({open:!1,name:"",json:""}),q.success(`Added MCP: ${A}`)},N=A=>{c(E=>{const{[A]:M,...I}=E.mcpServers||{};return{...E,mcpServers:I}}),q.success(`Removed MCP: ${A}`)},P=A=>{k(E=>({...E,[A]:!E[A]}))};return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-purple-500/10 flex items-center justify-center",children:t.jsx(Mc,{className:"w-5 h-5 text-purple-500"})}),t.jsxs("div",{children:[t.jsxs("h2",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:["Antigravity Settings",t.jsx(qe,{variant:"outline",className:"text-xs font-normal text-purple-600 border-purple-300 dark:border-purple-700",children:"Google"})]}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Stored in: ",t.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs",children:n})]})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("div",{className:"flex bg-muted rounded-lg p-1",children:[t.jsx("button",{className:`px-3 py-1 text-sm rounded-md transition-colors ${u==="rich"?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>f("rich"),children:"Settings"}),t.jsx("button",{className:`px-3 py-1 text-sm rounded-md transition-colors ${u==="json"?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>{h(JSON.stringify(o,null,2)),f("json")},children:"JSON"})]}),t.jsxs(ne,{onClick:v,disabled:d||s,children:[d?t.jsx(Qe,{className:"w-4 h-4 mr-2 animate-spin"}):t.jsx(Zr,{className:"w-4 h-4 mr-2"}),"Save"]})]})]}),u==="json"?t.jsx("div",{className:"border border-border rounded-lg bg-card overflow-hidden",children:t.jsx(yt,{value:m,onChange:A=>h(A.target.value),className:"font-mono text-sm min-h-[500px] border-0 rounded-none resize-none",placeholder:"{ }"})}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"border border-border rounded-lg p-4 bg-card",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(Qn,{className:"w-4 h-4 text-purple-500"}),"Security Policies"]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Terminal Command Execution"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Control how the agent executes shell commands"})]}),t.jsxs(ir,{value:x("terminalPolicy","auto"),onValueChange:A=>y("terminalPolicy",A),children:[t.jsx(Qt,{className:"w-44",children:t.jsx(or,{})}),t.jsx(Zt,{children:_z.map(A=>t.jsx(gt,{value:A.id,children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{children:A.name}),A.dangerous&&t.jsx(qe,{variant:"destructive",className:"text-xs",children:"Risk"})]})},A.id))})]})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Review Policy"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"When the agent should request human review"})]}),t.jsxs(ir,{value:x("reviewPolicy","agent-decides"),onValueChange:A=>y("reviewPolicy",A),children:[t.jsx(Qt,{className:"w-44",children:t.jsx(or,{})}),t.jsx(Zt,{children:kz.map(A=>t.jsx(gt,{value:A.id,children:A.name},A.id))})]})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"JavaScript Execution"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Control browser JavaScript execution"})]}),t.jsxs(ir,{value:x("jsPolicy","request-review"),onValueChange:A=>y("jsPolicy",A),children:[t.jsx(Qt,{className:"w-44",children:t.jsx(or,{})}),t.jsx(Zt,{children:Sz.map(A=>t.jsx(gt,{value:A.id,children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{children:A.name}),A.dangerous&&t.jsx(qe,{variant:"destructive",className:"text-xs",children:"Risk"})]})},A.id))})]})]})]})]}),t.jsxs("div",{className:"border border-border rounded-lg p-4 bg-card",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground flex items-center gap-2",children:[t.jsx(ws,{className:"w-4 h-4 text-purple-500"}),"MCP Servers",t.jsx(qe,{variant:"secondary",className:"text-xs",children:Object.keys(b).length})]}),t.jsxs(ne,{size:"sm",variant:"outline",onClick:()=>w({open:!0,name:"",json:`{
649
649
  "command": "npx",
650
650
  "args": ["-y", "@example/mcp-server"]
651
651
  }`}),children:[t.jsx(Rt,{className:"w-4 h-4 mr-1"}),"Add MCP"]})]}),t.jsx("div",{className:"space-y-2",children:Object.keys(b).length===0?t.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No MCP servers configured"}):Object.entries(b).map(([A,E])=>t.jsxs(qo,{open:j[A],onOpenChange:()=>P(A),children:[t.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-background group",children:[t.jsxs(Ko,{className:"flex items-center gap-2 flex-1 text-left",children:[j[A]?t.jsx(hr,{className:"w-4 h-4 text-muted-foreground"}):t.jsx(Qr,{className:"w-4 h-4 text-muted-foreground"}),t.jsx(ws,{className:"w-4 h-4 text-purple-500"}),t.jsx("span",{className:"font-medium text-sm",children:A}),t.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:E.command})]}),t.jsx(ne,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 text-destructive hover:text-destructive",onClick:()=>N(A),children:t.jsx(fs,{className:"w-4 h-4"})})]}),t.jsx(Yo,{children:t.jsx("div",{className:"mt-2 ml-6 p-3 rounded-lg bg-muted/50 border",children:t.jsx("pre",{className:"text-xs font-mono text-muted-foreground overflow-x-auto",children:JSON.stringify(E,null,2)})})})]},A))})]}),t.jsxs("div",{className:"border border-border rounded-lg p-4 bg-card",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(eo,{className:"w-4 h-4 text-purple-500"}),"Browser Settings"]}),t.jsx("div",{className:"space-y-4",children:t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"URL Allowlist"}),t.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Domains the agent can visit (one per line)"}),t.jsx(yt,{value:x("browserAllowlist",""),onChange:A=>y("browserAllowlist",A.target.value),placeholder:`github.com
652
652
  stackoverflow.com
653
- docs.python.org`,className:"font-mono text-sm",rows:4})]})})]}),t.jsxs("div",{className:"border border-border rounded-lg p-4 bg-card",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(Xs,{className:"w-4 h-4 text-purple-500"}),"Agent Behavior"]}),t.jsx("div",{className:"space-y-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Default Mode"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Planning mode uses structured plans; Fast mode executes directly"})]}),t.jsxs(ir,{value:x("agentMode","planning"),onValueChange:A=>y("agentMode",A),children:[t.jsx(Qt,{className:"w-36",children:t.jsx(or,{})}),t.jsxs(Zt,{children:[t.jsx(gt,{value:"planning",children:"Planning"}),t.jsx(gt,{value:"fast",children:"Fast"})]})]})]})})]})]}),t.jsx(vt,{open:g.open,onOpenChange:A=>w({...g,open:A}),children:t.jsxs(ft,{className:"bg-card",children:[t.jsxs(mt,{children:[t.jsx(pt,{children:"Add MCP Server"}),t.jsx(Gt,{children:"Add a new MCP server to Antigravity"})]}),t.jsxs("div",{className:"space-y-4 py-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium",children:"Name"}),t.jsx(Oe,{value:g.name,onChange:A=>w({...g,name:A.target.value}),placeholder:"my-mcp-server",className:"mt-1"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium",children:"Configuration (JSON)"}),t.jsx(yt,{value:g.json,onChange:A=>w({...g,json:A.target.value}),className:"mt-1 font-mono text-sm",rows:6})]})]}),t.jsxs(St,{children:[t.jsx(ne,{variant:"ghost",onClick:()=>w({open:!1,name:"",json:""}),children:"Cancel"}),t.jsxs(ne,{onClick:S,children:[t.jsx(Rt,{className:"w-4 h-4 mr-2"}),"Add MCP"]})]})]})})]})}function Cz(){const[e,r]=_.useState(null),[s,n]=_.useState(!0);_.useEffect(()=>{o()},[]);const o=async()=>{try{n(!0);const d=await he.getAntigravitySettings();r(d.settings)}catch(d){console.error("Failed to load Antigravity settings:",d)}finally{n(!1)}},c=async d=>{try{await he.saveAntigravitySettings(d),r(d),q.success("Antigravity settings saved!")}catch(l){q.error("Failed to save settings: "+l.message)}};return s?t.jsx("div",{className:"flex items-center justify-center h-64",children:t.jsx(Qe,{className:"w-8 h-8 animate-spin text-purple-600"})}):t.jsxs("div",{className:"space-y-6",children:[t.jsx("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 p-6 shadow-sm",children:t.jsx(Sz,{settings:e,onSave:c,loading:s,settingsPath:"~/.gemini/antigravity/settings.json"})}),t.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-4 border border-transparent dark:border-slate-800",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white mb-2",children:"CLI Commands"}),t.jsxs("div",{className:"space-y-1 text-sm text-gray-600 dark:text-slate-400 font-mono",children:[t.jsx("p",{children:"coder-config apply # Generate settings for all tools"}),t.jsx("p",{children:"coder-config apply --antigravity # Generate Antigravity settings only"})]})]})]})}const jz=[{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",description:"Latest and most capable"},{id:"gpt-5-codex",name:"GPT-5 Codex",description:"Previous generation"},{id:"gpt-5",name:"GPT-5",description:"General purpose"},{id:"o3-mini",name:"o3-mini",description:"Fast reasoning model"}],Nz=[{id:"untrusted",name:"Untrusted",description:"Ask for everything"},{id:"on-request",name:"On Request",description:"Ask before running commands (default)"},{id:"never",name:"Never",description:"Never ask (use with caution)"}],Ez=[{id:"read-only",name:"Read Only",description:"Can only read files (default)"},{id:"workspace-write",name:"Workspace Write",description:"Can write within workspace"},{id:"danger-full-access",name:"Full Access",description:"Full filesystem access (dangerous)"}],Pz=[{id:"minimal",name:"Minimal",description:"Fastest, least thorough"},{id:"low",name:"Low",description:"Quick responses"},{id:"medium",name:"Medium",description:"Balanced (default)"},{id:"high",name:"High",description:"More thorough"},{id:"xhigh",name:"Extra High",description:"Most thorough"}],Az=[{id:"save-all",name:"Save All",description:"Keep all session history"},{id:"none",name:"None",description:"Do not persist history"}];function Tz({settings:e,rawToml:r,onSave:s,loading:n,settingsPath:o}){const[c,d]=_.useState(e||{}),[l,u]=_.useState(!1),[f,m]=_.useState("rich"),[h,g]=_.useState(r||""),[w,j]=_.useState({open:!1,name:"",json:""}),[k,v]=_.useState({}),y=async()=>{u(!0);try{f==="toml"?await s(null,h):await s(c),q.success("Settings saved")}catch(I){q.error("Failed to save: "+I.message)}finally{u(!1)}},x=(I,B)=>{d(U=>({...U,[I]:B}))},b=(I,B,U)=>{d(V=>({...V,[I]:{...V[I],[B]:U}}))},S=(I,B="")=>(c==null?void 0:c[I])??B,N=(I,B,U=!1)=>{var V;return((V=c==null?void 0:c[I])==null?void 0:V[B])??U},P=c.mcp_servers||{},A=()=>{const{name:I,json:B}=w;if(!I.trim()){q.error("Please enter a name for the MCP server");return}let U;try{U=JSON.parse(B)}catch{q.error("Invalid JSON configuration");return}if(!U.command&&!U.url){q.error('MCP config must have a "command" (stdio) or "url" (HTTP) field');return}d(V=>({...V,mcp_servers:{...V.mcp_servers,[I.trim()]:U}})),j({open:!1,name:"",json:""}),q.success(`Added MCP: ${I}`)},E=I=>{d(B=>{const{[I]:U,...V}=B.mcp_servers||{};return{...B,mcp_servers:V}}),q.success(`Removed MCP: ${I}`)},M=I=>{v(B=>({...B,[I]:!B[I]}))};return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-green-500/10 flex items-center justify-center",children:t.jsx(Ut,{className:"w-5 h-5 text-green-500"})}),t.jsxs("div",{children:[t.jsxs("h2",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:["Codex CLI Settings",t.jsxs(qe,{variant:"outline",className:"text-xs font-normal text-green-600 border-green-300 dark:border-green-700",children:[t.jsx(Vt,{className:"w-3 h-3 mr-1"}),"OpenAI"]})]}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Stored in: ",t.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs",children:o})]})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("div",{className:"flex bg-muted rounded-lg p-1",children:[t.jsx("button",{className:`px-3 py-1 text-sm rounded-md transition-colors ${f==="rich"?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>m("rich"),children:"Settings"}),t.jsx("button",{className:`px-3 py-1 text-sm rounded-md transition-colors ${f==="toml"?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>m("toml"),children:"TOML"})]}),t.jsxs(ne,{onClick:y,disabled:l||n,children:[l?t.jsx(Qe,{className:"w-4 h-4 mr-2 animate-spin"}):t.jsx(Zr,{className:"w-4 h-4 mr-2"}),"Save"]})]})]}),f==="toml"?t.jsx("div",{className:"border border-border rounded-lg bg-card overflow-hidden",children:t.jsx(yt,{value:h,onChange:I=>g(I.target.value),className:"font-mono text-sm min-h-[500px] border-0 rounded-none resize-none",placeholder:"# Codex CLI config.toml"})}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"border border-border rounded-lg p-4 bg-card",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(Vt,{className:"w-4 h-4 text-green-500"}),"Model"]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Default Model"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Model used for Codex CLI sessions"})]}),t.jsxs(ir,{value:S("model",""),onValueChange:I=>x("model",I),children:[t.jsx(Qt,{className:"w-48",children:t.jsx(or,{placeholder:"Select model"})}),t.jsx(Zt,{children:jz.map(I=>t.jsx(gt,{value:I.id,children:t.jsx("div",{className:"flex flex-col",children:t.jsx("span",{children:I.name})})},I.id))})]})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Reasoning Effort"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"How thoroughly the model should reason"})]}),t.jsxs(ir,{value:S("model_reasoning_effort","medium"),onValueChange:I=>x("model_reasoning_effort",I),children:[t.jsx(Qt,{className:"w-48",children:t.jsx(or,{})}),t.jsx(Zt,{children:Pz.map(I=>t.jsx(gt,{value:I.id,children:I.name},I.id))})]})]})]})]}),t.jsxs("div",{className:"border border-border rounded-lg p-4 bg-card",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(Qn,{className:"w-4 h-4 text-green-500"}),"Security"]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Approval Policy"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"When to ask for command approval"})]}),t.jsxs(ir,{value:S("approval_policy","on-request"),onValueChange:I=>x("approval_policy",I),children:[t.jsx(Qt,{className:"w-48",children:t.jsx(or,{})}),t.jsx(Zt,{children:Nz.map(I=>t.jsx(gt,{value:I.id,children:I.name},I.id))})]})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Sandbox Mode"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Filesystem and network access level"})]}),t.jsxs(ir,{value:S("sandbox_mode","read-only"),onValueChange:I=>x("sandbox_mode",I),children:[t.jsx(Qt,{className:"w-48",children:t.jsx(or,{})}),t.jsx(Zt,{children:Ez.map(I=>t.jsx(gt,{value:I.id,children:I.name},I.id))})]})]})]})]}),t.jsxs("div",{className:"border border-border rounded-lg p-4 bg-card",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground flex items-center gap-2",children:[t.jsx(ws,{className:"w-4 h-4 text-green-500"}),"MCP Servers",t.jsx(qe,{variant:"secondary",className:"text-xs",children:Object.keys(P).length})]}),t.jsxs(ne,{size:"sm",variant:"outline",onClick:()=>j({open:!0,name:"",json:`{
653
+ docs.python.org`,className:"font-mono text-sm",rows:4})]})})]}),t.jsxs("div",{className:"border border-border rounded-lg p-4 bg-card",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(Xs,{className:"w-4 h-4 text-purple-500"}),"Agent Behavior"]}),t.jsx("div",{className:"space-y-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Default Mode"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Planning mode uses structured plans; Fast mode executes directly"})]}),t.jsxs(ir,{value:x("agentMode","planning"),onValueChange:A=>y("agentMode",A),children:[t.jsx(Qt,{className:"w-36",children:t.jsx(or,{})}),t.jsxs(Zt,{children:[t.jsx(gt,{value:"planning",children:"Planning"}),t.jsx(gt,{value:"fast",children:"Fast"})]})]})]})})]})]}),t.jsx(vt,{open:g.open,onOpenChange:A=>w({...g,open:A}),children:t.jsxs(ft,{className:"bg-card",children:[t.jsxs(mt,{children:[t.jsx(pt,{children:"Add MCP Server"}),t.jsx(Gt,{children:"Add a new MCP server to Antigravity"})]}),t.jsxs("div",{className:"space-y-4 py-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium",children:"Name"}),t.jsx(Oe,{value:g.name,onChange:A=>w({...g,name:A.target.value}),placeholder:"my-mcp-server",className:"mt-1"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium",children:"Configuration (JSON)"}),t.jsx(yt,{value:g.json,onChange:A=>w({...g,json:A.target.value}),className:"mt-1 font-mono text-sm",rows:6})]})]}),t.jsxs(St,{children:[t.jsx(ne,{variant:"ghost",onClick:()=>w({open:!1,name:"",json:""}),children:"Cancel"}),t.jsxs(ne,{onClick:S,children:[t.jsx(Rt,{className:"w-4 h-4 mr-2"}),"Add MCP"]})]})]})})]})}function jz(){const[e,r]=_.useState(null),[s,n]=_.useState(!0);_.useEffect(()=>{o()},[]);const o=async()=>{try{n(!0);const d=await he.getAntigravitySettings();r(d.settings)}catch(d){console.error("Failed to load Antigravity settings:",d)}finally{n(!1)}},c=async d=>{try{await he.saveAntigravitySettings(d),r(d),q.success("Antigravity settings saved!")}catch(l){q.error("Failed to save settings: "+l.message)}};return s?t.jsx("div",{className:"flex items-center justify-center h-64",children:t.jsx(Qe,{className:"w-8 h-8 animate-spin text-purple-600"})}):t.jsxs("div",{className:"space-y-6",children:[t.jsx("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 p-6 shadow-sm",children:t.jsx(Cz,{settings:e,onSave:c,loading:s,settingsPath:"~/.gemini/antigravity/settings.json"})}),t.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-4 border border-transparent dark:border-slate-800",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white mb-2",children:"CLI Commands"}),t.jsxs("div",{className:"space-y-1 text-sm text-gray-600 dark:text-slate-400 font-mono",children:[t.jsx("p",{children:"coder-config apply # Generate settings for all tools"}),t.jsx("p",{children:"coder-config apply --antigravity # Generate Antigravity settings only"})]})]})]})}const Nz=[{id:"gpt-5.2-codex",name:"GPT-5.2 Codex",description:"Latest and most capable"},{id:"gpt-5-codex",name:"GPT-5 Codex",description:"Previous generation"},{id:"gpt-5",name:"GPT-5",description:"General purpose"},{id:"o3-mini",name:"o3-mini",description:"Fast reasoning model"}],Ez=[{id:"untrusted",name:"Untrusted",description:"Ask for everything"},{id:"on-request",name:"On Request",description:"Ask before running commands (default)"},{id:"never",name:"Never",description:"Never ask (use with caution)"}],Pz=[{id:"read-only",name:"Read Only",description:"Can only read files (default)"},{id:"workspace-write",name:"Workspace Write",description:"Can write within workspace"},{id:"danger-full-access",name:"Full Access",description:"Full filesystem access (dangerous)"}],Az=[{id:"minimal",name:"Minimal",description:"Fastest, least thorough"},{id:"low",name:"Low",description:"Quick responses"},{id:"medium",name:"Medium",description:"Balanced (default)"},{id:"high",name:"High",description:"More thorough"},{id:"xhigh",name:"Extra High",description:"Most thorough"}],Tz=[{id:"save-all",name:"Save All",description:"Keep all session history"},{id:"none",name:"None",description:"Do not persist history"}];function Rz({settings:e,rawToml:r,onSave:s,loading:n,settingsPath:o}){const[c,d]=_.useState(e||{}),[l,u]=_.useState(!1),[f,m]=_.useState("rich"),[h,g]=_.useState(r||""),[w,j]=_.useState({open:!1,name:"",json:""}),[k,v]=_.useState({}),y=async()=>{u(!0);try{f==="toml"?await s(null,h):await s(c),q.success("Settings saved")}catch(I){q.error("Failed to save: "+I.message)}finally{u(!1)}},x=(I,B)=>{d(U=>({...U,[I]:B}))},b=(I,B,U)=>{d(V=>({...V,[I]:{...V[I],[B]:U}}))},S=(I,B="")=>(c==null?void 0:c[I])??B,N=(I,B,U=!1)=>{var V;return((V=c==null?void 0:c[I])==null?void 0:V[B])??U},P=c.mcp_servers||{},A=()=>{const{name:I,json:B}=w;if(!I.trim()){q.error("Please enter a name for the MCP server");return}let U;try{U=JSON.parse(B)}catch{q.error("Invalid JSON configuration");return}if(!U.command&&!U.url){q.error('MCP config must have a "command" (stdio) or "url" (HTTP) field');return}d(V=>({...V,mcp_servers:{...V.mcp_servers,[I.trim()]:U}})),j({open:!1,name:"",json:""}),q.success(`Added MCP: ${I}`)},E=I=>{d(B=>{const{[I]:U,...V}=B.mcp_servers||{};return{...B,mcp_servers:V}}),q.success(`Removed MCP: ${I}`)},M=I=>{v(B=>({...B,[I]:!B[I]}))};return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-green-500/10 flex items-center justify-center",children:t.jsx(Ut,{className:"w-5 h-5 text-green-500"})}),t.jsxs("div",{children:[t.jsxs("h2",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:["Codex CLI Settings",t.jsxs(qe,{variant:"outline",className:"text-xs font-normal text-green-600 border-green-300 dark:border-green-700",children:[t.jsx(Vt,{className:"w-3 h-3 mr-1"}),"OpenAI"]})]}),t.jsxs("p",{className:"text-sm text-muted-foreground",children:["Stored in: ",t.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs",children:o})]})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("div",{className:"flex bg-muted rounded-lg p-1",children:[t.jsx("button",{className:`px-3 py-1 text-sm rounded-md transition-colors ${f==="rich"?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>m("rich"),children:"Settings"}),t.jsx("button",{className:`px-3 py-1 text-sm rounded-md transition-colors ${f==="toml"?"bg-background shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>m("toml"),children:"TOML"})]}),t.jsxs(ne,{onClick:y,disabled:l||n,children:[l?t.jsx(Qe,{className:"w-4 h-4 mr-2 animate-spin"}):t.jsx(Zr,{className:"w-4 h-4 mr-2"}),"Save"]})]})]}),f==="toml"?t.jsx("div",{className:"border border-border rounded-lg bg-card overflow-hidden",children:t.jsx(yt,{value:h,onChange:I=>g(I.target.value),className:"font-mono text-sm min-h-[500px] border-0 rounded-none resize-none",placeholder:"# Codex CLI config.toml"})}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"border border-border rounded-lg p-4 bg-card",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(Vt,{className:"w-4 h-4 text-green-500"}),"Model"]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Default Model"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Model used for Codex CLI sessions"})]}),t.jsxs(ir,{value:S("model",""),onValueChange:I=>x("model",I),children:[t.jsx(Qt,{className:"w-48",children:t.jsx(or,{placeholder:"Select model"})}),t.jsx(Zt,{children:Nz.map(I=>t.jsx(gt,{value:I.id,children:t.jsx("div",{className:"flex flex-col",children:t.jsx("span",{children:I.name})})},I.id))})]})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Reasoning Effort"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"How thoroughly the model should reason"})]}),t.jsxs(ir,{value:S("model_reasoning_effort","medium"),onValueChange:I=>x("model_reasoning_effort",I),children:[t.jsx(Qt,{className:"w-48",children:t.jsx(or,{})}),t.jsx(Zt,{children:Az.map(I=>t.jsx(gt,{value:I.id,children:I.name},I.id))})]})]})]})]}),t.jsxs("div",{className:"border border-border rounded-lg p-4 bg-card",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(Qn,{className:"w-4 h-4 text-green-500"}),"Security"]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Approval Policy"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"When to ask for command approval"})]}),t.jsxs(ir,{value:S("approval_policy","on-request"),onValueChange:I=>x("approval_policy",I),children:[t.jsx(Qt,{className:"w-48",children:t.jsx(or,{})}),t.jsx(Zt,{children:Ez.map(I=>t.jsx(gt,{value:I.id,children:I.name},I.id))})]})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Sandbox Mode"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Filesystem and network access level"})]}),t.jsxs(ir,{value:S("sandbox_mode","read-only"),onValueChange:I=>x("sandbox_mode",I),children:[t.jsx(Qt,{className:"w-48",children:t.jsx(or,{})}),t.jsx(Zt,{children:Pz.map(I=>t.jsx(gt,{value:I.id,children:I.name},I.id))})]})]})]})]}),t.jsxs("div",{className:"border border-border rounded-lg p-4 bg-card",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground flex items-center gap-2",children:[t.jsx(ws,{className:"w-4 h-4 text-green-500"}),"MCP Servers",t.jsx(qe,{variant:"secondary",className:"text-xs",children:Object.keys(P).length})]}),t.jsxs(ne,{size:"sm",variant:"outline",onClick:()=>j({open:!0,name:"",json:`{
654
654
  "command": "npx",
655
655
  "args": ["-y", "@example/mcp-server"],
656
656
  "enabled": true
657
- }`}),children:[t.jsx(Rt,{className:"w-4 h-4 mr-1"}),"Add MCP"]})]}),t.jsx("div",{className:"space-y-2",children:Object.keys(P).length===0?t.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No MCP servers configured"}):Object.entries(P).map(([I,B])=>t.jsxs(qo,{open:k[I],onOpenChange:()=>M(I),children:[t.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-background group",children:[t.jsxs(Ko,{className:"flex items-center gap-2 flex-1 text-left",children:[k[I]?t.jsx(hr,{className:"w-4 h-4 text-muted-foreground"}):t.jsx(Qr,{className:"w-4 h-4 text-muted-foreground"}),t.jsx(ws,{className:"w-4 h-4 text-green-500"}),t.jsx("span",{className:"font-medium text-sm",children:I}),t.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:B.url?`http: ${B.url}`:B.command}),B.enabled===!1&&t.jsx(qe,{variant:"secondary",className:"text-xs",children:"Disabled"})]}),t.jsx(ne,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 text-destructive hover:text-destructive",onClick:()=>E(I),children:t.jsx(fs,{className:"w-4 h-4"})})]}),t.jsx(Yo,{children:t.jsx("div",{className:"mt-2 ml-6 p-3 rounded-lg bg-muted/50 border",children:t.jsx("pre",{className:"text-xs font-mono text-muted-foreground overflow-x-auto",children:JSON.stringify(B,null,2)})})})]},I))})]}),t.jsxs("div",{className:"border border-border rounded-lg p-4 bg-card",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(Yi,{className:"w-4 h-4 text-green-500"}),"Features"]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Shell Snapshot"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Speed up repeated commands (Beta)"})]}),t.jsx(xt,{checked:N("features","shell_snapshot",!0),onCheckedChange:I=>b("features","shell_snapshot",I)})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Web Search"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Allow the model to search the web"})]}),t.jsx(xt,{checked:N("features","web_search_request",!0),onCheckedChange:I=>b("features","web_search_request",I)})]})]})]}),t.jsxs("div",{className:"border border-border rounded-lg p-4 bg-card",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(Xs,{className:"w-4 h-4 text-green-500"}),"Display"]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Animations"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Enable UI animations"})]}),t.jsx(xt,{checked:N("tui","animations",!0),onCheckedChange:I=>b("tui","animations",I)})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Notifications"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Show system notifications"})]}),t.jsx(xt,{checked:N("tui","notifications",!0),onCheckedChange:I=>b("tui","notifications",I)})]})]})]}),t.jsxs("div",{className:"border border-border rounded-lg p-4 bg-card",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(Tu,{className:"w-4 h-4 text-green-500"}),"History"]}),t.jsx("div",{className:"space-y-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Persistence"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"How session history is saved"})]}),t.jsxs(ir,{value:N("history","persistence","save-all"),onValueChange:I=>b("history","persistence",I),children:[t.jsx(Qt,{className:"w-48",children:t.jsx(or,{})}),t.jsx(Zt,{children:Az.map(I=>t.jsx(gt,{value:I.id,children:I.name},I.id))})]})]})})]}),t.jsxs("div",{className:"border border-border rounded-lg p-4 bg-card",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(mS,{className:"w-4 h-4 text-green-500"}),"Analytics"]}),t.jsx("div",{className:"space-y-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Usage Metrics"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Send anonymous usage data to OpenAI"})]}),t.jsx(xt,{checked:N("analytics","enabled",!0),onCheckedChange:I=>b("analytics","enabled",I)})]})})]})]}),t.jsx(vt,{open:w.open,onOpenChange:I=>j({...w,open:I}),children:t.jsxs(ft,{className:"bg-card",children:[t.jsxs(mt,{children:[t.jsx(pt,{children:"Add MCP Server"}),t.jsx(Gt,{children:"Add a new MCP server to Codex CLI"})]}),t.jsxs("div",{className:"space-y-4 py-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium",children:"Name"}),t.jsx(Oe,{value:w.name,onChange:I=>j({...w,name:I.target.value}),placeholder:"my-mcp-server",className:"mt-1"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium",children:"Configuration (JSON)"}),t.jsx(yt,{value:w.json,onChange:I=>j({...w,json:I.target.value}),className:"mt-1 font-mono text-sm",rows:6})]})]}),t.jsxs(St,{children:[t.jsx(ne,{variant:"ghost",onClick:()=>j({open:!1,name:"",json:""}),children:"Cancel"}),t.jsxs(ne,{onClick:A,children:[t.jsx(Rt,{className:"w-4 h-4 mr-2"}),"Add MCP"]})]})]})})]})}function Rz(){const[e,r]=_.useState(null),[s,n]=_.useState(""),[o,c]=_.useState(!0);_.useEffect(()=>{d()},[]);const d=async()=>{try{c(!0);const u=await he.getCodexSettings();r(u.settings),n(u.raw||"")}catch(u){console.error("Failed to load Codex settings:",u)}finally{c(!1)}},l=async(u,f=void 0)=>{try{const m=await he.saveCodexSettings(u,f);m.success?(r(m.settings),q.success("Codex CLI settings saved!")):q.error("Failed to save: "+m.error)}catch(m){q.error("Failed to save settings: "+m.message)}};return o?t.jsx("div",{className:"flex items-center justify-center h-64",children:t.jsx(Qe,{className:"w-8 h-8 animate-spin text-green-600"})}):t.jsxs("div",{className:"space-y-6",children:[t.jsx("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 p-6 shadow-sm",children:t.jsx(Tz,{settings:e,rawToml:s,onSave:l,loading:o,settingsPath:"~/.codex/config.toml"})}),t.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-4 border border-transparent dark:border-slate-800",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white mb-2",children:"CLI Commands"}),t.jsxs("div",{className:"space-y-1 text-sm text-gray-600 dark:text-slate-400 font-mono",children:[t.jsx("p",{children:"codex # Start Codex CLI"}),t.jsx("p",{children:"codex --model gpt-5.2-codex # Use specific model"}),t.jsx("p",{children:"codex --full-auto # Low-friction mode"})]})]}),t.jsxs("div",{className:"bg-green-50 dark:bg-green-950/20 rounded-lg p-4 border border-green-200 dark:border-green-800",children:[t.jsx("h4",{className:"text-sm font-medium text-green-900 dark:text-green-100 mb-1",children:"Documentation"}),t.jsxs("p",{className:"text-sm text-green-700 dark:text-green-300",children:["See the full configuration reference at"," ",t.jsx("a",{href:"https://developers.openai.com/codex/config-reference/",target:"_blank",rel:"noopener noreferrer",className:"underline hover:no-underline",children:"developers.openai.com/codex"})]})]})]})}const Mz="~/reg/tools",S_={claude:{name:"Claude Code",command:"claude",color:"orange"},gemini:{name:"Gemini CLI",command:"gemini",color:"blue"}};function Iz({project:e}){const[r,s]=_.useState(""),[n,o]=_.useState(""),[c,d]=_.useState(Mz),[l,u]=_.useState(!1),[f,m]=_.useState(null),[h,g]=_.useState(!1),[w,j]=_.useState("claude");_.useEffect(()=>{k()},[]);const k=async()=>{var N;try{const P=await he.getConfig();j(((N=P.config)==null?void 0:N.aiAssistant)||"claude")}catch(P){console.error("Failed to load preferences:",P)}},v=S_[w]||S_.claude,y=()=>{if(!r.trim()){q.error("Please enter an MCP name");return}const N=`Create a new MCP server project called "${r}" with the following:
657
+ }`}),children:[t.jsx(Rt,{className:"w-4 h-4 mr-1"}),"Add MCP"]})]}),t.jsx("div",{className:"space-y-2",children:Object.keys(P).length===0?t.jsx("p",{className:"text-sm text-muted-foreground italic",children:"No MCP servers configured"}):Object.entries(P).map(([I,B])=>t.jsxs(qo,{open:k[I],onOpenChange:()=>M(I),children:[t.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg border bg-background group",children:[t.jsxs(Ko,{className:"flex items-center gap-2 flex-1 text-left",children:[k[I]?t.jsx(hr,{className:"w-4 h-4 text-muted-foreground"}):t.jsx(Qr,{className:"w-4 h-4 text-muted-foreground"}),t.jsx(ws,{className:"w-4 h-4 text-green-500"}),t.jsx("span",{className:"font-medium text-sm",children:I}),t.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:B.url?`http: ${B.url}`:B.command}),B.enabled===!1&&t.jsx(qe,{variant:"secondary",className:"text-xs",children:"Disabled"})]}),t.jsx(ne,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100 text-destructive hover:text-destructive",onClick:()=>E(I),children:t.jsx(fs,{className:"w-4 h-4"})})]}),t.jsx(Yo,{children:t.jsx("div",{className:"mt-2 ml-6 p-3 rounded-lg bg-muted/50 border",children:t.jsx("pre",{className:"text-xs font-mono text-muted-foreground overflow-x-auto",children:JSON.stringify(B,null,2)})})})]},I))})]}),t.jsxs("div",{className:"border border-border rounded-lg p-4 bg-card",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(Yi,{className:"w-4 h-4 text-green-500"}),"Features"]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Shell Snapshot"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Speed up repeated commands (Beta)"})]}),t.jsx(xt,{checked:N("features","shell_snapshot",!0),onCheckedChange:I=>b("features","shell_snapshot",I)})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Web Search"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Allow the model to search the web"})]}),t.jsx(xt,{checked:N("features","web_search_request",!0),onCheckedChange:I=>b("features","web_search_request",I)})]})]})]}),t.jsxs("div",{className:"border border-border rounded-lg p-4 bg-card",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(Xs,{className:"w-4 h-4 text-green-500"}),"Display"]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Animations"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Enable UI animations"})]}),t.jsx(xt,{checked:N("tui","animations",!0),onCheckedChange:I=>b("tui","animations",I)})]}),t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Notifications"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Show system notifications"})]}),t.jsx(xt,{checked:N("tui","notifications",!0),onCheckedChange:I=>b("tui","notifications",I)})]})]})]}),t.jsxs("div",{className:"border border-border rounded-lg p-4 bg-card",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(Tu,{className:"w-4 h-4 text-green-500"}),"History"]}),t.jsx("div",{className:"space-y-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Persistence"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"How session history is saved"})]}),t.jsxs(ir,{value:N("history","persistence","save-all"),onValueChange:I=>b("history","persistence",I),children:[t.jsx(Qt,{className:"w-48",children:t.jsx(or,{})}),t.jsx(Zt,{children:Tz.map(I=>t.jsx(gt,{value:I.id,children:I.name},I.id))})]})]})})]}),t.jsxs("div",{className:"border border-border rounded-lg p-4 bg-card",children:[t.jsxs("h3",{className:"text-sm font-medium text-foreground mb-4 flex items-center gap-2",children:[t.jsx(mS,{className:"w-4 h-4 text-green-500"}),"Analytics"]}),t.jsx("div",{className:"space-y-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Usage Metrics"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Send anonymous usage data to OpenAI"})]}),t.jsx(xt,{checked:N("analytics","enabled",!0),onCheckedChange:I=>b("analytics","enabled",I)})]})})]})]}),t.jsx(vt,{open:w.open,onOpenChange:I=>j({...w,open:I}),children:t.jsxs(ft,{className:"bg-card",children:[t.jsxs(mt,{children:[t.jsx(pt,{children:"Add MCP Server"}),t.jsx(Gt,{children:"Add a new MCP server to Codex CLI"})]}),t.jsxs("div",{className:"space-y-4 py-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium",children:"Name"}),t.jsx(Oe,{value:w.name,onChange:I=>j({...w,name:I.target.value}),placeholder:"my-mcp-server",className:"mt-1"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium",children:"Configuration (JSON)"}),t.jsx(yt,{value:w.json,onChange:I=>j({...w,json:I.target.value}),className:"mt-1 font-mono text-sm",rows:6})]})]}),t.jsxs(St,{children:[t.jsx(ne,{variant:"ghost",onClick:()=>j({open:!1,name:"",json:""}),children:"Cancel"}),t.jsxs(ne,{onClick:A,children:[t.jsx(Rt,{className:"w-4 h-4 mr-2"}),"Add MCP"]})]})]})})]})}function Mz(){const[e,r]=_.useState(null),[s,n]=_.useState(""),[o,c]=_.useState(!0);_.useEffect(()=>{d()},[]);const d=async()=>{try{c(!0);const u=await he.getCodexSettings();r(u.settings),n(u.raw||"")}catch(u){console.error("Failed to load Codex settings:",u)}finally{c(!1)}},l=async(u,f=void 0)=>{try{const m=await he.saveCodexSettings(u,f);m.success?(r(m.settings),q.success("Codex CLI settings saved!")):q.error("Failed to save: "+m.error)}catch(m){q.error("Failed to save settings: "+m.message)}};return o?t.jsx("div",{className:"flex items-center justify-center h-64",children:t.jsx(Qe,{className:"w-8 h-8 animate-spin text-green-600"})}):t.jsxs("div",{className:"space-y-6",children:[t.jsx("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 p-6 shadow-sm",children:t.jsx(Rz,{settings:e,rawToml:s,onSave:l,loading:o,settingsPath:"~/.codex/config.toml"})}),t.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-4 border border-transparent dark:border-slate-800",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white mb-2",children:"CLI Commands"}),t.jsxs("div",{className:"space-y-1 text-sm text-gray-600 dark:text-slate-400 font-mono",children:[t.jsx("p",{children:"codex # Start Codex CLI"}),t.jsx("p",{children:"codex --model gpt-5.2-codex # Use specific model"}),t.jsx("p",{children:"codex --full-auto # Low-friction mode"})]})]}),t.jsxs("div",{className:"bg-green-50 dark:bg-green-950/20 rounded-lg p-4 border border-green-200 dark:border-green-800",children:[t.jsx("h4",{className:"text-sm font-medium text-green-900 dark:text-green-100 mb-1",children:"Documentation"}),t.jsxs("p",{className:"text-sm text-green-700 dark:text-green-300",children:["See the full configuration reference at"," ",t.jsx("a",{href:"https://developers.openai.com/codex/config-reference/",target:"_blank",rel:"noopener noreferrer",className:"underline hover:no-underline",children:"developers.openai.com/codex"})]})]})]})}const Iz="~/reg/tools",S_={claude:{name:"Claude Code",command:"claude",color:"orange"},gemini:{name:"Gemini CLI",command:"gemini",color:"blue"}};function Dz({project:e}){const[r,s]=_.useState(""),[n,o]=_.useState(""),[c,d]=_.useState(Iz),[l,u]=_.useState(!1),[f,m]=_.useState(null),[h,g]=_.useState(!1),[w,j]=_.useState("claude");_.useEffect(()=>{k()},[]);const k=async()=>{var N;try{const P=await he.getConfig();j(((N=P.config)==null?void 0:N.aiAssistant)||"claude")}catch(P){console.error("Failed to load preferences:",P)}},v=S_[w]||S_.claude,y=()=>{if(!r.trim()){q.error("Please enter an MCP name");return}const N=`Create a new MCP server project called "${r}" with the following:
658
658
  - Use Python with uv for package management
659
659
  - Use FastMCP framework
660
660
  - Description: ${n||"A custom MCP server"}
661
661
  - Create a single mcp_server.py file with basic structure
662
662
  - Include a pyproject.toml configured for uv
663
- - Add a README.md with usage instructions`;m(`cd "${c}" && ${v.command} "${N}"`),u(!0),g(!0)},x=N=>{console.log("Terminal session ready:",N)},b=(N,P)=>{console.log("Terminal exited:",N,P),g(!1),N===0&&q.success("MCP project created successfully!")},S=()=>{u(!1),m(null),g(!1),s(""),o("")};return t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx("div",{className:"flex-none p-6 border-b border-gray-200 dark:border-slate-700 bg-white dark:bg-slate-950",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsxs("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white flex items-center gap-2",children:[t.jsx(Wr,{className:"w-7 h-7 text-purple-600"}),"Create MCP Server"]}),t.jsxs("p",{className:"text-gray-500 dark:text-slate-400 mt-1",children:["Generate a new MCP server project with ",v.name," assistance"]})]}),l&&t.jsxs(ne,{variant:"outline",onClick:S,className:"text-gray-600 dark:text-slate-300",children:[t.jsx(Rt,{className:"w-4 h-4 mr-2"}),"New Project"]})]})}),t.jsxs("div",{className:"flex-1 overflow-hidden flex",children:[t.jsx("div",{className:`${l?"w-1/3 border-r border-gray-200 dark:border-slate-700":"w-full max-w-2xl mx-auto"} p-6 overflow-auto`,children:t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-slate-300 mb-2",children:"MCP Name *"}),t.jsx(Oe,{value:r,onChange:N=>s(N.target.value),placeholder:"my-awesome-mcp",disabled:h}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400 mt-1",children:"This will be the project folder name"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-slate-300 mb-2",children:"Description"}),t.jsx(yt,{value:n,onChange:N=>o(N.target.value),placeholder:"Describe what your MCP server will do...",className:"min-h-[100px]",disabled:h})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-slate-300 mb-2",children:"Output Directory"}),t.jsx(Oe,{value:c,onChange:N=>d(N.target.value),placeholder:"/path/to/projects",className:"font-mono text-sm",disabled:h}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400 mt-1",children:"Where to create the new MCP project"})]}),t.jsxs("div",{className:"bg-purple-50 dark:bg-purple-950/30 border border-purple-200 dark:border-purple-800 rounded-lg p-4",children:[t.jsx("h3",{className:"text-sm font-medium text-purple-900 dark:text-purple-300 mb-2",children:"What will be created:"}),t.jsxs("ul",{className:"text-sm text-purple-700 dark:text-purple-400 space-y-1",children:[t.jsxs("li",{className:"flex items-center gap-2",children:[t.jsx(eh,{className:"w-4 h-4"}),"Python project with uv package manager"]}),t.jsxs("li",{className:"flex items-center gap-2",children:[t.jsx(tl,{className:"w-4 h-4"}),"FastMCP framework setup"]}),t.jsxs("li",{className:"flex items-center gap-2",children:[t.jsx(vr,{className:"w-4 h-4"}),"mcp_server.py with basic structure"]}),t.jsxs("li",{className:"flex items-center gap-2",children:[t.jsx(Yn,{className:"w-4 h-4"}),"pyproject.toml configured for uv"]})]})]}),!l&&t.jsxs(ne,{onClick:y,className:"w-full bg-purple-600 hover:bg-purple-700 text-white",disabled:!r.trim(),children:[t.jsx(Wr,{className:"w-4 h-4 mr-2"}),"Create & Launch ",v.name]})]})}),l&&t.jsxs("div",{className:"flex-1 flex flex-col bg-gray-900",children:[t.jsxs("div",{className:"flex-none px-4 py-2 border-b border-gray-700 flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ut,{className:"w-4 h-4 text-gray-400"}),t.jsxs("span",{className:"text-sm text-gray-300",children:[v.name," Terminal"]})]}),t.jsx("div",{className:"flex items-center gap-2",children:h&&t.jsxs(qe,{variant:"outline",className:"bg-green-900/50 text-green-400 border-green-700",children:[t.jsx(Qe,{className:"w-3 h-3 mr-1 animate-spin"}),"Running"]})})]}),t.jsx("div",{className:"flex-1",children:t.jsx(Sh,{cwd:c,initialCommand:f,onReady:x,onExit:b,height:"100%"})})]})]})]})}var Dz=Symbol("radix.slottable");function Lz(e){const r=({children:s})=>t.jsx(t.Fragment,{children:s});return r.displayName=`${e}.Slottable`,r.__radixId=Dz,r}var Oz="AlertDialog",[Fz]=Ls(Oz,[hC]),lo=hC(),Bz="AlertDialogTrigger",$z=_.forwardRef((e,r)=>{const{__scopeAlertDialog:s,...n}=e,o=lo(s);return t.jsx(TL,{...o,...n,ref:r})});$z.displayName=Bz;var Hz="AlertDialogPortal",p2=e=>{const{__scopeAlertDialog:r,...s}=e,n=lo(r);return t.jsx(EC,{...n,...s})};p2.displayName=Hz;var zz="AlertDialogOverlay",g2=_.forwardRef((e,r)=>{const{__scopeAlertDialog:s,...n}=e,o=lo(s);return t.jsx(tx,{...o,...n,ref:r})});g2.displayName=zz;var Ja="AlertDialogContent",[Wz,Uz]=Fz(Ja),Vz=Lz("AlertDialogContent"),x2=_.forwardRef((e,r)=>{const{__scopeAlertDialog:s,children:n,...o}=e,c=lo(s),d=_.useRef(null),l=bt(r,d),u=_.useRef(null);return t.jsx(jL,{contentName:Ja,titleName:v2,docsSlug:"alert-dialog",children:t.jsx(Wz,{scope:s,cancelRef:u,children:t.jsxs(rx,{role:"alertdialog",...c,...o,ref:l,onOpenAutoFocus:Be(o.onOpenAutoFocus,f=>{var m;f.preventDefault(),(m=u.current)==null||m.focus({preventScroll:!0})}),onPointerDownOutside:f=>f.preventDefault(),onInteractOutside:f=>f.preventDefault(),children:[t.jsx(Vz,{children:n}),t.jsx(qz,{contentRef:d})]})})})});x2.displayName=Ja;var v2="AlertDialogTitle",y2=_.forwardRef((e,r)=>{const{__scopeAlertDialog:s,...n}=e,o=lo(s);return t.jsx(sx,{...o,...n,ref:r})});y2.displayName=v2;var b2="AlertDialogDescription",w2=_.forwardRef((e,r)=>{const{__scopeAlertDialog:s,...n}=e,o=lo(s);return t.jsx(nx,{...o,...n,ref:r})});w2.displayName=b2;var Gz="AlertDialogAction",_2=_.forwardRef((e,r)=>{const{__scopeAlertDialog:s,...n}=e,o=lo(s);return t.jsx(ix,{...o,...n,ref:r})});_2.displayName=Gz;var k2="AlertDialogCancel",S2=_.forwardRef((e,r)=>{const{__scopeAlertDialog:s,...n}=e,{cancelRef:o}=Uz(k2,s),c=lo(s),d=bt(r,o);return t.jsx(ix,{...c,...n,ref:d})});S2.displayName=k2;var qz=({contentRef:e})=>{const r=`\`${Ja}\` requires a description for the component to be accessible for screen reader users.
663
+ - Add a README.md with usage instructions`;m(`cd "${c}" && ${v.command} "${N}"`),u(!0),g(!0)},x=N=>{console.log("Terminal session ready:",N)},b=(N,P)=>{console.log("Terminal exited:",N,P),g(!1),N===0&&q.success("MCP project created successfully!")},S=()=>{u(!1),m(null),g(!1),s(""),o("")};return t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx("div",{className:"flex-none p-6 border-b border-gray-200 dark:border-slate-700 bg-white dark:bg-slate-950",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsxs("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white flex items-center gap-2",children:[t.jsx(Wr,{className:"w-7 h-7 text-purple-600"}),"Create MCP Server"]}),t.jsxs("p",{className:"text-gray-500 dark:text-slate-400 mt-1",children:["Generate a new MCP server project with ",v.name," assistance"]})]}),l&&t.jsxs(ne,{variant:"outline",onClick:S,className:"text-gray-600 dark:text-slate-300",children:[t.jsx(Rt,{className:"w-4 h-4 mr-2"}),"New Project"]})]})}),t.jsxs("div",{className:"flex-1 overflow-hidden flex",children:[t.jsx("div",{className:`${l?"w-1/3 border-r border-gray-200 dark:border-slate-700":"w-full max-w-2xl mx-auto"} p-6 overflow-auto`,children:t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-slate-300 mb-2",children:"MCP Name *"}),t.jsx(Oe,{value:r,onChange:N=>s(N.target.value),placeholder:"my-awesome-mcp",disabled:h}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400 mt-1",children:"This will be the project folder name"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-slate-300 mb-2",children:"Description"}),t.jsx(yt,{value:n,onChange:N=>o(N.target.value),placeholder:"Describe what your MCP server will do...",className:"min-h-[100px]",disabled:h})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-slate-300 mb-2",children:"Output Directory"}),t.jsx(Oe,{value:c,onChange:N=>d(N.target.value),placeholder:"/path/to/projects",className:"font-mono text-sm",disabled:h}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400 mt-1",children:"Where to create the new MCP project"})]}),t.jsxs("div",{className:"bg-purple-50 dark:bg-purple-950/30 border border-purple-200 dark:border-purple-800 rounded-lg p-4",children:[t.jsx("h3",{className:"text-sm font-medium text-purple-900 dark:text-purple-300 mb-2",children:"What will be created:"}),t.jsxs("ul",{className:"text-sm text-purple-700 dark:text-purple-400 space-y-1",children:[t.jsxs("li",{className:"flex items-center gap-2",children:[t.jsx(eh,{className:"w-4 h-4"}),"Python project with uv package manager"]}),t.jsxs("li",{className:"flex items-center gap-2",children:[t.jsx(tl,{className:"w-4 h-4"}),"FastMCP framework setup"]}),t.jsxs("li",{className:"flex items-center gap-2",children:[t.jsx(vr,{className:"w-4 h-4"}),"mcp_server.py with basic structure"]}),t.jsxs("li",{className:"flex items-center gap-2",children:[t.jsx(Yn,{className:"w-4 h-4"}),"pyproject.toml configured for uv"]})]})]}),!l&&t.jsxs(ne,{onClick:y,className:"w-full bg-purple-600 hover:bg-purple-700 text-white",disabled:!r.trim(),children:[t.jsx(Wr,{className:"w-4 h-4 mr-2"}),"Create & Launch ",v.name]})]})}),l&&t.jsxs("div",{className:"flex-1 flex flex-col bg-gray-900",children:[t.jsxs("div",{className:"flex-none px-4 py-2 border-b border-gray-700 flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Ut,{className:"w-4 h-4 text-gray-400"}),t.jsxs("span",{className:"text-sm text-gray-300",children:[v.name," Terminal"]})]}),t.jsx("div",{className:"flex items-center gap-2",children:h&&t.jsxs(qe,{variant:"outline",className:"bg-green-900/50 text-green-400 border-green-700",children:[t.jsx(Qe,{className:"w-3 h-3 mr-1 animate-spin"}),"Running"]})})]}),t.jsx("div",{className:"flex-1",children:t.jsx(Sh,{cwd:c,initialCommand:f,onReady:x,onExit:b,height:"100%"})})]})]})]})}var Lz=Symbol("radix.slottable");function Oz(e){const r=({children:s})=>t.jsx(t.Fragment,{children:s});return r.displayName=`${e}.Slottable`,r.__radixId=Lz,r}var Fz="AlertDialog",[Bz]=Ls(Fz,[hC]),lo=hC(),$z="AlertDialogTrigger",Hz=_.forwardRef((e,r)=>{const{__scopeAlertDialog:s,...n}=e,o=lo(s);return t.jsx(TL,{...o,...n,ref:r})});Hz.displayName=$z;var zz="AlertDialogPortal",p2=e=>{const{__scopeAlertDialog:r,...s}=e,n=lo(r);return t.jsx(EC,{...n,...s})};p2.displayName=zz;var Wz="AlertDialogOverlay",g2=_.forwardRef((e,r)=>{const{__scopeAlertDialog:s,...n}=e,o=lo(s);return t.jsx(tx,{...o,...n,ref:r})});g2.displayName=Wz;var Ja="AlertDialogContent",[Uz,Vz]=Bz(Ja),Gz=Oz("AlertDialogContent"),x2=_.forwardRef((e,r)=>{const{__scopeAlertDialog:s,children:n,...o}=e,c=lo(s),d=_.useRef(null),l=bt(r,d),u=_.useRef(null);return t.jsx(jL,{contentName:Ja,titleName:v2,docsSlug:"alert-dialog",children:t.jsx(Uz,{scope:s,cancelRef:u,children:t.jsxs(rx,{role:"alertdialog",...c,...o,ref:l,onOpenAutoFocus:Be(o.onOpenAutoFocus,f=>{var m;f.preventDefault(),(m=u.current)==null||m.focus({preventScroll:!0})}),onPointerDownOutside:f=>f.preventDefault(),onInteractOutside:f=>f.preventDefault(),children:[t.jsx(Gz,{children:n}),t.jsx(Kz,{contentRef:d})]})})})});x2.displayName=Ja;var v2="AlertDialogTitle",y2=_.forwardRef((e,r)=>{const{__scopeAlertDialog:s,...n}=e,o=lo(s);return t.jsx(sx,{...o,...n,ref:r})});y2.displayName=v2;var b2="AlertDialogDescription",w2=_.forwardRef((e,r)=>{const{__scopeAlertDialog:s,...n}=e,o=lo(s);return t.jsx(nx,{...o,...n,ref:r})});w2.displayName=b2;var qz="AlertDialogAction",_2=_.forwardRef((e,r)=>{const{__scopeAlertDialog:s,...n}=e,o=lo(s);return t.jsx(ix,{...o,...n,ref:r})});_2.displayName=qz;var k2="AlertDialogCancel",S2=_.forwardRef((e,r)=>{const{__scopeAlertDialog:s,...n}=e,{cancelRef:o}=Vz(k2,s),c=lo(s),d=bt(r,o);return t.jsx(ix,{...c,...n,ref:d})});S2.displayName=k2;var Kz=({contentRef:e})=>{const r=`\`${Ja}\` requires a description for the component to be accessible for screen reader users.
664
664
 
665
665
  You can add a description to the \`${Ja}\` by passing a \`${b2}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
666
666
 
667
667
  Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${Ja}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
668
668
 
669
- For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return _.useEffect(()=>{var n;document.getElementById((n=e.current)==null?void 0:n.getAttribute("aria-describedby"))||console.warn(r)},[r,e]),null},Kz=p2,C2=g2,j2=x2,N2=_2,E2=S2,P2=y2,A2=w2;const Yz=Kz,T2=_.forwardRef(({className:e,...r},s)=>t.jsx(C2,{className:Ee("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...r,ref:s}));T2.displayName=C2.displayName;const Xz=_.forwardRef(({className:e,...r},s)=>t.jsxs(Yz,{children:[t.jsx(T2,{}),t.jsx(j2,{ref:s,className:Ee("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...r})]}));Xz.displayName=j2.displayName;const Jz=_.forwardRef(({className:e,...r},s)=>t.jsx(P2,{ref:s,className:Ee("text-lg font-semibold",e),...r}));Jz.displayName=P2.displayName;const Qz=_.forwardRef(({className:e,...r},s)=>t.jsx(A2,{ref:s,className:Ee("text-sm text-muted-foreground",e),...r}));Qz.displayName=A2.displayName;const Zz=_.forwardRef(({className:e,...r},s)=>t.jsx(N2,{ref:s,className:Ee(Vg(),e),...r}));Zz.displayName=N2.displayName;const eW=_.forwardRef(({className:e,...r},s)=>t.jsx(E2,{ref:s,className:Ee(Vg({variant:"outline"}),"mt-2 sm:mt-0",e),...r}));eW.displayName=E2.displayName;const tW=(e,r)=>{try{const s=localStorage.getItem(`claude-config-${e}`);return s?JSON.parse(s):r}catch{return r}},rW=(e,r)=>{try{localStorage.setItem(`claude-config-${e}`,JSON.stringify(r))}catch{}},C_={claude:{name:"Claude Code",command:"claude",color:"orange"},gemini:{name:"Gemini CLI",command:"gemini",color:"blue"}};function sW({registry:e,searchQuery:r,setSearchQuery:s,onUpdate:n}){var ae;const[o,c]=_.useState(()=>tW("registrySearchMode","local")),d=re=>{c(re),rW("registrySearchMode",re)},[l,u]=_.useState([]),[f,m]=_.useState(!1),[h,g]=_.useState({open:!1,name:"",mcp:null,isNew:!1}),[w,j]=_.useState({name:"",command:"npx",args:"",env:"",description:""}),[k,v]=_.useState(!1),[y,x]=_.useState([]),[b,S]=_.useState(""),[N,P]=_.useState({open:!1,url:"",showTerminal:!1,localTool:null,pastedConfig:"",mode:"url"}),[A,E]=_.useState(""),[M,I]=_.useState("claude");_.useEffect(()=>{(async()=>{var de;try{const Se=await he.getConfig();I(((de=Se.config)==null?void 0:de.aiAssistant)||"claude")}catch(Se){console.error("Failed to load preferences:",Se)}})()},[]);const B=C_[M]||C_.claude,U=Object.entries(e.mcpServers||{}),V=U.filter(([re])=>re.toLowerCase().includes(r.toLowerCase()));_.useEffect(()=>{(async()=>{try{const de=await he.getMcpTools();x(de.tools||[]),S(de.dir||"")}catch(de){console.error("Failed to load MCP tools:",de)}})()},[]);const Q=y.filter(re=>{var de;return!((de=e.mcpServers)!=null&&de[re.name])&&re.name.toLowerCase().includes(r.toLowerCase())}),z=(re,de)=>{j({name:re,command:de.command||"npx",args:JSON.stringify(de.args||[],null,2),env:JSON.stringify(de.env||{},null,2),description:de.description||""}),g({open:!0,name:re,mcp:de,isNew:!1})},[H,Y]=_.useState({open:!1,json:""}),K=()=>{Y({open:!0,json:""})},O=async()=>{if(!H.json.trim()){q.error("Please paste the MCP JSON configuration");return}try{let re;try{re=JSON.parse(H.json)}catch{q.error("Invalid JSON format");return}let de={};if(re.mcpServers&&typeof re.mcpServers=="object")de=re.mcpServers;else if(typeof re=="object"&&!Array.isArray(re)){if(Object.keys(re).includes("command")){q.error('JSON is missing the MCP name. Expected: { "name": { "command": "...", "args": [...] } }');return}de=re}if(Object.keys(de).length===0){q.error("No MCP configurations found in the JSON");return}for(const[Ue,pe]of Object.entries(de))if(!pe.command){q.error(`MCP "${Ue}" is missing required "command" field`);return}const Se={...e};Se.mcpServers||(Se.mcpServers={});for(const[Ue,pe]of Object.entries(de))Se.mcpServers[Ue]=pe;await he.updateRegistry(Se);const Re=Object.keys(de).length;q.success(`Added ${Re} MCP${Re>1?"s":""} to registry!`),Y({open:!1,json:""}),n()}catch(re){q.error("Failed to add: "+re.message)}},T=re=>{const Se={[re.name.replace("@modelcontextprotocol/server-","").replace("mcp-server-","").replace("mcp-","").replace(/-/g,"_")]:{command:re.suggestedCommand||"npx",args:re.suggestedArgs||["-y",re.name],...re.description&&{description:re.description}}};Y({open:!0,json:JSON.stringify(Se,null,2)})},F=re=>{let de,Se;re.type==="python"?(de="uv",Se=["run","--directory",re.path,"python",re.entryPoint||"mcp_server.py"]):(de="node",Se=[re.path+"/index.js"]);const Re={[re.name]:{command:de,args:Se,...re.description&&{description:re.description}}};Y({open:!0,json:JSON.stringify(Re,null,2)})},$=()=>{if(!N.url.trim()){q.error("Please enter a URL");return}P(re=>({...re,showTerminal:!0}))},D=()=>{if(N.localTool){const Se=N.localTool,Re=`Analyze the MCP server at ${Se.path}. Read the README and source files to understand how to run it. Output a JSON config block with name, command, args array, and description for the MCP registry. Be specific about the exact command needed.`;return`cd '${Se.path}' && ${B.command} '${Re}'`}const de=`Clone ${N.url.trim()} into ~/reg/tools. Read the README, determine if Python or Node MCP server, and output a JSON config block with name, command, args, and description.`;return`cd ~/reg/tools && ${B.command} '${de}'`},X=re=>{P({open:!0,url:"",showTerminal:!0,localTool:re,pastedConfig:""})},te=re=>{re===0&&(q.success("Import completed! Paste the JSON config below to add it to the registry."),he.getMcpTools().then(de=>{x(de.tools||[])}))},fe=async()=>{if(!N.pastedConfig.trim()){q.error("Please paste the JSON config first");return}try{let re;try{re=JSON.parse(N.pastedConfig)}catch{q.error("Invalid JSON format");return}let de={};if(re.mcpServers&&typeof re.mcpServers=="object")de=re.mcpServers;else if(typeof re=="object"&&!Array.isArray(re))if(Object.keys(re).includes("command")){q.error('JSON is missing the MCP name. Expected format: { "name": { "command": "...", "args": [...] } }');return}else de=re;if(Object.keys(de).length===0){q.error("No MCP configurations found in the pasted JSON");return}for(const[Ue,pe]of Object.entries(de))if(!pe.command){q.error(`MCP "${Ue}" is missing required "command" field`);return}const Se={...e};Se.mcpServers||(Se.mcpServers={});for(const[Ue,pe]of Object.entries(de))Se.mcpServers[Ue]=pe;await he.updateRegistry(Se);const Re=Object.keys(de).length;q.success(`Added ${Re} MCP${Re>1?"s":""} to registry!`),P({open:!1,url:"",showTerminal:!1,localTool:null,pastedConfig:"",mode:"url"}),n()}catch(re){q.error("Failed to add config: "+re.message)}},J=async()=>{v(!0);try{let re,de;try{re=JSON.parse(w.args),de=JSON.parse(w.env)}catch{q.error("Invalid JSON in args or env"),v(!1);return}const Se={...e};Se.mcpServers||(Se.mcpServers={});const Re={command:w.command,args:re,...Object.keys(de).length>0&&{env:de},...w.description&&{description:w.description}};Se.mcpServers[h.name]=Re,await he.updateRegistry(Se),q.success("MCP updated"),g({open:!1,name:"",mcp:null,isNew:!1}),n()}catch(re){q.error("Failed to save: "+re.message)}finally{v(!1)}},W=async re=>{try{const de={...e};delete de.mcpServers[re],await he.updateRegistry(de),q.success(`Removed ${re} from registry`),n()}catch(de){q.error("Failed to delete: "+de.message)}},le=async()=>{if(r.trim()){m(!0);try{const re=o==="github"?await he.searchGithub(r):await he.searchNpm(r);u(re.results||[])}catch(re){q.error("Search failed: "+re.message),u([])}finally{m(!1)}}};return _.useEffect(()=>{o!=="local"&&u([])},[o]),t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 overflow-hidden shadow-sm",children:[t.jsxs("div",{className:"p-5 border-b border-gray-200 dark:border-slate-700",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white dark:text-white flex items-center gap-2",children:[t.jsx(Yn,{className:"w-5 h-5 text-blue-600"}),"MCP Registry"]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs(ne,{variant:"outline",size:"sm",onClick:()=>P({open:!0,url:"",showTerminal:!1,localTool:null,pastedConfig:"",mode:"folder"}),className:"border-green-300 dark:border-green-700 text-green-700 dark:text-green-400 hover:bg-green-50 dark:hover:bg-green-950/30",children:[t.jsx(Xr,{className:"w-4 h-4 mr-2"}),"Import Folder"]}),t.jsxs(ne,{variant:"outline",size:"sm",onClick:()=>P({open:!0,url:"",showTerminal:!1,localTool:null,pastedConfig:"",mode:"url"}),className:"border-purple-300 dark:border-purple-700 text-purple-700 dark:text-purple-400 hover:bg-purple-50 dark:hover:bg-purple-950/30",children:[t.jsx(xu,{className:"w-4 h-4 mr-2"}),"Import URL"]}),t.jsxs(ne,{variant:"outline",size:"sm",onClick:K,className:"border-blue-300 dark:border-blue-700 text-blue-700 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-950/30",children:[t.jsx(Rt,{className:"w-4 h-4 mr-2"}),"Add MCP"]})]})]}),t.jsxs("div",{className:"flex gap-2 mb-4",children:[t.jsxs(ne,{variant:o==="local"?"default":"outline",size:"sm",onClick:()=>d("local"),className:o==="local"?"bg-blue-600":"",children:[t.jsx(Yn,{className:"w-4 h-4 mr-2"}),"Registry (",U.length,")"]}),t.jsxs(ne,{variant:o==="tools"?"default":"outline",size:"sm",onClick:()=>d("tools"),className:o==="tools"?"bg-purple-600":"",children:[t.jsx(Xr,{className:"w-4 h-4 mr-2"}),"Tools (",y.length,")"]}),t.jsxs(ne,{variant:o==="github"?"default":"outline",size:"sm",onClick:()=>d("github"),className:o==="github"?"bg-gray-800":"",children:[t.jsx(S5,{className:"w-4 h-4 mr-2"}),"GitHub"]}),t.jsxs(ne,{variant:o==="npm"?"default":"outline",size:"sm",onClick:()=>d("npm"),className:o==="npm"?"bg-red-600":"",children:[t.jsx(eo,{className:"w-4 h-4 mr-2"}),"npm"]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs("div",{className:"relative flex-1",children:[t.jsx(Ic,{className:"w-4 h-4 absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),t.jsx(Oe,{value:r,onChange:re=>s(re.target.value),onKeyDown:re=>re.key==="Enter"&&!["local","tools"].includes(o)&&le(),placeholder:o==="local"?"Filter registry...":o==="tools"?"Filter discovered tools...":`Search ${o} for MCPs...`,className:"pl-9 bg-white dark:bg-slate-900 border-gray-300 dark:border-slate-600"})]}),!["local","tools"].includes(o)&&t.jsx(ne,{onClick:le,disabled:f,children:f?t.jsx(Qe,{className:"w-4 h-4 animate-spin"}):"Search"})]})]}),o==="local"&&t.jsxs("div",{className:"p-4 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[V.map(([re,de],Se)=>{var Re;return t.jsxs(Ua.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:Se*.03},className:"bg-white dark:bg-slate-900 rounded-lg border border-gray-200 dark:border-slate-700 p-4 hover:border-blue-300 hover:shadow-md transition-all group",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("h3",{className:"font-semibold text-gray-900 dark:text-white",children:re}),t.jsxs(En,{children:[t.jsx(Pn,{asChild:!0,children:t.jsx(ne,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100",children:t.jsx(i5,{className:"w-4 h-4 text-gray-400"})})}),t.jsxs(hn,{children:[t.jsxs(jt,{onClick:()=>z(re,de),children:[t.jsx(yS,{className:"w-4 h-4 mr-2"}),"Edit"]}),t.jsxs(jt,{className:"text-red-600",onClick:()=>W(re),children:[t.jsx(fs,{className:"w-4 h-4 mr-2"}),"Delete"]})]})]})]}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-slate-400 mb-3",children:de.description||"MCP server"}),t.jsxs("code",{className:"text-xs text-gray-500 dark:text-slate-400 block truncate bg-gray-50 dark:bg-slate-800 px-2 py-1 rounded",children:[de.command," ",(Re=de.args)==null?void 0:Re.join(" ")]}),de.env&&Object.keys(de.env).length>0&&t.jsxs("div",{className:"mt-2 text-xs text-amber-600",children:["Requires: ",Object.keys(de.env).join(", ")]})]},re)}),V.length===0&&t.jsx("div",{className:"col-span-full text-center py-8 text-gray-500 dark:text-slate-400",children:r?"No MCPs match your search.":"Registry is empty. Add MCPs or search online."})]}),o==="tools"&&t.jsxs("div",{className:"p-4",children:[b&&t.jsxs("div",{className:"mb-4 text-sm text-gray-500 dark:text-slate-400 flex items-center gap-2",children:[t.jsx(Xr,{className:"w-4 h-4"}),"Scanning: ",b]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[Q.map((re,de)=>t.jsxs(Ua.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:de*.03},className:"bg-purple-50 dark:bg-purple-950/30 rounded-lg border border-purple-200 dark:border-purple-800 p-4 hover:border-purple-400 dark:hover:border-purple-600 hover:shadow-md transition-all",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("h3",{className:"font-semibold text-purple-900 dark:text-purple-200",children:re.name}),t.jsx(qe,{variant:"outline",className:"text-purple-600 dark:text-purple-400 border-purple-300 dark:border-purple-700",children:re.type==="python"?"Python":"Node"})]}),t.jsx("p",{className:"text-sm text-purple-700 dark:text-purple-300 mb-3",children:re.description||"MCP tool"}),t.jsx("code",{className:"text-xs text-purple-600 dark:text-purple-400 block truncate bg-purple-100 dark:bg-purple-900/50 px-2 py-1 rounded mb-3",children:re.path}),re.framework&&t.jsxs("div",{className:"text-xs text-purple-500 dark:text-purple-400 mb-3",children:["Framework: ",re.framework]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs(ne,{size:"sm",variant:"outline",onClick:()=>F(re),className:"flex-1 border-purple-300 dark:border-purple-700 text-purple-700 dark:text-purple-300 hover:bg-purple-100 dark:hover:bg-purple-900/50",children:[t.jsx(Rt,{className:"w-4 h-4 mr-1"}),"Quick"]}),t.jsxs(ne,{size:"sm",onClick:()=>X(re),className:"flex-1 bg-purple-600 hover:bg-purple-700 text-white",children:[t.jsx(Wr,{className:"w-4 h-4 mr-1"}),"Smart"]})]})]},re.name)),Q.length===0&&y.length>0&&t.jsx("div",{className:"col-span-full text-center py-8 text-gray-500 dark:text-slate-400",children:"All discovered tools are already in the registry."}),y.length===0&&t.jsxs("div",{className:"col-span-full text-center py-8 text-gray-500 dark:text-slate-400",children:["No MCP tools found in ",b,". Create one using the Developer > Create MCP view."]})]})]}),!["local","tools"].includes(o)&&t.jsx("div",{className:"p-4",children:f?t.jsxs("div",{className:"text-center py-8",children:[t.jsx(Qe,{className:"w-8 h-8 animate-spin mx-auto text-gray-400"}),t.jsxs("p",{className:"text-gray-500 dark:text-slate-400 mt-2",children:["Searching ",o,"..."]})]}):l.length>0?t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:l.map((re,de)=>{var Se;return t.jsxs(Ua.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:de*.03},className:"bg-white dark:bg-slate-900 rounded-lg border border-gray-200 dark:border-slate-700 p-4 hover:border-blue-300 hover:shadow-md transition-all",children:[t.jsxs("div",{className:"flex items-start justify-between mb-2",children:[t.jsx("h3",{className:"font-semibold text-gray-900 dark:text-white text-sm",children:re.name}),re.stars!==void 0&&t.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-600",children:[t.jsx(CI,{className:"w-3 h-3"}),re.stars]})]}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-slate-400 mb-3 line-clamp-2",children:re.description||"No description"}),t.jsxs("code",{className:"text-xs text-gray-500 dark:text-slate-400 block truncate bg-gray-50 dark:bg-slate-800 px-2 py-1 rounded mb-3",children:[re.suggestedCommand," ",(Se=re.suggestedArgs)==null?void 0:Se.join(" ")]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs(ne,{size:"sm",onClick:()=>T(re),className:"flex-1 bg-blue-600 hover:bg-blue-700 text-white",children:[t.jsx(Rt,{className:"w-3 h-3 mr-1"}),"Add to Registry"]}),re.url&&t.jsx(ne,{size:"sm",variant:"outline",onClick:()=>window.open(re.url,"_blank"),children:t.jsx(xu,{className:"w-3 h-3"})})]})]},re.name||de)})}):t.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-slate-400",children:r?"No results found. Try a different search term.":`Enter a search term to find MCPs on ${o}.`})})]}),t.jsx(vt,{open:H.open,onOpenChange:re=>Y({...H,open:re}),children:t.jsxs(ft,{className:"bg-white dark:bg-slate-950 max-w-2xl",children:[t.jsxs(mt,{children:[t.jsx(pt,{children:"Add MCP to Registry"}),t.jsx(Gt,{children:"Paste the MCP JSON configuration block to add to your registry."})]}),t.jsxs("div",{className:"py-4",children:[t.jsx(yt,{value:H.json,onChange:re=>Y({...H,json:re.target.value}),placeholder:`{
669
+ For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return _.useEffect(()=>{var n;document.getElementById((n=e.current)==null?void 0:n.getAttribute("aria-describedby"))||console.warn(r)},[r,e]),null},Yz=p2,C2=g2,j2=x2,N2=_2,E2=S2,P2=y2,A2=w2;const Xz=Yz,T2=_.forwardRef(({className:e,...r},s)=>t.jsx(C2,{className:Ee("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...r,ref:s}));T2.displayName=C2.displayName;const Jz=_.forwardRef(({className:e,...r},s)=>t.jsxs(Xz,{children:[t.jsx(T2,{}),t.jsx(j2,{ref:s,className:Ee("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...r})]}));Jz.displayName=j2.displayName;const Qz=_.forwardRef(({className:e,...r},s)=>t.jsx(P2,{ref:s,className:Ee("text-lg font-semibold",e),...r}));Qz.displayName=P2.displayName;const Zz=_.forwardRef(({className:e,...r},s)=>t.jsx(A2,{ref:s,className:Ee("text-sm text-muted-foreground",e),...r}));Zz.displayName=A2.displayName;const eW=_.forwardRef(({className:e,...r},s)=>t.jsx(N2,{ref:s,className:Ee(Vg(),e),...r}));eW.displayName=N2.displayName;const tW=_.forwardRef(({className:e,...r},s)=>t.jsx(E2,{ref:s,className:Ee(Vg({variant:"outline"}),"mt-2 sm:mt-0",e),...r}));tW.displayName=E2.displayName;const rW=(e,r)=>{try{const s=localStorage.getItem(`claude-config-${e}`);return s?JSON.parse(s):r}catch{return r}},sW=(e,r)=>{try{localStorage.setItem(`claude-config-${e}`,JSON.stringify(r))}catch{}},C_={claude:{name:"Claude Code",command:"claude",color:"orange"},gemini:{name:"Gemini CLI",command:"gemini",color:"blue"}};function nW({registry:e,searchQuery:r,setSearchQuery:s,onUpdate:n}){var ae;const[o,c]=_.useState(()=>rW("registrySearchMode","local")),d=re=>{c(re),sW("registrySearchMode",re)},[l,u]=_.useState([]),[f,m]=_.useState(!1),[h,g]=_.useState({open:!1,name:"",mcp:null,isNew:!1}),[w,j]=_.useState({name:"",command:"npx",args:"",env:"",description:""}),[k,v]=_.useState(!1),[y,x]=_.useState([]),[b,S]=_.useState(""),[N,P]=_.useState({open:!1,url:"",showTerminal:!1,localTool:null,pastedConfig:"",mode:"url"}),[A,E]=_.useState(""),[M,I]=_.useState("claude");_.useEffect(()=>{(async()=>{var de;try{const Se=await he.getConfig();I(((de=Se.config)==null?void 0:de.aiAssistant)||"claude")}catch(Se){console.error("Failed to load preferences:",Se)}})()},[]);const B=C_[M]||C_.claude,U=Object.entries(e.mcpServers||{}),V=U.filter(([re])=>re.toLowerCase().includes(r.toLowerCase()));_.useEffect(()=>{(async()=>{try{const de=await he.getMcpTools();x(de.tools||[]),S(de.dir||"")}catch(de){console.error("Failed to load MCP tools:",de)}})()},[]);const Q=y.filter(re=>{var de;return!((de=e.mcpServers)!=null&&de[re.name])&&re.name.toLowerCase().includes(r.toLowerCase())}),z=(re,de)=>{j({name:re,command:de.command||"npx",args:JSON.stringify(de.args||[],null,2),env:JSON.stringify(de.env||{},null,2),description:de.description||""}),g({open:!0,name:re,mcp:de,isNew:!1})},[H,Y]=_.useState({open:!1,json:""}),K=()=>{Y({open:!0,json:""})},O=async()=>{if(!H.json.trim()){q.error("Please paste the MCP JSON configuration");return}try{let re;try{re=JSON.parse(H.json)}catch{q.error("Invalid JSON format");return}let de={};if(re.mcpServers&&typeof re.mcpServers=="object")de=re.mcpServers;else if(typeof re=="object"&&!Array.isArray(re)){if(Object.keys(re).includes("command")){q.error('JSON is missing the MCP name. Expected: { "name": { "command": "...", "args": [...] } }');return}de=re}if(Object.keys(de).length===0){q.error("No MCP configurations found in the JSON");return}for(const[Ue,pe]of Object.entries(de))if(!pe.command){q.error(`MCP "${Ue}" is missing required "command" field`);return}const Se={...e};Se.mcpServers||(Se.mcpServers={});for(const[Ue,pe]of Object.entries(de))Se.mcpServers[Ue]=pe;await he.updateRegistry(Se);const Re=Object.keys(de).length;q.success(`Added ${Re} MCP${Re>1?"s":""} to registry!`),Y({open:!1,json:""}),n()}catch(re){q.error("Failed to add: "+re.message)}},T=re=>{const Se={[re.name.replace("@modelcontextprotocol/server-","").replace("mcp-server-","").replace("mcp-","").replace(/-/g,"_")]:{command:re.suggestedCommand||"npx",args:re.suggestedArgs||["-y",re.name],...re.description&&{description:re.description}}};Y({open:!0,json:JSON.stringify(Se,null,2)})},F=re=>{let de,Se;re.type==="python"?(de="uv",Se=["run","--directory",re.path,"python",re.entryPoint||"mcp_server.py"]):(de="node",Se=[re.path+"/index.js"]);const Re={[re.name]:{command:de,args:Se,...re.description&&{description:re.description}}};Y({open:!0,json:JSON.stringify(Re,null,2)})},$=()=>{if(!N.url.trim()){q.error("Please enter a URL");return}P(re=>({...re,showTerminal:!0}))},D=()=>{if(N.localTool){const Se=N.localTool,Re=`Analyze the MCP server at ${Se.path}. Read the README and source files to understand how to run it. Output a JSON config block with name, command, args array, and description for the MCP registry. Be specific about the exact command needed.`;return`cd '${Se.path}' && ${B.command} '${Re}'`}const de=`Clone ${N.url.trim()} into ~/reg/tools. Read the README, determine if Python or Node MCP server, and output a JSON config block with name, command, args, and description.`;return`cd ~/reg/tools && ${B.command} '${de}'`},X=re=>{P({open:!0,url:"",showTerminal:!0,localTool:re,pastedConfig:""})},te=re=>{re===0&&(q.success("Import completed! Paste the JSON config below to add it to the registry."),he.getMcpTools().then(de=>{x(de.tools||[])}))},fe=async()=>{if(!N.pastedConfig.trim()){q.error("Please paste the JSON config first");return}try{let re;try{re=JSON.parse(N.pastedConfig)}catch{q.error("Invalid JSON format");return}let de={};if(re.mcpServers&&typeof re.mcpServers=="object")de=re.mcpServers;else if(typeof re=="object"&&!Array.isArray(re))if(Object.keys(re).includes("command")){q.error('JSON is missing the MCP name. Expected format: { "name": { "command": "...", "args": [...] } }');return}else de=re;if(Object.keys(de).length===0){q.error("No MCP configurations found in the pasted JSON");return}for(const[Ue,pe]of Object.entries(de))if(!pe.command){q.error(`MCP "${Ue}" is missing required "command" field`);return}const Se={...e};Se.mcpServers||(Se.mcpServers={});for(const[Ue,pe]of Object.entries(de))Se.mcpServers[Ue]=pe;await he.updateRegistry(Se);const Re=Object.keys(de).length;q.success(`Added ${Re} MCP${Re>1?"s":""} to registry!`),P({open:!1,url:"",showTerminal:!1,localTool:null,pastedConfig:"",mode:"url"}),n()}catch(re){q.error("Failed to add config: "+re.message)}},J=async()=>{v(!0);try{let re,de;try{re=JSON.parse(w.args),de=JSON.parse(w.env)}catch{q.error("Invalid JSON in args or env"),v(!1);return}const Se={...e};Se.mcpServers||(Se.mcpServers={});const Re={command:w.command,args:re,...Object.keys(de).length>0&&{env:de},...w.description&&{description:w.description}};Se.mcpServers[h.name]=Re,await he.updateRegistry(Se),q.success("MCP updated"),g({open:!1,name:"",mcp:null,isNew:!1}),n()}catch(re){q.error("Failed to save: "+re.message)}finally{v(!1)}},W=async re=>{try{const de={...e};delete de.mcpServers[re],await he.updateRegistry(de),q.success(`Removed ${re} from registry`),n()}catch(de){q.error("Failed to delete: "+de.message)}},le=async()=>{if(r.trim()){m(!0);try{const re=o==="github"?await he.searchGithub(r):await he.searchNpm(r);u(re.results||[])}catch(re){q.error("Search failed: "+re.message),u([])}finally{m(!1)}}};return _.useEffect(()=>{o!=="local"&&u([])},[o]),t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 overflow-hidden shadow-sm",children:[t.jsxs("div",{className:"p-5 border-b border-gray-200 dark:border-slate-700",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white dark:text-white flex items-center gap-2",children:[t.jsx(Yn,{className:"w-5 h-5 text-blue-600"}),"MCP Registry"]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs(ne,{variant:"outline",size:"sm",onClick:()=>P({open:!0,url:"",showTerminal:!1,localTool:null,pastedConfig:"",mode:"folder"}),className:"border-green-300 dark:border-green-700 text-green-700 dark:text-green-400 hover:bg-green-50 dark:hover:bg-green-950/30",children:[t.jsx(Xr,{className:"w-4 h-4 mr-2"}),"Import Folder"]}),t.jsxs(ne,{variant:"outline",size:"sm",onClick:()=>P({open:!0,url:"",showTerminal:!1,localTool:null,pastedConfig:"",mode:"url"}),className:"border-purple-300 dark:border-purple-700 text-purple-700 dark:text-purple-400 hover:bg-purple-50 dark:hover:bg-purple-950/30",children:[t.jsx(xu,{className:"w-4 h-4 mr-2"}),"Import URL"]}),t.jsxs(ne,{variant:"outline",size:"sm",onClick:K,className:"border-blue-300 dark:border-blue-700 text-blue-700 dark:text-blue-400 hover:bg-blue-50 dark:hover:bg-blue-950/30",children:[t.jsx(Rt,{className:"w-4 h-4 mr-2"}),"Add MCP"]})]})]}),t.jsxs("div",{className:"flex gap-2 mb-4",children:[t.jsxs(ne,{variant:o==="local"?"default":"outline",size:"sm",onClick:()=>d("local"),className:o==="local"?"bg-blue-600":"",children:[t.jsx(Yn,{className:"w-4 h-4 mr-2"}),"Registry (",U.length,")"]}),t.jsxs(ne,{variant:o==="tools"?"default":"outline",size:"sm",onClick:()=>d("tools"),className:o==="tools"?"bg-purple-600":"",children:[t.jsx(Xr,{className:"w-4 h-4 mr-2"}),"Tools (",y.length,")"]}),t.jsxs(ne,{variant:o==="github"?"default":"outline",size:"sm",onClick:()=>d("github"),className:o==="github"?"bg-gray-800":"",children:[t.jsx(S5,{className:"w-4 h-4 mr-2"}),"GitHub"]}),t.jsxs(ne,{variant:o==="npm"?"default":"outline",size:"sm",onClick:()=>d("npm"),className:o==="npm"?"bg-red-600":"",children:[t.jsx(eo,{className:"w-4 h-4 mr-2"}),"npm"]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs("div",{className:"relative flex-1",children:[t.jsx(Ic,{className:"w-4 h-4 absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),t.jsx(Oe,{value:r,onChange:re=>s(re.target.value),onKeyDown:re=>re.key==="Enter"&&!["local","tools"].includes(o)&&le(),placeholder:o==="local"?"Filter registry...":o==="tools"?"Filter discovered tools...":`Search ${o} for MCPs...`,className:"pl-9 bg-white dark:bg-slate-900 border-gray-300 dark:border-slate-600"})]}),!["local","tools"].includes(o)&&t.jsx(ne,{onClick:le,disabled:f,children:f?t.jsx(Qe,{className:"w-4 h-4 animate-spin"}):"Search"})]})]}),o==="local"&&t.jsxs("div",{className:"p-4 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[V.map(([re,de],Se)=>{var Re;return t.jsxs(Ua.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:Se*.03},className:"bg-white dark:bg-slate-900 rounded-lg border border-gray-200 dark:border-slate-700 p-4 hover:border-blue-300 hover:shadow-md transition-all group",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("h3",{className:"font-semibold text-gray-900 dark:text-white",children:re}),t.jsxs(En,{children:[t.jsx(Pn,{asChild:!0,children:t.jsx(ne,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-0 group-hover:opacity-100",children:t.jsx(i5,{className:"w-4 h-4 text-gray-400"})})}),t.jsxs(hn,{children:[t.jsxs(jt,{onClick:()=>z(re,de),children:[t.jsx(yS,{className:"w-4 h-4 mr-2"}),"Edit"]}),t.jsxs(jt,{className:"text-red-600",onClick:()=>W(re),children:[t.jsx(fs,{className:"w-4 h-4 mr-2"}),"Delete"]})]})]})]}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-slate-400 mb-3",children:de.description||"MCP server"}),t.jsxs("code",{className:"text-xs text-gray-500 dark:text-slate-400 block truncate bg-gray-50 dark:bg-slate-800 px-2 py-1 rounded",children:[de.command," ",(Re=de.args)==null?void 0:Re.join(" ")]}),de.env&&Object.keys(de.env).length>0&&t.jsxs("div",{className:"mt-2 text-xs text-amber-600",children:["Requires: ",Object.keys(de.env).join(", ")]})]},re)}),V.length===0&&t.jsx("div",{className:"col-span-full text-center py-8 text-gray-500 dark:text-slate-400",children:r?"No MCPs match your search.":"Registry is empty. Add MCPs or search online."})]}),o==="tools"&&t.jsxs("div",{className:"p-4",children:[b&&t.jsxs("div",{className:"mb-4 text-sm text-gray-500 dark:text-slate-400 flex items-center gap-2",children:[t.jsx(Xr,{className:"w-4 h-4"}),"Scanning: ",b]}),t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[Q.map((re,de)=>t.jsxs(Ua.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:de*.03},className:"bg-purple-50 dark:bg-purple-950/30 rounded-lg border border-purple-200 dark:border-purple-800 p-4 hover:border-purple-400 dark:hover:border-purple-600 hover:shadow-md transition-all",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("h3",{className:"font-semibold text-purple-900 dark:text-purple-200",children:re.name}),t.jsx(qe,{variant:"outline",className:"text-purple-600 dark:text-purple-400 border-purple-300 dark:border-purple-700",children:re.type==="python"?"Python":"Node"})]}),t.jsx("p",{className:"text-sm text-purple-700 dark:text-purple-300 mb-3",children:re.description||"MCP tool"}),t.jsx("code",{className:"text-xs text-purple-600 dark:text-purple-400 block truncate bg-purple-100 dark:bg-purple-900/50 px-2 py-1 rounded mb-3",children:re.path}),re.framework&&t.jsxs("div",{className:"text-xs text-purple-500 dark:text-purple-400 mb-3",children:["Framework: ",re.framework]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs(ne,{size:"sm",variant:"outline",onClick:()=>F(re),className:"flex-1 border-purple-300 dark:border-purple-700 text-purple-700 dark:text-purple-300 hover:bg-purple-100 dark:hover:bg-purple-900/50",children:[t.jsx(Rt,{className:"w-4 h-4 mr-1"}),"Quick"]}),t.jsxs(ne,{size:"sm",onClick:()=>X(re),className:"flex-1 bg-purple-600 hover:bg-purple-700 text-white",children:[t.jsx(Wr,{className:"w-4 h-4 mr-1"}),"Smart"]})]})]},re.name)),Q.length===0&&y.length>0&&t.jsx("div",{className:"col-span-full text-center py-8 text-gray-500 dark:text-slate-400",children:"All discovered tools are already in the registry."}),y.length===0&&t.jsxs("div",{className:"col-span-full text-center py-8 text-gray-500 dark:text-slate-400",children:["No MCP tools found in ",b,". Create one using the Developer > Create MCP view."]})]})]}),!["local","tools"].includes(o)&&t.jsx("div",{className:"p-4",children:f?t.jsxs("div",{className:"text-center py-8",children:[t.jsx(Qe,{className:"w-8 h-8 animate-spin mx-auto text-gray-400"}),t.jsxs("p",{className:"text-gray-500 dark:text-slate-400 mt-2",children:["Searching ",o,"..."]})]}):l.length>0?t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:l.map((re,de)=>{var Se;return t.jsxs(Ua.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:de*.03},className:"bg-white dark:bg-slate-900 rounded-lg border border-gray-200 dark:border-slate-700 p-4 hover:border-blue-300 hover:shadow-md transition-all",children:[t.jsxs("div",{className:"flex items-start justify-between mb-2",children:[t.jsx("h3",{className:"font-semibold text-gray-900 dark:text-white text-sm",children:re.name}),re.stars!==void 0&&t.jsxs("div",{className:"flex items-center gap-1 text-xs text-amber-600",children:[t.jsx(CI,{className:"w-3 h-3"}),re.stars]})]}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-slate-400 mb-3 line-clamp-2",children:re.description||"No description"}),t.jsxs("code",{className:"text-xs text-gray-500 dark:text-slate-400 block truncate bg-gray-50 dark:bg-slate-800 px-2 py-1 rounded mb-3",children:[re.suggestedCommand," ",(Se=re.suggestedArgs)==null?void 0:Se.join(" ")]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs(ne,{size:"sm",onClick:()=>T(re),className:"flex-1 bg-blue-600 hover:bg-blue-700 text-white",children:[t.jsx(Rt,{className:"w-3 h-3 mr-1"}),"Add to Registry"]}),re.url&&t.jsx(ne,{size:"sm",variant:"outline",onClick:()=>window.open(re.url,"_blank"),children:t.jsx(xu,{className:"w-3 h-3"})})]})]},re.name||de)})}):t.jsx("div",{className:"text-center py-8 text-gray-500 dark:text-slate-400",children:r?"No results found. Try a different search term.":`Enter a search term to find MCPs on ${o}.`})})]}),t.jsx(vt,{open:H.open,onOpenChange:re=>Y({...H,open:re}),children:t.jsxs(ft,{className:"bg-white dark:bg-slate-950 max-w-2xl",children:[t.jsxs(mt,{children:[t.jsx(pt,{children:"Add MCP to Registry"}),t.jsx(Gt,{children:"Paste the MCP JSON configuration block to add to your registry."})]}),t.jsxs("div",{className:"py-4",children:[t.jsx(yt,{value:H.json,onChange:re=>Y({...H,json:re.target.value}),placeholder:`{
670
670
  "my-mcp": {
671
671
  "command": "npx",
672
672
  "args": ["-y", "@example/mcp-server"],
@@ -681,7 +681,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/alert-
681
681
  "args": ["-y", "@example/mcp-server"]
682
682
  }
683
683
  }
684
- }`,className:"font-mono text-sm bg-white dark:bg-slate-900",rows:6})]}),t.jsxs("div",{className:"mt-4 flex justify-between",children:[t.jsx(ne,{variant:"outline",onClick:()=>P({open:!1,url:"",showTerminal:!1,localTool:null,pastedConfig:"",mode:"url"}),children:"Close"}),t.jsxs(ne,{onClick:fe,disabled:!N.pastedConfig.trim(),className:"bg-green-600 hover:bg-green-700 text-white",children:[t.jsx(Rt,{className:"w-4 h-4 mr-2"}),"Add to Registry"]})]})]})]})}),t.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-4 border border-transparent dark:border-slate-800",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white mb-2",children:"CLI Commands"}),t.jsxs("div",{className:"space-y-1 text-sm text-gray-600 dark:text-slate-400 font-mono",children:[t.jsx("p",{children:"coder-config list # List available MCPs (✓ = active)"}),t.jsx("p",{children:"coder-config add <mcp> [mcp...] # Add MCP(s) to project"}),t.jsx("p",{children:"coder-config remove <mcp> [mcp...] # Remove MCP(s) from project"}),t.jsx("p",{children:"coder-config registry # List MCPs in registry"}),t.jsx("p",{children:"coder-config registry add <name> '...' # Add MCP to registry"}),t.jsx("p",{children:"coder-config registry remove <name> # Remove from registry"})]})]})]})}function nW({project:e,onUpdate:r}){var B,U,V,Q;const[s,n]=_.useState(null),[o,c]=_.useState(!0),[d,l]=_.useState(null),[u,f]=_.useState(""),[m,h]=_.useState(!1),[g,w]=_.useState("global"),[j,k]=_.useState(""),[v,y]=_.useState([]),[x,b]=_.useState({open:!1,type:"preference",name:"",description:"",wrong:"",right:"",category:"",details:"",title:"",context:"",decision:"",rationale:"",content:""});_.useEffect(()=>{S()},[]);const S=async()=>{try{c(!0);const z=await he.getMemory();n(z)}catch{q.error("Failed to load memory")}finally{c(!1)}};_.useEffect(()=>{d&&N(d.path)},[d]);const N=async z=>{try{const H=await he.getMemoryFile(z);f(H.content||"")}catch{q.error("Failed to load file")}},P=async()=>{if(d){h(!0);try{await he.saveMemoryFile(d.path,u),q.success("Saved!"),S()}catch{q.error("Failed to save")}finally{h(!1)}}},A=async()=>{if(!j.trim()){y([]);return}try{const z=await he.searchMemory(j);y(z.results||[])}catch{q.error("Search failed")}},E=async()=>{let z="";const{type:H}=x;switch(H){case"preference":if(!x.name.trim()){q.error("Name required");return}z=`**${x.name}**: ${x.description}`;break;case"correction":if(!x.wrong.trim()||!x.right.trim()){q.error('Both "wrong" and "right" are required');return}z=`**Wrong**: ${x.wrong}
684
+ }`,className:"font-mono text-sm bg-white dark:bg-slate-900",rows:6})]}),t.jsxs("div",{className:"mt-4 flex justify-between",children:[t.jsx(ne,{variant:"outline",onClick:()=>P({open:!1,url:"",showTerminal:!1,localTool:null,pastedConfig:"",mode:"url"}),children:"Close"}),t.jsxs(ne,{onClick:fe,disabled:!N.pastedConfig.trim(),className:"bg-green-600 hover:bg-green-700 text-white",children:[t.jsx(Rt,{className:"w-4 h-4 mr-2"}),"Add to Registry"]})]})]})]})}),t.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-4 border border-transparent dark:border-slate-800",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white mb-2",children:"CLI Commands"}),t.jsxs("div",{className:"space-y-1 text-sm text-gray-600 dark:text-slate-400 font-mono",children:[t.jsx("p",{children:"coder-config list # List available MCPs (✓ = active)"}),t.jsx("p",{children:"coder-config add <mcp> [mcp...] # Add MCP(s) to project"}),t.jsx("p",{children:"coder-config remove <mcp> [mcp...] # Remove MCP(s) from project"}),t.jsx("p",{children:"coder-config registry # List MCPs in registry"}),t.jsx("p",{children:"coder-config registry add <name> '...' # Add MCP to registry"}),t.jsx("p",{children:"coder-config registry remove <name> # Remove from registry"})]})]})]})}function iW({project:e,onUpdate:r}){var B,U,V,Q;const[s,n]=_.useState(null),[o,c]=_.useState(!0),[d,l]=_.useState(null),[u,f]=_.useState(""),[m,h]=_.useState(!1),[g,w]=_.useState("global"),[j,k]=_.useState(""),[v,y]=_.useState([]),[x,b]=_.useState({open:!1,type:"preference",name:"",description:"",wrong:"",right:"",category:"",details:"",title:"",context:"",decision:"",rationale:"",content:""});_.useEffect(()=>{S()},[]);const S=async()=>{try{c(!0);const z=await he.getMemory();n(z)}catch{q.error("Failed to load memory")}finally{c(!1)}};_.useEffect(()=>{d&&N(d.path)},[d]);const N=async z=>{try{const H=await he.getMemoryFile(z);f(H.content||"")}catch{q.error("Failed to load file")}},P=async()=>{if(d){h(!0);try{await he.saveMemoryFile(d.path,u),q.success("Saved!"),S()}catch{q.error("Failed to save")}finally{h(!1)}}},A=async()=>{if(!j.trim()){y([]);return}try{const z=await he.searchMemory(j);y(z.results||[])}catch{q.error("Search failed")}},E=async()=>{let z="";const{type:H}=x;switch(H){case"preference":if(!x.name.trim()){q.error("Name required");return}z=`**${x.name}**: ${x.description}`;break;case"correction":if(!x.wrong.trim()||!x.right.trim()){q.error('Both "wrong" and "right" are required');return}z=`**Wrong**: ${x.wrong}
685
685
  **Right**: ${x.right}`;break;case"fact":if(!x.category.trim()){q.error("Category required");return}z=`**${x.category}**: ${x.details}`;break;case"pattern":if(!x.name.trim()){q.error("Name required");return}z=`**${x.name}**
686
686
  ${x.description}`;break;case"decision":if(!x.title.trim()){q.error("Title required");return}z=`**${x.title}**
687
687
 
@@ -691,9 +691,9 @@ ${x.description}`;break;case"decision":if(!x.title.trim()){q.error("Title requir
691
691
 
692
692
  **Rationale**: ${x.rationale}`;break;case"issue":if(!x.title.trim()){q.error("Title required");return}z=`**${x.title}**
693
693
 
694
- ${x.description}`;break;case"history":case"context":default:if(!x.content.trim()){q.error("Content required");return}z=x.content;break}try{const Y=["pattern","decision","issue","history","context"].includes(H)?"project":"global";await he.addMemoryEntry(H,z,Y),q.success(`Added ${H} entry`),b({open:!1,type:"preference",name:"",description:"",wrong:"",right:"",category:"",details:"",title:"",context:"",decision:"",rationale:"",content:""}),S()}catch{q.error("Failed to add entry")}},M=async()=>{try{await he.initProjectMemory(e.dir),q.success("Project memory initialized!"),S()}catch(z){q.error(z.message||"Failed to initialize")}};if(o)return t.jsx("div",{className:"flex items-center justify-center h-64",children:t.jsx(Qe,{className:"w-8 h-8 animate-spin text-indigo-600"})});const I={global:[{id:"preference",label:"Preference",icon:Xs,desc:"User preferences (tools, style, etc.)"},{id:"correction",label:"Correction",icon:Is,desc:"Mistakes to avoid"},{id:"fact",label:"Fact",icon:Oo,desc:"Facts about your environment"}],project:[{id:"context",label:"Context",icon:vr,desc:"Project overview and conventions"},{id:"pattern",label:"Pattern",icon:eh,desc:"Code patterns in this project"},{id:"decision",label:"Decision",icon:Yi,desc:"Architecture decisions"},{id:"issue",label:"Issue",icon:Is,desc:"Known issues and workarounds"},{id:"history",label:"History",icon:Ga,desc:"Session work log"}]};return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 p-5 shadow-sm",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center gap-2",children:[t.jsx(Fo,{className:"w-5 h-5 text-purple-600"}),"Memory System"]}),t.jsx("div",{className:"flex gap-2",children:t.jsxs(ne,{variant:"outline",size:"sm",onClick:()=>b({open:!0,type:"preference",name:"",description:"",wrong:"",right:"",category:"",details:"",title:"",context:"",decision:"",rationale:"",content:""}),children:[t.jsx(Rt,{className:"w-4 h-4 mr-2"}),"Add Entry"]})})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Oe,{placeholder:"Search memory...",value:j,onChange:z=>k(z.target.value),onKeyDown:z=>z.key==="Enter"&&A(),className:"flex-1"}),t.jsx(ne,{variant:"outline",onClick:A,children:t.jsx(Ic,{className:"w-4 h-4"})})]}),v.length>0&&t.jsxs("div",{className:"mt-4 p-3 bg-gray-50 dark:bg-slate-900 rounded-lg",children:[t.jsx("h3",{className:"text-sm font-medium text-gray-700 dark:text-slate-300 mb-2",children:"Search Results"}),t.jsx("div",{className:"space-y-2",children:v.map((z,H)=>t.jsxs("div",{className:"text-sm",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(qe,{variant:z.scope==="global"?"default":"secondary",children:z.scope}),t.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:z.file})]}),z.matches.map((Y,K)=>t.jsxs("div",{className:"ml-4 text-gray-600 dark:text-slate-400 text-xs mt-1",children:["Line ",Y.line,": ",Y.text]},K))]},H))})]})]}),t.jsx("div",{className:"flex gap-2 border-b border-gray-200 dark:border-slate-700 pb-2",children:["global","project","sync"].map(z=>t.jsxs("button",{onClick:()=>w(z),className:`px-4 py-2 text-sm font-medium rounded-t-lg transition-colors ${g===z?"bg-white dark:bg-slate-950 border border-b-white dark:border-b-slate-950 border-gray-200 dark:border-slate-700 -mb-[1px] text-indigo-600 dark:text-indigo-400":"text-gray-600 dark:text-slate-400 hover:text-gray-900 dark:hover:text-white"}`,children:[z.charAt(0).toUpperCase()+z.slice(1)," Memory"]},z))}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[t.jsxs("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 overflow-hidden shadow-sm",children:[t.jsxs("div",{className:"p-4 border-b border-gray-200 dark:border-slate-700",children:[t.jsxs("h3",{className:"font-medium text-gray-900 dark:text-white",children:[g==="global"&&"Global Memory Files",g==="project"&&"Project Memory Files",g==="sync"&&"Sync State"]}),t.jsxs("p",{className:"text-xs text-gray-500 dark:text-slate-400 mt-1",children:[g==="global"&&"~/.claude/memory/",g==="project"&&`${e.dir}/.claude/memory/`,g==="sync"&&"~/.claude/sync/"]})]}),t.jsxs("div",{className:"divide-y divide-gray-100 dark:divide-slate-800",children:[g==="global"&&((B=s==null?void 0:s.global)==null?void 0:B.files.map(z=>t.jsxs("button",{onClick:()=>z.exists&&l(z),className:`w-full px-4 py-3 flex items-center gap-3 text-left hover:bg-gray-50 dark:hover:bg-slate-900 transition-colors ${(d==null?void 0:d.path)===z.path?"bg-indigo-50 dark:bg-indigo-950/30":""} ${z.exists?"":"opacity-50"}`,children:[t.jsx(vr,{className:"w-4 h-4 text-gray-400 dark:text-slate-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:z.name}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400",children:z.type})]}),z.exists?t.jsx(It,{className:"w-4 h-4 text-green-500"}):t.jsx("span",{className:"text-xs text-gray-400 dark:text-slate-500",children:"Not created"})]},z.name))),g==="project"&&t.jsx(t.Fragment,{children:(U=s==null?void 0:s.project)!=null&&U.initialized?(V=s==null?void 0:s.project)==null?void 0:V.files.map(z=>t.jsxs("button",{onClick:()=>z.exists&&l(z),className:`w-full px-4 py-3 flex items-center gap-3 text-left hover:bg-gray-50 dark:hover:bg-slate-900 transition-colors ${(d==null?void 0:d.path)===z.path?"bg-indigo-50 dark:bg-indigo-950/30":""} ${z.exists?"":"opacity-50"}`,children:[t.jsx(vr,{className:"w-4 h-4 text-gray-400 dark:text-slate-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:z.name}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400",children:z.type})]}),z.exists?t.jsx(It,{className:"w-4 h-4 text-green-500"}):t.jsx("span",{className:"text-xs text-gray-400 dark:text-slate-500",children:"Not created"})]},z.name)):t.jsxs("div",{className:"p-6 text-center",children:[t.jsx(Fo,{className:"w-12 h-12 text-gray-300 dark:text-slate-600 mx-auto mb-3"}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-slate-400 mb-4",children:"Project memory not initialized"}),t.jsxs(ne,{onClick:M,className:"bg-purple-600 hover:bg-purple-700 text-white",children:[t.jsx(Rt,{className:"w-4 h-4 mr-2"}),"Initialize Project Memory"]})]})}),g==="sync"&&t.jsx("div",{className:"p-4",children:(Q=s==null?void 0:s.sync)!=null&&Q.state?t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-slate-300 mb-2",children:"Current State"}),t.jsx("pre",{className:"text-xs bg-gray-50 dark:bg-slate-900 p-3 rounded overflow-auto max-h-48 text-gray-800 dark:text-slate-300",children:JSON.stringify(s.sync.state,null,2)})]}),s.sync.history.length>0&&t.jsxs("div",{children:[t.jsxs("h4",{className:"text-sm font-medium text-gray-700 dark:text-slate-300 mb-2",children:["History (",s.sync.history.length,")"]}),t.jsx("div",{className:"space-y-1",children:s.sync.history.map((z,H)=>t.jsxs("div",{className:"text-xs text-gray-600 dark:text-slate-400 flex items-center gap-2",children:[t.jsx(Ga,{className:"w-3 h-3"}),z.name]},H))})]})]}):t.jsxs("div",{className:"text-center py-6",children:[t.jsx(Ga,{className:"w-12 h-12 text-gray-300 dark:text-slate-600 mx-auto mb-3"}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-slate-400",children:"No sync state"}),t.jsx("p",{className:"text-xs text-gray-400 dark:text-slate-500 mt-1",children:"State is created by session hooks"})]})})]})]}),t.jsxs("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 overflow-hidden shadow-sm",children:[t.jsxs("div",{className:"p-4 border-b border-gray-200 dark:border-slate-700 flex items-center justify-between",children:[t.jsx("h3",{className:"font-medium text-gray-900 dark:text-white",children:d?d.name:"Select a file"}),d&&t.jsxs(ne,{size:"sm",onClick:P,disabled:m,className:"bg-indigo-600 hover:bg-indigo-700 text-white",children:[m?t.jsx(Qe,{className:"w-4 h-4 mr-2 animate-spin"}):t.jsx(Zr,{className:"w-4 h-4 mr-2"}),"Save"]})]}),t.jsx("div",{className:"p-4",children:d?t.jsx(yt,{value:u,onChange:z=>f(z.target.value),className:"font-mono text-sm min-h-[400px]",placeholder:"File content..."}):t.jsx("div",{className:"flex items-center justify-center h-[400px] text-gray-400 dark:text-slate-500",children:t.jsxs("div",{className:"text-center",children:[t.jsx(vr,{className:"w-12 h-12 mx-auto mb-3 opacity-50"}),t.jsx("p",{children:"Select a file to edit"})]})})})]})]}),t.jsx(vt,{open:x.open,onOpenChange:z=>b({...x,open:z}),children:t.jsxs(ft,{className:"max-w-lg",children:[t.jsxs(mt,{children:[t.jsx(pt,{children:"Add Memory Entry"}),t.jsx(Gt,{children:"Add a new entry to the appropriate memory file."})]}),t.jsxs("div",{className:"py-4 space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Entry Type"}),t.jsx("div",{className:"mt-2 grid grid-cols-2 gap-2",children:[...I.global,...I.project].map(z=>{const H=z.icon,Y=I.global.some(K=>K.id===z.id);return t.jsxs("button",{onClick:()=>b({...x,type:z.id}),className:`p-2 rounded-lg border text-left transition-colors ${x.type===z.id?"border-indigo-500 bg-indigo-50 dark:bg-indigo-950/30":"border-gray-200 dark:border-slate-700 hover:border-gray-300 dark:hover:border-slate-600"}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(H,{className:"w-4 h-4 text-gray-500 dark:text-slate-400"}),t.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:z.label})]}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400 mt-1",children:Y?"Global":"Project"})]},z.id)})})]}),x.type==="preference"&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Name"}),t.jsx(Oe,{value:x.name,onChange:z=>b({...x,name:z.target.value}),placeholder:"e.g., package-manager",className:"mt-1"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Description"}),t.jsx(Oe,{value:x.description,onChange:z=>b({...x,description:z.target.value}),placeholder:"e.g., Always use pnpm instead of npm",className:"mt-1"})]})]}),x.type==="correction"&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Wrong (what to avoid)"}),t.jsx(yt,{value:x.wrong,onChange:z=>b({...x,wrong:z.target.value}),placeholder:"e.g., Using npm install",className:"mt-1",rows:2})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Right (what to do instead)"}),t.jsx(yt,{value:x.right,onChange:z=>b({...x,right:z.target.value}),placeholder:"e.g., Use pnpm install",className:"mt-1",rows:2})]})]}),x.type==="fact"&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Category"}),t.jsx(Oe,{value:x.category,onChange:z=>b({...x,category:z.target.value}),placeholder:"e.g., shell, editor, system",className:"mt-1"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Details"}),t.jsx(yt,{value:x.details,onChange:z=>b({...x,details:z.target.value}),placeholder:"e.g., Using zsh with oh-my-zsh",className:"mt-1",rows:2})]})]}),x.type==="pattern"&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Pattern Name"}),t.jsx(Oe,{value:x.name,onChange:z=>b({...x,name:z.target.value}),placeholder:"e.g., API Response Format",className:"mt-1"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Description"}),t.jsx(yt,{value:x.description,onChange:z=>b({...x,description:z.target.value}),placeholder:"Describe the pattern and when to use it...",className:"mt-1",rows:3})]})]}),x.type==="decision"&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Title"}),t.jsx(Oe,{value:x.title,onChange:z=>b({...x,title:z.target.value}),placeholder:"e.g., Use React Query for data fetching",className:"mt-1"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Context"}),t.jsx(yt,{value:x.context,onChange:z=>b({...x,context:z.target.value}),placeholder:"What problem were we solving?",className:"mt-1",rows:2})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Decision"}),t.jsx(yt,{value:x.decision,onChange:z=>b({...x,decision:z.target.value}),placeholder:"What did we decide?",className:"mt-1",rows:2})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Rationale"}),t.jsx(yt,{value:x.rationale,onChange:z=>b({...x,rationale:z.target.value}),placeholder:"Why this choice over alternatives?",className:"mt-1",rows:2})]})]}),x.type==="issue"&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Issue Title"}),t.jsx(Oe,{value:x.title,onChange:z=>b({...x,title:z.target.value}),placeholder:"e.g., Memory leak in useEffect",className:"mt-1"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Description / Workaround"}),t.jsx(yt,{value:x.description,onChange:z=>b({...x,description:z.target.value}),placeholder:"Describe the issue and any workarounds...",className:"mt-1",rows:3})]})]}),(x.type==="history"||x.type==="context")&&t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Content"}),t.jsx(yt,{value:x.content,onChange:z=>b({...x,content:z.target.value}),placeholder:x.type==="history"?"What work was done this session?":"Project context and overview...",className:"mt-1",rows:4})]})]}),t.jsxs(St,{children:[t.jsx(ne,{variant:"ghost",onClick:()=>b({...x,open:!1}),children:"Cancel"}),t.jsxs(ne,{onClick:E,className:"bg-purple-600 hover:bg-purple-700 text-white",children:[t.jsx(Rt,{className:"w-4 h-4 mr-2"}),"Add Entry"]})]})]})}),t.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-4 border border-transparent dark:border-slate-800",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white mb-2",children:"CLI Commands"}),t.jsxs("div",{className:"space-y-1 text-sm text-gray-600 dark:text-slate-400 font-mono",children:[t.jsx("p",{children:"coder-config memory # Show memory status"}),t.jsx("p",{children:"coder-config memory init # Initialize project memory"}),t.jsx("p",{children:'coder-config memory add <type> "<content>" # Add entry'}),t.jsx("p",{children:"coder-config memory search <query> # Search all memory"}),t.jsx("p",{className:"text-gray-400 dark:text-slate-500 text-xs mt-2",children:"# Types: preference, correction, fact (global) | context, pattern, decision, issue, history (project)"})]})]})]})}function iW({icon:e,iconColor:r="indigo",title:s,subtitle:n,actions:o,className:c}){const d={indigo:"bg-indigo-100 dark:bg-indigo-900/30 text-indigo-600 dark:text-indigo-400",blue:"bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400",green:"bg-green-100 dark:bg-green-900/30 text-green-600 dark:text-green-400",purple:"bg-purple-100 dark:bg-purple-900/30 text-purple-600 dark:text-purple-400",amber:"bg-amber-100 dark:bg-amber-900/30 text-amber-600 dark:text-amber-400",red:"bg-red-100 dark:bg-red-900/30 text-red-600 dark:text-red-400",gray:"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400"};return t.jsxs("div",{className:Ee("flex items-center justify-between",c),children:[t.jsxs("div",{className:"flex items-center gap-3",children:[e&&t.jsx("div",{className:Ee("w-10 h-10 rounded-lg flex items-center justify-center",d[r]),children:e}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:s}),n&&t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:n})]})]}),o&&t.jsx("div",{className:"flex gap-2",children:o})]})}function oW({icon:e,title:r,description:s,action:n,className:o}){return t.jsxs("div",{className:Ee("p-12 text-center",o),children:[e&&t.jsx("div",{className:"mx-auto mb-4 text-gray-300 dark:text-slate-600",children:e}),t.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-white mb-2",children:r}),s&&t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 mb-4",children:s}),n]})}function j_({className:e,size:r="default"}){const s={sm:"w-4 h-4",default:"w-6 h-6",lg:"w-8 h-8"};return t.jsx(Qe,{className:Ee("animate-spin",s[r],e)})}function aW(e={}){const[r,s]=_.useState(!1);return{execute:_.useCallback(async o=>{var c,d,l,u;s(!0);try{const f=await o();if(f&&typeof f=="object"){if(f.success===!1){const m=f.error||"Operation failed";return(c=e.onError)==null||c.call(e,m),f}if(f.success===!0||f.success===void 0)return(d=e.onSuccess)==null||d.call(e,f),f}return(l=e.onSuccess)==null||l.call(e,f),f}catch(f){const m=f.message||"Operation failed";return(u=e.onError)==null||u.call(e,m),{success:!1,error:m}}finally{s(!1)}},[e.onSuccess,e.onError]),loading:r}}function lW(e=null){const[r,s]=_.useState(!1),[n,o]=_.useState(e),c=_.useCallback((u=null)=>{o(u),s(!0)},[]),d=_.useCallback(()=>{s(!1),setTimeout(()=>o(null),150)},[]),l=_.useCallback(u=>{u?s(!0):d()},[d]);return{isOpen:r,data:n,open:c,close:d,onOpenChange:l,setData:o}}function cW({onProjectSwitch:e}){const{projects:r,loading:s,fetch:n,remove:o,update:c}=Fx(),[d,l]=_.useState(!1),u=lW(),[f,m]=_.useState(""),{execute:h,loading:g}=aW({onSuccess:()=>{q.success("Project updated"),u.close()},onError:v=>q.error(v||"Failed to update project")});_.useEffect(()=>{n()},[n]);const w=v=>{m(v.name),u.open(v)},j=()=>{!u.data||!f.trim()||h(()=>c(u.data.id,{name:f.trim()}))},k=async v=>{if(!confirm(`Remove "${v.name}" from the registry?
694
+ ${x.description}`;break;case"history":case"context":default:if(!x.content.trim()){q.error("Content required");return}z=x.content;break}try{const Y=["pattern","decision","issue","history","context"].includes(H)?"project":"global";await he.addMemoryEntry(H,z,Y),q.success(`Added ${H} entry`),b({open:!1,type:"preference",name:"",description:"",wrong:"",right:"",category:"",details:"",title:"",context:"",decision:"",rationale:"",content:""}),S()}catch{q.error("Failed to add entry")}},M=async()=>{try{await he.initProjectMemory(e.dir),q.success("Project memory initialized!"),S()}catch(z){q.error(z.message||"Failed to initialize")}};if(o)return t.jsx("div",{className:"flex items-center justify-center h-64",children:t.jsx(Qe,{className:"w-8 h-8 animate-spin text-indigo-600"})});const I={global:[{id:"preference",label:"Preference",icon:Xs,desc:"User preferences (tools, style, etc.)"},{id:"correction",label:"Correction",icon:Is,desc:"Mistakes to avoid"},{id:"fact",label:"Fact",icon:Oo,desc:"Facts about your environment"}],project:[{id:"context",label:"Context",icon:vr,desc:"Project overview and conventions"},{id:"pattern",label:"Pattern",icon:eh,desc:"Code patterns in this project"},{id:"decision",label:"Decision",icon:Yi,desc:"Architecture decisions"},{id:"issue",label:"Issue",icon:Is,desc:"Known issues and workarounds"},{id:"history",label:"History",icon:Ga,desc:"Session work log"}]};return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 p-5 shadow-sm",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center gap-2",children:[t.jsx(Fo,{className:"w-5 h-5 text-purple-600"}),"Memory System"]}),t.jsx("div",{className:"flex gap-2",children:t.jsxs(ne,{variant:"outline",size:"sm",onClick:()=>b({open:!0,type:"preference",name:"",description:"",wrong:"",right:"",category:"",details:"",title:"",context:"",decision:"",rationale:"",content:""}),children:[t.jsx(Rt,{className:"w-4 h-4 mr-2"}),"Add Entry"]})})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Oe,{placeholder:"Search memory...",value:j,onChange:z=>k(z.target.value),onKeyDown:z=>z.key==="Enter"&&A(),className:"flex-1"}),t.jsx(ne,{variant:"outline",onClick:A,children:t.jsx(Ic,{className:"w-4 h-4"})})]}),v.length>0&&t.jsxs("div",{className:"mt-4 p-3 bg-gray-50 dark:bg-slate-900 rounded-lg",children:[t.jsx("h3",{className:"text-sm font-medium text-gray-700 dark:text-slate-300 mb-2",children:"Search Results"}),t.jsx("div",{className:"space-y-2",children:v.map((z,H)=>t.jsxs("div",{className:"text-sm",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(qe,{variant:z.scope==="global"?"default":"secondary",children:z.scope}),t.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:z.file})]}),z.matches.map((Y,K)=>t.jsxs("div",{className:"ml-4 text-gray-600 dark:text-slate-400 text-xs mt-1",children:["Line ",Y.line,": ",Y.text]},K))]},H))})]})]}),t.jsx("div",{className:"flex gap-2 border-b border-gray-200 dark:border-slate-700 pb-2",children:["global","project","sync"].map(z=>t.jsxs("button",{onClick:()=>w(z),className:`px-4 py-2 text-sm font-medium rounded-t-lg transition-colors ${g===z?"bg-white dark:bg-slate-950 border border-b-white dark:border-b-slate-950 border-gray-200 dark:border-slate-700 -mb-[1px] text-indigo-600 dark:text-indigo-400":"text-gray-600 dark:text-slate-400 hover:text-gray-900 dark:hover:text-white"}`,children:[z.charAt(0).toUpperCase()+z.slice(1)," Memory"]},z))}),t.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[t.jsxs("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 overflow-hidden shadow-sm",children:[t.jsxs("div",{className:"p-4 border-b border-gray-200 dark:border-slate-700",children:[t.jsxs("h3",{className:"font-medium text-gray-900 dark:text-white",children:[g==="global"&&"Global Memory Files",g==="project"&&"Project Memory Files",g==="sync"&&"Sync State"]}),t.jsxs("p",{className:"text-xs text-gray-500 dark:text-slate-400 mt-1",children:[g==="global"&&"~/.claude/memory/",g==="project"&&`${e.dir}/.claude/memory/`,g==="sync"&&"~/.claude/sync/"]})]}),t.jsxs("div",{className:"divide-y divide-gray-100 dark:divide-slate-800",children:[g==="global"&&((B=s==null?void 0:s.global)==null?void 0:B.files.map(z=>t.jsxs("button",{onClick:()=>z.exists&&l(z),className:`w-full px-4 py-3 flex items-center gap-3 text-left hover:bg-gray-50 dark:hover:bg-slate-900 transition-colors ${(d==null?void 0:d.path)===z.path?"bg-indigo-50 dark:bg-indigo-950/30":""} ${z.exists?"":"opacity-50"}`,children:[t.jsx(vr,{className:"w-4 h-4 text-gray-400 dark:text-slate-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:z.name}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400",children:z.type})]}),z.exists?t.jsx(It,{className:"w-4 h-4 text-green-500"}):t.jsx("span",{className:"text-xs text-gray-400 dark:text-slate-500",children:"Not created"})]},z.name))),g==="project"&&t.jsx(t.Fragment,{children:(U=s==null?void 0:s.project)!=null&&U.initialized?(V=s==null?void 0:s.project)==null?void 0:V.files.map(z=>t.jsxs("button",{onClick:()=>z.exists&&l(z),className:`w-full px-4 py-3 flex items-center gap-3 text-left hover:bg-gray-50 dark:hover:bg-slate-900 transition-colors ${(d==null?void 0:d.path)===z.path?"bg-indigo-50 dark:bg-indigo-950/30":""} ${z.exists?"":"opacity-50"}`,children:[t.jsx(vr,{className:"w-4 h-4 text-gray-400 dark:text-slate-500"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:z.name}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400",children:z.type})]}),z.exists?t.jsx(It,{className:"w-4 h-4 text-green-500"}):t.jsx("span",{className:"text-xs text-gray-400 dark:text-slate-500",children:"Not created"})]},z.name)):t.jsxs("div",{className:"p-6 text-center",children:[t.jsx(Fo,{className:"w-12 h-12 text-gray-300 dark:text-slate-600 mx-auto mb-3"}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-slate-400 mb-4",children:"Project memory not initialized"}),t.jsxs(ne,{onClick:M,className:"bg-purple-600 hover:bg-purple-700 text-white",children:[t.jsx(Rt,{className:"w-4 h-4 mr-2"}),"Initialize Project Memory"]})]})}),g==="sync"&&t.jsx("div",{className:"p-4",children:(Q=s==null?void 0:s.sync)!=null&&Q.state?t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-slate-300 mb-2",children:"Current State"}),t.jsx("pre",{className:"text-xs bg-gray-50 dark:bg-slate-900 p-3 rounded overflow-auto max-h-48 text-gray-800 dark:text-slate-300",children:JSON.stringify(s.sync.state,null,2)})]}),s.sync.history.length>0&&t.jsxs("div",{children:[t.jsxs("h4",{className:"text-sm font-medium text-gray-700 dark:text-slate-300 mb-2",children:["History (",s.sync.history.length,")"]}),t.jsx("div",{className:"space-y-1",children:s.sync.history.map((z,H)=>t.jsxs("div",{className:"text-xs text-gray-600 dark:text-slate-400 flex items-center gap-2",children:[t.jsx(Ga,{className:"w-3 h-3"}),z.name]},H))})]})]}):t.jsxs("div",{className:"text-center py-6",children:[t.jsx(Ga,{className:"w-12 h-12 text-gray-300 dark:text-slate-600 mx-auto mb-3"}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-slate-400",children:"No sync state"}),t.jsx("p",{className:"text-xs text-gray-400 dark:text-slate-500 mt-1",children:"State is created by session hooks"})]})})]})]}),t.jsxs("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 overflow-hidden shadow-sm",children:[t.jsxs("div",{className:"p-4 border-b border-gray-200 dark:border-slate-700 flex items-center justify-between",children:[t.jsx("h3",{className:"font-medium text-gray-900 dark:text-white",children:d?d.name:"Select a file"}),d&&t.jsxs(ne,{size:"sm",onClick:P,disabled:m,className:"bg-indigo-600 hover:bg-indigo-700 text-white",children:[m?t.jsx(Qe,{className:"w-4 h-4 mr-2 animate-spin"}):t.jsx(Zr,{className:"w-4 h-4 mr-2"}),"Save"]})]}),t.jsx("div",{className:"p-4",children:d?t.jsx(yt,{value:u,onChange:z=>f(z.target.value),className:"font-mono text-sm min-h-[400px]",placeholder:"File content..."}):t.jsx("div",{className:"flex items-center justify-center h-[400px] text-gray-400 dark:text-slate-500",children:t.jsxs("div",{className:"text-center",children:[t.jsx(vr,{className:"w-12 h-12 mx-auto mb-3 opacity-50"}),t.jsx("p",{children:"Select a file to edit"})]})})})]})]}),t.jsx(vt,{open:x.open,onOpenChange:z=>b({...x,open:z}),children:t.jsxs(ft,{className:"max-w-lg",children:[t.jsxs(mt,{children:[t.jsx(pt,{children:"Add Memory Entry"}),t.jsx(Gt,{children:"Add a new entry to the appropriate memory file."})]}),t.jsxs("div",{className:"py-4 space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Entry Type"}),t.jsx("div",{className:"mt-2 grid grid-cols-2 gap-2",children:[...I.global,...I.project].map(z=>{const H=z.icon,Y=I.global.some(K=>K.id===z.id);return t.jsxs("button",{onClick:()=>b({...x,type:z.id}),className:`p-2 rounded-lg border text-left transition-colors ${x.type===z.id?"border-indigo-500 bg-indigo-50 dark:bg-indigo-950/30":"border-gray-200 dark:border-slate-700 hover:border-gray-300 dark:hover:border-slate-600"}`,children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(H,{className:"w-4 h-4 text-gray-500 dark:text-slate-400"}),t.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white",children:z.label})]}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400 mt-1",children:Y?"Global":"Project"})]},z.id)})})]}),x.type==="preference"&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Name"}),t.jsx(Oe,{value:x.name,onChange:z=>b({...x,name:z.target.value}),placeholder:"e.g., package-manager",className:"mt-1"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Description"}),t.jsx(Oe,{value:x.description,onChange:z=>b({...x,description:z.target.value}),placeholder:"e.g., Always use pnpm instead of npm",className:"mt-1"})]})]}),x.type==="correction"&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Wrong (what to avoid)"}),t.jsx(yt,{value:x.wrong,onChange:z=>b({...x,wrong:z.target.value}),placeholder:"e.g., Using npm install",className:"mt-1",rows:2})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Right (what to do instead)"}),t.jsx(yt,{value:x.right,onChange:z=>b({...x,right:z.target.value}),placeholder:"e.g., Use pnpm install",className:"mt-1",rows:2})]})]}),x.type==="fact"&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Category"}),t.jsx(Oe,{value:x.category,onChange:z=>b({...x,category:z.target.value}),placeholder:"e.g., shell, editor, system",className:"mt-1"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Details"}),t.jsx(yt,{value:x.details,onChange:z=>b({...x,details:z.target.value}),placeholder:"e.g., Using zsh with oh-my-zsh",className:"mt-1",rows:2})]})]}),x.type==="pattern"&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Pattern Name"}),t.jsx(Oe,{value:x.name,onChange:z=>b({...x,name:z.target.value}),placeholder:"e.g., API Response Format",className:"mt-1"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Description"}),t.jsx(yt,{value:x.description,onChange:z=>b({...x,description:z.target.value}),placeholder:"Describe the pattern and when to use it...",className:"mt-1",rows:3})]})]}),x.type==="decision"&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Title"}),t.jsx(Oe,{value:x.title,onChange:z=>b({...x,title:z.target.value}),placeholder:"e.g., Use React Query for data fetching",className:"mt-1"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Context"}),t.jsx(yt,{value:x.context,onChange:z=>b({...x,context:z.target.value}),placeholder:"What problem were we solving?",className:"mt-1",rows:2})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Decision"}),t.jsx(yt,{value:x.decision,onChange:z=>b({...x,decision:z.target.value}),placeholder:"What did we decide?",className:"mt-1",rows:2})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Rationale"}),t.jsx(yt,{value:x.rationale,onChange:z=>b({...x,rationale:z.target.value}),placeholder:"Why this choice over alternatives?",className:"mt-1",rows:2})]})]}),x.type==="issue"&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Issue Title"}),t.jsx(Oe,{value:x.title,onChange:z=>b({...x,title:z.target.value}),placeholder:"e.g., Memory leak in useEffect",className:"mt-1"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Description / Workaround"}),t.jsx(yt,{value:x.description,onChange:z=>b({...x,description:z.target.value}),placeholder:"Describe the issue and any workarounds...",className:"mt-1",rows:3})]})]}),(x.type==="history"||x.type==="context")&&t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Content"}),t.jsx(yt,{value:x.content,onChange:z=>b({...x,content:z.target.value}),placeholder:x.type==="history"?"What work was done this session?":"Project context and overview...",className:"mt-1",rows:4})]})]}),t.jsxs(St,{children:[t.jsx(ne,{variant:"ghost",onClick:()=>b({...x,open:!1}),children:"Cancel"}),t.jsxs(ne,{onClick:E,className:"bg-purple-600 hover:bg-purple-700 text-white",children:[t.jsx(Rt,{className:"w-4 h-4 mr-2"}),"Add Entry"]})]})]})}),t.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-4 border border-transparent dark:border-slate-800",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white mb-2",children:"CLI Commands"}),t.jsxs("div",{className:"space-y-1 text-sm text-gray-600 dark:text-slate-400 font-mono",children:[t.jsx("p",{children:"coder-config memory # Show memory status"}),t.jsx("p",{children:"coder-config memory init # Initialize project memory"}),t.jsx("p",{children:'coder-config memory add <type> "<content>" # Add entry'}),t.jsx("p",{children:"coder-config memory search <query> # Search all memory"}),t.jsx("p",{className:"text-gray-400 dark:text-slate-500 text-xs mt-2",children:"# Types: preference, correction, fact (global) | context, pattern, decision, issue, history (project)"})]})]})]})}function oW({icon:e,iconColor:r="indigo",title:s,subtitle:n,actions:o,className:c}){const d={indigo:"bg-indigo-100 dark:bg-indigo-900/30 text-indigo-600 dark:text-indigo-400",blue:"bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400",green:"bg-green-100 dark:bg-green-900/30 text-green-600 dark:text-green-400",purple:"bg-purple-100 dark:bg-purple-900/30 text-purple-600 dark:text-purple-400",amber:"bg-amber-100 dark:bg-amber-900/30 text-amber-600 dark:text-amber-400",red:"bg-red-100 dark:bg-red-900/30 text-red-600 dark:text-red-400",gray:"bg-gray-100 dark:bg-gray-800 text-gray-600 dark:text-gray-400"};return t.jsxs("div",{className:Ee("flex items-center justify-between",c),children:[t.jsxs("div",{className:"flex items-center gap-3",children:[e&&t.jsx("div",{className:Ee("w-10 h-10 rounded-lg flex items-center justify-center",d[r]),children:e}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:s}),n&&t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:n})]})]}),o&&t.jsx("div",{className:"flex gap-2",children:o})]})}function aW({icon:e,title:r,description:s,action:n,className:o}){return t.jsxs("div",{className:Ee("p-12 text-center",o),children:[e&&t.jsx("div",{className:"mx-auto mb-4 text-gray-300 dark:text-slate-600",children:e}),t.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-white mb-2",children:r}),s&&t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 mb-4",children:s}),n]})}function j_({className:e,size:r="default"}){const s={sm:"w-4 h-4",default:"w-6 h-6",lg:"w-8 h-8"};return t.jsx(Qe,{className:Ee("animate-spin",s[r],e)})}function lW(e={}){const[r,s]=_.useState(!1);return{execute:_.useCallback(async o=>{var c,d,l,u;s(!0);try{const f=await o();if(f&&typeof f=="object"){if(f.success===!1){const m=f.error||"Operation failed";return(c=e.onError)==null||c.call(e,m),f}if(f.success===!0||f.success===void 0)return(d=e.onSuccess)==null||d.call(e,f),f}return(l=e.onSuccess)==null||l.call(e,f),f}catch(f){const m=f.message||"Operation failed";return(u=e.onError)==null||u.call(e,m),{success:!1,error:m}}finally{s(!1)}},[e.onSuccess,e.onError]),loading:r}}function cW(e=null){const[r,s]=_.useState(!1),[n,o]=_.useState(e),c=_.useCallback((u=null)=>{o(u),s(!0)},[]),d=_.useCallback(()=>{s(!1),setTimeout(()=>o(null),150)},[]),l=_.useCallback(u=>{u?s(!0):d()},[d]);return{isOpen:r,data:n,open:c,close:d,onOpenChange:l,setData:o}}function dW({onProjectSwitch:e}){const{projects:r,loading:s,fetch:n,remove:o,update:c}=Fx(),[d,l]=_.useState(!1),u=cW(),[f,m]=_.useState(""),{execute:h,loading:g}=lW({onSuccess:()=>{q.success("Project updated"),u.close()},onError:v=>q.error(v||"Failed to update project")});_.useEffect(()=>{n()},[n]);const w=v=>{m(v.name),u.open(v)},j=()=>{!u.data||!f.trim()||h(()=>c(u.data.id,{name:f.trim()}))},k=async v=>{if(!confirm(`Remove "${v.name}" from the registry?
695
695
 
696
- This won't delete any files.`))return;const y=await o(v.id);y.success?q.success(`Removed project: ${v.name}`):q.error(y.error||"Failed to remove project")};return s?t.jsx("div",{className:"flex items-center justify-center h-64",children:t.jsx(j_,{size:"lg",className:"text-indigo-600"})}):t.jsxs("div",{className:"space-y-6",children:[t.jsx(iW,{icon:t.jsx(Zi,{className:"w-5 h-5"}),iconColor:"indigo",title:"Projects",subtitle:"Registered projects for quick switching",actions:t.jsxs(t.Fragment,{children:[t.jsxs(ne,{variant:"outline",onClick:()=>n(),size:"sm",children:[t.jsx(Dr,{className:"w-4 h-4 mr-2"}),"Refresh"]}),t.jsxs(ne,{onClick:()=>l(!0),className:"bg-indigo-600 hover:bg-indigo-700",children:[t.jsx(Rt,{className:"w-4 h-4 mr-2"}),"Add Project"]})]})}),t.jsx("div",{className:"bg-blue-50 dark:bg-blue-950/30 border border-blue-200 dark:border-blue-800 rounded-lg p-4 text-sm text-blue-700 dark:text-blue-400",children:t.jsx("p",{children:"Projects registered here can be quickly switched in the header dropdown. The UI will update to show the selected project's configuration."})}),t.jsx("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 shadow-sm overflow-hidden",children:r.length===0?t.jsx(oW,{icon:t.jsx(Xr,{className:"w-12 h-12"}),title:"No Projects Yet",description:"Add your first project to get started with quick switching.",action:t.jsxs(ne,{onClick:()=>l(!0),children:[t.jsx(Rt,{className:"w-4 h-4 mr-2"}),"Add Your First Project"]})}):t.jsx("div",{className:"divide-y divide-gray-100 dark:divide-slate-800",children:r.map(v=>t.jsxs("div",{className:`p-4 flex items-center gap-4 transition-colors ${v.isActive?"bg-indigo-50 dark:bg-indigo-950/30":"hover:bg-gray-50 dark:hover:bg-slate-900"}`,children:[t.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${v.isActive?"bg-indigo-100 dark:bg-indigo-900/50":v.exists?"bg-gray-100 dark:bg-slate-800":"bg-amber-100 dark:bg-amber-900/30"}`,children:v.isActive?t.jsx(It,{className:"w-5 h-5 text-indigo-600 dark:text-indigo-400"}):v.exists?t.jsx(Xr,{className:"w-5 h-5 text-gray-500 dark:text-slate-400"}):t.jsx(mi,{className:"w-5 h-5 text-amber-600 dark:text-amber-400"})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("h3",{className:`font-medium truncate ${v.isActive?"text-indigo-700 dark:text-indigo-400":"text-gray-900 dark:text-white"}`,children:v.name}),v.hasClaudeConfig&&t.jsx("span",{className:"text-xs bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400 px-1.5 py-0.5 rounded",children:".claude"}),v.isActive&&t.jsx("span",{className:"text-xs bg-indigo-100 dark:bg-indigo-900/50 text-indigo-700 dark:text-indigo-400 px-1.5 py-0.5 rounded",children:"Active"})]}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 font-mono truncate",children:v.path.replace(/^\/Users\/[^/]+/,"~")}),!v.exists&&t.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400 mt-1",children:"Path not found - the directory may have been moved or deleted"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ne,{size:"sm",variant:"ghost",onClick:()=>w(v),className:"text-gray-500 dark:text-slate-400 hover:text-indigo-600 dark:hover:text-indigo-400",title:"Edit project name",children:t.jsx(al,{className:"w-4 h-4"})}),t.jsx(ne,{size:"sm",variant:"ghost",onClick:()=>k(v),className:"text-gray-500 dark:text-slate-400 hover:text-red-600 dark:hover:text-red-400",title:"Remove from registry",children:t.jsx(fs,{className:"w-4 h-4"})})]})]},v.id))})}),t.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-4 border border-transparent dark:border-slate-800",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white mb-2",children:"CLI Commands"}),t.jsxs("div",{className:"space-y-1 text-sm text-gray-600 dark:text-slate-400 font-mono",children:[t.jsx("p",{children:"coder-config project add [path] # Add project"}),t.jsx("p",{children:"coder-config project remove <name> # Remove project"}),t.jsx("p",{children:"coder-config project # List projects"})]})]}),t.jsx(EN,{open:d,onOpenChange:l,onAdded:n}),t.jsx(vt,{open:u.isOpen,onOpenChange:u.onOpenChange,children:t.jsxs(ft,{className:"bg-card",children:[t.jsxs(mt,{children:[t.jsx(pt,{children:"Edit Project"}),t.jsx(Gt,{children:"Update the project name displayed in the registry."})]}),t.jsxs("div",{className:"py-4",children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Project Name"}),t.jsx(Oe,{value:f,onChange:v=>m(v.target.value),placeholder:"My Project",className:"mt-1",onKeyDown:v=>v.key==="Enter"&&j()}),u.data&&t.jsx("p",{className:"text-xs text-muted-foreground mt-2 font-mono",children:u.data.path.replace(/^\/Users\/[^/]+/,"~")})]}),t.jsxs(St,{children:[t.jsx(ne,{variant:"ghost",onClick:u.close,children:"Cancel"}),t.jsxs(ne,{onClick:j,disabled:g||!f.trim(),children:[g?t.jsx(j_,{size:"sm",className:"mr-2"}):null,"Save"]})]})]})})]})}const dW=[{id:"getting-started",title:"Getting Started",icon:Oo,subsections:[{id:"installation",title:"Installation"},{id:"quick-start",title:"Quick Start"},{id:"updating",title:"Updating"}]},{id:"projects",title:"Project Management",icon:Hn,subsections:[{id:"project-registry",title:"Project Registry"},{id:"project-switching",title:"Switching Projects"},{id:"project-structure",title:"Project Structure"}]},{id:"file-explorer",title:"Project Explorer",icon:Xr,subsections:[{id:"claude-folders",title:".claude Folders"},{id:"rules",title:"Rules"},{id:"skills",title:"Skills"},{id:"workflows",title:"Workflows"},{id:"hierarchy",title:"Configuration Hierarchy"},{id:"subprojects",title:"Sub-Projects"}]},{id:"workstreams",title:"Workstreams",icon:Hn,subsections:[{id:"workstreams-overview",title:"Overview"},{id:"creating-workstreams",title:"Creating Workstreams"},{id:"workstream-hooks",title:"Hook Integration"},{id:"activity-tracking",title:"Activity Tracking"}]},{id:"loops",title:"Ralph Loops",icon:vc,isExperimental:!0,subsections:[{id:"loops-overview",title:"Overview"},{id:"creating-loops",title:"Creating Loops"},{id:"loop-phases",title:"Loop Phases"},{id:"loop-controls",title:"Controls"},{id:"loop-configuration",title:"Configuration"}]},{id:"plugins",title:"Plugins",icon:Yn,subsections:[{id:"plugins-overview",title:"Overview"},{id:"installing-plugins",title:"Installing Plugins"},{id:"plugin-marketplaces",title:"Marketplaces"}]},{id:"mcp-registry",title:"MCP Registry",icon:Yn,subsections:[{id:"mcp-overview",title:"Overview"},{id:"adding-mcps",title:"Adding MCPs"},{id:"configuring-mcps",title:"Configuring MCPs"},{id:"environment-vars",title:"Environment Variables"}]},{id:"memory",title:"Memory System",icon:Fo,subsections:[{id:"memory-overview",title:"Overview"},{id:"global-memory",title:"Global Memory"},{id:"project-memory",title:"Project Memory"},{id:"memory-entries",title:"Memory Entry Types"}]},{id:"sessions",title:"Session Persistence",icon:Zr,isNew:!0,subsections:[{id:"sessions-overview",title:"Overview"},{id:"sessions-usage",title:"Using Sessions"},{id:"sessions-storage",title:"Storage"}]},{id:"claude-settings",title:"Claude Code Settings",icon:Qn,subsections:[{id:"permissions",title:"Permissions"},{id:"model-selection",title:"Model Selection"},{id:"behavior",title:"Behavior Settings"},{id:"hooks",title:"Hooks"}]},{id:"gemini-settings",title:"Gemini CLI Settings",icon:Ut,subsections:[{id:"gemini-model",title:"Model Selection"},{id:"gemini-display",title:"Display Options"},{id:"gemini-general",title:"General Settings"},{id:"gemini-sandbox",title:"Sandbox Mode"}]},{id:"codex-settings",title:"Codex CLI Settings",icon:Ut,subsections:[{id:"codex-overview",title:"Overview"},{id:"codex-model",title:"Model Selection"},{id:"codex-security",title:"Security Settings"},{id:"codex-mcp",title:"MCP Servers"},{id:"codex-features",title:"Features & Display"}]},{id:"antigravity-settings",title:"Antigravity Settings",icon:Mc,subsections:[{id:"antigravity-security",title:"Security Policies"},{id:"antigravity-mcp",title:"MCP Servers"},{id:"antigravity-browser",title:"Browser Allowlist"},{id:"antigravity-agent",title:"Agent Mode"}]},{id:"cli",title:"CLI Reference",icon:Ut,subsections:[{id:"cli-overview",title:"Overview"},{id:"cli-commands",title:"All Commands"},{id:"daemon-mode",title:"Daemon Mode"}]},{id:"multi-tool",title:"Multi-Tool Support",icon:Vt,subsections:[{id:"supported-tools",title:"Supported Tools"},{id:"gemini-cli",title:"Gemini CLI"},{id:"antigravity",title:"Antigravity"},{id:"tool-differences",title:"Tool Differences"},{id:"enabling-tools",title:"Enabling Tools"},{id:"syncing-rules",title:"Syncing Rules"}]},{id:"keyboard",title:"Keyboard Shortcuts",icon:M5,subsections:[]},{id:"troubleshooting",title:"Troubleshooting",icon:Va,subsections:[{id:"common-issues",title:"Common Issues"},{id:"getting-help",title:"Getting Help"}]}],uW={installation:{title:"Installation",content:`
696
+ This won't delete any files.`))return;const y=await o(v.id);y.success?q.success(`Removed project: ${v.name}`):q.error(y.error||"Failed to remove project")};return s?t.jsx("div",{className:"flex items-center justify-center h-64",children:t.jsx(j_,{size:"lg",className:"text-indigo-600"})}):t.jsxs("div",{className:"space-y-6",children:[t.jsx(oW,{icon:t.jsx(Zi,{className:"w-5 h-5"}),iconColor:"indigo",title:"Projects",subtitle:"Registered projects for quick switching",actions:t.jsxs(t.Fragment,{children:[t.jsxs(ne,{variant:"outline",onClick:()=>n(),size:"sm",children:[t.jsx(Dr,{className:"w-4 h-4 mr-2"}),"Refresh"]}),t.jsxs(ne,{onClick:()=>l(!0),className:"bg-indigo-600 hover:bg-indigo-700",children:[t.jsx(Rt,{className:"w-4 h-4 mr-2"}),"Add Project"]})]})}),t.jsx("div",{className:"bg-blue-50 dark:bg-blue-950/30 border border-blue-200 dark:border-blue-800 rounded-lg p-4 text-sm text-blue-700 dark:text-blue-400",children:t.jsx("p",{children:"Projects registered here can be quickly switched in the header dropdown. The UI will update to show the selected project's configuration."})}),t.jsx("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 shadow-sm overflow-hidden",children:r.length===0?t.jsx(aW,{icon:t.jsx(Xr,{className:"w-12 h-12"}),title:"No Projects Yet",description:"Add your first project to get started with quick switching.",action:t.jsxs(ne,{onClick:()=>l(!0),children:[t.jsx(Rt,{className:"w-4 h-4 mr-2"}),"Add Your First Project"]})}):t.jsx("div",{className:"divide-y divide-gray-100 dark:divide-slate-800",children:r.map(v=>t.jsxs("div",{className:`p-4 flex items-center gap-4 transition-colors ${v.isActive?"bg-indigo-50 dark:bg-indigo-950/30":"hover:bg-gray-50 dark:hover:bg-slate-900"}`,children:[t.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${v.isActive?"bg-indigo-100 dark:bg-indigo-900/50":v.exists?"bg-gray-100 dark:bg-slate-800":"bg-amber-100 dark:bg-amber-900/30"}`,children:v.isActive?t.jsx(It,{className:"w-5 h-5 text-indigo-600 dark:text-indigo-400"}):v.exists?t.jsx(Xr,{className:"w-5 h-5 text-gray-500 dark:text-slate-400"}):t.jsx(mi,{className:"w-5 h-5 text-amber-600 dark:text-amber-400"})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("h3",{className:`font-medium truncate ${v.isActive?"text-indigo-700 dark:text-indigo-400":"text-gray-900 dark:text-white"}`,children:v.name}),v.hasClaudeConfig&&t.jsx("span",{className:"text-xs bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400 px-1.5 py-0.5 rounded",children:".claude"}),v.isActive&&t.jsx("span",{className:"text-xs bg-indigo-100 dark:bg-indigo-900/50 text-indigo-700 dark:text-indigo-400 px-1.5 py-0.5 rounded",children:"Active"})]}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 font-mono truncate",children:v.path.replace(/^\/Users\/[^/]+/,"~")}),!v.exists&&t.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400 mt-1",children:"Path not found - the directory may have been moved or deleted"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ne,{size:"sm",variant:"ghost",onClick:()=>w(v),className:"text-gray-500 dark:text-slate-400 hover:text-indigo-600 dark:hover:text-indigo-400",title:"Edit project name",children:t.jsx(al,{className:"w-4 h-4"})}),t.jsx(ne,{size:"sm",variant:"ghost",onClick:()=>k(v),className:"text-gray-500 dark:text-slate-400 hover:text-red-600 dark:hover:text-red-400",title:"Remove from registry",children:t.jsx(fs,{className:"w-4 h-4"})})]})]},v.id))})}),t.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-4 border border-transparent dark:border-slate-800",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white mb-2",children:"CLI Commands"}),t.jsxs("div",{className:"space-y-1 text-sm text-gray-600 dark:text-slate-400 font-mono",children:[t.jsx("p",{children:"coder-config project add [path] # Add project"}),t.jsx("p",{children:"coder-config project remove <name> # Remove project"}),t.jsx("p",{children:"coder-config project # List projects"})]})]}),t.jsx(EN,{open:d,onOpenChange:l,onAdded:n}),t.jsx(vt,{open:u.isOpen,onOpenChange:u.onOpenChange,children:t.jsxs(ft,{className:"bg-card",children:[t.jsxs(mt,{children:[t.jsx(pt,{children:"Edit Project"}),t.jsx(Gt,{children:"Update the project name displayed in the registry."})]}),t.jsxs("div",{className:"py-4",children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Project Name"}),t.jsx(Oe,{value:f,onChange:v=>m(v.target.value),placeholder:"My Project",className:"mt-1",onKeyDown:v=>v.key==="Enter"&&j()}),u.data&&t.jsx("p",{className:"text-xs text-muted-foreground mt-2 font-mono",children:u.data.path.replace(/^\/Users\/[^/]+/,"~")})]}),t.jsxs(St,{children:[t.jsx(ne,{variant:"ghost",onClick:u.close,children:"Cancel"}),t.jsxs(ne,{onClick:j,disabled:g||!f.trim(),children:[g?t.jsx(j_,{size:"sm",className:"mr-2"}):null,"Save"]})]})]})})]})}const uW=[{id:"getting-started",title:"Getting Started",icon:Oo,subsections:[{id:"installation",title:"Installation"},{id:"quick-start",title:"Quick Start"},{id:"updating",title:"Updating"}]},{id:"projects",title:"Project Management",icon:Hn,subsections:[{id:"project-registry",title:"Project Registry"},{id:"project-switching",title:"Switching Projects"},{id:"project-structure",title:"Project Structure"}]},{id:"file-explorer",title:"Project Explorer",icon:Xr,subsections:[{id:"claude-folders",title:".claude Folders"},{id:"rules",title:"Rules"},{id:"skills",title:"Skills"},{id:"workflows",title:"Workflows"},{id:"hierarchy",title:"Configuration Hierarchy"},{id:"subprojects",title:"Sub-Projects"}]},{id:"workstreams",title:"Workstreams",icon:Hn,subsections:[{id:"workstreams-overview",title:"Overview"},{id:"creating-workstreams",title:"Creating Workstreams"},{id:"workstream-hooks",title:"Hook Integration"},{id:"activity-tracking",title:"Activity Tracking"}]},{id:"loops",title:"Ralph Loops",icon:vc,isExperimental:!0,subsections:[{id:"loops-overview",title:"Overview"},{id:"creating-loops",title:"Creating Loops"},{id:"loop-phases",title:"Loop Phases"},{id:"loop-controls",title:"Controls"},{id:"loop-configuration",title:"Configuration"}]},{id:"plugins",title:"Plugins",icon:Yn,subsections:[{id:"plugins-overview",title:"Overview"},{id:"installing-plugins",title:"Installing Plugins"},{id:"plugin-marketplaces",title:"Marketplaces"}]},{id:"mcp-registry",title:"MCP Registry",icon:Yn,subsections:[{id:"mcp-overview",title:"Overview"},{id:"adding-mcps",title:"Adding MCPs"},{id:"configuring-mcps",title:"Configuring MCPs"},{id:"environment-vars",title:"Environment Variables"}]},{id:"memory",title:"Memory System",icon:Fo,subsections:[{id:"memory-overview",title:"Overview"},{id:"global-memory",title:"Global Memory"},{id:"project-memory",title:"Project Memory"},{id:"memory-entries",title:"Memory Entry Types"}]},{id:"sessions",title:"Session Persistence",icon:Zr,isNew:!0,subsections:[{id:"sessions-overview",title:"Overview"},{id:"sessions-usage",title:"Using Sessions"},{id:"sessions-storage",title:"Storage"}]},{id:"claude-settings",title:"Claude Code Settings",icon:Qn,subsections:[{id:"permissions",title:"Permissions"},{id:"model-selection",title:"Model Selection"},{id:"behavior",title:"Behavior Settings"},{id:"hooks",title:"Hooks"}]},{id:"gemini-settings",title:"Gemini CLI Settings",icon:Ut,subsections:[{id:"gemini-model",title:"Model Selection"},{id:"gemini-display",title:"Display Options"},{id:"gemini-general",title:"General Settings"},{id:"gemini-sandbox",title:"Sandbox Mode"}]},{id:"codex-settings",title:"Codex CLI Settings",icon:Ut,subsections:[{id:"codex-overview",title:"Overview"},{id:"codex-model",title:"Model Selection"},{id:"codex-security",title:"Security Settings"},{id:"codex-mcp",title:"MCP Servers"},{id:"codex-features",title:"Features & Display"}]},{id:"antigravity-settings",title:"Antigravity Settings",icon:Mc,subsections:[{id:"antigravity-security",title:"Security Policies"},{id:"antigravity-mcp",title:"MCP Servers"},{id:"antigravity-browser",title:"Browser Allowlist"},{id:"antigravity-agent",title:"Agent Mode"}]},{id:"cli",title:"CLI Reference",icon:Ut,subsections:[{id:"cli-overview",title:"Overview"},{id:"cli-commands",title:"All Commands"},{id:"daemon-mode",title:"Daemon Mode"}]},{id:"multi-tool",title:"Multi-Tool Support",icon:Vt,subsections:[{id:"supported-tools",title:"Supported Tools"},{id:"gemini-cli",title:"Gemini CLI"},{id:"antigravity",title:"Antigravity"},{id:"tool-differences",title:"Tool Differences"},{id:"enabling-tools",title:"Enabling Tools"},{id:"syncing-rules",title:"Syncing Rules"}]},{id:"keyboard",title:"Keyboard Shortcuts",icon:M5,subsections:[]},{id:"troubleshooting",title:"Troubleshooting",icon:Va,subsections:[{id:"common-issues",title:"Common Issues"},{id:"getting-help",title:"Getting Help"}]}],hW={installation:{title:"Installation",content:`
697
697
  ## Installation
698
698
 
699
699
  Choose your preferred installation method:
@@ -791,7 +791,7 @@ npm install -g coder-config@latest
791
791
  coder-config ui stop
792
792
  coder-config ui
793
793
  \`\`\`
794
- `}},hW={"project-registry":{title:"Project Registry",content:`
794
+ `}},fW={"project-registry":{title:"Project Registry",content:`
795
795
  ## Project Registry
796
796
 
797
797
  The project registry keeps track of all your Claude-enabled projects. It's stored in \`~/.coder-config/projects.json\` (or \`~/.claude-config/projects.json\` for legacy installs).
@@ -874,7 +874,7 @@ your-project/
874
874
  ### Generated Files
875
875
 
876
876
  The \`.mcp.json\` file in your project root is generated by running \`coder-config apply\`. Claude Code reads this file to configure MCPs.
877
- `}},fW={"claude-folders":{title:".claude Folders",content:`
877
+ `}},mW={"claude-folders":{title:".claude Folders",content:`
878
878
  ## .claude Folders
879
879
 
880
880
  The \`.claude\` folder contains all Claude Code configuration for a directory.
@@ -1072,7 +1072,7 @@ Coder Config uses a hierarchical configuration system where settings cascade fro
1072
1072
  ### Viewing the Hierarchy
1073
1073
 
1074
1074
  In the Project Explorer, you'll see all \`.claude\` folders in the hierarchy from your project up to home. You can manage configuration at each level.
1075
- `}},mW={"workstreams-overview":{title:"Workstreams Overview",content:`
1075
+ `}},pW={"workstreams-overview":{title:"Workstreams Overview",content:`
1076
1076
  ## Workstreams
1077
1077
 
1078
1078
  Workstreams are **virtual projects** that group multiple repos belonging to the same product or system.
@@ -1256,7 +1256,7 @@ Based on co-activity patterns, coder-config suggests workstreams:
1256
1256
  - Only file paths are logged (not file contents)
1257
1257
  - You can delete the activity file at any time
1258
1258
  - Activity tracking is read-only and never modifies your code
1259
- `}},pW={"loops-overview":{title:"Ralph Loops Overview",content:`
1259
+ `}},gW={"loops-overview":{title:"Ralph Loops Overview",content:`
1260
1260
  ## Ralph Loops
1261
1261
 
1262
1262
  > **Experimental Feature:** Ralph Loops must be enabled in **Preferences > Experimental Features** before use.
@@ -1527,7 +1527,7 @@ Loop data is stored in:
1527
1527
  ├── clarifications.md # Q&A from clarify phase
1528
1528
  └── iterations/ # Per-iteration logs
1529
1529
  \`\`\`
1530
- `}},gW={"plugins-overview":{title:"Plugins Overview",content:`
1530
+ `}},xW={"plugins-overview":{title:"Plugins Overview",content:`
1531
1531
  ## Plugins
1532
1532
 
1533
1533
  Claude Code plugins extend functionality with LSP servers, MCP servers, and skills.
@@ -1649,7 +1649,7 @@ marketplace/
1649
1649
  ]
1650
1650
  }
1651
1651
  \`\`\`
1652
- `}},xW={"mcp-overview":{title:"MCP Overview",content:`
1652
+ `}},vW={"mcp-overview":{title:"MCP Overview",content:`
1653
1653
  ## MCP Overview
1654
1654
 
1655
1655
  MCPs (Model Context Protocol servers) extend Claude's capabilities by providing additional tools and context.
@@ -1816,7 +1816,7 @@ Use the **Environment** view in the sidebar to manage environment variables for
1816
1816
  - Never commit \`.claude/.env\` to version control
1817
1817
  - Add it to your \`.gitignore\`
1818
1818
  - Use different values for development and production
1819
- `}},vW={"memory-overview":{title:"Memory Overview",content:`
1819
+ `}},yW={"memory-overview":{title:"Memory Overview",content:`
1820
1820
  ## Memory System
1821
1821
 
1822
1822
  The memory system allows Claude to retain knowledge across sessions.
@@ -1963,7 +1963,7 @@ A known issue with workaround.
1963
1963
  **Problem**: Description of the issue
1964
1964
  **Workaround**: How to work around it
1965
1965
  \`\`\`
1966
- `}},yW={"sessions-overview":{title:"Session Persistence",content:`
1966
+ `}},bW={"sessions-overview":{title:"Session Persistence",content:`
1967
1967
  ## Session Persistence
1968
1968
 
1969
1969
  Save context from a Claude Code session and restore it on the next session start.
@@ -2047,7 +2047,7 @@ Saved context is automatically restored if it's less than 7 days old.
2047
2047
  ### Manual Context
2048
2048
 
2049
2049
  You can manually edit \`.claude/session-context.md\` to inject custom context into your next session.
2050
- `}},bW={permissions:{title:"Permissions",content:`
2050
+ `}},wW={permissions:{title:"Permissions",content:`
2051
2051
  ## Permissions
2052
2052
 
2053
2053
  Control what Claude Code can do automatically.
@@ -2172,7 +2172,7 @@ Key events include:
2172
2172
  - Log tool usage
2173
2173
  - Custom notifications
2174
2174
  - Workstream context injection
2175
- `}},wW={"gemini-model":{title:"Model Selection",content:`
2175
+ `}},_W={"gemini-model":{title:"Model Selection",content:`
2176
2176
  ## Model Selection
2177
2177
 
2178
2178
  Choose which Gemini model to use.
@@ -2286,7 +2286,7 @@ Only disable sandbox mode when:
2286
2286
  - Debugging sandbox-related issues
2287
2287
 
2288
2288
  **Warning**: Disabling sandbox mode reduces security isolation.
2289
- `}},_W={"codex-overview":{title:"Codex CLI Overview",content:`
2289
+ `}},kW={"codex-overview":{title:"Codex CLI Overview",content:`
2290
2290
  ## Codex CLI
2291
2291
 
2292
2292
  OpenAI's Codex CLI is an AI-powered coding assistant that runs in your terminal, similar to Claude Code.
@@ -2516,7 +2516,7 @@ For low-friction autonomous coding:
2516
2516
  # Full auto mode - minimal approvals
2517
2517
  codex --full-auto
2518
2518
  \`\`\`
2519
- `}},kW={"antigravity-security":{title:"Security Policies",content:`
2519
+ `}},SW={"antigravity-security":{title:"Security Policies",content:`
2520
2520
  ## Security Policies
2521
2521
 
2522
2522
  Control Antigravity's execution behavior.
@@ -2607,7 +2607,7 @@ Agent mode is useful for:
2607
2607
  ### Caution
2608
2608
 
2609
2609
  Agent mode can make many changes quickly. Use with code review policy enabled.
2610
- `}},SW={"cli-overview":{title:"CLI Overview",content:`
2610
+ `}},CW={"cli-overview":{title:"CLI Overview",content:`
2611
2611
  ## CLI Overview
2612
2612
 
2613
2613
  The \`coder-config\` CLI provides command-line access to all features.
@@ -2761,7 +2761,7 @@ coder-config ui -f
2761
2761
  ### Logs
2762
2762
 
2763
2763
  Daemon logs are stored in \`~/.coder-config/ui.log\`
2764
- `}},CW={"supported-tools":{title:"Supported Tools",content:`
2764
+ `}},jW={"supported-tools":{title:"Supported Tools",content:`
2765
2765
  ## Supported AI Coding Tools
2766
2766
 
2767
2767
  coder-config supports multiple AI coding assistants:
@@ -2946,7 +2946,7 @@ Rules can be synced in any direction between these three tools.
2946
2946
  - Target files are **overwritten** if they exist
2947
2947
  - Instructions files (CLAUDE.md / GEMINI.md) are not synced
2948
2948
  - Skills and workflows are Claude-specific (not synced)
2949
- `}},jW={keyboard:{title:"Keyboard Shortcuts",content:`
2949
+ `}},NW={keyboard:{title:"Keyboard Shortcuts",content:`
2950
2950
  ## Keyboard Shortcuts
2951
2951
 
2952
2952
  ### File Explorer
@@ -2970,7 +2970,7 @@ Rules can be synced in any direction between these three tools.
2970
2970
  | Shortcut | Action |
2971
2971
  |----------|--------|
2972
2972
  | \`Ctrl/Cmd + 1-9\` | Switch sidebar sections |
2973
- `}},NW={"common-issues":{title:"Common Issues",content:`
2973
+ `}},EW={"common-issues":{title:"Common Issues",content:`
2974
2974
  ## Common Issues
2975
2975
 
2976
2976
  ### UI won't start
@@ -3039,12 +3039,12 @@ When reporting issues, include:
3039
3039
  - Node.js version (\`node --version\`)
3040
3040
  - Operating system
3041
3041
  - Error messages or logs
3042
- `}},EW={...uW,...hW,...fW,...mW,...pW,...gW,...xW,...vW,...yW,...bW,...wW,..._W,...kW,...SW,...CW,...jW,...NW};function R2(e){let r=e.replace(/```(\w*)\n([\s\S]*?)```/g,(s,n,o)=>`<pre class="bg-zinc-900 text-zinc-100 p-4 rounded-lg overflow-x-auto my-4"><code class="text-sm">${o.replace(/\\\`/g,"`").replace(/</g,"&lt;").replace(/>/g,"&gt;").trim()}</code></pre>`);return r=r.replace(/(\|[^\n]+\|\n\|[-| :]+\|\n(?:\|[^\n]+\|\n?)+)/g,s=>{const n=s.trim().split(`
3043
- `);if(n.length<2)return s;const o=n[0].split("|").filter(d=>d.trim()).map(d=>`<th class="border border-border px-3 py-2 bg-muted font-semibold text-left">${d.trim()}</th>`).join(""),c=n.slice(2).map(d=>`<tr>${d.split("|").filter(u=>u.trim()).map(u=>`<td class="border border-border px-3 py-2">${u.trim()}</td>`).join("")}</tr>`).join("");return`<table class="w-full border-collapse border border-border my-4"><thead><tr>${o}</tr></thead><tbody>${c}</tbody></table>`}),r=r.replace(/`([^`]+)`/g,(s,n)=>`<code class="bg-muted px-1.5 py-0.5 rounded text-sm font-mono">${n.replace(/\*/g,"&#42;").replace(/_/g,"&#95;")}</code>`),r.replace(/^### (.*$)/gim,'<h3 class="text-lg font-semibold mt-6 mb-2 text-foreground">$1</h3>').replace(/^## (.*$)/gim,'<h2 class="text-xl font-semibold mt-8 mb-4 text-foreground">$1</h2>').replace(/^# (.*$)/gim,'<h1 class="text-2xl font-bold mb-6 text-foreground">$1</h1>').replace(/!\[([^\]]*)\]\(([^)]+)\)/g,'<img src="$2" alt="$1" class="rounded-lg shadow-lg my-4 max-w-full border border-border" />').replace(/\*\*(.*?)\*\*/g,"<strong>$1</strong>").replace(/\*(.*?)\*/g,"<em>$1</em>").replace(/^- (.*$)/gim,'<li class="ml-4 list-disc">$1</li>').replace(/((?:<li class="ml-4 list-disc">.*<\/li>\n?)+)/g,'<ul class="list-disc my-2">$1</ul>').replace(/^\d+\. (.*$)/gim,'<li class="ml-4 list-decimal">$1</li>').replace(/((?:<li class="ml-4 list-decimal">.*<\/li>\n?)+)/g,'<ol class="list-decimal my-2">$1</ol>').replace(/\n\n/g,'</p><p class="my-3 text-foreground">').replace(/\n/g,"<br/>")}function PW(){const[e,r]=_.useState("installation"),[s,n]=_.useState({"getting-started":!0}),o=d=>{n(l=>({...l,[d]:!l[d]}))},c=EW[e];return t.jsxs("div",{className:"flex h-full",children:[t.jsxs("div",{className:"w-64 border-r border-border bg-muted/50 flex flex-col",children:[t.jsx("div",{className:"p-4 border-b border-border",children:t.jsxs("h2",{className:"font-semibold flex items-center gap-2 text-foreground",children:[t.jsx(Oo,{className:"w-5 h-5"}),"Documentation"]})}),t.jsx(Js,{className:"flex-1",children:t.jsx("div",{className:"p-2",children:dW.map(d=>t.jsxs("div",{className:"mb-1",children:[t.jsxs("button",{className:Ee("w-full flex items-center gap-2 px-3 py-2 text-sm rounded-md hover:bg-accent text-left",(e===d.id||d.subsections.some(l=>l.id===e))&&"bg-accent"),onClick:()=>{d.subsections.length>0?(o(d.id),s[d.id]||r(d.subsections[0].id)):r(d.id)},children:[t.jsx(d.icon,{className:"w-4 h-4 text-muted-foreground"}),t.jsx("span",{className:"flex-1",children:d.title}),d.isNew&&t.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded font-medium bg-green-500/20 text-green-600 dark:text-green-400",children:"new"}),d.subsections.length>0&&t.jsx(Qr,{className:Ee("w-4 h-4 text-muted-foreground transition-transform",s[d.id]&&"rotate-90")})]}),d.subsections.length>0&&s[d.id]&&t.jsx("div",{className:"ml-6 mt-1 space-y-1",children:d.subsections.map(l=>t.jsx("button",{className:Ee("w-full text-left px-3 py-1.5 text-sm rounded-md hover:bg-accent text-foreground",e===l.id&&"bg-accent text-primary font-medium"),onClick:()=>r(l.id),children:l.title},l.id))})]},d.id))})})]}),t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(Js,{className:"h-full",children:t.jsx("div",{className:"max-w-3xl mx-auto p-8",children:c?t.jsx("div",{className:"prose prose-sm max-w-none",children:t.jsx("div",{dangerouslySetInnerHTML:{__html:R2(c.content)}})}):t.jsxs("div",{className:"text-center text-muted-foreground py-12",children:[t.jsx(Oo,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),t.jsx("p",{children:"Select a topic from the sidebar"})]})})})})]})}var AW={};const N_={development:"bg-blue-100 text-blue-700 border-blue-200 dark:bg-blue-900/30 dark:text-blue-400 dark:border-blue-800",productivity:"bg-green-100 text-green-700 border-green-200 dark:bg-green-900/30 dark:text-green-400 dark:border-green-800",integration:"bg-purple-100 text-purple-700 border-purple-200 dark:bg-purple-900/30 dark:text-purple-400 dark:border-purple-800",external:"bg-orange-100 text-orange-700 border-orange-200 dark:bg-orange-900/30 dark:text-orange-400 dark:border-orange-800",lsp:"bg-cyan-100 text-cyan-700 border-cyan-200 dark:bg-cyan-900/30 dark:text-cyan-400 dark:border-cyan-800",default:"bg-gray-100 text-gray-700 border-gray-200 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-700"};function TW(){var le,ae,re,de,Se,Re,Ue;const[e,r]=_.useState(!0),[s,n]=_.useState({allPlugins:[],categories:[],marketplaces:[],enabledPlugins:null}),[o,c]=_.useState(""),[d,l]=_.useState([]),[u,f]=_.useState([]),[m,h]=_.useState(!0),[g,w]=_.useState(!0),[j,k]=_.useState(!0),[v,y]=_.useState(!0),[x,b]=_.useState("name"),[S,N]=_.useState(null),[P,A]=_.useState({open:!1,repo:""}),[E,M]=_.useState(!1),[I,B]=_.useState({open:!1,plugin:null}),[U,V]=_.useState(!1),Q=async()=>{r(!0);try{const pe=await he.getPlugins();n(pe)}catch(pe){q.error("Failed to load plugins: "+pe.message)}finally{r(!1)}};_.useEffect(()=>{Q()},[]);const z=_.useMemo(()=>{let pe=s.allPlugins||[];if(o){const _e=o.toLowerCase();pe=pe.filter($e=>{var Ge,et,Nt;return((Ge=$e.name)==null?void 0:Ge.toLowerCase().includes(_e))||((et=$e.description)==null?void 0:et.toLowerCase().includes(_e))||((Nt=$e.category)==null?void 0:Nt.toLowerCase().includes(_e))})}return pe=pe.filter(_e=>!(_e.sourceType==="external"&&!g||_e.sourceType==="internal"&&!m)),pe=pe.filter(_e=>!(_e.installed&&!j||!_e.installed&&!v)),d.length>0&&(pe=pe.filter(_e=>d.includes(_e.category))),u.length>0&&(pe=pe.filter(_e=>u.includes(_e.marketplace))),pe.sort((_e,$e)=>{if(x==="installed"){if(_e.installed&&!$e.installed)return-1;if(!_e.installed&&$e.installed)return 1}if(x==="category"){const Ge=(_e.category||"zzz").localeCompare($e.category||"zzz");if(Ge!==0)return Ge}return _e.name.localeCompare($e.name)}),pe},[s.allPlugins,o,g,m,j,v,d,u,x]),H=pe=>{l(_e=>_e.includes(pe)?_e.filter($e=>$e!==pe):[..._e,pe])},Y=pe=>{f(_e=>_e.includes(pe)?_e.filter($e=>$e!==pe):[..._e,pe])},K=async pe=>{N(pe);try{const _e=await he.refreshMarketplace(pe);_e.success?(q.success(`Refreshed ${pe}`),await Q()):q.error(_e.error||"Failed to refresh marketplace")}catch(_e){q.error("Failed to refresh: "+_e.message)}finally{N(null)}},O=async()=>{if(!P.repo.trim()){q.error("Please enter a repository URL");return}try{const pe=await he.addMarketplace("",P.repo.trim());pe.success?(q.success("Marketplace added"),A({open:!1,repo:""}),await Q()):q.error(pe.error||"Failed to add marketplace")}catch(pe){q.error("Failed to add marketplace: "+pe.message)}},T=async(pe,_e,$e)=>{V(!0);try{const Ge=$e!==!0,et=await he.setPluginEnabled(pe,_e,Ge);et.success?(q.success(`Plugin ${Ge?"enabled":"disabled"} for ${pe===AW.HOME?"~":pe}`),await Q()):q.error(et.error||"Failed to update plugin state")}catch(Ge){q.error("Failed to update plugin: "+Ge.message)}finally{V(!1)}},F=async(pe,_e)=>{V(!0);try{const $e=await he.setPluginEnabled(pe,_e,null);$e.success?(q.success("Plugin override removed"),await Q()):q.error($e.error||"Failed to remove override")}catch($e){q.error("Failed to update plugin: "+$e.message)}finally{V(!1)}},$=pe=>{B({open:!0,plugin:pe})},D=(s.allPlugins||[]).filter(pe=>pe.installed).length,X=(s.allPlugins||[]).filter(pe=>!pe.installed).length,te=(s.allPlugins||[]).filter(pe=>pe.sourceType==="internal").length,fe=(s.allPlugins||[]).filter(pe=>pe.sourceType==="external").length,J=s.marketplaces||[],W=s.categories||[];return e?t.jsx("div",{className:"flex items-center justify-center h-64",children:t.jsx(Qe,{className:"w-8 h-8 animate-spin text-primary"})}):t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"bg-indigo-50 dark:bg-indigo-950/30 border border-indigo-200 dark:border-indigo-800 rounded-lg p-4 flex items-start gap-3",children:[t.jsx(rh,{className:"w-5 h-5 text-indigo-600 dark:text-indigo-400 flex-shrink-0 mt-0.5"}),t.jsxs("div",{className:"text-sm text-indigo-800 dark:text-indigo-300",children:[t.jsx("p",{className:"font-medium",children:"Install plugins from Project Explorer"}),t.jsxs("p",{className:"text-indigo-600 dark:text-indigo-400 mt-1",children:["Use the ",t.jsx("kbd",{className:"px-1.5 py-0.5 bg-indigo-100 dark:bg-indigo-900 rounded text-xs",children:"+"}),' menu on any project and select "Install Plugins" to add plugins with project-level scope control.']})]})]}),t.jsxs("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 overflow-hidden shadow-sm",children:[t.jsxs("div",{className:"p-5 border-b border-gray-200 dark:border-slate-700",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center gap-2",children:[t.jsx($o,{className:"w-5 h-5 text-indigo-600"}),"Plugin Directory",t.jsxs(qe,{variant:"outline",className:"ml-2 font-normal",children:[z.length," of ",((le=s.allPlugins)==null?void 0:le.length)||0]})]}),t.jsx(ne,{variant:"ghost",size:"sm",onClick:Q,disabled:e,children:t.jsx(Dr,{className:`w-4 h-4 ${e?"animate-spin":""}`})})]}),t.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[t.jsxs("div",{className:"relative flex-1",children:[t.jsx(Ic,{className:"w-4 h-4 absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),t.jsx(Oe,{value:o,onChange:pe=>c(pe.target.value),placeholder:"Search plugins...",className:"pl-9 bg-white dark:bg-slate-900 border-gray-300 dark:border-slate-700"})]}),t.jsxs(ir,{value:x,onValueChange:b,children:[t.jsx(Qt,{className:"w-40",children:t.jsx(or,{placeholder:"Sort by"})}),t.jsxs(Zt,{children:[t.jsx(gt,{value:"name",children:"Name"}),t.jsx(gt,{value:"installed",children:"Installed first"}),t.jsx(gt,{value:"category",children:"Category"})]})]})]}),t.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[t.jsxs(En,{children:[t.jsx(Pn,{asChild:!0,children:t.jsxs(ne,{variant:"outline",size:"sm",className:"h-8 text-xs gap-1",children:[t.jsx(Zd,{className:"w-3 h-3"}),"Marketplace",u.length>0&&t.jsx(qe,{variant:"secondary",className:"ml-1 h-4 px-1 text-[10px]",children:u.length}),t.jsx(hr,{className:"w-3 h-3 ml-1"})]})}),t.jsxs(hn,{align:"start",className:"w-56",children:[t.jsx(kc,{className:"text-xs",children:"Filter by marketplace"}),t.jsx(bs,{}),J.length>0?J.map(pe=>t.jsx(_c,{checked:u.includes(pe.name),onCheckedChange:()=>Y(pe.name),children:pe.name},pe.name)):t.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"No marketplaces"}),t.jsx(bs,{}),t.jsxs(jt,{onClick:()=>M(!0),children:[t.jsx(Xs,{className:"w-3 h-3 mr-2"}),"Manage Marketplaces"]}),u.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(bs,{}),t.jsx(jt,{onClick:()=>f([]),children:"Clear filters"})]})]})]}),t.jsxs(En,{children:[t.jsx(Pn,{asChild:!0,children:t.jsxs(ne,{variant:"outline",size:"sm",className:"h-8 text-xs gap-1",children:[t.jsx($g,{className:"w-3 h-3"}),"Category",d.length>0&&t.jsx(qe,{variant:"secondary",className:"ml-1 h-4 px-1 text-[10px]",children:d.length}),t.jsx(hr,{className:"w-3 h-3 ml-1"})]})}),t.jsxs(hn,{align:"start",className:"w-48",children:[t.jsx(kc,{className:"text-xs",children:"Filter by category"}),t.jsx(bs,{}),W.map(pe=>t.jsx(_c,{checked:d.includes(pe),onCheckedChange:()=>H(pe),children:pe},pe)),d.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(bs,{}),t.jsx(jt,{onClick:()=>l([]),children:"Clear filters"})]})]})]}),t.jsxs("div",{className:"flex items-center gap-4 text-xs",children:[t.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[t.jsx(xt,{checked:j,onCheckedChange:k,className:"h-4 w-7 data-[state=checked]:bg-green-600"}),t.jsxs("span",{className:"text-gray-600 dark:text-slate-400",children:["Installed (",D,")"]})]}),t.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[t.jsx(xt,{checked:v,onCheckedChange:y,className:"h-4 w-7 data-[state=checked]:bg-blue-600"}),t.jsxs("span",{className:"text-gray-600 dark:text-slate-400",children:["Available (",X,")"]})]}),t.jsx("span",{className:"text-gray-300 dark:text-slate-600",children:"|"}),t.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[t.jsx(xt,{checked:m,onCheckedChange:h,className:"h-4 w-7 data-[state=checked]:bg-indigo-600"}),t.jsxs("span",{className:"text-gray-600 dark:text-slate-400 flex items-center gap-1",children:[t.jsx(fS,{className:"w-3 h-3"})," Anthropic (",te,")"]})]}),t.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[t.jsx(xt,{checked:g,onCheckedChange:w,className:"h-4 w-7 data-[state=checked]:bg-orange-600"}),t.jsxs("span",{className:"text-gray-600 dark:text-slate-400 flex items-center gap-1",children:[t.jsx(eo,{className:"w-3 h-3"})," Community (",fe,")"]})]})]})]})]}),t.jsxs("div",{className:"p-4 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[z.map((pe,_e)=>{const $e=N_[pe.category]||N_.default,Ge=pe.mcpServers?Object.keys(pe.mcpServers).length:0,et=pe.lspServers?Object.keys(pe.lspServers).length:0,Nt=`${pe.name}@${pe.marketplace}`,ke=pe.enabledState,me=(ke==null?void 0:ke.merged)===!0;return(ke==null?void 0:ke.merged)!==null&&(ke==null||ke.merged),t.jsxs(Ua.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:Math.min(_e*.02,.3)},className:`rounded-lg border p-4 transition-all hover:shadow-md ${me?"bg-emerald-50 border-emerald-200 dark:bg-emerald-950/20 dark:border-emerald-800":pe.installed?"bg-green-50 border-green-200 dark:bg-green-950/20 dark:border-green-800":"bg-white border-gray-200 dark:bg-slate-900 dark:border-slate-700"}`,children:[t.jsxs("div",{className:"flex items-start justify-between mb-2",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[t.jsx("h3",{className:"font-semibold text-gray-900 dark:text-white truncate",children:pe.name}),pe.sourceType==="external"&&t.jsx(eo,{className:"w-3.5 h-3.5 text-orange-500 flex-shrink-0",title:"Community plugin"})]}),t.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[pe.installed&&t.jsxs(qe,{variant:"outline",className:"text-green-600 border-green-300 dark:text-green-400 dark:border-green-700 text-[10px]",children:[t.jsx(It,{className:"w-2.5 h-2.5 mr-0.5"}),"Installed"]}),me&&t.jsxs(qe,{variant:"outline",className:"text-emerald-600 border-emerald-300 dark:text-emerald-400 dark:border-emerald-700 text-[10px]",children:[t.jsx(Ub,{className:"w-2.5 h-2.5 mr-0.5"}),"Enabled"]})]})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[pe.installed&&t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(ne,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-60 hover:opacity-100",onClick:()=>$(pe),children:t.jsx(Xs,{className:"w-4 h-4"})})}),t.jsx(Ot,{children:t.jsx("p",{children:"Configure per-directory"})})]})}),pe.homepage&&t.jsx(ne,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-60 hover:opacity-100",onClick:()=>window.open(pe.homepage,"_blank"),children:t.jsx(xu,{className:"w-4 h-4"})})]})]}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-slate-400 mb-3 line-clamp-2",children:pe.description||"No description available"}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap mb-2",children:[pe.category&&t.jsx(qe,{variant:"outline",className:`text-[10px] px-1.5 py-0 ${$e}`,children:pe.category}),pe.version&&t.jsxs("span",{className:"text-[10px] text-gray-400 dark:text-slate-500",children:["v",pe.version]})]}),(Ge>0||et>0||pe.commands)&&t.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-gray-500 dark:text-slate-500 pt-2 border-t border-gray-100 dark:border-slate-800",children:[et>0&&t.jsxs("span",{className:"flex items-center gap-1 bg-cyan-50 dark:bg-cyan-900/20 px-1.5 py-0.5 rounded",children:[t.jsx(Yn,{className:"w-3 h-3 text-cyan-600"}),et," LSP"]}),Ge>0&&t.jsxs("span",{className:"flex items-center gap-1 bg-blue-50 dark:bg-blue-900/20 px-1.5 py-0.5 rounded",children:[t.jsx(ws,{className:"w-3 h-3 text-blue-600"}),Ge," MCP"]}),pe.commands&&t.jsxs("span",{className:"flex items-center gap-1 bg-green-50 dark:bg-green-900/20 px-1.5 py-0.5 rounded",children:[t.jsx(Ut,{className:"w-3 h-3 text-green-600"}),"Commands"]})]})]},Nt)}),z.length===0&&t.jsxs("div",{className:"col-span-full text-center py-12 text-gray-500 dark:text-slate-400",children:[t.jsx($o,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),t.jsx("p",{className:"font-medium",children:"No plugins found"}),t.jsx("p",{className:"text-sm mt-1",children:"Try adjusting your filters or search query"}),(d.length>0||u.length>0||o)&&t.jsx(ne,{variant:"link",size:"sm",onClick:()=>{l([]),f([]),c("")},className:"mt-2",children:"Clear all filters"})]})]})]}),t.jsx(vt,{open:P.open,onOpenChange:pe=>A({...P,open:pe}),children:t.jsxs(ft,{className:"max-w-lg",children:[t.jsxs(mt,{children:[t.jsxs(pt,{className:"flex items-center gap-2",children:[t.jsx(Zd,{className:"w-5 h-5 text-purple-600"}),"Add Plugin Marketplace"]}),t.jsx(Gt,{children:"Add a marketplace from a GitHub repository URL or local path."})]}),t.jsx("div",{className:"space-y-4 py-4",children:t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Repository URL or Path"}),t.jsx(Oe,{value:P.repo,onChange:pe=>A({...P,repo:pe.target.value}),placeholder:"owner/repo or full GitHub URL",className:"mt-1"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400 mt-2",children:"Supported formats:"}),t.jsxs("ul",{className:"text-xs text-gray-500 dark:text-slate-400 mt-1 space-y-1 ml-2",children:[t.jsxs("li",{children:[t.jsx("code",{className:"bg-gray-100 dark:bg-slate-700 px-1 rounded",children:"owner/repo"})," — GitHub shorthand"]}),t.jsxs("li",{children:[t.jsx("code",{className:"bg-gray-100 dark:bg-slate-700 px-1 rounded",children:"https://github.com/owner/repo"})," — Full URL"]}),t.jsxs("li",{children:[t.jsx("code",{className:"bg-gray-100 dark:bg-slate-700 px-1 rounded",children:"/local/path"})," — Local directory"]})]}),t.jsxs("p",{className:"text-xs text-gray-400 dark:text-slate-500 mt-2",children:["Search GitHub for ",t.jsx("code",{className:"bg-gray-100 dark:bg-slate-700 px-1 rounded",children:"claude-plugins"})," to find community marketplaces."]})]})}),t.jsxs(St,{children:[t.jsx(ne,{variant:"ghost",onClick:()=>A({open:!1,repo:""}),children:"Cancel"}),t.jsxs(ne,{onClick:O,className:"bg-purple-600 hover:bg-purple-700 text-white",children:[t.jsx(Rt,{className:"w-4 h-4 mr-2"}),"Add Marketplace"]})]})]})}),t.jsx(vt,{open:E,onOpenChange:M,children:t.jsxs(ft,{className:"max-w-2xl",children:[t.jsxs(mt,{children:[t.jsxs(pt,{className:"flex items-center gap-2",children:[t.jsx(Zd,{className:"w-5 h-5 text-purple-600"}),"Plugin Marketplaces",t.jsx(qe,{variant:"outline",className:"ml-2 font-normal",children:J.length})]}),t.jsx(Gt,{children:"Manage your plugin marketplaces. Add external marketplaces to discover more plugins."})]}),t.jsx("div",{className:"py-4",children:J.length>0?t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:J.map(pe=>{var $e,Ge,et;const _e=((($e=pe.plugins)==null?void 0:$e.length)||0)+(((Ge=pe.externalPlugins)==null?void 0:Ge.length)||0);return t.jsxs("div",{className:"bg-purple-50 dark:bg-purple-950/20 rounded-lg border border-purple-200 dark:border-purple-800 p-4",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("h3",{className:"font-semibold text-purple-900 dark:text-purple-200",children:pe.name}),t.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>K(pe.name),disabled:S===pe.name,className:"h-7 w-7 p-0",children:t.jsx(Dr,{className:`w-4 h-4 text-purple-600 dark:text-purple-400 ${S===pe.name?"animate-spin":""}`})})]}),t.jsx("p",{className:"text-sm text-purple-700 dark:text-purple-300 mb-2 truncate",children:typeof pe.source=="string"?pe.source:((et=pe.source)==null?void 0:et.repo)||"Unknown source"}),t.jsxs("div",{className:"flex items-center justify-between text-xs text-purple-600 dark:text-purple-400",children:[t.jsxs("span",{children:[_e," plugins"]}),pe.lastUpdated&&t.jsxs("span",{children:["Updated: ",new Date(pe.lastUpdated).toLocaleDateString()]})]})]},pe.name)})}):t.jsxs("div",{className:"text-center py-8 text-gray-500 dark:text-slate-400",children:[t.jsx(Zd,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),t.jsx("p",{children:"No marketplaces configured."}),t.jsx("p",{className:"text-sm mt-1",children:"Add a marketplace to discover plugins."})]})}),t.jsxs(St,{children:[t.jsx(ne,{variant:"outline",onClick:()=>M(!1),children:"Close"}),t.jsxs(ne,{onClick:()=>{M(!1),A({open:!0,repo:""})},className:"bg-purple-600 hover:bg-purple-700 text-white",children:[t.jsx(Rt,{className:"w-4 h-4 mr-2"}),"Add Marketplace"]})]})]})}),t.jsx(vt,{open:I.open,onOpenChange:pe=>B({...I,open:pe}),children:t.jsxs(ft,{className:"max-w-lg",children:[t.jsxs(mt,{children:[t.jsxs(pt,{className:"flex items-center gap-2",children:[t.jsx(zb,{className:"w-5 h-5 text-emerald-600"}),"Configure Plugin: ",(ae=I.plugin)==null?void 0:ae.name]}),t.jsx(Gt,{children:"Enable or disable this plugin for specific directories. Child directories inherit parent settings unless overridden."})]}),t.jsxs("div",{className:"space-y-3 py-4 max-h-[400px] overflow-y-auto",children:[(Se=(de=(re=I.plugin)==null?void 0:re.enabledState)==null?void 0:de.perDir)==null?void 0:Se.map((pe,_e)=>{const $e=`${I.plugin.name}@${I.plugin.marketplace}`,Ge=pe.enabled!==null&&pe.enabled!==void 0,et=pe.enabled===!0,Nt=pe.enabled===!1;let ke=null;if(!Ge&&_e>0)for(let me=_e-1;me>=0;me--){const be=I.plugin.enabledState.perDir[me];if(be.enabled!==null&&be.enabled!==void 0){ke=be.enabled;break}}return t.jsxs("div",{className:`flex items-center justify-between p-3 rounded-lg border ${et?"bg-emerald-50 border-emerald-200 dark:bg-emerald-950/30 dark:border-emerald-800":Nt?"bg-red-50 border-red-200 dark:bg-red-950/30 dark:border-red-800":"bg-gray-50 border-gray-200 dark:bg-slate-800/50 dark:border-slate-700"}`,children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("code",{className:"text-sm font-mono text-gray-700 dark:text-slate-300 truncate",children:pe.label}),!Ge&&ke!==null&&t.jsxs(qe,{variant:"outline",className:"text-[10px] text-gray-500",children:["inherited: ",ke?"on":"off"]})]}),Ge&&t.jsx("p",{className:"text-[10px] text-gray-500 dark:text-slate-400 mt-0.5",children:et?"Explicitly enabled":"Explicitly disabled"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[Ge&&t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(ne,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-gray-400 hover:text-gray-600",onClick:()=>F(pe.dir,$e),disabled:U,children:t.jsx(W5,{className:"w-4 h-4"})})}),t.jsx(Ot,{children:t.jsx("p",{children:"Remove override (inherit from parent)"})})]})}),t.jsxs("div",{className:"flex items-center gap-1 border rounded-lg overflow-hidden",children:[t.jsx(ne,{variant:et?"default":"ghost",size:"sm",className:`h-7 px-2 rounded-none ${et?"bg-emerald-600 hover:bg-emerald-700 text-white":""}`,onClick:()=>T(pe.dir,$e,!1),disabled:U||et,children:t.jsx(Ub,{className:"w-3 h-3"})}),t.jsx(ne,{variant:Nt?"default":"ghost",size:"sm",className:`h-7 px-2 rounded-none ${Nt?"bg-red-600 hover:bg-red-700 text-white":""}`,onClick:()=>T(pe.dir,$e,!0),disabled:U||Nt,children:t.jsx(lI,{className:"w-3 h-3"})})]})]})]},pe.dir)}),(!((Ue=(Re=I.plugin)==null?void 0:Re.enabledState)!=null&&Ue.perDir)||I.plugin.enabledState.perDir.length===0)&&t.jsxs("div",{className:"text-center py-8 text-gray-500 dark:text-slate-400",children:[t.jsx(zb,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),t.jsx("p",{children:"No config hierarchy found."}),t.jsx("p",{className:"text-sm mt-1",children:"Create a .claude/mcps.json in your project first."})]})]}),t.jsx(St,{children:t.jsx(ne,{variant:"ghost",onClick:()=>B({open:!1,plugin:null}),children:"Done"})})]})}),t.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-4 border border-transparent dark:border-slate-800",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white mb-2",children:"CLI Commands (Claude Code)"}),t.jsxs("div",{className:"space-y-1 text-sm text-gray-600 dark:text-slate-400 font-mono",children:[t.jsx("p",{className:"text-gray-400 dark:text-slate-500",children:"# Add marketplace (one-time)"}),t.jsx("p",{children:"claude plugin marketplace add regression-io/coder-config-plugins"}),t.jsx("p",{className:"text-gray-400 dark:text-slate-500 mt-2",children:"# Install plugins from marketplace"}),t.jsx("p",{children:"claude plugin install <name>@coder-config-plugins"}),t.jsx("p",{className:"text-gray-400 dark:text-slate-500 mt-2",children:"# Manage plugins"}),t.jsx("p",{children:"claude plugin list # List installed"}),t.jsx("p",{children:"claude plugin uninstall <name> # Remove plugin"})]})]})]})}const M2=[{name:"red",hex:"#ef4444"},{name:"orange",hex:"#f97316"},{name:"yellow",hex:"#eab308"},{name:"green",hex:"#22c55e"},{name:"cyan",hex:"#06b6d4"},{name:"blue",hex:"#3b82f6"},{name:"purple",hex:"#a855f7"},{name:"pink",hex:"#ec4899"},{name:"gray",hex:"#9ca3af"}];function RW({color:e,size:r="md"}){const s=M2.find(o=>o.name===e);if(!s)return null;const n=r==="sm"?"w-2.5 h-2.5":"w-3.5 h-3.5";return t.jsx("span",{className:`inline-block rounded-full ${n} flex-shrink-0 ring-1 ring-black/10 dark:ring-white/20`,style:{backgroundColor:s.hex},title:`Color: ${e}`})}function MW({value:e,onChange:r}){return t.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[t.jsx("button",{type:"button",onClick:()=>r(null),className:`w-7 h-7 rounded-full border-2 flex items-center justify-center transition-all ${e?"border-gray-300 dark:border-slate-600 hover:border-gray-400":"border-purple-600 dark:border-purple-400"}`,title:"No color",children:t.jsx(Nn,{className:"w-3 h-3 text-gray-400"})}),M2.map(s=>t.jsx("button",{type:"button",onClick:()=>r(s.name),className:`w-7 h-7 rounded-full border-2 transition-all ${e===s.name?"border-gray-900 dark:border-white scale-110":"border-transparent hover:scale-105"}`,style:{backgroundColor:s.hex},title:s.name},s.name))]})}function IW({onWorkstreamChange:e}){var ho,Mn,oa,fo,ti,xs,mo,Or;const{projects:r,fetch:s}=Fx(),{workstreams:n,loading:o,fetch:c,create:d,update:l,delete:u,addProject:f,removeProject:m,countWorkstreamsForProject:h}=MN(),[g,w]=_.useState(null),[j,k]=_.useState(!1),[v,y]=_.useState(null),[x,b]=_.useState(!1),[S,N]=_.useState(null),[P,A]=_.useState(new Set),[E,M]=_.useState(""),[I,B]=_.useState(""),[U,V]=_.useState([]),[Q,z]=_.useState(!1),[H,Y]=_.useState(!1),[K,O]=_.useState({}),[T,F]=_.useState({}),[$,D]=_.useState({}),[X,te]=_.useState({isInstalled:!1,loading:!0}),[fe,J]=_.useState(!1),[W,le]=_.useState(null),[ae,re]=_.useState([]),[de,Se]=_.useState(!1),[Re,Ue]=_.useState(()=>{try{return JSON.parse(localStorage.getItem("dismissedWorkstreamSuggestions")||"[]")}catch{return[]}}),[pe,_e]=_.useState(!1),[$e,Ge]=_.useState(""),[et,Nt]=_.useState([]),[ke,me]=_.useState("llama3.2"),[be,Z]=_.useState(null),[oe,we]=_.useState(""),[Ce,Fe]=_.useState(!1),[He,ct]=_.useState({installed:!1,loading:!0}),[st,zt]=_.useState({workstreamAutoActivate:!0}),[Lr,Vr]=_.useState(!1),[tr,Pr]=_.useState(!1),[qt,Cr]=_.useState(null),[ps,ts]=_.useState("");_.useEffect(()=>{c(),s(),Wt(),lr(),Bs(),at(),Fs()},[c,s]);const Fs=async()=>{try{const ee=await he.getAvailableAITools();ee.success&&ee.tools&&(Nt(ee.tools),ee.tools.find(Xe=>Xe.id==="claude"&&Xe.available)&&Ge("claude"))}catch(ee){console.error("Failed to load AI tools:",ee)}},Bs=async()=>{try{const ee=await he.getCdHookStatus();ct({...ee,loading:!1})}catch(ee){ct({installed:!1,loading:!1,error:ee.message})}},at=async()=>{try{const ee=await he.getWorkstreamSettings();zt(ee.settings||{workstreamAutoActivate:!0})}catch(ee){console.error("Failed to load global settings:",ee)}},Wt=async()=>{try{const ee=await he.getWorkstreamHookStatus();te({...ee,loading:!1})}catch(ee){te({isInstalled:!1,loading:!1,error:ee.message})}},lr=async()=>{try{Se(!0);const[ee,De]=await Promise.all([he.getActivitySummary(),he.getWorkstreamSuggestions()]);le(ee),re(De.suggestions||[])}catch(ee){console.log("Activity data not available:",ee.message)}finally{Se(!1)}},fr=ee=>{M(ee.name),V([...ee.projects]),B(`# Auto-generated workstream based on activity patterns
3042
+ `}},PW={...hW,...fW,...mW,...pW,...gW,...xW,...vW,...yW,...bW,...wW,..._W,...kW,...SW,...CW,...jW,...NW,...EW};function R2(e){let r=e.replace(/```(\w*)\n([\s\S]*?)```/g,(s,n,o)=>`<pre class="bg-zinc-900 text-zinc-100 p-4 rounded-lg overflow-x-auto my-4"><code class="text-sm">${o.replace(/\\\`/g,"`").replace(/</g,"&lt;").replace(/>/g,"&gt;").trim()}</code></pre>`);return r=r.replace(/(\|[^\n]+\|\n\|[-| :]+\|\n(?:\|[^\n]+\|\n?)+)/g,s=>{const n=s.trim().split(`
3043
+ `);if(n.length<2)return s;const o=n[0].split("|").filter(d=>d.trim()).map(d=>`<th class="border border-border px-3 py-2 bg-muted font-semibold text-left">${d.trim()}</th>`).join(""),c=n.slice(2).map(d=>`<tr>${d.split("|").filter(u=>u.trim()).map(u=>`<td class="border border-border px-3 py-2">${u.trim()}</td>`).join("")}</tr>`).join("");return`<table class="w-full border-collapse border border-border my-4"><thead><tr>${o}</tr></thead><tbody>${c}</tbody></table>`}),r=r.replace(/`([^`]+)`/g,(s,n)=>`<code class="bg-muted px-1.5 py-0.5 rounded text-sm font-mono">${n.replace(/\*/g,"&#42;").replace(/_/g,"&#95;")}</code>`),r.replace(/^### (.*$)/gim,'<h3 class="text-lg font-semibold mt-6 mb-2 text-foreground">$1</h3>').replace(/^## (.*$)/gim,'<h2 class="text-xl font-semibold mt-8 mb-4 text-foreground">$1</h2>').replace(/^# (.*$)/gim,'<h1 class="text-2xl font-bold mb-6 text-foreground">$1</h1>').replace(/!\[([^\]]*)\]\(([^)]+)\)/g,'<img src="$2" alt="$1" class="rounded-lg shadow-lg my-4 max-w-full border border-border" />').replace(/\*\*(.*?)\*\*/g,"<strong>$1</strong>").replace(/\*(.*?)\*/g,"<em>$1</em>").replace(/^- (.*$)/gim,'<li class="ml-4 list-disc">$1</li>').replace(/((?:<li class="ml-4 list-disc">.*<\/li>\n?)+)/g,'<ul class="list-disc my-2">$1</ul>').replace(/^\d+\. (.*$)/gim,'<li class="ml-4 list-decimal">$1</li>').replace(/((?:<li class="ml-4 list-decimal">.*<\/li>\n?)+)/g,'<ol class="list-decimal my-2">$1</ol>').replace(/\n\n/g,'</p><p class="my-3 text-foreground">').replace(/\n/g,"<br/>")}function AW(){const[e,r]=_.useState("installation"),[s,n]=_.useState({"getting-started":!0}),o=d=>{n(l=>({...l,[d]:!l[d]}))},c=PW[e];return t.jsxs("div",{className:"flex h-full",children:[t.jsxs("div",{className:"w-64 border-r border-border bg-muted/50 flex flex-col",children:[t.jsx("div",{className:"p-4 border-b border-border",children:t.jsxs("h2",{className:"font-semibold flex items-center gap-2 text-foreground",children:[t.jsx(Oo,{className:"w-5 h-5"}),"Documentation"]})}),t.jsx(Js,{className:"flex-1",children:t.jsx("div",{className:"p-2",children:uW.map(d=>t.jsxs("div",{className:"mb-1",children:[t.jsxs("button",{className:Ee("w-full flex items-center gap-2 px-3 py-2 text-sm rounded-md hover:bg-accent text-left",(e===d.id||d.subsections.some(l=>l.id===e))&&"bg-accent"),onClick:()=>{d.subsections.length>0?(o(d.id),s[d.id]||r(d.subsections[0].id)):r(d.id)},children:[t.jsx(d.icon,{className:"w-4 h-4 text-muted-foreground"}),t.jsx("span",{className:"flex-1",children:d.title}),d.isNew&&t.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded font-medium bg-green-500/20 text-green-600 dark:text-green-400",children:"new"}),d.subsections.length>0&&t.jsx(Qr,{className:Ee("w-4 h-4 text-muted-foreground transition-transform",s[d.id]&&"rotate-90")})]}),d.subsections.length>0&&s[d.id]&&t.jsx("div",{className:"ml-6 mt-1 space-y-1",children:d.subsections.map(l=>t.jsx("button",{className:Ee("w-full text-left px-3 py-1.5 text-sm rounded-md hover:bg-accent text-foreground",e===l.id&&"bg-accent text-primary font-medium"),onClick:()=>r(l.id),children:l.title},l.id))})]},d.id))})})]}),t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(Js,{className:"h-full",children:t.jsx("div",{className:"max-w-3xl mx-auto p-8",children:c?t.jsx("div",{className:"prose prose-sm max-w-none",children:t.jsx("div",{dangerouslySetInnerHTML:{__html:R2(c.content)}})}):t.jsxs("div",{className:"text-center text-muted-foreground py-12",children:[t.jsx(Oo,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),t.jsx("p",{children:"Select a topic from the sidebar"})]})})})})]})}var TW={};const N_={development:"bg-blue-100 text-blue-700 border-blue-200 dark:bg-blue-900/30 dark:text-blue-400 dark:border-blue-800",productivity:"bg-green-100 text-green-700 border-green-200 dark:bg-green-900/30 dark:text-green-400 dark:border-green-800",integration:"bg-purple-100 text-purple-700 border-purple-200 dark:bg-purple-900/30 dark:text-purple-400 dark:border-purple-800",external:"bg-orange-100 text-orange-700 border-orange-200 dark:bg-orange-900/30 dark:text-orange-400 dark:border-orange-800",lsp:"bg-cyan-100 text-cyan-700 border-cyan-200 dark:bg-cyan-900/30 dark:text-cyan-400 dark:border-cyan-800",default:"bg-gray-100 text-gray-700 border-gray-200 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-700"};function RW(){var le,ae,re,de,Se,Re,Ue;const[e,r]=_.useState(!0),[s,n]=_.useState({allPlugins:[],categories:[],marketplaces:[],enabledPlugins:null}),[o,c]=_.useState(""),[d,l]=_.useState([]),[u,f]=_.useState([]),[m,h]=_.useState(!0),[g,w]=_.useState(!0),[j,k]=_.useState(!0),[v,y]=_.useState(!0),[x,b]=_.useState("name"),[S,N]=_.useState(null),[P,A]=_.useState({open:!1,repo:""}),[E,M]=_.useState(!1),[I,B]=_.useState({open:!1,plugin:null}),[U,V]=_.useState(!1),Q=async()=>{r(!0);try{const pe=await he.getPlugins();n(pe)}catch(pe){q.error("Failed to load plugins: "+pe.message)}finally{r(!1)}};_.useEffect(()=>{Q()},[]);const z=_.useMemo(()=>{let pe=s.allPlugins||[];if(o){const _e=o.toLowerCase();pe=pe.filter($e=>{var Ge,et,Nt;return((Ge=$e.name)==null?void 0:Ge.toLowerCase().includes(_e))||((et=$e.description)==null?void 0:et.toLowerCase().includes(_e))||((Nt=$e.category)==null?void 0:Nt.toLowerCase().includes(_e))})}return pe=pe.filter(_e=>!(_e.sourceType==="external"&&!g||_e.sourceType==="internal"&&!m)),pe=pe.filter(_e=>!(_e.installed&&!j||!_e.installed&&!v)),d.length>0&&(pe=pe.filter(_e=>d.includes(_e.category))),u.length>0&&(pe=pe.filter(_e=>u.includes(_e.marketplace))),pe.sort((_e,$e)=>{if(x==="installed"){if(_e.installed&&!$e.installed)return-1;if(!_e.installed&&$e.installed)return 1}if(x==="category"){const Ge=(_e.category||"zzz").localeCompare($e.category||"zzz");if(Ge!==0)return Ge}return _e.name.localeCompare($e.name)}),pe},[s.allPlugins,o,g,m,j,v,d,u,x]),H=pe=>{l(_e=>_e.includes(pe)?_e.filter($e=>$e!==pe):[..._e,pe])},Y=pe=>{f(_e=>_e.includes(pe)?_e.filter($e=>$e!==pe):[..._e,pe])},K=async pe=>{N(pe);try{const _e=await he.refreshMarketplace(pe);_e.success?(q.success(`Refreshed ${pe}`),await Q()):q.error(_e.error||"Failed to refresh marketplace")}catch(_e){q.error("Failed to refresh: "+_e.message)}finally{N(null)}},O=async()=>{if(!P.repo.trim()){q.error("Please enter a repository URL");return}try{const pe=await he.addMarketplace("",P.repo.trim());pe.success?(q.success("Marketplace added"),A({open:!1,repo:""}),await Q()):q.error(pe.error||"Failed to add marketplace")}catch(pe){q.error("Failed to add marketplace: "+pe.message)}},T=async(pe,_e,$e)=>{V(!0);try{const Ge=$e!==!0,et=await he.setPluginEnabled(pe,_e,Ge);et.success?(q.success(`Plugin ${Ge?"enabled":"disabled"} for ${pe===TW.HOME?"~":pe}`),await Q()):q.error(et.error||"Failed to update plugin state")}catch(Ge){q.error("Failed to update plugin: "+Ge.message)}finally{V(!1)}},F=async(pe,_e)=>{V(!0);try{const $e=await he.setPluginEnabled(pe,_e,null);$e.success?(q.success("Plugin override removed"),await Q()):q.error($e.error||"Failed to remove override")}catch($e){q.error("Failed to update plugin: "+$e.message)}finally{V(!1)}},$=pe=>{B({open:!0,plugin:pe})},D=(s.allPlugins||[]).filter(pe=>pe.installed).length,X=(s.allPlugins||[]).filter(pe=>!pe.installed).length,te=(s.allPlugins||[]).filter(pe=>pe.sourceType==="internal").length,fe=(s.allPlugins||[]).filter(pe=>pe.sourceType==="external").length,J=s.marketplaces||[],W=s.categories||[];return e?t.jsx("div",{className:"flex items-center justify-center h-64",children:t.jsx(Qe,{className:"w-8 h-8 animate-spin text-primary"})}):t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"bg-indigo-50 dark:bg-indigo-950/30 border border-indigo-200 dark:border-indigo-800 rounded-lg p-4 flex items-start gap-3",children:[t.jsx(rh,{className:"w-5 h-5 text-indigo-600 dark:text-indigo-400 flex-shrink-0 mt-0.5"}),t.jsxs("div",{className:"text-sm text-indigo-800 dark:text-indigo-300",children:[t.jsx("p",{className:"font-medium",children:"Install plugins from Project Explorer"}),t.jsxs("p",{className:"text-indigo-600 dark:text-indigo-400 mt-1",children:["Use the ",t.jsx("kbd",{className:"px-1.5 py-0.5 bg-indigo-100 dark:bg-indigo-900 rounded text-xs",children:"+"}),' menu on any project and select "Install Plugins" to add plugins with project-level scope control.']})]})]}),t.jsxs("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 overflow-hidden shadow-sm",children:[t.jsxs("div",{className:"p-5 border-b border-gray-200 dark:border-slate-700",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center gap-2",children:[t.jsx($o,{className:"w-5 h-5 text-indigo-600"}),"Plugin Directory",t.jsxs(qe,{variant:"outline",className:"ml-2 font-normal",children:[z.length," of ",((le=s.allPlugins)==null?void 0:le.length)||0]})]}),t.jsx(ne,{variant:"ghost",size:"sm",onClick:Q,disabled:e,children:t.jsx(Dr,{className:`w-4 h-4 ${e?"animate-spin":""}`})})]}),t.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[t.jsxs("div",{className:"relative flex-1",children:[t.jsx(Ic,{className:"w-4 h-4 absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),t.jsx(Oe,{value:o,onChange:pe=>c(pe.target.value),placeholder:"Search plugins...",className:"pl-9 bg-white dark:bg-slate-900 border-gray-300 dark:border-slate-700"})]}),t.jsxs(ir,{value:x,onValueChange:b,children:[t.jsx(Qt,{className:"w-40",children:t.jsx(or,{placeholder:"Sort by"})}),t.jsxs(Zt,{children:[t.jsx(gt,{value:"name",children:"Name"}),t.jsx(gt,{value:"installed",children:"Installed first"}),t.jsx(gt,{value:"category",children:"Category"})]})]})]}),t.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[t.jsxs(En,{children:[t.jsx(Pn,{asChild:!0,children:t.jsxs(ne,{variant:"outline",size:"sm",className:"h-8 text-xs gap-1",children:[t.jsx(Zd,{className:"w-3 h-3"}),"Marketplace",u.length>0&&t.jsx(qe,{variant:"secondary",className:"ml-1 h-4 px-1 text-[10px]",children:u.length}),t.jsx(hr,{className:"w-3 h-3 ml-1"})]})}),t.jsxs(hn,{align:"start",className:"w-56",children:[t.jsx(kc,{className:"text-xs",children:"Filter by marketplace"}),t.jsx(bs,{}),J.length>0?J.map(pe=>t.jsx(_c,{checked:u.includes(pe.name),onCheckedChange:()=>Y(pe.name),children:pe.name},pe.name)):t.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"No marketplaces"}),t.jsx(bs,{}),t.jsxs(jt,{onClick:()=>M(!0),children:[t.jsx(Xs,{className:"w-3 h-3 mr-2"}),"Manage Marketplaces"]}),u.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(bs,{}),t.jsx(jt,{onClick:()=>f([]),children:"Clear filters"})]})]})]}),t.jsxs(En,{children:[t.jsx(Pn,{asChild:!0,children:t.jsxs(ne,{variant:"outline",size:"sm",className:"h-8 text-xs gap-1",children:[t.jsx($g,{className:"w-3 h-3"}),"Category",d.length>0&&t.jsx(qe,{variant:"secondary",className:"ml-1 h-4 px-1 text-[10px]",children:d.length}),t.jsx(hr,{className:"w-3 h-3 ml-1"})]})}),t.jsxs(hn,{align:"start",className:"w-48",children:[t.jsx(kc,{className:"text-xs",children:"Filter by category"}),t.jsx(bs,{}),W.map(pe=>t.jsx(_c,{checked:d.includes(pe),onCheckedChange:()=>H(pe),children:pe},pe)),d.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(bs,{}),t.jsx(jt,{onClick:()=>l([]),children:"Clear filters"})]})]})]}),t.jsxs("div",{className:"flex items-center gap-4 text-xs",children:[t.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[t.jsx(xt,{checked:j,onCheckedChange:k,className:"h-4 w-7 data-[state=checked]:bg-green-600"}),t.jsxs("span",{className:"text-gray-600 dark:text-slate-400",children:["Installed (",D,")"]})]}),t.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[t.jsx(xt,{checked:v,onCheckedChange:y,className:"h-4 w-7 data-[state=checked]:bg-blue-600"}),t.jsxs("span",{className:"text-gray-600 dark:text-slate-400",children:["Available (",X,")"]})]}),t.jsx("span",{className:"text-gray-300 dark:text-slate-600",children:"|"}),t.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[t.jsx(xt,{checked:m,onCheckedChange:h,className:"h-4 w-7 data-[state=checked]:bg-indigo-600"}),t.jsxs("span",{className:"text-gray-600 dark:text-slate-400 flex items-center gap-1",children:[t.jsx(fS,{className:"w-3 h-3"})," Anthropic (",te,")"]})]}),t.jsxs("label",{className:"flex items-center gap-1.5 cursor-pointer",children:[t.jsx(xt,{checked:g,onCheckedChange:w,className:"h-4 w-7 data-[state=checked]:bg-orange-600"}),t.jsxs("span",{className:"text-gray-600 dark:text-slate-400 flex items-center gap-1",children:[t.jsx(eo,{className:"w-3 h-3"})," Community (",fe,")"]})]})]})]})]}),t.jsxs("div",{className:"p-4 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[z.map((pe,_e)=>{const $e=N_[pe.category]||N_.default,Ge=pe.mcpServers?Object.keys(pe.mcpServers).length:0,et=pe.lspServers?Object.keys(pe.lspServers).length:0,Nt=`${pe.name}@${pe.marketplace}`,ke=pe.enabledState,me=(ke==null?void 0:ke.merged)===!0;return(ke==null?void 0:ke.merged)!==null&&(ke==null||ke.merged),t.jsxs(Ua.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:Math.min(_e*.02,.3)},className:`rounded-lg border p-4 transition-all hover:shadow-md ${me?"bg-emerald-50 border-emerald-200 dark:bg-emerald-950/20 dark:border-emerald-800":pe.installed?"bg-green-50 border-green-200 dark:bg-green-950/20 dark:border-green-800":"bg-white border-gray-200 dark:bg-slate-900 dark:border-slate-700"}`,children:[t.jsxs("div",{className:"flex items-start justify-between mb-2",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[t.jsx("h3",{className:"font-semibold text-gray-900 dark:text-white truncate",children:pe.name}),pe.sourceType==="external"&&t.jsx(eo,{className:"w-3.5 h-3.5 text-orange-500 flex-shrink-0",title:"Community plugin"})]}),t.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[pe.installed&&t.jsxs(qe,{variant:"outline",className:"text-green-600 border-green-300 dark:text-green-400 dark:border-green-700 text-[10px]",children:[t.jsx(It,{className:"w-2.5 h-2.5 mr-0.5"}),"Installed"]}),me&&t.jsxs(qe,{variant:"outline",className:"text-emerald-600 border-emerald-300 dark:text-emerald-400 dark:border-emerald-700 text-[10px]",children:[t.jsx(Ub,{className:"w-2.5 h-2.5 mr-0.5"}),"Enabled"]})]})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[pe.installed&&t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(ne,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-60 hover:opacity-100",onClick:()=>$(pe),children:t.jsx(Xs,{className:"w-4 h-4"})})}),t.jsx(Ot,{children:t.jsx("p",{children:"Configure per-directory"})})]})}),pe.homepage&&t.jsx(ne,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 opacity-60 hover:opacity-100",onClick:()=>window.open(pe.homepage,"_blank"),children:t.jsx(xu,{className:"w-4 h-4"})})]})]}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-slate-400 mb-3 line-clamp-2",children:pe.description||"No description available"}),t.jsxs("div",{className:"flex items-center gap-2 flex-wrap mb-2",children:[pe.category&&t.jsx(qe,{variant:"outline",className:`text-[10px] px-1.5 py-0 ${$e}`,children:pe.category}),pe.version&&t.jsxs("span",{className:"text-[10px] text-gray-400 dark:text-slate-500",children:["v",pe.version]})]}),(Ge>0||et>0||pe.commands)&&t.jsxs("div",{className:"flex items-center gap-3 text-[10px] text-gray-500 dark:text-slate-500 pt-2 border-t border-gray-100 dark:border-slate-800",children:[et>0&&t.jsxs("span",{className:"flex items-center gap-1 bg-cyan-50 dark:bg-cyan-900/20 px-1.5 py-0.5 rounded",children:[t.jsx(Yn,{className:"w-3 h-3 text-cyan-600"}),et," LSP"]}),Ge>0&&t.jsxs("span",{className:"flex items-center gap-1 bg-blue-50 dark:bg-blue-900/20 px-1.5 py-0.5 rounded",children:[t.jsx(ws,{className:"w-3 h-3 text-blue-600"}),Ge," MCP"]}),pe.commands&&t.jsxs("span",{className:"flex items-center gap-1 bg-green-50 dark:bg-green-900/20 px-1.5 py-0.5 rounded",children:[t.jsx(Ut,{className:"w-3 h-3 text-green-600"}),"Commands"]})]})]},Nt)}),z.length===0&&t.jsxs("div",{className:"col-span-full text-center py-12 text-gray-500 dark:text-slate-400",children:[t.jsx($o,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),t.jsx("p",{className:"font-medium",children:"No plugins found"}),t.jsx("p",{className:"text-sm mt-1",children:"Try adjusting your filters or search query"}),(d.length>0||u.length>0||o)&&t.jsx(ne,{variant:"link",size:"sm",onClick:()=>{l([]),f([]),c("")},className:"mt-2",children:"Clear all filters"})]})]})]}),t.jsx(vt,{open:P.open,onOpenChange:pe=>A({...P,open:pe}),children:t.jsxs(ft,{className:"max-w-lg",children:[t.jsxs(mt,{children:[t.jsxs(pt,{className:"flex items-center gap-2",children:[t.jsx(Zd,{className:"w-5 h-5 text-purple-600"}),"Add Plugin Marketplace"]}),t.jsx(Gt,{children:"Add a marketplace from a GitHub repository URL or local path."})]}),t.jsx("div",{className:"space-y-4 py-4",children:t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Repository URL or Path"}),t.jsx(Oe,{value:P.repo,onChange:pe=>A({...P,repo:pe.target.value}),placeholder:"owner/repo or full GitHub URL",className:"mt-1"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400 mt-2",children:"Supported formats:"}),t.jsxs("ul",{className:"text-xs text-gray-500 dark:text-slate-400 mt-1 space-y-1 ml-2",children:[t.jsxs("li",{children:[t.jsx("code",{className:"bg-gray-100 dark:bg-slate-700 px-1 rounded",children:"owner/repo"})," — GitHub shorthand"]}),t.jsxs("li",{children:[t.jsx("code",{className:"bg-gray-100 dark:bg-slate-700 px-1 rounded",children:"https://github.com/owner/repo"})," — Full URL"]}),t.jsxs("li",{children:[t.jsx("code",{className:"bg-gray-100 dark:bg-slate-700 px-1 rounded",children:"/local/path"})," — Local directory"]})]}),t.jsxs("p",{className:"text-xs text-gray-400 dark:text-slate-500 mt-2",children:["Search GitHub for ",t.jsx("code",{className:"bg-gray-100 dark:bg-slate-700 px-1 rounded",children:"claude-plugins"})," to find community marketplaces."]})]})}),t.jsxs(St,{children:[t.jsx(ne,{variant:"ghost",onClick:()=>A({open:!1,repo:""}),children:"Cancel"}),t.jsxs(ne,{onClick:O,className:"bg-purple-600 hover:bg-purple-700 text-white",children:[t.jsx(Rt,{className:"w-4 h-4 mr-2"}),"Add Marketplace"]})]})]})}),t.jsx(vt,{open:E,onOpenChange:M,children:t.jsxs(ft,{className:"max-w-2xl",children:[t.jsxs(mt,{children:[t.jsxs(pt,{className:"flex items-center gap-2",children:[t.jsx(Zd,{className:"w-5 h-5 text-purple-600"}),"Plugin Marketplaces",t.jsx(qe,{variant:"outline",className:"ml-2 font-normal",children:J.length})]}),t.jsx(Gt,{children:"Manage your plugin marketplaces. Add external marketplaces to discover more plugins."})]}),t.jsx("div",{className:"py-4",children:J.length>0?t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:J.map(pe=>{var $e,Ge,et;const _e=((($e=pe.plugins)==null?void 0:$e.length)||0)+(((Ge=pe.externalPlugins)==null?void 0:Ge.length)||0);return t.jsxs("div",{className:"bg-purple-50 dark:bg-purple-950/20 rounded-lg border border-purple-200 dark:border-purple-800 p-4",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("h3",{className:"font-semibold text-purple-900 dark:text-purple-200",children:pe.name}),t.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>K(pe.name),disabled:S===pe.name,className:"h-7 w-7 p-0",children:t.jsx(Dr,{className:`w-4 h-4 text-purple-600 dark:text-purple-400 ${S===pe.name?"animate-spin":""}`})})]}),t.jsx("p",{className:"text-sm text-purple-700 dark:text-purple-300 mb-2 truncate",children:typeof pe.source=="string"?pe.source:((et=pe.source)==null?void 0:et.repo)||"Unknown source"}),t.jsxs("div",{className:"flex items-center justify-between text-xs text-purple-600 dark:text-purple-400",children:[t.jsxs("span",{children:[_e," plugins"]}),pe.lastUpdated&&t.jsxs("span",{children:["Updated: ",new Date(pe.lastUpdated).toLocaleDateString()]})]})]},pe.name)})}):t.jsxs("div",{className:"text-center py-8 text-gray-500 dark:text-slate-400",children:[t.jsx(Zd,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),t.jsx("p",{children:"No marketplaces configured."}),t.jsx("p",{className:"text-sm mt-1",children:"Add a marketplace to discover plugins."})]})}),t.jsxs(St,{children:[t.jsx(ne,{variant:"outline",onClick:()=>M(!1),children:"Close"}),t.jsxs(ne,{onClick:()=>{M(!1),A({open:!0,repo:""})},className:"bg-purple-600 hover:bg-purple-700 text-white",children:[t.jsx(Rt,{className:"w-4 h-4 mr-2"}),"Add Marketplace"]})]})]})}),t.jsx(vt,{open:I.open,onOpenChange:pe=>B({...I,open:pe}),children:t.jsxs(ft,{className:"max-w-lg",children:[t.jsxs(mt,{children:[t.jsxs(pt,{className:"flex items-center gap-2",children:[t.jsx(zb,{className:"w-5 h-5 text-emerald-600"}),"Configure Plugin: ",(ae=I.plugin)==null?void 0:ae.name]}),t.jsx(Gt,{children:"Enable or disable this plugin for specific directories. Child directories inherit parent settings unless overridden."})]}),t.jsxs("div",{className:"space-y-3 py-4 max-h-[400px] overflow-y-auto",children:[(Se=(de=(re=I.plugin)==null?void 0:re.enabledState)==null?void 0:de.perDir)==null?void 0:Se.map((pe,_e)=>{const $e=`${I.plugin.name}@${I.plugin.marketplace}`,Ge=pe.enabled!==null&&pe.enabled!==void 0,et=pe.enabled===!0,Nt=pe.enabled===!1;let ke=null;if(!Ge&&_e>0)for(let me=_e-1;me>=0;me--){const be=I.plugin.enabledState.perDir[me];if(be.enabled!==null&&be.enabled!==void 0){ke=be.enabled;break}}return t.jsxs("div",{className:`flex items-center justify-between p-3 rounded-lg border ${et?"bg-emerald-50 border-emerald-200 dark:bg-emerald-950/30 dark:border-emerald-800":Nt?"bg-red-50 border-red-200 dark:bg-red-950/30 dark:border-red-800":"bg-gray-50 border-gray-200 dark:bg-slate-800/50 dark:border-slate-700"}`,children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("code",{className:"text-sm font-mono text-gray-700 dark:text-slate-300 truncate",children:pe.label}),!Ge&&ke!==null&&t.jsxs(qe,{variant:"outline",className:"text-[10px] text-gray-500",children:["inherited: ",ke?"on":"off"]})]}),Ge&&t.jsx("p",{className:"text-[10px] text-gray-500 dark:text-slate-400 mt-0.5",children:et?"Explicitly enabled":"Explicitly disabled"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[Ge&&t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(ne,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-gray-400 hover:text-gray-600",onClick:()=>F(pe.dir,$e),disabled:U,children:t.jsx(W5,{className:"w-4 h-4"})})}),t.jsx(Ot,{children:t.jsx("p",{children:"Remove override (inherit from parent)"})})]})}),t.jsxs("div",{className:"flex items-center gap-1 border rounded-lg overflow-hidden",children:[t.jsx(ne,{variant:et?"default":"ghost",size:"sm",className:`h-7 px-2 rounded-none ${et?"bg-emerald-600 hover:bg-emerald-700 text-white":""}`,onClick:()=>T(pe.dir,$e,!1),disabled:U||et,children:t.jsx(Ub,{className:"w-3 h-3"})}),t.jsx(ne,{variant:Nt?"default":"ghost",size:"sm",className:`h-7 px-2 rounded-none ${Nt?"bg-red-600 hover:bg-red-700 text-white":""}`,onClick:()=>T(pe.dir,$e,!0),disabled:U||Nt,children:t.jsx(lI,{className:"w-3 h-3"})})]})]})]},pe.dir)}),(!((Ue=(Re=I.plugin)==null?void 0:Re.enabledState)!=null&&Ue.perDir)||I.plugin.enabledState.perDir.length===0)&&t.jsxs("div",{className:"text-center py-8 text-gray-500 dark:text-slate-400",children:[t.jsx(zb,{className:"w-12 h-12 mx-auto mb-3 opacity-30"}),t.jsx("p",{children:"No config hierarchy found."}),t.jsx("p",{className:"text-sm mt-1",children:"Create a .claude/mcps.json in your project first."})]})]}),t.jsx(St,{children:t.jsx(ne,{variant:"ghost",onClick:()=>B({open:!1,plugin:null}),children:"Done"})})]})}),t.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-4 border border-transparent dark:border-slate-800",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white mb-2",children:"CLI Commands (Claude Code)"}),t.jsxs("div",{className:"space-y-1 text-sm text-gray-600 dark:text-slate-400 font-mono",children:[t.jsx("p",{className:"text-gray-400 dark:text-slate-500",children:"# Add marketplace (one-time)"}),t.jsx("p",{children:"claude plugin marketplace add regression-io/coder-config-plugins"}),t.jsx("p",{className:"text-gray-400 dark:text-slate-500 mt-2",children:"# Install plugins from marketplace"}),t.jsx("p",{children:"claude plugin install <name>@coder-config-plugins"}),t.jsx("p",{className:"text-gray-400 dark:text-slate-500 mt-2",children:"# Manage plugins"}),t.jsx("p",{children:"claude plugin list # List installed"}),t.jsx("p",{children:"claude plugin uninstall <name> # Remove plugin"})]})]})]})}const M2=[{name:"red",hex:"#ef4444"},{name:"orange",hex:"#f97316"},{name:"yellow",hex:"#eab308"},{name:"green",hex:"#22c55e"},{name:"cyan",hex:"#06b6d4"},{name:"blue",hex:"#3b82f6"},{name:"purple",hex:"#a855f7"},{name:"pink",hex:"#ec4899"},{name:"gray",hex:"#9ca3af"}];function MW({color:e,size:r="md"}){const s=M2.find(o=>o.name===e);if(!s)return null;const n=r==="sm"?"w-2.5 h-2.5":"w-3.5 h-3.5";return t.jsx("span",{className:`inline-block rounded-full ${n} flex-shrink-0 ring-1 ring-black/10 dark:ring-white/20`,style:{backgroundColor:s.hex},title:`Color: ${e}`})}function IW({value:e,onChange:r}){return t.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[t.jsx("button",{type:"button",onClick:()=>r(null),className:`w-7 h-7 rounded-full border-2 flex items-center justify-center transition-all ${e?"border-gray-300 dark:border-slate-600 hover:border-gray-400":"border-purple-600 dark:border-purple-400"}`,title:"No color",children:t.jsx(Nn,{className:"w-3 h-3 text-gray-400"})}),M2.map(s=>t.jsx("button",{type:"button",onClick:()=>r(s.name),className:`w-7 h-7 rounded-full border-2 transition-all ${e===s.name?"border-gray-900 dark:border-white scale-110":"border-transparent hover:scale-105"}`,style:{backgroundColor:s.hex},title:s.name},s.name))]})}function DW({onWorkstreamChange:e}){var ho,Mn,oa,fo,ti,xs,mo,Or;const{projects:r,fetch:s}=Fx(),{workstreams:n,loading:o,fetch:c,create:d,update:l,delete:u,addProject:f,removeProject:m,countWorkstreamsForProject:h}=MN(),[g,w]=_.useState(null),[j,k]=_.useState(!1),[v,y]=_.useState(null),[x,b]=_.useState(!1),[S,N]=_.useState(null),[P,A]=_.useState(new Set),[E,M]=_.useState(""),[I,B]=_.useState(""),[U,V]=_.useState([]),[Q,z]=_.useState(!1),[H,Y]=_.useState(!1),[K,O]=_.useState({}),[T,F]=_.useState({}),[$,D]=_.useState({}),[X,te]=_.useState({isInstalled:!1,loading:!0}),[fe,J]=_.useState(!1),[W,le]=_.useState(null),[ae,re]=_.useState([]),[de,Se]=_.useState(!1),[Re,Ue]=_.useState(()=>{try{return JSON.parse(localStorage.getItem("dismissedWorkstreamSuggestions")||"[]")}catch{return[]}}),[pe,_e]=_.useState(!1),[$e,Ge]=_.useState(""),[et,Nt]=_.useState([]),[ke,me]=_.useState("llama3.2"),[be,Z]=_.useState(null),[oe,we]=_.useState(""),[Ce,Fe]=_.useState(!1),[He,ct]=_.useState({installed:!1,loading:!0}),[st,zt]=_.useState({workstreamAutoActivate:!0}),[Lr,Vr]=_.useState(!1),[tr,Pr]=_.useState(!1),[qt,Cr]=_.useState(null),[ps,ts]=_.useState("");_.useEffect(()=>{c(),s(),Wt(),lr(),Bs(),at(),Fs()},[c,s]);const Fs=async()=>{try{const ee=await he.getAvailableAITools();ee.success&&ee.tools&&(Nt(ee.tools),ee.tools.find(Xe=>Xe.id==="claude"&&Xe.available)&&Ge("claude"))}catch(ee){console.error("Failed to load AI tools:",ee)}},Bs=async()=>{try{const ee=await he.getCdHookStatus();ct({...ee,loading:!1})}catch(ee){ct({installed:!1,loading:!1,error:ee.message})}},at=async()=>{try{const ee=await he.getWorkstreamSettings();zt(ee.settings||{workstreamAutoActivate:!0})}catch(ee){console.error("Failed to load global settings:",ee)}},Wt=async()=>{try{const ee=await he.getWorkstreamHookStatus();te({...ee,loading:!1})}catch(ee){te({isInstalled:!1,loading:!1,error:ee.message})}},lr=async()=>{try{Se(!0);const[ee,De]=await Promise.all([he.getActivitySummary(),he.getWorkstreamSuggestions()]);le(ee),re(De.suggestions||[])}catch(ee){console.log("Activity data not available:",ee.message)}finally{Se(!1)}},fr=ee=>{M(ee.name),V([...ee.projects]),B(`# Auto-generated workstream based on activity patterns
3044
3044
 
3045
3045
  These projects are frequently worked on together.`),k(!0)},ks=ee=>{V(De=>De.filter(Xe=>Xe!==ee))},Kt=ee=>{U.includes(ee)||V(De=>[...De,ee])},Yt=async ee=>{const De=K[ee];if(!De&&!T[ee]){D(Xe=>({...Xe,[ee]:!0}));try{const Xe=await he.getSubprojects(ee);F(Pt=>({...Pt,[ee]:Xe.subprojects||[]}))}catch(Xe){console.error("Failed to load subprojects:",Xe),F(Pt=>({...Pt,[ee]:[]}))}finally{D(Xe=>({...Xe,[ee]:!1}))}}O(Xe=>({...Xe,[ee]:!De}))},Gr=ee=>{const De=ee.projects.sort().join("|"),Xe=[...Re,De];Ue(Xe),localStorage.setItem("dismissedWorkstreamSuggestions",JSON.stringify(Xe)),re(Pt=>Pt.filter(Ht=>Ht.projects.sort().join("|")!==De)),q.success("Suggestion dismissed")},ht=ae.filter(ee=>{const De=ee.projects.sort().join("|");return!Re.includes(De)}),yr=async()=>{if(confirm("Clear activity data older than 30 days?"))try{const ee=await he.clearActivity(30);ee.success&&(q.success(`Cleared ${ee.cleared} old entries`),lr())}catch(ee){q.error("Failed to clear activity: "+ee.message)}},gs=async(ee,De)=>{var Xe;if(!ee||ee.length===0){q.error("Add projects first to generate rules");return}_e(!0);try{const Pt=$e==="ollama"?{model:ke}:{},Ht=await he.generateWorkstreamRules(ee,$e||!1,Pt);if(Ht.success&&Ht.rules){De(Ht.rules);const At=((Xe=et.find(cr=>cr.id===$e))==null?void 0:Xe.name)||"AI";q.success($e?`Generated rules with ${At}`:"Generated rules from repos")}else q.error(Ht.error||"Failed to generate rules")}catch(Pt){q.error("Failed to generate rules: "+Pt.message)}finally{_e(!1)}},rs=async()=>{J(!0);try{const ee=await he.installWorkstreamHook();ee.success?(q.success(ee.message),te(De=>({...De,isInstalled:!0}))):q.error(ee.error||"Failed to install hook")}catch(ee){q.error("Failed to install hook: "+ee.message)}finally{J(!1)}},rt=async()=>{Vr(!0);try{const ee=await he.installCdHook();ee.success?(q.success("CD hook installed. Restart your shell to activate."),ct(De=>({...De,installed:!0}))):q.error(ee.error||"Failed to install CD hook")}catch(ee){q.error("Failed to install CD hook: "+ee.message)}finally{Vr(!1)}},mn=async()=>{Vr(!0);try{const ee=await he.uninstallCdHook();ee.success?(q.success("CD hook uninstalled. Restart your shell to apply."),ct(De=>({...De,installed:!1}))):q.error(ee.error||"Failed to uninstall CD hook")}catch(ee){q.error("Failed to uninstall CD hook: "+ee.message)}finally{Vr(!1)}},pl=async()=>{const ee=!st.workstreamAutoActivate;try{await he.setGlobalAutoActivate(ee),zt(De=>({...De,workstreamAutoActivate:ee})),q.success(`Auto-activation ${ee?"enabled":"disabled"}`)}catch(De){q.error("Failed to update setting: "+De.message)}},ss=async(ee,De)=>{try{(await he.setWorkstreamAutoActivate(ee.id,De)).success&&(await c(),q.success(`Auto-activate ${De} for ${ee.name}`))}catch(Xe){q.error("Failed to update: "+Xe.message)}},Si=async()=>{if(!(!qt||!ps.trim()))try{(await he.addTriggerFolder(qt.id,ps.trim())).success&&(await c(),q.success("Trigger folder added"),Pr(!1),ts(""),Cr(null))}catch(ee){q.error("Failed to add trigger folder: "+ee.message)}},pn=async(ee,De)=>{try{(await he.removeTriggerFolder(ee.id,De)).success&&(await c(),q.success("Trigger folder removed"))}catch(Xe){q.error("Failed to remove trigger folder: "+Xe.message)}},Ar=()=>c(),co=async()=>{if(!E.trim()){q.error("Name is required");return}z(!0);const ee=await d(E.trim(),U,I);ee.success?(q.success(`Created workstream: ${E}`),k(!1),M(""),B(""),V([]),re(De=>De.filter(Xe=>Xe.name!==E.trim()))):q.error(ee.error||"Failed to create workstream"),z(!1)},ta=async ee=>{if(!confirm(`Delete workstream "${ee.name}"?
3046
3046
 
3047
- This cannot be undone.`))return;const De=await u(ee.id);De.success?q.success(`Deleted workstream: ${ee.name}`):q.error(De.error||"Failed to delete workstream")},ra=async()=>{if(!v)return;z(!0);const ee=await l(v.id,{name:v.name,rules:v.rules,projects:v.projects||[],color:v.color||null});ee.success?(q.success("Workstream updated"),y(null)):q.error(ee.error||"Failed to update workstream"),z(!1)},Ci=ee=>{Z(ee.id),we(ee.rules||"")},sa=()=>{Z(null),we("")},na=async ee=>{Fe(!0);try{const De=await he.updateWorkstream(ee.id,{name:ee.name,rules:oe,projects:ee.projects||[]});De.success?(await c(),q.success("Rules updated"),Z(null),we("")):q.error(De.error||"Failed to update rules")}catch(De){q.error("Failed to update rules: "+De.message)}finally{Fe(!1)}},ia=ee=>{A(De=>{const Xe=new Set(De);return Xe.has(ee)?Xe.delete(ee):Xe.add(ee),Xe})},uo=async()=>{if(!S||P.size===0)return;z(!0);let ee=0,De=null;for(const Xe of P)try{const Pt=await he.addProjectToWorkstream(S.id,Xe);Pt.success&&(De=Pt.workstream,ee++)}catch(Pt){console.error("Failed to add project:",Xe,Pt)}ee>0?(await c(),q.success(`Added ${ee} project${ee>1?"s":""} to ${S.name}`)):q.error("Failed to add projects"),z(!1),b(!1),N(null),A(new Set)},rr=async(ee,De)=>{const Xe=await m(ee.id,De);Xe.success?q.success(`Removed project from ${ee.name}`):q.error(Xe.error||"Failed to remove project")},gl=ee=>ee.split("/").pop()||ee,Qs=(ee,De=null)=>{var Ht,At;const Xe=h(ee),Pt=De?(At=(Ht=n.find(cr=>cr.id===De))==null?void 0:Ht.projects)==null?void 0:At.includes(ee):!1;return Xe===0?null:Xe===1?Pt?null:"in use":"shared"};return o?t.jsx("div",{className:"flex items-center justify-center h-64",children:t.jsx(Qe,{className:"w-8 h-8 animate-spin text-indigo-600"})}):t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-purple-100 dark:bg-purple-900/30 flex items-center justify-center",children:t.jsx(Hn,{className:"w-5 h-5 text-purple-600 dark:text-purple-400"})}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Workstreams"}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:"Context sets for multi-project workflows"})]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs(ne,{variant:"outline",onClick:Ar,size:"sm",children:[t.jsx(Dr,{className:"w-4 h-4 mr-2"}),"Refresh"]}),t.jsxs(ne,{onClick:()=>k(!0),className:"bg-purple-600 hover:bg-purple-700",children:[t.jsx(Rt,{className:"w-4 h-4 mr-2"}),"New Workstream"]})]})]}),t.jsx("div",{className:"bg-purple-50 dark:bg-purple-950/30 border border-purple-200 dark:border-purple-800 rounded-lg p-4 text-sm text-purple-700 dark:text-purple-400",children:t.jsxs("p",{children:[t.jsx("strong",{children:"Workstreams"})," let you group related repos together so Claude sees them as one cohesive project. Perfect for microservices, monorepos, or any multi-repo setup where context matters. Your custom rules and context persist across sessions, and Claude stays scoped to only the directories you specify."]})}),t.jsx("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 shadow-sm overflow-hidden",children:n.length===0?t.jsxs("div",{className:"p-12 text-center",children:[t.jsx(Hn,{className:"w-12 h-12 mx-auto mb-4 text-gray-300 dark:text-slate-600"}),t.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-white mb-2",children:"No Workstreams Yet"}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 mb-4",children:"Create your first workstream to organize multi-project contexts."}),t.jsxs(ne,{onClick:()=>k(!0),children:[t.jsx(Rt,{className:"w-4 h-4 mr-2"}),"Create Your First Workstream"]})]}):t.jsx("div",{className:"divide-y divide-gray-100 dark:divide-slate-800",children:n.map(ee=>{var De,Xe,Pt,Ht;return t.jsxs("div",{className:"group",children:[t.jsxs("div",{className:"p-4 flex items-center gap-4 transition-colors cursor-pointer hover:bg-gray-50 dark:hover:bg-slate-900",onClick:()=>w(g===ee.id?null:ee.id),children:[t.jsx("div",{className:"w-5 h-5 flex items-center justify-center text-gray-400",children:g===ee.id?t.jsx(hr,{className:"w-4 h-4"}):t.jsx(Qr,{className:"w-4 h-4"})}),t.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center bg-gray-100 dark:bg-slate-800",children:t.jsx(Hn,{className:"w-5 h-5 text-gray-500 dark:text-slate-400"})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[ee.color&&t.jsx(RW,{color:ee.color}),t.jsx("h3",{className:"font-medium truncate text-gray-900 dark:text-white",children:ee.name}),((De=ee.projects)==null?void 0:De.length)>0&&t.jsxs("span",{className:"text-xs bg-gray-100 dark:bg-slate-800 text-gray-600 dark:text-slate-400 px-1.5 py-0.5 rounded",children:[ee.projects.length," project",ee.projects.length!==1?"s":""]}),ee.rules&&t.jsxs("span",{className:"text-xs bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400 px-1.5 py-0.5 rounded",children:[t.jsx(vr,{className:"w-3 h-3 inline mr-0.5"}),"Rules"]})]}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 truncate",children:((Xe=ee.projects)==null?void 0:Xe.length)>0?ee.projects.map(At=>gl(At)).join(", "):"No projects added"})]}),t.jsxs("div",{className:"flex items-center gap-2",onClick:At=>At.stopPropagation(),children:[t.jsx(ne,{size:"sm",variant:"ghost",onClick:()=>y({...ee}),className:"text-gray-500 dark:text-slate-400 hover:text-purple-600 dark:hover:text-purple-400",title:"Edit workstream",children:t.jsx(Nm,{className:"w-4 h-4"})}),t.jsx(ne,{size:"sm",variant:"ghost",onClick:()=>ta(ee),className:"text-gray-500 dark:text-slate-400 hover:text-red-600 dark:hover:text-red-400",title:"Delete workstream",children:t.jsx(fs,{className:"w-4 h-4"})})]})]}),g===ee.id&&t.jsxs("div",{className:"px-4 pb-4 pl-16 space-y-4 bg-gray-50/50 dark:bg-slate-900/50",children:[t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Projects"}),t.jsxs(ne,{size:"sm",variant:"outline",onClick:()=>{N(ee),b(!0)},children:[t.jsx(fi,{className:"w-4 h-4 mr-1"}),"Add Project"]})]}),((Pt=ee.projects)==null?void 0:Pt.length)>0?t.jsx("div",{className:"space-y-1",children:ee.projects.map(At=>t.jsxs("div",{className:"flex items-center justify-between py-1.5 px-3 bg-white dark:bg-slate-800 rounded border border-gray-200 dark:border-slate-700",children:[t.jsx("span",{className:"text-sm font-mono text-gray-700 dark:text-slate-300 truncate",children:At.replace(/^\/Users\/[^/]+/,"~")}),t.jsx(ne,{size:"sm",variant:"ghost",onClick:()=>rr(ee,At),className:"text-gray-400 hover:text-red-500 h-6 w-6 p-0",children:t.jsx(Hb,{className:"w-4 h-4"})})]},At))}):t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 italic",children:"No projects added yet. Add projects to help organize your workstream."})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Trigger Folders"}),t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(Va,{className:"w-3.5 h-3.5 text-gray-400"})}),t.jsx(Ot,{children:t.jsx("p",{className:"max-w-xs text-xs",children:"Additional folders that activate this workstream when you cd into them. Projects are always trigger folders automatically."})})]})})]}),t.jsxs(ne,{size:"sm",variant:"outline",onClick:()=>{Cr(ee),Pr(!0)},children:[t.jsx(fi,{className:"w-4 h-4 mr-1"}),"Add Folder"]})]}),((Ht=ee.triggerFolders)==null?void 0:Ht.length)>0?t.jsx("div",{className:"space-y-1",children:ee.triggerFolders.map(At=>t.jsxs("div",{className:"flex items-center justify-between py-1.5 px-3 bg-white dark:bg-slate-800 rounded border border-gray-200 dark:border-slate-700",children:[t.jsx("span",{className:"text-sm font-mono text-gray-700 dark:text-slate-300 truncate",children:At.replace(/^\/Users\/[^/]+/,"~")}),t.jsx(ne,{size:"sm",variant:"ghost",onClick:()=>pn(ee,At),className:"text-gray-400 hover:text-red-500 h-6 w-6 p-0",children:t.jsx(Hb,{className:"w-4 h-4"})})]},At))}):t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 italic",children:"No extra trigger folders. Projects auto-trigger this workstream."})]}),t.jsxs("div",{className:"flex items-center justify-between py-2 px-3 bg-white dark:bg-slate-800 rounded border border-gray-200 dark:border-slate-700",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Yi,{className:"w-4 h-4 text-amber-500"}),t.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Auto-Activate on cd"})]}),t.jsxs(En,{children:[t.jsx(Pn,{asChild:!0,children:t.jsxs(ne,{variant:"outline",size:"sm",children:[ee.autoActivate===!0?"On":ee.autoActivate===!1?"Off":"Default",t.jsx(hr,{className:"w-3 h-3 ml-1"})]})}),t.jsxs(hn,{align:"end",children:[t.jsxs(jt,{onClick:()=>ss(ee,"on"),children:[t.jsx(It,{className:`w-4 h-4 mr-2 ${ee.autoActivate===!0?"opacity-100":"opacity-0"}`}),"On"]}),t.jsxs(jt,{onClick:()=>ss(ee,"off"),children:[t.jsx(It,{className:`w-4 h-4 mr-2 ${ee.autoActivate===!1?"opacity-100":"opacity-0"}`}),"Off"]}),t.jsxs(jt,{onClick:()=>ss(ee,"default"),children:[t.jsx(It,{className:`w-4 h-4 mr-2 ${ee.autoActivate===void 0?"opacity-100":"opacity-0"}`}),"Default (",st.workstreamAutoActivate?"On":"Off",")"]})]})]})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Rules"}),be===ee.id?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(ne,{size:"sm",variant:"ghost",onClick:sa,disabled:Ce,className:"text-gray-500 dark:text-slate-400 h-7",children:[t.jsx(Nn,{className:"w-4 h-4 mr-1"}),"Cancel"]}),t.jsxs(ne,{size:"sm",onClick:()=>na(ee),disabled:Ce,className:"bg-purple-600 hover:bg-purple-700 h-7",children:[Ce?t.jsx(Qe,{className:"w-4 h-4 animate-spin mr-1"}):t.jsx(Zr,{className:"w-4 h-4 mr-1"}),"Save"]})]}):t.jsxs(ne,{size:"sm",variant:"ghost",onClick:()=>Ci(ee),className:"text-gray-500 dark:text-slate-400 hover:text-purple-600 dark:hover:text-purple-400 h-7",children:[t.jsx(Nm,{className:"w-4 h-4 mr-1"}),"Edit"]})]}),be===ee.id?t.jsx(yt,{value:oe,onChange:At=>we(At.target.value),placeholder:"Context rules for this workstream. These will be injected into every Claude session when this workstream is active.",rows:8,className:"font-mono text-sm",autoFocus:!0}):ee.rules?t.jsx("pre",{className:"text-sm text-gray-600 dark:text-slate-400 bg-white dark:bg-slate-800 rounded border border-gray-200 dark:border-slate-700 p-3 overflow-auto max-h-40 whitespace-pre-wrap cursor-pointer hover:border-purple-300 dark:hover:border-purple-700 transition-colors",onClick:()=>Ci(ee),title:"Click to edit",children:ee.rules}):t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 italic cursor-pointer hover:text-purple-600 dark:hover:text-purple-400 transition-colors",onClick:()=>Ci(ee),children:"No rules defined. Click to add context rules for this workstream."})]})]})]},ee.id)})})}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("h3",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Hook Integration"}),t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx("button",{className:"text-gray-400 hover:text-gray-600 dark:hover:text-slate-300",children:t.jsx(Va,{className:"w-4 h-4"})})}),t.jsx(Ot,{side:"right",className:"max-w-xs",children:t.jsxs("p",{className:"text-sm",children:[t.jsx("strong",{children:"What are hooks?"}),t.jsx("br",{}),t.jsx("br",{}),"Hooks are scripts that run automatically at specific points in Claude Code sessions. The workstream hook runs before each prompt and injects your active workstream's rules into the context.",t.jsx("br",{}),t.jsx("br",{}),t.jsx("strong",{children:"How it works:"}),t.jsx("br",{}),"1. You activate a workstream",t.jsx("br",{}),"2. Hook detects the active workstream",t.jsx("br",{}),"3. Rules are prepended to Claude's context",t.jsx("br",{}),"4. Claude understands your project context"]})})]})})]}),X.isInstalled?t.jsx("div",{className:"bg-green-50 dark:bg-green-950/30 border border-green-200 dark:border-green-800 rounded-lg p-4 text-sm text-green-700 dark:text-green-400",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(vi,{className:"w-5 h-5 flex-shrink-0"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium",children:"Hook Installed"}),t.jsx("p",{className:"text-green-600 dark:text-green-500",children:"Workstream rules will be automatically injected into every Claude session."})]})]})}):t.jsx("div",{className:"bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800 rounded-lg p-4 text-sm text-amber-700 dark:text-amber-400",children:t.jsxs("div",{className:"flex gap-3",children:[t.jsx(Is,{className:"w-5 h-5 flex-shrink-0 mt-0.5"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("p",{className:"font-medium mb-1",children:"Hook Not Installed"}),t.jsx("p",{className:"mb-3",children:"Install the pre-prompt hook to automatically inject workstream rules into every Claude session."}),t.jsxs(ne,{onClick:rs,disabled:fe||X.loading,size:"sm",className:"bg-amber-600 hover:bg-amber-700 text-white",children:[fe?t.jsx(Qe,{className:"w-4 h-4 animate-spin mr-2"}):t.jsx(yi,{className:"w-4 h-4 mr-2"}),"Install Hook"]}),t.jsxs("p",{className:"text-xs mt-2 text-amber-600 dark:text-amber-500",children:["Creates ",t.jsx("code",{className:"bg-amber-100 dark:bg-amber-900/50 px-1 rounded",children:"~/.claude/hooks/pre-prompt.sh"})]})]})]})})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("h3",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Folder Auto-Activation"}),t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(Va,{className:"w-4 h-4 text-gray-400"})}),t.jsxs(Ot,{className:"max-w-sm",children:[t.jsx("p",{className:"text-sm mb-2",children:t.jsx("strong",{children:"How it works:"})}),t.jsxs("ol",{className:"text-xs space-y-1 list-decimal list-inside",children:[t.jsx("li",{children:"Install the CD hook to your shell"}),t.jsxs("li",{children:["When you ",t.jsx("code",{className:"bg-slate-700 px-1 rounded",children:"cd"})," into a folder matching a workstream, it auto-activates"]}),t.jsx("li",{children:"If multiple workstreams match, you'll be prompted to choose"})]})]})]})})]}),t.jsxs("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 shadow-sm p-4",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4 pb-4 border-b border-gray-200 dark:border-slate-800",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Yi,{className:"w-4 h-4 text-amber-500"}),t.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Global Auto-Activate"}),t.jsx("span",{className:"text-xs text-gray-500 dark:text-slate-400",children:"(default for all workstreams)"})]}),t.jsx(ne,{variant:st.workstreamAutoActivate?"default":"outline",size:"sm",onClick:pl,children:st.workstreamAutoActivate?"Enabled":"Disabled"})]}),He.installed?t.jsxs("div",{className:"flex items-start gap-3 p-3 bg-green-50 dark:bg-green-900/20 rounded-lg border border-green-200 dark:border-green-800",children:[t.jsx(vi,{className:"w-5 h-5 text-green-600 dark:text-green-400 flex-shrink-0 mt-0.5"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("p",{className:"font-medium text-green-800 dark:text-green-300",children:"CD Hook Installed"}),t.jsxs("p",{className:"text-xs text-green-600 dark:text-green-400 mt-1",children:["Shell: ",He.shell," • RC file: ",t.jsx("code",{className:"bg-green-100 dark:bg-green-900/50 px-1 rounded",children:(ho=He.rcFile)==null?void 0:ho.replace(/^\/Users\/[^/]+/,"~")})]}),t.jsxs(ne,{variant:"outline",size:"sm",className:"mt-2",onClick:mn,disabled:Lr,children:[Lr?t.jsx(Qe,{className:"w-4 h-4 animate-spin mr-2"}):null,"Uninstall"]})]})]}):t.jsxs("div",{className:"flex items-start gap-3 p-3 bg-amber-50 dark:bg-amber-900/20 rounded-lg border border-amber-200 dark:border-amber-800",children:[t.jsx(Is,{className:"w-5 h-5 text-amber-600 dark:text-amber-400 flex-shrink-0 mt-0.5"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium text-amber-800 dark:text-amber-300 mb-1",children:"CD Hook Not Installed"}),t.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400 mb-2",children:"Install the hook to auto-activate workstreams when you cd into matching folders."}),t.jsxs(ne,{variant:"default",size:"sm",onClick:rt,disabled:Lr||He.loading,className:"bg-amber-600 hover:bg-amber-700 text-white",children:[Lr?t.jsx(Qe,{className:"w-4 h-4 animate-spin mr-2"}):t.jsx(yi,{className:"w-4 h-4 mr-2"}),"Install CD Hook"]}),t.jsxs("p",{className:"text-xs mt-2 text-amber-600 dark:text-amber-500",children:["Adds function to ",t.jsx("code",{className:"bg-amber-100 dark:bg-amber-900/50 px-1 rounded",children:"~/.zshrc"})," or ",t.jsx("code",{className:"bg-amber-100 dark:bg-amber-900/50 px-1 rounded",children:"~/.bashrc"})]})]})]})]})]}),W&&W.totalSessions>0&&t.jsxs("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 shadow-sm p-4",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(NM,{className:"w-5 h-5 text-indigo-600 dark:text-indigo-400"}),t.jsx("h3",{className:"font-medium text-gray-900 dark:text-white",children:"Activity Insights"})]}),t.jsxs(ne,{variant:"ghost",size:"sm",onClick:yr,className:"text-gray-500 dark:text-slate-400 hover:text-red-500",children:[t.jsx(fs,{className:"w-4 h-4 mr-1"}),"Clear Old"]})]}),t.jsxs("div",{className:"grid grid-cols-3 gap-4 mb-4",children:[t.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-3",children:[t.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-slate-400 text-xs mb-1",children:[t.jsx(mS,{className:"w-3 h-3"}),"Sessions"]}),t.jsx("div",{className:"text-2xl font-semibold text-gray-900 dark:text-white",children:W.totalSessions})]}),t.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-3",children:[t.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-slate-400 text-xs mb-1",children:[t.jsx(vr,{className:"w-3 h-3"}),"Files Tracked"]}),t.jsx("div",{className:"text-2xl font-semibold text-gray-900 dark:text-white",children:W.totalFiles})]}),t.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-3",children:[t.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-slate-400 text-xs mb-1",children:[t.jsx(Hn,{className:"w-3 h-3"}),"Projects Active"]}),t.jsx("div",{className:"text-2xl font-semibold text-gray-900 dark:text-white",children:W.projectCount})]})]}),((Mn=W.topProjects)==null?void 0:Mn.length)>0&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-slate-300 mb-2",children:"Most Active Projects"}),t.jsx("div",{className:"space-y-1",children:W.topProjects.slice(0,5).map((ee,De)=>t.jsxs("div",{className:"flex items-center justify-between text-sm",children:[t.jsx("span",{className:"text-gray-600 dark:text-slate-400 truncate",title:ee.path,children:ee.path.split("/").pop()}),t.jsxs("span",{className:"text-gray-400 dark:text-slate-500 text-xs",children:[ee.fileCount," files"]})]},ee.path))})]})]}),ht.length>0&&t.jsxs("div",{className:"bg-gradient-to-r from-indigo-50 to-purple-50 dark:from-indigo-950/30 dark:to-purple-950/30 rounded-xl border border-indigo-200 dark:border-indigo-800 p-4",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[t.jsx(Vt,{className:"w-5 h-5 text-indigo-600 dark:text-indigo-400"}),t.jsx("h3",{className:"font-medium text-indigo-900 dark:text-indigo-300",children:"Suggested Workstreams"}),t.jsx("span",{className:"text-xs bg-indigo-100 dark:bg-indigo-900/50 text-indigo-600 dark:text-indigo-400 px-1.5 py-0.5 rounded",children:"Based on activity patterns"})]}),t.jsx("p",{className:"text-sm text-indigo-700 dark:text-indigo-400 mb-4",children:"These projects are frequently worked on together. Create a workstream to group them?"}),t.jsx("div",{className:"space-y-3",children:ht.map(ee=>t.jsxs("div",{className:"bg-white dark:bg-slate-900 rounded-lg border border-indigo-200 dark:border-indigo-800 p-3",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Yi,{className:"w-4 h-4 text-amber-500"}),t.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:ee.name}),ee.coActivityScore&&t.jsxs("span",{className:"text-xs text-gray-500 dark:text-slate-400",children:[ee.coActivityScore,"% co-activity"]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ne,{size:"sm",variant:"ghost",onClick:()=>Gr(ee),className:"text-gray-400 hover:text-gray-600 dark:hover:text-slate-300",title:"Dismiss suggestion",children:t.jsx(Nn,{className:"w-4 h-4"})}),t.jsxs(ne,{size:"sm",onClick:()=>fr(ee),className:"bg-indigo-600 hover:bg-indigo-700",children:[t.jsx(Rt,{className:"w-4 h-4 mr-1"}),"Create"]})]})]}),t.jsx("div",{className:"flex flex-wrap gap-1",children:ee.projects.map(De=>t.jsx("span",{className:"text-xs bg-gray-100 dark:bg-slate-800 text-gray-600 dark:text-slate-400 px-2 py-0.5 rounded",children:De.split("/").pop()},De))})]},ee.name))})]}),t.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-4 border border-transparent dark:border-slate-800",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white mb-2",children:"CLI Commands"}),t.jsxs("div",{className:"space-y-1 text-sm text-gray-600 dark:text-slate-400 font-mono",children:[t.jsx("p",{children:"coder-config workstream # List workstreams"}),t.jsx("p",{children:'coder-config workstream use "Name" # Set workstream for this tab'}),t.jsx("p",{children:'coder-config workstream create "Name" # Create workstream'})]})]}),t.jsx(vt,{open:j,onOpenChange:ee=>{ee||(k(!1),M(""),B(""),V([]),Y(!1),O({}))},children:t.jsxs(ft,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[t.jsx(mt,{children:t.jsxs(pt,{className:"flex items-center gap-2",children:[t.jsx(Hn,{className:"w-5 h-5 text-purple-600"}),"Create Workstream"]})}),t.jsxs("div",{className:"space-y-4 py-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300 mb-1 block",children:"Name"}),t.jsx(Oe,{value:E,onChange:ee=>M(ee.target.value),placeholder:"e.g., User Auth, Admin Dashboard",autoFocus:!0})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Projects"}),t.jsxs(ne,{type:"button",size:"sm",variant:"outline",onClick:()=>Y(!H),children:[t.jsx(fi,{className:"w-4 h-4 mr-1"}),"Add"]})]}),U.length>0?t.jsx("div",{className:"space-y-1 mb-2",children:U.map(ee=>t.jsxs("div",{className:"flex items-center justify-between py-1.5 px-3 bg-gray-50 dark:bg-slate-800 rounded border border-gray-200 dark:border-slate-700",children:[t.jsx("span",{className:"text-sm font-mono text-gray-700 dark:text-slate-300 truncate",children:ee.replace(/^\/Users\/[^/]+/,"~")}),t.jsx(ne,{type:"button",size:"sm",variant:"ghost",onClick:()=>ks(ee),className:"text-gray-400 hover:text-red-500 h-6 w-6 p-0",children:t.jsx(Nn,{className:"w-4 h-4"})})]},ee))}):t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 italic mb-2",children:"No projects added. Add projects to help organize your workstream."}),H&&r.length>0&&t.jsx("div",{className:"border border-gray-200 dark:border-slate-700 rounded-lg p-2 max-h-64 overflow-y-auto bg-white dark:bg-slate-900",children:r.map(ee=>{const De=Qs(ee.path),Xe=K[ee.path],Pt=$[ee.path],Ht=T[ee.path]||[],At=U.includes(ee.path);return t.jsxs("div",{className:"mb-1",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{type:"button",onClick:()=>Yt(ee.path),className:"p-1 hover:bg-gray-100 dark:hover:bg-slate-800 rounded",title:"Show sub-projects",children:Pt?t.jsx(Qe,{className:"w-4 h-4 animate-spin text-gray-400"}):Xe?t.jsx(hr,{className:"w-4 h-4 text-gray-400"}):t.jsx(Qr,{className:"w-4 h-4 text-gray-400"})}),t.jsxs("button",{type:"button",onClick:()=>Kt(ee.path),disabled:At,className:`flex-1 text-left p-2 rounded transition-colors ${At?"bg-purple-50 dark:bg-purple-950/30 opacity-50":"hover:bg-purple-50 dark:hover:bg-purple-950/30"}`,children:[t.jsxs("div",{className:"flex items-center justify-between text-sm",children:[t.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:ee.name}),t.jsxs("div",{className:"flex items-center gap-1",children:[De&&t.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${De==="shared"?"bg-amber-100 dark:bg-amber-900/50 text-amber-700 dark:text-amber-400":"bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-400"}`,children:De}),At&&t.jsx(It,{className:"w-4 h-4 text-purple-600"})]})]}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400 font-mono truncate",children:ee.path.replace(/^\/Users\/[^/]+/,"~")})]})]}),Xe&&Ht.length>0&&t.jsx("div",{className:"ml-6 mt-1 space-y-1 border-l-2 border-gray-200 dark:border-slate-700 pl-2",children:Ht.map(cr=>{const jr=U.includes(cr.dir),_r=Qs(cr.dir);return t.jsxs("button",{type:"button",onClick:()=>Kt(cr.dir),disabled:jr,className:`w-full text-left p-2 rounded transition-colors ${jr?"bg-purple-50 dark:bg-purple-950/30 opacity-50":"hover:bg-purple-50 dark:hover:bg-purple-950/30"}`,children:[t.jsxs("div",{className:"flex items-center justify-between text-sm",children:[t.jsx("span",{className:"text-gray-700 dark:text-slate-300",children:cr.name}),t.jsxs("div",{className:"flex items-center gap-1",children:[_r&&t.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${_r==="shared"?"bg-amber-100 dark:bg-amber-900/50 text-amber-700 dark:text-amber-400":"bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-400"}`,children:_r}),jr&&t.jsx(It,{className:"w-4 h-4 text-purple-600"})]})]}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400 font-mono",children:cr.relativePath})]},cr.dir)})}),Xe&&Ht.length===0&&!Pt&&t.jsx("div",{className:"ml-6 mt-1 pl-2 text-xs text-gray-400 dark:text-slate-500 italic",children:"No sub-projects found"})]},ee.id)})})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Context (optional)"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(En,{children:[t.jsx(Pn,{asChild:!0,children:t.jsxs(ne,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",children:[t.jsx(Vt,{className:"w-3 h-3"}),$e?((oa=et.find(ee=>ee.id===$e))==null?void 0:oa.name)||$e:"Basic",t.jsx(hr,{className:"w-3 h-3"})]})}),t.jsxs(hn,{align:"end",children:[t.jsx(jt,{onClick:()=>Ge(""),children:t.jsx("span",{className:"text-xs",children:"Basic (no AI)"})}),et.filter(ee=>ee.available).map(ee=>t.jsxs(jt,{onClick:()=>Ge(ee.id),children:[t.jsx("span",{className:"text-xs",children:ee.name}),ee.id===$e&&t.jsx(It,{className:"w-3 h-3 ml-2"})]},ee.id)),et.filter(ee=>!ee.available).length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-2 py-1 text-xs text-gray-400",children:"Not installed:"}),et.filter(ee=>!ee.available).map(ee=>t.jsx(jt,{disabled:!0,className:"text-gray-400",children:t.jsx("span",{className:"text-xs",children:ee.name})},ee.id))]})]})]}),$e==="ollama"&&t.jsx(Oe,{value:ke,onChange:ee=>me(ee.target.value),placeholder:"Model",className:"h-7 w-24 text-xs"}),t.jsxs(ne,{type:"button",size:"sm",variant:"ghost",onClick:()=>gs(U,B),disabled:pe||U.length===0,className:"text-xs h-7 text-purple-600 hover:text-purple-700 hover:bg-purple-50 dark:hover:bg-purple-950/30",title:$e?`Generate with ${(fo=et.find(ee=>ee.id===$e))==null?void 0:fo.name}`:"Extract from README, package.json, etc.",children:[pe?t.jsx(Qe,{className:"w-3 h-3 animate-spin mr-1"}):t.jsx(Wr,{className:"w-3 h-3 mr-1"}),"Generate"]})]})]}),t.jsx(yt,{value:I,onChange:ee=>B(ee.target.value),placeholder:"Context rules for this workstream. These will be injected into every Claude session when this workstream is active.",rows:6}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400 mt-1",children:'Example: "Focus on user authentication. Use JWT tokens. React Query for state management."'})]})]}),t.jsxs(St,{children:[t.jsx(ne,{variant:"outline",onClick:()=>{k(!1),M(""),B(""),V([]),Y(!1),O({})},children:"Cancel"}),t.jsxs(ne,{onClick:co,disabled:Q||!E.trim(),className:"bg-purple-600 hover:bg-purple-700",children:[Q?t.jsx(Qe,{className:"w-4 h-4 animate-spin mr-2"}):t.jsx(Rt,{className:"w-4 h-4 mr-2"}),"Create"]})]})]})}),t.jsx(vt,{open:!!v,onOpenChange:ee=>!ee&&y(null),children:t.jsxs(ft,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[t.jsx(mt,{children:t.jsxs(pt,{className:"flex items-center gap-2",children:[t.jsx(Nm,{className:"w-5 h-5 text-purple-600"}),"Edit Workstream"]})}),v&&t.jsxs("div",{className:"space-y-4 py-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300 mb-1 block",children:"Name"}),t.jsx(Oe,{value:v.name,onChange:ee=>y(De=>({...De,name:ee.target.value}))})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300 mb-1.5 block",children:"Color"}),t.jsx(MW,{value:v.color||null,onChange:ee=>y(De=>({...De,color:ee}))}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400 mt-1.5",children:"Shown in the list and the Full statusline (when active)."})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Projects"}),t.jsxs(ne,{type:"button",size:"sm",variant:"outline",onClick:()=>y(ee=>({...ee,showPicker:!ee.showPicker})),children:[t.jsx(fi,{className:"w-4 h-4 mr-1"}),"Add"]})]}),((ti=v.projects)==null?void 0:ti.length)>0?t.jsx("div",{className:"space-y-1 mb-2",children:v.projects.map(ee=>t.jsxs("div",{className:"flex items-center justify-between py-1.5 px-3 bg-gray-50 dark:bg-slate-800 rounded border border-gray-200 dark:border-slate-700",children:[t.jsx("span",{className:"text-sm font-mono text-gray-700 dark:text-slate-300 truncate",children:ee.replace(/^\/Users\/[^/]+/,"~")}),t.jsx(ne,{type:"button",size:"sm",variant:"ghost",onClick:()=>y(De=>({...De,projects:De.projects.filter(Xe=>Xe!==ee)})),className:"text-gray-400 hover:text-red-500 h-6 w-6 p-0",children:t.jsx(Nn,{className:"w-4 h-4"})})]},ee))}):t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 italic mb-2",children:"No projects in this workstream."}),v.showPicker&&r.length>0&&t.jsx("div",{className:"border border-gray-200 dark:border-slate-700 rounded-lg p-2 max-h-48 overflow-y-auto bg-white dark:bg-slate-900",children:r.map(ee=>{var cr;const De=(cr=v.projects)==null?void 0:cr.includes(ee.path),Xe=Qs(ee.path,v.id),Pt=K[ee.path],Ht=$[ee.path],At=T[ee.path]||[];return t.jsxs("div",{className:"mb-1",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{type:"button",onClick:()=>Yt(ee.path),className:"p-1 hover:bg-gray-100 dark:hover:bg-slate-800 rounded",title:"Show sub-projects",children:Ht?t.jsx(Qe,{className:"w-4 h-4 animate-spin text-gray-400"}):Pt?t.jsx(hr,{className:"w-4 h-4 text-gray-400"}):t.jsx(Qr,{className:"w-4 h-4 text-gray-400"})}),t.jsxs("button",{type:"button",onClick:()=>!De&&y(jr=>({...jr,projects:[...jr.projects||[],ee.path]})),disabled:De,className:`flex-1 text-left p-2 rounded transition-colors ${De?"bg-purple-50 dark:bg-purple-950/30 opacity-50":"hover:bg-purple-50 dark:hover:bg-purple-950/30"}`,children:[t.jsxs("div",{className:"flex items-center justify-between text-sm",children:[t.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:ee.name}),t.jsxs("div",{className:"flex items-center gap-1",children:[Xe&&t.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${Xe==="shared"?"bg-amber-100 dark:bg-amber-900/50 text-amber-700 dark:text-amber-400":"bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-400"}`,children:Xe}),De&&t.jsx(It,{className:"w-4 h-4 text-purple-600"})]})]}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400 font-mono truncate",children:ee.path.replace(/^\/Users\/[^/]+/,"~")})]})]}),Pt&&At.length>0&&t.jsx("div",{className:"ml-6 mt-1 space-y-1 border-l-2 border-gray-200 dark:border-slate-700 pl-2",children:At.map(jr=>{var Ss;const _r=(Ss=v.projects)==null?void 0:Ss.includes(jr.dir),ns=Qs(jr.dir,v.id);return t.jsxs("button",{type:"button",onClick:()=>!_r&&y(Zs=>({...Zs,projects:[...Zs.projects||[],jr.dir]})),disabled:_r,className:`w-full text-left p-2 rounded transition-colors ${_r?"bg-purple-50 dark:bg-purple-950/30 opacity-50":"hover:bg-purple-50 dark:hover:bg-purple-950/30"}`,children:[t.jsxs("div",{className:"flex items-center justify-between text-sm",children:[t.jsx("span",{className:"text-gray-700 dark:text-slate-300",children:jr.name}),t.jsxs("div",{className:"flex items-center gap-1",children:[ns&&t.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${ns==="shared"?"bg-amber-100 dark:bg-amber-900/50 text-amber-700 dark:text-amber-400":"bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-400"}`,children:ns}),_r&&t.jsx(It,{className:"w-4 h-4 text-purple-600"})]})]}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400 font-mono truncate",children:jr.relativePath})]},jr.dir)})}),Pt&&At.length===0&&!Ht&&t.jsx("div",{className:"ml-6 mt-1 pl-2 text-xs text-gray-400 dark:text-slate-500 italic",children:"No sub-projects found"})]},ee.id)})})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Rules"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(En,{children:[t.jsx(Pn,{asChild:!0,children:t.jsxs(ne,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",children:[t.jsx(Vt,{className:"w-3 h-3"}),$e?((xs=et.find(ee=>ee.id===$e))==null?void 0:xs.name)||$e:"Basic",t.jsx(hr,{className:"w-3 h-3"})]})}),t.jsxs(hn,{align:"end",children:[t.jsx(jt,{onClick:()=>Ge(""),children:t.jsx("span",{className:"text-xs",children:"Basic (no AI)"})}),et.filter(ee=>ee.available).map(ee=>t.jsxs(jt,{onClick:()=>Ge(ee.id),children:[t.jsx("span",{className:"text-xs",children:ee.name}),ee.id===$e&&t.jsx(It,{className:"w-3 h-3 ml-2"})]},ee.id)),et.filter(ee=>!ee.available).length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-2 py-1 text-xs text-gray-400",children:"Not installed:"}),et.filter(ee=>!ee.available).map(ee=>t.jsx(jt,{disabled:!0,className:"text-gray-400",children:t.jsx("span",{className:"text-xs",children:ee.name})},ee.id))]})]})]}),$e==="ollama"&&t.jsx(Oe,{value:ke,onChange:ee=>me(ee.target.value),placeholder:"Model",className:"h-7 w-24 text-xs"}),t.jsxs(ne,{type:"button",size:"sm",variant:"ghost",onClick:()=>gs(v.projects,ee=>y(De=>({...De,rules:ee}))),disabled:pe||!((mo=v.projects)!=null&&mo.length),className:"text-xs h-7 text-purple-600 hover:text-purple-700 hover:bg-purple-50 dark:hover:bg-purple-950/30",title:$e?`Generate with ${(Or=et.find(ee=>ee.id===$e))==null?void 0:Or.name}`:"Extract from README, package.json, etc.",children:[pe?t.jsx(Qe,{className:"w-3 h-3 animate-spin mr-1"}):t.jsx(Wr,{className:"w-3 h-3 mr-1"}),"Generate"]})]})]}),t.jsx(yt,{value:v.rules||"",onChange:ee=>y(De=>({...De,rules:ee.target.value})),placeholder:"Context rules for this workstream...",rows:8})]})]}),t.jsxs(St,{children:[t.jsx(ne,{variant:"outline",onClick:()=>y(null),children:"Cancel"}),t.jsxs(ne,{onClick:ra,disabled:Q,className:"bg-purple-600 hover:bg-purple-700",children:[Q?t.jsx(Qe,{className:"w-4 h-4 animate-spin mr-2"}):t.jsx(Zr,{className:"w-4 h-4 mr-2"}),"Save Changes"]})]})]})}),t.jsx(vt,{open:x,onOpenChange:ee=>{b(ee),ee||(O({}),A(new Set))},children:t.jsxs(ft,{className:"max-w-lg",children:[t.jsx(mt,{children:t.jsxs(pt,{className:"flex items-center gap-2",children:[t.jsx(fi,{className:"w-5 h-5 text-purple-600"}),"Add Project to ",S==null?void 0:S.name]})}),t.jsxs("div",{className:"py-4",children:[t.jsx("p",{className:"text-sm text-gray-600 dark:text-slate-400 mb-4",children:"Select projects to add to this workstream (multi-select enabled):"}),r.length>0?t.jsx("div",{className:"space-y-1 max-h-64 overflow-y-auto border border-gray-200 dark:border-slate-700 rounded-lg p-2 bg-white dark:bg-slate-900",children:r.map(ee=>{var jr;const De=(jr=S==null?void 0:S.projects)==null?void 0:jr.includes(ee.path),Xe=P.has(ee.path),Pt=Qs(ee.path,S==null?void 0:S.id),Ht=K[ee.path],At=$[ee.path],cr=T[ee.path]||[];return t.jsxs("div",{className:"mb-1",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{type:"button",onClick:()=>Yt(ee.path),className:"p-1 hover:bg-gray-100 dark:hover:bg-slate-800 rounded",title:"Show sub-projects",children:At?t.jsx(Qe,{className:"w-4 h-4 animate-spin text-gray-400"}):Ht?t.jsx(hr,{className:"w-4 h-4 text-gray-400"}):t.jsx(Qr,{className:"w-4 h-4 text-gray-400"})}),t.jsxs("button",{type:"button",onClick:()=>!De&&ia(ee.path),disabled:De,className:`flex-1 text-left p-2 rounded transition-colors ${De?"bg-gray-100 dark:bg-slate-800 opacity-50 cursor-not-allowed":Xe?"bg-purple-100 dark:bg-purple-950/50 ring-2 ring-purple-500":"hover:bg-purple-50 dark:hover:bg-purple-950/30"}`,children:[t.jsxs("div",{className:"flex items-center justify-between text-sm",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:`w-4 h-4 rounded border-2 flex items-center justify-center ${De?"bg-gray-300 dark:bg-slate-600 border-gray-300 dark:border-slate-600":Xe?"bg-purple-600 border-purple-600":"border-gray-300 dark:border-slate-600"}`,children:(De||Xe)&&t.jsx(It,{className:"w-3 h-3 text-white"})}),t.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:ee.name})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[Pt&&t.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${Pt==="shared"?"bg-amber-100 dark:bg-amber-900/50 text-amber-700 dark:text-amber-400":"bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-400"}`,children:Pt}),De&&t.jsx("span",{className:"text-xs text-gray-500 dark:text-slate-400",children:"added"})]})]}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400 font-mono truncate ml-6",children:ee.path.replace(/^\/Users\/[^/]+/,"~")})]})]}),Ht&&cr.length>0&&t.jsx("div",{className:"ml-6 mt-1 space-y-1 border-l-2 border-gray-200 dark:border-slate-700 pl-2",children:cr.map(_r=>{var In;const ns=(In=S==null?void 0:S.projects)==null?void 0:In.includes(_r.dir),Ss=P.has(_r.dir),Zs=Qs(_r.dir,S==null?void 0:S.id);return t.jsxs("button",{type:"button",onClick:()=>!ns&&ia(_r.dir),disabled:ns,className:`w-full text-left p-2 rounded transition-colors ${ns?"bg-gray-100 dark:bg-slate-800 opacity-50 cursor-not-allowed":Ss?"bg-purple-100 dark:bg-purple-950/50 ring-2 ring-purple-500":"hover:bg-purple-50 dark:hover:bg-purple-950/30"}`,children:[t.jsxs("div",{className:"flex items-center justify-between text-sm",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:`w-4 h-4 rounded border-2 flex items-center justify-center ${ns?"bg-gray-300 dark:bg-slate-600 border-gray-300 dark:border-slate-600":Ss?"bg-purple-600 border-purple-600":"border-gray-300 dark:border-slate-600"}`,children:(ns||Ss)&&t.jsx(It,{className:"w-3 h-3 text-white"})}),t.jsx("span",{className:"text-gray-700 dark:text-slate-300",children:_r.name})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[Zs&&t.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${Zs==="shared"?"bg-amber-100 dark:bg-amber-900/50 text-amber-700 dark:text-amber-400":"bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-400"}`,children:Zs}),ns&&t.jsx("span",{className:"text-xs text-gray-500 dark:text-slate-400",children:"added"})]})]}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400 font-mono truncate ml-6",children:_r.relativePath})]},_r.dir)})}),Ht&&cr.length===0&&!At&&t.jsx("div",{className:"ml-6 mt-1 pl-2 text-xs text-gray-400 dark:text-slate-500 italic",children:"No sub-projects found"})]},ee.id)})}):t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 text-center py-4",children:"No projects registered. Add projects in the Projects view first."})]}),t.jsxs(St,{children:[t.jsx(ne,{variant:"outline",onClick:()=>{b(!1),A(new Set)},children:"Cancel"}),t.jsxs(ne,{onClick:uo,disabled:P.size===0||Q,className:"bg-purple-600 hover:bg-purple-700",children:[Q?t.jsx(Qe,{className:"w-4 h-4 animate-spin mr-2"}):t.jsx(Rt,{className:"w-4 h-4 mr-2"}),"Add Selected (",P.size,")"]})]})]})}),t.jsx(vt,{open:tr,onOpenChange:ee=>{ee||(Pr(!1),ts(""),Cr(null))},children:t.jsxs(ft,{children:[t.jsx(mt,{children:t.jsx(pt,{children:"Add Trigger Folder"})}),t.jsxs("div",{className:"space-y-4 py-4",children:[t.jsxs("p",{className:"text-sm text-gray-600 dark:text-slate-400",children:["Add a folder that will trigger the workstream ",t.jsx("strong",{children:qt==null?void 0:qt.name})," when you cd into it."]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300 mb-1 block",children:"Folder Path"}),t.jsx(Oe,{value:ps,onChange:ee=>ts(ee.target.value),placeholder:"~/path/to/folder",className:"font-mono"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400 mt-1",children:"Use absolute path or ~ for home directory"})]})]}),t.jsxs(St,{children:[t.jsx(ne,{variant:"outline",onClick:()=>{Pr(!1),ts(""),Cr(null)},children:"Cancel"}),t.jsxs(ne,{onClick:Si,disabled:!ps.trim(),className:"bg-purple-600 hover:bg-purple-700",children:[t.jsx(fi,{className:"w-4 h-4 mr-2"}),"Add Folder"]})]})]})})]})}const E_={clarify:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",plan:"bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200",execute:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200"},Oa={pending:t.jsx(Ga,{className:"w-4 h-4 text-gray-500"}),running:t.jsx(zg,{className:"w-4 h-4 text-green-500"}),paused:t.jsx(Sp,{className:"w-4 h-4 text-yellow-500"}),completed:t.jsx(vi,{className:"w-4 h-4 text-green-600"}),failed:t.jsx(Ki,{className:"w-4 h-4 text-red-500"}),cancelled:t.jsx(Ki,{className:"w-4 h-4 text-gray-500"})};function DW({activeProject:e=null}){var xl,vl,la,yl,bl,wl,ca,po,gn,xn,vn;const[r,s]=_.useState([]),[n,o]=_.useState(!0),[c,d]=_.useState(null),[l,u]=_.useState({}),{workstreams:f,activeId:m,fetch:h}=MN(),[g,w]=_.useState(""),[j,k]=_.useState(!1),[v,y]=_.useState(!1),[x,b]=_.useState(!1),[S,N]=_.useState(!1),[P,A]=_.useState(null),[E,M]=_.useState(!1),[I,B]=_.useState(null),[U,V]=_.useState(""),[Q,z]=_.useState(""),[H,Y]=_.useState(50),[K,O]=_.useState("DONE"),[T,F]=_.useState(!1),[$,D]=_.useState(!1),[X,te]=_.useState(!1),[fe,J]=_.useState(""),[W,le]=_.useState(""),[ae,re]=_.useState(!1),[de,Se]=_.useState(!1),[Re,Ue]=_.useState(null),[pe,_e]=_.useState("create"),[$e,Ge]=_.useState(""),[et,Nt]=_.useState(""),[ke,me]=_.useState(50),[be,Z]=_.useState("DONE"),[oe,we]=_.useState(""),[Ce,Fe]=_.useState(50),[He,ct]=_.useState(!1),[st,zt]=_.useState("DONE"),[Lr,Vr]=_.useState([]),[tr,Pr]=_.useState({stopHook:{},prepromptHook:{}}),[qt,Cr]=_.useState(!1),[ps,ts]=_.useState({needsInstall:!0}),[Fs,Bs]=_.useState(!1),[at,Wt]=_.useState(null),[lr,fr]=_.useState(null),[ks,Kt]=_.useState(!1),[Yt,Gr]=_.useState(!1),[ht,yr]=_.useState(null),[gs,rs]=_.useState(!0),[rt,mn]=_.useState(null),[pl,ss]=_.useState(!1);_.useEffect(()=>{Ar(),co(),ta(),h(),pn()},[h]);const Si=_.useRef(null);_.useEffect(()=>{if(!Yt||!ht){Si.current=null;return}Si.current=ht.status;const ie=setInterval(async()=>{var Le,Dt,Tr;try{const kt=(await he.getLoop(ht.id)).loop,Fr=Si.current!==kt.status,Br=["completed","paused","failed","cancelled"].includes(kt.status);if(Fr&&Br){clearInterval(ie);const os={id:kt.id,name:kt.name,task:(Le=kt.task)==null?void 0:Le.original,status:kt.status,pauseReason:kt.pauseReason,iterations:((Dt=kt.iterations)==null?void 0:Dt.current)||0,maxIterations:((Tr=kt.iterations)==null?void 0:Tr.max)||50,phase:kt.phase,startedAt:kt.startedAt,completedAt:kt.completedAt||new Date().toISOString(),duration:kt.startedAt?Math.round((Date.now()-new Date(kt.startedAt).getTime())/1e3):null};mn(os),kt.status==="completed"?q.success("Loop completed successfully!"):kt.status==="paused"?q.info(`Loop paused: ${kt.pauseReason||"unknown reason"}`):kt.status==="failed"?q.error("Loop failed"):kt.status==="cancelled"&&q.warning("Loop cancelled"),Ar(),gs&&kt.status==="completed"?setTimeout(()=>{Gr(!1),yr(null),ss(!0)},1500):ss(!0)}Si.current=kt.status}catch(is){console.error("Failed to poll loop status:",is)}},3e3);return()=>clearInterval(ie)},[Yt,ht,gs]);const pn=async()=>{try{const ie=await he.getRalphLoopPluginStatus();ts(ie)}catch(ie){console.error("Failed to load plugin status:",ie)}};_.useEffect(()=>{j&&m&&z(m)},[j,m]);const Ar=async()=>{try{o(!0);const ie=await he.getLoops();s(ie.loops||[]),u(ie.config||{})}catch{q.error("Failed to load loops")}finally{o(!1)}},co=async()=>{try{const Le=(await he.getLoopConfig()).config||{};u(Le),Fe(Le.maxIterations||50),ct(Le.autoApprovePlan||!1),zt(Le.completionPromise||"DONE"),Y(Le.maxIterations||50),O(Le.completionPromise||"DONE")}catch(ie){console.error("Failed to load config:",ie)}},ta=async()=>{try{const ie=await he.getLoopHookStatus();Pr(ie)}catch(ie){console.error("Failed to load hook status:",ie)}},ra=async()=>{try{const ie=await he.getLoopHistory();Vr(ie.completed||[])}catch{q.error("Failed to load history")}},Ci=async()=>{if(!U.trim()){q.error("Task description is required");return}await Qs(U)},sa=async()=>{if(!U.trim()){q.error("Enter a task description first");return}try{D(!0),le(U),_e("create");const ie=await he.tuneLoopPrompt(U,(e==null?void 0:e.path)||(e==null?void 0:e.dir)||null);ie.success?(J(ie.tunedPrompt),te(!0)):q.error(ie.error||"Failed to tune prompt")}catch(ie){q.error(ie.message)}finally{D(!1)}},na=()=>{pe==="edit"?Nt(fe):(V(fe),re(!0)),te(!1),q.success("Tuned prompt applied")},ia=()=>{te(!1)},uo=ie=>{ie.status==="failed"||ie.status==="paused"||ie.status==="cancelled"?(Ue(ie),Se(!0)):mo(ie.id)},rr=async()=>{var ie,Le,Dt,Tr;if(Re)try{D(!0);const is=((ie=Re.task)==null?void 0:ie.original)||"",kt=await he.getLoop(Re.id),Fr=kt.loop||Re,Br={status:Fr.status,pauseReason:Fr.pauseReason,iterations:((Le=Fr.iterations)==null?void 0:Le.current)||0,maxIterations:((Dt=Fr.iterations)==null?void 0:Dt.max)||50,phase:Fr.phase,clarifications:kt.clarifications||"",plan:kt.plan||"",iterationHistory:(((Tr=Fr.iterations)==null?void 0:Tr.history)||[]).slice(-5).map(go=>`Iteration ${go.n}: ${go.summary||"no summary"}`).join(`
3047
+ This cannot be undone.`))return;const De=await u(ee.id);De.success?q.success(`Deleted workstream: ${ee.name}`):q.error(De.error||"Failed to delete workstream")},ra=async()=>{if(!v)return;z(!0);const ee=await l(v.id,{name:v.name,rules:v.rules,projects:v.projects||[],color:v.color||null});ee.success?(q.success("Workstream updated"),y(null)):q.error(ee.error||"Failed to update workstream"),z(!1)},Ci=ee=>{Z(ee.id),we(ee.rules||"")},sa=()=>{Z(null),we("")},na=async ee=>{Fe(!0);try{const De=await he.updateWorkstream(ee.id,{name:ee.name,rules:oe,projects:ee.projects||[]});De.success?(await c(),q.success("Rules updated"),Z(null),we("")):q.error(De.error||"Failed to update rules")}catch(De){q.error("Failed to update rules: "+De.message)}finally{Fe(!1)}},ia=ee=>{A(De=>{const Xe=new Set(De);return Xe.has(ee)?Xe.delete(ee):Xe.add(ee),Xe})},uo=async()=>{if(!S||P.size===0)return;z(!0);let ee=0,De=null;for(const Xe of P)try{const Pt=await he.addProjectToWorkstream(S.id,Xe);Pt.success&&(De=Pt.workstream,ee++)}catch(Pt){console.error("Failed to add project:",Xe,Pt)}ee>0?(await c(),q.success(`Added ${ee} project${ee>1?"s":""} to ${S.name}`)):q.error("Failed to add projects"),z(!1),b(!1),N(null),A(new Set)},rr=async(ee,De)=>{const Xe=await m(ee.id,De);Xe.success?q.success(`Removed project from ${ee.name}`):q.error(Xe.error||"Failed to remove project")},gl=ee=>ee.split("/").pop()||ee,Qs=(ee,De=null)=>{var Ht,At;const Xe=h(ee),Pt=De?(At=(Ht=n.find(cr=>cr.id===De))==null?void 0:Ht.projects)==null?void 0:At.includes(ee):!1;return Xe===0?null:Xe===1?Pt?null:"in use":"shared"};return o?t.jsx("div",{className:"flex items-center justify-center h-64",children:t.jsx(Qe,{className:"w-8 h-8 animate-spin text-indigo-600"})}):t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-lg bg-purple-100 dark:bg-purple-900/30 flex items-center justify-center",children:t.jsx(Hn,{className:"w-5 h-5 text-purple-600 dark:text-purple-400"})}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Workstreams"}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:"Context sets for multi-project workflows"})]})]}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs(ne,{variant:"outline",onClick:Ar,size:"sm",children:[t.jsx(Dr,{className:"w-4 h-4 mr-2"}),"Refresh"]}),t.jsxs(ne,{onClick:()=>k(!0),className:"bg-purple-600 hover:bg-purple-700",children:[t.jsx(Rt,{className:"w-4 h-4 mr-2"}),"New Workstream"]})]})]}),t.jsx("div",{className:"bg-purple-50 dark:bg-purple-950/30 border border-purple-200 dark:border-purple-800 rounded-lg p-4 text-sm text-purple-700 dark:text-purple-400",children:t.jsxs("p",{children:[t.jsx("strong",{children:"Workstreams"})," let you group related repos together so Claude sees them as one cohesive project. Perfect for microservices, monorepos, or any multi-repo setup where context matters. Your custom rules and context persist across sessions, and Claude stays scoped to only the directories you specify."]})}),t.jsx("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 shadow-sm overflow-hidden",children:n.length===0?t.jsxs("div",{className:"p-12 text-center",children:[t.jsx(Hn,{className:"w-12 h-12 mx-auto mb-4 text-gray-300 dark:text-slate-600"}),t.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-white mb-2",children:"No Workstreams Yet"}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 mb-4",children:"Create your first workstream to organize multi-project contexts."}),t.jsxs(ne,{onClick:()=>k(!0),children:[t.jsx(Rt,{className:"w-4 h-4 mr-2"}),"Create Your First Workstream"]})]}):t.jsx("div",{className:"divide-y divide-gray-100 dark:divide-slate-800",children:n.map(ee=>{var De,Xe,Pt,Ht;return t.jsxs("div",{className:"group",children:[t.jsxs("div",{className:"p-4 flex items-center gap-4 transition-colors cursor-pointer hover:bg-gray-50 dark:hover:bg-slate-900",onClick:()=>w(g===ee.id?null:ee.id),children:[t.jsx("div",{className:"w-5 h-5 flex items-center justify-center text-gray-400",children:g===ee.id?t.jsx(hr,{className:"w-4 h-4"}):t.jsx(Qr,{className:"w-4 h-4"})}),t.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center bg-gray-100 dark:bg-slate-800",children:t.jsx(Hn,{className:"w-5 h-5 text-gray-500 dark:text-slate-400"})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[ee.color&&t.jsx(MW,{color:ee.color}),t.jsx("h3",{className:"font-medium truncate text-gray-900 dark:text-white",children:ee.name}),((De=ee.projects)==null?void 0:De.length)>0&&t.jsxs("span",{className:"text-xs bg-gray-100 dark:bg-slate-800 text-gray-600 dark:text-slate-400 px-1.5 py-0.5 rounded",children:[ee.projects.length," project",ee.projects.length!==1?"s":""]}),ee.rules&&t.jsxs("span",{className:"text-xs bg-blue-100 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400 px-1.5 py-0.5 rounded",children:[t.jsx(vr,{className:"w-3 h-3 inline mr-0.5"}),"Rules"]})]}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 truncate",children:((Xe=ee.projects)==null?void 0:Xe.length)>0?ee.projects.map(At=>gl(At)).join(", "):"No projects added"})]}),t.jsxs("div",{className:"flex items-center gap-2",onClick:At=>At.stopPropagation(),children:[t.jsx(ne,{size:"sm",variant:"ghost",onClick:()=>y({...ee}),className:"text-gray-500 dark:text-slate-400 hover:text-purple-600 dark:hover:text-purple-400",title:"Edit workstream",children:t.jsx(Nm,{className:"w-4 h-4"})}),t.jsx(ne,{size:"sm",variant:"ghost",onClick:()=>ta(ee),className:"text-gray-500 dark:text-slate-400 hover:text-red-600 dark:hover:text-red-400",title:"Delete workstream",children:t.jsx(fs,{className:"w-4 h-4"})})]})]}),g===ee.id&&t.jsxs("div",{className:"px-4 pb-4 pl-16 space-y-4 bg-gray-50/50 dark:bg-slate-900/50",children:[t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Projects"}),t.jsxs(ne,{size:"sm",variant:"outline",onClick:()=>{N(ee),b(!0)},children:[t.jsx(fi,{className:"w-4 h-4 mr-1"}),"Add Project"]})]}),((Pt=ee.projects)==null?void 0:Pt.length)>0?t.jsx("div",{className:"space-y-1",children:ee.projects.map(At=>t.jsxs("div",{className:"flex items-center justify-between py-1.5 px-3 bg-white dark:bg-slate-800 rounded border border-gray-200 dark:border-slate-700",children:[t.jsx("span",{className:"text-sm font-mono text-gray-700 dark:text-slate-300 truncate",children:At.replace(/^\/Users\/[^/]+/,"~")}),t.jsx(ne,{size:"sm",variant:"ghost",onClick:()=>rr(ee,At),className:"text-gray-400 hover:text-red-500 h-6 w-6 p-0",children:t.jsx(Hb,{className:"w-4 h-4"})})]},At))}):t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 italic",children:"No projects added yet. Add projects to help organize your workstream."})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Trigger Folders"}),t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(Va,{className:"w-3.5 h-3.5 text-gray-400"})}),t.jsx(Ot,{children:t.jsx("p",{className:"max-w-xs text-xs",children:"Additional folders that activate this workstream when you cd into them. Projects are always trigger folders automatically."})})]})})]}),t.jsxs(ne,{size:"sm",variant:"outline",onClick:()=>{Cr(ee),Pr(!0)},children:[t.jsx(fi,{className:"w-4 h-4 mr-1"}),"Add Folder"]})]}),((Ht=ee.triggerFolders)==null?void 0:Ht.length)>0?t.jsx("div",{className:"space-y-1",children:ee.triggerFolders.map(At=>t.jsxs("div",{className:"flex items-center justify-between py-1.5 px-3 bg-white dark:bg-slate-800 rounded border border-gray-200 dark:border-slate-700",children:[t.jsx("span",{className:"text-sm font-mono text-gray-700 dark:text-slate-300 truncate",children:At.replace(/^\/Users\/[^/]+/,"~")}),t.jsx(ne,{size:"sm",variant:"ghost",onClick:()=>pn(ee,At),className:"text-gray-400 hover:text-red-500 h-6 w-6 p-0",children:t.jsx(Hb,{className:"w-4 h-4"})})]},At))}):t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 italic",children:"No extra trigger folders. Projects auto-trigger this workstream."})]}),t.jsxs("div",{className:"flex items-center justify-between py-2 px-3 bg-white dark:bg-slate-800 rounded border border-gray-200 dark:border-slate-700",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Yi,{className:"w-4 h-4 text-amber-500"}),t.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Auto-Activate on cd"})]}),t.jsxs(En,{children:[t.jsx(Pn,{asChild:!0,children:t.jsxs(ne,{variant:"outline",size:"sm",children:[ee.autoActivate===!0?"On":ee.autoActivate===!1?"Off":"Default",t.jsx(hr,{className:"w-3 h-3 ml-1"})]})}),t.jsxs(hn,{align:"end",children:[t.jsxs(jt,{onClick:()=>ss(ee,"on"),children:[t.jsx(It,{className:`w-4 h-4 mr-2 ${ee.autoActivate===!0?"opacity-100":"opacity-0"}`}),"On"]}),t.jsxs(jt,{onClick:()=>ss(ee,"off"),children:[t.jsx(It,{className:`w-4 h-4 mr-2 ${ee.autoActivate===!1?"opacity-100":"opacity-0"}`}),"Off"]}),t.jsxs(jt,{onClick:()=>ss(ee,"default"),children:[t.jsx(It,{className:`w-4 h-4 mr-2 ${ee.autoActivate===void 0?"opacity-100":"opacity-0"}`}),"Default (",st.workstreamAutoActivate?"On":"Off",")"]})]})]})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Rules"}),be===ee.id?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(ne,{size:"sm",variant:"ghost",onClick:sa,disabled:Ce,className:"text-gray-500 dark:text-slate-400 h-7",children:[t.jsx(Nn,{className:"w-4 h-4 mr-1"}),"Cancel"]}),t.jsxs(ne,{size:"sm",onClick:()=>na(ee),disabled:Ce,className:"bg-purple-600 hover:bg-purple-700 h-7",children:[Ce?t.jsx(Qe,{className:"w-4 h-4 animate-spin mr-1"}):t.jsx(Zr,{className:"w-4 h-4 mr-1"}),"Save"]})]}):t.jsxs(ne,{size:"sm",variant:"ghost",onClick:()=>Ci(ee),className:"text-gray-500 dark:text-slate-400 hover:text-purple-600 dark:hover:text-purple-400 h-7",children:[t.jsx(Nm,{className:"w-4 h-4 mr-1"}),"Edit"]})]}),be===ee.id?t.jsx(yt,{value:oe,onChange:At=>we(At.target.value),placeholder:"Context rules for this workstream. These will be injected into every Claude session when this workstream is active.",rows:8,className:"font-mono text-sm",autoFocus:!0}):ee.rules?t.jsx("pre",{className:"text-sm text-gray-600 dark:text-slate-400 bg-white dark:bg-slate-800 rounded border border-gray-200 dark:border-slate-700 p-3 overflow-auto max-h-40 whitespace-pre-wrap cursor-pointer hover:border-purple-300 dark:hover:border-purple-700 transition-colors",onClick:()=>Ci(ee),title:"Click to edit",children:ee.rules}):t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 italic cursor-pointer hover:text-purple-600 dark:hover:text-purple-400 transition-colors",onClick:()=>Ci(ee),children:"No rules defined. Click to add context rules for this workstream."})]})]})]},ee.id)})})}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("h3",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Hook Integration"}),t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx("button",{className:"text-gray-400 hover:text-gray-600 dark:hover:text-slate-300",children:t.jsx(Va,{className:"w-4 h-4"})})}),t.jsx(Ot,{side:"right",className:"max-w-xs",children:t.jsxs("p",{className:"text-sm",children:[t.jsx("strong",{children:"What are hooks?"}),t.jsx("br",{}),t.jsx("br",{}),"Hooks are scripts that run automatically at specific points in Claude Code sessions. The workstream hook runs before each prompt and injects your active workstream's rules into the context.",t.jsx("br",{}),t.jsx("br",{}),t.jsx("strong",{children:"How it works:"}),t.jsx("br",{}),"1. You activate a workstream",t.jsx("br",{}),"2. Hook detects the active workstream",t.jsx("br",{}),"3. Rules are prepended to Claude's context",t.jsx("br",{}),"4. Claude understands your project context"]})})]})})]}),X.isInstalled?t.jsx("div",{className:"bg-green-50 dark:bg-green-950/30 border border-green-200 dark:border-green-800 rounded-lg p-4 text-sm text-green-700 dark:text-green-400",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(vi,{className:"w-5 h-5 flex-shrink-0"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium",children:"Hook Installed"}),t.jsx("p",{className:"text-green-600 dark:text-green-500",children:"Workstream rules will be automatically injected into every Claude session."})]})]})}):t.jsx("div",{className:"bg-amber-50 dark:bg-amber-950/30 border border-amber-200 dark:border-amber-800 rounded-lg p-4 text-sm text-amber-700 dark:text-amber-400",children:t.jsxs("div",{className:"flex gap-3",children:[t.jsx(Is,{className:"w-5 h-5 flex-shrink-0 mt-0.5"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("p",{className:"font-medium mb-1",children:"Hook Not Installed"}),t.jsx("p",{className:"mb-3",children:"Install the pre-prompt hook to automatically inject workstream rules into every Claude session."}),t.jsxs(ne,{onClick:rs,disabled:fe||X.loading,size:"sm",className:"bg-amber-600 hover:bg-amber-700 text-white",children:[fe?t.jsx(Qe,{className:"w-4 h-4 animate-spin mr-2"}):t.jsx(yi,{className:"w-4 h-4 mr-2"}),"Install Hook"]}),t.jsxs("p",{className:"text-xs mt-2 text-amber-600 dark:text-amber-500",children:["Creates ",t.jsx("code",{className:"bg-amber-100 dark:bg-amber-900/50 px-1 rounded",children:"~/.claude/hooks/pre-prompt.sh"})]})]})]})})]}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("h3",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Folder Auto-Activation"}),t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(Va,{className:"w-4 h-4 text-gray-400"})}),t.jsxs(Ot,{className:"max-w-sm",children:[t.jsx("p",{className:"text-sm mb-2",children:t.jsx("strong",{children:"How it works:"})}),t.jsxs("ol",{className:"text-xs space-y-1 list-decimal list-inside",children:[t.jsx("li",{children:"Install the CD hook to your shell"}),t.jsxs("li",{children:["When you ",t.jsx("code",{className:"bg-slate-700 px-1 rounded",children:"cd"})," into a folder matching a workstream, it auto-activates"]}),t.jsx("li",{children:"If multiple workstreams match, you'll be prompted to choose"})]})]})]})})]}),t.jsxs("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 shadow-sm p-4",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4 pb-4 border-b border-gray-200 dark:border-slate-800",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Yi,{className:"w-4 h-4 text-amber-500"}),t.jsx("span",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Global Auto-Activate"}),t.jsx("span",{className:"text-xs text-gray-500 dark:text-slate-400",children:"(default for all workstreams)"})]}),t.jsx(ne,{variant:st.workstreamAutoActivate?"default":"outline",size:"sm",onClick:pl,children:st.workstreamAutoActivate?"Enabled":"Disabled"})]}),He.installed?t.jsxs("div",{className:"flex items-start gap-3 p-3 bg-green-50 dark:bg-green-900/20 rounded-lg border border-green-200 dark:border-green-800",children:[t.jsx(vi,{className:"w-5 h-5 text-green-600 dark:text-green-400 flex-shrink-0 mt-0.5"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("p",{className:"font-medium text-green-800 dark:text-green-300",children:"CD Hook Installed"}),t.jsxs("p",{className:"text-xs text-green-600 dark:text-green-400 mt-1",children:["Shell: ",He.shell," • RC file: ",t.jsx("code",{className:"bg-green-100 dark:bg-green-900/50 px-1 rounded",children:(ho=He.rcFile)==null?void 0:ho.replace(/^\/Users\/[^/]+/,"~")})]}),t.jsxs(ne,{variant:"outline",size:"sm",className:"mt-2",onClick:mn,disabled:Lr,children:[Lr?t.jsx(Qe,{className:"w-4 h-4 animate-spin mr-2"}):null,"Uninstall"]})]})]}):t.jsxs("div",{className:"flex items-start gap-3 p-3 bg-amber-50 dark:bg-amber-900/20 rounded-lg border border-amber-200 dark:border-amber-800",children:[t.jsx(Is,{className:"w-5 h-5 text-amber-600 dark:text-amber-400 flex-shrink-0 mt-0.5"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium text-amber-800 dark:text-amber-300 mb-1",children:"CD Hook Not Installed"}),t.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400 mb-2",children:"Install the hook to auto-activate workstreams when you cd into matching folders."}),t.jsxs(ne,{variant:"default",size:"sm",onClick:rt,disabled:Lr||He.loading,className:"bg-amber-600 hover:bg-amber-700 text-white",children:[Lr?t.jsx(Qe,{className:"w-4 h-4 animate-spin mr-2"}):t.jsx(yi,{className:"w-4 h-4 mr-2"}),"Install CD Hook"]}),t.jsxs("p",{className:"text-xs mt-2 text-amber-600 dark:text-amber-500",children:["Adds function to ",t.jsx("code",{className:"bg-amber-100 dark:bg-amber-900/50 px-1 rounded",children:"~/.zshrc"})," or ",t.jsx("code",{className:"bg-amber-100 dark:bg-amber-900/50 px-1 rounded",children:"~/.bashrc"})]})]})]})]})]}),W&&W.totalSessions>0&&t.jsxs("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 shadow-sm p-4",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(NM,{className:"w-5 h-5 text-indigo-600 dark:text-indigo-400"}),t.jsx("h3",{className:"font-medium text-gray-900 dark:text-white",children:"Activity Insights"})]}),t.jsxs(ne,{variant:"ghost",size:"sm",onClick:yr,className:"text-gray-500 dark:text-slate-400 hover:text-red-500",children:[t.jsx(fs,{className:"w-4 h-4 mr-1"}),"Clear Old"]})]}),t.jsxs("div",{className:"grid grid-cols-3 gap-4 mb-4",children:[t.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-3",children:[t.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-slate-400 text-xs mb-1",children:[t.jsx(mS,{className:"w-3 h-3"}),"Sessions"]}),t.jsx("div",{className:"text-2xl font-semibold text-gray-900 dark:text-white",children:W.totalSessions})]}),t.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-3",children:[t.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-slate-400 text-xs mb-1",children:[t.jsx(vr,{className:"w-3 h-3"}),"Files Tracked"]}),t.jsx("div",{className:"text-2xl font-semibold text-gray-900 dark:text-white",children:W.totalFiles})]}),t.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-3",children:[t.jsxs("div",{className:"flex items-center gap-2 text-gray-500 dark:text-slate-400 text-xs mb-1",children:[t.jsx(Hn,{className:"w-3 h-3"}),"Projects Active"]}),t.jsx("div",{className:"text-2xl font-semibold text-gray-900 dark:text-white",children:W.projectCount})]})]}),((Mn=W.topProjects)==null?void 0:Mn.length)>0&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-gray-700 dark:text-slate-300 mb-2",children:"Most Active Projects"}),t.jsx("div",{className:"space-y-1",children:W.topProjects.slice(0,5).map((ee,De)=>t.jsxs("div",{className:"flex items-center justify-between text-sm",children:[t.jsx("span",{className:"text-gray-600 dark:text-slate-400 truncate",title:ee.path,children:ee.path.split("/").pop()}),t.jsxs("span",{className:"text-gray-400 dark:text-slate-500 text-xs",children:[ee.fileCount," files"]})]},ee.path))})]})]}),ht.length>0&&t.jsxs("div",{className:"bg-gradient-to-r from-indigo-50 to-purple-50 dark:from-indigo-950/30 dark:to-purple-950/30 rounded-xl border border-indigo-200 dark:border-indigo-800 p-4",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[t.jsx(Vt,{className:"w-5 h-5 text-indigo-600 dark:text-indigo-400"}),t.jsx("h3",{className:"font-medium text-indigo-900 dark:text-indigo-300",children:"Suggested Workstreams"}),t.jsx("span",{className:"text-xs bg-indigo-100 dark:bg-indigo-900/50 text-indigo-600 dark:text-indigo-400 px-1.5 py-0.5 rounded",children:"Based on activity patterns"})]}),t.jsx("p",{className:"text-sm text-indigo-700 dark:text-indigo-400 mb-4",children:"These projects are frequently worked on together. Create a workstream to group them?"}),t.jsx("div",{className:"space-y-3",children:ht.map(ee=>t.jsxs("div",{className:"bg-white dark:bg-slate-900 rounded-lg border border-indigo-200 dark:border-indigo-800 p-3",children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Yi,{className:"w-4 h-4 text-amber-500"}),t.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:ee.name}),ee.coActivityScore&&t.jsxs("span",{className:"text-xs text-gray-500 dark:text-slate-400",children:[ee.coActivityScore,"% co-activity"]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ne,{size:"sm",variant:"ghost",onClick:()=>Gr(ee),className:"text-gray-400 hover:text-gray-600 dark:hover:text-slate-300",title:"Dismiss suggestion",children:t.jsx(Nn,{className:"w-4 h-4"})}),t.jsxs(ne,{size:"sm",onClick:()=>fr(ee),className:"bg-indigo-600 hover:bg-indigo-700",children:[t.jsx(Rt,{className:"w-4 h-4 mr-1"}),"Create"]})]})]}),t.jsx("div",{className:"flex flex-wrap gap-1",children:ee.projects.map(De=>t.jsx("span",{className:"text-xs bg-gray-100 dark:bg-slate-800 text-gray-600 dark:text-slate-400 px-2 py-0.5 rounded",children:De.split("/").pop()},De))})]},ee.name))})]}),t.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-4 border border-transparent dark:border-slate-800",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white mb-2",children:"CLI Commands"}),t.jsxs("div",{className:"space-y-1 text-sm text-gray-600 dark:text-slate-400 font-mono",children:[t.jsx("p",{children:"coder-config workstream # List workstreams"}),t.jsx("p",{children:'coder-config workstream use "Name" # Set workstream for this tab'}),t.jsx("p",{children:'coder-config workstream create "Name" # Create workstream'})]})]}),t.jsx(vt,{open:j,onOpenChange:ee=>{ee||(k(!1),M(""),B(""),V([]),Y(!1),O({}))},children:t.jsxs(ft,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[t.jsx(mt,{children:t.jsxs(pt,{className:"flex items-center gap-2",children:[t.jsx(Hn,{className:"w-5 h-5 text-purple-600"}),"Create Workstream"]})}),t.jsxs("div",{className:"space-y-4 py-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300 mb-1 block",children:"Name"}),t.jsx(Oe,{value:E,onChange:ee=>M(ee.target.value),placeholder:"e.g., User Auth, Admin Dashboard",autoFocus:!0})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Projects"}),t.jsxs(ne,{type:"button",size:"sm",variant:"outline",onClick:()=>Y(!H),children:[t.jsx(fi,{className:"w-4 h-4 mr-1"}),"Add"]})]}),U.length>0?t.jsx("div",{className:"space-y-1 mb-2",children:U.map(ee=>t.jsxs("div",{className:"flex items-center justify-between py-1.5 px-3 bg-gray-50 dark:bg-slate-800 rounded border border-gray-200 dark:border-slate-700",children:[t.jsx("span",{className:"text-sm font-mono text-gray-700 dark:text-slate-300 truncate",children:ee.replace(/^\/Users\/[^/]+/,"~")}),t.jsx(ne,{type:"button",size:"sm",variant:"ghost",onClick:()=>ks(ee),className:"text-gray-400 hover:text-red-500 h-6 w-6 p-0",children:t.jsx(Nn,{className:"w-4 h-4"})})]},ee))}):t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 italic mb-2",children:"No projects added. Add projects to help organize your workstream."}),H&&r.length>0&&t.jsx("div",{className:"border border-gray-200 dark:border-slate-700 rounded-lg p-2 max-h-64 overflow-y-auto bg-white dark:bg-slate-900",children:r.map(ee=>{const De=Qs(ee.path),Xe=K[ee.path],Pt=$[ee.path],Ht=T[ee.path]||[],At=U.includes(ee.path);return t.jsxs("div",{className:"mb-1",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{type:"button",onClick:()=>Yt(ee.path),className:"p-1 hover:bg-gray-100 dark:hover:bg-slate-800 rounded",title:"Show sub-projects",children:Pt?t.jsx(Qe,{className:"w-4 h-4 animate-spin text-gray-400"}):Xe?t.jsx(hr,{className:"w-4 h-4 text-gray-400"}):t.jsx(Qr,{className:"w-4 h-4 text-gray-400"})}),t.jsxs("button",{type:"button",onClick:()=>Kt(ee.path),disabled:At,className:`flex-1 text-left p-2 rounded transition-colors ${At?"bg-purple-50 dark:bg-purple-950/30 opacity-50":"hover:bg-purple-50 dark:hover:bg-purple-950/30"}`,children:[t.jsxs("div",{className:"flex items-center justify-between text-sm",children:[t.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:ee.name}),t.jsxs("div",{className:"flex items-center gap-1",children:[De&&t.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${De==="shared"?"bg-amber-100 dark:bg-amber-900/50 text-amber-700 dark:text-amber-400":"bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-400"}`,children:De}),At&&t.jsx(It,{className:"w-4 h-4 text-purple-600"})]})]}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400 font-mono truncate",children:ee.path.replace(/^\/Users\/[^/]+/,"~")})]})]}),Xe&&Ht.length>0&&t.jsx("div",{className:"ml-6 mt-1 space-y-1 border-l-2 border-gray-200 dark:border-slate-700 pl-2",children:Ht.map(cr=>{const jr=U.includes(cr.dir),_r=Qs(cr.dir);return t.jsxs("button",{type:"button",onClick:()=>Kt(cr.dir),disabled:jr,className:`w-full text-left p-2 rounded transition-colors ${jr?"bg-purple-50 dark:bg-purple-950/30 opacity-50":"hover:bg-purple-50 dark:hover:bg-purple-950/30"}`,children:[t.jsxs("div",{className:"flex items-center justify-between text-sm",children:[t.jsx("span",{className:"text-gray-700 dark:text-slate-300",children:cr.name}),t.jsxs("div",{className:"flex items-center gap-1",children:[_r&&t.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${_r==="shared"?"bg-amber-100 dark:bg-amber-900/50 text-amber-700 dark:text-amber-400":"bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-400"}`,children:_r}),jr&&t.jsx(It,{className:"w-4 h-4 text-purple-600"})]})]}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400 font-mono",children:cr.relativePath})]},cr.dir)})}),Xe&&Ht.length===0&&!Pt&&t.jsx("div",{className:"ml-6 mt-1 pl-2 text-xs text-gray-400 dark:text-slate-500 italic",children:"No sub-projects found"})]},ee.id)})})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Context (optional)"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(En,{children:[t.jsx(Pn,{asChild:!0,children:t.jsxs(ne,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",children:[t.jsx(Vt,{className:"w-3 h-3"}),$e?((oa=et.find(ee=>ee.id===$e))==null?void 0:oa.name)||$e:"Basic",t.jsx(hr,{className:"w-3 h-3"})]})}),t.jsxs(hn,{align:"end",children:[t.jsx(jt,{onClick:()=>Ge(""),children:t.jsx("span",{className:"text-xs",children:"Basic (no AI)"})}),et.filter(ee=>ee.available).map(ee=>t.jsxs(jt,{onClick:()=>Ge(ee.id),children:[t.jsx("span",{className:"text-xs",children:ee.name}),ee.id===$e&&t.jsx(It,{className:"w-3 h-3 ml-2"})]},ee.id)),et.filter(ee=>!ee.available).length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-2 py-1 text-xs text-gray-400",children:"Not installed:"}),et.filter(ee=>!ee.available).map(ee=>t.jsx(jt,{disabled:!0,className:"text-gray-400",children:t.jsx("span",{className:"text-xs",children:ee.name})},ee.id))]})]})]}),$e==="ollama"&&t.jsx(Oe,{value:ke,onChange:ee=>me(ee.target.value),placeholder:"Model",className:"h-7 w-24 text-xs"}),t.jsxs(ne,{type:"button",size:"sm",variant:"ghost",onClick:()=>gs(U,B),disabled:pe||U.length===0,className:"text-xs h-7 text-purple-600 hover:text-purple-700 hover:bg-purple-50 dark:hover:bg-purple-950/30",title:$e?`Generate with ${(fo=et.find(ee=>ee.id===$e))==null?void 0:fo.name}`:"Extract from README, package.json, etc.",children:[pe?t.jsx(Qe,{className:"w-3 h-3 animate-spin mr-1"}):t.jsx(Wr,{className:"w-3 h-3 mr-1"}),"Generate"]})]})]}),t.jsx(yt,{value:I,onChange:ee=>B(ee.target.value),placeholder:"Context rules for this workstream. These will be injected into every Claude session when this workstream is active.",rows:6}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400 mt-1",children:'Example: "Focus on user authentication. Use JWT tokens. React Query for state management."'})]})]}),t.jsxs(St,{children:[t.jsx(ne,{variant:"outline",onClick:()=>{k(!1),M(""),B(""),V([]),Y(!1),O({})},children:"Cancel"}),t.jsxs(ne,{onClick:co,disabled:Q||!E.trim(),className:"bg-purple-600 hover:bg-purple-700",children:[Q?t.jsx(Qe,{className:"w-4 h-4 animate-spin mr-2"}):t.jsx(Rt,{className:"w-4 h-4 mr-2"}),"Create"]})]})]})}),t.jsx(vt,{open:!!v,onOpenChange:ee=>!ee&&y(null),children:t.jsxs(ft,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[t.jsx(mt,{children:t.jsxs(pt,{className:"flex items-center gap-2",children:[t.jsx(Nm,{className:"w-5 h-5 text-purple-600"}),"Edit Workstream"]})}),v&&t.jsxs("div",{className:"space-y-4 py-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300 mb-1 block",children:"Name"}),t.jsx(Oe,{value:v.name,onChange:ee=>y(De=>({...De,name:ee.target.value}))})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300 mb-1.5 block",children:"Color"}),t.jsx(IW,{value:v.color||null,onChange:ee=>y(De=>({...De,color:ee}))}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400 mt-1.5",children:"Shown in the list and the Full statusline (when active)."})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-2",children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Projects"}),t.jsxs(ne,{type:"button",size:"sm",variant:"outline",onClick:()=>y(ee=>({...ee,showPicker:!ee.showPicker})),children:[t.jsx(fi,{className:"w-4 h-4 mr-1"}),"Add"]})]}),((ti=v.projects)==null?void 0:ti.length)>0?t.jsx("div",{className:"space-y-1 mb-2",children:v.projects.map(ee=>t.jsxs("div",{className:"flex items-center justify-between py-1.5 px-3 bg-gray-50 dark:bg-slate-800 rounded border border-gray-200 dark:border-slate-700",children:[t.jsx("span",{className:"text-sm font-mono text-gray-700 dark:text-slate-300 truncate",children:ee.replace(/^\/Users\/[^/]+/,"~")}),t.jsx(ne,{type:"button",size:"sm",variant:"ghost",onClick:()=>y(De=>({...De,projects:De.projects.filter(Xe=>Xe!==ee)})),className:"text-gray-400 hover:text-red-500 h-6 w-6 p-0",children:t.jsx(Nn,{className:"w-4 h-4"})})]},ee))}):t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 italic mb-2",children:"No projects in this workstream."}),v.showPicker&&r.length>0&&t.jsx("div",{className:"border border-gray-200 dark:border-slate-700 rounded-lg p-2 max-h-48 overflow-y-auto bg-white dark:bg-slate-900",children:r.map(ee=>{var cr;const De=(cr=v.projects)==null?void 0:cr.includes(ee.path),Xe=Qs(ee.path,v.id),Pt=K[ee.path],Ht=$[ee.path],At=T[ee.path]||[];return t.jsxs("div",{className:"mb-1",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{type:"button",onClick:()=>Yt(ee.path),className:"p-1 hover:bg-gray-100 dark:hover:bg-slate-800 rounded",title:"Show sub-projects",children:Ht?t.jsx(Qe,{className:"w-4 h-4 animate-spin text-gray-400"}):Pt?t.jsx(hr,{className:"w-4 h-4 text-gray-400"}):t.jsx(Qr,{className:"w-4 h-4 text-gray-400"})}),t.jsxs("button",{type:"button",onClick:()=>!De&&y(jr=>({...jr,projects:[...jr.projects||[],ee.path]})),disabled:De,className:`flex-1 text-left p-2 rounded transition-colors ${De?"bg-purple-50 dark:bg-purple-950/30 opacity-50":"hover:bg-purple-50 dark:hover:bg-purple-950/30"}`,children:[t.jsxs("div",{className:"flex items-center justify-between text-sm",children:[t.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:ee.name}),t.jsxs("div",{className:"flex items-center gap-1",children:[Xe&&t.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${Xe==="shared"?"bg-amber-100 dark:bg-amber-900/50 text-amber-700 dark:text-amber-400":"bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-400"}`,children:Xe}),De&&t.jsx(It,{className:"w-4 h-4 text-purple-600"})]})]}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400 font-mono truncate",children:ee.path.replace(/^\/Users\/[^/]+/,"~")})]})]}),Pt&&At.length>0&&t.jsx("div",{className:"ml-6 mt-1 space-y-1 border-l-2 border-gray-200 dark:border-slate-700 pl-2",children:At.map(jr=>{var Ss;const _r=(Ss=v.projects)==null?void 0:Ss.includes(jr.dir),ns=Qs(jr.dir,v.id);return t.jsxs("button",{type:"button",onClick:()=>!_r&&y(Zs=>({...Zs,projects:[...Zs.projects||[],jr.dir]})),disabled:_r,className:`w-full text-left p-2 rounded transition-colors ${_r?"bg-purple-50 dark:bg-purple-950/30 opacity-50":"hover:bg-purple-50 dark:hover:bg-purple-950/30"}`,children:[t.jsxs("div",{className:"flex items-center justify-between text-sm",children:[t.jsx("span",{className:"text-gray-700 dark:text-slate-300",children:jr.name}),t.jsxs("div",{className:"flex items-center gap-1",children:[ns&&t.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${ns==="shared"?"bg-amber-100 dark:bg-amber-900/50 text-amber-700 dark:text-amber-400":"bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-400"}`,children:ns}),_r&&t.jsx(It,{className:"w-4 h-4 text-purple-600"})]})]}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400 font-mono truncate",children:jr.relativePath})]},jr.dir)})}),Pt&&At.length===0&&!Ht&&t.jsx("div",{className:"ml-6 mt-1 pl-2 text-xs text-gray-400 dark:text-slate-500 italic",children:"No sub-projects found"})]},ee.id)})})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300",children:"Rules"}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(En,{children:[t.jsx(Pn,{asChild:!0,children:t.jsxs(ne,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",children:[t.jsx(Vt,{className:"w-3 h-3"}),$e?((xs=et.find(ee=>ee.id===$e))==null?void 0:xs.name)||$e:"Basic",t.jsx(hr,{className:"w-3 h-3"})]})}),t.jsxs(hn,{align:"end",children:[t.jsx(jt,{onClick:()=>Ge(""),children:t.jsx("span",{className:"text-xs",children:"Basic (no AI)"})}),et.filter(ee=>ee.available).map(ee=>t.jsxs(jt,{onClick:()=>Ge(ee.id),children:[t.jsx("span",{className:"text-xs",children:ee.name}),ee.id===$e&&t.jsx(It,{className:"w-3 h-3 ml-2"})]},ee.id)),et.filter(ee=>!ee.available).length>0&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"px-2 py-1 text-xs text-gray-400",children:"Not installed:"}),et.filter(ee=>!ee.available).map(ee=>t.jsx(jt,{disabled:!0,className:"text-gray-400",children:t.jsx("span",{className:"text-xs",children:ee.name})},ee.id))]})]})]}),$e==="ollama"&&t.jsx(Oe,{value:ke,onChange:ee=>me(ee.target.value),placeholder:"Model",className:"h-7 w-24 text-xs"}),t.jsxs(ne,{type:"button",size:"sm",variant:"ghost",onClick:()=>gs(v.projects,ee=>y(De=>({...De,rules:ee}))),disabled:pe||!((mo=v.projects)!=null&&mo.length),className:"text-xs h-7 text-purple-600 hover:text-purple-700 hover:bg-purple-50 dark:hover:bg-purple-950/30",title:$e?`Generate with ${(Or=et.find(ee=>ee.id===$e))==null?void 0:Or.name}`:"Extract from README, package.json, etc.",children:[pe?t.jsx(Qe,{className:"w-3 h-3 animate-spin mr-1"}):t.jsx(Wr,{className:"w-3 h-3 mr-1"}),"Generate"]})]})]}),t.jsx(yt,{value:v.rules||"",onChange:ee=>y(De=>({...De,rules:ee.target.value})),placeholder:"Context rules for this workstream...",rows:8})]})]}),t.jsxs(St,{children:[t.jsx(ne,{variant:"outline",onClick:()=>y(null),children:"Cancel"}),t.jsxs(ne,{onClick:ra,disabled:Q,className:"bg-purple-600 hover:bg-purple-700",children:[Q?t.jsx(Qe,{className:"w-4 h-4 animate-spin mr-2"}):t.jsx(Zr,{className:"w-4 h-4 mr-2"}),"Save Changes"]})]})]})}),t.jsx(vt,{open:x,onOpenChange:ee=>{b(ee),ee||(O({}),A(new Set))},children:t.jsxs(ft,{className:"max-w-lg",children:[t.jsx(mt,{children:t.jsxs(pt,{className:"flex items-center gap-2",children:[t.jsx(fi,{className:"w-5 h-5 text-purple-600"}),"Add Project to ",S==null?void 0:S.name]})}),t.jsxs("div",{className:"py-4",children:[t.jsx("p",{className:"text-sm text-gray-600 dark:text-slate-400 mb-4",children:"Select projects to add to this workstream (multi-select enabled):"}),r.length>0?t.jsx("div",{className:"space-y-1 max-h-64 overflow-y-auto border border-gray-200 dark:border-slate-700 rounded-lg p-2 bg-white dark:bg-slate-900",children:r.map(ee=>{var jr;const De=(jr=S==null?void 0:S.projects)==null?void 0:jr.includes(ee.path),Xe=P.has(ee.path),Pt=Qs(ee.path,S==null?void 0:S.id),Ht=K[ee.path],At=$[ee.path],cr=T[ee.path]||[];return t.jsxs("div",{className:"mb-1",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{type:"button",onClick:()=>Yt(ee.path),className:"p-1 hover:bg-gray-100 dark:hover:bg-slate-800 rounded",title:"Show sub-projects",children:At?t.jsx(Qe,{className:"w-4 h-4 animate-spin text-gray-400"}):Ht?t.jsx(hr,{className:"w-4 h-4 text-gray-400"}):t.jsx(Qr,{className:"w-4 h-4 text-gray-400"})}),t.jsxs("button",{type:"button",onClick:()=>!De&&ia(ee.path),disabled:De,className:`flex-1 text-left p-2 rounded transition-colors ${De?"bg-gray-100 dark:bg-slate-800 opacity-50 cursor-not-allowed":Xe?"bg-purple-100 dark:bg-purple-950/50 ring-2 ring-purple-500":"hover:bg-purple-50 dark:hover:bg-purple-950/30"}`,children:[t.jsxs("div",{className:"flex items-center justify-between text-sm",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:`w-4 h-4 rounded border-2 flex items-center justify-center ${De?"bg-gray-300 dark:bg-slate-600 border-gray-300 dark:border-slate-600":Xe?"bg-purple-600 border-purple-600":"border-gray-300 dark:border-slate-600"}`,children:(De||Xe)&&t.jsx(It,{className:"w-3 h-3 text-white"})}),t.jsx("span",{className:"font-medium text-gray-900 dark:text-white",children:ee.name})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[Pt&&t.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${Pt==="shared"?"bg-amber-100 dark:bg-amber-900/50 text-amber-700 dark:text-amber-400":"bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-400"}`,children:Pt}),De&&t.jsx("span",{className:"text-xs text-gray-500 dark:text-slate-400",children:"added"})]})]}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400 font-mono truncate ml-6",children:ee.path.replace(/^\/Users\/[^/]+/,"~")})]})]}),Ht&&cr.length>0&&t.jsx("div",{className:"ml-6 mt-1 space-y-1 border-l-2 border-gray-200 dark:border-slate-700 pl-2",children:cr.map(_r=>{var In;const ns=(In=S==null?void 0:S.projects)==null?void 0:In.includes(_r.dir),Ss=P.has(_r.dir),Zs=Qs(_r.dir,S==null?void 0:S.id);return t.jsxs("button",{type:"button",onClick:()=>!ns&&ia(_r.dir),disabled:ns,className:`w-full text-left p-2 rounded transition-colors ${ns?"bg-gray-100 dark:bg-slate-800 opacity-50 cursor-not-allowed":Ss?"bg-purple-100 dark:bg-purple-950/50 ring-2 ring-purple-500":"hover:bg-purple-50 dark:hover:bg-purple-950/30"}`,children:[t.jsxs("div",{className:"flex items-center justify-between text-sm",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("div",{className:`w-4 h-4 rounded border-2 flex items-center justify-center ${ns?"bg-gray-300 dark:bg-slate-600 border-gray-300 dark:border-slate-600":Ss?"bg-purple-600 border-purple-600":"border-gray-300 dark:border-slate-600"}`,children:(ns||Ss)&&t.jsx(It,{className:"w-3 h-3 text-white"})}),t.jsx("span",{className:"text-gray-700 dark:text-slate-300",children:_r.name})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[Zs&&t.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded ${Zs==="shared"?"bg-amber-100 dark:bg-amber-900/50 text-amber-700 dark:text-amber-400":"bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-400"}`,children:Zs}),ns&&t.jsx("span",{className:"text-xs text-gray-500 dark:text-slate-400",children:"added"})]})]}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400 font-mono truncate ml-6",children:_r.relativePath})]},_r.dir)})}),Ht&&cr.length===0&&!At&&t.jsx("div",{className:"ml-6 mt-1 pl-2 text-xs text-gray-400 dark:text-slate-500 italic",children:"No sub-projects found"})]},ee.id)})}):t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400 text-center py-4",children:"No projects registered. Add projects in the Projects view first."})]}),t.jsxs(St,{children:[t.jsx(ne,{variant:"outline",onClick:()=>{b(!1),A(new Set)},children:"Cancel"}),t.jsxs(ne,{onClick:uo,disabled:P.size===0||Q,className:"bg-purple-600 hover:bg-purple-700",children:[Q?t.jsx(Qe,{className:"w-4 h-4 animate-spin mr-2"}):t.jsx(Rt,{className:"w-4 h-4 mr-2"}),"Add Selected (",P.size,")"]})]})]})}),t.jsx(vt,{open:tr,onOpenChange:ee=>{ee||(Pr(!1),ts(""),Cr(null))},children:t.jsxs(ft,{children:[t.jsx(mt,{children:t.jsx(pt,{children:"Add Trigger Folder"})}),t.jsxs("div",{className:"space-y-4 py-4",children:[t.jsxs("p",{className:"text-sm text-gray-600 dark:text-slate-400",children:["Add a folder that will trigger the workstream ",t.jsx("strong",{children:qt==null?void 0:qt.name})," when you cd into it."]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-slate-300 mb-1 block",children:"Folder Path"}),t.jsx(Oe,{value:ps,onChange:ee=>ts(ee.target.value),placeholder:"~/path/to/folder",className:"font-mono"}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400 mt-1",children:"Use absolute path or ~ for home directory"})]})]}),t.jsxs(St,{children:[t.jsx(ne,{variant:"outline",onClick:()=>{Pr(!1),ts(""),Cr(null)},children:"Cancel"}),t.jsxs(ne,{onClick:Si,disabled:!ps.trim(),className:"bg-purple-600 hover:bg-purple-700",children:[t.jsx(fi,{className:"w-4 h-4 mr-2"}),"Add Folder"]})]})]})})]})}const E_={clarify:"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",plan:"bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200",execute:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200"},Oa={pending:t.jsx(Ga,{className:"w-4 h-4 text-gray-500"}),running:t.jsx(zg,{className:"w-4 h-4 text-green-500"}),paused:t.jsx(Sp,{className:"w-4 h-4 text-yellow-500"}),completed:t.jsx(vi,{className:"w-4 h-4 text-green-600"}),failed:t.jsx(Ki,{className:"w-4 h-4 text-red-500"}),cancelled:t.jsx(Ki,{className:"w-4 h-4 text-gray-500"})};function LW({activeProject:e=null}){var xl,vl,la,yl,bl,wl,ca,po,gn,xn,vn;const[r,s]=_.useState([]),[n,o]=_.useState(!0),[c,d]=_.useState(null),[l,u]=_.useState({}),{workstreams:f,activeId:m,fetch:h}=MN(),[g,w]=_.useState(""),[j,k]=_.useState(!1),[v,y]=_.useState(!1),[x,b]=_.useState(!1),[S,N]=_.useState(!1),[P,A]=_.useState(null),[E,M]=_.useState(!1),[I,B]=_.useState(null),[U,V]=_.useState(""),[Q,z]=_.useState(""),[H,Y]=_.useState(50),[K,O]=_.useState("DONE"),[T,F]=_.useState(!1),[$,D]=_.useState(!1),[X,te]=_.useState(!1),[fe,J]=_.useState(""),[W,le]=_.useState(""),[ae,re]=_.useState(!1),[de,Se]=_.useState(!1),[Re,Ue]=_.useState(null),[pe,_e]=_.useState("create"),[$e,Ge]=_.useState(""),[et,Nt]=_.useState(""),[ke,me]=_.useState(50),[be,Z]=_.useState("DONE"),[oe,we]=_.useState(""),[Ce,Fe]=_.useState(50),[He,ct]=_.useState(!1),[st,zt]=_.useState("DONE"),[Lr,Vr]=_.useState([]),[tr,Pr]=_.useState({stopHook:{},prepromptHook:{}}),[qt,Cr]=_.useState(!1),[ps,ts]=_.useState({needsInstall:!0}),[Fs,Bs]=_.useState(!1),[at,Wt]=_.useState(null),[lr,fr]=_.useState(null),[ks,Kt]=_.useState(!1),[Yt,Gr]=_.useState(!1),[ht,yr]=_.useState(null),[gs,rs]=_.useState(!0),[rt,mn]=_.useState(null),[pl,ss]=_.useState(!1);_.useEffect(()=>{Ar(),co(),ta(),h(),pn()},[h]);const Si=_.useRef(null);_.useEffect(()=>{if(!Yt||!ht){Si.current=null;return}Si.current=ht.status;const ie=setInterval(async()=>{var Le,Dt,Tr;try{const kt=(await he.getLoop(ht.id)).loop,Fr=Si.current!==kt.status,Br=["completed","paused","failed","cancelled"].includes(kt.status);if(Fr&&Br){clearInterval(ie);const os={id:kt.id,name:kt.name,task:(Le=kt.task)==null?void 0:Le.original,status:kt.status,pauseReason:kt.pauseReason,iterations:((Dt=kt.iterations)==null?void 0:Dt.current)||0,maxIterations:((Tr=kt.iterations)==null?void 0:Tr.max)||50,phase:kt.phase,startedAt:kt.startedAt,completedAt:kt.completedAt||new Date().toISOString(),duration:kt.startedAt?Math.round((Date.now()-new Date(kt.startedAt).getTime())/1e3):null};mn(os),kt.status==="completed"?q.success("Loop completed successfully!"):kt.status==="paused"?q.info(`Loop paused: ${kt.pauseReason||"unknown reason"}`):kt.status==="failed"?q.error("Loop failed"):kt.status==="cancelled"&&q.warning("Loop cancelled"),Ar(),gs&&kt.status==="completed"?setTimeout(()=>{Gr(!1),yr(null),ss(!0)},1500):ss(!0)}Si.current=kt.status}catch(is){console.error("Failed to poll loop status:",is)}},3e3);return()=>clearInterval(ie)},[Yt,ht,gs]);const pn=async()=>{try{const ie=await he.getRalphLoopPluginStatus();ts(ie)}catch(ie){console.error("Failed to load plugin status:",ie)}};_.useEffect(()=>{j&&m&&z(m)},[j,m]);const Ar=async()=>{try{o(!0);const ie=await he.getLoops();s(ie.loops||[]),u(ie.config||{})}catch{q.error("Failed to load loops")}finally{o(!1)}},co=async()=>{try{const Le=(await he.getLoopConfig()).config||{};u(Le),Fe(Le.maxIterations||50),ct(Le.autoApprovePlan||!1),zt(Le.completionPromise||"DONE"),Y(Le.maxIterations||50),O(Le.completionPromise||"DONE")}catch(ie){console.error("Failed to load config:",ie)}},ta=async()=>{try{const ie=await he.getLoopHookStatus();Pr(ie)}catch(ie){console.error("Failed to load hook status:",ie)}},ra=async()=>{try{const ie=await he.getLoopHistory();Vr(ie.completed||[])}catch{q.error("Failed to load history")}},Ci=async()=>{if(!U.trim()){q.error("Task description is required");return}await Qs(U)},sa=async()=>{if(!U.trim()){q.error("Enter a task description first");return}try{D(!0),le(U),_e("create");const ie=await he.tuneLoopPrompt(U,(e==null?void 0:e.path)||(e==null?void 0:e.dir)||null);ie.success?(J(ie.tunedPrompt),te(!0)):q.error(ie.error||"Failed to tune prompt")}catch(ie){q.error(ie.message)}finally{D(!1)}},na=()=>{pe==="edit"?Nt(fe):(V(fe),re(!0)),te(!1),q.success("Tuned prompt applied")},ia=()=>{te(!1)},uo=ie=>{ie.status==="failed"||ie.status==="paused"||ie.status==="cancelled"?(Ue(ie),Se(!0)):mo(ie.id)},rr=async()=>{var ie,Le,Dt,Tr;if(Re)try{D(!0);const is=((ie=Re.task)==null?void 0:ie.original)||"",kt=await he.getLoop(Re.id),Fr=kt.loop||Re,Br={status:Fr.status,pauseReason:Fr.pauseReason,iterations:((Le=Fr.iterations)==null?void 0:Le.current)||0,maxIterations:((Dt=Fr.iterations)==null?void 0:Dt.max)||50,phase:Fr.phase,clarifications:kt.clarifications||"",plan:kt.plan||"",iterationHistory:(((Tr=Fr.iterations)==null?void 0:Tr.history)||[]).slice(-5).map(go=>`Iteration ${go.n}: ${go.summary||"no summary"}`).join(`
3048
3048
  `)};let os="";Br.clarifications&&(os+=`=== Clarifications ===
3049
3049
  ${Br.clarifications}
3050
3050
 
@@ -3053,12 +3053,12 @@ ${Br.plan}
3053
3053
 
3054
3054
  `),Br.iterationHistory&&(os+=`=== Recent Iterations ===
3055
3055
  ${Br.iterationHistory}
3056
- `),Br.transcript=os;const ri=await he.tuneLoopPrompt(is,Re.projectPath||(e==null?void 0:e.path)||(e==null?void 0:e.dir)||null,Br);ri.success?(await he.updateLoop(Re.id,{task:{original:ri.tunedPrompt}}),q.success("Prompt tuned and loop updated"),Se(!1),await Or(Re.id),Ar()):q.error(ri.error||"Failed to tune prompt")}catch(is){q.error(is.message)}finally{D(!1),Ue(null)}},gl=async()=>{Re&&(Se(!1),await mo(Re.id),Ue(null))},Qs=async ie=>{try{F(!0);const Le=await he.createLoop(ie,{workstreamId:Q||null,projectPath:(e==null?void 0:e.path)||(e==null?void 0:e.dir)||null,maxIterations:parseInt(H,10)||50,completionPromise:K||"DONE"});Le.success?(q.success("Loop created"),k(!1),V(""),z(""),Y(Ce),O(st),re(!1),Ar()):q.error(Le.error||"Failed to create loop")}catch(Le){q.error(Le.message)}finally{F(!1)}},ho=async ie=>{if(ps.needsInstall){Wt(ie),fr("start"),Bs(!0);return}await Mn(ie)},Mn=async ie=>{try{const Le=await he.startLoop(ie);Le.success&&Le.loop?(q.success("Loop started - launching Claude Code"),yr(Le.loop),Gr(!0),Ar()):q.error(Le.error||"Failed to start loop")}catch(Le){q.error(Le.message)}},oa=async()=>{try{Kt(!0);const ie=await he.installRalphLoopPlugin();ie.success?(q.success("ralph-loop plugin installed"),ts({installed:!0,scope:"user",needsInstall:!1}),Bs(!1),at&&(lr==="resume"?await Or(at):await Mn(at),Wt(null),fr(null))):q.error(ie.error||"Failed to install plugin")}catch(ie){q.error(ie.message)}finally{Kt(!1)}},fo=()=>{Bs(!1),Wt(null),fr(null)},ti=_.useCallback(async(ie,Le)=>{var Dt,Tr,is,kt,Fr,Br,os,ri,go,ji,Ni,si,xo,Kc;if(ht)try{const wt=(await he.getLoop(ht.id)).loop;if(wt.taskComplete||wt.status==="completed")q.success("Loop completed successfully!"),mn({id:wt.id,name:wt.name,task:(Dt=wt.task)==null?void 0:Dt.original,status:"completed",iterations:((Tr=wt.iterations)==null?void 0:Tr.current)||0,maxIterations:((is=wt.iterations)==null?void 0:is.max)||50,phase:wt.phase,startedAt:wt.startedAt,completedAt:wt.completedAt||new Date().toISOString()}),ss(!0),Gr(!1),yr(null);else if(wt.status==="paused")q.info(`Loop paused: ${wt.pauseReason||"user requested"}`),mn({id:wt.id,name:wt.name,task:(kt=wt.task)==null?void 0:kt.original,status:"paused",pauseReason:wt.pauseReason,iterations:((Fr=wt.iterations)==null?void 0:Fr.current)||0,maxIterations:((Br=wt.iterations)==null?void 0:Br.max)||50,phase:wt.phase,startedAt:wt.startedAt,completedAt:new Date().toISOString()}),ss(!0);else if(ie===0&&!Le)await he.completeLoop(wt.id),q.success("Loop completed successfully!"),mn({id:wt.id,name:wt.name,task:(os=wt.task)==null?void 0:os.original,status:"completed",iterations:((ri=wt.iterations)==null?void 0:ri.current)||0,maxIterations:((go=wt.iterations)==null?void 0:go.max)||50,phase:"execute",startedAt:wt.startedAt,completedAt:new Date().toISOString()}),ss(!0),Gr(!1),yr(null);else if(((ji=wt.iterations)==null?void 0:ji.current)>=((Ni=wt.iterations)==null?void 0:Ni.max))q.warning("Loop reached max iterations"),await he.pauseLoop(wt.id);else{const da=Le?`Signal: ${Le}`:`Exit code: ${ie}`;mn({id:wt.id,name:wt.name,task:(si=wt.task)==null?void 0:si.original,status:"paused",pauseReason:da,iterations:((xo=wt.iterations)==null?void 0:xo.current)||0,maxIterations:((Kc=wt.iterations)==null?void 0:Kc.max)||50,phase:wt.phase,startedAt:wt.startedAt,completedAt:new Date().toISOString()}),ss(!0)}Ar()}catch(Yc){console.error("Failed to check loop status:",Yc)}},[ht]),xs=async ie=>{try{const Le=await he.pauseLoop(ie);Le.success?(q.success("Loop paused"),Ar()):q.error(Le.error||"Failed to pause loop")}catch(Le){q.error(Le.message)}},mo=async ie=>{if(ps.needsInstall){Wt(ie),fr("resume"),Bs(!0);return}await Or(ie)},Or=async ie=>{try{const Le=await he.resumeLoop(ie);Le.success&&Le.loop?(q.success("Loop resumed - launching Claude Code"),yr(Le.loop),Gr(!0),Ar()):q.error(Le.error||"Failed to resume loop")}catch(Le){q.error(Le.message)}},ee=async ie=>{if(confirm("Cancel this loop?"))try{const Le=await he.cancelLoop(ie);Le.success?(q.success("Loop cancelled"),Ar()):q.error(Le.error||"Failed to cancel loop")}catch(Le){q.error(Le.message)}},De=async ie=>{if(confirm("Delete this loop and all its data?"))try{const Le=await he.deleteLoop(ie);Le.success?(q.success("Loop deleted"),Ar()):q.error(Le.error||"Failed to delete loop")}catch(Le){q.error(Le.message)}},Xe=ie=>{var Le,Dt;B(ie),Ge(ie.name||""),Nt(((Le=ie.task)==null?void 0:Le.original)||""),me(((Dt=ie.iterations)==null?void 0:Dt.max)||50),Z(ie.completionPromise||"DONE"),we(ie.workstreamId||""),M(!0)},Pt=async()=>{if(I)try{F(!0);const ie={name:$e,task:{original:et},iterations:{max:parseInt(ke,10)},completionPromise:be,workstreamId:oe||null},Le=await he.updateLoop(I.id,ie);Le.success?(q.success("Loop updated"),M(!1),B(null),Ar()):q.error(Le.error||"Failed to update loop")}catch(ie){q.error(ie.message)}finally{F(!1)}},Ht=async ie=>{var Le,Dt;try{F(!0);const Tr=await he.createLoop(((Le=ie.task)==null?void 0:Le.original)||"",{name:`${ie.name} (copy)`,workstreamId:ie.workstreamId||null,projectPath:ie.projectPath||(e==null?void 0:e.path)||(e==null?void 0:e.dir)||null,maxIterations:((Dt=ie.iterations)==null?void 0:Dt.max)||50,completionPromise:ie.completionPromise||"DONE"});Tr.success?(q.success("Loop copied"),Ar()):q.error(Tr.error||"Failed to copy loop")}catch(Tr){q.error(Tr.message)}finally{F(!1)}},At=async ie=>{try{const Le=await he.approveLoop(ie);Le.success?(q.success("Plan approved"),Ar()):q.error(Le.error||"Failed to approve plan")}catch(Le){q.error(Le.message)}},cr=async()=>{try{F(!0);const ie=await he.updateLoopConfig({maxIterations:parseInt(Ce,10),autoApprovePlan:He,completionPromise:st});ie.success?(q.success("Configuration saved"),y(!1),co()):q.error(ie.error||"Failed to save configuration")}catch(ie){q.error(ie.message)}finally{F(!1)}},jr=async()=>{try{Cr(!0);const ie=await he.installLoopHooks();ie.success?(q.success("Hooks installed successfully"),ta()):q.error(ie.error||"Failed to install hooks")}catch(ie){q.error(ie.message)}finally{Cr(!1)}},_r=async ie=>{try{const Le=await he.getLoop(ie.id);A({...Le.loop,clarifications:Le.clarifications,plan:Le.plan}),N(!0)}catch{q.error("Failed to load loop details")}},ns=ie=>{navigator.clipboard.writeText(ie),q.success("Copied to clipboard")},Ss=ie=>ie?new Date(ie).toLocaleString():"-",Zs=ie=>ie.iterations?Math.min(100,ie.iterations.current/ie.iterations.max*100):0,In=((xl=tr.stopHook)==null?void 0:xl.registered)&&((vl=tr.prepromptHook)==null?void 0:vl.registered),qc=ie=>{if(!ie)return null;const Le=f.find(Dt=>Dt.id===ie);return(Le==null?void 0:Le.name)||ie},aa=g?r.filter(ie=>ie.workstreamId===g):r,Tt=(ie,Le=!1)=>{var kt,Fr;const Dt=((kt=ie.task)==null?void 0:kt.original)||"";if((Fr=ie.iterations)!=null&&Fr.max,ie.completionPromise,Le){const Br=Dt.replace(/\n+/g," ").substring(0,100),os=Dt.length>100?"...":"";return`claude --dangerously-skip-permissions "${Br.replace(/"/g,'\\"')}${os}"`}return{startCmd:"claude --dangerously-skip-permissions",skillCmd:Dt}};return t.jsxs("div",{className:"p-6 space-y-6 max-w-6xl mx-auto",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[t.jsx(vc,{className:"w-6 h-6"}),"Ralph Loops"]}),t.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Autonomous development loops with iteration tracking and safety controls"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[f.length>0&&t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx($g,{className:"w-4 h-4 text-muted-foreground"}),t.jsxs("select",{className:"text-sm border rounded px-2 py-1 bg-background",value:g,onChange:ie=>w(ie.target.value),children:[t.jsx("option",{value:"",children:"All workstreams"}),f.map(ie=>t.jsx("option",{value:ie.id,children:ie.name},ie.id))]})]}),t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsxs(ne,{variant:"outline",size:"sm",onClick:()=>{ra(),b(!0)},children:[t.jsx(Tu,{className:"w-4 h-4 mr-1"}),"History"]})}),t.jsx(Ot,{children:"View completed loops"})]})}),t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsxs(ne,{variant:"outline",size:"sm",onClick:()=>y(!0),children:[t.jsx(Xs,{className:"w-4 h-4 mr-1"}),"Config"]})}),t.jsx(Ot,{children:"Configure loop defaults"})]})}),t.jsxs(ne,{onClick:()=>k(!0),children:[t.jsx(Rt,{className:"w-4 h-4 mr-1"}),"New Loop"]})]})]}),!In&&t.jsxs("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4 flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Is,{className:"w-5 h-5 text-yellow-600"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium text-yellow-800 dark:text-yellow-200",children:"Hooks not installed"}),t.jsx("p",{className:"text-sm text-yellow-700 dark:text-yellow-300",children:"Install the Ralph Loop hooks to enable automatic loop continuation"})]})]}),t.jsxs(ne,{variant:"outline",size:"sm",onClick:jr,disabled:qt,children:[qt?t.jsx(Qe,{className:"w-4 h-4 animate-spin mr-1"}):null,"Install Hooks"]})]}),n?t.jsx("div",{className:"flex items-center justify-center py-12",children:t.jsx(Qe,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):aa.length===0?t.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[t.jsx(vc,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),t.jsx("p",{className:"text-lg font-medium",children:g?"No loops in this workstream":"No loops yet"}),t.jsx("p",{className:"text-sm mt-1",children:"Create a loop to start autonomous development"})]}):t.jsx("div",{className:"space-y-3",children:aa.map(ie=>{var Le,Dt,Tr,is,kt;return t.jsxs("div",{className:"border rounded-lg bg-card overflow-hidden",children:[t.jsxs("div",{className:"p-4 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>d(c===ie.id?null:ie.id),children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[c===ie.id?t.jsx(hr,{className:"w-4 h-4 text-muted-foreground"}):t.jsx(Qr,{className:"w-4 h-4 text-muted-foreground"}),Oa[ie.status]||Oa.pending,t.jsxs("div",{children:[t.jsx("h3",{className:"font-medium",children:ie.name}),t.jsx("p",{className:"text-sm text-muted-foreground truncate max-w-md",children:((Le=ie.task)==null?void 0:Le.original)||"No task"})]})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[ie.workstreamId&&t.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200 flex items-center gap-1",children:[t.jsx(Hn,{className:"w-3 h-3"}),qc(ie.workstreamId)]}),t.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${E_[ie.phase]||"bg-gray-100 dark:bg-gray-800"}`,children:ie.phase}),t.jsxs("span",{className:"text-sm text-muted-foreground",children:[((Dt=ie.iterations)==null?void 0:Dt.current)||0,"/",((Tr=ie.iterations)==null?void 0:Tr.max)||50]}),t.jsxs("div",{className:"flex items-center gap-1",onClick:Fr=>Fr.stopPropagation(),children:[ie.status==="pending"&&t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>ho(ie.id),children:t.jsx(zg,{className:"w-4 h-4"})})}),t.jsx(Ot,{children:"Start loop"})]})}),ie.status==="running"&&t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>xs(ie.id),children:t.jsx(Sp,{className:"w-4 h-4"})})}),t.jsx(Ot,{children:"Pause loop"})]})}),ie.status==="paused"&&t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>uo(ie),children:t.jsx(Qd,{className:"w-4 h-4"})})}),t.jsx(Ot,{children:"Resume loop"})]})}),(ie.status==="cancelled"||ie.status==="failed")&&t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>uo(ie),children:t.jsx(Qd,{className:"w-4 h-4"})})}),t.jsx(Ot,{children:"Restart loop"})]})}),ie.phase==="plan"&&ie.status==="running"&&t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>At(ie.id),children:t.jsx(It,{className:"w-4 h-4"})})}),t.jsx(Ot,{children:"Approve plan"})]})}),t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>Xe(ie),children:t.jsx(al,{className:"w-4 h-4"})})}),t.jsx(Ot,{children:"Edit loop"})]})}),t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>Ht(ie),children:t.jsx(Bo,{className:"w-4 h-4"})})}),t.jsx(Ot,{children:"Duplicate loop"})]})}),t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>_r(ie),children:t.jsx(Fg,{className:"w-4 h-4"})})}),t.jsx(Ot,{children:"View details"})]})}),(ie.status==="running"||ie.status==="paused")&&t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>ee(ie.id),children:t.jsx(Ki,{className:"w-4 h-4"})})}),t.jsx(Ot,{children:"Cancel loop"})]})}),t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>De(ie.id),children:t.jsx(fs,{className:"w-4 h-4 text-red-500"})})}),t.jsx(Ot,{children:"Delete loop"})]})})]})]})]}),t.jsxs("div",{className:"mt-3",children:[t.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground mb-1",children:[t.jsx("span",{children:"Iterations"}),t.jsxs("span",{children:[((is=ie.iterations)==null?void 0:is.current)||0," / ",((kt=ie.iterations)==null?void 0:kt.max)||50]})]}),t.jsx("div",{className:"h-1.5 bg-muted rounded-full overflow-hidden",children:t.jsx("div",{className:"h-full bg-blue-500 transition-all",style:{width:`${Zs(ie)}%`}})})]})]}),c===ie.id&&t.jsxs("div",{className:"border-t p-4 bg-muted/30 space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"ID:"}),t.jsx("span",{className:"ml-2 font-mono",children:ie.id}),t.jsx(ne,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 ml-1",onClick:()=>ns(ie.id),children:t.jsx(Bo,{className:"w-3 h-3"})})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Status:"}),t.jsxs("span",{className:"ml-2",children:[ie.status,ie.pauseReason?` (${ie.pauseReason})`:""]})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Created:"}),t.jsx("span",{className:"ml-2",children:Ss(ie.createdAt)})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Updated:"}),t.jsx("span",{className:"ml-2",children:Ss(ie.updatedAt)})]}),ie.workstreamId&&t.jsxs("div",{className:"col-span-2",children:[t.jsx("span",{className:"text-muted-foreground",children:"Workstream:"}),t.jsxs("span",{className:"ml-2 inline-flex items-center gap-1",children:[t.jsx(Hn,{className:"w-3 h-3 text-purple-500"}),qc(ie.workstreamId)]})]})]}),t.jsxs("div",{className:"bg-muted p-3 rounded-md",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx(Ut,{className:"w-4 h-4"}),t.jsx("span",{className:"text-sm font-medium",children:"Run this loop (uses official ralph-loop plugin):"})]}),t.jsx("code",{className:"text-xs bg-background p-2 rounded block whitespace-pre-wrap",children:Tt(ie,!0)})]})]})]},ie.id)})}),t.jsx(vt,{open:j,onOpenChange:k,children:t.jsxs(ft,{className:"sm:max-w-lg",children:[t.jsx(mt,{children:t.jsx(pt,{children:"Create New Loop"})}),t.jsxs("div",{className:"space-y-4 py-4",children:[t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("label",{className:"text-sm font-medium",children:"Task Description"}),t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsxs(ne,{variant:"outline",size:"sm",onClick:sa,disabled:$||!U.trim(),className:"h-7 text-xs",children:[$?t.jsx(Qe,{className:"w-3 h-3 animate-spin mr-1"}):t.jsx(Wr,{className:"w-3 h-3 mr-1"}),"Tune with AI"]})}),t.jsx(Ot,{children:t.jsx("p",{className:"max-w-xs",children:"Use Claude to optimize your prompt for Ralph Loop execution - adds clear completion signals, verification steps, and acceptance criteria."})})]})})]}),t.jsx(yt,{placeholder:"Describe what you want Claude to accomplish...",value:U,onChange:ie=>{V(ie.target.value),re(!1)},rows:4}),t.jsxs("div",{className:"flex items-center justify-between mt-1",children:[t.jsx("p",{className:"text-xs text-muted-foreground",children:"Be specific about the goal. The loop will continue until this task is completed."}),ae&&t.jsxs("span",{className:"text-xs text-green-600 dark:text-green-400 flex items-center gap-1",children:[t.jsx(Vt,{className:"w-3 h-3"}),"AI-tuned"]})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Project"}),t.jsx("div",{className:"text-sm p-2 bg-muted rounded-md",children:e?t.jsx("span",{className:"font-mono",children:e.name||e.path||e.dir}):t.jsx("span",{className:"text-muted-foreground",children:"No project selected - loop will run in server directory"})})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Max Iterations"}),t.jsx(Oe,{type:"number",value:H,onChange:ie=>Y(ie.target.value),min:1,max:1e3}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Safety limit for the loop"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Completion Promise"}),t.jsx(Oe,{value:K,onChange:ie=>O(ie.target.value),placeholder:"DONE"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Text that signals completion"})]})]}),f.length>0&&t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Workstream (optional)"}),t.jsxs("select",{className:"w-full border rounded-md p-2 bg-background",value:Q,onChange:ie=>z(ie.target.value),children:[t.jsx("option",{value:"",children:"No workstream"}),f.map(ie=>t.jsx("option",{value:ie.id,children:ie.name},ie.id))]})]})]}),t.jsxs(St,{children:[t.jsx(ne,{variant:"outline",onClick:()=>k(!1),children:"Cancel"}),t.jsxs(ne,{onClick:Ci,disabled:T||!U.trim(),children:[T?t.jsx(Qe,{className:"w-4 h-4 animate-spin mr-1"}):null,"Create Loop"]})]})]})}),t.jsx(vt,{open:E,onOpenChange:M,children:t.jsxs(ft,{className:"sm:max-w-lg",children:[t.jsx(mt,{children:t.jsx(pt,{children:"Edit Loop"})}),t.jsxs("div",{className:"space-y-4 py-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Name"}),t.jsx(Oe,{placeholder:"Loop name",value:$e,onChange:ie=>Ge(ie.target.value)})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("label",{className:"text-sm font-medium",children:"Task Description"}),t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsxs(ne,{variant:"outline",size:"sm",onClick:async()=>{if(!et.trim()){q.error("Enter a task description first");return}try{D(!0),le(et),_e("edit");const ie=await he.tuneLoopPrompt(et,(I==null?void 0:I.projectPath)||(e==null?void 0:e.path)||(e==null?void 0:e.dir)||null);ie.success?(J(ie.tunedPrompt),te(!0)):q.error(ie.error||"Failed to tune prompt")}catch(ie){q.error(ie.message)}finally{D(!1)}},disabled:$||!et.trim(),className:"h-7 text-xs",children:[$?t.jsx(Qe,{className:"w-3 h-3 animate-spin mr-1"}):t.jsx(Wr,{className:"w-3 h-3 mr-1"}),"Tune with AI"]})}),t.jsx(Ot,{children:t.jsx("p",{className:"max-w-xs",children:"Use Claude to optimize your prompt for Ralph Loop execution."})})]})})]}),t.jsx(yt,{placeholder:"Describe what you want Claude to accomplish...",value:et,onChange:ie=>Nt(ie.target.value),rows:4})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Max Iterations"}),t.jsx(Oe,{type:"number",value:ke,onChange:ie=>me(ie.target.value),min:1,max:1e3})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Completion Promise"}),t.jsx(Oe,{value:be,onChange:ie=>Z(ie.target.value),placeholder:"DONE"})]})]}),f.length>0&&t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Workstream"}),t.jsxs("select",{className:"w-full border rounded-md p-2 bg-background",value:oe,onChange:ie=>we(ie.target.value),children:[t.jsx("option",{value:"",children:"No workstream"}),f.map(ie=>t.jsx("option",{value:ie.id,children:ie.name},ie.id))]})]}),I&&t.jsxs("div",{className:"text-xs text-muted-foreground",children:[t.jsxs("span",{children:["ID: ",I.id]}),t.jsx("span",{className:"mx-2",children:"|"}),t.jsxs("span",{children:["Status: ",I.status]}),t.jsx("span",{className:"mx-2",children:"|"}),t.jsxs("span",{children:["Phase: ",I.phase]})]})]}),t.jsxs(St,{children:[t.jsx(ne,{variant:"outline",onClick:()=>M(!1),children:"Cancel"}),t.jsxs(ne,{onClick:Pt,disabled:T||!et.trim(),children:[T?t.jsx(Qe,{className:"w-4 h-4 animate-spin mr-1"}):null,"Save Changes"]})]})]})}),t.jsx(vt,{open:v,onOpenChange:y,children:t.jsxs(ft,{className:"sm:max-w-md",children:[t.jsx(mt,{children:t.jsx(pt,{children:"Loop Configuration"})}),t.jsxs("div",{className:"space-y-4 py-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Max Iterations"}),t.jsx(Oe,{type:"number",value:Ce,onChange:ie=>Fe(ie.target.value),min:1,max:1e3}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Loop will pause after this many iterations"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Default Completion Promise"}),t.jsx(Oe,{value:st,onChange:ie=>zt(ie.target.value),placeholder:"DONE"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Default text that signals loop completion (used with official ralph-loop plugin)"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"checkbox",id:"autoApprovePlan",checked:He,onChange:ie=>ct(ie.target.checked),className:"rounded"}),t.jsx("label",{htmlFor:"autoApprovePlan",className:"text-sm",children:"Auto-approve plans (skip manual plan approval)"})]})]}),t.jsxs(St,{children:[t.jsx(ne,{variant:"outline",onClick:()=>y(!1),children:"Cancel"}),t.jsxs(ne,{onClick:cr,disabled:T,children:[T?t.jsx(Qe,{className:"w-4 h-4 animate-spin mr-1"}):null,"Save"]})]})]})}),t.jsx(vt,{open:x,onOpenChange:b,children:t.jsxs(ft,{className:"sm:max-w-2xl max-h-[80vh] overflow-y-auto",children:[t.jsx(mt,{children:t.jsx(pt,{children:"Loop History"})}),t.jsx("div",{className:"space-y-3 py-4",children:Lr.length===0?t.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No completed loops yet"}):Lr.slice().reverse().map(ie=>t.jsxs("div",{className:"border rounded-lg p-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[Oa[ie.status]||Oa.completed,t.jsx("span",{className:"font-medium",children:ie.name})]}),t.jsx("span",{className:"text-xs text-muted-foreground",children:Ss(ie.completedAt)})]}),t.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:ie.task}),t.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:t.jsxs("span",{children:["Iterations: ",ie.totalIterations]})})]},ie.id))})]})}),t.jsx(vt,{open:S,onOpenChange:N,children:t.jsxs(ft,{className:"sm:max-w-3xl max-h-[80vh] overflow-y-auto",children:[t.jsx(mt,{children:t.jsx(pt,{children:(P==null?void 0:P.name)||"Loop Details"})}),P&&t.jsxs("div",{className:"space-y-4 py-4",children:[t.jsxs("div",{className:"grid grid-cols-3 gap-4 text-sm",children:[t.jsxs("div",{className:"border rounded p-3",children:[t.jsx("div",{className:"text-muted-foreground text-xs mb-1",children:"Phase"}),t.jsx("span",{className:`text-sm px-2 py-0.5 rounded-full ${E_[P.phase]||""}`,children:P.phase})]}),t.jsxs("div",{className:"border rounded p-3",children:[t.jsx("div",{className:"text-muted-foreground text-xs mb-1",children:"Status"}),t.jsxs("div",{className:"flex items-center gap-1",children:[Oa[P.status],t.jsx("span",{children:P.status})]})]}),t.jsxs("div",{className:"border rounded p-3",children:[t.jsx("div",{className:"text-muted-foreground text-xs mb-1",children:"Progress"}),t.jsxs("span",{children:[((la=P.iterations)==null?void 0:la.current)||0," / ",((yl=P.iterations)==null?void 0:yl.max)||50]})]})]}),t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium mb-2",children:"Task"}),t.jsx("div",{className:"bg-muted p-3 rounded text-sm",children:(bl=P.task)==null?void 0:bl.original})]}),P.clarifications&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium mb-2",children:"Clarifications"}),t.jsx("div",{className:"bg-muted p-3 rounded text-sm whitespace-pre-wrap max-h-40 overflow-y-auto",children:P.clarifications})]}),P.plan&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium mb-2",children:"Plan"}),t.jsx("div",{className:"bg-muted p-3 rounded text-sm whitespace-pre-wrap max-h-60 overflow-y-auto font-mono",children:P.plan})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium mb-2",children:"Max Iterations"}),t.jsx("div",{className:"bg-muted p-2 rounded text-sm",children:((wl=P.iterations)==null?void 0:wl.max)||50})]}),t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium mb-2",children:"Completion Promise"}),t.jsxs("div",{className:"bg-muted p-2 rounded text-sm font-mono",children:["<promise>",P.completionPromise||"DONE","</promise>"]})]})]}),t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium mb-2",children:"Run Command (uses official ralph-loop plugin)"}),t.jsx("code",{className:"text-xs bg-muted p-3 rounded block whitespace-pre-wrap",children:Tt(P,!0)})]})]})]})}),t.jsx(vt,{open:Fs,onOpenChange:Bs,children:t.jsxs(ft,{className:"sm:max-w-md",children:[t.jsx(mt,{children:t.jsxs(pt,{className:"flex items-center gap-2",children:[t.jsx(yi,{className:"w-5 h-5"}),"Install ralph-loop Plugin"]})}),t.jsxs("div",{className:"py-4",children:[t.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:["The ",t.jsx("code",{className:"bg-muted px-1 rounded",children:"ralph-loop"})," plugin is required to run loops. This plugin provides the ",t.jsx("code",{className:"bg-muted px-1 rounded",children:"/ralph-loop"})," command that enables autonomous iteration."]}),ps.scope==="project"&&t.jsx("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded p-3 mb-4",children:t.jsxs("p",{className:"text-sm text-yellow-800 dark:text-yellow-200",children:["Plugin is currently installed only for project: ",t.jsx("br",{}),t.jsx("code",{className:"text-xs",children:ps.projectPath})]})}),t.jsx("p",{className:"text-sm",children:"Install the plugin globally (user scope) to use loops from any project?"})]}),t.jsxs(St,{children:[t.jsx(ne,{variant:"outline",onClick:fo,disabled:ks,children:"Cancel"}),t.jsx(ne,{onClick:oa,disabled:ks,children:ks?t.jsxs(t.Fragment,{children:[t.jsx(Qe,{className:"w-4 h-4 animate-spin mr-1"}),"Installing..."]}):t.jsxs(t.Fragment,{children:[t.jsx(yi,{className:"w-4 h-4 mr-1"}),"Install Plugin"]})})]})]})}),t.jsx(Xj,{open:Yt,onOpenChange:ie=>{Gr(ie),ie||(yr(null),Ar())},title:ht?`Loop: ${ht.name}`:"Running Loop",description:ht?((po=(ca=ht.task)==null?void 0:ca.original)==null?void 0:po.substring(0,100))+(((xn=(gn=ht.task)==null?void 0:gn.original)==null?void 0:xn.length)>100?"...":""):"",cwd:ht==null?void 0:ht.projectPath,initialCommand:ht?Tt(ht).startCmd:"",delayedCommand:ht?Tt(ht).skillCmd:"",delayedCommandDelay:5e3,env:ht?{CODER_LOOP_ID:ht.id,...ht.workstreamId&&{CODER_WORKSTREAM:ht.workstreamId}}:{},onExit:ti,headerExtra:t.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer select-none",children:[t.jsx("input",{type:"checkbox",checked:gs,onChange:ie=>rs(ie.target.checked),className:"rounded"}),"Auto-close when done"]})}),t.jsx(vt,{open:X,onOpenChange:te,children:t.jsxs(ft,{className:"sm:max-w-2xl max-h-[80vh] overflow-y-auto",children:[t.jsx(mt,{children:t.jsxs(pt,{className:"flex items-center gap-2",children:[t.jsx(Wr,{className:"w-5 h-5 text-purple-500"}),"AI-Tuned Prompt"]})}),t.jsxs("div",{className:"space-y-4 py-4",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium mb-2 text-muted-foreground",children:"Original Prompt"}),t.jsx("div",{className:"bg-muted p-3 rounded text-sm whitespace-pre-wrap max-h-32 overflow-y-auto",children:W})]}),t.jsxs("div",{children:[t.jsxs("h4",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[t.jsx(Vt,{className:"w-4 h-4 text-purple-500"}),"Tuned Prompt"]}),t.jsx(yt,{value:fe,onChange:ie=>J(ie.target.value),rows:10,className:"font-mono text-sm"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"You can edit the tuned prompt before accepting it."})]})]}),t.jsxs(St,{children:[t.jsx(ne,{variant:"outline",onClick:ia,children:"Keep Original"}),t.jsxs(ne,{onClick:na,children:[t.jsx(It,{className:"w-4 h-4 mr-1"}),"Use Tuned Prompt"]})]})]})}),t.jsx(vt,{open:de,onOpenChange:Se,children:t.jsxs(ft,{className:"sm:max-w-md",children:[t.jsx(mt,{children:t.jsxs(pt,{className:"flex items-center gap-2",children:[t.jsx(Qd,{className:"w-5 h-5"}),"Resume Loop"]})}),t.jsx("div",{className:"py-4",children:Re&&t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"text-sm mb-4",children:["This loop ",Re.status==="failed"?"failed":Re.status==="cancelled"?"was cancelled":"was paused",Re.pauseReason&&`: ${Re.pauseReason}`]}),t.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Would you like to tune the prompt with AI before resuming? This can help add guardrails based on what went wrong."}),t.jsx("div",{className:"bg-muted p-3 rounded text-sm max-h-32 overflow-y-auto",children:(vn=Re.task)==null?void 0:vn.original})]})}),t.jsxs(St,{className:"flex-col sm:flex-row gap-2",children:[t.jsx(ne,{variant:"outline",onClick:()=>{Se(!1),Ue(null)},children:"Cancel"}),t.jsx(ne,{variant:"secondary",onClick:gl,children:"Resume As-Is"}),t.jsxs(ne,{onClick:rr,disabled:$,children:[$?t.jsx(Qe,{className:"w-4 h-4 animate-spin mr-1"}):t.jsx(Wr,{className:"w-4 h-4 mr-1"}),"Tune & Resume"]})]})]})}),t.jsx(vt,{open:pl,onOpenChange:ss,children:t.jsxs(ft,{className:"sm:max-w-md",children:[t.jsx(mt,{children:t.jsxs(pt,{className:"flex items-center gap-2",children:[(rt==null?void 0:rt.status)==="completed"&&t.jsxs(t.Fragment,{children:[t.jsx(vi,{className:"w-5 h-5 text-green-600"})," Loop Completed"]}),(rt==null?void 0:rt.status)==="paused"&&t.jsxs(t.Fragment,{children:[t.jsx(Sp,{className:"w-5 h-5 text-yellow-500"})," Loop Paused"]}),(rt==null?void 0:rt.status)==="failed"&&t.jsxs(t.Fragment,{children:[t.jsx(Ki,{className:"w-5 h-5 text-red-500"})," Loop Failed"]}),(rt==null?void 0:rt.status)==="cancelled"&&t.jsxs(t.Fragment,{children:[t.jsx(Ki,{className:"w-5 h-5 text-gray-500"})," Loop Cancelled"]})]})}),rt&&t.jsxs("div",{className:"space-y-4 py-4",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium mb-1",children:"Task"}),t.jsx("p",{className:"text-sm text-muted-foreground bg-muted p-2 rounded",children:rt.task})]}),rt.pauseReason&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium mb-1",children:"Reason"}),t.jsx("p",{className:"text-sm text-muted-foreground bg-muted p-2 rounded",children:rt.pauseReason})]}),t.jsxs("div",{className:"grid grid-cols-3 gap-3 text-sm",children:[t.jsxs("div",{className:"border rounded p-3",children:[t.jsx("div",{className:"text-muted-foreground text-xs mb-1",children:"Status"}),t.jsxs("div",{className:"font-medium flex items-center gap-1",children:[Oa[rt.status],t.jsx("span",{className:"capitalize",children:rt.status})]})]}),t.jsxs("div",{className:"border rounded p-3",children:[t.jsx("div",{className:"text-muted-foreground text-xs mb-1",children:"Iterations"}),t.jsxs("div",{className:"font-medium",children:[rt.iterations," / ",rt.maxIterations]})]}),t.jsxs("div",{className:"border rounded p-3",children:[t.jsx("div",{className:"text-muted-foreground text-xs mb-1",children:"Duration"}),t.jsx("div",{className:"font-medium",children:rt.duration!=null?rt.duration<60?`${rt.duration}s`:rt.duration<3600?`${Math.floor(rt.duration/60)}m ${rt.duration%60}s`:`${Math.floor(rt.duration/3600)}h ${Math.floor(rt.duration%3600/60)}m`:"-"})]})]}),t.jsxs("div",{className:"text-xs text-muted-foreground",children:[rt.status==="completed"?"Completed":"Stopped"," at ",Ss(rt.completedAt)]})]}),t.jsxs(St,{children:[t.jsx(ne,{variant:"outline",onClick:()=>ss(!1),children:"Close"}),((rt==null?void 0:rt.status)==="paused"||(rt==null?void 0:rt.status)==="failed"||(rt==null?void 0:rt.status)==="cancelled")&&t.jsxs(ne,{onClick:()=>{if(ss(!1),rt!=null&&rt.id){const ie=r.find(Le=>Le.id===rt.id);ie&&uo(ie)}},children:[t.jsx(Qd,{className:"w-4 h-4 mr-1"}),(rt==null?void 0:rt.status)==="paused"?"Resume":"Restart"]}),t.jsx(ne,{variant:"secondary",onClick:()=>{if(ss(!1),rt!=null&&rt.id){const ie=r.find(Le=>Le.id===rt.id);ie&&_r(ie)}},children:"View Details"})]})]})})]})}function LW(e,r=[]){let s=[];function n(c,d){const l=_.createContext(d);l.displayName=c+"Context";const u=s.length;s=[...s,d];const f=h=>{var y;const{scope:g,children:w,...j}=h,k=((y=g==null?void 0:g[e])==null?void 0:y[u])||l,v=_.useMemo(()=>j,Object.values(j));return t.jsx(k.Provider,{value:v,children:w})};f.displayName=c+"Provider";function m(h,g){var k;const w=((k=g==null?void 0:g[e])==null?void 0:k[u])||l,j=_.useContext(w);if(j)return j;if(d!==void 0)return d;throw new Error(`\`${h}\` must be used within \`${c}\``)}return[f,m]}const o=()=>{const c=s.map(d=>_.createContext(d));return function(l){const u=(l==null?void 0:l[e])||c;return _.useMemo(()=>({[`__scope${e}`]:{...l,[e]:u}}),[l,u])}};return o.scopeName=e,[n,OW(o,...r)]}function OW(...e){const r=e[0];if(e.length===1)return r;const s=()=>{const n=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(c){const d=n.reduce((l,{useScope:u,scopeName:f})=>{const h=u(c)[`__scope${f}`];return{...l,...h}},{});return _.useMemo(()=>({[`__scope${r.scopeName}`]:d}),[d])}};return s.scopeName=r.scopeName,s}var FW=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],I2=FW.reduce((e,r)=>{const s=sh(`Primitive.${r}`),n=_.forwardRef((o,c)=>{const{asChild:d,...l}=o,u=d?s:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),t.jsx(u,{...l,ref:c})});return n.displayName=`Primitive.${r}`,{...e,[r]:n}},{}),Zx="Progress",e0=100,[BW]=LW(Zx),[$W,HW]=BW(Zx),D2=_.forwardRef((e,r)=>{const{__scopeProgress:s,value:n=null,max:o,getValueLabel:c=zW,...d}=e;(o||o===0)&&!P_(o)&&console.error(WW(`${o}`,"Progress"));const l=P_(o)?o:e0;n!==null&&!A_(n,l)&&console.error(UW(`${n}`,"Progress"));const u=A_(n,l)?n:null,f=qu(u)?c(u,l):void 0;return t.jsx($W,{scope:s,value:u,max:l,children:t.jsx(I2.div,{"aria-valuemax":l,"aria-valuemin":0,"aria-valuenow":qu(u)?u:void 0,"aria-valuetext":f,role:"progressbar","data-state":F2(u,l),"data-value":u??void 0,"data-max":l,...d,ref:r})})});D2.displayName=Zx;var L2="ProgressIndicator",O2=_.forwardRef((e,r)=>{const{__scopeProgress:s,...n}=e,o=HW(L2,s);return t.jsx(I2.div,{"data-state":F2(o.value,o.max),"data-value":o.value??void 0,"data-max":o.max,...n,ref:r})});O2.displayName=L2;function zW(e,r){return`${Math.round(e/r*100)}%`}function F2(e,r){return e==null?"indeterminate":e===r?"complete":"loading"}function qu(e){return typeof e=="number"}function P_(e){return qu(e)&&!isNaN(e)&&e>0}function A_(e,r){return qu(e)&&!isNaN(e)&&e<=r&&e>=0}function WW(e,r){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${r}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${e0}\`.`}function UW(e,r){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${r}\`. The \`value\` prop must be:
3056
+ `),Br.transcript=os;const ri=await he.tuneLoopPrompt(is,Re.projectPath||(e==null?void 0:e.path)||(e==null?void 0:e.dir)||null,Br);ri.success?(await he.updateLoop(Re.id,{task:{original:ri.tunedPrompt}}),q.success("Prompt tuned and loop updated"),Se(!1),await Or(Re.id),Ar()):q.error(ri.error||"Failed to tune prompt")}catch(is){q.error(is.message)}finally{D(!1),Ue(null)}},gl=async()=>{Re&&(Se(!1),await mo(Re.id),Ue(null))},Qs=async ie=>{try{F(!0);const Le=await he.createLoop(ie,{workstreamId:Q||null,projectPath:(e==null?void 0:e.path)||(e==null?void 0:e.dir)||null,maxIterations:parseInt(H,10)||50,completionPromise:K||"DONE"});Le.success?(q.success("Loop created"),k(!1),V(""),z(""),Y(Ce),O(st),re(!1),Ar()):q.error(Le.error||"Failed to create loop")}catch(Le){q.error(Le.message)}finally{F(!1)}},ho=async ie=>{if(ps.needsInstall){Wt(ie),fr("start"),Bs(!0);return}await Mn(ie)},Mn=async ie=>{try{const Le=await he.startLoop(ie);Le.success&&Le.loop?(q.success("Loop started - launching Claude Code"),yr(Le.loop),Gr(!0),Ar()):q.error(Le.error||"Failed to start loop")}catch(Le){q.error(Le.message)}},oa=async()=>{try{Kt(!0);const ie=await he.installRalphLoopPlugin();ie.success?(q.success("ralph-loop plugin installed"),ts({installed:!0,scope:"user",needsInstall:!1}),Bs(!1),at&&(lr==="resume"?await Or(at):await Mn(at),Wt(null),fr(null))):q.error(ie.error||"Failed to install plugin")}catch(ie){q.error(ie.message)}finally{Kt(!1)}},fo=()=>{Bs(!1),Wt(null),fr(null)},ti=_.useCallback(async(ie,Le)=>{var Dt,Tr,is,kt,Fr,Br,os,ri,go,ji,Ni,si,xo,Kc;if(ht)try{const wt=(await he.getLoop(ht.id)).loop;if(wt.taskComplete||wt.status==="completed")q.success("Loop completed successfully!"),mn({id:wt.id,name:wt.name,task:(Dt=wt.task)==null?void 0:Dt.original,status:"completed",iterations:((Tr=wt.iterations)==null?void 0:Tr.current)||0,maxIterations:((is=wt.iterations)==null?void 0:is.max)||50,phase:wt.phase,startedAt:wt.startedAt,completedAt:wt.completedAt||new Date().toISOString()}),ss(!0),Gr(!1),yr(null);else if(wt.status==="paused")q.info(`Loop paused: ${wt.pauseReason||"user requested"}`),mn({id:wt.id,name:wt.name,task:(kt=wt.task)==null?void 0:kt.original,status:"paused",pauseReason:wt.pauseReason,iterations:((Fr=wt.iterations)==null?void 0:Fr.current)||0,maxIterations:((Br=wt.iterations)==null?void 0:Br.max)||50,phase:wt.phase,startedAt:wt.startedAt,completedAt:new Date().toISOString()}),ss(!0);else if(ie===0&&!Le)await he.completeLoop(wt.id),q.success("Loop completed successfully!"),mn({id:wt.id,name:wt.name,task:(os=wt.task)==null?void 0:os.original,status:"completed",iterations:((ri=wt.iterations)==null?void 0:ri.current)||0,maxIterations:((go=wt.iterations)==null?void 0:go.max)||50,phase:"execute",startedAt:wt.startedAt,completedAt:new Date().toISOString()}),ss(!0),Gr(!1),yr(null);else if(((ji=wt.iterations)==null?void 0:ji.current)>=((Ni=wt.iterations)==null?void 0:Ni.max))q.warning("Loop reached max iterations"),await he.pauseLoop(wt.id);else{const da=Le?`Signal: ${Le}`:`Exit code: ${ie}`;mn({id:wt.id,name:wt.name,task:(si=wt.task)==null?void 0:si.original,status:"paused",pauseReason:da,iterations:((xo=wt.iterations)==null?void 0:xo.current)||0,maxIterations:((Kc=wt.iterations)==null?void 0:Kc.max)||50,phase:wt.phase,startedAt:wt.startedAt,completedAt:new Date().toISOString()}),ss(!0)}Ar()}catch(Yc){console.error("Failed to check loop status:",Yc)}},[ht]),xs=async ie=>{try{const Le=await he.pauseLoop(ie);Le.success?(q.success("Loop paused"),Ar()):q.error(Le.error||"Failed to pause loop")}catch(Le){q.error(Le.message)}},mo=async ie=>{if(ps.needsInstall){Wt(ie),fr("resume"),Bs(!0);return}await Or(ie)},Or=async ie=>{try{const Le=await he.resumeLoop(ie);Le.success&&Le.loop?(q.success("Loop resumed - launching Claude Code"),yr(Le.loop),Gr(!0),Ar()):q.error(Le.error||"Failed to resume loop")}catch(Le){q.error(Le.message)}},ee=async ie=>{if(confirm("Cancel this loop?"))try{const Le=await he.cancelLoop(ie);Le.success?(q.success("Loop cancelled"),Ar()):q.error(Le.error||"Failed to cancel loop")}catch(Le){q.error(Le.message)}},De=async ie=>{if(confirm("Delete this loop and all its data?"))try{const Le=await he.deleteLoop(ie);Le.success?(q.success("Loop deleted"),Ar()):q.error(Le.error||"Failed to delete loop")}catch(Le){q.error(Le.message)}},Xe=ie=>{var Le,Dt;B(ie),Ge(ie.name||""),Nt(((Le=ie.task)==null?void 0:Le.original)||""),me(((Dt=ie.iterations)==null?void 0:Dt.max)||50),Z(ie.completionPromise||"DONE"),we(ie.workstreamId||""),M(!0)},Pt=async()=>{if(I)try{F(!0);const ie={name:$e,task:{original:et},iterations:{max:parseInt(ke,10)},completionPromise:be,workstreamId:oe||null},Le=await he.updateLoop(I.id,ie);Le.success?(q.success("Loop updated"),M(!1),B(null),Ar()):q.error(Le.error||"Failed to update loop")}catch(ie){q.error(ie.message)}finally{F(!1)}},Ht=async ie=>{var Le,Dt;try{F(!0);const Tr=await he.createLoop(((Le=ie.task)==null?void 0:Le.original)||"",{name:`${ie.name} (copy)`,workstreamId:ie.workstreamId||null,projectPath:ie.projectPath||(e==null?void 0:e.path)||(e==null?void 0:e.dir)||null,maxIterations:((Dt=ie.iterations)==null?void 0:Dt.max)||50,completionPromise:ie.completionPromise||"DONE"});Tr.success?(q.success("Loop copied"),Ar()):q.error(Tr.error||"Failed to copy loop")}catch(Tr){q.error(Tr.message)}finally{F(!1)}},At=async ie=>{try{const Le=await he.approveLoop(ie);Le.success?(q.success("Plan approved"),Ar()):q.error(Le.error||"Failed to approve plan")}catch(Le){q.error(Le.message)}},cr=async()=>{try{F(!0);const ie=await he.updateLoopConfig({maxIterations:parseInt(Ce,10),autoApprovePlan:He,completionPromise:st});ie.success?(q.success("Configuration saved"),y(!1),co()):q.error(ie.error||"Failed to save configuration")}catch(ie){q.error(ie.message)}finally{F(!1)}},jr=async()=>{try{Cr(!0);const ie=await he.installLoopHooks();ie.success?(q.success("Hooks installed successfully"),ta()):q.error(ie.error||"Failed to install hooks")}catch(ie){q.error(ie.message)}finally{Cr(!1)}},_r=async ie=>{try{const Le=await he.getLoop(ie.id);A({...Le.loop,clarifications:Le.clarifications,plan:Le.plan}),N(!0)}catch{q.error("Failed to load loop details")}},ns=ie=>{navigator.clipboard.writeText(ie),q.success("Copied to clipboard")},Ss=ie=>ie?new Date(ie).toLocaleString():"-",Zs=ie=>ie.iterations?Math.min(100,ie.iterations.current/ie.iterations.max*100):0,In=((xl=tr.stopHook)==null?void 0:xl.registered)&&((vl=tr.prepromptHook)==null?void 0:vl.registered),qc=ie=>{if(!ie)return null;const Le=f.find(Dt=>Dt.id===ie);return(Le==null?void 0:Le.name)||ie},aa=g?r.filter(ie=>ie.workstreamId===g):r,Tt=(ie,Le=!1)=>{var kt,Fr;const Dt=((kt=ie.task)==null?void 0:kt.original)||"";if((Fr=ie.iterations)!=null&&Fr.max,ie.completionPromise,Le){const Br=Dt.replace(/\n+/g," ").substring(0,100),os=Dt.length>100?"...":"";return`claude --dangerously-skip-permissions "${Br.replace(/"/g,'\\"')}${os}"`}return{startCmd:"claude --dangerously-skip-permissions",skillCmd:Dt}};return t.jsxs("div",{className:"p-6 space-y-6 max-w-6xl mx-auto",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[t.jsx(vc,{className:"w-6 h-6"}),"Ralph Loops"]}),t.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Autonomous development loops with iteration tracking and safety controls"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[f.length>0&&t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx($g,{className:"w-4 h-4 text-muted-foreground"}),t.jsxs("select",{className:"text-sm border rounded px-2 py-1 bg-background",value:g,onChange:ie=>w(ie.target.value),children:[t.jsx("option",{value:"",children:"All workstreams"}),f.map(ie=>t.jsx("option",{value:ie.id,children:ie.name},ie.id))]})]}),t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsxs(ne,{variant:"outline",size:"sm",onClick:()=>{ra(),b(!0)},children:[t.jsx(Tu,{className:"w-4 h-4 mr-1"}),"History"]})}),t.jsx(Ot,{children:"View completed loops"})]})}),t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsxs(ne,{variant:"outline",size:"sm",onClick:()=>y(!0),children:[t.jsx(Xs,{className:"w-4 h-4 mr-1"}),"Config"]})}),t.jsx(Ot,{children:"Configure loop defaults"})]})}),t.jsxs(ne,{onClick:()=>k(!0),children:[t.jsx(Rt,{className:"w-4 h-4 mr-1"}),"New Loop"]})]})]}),!In&&t.jsxs("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-4 flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(Is,{className:"w-5 h-5 text-yellow-600"}),t.jsxs("div",{children:[t.jsx("p",{className:"font-medium text-yellow-800 dark:text-yellow-200",children:"Hooks not installed"}),t.jsx("p",{className:"text-sm text-yellow-700 dark:text-yellow-300",children:"Install the Ralph Loop hooks to enable automatic loop continuation"})]})]}),t.jsxs(ne,{variant:"outline",size:"sm",onClick:jr,disabled:qt,children:[qt?t.jsx(Qe,{className:"w-4 h-4 animate-spin mr-1"}):null,"Install Hooks"]})]}),n?t.jsx("div",{className:"flex items-center justify-center py-12",children:t.jsx(Qe,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):aa.length===0?t.jsxs("div",{className:"text-center py-12 text-muted-foreground",children:[t.jsx(vc,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),t.jsx("p",{className:"text-lg font-medium",children:g?"No loops in this workstream":"No loops yet"}),t.jsx("p",{className:"text-sm mt-1",children:"Create a loop to start autonomous development"})]}):t.jsx("div",{className:"space-y-3",children:aa.map(ie=>{var Le,Dt,Tr,is,kt;return t.jsxs("div",{className:"border rounded-lg bg-card overflow-hidden",children:[t.jsxs("div",{className:"p-4 cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>d(c===ie.id?null:ie.id),children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[c===ie.id?t.jsx(hr,{className:"w-4 h-4 text-muted-foreground"}):t.jsx(Qr,{className:"w-4 h-4 text-muted-foreground"}),Oa[ie.status]||Oa.pending,t.jsxs("div",{children:[t.jsx("h3",{className:"font-medium",children:ie.name}),t.jsx("p",{className:"text-sm text-muted-foreground truncate max-w-md",children:((Le=ie.task)==null?void 0:Le.original)||"No task"})]})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[ie.workstreamId&&t.jsxs("span",{className:"text-xs px-2 py-0.5 rounded-full bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200 flex items-center gap-1",children:[t.jsx(Hn,{className:"w-3 h-3"}),qc(ie.workstreamId)]}),t.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full ${E_[ie.phase]||"bg-gray-100 dark:bg-gray-800"}`,children:ie.phase}),t.jsxs("span",{className:"text-sm text-muted-foreground",children:[((Dt=ie.iterations)==null?void 0:Dt.current)||0,"/",((Tr=ie.iterations)==null?void 0:Tr.max)||50]}),t.jsxs("div",{className:"flex items-center gap-1",onClick:Fr=>Fr.stopPropagation(),children:[ie.status==="pending"&&t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>ho(ie.id),children:t.jsx(zg,{className:"w-4 h-4"})})}),t.jsx(Ot,{children:"Start loop"})]})}),ie.status==="running"&&t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>xs(ie.id),children:t.jsx(Sp,{className:"w-4 h-4"})})}),t.jsx(Ot,{children:"Pause loop"})]})}),ie.status==="paused"&&t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>uo(ie),children:t.jsx(Qd,{className:"w-4 h-4"})})}),t.jsx(Ot,{children:"Resume loop"})]})}),(ie.status==="cancelled"||ie.status==="failed")&&t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>uo(ie),children:t.jsx(Qd,{className:"w-4 h-4"})})}),t.jsx(Ot,{children:"Restart loop"})]})}),ie.phase==="plan"&&ie.status==="running"&&t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>At(ie.id),children:t.jsx(It,{className:"w-4 h-4"})})}),t.jsx(Ot,{children:"Approve plan"})]})}),t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>Xe(ie),children:t.jsx(al,{className:"w-4 h-4"})})}),t.jsx(Ot,{children:"Edit loop"})]})}),t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>Ht(ie),children:t.jsx(Bo,{className:"w-4 h-4"})})}),t.jsx(Ot,{children:"Duplicate loop"})]})}),t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>_r(ie),children:t.jsx(Fg,{className:"w-4 h-4"})})}),t.jsx(Ot,{children:"View details"})]})}),(ie.status==="running"||ie.status==="paused")&&t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>ee(ie.id),children:t.jsx(Ki,{className:"w-4 h-4"})})}),t.jsx(Ot,{children:"Cancel loop"})]})}),t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>De(ie.id),children:t.jsx(fs,{className:"w-4 h-4 text-red-500"})})}),t.jsx(Ot,{children:"Delete loop"})]})})]})]})]}),t.jsxs("div",{className:"mt-3",children:[t.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground mb-1",children:[t.jsx("span",{children:"Iterations"}),t.jsxs("span",{children:[((is=ie.iterations)==null?void 0:is.current)||0," / ",((kt=ie.iterations)==null?void 0:kt.max)||50]})]}),t.jsx("div",{className:"h-1.5 bg-muted rounded-full overflow-hidden",children:t.jsx("div",{className:"h-full bg-blue-500 transition-all",style:{width:`${Zs(ie)}%`}})})]})]}),c===ie.id&&t.jsxs("div",{className:"border-t p-4 bg-muted/30 space-y-4",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"ID:"}),t.jsx("span",{className:"ml-2 font-mono",children:ie.id}),t.jsx(ne,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 ml-1",onClick:()=>ns(ie.id),children:t.jsx(Bo,{className:"w-3 h-3"})})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Status:"}),t.jsxs("span",{className:"ml-2",children:[ie.status,ie.pauseReason?` (${ie.pauseReason})`:""]})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Created:"}),t.jsx("span",{className:"ml-2",children:Ss(ie.createdAt)})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Updated:"}),t.jsx("span",{className:"ml-2",children:Ss(ie.updatedAt)})]}),ie.workstreamId&&t.jsxs("div",{className:"col-span-2",children:[t.jsx("span",{className:"text-muted-foreground",children:"Workstream:"}),t.jsxs("span",{className:"ml-2 inline-flex items-center gap-1",children:[t.jsx(Hn,{className:"w-3 h-3 text-purple-500"}),qc(ie.workstreamId)]})]})]}),t.jsxs("div",{className:"bg-muted p-3 rounded-md",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[t.jsx(Ut,{className:"w-4 h-4"}),t.jsx("span",{className:"text-sm font-medium",children:"Run this loop (uses official ralph-loop plugin):"})]}),t.jsx("code",{className:"text-xs bg-background p-2 rounded block whitespace-pre-wrap",children:Tt(ie,!0)})]})]})]},ie.id)})}),t.jsx(vt,{open:j,onOpenChange:k,children:t.jsxs(ft,{className:"sm:max-w-lg",children:[t.jsx(mt,{children:t.jsx(pt,{children:"Create New Loop"})}),t.jsxs("div",{className:"space-y-4 py-4",children:[t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("label",{className:"text-sm font-medium",children:"Task Description"}),t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsxs(ne,{variant:"outline",size:"sm",onClick:sa,disabled:$||!U.trim(),className:"h-7 text-xs",children:[$?t.jsx(Qe,{className:"w-3 h-3 animate-spin mr-1"}):t.jsx(Wr,{className:"w-3 h-3 mr-1"}),"Tune with AI"]})}),t.jsx(Ot,{children:t.jsx("p",{className:"max-w-xs",children:"Use Claude to optimize your prompt for Ralph Loop execution - adds clear completion signals, verification steps, and acceptance criteria."})})]})})]}),t.jsx(yt,{placeholder:"Describe what you want Claude to accomplish...",value:U,onChange:ie=>{V(ie.target.value),re(!1)},rows:4}),t.jsxs("div",{className:"flex items-center justify-between mt-1",children:[t.jsx("p",{className:"text-xs text-muted-foreground",children:"Be specific about the goal. The loop will continue until this task is completed."}),ae&&t.jsxs("span",{className:"text-xs text-green-600 dark:text-green-400 flex items-center gap-1",children:[t.jsx(Vt,{className:"w-3 h-3"}),"AI-tuned"]})]})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Project"}),t.jsx("div",{className:"text-sm p-2 bg-muted rounded-md",children:e?t.jsx("span",{className:"font-mono",children:e.name||e.path||e.dir}):t.jsx("span",{className:"text-muted-foreground",children:"No project selected - loop will run in server directory"})})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Max Iterations"}),t.jsx(Oe,{type:"number",value:H,onChange:ie=>Y(ie.target.value),min:1,max:1e3}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Safety limit for the loop"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Completion Promise"}),t.jsx(Oe,{value:K,onChange:ie=>O(ie.target.value),placeholder:"DONE"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Text that signals completion"})]})]}),f.length>0&&t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Workstream (optional)"}),t.jsxs("select",{className:"w-full border rounded-md p-2 bg-background",value:Q,onChange:ie=>z(ie.target.value),children:[t.jsx("option",{value:"",children:"No workstream"}),f.map(ie=>t.jsx("option",{value:ie.id,children:ie.name},ie.id))]})]})]}),t.jsxs(St,{children:[t.jsx(ne,{variant:"outline",onClick:()=>k(!1),children:"Cancel"}),t.jsxs(ne,{onClick:Ci,disabled:T||!U.trim(),children:[T?t.jsx(Qe,{className:"w-4 h-4 animate-spin mr-1"}):null,"Create Loop"]})]})]})}),t.jsx(vt,{open:E,onOpenChange:M,children:t.jsxs(ft,{className:"sm:max-w-lg",children:[t.jsx(mt,{children:t.jsx(pt,{children:"Edit Loop"})}),t.jsxs("div",{className:"space-y-4 py-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Name"}),t.jsx(Oe,{placeholder:"Loop name",value:$e,onChange:ie=>Ge(ie.target.value)})]}),t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("label",{className:"text-sm font-medium",children:"Task Description"}),t.jsx(ur,{children:t.jsxs(Ft,{children:[t.jsx(Bt,{asChild:!0,children:t.jsxs(ne,{variant:"outline",size:"sm",onClick:async()=>{if(!et.trim()){q.error("Enter a task description first");return}try{D(!0),le(et),_e("edit");const ie=await he.tuneLoopPrompt(et,(I==null?void 0:I.projectPath)||(e==null?void 0:e.path)||(e==null?void 0:e.dir)||null);ie.success?(J(ie.tunedPrompt),te(!0)):q.error(ie.error||"Failed to tune prompt")}catch(ie){q.error(ie.message)}finally{D(!1)}},disabled:$||!et.trim(),className:"h-7 text-xs",children:[$?t.jsx(Qe,{className:"w-3 h-3 animate-spin mr-1"}):t.jsx(Wr,{className:"w-3 h-3 mr-1"}),"Tune with AI"]})}),t.jsx(Ot,{children:t.jsx("p",{className:"max-w-xs",children:"Use Claude to optimize your prompt for Ralph Loop execution."})})]})})]}),t.jsx(yt,{placeholder:"Describe what you want Claude to accomplish...",value:et,onChange:ie=>Nt(ie.target.value),rows:4})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Max Iterations"}),t.jsx(Oe,{type:"number",value:ke,onChange:ie=>me(ie.target.value),min:1,max:1e3})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Completion Promise"}),t.jsx(Oe,{value:be,onChange:ie=>Z(ie.target.value),placeholder:"DONE"})]})]}),f.length>0&&t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Workstream"}),t.jsxs("select",{className:"w-full border rounded-md p-2 bg-background",value:oe,onChange:ie=>we(ie.target.value),children:[t.jsx("option",{value:"",children:"No workstream"}),f.map(ie=>t.jsx("option",{value:ie.id,children:ie.name},ie.id))]})]}),I&&t.jsxs("div",{className:"text-xs text-muted-foreground",children:[t.jsxs("span",{children:["ID: ",I.id]}),t.jsx("span",{className:"mx-2",children:"|"}),t.jsxs("span",{children:["Status: ",I.status]}),t.jsx("span",{className:"mx-2",children:"|"}),t.jsxs("span",{children:["Phase: ",I.phase]})]})]}),t.jsxs(St,{children:[t.jsx(ne,{variant:"outline",onClick:()=>M(!1),children:"Cancel"}),t.jsxs(ne,{onClick:Pt,disabled:T||!et.trim(),children:[T?t.jsx(Qe,{className:"w-4 h-4 animate-spin mr-1"}):null,"Save Changes"]})]})]})}),t.jsx(vt,{open:v,onOpenChange:y,children:t.jsxs(ft,{className:"sm:max-w-md",children:[t.jsx(mt,{children:t.jsx(pt,{children:"Loop Configuration"})}),t.jsxs("div",{className:"space-y-4 py-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Max Iterations"}),t.jsx(Oe,{type:"number",value:Ce,onChange:ie=>Fe(ie.target.value),min:1,max:1e3}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Loop will pause after this many iterations"})]}),t.jsxs("div",{children:[t.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Default Completion Promise"}),t.jsx(Oe,{value:st,onChange:ie=>zt(ie.target.value),placeholder:"DONE"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Default text that signals loop completion (used with official ralph-loop plugin)"})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{type:"checkbox",id:"autoApprovePlan",checked:He,onChange:ie=>ct(ie.target.checked),className:"rounded"}),t.jsx("label",{htmlFor:"autoApprovePlan",className:"text-sm",children:"Auto-approve plans (skip manual plan approval)"})]})]}),t.jsxs(St,{children:[t.jsx(ne,{variant:"outline",onClick:()=>y(!1),children:"Cancel"}),t.jsxs(ne,{onClick:cr,disabled:T,children:[T?t.jsx(Qe,{className:"w-4 h-4 animate-spin mr-1"}):null,"Save"]})]})]})}),t.jsx(vt,{open:x,onOpenChange:b,children:t.jsxs(ft,{className:"sm:max-w-2xl max-h-[80vh] overflow-y-auto",children:[t.jsx(mt,{children:t.jsx(pt,{children:"Loop History"})}),t.jsx("div",{className:"space-y-3 py-4",children:Lr.length===0?t.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No completed loops yet"}):Lr.slice().reverse().map(ie=>t.jsxs("div",{className:"border rounded-lg p-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[Oa[ie.status]||Oa.completed,t.jsx("span",{className:"font-medium",children:ie.name})]}),t.jsx("span",{className:"text-xs text-muted-foreground",children:Ss(ie.completedAt)})]}),t.jsx("p",{className:"text-sm text-muted-foreground mt-1 truncate",children:ie.task}),t.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:t.jsxs("span",{children:["Iterations: ",ie.totalIterations]})})]},ie.id))})]})}),t.jsx(vt,{open:S,onOpenChange:N,children:t.jsxs(ft,{className:"sm:max-w-3xl max-h-[80vh] overflow-y-auto",children:[t.jsx(mt,{children:t.jsx(pt,{children:(P==null?void 0:P.name)||"Loop Details"})}),P&&t.jsxs("div",{className:"space-y-4 py-4",children:[t.jsxs("div",{className:"grid grid-cols-3 gap-4 text-sm",children:[t.jsxs("div",{className:"border rounded p-3",children:[t.jsx("div",{className:"text-muted-foreground text-xs mb-1",children:"Phase"}),t.jsx("span",{className:`text-sm px-2 py-0.5 rounded-full ${E_[P.phase]||""}`,children:P.phase})]}),t.jsxs("div",{className:"border rounded p-3",children:[t.jsx("div",{className:"text-muted-foreground text-xs mb-1",children:"Status"}),t.jsxs("div",{className:"flex items-center gap-1",children:[Oa[P.status],t.jsx("span",{children:P.status})]})]}),t.jsxs("div",{className:"border rounded p-3",children:[t.jsx("div",{className:"text-muted-foreground text-xs mb-1",children:"Progress"}),t.jsxs("span",{children:[((la=P.iterations)==null?void 0:la.current)||0," / ",((yl=P.iterations)==null?void 0:yl.max)||50]})]})]}),t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium mb-2",children:"Task"}),t.jsx("div",{className:"bg-muted p-3 rounded text-sm",children:(bl=P.task)==null?void 0:bl.original})]}),P.clarifications&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium mb-2",children:"Clarifications"}),t.jsx("div",{className:"bg-muted p-3 rounded text-sm whitespace-pre-wrap max-h-40 overflow-y-auto",children:P.clarifications})]}),P.plan&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium mb-2",children:"Plan"}),t.jsx("div",{className:"bg-muted p-3 rounded text-sm whitespace-pre-wrap max-h-60 overflow-y-auto font-mono",children:P.plan})]}),t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium mb-2",children:"Max Iterations"}),t.jsx("div",{className:"bg-muted p-2 rounded text-sm",children:((wl=P.iterations)==null?void 0:wl.max)||50})]}),t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium mb-2",children:"Completion Promise"}),t.jsxs("div",{className:"bg-muted p-2 rounded text-sm font-mono",children:["<promise>",P.completionPromise||"DONE","</promise>"]})]})]}),t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium mb-2",children:"Run Command (uses official ralph-loop plugin)"}),t.jsx("code",{className:"text-xs bg-muted p-3 rounded block whitespace-pre-wrap",children:Tt(P,!0)})]})]})]})}),t.jsx(vt,{open:Fs,onOpenChange:Bs,children:t.jsxs(ft,{className:"sm:max-w-md",children:[t.jsx(mt,{children:t.jsxs(pt,{className:"flex items-center gap-2",children:[t.jsx(yi,{className:"w-5 h-5"}),"Install ralph-loop Plugin"]})}),t.jsxs("div",{className:"py-4",children:[t.jsxs("p",{className:"text-sm text-muted-foreground mb-4",children:["The ",t.jsx("code",{className:"bg-muted px-1 rounded",children:"ralph-loop"})," plugin is required to run loops. This plugin provides the ",t.jsx("code",{className:"bg-muted px-1 rounded",children:"/ralph-loop"})," command that enables autonomous iteration."]}),ps.scope==="project"&&t.jsx("div",{className:"bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded p-3 mb-4",children:t.jsxs("p",{className:"text-sm text-yellow-800 dark:text-yellow-200",children:["Plugin is currently installed only for project: ",t.jsx("br",{}),t.jsx("code",{className:"text-xs",children:ps.projectPath})]})}),t.jsx("p",{className:"text-sm",children:"Install the plugin globally (user scope) to use loops from any project?"})]}),t.jsxs(St,{children:[t.jsx(ne,{variant:"outline",onClick:fo,disabled:ks,children:"Cancel"}),t.jsx(ne,{onClick:oa,disabled:ks,children:ks?t.jsxs(t.Fragment,{children:[t.jsx(Qe,{className:"w-4 h-4 animate-spin mr-1"}),"Installing..."]}):t.jsxs(t.Fragment,{children:[t.jsx(yi,{className:"w-4 h-4 mr-1"}),"Install Plugin"]})})]})]})}),t.jsx(Xj,{open:Yt,onOpenChange:ie=>{Gr(ie),ie||(yr(null),Ar())},title:ht?`Loop: ${ht.name}`:"Running Loop",description:ht?((po=(ca=ht.task)==null?void 0:ca.original)==null?void 0:po.substring(0,100))+(((xn=(gn=ht.task)==null?void 0:gn.original)==null?void 0:xn.length)>100?"...":""):"",cwd:ht==null?void 0:ht.projectPath,initialCommand:ht?Tt(ht).startCmd:"",delayedCommand:ht?Tt(ht).skillCmd:"",delayedCommandDelay:5e3,env:ht?{CODER_LOOP_ID:ht.id,...ht.workstreamId&&{CODER_WORKSTREAM:ht.workstreamId}}:{},onExit:ti,headerExtra:t.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer select-none",children:[t.jsx("input",{type:"checkbox",checked:gs,onChange:ie=>rs(ie.target.checked),className:"rounded"}),"Auto-close when done"]})}),t.jsx(vt,{open:X,onOpenChange:te,children:t.jsxs(ft,{className:"sm:max-w-2xl max-h-[80vh] overflow-y-auto",children:[t.jsx(mt,{children:t.jsxs(pt,{className:"flex items-center gap-2",children:[t.jsx(Wr,{className:"w-5 h-5 text-purple-500"}),"AI-Tuned Prompt"]})}),t.jsxs("div",{className:"space-y-4 py-4",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium mb-2 text-muted-foreground",children:"Original Prompt"}),t.jsx("div",{className:"bg-muted p-3 rounded text-sm whitespace-pre-wrap max-h-32 overflow-y-auto",children:W})]}),t.jsxs("div",{children:[t.jsxs("h4",{className:"text-sm font-medium mb-2 flex items-center gap-2",children:[t.jsx(Vt,{className:"w-4 h-4 text-purple-500"}),"Tuned Prompt"]}),t.jsx(yt,{value:fe,onChange:ie=>J(ie.target.value),rows:10,className:"font-mono text-sm"}),t.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"You can edit the tuned prompt before accepting it."})]})]}),t.jsxs(St,{children:[t.jsx(ne,{variant:"outline",onClick:ia,children:"Keep Original"}),t.jsxs(ne,{onClick:na,children:[t.jsx(It,{className:"w-4 h-4 mr-1"}),"Use Tuned Prompt"]})]})]})}),t.jsx(vt,{open:de,onOpenChange:Se,children:t.jsxs(ft,{className:"sm:max-w-md",children:[t.jsx(mt,{children:t.jsxs(pt,{className:"flex items-center gap-2",children:[t.jsx(Qd,{className:"w-5 h-5"}),"Resume Loop"]})}),t.jsx("div",{className:"py-4",children:Re&&t.jsxs(t.Fragment,{children:[t.jsxs("p",{className:"text-sm mb-4",children:["This loop ",Re.status==="failed"?"failed":Re.status==="cancelled"?"was cancelled":"was paused",Re.pauseReason&&`: ${Re.pauseReason}`]}),t.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:"Would you like to tune the prompt with AI before resuming? This can help add guardrails based on what went wrong."}),t.jsx("div",{className:"bg-muted p-3 rounded text-sm max-h-32 overflow-y-auto",children:(vn=Re.task)==null?void 0:vn.original})]})}),t.jsxs(St,{className:"flex-col sm:flex-row gap-2",children:[t.jsx(ne,{variant:"outline",onClick:()=>{Se(!1),Ue(null)},children:"Cancel"}),t.jsx(ne,{variant:"secondary",onClick:gl,children:"Resume As-Is"}),t.jsxs(ne,{onClick:rr,disabled:$,children:[$?t.jsx(Qe,{className:"w-4 h-4 animate-spin mr-1"}):t.jsx(Wr,{className:"w-4 h-4 mr-1"}),"Tune & Resume"]})]})]})}),t.jsx(vt,{open:pl,onOpenChange:ss,children:t.jsxs(ft,{className:"sm:max-w-md",children:[t.jsx(mt,{children:t.jsxs(pt,{className:"flex items-center gap-2",children:[(rt==null?void 0:rt.status)==="completed"&&t.jsxs(t.Fragment,{children:[t.jsx(vi,{className:"w-5 h-5 text-green-600"})," Loop Completed"]}),(rt==null?void 0:rt.status)==="paused"&&t.jsxs(t.Fragment,{children:[t.jsx(Sp,{className:"w-5 h-5 text-yellow-500"})," Loop Paused"]}),(rt==null?void 0:rt.status)==="failed"&&t.jsxs(t.Fragment,{children:[t.jsx(Ki,{className:"w-5 h-5 text-red-500"})," Loop Failed"]}),(rt==null?void 0:rt.status)==="cancelled"&&t.jsxs(t.Fragment,{children:[t.jsx(Ki,{className:"w-5 h-5 text-gray-500"})," Loop Cancelled"]})]})}),rt&&t.jsxs("div",{className:"space-y-4 py-4",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium mb-1",children:"Task"}),t.jsx("p",{className:"text-sm text-muted-foreground bg-muted p-2 rounded",children:rt.task})]}),rt.pauseReason&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium mb-1",children:"Reason"}),t.jsx("p",{className:"text-sm text-muted-foreground bg-muted p-2 rounded",children:rt.pauseReason})]}),t.jsxs("div",{className:"grid grid-cols-3 gap-3 text-sm",children:[t.jsxs("div",{className:"border rounded p-3",children:[t.jsx("div",{className:"text-muted-foreground text-xs mb-1",children:"Status"}),t.jsxs("div",{className:"font-medium flex items-center gap-1",children:[Oa[rt.status],t.jsx("span",{className:"capitalize",children:rt.status})]})]}),t.jsxs("div",{className:"border rounded p-3",children:[t.jsx("div",{className:"text-muted-foreground text-xs mb-1",children:"Iterations"}),t.jsxs("div",{className:"font-medium",children:[rt.iterations," / ",rt.maxIterations]})]}),t.jsxs("div",{className:"border rounded p-3",children:[t.jsx("div",{className:"text-muted-foreground text-xs mb-1",children:"Duration"}),t.jsx("div",{className:"font-medium",children:rt.duration!=null?rt.duration<60?`${rt.duration}s`:rt.duration<3600?`${Math.floor(rt.duration/60)}m ${rt.duration%60}s`:`${Math.floor(rt.duration/3600)}h ${Math.floor(rt.duration%3600/60)}m`:"-"})]})]}),t.jsxs("div",{className:"text-xs text-muted-foreground",children:[rt.status==="completed"?"Completed":"Stopped"," at ",Ss(rt.completedAt)]})]}),t.jsxs(St,{children:[t.jsx(ne,{variant:"outline",onClick:()=>ss(!1),children:"Close"}),((rt==null?void 0:rt.status)==="paused"||(rt==null?void 0:rt.status)==="failed"||(rt==null?void 0:rt.status)==="cancelled")&&t.jsxs(ne,{onClick:()=>{if(ss(!1),rt!=null&&rt.id){const ie=r.find(Le=>Le.id===rt.id);ie&&uo(ie)}},children:[t.jsx(Qd,{className:"w-4 h-4 mr-1"}),(rt==null?void 0:rt.status)==="paused"?"Resume":"Restart"]}),t.jsx(ne,{variant:"secondary",onClick:()=>{if(ss(!1),rt!=null&&rt.id){const ie=r.find(Le=>Le.id===rt.id);ie&&_r(ie)}},children:"View Details"})]})]})})]})}function OW(e,r=[]){let s=[];function n(c,d){const l=_.createContext(d);l.displayName=c+"Context";const u=s.length;s=[...s,d];const f=h=>{var y;const{scope:g,children:w,...j}=h,k=((y=g==null?void 0:g[e])==null?void 0:y[u])||l,v=_.useMemo(()=>j,Object.values(j));return t.jsx(k.Provider,{value:v,children:w})};f.displayName=c+"Provider";function m(h,g){var k;const w=((k=g==null?void 0:g[e])==null?void 0:k[u])||l,j=_.useContext(w);if(j)return j;if(d!==void 0)return d;throw new Error(`\`${h}\` must be used within \`${c}\``)}return[f,m]}const o=()=>{const c=s.map(d=>_.createContext(d));return function(l){const u=(l==null?void 0:l[e])||c;return _.useMemo(()=>({[`__scope${e}`]:{...l,[e]:u}}),[l,u])}};return o.scopeName=e,[n,FW(o,...r)]}function FW(...e){const r=e[0];if(e.length===1)return r;const s=()=>{const n=e.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(c){const d=n.reduce((l,{useScope:u,scopeName:f})=>{const h=u(c)[`__scope${f}`];return{...l,...h}},{});return _.useMemo(()=>({[`__scope${r.scopeName}`]:d}),[d])}};return s.scopeName=r.scopeName,s}var BW=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],I2=BW.reduce((e,r)=>{const s=sh(`Primitive.${r}`),n=_.forwardRef((o,c)=>{const{asChild:d,...l}=o,u=d?s:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),t.jsx(u,{...l,ref:c})});return n.displayName=`Primitive.${r}`,{...e,[r]:n}},{}),Zx="Progress",e0=100,[$W]=OW(Zx),[HW,zW]=$W(Zx),D2=_.forwardRef((e,r)=>{const{__scopeProgress:s,value:n=null,max:o,getValueLabel:c=WW,...d}=e;(o||o===0)&&!P_(o)&&console.error(UW(`${o}`,"Progress"));const l=P_(o)?o:e0;n!==null&&!A_(n,l)&&console.error(VW(`${n}`,"Progress"));const u=A_(n,l)?n:null,f=qu(u)?c(u,l):void 0;return t.jsx(HW,{scope:s,value:u,max:l,children:t.jsx(I2.div,{"aria-valuemax":l,"aria-valuemin":0,"aria-valuenow":qu(u)?u:void 0,"aria-valuetext":f,role:"progressbar","data-state":F2(u,l),"data-value":u??void 0,"data-max":l,...d,ref:r})})});D2.displayName=Zx;var L2="ProgressIndicator",O2=_.forwardRef((e,r)=>{const{__scopeProgress:s,...n}=e,o=zW(L2,s);return t.jsx(I2.div,{"data-state":F2(o.value,o.max),"data-value":o.value??void 0,"data-max":o.max,...n,ref:r})});O2.displayName=L2;function WW(e,r){return`${Math.round(e/r*100)}%`}function F2(e,r){return e==null?"indeterminate":e===r?"complete":"loading"}function qu(e){return typeof e=="number"}function P_(e){return qu(e)&&!isNaN(e)&&e>0}function A_(e,r){return qu(e)&&!isNaN(e)&&e<=r&&e>=0}function UW(e,r){return`Invalid prop \`max\` of value \`${e}\` supplied to \`${r}\`. Only numbers greater than 0 are valid max values. Defaulting to \`${e0}\`.`}function VW(e,r){return`Invalid prop \`value\` of value \`${e}\` supplied to \`${r}\`. The \`value\` prop must be:
3057
3057
  - a positive number
3058
3058
  - less than the value passed to \`max\` (or ${e0} if no \`max\` prop is set)
3059
3059
  - \`null\` or \`undefined\` if the progress is indeterminate.
3060
3060
 
3061
- Defaulting to \`null\`.`}var B2=D2,VW=O2;const $2=_.forwardRef(({className:e,value:r,...s},n)=>t.jsx(B2,{ref:n,className:Ee("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",e),...s,children:t.jsx(VW,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(r||0)}%)`}})}));$2.displayName=B2.displayName;const Fa=[{id:"welcome",title:"Welcome",icon:Vt,subsections:[{id:"intro",title:"What is Coder Config?"},{id:"what-youll-learn",title:"What You'll Learn"}]},{id:"first-project",title:"Your First Project",icon:fi,subsections:[{id:"adding-project",title:"Adding a Project"},{id:"exploring-project",title:"Exploring Your Project"},{id:"claude-folder",title:"The .claude Folder"}]},{id:"rules-guide",title:"Working with Rules",icon:vr,subsections:[{id:"what-are-rules",title:"What Are Rules?"},{id:"creating-rules",title:"Creating Your First Rule"},{id:"rule-tips",title:"Tips for Great Rules"}]},{id:"mcp-guide",title:"MCP Servers",icon:Yn,subsections:[{id:"what-are-mcps",title:"What Are MCPs?"},{id:"adding-mcp",title:"Adding Your First MCP"},{id:"mcp-config",title:"Configuring MCPs"}]},{id:"permissions-guide",title:"Permissions",icon:Qn,subsections:[{id:"understanding-permissions",title:"How Permissions Work"},{id:"setting-permissions",title:"Setting Up Permissions"},{id:"permission-patterns",title:"Permission Patterns"}]},{id:"memory-guide",title:"Memory System",icon:Fo,subsections:[{id:"what-is-memory",title:"What is Memory?"},{id:"using-memory",title:"Using Memory"}]},{id:"plugins-guide",title:"Plugins",icon:$o,subsections:[{id:"what-are-plugins",title:"What Are Plugins?"},{id:"installing-plugin",title:"Installing a Plugin"}]},{id:"workstreams-guide",title:"Workstreams",icon:bS,subsections:[{id:"what-are-workstreams",title:"What Are Workstreams?"},{id:"creating-workstream",title:"Creating a Workstream"}]},{id:"loops-guide",title:"Ralph Loops",icon:vc,isExperimental:!0,subsections:[{id:"what-are-loops",title:"What Are Ralph Loops?"},{id:"creating-first-loop",title:"Your First Loop"}]},{id:"multi-tool-guide",title:"Multi-Tool Support",icon:Wr,subsections:[{id:"other-tools",title:"Beyond Claude Code"},{id:"syncing-tools",title:"Syncing Between Tools"}]},{id:"next-steps",title:"Next Steps",icon:Mc,subsections:[]}],GW={intro:{title:"What is Coder Config?",content:`
3061
+ Defaulting to \`null\`.`}var B2=D2,GW=O2;const $2=_.forwardRef(({className:e,value:r,...s},n)=>t.jsx(B2,{ref:n,className:Ee("relative h-2 w-full overflow-hidden rounded-full bg-primary/20",e),...s,children:t.jsx(GW,{className:"h-full w-full flex-1 bg-primary transition-all",style:{transform:`translateX(-${100-(r||0)}%)`}})}));$2.displayName=B2.displayName;const Fa=[{id:"welcome",title:"Welcome",icon:Vt,subsections:[{id:"intro",title:"What is Coder Config?"},{id:"what-youll-learn",title:"What You'll Learn"}]},{id:"first-project",title:"Your First Project",icon:fi,subsections:[{id:"adding-project",title:"Adding a Project"},{id:"exploring-project",title:"Exploring Your Project"},{id:"claude-folder",title:"The .claude Folder"}]},{id:"rules-guide",title:"Working with Rules",icon:vr,subsections:[{id:"what-are-rules",title:"What Are Rules?"},{id:"creating-rules",title:"Creating Your First Rule"},{id:"rule-tips",title:"Tips for Great Rules"}]},{id:"mcp-guide",title:"MCP Servers",icon:Yn,subsections:[{id:"what-are-mcps",title:"What Are MCPs?"},{id:"adding-mcp",title:"Adding Your First MCP"},{id:"mcp-config",title:"Configuring MCPs"}]},{id:"permissions-guide",title:"Permissions",icon:Qn,subsections:[{id:"understanding-permissions",title:"How Permissions Work"},{id:"setting-permissions",title:"Setting Up Permissions"},{id:"permission-patterns",title:"Permission Patterns"}]},{id:"memory-guide",title:"Memory System",icon:Fo,subsections:[{id:"what-is-memory",title:"What is Memory?"},{id:"using-memory",title:"Using Memory"}]},{id:"plugins-guide",title:"Plugins",icon:$o,subsections:[{id:"what-are-plugins",title:"What Are Plugins?"},{id:"installing-plugin",title:"Installing a Plugin"}]},{id:"workstreams-guide",title:"Workstreams",icon:bS,subsections:[{id:"what-are-workstreams",title:"What Are Workstreams?"},{id:"creating-workstream",title:"Creating a Workstream"}]},{id:"loops-guide",title:"Ralph Loops",icon:vc,isExperimental:!0,subsections:[{id:"what-are-loops",title:"What Are Ralph Loops?"},{id:"creating-first-loop",title:"Your First Loop"}]},{id:"multi-tool-guide",title:"Multi-Tool Support",icon:Wr,subsections:[{id:"other-tools",title:"Beyond Claude Code"},{id:"syncing-tools",title:"Syncing Between Tools"}]},{id:"next-steps",title:"Next Steps",icon:Mc,subsections:[]}],qW={intro:{title:"What is Coder Config?",content:`
3062
3062
  Coder Config is your **control center** for AI coding tools. It supports **Claude Code**, **Gemini CLI**, **Codex CLI**, and **Antigravity**—all from one place. Instead of manually editing JSON files or remembering command-line flags, you get a friendly UI to manage everything.
3063
3063
 
3064
3064
  You might be running the desktop app (downloaded from [GitHub Releases](https://github.com/regression-io/coder-config/releases)), or you installed the npm package with \`npm install -g coder-config\` and ran \`coder-config ui\`. Either way works identically—this tutorial applies to both.
@@ -3090,7 +3090,7 @@ Finally, we'll tackle workstreams—the feature that makes working across multip
3090
3090
  Each section takes about five minutes. You can stop anytime and pick up where you left off.
3091
3091
 
3092
3092
  Ready? Click **"Adding a Project"** below to begin.
3093
- `}},qW={"adding-project":{title:"Adding a Project",content:`
3093
+ `}},KW={"adding-project":{title:"Adding a Project",content:`
3094
3094
  In Coder Config, a "project" is just a folder on your computer—usually one containing code. It might be a git repository, a single app, or any directory where you do development work.
3095
3095
 
3096
3096
  ### Finding the Add Project Button
@@ -3132,7 +3132,7 @@ New projects don't have AI configuration yet. That's fine. In the Project Explor
3132
3132
  The built-in editor handles the file formats your tools use: markdown for rules, JSON for MCP configs and settings. Changes save automatically when you navigate away, though you can also save explicitly.
3133
3133
 
3134
3134
  Let's create the \`.claude\` folder in the next section, then start writing rules.
3135
- `},"claude-folder":{title:"The .claude Folder",content:"\nThe `.claude` folder is where your project's AI configuration lives. Everything your AI needs to know about your project—how you want it to behave, what tools it can use, what patterns to follow—goes here.\n\n### Creating the Folder\n\nIf your project doesn't have a `.claude` folder yet, go to Project Explorer and use the **+** menu on your project folder. Creating any config file (like a rule or `mcps.json`) will automatically create the `.claude` folder. The typical structure looks like this:\n\n```\n.claude/\n├── rules/ # Markdown files with guidelines\n├── commands/ # Skills (reusable prompts)\n├── settings.local.json # Project-specific settings\n└── mcps.json # MCP server configurations\n```\n\nYou can also create this manually if you prefer—it's just regular folders and files.\n\n### What Each Piece Does\n\nThe `rules/` folder contains markdown files that tell your AI about your project. These are instructions, conventions, things to avoid—any guidance you'd give a new team member. They're read at the start of every session.\n\nThe `commands/` folder holds skills—reusable prompts you can invoke with slash commands. If you find yourself typing the same instructions over and over, turn them into a skill.\n\nThe `settings.local.json` file stores project-specific settings that override global defaults. And `mcps.json` defines which MCP servers this project uses.\n\n### The CLAUDE.md Alternative\n\nThere's another option: create a `CLAUDE.md` file in your project root (not inside `.claude/`). Your AI reads this automatically too. Some developers prefer this because it's more visible—right there at the top level where everyone can see it.\n\nYou can use both. The `CLAUDE.md` file works well for high-level project context, while the `.claude/rules/` folder suits more detailed, categorized guidelines.\n\n### Should You Commit It?\n\nGenerally, yes. Committing your `.claude` folder means everyone on your team gets the same AI-assisted experience. The one exception is `settings.local.json`—that's for personal preferences and should probably stay in your `.gitignore`.\n\nNow that you have the structure in place, let's learn about rules—the most powerful way to configure your AI for your project.\n "}},KW={"what-are-rules":{title:"What Are Rules?",content:`
3135
+ `},"claude-folder":{title:"The .claude Folder",content:"\nThe `.claude` folder is where your project's AI configuration lives. Everything your AI needs to know about your project—how you want it to behave, what tools it can use, what patterns to follow—goes here.\n\n### Creating the Folder\n\nIf your project doesn't have a `.claude` folder yet, go to Project Explorer and use the **+** menu on your project folder. Creating any config file (like a rule or `mcps.json`) will automatically create the `.claude` folder. The typical structure looks like this:\n\n```\n.claude/\n├── rules/ # Markdown files with guidelines\n├── commands/ # Skills (reusable prompts)\n├── settings.local.json # Project-specific settings\n└── mcps.json # MCP server configurations\n```\n\nYou can also create this manually if you prefer—it's just regular folders and files.\n\n### What Each Piece Does\n\nThe `rules/` folder contains markdown files that tell your AI about your project. These are instructions, conventions, things to avoid—any guidance you'd give a new team member. They're read at the start of every session.\n\nThe `commands/` folder holds skills—reusable prompts you can invoke with slash commands. If you find yourself typing the same instructions over and over, turn them into a skill.\n\nThe `settings.local.json` file stores project-specific settings that override global defaults. And `mcps.json` defines which MCP servers this project uses.\n\n### The CLAUDE.md Alternative\n\nThere's another option: create a `CLAUDE.md` file in your project root (not inside `.claude/`). Your AI reads this automatically too. Some developers prefer this because it's more visible—right there at the top level where everyone can see it.\n\nYou can use both. The `CLAUDE.md` file works well for high-level project context, while the `.claude/rules/` folder suits more detailed, categorized guidelines.\n\n### Should You Commit It?\n\nGenerally, yes. Committing your `.claude` folder means everyone on your team gets the same AI-assisted experience. The one exception is `settings.local.json`—that's for personal preferences and should probably stay in your `.gitignore`.\n\nNow that you have the structure in place, let's learn about rules—the most powerful way to configure your AI for your project.\n "}},YW={"what-are-rules":{title:"What Are Rules?",content:`
3136
3136
  Rules are instructions for your AI assistant written in plain Markdown. They tell it things about your project—how it's structured, what coding conventions to follow, what to avoid. Think of them as persistent context that gets loaded before every conversation.
3137
3137
 
3138
3138
  ### How Rules Work
@@ -3236,7 +3236,7 @@ Rules should evolve with your project. When you change a convention, update the
3236
3236
  Your AI is smart. You don't need to specify obvious things or standard best practices. Focus your rules on things that are unique to your project—your specific conventions, patterns that aren't obvious from the code, requirements that deviate from the norm.
3237
3237
 
3238
3238
  If you find yourself writing a very long rules file, consider whether everything in it is truly specific to your project or just general good practice your AI already knows.
3239
- `}},YW={"what-are-mcps":{title:"What Are MCPs?",content:`
3239
+ `}},XW={"what-are-mcps":{title:"What Are MCPs?",content:`
3240
3240
  MCP stands for Model Context Protocol. In practical terms, MCPs are plugins that give your AI coding tools new abilities—ways to interact with systems beyond just reading and writing files.
3241
3241
 
3242
3242
  ### What MCPs Can Do
@@ -3338,7 +3338,7 @@ To remove an MCP from a project, find it in your project's MCP list and click th
3338
3338
  When an MCP isn't working, start by checking whether environment variables are set correctly—missing tokens or credentials are the most common problem. If that looks fine, try running the MCP command manually in your terminal to see if the package is installed and working. Make sure you clicked Re-apply and restarted your AI tool, since config changes don't take effect until both happen. Finally, check your AI tool's output for error messages—they usually point directly at the problem.
3339
3339
 
3340
3340
  The MCP Registry includes troubleshooting notes for each MCP. Check there if you're stuck on a specific one.
3341
- `}},XW={"understanding-permissions":{title:"How Permissions Work",content:`
3341
+ `}},JW={"understanding-permissions":{title:"How Permissions Work",content:`
3342
3342
  Permissions control how much autonomy your AI has. Without them, your AI either asks permission for everything (slow and tedious) or runs in full trust mode (fast but risky). Permissions let you find the middle ground—automatic approval for safe operations, manual review for sensitive ones.
3343
3343
 
3344
3344
  ### The Three Levels
@@ -3396,7 +3396,7 @@ Hover over any rule chip in the UI to see what it matches. The interface explain
3396
3396
  ### Testing Your Setup
3397
3397
 
3398
3398
  After configuring, try working with your AI normally. If you find yourself approving the same thing repeatedly, consider allowing it. If something happens that makes you uncomfortable, add an ask or deny rule. Permissions are meant to be tuned over time as you learn what works for your workflow.
3399
- `},"permission-patterns":{title:"Permission Patterns",content:"\nPermissions use pattern matching to determine what operations they cover. Understanding patterns lets you write precise rules.\n\n### File Patterns\n\nFile patterns control Read, Edit, and Write operations. The pattern `**` matches everything at any depth, so `Read(**)` means your AI can read any file anywhere in your project. The pattern `*.js` matches JavaScript files but only in the current directory—if you want all JavaScript files at any depth, use `**/*.js` instead. The pattern `src/**` matches everything under the src folder. For an exact file match, just use the filename: `.env` matches exactly that file and nothing else. You can also use brace expansion: `*.{ts,tsx}` matches both TypeScript and TSX files.\n\n### Bash Patterns\n\nBash patterns control what shell commands your AI can run. The format is `command:arguments` where the colon separates the base command from its arguments.\n\nThe pattern `npm:*` matches any npm command with any arguments—that includes npm install, npm test, npm run build, and everything else npm can do. Similarly, `git:*` matches any git command. If you want to be more specific, `npm:test` matches exactly \"npm test\" and nothing else. A bare `*` matches any command at all, which is powerful but dangerous in the Allow column.\n\n### MCP Patterns\n\nMCP patterns control which tools from which MCP servers your AI can use. The format uses double underscores: `mcp__servername__toolname`.\n\nThe pattern `mcp__filesystem__*` matches any tool from the filesystem MCP. The pattern `mcp__github__*` matches any GitHub MCP tool. If you want to allow all MCP tools across all servers, `mcp__*__*` does that—though it's quite broad.\n\n### How Patterns Combine\n\nYou can add multiple rules at each permission level. They combine logically: if any Allow rule matches an operation, it's allowed (unless a Deny rule also matches, since Deny always takes precedence).\n\nA typical setup might allow reading anything, allow editing source files specifically, deny editing env files absolutely, and ask about all other edits. The deny rule catches the env files even though Edit would otherwise be allowed for source.\n\n### Precision vs Simplicity\n\nMore precise patterns give finer control but require more maintenance. Simpler patterns are easier to understand but less flexible.\n\nStart simple. Allowing all reads is probably fine—reading files is rarely dangerous. Asking about all edits is a safe default. Add more specific rules when you notice patterns in what you're approving or denying repeatedly. The permission system is designed to evolve with your workflow.\n "}},JW={"what-is-memory":{title:"What is Memory?",content:`
3399
+ `},"permission-patterns":{title:"Permission Patterns",content:"\nPermissions use pattern matching to determine what operations they cover. Understanding patterns lets you write precise rules.\n\n### File Patterns\n\nFile patterns control Read, Edit, and Write operations. The pattern `**` matches everything at any depth, so `Read(**)` means your AI can read any file anywhere in your project. The pattern `*.js` matches JavaScript files but only in the current directory—if you want all JavaScript files at any depth, use `**/*.js` instead. The pattern `src/**` matches everything under the src folder. For an exact file match, just use the filename: `.env` matches exactly that file and nothing else. You can also use brace expansion: `*.{ts,tsx}` matches both TypeScript and TSX files.\n\n### Bash Patterns\n\nBash patterns control what shell commands your AI can run. The format is `command:arguments` where the colon separates the base command from its arguments.\n\nThe pattern `npm:*` matches any npm command with any arguments—that includes npm install, npm test, npm run build, and everything else npm can do. Similarly, `git:*` matches any git command. If you want to be more specific, `npm:test` matches exactly \"npm test\" and nothing else. A bare `*` matches any command at all, which is powerful but dangerous in the Allow column.\n\n### MCP Patterns\n\nMCP patterns control which tools from which MCP servers your AI can use. The format uses double underscores: `mcp__servername__toolname`.\n\nThe pattern `mcp__filesystem__*` matches any tool from the filesystem MCP. The pattern `mcp__github__*` matches any GitHub MCP tool. If you want to allow all MCP tools across all servers, `mcp__*__*` does that—though it's quite broad.\n\n### How Patterns Combine\n\nYou can add multiple rules at each permission level. They combine logically: if any Allow rule matches an operation, it's allowed (unless a Deny rule also matches, since Deny always takes precedence).\n\nA typical setup might allow reading anything, allow editing source files specifically, deny editing env files absolutely, and ask about all other edits. The deny rule catches the env files even though Edit would otherwise be allowed for source.\n\n### Precision vs Simplicity\n\nMore precise patterns give finer control but require more maintenance. Simpler patterns are easier to understand but less flexible.\n\nStart simple. Allowing all reads is probably fine—reading files is rarely dangerous. Asking about all edits is a safe default. Add more specific rules when you notice patterns in what you're approving or denying repeatedly. The permission system is designed to evolve with your workflow.\n "}},QW={"what-is-memory":{title:"What is Memory?",content:`
3400
3400
  Memory lets your AI retain information across conversations. Without it, every session starts fresh—your AI doesn't know you prefer tabs over spaces, or that your team has specific naming conventions, or that last week you decided to use PostgreSQL instead of MySQL. With memory, you teach your AI once and it remembers.
3401
3401
 
3402
3402
  ### Two Kinds of Memory
@@ -3466,7 +3466,7 @@ Check your memory files occasionally. Delete duplicates. Consolidate related ent
3466
3466
  ### Where Files Live
3467
3467
 
3468
3468
  Global memory lives at \`~/.claude/memory/\` and project memory at \`your-project/.claude/memory/\`. You can edit these files directly if you prefer—they're just markdown. Coder Config's Memory view is a convenience, not a requirement.
3469
- `}},QW={"what-are-plugins":{title:"What Are Plugins?",content:`
3469
+ `}},ZW={"what-are-plugins":{title:"What Are Plugins?",content:`
3470
3470
  Plugins are pre-packaged configurations you can install with a click. Instead of writing rules from scratch, researching best practices, and figuring out which MCPs work well together, you install a plugin that someone else has already assembled.
3471
3471
 
3472
3472
  ### What's Inside a Plugin
@@ -3514,7 +3514,7 @@ Back on the Plugins view, you'll see a section showing what you've installed. Yo
3514
3514
  The default marketplace is just a starting point. You can add additional marketplaces from the **Plugins** view using **Manage Marketplaces**. Community marketplaces, company-internal collections, or your own curated set—add the git repo URL and refresh to see new plugins.
3515
3515
 
3516
3516
  You can also create your own plugins. The format is straightforward: a git repo with a manifest file and your configuration files. The Plugins view links to documentation if you want to try this.
3517
- `}},ZW={"what-are-workstreams":{title:"What Are Workstreams?",content:`
3517
+ `}},eU={"what-are-workstreams":{title:"What Are Workstreams?",content:`
3518
3518
  Workstreams solve a problem that anyone working on multi-repo projects knows well: your code is split across several repositories, but mentally it's all one thing.
3519
3519
 
3520
3520
  ### The Multi-Repo Reality
@@ -3587,7 +3587,7 @@ You can also manually activate a workstream with \`coder-config workstream use <
3587
3587
  ### One Product Per Workstream
3588
3588
 
3589
3589
  Keep workstreams focused. Each workstream represents one product or system. If you work on multiple products, create separate workstreams. Mixing unrelated repos in one workstream dilutes the context and confuses your AI about what goes with what.
3590
- `}},eU={"what-are-loops":{title:"What Are Ralph Loops?",content:`
3590
+ `}},tU={"what-are-loops":{title:"What Are Ralph Loops?",content:`
3591
3591
  > **Experimental Feature:** Ralph Loops must be enabled in **Preferences → Experimental Features** before use.
3592
3592
 
3593
3593
  Ralph Loops let your AI work autonomously on larger tasks. Instead of the usual back-and-forth where you give your AI an instruction, it does some work, and you say "continue" over and over, loops let your AI keep going until the task is done.
@@ -3659,7 +3659,7 @@ When the task completes, your AI reports what it accomplished. Review the change
3659
3659
  Loops work best for well-defined tasks that take significant effort but don't require constant human judgment. Feature implementations, test coverage expansion, refactoring, migration work—things where the goal is clear but the execution is tedious.
3660
3660
 
3661
3661
  For exploratory work where you're not sure what you want yet, the normal interactive mode might serve you better. Loops shine when you know the destination; they handle the journey.
3662
- `}},tU={"other-tools":{title:"Beyond Claude Code",content:`
3662
+ `}},rU={"other-tools":{title:"Beyond Claude Code",content:`
3663
3663
  Coder Config started as a configuration manager for Claude Code, but it's grown to support other AI coding tools too. If you use multiple assistants—maybe Claude for complex reasoning and Gemini for quick tasks—you can manage them all from one place.
3664
3664
 
3665
3665
  ### Supported Tools
@@ -3717,7 +3717,7 @@ If you need tool-specific rules that shouldn't sync, put them in a separate fold
3717
3717
  Each enabled tool has its own settings page in the sidebar. Claude Code has permissions and model preferences. Gemini CLI has display and sandbox settings. Codex CLI has security policies.
3718
3718
 
3719
3719
  Configure each tool according to its capabilities and your needs. The unified rules give you consistency in coding conventions; the per-tool settings let you optimize each assistant's behavior.
3720
- `}},rU={"next-steps":{title:"Next Steps",content:`
3720
+ `}},sU={"next-steps":{title:"Next Steps",content:`
3721
3721
  You've finished the Coder Config tutorial. At this point you know how to add projects, write rules, configure MCP servers, set up permissions, use the memory system, install plugins, work with workstreams, and sync across multiple tools.
3722
3722
 
3723
3723
  That covers the core functionality. Here's how to go deeper.
@@ -3760,6 +3760,6 @@ Everything you can do in the UI, you can do from the command line. Some power us
3760
3760
  Thanks for using Coder Config. The goal is to make AI coding assistants work the way you want them to, without the friction of scattered configuration files and forgotten context. Hopefully this tool helps.
3761
3761
 
3762
3762
  Happy coding.
3763
- `}},sU={...GW,...qW,...KW,...YW,...XW,...JW,...QW,...ZW,...eU,...tU,...rU},hu={welcome:{bg:"bg-violet-500",light:"bg-violet-100 dark:bg-violet-950",text:"text-violet-600 dark:text-violet-400"},"first-project":{bg:"bg-blue-500",light:"bg-blue-100 dark:bg-blue-950",text:"text-blue-600 dark:text-blue-400"},"rules-guide":{bg:"bg-emerald-500",light:"bg-emerald-100 dark:bg-emerald-950",text:"text-emerald-600 dark:text-emerald-400"},"mcp-guide":{bg:"bg-orange-500",light:"bg-orange-100 dark:bg-orange-950",text:"text-orange-600 dark:text-orange-400"},"permissions-guide":{bg:"bg-green-500",light:"bg-green-100 dark:bg-green-950",text:"text-green-600 dark:text-green-400"},"memory-guide":{bg:"bg-pink-500",light:"bg-pink-100 dark:bg-pink-950",text:"text-pink-600 dark:text-pink-400"},"plugins-guide":{bg:"bg-purple-500",light:"bg-purple-100 dark:bg-purple-950",text:"text-purple-600 dark:text-purple-400"},"workstreams-guide":{bg:"bg-cyan-500",light:"bg-cyan-100 dark:bg-cyan-950",text:"text-cyan-600 dark:text-cyan-400"},"loops-guide":{bg:"bg-teal-500",light:"bg-teal-100 dark:bg-teal-950",text:"text-teal-600 dark:text-teal-400"},"multi-tool-guide":{bg:"bg-amber-500",light:"bg-amber-100 dark:bg-amber-950",text:"text-amber-600 dark:text-amber-400"},"next-steps":{bg:"bg-rose-500",light:"bg-rose-100 dark:bg-rose-950",text:"text-rose-600 dark:text-rose-400"}},T_="claude-config-tutorial-visited",ip="claude-config-tutorial-active";function nU(){const[e,r]=_.useState(()=>{try{return localStorage.getItem(ip)||"intro"}catch{return"intro"}}),[s,n]=_.useState(()=>{try{const b=localStorage.getItem(ip)||"intro",S={welcome:!0};for(const N of Fa)N.subsections.some(P=>P.id===b)&&(S[N.id]=!0);return S}catch{return{welcome:!0}}}),[o,c]=_.useState(()=>{try{return JSON.parse(localStorage.getItem(T_)||"[]")}catch{return[]}}),d=_.useRef(null);_.useEffect(()=>{if(d.current){const b=d.current.querySelector("[data-radix-scroll-area-viewport]");b&&(b.scrollTop=0)}},[e]),_.useEffect(()=>{if(e&&(localStorage.setItem(ip,e),!o.includes(e))){const b=[...o,e];c(b),localStorage.setItem(T_,JSON.stringify(b))}},[e,o]);const l=b=>{n(S=>({...S,[b]:!S[b]}))},u=sU[e],f=Fa.flatMap(b=>b.subsections.length>0?b.subsections.map(S=>S.id):[b.id]),m=f.indexOf(e),h=m>0?f[m-1]:null,g=m<f.length-1?f[m+1]:null,w=Math.round(o.length/f.length*100),k=(()=>{for(const b of Fa)if(b.id===e||b.subsections.some(S=>S.id===e))return b;return Fa[0]})(),v=hu[k.id]||hu.welcome,y=b=>{for(const S of Fa){if(S.id===b)return S.title;const N=S.subsections.find(P=>P.id===b);if(N)return N.title}return""},x=b=>({__html:R2(b)});return t.jsxs("div",{className:"flex h-full",children:[t.jsxs("div",{className:"w-72 border-r border-border bg-muted/30 flex flex-col",children:[t.jsxs("div",{className:"p-4 border-b border-border bg-gradient-to-r from-indigo-500/10 to-purple-500/10",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-indigo-500 to-purple-600 flex items-center justify-center shadow-lg",children:t.jsx(Au,{className:"w-5 h-5 text-white"})}),t.jsxs("div",{children:[t.jsx("h2",{className:"font-semibold text-foreground",children:"Tutorial"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Step-by-step guide"})]})]}),t.jsxs("div",{className:"mt-3",children:[t.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground mb-1",children:[t.jsx("span",{children:"Progress"}),t.jsxs("span",{children:[w,"% complete"]})]}),t.jsx($2,{value:w,className:"h-2"})]})]}),t.jsx(Js,{className:"flex-1",children:t.jsx("div",{className:"p-2",children:Fa.map((b,S)=>{const N=b.icon,P=hu[b.id]||hu.welcome,A=e===b.id||b.subsections.some(M=>M.id===e),E=b.subsections.length>0?b.subsections.every(M=>o.includes(M.id)):o.includes(b.id);return t.jsxs("div",{className:"mb-1",children:[t.jsxs("button",{className:Ee("w-full flex items-center gap-2 px-3 py-2.5 text-sm rounded-lg hover:bg-accent text-left transition-all",A&&"bg-accent"),onClick:()=>{b.subsections.length>0?(l(b.id),s[b.id]||r(b.subsections[0].id)):r(b.id)},children:[t.jsx("span",{className:Ee("w-7 h-7 rounded-lg flex items-center justify-center transition-colors",A?P.bg+" text-white":P.light),children:E?t.jsx(vi,{className:"w-4 h-4"}):t.jsx(N,{className:Ee("w-4 h-4",!A&&P.text)})}),t.jsx("span",{className:Ee("flex-1",A&&"font-medium"),children:b.title}),b.subsections.length>0&&t.jsx(Qr,{className:Ee("w-4 h-4 text-muted-foreground transition-transform",s[b.id]&&"rotate-90")})]}),b.subsections.length>0&&s[b.id]&&t.jsx("div",{className:"ml-4 mt-1 space-y-0.5 border-l-2 border-border pl-3",children:b.subsections.map(M=>{const I=e===M.id,B=o.includes(M.id);return t.jsxs("button",{className:Ee("w-full text-left px-3 py-1.5 text-sm rounded-md hover:bg-accent text-foreground flex items-center gap-2",I&&"bg-accent font-medium",I&&P.text),onClick:()=>r(M.id),children:[B&&!I&&t.jsx(vi,{className:"w-3 h-3 text-green-500"}),t.jsx("span",{className:Ee(!B&&!I&&"ml-5"),children:M.title})]},M.id)})})]},b.id)})})})]}),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[t.jsx("div",{className:Ee("px-8 py-4 border-b border-border",v.light),children:t.jsxs("div",{className:"max-w-3xl mx-auto flex items-center gap-3",children:[t.jsx("div",{className:Ee("w-10 h-10 rounded-xl flex items-center justify-center",v.bg,"text-white"),children:t.jsx(k.icon,{className:"w-5 h-5"})}),t.jsxs("div",{children:[t.jsx("p",{className:Ee("text-sm font-medium",v.text),children:k.title}),t.jsx("h1",{className:"text-lg font-semibold text-foreground",children:(u==null?void 0:u.title)||y(e)})]})]})}),t.jsx(Js,{className:"flex-1",ref:d,children:t.jsx("div",{className:"max-w-3xl mx-auto p-8",children:u?t.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert prose-headings:text-foreground prose-p:text-muted-foreground prose-strong:text-foreground [&_:not(pre)>code]:text-primary [&_:not(pre)>code]:bg-muted [&_:not(pre)>code]:px-1 [&_:not(pre)>code]:py-0.5 [&_:not(pre)>code]:rounded [&_pre]:bg-zinc-900 [&_pre]:text-zinc-100 [&_pre]:border [&_pre]:border-zinc-700 [&_pre_code]:text-zinc-100 [&_pre_code]:bg-transparent [&_pre_code]:p-0",dangerouslySetInnerHTML:x(u.content)}):t.jsxs("div",{className:"text-center text-muted-foreground py-12",children:[t.jsx(Au,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),t.jsx("p",{children:"Select a topic from the sidebar"})]})})}),t.jsx("div",{className:"border-t border-border p-4 bg-muted/30",children:t.jsxs("div",{className:"max-w-3xl mx-auto flex items-center justify-between",children:[h?t.jsxs(ne,{variant:"ghost",onClick:()=>r(h),className:"flex items-center gap-2",children:[t.jsx($M,{className:"w-4 h-4"}),t.jsx("span",{className:"max-w-[150px] truncate",children:y(h)})]}):t.jsx("div",{}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:[m+1," of ",f.length]}),g?t.jsxs(ne,{onClick:()=>r(g),className:Ee("flex items-center gap-2",v.bg,"hover:opacity-90"),children:[t.jsx("span",{className:"max-w-[150px] truncate",children:y(g)}),t.jsx(Og,{className:"w-4 h-4"})]}):t.jsx(ne,{variant:"outline",onClick:()=>r("intro"),className:"flex items-center gap-2",children:"Start Over"})]})})]})]})}function iU(){const[e,r]=_.useState(null),[s,n]=_.useState(!0),[o,c]=_.useState(!1),[d,l]=_.useState(!1),[u,f]=_.useState(!1),[m,h]=_.useState(null);_.useEffect(()=>{g()},[]);const g=async()=>{try{n(!0);const S=await he.getSessionStatus();r(S)}catch{q.error("Failed to load session status")}finally{n(!1)}},w=async()=>{var S,N;c(!0);try{const P=await he.installSessionAll();P.success?(q.success("Session persistence installed!"),g()):q.error(((S=P.hooks)==null?void 0:S.error)||((N=P.command)==null?void 0:N.error)||"Installation failed")}catch{q.error("Installation failed")}finally{c(!1)}},j=async()=>{c(!0);try{const S=await he.installSessionHooks();S.success?(q.success("Session hooks installed!"),g()):q.error(S.error||"Failed to install hooks")}catch{q.error("Failed to install hooks")}finally{c(!1)}},k=async()=>{c(!0);try{const S=await he.installFlushCommand();S.success?(q.success(S.alreadyInstalled?"/flush command already installed":"/flush command installed!"),g()):q.error(S.error||"Failed to install command")}catch{q.error("Failed to install command")}finally{c(!1)}},v=async()=>{l(!0);try{const S=await he.clearSessionContext();S.success?(q.success(S.cleared?"Session context cleared":"No context to clear"),g()):q.error("Failed to clear context")}catch{q.error("Failed to clear context")}finally{l(!1)}},y=async()=>{try{const S=await he.getSessionContext();h(S.content),f(!0)}catch{q.error("Failed to load context")}},x=S=>S===null?"Unknown":S<60?`${S} minutes ago`:S<1440?`${Math.floor(S/60)} hours ago`:`${Math.floor(S/1440)} days ago`;if(s)return t.jsx("div",{className:"flex items-center justify-center h-64",children:t.jsx(Qe,{className:"w-8 h-8 animate-spin text-indigo-600"})});const b=(e==null?void 0:e.hooksInstalled)&&(e==null?void 0:e.flushCommandInstalled)&&(e==null?void 0:e.permissionInstalled);return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 p-5 shadow-sm",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"p-2 rounded-lg bg-indigo-100 dark:bg-indigo-950",children:t.jsx(Zr,{className:"w-5 h-5 text-indigo-600 dark:text-indigo-400"})}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Session Persistence"}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:"Save and restore Claude Code session context"})]})]}),t.jsx(ne,{variant:"ghost",size:"sm",onClick:g,children:t.jsx(Dr,{className:"w-4 h-4"})})]}),t.jsxs("p",{className:"text-sm text-gray-600 dark:text-slate-400",children:["Session persistence allows you to save your current Claude Code context using the ",t.jsx("code",{className:"bg-gray-100 dark:bg-slate-800 px-1.5 py-0.5 rounded text-indigo-600 dark:text-indigo-400",children:"/flush"})," command, and automatically restore it when you start a new session."]})]}),t.jsxs("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 overflow-hidden shadow-sm",children:[t.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-slate-700",children:t.jsx("h3",{className:"font-medium text-gray-900 dark:text-white",children:"Installation Status"})}),t.jsxs("div",{className:"divide-y divide-gray-100 dark:divide-slate-800",children:[t.jsxs("div",{className:"p-4 flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[e!=null&&e.hooksInstalled?t.jsx(It,{className:"w-5 h-5 text-green-500"}):t.jsx(Is,{className:"w-5 h-5 text-amber-500"}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Session Hooks"}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Auto-restore context on session start, preserve on session end"})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(qe,{variant:e!=null&&e.hooksInstalled?"default":"secondary",children:e!=null&&e.hooksInstalled?"Installed":"Not Installed"}),!(e!=null&&e.hooksInstalled)&&t.jsx(ne,{variant:"outline",size:"sm",onClick:j,disabled:o,children:o?t.jsx(Qe,{className:"w-4 h-4 animate-spin"}):"Install"})]})]}),t.jsxs("div",{className:"p-4 flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[e!=null&&e.flushCommandInstalled?t.jsx(It,{className:"w-5 h-5 text-green-500"}):t.jsx(Is,{className:"w-5 h-5 text-amber-500"}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"/flush Command"}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Adds the /flush command to save session context"})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(qe,{variant:e!=null&&e.flushCommandInstalled?"default":"secondary",children:e!=null&&e.flushCommandInstalled?"Installed":"Not Installed"}),!(e!=null&&e.flushCommandInstalled)&&t.jsx(ne,{variant:"outline",size:"sm",onClick:k,disabled:o,children:o?t.jsx(Qe,{className:"w-4 h-4 animate-spin"}):"Install"})]})]}),t.jsxs("div",{className:"p-4 flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[e!=null&&e.permissionInstalled?t.jsx(It,{className:"w-5 h-5 text-green-500"}):t.jsx(Is,{className:"w-5 h-5 text-amber-500"}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Write Permission"}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Allows Claude to write session context without prompting"})]})]}),t.jsx(qe,{variant:e!=null&&e.permissionInstalled?"default":"secondary",children:e!=null&&e.permissionInstalled?"Granted":"Not Granted"})]})]}),!b&&t.jsx("div",{className:"p-4 bg-gray-50 dark:bg-slate-900 border-t border-gray-200 dark:border-slate-800",children:t.jsxs(ne,{onClick:w,disabled:o,className:"w-full bg-indigo-600 hover:bg-indigo-700 text-white",children:[o?t.jsx(Qe,{className:"w-4 h-4 mr-2 animate-spin"}):t.jsx(yi,{className:"w-4 h-4 mr-2"}),"Install All"]})})]}),t.jsxs("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 overflow-hidden shadow-sm",children:[t.jsxs("div",{className:"p-4 border-b border-gray-200 dark:border-slate-700 flex items-center justify-between",children:[t.jsx("h3",{className:"font-medium text-gray-900 dark:text-white",children:"Saved Context"}),(e==null?void 0:e.hasSavedContext)&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(ne,{variant:"outline",size:"sm",onClick:y,children:[t.jsx(vr,{className:"w-4 h-4 mr-2"}),"View"]}),t.jsx(ne,{variant:"outline",size:"sm",onClick:v,disabled:d,className:"text-red-600 hover:text-red-700 hover:bg-red-50 dark:hover:bg-red-950",children:d?t.jsx(Qe,{className:"w-4 h-4 animate-spin"}):t.jsx(fs,{className:"w-4 h-4"})})]})]}),t.jsx("div",{className:"p-4",children:e!=null&&e.hasSavedContext?t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx(Ga,{className:"w-4 h-4 text-gray-400"}),t.jsx("span",{className:"text-gray-600 dark:text-slate-400",children:"Last saved:"}),t.jsx("span",{className:"text-gray-900 dark:text-white",children:x(e.contextAge)})]}),e.contextPreview&&t.jsx("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-3",children:t.jsx("pre",{className:"text-xs text-gray-600 dark:text-slate-400 whitespace-pre-wrap overflow-hidden",children:e.contextPreview})}),t.jsxs("div",{className:"text-xs text-gray-500 dark:text-slate-500",children:["Storage: ",e.sessionDir]})]}):t.jsxs("div",{className:"text-center py-6",children:[t.jsx(Zr,{className:"w-12 h-12 text-gray-300 dark:text-slate-600 mx-auto mb-3"}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-slate-400",children:"No saved context"}),t.jsxs("p",{className:"text-xs text-gray-400 dark:text-slate-500 mt-1",children:["Use ",t.jsx("code",{className:"bg-gray-100 dark:bg-slate-800 px-1 rounded",children:"/flush"})," in Claude Code to save your session"]})]})})]}),(e==null?void 0:e.lastSession)&&t.jsxs("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 overflow-hidden shadow-sm",children:[t.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-slate-700",children:t.jsx("h3",{className:"font-medium text-gray-900 dark:text-white",children:"Last Session"})}),t.jsxs("div",{className:"p-4 space-y-2",children:[e.lastSession.session_id&&t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx("span",{className:"text-gray-500 dark:text-slate-400 w-20",children:"ID:"}),t.jsx("code",{className:"text-xs bg-gray-100 dark:bg-slate-800 px-2 py-0.5 rounded",children:e.lastSession.session_id})]}),e.lastSession.cwd&&t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx("span",{className:"text-gray-500 dark:text-slate-400 w-20",children:"Directory:"}),t.jsx("span",{className:"text-gray-900 dark:text-white font-mono text-xs",children:e.lastSession.cwd})]}),e.lastSession.timestamp&&t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx("span",{className:"text-gray-500 dark:text-slate-400 w-20",children:"Ended:"}),t.jsx("span",{className:"text-gray-900 dark:text-white",children:e.lastSession.timestamp})]}),e.lastSession.reason&&t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx("span",{className:"text-gray-500 dark:text-slate-400 w-20",children:"Reason:"}),t.jsx(qe,{variant:"secondary",children:e.lastSession.reason})]})]})]}),t.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-4 border border-transparent dark:border-slate-800",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white mb-2",children:"How to Use"}),t.jsxs("ol",{className:"space-y-2 text-sm text-gray-600 dark:text-slate-400",children:[t.jsxs("li",{className:"flex gap-2",children:[t.jsx("span",{className:"font-medium text-indigo-600 dark:text-indigo-400",children:"1."}),"Install session hooks and the /flush command above"]}),t.jsxs("li",{className:"flex gap-2",children:[t.jsx("span",{className:"font-medium text-indigo-600 dark:text-indigo-400",children:"2."}),"Use ",t.jsx("code",{className:"bg-white dark:bg-slate-800 px-1.5 py-0.5 rounded",children:"/flush"})," in Claude Code before ending a session"]}),t.jsxs("li",{className:"flex gap-2",children:[t.jsx("span",{className:"font-medium text-indigo-600 dark:text-indigo-400",children:"3."}),"Your context is automatically restored when you start a new session"]})]})]}),t.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-4 border border-transparent dark:border-slate-800",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white mb-2",children:"CLI Commands"}),t.jsxs("div",{className:"space-y-1 text-sm text-gray-600 dark:text-slate-400 font-mono",children:[t.jsx("p",{children:"coder-config session # Show session status"}),t.jsx("p",{children:"coder-config session install-hooks # Install session hooks"}),t.jsx("p",{children:"coder-config session clear # Clear saved context"})]})]}),t.jsx(vt,{open:u,onOpenChange:f,children:t.jsxs(ft,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[t.jsxs(mt,{children:[t.jsx(pt,{children:"Saved Context"}),t.jsx(Gt,{children:"This context will be restored on your next Claude Code session"})]}),t.jsx("div",{className:"flex-1 overflow-auto py-4",children:t.jsx("pre",{className:"text-sm text-gray-700 dark:text-slate-300 whitespace-pre-wrap bg-gray-50 dark:bg-slate-900 p-4 rounded-lg",children:m||"No content"})}),t.jsx(St,{children:t.jsx(ne,{variant:"ghost",onClick:()=>f(!1),children:"Close"})})]})})]})}const oU=[{id:"model",label:"Model Name",preview:"claude-opus-4-7"},{id:"context-bar",label:"Context Bar",preview:"●●●●○○○○○○ 37%",hasStyle:!0},{id:"ctx-pct",label:"Context %",preview:"37% ctx"},{id:"ctx-tokens",label:"Token Counts",preview:"74.4K/200.0K"},{id:"ctx-remaining",label:"Context Remaining",preview:"63% ctx left"},{id:"lines-changed",label:"Lines Changed",preview:"+146 -13"},{id:"git-branch",label:"Git Branch",preview:"main"},{id:"duration",label:"Duration",preview:"5h 32m"},{id:"cost",label:"Cost (API equiv.)",preview:"$0.142"}],Zp={prefix:"* ",separator:" | ",blocks:[{id:"model",enabled:!0},{id:"context-bar",enabled:!0,style:"dots"},{id:"ctx-pct",enabled:!1},{id:"ctx-tokens",enabled:!1},{id:"ctx-remaining",enabled:!1},{id:"lines-changed",enabled:!1},{id:"git-branch",enabled:!1},{id:"duration",enabled:!1},{id:"cost",enabled:!1}]};function aU(e){const{prefix:r="* ",separator:s=" | ",blocks:n=[]}=e,o=[];for(const c of n.filter(d=>d.enabled))switch(c.id){case"model":o.push("claude-opus-4-7");break;case"context-bar":{const d=c.style==="blocks"?"█":"●",l=c.style==="blocks"?"░":"○";o.push(`ctx ${d.repeat(4)}${l.repeat(6)} 37%`);break}case"ctx-pct":o.push("37% ctx");break;case"ctx-tokens":o.push("74.4K/200.0K");break;case"ctx-remaining":o.push("63% ctx left");break;case"lines-changed":o.push("+146 -13");break;case"git-branch":o.push("main");break;case"duration":o.push("5h 32m");break;case"cost":o.push("$0.142");break}return o.length?r+o.join(s):"(empty)"}function eg(e){const{prefix:r="* ",separator:s=" | ",blocks:n=[]}=e,o=n.filter(f=>f.enabled),c=["#!/bin/bash",`# CONFIG: ${JSON.stringify(e)}`,"input=$(cat)"],d=f=>o.some(m=>m.id===f);d("model")&&c.push(`MODEL=$(echo "$input" | jq -r '.model.display_name // "?"')`),(d("context-bar")||d("ctx-pct")||d("ctx-remaining"))&&c.push(`PCT=$(echo "$input" | jq -r '.context_window.used_percentage // 0' | cut -d. -f1)`),d("ctx-remaining")&&c.push(`REM=$(echo "$input" | jq -r '.context_window.remaining_percentage // 0' | cut -d. -f1)`),d("ctx-tokens")&&(c.push(`CTX_USED=$(echo "$input" | jq -r '((.context_window.current_usage.input_tokens // 0) + (.context_window.current_usage.cache_creation_input_tokens // 0) + (.context_window.current_usage.cache_read_input_tokens // 0))')`),c.push(`CTX_MAX=$(echo "$input" | jq -r '.context_window.context_window_size // 200000')`),c.push('CTX_K=$(awk "BEGIN {printf \\"%.1fK\\", $CTX_USED/1000}")'),c.push('MAX_K=$(awk "BEGIN {printf \\"%.1fK\\", $CTX_MAX/1000}")')),d("lines-changed")&&(c.push(`LINES_ADD=$(echo "$input" | jq -r '.cost.total_lines_added // 0')`),c.push(`LINES_REM=$(echo "$input" | jq -r '.cost.total_lines_removed // 0')`)),d("duration")&&(c.push(`DUR_MS=$(echo "$input" | jq -r '.cost.total_duration_ms // 0')`),c.push("HOURS=$((DUR_MS / 3600000)); MINS=$(((DUR_MS % 3600000) / 60000)); SECS=$(((DUR_MS % 60000) / 1000))")),d("cost")&&(c.push(`COST=$(echo "$input" | jq -r '.cost.total_cost_usd // 0')`),c.push("COST_FMT=$(printf '$%.3f' $COST)")),d("git-branch")&&c.push("BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo '')");const l=o.find(f=>f.id==="context-bar");if(l){const f=l.style==="blocks"?"█":"●",m=l.style==="blocks"?"░":"○";c.push("FILLED=$((PCT / 10)); EMPTY=$((10 - FILLED))"),c.push(`BAR=""; [ "$FILLED" -gt 0 ] && BAR="$BAR$(printf '${f}%.0s' $(seq 1 $FILLED))"`),c.push(` [ "$EMPTY" -gt 0 ] && BAR="$BAR$(printf '${m}%.0s' $(seq 1 $EMPTY))"`)}let u=!0;for(const f of o){const m=(h,g)=>{u?(c.push(`OUT="${r}${h}"`),u=!1):g?c.push(`${g} && OUT="$OUT${s}${h}"`):c.push(`OUT="$OUT${s}${h}"`)};switch(f.id){case"model":m("$MODEL");break;case"context-bar":m("ctx $BAR $PCT%");break;case"ctx-pct":m("$PCT% ctx");break;case"ctx-tokens":m("$CTX_K/$MAX_K");break;case"ctx-remaining":m("$REM% ctx left");break;case"lines-changed":m("+$LINES_ADD -$LINES_REM",'[ "$LINES_ADD" != "0" ] || [ "$LINES_REM" != "0" ]');break;case"git-branch":m("$BRANCH",'[ -n "$BRANCH" ]');break;case"duration":u?(c.push(`[ "$HOURS" -gt 0 ] && OUT="${r}\${HOURS}h \${MINS}m" || OUT="${r}\${MINS}m \${SECS}s"`),u=!1):c.push(`[ "$HOURS" -gt 0 ] && OUT="$OUT${s}\${HOURS}h \${MINS}m" || OUT="$OUT${s}\${MINS}m \${SECS}s"`);break;case"cost":m("$COST_FMT");break}}return u&&c.push('OUT=""'),c.push('echo "$OUT"'),c.join(`
3763
+ `}},nU={...qW,...KW,...YW,...XW,...JW,...QW,...ZW,...eU,...tU,...rU,...sU},hu={welcome:{bg:"bg-violet-500",light:"bg-violet-100 dark:bg-violet-950",text:"text-violet-600 dark:text-violet-400"},"first-project":{bg:"bg-blue-500",light:"bg-blue-100 dark:bg-blue-950",text:"text-blue-600 dark:text-blue-400"},"rules-guide":{bg:"bg-emerald-500",light:"bg-emerald-100 dark:bg-emerald-950",text:"text-emerald-600 dark:text-emerald-400"},"mcp-guide":{bg:"bg-orange-500",light:"bg-orange-100 dark:bg-orange-950",text:"text-orange-600 dark:text-orange-400"},"permissions-guide":{bg:"bg-green-500",light:"bg-green-100 dark:bg-green-950",text:"text-green-600 dark:text-green-400"},"memory-guide":{bg:"bg-pink-500",light:"bg-pink-100 dark:bg-pink-950",text:"text-pink-600 dark:text-pink-400"},"plugins-guide":{bg:"bg-purple-500",light:"bg-purple-100 dark:bg-purple-950",text:"text-purple-600 dark:text-purple-400"},"workstreams-guide":{bg:"bg-cyan-500",light:"bg-cyan-100 dark:bg-cyan-950",text:"text-cyan-600 dark:text-cyan-400"},"loops-guide":{bg:"bg-teal-500",light:"bg-teal-100 dark:bg-teal-950",text:"text-teal-600 dark:text-teal-400"},"multi-tool-guide":{bg:"bg-amber-500",light:"bg-amber-100 dark:bg-amber-950",text:"text-amber-600 dark:text-amber-400"},"next-steps":{bg:"bg-rose-500",light:"bg-rose-100 dark:bg-rose-950",text:"text-rose-600 dark:text-rose-400"}},T_="claude-config-tutorial-visited",ip="claude-config-tutorial-active";function iU(){const[e,r]=_.useState(()=>{try{return localStorage.getItem(ip)||"intro"}catch{return"intro"}}),[s,n]=_.useState(()=>{try{const b=localStorage.getItem(ip)||"intro",S={welcome:!0};for(const N of Fa)N.subsections.some(P=>P.id===b)&&(S[N.id]=!0);return S}catch{return{welcome:!0}}}),[o,c]=_.useState(()=>{try{return JSON.parse(localStorage.getItem(T_)||"[]")}catch{return[]}}),d=_.useRef(null);_.useEffect(()=>{if(d.current){const b=d.current.querySelector("[data-radix-scroll-area-viewport]");b&&(b.scrollTop=0)}},[e]),_.useEffect(()=>{if(e&&(localStorage.setItem(ip,e),!o.includes(e))){const b=[...o,e];c(b),localStorage.setItem(T_,JSON.stringify(b))}},[e,o]);const l=b=>{n(S=>({...S,[b]:!S[b]}))},u=nU[e],f=Fa.flatMap(b=>b.subsections.length>0?b.subsections.map(S=>S.id):[b.id]),m=f.indexOf(e),h=m>0?f[m-1]:null,g=m<f.length-1?f[m+1]:null,w=Math.round(o.length/f.length*100),k=(()=>{for(const b of Fa)if(b.id===e||b.subsections.some(S=>S.id===e))return b;return Fa[0]})(),v=hu[k.id]||hu.welcome,y=b=>{for(const S of Fa){if(S.id===b)return S.title;const N=S.subsections.find(P=>P.id===b);if(N)return N.title}return""},x=b=>({__html:R2(b)});return t.jsxs("div",{className:"flex h-full",children:[t.jsxs("div",{className:"w-72 border-r border-border bg-muted/30 flex flex-col",children:[t.jsxs("div",{className:"p-4 border-b border-border bg-gradient-to-r from-indigo-500/10 to-purple-500/10",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-indigo-500 to-purple-600 flex items-center justify-center shadow-lg",children:t.jsx(Au,{className:"w-5 h-5 text-white"})}),t.jsxs("div",{children:[t.jsx("h2",{className:"font-semibold text-foreground",children:"Tutorial"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Step-by-step guide"})]})]}),t.jsxs("div",{className:"mt-3",children:[t.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground mb-1",children:[t.jsx("span",{children:"Progress"}),t.jsxs("span",{children:[w,"% complete"]})]}),t.jsx($2,{value:w,className:"h-2"})]})]}),t.jsx(Js,{className:"flex-1",children:t.jsx("div",{className:"p-2",children:Fa.map((b,S)=>{const N=b.icon,P=hu[b.id]||hu.welcome,A=e===b.id||b.subsections.some(M=>M.id===e),E=b.subsections.length>0?b.subsections.every(M=>o.includes(M.id)):o.includes(b.id);return t.jsxs("div",{className:"mb-1",children:[t.jsxs("button",{className:Ee("w-full flex items-center gap-2 px-3 py-2.5 text-sm rounded-lg hover:bg-accent text-left transition-all",A&&"bg-accent"),onClick:()=>{b.subsections.length>0?(l(b.id),s[b.id]||r(b.subsections[0].id)):r(b.id)},children:[t.jsx("span",{className:Ee("w-7 h-7 rounded-lg flex items-center justify-center transition-colors",A?P.bg+" text-white":P.light),children:E?t.jsx(vi,{className:"w-4 h-4"}):t.jsx(N,{className:Ee("w-4 h-4",!A&&P.text)})}),t.jsx("span",{className:Ee("flex-1",A&&"font-medium"),children:b.title}),b.subsections.length>0&&t.jsx(Qr,{className:Ee("w-4 h-4 text-muted-foreground transition-transform",s[b.id]&&"rotate-90")})]}),b.subsections.length>0&&s[b.id]&&t.jsx("div",{className:"ml-4 mt-1 space-y-0.5 border-l-2 border-border pl-3",children:b.subsections.map(M=>{const I=e===M.id,B=o.includes(M.id);return t.jsxs("button",{className:Ee("w-full text-left px-3 py-1.5 text-sm rounded-md hover:bg-accent text-foreground flex items-center gap-2",I&&"bg-accent font-medium",I&&P.text),onClick:()=>r(M.id),children:[B&&!I&&t.jsx(vi,{className:"w-3 h-3 text-green-500"}),t.jsx("span",{className:Ee(!B&&!I&&"ml-5"),children:M.title})]},M.id)})})]},b.id)})})})]}),t.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col",children:[t.jsx("div",{className:Ee("px-8 py-4 border-b border-border",v.light),children:t.jsxs("div",{className:"max-w-3xl mx-auto flex items-center gap-3",children:[t.jsx("div",{className:Ee("w-10 h-10 rounded-xl flex items-center justify-center",v.bg,"text-white"),children:t.jsx(k.icon,{className:"w-5 h-5"})}),t.jsxs("div",{children:[t.jsx("p",{className:Ee("text-sm font-medium",v.text),children:k.title}),t.jsx("h1",{className:"text-lg font-semibold text-foreground",children:(u==null?void 0:u.title)||y(e)})]})]})}),t.jsx(Js,{className:"flex-1",ref:d,children:t.jsx("div",{className:"max-w-3xl mx-auto p-8",children:u?t.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert prose-headings:text-foreground prose-p:text-muted-foreground prose-strong:text-foreground [&_:not(pre)>code]:text-primary [&_:not(pre)>code]:bg-muted [&_:not(pre)>code]:px-1 [&_:not(pre)>code]:py-0.5 [&_:not(pre)>code]:rounded [&_pre]:bg-zinc-900 [&_pre]:text-zinc-100 [&_pre]:border [&_pre]:border-zinc-700 [&_pre_code]:text-zinc-100 [&_pre_code]:bg-transparent [&_pre_code]:p-0",dangerouslySetInnerHTML:x(u.content)}):t.jsxs("div",{className:"text-center text-muted-foreground py-12",children:[t.jsx(Au,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),t.jsx("p",{children:"Select a topic from the sidebar"})]})})}),t.jsx("div",{className:"border-t border-border p-4 bg-muted/30",children:t.jsxs("div",{className:"max-w-3xl mx-auto flex items-center justify-between",children:[h?t.jsxs(ne,{variant:"ghost",onClick:()=>r(h),className:"flex items-center gap-2",children:[t.jsx($M,{className:"w-4 h-4"}),t.jsx("span",{className:"max-w-[150px] truncate",children:y(h)})]}):t.jsx("div",{}),t.jsxs("span",{className:"text-xs text-muted-foreground",children:[m+1," of ",f.length]}),g?t.jsxs(ne,{onClick:()=>r(g),className:Ee("flex items-center gap-2",v.bg,"hover:opacity-90"),children:[t.jsx("span",{className:"max-w-[150px] truncate",children:y(g)}),t.jsx(Og,{className:"w-4 h-4"})]}):t.jsx(ne,{variant:"outline",onClick:()=>r("intro"),className:"flex items-center gap-2",children:"Start Over"})]})})]})]})}function oU(){const[e,r]=_.useState(null),[s,n]=_.useState(!0),[o,c]=_.useState(!1),[d,l]=_.useState(!1),[u,f]=_.useState(!1),[m,h]=_.useState(null);_.useEffect(()=>{g()},[]);const g=async()=>{try{n(!0);const S=await he.getSessionStatus();r(S)}catch{q.error("Failed to load session status")}finally{n(!1)}},w=async()=>{var S,N;c(!0);try{const P=await he.installSessionAll();P.success?(q.success("Session persistence installed!"),g()):q.error(((S=P.hooks)==null?void 0:S.error)||((N=P.command)==null?void 0:N.error)||"Installation failed")}catch{q.error("Installation failed")}finally{c(!1)}},j=async()=>{c(!0);try{const S=await he.installSessionHooks();S.success?(q.success("Session hooks installed!"),g()):q.error(S.error||"Failed to install hooks")}catch{q.error("Failed to install hooks")}finally{c(!1)}},k=async()=>{c(!0);try{const S=await he.installFlushCommand();S.success?(q.success(S.alreadyInstalled?"/flush command already installed":"/flush command installed!"),g()):q.error(S.error||"Failed to install command")}catch{q.error("Failed to install command")}finally{c(!1)}},v=async()=>{l(!0);try{const S=await he.clearSessionContext();S.success?(q.success(S.cleared?"Session context cleared":"No context to clear"),g()):q.error("Failed to clear context")}catch{q.error("Failed to clear context")}finally{l(!1)}},y=async()=>{try{const S=await he.getSessionContext();h(S.content),f(!0)}catch{q.error("Failed to load context")}},x=S=>S===null?"Unknown":S<60?`${S} minutes ago`:S<1440?`${Math.floor(S/60)} hours ago`:`${Math.floor(S/1440)} days ago`;if(s)return t.jsx("div",{className:"flex items-center justify-center h-64",children:t.jsx(Qe,{className:"w-8 h-8 animate-spin text-indigo-600"})});const b=(e==null?void 0:e.hooksInstalled)&&(e==null?void 0:e.flushCommandInstalled)&&(e==null?void 0:e.permissionInstalled);return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 p-5 shadow-sm",children:[t.jsxs("div",{className:"flex items-center justify-between mb-4",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"p-2 rounded-lg bg-indigo-100 dark:bg-indigo-950",children:t.jsx(Zr,{className:"w-5 h-5 text-indigo-600 dark:text-indigo-400"})}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Session Persistence"}),t.jsx("p",{className:"text-sm text-gray-500 dark:text-slate-400",children:"Save and restore Claude Code session context"})]})]}),t.jsx(ne,{variant:"ghost",size:"sm",onClick:g,children:t.jsx(Dr,{className:"w-4 h-4"})})]}),t.jsxs("p",{className:"text-sm text-gray-600 dark:text-slate-400",children:["Session persistence allows you to save your current Claude Code context using the ",t.jsx("code",{className:"bg-gray-100 dark:bg-slate-800 px-1.5 py-0.5 rounded text-indigo-600 dark:text-indigo-400",children:"/flush"})," command, and automatically restore it when you start a new session."]})]}),t.jsxs("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 overflow-hidden shadow-sm",children:[t.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-slate-700",children:t.jsx("h3",{className:"font-medium text-gray-900 dark:text-white",children:"Installation Status"})}),t.jsxs("div",{className:"divide-y divide-gray-100 dark:divide-slate-800",children:[t.jsxs("div",{className:"p-4 flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[e!=null&&e.hooksInstalled?t.jsx(It,{className:"w-5 h-5 text-green-500"}):t.jsx(Is,{className:"w-5 h-5 text-amber-500"}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Session Hooks"}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Auto-restore context on session start, preserve on session end"})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(qe,{variant:e!=null&&e.hooksInstalled?"default":"secondary",children:e!=null&&e.hooksInstalled?"Installed":"Not Installed"}),!(e!=null&&e.hooksInstalled)&&t.jsx(ne,{variant:"outline",size:"sm",onClick:j,disabled:o,children:o?t.jsx(Qe,{className:"w-4 h-4 animate-spin"}):"Install"})]})]}),t.jsxs("div",{className:"p-4 flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[e!=null&&e.flushCommandInstalled?t.jsx(It,{className:"w-5 h-5 text-green-500"}):t.jsx(Is,{className:"w-5 h-5 text-amber-500"}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"/flush Command"}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Adds the /flush command to save session context"})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(qe,{variant:e!=null&&e.flushCommandInstalled?"default":"secondary",children:e!=null&&e.flushCommandInstalled?"Installed":"Not Installed"}),!(e!=null&&e.flushCommandInstalled)&&t.jsx(ne,{variant:"outline",size:"sm",onClick:k,disabled:o,children:o?t.jsx(Qe,{className:"w-4 h-4 animate-spin"}):"Install"})]})]}),t.jsxs("div",{className:"p-4 flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[e!=null&&e.permissionInstalled?t.jsx(It,{className:"w-5 h-5 text-green-500"}):t.jsx(Is,{className:"w-5 h-5 text-amber-500"}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"Write Permission"}),t.jsx("div",{className:"text-xs text-gray-500 dark:text-slate-400",children:"Allows Claude to write session context without prompting"})]})]}),t.jsx(qe,{variant:e!=null&&e.permissionInstalled?"default":"secondary",children:e!=null&&e.permissionInstalled?"Granted":"Not Granted"})]})]}),!b&&t.jsx("div",{className:"p-4 bg-gray-50 dark:bg-slate-900 border-t border-gray-200 dark:border-slate-800",children:t.jsxs(ne,{onClick:w,disabled:o,className:"w-full bg-indigo-600 hover:bg-indigo-700 text-white",children:[o?t.jsx(Qe,{className:"w-4 h-4 mr-2 animate-spin"}):t.jsx(yi,{className:"w-4 h-4 mr-2"}),"Install All"]})})]}),t.jsxs("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 overflow-hidden shadow-sm",children:[t.jsxs("div",{className:"p-4 border-b border-gray-200 dark:border-slate-700 flex items-center justify-between",children:[t.jsx("h3",{className:"font-medium text-gray-900 dark:text-white",children:"Saved Context"}),(e==null?void 0:e.hasSavedContext)&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(ne,{variant:"outline",size:"sm",onClick:y,children:[t.jsx(vr,{className:"w-4 h-4 mr-2"}),"View"]}),t.jsx(ne,{variant:"outline",size:"sm",onClick:v,disabled:d,className:"text-red-600 hover:text-red-700 hover:bg-red-50 dark:hover:bg-red-950",children:d?t.jsx(Qe,{className:"w-4 h-4 animate-spin"}):t.jsx(fs,{className:"w-4 h-4"})})]})]}),t.jsx("div",{className:"p-4",children:e!=null&&e.hasSavedContext?t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx(Ga,{className:"w-4 h-4 text-gray-400"}),t.jsx("span",{className:"text-gray-600 dark:text-slate-400",children:"Last saved:"}),t.jsx("span",{className:"text-gray-900 dark:text-white",children:x(e.contextAge)})]}),e.contextPreview&&t.jsx("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-3",children:t.jsx("pre",{className:"text-xs text-gray-600 dark:text-slate-400 whitespace-pre-wrap overflow-hidden",children:e.contextPreview})}),t.jsxs("div",{className:"text-xs text-gray-500 dark:text-slate-500",children:["Storage: ",e.sessionDir]})]}):t.jsxs("div",{className:"text-center py-6",children:[t.jsx(Zr,{className:"w-12 h-12 text-gray-300 dark:text-slate-600 mx-auto mb-3"}),t.jsx("p",{className:"text-sm text-gray-600 dark:text-slate-400",children:"No saved context"}),t.jsxs("p",{className:"text-xs text-gray-400 dark:text-slate-500 mt-1",children:["Use ",t.jsx("code",{className:"bg-gray-100 dark:bg-slate-800 px-1 rounded",children:"/flush"})," in Claude Code to save your session"]})]})})]}),(e==null?void 0:e.lastSession)&&t.jsxs("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 overflow-hidden shadow-sm",children:[t.jsx("div",{className:"p-4 border-b border-gray-200 dark:border-slate-700",children:t.jsx("h3",{className:"font-medium text-gray-900 dark:text-white",children:"Last Session"})}),t.jsxs("div",{className:"p-4 space-y-2",children:[e.lastSession.session_id&&t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx("span",{className:"text-gray-500 dark:text-slate-400 w-20",children:"ID:"}),t.jsx("code",{className:"text-xs bg-gray-100 dark:bg-slate-800 px-2 py-0.5 rounded",children:e.lastSession.session_id})]}),e.lastSession.cwd&&t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx("span",{className:"text-gray-500 dark:text-slate-400 w-20",children:"Directory:"}),t.jsx("span",{className:"text-gray-900 dark:text-white font-mono text-xs",children:e.lastSession.cwd})]}),e.lastSession.timestamp&&t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx("span",{className:"text-gray-500 dark:text-slate-400 w-20",children:"Ended:"}),t.jsx("span",{className:"text-gray-900 dark:text-white",children:e.lastSession.timestamp})]}),e.lastSession.reason&&t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx("span",{className:"text-gray-500 dark:text-slate-400 w-20",children:"Reason:"}),t.jsx(qe,{variant:"secondary",children:e.lastSession.reason})]})]})]}),t.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-4 border border-transparent dark:border-slate-800",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white mb-2",children:"How to Use"}),t.jsxs("ol",{className:"space-y-2 text-sm text-gray-600 dark:text-slate-400",children:[t.jsxs("li",{className:"flex gap-2",children:[t.jsx("span",{className:"font-medium text-indigo-600 dark:text-indigo-400",children:"1."}),"Install session hooks and the /flush command above"]}),t.jsxs("li",{className:"flex gap-2",children:[t.jsx("span",{className:"font-medium text-indigo-600 dark:text-indigo-400",children:"2."}),"Use ",t.jsx("code",{className:"bg-white dark:bg-slate-800 px-1.5 py-0.5 rounded",children:"/flush"})," in Claude Code before ending a session"]}),t.jsxs("li",{className:"flex gap-2",children:[t.jsx("span",{className:"font-medium text-indigo-600 dark:text-indigo-400",children:"3."}),"Your context is automatically restored when you start a new session"]})]})]}),t.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-4 border border-transparent dark:border-slate-800",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white mb-2",children:"CLI Commands"}),t.jsxs("div",{className:"space-y-1 text-sm text-gray-600 dark:text-slate-400 font-mono",children:[t.jsx("p",{children:"coder-config session # Show session status"}),t.jsx("p",{children:"coder-config session install-hooks # Install session hooks"}),t.jsx("p",{children:"coder-config session clear # Clear saved context"})]})]}),t.jsx(vt,{open:u,onOpenChange:f,children:t.jsxs(ft,{className:"max-w-2xl max-h-[80vh] overflow-hidden flex flex-col",children:[t.jsxs(mt,{children:[t.jsx(pt,{children:"Saved Context"}),t.jsx(Gt,{children:"This context will be restored on your next Claude Code session"})]}),t.jsx("div",{className:"flex-1 overflow-auto py-4",children:t.jsx("pre",{className:"text-sm text-gray-700 dark:text-slate-300 whitespace-pre-wrap bg-gray-50 dark:bg-slate-900 p-4 rounded-lg",children:m||"No content"})}),t.jsx(St,{children:t.jsx(ne,{variant:"ghost",onClick:()=>f(!1),children:"Close"})})]})})]})}const aU=[{id:"model",label:"Model Name",preview:"claude-opus-4-7"},{id:"context-bar",label:"Context Bar",preview:"●●●●○○○○○○ 37%",hasStyle:!0},{id:"ctx-pct",label:"Context %",preview:"37% ctx"},{id:"ctx-tokens",label:"Token Counts",preview:"74.4K/200.0K"},{id:"ctx-remaining",label:"Context Remaining",preview:"63% ctx left"},{id:"lines-changed",label:"Lines Changed",preview:"+146 -13"},{id:"git-branch",label:"Git Branch",preview:"main"},{id:"duration",label:"Duration",preview:"5h 32m"},{id:"cost",label:"Cost (API equiv.)",preview:"$0.142"},{id:"cache",label:"Cache Tier",preview:"cache 5m"}],Zp={prefix:"* ",separator:" | ",blocks:[{id:"model",enabled:!0},{id:"context-bar",enabled:!0,style:"dots"},{id:"ctx-pct",enabled:!1},{id:"ctx-tokens",enabled:!1},{id:"ctx-remaining",enabled:!1},{id:"lines-changed",enabled:!1},{id:"git-branch",enabled:!1},{id:"duration",enabled:!1},{id:"cost",enabled:!1},{id:"cache",enabled:!1}]};function lU(e){const{prefix:r="* ",separator:s=" | ",blocks:n=[]}=e,o=[];for(const c of n.filter(d=>d.enabled))switch(c.id){case"model":o.push("claude-opus-4-7");break;case"context-bar":{const d=c.style==="blocks"?"█":"●",l=c.style==="blocks"?"░":"○";o.push(`ctx ${d.repeat(4)}${l.repeat(6)} 37%`);break}case"ctx-pct":o.push("37% ctx");break;case"ctx-tokens":o.push("74.4K/200.0K");break;case"ctx-remaining":o.push("63% ctx left");break;case"lines-changed":o.push("+146 -13");break;case"git-branch":o.push("main");break;case"duration":o.push("5h 32m");break;case"cost":o.push("$0.142");break;case"cache":o.push("cache 5m");break}return o.length?r+o.join(s):"(empty)"}function eg(e){const{prefix:r="* ",separator:s=" | ",blocks:n=[]}=e,o=n.filter(f=>f.enabled),c=["#!/bin/bash",`# CONFIG: ${JSON.stringify(e)}`,"input=$(cat)"],d=f=>o.some(m=>m.id===f);d("model")&&c.push(`MODEL=$(echo "$input" | jq -r '.model.display_name // "?"')`),(d("context-bar")||d("ctx-pct")||d("ctx-remaining"))&&c.push(`PCT=$(echo "$input" | jq -r '.context_window.used_percentage // 0' | cut -d. -f1)`),d("ctx-remaining")&&c.push(`REM=$(echo "$input" | jq -r '.context_window.remaining_percentage // 0' | cut -d. -f1)`),d("ctx-tokens")&&(c.push(`CTX_USED=$(echo "$input" | jq -r '((.context_window.current_usage.input_tokens // 0) + (.context_window.current_usage.cache_creation_input_tokens // 0) + (.context_window.current_usage.cache_read_input_tokens // 0))')`),c.push(`CTX_MAX=$(echo "$input" | jq -r '.context_window.context_window_size // 200000')`),c.push('CTX_K=$(awk "BEGIN {printf \\"%.1fK\\", $CTX_USED/1000}")'),c.push('MAX_K=$(awk "BEGIN {printf \\"%.1fK\\", $CTX_MAX/1000}")')),d("lines-changed")&&(c.push(`LINES_ADD=$(echo "$input" | jq -r '.cost.total_lines_added // 0')`),c.push(`LINES_REM=$(echo "$input" | jq -r '.cost.total_lines_removed // 0')`)),d("duration")&&(c.push(`DUR_MS=$(echo "$input" | jq -r '.cost.total_duration_ms // 0')`),c.push("HOURS=$((DUR_MS / 3600000)); MINS=$(((DUR_MS % 3600000) / 60000)); SECS=$(((DUR_MS % 60000) / 1000))")),d("cost")&&(c.push(`COST=$(echo "$input" | jq -r '.cost.total_cost_usd // 0')`),c.push("COST_FMT=$(printf '$%.3f' $COST)")),d("git-branch")&&c.push("BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo '')"),d("cache")&&(c.push(`TRANSCRIPT=$(echo "$input" | jq -r '.transcript_path // ""')`),c.push('CACHE_TIER=""'),c.push('if [ -n "$TRANSCRIPT" ] && [ -f "$TRANSCRIPT" ]; then'),c.push(` CACHE_TIER=$(tail -200 "$TRANSCRIPT" 2>/dev/null | jq -r 'select(.message.usage.cache_creation) | if (.message.usage.cache_creation.ephemeral_1h_input_tokens // 0) > 0 then "1h" elif (.message.usage.cache_creation.ephemeral_5m_input_tokens // 0) > 0 then "5m" else empty end' 2>/dev/null | tail -1)`),c.push("fi"));const l=o.find(f=>f.id==="context-bar");if(l){const f=l.style==="blocks"?"█":"●",m=l.style==="blocks"?"░":"○";c.push("FILLED=$((PCT / 10)); EMPTY=$((10 - FILLED))"),c.push(`BAR=""; [ "$FILLED" -gt 0 ] && BAR="$BAR$(printf '${f}%.0s' $(seq 1 $FILLED))"`),c.push(` [ "$EMPTY" -gt 0 ] && BAR="$BAR$(printf '${m}%.0s' $(seq 1 $EMPTY))"`)}let u=!0;for(const f of o){const m=(h,g)=>{u?(c.push(`OUT="${r}${h}"`),u=!1):g?c.push(`${g} && OUT="$OUT${s}${h}"`):c.push(`OUT="$OUT${s}${h}"`)};switch(f.id){case"model":m("$MODEL");break;case"context-bar":m("ctx $BAR $PCT%");break;case"ctx-pct":m("$PCT% ctx");break;case"ctx-tokens":m("$CTX_K/$MAX_K");break;case"ctx-remaining":m("$REM% ctx left");break;case"lines-changed":m("+$LINES_ADD -$LINES_REM",'[ "$LINES_ADD" != "0" ] || [ "$LINES_REM" != "0" ]');break;case"git-branch":m("$BRANCH",'[ -n "$BRANCH" ]');break;case"duration":u?(c.push(`[ "$HOURS" -gt 0 ] && OUT="${r}\${HOURS}h \${MINS}m" || OUT="${r}\${MINS}m \${SECS}s"`),u=!1):c.push(`[ "$HOURS" -gt 0 ] && OUT="$OUT${s}\${HOURS}h \${MINS}m" || OUT="$OUT${s}\${MINS}m \${SECS}s"`);break;case"cost":m("$COST_FMT");break;case"cache":m("cache $CACHE_TIER",'[ -n "$CACHE_TIER" ]');break}}return u&&c.push('OUT=""'),c.push('echo "$OUT"'),c.join(`
3764
3764
  `)+`
3765
- `}function fu(e){const r=e==null?void 0:e.match(/^# CONFIG: (.+)$/m);if(!r)return null;try{return JSON.parse(r[1])}catch{return null}}function R_({value:e,onChange:r}){const[s,n]=_.useState("visual"),[o,c]=_.useState(()=>fu(e)||Zp);_.useEffect(()=>{const m=fu(e);m&&c(m)},[e]);const d=m=>{c(m),r(eg(m))},l=m=>{if(m==="raw")r(eg(o));else{const h=fu(e);h&&c(h)}n(m)},u=(m,h)=>{const g=[...o.blocks],w=m+h;w<0||w>=g.length||([g[m],g[w]]=[g[w],g[m]],d({...o,blocks:g}))},f=!!fu(e);return t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"flex gap-1 bg-gray-100 dark:bg-slate-800 rounded-lg p-1 w-fit",children:[["visual","Visual"],["raw","Raw Bash"]].map(([m,h])=>t.jsx("button",{onClick:()=>l(m),className:`px-3 py-1 rounded text-xs font-medium transition-colors ${s===m?"bg-white dark:bg-slate-700 text-gray-900 dark:text-white shadow-sm":"text-gray-500 dark:text-slate-400 hover:text-gray-700 dark:hover:text-slate-300"}`,children:h},m))}),s==="visual"?t.jsxs("div",{className:"space-y-2",children:[!f&&(e==null?void 0:e.trim())&&t.jsxs("p",{className:"text-xs text-amber-500 dark:text-amber-400",children:["This script wasn't generated by the visual editor — showing template."," ",t.jsx("button",{onClick:()=>d(Zp),className:"underline hover:no-underline",children:"Reset to default"})]}),t.jsx("div",{className:"px-2 py-1.5 bg-gray-950 rounded font-mono text-[11px] border border-gray-800 text-gray-300 truncate whitespace-pre",children:aU(o)}),t.jsx("div",{className:"flex gap-2",children:[["Prefix","prefix"],["Separator","separator"]].map(([m,h])=>t.jsxs("label",{className:"flex-1",children:[t.jsx("span",{className:"text-xs text-gray-500 dark:text-slate-400 block mb-0.5",children:m}),t.jsx("input",{type:"text",value:o[h],onChange:g=>d({...o,[h]:g.target.value}),className:"w-full text-xs px-2 py-1 rounded border border-gray-200 dark:border-slate-700 bg-white dark:bg-slate-900 text-gray-900 dark:text-white font-mono"})]},h))}),t.jsx("div",{className:"space-y-0.5",children:o.blocks.map((m,h)=>{const g=oU.find(w=>w.id===m.id);return g?t.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded bg-gray-50 dark:bg-slate-900 border border-gray-100 dark:border-slate-800",children:[t.jsxs("div",{className:"flex flex-col -my-0.5 shrink-0",children:[t.jsx("button",{onClick:()=>u(h,-1),disabled:h===0,className:"text-gray-300 dark:text-slate-700 hover:text-gray-600 dark:hover:text-slate-400 disabled:opacity-30 disabled:cursor-not-allowed leading-none",children:t.jsx(pS,{className:"w-3 h-3"})}),t.jsx("button",{onClick:()=>u(h,1),disabled:h===o.blocks.length-1,className:"text-gray-300 dark:text-slate-700 hover:text-gray-600 dark:hover:text-slate-400 disabled:opacity-30 disabled:cursor-not-allowed leading-none",children:t.jsx(hr,{className:"w-3 h-3"})})]}),t.jsx("input",{type:"checkbox",checked:m.enabled,onChange:w=>d({...o,blocks:o.blocks.map(j=>j.id===m.id?{...j,enabled:w.target.checked}:j)}),className:"rounded shrink-0 accent-indigo-500"}),t.jsx("span",{className:`flex-1 text-xs font-medium ${m.enabled?"text-gray-900 dark:text-white":"text-gray-400 dark:text-slate-600"}`,children:g.label}),t.jsx("span",{className:"text-[10px] text-gray-400 dark:text-slate-600 font-mono shrink-0 hidden sm:block",children:g.preview}),m.id==="context-bar"&&m.enabled&&t.jsxs("select",{value:m.style||"dots",onChange:w=>d({...o,blocks:o.blocks.map(j=>j.id==="context-bar"?{...j,style:w.target.value}:j)}),className:"text-xs px-1.5 py-0.5 rounded border border-gray-200 dark:border-slate-700 bg-white dark:bg-slate-900 text-gray-900 dark:text-white shrink-0",children:[t.jsx("option",{value:"dots",children:"●○ dots"}),t.jsx("option",{value:"blocks",children:"█░ blocks"})]})]},m.id):null})})]}):t.jsx(yt,{value:e,onChange:m=>r(m.target.value),className:"font-mono text-xs h-48 resize-y bg-gray-950 dark:bg-black text-green-400 border-gray-800",spellCheck:!1,autoFocus:!0})]})}const lU=["Built-in","Simple","Git","Cost","Custom"];function cU(e){const r={};for(const s of e)r[s.category]||(r[s.category]=[]),r[s.category].push(s);return r}const dU=eg(Zp);function uU(){const[e,r]=_.useState([]),[s,n]=_.useState("disabled"),[o,c]=_.useState(dU),[d,l]=_.useState(null),[u,f]=_.useState(""),[m,h]=_.useState(!0),[g,w]=_.useState(!1);_.useEffect(()=>{j()},[]);const j=async()=>{try{h(!0);const[b,S]=await Promise.all([he.getStatuslinePresets(),he.getCurrentStatusline()]);r(b.presets||[]),n(S.presetId||"disabled"),S.presetId==="custom"&&S.scriptContent&&c(S.scriptContent)}catch(b){q.error("Failed to load statuslines: "+b.message)}finally{h(!1)}},k=async b=>{if(!(b.id==="custom"||b.id===d)){w(!0);try{await he.setStatusline(b.id),n(b.id),q.success(b.id==="disabled"?"Statusline disabled":`Applied "${b.name}"`)}catch(S){q.error("Failed to apply: "+S.message)}finally{w(!1)}}},v=async(b,S)=>{if(S.stopPropagation(),b.id==="custom"){f(o),l("custom");return}try{const N=await he.getPresetScript(b.id);f(N.scriptContent||""),l(b.id)}catch(N){q.error("Failed to load script: "+N.message)}},y=async(b,S=u)=>{w(!0);try{const N=await he.setStatusline(b,S);if(N.success===!1)throw new Error(N.error||"Save failed");n(b),b==="custom"&&c(S),l(null),q.success("Script saved and applied")}catch(N){q.error("Failed to save: "+N.message)}finally{w(!1)}};if(m)return t.jsx("div",{className:"flex items-center justify-center h-64",children:t.jsx(Qe,{className:"w-8 h-8 animate-spin text-indigo-600"})});const x=cU(e);return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 p-6 shadow-sm",children:[t.jsxs("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center gap-2",children:[t.jsx(Ut,{className:"w-5 h-5 text-indigo-500"}),"Statusline"]}),t.jsxs("p",{className:"text-sm text-gray-500 dark:text-slate-400 mt-1",children:["Claude Code runs a shell script after each response and displays the output in the status bar. Scripts receive JSON session data via stdin. Requires"," ",t.jsx("code",{className:"bg-gray-100 dark:bg-slate-800 px-1 rounded text-xs",children:"jq"}),"."]}),t.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400 mt-2",children:"⚡ Changes apply to the next interaction in your Claude Code session (no restart needed)."})]}),lU.filter(b=>x[b]).map(b=>t.jsxs("div",{children:[t.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-slate-500 mb-3 px-1",children:b}),t.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3",children:x[b].map(S=>{const N=s===S.id,P=S.id==="custom",A=S.id==="disabled",E=d===S.id,M=!A;return t.jsxs("div",{onClick:()=>!P&&!E&&k(S),className:["rounded-xl border p-4 transition-all",P||E?"cursor-default":"cursor-pointer hover:border-indigo-400 dark:hover:border-indigo-500",N?"border-indigo-500 bg-indigo-50 dark:bg-indigo-950/40 shadow-sm":"border-gray-200 dark:border-slate-800 bg-white dark:bg-slate-950"].join(" "),children:[t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:S.name}),N&&!E&&t.jsx(It,{className:"w-4 h-4 text-indigo-500 shrink-0"})]}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400 mt-0.5",children:S.description})]}),M&&t.jsx("button",{onClick:I=>E?(I.stopPropagation(),l(null)):v(S,I),className:"p-1 rounded hover:bg-gray-100 dark:hover:bg-slate-800 text-gray-400 hover:text-gray-600 dark:hover:text-slate-300 shrink-0",title:E?"Close editor":"Edit script",children:E?t.jsx(Nn,{className:"w-3.5 h-3.5"}):t.jsx(al,{className:"w-3.5 h-3.5"})})]}),!E&&!P&&!A&&S.preview&&t.jsx("div",{className:"mt-3 px-2 py-1.5 bg-gray-950 dark:bg-black rounded font-mono text-[11px] border border-gray-800 whitespace-pre text-gray-300 truncate",children:S.preview}),!E&&A&&t.jsx("div",{className:"mt-3 px-2 py-1.5 bg-gray-950 dark:bg-black rounded font-mono text-[11px] border border-gray-800 text-gray-600 italic",children:"(no status bar)"}),E&&t.jsxs("div",{className:"mt-3 space-y-2",onClick:I=>I.stopPropagation(),children:[t.jsx(R_,{value:u,onChange:f}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs(ne,{size:"sm",className:"flex-1",onClick:()=>y(S.id),disabled:g||!u.trim(),children:[g?t.jsx(Qe,{className:"w-3 h-3 animate-spin mr-1"}):null,"Save & Apply"]}),t.jsx(ne,{size:"sm",variant:"outline",onClick:()=>l(null),children:"Cancel"})]})]}),P&&!E&&t.jsxs("div",{className:"mt-3 space-y-2",onClick:I=>I.stopPropagation(),children:[t.jsx(R_,{value:o,onChange:c}),t.jsxs(ne,{size:"sm",className:"w-full",onClick:()=>y("custom",o),disabled:g||!o.trim(),children:[g&&s==="custom"?t.jsx(Qe,{className:"w-3 h-3 animate-spin mr-1"}):null,"Apply Custom Script"]})]})]},S.id)})})]},b)),t.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-4 border border-transparent dark:border-slate-800 space-y-2",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"How it works"}),t.jsxs("p",{className:"text-xs text-gray-600 dark:text-slate-400",children:["Scripts are saved to ",t.jsx("code",{className:"bg-gray-100 dark:bg-slate-800 px-1 rounded",children:"~/.claude/statuslines/"})," and referenced in ",t.jsx("code",{className:"bg-gray-100 dark:bg-slate-800 px-1 rounded",children:"~/.claude/settings.json"})," as"," ",t.jsx("code",{className:"bg-gray-100 dark:bg-slate-800 px-1 rounded",children:"statusLine.command"}),". Claude Code pipes JSON session data to the script on each turn."]}),t.jsxs("p",{className:"text-xs text-gray-500 dark:text-slate-500",children:["Test a script:"," ",t.jsx("code",{className:"bg-gray-100 dark:bg-slate-800 px-1 rounded font-mono",children:`echo '{"model":{"display_name":"opus-4-6"},"context_window":{"used_percentage":37,"remaining_percentage":63}}' | ~/.claude/statuslines/full.sh`})]})]})]})}const hU=[{key:"default",label:"Default",description:"General purpose tasks"},{key:"background",label:"Background",description:"Background processing"},{key:"think",label:"Think",description:"Deep reasoning tasks"},{key:"longContext",label:"Long Context",description:"Large context windows"},{key:"webSearch",label:"Web Search",description:"Web search tasks"},{key:"image",label:"Image",description:"Image processing tasks"}];function fU(){const[e,r]=_.useState(null),[s,n]=_.useState({}),[o,c]=_.useState([]),[d,l]=_.useState(!0),[u,f]=_.useState(!1),[m,h]=_.useState(!1),[g,w]=_.useState({name:"",api_base_url:"",api_key:"",models:""}),[j,k]=_.useState(!1),[v,y]=_.useState(!1),[x,b]=_.useState(""),[S,N]=_.useState(!0),[P,A]=_.useState(!1),[E,M]=_.useState(""),I=_.useCallback(async()=>{var T,F;try{const[$,D,X]=await Promise.all([he.getRouterStatus(),he.getRouterConfig(),he.getRouterPresets()]);r($),n(D),c(X.presets||[]),(F=(T=D==null?void 0:D.Rules)==null?void 0:T.longContext)!=null&&F.threshold&&M(String(D.Rules.longContext.threshold))}catch{r({installed:!1,running:!1,configExists:!1})}finally{l(!1)}},[]);_.useEffect(()=>{I()},[I]);const B=[];if(s!=null&&s.Providers)for(const T of s.Providers)for(const F of T.models||[])B.push(`${T.name},${F}`);const U=async()=>{f(!0);try{e!=null&&e.running?(await he.stopRouter(),q.success("Router proxy stopped")):(await he.startRouter(),q.success("Router proxy started")),await I()}catch(T){q.error("Failed to toggle proxy: "+T.message)}finally{f(!1)}},V=()=>{navigator.clipboard.writeText('eval "$(coder-config router activate)"'),q.success("Activation command copied to clipboard")},Q=async(T,F)=>{try{await he.setRouterRule(T,F),q.success(`Rule updated for ${T}`),await I()}catch($){q.error("Failed to set rule: "+$.message)}},z=async()=>{if(!g.name||!g.api_base_url){q.error("Name and API base URL are required");return}k(!0);try{const T=g.models.split(",").map(F=>F.trim()).filter(Boolean);await he.addRouterProvider(g.name,{api_base_url:g.api_base_url,api_key:g.api_key,models:T}),q.success(`Provider "${g.name}" added`),h(!1),w({name:"",api_base_url:"",api_key:"",models:""}),await I()}catch(T){q.error("Failed to add provider: "+T.message)}finally{k(!1)}},H=async T=>{try{await he.removeRouterProvider(T),q.success(`Provider "${T}" removed`),await I()}catch(F){q.error("Failed to remove provider: "+F.message)}},Y=async()=>{if(!x.trim()){q.error("Preset name is required");return}try{await he.saveRouterPreset(x.trim()),q.success(`Preset "${x}" saved`),y(!1),b(""),await I()}catch(T){q.error("Failed to save preset: "+T.message)}},K=async T=>{try{await he.loadRouterPreset(T),q.success(`Preset "${T}" loaded`),await I()}catch(F){q.error("Failed to load preset: "+F.message)}},O=T=>{const $=((s==null?void 0:s.Rules)||{})[T];return $?typeof $=="string"?$:$.provider&&$.model?`${$.provider},${$.model}`:null:null};return d?t.jsx("div",{className:"flex items-center justify-center py-20",children:t.jsx(Qe,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):t.jsxs("div",{className:"space-y-6 max-w-5xl",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsxs("h2",{className:"text-2xl font-bold text-foreground flex items-center gap-2",children:[t.jsx(th,{className:"w-6 h-6"}),"Code Router"]}),t.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Route AI requests to different providers based on task type"})]}),t.jsxs(ne,{variant:"outline",size:"sm",onClick:I,children:[t.jsx(Yi,{className:"w-4 h-4 mr-1"}),"Refresh"]})]}),t.jsx("div",{className:"rounded-lg border border-border bg-card p-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-medium text-foreground",children:"Installation:"}),e!=null&&e.installed?t.jsxs(qe,{variant:"outline",className:"bg-green-50 text-green-700 border-green-200 dark:bg-green-900/30 dark:text-green-400 dark:border-green-800",children:[t.jsx(vi,{className:"w-3 h-3 mr-1"}),"Installed"]}):t.jsxs(qe,{variant:"outline",className:"bg-red-50 text-red-700 border-red-200 dark:bg-red-900/30 dark:text-red-400 dark:border-red-800",children:[t.jsx(Ki,{className:"w-3 h-3 mr-1"}),"Not Found"]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-medium text-foreground",children:"Proxy:"}),e!=null&&e.running?t.jsxs(qe,{variant:"outline",className:"bg-green-50 text-green-700 border-green-200 dark:bg-green-900/30 dark:text-green-400 dark:border-green-800",children:[t.jsx(vi,{className:"w-3 h-3 mr-1"}),"Running"]}):t.jsxs(qe,{variant:"outline",className:"bg-red-50 text-red-700 border-red-200 dark:bg-red-900/30 dark:text-red-400 dark:border-red-800",children:[t.jsx(Ki,{className:"w-3 h-3 mr-1"}),"Stopped"]})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(ne,{variant:"outline",size:"sm",onClick:V,children:[t.jsx(Bo,{className:"w-4 h-4 mr-1"}),"Copy Activation"]}),t.jsxs(ne,{size:"sm",disabled:!(e!=null&&e.installed)||u,onClick:U,variant:e!=null&&e.running?"destructive":"default",children:[u?t.jsx(Qe,{className:"w-4 h-4 mr-1 animate-spin"}):e!=null&&e.running?t.jsx(kI,{className:"w-4 h-4 mr-1"}):t.jsx(zg,{className:"w-4 h-4 mr-1"}),e!=null&&e.running?"Stop":"Start"]})]})]})}),t.jsxs("div",{className:"rounded-lg border border-border bg-card p-4",children:[t.jsxs("h3",{className:"text-lg font-semibold text-foreground mb-4 flex items-center gap-2",children:[t.jsx(Xs,{className:"w-5 h-5"}),"Routing Rules"]}),t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:hU.map(({key:T,label:F,description:$})=>{const D=O(T);return t.jsxs("div",{className:"rounded-md border border-border bg-background p-3 space-y-2",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-foreground",children:F}),t.jsx("div",{className:"text-xs text-muted-foreground",children:$})]}),t.jsxs(ir,{value:D||"__none__",onValueChange:X=>Q(T,X==="__none__"?"":X),children:[t.jsx(Qt,{className:"h-8 text-xs",children:t.jsx(or,{placeholder:"Not set"})}),t.jsxs(Zt,{children:[t.jsx(gt,{value:"__none__",children:"Not set"}),B.map(X=>t.jsx(gt,{value:X,children:X},X))]})]}),T==="longContext"&&t.jsx(Oe,{type:"number",placeholder:"Token threshold",className:"h-8 text-xs",value:E,onChange:X=>{M(X.target.value)},onBlur:async()=>{if(E)try{const X={...s};X.Rules||(X.Rules={}),X.Rules.longContext||(X.Rules.longContext={}),X.Rules.longContext.threshold=parseInt(E,10),await he.saveRouterConfig(X),q.success("Long context threshold updated"),await I()}catch(X){q.error("Failed to update threshold: "+X.message)}}})]},T)})})]}),t.jsx(qo,{open:S,onOpenChange:N,children:t.jsxs("div",{className:"rounded-lg border border-border bg-card",children:[t.jsx(Ko,{className:"w-full p-4 flex items-center justify-between hover:bg-accent/50 transition-colors rounded-t-lg",children:t.jsxs("h3",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[S?t.jsx(hr,{className:"w-5 h-5"}):t.jsx(Qr,{className:"w-5 h-5"}),"Providers",t.jsx(qe,{variant:"secondary",className:"ml-2",children:((s==null?void 0:s.Providers)||[]).length})]})}),t.jsx(Yo,{children:t.jsxs("div",{className:"px-4 pb-4 space-y-3",children:[((s==null?void 0:s.Providers)||[]).length===0?t.jsx("p",{className:"text-sm text-muted-foreground py-2",children:"No providers configured"}):((s==null?void 0:s.Providers)||[]).map(T=>t.jsxs("div",{className:"rounded-md border border-border bg-background p-3 flex items-start justify-between",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"text-sm font-medium text-foreground",children:T.name}),t.jsx("div",{className:"text-xs text-muted-foreground font-mono",children:T.api_base_url}),t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.jsxs(qe,{variant:"secondary",className:"text-xs",children:[(T.models||[]).length," model",(T.models||[]).length!==1?"s":""]}),T.transformers&&T.transformers.length>0&&t.jsxs(qe,{variant:"outline",className:"text-xs",children:[T.transformers.length," transformer",T.transformers.length!==1?"s":""]})]}),(T.models||[]).length>0&&t.jsx("div",{className:"text-xs text-muted-foreground mt-1",children:T.models.join(", ")})]}),t.jsx(ne,{variant:"ghost",size:"sm",className:"text-red-500 hover:text-red-700 hover:bg-red-50 dark:hover:bg-red-900/20",onClick:()=>H(T.name),children:t.jsx(fs,{className:"w-4 h-4"})})]},T.name)),t.jsxs(ne,{variant:"outline",size:"sm",onClick:()=>h(!0),className:"w-full",children:[t.jsx(Rt,{className:"w-4 h-4 mr-1"}),"Add Provider"]})]})})]})}),t.jsx(qo,{open:P,onOpenChange:A,children:t.jsxs("div",{className:"rounded-lg border border-border bg-card",children:[t.jsx(Ko,{className:"w-full p-4 flex items-center justify-between hover:bg-accent/50 transition-colors rounded-t-lg",children:t.jsxs("h3",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[P?t.jsx(hr,{className:"w-5 h-5"}):t.jsx(Qr,{className:"w-5 h-5"}),"Presets",t.jsx(qe,{variant:"secondary",className:"ml-2",children:o.length})]})}),t.jsx(Yo,{children:t.jsxs("div",{className:"px-4 pb-4 space-y-3",children:[o.length===0?t.jsx("p",{className:"text-sm text-muted-foreground py-2",children:"No saved presets"}):o.map(T=>t.jsxs("div",{className:"rounded-md border border-border bg-background p-3 flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-foreground",children:T.name}),T.date&&t.jsx("div",{className:"text-xs text-muted-foreground",children:new Date(T.date).toLocaleDateString()})]}),t.jsxs(ne,{variant:"outline",size:"sm",onClick:()=>K(T.name),children:[t.jsx(Ru,{className:"w-4 h-4 mr-1"}),"Load"]})]},T.name)),t.jsxs(ne,{variant:"outline",size:"sm",onClick:()=>y(!0),className:"w-full",children:[t.jsx(Zr,{className:"w-4 h-4 mr-1"}),"Save Current"]})]})})]})}),t.jsx(vt,{open:m,onOpenChange:h,children:t.jsxs(ft,{children:[t.jsxs(mt,{children:[t.jsx(pt,{children:"Add Provider"}),t.jsx(Gt,{children:"Configure a new AI provider for the router."})]}),t.jsxs("div",{className:"space-y-4 py-2",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Name"}),t.jsx(Oe,{placeholder:"e.g. openai",value:g.name,onChange:T=>w(F=>({...F,name:T.target.value}))})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"API Base URL"}),t.jsx(Oe,{placeholder:"https://api.openai.com/v1",value:g.api_base_url,onChange:T=>w(F=>({...F,api_base_url:T.target.value}))})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"API Key"}),t.jsx(Oe,{type:"password",placeholder:"sk-...",value:g.api_key,onChange:T=>w(F=>({...F,api_key:T.target.value}))})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Models (comma-separated)"}),t.jsx(Oe,{placeholder:"gpt-4o, gpt-4o-mini",value:g.models,onChange:T=>w(F=>({...F,models:T.target.value}))})]})]}),t.jsxs(St,{children:[t.jsx(ne,{variant:"outline",onClick:()=>h(!1),children:"Cancel"}),t.jsxs(ne,{onClick:z,disabled:j,children:[j&&t.jsx(Qe,{className:"w-4 h-4 mr-1 animate-spin"}),"Add Provider"]})]})]})}),t.jsx(vt,{open:v,onOpenChange:y,children:t.jsxs(ft,{children:[t.jsxs(mt,{children:[t.jsx(pt,{children:"Save Preset"}),t.jsx(Gt,{children:"Save the current router configuration as a named preset."})]}),t.jsx("div",{className:"space-y-4 py-2",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Preset Name"}),t.jsx(Oe,{placeholder:"e.g. cost-optimized",value:x,onChange:T=>b(T.target.value),onKeyDown:T=>T.key==="Enter"&&Y()})]})}),t.jsxs(St,{children:[t.jsx(ne,{variant:"outline",onClick:()=>y(!1),children:"Cancel"}),t.jsxs(ne,{onClick:Y,children:[t.jsx(Zr,{className:"w-4 h-4 mr-1"}),"Save"]})]})]})})]})}const mU=[{id:"projects",label:"All Projects",icon:Hn,section:"Projects"},{id:"explorer",label:"Project Explorer",icon:Zi,section:"Projects"},{id:"workstreams",label:"Workstreams",icon:bS,section:"Projects"},{id:"registry",label:"MCP Registry",icon:Yn,section:"Tools"},{id:"plugins",label:"Plugins",icon:$o,section:"Tools"},{id:"memory",label:"Memory",icon:Fo,section:"Tools"},{id:"claude-settings",label:"Claude Code",icon:Qn,section:"Configuration",tool:"claude"},{id:"gemini-settings",label:"Gemini CLI",icon:Ut,section:"Configuration",tool:"gemini"},{id:"codex-settings",label:"Codex CLI",icon:Ut,section:"Configuration",isNew:!0,tool:"codex"},{id:"antigravity-settings",label:"Antigravity",icon:Mc,section:"Configuration",tool:"antigravity"},{id:"create-mcp",label:"Create MCP",icon:Wr,section:"Developer"},{id:"loops",label:"Ralph Loops",icon:vc,section:"Developer",isNew:!0},{id:"router",label:"Code Router",icon:th,section:"Developer"},{id:"statuslines",label:"Statusline",icon:V5,section:"System",isNew:!0},{id:"sessions",label:"Sessions",icon:Zr,section:"System"},{id:"preferences",label:"Preferences",icon:wS,section:"System"},{id:"tutorial",label:"Tutorial",icon:Au,section:"Help"},{id:"docs",label:"Docs & Help",icon:Oo,section:"Help"}],M_=(e,r)=>{try{const s=localStorage.getItem(`claude-config-${e}`);return s?JSON.parse(s):r}catch{return r}},pU=(e,r)=>{try{localStorage.setItem(`claude-config-${e}`,JSON.stringify(r))}catch{}};function gU(){const{projects:e,activeProject:r,fetch:s,setActive:n}=Fx(),{appConfig:o,version:c,fetch:d,checkVersion:l}=Bw(),[u,f]=_.useState(()=>M_("currentView","explorer")),[m,h]=_.useState(!0),[g,w]=_.useState({dir:"",subprojects:[],hierarchy:[]}),[j,k]=_.useState([]),[v,y]=_.useState({mcpServers:{}}),[x,b]=_.useState([]),[S,N]=_.useState([]),[P,A]=_.useState(null),[E,M]=_.useState(null),[I,B]=_.useState(!1),[U,V]=_.useState({title:"",type:""}),[Q,z]=_.useState(""),[H,Y]=_.useState(""),K=_.useRef({}),[O,T]=_.useState(null),[F,$]=_.useState(!1),[D,X]=_.useState(!1),[te,fe]=_.useState(null),[J,W]=_.useState(!1),le=_.useRef(null);_.useEffect(()=>{pU("currentView",u)},[u]);const ae=_.useCallback(async()=>{try{const[me,be,Z,oe,we]=await Promise.all([he.getProject(),he.getConfigs(),he.getRegistry(),he.getRules(),he.getCommands()]);w(me),k(be),y(Z),b(oe),N(we),be.length>0&&!P&&A(be[be.length-1])}catch(me){q.error("Failed to load data: "+me.message)}finally{h(!1)}},[P]),re=_.useCallback(async(me=!1)=>{try{const be=await s(),Z=be==null?void 0:be.find(oe=>oe.isActive);if(me&&Z){const oe=await he.getSubprojects(Z.path);fe({dir:Z.path,subprojects:oe.subprojects||[]})}me&&!Z&&(M_("currentView",null)||f("projects"))}catch{console.log("Projects API not available")}},[s]),de=async me=>{try{const be=await n(me);be.success?(w({dir:be.dir,hierarchy:be.hierarchy,subprojects:be.subprojects}),fe({dir:be.dir,subprojects:be.subprojects}),await ae(),q.success(`Switched to ${be.project.name}`)):q.error(be.error||"Failed to switch project")}catch(be){q.error("Failed to switch project: "+be.message)}},Se=()=>{s()};_.useEffect(()=>{ae(),re(!0),(async()=>{try{const[be]=await Promise.all([l(),d()]);!le.current&&(be!=null&&be.installedVersion)&&(le.current=be.installedVersion);const Z=Bw.getState().appConfig;if(be!=null&&be.updateAvailable&&(be==null?void 0:be.updateMethod)==="npm")if(Z!=null&&Z.autoUpdate){q.info(`Auto-updating to v${be.latestVersion}...`),$(!0);const oe=await he.performUpdate({updateMethod:be.updateMethod,targetVersion:be.latestVersion,channel:be.channel});if(oe.success){q.success(`Updated to v${oe.newVersion}! Restarting server...`);try{await he.restartServer()}catch{}let we=0;const Ce=setInterval(async()=>{we++;try{await he.checkVersion(),clearInterval(Ce),q.success("Server restarted! Reloading..."),setTimeout(()=>window.location.reload(),500)}catch{we>30&&(clearInterval(Ce),q.info("Server restarting. Please refresh the page."),$(!1))}},500)}else q.error("Auto-update failed: "+oe.error),$(!1),T(be)}else T(be)}catch{}})()},[]),_.useEffect(()=>{const be=setInterval(async()=>{if(le.current)try{const Z=await he.checkVersion();Z!=null&&Z.installedVersion&&Z.installedVersion!==le.current&&(console.log(`[stale-ui] Server updated to v${Z.installedVersion}, refreshing...`),window.location.reload())}catch{}},3e4);return()=>clearInterval(be)},[]);const Re=(me,be)=>{if(!me||!be)return!1;const Z=Ce=>Ce.split(".").map(Fe=>parseInt(Fe,10)||0),oe=Z(me),we=Z(be);for(let Ce=0;Ce<Math.max(oe.length,we.length);Ce++){if((oe[Ce]||0)>(we[Ce]||0))return!0;if((oe[Ce]||0)<(we[Ce]||0))return!1}return!1},Ue=async(me,be="npm",Z)=>{$(!0);const oe=await he.performUpdate({updateMethod:be,targetVersion:me,channel:Z});if(oe.success){q.success(`Updated to v${oe.newVersion}! Restarting server...`),T(null);try{await he.restartServer()}catch{}let we=0;const Ce=setInterval(async()=>{we++;try{await he.checkVersion(),clearInterval(Ce),q.success("Server restarted! Reloading..."),setTimeout(()=>window.location.reload(),500)}catch{we>30&&(clearInterval(Ce),q.info("Server restarting. Please refresh the page."),$(!1))}},500);return!0}else return q.error("Update failed: "+oe.error),$(!1),!1},pe=async()=>{W(!0);try{const me=await he.checkVersion(),be=me==null?void 0:me.installedVersion,Z=me==null?void 0:me.latestVersion;if(be&&le.current&&be!==le.current){q.info(`Refreshing to v${be}...`),setTimeout(()=>window.location.reload(),500);return}Re(Z,be)&&(o!=null&&o.autoUpdate?(W(!1),q.info(`Auto-updating to v${Z}...`),await Ue(Z,(me==null?void 0:me.updateMethod)||"npm",me==null?void 0:me.channel)):(T({...me,updateAvailable:!0}),q.info(`Update available: v${Z}`)))}catch{q.error("Failed to check for updates")}finally{W(!1)}},_e=async()=>{if(O!=null&&O.updateAvailable){$(!0);try{const me=await he.performUpdate({updateMethod:O.updateMethod,sourcePath:O.sourcePath,targetVersion:O.latestVersion,channel:O.channel});if(me.success){q.success(`Updated to v${me.newVersion}! Restarting server...`),T(null),setVersion(me.newVersion);try{await he.restartServer()}catch{}let be=0;const Z=setInterval(async()=>{be++;try{await he.checkVersion(),clearInterval(Z),q.success("Server restarted! Reloading..."),setTimeout(()=>window.location.reload(),500)}catch{be>30&&(clearInterval(Z),q.info("Server restarting. Please refresh the page."),$(!1))}},500)}else q.error("Update failed: "+me.error),$(!1)}catch(me){q.error("Update failed: "+me.message),$(!1)}}};_.useEffect(()=>{const me=async()=>{try{const{hashes:Z}=await he.getFileHashes(),oe=K.current,we=Object.keys(Z).some(Fe=>oe[Fe]!==Z[Fe])||Object.keys(oe).some(Fe=>!Z[Fe]),Ce=oe.__subprojects__!==Z.__subprojects__;if(we&&Object.keys(oe).length>0&&(await ae(),Ce&&te))try{const Fe=await he.getSubprojects(te.dir);fe(He=>({...He,subprojects:Fe.subprojects||[]}))}catch{}K.current=Z}catch{}},be=setInterval(me,2e3);return me(),()=>clearInterval(be)},[ae,te]);const $e=new Set;j.forEach(me=>{var be,Z;(((be=me.config)==null?void 0:be.include)||[]).forEach(oe=>$e.add(oe)),Object.keys(((Z=me.config)==null?void 0:Z.mcpServers)||{}).forEach(oe=>$e.add(oe))});const Ge={mcps:$e.size,rules:x.length,commands:S.length},et=async()=>{try{const me=await he.applyConfig(g.dir);if(me.tools){const be=Object.entries(me.tools).filter(([,Z])=>Z).map(([Z])=>Z==="claude"?"Claude Code":"Antigravity");be.length>0?q.success(`Config applied to: ${be.join(", ")}`):q.warning("No tools were updated")}else q.success("Configuration applied successfully!")}catch(me){q.error("Failed to apply config: "+me.message)}},Nt=async()=>{h(!0),await ae(),q.success("Data refreshed")};if(m)return t.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:t.jsxs("div",{className:"flex flex-col items-center gap-4",children:[t.jsx(Qe,{className:"w-8 h-8 animate-spin text-primary"}),t.jsx("p",{className:"text-muted-foreground",children:"Loading configuration..."})]})});const ke=()=>{switch(u){case"explorer":return t.jsx(F8,{project:g,onRefresh:ae});case"registry":return t.jsx(sW,{registry:v,searchQuery:Q,setSearchQuery:z,onUpdate:ae});case"plugins":return t.jsx(TW,{});case"memory":return t.jsx(nW,{project:g,onUpdate:ae});case"create-mcp":return t.jsx(Iz,{project:g});case"claude-settings":return t.jsx(yz,{});case"gemini-settings":return t.jsx(bz,{});case"codex-settings":return t.jsx(Rz,{});case"antigravity-settings":return t.jsx(Cz,{});case"statuslines":return t.jsx(uU,{});case"sessions":return t.jsx(iU,{});case"preferences":return t.jsx(vz,{onConfigChange:()=>d()});case"projects":return t.jsx(cW,{onProjectSwitch:me=>{w({dir:me.dir,hierarchy:me.hierarchy,subprojects:me.subprojects}),fe({dir:me.dir,subprojects:me.subprojects}),ae(),re()}});case"workstreams":return t.jsx(IW,{onWorkstreamChange:me=>{q.success(`Switched to workstream: ${me.name}`)}});case"loops":return t.jsx(DW,{activeProject:r});case"router":return t.jsx(fU,{});case"docs":return t.jsx(PW,{});case"tutorial":return t.jsx(nU,{});default:return null}};return t.jsxs("div",{className:"min-h-screen bg-background",children:[t.jsx("header",{className:"h-16 bg-card border-b border-border sticky top-0 z-50 shadow-sm",children:t.jsxs("div",{className:"h-full px-6 flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-indigo-500 to-purple-600 flex items-center justify-center shadow-lg shadow-indigo-500/20",children:t.jsxs("svg",{width:"22",height:"22",viewBox:"0 0 128 128",children:[t.jsx("circle",{cx:"64",cy:"64",r:"52",fill:"none",stroke:"white",strokeWidth:"10",strokeDasharray:"24 12"}),t.jsx("circle",{cx:"64",cy:"64",r:"28",fill:"white"}),t.jsx("circle",{cx:"64",cy:"64",r:"12",fill:"#7c3aed"})]})}),t.jsx("div",{children:t.jsxs("h1",{className:"text-xl font-bold text-foreground",children:["Coder ",t.jsx("span",{className:"text-primary",children:"Config"})]})}),O&&t.jsxs("button",{onClick:_e,disabled:F,className:"ml-3 px-2.5 py-1 text-xs font-medium bg-green-100 text-green-700 hover:bg-green-200 rounded-full flex items-center gap-1.5 transition-colors disabled:opacity-50",children:[F?t.jsx(Qe,{className:"w-3 h-3 animate-spin"}):t.jsx(yi,{className:"w-3 h-3"}),F?"Updating...":`Update to v${O.latestVersion}`]})]}),t.jsx(RN,{orientation:"vertical",className:"h-6"}),t.jsx(B8,{projects:e,activeProject:r,onSwitch:de,onAddClick:()=>X(!0),onManageClick:()=>f("projects")})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(W8,{}),t.jsx(ne,{variant:"ghost",size:"sm",onClick:Nt,children:t.jsx(Dr,{className:"w-4 h-4"})}),t.jsxs(ne,{onClick:et,variant:"ghost",size:"sm",className:"gap-2 text-muted-foreground hover:text-foreground",title:"Config auto-applies on save. Click to manually re-apply.",children:[t.jsx(Mc,{className:"w-4 h-4"}),"Re-apply"]})]})]})}),t.jsxs("div",{className:"flex",children:[t.jsxs("aside",{className:"w-64 h-[calc(100vh-64px)] border-r border-border bg-card sticky top-16 flex flex-col",children:[t.jsx(Js,{className:"flex-1 py-4",children:["Projects","Tools","Configuration","Developer","System","Help"].map(me=>t.jsxs("div",{className:"mb-6",children:[t.jsx("h3",{className:"px-4 mb-2 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:me}),t.jsx("div",{className:"space-y-0.5",children:mU.filter(be=>be.section===me).filter(be=>{var Z;return be.id!=="loops"||((Z=o==null?void 0:o.experimental)==null?void 0:Z.ralphLoops)}).filter(be=>!be.tool||((o==null?void 0:o.enabledTools)||["claude"]).includes(be.tool)).map(be=>{const Z=be.icon,oe=u===be.id;return t.jsxs("button",{onClick:()=>f(be.id),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-all duration-200 border-l-2 ${oe?"bg-accent border-primary text-primary font-medium":"border-transparent text-muted-foreground hover:text-foreground hover:bg-accent"}`,children:[t.jsx(Z,{className:"w-4 h-4"}),t.jsx("span",{className:"flex-1 text-left",children:be.label}),be.badge&&t.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full font-medium ${oe?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"}`,children:Ge[be.badge]}),be.isNew&&t.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded font-medium bg-green-500/20 text-green-600 dark:text-green-400",children:"new"})]},be.id)})})]},me))}),t.jsx("div",{className:"px-4 py-3 border-t border-border",children:t.jsxs("button",{onClick:pe,disabled:J,className:"text-xs text-muted-foreground hover:text-foreground transition-colors flex items-center gap-1",title:"Check for updates",children:[J?t.jsx(Qe,{className:"w-3 h-3 animate-spin"}):null,c?`v${c}`:""]})})]}),t.jsx("main",{style:["explorer","docs","tutorial"].includes(u)?{}:{zoom:.9},className:Ee("flex-1 overflow-auto",["explorer","docs","tutorial"].includes(u)?"h-[calc(100vh-64px)]":"p-6"),children:t.jsx(F_,{mode:"wait",children:t.jsx(Ua.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:["explorer","docs","tutorial"].includes(u)?"h-full":"",children:ke()},u)})})]}),t.jsx(EN,{open:D,onOpenChange:X,onAdded:Se}),t.jsx($8,{onStartTutorial:()=>f("tutorial")})]})}function xU(){const[e,r]=_.useState(!1),[s,n]=_.useState(!1),[o,c]=_.useState(!1),d=_.useCallback(async()=>{n(!0);try{await he.restartServer(),q.info("Server restarting... page will reload."),setTimeout(()=>{window.location.reload()},2e3)}catch(u){q.error("Failed to restart: "+u.message),n(!1)}},[]),l=_.useCallback(()=>{c(!0),r(!1),q.dismiss("update-available")},[]);return _.useEffect(()=>{let u;const f=async()=>{try{const m=await he.getVersion();console.log("[Update Check]",m),m.needsRestart&&!o&&r(!0)}catch{}};return f(),u=setInterval(f,3e4),()=>clearInterval(u)},[o]),t.jsx(H8,{children:t.jsxs("div",{className:"min-h-screen bg-background",children:[e&&!s&&t.jsxs("div",{className:"fixed top-0 left-0 right-0 z-50 bg-blue-600 text-white px-4 py-2 flex items-center justify-center gap-2 shadow-lg cursor-pointer hover:bg-blue-700 transition-colors",onClick:d,children:[t.jsx(Dr,{className:"w-4 h-4"}),t.jsx("span",{className:"text-sm font-medium",children:"Update available — click to restart"}),t.jsx("button",{onClick:u=>{u.stopPropagation(),l()},className:"absolute right-3 p-1 hover:bg-blue-500 rounded",children:t.jsx(Nn,{className:"w-4 h-4"})})]}),s&&t.jsxs("div",{className:"fixed top-0 left-0 right-0 z-50 bg-amber-600 text-white px-4 py-2 flex items-center justify-center gap-2",children:[t.jsx(Dr,{className:"w-4 h-4 animate-spin"}),t.jsx("span",{className:"text-sm font-medium",children:"Restarting server..."})]}),t.jsx(gU,{}),t.jsx(XP,{position:"bottom-right",richColors:!0})]})})}kP.createRoot(document.getElementById("root")).render(t.jsx(xU,{}));
3765
+ `}function fu(e){const r=e==null?void 0:e.match(/^# CONFIG: (.+)$/m);if(!r)return null;try{return JSON.parse(r[1])}catch{return null}}function R_({value:e,onChange:r}){const[s,n]=_.useState("visual"),[o,c]=_.useState(()=>fu(e)||Zp);_.useEffect(()=>{const m=fu(e);m&&c(m)},[e]);const d=m=>{c(m),r(eg(m))},l=m=>{if(m==="raw")r(eg(o));else{const h=fu(e);h&&c(h)}n(m)},u=(m,h)=>{const g=[...o.blocks],w=m+h;w<0||w>=g.length||([g[m],g[w]]=[g[w],g[m]],d({...o,blocks:g}))},f=!!fu(e);return t.jsxs("div",{className:"space-y-2",children:[t.jsx("div",{className:"flex gap-1 bg-gray-100 dark:bg-slate-800 rounded-lg p-1 w-fit",children:[["visual","Visual"],["raw","Raw Bash"]].map(([m,h])=>t.jsx("button",{onClick:()=>l(m),className:`px-3 py-1 rounded text-xs font-medium transition-colors ${s===m?"bg-white dark:bg-slate-700 text-gray-900 dark:text-white shadow-sm":"text-gray-500 dark:text-slate-400 hover:text-gray-700 dark:hover:text-slate-300"}`,children:h},m))}),s==="visual"?t.jsxs("div",{className:"space-y-2",children:[!f&&(e==null?void 0:e.trim())&&t.jsxs("p",{className:"text-xs text-amber-500 dark:text-amber-400",children:["This script wasn't generated by the visual editor — showing template."," ",t.jsx("button",{onClick:()=>d(Zp),className:"underline hover:no-underline",children:"Reset to default"})]}),t.jsx("div",{className:"px-2 py-1.5 bg-gray-950 rounded font-mono text-[11px] border border-gray-800 text-gray-300 truncate whitespace-pre",children:lU(o)}),t.jsx("div",{className:"flex gap-2",children:[["Prefix","prefix"],["Separator","separator"]].map(([m,h])=>t.jsxs("label",{className:"flex-1",children:[t.jsx("span",{className:"text-xs text-gray-500 dark:text-slate-400 block mb-0.5",children:m}),t.jsx("input",{type:"text",value:o[h],onChange:g=>d({...o,[h]:g.target.value}),className:"w-full text-xs px-2 py-1 rounded border border-gray-200 dark:border-slate-700 bg-white dark:bg-slate-900 text-gray-900 dark:text-white font-mono"})]},h))}),t.jsx("div",{className:"space-y-0.5",children:o.blocks.map((m,h)=>{const g=aU.find(w=>w.id===m.id);return g?t.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded bg-gray-50 dark:bg-slate-900 border border-gray-100 dark:border-slate-800",children:[t.jsxs("div",{className:"flex flex-col -my-0.5 shrink-0",children:[t.jsx("button",{onClick:()=>u(h,-1),disabled:h===0,className:"text-gray-300 dark:text-slate-700 hover:text-gray-600 dark:hover:text-slate-400 disabled:opacity-30 disabled:cursor-not-allowed leading-none",children:t.jsx(pS,{className:"w-3 h-3"})}),t.jsx("button",{onClick:()=>u(h,1),disabled:h===o.blocks.length-1,className:"text-gray-300 dark:text-slate-700 hover:text-gray-600 dark:hover:text-slate-400 disabled:opacity-30 disabled:cursor-not-allowed leading-none",children:t.jsx(hr,{className:"w-3 h-3"})})]}),t.jsx("input",{type:"checkbox",checked:m.enabled,onChange:w=>d({...o,blocks:o.blocks.map(j=>j.id===m.id?{...j,enabled:w.target.checked}:j)}),className:"rounded shrink-0 accent-indigo-500"}),t.jsx("span",{className:`flex-1 text-xs font-medium ${m.enabled?"text-gray-900 dark:text-white":"text-gray-400 dark:text-slate-600"}`,children:g.label}),t.jsx("span",{className:"text-[10px] text-gray-400 dark:text-slate-600 font-mono shrink-0 hidden sm:block",children:g.preview}),m.id==="context-bar"&&m.enabled&&t.jsxs("select",{value:m.style||"dots",onChange:w=>d({...o,blocks:o.blocks.map(j=>j.id==="context-bar"?{...j,style:w.target.value}:j)}),className:"text-xs px-1.5 py-0.5 rounded border border-gray-200 dark:border-slate-700 bg-white dark:bg-slate-900 text-gray-900 dark:text-white shrink-0",children:[t.jsx("option",{value:"dots",children:"●○ dots"}),t.jsx("option",{value:"blocks",children:"█░ blocks"})]})]},m.id):null})})]}):t.jsx(yt,{value:e,onChange:m=>r(m.target.value),className:"font-mono text-xs h-48 resize-y bg-gray-950 dark:bg-black text-green-400 border-gray-800",spellCheck:!1,autoFocus:!0})]})}const cU=["Built-in","Simple","Git","Cost","Custom"];function dU(e){const r={};for(const s of e)r[s.category]||(r[s.category]=[]),r[s.category].push(s);return r}const uU=eg(Zp);function hU(){const[e,r]=_.useState([]),[s,n]=_.useState("disabled"),[o,c]=_.useState(uU),[d,l]=_.useState(null),[u,f]=_.useState(""),[m,h]=_.useState(!0),[g,w]=_.useState(!1);_.useEffect(()=>{j()},[]);const j=async()=>{try{h(!0);const[b,S]=await Promise.all([he.getStatuslinePresets(),he.getCurrentStatusline()]);r(b.presets||[]),n(S.presetId||"disabled"),S.presetId==="custom"&&S.scriptContent&&c(S.scriptContent)}catch(b){q.error("Failed to load statuslines: "+b.message)}finally{h(!1)}},k=async b=>{if(!(b.id==="custom"||b.id===d)){w(!0);try{await he.setStatusline(b.id),n(b.id),q.success(b.id==="disabled"?"Statusline disabled":`Applied "${b.name}"`)}catch(S){q.error("Failed to apply: "+S.message)}finally{w(!1)}}},v=async(b,S)=>{if(S.stopPropagation(),b.id==="custom"){f(o),l("custom");return}try{const N=await he.getPresetScript(b.id);f(N.scriptContent||""),l(b.id)}catch(N){q.error("Failed to load script: "+N.message)}},y=async(b,S=u)=>{w(!0);try{const N=await he.setStatusline(b,S);if(N.success===!1)throw new Error(N.error||"Save failed");n(b),b==="custom"&&c(S),l(null),q.success("Script saved and applied")}catch(N){q.error("Failed to save: "+N.message)}finally{w(!1)}};if(m)return t.jsx("div",{className:"flex items-center justify-center h-64",children:t.jsx(Qe,{className:"w-8 h-8 animate-spin text-indigo-600"})});const x=dU(e);return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{className:"bg-white dark:bg-slate-950 rounded-xl border border-gray-200 dark:border-slate-800 p-6 shadow-sm",children:[t.jsxs("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center gap-2",children:[t.jsx(Ut,{className:"w-5 h-5 text-indigo-500"}),"Statusline"]}),t.jsxs("p",{className:"text-sm text-gray-500 dark:text-slate-400 mt-1",children:["Claude Code runs a shell script after each response and displays the output in the status bar. Scripts receive JSON session data via stdin. Requires"," ",t.jsx("code",{className:"bg-gray-100 dark:bg-slate-800 px-1 rounded text-xs",children:"jq"}),"."]}),t.jsx("p",{className:"text-xs text-amber-600 dark:text-amber-400 mt-2",children:"⚡ Changes apply to the next interaction in your Claude Code session (no restart needed)."})]}),cU.filter(b=>x[b]).map(b=>t.jsxs("div",{children:[t.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wider text-gray-500 dark:text-slate-500 mb-3 px-1",children:b}),t.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3",children:x[b].map(S=>{const N=s===S.id,P=S.id==="custom",A=S.id==="disabled",E=d===S.id,M=!A;return t.jsxs("div",{onClick:()=>!P&&!E&&k(S),className:["rounded-xl border p-4 transition-all",P||E?"cursor-default":"cursor-pointer hover:border-indigo-400 dark:hover:border-indigo-500",N?"border-indigo-500 bg-indigo-50 dark:bg-indigo-950/40 shadow-sm":"border-gray-200 dark:border-slate-800 bg-white dark:bg-slate-950"].join(" "),children:[t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-medium text-gray-900 dark:text-white truncate",children:S.name}),N&&!E&&t.jsx(It,{className:"w-4 h-4 text-indigo-500 shrink-0"})]}),t.jsx("p",{className:"text-xs text-gray-500 dark:text-slate-400 mt-0.5",children:S.description})]}),M&&t.jsx("button",{onClick:I=>E?(I.stopPropagation(),l(null)):v(S,I),className:"p-1 rounded hover:bg-gray-100 dark:hover:bg-slate-800 text-gray-400 hover:text-gray-600 dark:hover:text-slate-300 shrink-0",title:E?"Close editor":"Edit script",children:E?t.jsx(Nn,{className:"w-3.5 h-3.5"}):t.jsx(al,{className:"w-3.5 h-3.5"})})]}),!E&&!P&&!A&&S.preview&&t.jsx("div",{className:"mt-3 px-2 py-1.5 bg-gray-950 dark:bg-black rounded font-mono text-[11px] border border-gray-800 whitespace-pre text-gray-300 truncate",children:S.preview}),!E&&A&&t.jsx("div",{className:"mt-3 px-2 py-1.5 bg-gray-950 dark:bg-black rounded font-mono text-[11px] border border-gray-800 text-gray-600 italic",children:"(no status bar)"}),E&&t.jsxs("div",{className:"mt-3 space-y-2",onClick:I=>I.stopPropagation(),children:[t.jsx(R_,{value:u,onChange:f}),t.jsxs("div",{className:"flex gap-2",children:[t.jsxs(ne,{size:"sm",className:"flex-1",onClick:()=>y(S.id),disabled:g||!u.trim(),children:[g?t.jsx(Qe,{className:"w-3 h-3 animate-spin mr-1"}):null,"Save & Apply"]}),t.jsx(ne,{size:"sm",variant:"outline",onClick:()=>l(null),children:"Cancel"})]})]}),P&&!E&&t.jsxs("div",{className:"mt-3 space-y-2",onClick:I=>I.stopPropagation(),children:[t.jsx(R_,{value:o,onChange:c}),t.jsxs(ne,{size:"sm",className:"w-full",onClick:()=>y("custom",o),disabled:g||!o.trim(),children:[g&&s==="custom"?t.jsx(Qe,{className:"w-3 h-3 animate-spin mr-1"}):null,"Apply Custom Script"]})]})]},S.id)})})]},b)),t.jsxs("div",{className:"bg-gray-50 dark:bg-slate-900 rounded-lg p-4 border border-transparent dark:border-slate-800 space-y-2",children:[t.jsx("h4",{className:"text-sm font-medium text-gray-900 dark:text-white",children:"How it works"}),t.jsxs("p",{className:"text-xs text-gray-600 dark:text-slate-400",children:["Scripts are saved to ",t.jsx("code",{className:"bg-gray-100 dark:bg-slate-800 px-1 rounded",children:"~/.claude/statuslines/"})," and referenced in ",t.jsx("code",{className:"bg-gray-100 dark:bg-slate-800 px-1 rounded",children:"~/.claude/settings.json"})," as"," ",t.jsx("code",{className:"bg-gray-100 dark:bg-slate-800 px-1 rounded",children:"statusLine.command"}),". Claude Code pipes JSON session data to the script on each turn."]}),t.jsxs("p",{className:"text-xs text-gray-500 dark:text-slate-500",children:["Test a script:"," ",t.jsx("code",{className:"bg-gray-100 dark:bg-slate-800 px-1 rounded font-mono",children:`echo '{"model":{"display_name":"opus-4-6"},"context_window":{"used_percentage":37,"remaining_percentage":63}}' | ~/.claude/statuslines/full.sh`})]})]})]})}const fU=[{key:"default",label:"Default",description:"General purpose tasks"},{key:"background",label:"Background",description:"Background processing"},{key:"think",label:"Think",description:"Deep reasoning tasks"},{key:"longContext",label:"Long Context",description:"Large context windows"},{key:"webSearch",label:"Web Search",description:"Web search tasks"},{key:"image",label:"Image",description:"Image processing tasks"}];function mU(){const[e,r]=_.useState(null),[s,n]=_.useState({}),[o,c]=_.useState([]),[d,l]=_.useState(!0),[u,f]=_.useState(!1),[m,h]=_.useState(!1),[g,w]=_.useState({name:"",api_base_url:"",api_key:"",models:""}),[j,k]=_.useState(!1),[v,y]=_.useState(!1),[x,b]=_.useState(""),[S,N]=_.useState(!0),[P,A]=_.useState(!1),[E,M]=_.useState(""),I=_.useCallback(async()=>{var T,F;try{const[$,D,X]=await Promise.all([he.getRouterStatus(),he.getRouterConfig(),he.getRouterPresets()]);r($),n(D),c(X.presets||[]),(F=(T=D==null?void 0:D.Rules)==null?void 0:T.longContext)!=null&&F.threshold&&M(String(D.Rules.longContext.threshold))}catch{r({installed:!1,running:!1,configExists:!1})}finally{l(!1)}},[]);_.useEffect(()=>{I()},[I]);const B=[];if(s!=null&&s.Providers)for(const T of s.Providers)for(const F of T.models||[])B.push(`${T.name},${F}`);const U=async()=>{f(!0);try{e!=null&&e.running?(await he.stopRouter(),q.success("Router proxy stopped")):(await he.startRouter(),q.success("Router proxy started")),await I()}catch(T){q.error("Failed to toggle proxy: "+T.message)}finally{f(!1)}},V=()=>{navigator.clipboard.writeText('eval "$(coder-config router activate)"'),q.success("Activation command copied to clipboard")},Q=async(T,F)=>{try{await he.setRouterRule(T,F),q.success(`Rule updated for ${T}`),await I()}catch($){q.error("Failed to set rule: "+$.message)}},z=async()=>{if(!g.name||!g.api_base_url){q.error("Name and API base URL are required");return}k(!0);try{const T=g.models.split(",").map(F=>F.trim()).filter(Boolean);await he.addRouterProvider(g.name,{api_base_url:g.api_base_url,api_key:g.api_key,models:T}),q.success(`Provider "${g.name}" added`),h(!1),w({name:"",api_base_url:"",api_key:"",models:""}),await I()}catch(T){q.error("Failed to add provider: "+T.message)}finally{k(!1)}},H=async T=>{try{await he.removeRouterProvider(T),q.success(`Provider "${T}" removed`),await I()}catch(F){q.error("Failed to remove provider: "+F.message)}},Y=async()=>{if(!x.trim()){q.error("Preset name is required");return}try{await he.saveRouterPreset(x.trim()),q.success(`Preset "${x}" saved`),y(!1),b(""),await I()}catch(T){q.error("Failed to save preset: "+T.message)}},K=async T=>{try{await he.loadRouterPreset(T),q.success(`Preset "${T}" loaded`),await I()}catch(F){q.error("Failed to load preset: "+F.message)}},O=T=>{const $=((s==null?void 0:s.Rules)||{})[T];return $?typeof $=="string"?$:$.provider&&$.model?`${$.provider},${$.model}`:null:null};return d?t.jsx("div",{className:"flex items-center justify-center py-20",children:t.jsx(Qe,{className:"w-6 h-6 animate-spin text-muted-foreground"})}):t.jsxs("div",{className:"space-y-6 max-w-5xl",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsxs("h2",{className:"text-2xl font-bold text-foreground flex items-center gap-2",children:[t.jsx(th,{className:"w-6 h-6"}),"Code Router"]}),t.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Route AI requests to different providers based on task type"})]}),t.jsxs(ne,{variant:"outline",size:"sm",onClick:I,children:[t.jsx(Yi,{className:"w-4 h-4 mr-1"}),"Refresh"]})]}),t.jsx("div",{className:"rounded-lg border border-border bg-card p-4",children:t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-medium text-foreground",children:"Installation:"}),e!=null&&e.installed?t.jsxs(qe,{variant:"outline",className:"bg-green-50 text-green-700 border-green-200 dark:bg-green-900/30 dark:text-green-400 dark:border-green-800",children:[t.jsx(vi,{className:"w-3 h-3 mr-1"}),"Installed"]}):t.jsxs(qe,{variant:"outline",className:"bg-red-50 text-red-700 border-red-200 dark:bg-red-900/30 dark:text-red-400 dark:border-red-800",children:[t.jsx(Ki,{className:"w-3 h-3 mr-1"}),"Not Found"]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-sm font-medium text-foreground",children:"Proxy:"}),e!=null&&e.running?t.jsxs(qe,{variant:"outline",className:"bg-green-50 text-green-700 border-green-200 dark:bg-green-900/30 dark:text-green-400 dark:border-green-800",children:[t.jsx(vi,{className:"w-3 h-3 mr-1"}),"Running"]}):t.jsxs(qe,{variant:"outline",className:"bg-red-50 text-red-700 border-red-200 dark:bg-red-900/30 dark:text-red-400 dark:border-red-800",children:[t.jsx(Ki,{className:"w-3 h-3 mr-1"}),"Stopped"]})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(ne,{variant:"outline",size:"sm",onClick:V,children:[t.jsx(Bo,{className:"w-4 h-4 mr-1"}),"Copy Activation"]}),t.jsxs(ne,{size:"sm",disabled:!(e!=null&&e.installed)||u,onClick:U,variant:e!=null&&e.running?"destructive":"default",children:[u?t.jsx(Qe,{className:"w-4 h-4 mr-1 animate-spin"}):e!=null&&e.running?t.jsx(kI,{className:"w-4 h-4 mr-1"}):t.jsx(zg,{className:"w-4 h-4 mr-1"}),e!=null&&e.running?"Stop":"Start"]})]})]})}),t.jsxs("div",{className:"rounded-lg border border-border bg-card p-4",children:[t.jsxs("h3",{className:"text-lg font-semibold text-foreground mb-4 flex items-center gap-2",children:[t.jsx(Xs,{className:"w-5 h-5"}),"Routing Rules"]}),t.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-3",children:fU.map(({key:T,label:F,description:$})=>{const D=O(T);return t.jsxs("div",{className:"rounded-md border border-border bg-background p-3 space-y-2",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-foreground",children:F}),t.jsx("div",{className:"text-xs text-muted-foreground",children:$})]}),t.jsxs(ir,{value:D||"__none__",onValueChange:X=>Q(T,X==="__none__"?"":X),children:[t.jsx(Qt,{className:"h-8 text-xs",children:t.jsx(or,{placeholder:"Not set"})}),t.jsxs(Zt,{children:[t.jsx(gt,{value:"__none__",children:"Not set"}),B.map(X=>t.jsx(gt,{value:X,children:X},X))]})]}),T==="longContext"&&t.jsx(Oe,{type:"number",placeholder:"Token threshold",className:"h-8 text-xs",value:E,onChange:X=>{M(X.target.value)},onBlur:async()=>{if(E)try{const X={...s};X.Rules||(X.Rules={}),X.Rules.longContext||(X.Rules.longContext={}),X.Rules.longContext.threshold=parseInt(E,10),await he.saveRouterConfig(X),q.success("Long context threshold updated"),await I()}catch(X){q.error("Failed to update threshold: "+X.message)}}})]},T)})})]}),t.jsx(qo,{open:S,onOpenChange:N,children:t.jsxs("div",{className:"rounded-lg border border-border bg-card",children:[t.jsx(Ko,{className:"w-full p-4 flex items-center justify-between hover:bg-accent/50 transition-colors rounded-t-lg",children:t.jsxs("h3",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[S?t.jsx(hr,{className:"w-5 h-5"}):t.jsx(Qr,{className:"w-5 h-5"}),"Providers",t.jsx(qe,{variant:"secondary",className:"ml-2",children:((s==null?void 0:s.Providers)||[]).length})]})}),t.jsx(Yo,{children:t.jsxs("div",{className:"px-4 pb-4 space-y-3",children:[((s==null?void 0:s.Providers)||[]).length===0?t.jsx("p",{className:"text-sm text-muted-foreground py-2",children:"No providers configured"}):((s==null?void 0:s.Providers)||[]).map(T=>t.jsxs("div",{className:"rounded-md border border-border bg-background p-3 flex items-start justify-between",children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"text-sm font-medium text-foreground",children:T.name}),t.jsx("div",{className:"text-xs text-muted-foreground font-mono",children:T.api_base_url}),t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.jsxs(qe,{variant:"secondary",className:"text-xs",children:[(T.models||[]).length," model",(T.models||[]).length!==1?"s":""]}),T.transformers&&T.transformers.length>0&&t.jsxs(qe,{variant:"outline",className:"text-xs",children:[T.transformers.length," transformer",T.transformers.length!==1?"s":""]})]}),(T.models||[]).length>0&&t.jsx("div",{className:"text-xs text-muted-foreground mt-1",children:T.models.join(", ")})]}),t.jsx(ne,{variant:"ghost",size:"sm",className:"text-red-500 hover:text-red-700 hover:bg-red-50 dark:hover:bg-red-900/20",onClick:()=>H(T.name),children:t.jsx(fs,{className:"w-4 h-4"})})]},T.name)),t.jsxs(ne,{variant:"outline",size:"sm",onClick:()=>h(!0),className:"w-full",children:[t.jsx(Rt,{className:"w-4 h-4 mr-1"}),"Add Provider"]})]})})]})}),t.jsx(qo,{open:P,onOpenChange:A,children:t.jsxs("div",{className:"rounded-lg border border-border bg-card",children:[t.jsx(Ko,{className:"w-full p-4 flex items-center justify-between hover:bg-accent/50 transition-colors rounded-t-lg",children:t.jsxs("h3",{className:"text-lg font-semibold text-foreground flex items-center gap-2",children:[P?t.jsx(hr,{className:"w-5 h-5"}):t.jsx(Qr,{className:"w-5 h-5"}),"Presets",t.jsx(qe,{variant:"secondary",className:"ml-2",children:o.length})]})}),t.jsx(Yo,{children:t.jsxs("div",{className:"px-4 pb-4 space-y-3",children:[o.length===0?t.jsx("p",{className:"text-sm text-muted-foreground py-2",children:"No saved presets"}):o.map(T=>t.jsxs("div",{className:"rounded-md border border-border bg-background p-3 flex items-center justify-between",children:[t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-foreground",children:T.name}),T.date&&t.jsx("div",{className:"text-xs text-muted-foreground",children:new Date(T.date).toLocaleDateString()})]}),t.jsxs(ne,{variant:"outline",size:"sm",onClick:()=>K(T.name),children:[t.jsx(Ru,{className:"w-4 h-4 mr-1"}),"Load"]})]},T.name)),t.jsxs(ne,{variant:"outline",size:"sm",onClick:()=>y(!0),className:"w-full",children:[t.jsx(Zr,{className:"w-4 h-4 mr-1"}),"Save Current"]})]})})]})}),t.jsx(vt,{open:m,onOpenChange:h,children:t.jsxs(ft,{children:[t.jsxs(mt,{children:[t.jsx(pt,{children:"Add Provider"}),t.jsx(Gt,{children:"Configure a new AI provider for the router."})]}),t.jsxs("div",{className:"space-y-4 py-2",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Name"}),t.jsx(Oe,{placeholder:"e.g. openai",value:g.name,onChange:T=>w(F=>({...F,name:T.target.value}))})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"API Base URL"}),t.jsx(Oe,{placeholder:"https://api.openai.com/v1",value:g.api_base_url,onChange:T=>w(F=>({...F,api_base_url:T.target.value}))})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"API Key"}),t.jsx(Oe,{type:"password",placeholder:"sk-...",value:g.api_key,onChange:T=>w(F=>({...F,api_key:T.target.value}))})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Models (comma-separated)"}),t.jsx(Oe,{placeholder:"gpt-4o, gpt-4o-mini",value:g.models,onChange:T=>w(F=>({...F,models:T.target.value}))})]})]}),t.jsxs(St,{children:[t.jsx(ne,{variant:"outline",onClick:()=>h(!1),children:"Cancel"}),t.jsxs(ne,{onClick:z,disabled:j,children:[j&&t.jsx(Qe,{className:"w-4 h-4 mr-1 animate-spin"}),"Add Provider"]})]})]})}),t.jsx(vt,{open:v,onOpenChange:y,children:t.jsxs(ft,{children:[t.jsxs(mt,{children:[t.jsx(pt,{children:"Save Preset"}),t.jsx(Gt,{children:"Save the current router configuration as a named preset."})]}),t.jsx("div",{className:"space-y-4 py-2",children:t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{className:"text-sm font-medium text-foreground",children:"Preset Name"}),t.jsx(Oe,{placeholder:"e.g. cost-optimized",value:x,onChange:T=>b(T.target.value),onKeyDown:T=>T.key==="Enter"&&Y()})]})}),t.jsxs(St,{children:[t.jsx(ne,{variant:"outline",onClick:()=>y(!1),children:"Cancel"}),t.jsxs(ne,{onClick:Y,children:[t.jsx(Zr,{className:"w-4 h-4 mr-1"}),"Save"]})]})]})})]})}const pU=[{id:"projects",label:"All Projects",icon:Hn,section:"Projects"},{id:"explorer",label:"Project Explorer",icon:Zi,section:"Projects"},{id:"workstreams",label:"Workstreams",icon:bS,section:"Projects"},{id:"registry",label:"MCP Registry",icon:Yn,section:"Tools"},{id:"plugins",label:"Plugins",icon:$o,section:"Tools"},{id:"memory",label:"Memory",icon:Fo,section:"Tools"},{id:"claude-settings",label:"Claude Code",icon:Qn,section:"Configuration",tool:"claude"},{id:"gemini-settings",label:"Gemini CLI",icon:Ut,section:"Configuration",tool:"gemini"},{id:"codex-settings",label:"Codex CLI",icon:Ut,section:"Configuration",isNew:!0,tool:"codex"},{id:"antigravity-settings",label:"Antigravity",icon:Mc,section:"Configuration",tool:"antigravity"},{id:"create-mcp",label:"Create MCP",icon:Wr,section:"Developer"},{id:"loops",label:"Ralph Loops",icon:vc,section:"Developer",isNew:!0},{id:"router",label:"Code Router",icon:th,section:"Developer"},{id:"statuslines",label:"Statusline",icon:V5,section:"System",isNew:!0},{id:"sessions",label:"Sessions",icon:Zr,section:"System"},{id:"preferences",label:"Preferences",icon:wS,section:"System"},{id:"tutorial",label:"Tutorial",icon:Au,section:"Help"},{id:"docs",label:"Docs & Help",icon:Oo,section:"Help"}],M_=(e,r)=>{try{const s=localStorage.getItem(`claude-config-${e}`);return s?JSON.parse(s):r}catch{return r}},gU=(e,r)=>{try{localStorage.setItem(`claude-config-${e}`,JSON.stringify(r))}catch{}};function xU(){const{projects:e,activeProject:r,fetch:s,setActive:n}=Fx(),{appConfig:o,version:c,fetch:d,checkVersion:l}=Bw(),[u,f]=_.useState(()=>M_("currentView","explorer")),[m,h]=_.useState(!0),[g,w]=_.useState({dir:"",subprojects:[],hierarchy:[]}),[j,k]=_.useState([]),[v,y]=_.useState({mcpServers:{}}),[x,b]=_.useState([]),[S,N]=_.useState([]),[P,A]=_.useState(null),[E,M]=_.useState(null),[I,B]=_.useState(!1),[U,V]=_.useState({title:"",type:""}),[Q,z]=_.useState(""),[H,Y]=_.useState(""),K=_.useRef({}),[O,T]=_.useState(null),[F,$]=_.useState(!1),[D,X]=_.useState(!1),[te,fe]=_.useState(null),[J,W]=_.useState(!1),le=_.useRef(null);_.useEffect(()=>{gU("currentView",u)},[u]);const ae=_.useCallback(async()=>{try{const[me,be,Z,oe,we]=await Promise.all([he.getProject(),he.getConfigs(),he.getRegistry(),he.getRules(),he.getCommands()]);w(me),k(be),y(Z),b(oe),N(we),be.length>0&&!P&&A(be[be.length-1])}catch(me){q.error("Failed to load data: "+me.message)}finally{h(!1)}},[P]),re=_.useCallback(async(me=!1)=>{try{const be=await s(),Z=be==null?void 0:be.find(oe=>oe.isActive);if(me&&Z){const oe=await he.getSubprojects(Z.path);fe({dir:Z.path,subprojects:oe.subprojects||[]})}me&&!Z&&(M_("currentView",null)||f("projects"))}catch{console.log("Projects API not available")}},[s]),de=async me=>{try{const be=await n(me);be.success?(w({dir:be.dir,hierarchy:be.hierarchy,subprojects:be.subprojects}),fe({dir:be.dir,subprojects:be.subprojects}),await ae(),q.success(`Switched to ${be.project.name}`)):q.error(be.error||"Failed to switch project")}catch(be){q.error("Failed to switch project: "+be.message)}},Se=()=>{s()};_.useEffect(()=>{ae(),re(!0),(async()=>{try{const[be]=await Promise.all([l(),d()]);!le.current&&(be!=null&&be.installedVersion)&&(le.current=be.installedVersion);const Z=Bw.getState().appConfig;if(be!=null&&be.updateAvailable&&(be==null?void 0:be.updateMethod)==="npm")if(Z!=null&&Z.autoUpdate){q.info(`Auto-updating to v${be.latestVersion}...`),$(!0);const oe=await he.performUpdate({updateMethod:be.updateMethod,targetVersion:be.latestVersion,channel:be.channel});if(oe.success){q.success(`Updated to v${oe.newVersion}! Restarting server...`);try{await he.restartServer()}catch{}let we=0;const Ce=setInterval(async()=>{we++;try{await he.checkVersion(),clearInterval(Ce),q.success("Server restarted! Reloading..."),setTimeout(()=>window.location.reload(),500)}catch{we>30&&(clearInterval(Ce),q.info("Server restarting. Please refresh the page."),$(!1))}},500)}else q.error("Auto-update failed: "+oe.error),$(!1),T(be)}else T(be)}catch{}})()},[]),_.useEffect(()=>{const be=setInterval(async()=>{if(le.current)try{const Z=await he.checkVersion();Z!=null&&Z.installedVersion&&Z.installedVersion!==le.current&&(console.log(`[stale-ui] Server updated to v${Z.installedVersion}, refreshing...`),window.location.reload())}catch{}},3e4);return()=>clearInterval(be)},[]);const Re=(me,be)=>{if(!me||!be)return!1;const Z=Ce=>Ce.split(".").map(Fe=>parseInt(Fe,10)||0),oe=Z(me),we=Z(be);for(let Ce=0;Ce<Math.max(oe.length,we.length);Ce++){if((oe[Ce]||0)>(we[Ce]||0))return!0;if((oe[Ce]||0)<(we[Ce]||0))return!1}return!1},Ue=async(me,be="npm",Z)=>{$(!0);const oe=await he.performUpdate({updateMethod:be,targetVersion:me,channel:Z});if(oe.success){q.success(`Updated to v${oe.newVersion}! Restarting server...`),T(null);try{await he.restartServer()}catch{}let we=0;const Ce=setInterval(async()=>{we++;try{await he.checkVersion(),clearInterval(Ce),q.success("Server restarted! Reloading..."),setTimeout(()=>window.location.reload(),500)}catch{we>30&&(clearInterval(Ce),q.info("Server restarting. Please refresh the page."),$(!1))}},500);return!0}else return q.error("Update failed: "+oe.error),$(!1),!1},pe=async()=>{W(!0);try{const me=await he.checkVersion(),be=me==null?void 0:me.installedVersion,Z=me==null?void 0:me.latestVersion;if(be&&le.current&&be!==le.current){q.info(`Refreshing to v${be}...`),setTimeout(()=>window.location.reload(),500);return}Re(Z,be)&&(o!=null&&o.autoUpdate?(W(!1),q.info(`Auto-updating to v${Z}...`),await Ue(Z,(me==null?void 0:me.updateMethod)||"npm",me==null?void 0:me.channel)):(T({...me,updateAvailable:!0}),q.info(`Update available: v${Z}`)))}catch{q.error("Failed to check for updates")}finally{W(!1)}},_e=async()=>{if(O!=null&&O.updateAvailable){$(!0);try{const me=await he.performUpdate({updateMethod:O.updateMethod,sourcePath:O.sourcePath,targetVersion:O.latestVersion,channel:O.channel});if(me.success){q.success(`Updated to v${me.newVersion}! Restarting server...`),T(null),setVersion(me.newVersion);try{await he.restartServer()}catch{}let be=0;const Z=setInterval(async()=>{be++;try{await he.checkVersion(),clearInterval(Z),q.success("Server restarted! Reloading..."),setTimeout(()=>window.location.reload(),500)}catch{be>30&&(clearInterval(Z),q.info("Server restarting. Please refresh the page."),$(!1))}},500)}else q.error("Update failed: "+me.error),$(!1)}catch(me){q.error("Update failed: "+me.message),$(!1)}}};_.useEffect(()=>{const me=async()=>{try{const{hashes:Z}=await he.getFileHashes(),oe=K.current,we=Object.keys(Z).some(Fe=>oe[Fe]!==Z[Fe])||Object.keys(oe).some(Fe=>!Z[Fe]),Ce=oe.__subprojects__!==Z.__subprojects__;if(we&&Object.keys(oe).length>0&&(await ae(),Ce&&te))try{const Fe=await he.getSubprojects(te.dir);fe(He=>({...He,subprojects:Fe.subprojects||[]}))}catch{}K.current=Z}catch{}},be=setInterval(me,2e3);return me(),()=>clearInterval(be)},[ae,te]);const $e=new Set;j.forEach(me=>{var be,Z;(((be=me.config)==null?void 0:be.include)||[]).forEach(oe=>$e.add(oe)),Object.keys(((Z=me.config)==null?void 0:Z.mcpServers)||{}).forEach(oe=>$e.add(oe))});const Ge={mcps:$e.size,rules:x.length,commands:S.length},et=async()=>{try{const me=await he.applyConfig(g.dir);if(me.tools){const be=Object.entries(me.tools).filter(([,Z])=>Z).map(([Z])=>Z==="claude"?"Claude Code":"Antigravity");be.length>0?q.success(`Config applied to: ${be.join(", ")}`):q.warning("No tools were updated")}else q.success("Configuration applied successfully!")}catch(me){q.error("Failed to apply config: "+me.message)}},Nt=async()=>{h(!0),await ae(),q.success("Data refreshed")};if(m)return t.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:t.jsxs("div",{className:"flex flex-col items-center gap-4",children:[t.jsx(Qe,{className:"w-8 h-8 animate-spin text-primary"}),t.jsx("p",{className:"text-muted-foreground",children:"Loading configuration..."})]})});const ke=()=>{switch(u){case"explorer":return t.jsx(F8,{project:g,onRefresh:ae});case"registry":return t.jsx(nW,{registry:v,searchQuery:Q,setSearchQuery:z,onUpdate:ae});case"plugins":return t.jsx(RW,{});case"memory":return t.jsx(iW,{project:g,onUpdate:ae});case"create-mcp":return t.jsx(Dz,{project:g});case"claude-settings":return t.jsx(bz,{});case"gemini-settings":return t.jsx(wz,{});case"codex-settings":return t.jsx(Mz,{});case"antigravity-settings":return t.jsx(jz,{});case"statuslines":return t.jsx(hU,{});case"sessions":return t.jsx(oU,{});case"preferences":return t.jsx(yz,{onConfigChange:()=>d()});case"projects":return t.jsx(dW,{onProjectSwitch:me=>{w({dir:me.dir,hierarchy:me.hierarchy,subprojects:me.subprojects}),fe({dir:me.dir,subprojects:me.subprojects}),ae(),re()}});case"workstreams":return t.jsx(DW,{onWorkstreamChange:me=>{q.success(`Switched to workstream: ${me.name}`)}});case"loops":return t.jsx(LW,{activeProject:r});case"router":return t.jsx(mU,{});case"docs":return t.jsx(AW,{});case"tutorial":return t.jsx(iU,{});default:return null}};return t.jsxs("div",{className:"min-h-screen bg-background",children:[t.jsx("header",{className:"h-16 bg-card border-b border-border sticky top-0 z-50 shadow-sm",children:t.jsxs("div",{className:"h-full px-6 flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-indigo-500 to-purple-600 flex items-center justify-center shadow-lg shadow-indigo-500/20",children:t.jsxs("svg",{width:"22",height:"22",viewBox:"0 0 128 128",children:[t.jsx("circle",{cx:"64",cy:"64",r:"52",fill:"none",stroke:"white",strokeWidth:"10",strokeDasharray:"24 12"}),t.jsx("circle",{cx:"64",cy:"64",r:"28",fill:"white"}),t.jsx("circle",{cx:"64",cy:"64",r:"12",fill:"#7c3aed"})]})}),t.jsx("div",{children:t.jsxs("h1",{className:"text-xl font-bold text-foreground",children:["Coder ",t.jsx("span",{className:"text-primary",children:"Config"})]})}),O&&t.jsxs("button",{onClick:_e,disabled:F,className:"ml-3 px-2.5 py-1 text-xs font-medium bg-green-100 text-green-700 hover:bg-green-200 rounded-full flex items-center gap-1.5 transition-colors disabled:opacity-50",children:[F?t.jsx(Qe,{className:"w-3 h-3 animate-spin"}):t.jsx(yi,{className:"w-3 h-3"}),F?"Updating...":`Update to v${O.latestVersion}`]})]}),t.jsx(RN,{orientation:"vertical",className:"h-6"}),t.jsx(B8,{projects:e,activeProject:r,onSwitch:de,onAddClick:()=>X(!0),onManageClick:()=>f("projects")})]}),t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx(W8,{}),t.jsx(ne,{variant:"ghost",size:"sm",onClick:Nt,children:t.jsx(Dr,{className:"w-4 h-4"})}),t.jsxs(ne,{onClick:et,variant:"ghost",size:"sm",className:"gap-2 text-muted-foreground hover:text-foreground",title:"Config auto-applies on save. Click to manually re-apply.",children:[t.jsx(Mc,{className:"w-4 h-4"}),"Re-apply"]})]})]})}),t.jsxs("div",{className:"flex",children:[t.jsxs("aside",{className:"w-64 h-[calc(100vh-64px)] border-r border-border bg-card sticky top-16 flex flex-col",children:[t.jsx(Js,{className:"flex-1 py-4",children:["Projects","Tools","Configuration","Developer","System","Help"].map(me=>t.jsxs("div",{className:"mb-6",children:[t.jsx("h3",{className:"px-4 mb-2 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground",children:me}),t.jsx("div",{className:"space-y-0.5",children:pU.filter(be=>be.section===me).filter(be=>{var Z;return be.id!=="loops"||((Z=o==null?void 0:o.experimental)==null?void 0:Z.ralphLoops)}).filter(be=>!be.tool||((o==null?void 0:o.enabledTools)||["claude"]).includes(be.tool)).map(be=>{const Z=be.icon,oe=u===be.id;return t.jsxs("button",{onClick:()=>f(be.id),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-all duration-200 border-l-2 ${oe?"bg-accent border-primary text-primary font-medium":"border-transparent text-muted-foreground hover:text-foreground hover:bg-accent"}`,children:[t.jsx(Z,{className:"w-4 h-4"}),t.jsx("span",{className:"flex-1 text-left",children:be.label}),be.badge&&t.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full font-medium ${oe?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"}`,children:Ge[be.badge]}),be.isNew&&t.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded font-medium bg-green-500/20 text-green-600 dark:text-green-400",children:"new"})]},be.id)})})]},me))}),t.jsx("div",{className:"px-4 py-3 border-t border-border",children:t.jsxs("button",{onClick:pe,disabled:J,className:"text-xs text-muted-foreground hover:text-foreground transition-colors flex items-center gap-1",title:"Check for updates",children:[J?t.jsx(Qe,{className:"w-3 h-3 animate-spin"}):null,c?`v${c}`:""]})})]}),t.jsx("main",{style:["explorer","docs","tutorial"].includes(u)?{}:{zoom:.9},className:Ee("flex-1 overflow-auto",["explorer","docs","tutorial"].includes(u)?"h-[calc(100vh-64px)]":"p-6"),children:t.jsx(F_,{mode:"wait",children:t.jsx(Ua.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:["explorer","docs","tutorial"].includes(u)?"h-full":"",children:ke()},u)})})]}),t.jsx(EN,{open:D,onOpenChange:X,onAdded:Se}),t.jsx($8,{onStartTutorial:()=>f("tutorial")})]})}function vU(){const[e,r]=_.useState(!1),[s,n]=_.useState(!1),[o,c]=_.useState(!1),d=_.useCallback(async()=>{n(!0);try{await he.restartServer(),q.info("Server restarting... page will reload."),setTimeout(()=>{window.location.reload()},2e3)}catch(u){q.error("Failed to restart: "+u.message),n(!1)}},[]),l=_.useCallback(()=>{c(!0),r(!1),q.dismiss("update-available")},[]);return _.useEffect(()=>{let u;const f=async()=>{try{const m=await he.getVersion();console.log("[Update Check]",m),m.needsRestart&&!o&&r(!0)}catch{}};return f(),u=setInterval(f,3e4),()=>clearInterval(u)},[o]),t.jsx(H8,{children:t.jsxs("div",{className:"min-h-screen bg-background",children:[e&&!s&&t.jsxs("div",{className:"fixed top-0 left-0 right-0 z-50 bg-blue-600 text-white px-4 py-2 flex items-center justify-center gap-2 shadow-lg cursor-pointer hover:bg-blue-700 transition-colors",onClick:d,children:[t.jsx(Dr,{className:"w-4 h-4"}),t.jsx("span",{className:"text-sm font-medium",children:"Update available — click to restart"}),t.jsx("button",{onClick:u=>{u.stopPropagation(),l()},className:"absolute right-3 p-1 hover:bg-blue-500 rounded",children:t.jsx(Nn,{className:"w-4 h-4"})})]}),s&&t.jsxs("div",{className:"fixed top-0 left-0 right-0 z-50 bg-amber-600 text-white px-4 py-2 flex items-center justify-center gap-2",children:[t.jsx(Dr,{className:"w-4 h-4 animate-spin"}),t.jsx("span",{className:"text-sm font-medium",children:"Restarting server..."})]}),t.jsx(xU,{}),t.jsx(XP,{position:"bottom-right",richColors:!0})]})})}kP.createRoot(document.getElementById("root")).render(t.jsx(vU,{}));