byterover-cli 3.8.2 → 3.8.3

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.
@@ -20,7 +20,7 @@ Please change the parent <Route path="${T}"> to <Route path="${T==="/"?"*":`${T}
20
20
  ${l.right}px ${l.bottom}px,
21
21
  ${l.right}px ${l.top}px,
22
22
  ${l.left}px ${l.top}px
23
- )`}return p.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...o,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:a}})}),Ox=C.forwardRef(function(t,n){const{keepMounted:r=!1,...o}=t,{store:a}=Ka(),l=a.useState("mounted"),c=a.useState("modal"),f=a.useState("open");return l||r?p.jsx(KT.Provider,{value:r,children:p.jsxs(h6,{ref:n,...o,children:[l&&c===!0&&p.jsx(r9,{ref:a.context.internalBackdropRef,inert:K6(!f)}),t.children]})}):null});let bC={},vC={},wC="";function oH(e){if(typeof document>"u")return!1;const t=Gt(e);return $n(t).innerWidth-t.documentElement.clientWidth>0}function aH(e){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;const n=Gt(e),r=n.documentElement,o=n.body,a=$a(r)?r:o,l=a.style.overflowY,c=r.style.scrollbarGutter;r.style.scrollbarGutter="stable",a.style.overflowY="scroll";const f=a.offsetWidth;a.style.overflowY="hidden";const d=a.offsetWidth;return a.style.overflowY=l,r.style.scrollbarGutter=c,f===d}function sH(e){const t=Gt(e),n=t.documentElement,r=t.body,o=$a(n)?n:r,a={overflowY:o.style.overflowY,overflowX:o.style.overflowX};return Object.assign(o.style,{overflowY:"hidden",overflowX:"hidden"}),()=>{Object.assign(o.style,a)}}function lH(e){const t=Gt(e),n=t.documentElement,r=t.body,o=$n(n);let a=0,l=0,c=!1;const f=to.create();if(jk&&(o.visualViewport?.scale??1)!==1)return()=>{};function d(){const y=o.getComputedStyle(n),x=o.getComputedStyle(r),E=(y.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";a=n.scrollTop,l=n.scrollLeft,bC={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},wC=n.style.scrollBehavior,vC={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};const k=n.scrollHeight>n.clientHeight,T=n.scrollWidth>n.clientWidth,R=y.overflowY==="scroll"||x.overflowY==="scroll",L=y.overflowX==="scroll"||x.overflowX==="scroll",j=Math.max(0,o.innerWidth-r.clientWidth),N=Math.max(0,o.innerHeight-r.clientHeight),A=parseFloat(x.marginTop)+parseFloat(x.marginBottom),D=parseFloat(x.marginLeft)+parseFloat(x.marginRight),U=$a(n)?n:r;if(c=aH(e),c){n.style.scrollbarGutter=E,U.style.overflowY="hidden",U.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:E,overflowY:"hidden",overflowX:"hidden"}),(k||R)&&(n.style.overflowY="scroll"),(T||L)&&(n.style.overflowX="scroll"),Object.assign(r.style,{position:"relative",height:A||N?`calc(100dvh - ${A+N}px)`:"100dvh",width:D||j?`calc(100vw - ${D+j}px)`:"100vw",boxSizing:"border-box",overflow:"hidden",scrollBehavior:"unset"}),r.scrollTop=a,r.scrollLeft=l,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function g(){Object.assign(n.style,bC),Object.assign(r.style,vC),c||(n.scrollTop=a,n.scrollLeft=l,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=wC)}function h(){g(),f.request(d)}return d(),o.addEventListener("resize",h),()=>{f.cancel(),g(),typeof o.removeEventListener=="function"&&o.removeEventListener("resize",h)}}class cH{lockCount=0;restore=null;timeoutLock=$i.create();timeoutUnlock=$i.create();acquire(t){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(t)),this.release}release=()=>{this.lockCount-=1,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(t){if(this.lockCount===0||this.restore!==null)return;const r=Gt(t).documentElement,o=$n(r).getComputedStyle(r).overflowY;if(o==="hidden"||o==="clip"){this.restore=dr;return}const a=Mk||!oH(t);this.restore=a?sH(t):lH(t)}}const uH=new cH;function i9(e=!0,t=null){qe(()=>{if(e)return uH.acquire(t)},[e,t])}function fH(e){const t=C.useRef(""),n=C.useCallback(o=>{o.defaultPrevented||(t.current=o.pointerType,e(o,o.pointerType))},[e]);return{onClick:C.useCallback(o=>{if(o.detail===0){e(o,"keyboard");return}"pointerType"in o?e(o,o.pointerType):e(o,t.current),t.current=""},[e]),onPointerDown:n}}function o9(e,t){const n=C.useRef(e),r=st(t);qe(()=>{n.current!==e&&r(n.current)},[e,r]),qe(()=>{n.current=e},[e])}function a9(e){const[t,n]=C.useState(null),r=st((l,c)=>{e||n(c||(Mk?"touch":""))});o9(e,l=>{l&&!e&&n(null)});const{onClick:o,onPointerDown:a}=fH(r);return C.useMemo(()=>({openMethod:t,triggerProps:{onClick:o,onPointerDown:a}}),[t,o,a])}function s9(e){const{store:t,parentContext:n,actionsRef:r}=e,o=t.useState("open"),a=t.useState("disablePointerDismissal"),l=t.useState("modal"),c=t.useState("popupElement"),{openMethod:f,triggerProps:d}=a9(o);Zy(t);const{forceUnmount:g}=Jy(o,t),h=st(U=>{const I=Et(U);return I.preventUnmountOnClose=()=>{t.set("preventUnmountingOnClose",!0)},I}),y=C.useCallback(()=>{t.setOpen(!1,h(qy))},[t,h]);C.useImperativeHandle(r,()=>({unmount:g,close:y}),[g,y]);const x=nx({popupStore:t,onOpenChange:t.setOpen,treatPopupAsFloatingElement:!0,noEmit:!0}),[v,S]=C.useState(0),E=v===0,k=F6(x),T=Wy(x,{outsidePressEvent(){return t.context.internalBackdropRef.current||t.context.backdropRef.current?"intentional":{mouse:l==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(U){if(!t.context.outsidePressEnabledRef.current||"button"in U&&U.button!==0||"touches"in U&&U.touches.length!==1)return!1;const I=Ar(U);if(E&&!a){const q=I;return l&&(t.context.internalBackdropRef.current||t.context.backdropRef.current)?t.context.internalBackdropRef.current===q||t.context.backdropRef.current===q||ht(q,c)&&!q?.hasAttribute("data-base-ui-portal"):!0}return!1},escapeKey:E});i9(o&&l===!0,c);const{getReferenceProps:R,getFloatingProps:L,getTriggerProps:j}=Lf([k,T]);t.useContextCallback("onNestedDialogOpen",U=>{S(U+1)}),t.useContextCallback("onNestedDialogClose",()=>{S(0)}),C.useEffect(()=>(n?.onNestedDialogOpen&&o&&n.onNestedDialogOpen(v),n?.onNestedDialogClose&&!o&&n.onNestedDialogClose(),()=>{n?.onNestedDialogClose&&o&&n.onNestedDialogClose()}),[o,n,v]);const N=C.useMemo(()=>R(d),[R,d]),A=C.useMemo(()=>j(d),[j,d]),D=C.useMemo(()=>L(),[L]);t.useSyncedValues({openMethod:f,activeTriggerProps:N,inactiveTriggerProps:A,popupProps:D,floatingRootContext:x,nestedOpenDialogCount:v})}const dH={...tx,modal:rt(e=>e.modal),nested:rt(e=>e.nested),nestedOpenDialogCount:rt(e=>e.nestedOpenDialogCount),disablePointerDismissal:rt(e=>e.disablePointerDismissal),openMethod:rt(e=>e.openMethod),descriptionElementId:rt(e=>e.descriptionElementId),titleElementId:rt(e=>e.titleElementId),viewportElement:rt(e=>e.viewportElement),role:rt(e=>e.role)};class l9 extends n0{constructor(t){super(hH(t),{popupRef:C.createRef(),backdropRef:C.createRef(),internalBackdropRef:C.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:new Mf,onOpenChange:void 0,onOpenChangeComplete:void 0},dH)}setOpen=(t,n)=>{if(n.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},!t&&n.trigger==null&&this.state.activeTriggerId!=null&&(n.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(t,n),n.isCanceled)return;const r={open:t,nativeEvent:n.event,reason:n.reason,nested:this.state.nested};this.state.floatingRootContext.context.events?.emit("openchange",r);const o={open:t},a=n.trigger?.id??null;(a||t)&&(o.activeTriggerId=a,o.activeTriggerElement=n.trigger??null),this.update(o)}}function hH(e={}){return{...ex(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,role:"dialog",...e}}function c9(e){const{children:t,open:n,defaultOpen:r=!1,onOpenChange:o,onOpenChangeComplete:a,disablePointerDismissal:l=!1,modal:c=!0,actionsRef:f,handle:d,triggerId:g,defaultTriggerId:h=null}=e,y=Ka(!0),x=!!y,v=Zn(()=>d?.store??new l9({open:r,openProp:n,activeTriggerId:h,triggerIdProp:g,modal:c,disablePointerDismissal:l,nested:x})).current;My(()=>{n===void 0&&v.state.open===!1&&r===!0&&v.update({open:!0,activeTriggerId:h})}),v.useControlledProp("openProp",n),v.useControlledProp("triggerIdProp",g),v.useSyncedValues({disablePointerDismissal:l,nested:x,modal:c}),v.useContextCallback("onOpenChange",o),v.useContextCallback("onOpenChangeComplete",a);const S=v.useState("payload");s9({store:v,actionsRef:f,parentContext:y?.store.context});const E=C.useMemo(()=>({store:v}),[v]);return p.jsx(Tx.Provider,{value:E,children:typeof t=="function"?t({payload:S}):t})}const u9=C.forwardRef(function(t,n){const{render:r,className:o,id:a,...l}=t,{store:c}=Ka(),f=Gi(a);return c.useSyncedValueWithCleanup("titleElementId",f),ln("h2",t,{ref:n,props:[{id:f},l]})}),pH=C.forwardRef(function(t,n){const{render:r,className:o,disabled:a=!1,focusableWhenDisabled:l=!1,nativeButton:c=!0,...f}=t,{getButtonProps:d,buttonRef:g}=zf({disabled:a,focusableWhenDisabled:l,native:c});return ln("button",t,{state:{disabled:a},ref:[n,g],props:[f,d]})}),mH=o0("group/button inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 cursor-pointer",{variants:{variant:{default:"bg-primary text-foreground font-medium hover:bg-primary/80",outline:"border-border bg-background shadow-xs hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-background dark:hover:bg-muted",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive text-foreground hover:bg-destructive/80 focus-visible:border-destructive/40 focus-visible:ring-destructive/20",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 gap-1.5 px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",xs:"h-6 gap-1 rounded-[min(var(--radius-md),8px)] px-2 text-xs in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-8 gap-1 rounded-[min(var(--radius-md),10px)] px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5",lg:"h-10 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3",icon:"size-9","icon-xs":"size-6 rounded-[min(var(--radius-md),8px)] in-data-[slot=button-group]:rounded-md [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-8 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-md","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function De({className:e,variant:t="default",size:n="default",...r}){return p.jsx(pH,{"data-slot":"button",className:we(mH({variant:t,size:n,className:e})),...r})}function $s({...e}){return p.jsx(c9,{"data-slot":"dialog",...e})}function gH({...e}){return p.jsx(Ox,{"data-slot":"dialog-portal",...e})}function H1({...e}){return p.jsx(Pf,{"data-slot":"dialog-close",...e})}function yH({className:e,...t}){return p.jsx(Ax,{"data-slot":"dialog-overlay",className:we("fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",e),...t})}function Gs({className:e,children:t,showCloseButton:n=!0,...r}){return p.jsxs(gH,{children:[p.jsx(yH,{}),p.jsxs(Nx,{"data-slot":"dialog-content",className:we("fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-6 rounded-xl bg-background p-6 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-md data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...r,children:[t,n&&p.jsxs(Pf,{"data-slot":"dialog-close",render:p.jsx(De,{variant:"ghost",className:"absolute top-4 right-4",size:"icon-sm"}),children:[p.jsx(qp,{}),p.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function ui({className:e,...t}){return p.jsx("div",{"data-slot":"dialog-header",className:we("flex flex-col gap-2",e),...t})}function Qa({className:e,showCloseButton:t=!1,children:n,...r}){return p.jsxs("div",{"data-slot":"dialog-footer",className:we("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...r,children:[n,t&&p.jsx(Pf,{render:p.jsx(De,{variant:"outline"}),children:"Close"})]})}function fi({className:e,...t}){return p.jsx(u9,{"data-slot":"dialog-title",className:we("leading-none text-lg font-semibold text-foreground",e),...t})}function Ff({className:e,...t}){return p.jsx(WT,{"data-slot":"dialog-description",className:we("text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...t})}const f9=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();const xH=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const bH=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase());const SC=e=>{const t=bH(e);return t.charAt(0).toUpperCase()+t.slice(1)};var E2={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const vH=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1},wH=C.createContext({}),SH=()=>C.useContext(wH),CH=C.forwardRef(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,className:o="",children:a,iconNode:l,...c},f)=>{const{size:d=24,strokeWidth:g=2,absoluteStrokeWidth:h=!1,color:y="currentColor",className:x=""}=SH()??{},v=r??h?Number(n??g)*24/Number(t??d):n??g;return C.createElement("svg",{ref:f,...E2,width:t??d??E2.width,height:t??d??E2.height,stroke:e??y,strokeWidth:v,className:f9("lucide",x,o),...!a&&!vH(c)&&{"aria-hidden":"true"},...c},[...l.map(([S,E])=>C.createElement(S,E)),...Array.isArray(a)?a:[a]])});const ft=(e,t)=>{const n=C.forwardRef(({className:r,...o},a)=>C.createElement(CH,{ref:a,iconNode:t,className:f9(`lucide-${xH(SC(e))}`,`lucide-${e}`,r),...o}));return n.displayName=SC(e),n};const EH=[["path",{d:"M17 7 7 17",key:"15tmo1"}],["path",{d:"M17 17H7V7",key:"1org7z"}]],kH=ft("arrow-down-left",EH);const TH=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],AH=ft("arrow-down",TH);const RH=[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]],NH=ft("arrow-right-left",RH);const OH=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],d9=ft("arrow-right",OH);const jH=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],MH=ft("arrow-up",jH);const LH=[["path",{d:"M13.5 10.5 15 9",key:"1nsxvm"}],["path",{d:"M4 4v15a1 1 0 0 0 1 1h15",key:"1w6lkd"}],["path",{d:"M4.293 19.707 6 18",key:"3g1p8c"}],["path",{d:"m9 15 1.5-1.5",key:"1xfbes"}]],_H=ft("axis-3d",LH);const DH=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],IH=ft("book-open",DH);const zH=[["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z",key:"uouzyp"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M21 21a4 4 0 0 0-3.81-4",key:"1b0z45"}],["path",{d:"M21 5a4 4 0 0 1-3.55 3.97",key:"5cxbf6"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M3 21a4 4 0 0 1 3.81-4",key:"1fjd4g"}],["path",{d:"M3 5a4 4 0 0 0 3.55 3.97",key:"1d7oge"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13",key:"1vgav8"}]],PH=ft("bug",zH);const FH=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Ys=ft("check",FH);const BH=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Bf=ft("chevron-down",BH);const HH=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Fs=ft("chevron-left",HH);const UH=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],h9=ft("chevron-right",UH);const qH=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],VH=ft("chevron-up",qH);const $H=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],GH=ft("chevrons-left",$H);const YH=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],WH=ft("chevrons-right",YH);const KH=[["path",{d:"M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z",key:"kmsa83"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],QH=ft("circle-play",KH);const XH=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],ZH=ft("circle-question-mark",XH);const JH=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],eU=ft("circle-x",JH);const tU=[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]],nU=ft("command",tU);const rU=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],iU=ft("copy",rU);const oU=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],aU=ft("external-link",oU);const sU=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M9 17h6",key:"r8uit2"}]],lU=ft("file-diff",sU);const cU=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],c0=ft("file-text",cU);const uU=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],fU=ft("folder-open",uU);const dU=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],p9=ft("folder",dU);const hU=[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]],pU=ft("git-commit-horizontal",hU);const mU=[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]],jx=ft("git-branch",mU);const gU=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],yU=ft("globe",gU);const xU=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],m9=ft("house",xU);const bU=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],vU=ft("key",bU);const wU=[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]],SU=ft("lightbulb",wU);const CU=[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]],EU=ft("list-todo",CU);const kU=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],ai=ft("loader-circle",kU);const TU=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],AU=ft("log-out",TU);const RU=[["path",{d:"M5 12h14",key:"1ays0h"}]],Mx=ft("minus",RU);const NU=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],OU=ft("paperclip",NU);const jU=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]],MU=ft("plug",jU);const LU=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Xa=ft("plus",LU);const _U=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],vc=ft("search",_U);const DU=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],IU=ft("server",DU);const zU=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],PU=ft("sparkles",zU);const FU=[["path",{d:"M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6",key:"y09zxi"}],["path",{d:"m21 3-9 9",key:"mpx6sq"}],["path",{d:"M15 3h6v6",key:"1q9fwt"}]],BU=ft("square-arrow-out-up-right",FU);const HU=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],UU=ft("trash-2",HU);const qU=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],VU=ft("triangle-alert",qU);const $U=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],g9=ft("undo-2",$U);const GU=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],Lx=ft("user",GU);const YU=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],y9=ft("x",YU),WU={ERR_NOT_AUTHENTICATED:"Please sign in to continue.",ERR_PROVIDER_NOT_CONFIGURED:"No provider is connected, or its credentials are missing or expired.",ERR_VC_ALREADY_INITIALIZED:"Version control is already initialized for this project.",ERR_VC_AUTH_FAILED:"Authentication failed. Please sign in and try again.",ERR_VC_BRANCH_NOT_FOUND:"Branch not found. You can create a new branch if needed.",ERR_VC_NO_COMMITS:"Make at least one commit before continuing.",ERR_VC_NO_REMOTE:"No remote is configured yet. Set one up before using pull, push, or fetch.",ERR_VC_NO_UPSTREAM:"This branch has no upstream configured yet. Use the Push button to publish it and set upstream in one step.",ERR_VC_NON_FAST_FORWARD:"The remote has changes. Pull first, then try again.",ERR_VC_NOTHING_TO_PUSH:"Nothing to push — stage and commit your changes first.",ERR_VC_REMOTE_ALREADY_EXISTS:"A remote named 'origin' already exists. Remove or rename it before adding a new one.",ERR_VC_USER_NOT_CONFIGURED:({projectPath:e})=>e?`Please run \`brv vc config\` in "${e}" to set your commit author before committing.`:"Please run `brv vc config` inside your project to set commit author before committing."},KU="Something went wrong";function CC(e,t){return typeof e=="object"&&e!==null&&t in e&&typeof e[t]=="string"}function Cn(e,t=KU,n={}){if(CC(e,"code")){const r=WU[e.code];if(r!==void 0)return typeof r=="function"?r(n):r}return CC(e,"message")?e.message:t}const QU=async({contextLength:e,modelId:t,providerId:n})=>{const{apiClient:r}=Be.getState();if(!r)throw new Error("Not connected");const o=await r.request(qT.SET_ACTIVE,{contextLength:e,modelId:t,providerId:n});if(!o.success&&o.error)throw new Error(o.error);return o},XU=({mutationConfig:e}={})=>wn({...e,mutationFn:QU});function u0({label:e}){return p.jsx(Yo,{className:"mono border-primary-foreground bg-primary-foreground/20 h-6 w-fit gap-1 px-2 text-[10px] tracking-[0.08em] uppercase",variant:"outline",children:e})}const ZU=3e5,JU=({providerId:e})=>{const{apiClient:t}=Be.getState();return t?t.request(Wo.AWAIT_OAUTH_CALLBACK,{providerId:e},{timeout:ZU}):Promise.reject(new Error("Not connected"))},eq=({mutationConfig:e}={})=>{const t=cn(),{onSuccess:n,...r}=e??{};return wn({onSuccess(...o){t.invalidateQueries({queryKey:bc().queryKey}),n?.(...o)},...r,mutationFn:JU})},tq=({apiKey:e,baseUrl:t,providerId:n})=>{const{apiClient:r}=Be.getState();return r?r.request(Wo.CONNECT,{apiKey:e,baseUrl:t,providerId:n}):Promise.reject(new Error("Not connected"))},nq=({mutationConfig:e}={})=>{const t=cn(),{onSuccess:n,...r}=e??{};return wn({onSuccess(...o){t.invalidateQueries({queryKey:bc().queryKey}),n?.(...o)},...r,mutationFn:tq})},rq=({providerId:e})=>{const{apiClient:t}=Be.getState();return t?t.request(Wo.DISCONNECT,{providerId:e}):Promise.reject(new Error("Not connected"))},iq=({mutationConfig:e}={})=>{const t=cn(),{onSuccess:n,...r}=e??{};return wn({onSuccess(...o){t.invalidateQueries({queryKey:bc().queryKey}),n?.(...o)},...r,mutationFn:rq})},oq=({providerId:e})=>{const{apiClient:t}=Be.getState();return t?t.request(Wo.SET_ACTIVE,{providerId:e}):Promise.reject(new Error("Not connected"))},aq=({mutationConfig:e}={})=>{const t=cn(),{onSuccess:n,...r}=e??{};return wn({onSuccess(...o){t.invalidateQueries({queryKey:bc().queryKey}),t.invalidateQueries({queryKey:Ex().queryKey}),n?.(...o)},...r,mutationFn:oq})},sq=({providerId:e})=>{const{apiClient:t}=Be.getState();return t?t.request(Wo.START_OAUTH,{providerId:e}):Promise.reject(new Error("Not connected"))},lq=({mutationConfig:e}={})=>wn({...e,mutationFn:sq}),cq=({apiKey:e,providerId:t})=>{const{apiClient:n}=Be.getState();return n?n.request(Wo.VALIDATE_API_KEY,{apiKey:e,providerId:t}):Promise.reject(new Error("Not connected"))},uq=({mutationConfig:e}={})=>wn({...e,mutationFn:cq});let EC=(function(e){return e.disabled="data-disabled",e.valid="data-valid",e.invalid="data-invalid",e.touched="data-touched",e.dirty="data-dirty",e.filled="data-filled",e.focused="data-focused",e})({});const fq={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},Hu={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},dq={disabled:!1,...Hu},_x={valid(e){return e===null?null:e?{[EC.valid]:""}:{[EC.invalid]:""}}},hq=C.createContext({invalid:void 0,name:void 0,validityData:{state:fq,errors:[],error:"",value:"",initialValue:null},setValidityData:dr,disabled:void 0,touched:Hu.touched,setTouched:dr,dirty:Hu.dirty,setDirty:dr,filled:Hu.filled,setFilled:dr,focused:Hu.focused,setFocused:dr,validate:()=>null,validationMode:"onSubmit",validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:dq,markedDirtyRef:{current:!1},validation:{getValidationProps:(e=Ln)=>e,getInputValidationProps:(e=Ln)=>e,inputRef:{current:null},commit:async()=>{}}});function Dx(e=!0){const t=C.useContext(hq);if(t.setValidityData===dr&&!e)throw new Error(Gn(28));return t}const pq=C.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:dr,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function x9(){return C.useContext(pq)}const mq=C.createContext({controlId:void 0,registerControlId:dr,labelId:void 0,setLabelId:dr,messageIds:[],setMessageIds:dr,getDescriptionProps:e=>e});function Ix(){return C.useContext(mq)}function gq(e,t){return{...e,state:{...e.state,valid:!t&&e.state.valid}}}function b9({controlled:e,default:t,name:n,state:r="value"}){const{current:o}=C.useRef(e!==void 0),[a,l]=C.useState(t),c=o?e:a,f=C.useCallback(d=>{o||l(d)},[]);return[c,f]}function yq(e={}){const{id:t,implicit:n=!1,controlRef:r}=e,{controlId:o,registerControlId:a}=Ix(),l=Gi(t),c=n?o:void 0,f=Zn(()=>Symbol("labelable-control")),d=C.useRef(!1),g=C.useRef(t!=null),h=st(()=>{!d.current||a===dr||(d.current=!1,a(f.current,void 0))});return qe(()=>{if(a===dr)return;let y;if(n){const x=r?.current;Yt(x)&&x.closest("label")!=null?y=t??null:y=c??l}else if(t!=null)g.current=!0,y=t;else if(g.current)y=l;else{h();return}if(y===void 0){h();return}d.current=!0,a(f.current,y)},[t,r,c,a,n,l,f,h]),C.useEffect(()=>h,[h]),o??l}function v9(e){const{enabled:t=!0,value:n,id:r,name:o,controlRef:a,commit:l}=e,{formRef:c}=x9(),{invalid:f,markedDirtyRef:d,validityData:g,setValidityData:h}=Dx(),y=st(e.getValue);qe(()=>{if(!t)return;let x=n;x===void 0&&(x=y()),g.initialValue===null&&x!==null&&h(v=>({...v,initialValue:x}))},[t,h,n,g.initialValue,y]),qe(()=>{!t||!r||c.current.fields.set(r,{getValue:y,name:o,controlRef:a,validityData:gq(g,f),validate(x=!0){let v=n;v===void 0&&(v=y()),d.current=!0,x?Mi.flushSync(()=>l(v)):l(v)}})},[l,a,t,c,y,r,f,d,o,g,n]),qe(()=>{const x=c.current.fields;return()=>{r&&x.delete(r)}},[c,r])}const xq=C.forwardRef(function(t,n){const{render:r,className:o,id:a,name:l,value:c,disabled:f=!1,onValueChange:d,defaultValue:g,autoFocus:h=!1,...y}=t,{state:x,name:v,disabled:S,setTouched:E,setDirty:k,validityData:T,setFocused:R,setFilled:L,validationMode:j,validation:N}=Dx(),A=S||f,D=v??l,U={...x,disabled:A},{labelId:I}=Ix(),q=yq({id:a});qe(()=>{const F=c!=null;N.inputRef.current?.value||F&&c!==""?L(!0):F&&c===""&&L(!1)},[N.inputRef,L,c]);const $=C.useRef(null);qe(()=>{h&&$.current===ii(Gt($.current))&&R(!0)},[h,R]);const[V]=b9({controlled:c,default:g,name:"FieldControl",state:"value"}),Y=c!==void 0,H=Y?V:void 0;return v9({id:q,name:D,commit:N.commit,value:H,getValue:()=>N.inputRef.current?.value,controlRef:N.inputRef}),ln("input",t,{ref:[n,$],state:U,props:[{id:q,disabled:A,name:D,ref:N.inputRef,"aria-labelledby":I,autoFocus:h,...Y?{value:H}:{defaultValue:g},onChange(F){const G=F.currentTarget.value;d?.(G,Et(Jp,F.nativeEvent)),k(G!==T.initialValue),L(G!=="")},onFocus(){R(!0)},onBlur(F){E(!0),R(!1),j==="onBlur"&&N.commit(F.currentTarget.value)},onKeyDown(F){F.currentTarget.tagName==="INPUT"&&F.key==="Enter"&&(E(!0),N.commit(F.currentTarget.value))}},N.getInputValidationProps(),y],stateAttributesMapping:_x})}),bq=C.createContext({disabled:!1});function vq(){return C.useContext(bq)}const wq=C.createContext(void 0);function Sq(e=!0){const t=C.useContext(wq);if(t===void 0&&!e)throw new Error(Gn(3));return t}const Cq=C.forwardRef(function(t,n){return p.jsx(xq,{ref:n,...t})});function Ko({className:e,type:t,...n}){return p.jsx(Cq,{type:t,"data-slot":"input",className:we("h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-2.5 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",e),...n})}function Eq({error:e,isOptional:t,isValidating:n,onBack:r,onSubmit:o,provider:a}){const[l,c]=C.useState("");return p.jsxs("div",{className:"flex flex-1 flex-col gap-6",children:[p.jsx(ui,{children:p.jsxs(fi,{className:"flex items-center gap-2",children:[p.jsx("button",{className:"hover:bg-muted rounded p-0.5 transition-colors",onClick:r,type:"button",children:p.jsx(Fs,{className:"size-5"})}),"Selecting ",a.name]})}),p.jsxs("div",{className:"flex flex-col gap-4",children:[a.apiKeyUrl&&p.jsxs("p",{className:"text-muted-foreground text-sm",children:["Get your API key at"," ",p.jsx("a",{className:"underline hover:text-foreground",href:a.apiKeyUrl,rel:"noopener noreferrer",target:"_blank",children:a.apiKeyUrl})]}),e&&p.jsx("div",{className:"text-destructive bg-destructive/10 rounded-lg px-4 py-2.5 text-sm",children:e}),p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsxs("label",{className:"text-foreground text-sm font-medium",htmlFor:"api-key",children:["Enter your ",a.name," API key"]}),p.jsx(Ko,{id:"api-key",onChange:f=>c(f.target.value),placeholder:"Enter key",type:"password",value:l})]})]}),p.jsxs(Qa,{className:"mt-auto",children:[p.jsx(De,{onClick:r,variant:"secondary",children:"Cancel"}),p.jsx(De,{disabled:!t&&!l.trim()||n,onClick:()=>o(l.trim()),children:n?"Validating...":"Change"})]})]})}function kq({onBack:e,onSelect:t,provider:n}){return p.jsxs("div",{className:"flex flex-1 flex-col gap-6",children:[p.jsx(ui,{children:p.jsxs(fi,{className:"flex items-center gap-2",children:[p.jsx("button",{className:"hover:bg-muted rounded p-0.5 transition-colors",onClick:e,type:"button",children:p.jsx(Fs,{className:"size-5"})}),"Connect ",n.name]})}),p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsxs("button",{className:"hover:bg-muted flex w-full cursor-pointer items-center gap-3 rounded-lg px-3 py-3 text-left transition-colors",onClick:()=>t("oauth"),type:"button",children:[p.jsx(yU,{className:"text-muted-foreground size-5"}),p.jsxs("div",{className:"flex flex-col",children:[p.jsx("span",{className:"text-foreground text-sm font-medium",children:n.oauthLabel??"Sign in with browser"}),p.jsx("span",{className:"text-muted-foreground text-xs",children:"Authenticate via OAuth in your browser"})]})]}),p.jsxs("button",{className:"hover:bg-muted flex w-full cursor-pointer items-center gap-3 rounded-lg px-3 py-3 text-left transition-colors",onClick:()=>t("api-key"),type:"button",children:[p.jsx(vU,{className:"text-muted-foreground size-5"}),p.jsxs("div",{className:"flex flex-col",children:[p.jsx("span",{className:"text-foreground text-sm font-medium",children:"Enter API key"}),p.jsx("span",{className:"text-muted-foreground text-xs",children:"Paste your API key manually"})]})]})]}),p.jsx(Qa,{className:"mt-auto",children:p.jsx(De,{onClick:e,variant:"secondary",children:"Cancel"})})]})}function Tq(e){if(!e)return"Base URL is required";try{const t=new URL(e);return["http:","https:"].includes(t.protocol)?void 0:"URL must start with http:// or https://"}catch{return"Invalid URL format"}}function Aq({error:e,onBack:t,onSubmit:n,provider:r}){const[o,a]=C.useState(""),[l,c]=C.useState(),f=l??e,d=C.useCallback(()=>{const g=o.trim().replace(/\/+$/,""),h=Tq(g);if(h){c(h);return}c(void 0),n(g)},[o,n]);return p.jsxs("div",{className:"flex flex-1 flex-col gap-6",children:[p.jsx(ui,{children:p.jsxs(fi,{className:"flex items-center gap-2",children:[p.jsx("button",{className:"hover:bg-muted rounded p-0.5 transition-colors",onClick:t,type:"button",children:p.jsx(Fs,{className:"size-5"})}),"Selecting ",r.name]})}),p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsx("label",{className:"text-foreground text-sm font-medium",htmlFor:"base-url",children:"Enter endpoint manually"}),p.jsx(Ko,{id:"base-url",onChange:g=>{a(g.target.value),c(void 0)},placeholder:"http://localhost:11434/v1",value:o}),f&&p.jsx("p",{className:"text-destructive text-sm",children:f})]}),p.jsxs(Qa,{className:"mt-auto",children:[p.jsx(De,{onClick:t,variant:"secondary",children:"Cancel"}),p.jsx(De,{disabled:!o.trim(),onClick:d,children:"Change"})]})]})}const w9=()=>{const{apiClient:e}=Be.getState();return e?e.request(_f.START_LOGIN,{skipBrowserLaunch:!0}):Promise.reject(new Error("Not connected"))},S9=e=>{const{apiClient:t}=Be.getState();return t?t.on(_f.LOGIN_COMPLETED,e):()=>{}};function zx(e){try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}const Rq=2500;function Nq({onAuthenticated:e,onBack:t}){const n=cn(),r=ji(f=>f.isAuthorized),o=ji(f=>f.setLoggingIn),[a,l]=C.useState({type:"idle"});C.useEffect(()=>{r&&a.type==="waiting"&&(o(!1),e())},[r,e,o,a.type]),C.useEffect(()=>a.type!=="waiting"?void 0:S9(d=>{d.success&&d.user?n.invalidateQueries({queryKey:so().queryKey}):l({message:d.error??"Authentication failed",type:"error"}),o(!1)}),[n,o,a.type]),C.useEffect(()=>{if(a.type!=="waiting")return;let f=!1;async function d(){try{const h=await n.fetchQuery(so());if(f)return;h.isAuthorized&&(n.invalidateQueries({queryKey:so().queryKey}),o(!1))}catch{}}const g=globalThis.setInterval(d,Rq);return()=>{f=!0,globalThis.clearInterval(g)}},[n,o,a.type]);async function c(){o(!0);const f=window.open("about:blank","_blank");l({type:"starting"});try{const d=await w9();if(!zx(d.authUrl))throw f?.close(),new Error("Received an unsafe OAuth URL from the daemon");f&&!f.closed?f.location.href=d.authUrl:window.open(d.authUrl,"_blank","noopener,noreferrer"),l({authUrl:d.authUrl,type:"waiting"})}catch(d){o(!1),l({message:d instanceof Error?d.message:"Unable to start login",type:"error"})}}return p.jsxs("div",{className:"flex flex-1 flex-col gap-6",children:[p.jsx(ui,{children:p.jsxs(fi,{className:"flex items-center gap-2",children:[p.jsx("button",{className:"hover:bg-muted rounded p-0.5 transition-colors",onClick:t,type:"button",children:p.jsx(Fs,{className:"size-5"})}),"Sign in to ByteRover"]})}),p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("p",{className:"text-muted-foreground text-sm",children:["ByteRover requires authentication before it can be used as a provider. Sign in to your"," ",p.jsx("span",{className:"text-foreground",children:"byterover.dev"})," account to continue."]}),a.type==="starting"&&p.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-blue-500/20 bg-blue-500/5 p-3 text-sm text-blue-700",children:[p.jsx(ai,{className:"size-4 animate-spin"}),"Starting authentication…"]}),a.type==="waiting"&&p.jsxs("div",{className:"flex flex-col gap-1 rounded-lg border bg-card p-3",children:[p.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[p.jsx(ai,{className:"text-primary size-4 animate-spin"}),"Finish signing in in the new tab."]}),p.jsxs("div",{className:"text-muted-foreground pl-6 text-xs",children:["If the tab didn’t open,"," ",p.jsx("a",{className:"underline underline-offset-2",href:a.authUrl,rel:"noopener noreferrer",target:"_blank",children:"click this link"}),"."]})]}),a.type==="error"&&p.jsx("div",{className:"text-destructive bg-destructive/10 rounded-lg px-4 py-2.5 text-sm",children:a.message})]}),p.jsxs(Qa,{className:"mt-auto",children:[p.jsx(De,{onClick:t,variant:"secondary",children:"Cancel"}),a.type==="error"?p.jsx(De,{onClick:()=>l({type:"idle"}),children:"Try again"}):p.jsx(De,{disabled:a.type==="starting"||a.type==="waiting",onClick:c,children:a.type==="waiting"?"Waiting…":"Sign in"})]})]})}const Oq=({providerId:e})=>{const{apiClient:t}=Be.getState();return t?t.request(qT.LIST,{providerId:e}):Promise.reject(new Error("Not connected"))},jq=e=>({queryFn:()=>Oq({providerId:e}),queryKey:["models",e]}),C9=({providerId:e,queryConfig:t})=>br({...jq(e),...t});function Mq({onBack:e,onSelect:t,providerId:n}){const[r,o]=C.useState(""),{data:a,isLoading:l}=C9({providerId:n}),[c,f]=C.useState(),d=C.useMemo(()=>a?.models??[],[a?.models]);C.useEffect(()=>{a?.activeModel&&!c&&f(a.activeModel)},[a?.activeModel,c]);const g=C.useMemo(()=>{if(!r)return d;const y=r.toLowerCase();return d.filter(x=>x.name.toLowerCase().includes(y)||x.id.toLowerCase().includes(y))},[d,r]),h=C.useMemo(()=>d.find(y=>y.id===c),[d,c]);return l?p.jsxs("div",{className:"flex flex-1 flex-col gap-6",children:[p.jsx(ui,{children:p.jsxs(fi,{className:"flex items-center gap-2",children:[p.jsx("button",{className:"hover:bg-muted rounded p-0.5 transition-colors",onClick:e,type:"button",children:p.jsx(Fs,{className:"size-5"})}),"Choose model"]})}),p.jsx("div",{className:"flex items-center justify-center py-12",children:p.jsx(ai,{className:"text-muted-foreground size-5 animate-spin"})})]}):p.jsxs("div",{className:"flex flex-1 flex-col gap-6",children:[p.jsx(ui,{children:p.jsxs(fi,{className:"flex items-center gap-2",children:[p.jsx("button",{className:"hover:bg-muted rounded p-0.5 transition-colors",onClick:e,type:"button",children:p.jsx(Fs,{className:"size-5"})}),"Choose model"]})}),p.jsxs("div",{className:"flex flex-col gap-3",children:[p.jsxs("div",{className:"relative",children:[p.jsx(vc,{className:"text-muted-foreground absolute top-1/2 left-3 size-4 -translate-y-1/2"}),p.jsx(Ko,{className:"pl-9",onChange:y=>o(y.target.value),placeholder:"Search...",value:r})]}),p.jsxs("div",{className:"max-h-96 overflow-y-auto",children:[g.map(y=>{const x=y.id===c;return p.jsxs("button",{className:`border-border flex w-full cursor-pointer items-center justify-between border-b px-3 py-2.5 text-left transition-colors last:border-b-0 ${x?"bg-primary/10":"hover:bg-muted"}`,onClick:()=>f(y.id),type:"button",children:[p.jsx("span",{className:"text-foreground text-sm",children:y.name}),x&&p.jsx(Ys,{className:"text-primary size-4"})]},y.id)}),g.length===0&&p.jsx("p",{className:"text-muted-foreground py-8 text-center text-sm",children:"No models found"})]})]}),p.jsxs(Qa,{className:"mt-auto",children:[p.jsx(De,{onClick:e,variant:"secondary",children:"Cancel"}),p.jsx(De,{disabled:!h,onClick:()=>h&&t(h),children:"Confirm"})]})]})}function Lq({error:e,onAction:t,onBack:n,provider:r}){const{data:o}=C9({providerId:r.id}),a=o?.activeModel,l=r.id==="byterover";return p.jsxs("div",{className:"flex flex-1 flex-col gap-6",children:[p.jsx(ui,{children:p.jsxs(fi,{className:"flex items-center gap-2",children:[p.jsx("button",{className:"hover:bg-muted rounded p-0.5 transition-colors",onClick:n,type:"button",children:p.jsx(Fs,{className:"size-5"})}),r.name]})}),p.jsxs("div",{className:"flex flex-col gap-4",children:[e&&p.jsx("div",{className:"text-destructive bg-destructive/10 rounded-lg px-4 py-2.5 text-sm",children:e}),l?p.jsxs("div",{className:"flex items-start justify-between",children:[p.jsxs("div",{className:"flex flex-col gap-1",children:[p.jsx("span",{className:"text-foreground text-sm font-medium",children:"Status"}),p.jsx("span",{className:"text-muted-foreground text-sm",children:r.isConnected?"Connected":"Not connected"})]}),r.isConnected&&p.jsx(De,{onClick:()=>t("disconnect"),size:"sm",variant:"outline",children:"Disconnect"})]}):p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex items-start justify-between",children:[p.jsxs("div",{className:"flex flex-col gap-1",children:[p.jsx("span",{className:"text-foreground text-sm font-medium",children:"Model"}),p.jsx("span",{className:"text-muted-foreground text-sm",children:a??"Not selected"})]}),p.jsx(De,{onClick:()=>t("change_model"),size:"sm",variant:"outline",children:"Change"})]}),p.jsxs("div",{className:"flex items-start justify-between",children:[p.jsxs("div",{className:"flex flex-col gap-1",children:[p.jsx("span",{className:"text-foreground text-sm font-medium",children:r.authMethod==="oauth"?"OAuth":"API Key"}),p.jsx("span",{className:"text-muted-foreground text-sm",children:r.authMethod==="oauth"?"Authenticated via browser":"****************"})]}),p.jsx(De,{onClick:()=>t("disconnect"),size:"sm",variant:"outline",children:"Disconnect"})]})]})]}),!r.isCurrent&&p.jsxs(Qa,{className:"mt-auto",children:[p.jsx(De,{onClick:n,variant:"secondary",children:"Cancel"}),p.jsx(De,{onClick:()=>t("activate"),children:"Active"})]})]})}const _q="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4.53096%2012.97L8.07285%2010.9839L8.13242%2010.8115L8.07285%2010.7155H7.90026L7.30833%2010.679L5.28456%2010.6244L3.5294%2010.5515L1.82897%2010.4604L1.4011%2010.3693L1%209.84087L1.04132%209.57726L1.40112%209.33553L1.91647%209.38047L3.05537%209.45823L4.76433%209.57605L6.00411%209.64894L7.8407%209.83964H8.13242L8.17374%209.72182L8.07407%209.64894L7.99629%209.57605L6.22776%208.37831L4.31339%207.11255L3.31063%206.38372L2.76851%206.01443L2.49504%205.66823L2.37713%204.91268L2.86941%204.3709L3.53062%204.41585L3.69958%204.46079L4.3693%204.97583L5.79991%206.08247L7.66811%207.45754L7.94158%207.68469L8.05098%207.60696L8.06435%207.55229L7.94158%207.34701L6.92544%205.51154L5.84125%203.64449L5.35869%202.8707L5.23107%202.40667C5.1861%202.21595%205.15329%202.05561%205.15329%201.86003L5.71361%201.09961L6.02356%201L6.77108%201.09961L7.0859%201.37293L7.55021%202.43462L8.30258%204.10609L9.46944%206.37885L9.81099%207.05303L9.9933%207.67741L10.0614%207.86813H10.1793V7.75881L10.2753%206.47848L10.4528%204.9066L10.6254%202.88406L10.6849%202.31435L10.9669%201.63166L11.5272%201.2624L11.9648%201.47133L12.3246%201.98638L12.2748%202.31922L12.0608%203.70888L11.6415%205.8857L11.368%207.34338H11.5272L11.7095%207.16118L12.4474%206.18209L13.6871%204.6333L14.2341%204.01864L14.8722%203.3396L15.2818%203.01648H16.0561L16.6262%203.86316L16.3709%204.73776L15.5736%205.74843L14.9123%206.60483L13.9643%207.88029L13.3723%208.90067L13.427%208.98206L13.568%208.96869L15.7097%208.51317L16.8668%208.30424L18.2476%208.06736L18.8724%208.3589L18.9404%208.65528L18.6949%209.26145L17.2181%209.62586L15.4861%209.97207L12.9068%2010.5819L12.8752%2010.605L12.9117%2010.6499L14.0737%2010.7592L14.5708%2010.7859H15.7875L18.0531%2010.9548L18.6451%2011.3459L19%2011.8246L18.9404%2012.189L18.0288%2012.653L16.7988%2012.3614L13.9278%2011.6788L12.9433%2011.4334H12.8072V11.5148L13.6276%2012.3165L15.1311%2013.6734L17.0139%2015.4226L17.1099%2015.855L16.8681%2016.1964L16.6128%2016.1599L14.9585%2014.9161L14.3204%2014.3561L12.8752%2013.1401H12.7792V13.2676L13.1122%2013.7548L14.871%2016.3968L14.9622%2017.2071L14.8346%2017.4706L14.3788%2017.6298L13.878%2017.5387L12.8485%2016.0944L11.7861%2014.4678L10.9292%2013.0101L10.8247%2013.0697L10.3191%2018.5129L10.0821%2018.7911L9.53507%2019L9.07927%2018.6538L8.83739%2018.0938L9.07927%2016.9872L9.37099%2015.5429L9.608%2014.3949L9.82193%2012.9688L9.94955%2012.4951L9.94105%2012.4635L9.83651%2012.4769L8.76081%2013.9528L7.12479%2016.1624L5.83031%2017.5472L5.52036%2017.6699L4.98312%2017.3917L5.03294%2016.8949L5.33317%2016.4527L7.12479%2014.1751L8.20535%2012.7635L8.90303%2011.9485L8.89817%2011.8306H8.85684L4.09825%2014.9185L3.25106%2015.0278L2.88643%2014.6865L2.9314%2014.1265L3.10398%2013.9443L4.5346%2012.9603L4.52974%2012.9652L4.53096%2012.97Z'%20fill='%23D4D4D4'/%3e%3c/svg%3e",Dq="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M10%2020C15.5228%2020%2020%2015.5228%2020%2010C20%204.47715%2015.5228%200%2010%200C4.47715%200%200%204.47715%200%2010C0%2015.5228%204.47715%2020%2010%2020Z'%20fill='black'/%3e%3cpath%20d='M10.001%2019.002C14.9715%2019.002%2019.001%2014.9725%2019.001%2010.002C19.001%205.03139%2014.9715%201.00195%2010.001%201.00195C5.03042%201.00195%201.00098%205.03139%201.00098%2010.002C1.00098%2014.9725%205.03042%2019.002%2010.001%2019.002Z'%20fill='%23FAFAFA'/%3e%3cpath%20d='M9.99951%2017.998C14.4178%2017.998%2017.9995%2014.4163%2017.9995%209.99805C17.9995%205.57977%2014.4178%201.99805%209.99951%201.99805C5.58123%201.99805%201.99951%205.57977%201.99951%209.99805C1.99951%2014.4163%205.58123%2017.998%209.99951%2017.998Z'%20fill='black'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M3.31787%209.29102C3.31787%209.29102%2018.082%209.72982%2016.6512%2015.291C15.9389%2016.4198%2015.8512%2015.691%2015.8512%2015.691C15.8512%2015.691%2018.2852%2011.1457%203.31787%209.29102Z'%20fill='%23FAFAFA'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M5.27588%205.86523C5.27588%205.86523%2020.04%206.30403%2018.6092%2011.8652C17.8969%2012.994%2017.8092%2012.2652%2017.8092%2012.2652C17.8092%2012.2652%2020.2432%207.7199%205.27588%205.86523Z'%20fill='%23FAFAFA'/%3e%3cpath%20d='M8.72058%203.59961C8.75064%203.60051%2016.4092%203.83385%2017.83%206.39648L17.3895%206.91504C16.922%205.87794%2015.0863%204.38843%208.72058%203.59961Z'%20fill='%23FAFAFA'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M5.45898%2013.9904C5.48859%2013.9908%2013.7293%2014.1055%2013.9676%2017.2002L13.4287%2017.5307C13.2582%2016.5898%2011.9628%2014.9484%205.45898%2013.9904Z'%20fill='%23FAFAFA'/%3e%3c/svg%3e",Iq="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M11.7675%202.25036C9.71229%202.25036%207.74126%203.06679%206.28801%204.52004C4.83476%205.97329%204.01833%207.94432%204.01833%209.99953C4.01833%2012.0547%204.83476%2014.0258%206.28801%2015.479C7.74126%2016.9323%209.71229%2017.7487%2011.7675%2017.7487V18.9162C6.8425%2018.9162%202.85083%2014.9237%202.85083%209.9987C2.85083%205.0737%206.84166%201.08203%2011.7667%201.08203V2.24953L11.7675%202.25036ZM15.7275%205.31453C15.1118%204.79188%2014.3989%204.3961%2013.6297%204.14994C12.8605%203.90378%2012.0503%203.8121%2011.2455%203.88018C10.4408%203.94825%209.65746%204.17474%208.94056%204.54661C8.22366%204.91848%207.58735%205.42841%207.06821%206.04706C6.54907%206.6657%206.15735%207.38088%205.91557%208.15144C5.6738%208.92201%205.58673%209.73277%205.65938%2010.5371C5.73204%2011.3414%205.96298%2012.1235%206.33892%2012.8382C6.71487%2013.553%207.2284%2014.1864%207.85%2014.702L7.09916%2015.597C6.36511%2014.9813%205.75953%2014.227%205.31702%2013.3772C4.87452%2012.5274%204.60374%2011.5987%204.52017%2010.6443C4.43659%209.68983%204.54185%208.72826%204.82994%207.81448C5.11802%206.90071%205.58329%206.05264%206.19916%205.3187C6.81497%204.58461%207.56935%203.97902%208.41922%203.5365C9.26909%203.09398%2010.1978%202.8232%2011.1523%202.73963C12.1069%202.65606%2013.0685%202.76132%2013.9823%203.04942C14.8962%203.33752%2015.7443%203.8028%2016.4783%204.4187L15.7275%205.31453ZM13.8483%206.01786C12.7928%205.47266%2011.5646%205.36641%2010.4311%205.72223C9.29756%206.07806%208.35044%206.86716%207.79583%207.91781C7.24123%208.96847%207.12401%2010.1956%207.4697%2011.3323C7.81539%2012.4689%208.596%2013.4231%209.64166%2013.987L9.095%2015.0204C7.7889%2014.3042%206.81675%2013.1032%206.38832%2011.6766C5.95989%2010.25%206.10954%208.7121%206.80498%207.39485C7.50041%206.07759%208.68587%205.08657%2010.1055%204.63564C11.5252%204.1847%2013.0652%204.31001%2014.3933%204.98453L13.8483%206.01786ZM11.7667%207.11536C11.0017%207.11536%2010.2681%207.41923%209.72725%207.96012C9.18636%208.501%208.8825%209.2346%208.8825%209.99953C8.8825%2010.7645%209.18636%2011.4981%209.72725%2012.0389C10.2681%2012.5798%2011.0017%2012.8837%2011.7667%2012.8837V14.052C10.6919%2014.052%209.6611%2013.6251%208.90111%2012.8651C8.14112%2012.1051%207.71416%2011.0743%207.71416%209.99953C7.71416%208.92474%208.14112%207.89397%208.90111%207.13398C9.6611%206.37399%2010.6919%205.94703%2011.7667%205.94703V7.11536Z'%20fill='%23D4D4D4'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M12.8392%209.03094C12.715%208.89716%2012.5718%208.78232%2012.4142%208.69011C12.277%208.60856%2012.1205%208.56486%2011.9609%208.56344C11.7484%208.56344%2011.5584%208.60261%2011.3909%208.68011C11.229%208.75304%2011.0835%208.85797%2010.9632%208.98857C10.8429%209.11918%2010.7503%209.27277%2010.6909%209.44011C10.6292%209.60927%2010.5992%209.78677%2010.5992%209.96594C10.5992%2010.1476%2010.6292%2010.3243%2010.6909%2010.4918C10.7508%2010.6589%2010.8436%2010.8124%2010.9638%2010.9431C11.0841%2011.0738%2011.2293%2011.179%2011.3909%2011.2526C11.5576%2011.3301%2011.7492%2011.3693%2011.9609%2011.3693C12.1409%2011.3693%2012.3084%2011.3309%2012.4626%2011.2568C12.6192%2011.1818%2012.7542%2011.0693%2012.8584%2010.9301L13.6317%2011.7684C13.5151%2011.8851%2013.3817%2011.9859%2013.2301%2012.0709C12.9496%2012.2274%2012.6443%2012.3345%2012.3276%2012.3876C12.1859%2012.4093%2012.0634%2012.4209%2011.9609%2012.4209C11.6246%2012.423%2011.2908%2012.3637%2010.9759%2012.2459C10.6781%2012.1358%2010.4057%2011.9666%2010.1751%2011.7484C9.94568%2011.5293%209.76311%2011.2659%209.63839%2010.9743C9.50286%2010.6556%209.43531%2010.3122%209.44005%209.96594C9.44005%209.59594%209.50672%209.26011%209.63839%208.95761C9.76339%208.66594%209.94505%208.40261%2010.1742%208.18344C10.4059%207.96594%2010.6784%207.79677%2010.9759%207.68677C11.2908%207.56898%2011.6246%207.50967%2011.9609%207.51177C12.2567%207.51177%2012.5542%207.56844%2012.8542%207.68177C13.1551%207.79677%2013.4251%207.98177%2013.6409%208.22261L12.8392%209.03094Z'%20fill='%23D4D4D4'/%3e%3c/svg%3e",zq="data:image/svg+xml,%3csvg%20width='154'%20height='154'%20viewBox='0%200%20154%20154'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmask%20id='mask0_2024_36638'%20style='mask-type:luminance'%20maskUnits='userSpaceOnUse'%20x='0'%20y='0'%20width='155'%20height='155'%3e%3cpath%20d='M0%200H154.006V154.006H0V0Z'%20fill='white'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_2024_36638)'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M49.8953%2091.6962C54.0408%2091.6962%2062.2864%2091.4688%2073.6847%2086.7762C86.9655%2081.308%20113.39%2071.381%20132.453%2061.1848C145.784%2054.0535%20151.628%2044.621%20151.628%2031.9191C151.628%2014.2909%20137.337%200%20119.709%200H45.8476C20.5281%200%200%2020.5272%200%2045.8485C0%2071.169%2019.2191%2091.6962%2049.8953%2091.6962Z'%20fill='white'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M62.3879%20123.269C62.388%20117.199%2064.1868%20111.266%2067.5572%20106.218C70.9276%20101.17%2075.7184%2097.2344%2081.3244%2094.908L104.585%2085.2545C128.112%2075.4896%20154.009%2092.78%20154.009%20118.254C154.009%20137.99%20138.007%20153.987%20118.27%20153.982L93.0868%20153.976C76.1307%20153.971%2062.3879%20140.225%2062.3879%20123.269Z'%20fill='white'/%3e%3cpath%20d='M26.4302%2097.7402C11.8322%2097.7402%200%20109.572%200%20124.17V127.593C0%20142.189%2011.8331%20154.022%2026.4293%20154.022C41.0263%20154.022%2052.8595%20142.189%2052.8595%20127.593V124.17C52.8595%20109.572%2041.0263%2097.7402%2026.4302%2097.7402Z'%20fill='white'/%3e%3c/g%3e%3c/svg%3e",Pq="/assets/deepinfra-provider-C9hH_wkN.svg",Fq="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M17.05%209.04649C15.6632%208.44953%2014.4499%207.63057%2013.4094%206.59059C12.3695%205.55064%2011.5505%204.33675%2010.9535%202.94998C10.7243%202.4185%2010.5402%201.87217%2010.399%201.31204C10.353%201.12891%2010.1888%201%2010%201C9.81124%201%209.64703%201.12891%209.60102%201.31204C9.45981%201.87217%209.27566%202.41798%209.04649%202.94998C8.44953%204.33675%207.63057%205.55064%206.59059%206.59059C5.55064%207.63057%204.33675%208.44953%202.94998%209.04649C2.41849%209.27566%201.87217%209.4598%201.31204%209.60102C1.12891%209.64703%201%209.81124%201%2010C1%2010.1888%201.12891%2010.353%201.31204%2010.399C1.87217%2010.5402%202.41798%2010.7243%202.94998%2010.9535C4.33675%2011.5505%205.55014%2012.3695%206.59059%2013.4094C7.63107%2014.4494%208.44953%2015.6632%209.04649%2017.05C9.27566%2017.5815%209.45981%2018.1278%209.60102%2018.688C9.64703%2018.8711%209.81124%2019%2010%2019C10.1888%2019%2010.353%2018.8711%2010.399%2018.688C10.5402%2018.1278%2010.7243%2017.582%2010.9535%2017.05C11.5505%2015.6632%2012.3695%2014.4499%2013.4094%2013.4094C14.4494%2012.3695%2015.6632%2011.5505%2017.05%2010.9535C17.5815%2010.7243%2018.1278%2010.5402%2018.688%2010.399C18.8711%2010.353%2019%2010.1888%2019%2010C19%209.81124%2018.8711%209.64703%2018.688%209.60102C18.1278%209.4598%2017.582%209.27566%2017.05%209.04649Z'%20fill='%23D4D4D4'/%3e%3c/svg%3e",Bq="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M10.03%201.66627C6.81913%201.6371%204.19663%204.16627%204.16663%207.3171C4.13746%2010.4688%206.71246%2013.0438%209.92329%2013.0729H11.94V10.9346H10.03C8.02413%2010.9579%206.37996%209.3796%206.35663%207.4096C6.33246%205.44127%207.94079%203.82793%209.94663%203.8046H10.03C12.0358%203.8046%2013.6616%205.40043%2013.6675%207.3696V12.6238C13.6675%2014.5754%2012.0475%2016.1654%2010.065%2016.1896C9.11901%2016.1829%208.2127%2015.8088%207.53746%2015.1463L5.99496%2016.6613C7.07129%2017.7186%208.51543%2018.3177%2010.0241%2018.3329H10.1008C13.27%2018.2863%2015.8158%2015.7638%2015.8333%2012.6529V7.23627C15.7558%204.13543%2013.1808%201.66627%2010.03%201.66627Z'%20fill='%23D4D4D4'/%3e%3c/svg%3e",Hq="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M18.205%200C18.63%200%2019.0377%200.168834%2019.3382%200.469361C19.6387%200.769888%2019.8075%201.17749%2019.8075%201.6025C19.8075%202.02751%2019.6387%202.43511%2019.3382%202.73564C19.0377%203.03617%2018.63%203.205%2018.205%203.205H16.7917C16.7669%203.20511%2016.7423%203.20032%2016.7194%203.1909C16.6964%203.18149%2016.6756%203.16763%2016.658%203.15013C16.6404%203.13263%2016.6265%203.11184%2016.617%203.08893C16.6074%203.06603%2016.6025%203.04147%2016.6025%203.01667V1.6025C16.6025%200.7175%2017.32%200%2018.205%200Z'%20fill='%23D4D4D4'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M9.22083%209.3319L15.2683%203.3319C15.3825%203.21857%2015.3183%202.99023%2015.1717%202.99023H11.9167C11.8984%202.99044%2011.8804%202.99431%2011.8636%203.00161C11.8469%203.00891%2011.8318%203.01949%2011.8192%203.03273L5.3025%209.49607C5.20083%209.59607%205.05083%209.5069%205.05083%209.3469V3.18273C5.05083%203.0769%204.98167%202.99107%204.89667%202.99107H2.655C2.56917%202.99107%202.5%203.0769%202.5%203.18273V16.4744C2.5%2016.5811%202.56917%2016.6661%202.655%2016.6661H4.89667C4.9825%2016.6661%205.05167%2016.5811%205.05167%2016.4744V13.7661C5.05167%2013.7086%205.0725%2013.6536%205.10917%2013.6177L7.12917%2011.6127C7.15062%2011.5896%207.17967%2011.5749%207.21102%2011.5714C7.24238%2011.5679%207.27395%2011.5758%207.3%2011.5936L12.7033%2015.5702C13.5615%2016.1549%2014.5491%2016.5218%2015.5808%2016.6394C15.6708%2016.6494%2015.7475%2016.5602%2015.7475%2016.4477V13.8977C15.7475%2013.8002%2015.6892%2013.7211%2015.6108%2013.7086C15.0053%2013.6107%2014.4287%2013.3812%2013.9217%2013.0361L9.24417%209.6494C9.14667%209.5844%209.13417%209.4169%209.22083%209.3319Z'%20fill='%23D4D4D4'/%3e%3c/svg%3e",Uq="/assets/minimax-provider-BqW25BvT.svg",qq="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M2.85667%202.83398H5.71417V5.69065H8.57167V8.54815H8.57H11.4292V5.69065H14.285V2.83398H17.1433V14.2623H20V17.1198H11.4283V14.2632H8.57167V11.4057H5.71333V14.2623L8.57167%2014.2632V17.1198H0V14.2623H2.85667V2.83398ZM11.4283%2014.2632H14.285V11.4057H11.4292V14.2632H11.4283Z'%20fill='%23D4D4D4'/%3e%3c/svg%3e",kC="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M17.813%208.3673C18.2269%207.14159%2018.0844%205.79887%2017.4226%204.68397C16.4272%202.97394%2014.4263%202.09417%2012.4721%202.50818C11.6027%201.54178%2010.3537%200.992208%209.04425%201.00008C7.04673%200.995583%205.27439%202.26461%204.65985%204.14003C3.37663%204.39934%202.26898%205.19192%201.62082%206.31526C0.618065%208.0208%200.846663%2010.1707%202.18632%2011.6332C1.77245%2012.859%201.91497%2014.2017%202.57682%2015.3166C3.57216%2017.0266%205.5731%2017.9064%207.5273%2017.4924C8.39608%2018.4588%209.64567%2019.0083%2010.9551%2018.9999C12.9538%2019.005%2014.7267%2017.7348%2015.3412%2015.8577C16.6245%2015.5984%2017.7321%2014.8058%2018.3803%2013.6825C19.3819%2011.9769%2019.1527%209.82871%2017.8136%208.36618L17.813%208.3673ZM10.9563%2017.8237C10.1565%2017.8248%209.38173%2017.5486%208.76777%2017.0429C8.7957%2017.0283%208.84416%2017.0019%208.87551%2016.9827L12.508%2014.9127C12.6938%2014.8086%2012.8078%2014.6134%2012.8067%2014.4025V9.34945L14.3419%2010.2242C14.3584%2010.232%2014.3693%2010.2478%2014.3715%2010.2658V14.4503C14.3693%2016.3111%2012.8421%2017.8198%2010.9563%2017.8237ZM3.6115%2014.7282C3.21074%2014.0453%203.06651%2013.2448%203.2039%2012.468C3.23069%2012.4838%203.27801%2012.5125%203.31164%2012.5316L6.94412%2014.6016C7.12825%2014.7079%207.35628%2014.7079%207.54098%2014.6016L11.9755%2012.0748V13.8242C11.9767%2013.8422%2011.9681%2013.8597%2011.9539%2013.8709L8.28207%2015.9629C6.64654%2016.8922%204.55781%2016.3398%203.61207%2014.7282H3.6115ZM2.65549%206.90421C3.05454%206.2202%203.68447%205.69706%204.43468%205.42537C4.43468%205.4563%204.43297%205.51087%204.43297%205.54912V9.68977C4.43183%209.90015%204.54584%2010.0953%204.73111%2010.1994L9.16568%2012.7256L7.63048%2013.6004C7.61509%2013.6105%207.59571%2013.6122%207.57861%2013.6049L3.90622%2011.5112C2.27412%2010.5785%201.71431%208.51806%202.65492%206.90477L2.65549%206.90421ZM15.2688%209.80058L10.8343%207.27378L12.3695%206.39964C12.3849%206.38951%2012.4042%206.38782%2012.4213%206.39514L16.0937%208.48712C17.7287%209.4192%2018.2891%2011.4831%2017.3445%2013.0963C16.9448%2013.7792%2016.3155%2014.3024%2015.5658%2014.5746V10.3102C15.5675%2010.0998%2015.4541%209.90521%2015.2694%209.80058H15.2688ZM16.7966%207.53141C16.7698%207.5151%2016.7225%207.48697%2016.6889%207.46785L13.0564%205.3978C12.8723%205.29149%2012.6442%205.29149%2012.4595%205.3978L8.02497%207.92461V6.17519C8.02383%206.15719%208.03238%206.13976%208.04663%206.12851L11.7184%204.03821C13.354%203.10725%2015.445%203.66133%2016.3879%205.27574C16.7864%205.9575%2016.9306%206.75571%2016.7955%207.53141H16.7966ZM7.19039%2010.6494L5.65462%209.77471C5.63809%209.76683%205.62726%209.75108%205.62498%209.73308V5.54856C5.62612%203.68552%207.1579%202.17573%209.04596%202.17686C9.84463%202.17686%2010.6176%202.45361%2011.2316%202.95763C11.2037%202.97225%2011.1558%202.99869%2011.1239%203.01781L7.49138%205.08786C7.30554%205.19192%207.19153%205.38655%207.19267%205.59749L7.19039%2010.6483V10.6494ZM8.0244%208.87525L9.99969%207.74967L11.975%208.87469V11.1253L9.99969%2012.2503L8.0244%2011.1253V8.87525Z'%20fill='%23D4D4D4'/%3e%3c/svg%3e",Vq="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmask%20id='mask0_1940_35557'%20style='mask-type:luminance'%20maskUnits='userSpaceOnUse'%20x='2'%20y='2'%20width='16'%20height='16'%3e%3cpath%20d='M2%202H18V18H2V2Z'%20fill='white'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_1940_35557)'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M13.2027%203.30472L18.016%206.04138V6.09938L13.1533%208.80669L13.1647%207.39538L12.6173%207.37538C11.9113%207.35669%2011.5433%207.37669%2011.1053%207.44869C10.396%207.56538%209.74666%207.83337%209.00734%208.35003L7.56334%209.35338C7.374%209.48338%207.23334%209.57738%207.11%209.65669L6.76666%209.87138L6.502%2010.0274L6.75866%2010.1807L7.112%2010.406C7.42934%2010.6154%207.892%2010.9367%208.91266%2011.65C9.65266%2012.1667%2010.3013%2012.4347%2011.0107%2012.5514L11.2107%2012.5814C11.6733%2012.642%2012.1273%2012.644%2013.094%2012.6034L13.1087%2011.164L17.922%2013.9007V13.9587L13.0593%2016.6667L13.0687%2015.4254L12.6453%2015.44C11.7213%2015.468%2011.2207%2015.4414%2010.5533%2015.332C9.424%2015.1454%208.38%2014.7147%207.29934%2013.9594L5.86066%2012.9594C5.69519%2012.8453%205.52738%2012.7346%205.35734%2012.6274L5.046%2012.4407C4.87788%2012.3438%204.70897%2012.2483%204.53934%2012.154C3.93866%2011.82%202.37531%2011.4107%202%2011.4107V8.59203L2.09334%208.59469C2.46934%208.59003%204.03334%208.18003%204.63266%207.84538L5.31%207.45869L5.602%207.27603C5.88734%207.08938%206.31666%206.79203%207.39266%206.04069C8.47334%205.28537%209.51666%204.85403%2010.6467%204.66803C11.4147%204.54138%2011.9627%204.52603%2013.1893%204.57603L13.2027%203.30472Z'%20fill='%23D4D4D4'/%3e%3c/g%3e%3c/svg%3e",$q="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M16.4875%200V6.06H18.75V14.6833H16.3042V20L10.44%2014.8383V19.9592H9.53083V14.8325L3.66%2020V14.6125H1.25V5.99H3.65333V0L9.53083%205.41167V0.158333H10.4392V5.56667L16.4875%200ZM10.44%207.53667V13.6358L15.395%2017.9975V12.0333L10.44%207.53667ZM9.52417%207.47L4.56917%2011.9683V17.9975L9.52417%2013.6358V7.47083V7.47ZM16.3042%2013.7867H17.8408V6.9575H11.2167L16.3042%2011.5742V13.7867ZM8.81917%206.88667H2.15833V13.7158H3.65833V11.5692L8.81833%206.88583L8.81917%206.88667ZM4.5625%202.06333V5.98833H8.825L4.5625%202.06333ZM15.5783%202.06333L11.3158%205.98833H15.5783V2.06333Z'%20fill='%23D4D4D4'/%3e%3c/svg%3e",Gq="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_1940_35595)'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M19.3308%203.75216C19.0025%203.18344%2018.5654%202.68496%2018.0444%202.28519C17.5234%201.88543%2016.9288%201.5922%2016.2945%201.42227C15.6601%201.25233%2014.9986%201.20901%2014.3475%201.29479C13.6964%201.38056%2013.0686%201.59374%2012.5%201.92216C11.7706%202.34073%2011.1591%202.93729%2010.7227%203.65615C10.2862%204.37502%2010.039%205.19274%2010.0042%206.033L15.0008%206.03966V6.46883H10.0042C10.0367%207.24966%2010.2525%208.02716%2010.6708%208.75216C10.9925%209.33338%2011.4267%209.84468%2011.9482%2010.2562C12.4696%2010.6677%2013.0679%2010.9712%2013.708%2011.1489C14.348%2011.3266%2015.0171%2011.375%2015.6761%2011.2912C16.3351%2011.2075%2016.9707%2010.9932%2017.546%2010.661C18.1213%2010.3288%2018.6245%209.88533%2019.0265%209.35644C19.4284%208.82755%2019.7209%208.22387%2019.8869%207.58067C20.0529%206.93746%2020.0891%206.26762%2019.9934%205.61028C19.8976%204.95293%2019.6718%204.32126%2019.3292%203.75216H19.3308Z'%20fill='%23D4D4D4'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M0.670785%203.74946C0.342331%204.31807%200.129098%204.94582%200.0432647%205.59684C-0.042569%206.24787%200.00067736%206.90943%200.170534%207.54374C0.340391%208.17806%200.633531%208.7727%201.03322%209.29371C1.4329%209.81473%201.9313%2010.2519%202.49995%2010.5803C3.22718%2011.0028%204.04963%2011.2341%204.89049%2011.2526C5.73134%2011.2711%206.56317%2011.0762%207.30829%2010.6861L4.81579%206.35529L5.18745%206.14113L7.68495%2010.4678C8.32417%2010.0608%208.86254%209.51393%209.25936%208.86837C9.65619%208.22281%209.90109%207.4955%209.97556%206.7414C10.05%205.9873%209.95213%205.22614%209.68925%204.51543C9.42637%203.80472%209.00539%203.16306%208.45812%202.63893C7.91085%202.11481%207.25161%201.72193%206.53021%201.48999C5.80881%201.25804%205.04413%201.1931%204.29395%201.30007C3.54377%201.40704%202.82771%201.68312%202.1999%202.10745C1.57208%202.53178%201.04975%203.09326%200.670785%203.74946Z'%20fill='%23D4D4D4'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M9.99996%2019.9121C11.3259%2019.9119%2012.5975%2019.385%2013.535%2018.4473C14.4725%2017.5097%2014.9991%2016.238%2014.9991%2014.9121C14.9991%2013.1371%2014.0825%2011.5821%2012.6866%2010.6954L10.1825%2015.0196L9.81246%2014.8046L12.31%2010.4779C11.6379%2010.1278%2010.895%209.93492%2010.1375%209.91401C9.37993%209.8931%208.62755%2010.0447%207.93719%2010.3572C7.24683%2010.6698%206.63655%2011.1352%206.15248%2011.7183C5.66841%2012.3014%205.32321%2012.9869%205.14298%2013.723C4.96274%2014.459%204.95219%2015.2265%205.11211%2015.9672C5.27203%2016.708%205.59824%2017.4027%206.06609%2017.9989C6.53394%2018.5951%207.13119%2019.0771%207.8127%2019.4085C8.4942%2019.74%209.24213%2019.9122%209.99996%2019.9121Z'%20fill='%23D4D4D4'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_1940_35595'%3e%3crect%20width='20'%20height='20'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",Yq="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M10%203L18%2017H2L10%203Z'%20fill='%23D4D4D4'/%3e%3c/svg%3e",Wq="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M6.1283%207.65527L13.1584%2018H10.0336L3.0035%207.65527H6.1283ZM6.1255%2013.4007L7.6886%2015.7018L6.1269%2018H3L6.1255%2013.4007ZM17%203.15055V18H14.4387V6.91927L17%203.15055ZM17%202L10.0336%2012.2509L8.4705%209.95055L13.8731%202H17Z'%20fill='%23D4D4D4'/%3e%3c/svg%3e",Kq="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M10.5744%203L9.03162%205.0671H2.46254L4.00458%203H10.5751H10.5744ZM18.4716%2014.9336L16.9302%2017H10.3838L11.9237%2014.9336H18.4716ZM19%203L8.562%2017H2L12.438%203H19Z'%20fill='%23D4D4D4'/%3e%3c/svg%3e",Qq={anthropic:_q,byterover:Dq,cerebras:Iq,cohere:zq,deepinfra:Pq,glm:Kq,google:Fq,groq:Bq,minimax:Uq,mistral:qq,moonshot:Hq,openai:kC,"openai-compatible":kC,openrouter:Vq,perplexity:$q,togetherai:Gq,vercel:Yq,xai:Wq};function Xq({onSelect:e,providers:t}){const[n,r]=C.useState(""),o=C.useMemo(()=>{if(!n)return t;const a=n.toLowerCase();return t.filter(l=>l.name.toLowerCase().includes(a))},[t,n]);return p.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-5",children:[p.jsxs(ui,{children:[p.jsx(fi,{children:"Pick a provider to power curate & query"}),p.jsx(Ff,{children:"ByteRover routes LLM calls through your chosen provider. You can change this later."})]}),p.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3",children:[p.jsxs("div",{className:"relative",children:[p.jsx(vc,{className:"text-muted-foreground absolute top-1/2 left-3 size-4 -translate-y-1/2"}),p.jsx(Ko,{className:"pl-9",onChange:a=>r(a.target.value),placeholder:"Search...",value:n})]}),p.jsx("div",{className:"flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto pr-4 -mr-4 [scrollbar-gutter:stable]",children:o.map(a=>{const l=Qq[a.id],c=a.isCurrent;return p.jsxs("button",{className:we("group/row flex w-full cursor-pointer items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors",c?"border-primary-foreground/40 bg-primary/5":"border-border hover:border-foreground/25"),onClick:()=>e(a),type:"button",children:[p.jsx("div",{className:"bg-muted/50 grid size-7 shrink-0 place-items-center overflow-hidden rounded-md",children:l&&p.jsx("img",{alt:"",className:"size-5",src:l})}),p.jsx("span",{className:"text-foreground flex-1 text-sm font-medium",children:a.name}),p.jsx("div",{className:we("grid size-[18px] shrink-0 place-items-center rounded-full border transition-colors",c?"bg-primary-foreground border-primary-foreground":"border-border"),children:c&&p.jsx(Ys,{className:"text-background size-3",strokeWidth:3})})]},a.id)})})]})]})}const k2="byterover",Zq=6,Jq=1e3;function eV(e){return new Promise(t=>{setTimeout(t,e)})}function Px({onOpenChange:e,onProviderActivated:t,open:n,tourStepLabel:r}){const[o,a]=C.useState("select"),[l,c]=C.useState(),[f,d]=C.useState(),[g,h]=C.useState(),[y,x]=C.useState(!1),v=ji(M=>M.isAuthorized),{data:S}=VT(),E=nq(),k=iq(),T=aq(),R=uq(),L=lq(),j=eq(),N=XU(),A=S?.providers??[],D=C.useCallback(()=>{a("select"),c(void 0),d(void 0),h(void 0),x(!1)},[]),U=C.useCallback(()=>{e(!1),setTimeout(D,150)},[e,D]),I=C.useCallback(M=>{M?e(!0):(e(!1),setTimeout(D,150))},[e,D]),q=C.useCallback(async M=>{a("connecting");try{let P=await E.mutateAsync({providerId:M.id});for(let Q=0;!P.success&&Q<Zq;Q++)await eV(Jq),P=await E.mutateAsync({providerId:M.id});if(!P.success){ut.error(P.error??"Failed to connect ByteRover"),a("select");return}await T.mutateAsync({providerId:M.id}),ut.success(`Connected to ${M.name}`),t?.(),U()}catch(P){ut.error(Cn(P,"Connection failed")),a("select")}},[E,t,U,T]),$=C.useCallback(async M=>{if(c(M),h(void 0),M.id===k2&&!v){a("login_prompt");return}if(M.id===k2&&M.isCurrent){t?.(),U();return}if(M.isConnected){a("provider_actions");return}if(M.id===k2){await q(M);return}if(M.id==="openai-compatible"){a("base_url");return}if(M.supportsOAuth){a("auth_method");return}if(M.requiresApiKey){a("api_key");return}a("connecting");try{await E.mutateAsync({providerId:M.id}),x(!0),a("model_select")}catch(P){ut.error(Cn(P,"Connection failed")),a("select")}},[q,E,v,t,U]),V=C.useCallback(async M=>{a("connecting");try{const P=await L.mutateAsync({providerId:M.id});if(!P.success){ut.error(P.error??"Failed to start OAuth"),a("select");return}const Q=await j.mutateAsync({providerId:M.id});Q.success?(x(!0),a("model_select")):(ut.error(Q.error??"OAuth failed"),a("select"))}catch(P){ut.error(Cn(P,"OAuth failed")),a("select")}},[j,L]),Y=C.useCallback(async M=>{if(l)switch(M){case"activate":{a("connecting");try{await T.mutateAsync({providerId:l.id}),ut.success(`Activated ${l.name}`),t?.(),U()}catch(P){h(Cn(P,"Failed")),a("provider_actions")}break}case"change_model":{a("model_select");break}case"disconnect":{a("connecting");try{await k.mutateAsync({providerId:l.id}),ut.success(`Disconnected ${l.name}`),a("select"),c(void 0),h(void 0)}catch(P){h(Cn(P,"Failed")),a("provider_actions")}break}case"reconfigure":{a("base_url");break}case"reconnect_oauth":{await V(l);break}case"replace":{a("api_key");break}}},[k,V,t,U,l,T]),H=C.useCallback(M=>{d(M),a("api_key")},[]),B=C.useCallback(async M=>{if(l){if(l.id!=="openai-compatible"&&M)try{const P=await R.mutateAsync({apiKey:M,providerId:l.id});if(!P.isValid){h(P.error??"Invalid API key");return}}catch(P){h(Cn(P,"Validation failed"));return}a("connecting");try{await E.mutateAsync({apiKey:M||void 0,baseUrl:f??void 0,providerId:l.id}),x(!0),a("model_select")}catch(P){h(Cn(P,"Connection failed")),a("api_key")}}},[f,E,l,R]),F=C.useCallback(async M=>{if(l)try{await N.mutateAsync({contextLength:M.contextLength,modelId:M.id,providerId:l.id}),y?(ut.success(`Connected to ${l.name}`),t?.(),U()):(ut.success(`Model set to ${M.name}`),a("provider_actions"))}catch(P){ut.error(Cn(P,"Failed to set model"))}},[y,t,U,l,N]),G=C.useCallback(()=>{h(void 0),l?.id==="openai-compatible"?a("base_url"):l?.supportsOAuth?a("auth_method"):a("select")},[l]),ie=()=>{switch(o){case"api_key":return l?p.jsx(Eq,{error:g,isOptional:l.id==="openai-compatible",isValidating:R.isPending,onBack:G,onSubmit:M=>B(M),provider:l}):null;case"auth_method":return l?p.jsx(kq,{onBack:()=>{a("select"),c(void 0),h(void 0)},onSelect:M=>{M==="oauth"?V(l):a("api_key")},provider:l}):null;case"base_url":return l?p.jsx(Aq,{error:g,onBack:()=>{a("select"),h(void 0)},onSubmit:H,provider:l}):null;case"connecting":return p.jsxs("div",{className:"flex flex-col items-center gap-3 py-12",children:[p.jsx(ai,{className:"text-primary size-6 animate-spin"}),p.jsxs("p",{className:"text-muted-foreground text-sm",children:["Connecting to ",l?.name,"..."]})]});case"login_prompt":return l?p.jsx(Nq,{onAuthenticated:()=>{q(l)},onBack:()=>{a("select"),c(void 0)}}):null;case"model_select":return l?p.jsx(Mq,{onBack:()=>{a(y?"select":"provider_actions")},onSelect:F,providerId:l.id}):null;case"provider_actions":return l?p.jsx(Lq,{error:g,onAction:Y,onBack:()=>{a("select"),c(void 0),h(void 0)},provider:l}):null;case"select":return p.jsx(Xq,{onSelect:M=>$(M),providers:A});default:return null}};return p.jsx($s,{onOpenChange:I,open:n,children:p.jsxs(Gs,{className:"flex h-150 flex-col sm:max-w-lg",showCloseButton:o==="select"||o==="model_select"||o==="connecting"||o==="login_prompt",children:[r&&p.jsx(u0,{label:r}),ie()]})})}function E9({...e}){return p.jsx(c9,{"data-slot":"sheet",...e})}function tV({...e}){return p.jsx(Ox,{"data-slot":"sheet-portal",...e})}function nV({className:e,...t}){return p.jsx(Ax,{"data-slot":"sheet-overlay",className:we("fixed inset-0 z-50 bg-black/10 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:backdrop-blur-xs",e),...t})}function k9({className:e,children:t,side:n="right",showCloseButton:r=!0,...o}){return p.jsxs(tV,{children:[p.jsx(nV,{}),p.jsxs(Nx,{"data-slot":"sheet-content","data-side":n,className:we("fixed z-50 flex flex-col gap-4 bg-background bg-clip-padding text-sm shadow-lg transition duration-200 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-[2.5rem] data-[side=bottom]:data-starting-style:translate-y-[2.5rem] data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:border-r data-[side=left]:data-ending-style:translate-x-[-2.5rem] data-[side=left]:data-starting-style:translate-x-[-2.5rem] data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=right]:data-ending-style:translate-x-[2.5rem] data-[side=right]:data-starting-style:translate-x-[2.5rem] data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:translate-y-[-2.5rem] data-[side=top]:data-starting-style:translate-y-[-2.5rem] ",e),...o,children:[t,r&&p.jsxs(Pf,{"data-slot":"sheet-close",render:p.jsx(De,{variant:"ghost",className:"absolute top-4 right-4",size:"icon-sm"}),children:[p.jsx(qp,{}),p.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Fx({className:e,...t}){return p.jsx("textarea",{"data-slot":"textarea",className:we("flex field-sizing-content min-h-16 w-full rounded-md border border-border bg-background px-2.5 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-background dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",e),...t})}const rV=e=>{const{apiClient:t}=Be.getState();return t?t.request(ks.CREATE,e):Promise.reject(new Error("Not connected"))},iV=({mutationConfig:e}={})=>wn({...e,mutationFn:rV});function oV(e){const t=iV(),n=e.content.trim().length>0,{isPending:r}=t;return{canSubmit:n,isPending:r,submit:async()=>{if(!n||r)return;if(!e.hasActiveProvider){e.onProviderRequired();return}const a=crypto.randomUUID(),l={...e.projectPath?{clientCwd:e.projectPath,projectPath:e.projectPath}:{},content:e.content.trim(),taskId:a,type:e.type};try{await t.mutateAsync(l);const c=e.type==="query"?"Query":"Curate";ut.success(`${c} task queued`,{position:"top-center"}),e.onSubmitted?.(a,e.openDetailAfter),e.onClose()}catch(c){ut.error(c instanceof Error?c.message:"Failed to create task",{position:"top-center"})}}}}const TC={curate:"JWT tokens expire after 24h. Refresh window is 7 days. Rotation happens on every successful refresh — old refresh token is invalidated immediately.",query:"What is our auth token expiration policy?"},aV={curate:"Plain text knowledge to capture into the project context tree.",query:"The agent searches the project context tree and synthesizes an answer."};function sV({type:e}){return p.jsx("p",{className:"text-muted-foreground/60 text-xs",children:aV[e]})}function lV(){return p.jsxs("p",{className:"text-muted-foreground/60 mt-2 flex items-center gap-1.5 text-xs",children:[p.jsx(SU,{className:"size-3 shrink-0"}),p.jsxs("span",{children:["For file or folder attachments, use"," ",p.jsx("code",{className:"bg-muted text-foreground/80 mono rounded px-1.5 py-0.5 text-[11px]",children:"brv curate -f <path>"})," ","from the CLI."]})]})}function cV({label:e}){return p.jsxs(Yo,{className:"text-primary-foreground absolute top-2.5 right-3 gap-1.5 px-2 text-[10px] tracking-[0.08em] uppercase",variant:"secondary",children:[p.jsx("span",{"aria-hidden":!0,className:"bg-primary-foreground size-1.5 rounded-full"}),e]})}let AC=(function(e){return e.checked="data-checked",e.unchecked="data-unchecked",e.indeterminate="data-indeterminate",e.disabled="data-disabled",e.readonly="data-readonly",e.required="data-required",e.valid="data-valid",e.invalid="data-invalid",e.touched="data-touched",e.dirty="data-dirty",e.filled="data-filled",e.focused="data-focused",e})({});function T9(e){return C.useMemo(()=>({checked(t){return e.indeterminate?{}:t?{[AC.checked]:""}:{[AC.unchecked]:""}},..._x}),[e.indeterminate])}function uV(e,t,n,r=!0,o){const[a,l]=C.useState(),c=Gi(o?`${o}-label`:void 0),f=e??t??a;return qe(()=>{const d=e||t||!r?void 0:fV(n.current,c);a!==d&&l(d)}),f}function fV(e,t){const n=dV(e);if(n)return!n.id&&t&&(n.id=t),n.id||void 0}function dV(e){if(!e)return;const t=e.parentElement;if(t&&t.tagName==="LABEL")return t;const n=e.id;if(n){const o=e.nextElementSibling;if(o&&o.htmlFor===n)return o}const r=e.labels;return r&&r[0]}const A9=C.createContext(void 0);function hV(){const e=C.useContext(A9);if(e===void 0)throw new Error(Gn(14));return e}const pV="data-parent",mV=C.forwardRef(function(t,n){const{checked:r,className:o,defaultChecked:a=!1,"aria-labelledby":l,disabled:c=!1,id:f,indeterminate:d=!1,inputRef:g,name:h,onCheckedChange:y,parent:x=!1,readOnly:v=!1,render:S,required:E=!1,uncheckedValue:k,value:T,nativeButton:R=!1,...L}=t,{clearErrors:j}=x9(),{disabled:N,name:A,setDirty:D,setFilled:U,setFocused:I,setTouched:q,state:$,validationMode:V,validityData:Y,shouldValidateOnChange:H,validation:B}=Dx(),F=vq(),{labelId:G,controlId:ie,registerControlId:M,getDescriptionProps:P}=Ix(),Q=Sq(),_=Q?.parent,ee=_&&Q.allValues,J=N||F.disabled||Q?.disabled||c,re=A??h,pe=T??re,fe=Gi(),Ce=Gi();let Ee=ie;ee?Ee=x?Ce:`${_.id}-${pe}`:f&&(Ee=f);let Ie={};ee&&(x?Ie=Q.parent.getParentProps():pe&&(Ie=Q.parent.getChildProps(pe)));const Ye=st(y),{checked:je=r,indeterminate:_e=d,onCheckedChange:ye,...We}=Ie,Te=Q?.value,Re=Q?.setValue,he=Q?.defaultValue,Se=C.useRef(null),ne=Zn(()=>Symbol("checkbox-control")),xe=C.useRef(!1),{getButtonProps:ze,buttonRef:Ue}=zf({disabled:J,native:R}),wt=Q?.validation??B,[ae,ve]=b9({controlled:pe&&Te&&!x?Te.includes(pe):je,default:pe&&he&&!x?he.includes(pe):a,name:"Checkbox",state:"checked"});qe(()=>{M!==dr&&(xe.current=!0,M(ne.current,Ee))},[Ee,Q,M,x,ne]),C.useEffect(()=>{const Qe=ne.current;return()=>{!xe.current||M===dr||(xe.current=!1,M(Qe,void 0))}},[M,ne]),v9({enabled:!Q,id:fe,commit:wt.commit,value:ae,controlRef:Se,name:re,getValue:()=>ae});const Oe=C.useRef(null),Me=Ms(g,Oe,wt.inputRef),He=uV(l,G,Oe,!R,Ee??void 0);qe(()=>{Oe.current&&(Oe.current.indeterminate=_e,ae&&U(!0))},[ae,_e,U]),o9(ae,()=>{Q&&!x||(j(re),U(ae),D(ae!==Y.initialValue),H()?wt.commit(ae):wt.commit(ae,!0))});const kt=Ba({checked:ae,disabled:J,name:x?void 0:re,id:R?void 0:Ee??void 0,required:E,ref:Me,style:re?J_:a6,tabIndex:-1,type:"checkbox","aria-hidden":!0,onChange(Qe){if(Qe.nativeEvent.defaultPrevented)return;const yt=Qe.target.checked,Pt=Et(Jp,Qe.nativeEvent);if(ye?.(yt,Pt),Ye(yt,Pt),!Pt.isCanceled&&(ve(yt),pe&&Te&&Re&&!x)){const Wt=yt?[...Te,pe]:Te.filter(yn=>yn!==pe);Re(Wt,Pt)}},onFocus(){Se.current?.focus()}},T!==void 0?{value:(Q?ae&&T:T)||""}:Ln,P,Q?wt.getValidationProps:wt.getInputValidationProps),Ft=ee?!!je:ae,Xe=ee&&_e||d;C.useEffect(()=>{if(!_||!pe)return;const Qe=_.disabledStatesRef.current;return Qe.set(pe,J),()=>{Qe.delete(pe)}},[_,J,pe]);const Ve=C.useMemo(()=>({...$,checked:Ft,disabled:J,readOnly:v,required:E,indeterminate:Xe}),[$,Ft,J,v,E,Xe]),pt=T9(Ve),mt=ln("span",t,{state:Ve,ref:[Ue,Se,n,Q?.registerControlRef],props:[{id:R?Ee??void 0:fe,role:"checkbox","aria-checked":_e?"mixed":ae,"aria-readonly":v||void 0,"aria-required":E||void 0,"aria-labelledby":He,[pV]:x?"":void 0,onFocus(){I(!0)},onBlur(){const Qe=Oe.current;Qe&&(q(!0),I(!1),V==="onBlur"&&wt.commit(Q?Te:Qe.checked))},onClick(Qe){v||J||(Qe.preventDefault(),Oe.current?.dispatchEvent(new PointerEvent("click",{bubbles:!0,shiftKey:Qe.shiftKey,ctrlKey:Qe.ctrlKey,altKey:Qe.altKey,metaKey:Qe.metaKey})))}},P,wt.getValidationProps,L,We,ze],stateAttributesMapping:pt});return p.jsxs(A9.Provider,{value:Ve,children:[mt,!ae&&!Q&&re&&!x&&k!==void 0&&p.jsx("input",{type:"hidden",name:re,value:k}),p.jsx("input",{...kt})]})}),gV=C.forwardRef(function(t,n){const{render:r,className:o,keepMounted:a=!1,...l}=t,c=hV(),f=c.checked||c.indeterminate,{mounted:d,transitionStatus:g,setMounted:h}=Xy(f),y=C.useRef(null),x={...c,transitionStatus:g};mc({open:f,ref:y,onComplete(){f||h(!1)}});const v=T9(c),S=C.useMemo(()=>({...v,...pc,..._x}),[v]),E=a||d,k=ln("span",t,{ref:[n,y],state:x,stateAttributesMapping:S,props:l});return E?k:null});function yV({className:e,...t}){return p.jsx(mV,{"data-slot":"checkbox",className:we("peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input shadow-xs transition-shadow outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-foreground dark:data-checked:bg-primary",e),...t,children:p.jsx(gV,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none [&>svg]:size-3.5",children:p.jsx(qE,{})})})}function xV({canSubmit:e,hasActiveProvider:t,inTour:n,isPending:r,onClose:o,onOpenDetailChange:a,onSubmit:l,openDetailAfter:c,type:f}){const y=r?f==="query"?"Querying…":"Curating…":n||t?f==="query"?"Query":"Curate":"Connect provider…";return p.jsxs("footer",{className:"border-border flex items-center justify-between gap-3 border-t px-7 py-3.5",children:[n?p.jsx("span",{}):p.jsxs("label",{className:"text-muted-foreground inline-flex cursor-pointer items-center gap-2 text-xs",children:[p.jsx(yV,{checked:c,onCheckedChange:a}),"Open after submit"]}),p.jsxs("div",{className:"ml-2 flex items-center gap-2",children:[p.jsx(De,{onClick:o,size:"sm",variant:"ghost",children:"Cancel"}),p.jsx(De,{disabled:!e||r,onClick:l,size:"sm",children:y})]})]})}function bV({inTour:e,onTypeChange:t,projectPath:n,tourStepLabel:r,type:o}){return p.jsxs("header",{className:"border-border flex flex-col gap-2 border-b px-7 pt-5 pb-4",children:[r&&p.jsx(u0,{label:r}),p.jsxs("div",{className:"flex items-center justify-between gap-4 pr-10",children:[p.jsxs("h2",{className:"text-foreground flex items-baseline gap-1.5 text-lg font-medium tracking-tight",children:[p.jsx("span",{className:"text-muted-foreground/70 font-normal",children:"New"}),p.jsxs("span",{children:[o," task"]})]}),!e&&p.jsx(vV,{onChange:t,value:o})]}),p.jsxs("p",{className:"text-muted-foreground/70 text-xs",children:[o==="query"?"Searches":"Will dispatch to"," ",p.jsx("span",{className:"text-identifier mono",children:n||"(no project selected)"})]})]})}function vV({onChange:e,value:t}){return p.jsxs("div",{className:"border-border bg-muted relative inline-flex rounded-md border p-0.5",children:[p.jsx("span",{"aria-hidden":!0,className:we("bg-background border-border absolute top-0.5 bottom-0.5 w-[calc(50%-2px)] rounded border transition-transform duration-200 ease-out",t==="query"?"translate-x-full":"translate-x-0")}),["curate","query"].map(n=>p.jsx("button",{className:we("relative z-10 px-3 py-1 text-xs font-medium transition-colors",n===t?"text-foreground":"text-muted-foreground hover:text-foreground/80"),onClick:()=>e(n),type:"button",children:n==="curate"?"Curate":"Query"},n))]})}function R9({initialContent:e,initialType:t,onClose:n,onSubmitted:r,open:o,prefillNotice:a,tourStepLabel:l}){const c=!!l;return p.jsx(E9,{onOpenChange:f=>!f&&n(),open:o,children:p.jsx(k9,{className:we("data-[side=right]:w-full data-[side=right]:max-w-xl p-0 shadow-[inset_1px_0_0_rgba(96,165,250,0.18)]",!c&&"sheet-no-overlay"),side:"right",children:o&&p.jsx(wV,{initialContent:e,initialType:t,onClose:n,onSubmitted:r,prefillNotice:a,tourStepLabel:l})})})}function wV({initialContent:e,initialType:t,onClose:n,onSubmitted:r,prefillNotice:o,tourStepLabel:a}){const l=Be(q=>q.selectedProject),{data:c}=kx(),[f,d]=C.useState(t??"curate"),[g,h]=C.useState(e??""),[y,x]=C.useState(!0),[v,S]=C.useState(!1),[E,k]=C.useState(!!e),T=C.useRef(null);C.useEffect(()=>{T.current?.focus()},[]);const R=!!c,L=!!a,{canSubmit:j,isPending:N,submit:A}=oV({content:g,hasActiveProvider:R,onClose:n,onProviderRequired:()=>S(!0),onSubmitted:r,openDetailAfter:y,projectPath:l,type:f}),D=q=>{if((q.metaKey||q.ctrlKey)&&q.key==="Enter"){q.preventDefault(),A().catch(()=>{});return}q.key==="Tab"&&!q.shiftKey&&!g&&(q.preventDefault(),h(TC[f]))},U=!!(o&&E&&g===(e??"")),I=q=>{E&&q!==(e??"")&&k(!1),h(q)};return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[p.jsx(bV,{inTour:L,onTypeChange:d,projectPath:l,tourStepLabel:a,type:f}),p.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto px-7 py-5",children:[p.jsxs("div",{className:"space-y-1.5",children:[p.jsxs("div",{className:"relative",children:[p.jsx(Fx,{className:"bg-card dark:bg-card text-foreground/90 mono min-h-64 pr-4 pb-7 text-sm leading-relaxed",onChange:q=>I(q.target.value),onKeyDown:D,placeholder:TC[f],ref:T,rows:f==="query"?4:6,value:g}),U&&o&&p.jsx(cV,{label:o}),p.jsxs("span",{className:"text-muted-foreground/40 mono pointer-events-none absolute right-3 bottom-2 flex items-center gap-2 text-[10px] tabular-nums",children:[p.jsx("span",{className:"text-muted-foreground/60",children:g?p.jsxs(p.Fragment,{children:[p.jsxs("kbd",{className:"bg-muted text-foreground/70 inline-flex items-center gap-1 rounded px-1.5 py-0.5 leading-none",children:[p.jsx(nU,{className:"size-2.5"})," · Ctrl + Enter"]})," ","to ",f]}):p.jsxs(p.Fragment,{children:[p.jsx("kbd",{className:"bg-muted text-foreground/70 inline-flex items-center rounded px-1.5 py-0.5 leading-none",children:"Tab"})," ","to use example"]})}),p.jsxs("span",{children:[g.length," chars"]})]})]}),p.jsx(sV,{type:f})]}),f==="curate"&&!L&&p.jsx(lV,{})]}),p.jsx(xV,{canSubmit:j,hasActiveProvider:R,inTour:L,isPending:N,onClose:n,onOpenDetailChange:x,onSubmit:A,openDetailAfter:y,type:f})]}),p.jsx(Px,{onOpenChange:S,open:v})]})}function SV(){const e=on(c=>c.tourActive),t=on(c=>c.tourStep),n=on(c=>c.advanceTour),r=on(c=>c.exitTour),o=qa(),a=e&&t==="connector",l=()=>{n(),o("/configuration")};return p.jsx($s,{onOpenChange:c=>!c&&r(),open:a,children:p.jsxs(Gs,{className:"flex flex-col gap-5 p-6 sm:max-w-[460px]",children:[p.jsx(u0,{label:"Step 4 of 4 · Optional"}),p.jsxs("div",{className:"flex flex-col gap-3",children:[p.jsx("div",{className:"bg-primary/12 text-primary-foreground grid size-10 place-items-center rounded-lg",children:p.jsx(MU,{className:"size-5"})}),p.jsx("h2",{className:"text-foreground text-base font-semibold",children:"Use ByteRover from your AI agent"}),p.jsxs("p",{className:"text-muted-foreground text-sm leading-relaxed",children:["Connect a tool like Claude Code, Cursor, or any MCP client and you can curate & query the context tree without leaving your chat. It's optional — you can always come back via the"," ",p.jsx("span",{className:"text-foreground font-medium",children:"Configuration"})," tab."]})]}),p.jsxs("div",{className:"border-border -mx-6 -mb-6 mt-2 flex items-center gap-2 border-t px-6 py-4",children:[p.jsx(De,{onClick:()=>n(),type:"button",variant:"ghost",children:"Maybe later"}),p.jsx("div",{className:"flex-1"}),p.jsxs(De,{onClick:l,type:"button",children:["Open Configuration",p.jsx(d9,{className:"size-4"})]})]})]})})}function CV(){return on.getState().tourStep==="provider"}const EV="JWT tokens expire after 24h. Refresh window is 7 days. Rotation happens on every successful refresh — old refresh token is invalidated immediately.",kV="What is our auth token expiration policy?";function TV(){const e=on(d=>d.tourActive),t=on(d=>d.tourStep),n=on(d=>d.tourTaskId),r=on(d=>d.exitTour),o=on(d=>d.advanceTour),a=on(d=>d.setTourTaskId),l=qa(),c=C.useRef(!1);if(!e||!t)return null;const f=(t==="curate"||t==="query")&&!n;return p.jsxs(p.Fragment,{children:[t==="provider"&&p.jsx(Px,{onOpenChange:d=>{d||CV()&&r()},onProviderActivated:()=>o(),open:!0,tourStepLabel:"Step 1 of 4"}),f&&p.jsx(R9,{initialContent:t==="curate"?EV:kV,initialType:t,onClose:()=>{if(c.current){c.current=!1;return}r()},onSubmitted:d=>{c.current=!0,a(d),l(`/tasks?task=${d}`)},open:!0,prefillNotice:"example",tourStepLabel:t==="curate"?"Step 2 of 4":"Step 3 of 4"},t),p.jsx(SV,{})]})}function AV(){const e=on(o=>o.seenWelcome),t=on(o=>o.dismissWelcome),n=on(o=>o.startTour),r=Be(o=>o.selectedProject);return e?null:p.jsx($s,{onOpenChange:o=>!o&&t(),open:!0,children:p.jsxs(Gs,{className:"flex max-w-[420px] flex-col items-center gap-6 p-8 text-center sm:max-w-[420px]",showCloseButton:!1,children:[p.jsx("img",{alt:"Byterover",className:"size-11",src:gx}),p.jsxs(ui,{className:"flex flex-col gap-2.5",children:[p.jsx(fi,{className:"text-foreground text-xl font-semibold tracking-tight",children:"Welcome to ByteRover"}),p.jsxs(Ff,{className:"text-muted-foreground text-sm leading-relaxed",children:["A 3-minute tour will get you from zero to your first answer. You can restart it any time from the"," ",p.jsx("span",{className:"text-foreground font-medium",children:"Help"})," menu in the top-right."]})]}),p.jsxs("div",{className:"flex w-full max-w-[300px] flex-col gap-2",children:[p.jsxs(De,{onClick:()=>n(),size:"lg",children:[p.jsx(PU,{className:"size-4"}),"Take the tour"]}),p.jsx(De,{className:"text-muted-foreground hover:text-foreground text-xs",onClick:()=>t(),variant:"link",children:"Skip — take me in"})]}),r&&p.jsx("p",{className:"text-identifier mono max-w-full truncate text-[10px] tracking-wider",title:r,children:r})]})})}function RV(){const e=on(o=>o.tourActive),t=on(o=>o.tourStep),n=on(o=>o.advanceTour),{data:r}=kx({queryConfig:{enabled:e&&t==="provider"}});C.useEffect(()=>{!e||t!=="provider"||r?.activeModel&&n()},[e,t,r?.activeModel,n])}const NV=()=>{const{apiClient:e}=Be.getState();return e?e.request(rr.STATUS):Promise.reject(new Error("Not connected"))},hi=()=>({queryFn:NV,queryKey:["vc","status"],refetchInterval:3e3,refetchIntervalInBackground:!1,staleTime:2e3}),Bx=({queryConfig:e}={})=>br({...hi(),...e}),OV=["both_added","both_modified","deleted_modified"];function jV(e){return OV.includes(e)?e:void 0}function N9(e){if(!e)return{staged:[],unmerged:[],unstaged:[]};const t=new Set(e.conflictMarkerFiles??[]),n=(e.unmerged??[]).map(({path:l,type:c})=>({conflictType:jV(c),hasMarkers:t.has(l),isStaged:!1,path:l,status:"unmerged"})),r=[...e.staged.added.map(l=>({isStaged:!0,path:l,status:"added"})),...e.staged.modified.map(l=>({isStaged:!0,path:l,status:"modified"})),...e.staged.deleted.map(l=>({isStaged:!0,path:l,status:"deleted"}))],o=[...e.unstaged.modified.map(l=>({isStaged:!1,path:l,status:"modified"})),...e.unstaged.deleted.map(l=>({isStaged:!1,path:l,status:"deleted"})),...e.untracked.map(l=>({isStaged:!1,path:l,status:"untracked"}))],a=(l,c)=>l.path.localeCompare(c.path);return{staged:r.sort(a),unmerged:n.sort(a),unstaged:o.sort(a)}}const MV="/assets/logo-byterover-DB7H7faH.svg",O9=C.createContext(void 0);function j9(){const e=C.useContext(O9);if(e===void 0)throw new Error(Gn(13));return e}const Hx={imageLoadingStatus:()=>null},LV=C.forwardRef(function(t,n){const{className:r,render:o,...a}=t,[l,c]=C.useState("idle"),f={imageLoadingStatus:l},d=C.useMemo(()=>({imageLoadingStatus:l,setImageLoadingStatus:c}),[l,c]),g=ln("span",t,{state:f,ref:n,props:a,stateAttributesMapping:Hx});return p.jsx(O9.Provider,{value:d,children:g})});function _V(e,{referrerPolicy:t,crossOrigin:n}){const[r,o]=C.useState("idle");return qe(()=>{if(!e)return o("error"),dr;let a=!0;const l=new window.Image,c=f=>()=>{a&&o(f)};return o("loading"),l.onload=c("loaded"),l.onerror=c("error"),t&&(l.referrerPolicy=t),l.crossOrigin=n??null,l.src=e,()=>{a=!1}},[e,n,t]),r}const DV={...Hx,...pc},IV=C.forwardRef(function(t,n){const{className:r,render:o,onLoadingStatusChange:a,referrerPolicy:l,crossOrigin:c,...f}=t,d=j9(),g=_V(t.src,{referrerPolicy:l,crossOrigin:c}),h=g==="loaded",{mounted:y,transitionStatus:x,setMounted:v}=Xy(h),S=C.useRef(null),E=st(R=>{a?.(R),d.setImageLoadingStatus(R)});qe(()=>{g!=="idle"&&E(g)},[g,E]);const k={imageLoadingStatus:g,transitionStatus:x};mc({open:h,ref:S,onComplete(){h||v(!1)}});const T=ln("img",t,{state:k,ref:[n,S],props:f,stateAttributesMapping:DV,enabled:y});return y?T:null}),zV=C.forwardRef(function(t,n){const{className:r,render:o,delay:a,...l}=t,{imageLoadingStatus:c}=j9(),[f,d]=C.useState(a===void 0),g=jr();return C.useEffect(()=>(a!==void 0&&g.start(a,()=>d(!0)),g.clear),[g,a]),ln("span",t,{state:{imageLoadingStatus:c},ref:n,props:l,stateAttributesMapping:Hx,enabled:c!=="loaded"&&f})});function f0({className:e,size:t="default",...n}){return p.jsx(LV,{"data-slot":"avatar","data-size":t,className:we("group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten",e),...n})}function Ux({className:e,...t}){return p.jsx(IV,{"data-slot":"avatar-image",className:we("aspect-square size-full rounded-full object-cover",e),...t})}function d0({className:e,...t}){return p.jsx(zV,{"data-slot":"avatar-fallback",className:we("flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs",e),...t})}const M9=C.createContext(void 0);function qx(e){const t=C.useContext(M9);if(t===void 0&&!e)throw new Error(Gn(33));return t}const L9=C.createContext(void 0);function Qo(e){const t=C.useContext(L9);if(t===void 0&&!e)throw new Error(Gn(36));return t}const PV=C.createContext(void 0);function h0(e=!0){const t=C.useContext(PV);if(t===void 0&&!e)throw new Error(Gn(25));return t}function FV(e){const{closeOnClick:t,highlighted:n,id:r,nodeId:o,store:a,typingRef:l,itemRef:c,itemMetadata:f}=e,{events:d}=a.useState("floatingTreeRoot"),g=h0(!0),h=g!==void 0;return C.useMemo(()=>({id:r,role:"menuitem",tabIndex:n?0:-1,onKeyDown(y){y.key===" "&&l?.current&&y.preventDefault()},onMouseMove(y){o&&d.emit("itemhover",{nodeId:o,target:y.currentTarget})},onClick(y){t&&d.emit("close",{domEvent:y,reason:t6})},onMouseUp(y){if(g){const x=g.initialCursorPointRef.current;if(g.initialCursorPointRef.current=null,h&&x&&Math.abs(y.clientX-x.x)<=1&&Math.abs(y.clientY-x.y)<=1||h&&!_k&&y.button===2)return}c.current&&a.context.allowMouseUpTriggerRef.current&&(!h||y.button===2)&&(!f||f.type==="regular-item")&&c.current.click()}}),[t,n,r,d,o,a,l,c,g,h,f])}const BV={type:"regular-item"};function _9(e){const{closeOnClick:t,disabled:n=!1,highlighted:r,id:o,store:a,typingRef:l=a.context.typingRef,nativeButton:c,itemMetadata:f,nodeId:d}=e,g=C.useRef(null),{getButtonProps:h,buttonRef:y}=zf({disabled:n,focusableWhenDisabled:!0,native:c,composite:!0}),x=FV({closeOnClick:t,highlighted:r,id:o,nodeId:d,store:a,typingRef:l,itemRef:g,itemMetadata:f}),v=C.useCallback(E=>Ba(x,{onMouseEnter(){f.type==="submenu-trigger"&&f.setActive()}},E,h),[x,h,f]),S=Ms(g,y);return C.useMemo(()=>({getItemProps:v,itemRef:S}),[v,S])}const D9=C.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});function HV(){return C.useContext(D9)}let UV=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function Vx(e={}){const{label:t,metadata:n,textRef:r,indexGuessBehavior:o,index:a}=e,{register:l,unregister:c,subscribeMapChange:f,elementsRef:d,labelsRef:g,nextIndexRef:h}=HV(),y=C.useRef(-1),[x,v]=C.useState(a??(o===UV.GuessFromOrder?()=>{if(y.current===-1){const k=h.current;h.current+=1,y.current=k}return y.current}:-1)),S=C.useRef(null),E=C.useCallback(k=>{if(S.current=k,x!==-1&&k!==null&&(d.current[x]=k,g)){const T=t!==void 0;g.current[x]=T?t:r?.current?.textContent??k.textContent}},[x,d,g,t,r]);return qe(()=>{if(a!=null)return;const k=S.current;if(k)return l(k,n),()=>{c(k)}},[a,l,c,n]),qe(()=>{if(a==null)return f(k=>{const T=S.current?k.get(S.current)?.index:null;T!=null&&v(T)})},[a,f,v]),C.useMemo(()=>({ref:E,index:x}),[x,E])}const I9=C.createContext(void 0);function qV(){const e=C.useContext(I9);if(e===void 0)throw new Error(Gn(31));return e}const VV=C.forwardRef(function(t,n){const{render:r,className:o,...a}=t,[l,c]=C.useState(void 0),f=C.useMemo(()=>({setLabelId:c}),[c]),d=ln("div",t,{ref:n,props:{role:"group","aria-labelledby":l,...a}});return p.jsx(I9.Provider,{value:f,children:d})}),$V=C.forwardRef(function(t,n){const{className:r,render:o,id:a,...l}=t,c=Gi(a),{setLabelId:f}=qV();return qe(()=>(f(c),()=>{f(void 0)}),[f,c]),ln("div",t,{ref:n,props:{id:c,role:"presentation",...l}})}),GV=C.forwardRef(function(t,n){const{render:r,className:o,id:a,label:l,nativeButton:c=!1,disabled:f=!1,closeOnClick:d=!0,...g}=t,h=Vx({label:l}),y=qx(!0),x=Gi(a),{store:v}=Qo(),S=v.useState("isActive",h.index),E=v.useState("itemProps"),{getItemProps:k,itemRef:T}=_9({closeOnClick:d,disabled:f,highlighted:S,id:x,store:v,nativeButton:c,nodeId:y?.nodeId,itemMetadata:BV});return ln("div",t,{state:{disabled:f,highlighted:S},props:[E,g,k],ref:[T,n,h.ref]})}),YV=C.createContext(void 0);function WV(e){return C.useContext(YV)}const KV={...qs,...pc},QV=C.forwardRef(function(t,n){const{render:r,className:o,finalFocus:a,...l}=t,{store:c}=Qo(),{side:f,align:d}=qx(),g=WV()!=null,h=c.useState("open"),y=c.useState("transitionStatus"),x=c.useState("popupProps"),v=c.useState("mounted"),S=c.useState("instantType"),E=c.useState("activeTriggerElement"),k=c.useState("parent"),T=c.useState("lastOpenChangeReason"),R=c.useState("rootId"),L=c.useState("floatingRootContext"),j=c.useState("floatingTreeRoot"),N=c.useState("closeDelay"),A=c.useState("activeTriggerElement"),D=k.type==="context-menu";mc({open:h,ref:c.context.popupRef,onComplete(){h&&c.context.onOpenChangeComplete?.(!0)}}),C.useEffect(()=>{function H(B){c.setOpen(!1,Et(B.reason,B.domEvent))}return j.events.on("close",H),()=>{j.events.off("close",H)}},[j.events,c]);const U=c.useState("hoverEnabled"),I=c.useState("disabled");P6(L,{enabled:U&&!I&&!D&&k.type!=="menubar",closeDelay:N});const q={transitionStatus:y,side:f,align:d,open:h,nested:k.type==="menu",instant:S},$=C.useCallback(H=>{c.set("popupElement",H)},[c]),V=ln("div",t,{state:q,ref:[n,c.context.popupRef,$],stateAttributesMapping:KV,props:[x,{onKeyDown(H){g&&n9.has(H.key)&&H.stopPropagation()}},i0(y),l,{"data-rootownerid":R}]});let Y=k.type===void 0||D;return(E||k.type==="menubar"&&T!==Uy)&&(Y=!0),p.jsx(x6,{context:L,modal:D,disabled:!v,returnFocus:a===void 0?Y:a,initialFocus:k.type!=="menu",restoreFocus:!0,externalTree:k.type!=="menubar"?j:void 0,previousFocusableElement:A,nextFocusableElement:k.type===void 0?c.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:k.type===void 0?c.context.beforeContentFocusGuardRef:void 0,children:V})}),z9=C.createContext(void 0);function XV(){const e=C.useContext(z9);if(e===void 0)throw new Error(Gn(32));return e}const ZV=C.forwardRef(function(t,n){const{keepMounted:r=!1,...o}=t,{store:a}=Qo();return a.useState("mounted")||r?p.jsx(z9.Provider,{value:r,children:p.jsx(h6,{ref:n,...o})}):null});function JV(e){const{children:t,elementsRef:n,labelsRef:r,onMapChange:o}=e,a=st(o),l=C.useRef(0),c=Zn(t$).current,f=Zn(e$).current,[d,g]=C.useState(0),h=C.useRef(d),y=st((k,T)=>{f.set(k,T??null),h.current+=1,g(h.current)}),x=st(k=>{f.delete(k),h.current+=1,g(h.current)}),v=C.useMemo(()=>{const k=new Map;return Array.from(f.keys()).filter(R=>R.isConnected).sort(n$).forEach((R,L)=>{const j=f.get(R)??{};k.set(R,{...j,index:L})}),k},[f,d]);qe(()=>{if(typeof MutationObserver!="function"||v.size===0)return;const k=new MutationObserver(T=>{const R=new Set,L=j=>R.has(j)?R.delete(j):R.add(j);T.forEach(j=>{j.removedNodes.forEach(L),j.addedNodes.forEach(L)}),R.size===0&&(h.current+=1,g(h.current))});return v.forEach((T,R)=>{R.parentElement&&k.observe(R.parentElement,{childList:!0})}),()=>{k.disconnect()}},[v]),qe(()=>{h.current===d&&(n.current.length!==v.size&&(n.current.length=v.size),r&&r.current.length!==v.size&&(r.current.length=v.size),l.current=v.size),a(v)},[a,v,n,r,d]),qe(()=>()=>{n.current=[]},[n]),qe(()=>()=>{r&&(r.current=[])},[r]);const S=st(k=>(c.add(k),()=>{c.delete(k)}));qe(()=>{c.forEach(k=>k(v))},[c,v]);const E=C.useMemo(()=>({register:y,unregister:x,subscribeMapChange:S,elementsRef:n,labelsRef:r,nextIndexRef:l}),[y,x,S,n,r,l]);return p.jsx(D9.Provider,{value:E,children:t})}function e$(){return new Map}function t$(){return new Set}function n$(e,t){const n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}const r$=C.forwardRef(function(t,n){const{anchor:r,positionMethod:o="absolute",className:a,render:l,side:c,align:f,sideOffset:d=0,alignOffset:g=0,collisionBoundary:h="clipping-ancestors",collisionPadding:y=5,arrowPadding:x=5,sticky:v=!1,disableAnchorTracking:S=!1,collisionAvoidance:E=P_,...k}=t,{store:T}=Qo(),R=XV(),L=h0(!0),j=T.useState("parent"),N=T.useState("floatingRootContext"),A=T.useState("floatingTreeRoot"),D=T.useState("mounted"),U=T.useState("open"),I=T.useState("modal"),q=T.useState("activeTriggerElement"),$=T.useState("transitionStatus"),V=T.useState("positionerElement"),Y=T.useState("instantType"),H=T.useState("hasViewport"),B=T.useState("lastOpenChangeReason"),F=T.useState("floatingNodeId"),G=T.useState("floatingParentNodeId"),ie=N.useState("domReferenceElement"),M=C.useRef(null),P=L6(V,!1,!1);let Q=r,_=d,ee=g,J=f,re=E;j.type==="context-menu"&&(Q=r??j.context?.anchor,J=J??"start",!c&&J!=="center"&&(ee=t.alignOffset??2,_=t.sideOffset??-5));let pe=c,fe=J;j.type==="menu"?(pe=pe??"inline-end",fe=fe??"start",re=t.collisionAvoidance??e6):j.type==="menubar"&&(pe=pe??"bottom",fe=fe??"start");const Ce=j.type==="context-menu",Ee=W6({anchor:Q,floatingRootContext:N,positionMethod:L?"fixed":o,mounted:D,side:pe,sideOffset:_,align:fe,alignOffset:ee,arrowPadding:Ce?0:x,collisionBoundary:h,collisionPadding:y,sticky:v,nodeId:F,keepMounted:R,disableAnchorTracking:S,collisionAvoidance:re,shiftCrossAxis:Ce&&!("side"in re&&re.side==="flip"),externalTree:A,adaptiveOrigin:H?G6:void 0}),Ie=C.useMemo(()=>{const Re={};return U||(Re.pointerEvents="none"),{role:"presentation",hidden:!D,style:{...Ee.positionerStyles,...Re}}},[U,D,Ee.positionerStyles]);C.useEffect(()=>{function Re(he){he.open&&(he.parentNodeId===F&&T.set("hoverEnabled",!1),he.nodeId!==F&&he.parentNodeId===T.select("floatingParentNodeId")&&T.setOpen(!1,Et(Fu)))}return A.events.on("menuopenchange",Re),()=>{A.events.off("menuopenchange",Re)}},[T,A.events,F]),C.useEffect(()=>{if(T.select("floatingParentNodeId")==null)return;function Re(he){if(he.open||he.nodeId!==T.select("floatingParentNodeId"))return;const Se=he.reason??Fu;T.setOpen(!1,Et(Se))}return A.events.on("menuopenchange",Re),()=>{A.events.off("menuopenchange",Re)}},[A.events,T]);const Ye=jr();C.useEffect(()=>{U||Ye.clear()},[U,Ye]),C.useEffect(()=>{function Re(he){if(!(!U||he.nodeId!==T.select("floatingParentNodeId")))if(he.target&&q&&q!==he.target){const Se=T.select("closeDelay");Se>0?Ye.isStarted()||Ye.start(Se,()=>{T.setOpen(!1,Et(Fu))}):T.setOpen(!1,Et(Fu))}else Ye.clear()}return A.events.on("itemhover",Re),()=>{A.events.off("itemhover",Re)}},[A.events,U,q,T,Ye]),C.useEffect(()=>{const Re={open:U,nodeId:F,parentNodeId:G,reason:T.select("lastOpenChangeReason")};A.events.emit("menuopenchange",Re)},[A.events,U,T,F,G]),qe(()=>{const Re=ie,he=M.current;if(Re&&(M.current=Re),he&&Re&&Re!==he){T.set("instantType",void 0);const Se=new AbortController;return P(()=>{T.set("instantType","trigger-change")},Se.signal),()=>{Se.abort()}}},[ie,P,T]);const je={open:U,side:Ee.side,align:Ee.align,anchorHidden:Ee.anchorHidden,nested:j.type==="menu",instant:Y},_e=C.useMemo(()=>({side:Ee.side,align:Ee.align,arrowRef:Ee.arrowRef,arrowUncentered:Ee.arrowUncentered,arrowStyles:Ee.arrowStyles,nodeId:Ee.context.nodeId}),[Ee.side,Ee.align,Ee.arrowRef,Ee.arrowUncentered,Ee.arrowStyles,Ee.context.nodeId]),ye=ln("div",t,{state:je,stateAttributesMapping:qs,ref:[n,T.useStateSetter("positionerElement")],props:[Ie,i0($),k]}),We=D&&j.type!=="menu"&&(j.type!=="menubar"&&I&&B!==Rr||j.type==="menubar"&&j.context.modal);let Te=null;return j.type==="menubar"?Te=j.context.contentElement:j.type===void 0&&(Te=q),p.jsxs(M9.Provider,{value:_e,children:[We&&p.jsx(r9,{ref:j.type==="context-menu"||j.type==="nested-context-menu"?j.context.internalBackdropRef:null,inert:K6(!U),cutout:Te}),p.jsx(xD,{id:F,children:p.jsx(JV,{elementsRef:T.context.itemDomElements,labelsRef:T.context.itemLabels,children:ye})})]})}),i$=C.createContext(null);function P9(e){return C.useContext(i$)}const o$={...tx,disabled:rt(e=>e.parent.type==="menubar"&&e.parent.context.disabled||e.disabled),modal:rt(e=>(e.parent.type===void 0||e.parent.type==="context-menu")&&(e.modal??!0)),allowMouseEnter:rt(e=>e.allowMouseEnter),stickIfOpen:rt(e=>e.stickIfOpen),parent:rt(e=>e.parent),rootId:rt(e=>e.parent.type==="menu"?e.parent.store.select("rootId"):e.parent.type!==void 0?e.parent.context.rootId:e.rootId),activeIndex:rt(e=>e.activeIndex),isActive:rt((e,t)=>e.activeIndex===t),hoverEnabled:rt(e=>e.hoverEnabled),instantType:rt(e=>e.instantType),lastOpenChangeReason:rt(e=>e.openChangeReason),floatingTreeRoot:rt(e=>e.parent.type==="menu"?e.parent.store.select("floatingTreeRoot"):e.floatingTreeRoot),floatingNodeId:rt(e=>e.floatingNodeId),floatingParentNodeId:rt(e=>e.floatingParentNodeId),itemProps:rt(e=>e.itemProps),closeDelay:rt(e=>e.closeDelay),hasViewport:rt(e=>e.hasViewport),keyboardEventRelay:rt(e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type==="menu")return e.parent.store.select("keyboardEventRelay")})};class $x extends n0{constructor(t){super({...a$(),...t},{positionerRef:C.createRef(),popupRef:C.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:C.createRef(),beforeContentFocusGuardRef:C.createRef(),onOpenChangeComplete:void 0,triggerElements:new Mf},o$),this.unsubscribeParentListener=this.observe("parent",n=>{if(this.unsubscribeParentListener?.(),n.type==="menu"){let r=n.store.select("rootId"),o=n.store.select("floatingTreeRoot"),a=n.store.select("keyboardEventRelay");this.unsubscribeParentListener=n.store.subscribe(()=>{const l=n.store.select("rootId"),c=n.store.select("floatingTreeRoot"),f=n.store.select("keyboardEventRelay");r===l&&o===c&&a===f||(r=l,o=c,a=f,this.notifyAll())}),this.context.allowMouseUpTriggerRef=n.store.context.allowMouseUpTriggerRef;return}n.type!==void 0&&(this.context.allowMouseUpTriggerRef=n.context.allowMouseUpTriggerRef),this.unsubscribeParentListener=null})}setOpen(t,n){this.state.floatingRootContext.context.events.emit("setOpen",{open:t,eventDetails:n})}static useStore(t,n){const r=Zn(()=>new $x(n)).current;return t??r}unsubscribeParentListener=null}function a$(){return{...ex(),disabled:!1,modal:!0,allowMouseEnter:!1,stickIfOpen:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new Gy,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:Ln,keyboardEventRelay:void 0,closeDelay:0,hasViewport:!1}}const F9=C.createContext(void 0);function B9(){return C.useContext(F9)}const H9=jy(function(t){const{children:n,open:r,onOpenChange:o,onOpenChangeComplete:a,defaultOpen:l=!1,disabled:c=!1,modal:f,loopFocus:d=!0,orientation:g="vertical",actionsRef:h,closeParentOnEsc:y=!1,handle:x,triggerId:v,defaultTriggerId:S=null,highlightItemOnHover:E=!0}=t,k=h0(!0),T=Qo(!0),R=P9(!0),L=B9(),j=C.useMemo(()=>L&&T?{type:"menu",store:T.store}:R?{type:"menubar",context:R}:k&&!T?{type:"context-menu",context:k}:{type:void 0},[k,T,R,L]),N=$x.useStore(x?.store,{open:l,openProp:r,activeTriggerId:S,triggerIdProp:v,parent:j});My(()=>{r===void 0&&N.state.open===!1&&l===!0&&N.update({open:!0,activeTriggerId:S})}),N.useControlledProp("openProp",r),N.useControlledProp("triggerIdProp",v),N.useContextCallback("onOpenChangeComplete",a);const A=N.useState("floatingTreeRoot"),D=y6(A),U=Go();qe(()=>{k&&!T?N.update({parent:{type:"context-menu",context:k},floatingNodeId:D,floatingParentNodeId:U}):T&&N.update({floatingNodeId:D,floatingParentNodeId:U})},[k,T,D,U,N]);const I=N.useState("open"),q=N.useState("activeTriggerElement"),$=N.useState("positionerElement"),V=N.useState("hoverEnabled"),Y=N.useState("modal"),H=N.useState("disabled"),B=N.useState("lastOpenChangeReason"),F=N.useState("parent"),G=N.useState("activeIndex"),ie=N.useState("payload"),M=N.useState("floatingParentNodeId"),P=C.useRef(null),Q=M!=null;let _;N.useSyncedValues({disabled:c,modal:F.type===void 0?f:void 0,rootId:Us()});const{openMethod:ee,triggerProps:J}=a9(I);Zy(N);const{forceUnmount:re}=Jy(I,N,()=>{N.update({allowMouseEnter:!1,stickIfOpen:!0})}),pe=C.useRef(F.type!=="context-menu"),fe=jr();C.useEffect(()=>{if(I||(P.current=null),F.type==="context-menu"){if(!I){fe.clear(),pe.current=!1;return}fe.start(500,()=>{pe.current=!0})}},[fe,I,F.type]),i9(I&&Y&&B!==Rr&&ee!=="touch",$),qe(()=>{!I&&!V&&N.set("hoverEnabled",!0)},[I,V,N]);const Ce=C.useRef(!0),Ee=jr(),Ie=st((Xe,Ve)=>{const pt=Ve.reason;if(I===Xe&&Ve.trigger===q&&B===pt||(Ve.preventUnmountOnClose=()=>{N.set("preventUnmountingOnClose",!0)},!Xe&&Ve.trigger==null&&(Ve.trigger=q??void 0),o?.(Xe,Ve),Ve.isCanceled))return;const mt={open:Xe,nativeEvent:Ve.event,reason:Ve.reason,nested:Q};_?.emit("openchange",mt);const Qe=Ve.event;if(Xe===!1&&Qe?.type==="click"&&Qe.pointerType==="touch"&&!Ce.current)return;if(!Xe&&G!==null){const fn=N.context.itemDomElements.current[G];queueMicrotask(()=>{fn?.setAttribute("tabindex","-1")})}Xe&&pt===Yl?(Ce.current=!1,Ee.start(300,()=>{Ce.current=!0})):(Ce.current=!0,Ee.clear());const yt=(pt===ic||pt===t6)&&Qe.detail===0&&Qe?.isTrusted,Pt=!Xe&&(pt===e0||pt==null),Wt={open:Xe,openChangeReason:pt};P.current=Ve.event??null;const yn=Ve.trigger?.id??null;(yn||Xe)&&(Wt.activeTriggerId=yn,Wt.activeTriggerElement=Ve.trigger??null),N.update(Wt),F.type==="menubar"&&(pt===Yl||pt===oc||pt===Rr||pt===qh||pt===Fu)?N.set("instantType","group"):yt||Pt?N.set("instantType",yt?"click":"dismiss"):N.set("instantType",void 0)}),Ye=C.useCallback(Xe=>{const Ve=Et(Xe);return Ve.preventUnmountOnClose=()=>{N.set("preventUnmountingOnClose",!0)},Ve},[N]),je=C.useCallback(()=>{N.setOpen(!1,Ye(qy))},[N,Ye]);C.useImperativeHandle(h,()=>({unmount:re,close:je}),[re,je]);let _e;F.type==="context-menu"&&(_e=F.context),C.useImperativeHandle(_e?.positionerRef,()=>$,[$]),C.useImperativeHandle(_e?.actionsRef,()=>({setOpen:Ie}),[Ie]);const ye=nx({popupStore:N,onOpenChange:Ie});_=ye.context.events,C.useEffect(()=>{const Xe=({open:Ve,eventDetails:pt})=>Ie(Ve,pt);return _.on("setOpen",Xe),()=>{_?.off("setOpen",Xe)}},[_,Ie]);const We=Wy(ye,{enabled:!H,bubbles:{escapeKey:y&&F.type==="menu"},outsidePress(){return F.type!=="context-menu"||P.current?.type==="contextmenu"?!0:pe.current},externalTree:Q?A:void 0}),Te=F6(ye,{role:"menu"}),Re=$6(),he=C.useCallback(Xe=>{N.select("activeIndex")!==Xe&&N.set("activeIndex",Xe)},[N]),Se=ez(ye,{enabled:!H,listRef:N.context.itemDomElements,activeIndex:G,nested:F.type!==void 0,loopFocus:d,orientation:g,parentOrientation:F.type==="menubar"?F.context.orientation:void 0,rtl:Re==="rtl",disabledIndices:w1,onNavigate:he,openOnArrowKeyDown:F.type!=="context-menu",externalTree:Q?A:void 0,focusItemOnHover:E}),ne=C.useCallback(Xe=>{N.context.typingRef.current=Xe},[N]),xe=nz(ye,{listRef:N.context.itemLabels,elementsRef:N.context.itemDomElements,activeIndex:G,resetMs:__,onMatch:Xe=>{I&&Xe!==G&&N.set("activeIndex",Xe)},onTypingChange:ne}),{getReferenceProps:ze,getFloatingProps:Ue,getItemProps:wt,getTriggerProps:ae}=Lf([We,Te,Se,xe]),ve=C.useMemo(()=>{const Xe=Ba(ze(),{onMouseMove(){N.set("allowMouseEnter",!0)}},J);return delete Xe.role,Xe},[ze,N,J]),Oe=C.useMemo(()=>{const Xe=ae();if(!Xe)return Xe;const Ve=Ba(Xe,J);return delete Ve.role,delete Ve["aria-controls"],Ve},[ae,J]),Me=C.useMemo(()=>Ue({onMouseMove(){N.set("allowMouseEnter",!0),F.type==="menu"&&N.set("hoverEnabled",!1)},onClick(){N.select("hoverEnabled")&&N.set("hoverEnabled",!1)},onKeyDown(Xe){const Ve=N.select("keyboardEventRelay");Ve&&!Xe.isPropagationStopped()&&Ve(Xe)}}),[Ue,F.type,N]),He=C.useMemo(()=>wt(),[wt]);N.useSyncedValues({floatingRootContext:ye,activeTriggerProps:ve,inactiveTriggerProps:Oe,popupProps:Me,itemProps:He});const kt=C.useMemo(()=>({store:N,parent:j}),[N,j]),Ft=p.jsx(L9.Provider,{value:kt,children:typeof n=="function"?n({payload:ie}):n});return F.type===void 0||F.type==="context-menu"?p.jsx(bD,{externalTree:A,children:Ft}):Ft});function s$(e){const t=Qo().store,n=C.useMemo(()=>({parentMenu:t}),[t]);return p.jsx(F9.Provider,{value:n,children:p.jsx(H9,{...e})})}function l$(e){const t=e.getBoundingClientRect(),n=window.getComputedStyle(e,"::before"),r=window.getComputedStyle(e,"::after");if(!(n.content!=="none"||r.content!=="none"))return t;const a=parseFloat(n.width)||0,l=parseFloat(n.height)||0,c=parseFloat(r.width)||0,f=parseFloat(r.height)||0,d=Math.max(t.width,a,c),g=Math.max(t.height,l,f),h=d-t.width,y=g-t.height;return{left:t.left-h/2,right:t.right+h/2,top:t.top-y/2,bottom:t.bottom+y/2}}function c$(e={}){const{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=Rx(),{ref:o,index:a}=Vx(e),l=n===a,c=C.useRef(null),f=Ms(o,c);return{compositeProps:C.useMemo(()=>({tabIndex:l?0:-1,onFocus(){r(a)},onMouseMove(){const g=c.current;if(!t||!g)return;const h=g.hasAttribute("disabled")||g.ariaDisabled==="true";!l&&!h&&g.focus()}}),[l,r,a,t]),compositeRef:f,index:a}}function u$(e){const{render:t,className:n,state:r=Ln,props:o=w1,refs:a=w1,metadata:l,stateAttributesMapping:c,tag:f="div",...d}=e,{compositeProps:g,compositeRef:h}=c$({metadata:l});return ln(f,e,{state:r,ref:[...a,h],props:[g,...o,d],stateAttributesMapping:c})}function U9(e){if(Rn(e)&&e.hasAttribute("data-rootownerid"))return e.getAttribute("data-rootownerid")??void 0;if(!oo(e))return U9(fo(e))}function f$(e){const{enabled:t=!0,mouseDownAction:n,open:r}=e,o=C.useRef(!1);return C.useMemo(()=>t?{onMouseDown:a=>{(n==="open"&&!r||n==="close"&&r)&&(o.current=!0,Gt(a.currentTarget).addEventListener("click",()=>{o.current=!1},{once:!0}))},onClick:a=>{o.current&&(o.current=!1,a.preventBaseUIHandler())}}:Ln,[t,n,r])}const Th=2,d$=Tk(function(t,n){const{render:r,className:o,disabled:a=!1,nativeButton:l=!0,id:c,openOnHover:f,delay:d=100,closeDelay:g=0,handle:h,payload:y,...x}=t,v=Qo(!0),S=h?.store??v?.store;if(!S)throw new Error(Gn(85));const E=Gi(c),k=S.useState("isTriggerActive",E),T=S.useState("floatingRootContext"),R=S.useState("isOpenedByTrigger",E),L=C.useRef(null),j=p$(),N=Rx(!0),A=Ya(),D=C.useMemo(()=>A??new Gy,[A]),U=y6(D),I=Go(),{registerTrigger:q,isMountedByThisTrigger:$}=D6(E,L,S,{payload:y,closeDelay:g,parent:j,floatingTreeRoot:D,floatingNodeId:U,floatingParentNodeId:I,keyboardEventRelay:N?.relayKeyboardEvent}),V=j.type==="menubar",Y=S.useState("disabled"),H=a||Y||V&&j.context.disabled,{getButtonProps:B,buttonRef:F}=zf({disabled:H,native:l});C.useEffect(()=>{!R&&j.type===void 0&&(S.context.allowMouseUpTriggerRef.current=!1)},[S,R,j.type]);const G=C.useRef(null),ie=jr(),M=st(Te=>{if(!G.current)return;ie.clear(),S.context.allowMouseUpTriggerRef.current=!1;const Re=Te.target;if(ht(G.current,Re)||ht(S.select("positionerElement"),Re)||Re===G.current||Re!=null&&U9(Re)===S.select("rootId"))return;const he=l$(G.current);Te.clientX>=he.left-Th&&Te.clientX<=he.right+Th&&Te.clientY>=he.top-Th&&Te.clientY<=he.bottom+Th||D.events.emit("close",{domEvent:Te,reason:H_})});C.useEffect(()=>{R&&S.select("lastOpenChangeReason")===Rr&&Gt(G.current).addEventListener("mouseup",M,{once:!0})},[R,M,S]);const P=V&&j.context.hasSubmenuOpen,_=ox(T,{enabled:(f??P)&&!H&&j.type!=="context-menu"&&(!V||P&&!$),handleClose:ax({blockPointerEvents:!V}),mouseOnly:!0,move:!1,restMs:j.type===void 0?d:void 0,delay:{close:g},triggerElementRef:L,externalTree:D,isActiveTrigger:k}),ee=h$(R,S.select("lastOpenChangeReason")),J=b6(T,{enabled:!H&&j.type!=="context-menu",event:R&&V?"click":"mousedown",toggle:!0,ignoreMouse:!1,stickIfOpen:j.type===void 0?ee:!1}),re=I6(T,{enabled:!H&&P}),pe=f$({open:R,enabled:V,mouseDownAction:"open"}),fe=Lf([J,re]),Ce={disabled:H,open:R},Ee=S.useState("triggerProps",$),Ie=[G,n,F,q,L],Ye=[fe.getReferenceProps(),_??Ln,Ee,{"aria-haspopup":"menu",id:E,onMouseDown:Te=>{if(S.select("open"))return;ie.start(200,()=>{S.context.allowMouseUpTriggerRef.current=!0}),Gt(Te.currentTarget).addEventListener("mouseup",M,{once:!0})}},V?{role:"menuitem"}:{},pe,x,B],je=C.useRef(null),_e=st(Te=>{Mi.flushSync(()=>{S.setOpen(!1,Et(oc,Te.nativeEvent,Te.currentTarget))}),j_(je.current)?.focus()}),ye=st(Te=>{const Re=S.select("positionerElement");if(Re&&Gl(Te,Re))S.context.beforeContentFocusGuardRef.current?.focus();else{Mi.flushSync(()=>{S.setOpen(!1,Et(oc,Te.nativeEvent,Te.currentTarget))});let he=O_(S.context.triggerFocusTargetRef.current||L.current);for(;he!==null&&ht(Re,he);){const Se=he;if(he=Hy(he),he===Se)break}he?.focus()}}),We=ln("button",t,{enabled:!V,stateAttributesMapping:FS,state:Ce,ref:Ie,props:Ye});return V?p.jsx(u$,{tag:"button",render:r,className:o,state:Ce,refs:Ie,props:Ye,stateAttributesMapping:FS}):R?p.jsxs(C.Fragment,{children:[p.jsx(ac,{ref:je,onFocus:_e},`${E}-pre-focus-guard`),p.jsx(C.Fragment,{children:We},E),p.jsx(ac,{ref:S.context.triggerFocusTargetRef,onFocus:ye},`${E}-post-focus-guard`)]}):p.jsx(C.Fragment,{children:We},E)});function h$(e,t){const n=jr(),[r,o]=C.useState(!1);return qe(()=>{e&&t==="trigger-hover"?(o(!0),n.start(D_,()=>{o(!1)})):e||(n.clear(),o(!1))},[e,t,n]),r}function p$(){const e=h0(!0),t=Qo(!0),n=P9();return C.useMemo(()=>n?{type:"menubar",context:n}:e&&!t?{type:"context-menu",context:e}:{type:void 0},[e,t,n])}const m$=C.forwardRef(function(t,n){const{className:r,render:o,orientation:a="horizontal",...l}=t;return ln("div",t,{state:{orientation:a},ref:n,props:[{role:"separator","aria-orientation":a},l]})}),g$=C.forwardRef(function(t,n){const{render:r,className:o,label:a,id:l,nativeButton:c=!1,openOnHover:f=!0,delay:d=100,closeDelay:g=0,disabled:h=!1,...y}=t,x=Vx(),v=qx(),{store:S}=Qo(),E=Gi(l),k=S.useState("open"),T=S.useState("floatingRootContext"),R=S.useState("floatingTreeRoot"),L=_6(E,S),j=C.useCallback(J=>{const re=L(J);return J!==null&&S.select("open")&&S.select("activeTriggerId")==null&&S.update({activeTriggerId:E,activeTriggerElement:J,closeDelay:g}),re},[L,g,S,E]),N=C.useRef(null),A=C.useCallback(J=>{N.current=J,S.set("activeTriggerElement",J)},[S]),D=B9();if(!D?.parentMenu)throw new Error(Gn(37));S.useSyncedValue("closeDelay",g);const U=D.parentMenu,I=U.useState("itemProps"),q=U.useState("isActive",x.index),$=C.useMemo(()=>({type:"submenu-trigger",setActive(){U.set("activeIndex",x.index)}}),[U,x.index]),V=S.useState("disabled"),Y=h||V,{getItemProps:H,itemRef:B}=_9({closeOnClick:!1,disabled:Y,highlighted:q,id:E,store:S,typingRef:U.context.typingRef,nativeButton:c,itemMetadata:$,nodeId:v?.nodeId}),F=S.useState("hoverEnabled"),G=U.useState("allowMouseEnter"),ie=ox(T,{enabled:F&&f&&!Y,handleClose:ax({blockPointerEvents:!0}),mouseOnly:!0,move:!0,restMs:d,delay:G?{open:d,close:g}:0,triggerElementRef:N,externalTree:R}),M=b6(T,{enabled:!Y,event:"mousedown",toggle:!f,ignoreMouse:f,stickIfOpen:!1}),P=Lf([M]),Q=S.useState("triggerProps",!0);return delete Q.id,ln("div",t,{state:{disabled:Y,highlighted:q,open:k},stateAttributesMapping:B6,props:[P.getReferenceProps(),ie,Q,I,{tabIndex:k||q?0:-1,onBlur(){q&&U.set("activeIndex",null)}},y,H],ref:[n,x.ref,B,j,A]})});function Ws({...e}){return p.jsx(H9,{"data-slot":"dropdown-menu",...e})}function Ks({...e}){return p.jsx(d$,{"data-slot":"dropdown-menu-trigger",...e})}function Za({align:e="start",alignOffset:t=0,side:n="bottom",sideOffset:r=4,className:o,...a}){return p.jsx(ZV,{children:p.jsx(r$,{className:"isolate z-50 outline-none",align:e,alignOffset:t,side:n,sideOffset:r,children:p.jsx(QV,{"data-slot":"dropdown-menu-content",className:we("z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg border border-border bg-neutral-900 p-1 text-foreground shadow-md ring-0 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-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 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95",o),...a})})})}function Os({...e}){return p.jsx(VV,{"data-slot":"dropdown-menu-group",...e})}function Ql({className:e,inset:t,...n}){return p.jsx($V,{"data-slot":"dropdown-menu-label","data-inset":t,className:we("px-2 py-1.5 text-xs font-medium text-muted-foreground data-inset:pl-8",e),...n})}function _n({className:e,inset:t,variant:n="default",...r}){return p.jsx(GV,{"data-slot":"dropdown-menu-item","data-inset":t,"data-variant":n,className:we("group/dropdown-menu-item relative flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-sm text-foreground outline-hidden select-none hover:bg-neutral-800 focus:bg-neutral-800 not-data-[variant=destructive]:focus:**:text-foreground data-inset:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",e),...r})}function Gx({...e}){return p.jsx(s$,{"data-slot":"dropdown-menu-sub",...e})}function Yx({className:e,inset:t,children:n,...r}){return p.jsxs(g$,{"data-slot":"dropdown-menu-sub-trigger","data-inset":t,className:we("flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-sm text-foreground outline-hidden select-none hover:bg-neutral-800 focus:bg-neutral-800 data-inset:pl-8 data-popup-open:bg-neutral-800 data-open:bg-neutral-800 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r,children:[n,p.jsx(VE,{className:"ml-auto"})]})}function Wx({align:e="start",alignOffset:t=-3,side:n="right",sideOffset:r=0,className:o,...a}){return p.jsx(Za,{"data-slot":"dropdown-menu-sub-content",className:we("w-auto min-w-24 rounded-lg border border-border bg-neutral-900 p-1 text-foreground shadow-lg ring-0 duration-100 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 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",o),align:e,alignOffset:t,side:n,sideOffset:r,...a})}function Fo({className:e,...t}){return p.jsx(m$,{"data-slot":"dropdown-menu-separator",className:we("-mx-1 my-1 h-px bg-border",e),...t})}function q9(e){const t=e.split(/[-_\s]+/).filter(Boolean);return t.length>=2?(t[0][0]+t[1][0]).toUpperCase():e.slice(0,2).toUpperCase()}const y$=()=>{const{apiClient:e}=Be.getState();return e?e.request(_f.LOGOUT):Promise.reject(new Error("Not connected"))},x$=({mutationConfig:e}={})=>{const t=cn(),{onSuccess:n,...r}=e??{};return wn({onSuccess(...o){t.invalidateQueries({queryKey:so().queryKey}),n?.(...o)},...r,mutationFn:y$})};function ja({className:e,size:t="default",...n}){return p.jsx("div",{"data-slot":"card","data-size":t,className:we("group/card flex flex-col gap-6 overflow-hidden rounded-xl bg-card py-6 text-sm text-card-foreground shadow-xs ring-1 ring-foreground/10 has-[>img:first-child]:pt-0 data-[size=sm]:gap-4 data-[size=sm]:py-4 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",e),...n})}function b$({className:e,...t}){return p.jsx("div",{"data-slot":"card-title",className:we("text-base leading-normal font-medium group-data-[size=sm]/card:text-sm",e),...t})}function Ah({className:e,...t}){return p.jsx("div",{"data-slot":"card-description",className:we("text-sm text-muted-foreground",e),...t})}const v$=2500;function w$({onOpenChange:e,open:t}){const n=cn(),r=ji(h=>h.isLoggingIn),o=ji(h=>h.setLoggingIn),a=Be(h=>h.connectionState),[l,c]=C.useState({type:"idle"});C.useEffect(()=>{t||(c({type:"idle"}),o(!1))},[t,o]),C.useEffect(()=>l.type!=="waiting"?void 0:S9(y=>{y.success&&y.user?(ut.success(`Logged in as ${y.user.email}`,{position:"top-center"}),n.invalidateQueries({queryKey:so().queryKey}),e(!1)):c({message:y.error??"Authentication failed",type:"error"}),o(!1)}),[e,n,o,l.type]),C.useEffect(()=>{if(l.type!=="waiting")return;let h=!1;async function y(){try{const v=await n.fetchQuery(so());if(h)return;v.isAuthorized&&v.user&&(ut.success(`Logged in as ${v.user.email}`,{position:"top-center"}),o(!1),e(!1))}catch{}}const x=globalThis.setInterval(y,v$);return()=>{h=!0,globalThis.clearInterval(x)}},[e,n,o,l.type]);async function f(){o(!0),c({type:"starting"});try{const h=await w9();if(!zx(h.authUrl))throw new Error("Received an unsafe OAuth URL from the daemon");window.open(h.authUrl,"_blank","noopener,noreferrer"),c({authUrl:h.authUrl,type:"waiting"})}catch(h){o(!1),c({message:h instanceof Error?h.message:"Unable to start login",type:"error"})}}function d(){c({type:"idle"})}const g=a!=="connected"||r;return p.jsx($s,{onOpenChange:e,open:t,children:p.jsxs(Gs,{children:[p.jsxs(ui,{children:[p.jsx(fi,{children:"Redirecting to ByteRover"}),p.jsxs(Ff,{children:["Please sign in to your ",p.jsx("span",{className:"text-foreground",children:"byterover.dev"})," account to continue."]})]}),l.type==="starting"&&p.jsx("div",{className:"rounded-lg border border-blue-500/20 bg-blue-500/5 p-3 text-sm text-blue-700",children:"Starting authentication…"}),l.type==="waiting"&&p.jsxs(ja,{className:"p-4 gap-2",children:[p.jsx("div",{children:"Finish signing in in the new tab."}),p.jsxs("div",{className:"text-xs text-muted-foreground",children:["If the tab didn’t open,"," ",p.jsx("a",{className:"underline underline-offset-2",href:l.authUrl,rel:"noopener noreferrer",target:"_blank",children:"click this link"}),"."]})]}),l.type==="error"&&p.jsx("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 p-3 text-sm text-destructive",children:l.message}),p.jsx(Qa,{children:l.type==="error"?p.jsxs(p.Fragment,{children:[p.jsx(H1,{render:p.jsx(De,{className:"cursor-pointer",variant:"ghost"}),children:"Cancel"}),p.jsx(De,{className:"cursor-pointer",onClick:d,children:"Try again"})]}):p.jsxs(p.Fragment,{children:[p.jsx(H1,{render:p.jsx(De,{className:"cursor-pointer",variant:"ghost"}),children:"Cancel"}),p.jsx(De,{className:"cursor-pointer",disabled:g,onClick:f,children:l.type==="waiting"?"Waiting for authentication…":"Proceed to Login"})]})})]})})}function S$(){const[e,t]=C.useState(!1);return p.jsxs(p.Fragment,{children:[p.jsx(De,{className:"h-auto rounded-full p-0 ml-2.5",onClick:()=>t(!0),variant:"ghost",children:p.jsx(f0,{children:p.jsx(d0,{className:"bg-transparent",children:p.jsx(Lx,{className:"size-4 shrink-0"})})})}),p.jsx(w$,{onOpenChange:t,open:e})]})}function C$(){const e=ji(o=>o.user),t=x$(),n=cn();if(C.useEffect(()=>{e||n.invalidateQueries({queryKey:so().queryKey}).catch(()=>{})},[n,e]),!e)return p.jsxs(De,{className:"ml-2.5",disabled:!0,size:"sm",variant:"outline",children:[p.jsx(Lx,{className:"size-4 shrink-0 text-muted-foreground"}),p.jsx("span",{children:"Signed in"})]});const r=e.name??e.email;return p.jsxs(Ws,{children:[p.jsx(Ks,{children:p.jsxs(f0,{className:"cursor-pointer",children:[p.jsx(Ux,{alt:r,src:e.avatarUrl}),p.jsx(d0,{children:q9(r)})]})}),p.jsxs(Za,{align:"start",className:"w-(--anchor-width) min-w-56",sideOffset:6,children:[p.jsx(Os,{children:p.jsxs(Ql,{className:"flex flex-col gap-0.5",children:[p.jsx("span",{className:"text-xs tracking-widest text-muted-foreground",children:"Signed in"}),p.jsx("span",{className:"truncate text-sm font-medium text-card-foreground!",children:e.email})]})}),p.jsx(Fo,{}),p.jsxs(_n,{disabled:t.isPending,onClick:()=>t.mutate(),children:[p.jsx(AU,{className:"size-4 text-muted-foreground!"}),p.jsx("span",{className:"text-sm",children:t.isPending?"Logging out…":"Log out"})]})]})]})}function E$(){const e=ji(n=>n.isAuthorized);return ji(n=>n.isLoadingInitial)?p.jsx(De,{className:"ml-2.5",disabled:!0,size:"icon",variant:"outline",children:p.jsx(Lx,{className:"size-4 shrink-0 text-muted-foreground animate-pulse"})}):e?p.jsx(C$,{}):p.jsx(S$,{})}function k$(){const e=on(o=>o.seenWelcome),t=on(o=>o.tourCompleted),n=on(o=>o.startTour),r=!e&&!t;return p.jsxs(Ws,{children:[p.jsx(Ks,{render:p.jsxs(De,{size:"sm",variant:"ghost",children:[p.jsx(ZH,{className:"size-4"}),"Help",r&&p.jsx("span",{"aria-hidden":!0,className:we("size-1.5 rounded-full bg-orange-500")})]})}),p.jsxs(Za,{align:"end",className:"w-56",children:[p.jsxs(_n,{className:"bg-primary/8 hover:bg-primary/12 focus:bg-primary/12",onClick:()=>n(),children:[p.jsx(QH,{className:"text-primary-foreground"}),p.jsx("span",{children:t?"Restart the tour":"Take the tour"})]}),p.jsx(Fo,{}),p.jsx(_n,{render:p.jsxs("a",{href:"https://docs.byterover.dev",rel:"noopener noreferrer",target:"_blank",children:[p.jsx(IH,{}),p.jsx("span",{children:"Documentation"})]})}),p.jsx(_n,{render:p.jsxs("a",{href:"https://github.com/campfirein/byterover-cli/issues",rel:"noopener noreferrer",target:"_blank",children:[p.jsx(PH,{}),p.jsx("span",{children:"Report an issue"})]})})]})]})}function T$(e){const{children:t,open:n,defaultOpen:r=!1,onOpenChange:o,onOpenChangeComplete:a,actionsRef:l,handle:c,triggerId:f,defaultTriggerId:d=null}=e,g=Ka(),h=!!g,y=Zn(()=>c?.store??new l9({open:r,openProp:n,activeTriggerId:d,triggerIdProp:f,modal:!0,disablePointerDismissal:!0,nested:h,role:"alertdialog"})).current;y.useControlledProp("openProp",n),y.useControlledProp("triggerIdProp",f),y.useSyncedValue("nested",h),y.useContextCallback("onOpenChange",o),y.useContextCallback("onOpenChangeComplete",a);const x=y.useState("payload");s9({store:y,actionsRef:l,parentContext:g?.store.context});const v=C.useMemo(()=>({store:y}),[y]);return p.jsx(Tx.Provider,{value:v,children:typeof t=="function"?t({payload:x}):t})}function p0({...e}){return p.jsx(T$,{"data-slot":"alert-dialog",...e})}function A$({...e}){return p.jsx(Ox,{"data-slot":"alert-dialog-portal",...e})}function R$({className:e,...t}){return p.jsx(Ax,{"data-slot":"alert-dialog-overlay",className:we("fixed inset-0 isolate z-50 bg-background/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",e),...t})}function m0({className:e,size:t="default",...n}){return p.jsxs(A$,{children:[p.jsx(R$,{}),p.jsx(Nx,{"data-slot":"alert-dialog-content","data-size":t,className:we("group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-6 rounded-xl bg-background p-6 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-lg data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...n})]})}function g0({className:e,...t}){return p.jsx("div",{"data-slot":"alert-dialog-header",className:we("grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-6 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",e),...t})}function y0({className:e,...t}){return p.jsx("div",{"data-slot":"alert-dialog-footer",className:we("flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",e),...t})}function x0({className:e,...t}){return p.jsx(u9,{"data-slot":"alert-dialog-title",className:we("text-lg font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",e),...t})}function b0({className:e,...t}){return p.jsx(WT,{"data-slot":"alert-dialog-description",className:we("text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...t})}function v0({className:e,variant:t="outline",size:n="default",...r}){return p.jsx(Pf,{"data-slot":"alert-dialog-cancel",className:we(e),render:p.jsx(De,{variant:t,size:n}),...r})}const N$="state:getProjectConfig",O$=e=>{const{apiClient:t}=Be.getState();return t?t.request(N$,{projectPath:e}):Promise.reject(new Error("Not connected"))},j$=e=>({enabled:e.length>0,queryFn:()=>O$(e),queryKey:["project-config",e]}),V9=({projectPath:e,queryConfig:t})=>br({...t,...j$(e)}),M$=()=>{const{apiClient:e}=Be.getState();return e?e.request(mB.GET):Promise.reject(new Error("Not connected"))},L$=()=>({queryFn:M$,queryKey:["projects"]}),$9=({queryConfig:e}={})=>br({...L$(),...e}),_$=/^(?:\/Users\/|\/home\/|[A-Za-z]:[/\\]Users[/\\])[^/\\]+([/\\].*)$/;function G9(e){const t=_$.exec(e);return t?`~${t[1]}`:e}function w0(e){return e.replace(/[/\\]+$/,"").split(/[/\\]/).at(-1)||e}const RC=["bg-gradient-to-br from-red-600 to-red-500 text-white","bg-gradient-to-br from-orange-400 to-pink-500 text-white","bg-gradient-to-br from-teal-500 to-emerald-500 text-white","bg-gradient-to-br from-blue-800 to-blue-600 text-white","bg-gradient-to-br from-sky-400 to-sky-300 text-white","bg-gradient-to-br from-purple-500 to-pink-500 text-white","bg-gradient-to-br from-green-500 to-lime-300 text-white","bg-gradient-to-br from-yellow-300 to-orange-400 text-white","bg-gradient-to-br from-orange-500 to-red-600 text-white","bg-gradient-to-br from-cyan-400 to-cyan-300 text-white"];function D$(e){let t=0;for(let n=0;n<e.length;n++){const r=e.codePointAt(n)??0;t=Math.abs(Math.trunc(t*31+r))}return RC[t%RC.length]}const I$={lg:"size-7 text-xs",md:"size-6 text-xs",sm:"size-5 text-[10px]"};function Kx({name:e,seed:t,size:n="md"}){return p.jsx("span",{className:we("relative flex shrink-0 items-center justify-center overflow-hidden rounded font-extrabold leading-4",'before:absolute before:inset-0 before:bg-black/10 before:content-[""]',I$[n],D$(t??e)),children:p.jsx("span",{className:"relative",children:q9(e)})})}function Y9({onClick:e,project:t}){const n=w0(t.projectPath);return p.jsxs("button",{className:"flex w-full items-center gap-2 rounded-md p-2 text-left transition-colors hover:bg-accent cursor-pointer",onClick:e,type:"button",children:[p.jsx(Kx,{name:n,seed:t.projectPath,size:"lg"}),p.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[p.jsx("span",{className:"truncate text-sm font-medium leading-5 text-card-foreground",children:n}),p.jsx("span",{className:"truncate text-xs leading-4 text-muted-foreground",children:G9(t.projectPath)})]})]})}function W9({onOpenChange:e,onSelect:t,open:n,projects:r}){const[o,a]=C.useState(""),l=C.useMemo(()=>{const f=o.trim().toLowerCase();return f?r.filter(d=>d.projectPath.toLowerCase().includes(f)):r},[r,o]);function c(f){t(f),e(!1)}return p.jsx($s,{onOpenChange:e,open:n,children:p.jsxs(Gs,{className:"gap-2 sm:max-w-lg",children:[p.jsxs(ui,{children:[p.jsx(fi,{children:"All projects"}),p.jsx(Ff,{children:p.jsxs("div",{className:"relative",children:[p.jsx(vc,{className:"absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),p.jsx(Ko,{autoFocus:!0,className:"pl-9",onChange:f=>a(f.target.value),placeholder:"Search...",value:o})]})})]}),p.jsx("div",{className:"-mx-4 no-scrollbar max-h-[60vh] min-h-[200px] overflow-y-auto px-4 mt-2",children:l.length===0?p.jsx("p",{className:"px-2 py-4 text-center text-xs text-muted-foreground",children:"No projects match your search."}):l.map(f=>p.jsx(Y9,{onClick:()=>c(f),project:f},f.projectPath))})]})})}const NC=5;function K9({name:e,project:t,remoteLabel:n}){return p.jsxs(p.Fragment,{children:[p.jsx(Kx,{name:e,seed:t.projectPath}),p.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[p.jsx("span",{className:"truncate text-sm font-medium leading-5 text-card-foreground!",children:e}),p.jsx("span",{className:"truncate text-xs leading-4 text-muted-foreground!",children:G9(t.projectPath)}),n&&p.jsx("span",{className:"text-muted-foreground! mono flex items-start gap-1 text-[10px] leading-4",children:p.jsxs("span",{className:"min-w-0 wrap-break-word",children:[p.jsx("span",{children:"Remote space: "}),p.jsx("span",{className:"text-primary-foreground! font-medium",children:n})]})})]})]})}function z$({onSelect:e,project:t,showRemote:n=!1}){const r=w0(t.projectPath),{data:o}=V9({projectPath:t.projectPath,queryConfig:{enabled:n}}),a=o?.brvConfig?.teamName,l=o?.brvConfig?.spaceName,c=a&&l?`${a} / ${l}`:void 0;return p.jsx(_n,{className:"gap-2 rounded-md",onClick:e,children:p.jsx(K9,{name:r,project:t,remoteLabel:c})})}function P$({isSelected:e,onSelect:t,project:n}){const r=w0(n.projectPath),{data:o}=V9({projectPath:n.projectPath}),a=o?.brvConfig?.teamName,l=o?.brvConfig?.spaceName,c=a&&l?`${a} / ${l}`:void 0,f=o?.remoteUrl&&zx(o.remoteUrl)?o.remoteUrl:void 0;return p.jsxs(Gx,{children:[p.jsx(Yx,{className:"gap-2 rounded-md",children:p.jsx(K9,{name:r,project:n,remoteLabel:c})}),p.jsxs(Wx,{className:"min-w-56",children:[p.jsxs(_n,{disabled:e,onClick:t,children:[p.jsx(NH,{className:"size-4"}),p.jsx("span",{className:"text-sm",children:e?"Current project":"Switch to this project"})]}),p.jsxs(_n,{disabled:!f,onClick:()=>{f&&window.open(f,"_blank","noopener,noreferrer")},children:[p.jsx(BU,{className:"size-4"}),p.jsx("span",{className:"text-sm",children:"Open Remote space"})]})]})]})}function F$(){const e=Be(v=>v.selectedProject),t=Be(v=>v.setSelectedProject),{data:n}=$9({queryConfig:{refetchInterval:3e3,refetchIntervalInBackground:!1,staleTime:30*1e3}}),r=C.useMemo(()=>n?.locations??[],[n]),{openProjects:o,recentProjects:a}=C.useMemo(()=>{const v=[],S=[];for(const E of r)E.isActive?v.push(E):S.push(E);return{openProjects:v,recentProjects:S}},[r]),[l,c]=C.useState(!1),[f,d]=C.useState(!1),[g,h]=C.useState(!1),y=w0(e);function x(v){v.projectPath!==e&&t(v.projectPath)}return p.jsxs(p.Fragment,{children:[p.jsxs(Ws,{onOpenChange:c,open:l,children:[p.jsxs(Ks,{render:p.jsx(De,{variant:"ghost"}),children:[e?p.jsx(Kx,{name:y,seed:e,size:"sm"}):null,p.jsx("span",{className:"truncate",children:y||"No project selected"}),p.jsx(Bf,{className:"size-4 shrink-0"})]}),p.jsxs(Za,{align:"start",className:"w-(--anchor-width) min-w-72",sideOffset:6,children:[p.jsxs(_n,{onClick:()=>d(!0),children:[p.jsx(fU,{className:"size-4"}),p.jsx("span",{className:"text-sm",children:"Open Project"})]}),p.jsx(Fo,{}),o.length>0&&p.jsxs(Os,{children:[p.jsx(Ql,{children:"Open Projects"}),o.map(v=>p.jsx(P$,{isSelected:v.projectPath===e,onSelect:()=>x(v),project:v},v.projectPath)),p.jsx(Fo,{})]}),a.length>0&&p.jsxs(Os,{children:[p.jsx(Ql,{children:"Recent Projects"}),a.slice(0,NC).map(v=>p.jsx(z$,{onSelect:()=>x(v),project:v},v.projectPath)),a.length>NC&&p.jsx(_n,{onClick:()=>h(!0),children:p.jsx("span",{className:"text-xs",children:"See all"})})]})]})]}),p.jsx(p0,{onOpenChange:d,open:f,children:p.jsxs(m0,{children:[p.jsxs(g0,{children:[p.jsx(x0,{children:"Add a project"}),p.jsxs(b0,{children:["To add a project, run ",p.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 text-sm",children:"brv webui"})," in that folder from your terminal. Once registered, it will appear here."]})]}),p.jsx(y0,{children:p.jsx(v0,{children:"Got it"})})]})}),p.jsx(W9,{onOpenChange:h,onSelect:x,open:g,projects:r})]})}const B$=()=>{const{apiClient:e}=Be.getState();return e?e.request(rr.BRANCH,{action:"list",all:!0}).then(t=>{if(t.action!=="list")throw new Error(`Unexpected branch response action: ${t.action}`);return t.branches}):Promise.reject(new Error("Not connected"))},Ja=()=>({queryFn:B$,queryKey:["vc","branches","all"],refetchInterval:1e4,refetchIntervalInBackground:!1,staleTime:5e3}),H$=({queryConfig:e}={})=>br({...Ja(),...e}),U$=e=>{const{apiClient:t}=Be.getState();return t?t.request(rr.BRANCH,{action:"set-upstream",upstream:e}):Promise.reject(new Error("Not connected"))},q$=({mutationConfig:e}={})=>{const t=cn(),{onSuccess:n,...r}=e??{};return wn({onSuccess(...o){t.invalidateQueries({queryKey:hi().queryKey}),t.invalidateQueries({queryKey:Ja().queryKey}),n?.(...o)},...r,mutationFn:U$})},V$=e=>{const{apiClient:t}=Be.getState();return t?t.request(rr.CHECKOUT,e):Promise.reject(new Error("Not connected"))},Q9=({mutationConfig:e}={})=>{const t=cn(),{onSuccess:n,...r}=e??{};return wn({onSuccess(...o){t.invalidateQueries({queryKey:hi().queryKey}),t.invalidateQueries({queryKey:Ja().queryKey}),n?.(...o)},...r,mutationFn:V$})},$$=(e={})=>{const{apiClient:t}=Be.getState();return t?t.request(rr.FETCH,e):Promise.reject(new Error("Not connected"))},G$=({mutationConfig:e}={})=>{const t=cn(),{onSuccess:n,...r}=e??{};return wn({onSuccess(...o){t.invalidateQueries({queryKey:hi().queryKey}),t.invalidateQueries({queryKey:Ja().queryKey}),n?.(...o)},...r,mutationFn:$$})},Y$=(e={})=>{const{apiClient:t}=Be.getState();return t?t.request(rr.PULL,e):Promise.reject(new Error("Not connected"))},X9=({mutationConfig:e}={})=>{const t=cn(),{onSuccess:n,...r}=e??{};return wn({onSuccess(...o){t.invalidateQueries({queryKey:hi().queryKey}),t.invalidateQueries({queryKey:Ja().queryKey}),n?.(...o)},...r,mutationFn:Y$})};function W$(e,t){const n=t.trim().toLowerCase();return n===""?[...e]:e.filter(r=>r.name.toLowerCase().includes(n))}const OC="refs/remotes/";function K$(e){const t=e.startsWith(OC)?e.slice(OC.length):e,n=t.indexOf("/");return n===-1?"unknown":t.slice(0,n)}function Q$(e){const t=[],n=new Map;for(const r of e)if(r.isRemote){const o=K$(r.name),a=n.get(o);a?a.push(r):n.set(o,[r])}else t.push(r);return{locals:t,remotesByHost:n}}function X$(e,t){return t?e.some(r=>!r.isRemote&&r.name===t)?[...e]:[{isCurrent:!0,isRemote:!1,name:t},...e]:[...e]}const Z$=e=>{const{apiClient:t}=Be.getState();return t?t.request(rr.BRANCH,{action:"delete",name:e}):Promise.reject(new Error("Not connected"))},J$=({mutationConfig:e}={})=>{const t=cn(),{onSuccess:n,...r}=e??{};return wn({onSuccess(...o){t.invalidateQueries({queryKey:Ja().queryKey}),n?.(...o)},...r,mutationFn:Z$})};function eG({branchName:e,onOpenChange:t,open:n}){const r=J$();async function o(){try{await r.mutateAsync(e),ut.success(`Deleted ${e}`,{position:"top-center"}),t(!1)}catch(a){ut.error(a instanceof Error?a.message:"Failed to delete branch",{position:"top-center"})}}return p.jsx(p0,{onOpenChange:t,open:n,children:p.jsxs(m0,{children:[p.jsxs(g0,{children:[p.jsx(x0,{children:"Delete branch?"}),p.jsxs(b0,{children:["Branch ",p.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 text-sm",children:e})," will be removed. Unmerged commits on this branch will be lost unless they are reachable from another ref."]})]}),p.jsxs(y0,{children:[p.jsx(v0,{children:"Cancel"}),p.jsx(De,{disabled:r.isPending,onClick:o,variant:"destructive",children:r.isPending?"Deleting…":"Delete branch"})]})]})})}const tG=()=>{const{apiClient:e}=Be.getState();return e?e.request(rr.INIT):Promise.reject(new Error("Not connected"))},nG=({mutationConfig:e}={})=>{const t=cn(),{onSuccess:n,...r}=e??{};return wn({onSuccess(...o){t.invalidateQueries({queryKey:hi().queryKey}),t.invalidateQueries({queryKey:Ja().queryKey}),n?.(...o)},...r,mutationFn:tG})};function Z9(){const e=nG();async function t(){try{const n=await e.mutateAsync();ut.success(n.reinitialized?"Reinitialized version control":"Initialized version control",{position:"top-center"})}catch(n){ut.error(n instanceof Error?n.message:"Failed to initialize",{position:"top-center"})}}return p.jsxs(De,{disabled:e.isPending,onClick:()=>{t().catch(()=>{})},size:"sm",variant:"outline",children:[p.jsx(jx,{className:"size-4 shrink-0"}),p.jsx("span",{children:e.isPending?"Initializing…":"Initialize Version Control"})]})}function rG({className:e,...t}){return p.jsx("label",{"data-slot":"label",className:we("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}const iG=o0("group/field flex w-full gap-3 data-[invalid=true]:text-destructive",{variants:{orientation:{vertical:"flex-col *:w-full [&>.sr-only]:w-auto",horizontal:"flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",responsive:"flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"}},defaultVariants:{orientation:"vertical"}});function oG({className:e,orientation:t="vertical",...n}){return p.jsx("div",{role:"group","data-slot":"field","data-orientation":t,className:we(iG({orientation:t}),e),...n})}function aG({className:e,...t}){return p.jsx(rG,{"data-slot":"field-label",className:we("group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border *:data-[slot=field]:p-3 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10","has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col",e),...t})}function sG({className:e,...t}){return p.jsx("p",{"data-slot":"field-description",className:we("text-left text-sm leading-normal font-normal text-muted-foreground group-has-data-horizontal/field:text-balance [[data-variant=legend]+&]:-mt-1.5","last:mt-0 nth-last-2:-mt-1","[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",e),...t})}function lG({initialName:e="",onOpenChange:t,open:n,startPoint:r}){const o=C.useId(),[a,l]=C.useState(e),[c,f]=C.useState(),d=Q9();C.useEffect(()=>{n&&(l(e),f(void 0))},[e,n]);async function g(){const h=a.trim();if(h){f(void 0);try{await d.mutateAsync({branch:h,create:!0,startPoint:r}),ut.success(r?`Created ${h} from ${r} and switched to it`:`Created and switched to ${h}`,{position:"top-center"}),t(!1)}catch(y){f(y instanceof Error?y.message:"Failed to create branch")}}}return p.jsx($s,{onOpenChange:t,open:n,children:p.jsxs(Gs,{children:[p.jsxs(ui,{children:[p.jsx(fi,{children:"New branch"}),p.jsx(Ff,{children:r?`Create a branch based on ${r} and switch to it.`:"Create a branch from the current HEAD and switch to it."})]}),p.jsxs(oG,{"data-invalid":!!c,children:[p.jsx(aG,{htmlFor:o,children:"Branch name"}),p.jsx(Ko,{"aria-invalid":!!c,autoFocus:!0,id:o,onChange:h=>{l(h.target.value),c&&f(void 0)},onKeyDown:h=>{h.key==="Enter"&&g()},placeholder:"Branch name",value:a}),p.jsx(sG,{children:c})]}),p.jsxs(Qa,{children:[p.jsx(H1,{render:p.jsx(De,{className:"cursor-pointer",variant:"ghost"}),children:"Cancel"}),p.jsx(De,{className:"cursor-pointer",disabled:a.trim().length===0||d.isPending,onClick:g,children:d.isPending?"Creating…":"Create branch"})]})]})})}const jl={position:"top-center"};function cG(e){return e?e.initialized?e.branch?e.branch:"detached":"No git repo":"branch"}function U1(e){const t=e.startsWith("refs/remotes/")?e.slice(13):e,n=t.indexOf("/");return n===-1?t:t.slice(n+1)}function uG(){const e=qa(),[t,n]=C.useState(!1),[r,o]=C.useState(""),[a,l]=C.useState(null),[c,f]=C.useState(""),[d,g]=C.useState(),[h,y]=C.useState(null),[x,v]=C.useState(new Set(["origin"])),S=Bx(),E=H$({queryConfig:{enabled:S.data?.initialized??!1}}),k=Q9(),T=G$(),R=X9(),L=q$(),{locals:j,remotesByHost:N}=C.useMemo(()=>{const _=X$(E.data??[],S.data?.branch),ee=r.trim()===""?_:W$(_,r);return Q$(ee)},[E.data,r,S.data?.branch]),{currentLocal:A,hasLocals:D,hasOtherLocals:U,otherLocals:I}=C.useMemo(()=>{let _;const ee=[];for(const J of j)J.isCurrent&&!_?_=J:ee.push(J);return{currentLocal:_,hasLocals:j.length>0,hasOtherLocals:ee.length>0,otherLocals:ee}},[j]),q=N.size>0;function $(_,ee=""){n(!1),f(ee),g(void 0),l(_)}function V(_){n(!1),f(U1(_)),g(_),l("new-branch")}async function Y(_,ee){n(!1);try{await k.mutateAsync({branch:_}),ut.success(ee,jl)}catch(J){ut.error("Failed to switch branch",{...jl,description:Cn(J)})}}function H(_){n(!1),y({branchName:_})}async function B(_){const ee=U1(_.name),J=(E.data??[]).find(re=>!re.isRemote&&re.name===ee);if(J){Y(J.name,`Switched to ${J.name}`).catch(()=>{});return}n(!1);try{await k.mutateAsync({branch:ee,create:!0,startPoint:_.name});try{await L.mutateAsync(_.name)}catch{}ut.success(`Switched to ${ee} (tracking ${_.name})`,jl)}catch(re){ut.error("Failed to checkout remote branch",{...jl,description:Cn(re)})}}function F(_){v(ee=>{const J=new Set(ee);return J.has(_)?J.delete(_):J.add(_),J})}function G(){n(!1),ut.promise(T.mutateAsync({}),{...jl,error:_=>({description:Cn(_),message:"Fetch failed"}),loading:"Fetching from remote…",success:"Fetched from remote"})}function ie(){n(!1),ut.promise(R.mutateAsync({}),{...jl,error:_=>({description:Cn(_),message:"Pull failed"}),loading:"Updating project…",success:_=>_.alreadyUpToDate?`${_.branch} is up to date`:`Pulled ${_.branch}`})}const M=S.data!==void 0,P=S.data?.initialized??!1,Q=cG(S.data);return M&&!P?p.jsx(Z9,{}):p.jsxs(p.Fragment,{children:[p.jsxs(Ws,{onOpenChange:n,open:t,children:[p.jsxs(Ks,{render:p.jsx(De,{disabled:!M,variant:"ghost"}),children:[p.jsx(jx,{className:"size-4 shrink-0"}),p.jsx("span",{className:"truncate max-w-40",children:Q}),p.jsx(Bf,{className:"size-4 shrink-0"})]}),p.jsxs(Za,{align:"start",className:"w-80 p-0",sideOffset:6,children:[p.jsxs("div",{className:"flex items-center gap-1.5 p-2 border-b border-border",children:[p.jsxs("div",{className:"relative min-w-0 flex-1",children:[p.jsx(vc,{className:"absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),p.jsx(Ko,{autoFocus:!0,className:"pl-8",onChange:_=>o(_.target.value),onKeyDown:_=>_.stopPropagation(),placeholder:"Search branches…",value:r})]}),p.jsx(De,{className:"shrink-0",disabled:T.isPending,onClick:G,size:"icon-sm",title:"Fetch",variant:"ghost",children:p.jsx(_H,{className:T.isPending?"size-4 animate-pulse":"size-4"})})]}),p.jsxs("div",{className:"max-h-[60vh] overflow-x-hidden overflow-y-auto py-1",children:[r.trim()===""&&p.jsxs(Os,{children:[p.jsxs(_n,{onClick:ie,children:[p.jsx(kH,{className:"size-5"}),p.jsx("span",{children:"Update Project"})]}),p.jsxs(_n,{onClick:()=>{n(!1),e("/changes")},children:[p.jsx(pU,{className:"size-5"}),p.jsx("span",{children:"Commit..."})]}),p.jsx(Fo,{}),p.jsxs(_n,{onClick:()=>$("new-branch",A?.name||""),children:[p.jsx(Xa,{className:"size-5"}),p.jsx("span",{children:"New Branch..."})]})]}),A?p.jsxs(p.Fragment,{children:[p.jsx(Fo,{}),p.jsxs(Os,{children:[p.jsx(Ql,{children:"Current"}),p.jsx(jC,{branch:A,onCheckout:()=>{Y(A.name,`Switched to ${A.name}`).catch(()=>{})},onDelete:()=>H(A.name),onNewBranchFrom:()=>V(A.name),trackingBranch:S.data?.trackingBranch})]})]}):null,U&&p.jsxs(p.Fragment,{children:[p.jsx(Fo,{}),p.jsxs(Os,{children:[p.jsx(Ql,{children:"Local"}),I.map(_=>p.jsx(jC,{branch:_,onCheckout:()=>{Y(_.name,`Switched to ${_.name}`).catch(()=>{})},onDelete:()=>H(_.name),onNewBranchFrom:()=>V(_.name)},_.name))]})]}),q&&p.jsxs(p.Fragment,{children:[p.jsx(Fo,{}),p.jsxs(Os,{children:[p.jsx(Ql,{children:"Remote"}),[...N.entries()].map(([_,ee])=>p.jsx(fG,{branches:ee,expanded:x.has(_),host:_,onBranchCheckout:B,onBranchNewBranchFrom:J=>V(J.name),onToggle:()=>F(_)},_))]})]}),!D&&!q&&p.jsx("p",{className:"px-3 py-4 text-center text-xs text-muted-foreground",children:r?"No branches match your search.":"No branches."})]})]})]}),p.jsx(lG,{initialName:c,onOpenChange:_=>_?null:l(null),open:a==="new-branch",startPoint:d}),p.jsx(eG,{branchName:h?.branchName??"",onOpenChange:_=>_?null:y(null),open:h!==null})]})}function jC({branch:e,onCheckout:t,onDelete:n,onNewBranchFrom:r,trackingBranch:o}){return p.jsxs(Gx,{children:[p.jsxs(Yx,{children:[p.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:e.isCurrent?p.jsx(Ys,{className:"size-4 text-primary"}):null}),p.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:e.name}),o?p.jsx("span",{className:"shrink-0 truncate max-w-32 text-xs text-muted-foreground",children:o}):null]}),p.jsxs(Wx,{className:"min-w-56",children:[!e.isCurrent&&p.jsx(_n,{onClick:t,children:"Checkout"}),p.jsx(_n,{onClick:r,children:p.jsxs("span",{className:"min-w-0 flex-1 truncate",children:["New Branch from '",e.name,"'..."]})}),!e.isCurrent&&p.jsxs(p.Fragment,{children:[p.jsx(Fo,{}),p.jsx(_n,{onClick:n,children:"Delete…"})]})]})]})}function fG({branches:e,expanded:t,host:n,onBranchCheckout:r,onBranchNewBranchFrom:o,onToggle:a}){return p.jsxs("div",{className:"flex min-w-0 flex-col",children:[p.jsxs("button",{className:"flex min-w-0 cursor-pointer items-center gap-2 px-3 py-1.5 text-sm text-foreground outline-none hover:bg-muted focus:bg-muted",onClick:a,type:"button",children:[p.jsx(h9,{className:`size-4 shrink-0 text-muted-foreground transition-transform ${t?"rotate-90":""}`}),p.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:n})]}),t?e.map(l=>p.jsx(dG,{branch:l,onCheckout:()=>r(l),onNewBranchFrom:()=>o(l)},l.name)):null]})}function dG({branch:e,onCheckout:t,onNewBranchFrom:n}){const r=U1(e.name);return p.jsxs(Gx,{children:[p.jsx(Yx,{className:"pl-15",children:p.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:r})}),p.jsxs(Wx,{className:"min-w-56",children:[p.jsx(_n,{onClick:t,children:"Checkout"}),p.jsx(_n,{onClick:n,children:p.jsxs("span",{className:"min-w-0 flex-1 truncate",children:["New Branch from '",e.name,"'..."]})})]})]})}function hG(){const e=Be(c=>c.version),[t,n]=C.useState(!1),{data:r}=VT(),{data:o}=kx(),a=r?.providers.find(c=>c.isCurrent),l=a?`${a.name}${o?.activeModel?` | ${o.activeModel}`:""}`:"No model configured";return p.jsxs("header",{className:"flex items-center gap-4 px-6 py-3.5",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsxs("div",{className:"flex items-center gap-1.5 mr-2.5",children:[p.jsx("img",{alt:"ByteRover",className:"w-32",src:MV}),e&&p.jsxs("span",{className:"text-primary-foreground text-xs font-medium",children:["v",e]})]}),p.jsx(F$,{}),p.jsx(uG,{}),p.jsxs(_s,{children:[p.jsxs(Ds,{render:p.jsx(Yo,{className:"border-primary-foreground/40 bg-primary-foreground/15 text-primary-foreground mono gap-1 px-1.5 text-[9px] leading-none font-semibold tracking-[0.16em] uppercase",variant:"outline"}),children:[p.jsx("span",{"aria-hidden":!0,className:"bg-primary-foreground size-1 shrink-0 rounded-full"}),p.jsx("span",{className:"leading-none",children:"Local"})]}),p.jsx(Is,{children:"You're viewing the local web UI, served from the daemon on your machine."})]})]}),p.jsx("div",{className:"flex-1"}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsxs(_s,{children:[p.jsxs(Ds,{render:p.jsx(De,{onClick:()=>n(!0),size:"sm",variant:"ghost"}),children:[p.jsx(IU,{className:"size-3.5 shrink-0 mr-1"}),l,!a&&p.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-amber-500"})]}),!a&&p.jsx(Is,{children:"Configure to use curate/query feature"})]}),p.jsx(Px,{onOpenChange:n,open:t}),p.jsx(k$,{}),p.jsx(E$,{})]})]})}function pG(){const{completed:e,inProgress:t,total:n}=BB(),r=n>0?`${e}/${n}`:void 0,o=t>0?"active":"idle";return[{label:"Context",path:"/contexts"},{label:"Changes",path:"/changes"},{badge:r,badgeTone:o,label:"Tasks",path:"/tasks"},{label:"Configuration",path:"/configuration"}]}function mG(){const{data:e}=Bx(),{staged:t,unmerged:n,unstaged:r}=N9(e),o=t.length+r.length+n.length;return o===0?null:p.jsx("span",{className:"ml-1.5 rounded-md bg-[#4f3422] p-1 text-xs font-semibold tabular-nums text-[#ffc53d]",children:o})}function gG(){const e=pG();return RV(),p.jsxs("div",{className:"flex h-screen flex-col",children:[p.jsx(hG,{}),p.jsx("nav",{className:"border-border flex gap-2 border-b px-6",children:e.map(t=>p.jsxs(Ck,{className:({isActive:n})=>we("flex items-center gap-1.5 border-b-2 px-2 pt-2 pb-3 text-sm transition-colors",{"border-primary-foreground text-primary-foreground font-medium":n,"border-transparent text-muted-foreground hover:text-foreground":!n}),to:t.path,children:[p.jsx("span",{children:t.label}),t.badge&&p.jsxs(Yo,{className:"tabular-nums",variant:"secondary",children:[t.badgeTone==="active"&&p.jsx("span",{"aria-hidden":!0,className:"bg-primary-foreground size-1.5 shrink-0 rounded-full"}),t.badge]}),t.path==="/changes"&&p.jsx(mG,{})]},t.path))}),p.jsx("main",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:p.jsx(bk,{})}),p.jsx(AV,{}),p.jsx(TV,{}),p.jsx(YB,{})]})}function yG(){return p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("section",{className:"grid gap-4 grid-cols-3",children:[p.jsxs(ja,{className:"gap-1 px-4 shadow-none ring-border/80",size:"sm",children:[p.jsx("div",{className:"text-xs tracking-wider uppercase text-muted-foreground",children:"Total tasks"}),p.jsx("strong",{className:"text-3xl leading-none",children:"0"}),p.jsx(Ah,{children:"Waiting for the skipped task-subscription issue."})]}),p.jsxs(ja,{className:"gap-1 px-4 shadow-none ring-border/80",size:"sm",children:[p.jsx("div",{className:"text-xs tracking-wider uppercase text-muted-foreground",children:"Success rate"}),p.jsx("strong",{className:"text-3xl leading-none",children:"0%"}),p.jsx(Ah,{children:"No client-side task history is wired into the web app yet."})]}),p.jsxs(ja,{className:"gap-1 px-4 shadow-none ring-border/80",size:"sm",children:[p.jsx("div",{className:"text-xs tracking-wider uppercase text-muted-foreground",children:"Average duration"}),p.jsx("strong",{className:"text-3xl leading-none",children:"0s"}),p.jsx(Ah,{children:"This will populate once task-store parity lands."})]})]}),p.jsxs(ja,{className:"min-h-56 items-start justify-center gap-3 px-5 shadow-sm ring-border/70",size:"sm",children:[p.jsx(Yo,{className:"rounded-sm border-yellow-500/20 bg-yellow-500/10 text-yellow-600",variant:"outline",children:"Empty state"}),p.jsx(b$,{className:"font-semibold",children:"No task data available yet"}),p.jsx(Ah,{children:"The plan explicitly skips the activity/task subscription issue. This page is wired as a placeholder so the route exists cleanly and can consume task-store data once that transport work lands."})]})]})}const xG="data:image/svg+xml,%3csvg%20width='120'%20height='120'%20viewBox='0%200%20120%20120'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M60%20120C93%20120%20120%2093%20120%2060C120%2027%2093%200%2060%200C27%200%200%2027%200%2060C0%2093%2027%20120%2060%20120Z'%20fill='url(%23paint0_linear_2037_60923)'%20fill-opacity='0.15'/%3e%3cpath%20d='M60%200.75C92.5858%200.75%20119.25%2027.4142%20119.25%2060C119.25%2092.5858%2092.5858%20119.25%2060%20119.25C27.4142%20119.25%200.75%2092.5858%200.75%2060C0.75%2027.4142%2027.4142%200.75%2060%200.75Z'%20stroke='url(%23paint1_linear_2037_60923)'%20stroke-opacity='0.5'%20stroke-width='1.5'/%3e%3cpath%20d='M87.3926%2037.6738C88.505%2036.4418%2090.2734%2036.4418%2091.3857%2037.6738C92.5382%2038.9504%2092.5381%2041.0486%2091.3857%2042.3252L51.6631%2086.3262C50.5507%2087.5582%2048.7823%2087.5582%2047.6699%2086.3262L29.6143%2066.3252C28.4621%2065.0486%2028.4621%2062.9514%2029.6143%2061.6748C30.7267%2060.4426%2032.495%2060.4426%2033.6074%2061.6748L47.625%2077.2021C48.717%2078.4118%2050.616%2078.4118%2051.708%2077.2021L87.3926%2037.6738Z'%20fill='url(%23paint2_linear_2037_60923)'%20stroke='%2300E275'%20stroke-width='1.5'/%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_2037_60923'%20x1='17.9848'%20y1='14.0983'%20x2='125.634'%20y2='103.845'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='white'/%3e%3cstop%20offset='1'%20stop-color='%23999999'%20stop-opacity='0.5'/%3e%3c/linearGradient%3e%3clinearGradient%20id='paint1_linear_2037_60923'%20x1='15.3936'%20y1='-1.63761e-06'%20x2='120'%20y2='90.8895'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='white'%20stop-opacity='0.5'/%3e%3cstop%20offset='1'%20stop-color='%23999999'%20stop-opacity='0'/%3e%3c/linearGradient%3e%3clinearGradient%20id='paint2_linear_2037_60923'%20x1='65.5979'%20y1='65.9795'%20x2='78.5737'%20y2='-56.684'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%2309814A'/%3e%3cstop%20offset='1'%20stop-color='%2300CC66'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e",bG=(e={})=>{const{apiClient:t}=Be.getState();return t?t.request(rr.ADD,e):Promise.reject(new Error("Not connected"))},vG=({mutationConfig:e}={})=>{const t=cn(),{onSuccess:n,...r}=e??{};return wn({onSuccess(...o){t.invalidateQueries({queryKey:hi().queryKey}),n?.(...o)},...r,mutationFn:bG})},wG=({addAll:e,filePaths:t,message:n})=>{const{apiClient:r}=Be.getState();if(!r)return Promise.reject(new Error("Not connected"));const o=()=>r.request(rr.COMMIT,{message:n});if(e||t&&t.length>0){const a=t?{filePaths:t}:{};return r.request(rr.ADD,a).then(o)}return o()},SG=({mutationConfig:e}={})=>{const t=cn(),{onSuccess:n,...r}=e??{};return wn({onSuccess(...o){t.invalidateQueries({queryKey:hi().queryKey}),n?.(...o)},...r,mutationFn:wG})},CG=()=>{const{apiClient:e}=Be.getState();return e?e.request(rr.MERGE,{action:"abort"}):Promise.reject(new Error("Not connected"))},EG=({mutationConfig:e}={})=>{const t=cn(),{onSuccess:n,...r}=e??{};return wn({onSuccess(...o){t.invalidateQueries({queryKey:hi().queryKey}),t.invalidateQueries({queryKey:["vc","diff"]}),t.invalidateQueries({queryKey:["vc","diffs"]}),n?.(...o)},...r,mutationFn:CG})},kG=e=>{const{apiClient:t}=Be.getState();return t?t.request(rr.MERGE,{action:"continue",message:e.message}):Promise.reject(new Error("Not connected"))},TG=({mutationConfig:e}={})=>{const t=cn(),{onSuccess:n,...r}=e??{};return wn({onSuccess(...o){t.invalidateQueries({queryKey:hi().queryKey}),t.invalidateQueries({queryKey:["vc","diff"]}),t.invalidateQueries({queryKey:["vc","diffs"]}),n?.(...o)},...r,mutationFn:kG})},AG=(e={})=>{const{apiClient:t}=Be.getState();return t?t.request(rr.PUSH,e):Promise.reject(new Error("Not connected"))},RG=({mutationConfig:e}={})=>{const t=cn(),{onSuccess:n,...r}=e??{};return wn({onSuccess(...o){t.invalidateQueries({queryKey:hi().queryKey}),t.invalidateQueries({queryKey:Ja().queryKey}),n?.(...o)},...r,mutationFn:AG})},NG=(e={})=>{const{apiClient:t}=Be.getState();return t?t.request(rr.RESET,e):Promise.reject(new Error("Not connected"))},OG=({mutationConfig:e}={})=>{const t=cn(),{onSuccess:n,...r}=e??{};return wn({onSuccess(...o){t.invalidateQueries({queryKey:hi().queryKey}),n?.(...o)},...r,mutationFn:NG})};function jG(e){return e.status==="unmerged"?"merge":e.isStaged?"staged":"unstaged"}function Zh(e){return`${jG(e)}:${e.path}`}const q1="Please sign in to use sync feature";function MC(e,t){return t?e:p.jsxs(_s,{children:[p.jsx(Ds,{render:p.jsx("span",{tabIndex:0}),children:e}),p.jsx(Is,{children:q1})]})}function MG({ahead:e=0,behind:t=0,branch:n,hasTracking:r,isAborting:o=!1,isAuthenticated:a,isPulling:l,isPushing:c,mergeInProgress:f=!1,onAbortMerge:d,onPull:g,onPush:h}){const y=l||c||o,x=a?r?"Pull from upstream":"No upstream tracking branch":q1,v=a?r?"Push to upstream":"Push and set upstream":q1,S=p.jsxs(De,{className:"h-7 gap-1 px-2 text-sm",disabled:y||!r||!a,onClick:g,size:"sm",title:x,variant:"ghost",children:[l?p.jsx(ai,{className:"size-3.5 animate-spin"}):p.jsx(AH,{className:"size-3.5"}),t>0&&p.jsx("span",{className:"text-sm tabular-nums",children:t})]}),E=p.jsxs(De,{className:"h-7 gap-1 px-2 text-sm",disabled:y||!a,onClick:h,size:"sm",title:v,variant:"ghost",children:[c?p.jsx(ai,{className:"size-3.5 animate-spin"}):p.jsx(MH,{className:"size-3.5"}),e>0&&p.jsx("span",{className:"text-sm tabular-nums",children:e})]});return p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"text-muted-foreground flex min-w-0 items-center gap-1.5",children:[p.jsx(jx,{className:"size-4 shrink-0"}),p.jsx("span",{className:"truncate text-sm font-medium",children:n??"(detached)"})]}),p.jsxs("div",{className:"flex items-center gap-0.5",children:[f&&d&&p.jsxs(De,{className:"text-destructive h-7 gap-1 px-2 text-sm hover:bg-destructive/10 hover:text-destructive",disabled:y,onClick:d,size:"sm",title:"Abort merge",variant:"ghost",children:[o?p.jsx(ai,{className:"size-3.5 animate-spin"}):p.jsx(eU,{className:"size-3.5"}),p.jsx("span",{children:"Abort"})]}),MC(S,a),MC(E,a)]})]})}function LG({canCommit:e,isCommitting:t,message:n,onCommit:r,onMessageChange:o}){const a=l=>{(l.metaKey||l.ctrlKey)&&l.key==="Enter"&&(l.preventDefault(),r())};return p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsx(Fx,{className:"min-h-20 resize-none",onChange:l=>o(l.target.value),onKeyDown:a,placeholder:"Commit message (Cmd/Ctrl+Enter to commit)",value:n}),p.jsx(De,{className:"w-full gap-2",disabled:!e||!n.trim()||t,onClick:r,size:"sm",children:"Commit"})]})}const _G=e=>{const{apiClient:t}=Be.getState();return t?t.request(rr.DIFF,e):Promise.reject(new Error("Not connected"))},DG=e=>({queryFn:()=>_G(e),queryKey:["vc","diff",e.path,e.side],staleTime:0}),IG=({enabled:e=!0,path:t,queryConfig:n,side:r})=>br({...DG({path:t,side:r}),enabled:e&&!!t,...n});function J9({file:e,onOpenFile:t,onStageToggle:n}){const r=e.isStaged?"Unstage":"Stage",o=e.isStaged?Mx:Xa,a=e.status==="deleted";return p.jsxs("div",{className:"border-border bg-muted sticky top-0 z-10 flex items-center gap-2 border-b px-3 py-1.5",children:[p.jsx(c0,{className:"text-primary-foreground size-4 shrink-0",strokeWidth:2}),p.jsx("span",{className:"text-foreground flex-1 truncate font-mono text-xs",children:e.path}),p.jsx(De,{className:"size-6 transition-colors hover:bg-foreground/15 dark:hover:bg-foreground/15 hover:text-foreground",disabled:a,onClick:t,size:"icon-xs",title:a?"File no longer exists":"Open file",variant:"ghost",children:p.jsx(aU,{className:"size-3"})}),p.jsx(De,{className:"size-6 transition-colors hover:bg-foreground/15 dark:hover:bg-foreground/15 hover:text-foreground",onClick:n,size:"icon-xs",title:r,variant:"ghost",children:p.jsx(o,{className:"size-3"})})]})}var T2={exports:{}};var LC;function zG(){return LC||(LC=1,(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var a="",l=0;l<arguments.length;l++){var c=arguments[l];c&&(a=o(a,r(c)))}return a}function r(a){if(typeof a=="string"||typeof a=="number")return a;if(typeof a!="object")return"";if(Array.isArray(a))return n.apply(null,a);if(a.toString!==Object.prototype.toString&&!a.toString.toString().includes("[native code]"))return a.toString();var l="";for(var c in a)t.call(a,c)&&a[c]&&(l=o(l,c));return l}function o(a,l){return l?a?a+" "+l:a+l:a}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(T2)),T2.exports}var PG=zG();const Hi=uc(PG);var _C=Number.isNaN||function(t){return typeof t=="number"&&t!==t};function FG(e,t){return!!(e===t||_C(e)&&_C(t))}function BG(e,t){if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(!FG(e[n],t[n]))return!1;return!0}function HG(e,t){t===void 0&&(t=BG);var n=null;function r(){for(var o=[],a=0;a<arguments.length;a++)o[a]=arguments[a];if(n&&n.lastThis===this&&t(o,n.lastArgs))return n.lastResult;var l=e.apply(this,o);return n={lastResult:l,lastArgs:o,lastThis:this},l}return r.clear=function(){n=null},r}function UG(e,t,n){let r=0,o;const a={},l=[];return e.forEach((c,f)=>{const d=t.some(g=>g>=f-n&&g<=f+n);!d&&o===void 0?(o={index:r,startLine:f,endLine:f,lines:1},l.push(o),a[f]=o.index,r++):!d&&o?(o.endLine=f,o.lines++,a[f]=o.index):o=void 0}),{lineBlocks:a,blocks:l}}class Xo{diff(t,n,r={}){let o;typeof r=="function"?(o=r,r={}):"callback"in r&&(o=r.callback);const a=this.castInput(t,r),l=this.castInput(n,r),c=this.removeEmpty(this.tokenize(a,r)),f=this.removeEmpty(this.tokenize(l,r));return this.diffWithOptionsObj(c,f,r,o)}diffWithOptionsObj(t,n,r,o){var a;const l=T=>{if(T=this.postProcess(T,r),o){setTimeout(function(){o(T)},0);return}else return T},c=n.length,f=t.length;let d=1,g=c+f;r.maxEditLength!=null&&(g=Math.min(g,r.maxEditLength));const h=(a=r.timeout)!==null&&a!==void 0?a:1/0,y=Date.now()+h,x=[{oldPos:-1,lastComponent:void 0}];let v=this.extractCommon(x[0],n,t,0,r);if(x[0].oldPos+1>=f&&v+1>=c)return l(this.buildValues(x[0].lastComponent,n,t));let S=-1/0,E=1/0;const k=()=>{for(let T=Math.max(S,-d);T<=Math.min(E,d);T+=2){let R;const L=x[T-1],j=x[T+1];L&&(x[T-1]=void 0);let N=!1;if(j){const D=j.oldPos-T;N=j&&0<=D&&D<c}const A=L&&L.oldPos+1<f;if(!N&&!A){x[T]=void 0;continue}if(!A||N&&L.oldPos<j.oldPos?R=this.addToPath(j,!0,!1,0,r):R=this.addToPath(L,!1,!0,1,r),v=this.extractCommon(R,n,t,T,r),R.oldPos+1>=f&&v+1>=c)return l(this.buildValues(R.lastComponent,n,t))||!0;x[T]=R,R.oldPos+1>=f&&(E=Math.min(E,T-1)),v+1>=c&&(S=Math.max(S,T+1))}d++};if(o)(function T(){setTimeout(function(){if(d>g||Date.now()>y)return o(void 0);k()||T()},0)})();else for(;d<=g&&Date.now()<=y;){const T=k();if(T)return T}}addToPath(t,n,r,o,a){const l=t.lastComponent;return l&&!a.oneChangePerToken&&l.added===n&&l.removed===r?{oldPos:t.oldPos+o,lastComponent:{count:l.count+1,added:n,removed:r,previousComponent:l.previousComponent}}:{oldPos:t.oldPos+o,lastComponent:{count:1,added:n,removed:r,previousComponent:l}}}extractCommon(t,n,r,o,a){const l=n.length,c=r.length;let f=t.oldPos,d=f-o,g=0;for(;d+1<l&&f+1<c&&this.equals(r[f+1],n[d+1],a);)d++,f++,g++,a.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return g&&!a.oneChangePerToken&&(t.lastComponent={count:g,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=f,d}equals(t,n,r){return r.comparator?r.comparator(t,n):t===n||!!r.ignoreCase&&t.toLowerCase()===n.toLowerCase()}removeEmpty(t){const n=[];for(let r=0;r<t.length;r++)t[r]&&n.push(t[r]);return n}castInput(t,n){return t}tokenize(t,n){return Array.from(t)}join(t){return t.join("")}postProcess(t,n){return t}get useLongestToken(){return!1}buildValues(t,n,r){const o=[];let a;for(;t;)o.push(t),a=t.previousComponent,delete t.previousComponent,t=a;o.reverse();const l=o.length;let c=0,f=0,d=0;for(;c<l;c++){const g=o[c];if(g.removed)g.value=this.join(r.slice(d,d+g.count)),d+=g.count;else{if(!g.added&&this.useLongestToken){let h=n.slice(f,f+g.count);h=h.map(function(y,x){const v=r[d+x];return v.length>y.length?v:y}),g.value=this.join(h)}else g.value=this.join(n.slice(f,f+g.count));f+=g.count,g.added||(d+=g.count)}}return o}}class qG extends Xo{}const e8=new qG;function VG(e,t,n){return e8.diff(e,t,n)}function DC(e,t){let n;for(n=0;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function IC(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return"";for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function V1(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function $1(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function ku(e,t){return V1(e,t,"")}function Rh(e,t){return $1(e,t,"")}function zC(e,t){return t.slice(0,$G(e,t))}function $G(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);const o=Array(r);let a=0;o[0]=0;for(let l=1;l<r;l++){for(t[l]==t[a]?o[l]=o[a]:o[l]=a;a>0&&t[l]!=t[a];)a=o[a];t[l]==t[a]&&a++}a=0;for(let l=n;l<e.length;l++){for(;a>0&&e[l]!=t[a];)a=o[a];e[l]==t[a]&&a++}return a}function GG(e){return e.includes(`\r
23
+ )`}return p.jsx("div",{ref:n,role:"presentation","data-base-ui-inert":"",...o,style:{position:"fixed",inset:0,userSelect:"none",WebkitUserSelect:"none",clipPath:a}})}),Ox=C.forwardRef(function(t,n){const{keepMounted:r=!1,...o}=t,{store:a}=Ka(),l=a.useState("mounted"),c=a.useState("modal"),f=a.useState("open");return l||r?p.jsx(KT.Provider,{value:r,children:p.jsxs(h6,{ref:n,...o,children:[l&&c===!0&&p.jsx(r9,{ref:a.context.internalBackdropRef,inert:K6(!f)}),t.children]})}):null});let bC={},vC={},wC="";function oH(e){if(typeof document>"u")return!1;const t=Gt(e);return $n(t).innerWidth-t.documentElement.clientWidth>0}function aH(e){if(!(typeof CSS<"u"&&CSS.supports&&CSS.supports("scrollbar-gutter","stable"))||typeof document>"u")return!1;const n=Gt(e),r=n.documentElement,o=n.body,a=$a(r)?r:o,l=a.style.overflowY,c=r.style.scrollbarGutter;r.style.scrollbarGutter="stable",a.style.overflowY="scroll";const f=a.offsetWidth;a.style.overflowY="hidden";const d=a.offsetWidth;return a.style.overflowY=l,r.style.scrollbarGutter=c,f===d}function sH(e){const t=Gt(e),n=t.documentElement,r=t.body,o=$a(n)?n:r,a={overflowY:o.style.overflowY,overflowX:o.style.overflowX};return Object.assign(o.style,{overflowY:"hidden",overflowX:"hidden"}),()=>{Object.assign(o.style,a)}}function lH(e){const t=Gt(e),n=t.documentElement,r=t.body,o=$n(n);let a=0,l=0,c=!1;const f=to.create();if(jk&&(o.visualViewport?.scale??1)!==1)return()=>{};function d(){const y=o.getComputedStyle(n),x=o.getComputedStyle(r),E=(y.scrollbarGutter||"").includes("both-edges")?"stable both-edges":"stable";a=n.scrollTop,l=n.scrollLeft,bC={scrollbarGutter:n.style.scrollbarGutter,overflowY:n.style.overflowY,overflowX:n.style.overflowX},wC=n.style.scrollBehavior,vC={position:r.style.position,height:r.style.height,width:r.style.width,boxSizing:r.style.boxSizing,overflowY:r.style.overflowY,overflowX:r.style.overflowX,scrollBehavior:r.style.scrollBehavior};const k=n.scrollHeight>n.clientHeight,T=n.scrollWidth>n.clientWidth,R=y.overflowY==="scroll"||x.overflowY==="scroll",L=y.overflowX==="scroll"||x.overflowX==="scroll",j=Math.max(0,o.innerWidth-r.clientWidth),N=Math.max(0,o.innerHeight-r.clientHeight),A=parseFloat(x.marginTop)+parseFloat(x.marginBottom),D=parseFloat(x.marginLeft)+parseFloat(x.marginRight),U=$a(n)?n:r;if(c=aH(e),c){n.style.scrollbarGutter=E,U.style.overflowY="hidden",U.style.overflowX="hidden";return}Object.assign(n.style,{scrollbarGutter:E,overflowY:"hidden",overflowX:"hidden"}),(k||R)&&(n.style.overflowY="scroll"),(T||L)&&(n.style.overflowX="scroll"),Object.assign(r.style,{position:"relative",height:A||N?`calc(100dvh - ${A+N}px)`:"100dvh",width:D||j?`calc(100vw - ${D+j}px)`:"100vw",boxSizing:"border-box",overflow:"hidden",scrollBehavior:"unset"}),r.scrollTop=a,r.scrollLeft=l,n.setAttribute("data-base-ui-scroll-locked",""),n.style.scrollBehavior="unset"}function g(){Object.assign(n.style,bC),Object.assign(r.style,vC),c||(n.scrollTop=a,n.scrollLeft=l,n.removeAttribute("data-base-ui-scroll-locked"),n.style.scrollBehavior=wC)}function h(){g(),f.request(d)}return d(),o.addEventListener("resize",h),()=>{f.cancel(),g(),typeof o.removeEventListener=="function"&&o.removeEventListener("resize",h)}}class cH{lockCount=0;restore=null;timeoutLock=$i.create();timeoutUnlock=$i.create();acquire(t){return this.lockCount+=1,this.lockCount===1&&this.restore===null&&this.timeoutLock.start(0,()=>this.lock(t)),this.release}release=()=>{this.lockCount-=1,this.lockCount===0&&this.restore&&this.timeoutUnlock.start(0,this.unlock)};unlock=()=>{this.lockCount===0&&this.restore&&(this.restore?.(),this.restore=null)};lock(t){if(this.lockCount===0||this.restore!==null)return;const r=Gt(t).documentElement,o=$n(r).getComputedStyle(r).overflowY;if(o==="hidden"||o==="clip"){this.restore=dr;return}const a=Mk||!oH(t);this.restore=a?sH(t):lH(t)}}const uH=new cH;function i9(e=!0,t=null){qe(()=>{if(e)return uH.acquire(t)},[e,t])}function fH(e){const t=C.useRef(""),n=C.useCallback(o=>{o.defaultPrevented||(t.current=o.pointerType,e(o,o.pointerType))},[e]);return{onClick:C.useCallback(o=>{if(o.detail===0){e(o,"keyboard");return}"pointerType"in o?e(o,o.pointerType):e(o,t.current),t.current=""},[e]),onPointerDown:n}}function o9(e,t){const n=C.useRef(e),r=st(t);qe(()=>{n.current!==e&&r(n.current)},[e,r]),qe(()=>{n.current=e},[e])}function a9(e){const[t,n]=C.useState(null),r=st((l,c)=>{e||n(c||(Mk?"touch":""))});o9(e,l=>{l&&!e&&n(null)});const{onClick:o,onPointerDown:a}=fH(r);return C.useMemo(()=>({openMethod:t,triggerProps:{onClick:o,onPointerDown:a}}),[t,o,a])}function s9(e){const{store:t,parentContext:n,actionsRef:r}=e,o=t.useState("open"),a=t.useState("disablePointerDismissal"),l=t.useState("modal"),c=t.useState("popupElement"),{openMethod:f,triggerProps:d}=a9(o);Zy(t);const{forceUnmount:g}=Jy(o,t),h=st(U=>{const I=Et(U);return I.preventUnmountOnClose=()=>{t.set("preventUnmountingOnClose",!0)},I}),y=C.useCallback(()=>{t.setOpen(!1,h(qy))},[t,h]);C.useImperativeHandle(r,()=>({unmount:g,close:y}),[g,y]);const x=nx({popupStore:t,onOpenChange:t.setOpen,treatPopupAsFloatingElement:!0,noEmit:!0}),[v,S]=C.useState(0),E=v===0,k=F6(x),T=Wy(x,{outsidePressEvent(){return t.context.internalBackdropRef.current||t.context.backdropRef.current?"intentional":{mouse:l==="trap-focus"?"sloppy":"intentional",touch:"sloppy"}},outsidePress(U){if(!t.context.outsidePressEnabledRef.current||"button"in U&&U.button!==0||"touches"in U&&U.touches.length!==1)return!1;const I=Ar(U);if(E&&!a){const q=I;return l&&(t.context.internalBackdropRef.current||t.context.backdropRef.current)?t.context.internalBackdropRef.current===q||t.context.backdropRef.current===q||ht(q,c)&&!q?.hasAttribute("data-base-ui-portal"):!0}return!1},escapeKey:E});i9(o&&l===!0,c);const{getReferenceProps:R,getFloatingProps:L,getTriggerProps:j}=Lf([k,T]);t.useContextCallback("onNestedDialogOpen",U=>{S(U+1)}),t.useContextCallback("onNestedDialogClose",()=>{S(0)}),C.useEffect(()=>(n?.onNestedDialogOpen&&o&&n.onNestedDialogOpen(v),n?.onNestedDialogClose&&!o&&n.onNestedDialogClose(),()=>{n?.onNestedDialogClose&&o&&n.onNestedDialogClose()}),[o,n,v]);const N=C.useMemo(()=>R(d),[R,d]),A=C.useMemo(()=>j(d),[j,d]),D=C.useMemo(()=>L(),[L]);t.useSyncedValues({openMethod:f,activeTriggerProps:N,inactiveTriggerProps:A,popupProps:D,floatingRootContext:x,nestedOpenDialogCount:v})}const dH={...tx,modal:rt(e=>e.modal),nested:rt(e=>e.nested),nestedOpenDialogCount:rt(e=>e.nestedOpenDialogCount),disablePointerDismissal:rt(e=>e.disablePointerDismissal),openMethod:rt(e=>e.openMethod),descriptionElementId:rt(e=>e.descriptionElementId),titleElementId:rt(e=>e.titleElementId),viewportElement:rt(e=>e.viewportElement),role:rt(e=>e.role)};class l9 extends n0{constructor(t){super(hH(t),{popupRef:C.createRef(),backdropRef:C.createRef(),internalBackdropRef:C.createRef(),outsidePressEnabledRef:{current:!0},triggerElements:new Mf,onOpenChange:void 0,onOpenChangeComplete:void 0},dH)}setOpen=(t,n)=>{if(n.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},!t&&n.trigger==null&&this.state.activeTriggerId!=null&&(n.trigger=this.state.activeTriggerElement??void 0),this.context.onOpenChange?.(t,n),n.isCanceled)return;const r={open:t,nativeEvent:n.event,reason:n.reason,nested:this.state.nested};this.state.floatingRootContext.context.events?.emit("openchange",r);const o={open:t},a=n.trigger?.id??null;(a||t)&&(o.activeTriggerId=a,o.activeTriggerElement=n.trigger??null),this.update(o)}}function hH(e={}){return{...ex(),modal:!0,disablePointerDismissal:!1,popupElement:null,viewportElement:null,descriptionElementId:void 0,titleElementId:void 0,openMethod:null,nested:!1,nestedOpenDialogCount:0,role:"dialog",...e}}function c9(e){const{children:t,open:n,defaultOpen:r=!1,onOpenChange:o,onOpenChangeComplete:a,disablePointerDismissal:l=!1,modal:c=!0,actionsRef:f,handle:d,triggerId:g,defaultTriggerId:h=null}=e,y=Ka(!0),x=!!y,v=Zn(()=>d?.store??new l9({open:r,openProp:n,activeTriggerId:h,triggerIdProp:g,modal:c,disablePointerDismissal:l,nested:x})).current;My(()=>{n===void 0&&v.state.open===!1&&r===!0&&v.update({open:!0,activeTriggerId:h})}),v.useControlledProp("openProp",n),v.useControlledProp("triggerIdProp",g),v.useSyncedValues({disablePointerDismissal:l,nested:x,modal:c}),v.useContextCallback("onOpenChange",o),v.useContextCallback("onOpenChangeComplete",a);const S=v.useState("payload");s9({store:v,actionsRef:f,parentContext:y?.store.context});const E=C.useMemo(()=>({store:v}),[v]);return p.jsx(Tx.Provider,{value:E,children:typeof t=="function"?t({payload:S}):t})}const u9=C.forwardRef(function(t,n){const{render:r,className:o,id:a,...l}=t,{store:c}=Ka(),f=Gi(a);return c.useSyncedValueWithCleanup("titleElementId",f),ln("h2",t,{ref:n,props:[{id:f},l]})}),pH=C.forwardRef(function(t,n){const{render:r,className:o,disabled:a=!1,focusableWhenDisabled:l=!1,nativeButton:c=!0,...f}=t,{getButtonProps:d,buttonRef:g}=zf({disabled:a,focusableWhenDisabled:l,native:c});return ln("button",t,{state:{disabled:a},ref:[n,g],props:[f,d]})}),mH=o0("group/button inline-flex shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 cursor-pointer",{variants:{variant:{default:"bg-primary text-foreground font-medium hover:bg-primary/80",outline:"border-border bg-background shadow-xs hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-background dark:hover:bg-muted",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive text-foreground hover:bg-destructive/80 focus-visible:border-destructive/40 focus-visible:ring-destructive/20",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 gap-1.5 px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",xs:"h-6 gap-1 rounded-[min(var(--radius-md),8px)] px-2 text-xs in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-8 gap-1 rounded-[min(var(--radius-md),10px)] px-2.5 in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5",lg:"h-10 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3",icon:"size-9","icon-xs":"size-6 rounded-[min(var(--radius-md),8px)] in-data-[slot=button-group]:rounded-md [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-8 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-md","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function De({className:e,variant:t="default",size:n="default",...r}){return p.jsx(pH,{"data-slot":"button",className:we(mH({variant:t,size:n,className:e})),...r})}function $s({...e}){return p.jsx(c9,{"data-slot":"dialog",...e})}function gH({...e}){return p.jsx(Ox,{"data-slot":"dialog-portal",...e})}function H1({...e}){return p.jsx(Pf,{"data-slot":"dialog-close",...e})}function yH({className:e,...t}){return p.jsx(Ax,{"data-slot":"dialog-overlay",className:we("fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",e),...t})}function Gs({className:e,children:t,showCloseButton:n=!0,...r}){return p.jsxs(gH,{children:[p.jsx(yH,{}),p.jsxs(Nx,{"data-slot":"dialog-content",className:we("fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-6 rounded-xl bg-background p-6 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-md data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...r,children:[t,n&&p.jsxs(Pf,{"data-slot":"dialog-close",render:p.jsx(De,{variant:"ghost",className:"absolute top-4 right-4",size:"icon-sm"}),children:[p.jsx(qp,{}),p.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function ui({className:e,...t}){return p.jsx("div",{"data-slot":"dialog-header",className:we("flex flex-col gap-2",e),...t})}function Qa({className:e,showCloseButton:t=!1,children:n,...r}){return p.jsxs("div",{"data-slot":"dialog-footer",className:we("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...r,children:[n,t&&p.jsx(Pf,{render:p.jsx(De,{variant:"outline"}),children:"Close"})]})}function fi({className:e,...t}){return p.jsx(u9,{"data-slot":"dialog-title",className:we("leading-none text-lg font-semibold text-foreground",e),...t})}function Ff({className:e,...t}){return p.jsx(WT,{"data-slot":"dialog-description",className:we("text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...t})}const f9=(...e)=>e.filter((t,n,r)=>!!t&&t.trim()!==""&&r.indexOf(t)===n).join(" ").trim();const xH=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const bH=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,r)=>r?r.toUpperCase():n.toLowerCase());const SC=e=>{const t=bH(e);return t.charAt(0).toUpperCase()+t.slice(1)};var E2={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const vH=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1},wH=C.createContext({}),SH=()=>C.useContext(wH),CH=C.forwardRef(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,className:o="",children:a,iconNode:l,...c},f)=>{const{size:d=24,strokeWidth:g=2,absoluteStrokeWidth:h=!1,color:y="currentColor",className:x=""}=SH()??{},v=r??h?Number(n??g)*24/Number(t??d):n??g;return C.createElement("svg",{ref:f,...E2,width:t??d??E2.width,height:t??d??E2.height,stroke:e??y,strokeWidth:v,className:f9("lucide",x,o),...!a&&!vH(c)&&{"aria-hidden":"true"},...c},[...l.map(([S,E])=>C.createElement(S,E)),...Array.isArray(a)?a:[a]])});const ft=(e,t)=>{const n=C.forwardRef(({className:r,...o},a)=>C.createElement(CH,{ref:a,iconNode:t,className:f9(`lucide-${xH(SC(e))}`,`lucide-${e}`,r),...o}));return n.displayName=SC(e),n};const EH=[["path",{d:"M17 7 7 17",key:"15tmo1"}],["path",{d:"M17 17H7V7",key:"1org7z"}]],kH=ft("arrow-down-left",EH);const TH=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],AH=ft("arrow-down",TH);const RH=[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]],NH=ft("arrow-right-left",RH);const OH=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],d9=ft("arrow-right",OH);const jH=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],MH=ft("arrow-up",jH);const LH=[["path",{d:"M13.5 10.5 15 9",key:"1nsxvm"}],["path",{d:"M4 4v15a1 1 0 0 0 1 1h15",key:"1w6lkd"}],["path",{d:"M4.293 19.707 6 18",key:"3g1p8c"}],["path",{d:"m9 15 1.5-1.5",key:"1xfbes"}]],_H=ft("axis-3d",LH);const DH=[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]],IH=ft("book-open",DH);const zH=[["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z",key:"uouzyp"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M21 21a4 4 0 0 0-3.81-4",key:"1b0z45"}],["path",{d:"M21 5a4 4 0 0 1-3.55 3.97",key:"5cxbf6"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M3 21a4 4 0 0 1 3.81-4",key:"1fjd4g"}],["path",{d:"M3 5a4 4 0 0 0 3.55 3.97",key:"1d7oge"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M9 7.13V6a3 3 0 1 1 6 0v1.13",key:"1vgav8"}]],PH=ft("bug",zH);const FH=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Ys=ft("check",FH);const BH=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Bf=ft("chevron-down",BH);const HH=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Fs=ft("chevron-left",HH);const UH=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],h9=ft("chevron-right",UH);const qH=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],VH=ft("chevron-up",qH);const $H=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],GH=ft("chevrons-left",$H);const YH=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],WH=ft("chevrons-right",YH);const KH=[["path",{d:"M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z",key:"kmsa83"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],QH=ft("circle-play",KH);const XH=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],ZH=ft("circle-question-mark",XH);const JH=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],eU=ft("circle-x",JH);const tU=[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]],nU=ft("command",tU);const rU=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],iU=ft("copy",rU);const oU=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],aU=ft("external-link",oU);const sU=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M9 10h6",key:"9gxzsh"}],["path",{d:"M12 13V7",key:"h0r20n"}],["path",{d:"M9 17h6",key:"r8uit2"}]],lU=ft("file-diff",sU);const cU=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],c0=ft("file-text",cU);const uU=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],fU=ft("folder-open",uU);const dU=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],p9=ft("folder",dU);const hU=[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]],pU=ft("git-commit-horizontal",hU);const mU=[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]],jx=ft("git-branch",mU);const gU=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],yU=ft("globe",gU);const xU=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],m9=ft("house",xU);const bU=[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]],vU=ft("key",bU);const wU=[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]],SU=ft("lightbulb",wU);const CU=[["path",{d:"M13 5h8",key:"a7qcls"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 19h8",key:"c3s6r1"}],["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["rect",{x:"3",y:"4",width:"6",height:"6",rx:"1",key:"cif1o7"}]],EU=ft("list-todo",CU);const kU=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],ai=ft("loader-circle",kU);const TU=[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]],AU=ft("log-out",TU);const RU=[["path",{d:"M5 12h14",key:"1ays0h"}]],Mx=ft("minus",RU);const NU=[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]],OU=ft("paperclip",NU);const jU=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]],MU=ft("plug",jU);const LU=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Xa=ft("plus",LU);const _U=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],vc=ft("search",_U);const DU=[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]],IU=ft("server",DU);const zU=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],PU=ft("sparkles",zU);const FU=[["path",{d:"M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6",key:"y09zxi"}],["path",{d:"m21 3-9 9",key:"mpx6sq"}],["path",{d:"M15 3h6v6",key:"1q9fwt"}]],BU=ft("square-arrow-out-up-right",FU);const HU=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],UU=ft("trash-2",HU);const qU=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],VU=ft("triangle-alert",qU);const $U=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],g9=ft("undo-2",$U);const GU=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],Lx=ft("user",GU);const YU=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],y9=ft("x",YU),WU={ERR_NOT_AUTHENTICATED:"Please sign in to continue.",ERR_PROVIDER_NOT_CONFIGURED:"No provider is connected, or its credentials are missing or expired.",ERR_VC_ALREADY_INITIALIZED:"Version control is already initialized for this project.",ERR_VC_AUTH_FAILED:"Authentication failed. Please sign in and try again.",ERR_VC_BRANCH_NOT_FOUND:"Branch not found. You can create a new branch if needed.",ERR_VC_NO_COMMITS:"Make at least one commit before continuing.",ERR_VC_NO_REMOTE:"No remote is configured yet. Set one up before using pull, push, or fetch.",ERR_VC_NO_UPSTREAM:"This branch has no upstream configured yet. Use the Push button to publish it and set upstream in one step.",ERR_VC_NON_FAST_FORWARD:"The remote has changes. Pull first, then try again.",ERR_VC_NOTHING_TO_PUSH:"Nothing to push — stage and commit your changes first.",ERR_VC_REMOTE_ALREADY_EXISTS:"A remote named 'origin' already exists. Remove or rename it before adding a new one.",ERR_VC_USER_NOT_CONFIGURED:({projectPath:e})=>e?`Please run \`brv vc config\` in "${e}" to set your commit author before committing.`:"Please run `brv vc config` inside your project to set commit author before committing."},KU="Something went wrong";function CC(e,t){return typeof e=="object"&&e!==null&&t in e&&typeof e[t]=="string"}function Cn(e,t=KU,n={}){if(CC(e,"code")){const r=WU[e.code];if(r!==void 0)return typeof r=="function"?r(n):r}return CC(e,"message")?e.message:t}const QU=async({contextLength:e,modelId:t,providerId:n})=>{const{apiClient:r}=Be.getState();if(!r)throw new Error("Not connected");const o=await r.request(qT.SET_ACTIVE,{contextLength:e,modelId:t,providerId:n});if(!o.success&&o.error)throw new Error(o.error);return o},XU=({mutationConfig:e}={})=>wn({...e,mutationFn:QU});function u0({label:e}){return p.jsx(Yo,{className:"mono border-primary-foreground bg-primary-foreground/20 h-6 w-fit gap-1 px-2 text-[10px] tracking-[0.08em] uppercase",variant:"outline",children:e})}const ZU=3e5,JU=({providerId:e})=>{const{apiClient:t}=Be.getState();return t?t.request(Wo.AWAIT_OAUTH_CALLBACK,{providerId:e},{timeout:ZU}):Promise.reject(new Error("Not connected"))},eq=({mutationConfig:e}={})=>{const t=cn(),{onSuccess:n,...r}=e??{};return wn({onSuccess(...o){t.invalidateQueries({queryKey:bc().queryKey}),n?.(...o)},...r,mutationFn:JU})},tq=({apiKey:e,baseUrl:t,providerId:n})=>{const{apiClient:r}=Be.getState();return r?r.request(Wo.CONNECT,{apiKey:e,baseUrl:t,providerId:n}):Promise.reject(new Error("Not connected"))},nq=({mutationConfig:e}={})=>{const t=cn(),{onSuccess:n,...r}=e??{};return wn({onSuccess(...o){t.invalidateQueries({queryKey:bc().queryKey}),n?.(...o)},...r,mutationFn:tq})},rq=({providerId:e})=>{const{apiClient:t}=Be.getState();return t?t.request(Wo.DISCONNECT,{providerId:e}):Promise.reject(new Error("Not connected"))},iq=({mutationConfig:e}={})=>{const t=cn(),{onSuccess:n,...r}=e??{};return wn({onSuccess(...o){t.invalidateQueries({queryKey:bc().queryKey}),n?.(...o)},...r,mutationFn:rq})},oq=({providerId:e})=>{const{apiClient:t}=Be.getState();return t?t.request(Wo.SET_ACTIVE,{providerId:e}):Promise.reject(new Error("Not connected"))},aq=({mutationConfig:e}={})=>{const t=cn(),{onSuccess:n,...r}=e??{};return wn({onSuccess(...o){t.invalidateQueries({queryKey:bc().queryKey}),t.invalidateQueries({queryKey:Ex().queryKey}),n?.(...o)},...r,mutationFn:oq})},sq=({providerId:e})=>{const{apiClient:t}=Be.getState();return t?t.request(Wo.START_OAUTH,{providerId:e}):Promise.reject(new Error("Not connected"))},lq=({mutationConfig:e}={})=>wn({...e,mutationFn:sq}),cq=({apiKey:e,providerId:t})=>{const{apiClient:n}=Be.getState();return n?n.request(Wo.VALIDATE_API_KEY,{apiKey:e,providerId:t}):Promise.reject(new Error("Not connected"))},uq=({mutationConfig:e}={})=>wn({...e,mutationFn:cq});let EC=(function(e){return e.disabled="data-disabled",e.valid="data-valid",e.invalid="data-invalid",e.touched="data-touched",e.dirty="data-dirty",e.filled="data-filled",e.focused="data-focused",e})({});const fq={badInput:!1,customError:!1,patternMismatch:!1,rangeOverflow:!1,rangeUnderflow:!1,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valid:null,valueMissing:!1},Hu={valid:null,touched:!1,dirty:!1,filled:!1,focused:!1},dq={disabled:!1,...Hu},_x={valid(e){return e===null?null:e?{[EC.valid]:""}:{[EC.invalid]:""}}},hq=C.createContext({invalid:void 0,name:void 0,validityData:{state:fq,errors:[],error:"",value:"",initialValue:null},setValidityData:dr,disabled:void 0,touched:Hu.touched,setTouched:dr,dirty:Hu.dirty,setDirty:dr,filled:Hu.filled,setFilled:dr,focused:Hu.focused,setFocused:dr,validate:()=>null,validationMode:"onSubmit",validationDebounceTime:0,shouldValidateOnChange:()=>!1,state:dq,markedDirtyRef:{current:!1},validation:{getValidationProps:(e=Ln)=>e,getInputValidationProps:(e=Ln)=>e,inputRef:{current:null},commit:async()=>{}}});function Dx(e=!0){const t=C.useContext(hq);if(t.setValidityData===dr&&!e)throw new Error(Gn(28));return t}const pq=C.createContext({formRef:{current:{fields:new Map}},errors:{},clearErrors:dr,validationMode:"onSubmit",submitAttemptedRef:{current:!1}});function x9(){return C.useContext(pq)}const mq=C.createContext({controlId:void 0,registerControlId:dr,labelId:void 0,setLabelId:dr,messageIds:[],setMessageIds:dr,getDescriptionProps:e=>e});function Ix(){return C.useContext(mq)}function gq(e,t){return{...e,state:{...e.state,valid:!t&&e.state.valid}}}function b9({controlled:e,default:t,name:n,state:r="value"}){const{current:o}=C.useRef(e!==void 0),[a,l]=C.useState(t),c=o?e:a,f=C.useCallback(d=>{o||l(d)},[]);return[c,f]}function yq(e={}){const{id:t,implicit:n=!1,controlRef:r}=e,{controlId:o,registerControlId:a}=Ix(),l=Gi(t),c=n?o:void 0,f=Zn(()=>Symbol("labelable-control")),d=C.useRef(!1),g=C.useRef(t!=null),h=st(()=>{!d.current||a===dr||(d.current=!1,a(f.current,void 0))});return qe(()=>{if(a===dr)return;let y;if(n){const x=r?.current;Yt(x)&&x.closest("label")!=null?y=t??null:y=c??l}else if(t!=null)g.current=!0,y=t;else if(g.current)y=l;else{h();return}if(y===void 0){h();return}d.current=!0,a(f.current,y)},[t,r,c,a,n,l,f,h]),C.useEffect(()=>h,[h]),o??l}function v9(e){const{enabled:t=!0,value:n,id:r,name:o,controlRef:a,commit:l}=e,{formRef:c}=x9(),{invalid:f,markedDirtyRef:d,validityData:g,setValidityData:h}=Dx(),y=st(e.getValue);qe(()=>{if(!t)return;let x=n;x===void 0&&(x=y()),g.initialValue===null&&x!==null&&h(v=>({...v,initialValue:x}))},[t,h,n,g.initialValue,y]),qe(()=>{!t||!r||c.current.fields.set(r,{getValue:y,name:o,controlRef:a,validityData:gq(g,f),validate(x=!0){let v=n;v===void 0&&(v=y()),d.current=!0,x?Mi.flushSync(()=>l(v)):l(v)}})},[l,a,t,c,y,r,f,d,o,g,n]),qe(()=>{const x=c.current.fields;return()=>{r&&x.delete(r)}},[c,r])}const xq=C.forwardRef(function(t,n){const{render:r,className:o,id:a,name:l,value:c,disabled:f=!1,onValueChange:d,defaultValue:g,autoFocus:h=!1,...y}=t,{state:x,name:v,disabled:S,setTouched:E,setDirty:k,validityData:T,setFocused:R,setFilled:L,validationMode:j,validation:N}=Dx(),A=S||f,D=v??l,U={...x,disabled:A},{labelId:I}=Ix(),q=yq({id:a});qe(()=>{const F=c!=null;N.inputRef.current?.value||F&&c!==""?L(!0):F&&c===""&&L(!1)},[N.inputRef,L,c]);const $=C.useRef(null);qe(()=>{h&&$.current===ii(Gt($.current))&&R(!0)},[h,R]);const[V]=b9({controlled:c,default:g,name:"FieldControl",state:"value"}),Y=c!==void 0,H=Y?V:void 0;return v9({id:q,name:D,commit:N.commit,value:H,getValue:()=>N.inputRef.current?.value,controlRef:N.inputRef}),ln("input",t,{ref:[n,$],state:U,props:[{id:q,disabled:A,name:D,ref:N.inputRef,"aria-labelledby":I,autoFocus:h,...Y?{value:H}:{defaultValue:g},onChange(F){const G=F.currentTarget.value;d?.(G,Et(Jp,F.nativeEvent)),k(G!==T.initialValue),L(G!=="")},onFocus(){R(!0)},onBlur(F){E(!0),R(!1),j==="onBlur"&&N.commit(F.currentTarget.value)},onKeyDown(F){F.currentTarget.tagName==="INPUT"&&F.key==="Enter"&&(E(!0),N.commit(F.currentTarget.value))}},N.getInputValidationProps(),y],stateAttributesMapping:_x})}),bq=C.createContext({disabled:!1});function vq(){return C.useContext(bq)}const wq=C.createContext(void 0);function Sq(e=!0){const t=C.useContext(wq);if(t===void 0&&!e)throw new Error(Gn(3));return t}const Cq=C.forwardRef(function(t,n){return p.jsx(xq,{ref:n,...t})});function Ko({className:e,type:t,...n}){return p.jsx(Cq,{type:t,"data-slot":"input",className:we("h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-2.5 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",e),...n})}function Eq({error:e,isOptional:t,isValidating:n,onBack:r,onSubmit:o,provider:a}){const[l,c]=C.useState("");return p.jsxs("div",{className:"flex flex-1 flex-col gap-6",children:[p.jsx(ui,{children:p.jsxs(fi,{className:"flex items-center gap-2",children:[p.jsx("button",{className:"hover:bg-muted rounded p-0.5 transition-colors",onClick:r,type:"button",children:p.jsx(Fs,{className:"size-5"})}),"Selecting ",a.name]})}),p.jsxs("div",{className:"flex flex-col gap-4",children:[a.apiKeyUrl&&p.jsxs("p",{className:"text-muted-foreground text-sm",children:["Get your API key at"," ",p.jsx("a",{className:"underline hover:text-foreground",href:a.apiKeyUrl,rel:"noopener noreferrer",target:"_blank",children:a.apiKeyUrl})]}),e&&p.jsx("div",{className:"text-destructive bg-destructive/10 rounded-lg px-4 py-2.5 text-sm",children:e}),p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsxs("label",{className:"text-foreground text-sm font-medium",htmlFor:"api-key",children:["Enter your ",a.name," API key"]}),p.jsx(Ko,{id:"api-key",onChange:f=>c(f.target.value),placeholder:"Enter key",type:"password",value:l})]})]}),p.jsxs(Qa,{className:"mt-auto",children:[p.jsx(De,{onClick:r,variant:"secondary",children:"Cancel"}),p.jsx(De,{disabled:!t&&!l.trim()||n,onClick:()=>o(l.trim()),children:n?"Validating...":"Change"})]})]})}function kq({onBack:e,onSelect:t,provider:n}){return p.jsxs("div",{className:"flex flex-1 flex-col gap-6",children:[p.jsx(ui,{children:p.jsxs(fi,{className:"flex items-center gap-2",children:[p.jsx("button",{className:"hover:bg-muted rounded p-0.5 transition-colors",onClick:e,type:"button",children:p.jsx(Fs,{className:"size-5"})}),"Connect ",n.name]})}),p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsxs("button",{className:"hover:bg-muted flex w-full cursor-pointer items-center gap-3 rounded-lg px-3 py-3 text-left transition-colors",onClick:()=>t("oauth"),type:"button",children:[p.jsx(yU,{className:"text-muted-foreground size-5"}),p.jsxs("div",{className:"flex flex-col",children:[p.jsx("span",{className:"text-foreground text-sm font-medium",children:n.oauthLabel??"Sign in with browser"}),p.jsx("span",{className:"text-muted-foreground text-xs",children:"Authenticate via OAuth in your browser"})]})]}),p.jsxs("button",{className:"hover:bg-muted flex w-full cursor-pointer items-center gap-3 rounded-lg px-3 py-3 text-left transition-colors",onClick:()=>t("api-key"),type:"button",children:[p.jsx(vU,{className:"text-muted-foreground size-5"}),p.jsxs("div",{className:"flex flex-col",children:[p.jsx("span",{className:"text-foreground text-sm font-medium",children:"Enter API key"}),p.jsx("span",{className:"text-muted-foreground text-xs",children:"Paste your API key manually"})]})]})]}),p.jsx(Qa,{className:"mt-auto",children:p.jsx(De,{onClick:e,variant:"secondary",children:"Cancel"})})]})}function Tq(e){if(!e)return"Base URL is required";try{const t=new URL(e);return["http:","https:"].includes(t.protocol)?void 0:"URL must start with http:// or https://"}catch{return"Invalid URL format"}}function Aq({error:e,onBack:t,onSubmit:n,provider:r}){const[o,a]=C.useState(""),[l,c]=C.useState(),f=l??e,d=C.useCallback(()=>{const g=o.trim().replace(/\/+$/,""),h=Tq(g);if(h){c(h);return}c(void 0),n(g)},[o,n]);return p.jsxs("div",{className:"flex flex-1 flex-col gap-6",children:[p.jsx(ui,{children:p.jsxs(fi,{className:"flex items-center gap-2",children:[p.jsx("button",{className:"hover:bg-muted rounded p-0.5 transition-colors",onClick:t,type:"button",children:p.jsx(Fs,{className:"size-5"})}),"Selecting ",r.name]})}),p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsx("label",{className:"text-foreground text-sm font-medium",htmlFor:"base-url",children:"Enter endpoint manually"}),p.jsx(Ko,{id:"base-url",onChange:g=>{a(g.target.value),c(void 0)},placeholder:"http://localhost:11434/v1",value:o}),f&&p.jsx("p",{className:"text-destructive text-sm",children:f})]}),p.jsxs(Qa,{className:"mt-auto",children:[p.jsx(De,{onClick:t,variant:"secondary",children:"Cancel"}),p.jsx(De,{disabled:!o.trim(),onClick:d,children:"Change"})]})]})}const w9=()=>{const{apiClient:e}=Be.getState();return e?e.request(_f.START_LOGIN,{skipBrowserLaunch:!0}):Promise.reject(new Error("Not connected"))},S9=e=>{const{apiClient:t}=Be.getState();return t?t.on(_f.LOGIN_COMPLETED,e):()=>{}};function zx(e){try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return!1}}const Rq=2500;function Nq({onAuthenticated:e,onBack:t}){const n=cn(),r=ji(f=>f.isAuthorized),o=ji(f=>f.setLoggingIn),[a,l]=C.useState({type:"idle"});C.useEffect(()=>{r&&a.type==="waiting"&&(o(!1),e())},[r,e,o,a.type]),C.useEffect(()=>a.type!=="waiting"?void 0:S9(d=>{d.success&&d.user?n.invalidateQueries({queryKey:so().queryKey}):l({message:d.error??"Authentication failed",type:"error"}),o(!1)}),[n,o,a.type]),C.useEffect(()=>{if(a.type!=="waiting")return;let f=!1;async function d(){try{const h=await n.fetchQuery(so());if(f)return;h.isAuthorized&&(n.invalidateQueries({queryKey:so().queryKey}),o(!1))}catch{}}const g=globalThis.setInterval(d,Rq);return()=>{f=!0,globalThis.clearInterval(g)}},[n,o,a.type]);async function c(){o(!0);const f=window.open("about:blank","_blank");l({type:"starting"});try{const d=await w9();if(!zx(d.authUrl))throw f?.close(),new Error("Received an unsafe OAuth URL from the daemon");f&&!f.closed?f.location.href=d.authUrl:window.open(d.authUrl,"_blank","noopener,noreferrer"),l({authUrl:d.authUrl,type:"waiting"})}catch(d){o(!1),l({message:d instanceof Error?d.message:"Unable to start login",type:"error"})}}return p.jsxs("div",{className:"flex flex-1 flex-col gap-6",children:[p.jsx(ui,{children:p.jsxs(fi,{className:"flex items-center gap-2",children:[p.jsx("button",{className:"hover:bg-muted rounded p-0.5 transition-colors",onClick:t,type:"button",children:p.jsx(Fs,{className:"size-5"})}),"Sign in to ByteRover"]})}),p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("p",{className:"text-muted-foreground text-sm",children:["ByteRover requires authentication before it can be used as a provider. Sign in to your"," ",p.jsx("span",{className:"text-foreground",children:"byterover.dev"})," account to continue."]}),a.type==="starting"&&p.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-blue-500/20 bg-blue-500/5 p-3 text-sm text-blue-700",children:[p.jsx(ai,{className:"size-4 animate-spin"}),"Starting authentication…"]}),a.type==="waiting"&&p.jsxs("div",{className:"flex flex-col gap-1 rounded-lg border bg-card p-3",children:[p.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[p.jsx(ai,{className:"text-primary size-4 animate-spin"}),"Finish signing in in the new tab."]}),p.jsxs("div",{className:"text-muted-foreground pl-6 text-xs",children:["If the tab didn’t open,"," ",p.jsx("a",{className:"underline underline-offset-2",href:a.authUrl,rel:"noopener noreferrer",target:"_blank",children:"click this link"}),"."]})]}),a.type==="error"&&p.jsx("div",{className:"text-destructive bg-destructive/10 rounded-lg px-4 py-2.5 text-sm",children:a.message})]}),p.jsxs(Qa,{className:"mt-auto",children:[p.jsx(De,{onClick:t,variant:"secondary",children:"Cancel"}),a.type==="error"?p.jsx(De,{onClick:()=>l({type:"idle"}),children:"Try again"}):p.jsx(De,{disabled:a.type==="starting"||a.type==="waiting",onClick:c,children:a.type==="waiting"?"Waiting…":"Sign in"})]})]})}const Oq=({providerId:e})=>{const{apiClient:t}=Be.getState();return t?t.request(qT.LIST,{providerId:e}):Promise.reject(new Error("Not connected"))},jq=e=>({queryFn:()=>Oq({providerId:e}),queryKey:["models",e]}),C9=({providerId:e,queryConfig:t})=>br({...jq(e),...t});function Mq({onBack:e,onSelect:t,providerId:n}){const[r,o]=C.useState(""),{data:a,isLoading:l}=C9({providerId:n}),[c,f]=C.useState(),d=C.useMemo(()=>a?.models??[],[a?.models]);C.useEffect(()=>{a?.activeModel&&!c&&f(a.activeModel)},[a?.activeModel,c]);const g=C.useMemo(()=>{if(!r)return d;const y=r.toLowerCase();return d.filter(x=>x.name.toLowerCase().includes(y)||x.id.toLowerCase().includes(y))},[d,r]),h=C.useMemo(()=>d.find(y=>y.id===c),[d,c]);return l?p.jsxs("div",{className:"flex flex-1 flex-col gap-6",children:[p.jsx(ui,{children:p.jsxs(fi,{className:"flex items-center gap-2",children:[p.jsx("button",{className:"hover:bg-muted rounded p-0.5 transition-colors",onClick:e,type:"button",children:p.jsx(Fs,{className:"size-5"})}),"Choose model"]})}),p.jsx("div",{className:"flex items-center justify-center py-12",children:p.jsx(ai,{className:"text-muted-foreground size-5 animate-spin"})})]}):p.jsxs("div",{className:"flex flex-1 flex-col gap-6",children:[p.jsx(ui,{children:p.jsxs(fi,{className:"flex items-center gap-2",children:[p.jsx("button",{className:"hover:bg-muted rounded p-0.5 transition-colors",onClick:e,type:"button",children:p.jsx(Fs,{className:"size-5"})}),"Choose model"]})}),p.jsxs("div",{className:"flex flex-col gap-3",children:[p.jsxs("div",{className:"relative",children:[p.jsx(vc,{className:"text-muted-foreground absolute top-1/2 left-3 size-4 -translate-y-1/2"}),p.jsx(Ko,{className:"pl-9",onChange:y=>o(y.target.value),placeholder:"Search...",value:r})]}),p.jsxs("div",{className:"max-h-96 overflow-y-auto",children:[g.map(y=>{const x=y.id===c;return p.jsxs("button",{className:`border-border flex w-full cursor-pointer items-center justify-between border-b px-3 py-2.5 text-left transition-colors last:border-b-0 ${x?"bg-primary/10":"hover:bg-muted"}`,onClick:()=>f(y.id),type:"button",children:[p.jsx("span",{className:"text-foreground text-sm",children:y.name}),x&&p.jsx(Ys,{className:"text-primary size-4"})]},y.id)}),g.length===0&&p.jsx("p",{className:"text-muted-foreground py-8 text-center text-sm",children:"No models found"})]})]}),p.jsxs(Qa,{className:"mt-auto",children:[p.jsx(De,{onClick:e,variant:"secondary",children:"Cancel"}),p.jsx(De,{disabled:!h,onClick:()=>h&&t(h),children:"Confirm"})]})]})}function Lq({error:e,onAction:t,onBack:n,provider:r}){const{data:o}=C9({providerId:r.id}),a=o?.activeModel,l=r.id==="byterover";return p.jsxs("div",{className:"flex flex-1 flex-col gap-6",children:[p.jsx(ui,{children:p.jsxs(fi,{className:"flex items-center gap-2",children:[p.jsx("button",{className:"hover:bg-muted rounded p-0.5 transition-colors",onClick:n,type:"button",children:p.jsx(Fs,{className:"size-5"})}),r.name]})}),p.jsxs("div",{className:"flex flex-col gap-4",children:[e&&p.jsx("div",{className:"text-destructive bg-destructive/10 rounded-lg px-4 py-2.5 text-sm",children:e}),l?p.jsxs("div",{className:"flex items-start justify-between",children:[p.jsxs("div",{className:"flex flex-col gap-1",children:[p.jsx("span",{className:"text-foreground text-sm font-medium",children:"Status"}),p.jsx("span",{className:"text-muted-foreground text-sm",children:r.isConnected?"Connected":"Not connected"})]}),r.isConnected&&p.jsx(De,{onClick:()=>t("disconnect"),size:"sm",variant:"outline",children:"Disconnect"})]}):p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex items-start justify-between",children:[p.jsxs("div",{className:"flex flex-col gap-1",children:[p.jsx("span",{className:"text-foreground text-sm font-medium",children:"Model"}),p.jsx("span",{className:"text-muted-foreground text-sm",children:a??"Not selected"})]}),p.jsx(De,{onClick:()=>t("change_model"),size:"sm",variant:"outline",children:"Change"})]}),p.jsxs("div",{className:"flex items-start justify-between",children:[p.jsxs("div",{className:"flex flex-col gap-1",children:[p.jsx("span",{className:"text-foreground text-sm font-medium",children:r.authMethod==="oauth"?"OAuth":"API Key"}),p.jsx("span",{className:"text-muted-foreground text-sm",children:r.authMethod==="oauth"?"Authenticated via browser":"****************"})]}),p.jsx(De,{onClick:()=>t("disconnect"),size:"sm",variant:"outline",children:"Disconnect"})]})]})]}),!r.isCurrent&&p.jsxs(Qa,{className:"mt-auto",children:[p.jsx(De,{onClick:n,variant:"secondary",children:"Cancel"}),p.jsx(De,{onClick:()=>t("activate"),children:"Active"})]})]})}const _q="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M4.53096%2012.97L8.07285%2010.9839L8.13242%2010.8115L8.07285%2010.7155H7.90026L7.30833%2010.679L5.28456%2010.6244L3.5294%2010.5515L1.82897%2010.4604L1.4011%2010.3693L1%209.84087L1.04132%209.57726L1.40112%209.33553L1.91647%209.38047L3.05537%209.45823L4.76433%209.57605L6.00411%209.64894L7.8407%209.83964H8.13242L8.17374%209.72182L8.07407%209.64894L7.99629%209.57605L6.22776%208.37831L4.31339%207.11255L3.31063%206.38372L2.76851%206.01443L2.49504%205.66823L2.37713%204.91268L2.86941%204.3709L3.53062%204.41585L3.69958%204.46079L4.3693%204.97583L5.79991%206.08247L7.66811%207.45754L7.94158%207.68469L8.05098%207.60696L8.06435%207.55229L7.94158%207.34701L6.92544%205.51154L5.84125%203.64449L5.35869%202.8707L5.23107%202.40667C5.1861%202.21595%205.15329%202.05561%205.15329%201.86003L5.71361%201.09961L6.02356%201L6.77108%201.09961L7.0859%201.37293L7.55021%202.43462L8.30258%204.10609L9.46944%206.37885L9.81099%207.05303L9.9933%207.67741L10.0614%207.86813H10.1793V7.75881L10.2753%206.47848L10.4528%204.9066L10.6254%202.88406L10.6849%202.31435L10.9669%201.63166L11.5272%201.2624L11.9648%201.47133L12.3246%201.98638L12.2748%202.31922L12.0608%203.70888L11.6415%205.8857L11.368%207.34338H11.5272L11.7095%207.16118L12.4474%206.18209L13.6871%204.6333L14.2341%204.01864L14.8722%203.3396L15.2818%203.01648H16.0561L16.6262%203.86316L16.3709%204.73776L15.5736%205.74843L14.9123%206.60483L13.9643%207.88029L13.3723%208.90067L13.427%208.98206L13.568%208.96869L15.7097%208.51317L16.8668%208.30424L18.2476%208.06736L18.8724%208.3589L18.9404%208.65528L18.6949%209.26145L17.2181%209.62586L15.4861%209.97207L12.9068%2010.5819L12.8752%2010.605L12.9117%2010.6499L14.0737%2010.7592L14.5708%2010.7859H15.7875L18.0531%2010.9548L18.6451%2011.3459L19%2011.8246L18.9404%2012.189L18.0288%2012.653L16.7988%2012.3614L13.9278%2011.6788L12.9433%2011.4334H12.8072V11.5148L13.6276%2012.3165L15.1311%2013.6734L17.0139%2015.4226L17.1099%2015.855L16.8681%2016.1964L16.6128%2016.1599L14.9585%2014.9161L14.3204%2014.3561L12.8752%2013.1401H12.7792V13.2676L13.1122%2013.7548L14.871%2016.3968L14.9622%2017.2071L14.8346%2017.4706L14.3788%2017.6298L13.878%2017.5387L12.8485%2016.0944L11.7861%2014.4678L10.9292%2013.0101L10.8247%2013.0697L10.3191%2018.5129L10.0821%2018.7911L9.53507%2019L9.07927%2018.6538L8.83739%2018.0938L9.07927%2016.9872L9.37099%2015.5429L9.608%2014.3949L9.82193%2012.9688L9.94955%2012.4951L9.94105%2012.4635L9.83651%2012.4769L8.76081%2013.9528L7.12479%2016.1624L5.83031%2017.5472L5.52036%2017.6699L4.98312%2017.3917L5.03294%2016.8949L5.33317%2016.4527L7.12479%2014.1751L8.20535%2012.7635L8.90303%2011.9485L8.89817%2011.8306H8.85684L4.09825%2014.9185L3.25106%2015.0278L2.88643%2014.6865L2.9314%2014.1265L3.10398%2013.9443L4.5346%2012.9603L4.52974%2012.9652L4.53096%2012.97Z'%20fill='%23D4D4D4'/%3e%3c/svg%3e",Dq="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M10%2020C15.5228%2020%2020%2015.5228%2020%2010C20%204.47715%2015.5228%200%2010%200C4.47715%200%200%204.47715%200%2010C0%2015.5228%204.47715%2020%2010%2020Z'%20fill='black'/%3e%3cpath%20d='M10.001%2019.002C14.9715%2019.002%2019.001%2014.9725%2019.001%2010.002C19.001%205.03139%2014.9715%201.00195%2010.001%201.00195C5.03042%201.00195%201.00098%205.03139%201.00098%2010.002C1.00098%2014.9725%205.03042%2019.002%2010.001%2019.002Z'%20fill='%23FAFAFA'/%3e%3cpath%20d='M9.99951%2017.998C14.4178%2017.998%2017.9995%2014.4163%2017.9995%209.99805C17.9995%205.57977%2014.4178%201.99805%209.99951%201.99805C5.58123%201.99805%201.99951%205.57977%201.99951%209.99805C1.99951%2014.4163%205.58123%2017.998%209.99951%2017.998Z'%20fill='black'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M3.31787%209.29102C3.31787%209.29102%2018.082%209.72982%2016.6512%2015.291C15.9389%2016.4198%2015.8512%2015.691%2015.8512%2015.691C15.8512%2015.691%2018.2852%2011.1457%203.31787%209.29102Z'%20fill='%23FAFAFA'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M5.27588%205.86523C5.27588%205.86523%2020.04%206.30403%2018.6092%2011.8652C17.8969%2012.994%2017.8092%2012.2652%2017.8092%2012.2652C17.8092%2012.2652%2020.2432%207.7199%205.27588%205.86523Z'%20fill='%23FAFAFA'/%3e%3cpath%20d='M8.72058%203.59961C8.75064%203.60051%2016.4092%203.83385%2017.83%206.39648L17.3895%206.91504C16.922%205.87794%2015.0863%204.38843%208.72058%203.59961Z'%20fill='%23FAFAFA'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M5.45898%2013.9904C5.48859%2013.9908%2013.7293%2014.1055%2013.9676%2017.2002L13.4287%2017.5307C13.2582%2016.5898%2011.9628%2014.9484%205.45898%2013.9904Z'%20fill='%23FAFAFA'/%3e%3c/svg%3e",Iq="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M11.7675%202.25036C9.71229%202.25036%207.74126%203.06679%206.28801%204.52004C4.83476%205.97329%204.01833%207.94432%204.01833%209.99953C4.01833%2012.0547%204.83476%2014.0258%206.28801%2015.479C7.74126%2016.9323%209.71229%2017.7487%2011.7675%2017.7487V18.9162C6.8425%2018.9162%202.85083%2014.9237%202.85083%209.9987C2.85083%205.0737%206.84166%201.08203%2011.7667%201.08203V2.24953L11.7675%202.25036ZM15.7275%205.31453C15.1118%204.79188%2014.3989%204.3961%2013.6297%204.14994C12.8605%203.90378%2012.0503%203.8121%2011.2455%203.88018C10.4408%203.94825%209.65746%204.17474%208.94056%204.54661C8.22366%204.91848%207.58735%205.42841%207.06821%206.04706C6.54907%206.6657%206.15735%207.38088%205.91557%208.15144C5.6738%208.92201%205.58673%209.73277%205.65938%2010.5371C5.73204%2011.3414%205.96298%2012.1235%206.33892%2012.8382C6.71487%2013.553%207.2284%2014.1864%207.85%2014.702L7.09916%2015.597C6.36511%2014.9813%205.75953%2014.227%205.31702%2013.3772C4.87452%2012.5274%204.60374%2011.5987%204.52017%2010.6443C4.43659%209.68983%204.54185%208.72826%204.82994%207.81448C5.11802%206.90071%205.58329%206.05264%206.19916%205.3187C6.81497%204.58461%207.56935%203.97902%208.41922%203.5365C9.26909%203.09398%2010.1978%202.8232%2011.1523%202.73963C12.1069%202.65606%2013.0685%202.76132%2013.9823%203.04942C14.8962%203.33752%2015.7443%203.8028%2016.4783%204.4187L15.7275%205.31453ZM13.8483%206.01786C12.7928%205.47266%2011.5646%205.36641%2010.4311%205.72223C9.29756%206.07806%208.35044%206.86716%207.79583%207.91781C7.24123%208.96847%207.12401%2010.1956%207.4697%2011.3323C7.81539%2012.4689%208.596%2013.4231%209.64166%2013.987L9.095%2015.0204C7.7889%2014.3042%206.81675%2013.1032%206.38832%2011.6766C5.95989%2010.25%206.10954%208.7121%206.80498%207.39485C7.50041%206.07759%208.68587%205.08657%2010.1055%204.63564C11.5252%204.1847%2013.0652%204.31001%2014.3933%204.98453L13.8483%206.01786ZM11.7667%207.11536C11.0017%207.11536%2010.2681%207.41923%209.72725%207.96012C9.18636%208.501%208.8825%209.2346%208.8825%209.99953C8.8825%2010.7645%209.18636%2011.4981%209.72725%2012.0389C10.2681%2012.5798%2011.0017%2012.8837%2011.7667%2012.8837V14.052C10.6919%2014.052%209.6611%2013.6251%208.90111%2012.8651C8.14112%2012.1051%207.71416%2011.0743%207.71416%209.99953C7.71416%208.92474%208.14112%207.89397%208.90111%207.13398C9.6611%206.37399%2010.6919%205.94703%2011.7667%205.94703V7.11536Z'%20fill='%23D4D4D4'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M12.8392%209.03094C12.715%208.89716%2012.5718%208.78232%2012.4142%208.69011C12.277%208.60856%2012.1205%208.56486%2011.9609%208.56344C11.7484%208.56344%2011.5584%208.60261%2011.3909%208.68011C11.229%208.75304%2011.0835%208.85797%2010.9632%208.98857C10.8429%209.11918%2010.7503%209.27277%2010.6909%209.44011C10.6292%209.60927%2010.5992%209.78677%2010.5992%209.96594C10.5992%2010.1476%2010.6292%2010.3243%2010.6909%2010.4918C10.7508%2010.6589%2010.8436%2010.8124%2010.9638%2010.9431C11.0841%2011.0738%2011.2293%2011.179%2011.3909%2011.2526C11.5576%2011.3301%2011.7492%2011.3693%2011.9609%2011.3693C12.1409%2011.3693%2012.3084%2011.3309%2012.4626%2011.2568C12.6192%2011.1818%2012.7542%2011.0693%2012.8584%2010.9301L13.6317%2011.7684C13.5151%2011.8851%2013.3817%2011.9859%2013.2301%2012.0709C12.9496%2012.2274%2012.6443%2012.3345%2012.3276%2012.3876C12.1859%2012.4093%2012.0634%2012.4209%2011.9609%2012.4209C11.6246%2012.423%2011.2908%2012.3637%2010.9759%2012.2459C10.6781%2012.1358%2010.4057%2011.9666%2010.1751%2011.7484C9.94568%2011.5293%209.76311%2011.2659%209.63839%2010.9743C9.50286%2010.6556%209.43531%2010.3122%209.44005%209.96594C9.44005%209.59594%209.50672%209.26011%209.63839%208.95761C9.76339%208.66594%209.94505%208.40261%2010.1742%208.18344C10.4059%207.96594%2010.6784%207.79677%2010.9759%207.68677C11.2908%207.56898%2011.6246%207.50967%2011.9609%207.51177C12.2567%207.51177%2012.5542%207.56844%2012.8542%207.68177C13.1551%207.79677%2013.4251%207.98177%2013.6409%208.22261L12.8392%209.03094Z'%20fill='%23D4D4D4'/%3e%3c/svg%3e",zq="data:image/svg+xml,%3csvg%20width='154'%20height='154'%20viewBox='0%200%20154%20154'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmask%20id='mask0_2024_36638'%20style='mask-type:luminance'%20maskUnits='userSpaceOnUse'%20x='0'%20y='0'%20width='155'%20height='155'%3e%3cpath%20d='M0%200H154.006V154.006H0V0Z'%20fill='white'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_2024_36638)'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M49.8953%2091.6962C54.0408%2091.6962%2062.2864%2091.4688%2073.6847%2086.7762C86.9655%2081.308%20113.39%2071.381%20132.453%2061.1848C145.784%2054.0535%20151.628%2044.621%20151.628%2031.9191C151.628%2014.2909%20137.337%200%20119.709%200H45.8476C20.5281%200%200%2020.5272%200%2045.8485C0%2071.169%2019.2191%2091.6962%2049.8953%2091.6962Z'%20fill='white'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M62.3879%20123.269C62.388%20117.199%2064.1868%20111.266%2067.5572%20106.218C70.9276%20101.17%2075.7184%2097.2344%2081.3244%2094.908L104.585%2085.2545C128.112%2075.4896%20154.009%2092.78%20154.009%20118.254C154.009%20137.99%20138.007%20153.987%20118.27%20153.982L93.0868%20153.976C76.1307%20153.971%2062.3879%20140.225%2062.3879%20123.269Z'%20fill='white'/%3e%3cpath%20d='M26.4302%2097.7402C11.8322%2097.7402%200%20109.572%200%20124.17V127.593C0%20142.189%2011.8331%20154.022%2026.4293%20154.022C41.0263%20154.022%2052.8595%20142.189%2052.8595%20127.593V124.17C52.8595%20109.572%2041.0263%2097.7402%2026.4302%2097.7402Z'%20fill='white'/%3e%3c/g%3e%3c/svg%3e",Pq="/assets/deepinfra-provider-C9hH_wkN.svg",Fq="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M17.05%209.04649C15.6632%208.44953%2014.4499%207.63057%2013.4094%206.59059C12.3695%205.55064%2011.5505%204.33675%2010.9535%202.94998C10.7243%202.4185%2010.5402%201.87217%2010.399%201.31204C10.353%201.12891%2010.1888%201%2010%201C9.81124%201%209.64703%201.12891%209.60102%201.31204C9.45981%201.87217%209.27566%202.41798%209.04649%202.94998C8.44953%204.33675%207.63057%205.55064%206.59059%206.59059C5.55064%207.63057%204.33675%208.44953%202.94998%209.04649C2.41849%209.27566%201.87217%209.4598%201.31204%209.60102C1.12891%209.64703%201%209.81124%201%2010C1%2010.1888%201.12891%2010.353%201.31204%2010.399C1.87217%2010.5402%202.41798%2010.7243%202.94998%2010.9535C4.33675%2011.5505%205.55014%2012.3695%206.59059%2013.4094C7.63107%2014.4494%208.44953%2015.6632%209.04649%2017.05C9.27566%2017.5815%209.45981%2018.1278%209.60102%2018.688C9.64703%2018.8711%209.81124%2019%2010%2019C10.1888%2019%2010.353%2018.8711%2010.399%2018.688C10.5402%2018.1278%2010.7243%2017.582%2010.9535%2017.05C11.5505%2015.6632%2012.3695%2014.4499%2013.4094%2013.4094C14.4494%2012.3695%2015.6632%2011.5505%2017.05%2010.9535C17.5815%2010.7243%2018.1278%2010.5402%2018.688%2010.399C18.8711%2010.353%2019%2010.1888%2019%2010C19%209.81124%2018.8711%209.64703%2018.688%209.60102C18.1278%209.4598%2017.582%209.27566%2017.05%209.04649Z'%20fill='%23D4D4D4'/%3e%3c/svg%3e",Bq="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M10.03%201.66627C6.81913%201.6371%204.19663%204.16627%204.16663%207.3171C4.13746%2010.4688%206.71246%2013.0438%209.92329%2013.0729H11.94V10.9346H10.03C8.02413%2010.9579%206.37996%209.3796%206.35663%207.4096C6.33246%205.44127%207.94079%203.82793%209.94663%203.8046H10.03C12.0358%203.8046%2013.6616%205.40043%2013.6675%207.3696V12.6238C13.6675%2014.5754%2012.0475%2016.1654%2010.065%2016.1896C9.11901%2016.1829%208.2127%2015.8088%207.53746%2015.1463L5.99496%2016.6613C7.07129%2017.7186%208.51543%2018.3177%2010.0241%2018.3329H10.1008C13.27%2018.2863%2015.8158%2015.7638%2015.8333%2012.6529V7.23627C15.7558%204.13543%2013.1808%201.66627%2010.03%201.66627Z'%20fill='%23D4D4D4'/%3e%3c/svg%3e",Hq="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M18.205%200C18.63%200%2019.0377%200.168834%2019.3382%200.469361C19.6387%200.769888%2019.8075%201.17749%2019.8075%201.6025C19.8075%202.02751%2019.6387%202.43511%2019.3382%202.73564C19.0377%203.03617%2018.63%203.205%2018.205%203.205H16.7917C16.7669%203.20511%2016.7423%203.20032%2016.7194%203.1909C16.6964%203.18149%2016.6756%203.16763%2016.658%203.15013C16.6404%203.13263%2016.6265%203.11184%2016.617%203.08893C16.6074%203.06603%2016.6025%203.04147%2016.6025%203.01667V1.6025C16.6025%200.7175%2017.32%200%2018.205%200Z'%20fill='%23D4D4D4'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M9.22083%209.3319L15.2683%203.3319C15.3825%203.21857%2015.3183%202.99023%2015.1717%202.99023H11.9167C11.8984%202.99044%2011.8804%202.99431%2011.8636%203.00161C11.8469%203.00891%2011.8318%203.01949%2011.8192%203.03273L5.3025%209.49607C5.20083%209.59607%205.05083%209.5069%205.05083%209.3469V3.18273C5.05083%203.0769%204.98167%202.99107%204.89667%202.99107H2.655C2.56917%202.99107%202.5%203.0769%202.5%203.18273V16.4744C2.5%2016.5811%202.56917%2016.6661%202.655%2016.6661H4.89667C4.9825%2016.6661%205.05167%2016.5811%205.05167%2016.4744V13.7661C5.05167%2013.7086%205.0725%2013.6536%205.10917%2013.6177L7.12917%2011.6127C7.15062%2011.5896%207.17967%2011.5749%207.21102%2011.5714C7.24238%2011.5679%207.27395%2011.5758%207.3%2011.5936L12.7033%2015.5702C13.5615%2016.1549%2014.5491%2016.5218%2015.5808%2016.6394C15.6708%2016.6494%2015.7475%2016.5602%2015.7475%2016.4477V13.8977C15.7475%2013.8002%2015.6892%2013.7211%2015.6108%2013.7086C15.0053%2013.6107%2014.4287%2013.3812%2013.9217%2013.0361L9.24417%209.6494C9.14667%209.5844%209.13417%209.4169%209.22083%209.3319Z'%20fill='%23D4D4D4'/%3e%3c/svg%3e",Uq="/assets/minimax-provider-BqW25BvT.svg",qq="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M2.85667%202.83398H5.71417V5.69065H8.57167V8.54815H8.57H11.4292V5.69065H14.285V2.83398H17.1433V14.2623H20V17.1198H11.4283V14.2632H8.57167V11.4057H5.71333V14.2623L8.57167%2014.2632V17.1198H0V14.2623H2.85667V2.83398ZM11.4283%2014.2632H14.285V11.4057H11.4292V14.2632H11.4283Z'%20fill='%23D4D4D4'/%3e%3c/svg%3e",kC="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M17.813%208.3673C18.2269%207.14159%2018.0844%205.79887%2017.4226%204.68397C16.4272%202.97394%2014.4263%202.09417%2012.4721%202.50818C11.6027%201.54178%2010.3537%200.992208%209.04425%201.00008C7.04673%200.995583%205.27439%202.26461%204.65985%204.14003C3.37663%204.39934%202.26898%205.19192%201.62082%206.31526C0.618065%208.0208%200.846663%2010.1707%202.18632%2011.6332C1.77245%2012.859%201.91497%2014.2017%202.57682%2015.3166C3.57216%2017.0266%205.5731%2017.9064%207.5273%2017.4924C8.39608%2018.4588%209.64567%2019.0083%2010.9551%2018.9999C12.9538%2019.005%2014.7267%2017.7348%2015.3412%2015.8577C16.6245%2015.5984%2017.7321%2014.8058%2018.3803%2013.6825C19.3819%2011.9769%2019.1527%209.82871%2017.8136%208.36618L17.813%208.3673ZM10.9563%2017.8237C10.1565%2017.8248%209.38173%2017.5486%208.76777%2017.0429C8.7957%2017.0283%208.84416%2017.0019%208.87551%2016.9827L12.508%2014.9127C12.6938%2014.8086%2012.8078%2014.6134%2012.8067%2014.4025V9.34945L14.3419%2010.2242C14.3584%2010.232%2014.3693%2010.2478%2014.3715%2010.2658V14.4503C14.3693%2016.3111%2012.8421%2017.8198%2010.9563%2017.8237ZM3.6115%2014.7282C3.21074%2014.0453%203.06651%2013.2448%203.2039%2012.468C3.23069%2012.4838%203.27801%2012.5125%203.31164%2012.5316L6.94412%2014.6016C7.12825%2014.7079%207.35628%2014.7079%207.54098%2014.6016L11.9755%2012.0748V13.8242C11.9767%2013.8422%2011.9681%2013.8597%2011.9539%2013.8709L8.28207%2015.9629C6.64654%2016.8922%204.55781%2016.3398%203.61207%2014.7282H3.6115ZM2.65549%206.90421C3.05454%206.2202%203.68447%205.69706%204.43468%205.42537C4.43468%205.4563%204.43297%205.51087%204.43297%205.54912V9.68977C4.43183%209.90015%204.54584%2010.0953%204.73111%2010.1994L9.16568%2012.7256L7.63048%2013.6004C7.61509%2013.6105%207.59571%2013.6122%207.57861%2013.6049L3.90622%2011.5112C2.27412%2010.5785%201.71431%208.51806%202.65492%206.90477L2.65549%206.90421ZM15.2688%209.80058L10.8343%207.27378L12.3695%206.39964C12.3849%206.38951%2012.4042%206.38782%2012.4213%206.39514L16.0937%208.48712C17.7287%209.4192%2018.2891%2011.4831%2017.3445%2013.0963C16.9448%2013.7792%2016.3155%2014.3024%2015.5658%2014.5746V10.3102C15.5675%2010.0998%2015.4541%209.90521%2015.2694%209.80058H15.2688ZM16.7966%207.53141C16.7698%207.5151%2016.7225%207.48697%2016.6889%207.46785L13.0564%205.3978C12.8723%205.29149%2012.6442%205.29149%2012.4595%205.3978L8.02497%207.92461V6.17519C8.02383%206.15719%208.03238%206.13976%208.04663%206.12851L11.7184%204.03821C13.354%203.10725%2015.445%203.66133%2016.3879%205.27574C16.7864%205.9575%2016.9306%206.75571%2016.7955%207.53141H16.7966ZM7.19039%2010.6494L5.65462%209.77471C5.63809%209.76683%205.62726%209.75108%205.62498%209.73308V5.54856C5.62612%203.68552%207.1579%202.17573%209.04596%202.17686C9.84463%202.17686%2010.6176%202.45361%2011.2316%202.95763C11.2037%202.97225%2011.1558%202.99869%2011.1239%203.01781L7.49138%205.08786C7.30554%205.19192%207.19153%205.38655%207.19267%205.59749L7.19039%2010.6483V10.6494ZM8.0244%208.87525L9.99969%207.74967L11.975%208.87469V11.1253L9.99969%2012.2503L8.0244%2011.1253V8.87525Z'%20fill='%23D4D4D4'/%3e%3c/svg%3e",Vq="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmask%20id='mask0_1940_35557'%20style='mask-type:luminance'%20maskUnits='userSpaceOnUse'%20x='2'%20y='2'%20width='16'%20height='16'%3e%3cpath%20d='M2%202H18V18H2V2Z'%20fill='white'/%3e%3c/mask%3e%3cg%20mask='url(%23mask0_1940_35557)'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M13.2027%203.30472L18.016%206.04138V6.09938L13.1533%208.80669L13.1647%207.39538L12.6173%207.37538C11.9113%207.35669%2011.5433%207.37669%2011.1053%207.44869C10.396%207.56538%209.74666%207.83337%209.00734%208.35003L7.56334%209.35338C7.374%209.48338%207.23334%209.57738%207.11%209.65669L6.76666%209.87138L6.502%2010.0274L6.75866%2010.1807L7.112%2010.406C7.42934%2010.6154%207.892%2010.9367%208.91266%2011.65C9.65266%2012.1667%2010.3013%2012.4347%2011.0107%2012.5514L11.2107%2012.5814C11.6733%2012.642%2012.1273%2012.644%2013.094%2012.6034L13.1087%2011.164L17.922%2013.9007V13.9587L13.0593%2016.6667L13.0687%2015.4254L12.6453%2015.44C11.7213%2015.468%2011.2207%2015.4414%2010.5533%2015.332C9.424%2015.1454%208.38%2014.7147%207.29934%2013.9594L5.86066%2012.9594C5.69519%2012.8453%205.52738%2012.7346%205.35734%2012.6274L5.046%2012.4407C4.87788%2012.3438%204.70897%2012.2483%204.53934%2012.154C3.93866%2011.82%202.37531%2011.4107%202%2011.4107V8.59203L2.09334%208.59469C2.46934%208.59003%204.03334%208.18003%204.63266%207.84538L5.31%207.45869L5.602%207.27603C5.88734%207.08938%206.31666%206.79203%207.39266%206.04069C8.47334%205.28537%209.51666%204.85403%2010.6467%204.66803C11.4147%204.54138%2011.9627%204.52603%2013.1893%204.57603L13.2027%203.30472Z'%20fill='%23D4D4D4'/%3e%3c/g%3e%3c/svg%3e",$q="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M16.4875%200V6.06H18.75V14.6833H16.3042V20L10.44%2014.8383V19.9592H9.53083V14.8325L3.66%2020V14.6125H1.25V5.99H3.65333V0L9.53083%205.41167V0.158333H10.4392V5.56667L16.4875%200ZM10.44%207.53667V13.6358L15.395%2017.9975V12.0333L10.44%207.53667ZM9.52417%207.47L4.56917%2011.9683V17.9975L9.52417%2013.6358V7.47083V7.47ZM16.3042%2013.7867H17.8408V6.9575H11.2167L16.3042%2011.5742V13.7867ZM8.81917%206.88667H2.15833V13.7158H3.65833V11.5692L8.81833%206.88583L8.81917%206.88667ZM4.5625%202.06333V5.98833H8.825L4.5625%202.06333ZM15.5783%202.06333L11.3158%205.98833H15.5783V2.06333Z'%20fill='%23D4D4D4'/%3e%3c/svg%3e",Gq="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_1940_35595)'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M19.3308%203.75216C19.0025%203.18344%2018.5654%202.68496%2018.0444%202.28519C17.5234%201.88543%2016.9288%201.5922%2016.2945%201.42227C15.6601%201.25233%2014.9986%201.20901%2014.3475%201.29479C13.6964%201.38056%2013.0686%201.59374%2012.5%201.92216C11.7706%202.34073%2011.1591%202.93729%2010.7227%203.65615C10.2862%204.37502%2010.039%205.19274%2010.0042%206.033L15.0008%206.03966V6.46883H10.0042C10.0367%207.24966%2010.2525%208.02716%2010.6708%208.75216C10.9925%209.33338%2011.4267%209.84468%2011.9482%2010.2562C12.4696%2010.6677%2013.0679%2010.9712%2013.708%2011.1489C14.348%2011.3266%2015.0171%2011.375%2015.6761%2011.2912C16.3351%2011.2075%2016.9707%2010.9932%2017.546%2010.661C18.1213%2010.3288%2018.6245%209.88533%2019.0265%209.35644C19.4284%208.82755%2019.7209%208.22387%2019.8869%207.58067C20.0529%206.93746%2020.0891%206.26762%2019.9934%205.61028C19.8976%204.95293%2019.6718%204.32126%2019.3292%203.75216H19.3308Z'%20fill='%23D4D4D4'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M0.670785%203.74946C0.342331%204.31807%200.129098%204.94582%200.0432647%205.59684C-0.042569%206.24787%200.00067736%206.90943%200.170534%207.54374C0.340391%208.17806%200.633531%208.7727%201.03322%209.29371C1.4329%209.81473%201.9313%2010.2519%202.49995%2010.5803C3.22718%2011.0028%204.04963%2011.2341%204.89049%2011.2526C5.73134%2011.2711%206.56317%2011.0762%207.30829%2010.6861L4.81579%206.35529L5.18745%206.14113L7.68495%2010.4678C8.32417%2010.0608%208.86254%209.51393%209.25936%208.86837C9.65619%208.22281%209.90109%207.4955%209.97556%206.7414C10.05%205.9873%209.95213%205.22614%209.68925%204.51543C9.42637%203.80472%209.00539%203.16306%208.45812%202.63893C7.91085%202.11481%207.25161%201.72193%206.53021%201.48999C5.80881%201.25804%205.04413%201.1931%204.29395%201.30007C3.54377%201.40704%202.82771%201.68312%202.1999%202.10745C1.57208%202.53178%201.04975%203.09326%200.670785%203.74946Z'%20fill='%23D4D4D4'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M9.99996%2019.9121C11.3259%2019.9119%2012.5975%2019.385%2013.535%2018.4473C14.4725%2017.5097%2014.9991%2016.238%2014.9991%2014.9121C14.9991%2013.1371%2014.0825%2011.5821%2012.6866%2010.6954L10.1825%2015.0196L9.81246%2014.8046L12.31%2010.4779C11.6379%2010.1278%2010.895%209.93492%2010.1375%209.91401C9.37993%209.8931%208.62755%2010.0447%207.93719%2010.3572C7.24683%2010.6698%206.63655%2011.1352%206.15248%2011.7183C5.66841%2012.3014%205.32321%2012.9869%205.14298%2013.723C4.96274%2014.459%204.95219%2015.2265%205.11211%2015.9672C5.27203%2016.708%205.59824%2017.4027%206.06609%2017.9989C6.53394%2018.5951%207.13119%2019.0771%207.8127%2019.4085C8.4942%2019.74%209.24213%2019.9122%209.99996%2019.9121Z'%20fill='%23D4D4D4'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_1940_35595'%3e%3crect%20width='20'%20height='20'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",Yq="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M10%203L18%2017H2L10%203Z'%20fill='%23D4D4D4'/%3e%3c/svg%3e",Wq="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M6.1283%207.65527L13.1584%2018H10.0336L3.0035%207.65527H6.1283ZM6.1255%2013.4007L7.6886%2015.7018L6.1269%2018H3L6.1255%2013.4007ZM17%203.15055V18H14.4387V6.91927L17%203.15055ZM17%202L10.0336%2012.2509L8.4705%209.95055L13.8731%202H17Z'%20fill='%23D4D4D4'/%3e%3c/svg%3e",Kq="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M10.5744%203L9.03162%205.0671H2.46254L4.00458%203H10.5751H10.5744ZM18.4716%2014.9336L16.9302%2017H10.3838L11.9237%2014.9336H18.4716ZM19%203L8.562%2017H2L12.438%203H19Z'%20fill='%23D4D4D4'/%3e%3c/svg%3e",Qq={anthropic:_q,byterover:Dq,cerebras:Iq,cohere:zq,deepinfra:Pq,glm:Kq,google:Fq,groq:Bq,minimax:Uq,mistral:qq,moonshot:Hq,openai:kC,"openai-compatible":kC,openrouter:Vq,perplexity:$q,togetherai:Gq,vercel:Yq,xai:Wq};function Xq({onSelect:e,providers:t}){const[n,r]=C.useState(""),o=C.useMemo(()=>{if(!n)return t;const a=n.toLowerCase();return t.filter(l=>l.name.toLowerCase().includes(a))},[t,n]);return p.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-5",children:[p.jsxs(ui,{children:[p.jsx(fi,{children:"Pick a provider to power curate & query"}),p.jsx(Ff,{children:"ByteRover routes LLM calls through your chosen provider. You can change this later."})]}),p.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3",children:[p.jsxs("div",{className:"relative",children:[p.jsx(vc,{className:"text-muted-foreground absolute top-1/2 left-3 size-4 -translate-y-1/2"}),p.jsx(Ko,{className:"pl-9",onChange:a=>r(a.target.value),placeholder:"Search...",value:n})]}),p.jsx("div",{className:"flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto pr-4 -mr-4 [scrollbar-gutter:stable]",children:o.map(a=>{const l=Qq[a.id],c=a.isCurrent;return p.jsxs("button",{className:we("group/row flex w-full cursor-pointer items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors",c?"border-primary-foreground/40 bg-primary/5":"border-border hover:border-foreground/25"),onClick:()=>e(a),title:a.description,type:"button",children:[p.jsx("div",{className:"bg-muted/50 grid size-7 shrink-0 place-items-center overflow-hidden rounded-md",children:l&&p.jsx("img",{alt:"",className:"size-5",src:l})}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"text-foreground truncate text-sm font-medium",children:a.name}),p.jsx("div",{className:"text-muted-foreground min-h-[1lh] truncate text-xs",children:a.description})]}),p.jsx("div",{className:we("grid size-[18px] shrink-0 place-items-center rounded-full border transition-colors",c?"bg-primary-foreground border-primary-foreground":"border-border"),children:c&&p.jsx(Ys,{className:"text-background size-3",strokeWidth:3})})]},a.id)})})]})]})}const k2="byterover",Zq=6,Jq=1e3;function eV(e){return new Promise(t=>{setTimeout(t,e)})}function Px({onOpenChange:e,onProviderActivated:t,open:n,tourStepLabel:r}){const[o,a]=C.useState("select"),[l,c]=C.useState(),[f,d]=C.useState(),[g,h]=C.useState(),[y,x]=C.useState(!1),v=ji(M=>M.isAuthorized),{data:S}=VT(),E=nq(),k=iq(),T=aq(),R=uq(),L=lq(),j=eq(),N=XU(),A=S?.providers??[],D=C.useCallback(()=>{a("select"),c(void 0),d(void 0),h(void 0),x(!1)},[]),U=C.useCallback(()=>{e(!1),setTimeout(D,150)},[e,D]),I=C.useCallback(M=>{M?e(!0):(e(!1),setTimeout(D,150))},[e,D]),q=C.useCallback(async M=>{a("connecting");try{let P=await E.mutateAsync({providerId:M.id});for(let Q=0;!P.success&&Q<Zq;Q++)await eV(Jq),P=await E.mutateAsync({providerId:M.id});if(!P.success){ut.error(P.error??"Failed to connect ByteRover"),a("select");return}await T.mutateAsync({providerId:M.id}),ut.success(`Connected to ${M.name}`),t?.(),U()}catch(P){ut.error(Cn(P,"Connection failed")),a("select")}},[E,t,U,T]),$=C.useCallback(async M=>{if(c(M),h(void 0),M.id===k2&&!v){a("login_prompt");return}if(M.id===k2&&M.isCurrent){t?.(),U();return}if(M.isConnected){a("provider_actions");return}if(M.id===k2){await q(M);return}if(M.id==="openai-compatible"){a("base_url");return}if(M.supportsOAuth){a("auth_method");return}if(M.requiresApiKey){a("api_key");return}a("connecting");try{await E.mutateAsync({providerId:M.id}),x(!0),a("model_select")}catch(P){ut.error(Cn(P,"Connection failed")),a("select")}},[q,E,v,t,U]),V=C.useCallback(async M=>{a("connecting");try{const P=await L.mutateAsync({providerId:M.id});if(!P.success){ut.error(P.error??"Failed to start OAuth"),a("select");return}const Q=await j.mutateAsync({providerId:M.id});Q.success?(x(!0),a("model_select")):(ut.error(Q.error??"OAuth failed"),a("select"))}catch(P){ut.error(Cn(P,"OAuth failed")),a("select")}},[j,L]),Y=C.useCallback(async M=>{if(l)switch(M){case"activate":{a("connecting");try{await T.mutateAsync({providerId:l.id}),ut.success(`Activated ${l.name}`),t?.(),U()}catch(P){h(Cn(P,"Failed")),a("provider_actions")}break}case"change_model":{a("model_select");break}case"disconnect":{a("connecting");try{await k.mutateAsync({providerId:l.id}),ut.success(`Disconnected ${l.name}`),a("select"),c(void 0),h(void 0)}catch(P){h(Cn(P,"Failed")),a("provider_actions")}break}case"reconfigure":{a("base_url");break}case"reconnect_oauth":{await V(l);break}case"replace":{a("api_key");break}}},[k,V,t,U,l,T]),H=C.useCallback(M=>{d(M),a("api_key")},[]),B=C.useCallback(async M=>{if(l){if(l.id!=="openai-compatible"&&M)try{const P=await R.mutateAsync({apiKey:M,providerId:l.id});if(!P.isValid){h(P.error??"Invalid API key");return}}catch(P){h(Cn(P,"Validation failed"));return}a("connecting");try{await E.mutateAsync({apiKey:M||void 0,baseUrl:f??void 0,providerId:l.id}),x(!0),a("model_select")}catch(P){h(Cn(P,"Connection failed")),a("api_key")}}},[f,E,l,R]),F=C.useCallback(async M=>{if(l)try{await N.mutateAsync({contextLength:M.contextLength,modelId:M.id,providerId:l.id}),y?(ut.success(`Connected to ${l.name}`),t?.(),U()):(ut.success(`Model set to ${M.name}`),a("provider_actions"))}catch(P){ut.error(Cn(P,"Failed to set model"))}},[y,t,U,l,N]),G=C.useCallback(()=>{h(void 0),l?.id==="openai-compatible"?a("base_url"):l?.supportsOAuth?a("auth_method"):a("select")},[l]),ie=()=>{switch(o){case"api_key":return l?p.jsx(Eq,{error:g,isOptional:l.id==="openai-compatible",isValidating:R.isPending,onBack:G,onSubmit:M=>B(M),provider:l}):null;case"auth_method":return l?p.jsx(kq,{onBack:()=>{a("select"),c(void 0),h(void 0)},onSelect:M=>{M==="oauth"?V(l):a("api_key")},provider:l}):null;case"base_url":return l?p.jsx(Aq,{error:g,onBack:()=>{a("select"),h(void 0)},onSubmit:H,provider:l}):null;case"connecting":return p.jsxs("div",{className:"flex flex-col items-center gap-3 py-12",children:[p.jsx(ai,{className:"text-primary size-6 animate-spin"}),p.jsxs("p",{className:"text-muted-foreground text-sm",children:["Connecting to ",l?.name,"..."]})]});case"login_prompt":return l?p.jsx(Nq,{onAuthenticated:()=>{q(l)},onBack:()=>{a("select"),c(void 0)}}):null;case"model_select":return l?p.jsx(Mq,{onBack:()=>{a(y?"select":"provider_actions")},onSelect:F,providerId:l.id}):null;case"provider_actions":return l?p.jsx(Lq,{error:g,onAction:Y,onBack:()=>{a("select"),c(void 0),h(void 0)},provider:l}):null;case"select":return p.jsx(Xq,{onSelect:M=>$(M),providers:A});default:return null}};return p.jsx($s,{onOpenChange:I,open:n,children:p.jsxs(Gs,{className:"flex h-150 flex-col sm:max-w-lg",showCloseButton:o==="select"||o==="model_select"||o==="connecting"||o==="login_prompt",children:[r&&p.jsx(u0,{label:r}),ie()]})})}function E9({...e}){return p.jsx(c9,{"data-slot":"sheet",...e})}function tV({...e}){return p.jsx(Ox,{"data-slot":"sheet-portal",...e})}function nV({className:e,...t}){return p.jsx(Ax,{"data-slot":"sheet-overlay",className:we("fixed inset-0 z-50 bg-black/10 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:backdrop-blur-xs",e),...t})}function k9({className:e,children:t,side:n="right",showCloseButton:r=!0,...o}){return p.jsxs(tV,{children:[p.jsx(nV,{}),p.jsxs(Nx,{"data-slot":"sheet-content","data-side":n,className:we("fixed z-50 flex flex-col gap-4 bg-background bg-clip-padding text-sm shadow-lg transition duration-200 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-[2.5rem] data-[side=bottom]:data-starting-style:translate-y-[2.5rem] data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:border-r data-[side=left]:data-ending-style:translate-x-[-2.5rem] data-[side=left]:data-starting-style:translate-x-[-2.5rem] data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=right]:data-ending-style:translate-x-[2.5rem] data-[side=right]:data-starting-style:translate-x-[2.5rem] data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:translate-y-[-2.5rem] data-[side=top]:data-starting-style:translate-y-[-2.5rem] ",e),...o,children:[t,r&&p.jsxs(Pf,{"data-slot":"sheet-close",render:p.jsx(De,{variant:"ghost",className:"absolute top-4 right-4",size:"icon-sm"}),children:[p.jsx(qp,{}),p.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function Fx({className:e,...t}){return p.jsx("textarea",{"data-slot":"textarea",className:we("flex field-sizing-content min-h-16 w-full rounded-md border border-border bg-background px-2.5 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none placeholder:text-muted-foreground focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-background dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",e),...t})}const rV=e=>{const{apiClient:t}=Be.getState();return t?t.request(ks.CREATE,e):Promise.reject(new Error("Not connected"))},iV=({mutationConfig:e}={})=>wn({...e,mutationFn:rV});function oV(e){const t=iV(),n=e.content.trim().length>0,{isPending:r}=t;return{canSubmit:n,isPending:r,submit:async()=>{if(!n||r)return;if(!e.hasActiveProvider){e.onProviderRequired();return}const a=crypto.randomUUID(),l={...e.projectPath?{clientCwd:e.projectPath,projectPath:e.projectPath}:{},content:e.content.trim(),taskId:a,type:e.type};try{await t.mutateAsync(l);const c=e.type==="query"?"Query":"Curate";ut.success(`${c} task queued`,{position:"top-center"}),e.onSubmitted?.(a,e.openDetailAfter),e.onClose()}catch(c){ut.error(c instanceof Error?c.message:"Failed to create task",{position:"top-center"})}}}}const TC={curate:"JWT tokens expire after 24h. Refresh window is 7 days. Rotation happens on every successful refresh — old refresh token is invalidated immediately.",query:"What is our auth token expiration policy?"},aV={curate:"Plain text knowledge to capture into the project context tree.",query:"The agent searches the project context tree and synthesizes an answer."};function sV({type:e}){return p.jsx("p",{className:"text-muted-foreground/60 text-xs",children:aV[e]})}function lV(){return p.jsxs("p",{className:"text-muted-foreground/60 mt-2 flex items-center gap-1.5 text-xs",children:[p.jsx(SU,{className:"size-3 shrink-0"}),p.jsxs("span",{children:["For file or folder attachments, use"," ",p.jsx("code",{className:"bg-muted text-foreground/80 mono rounded px-1.5 py-0.5 text-[11px]",children:"brv curate -f <path>"})," ","from the CLI."]})]})}function cV({label:e}){return p.jsxs(Yo,{className:"text-primary-foreground absolute top-2.5 right-3 gap-1.5 px-2 text-[10px] tracking-[0.08em] uppercase",variant:"secondary",children:[p.jsx("span",{"aria-hidden":!0,className:"bg-primary-foreground size-1.5 rounded-full"}),e]})}let AC=(function(e){return e.checked="data-checked",e.unchecked="data-unchecked",e.indeterminate="data-indeterminate",e.disabled="data-disabled",e.readonly="data-readonly",e.required="data-required",e.valid="data-valid",e.invalid="data-invalid",e.touched="data-touched",e.dirty="data-dirty",e.filled="data-filled",e.focused="data-focused",e})({});function T9(e){return C.useMemo(()=>({checked(t){return e.indeterminate?{}:t?{[AC.checked]:""}:{[AC.unchecked]:""}},..._x}),[e.indeterminate])}function uV(e,t,n,r=!0,o){const[a,l]=C.useState(),c=Gi(o?`${o}-label`:void 0),f=e??t??a;return qe(()=>{const d=e||t||!r?void 0:fV(n.current,c);a!==d&&l(d)}),f}function fV(e,t){const n=dV(e);if(n)return!n.id&&t&&(n.id=t),n.id||void 0}function dV(e){if(!e)return;const t=e.parentElement;if(t&&t.tagName==="LABEL")return t;const n=e.id;if(n){const o=e.nextElementSibling;if(o&&o.htmlFor===n)return o}const r=e.labels;return r&&r[0]}const A9=C.createContext(void 0);function hV(){const e=C.useContext(A9);if(e===void 0)throw new Error(Gn(14));return e}const pV="data-parent",mV=C.forwardRef(function(t,n){const{checked:r,className:o,defaultChecked:a=!1,"aria-labelledby":l,disabled:c=!1,id:f,indeterminate:d=!1,inputRef:g,name:h,onCheckedChange:y,parent:x=!1,readOnly:v=!1,render:S,required:E=!1,uncheckedValue:k,value:T,nativeButton:R=!1,...L}=t,{clearErrors:j}=x9(),{disabled:N,name:A,setDirty:D,setFilled:U,setFocused:I,setTouched:q,state:$,validationMode:V,validityData:Y,shouldValidateOnChange:H,validation:B}=Dx(),F=vq(),{labelId:G,controlId:ie,registerControlId:M,getDescriptionProps:P}=Ix(),Q=Sq(),_=Q?.parent,ee=_&&Q.allValues,J=N||F.disabled||Q?.disabled||c,re=A??h,pe=T??re,fe=Gi(),Ce=Gi();let Ee=ie;ee?Ee=x?Ce:`${_.id}-${pe}`:f&&(Ee=f);let Ie={};ee&&(x?Ie=Q.parent.getParentProps():pe&&(Ie=Q.parent.getChildProps(pe)));const Ye=st(y),{checked:je=r,indeterminate:_e=d,onCheckedChange:ye,...We}=Ie,Te=Q?.value,Re=Q?.setValue,he=Q?.defaultValue,Se=C.useRef(null),ne=Zn(()=>Symbol("checkbox-control")),xe=C.useRef(!1),{getButtonProps:ze,buttonRef:Ue}=zf({disabled:J,native:R}),wt=Q?.validation??B,[ae,ve]=b9({controlled:pe&&Te&&!x?Te.includes(pe):je,default:pe&&he&&!x?he.includes(pe):a,name:"Checkbox",state:"checked"});qe(()=>{M!==dr&&(xe.current=!0,M(ne.current,Ee))},[Ee,Q,M,x,ne]),C.useEffect(()=>{const Qe=ne.current;return()=>{!xe.current||M===dr||(xe.current=!1,M(Qe,void 0))}},[M,ne]),v9({enabled:!Q,id:fe,commit:wt.commit,value:ae,controlRef:Se,name:re,getValue:()=>ae});const Oe=C.useRef(null),Me=Ms(g,Oe,wt.inputRef),He=uV(l,G,Oe,!R,Ee??void 0);qe(()=>{Oe.current&&(Oe.current.indeterminate=_e,ae&&U(!0))},[ae,_e,U]),o9(ae,()=>{Q&&!x||(j(re),U(ae),D(ae!==Y.initialValue),H()?wt.commit(ae):wt.commit(ae,!0))});const kt=Ba({checked:ae,disabled:J,name:x?void 0:re,id:R?void 0:Ee??void 0,required:E,ref:Me,style:re?J_:a6,tabIndex:-1,type:"checkbox","aria-hidden":!0,onChange(Qe){if(Qe.nativeEvent.defaultPrevented)return;const yt=Qe.target.checked,Pt=Et(Jp,Qe.nativeEvent);if(ye?.(yt,Pt),Ye(yt,Pt),!Pt.isCanceled&&(ve(yt),pe&&Te&&Re&&!x)){const Wt=yt?[...Te,pe]:Te.filter(yn=>yn!==pe);Re(Wt,Pt)}},onFocus(){Se.current?.focus()}},T!==void 0?{value:(Q?ae&&T:T)||""}:Ln,P,Q?wt.getValidationProps:wt.getInputValidationProps),Ft=ee?!!je:ae,Xe=ee&&_e||d;C.useEffect(()=>{if(!_||!pe)return;const Qe=_.disabledStatesRef.current;return Qe.set(pe,J),()=>{Qe.delete(pe)}},[_,J,pe]);const Ve=C.useMemo(()=>({...$,checked:Ft,disabled:J,readOnly:v,required:E,indeterminate:Xe}),[$,Ft,J,v,E,Xe]),pt=T9(Ve),mt=ln("span",t,{state:Ve,ref:[Ue,Se,n,Q?.registerControlRef],props:[{id:R?Ee??void 0:fe,role:"checkbox","aria-checked":_e?"mixed":ae,"aria-readonly":v||void 0,"aria-required":E||void 0,"aria-labelledby":He,[pV]:x?"":void 0,onFocus(){I(!0)},onBlur(){const Qe=Oe.current;Qe&&(q(!0),I(!1),V==="onBlur"&&wt.commit(Q?Te:Qe.checked))},onClick(Qe){v||J||(Qe.preventDefault(),Oe.current?.dispatchEvent(new PointerEvent("click",{bubbles:!0,shiftKey:Qe.shiftKey,ctrlKey:Qe.ctrlKey,altKey:Qe.altKey,metaKey:Qe.metaKey})))}},P,wt.getValidationProps,L,We,ze],stateAttributesMapping:pt});return p.jsxs(A9.Provider,{value:Ve,children:[mt,!ae&&!Q&&re&&!x&&k!==void 0&&p.jsx("input",{type:"hidden",name:re,value:k}),p.jsx("input",{...kt})]})}),gV=C.forwardRef(function(t,n){const{render:r,className:o,keepMounted:a=!1,...l}=t,c=hV(),f=c.checked||c.indeterminate,{mounted:d,transitionStatus:g,setMounted:h}=Xy(f),y=C.useRef(null),x={...c,transitionStatus:g};mc({open:f,ref:y,onComplete(){f||h(!1)}});const v=T9(c),S=C.useMemo(()=>({...v,...pc,..._x}),[v]),E=a||d,k=ln("span",t,{ref:[n,y],state:x,stateAttributesMapping:S,props:l});return E?k:null});function yV({className:e,...t}){return p.jsx(mV,{"data-slot":"checkbox",className:we("peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input shadow-xs transition-shadow outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-foreground dark:data-checked:bg-primary",e),...t,children:p.jsx(gV,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none [&>svg]:size-3.5",children:p.jsx(qE,{})})})}function xV({canSubmit:e,hasActiveProvider:t,inTour:n,isPending:r,onClose:o,onOpenDetailChange:a,onSubmit:l,openDetailAfter:c,type:f}){const y=r?f==="query"?"Querying…":"Curating…":n||t?f==="query"?"Query":"Curate":"Connect provider…";return p.jsxs("footer",{className:"border-border flex items-center justify-between gap-3 border-t px-7 py-3.5",children:[n?p.jsx("span",{}):p.jsxs("label",{className:"text-muted-foreground inline-flex cursor-pointer items-center gap-2 text-xs",children:[p.jsx(yV,{checked:c,onCheckedChange:a}),"Open after submit"]}),p.jsxs("div",{className:"ml-2 flex items-center gap-2",children:[p.jsx(De,{onClick:o,size:"sm",variant:"ghost",children:"Cancel"}),p.jsx(De,{disabled:!e||r,onClick:l,size:"sm",children:y})]})]})}function bV({inTour:e,onTypeChange:t,projectPath:n,tourStepLabel:r,type:o}){return p.jsxs("header",{className:"border-border flex flex-col gap-2 border-b px-7 pt-5 pb-4",children:[r&&p.jsx(u0,{label:r}),p.jsxs("div",{className:"flex items-center justify-between gap-4 pr-10",children:[p.jsxs("h2",{className:"text-foreground flex items-baseline gap-1.5 text-lg font-medium tracking-tight",children:[p.jsx("span",{className:"text-muted-foreground/70 font-normal",children:"New"}),p.jsxs("span",{children:[o," task"]})]}),!e&&p.jsx(vV,{onChange:t,value:o})]}),p.jsxs("p",{className:"text-muted-foreground/70 text-xs",children:[o==="query"?"Searches":"Will dispatch to"," ",p.jsx("span",{className:"text-identifier mono",children:n||"(no project selected)"})]})]})}function vV({onChange:e,value:t}){return p.jsxs("div",{className:"border-border bg-muted relative inline-flex rounded-md border p-0.5",children:[p.jsx("span",{"aria-hidden":!0,className:we("bg-background border-border absolute top-0.5 bottom-0.5 w-[calc(50%-2px)] rounded border transition-transform duration-200 ease-out",t==="query"?"translate-x-full":"translate-x-0")}),["curate","query"].map(n=>p.jsx("button",{className:we("relative z-10 px-3 py-1 text-xs font-medium transition-colors",n===t?"text-foreground":"text-muted-foreground hover:text-foreground/80"),onClick:()=>e(n),type:"button",children:n==="curate"?"Curate":"Query"},n))]})}function R9({initialContent:e,initialType:t,onClose:n,onSubmitted:r,open:o,prefillNotice:a,tourStepLabel:l}){const c=!!l;return p.jsx(E9,{onOpenChange:f=>!f&&n(),open:o,children:p.jsx(k9,{className:we("data-[side=right]:w-full data-[side=right]:max-w-xl p-0 shadow-[inset_1px_0_0_rgba(96,165,250,0.18)]",!c&&"sheet-no-overlay"),side:"right",children:o&&p.jsx(wV,{initialContent:e,initialType:t,onClose:n,onSubmitted:r,prefillNotice:a,tourStepLabel:l})})})}function wV({initialContent:e,initialType:t,onClose:n,onSubmitted:r,prefillNotice:o,tourStepLabel:a}){const l=Be(q=>q.selectedProject),{data:c}=kx(),[f,d]=C.useState(t??"curate"),[g,h]=C.useState(e??""),[y,x]=C.useState(!0),[v,S]=C.useState(!1),[E,k]=C.useState(!!e),T=C.useRef(null);C.useEffect(()=>{T.current?.focus()},[]);const R=!!c,L=!!a,{canSubmit:j,isPending:N,submit:A}=oV({content:g,hasActiveProvider:R,onClose:n,onProviderRequired:()=>S(!0),onSubmitted:r,openDetailAfter:y,projectPath:l,type:f}),D=q=>{if((q.metaKey||q.ctrlKey)&&q.key==="Enter"){q.preventDefault(),A().catch(()=>{});return}q.key==="Tab"&&!q.shiftKey&&!g&&(q.preventDefault(),h(TC[f]))},U=!!(o&&E&&g===(e??"")),I=q=>{E&&q!==(e??"")&&k(!1),h(q)};return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[p.jsx(bV,{inTour:L,onTypeChange:d,projectPath:l,tourStepLabel:a,type:f}),p.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto px-7 py-5",children:[p.jsxs("div",{className:"space-y-1.5",children:[p.jsxs("div",{className:"relative",children:[p.jsx(Fx,{className:"bg-card dark:bg-card text-foreground/90 mono min-h-64 pr-4 pb-7 text-sm leading-relaxed",onChange:q=>I(q.target.value),onKeyDown:D,placeholder:TC[f],ref:T,rows:f==="query"?4:6,value:g}),U&&o&&p.jsx(cV,{label:o}),p.jsxs("span",{className:"text-muted-foreground/40 mono pointer-events-none absolute right-3 bottom-2 flex items-center gap-2 text-[10px] tabular-nums",children:[p.jsx("span",{className:"text-muted-foreground/60",children:g?p.jsxs(p.Fragment,{children:[p.jsxs("kbd",{className:"bg-muted text-foreground/70 inline-flex items-center gap-1 rounded px-1.5 py-0.5 leading-none",children:[p.jsx(nU,{className:"size-2.5"})," · Ctrl + Enter"]})," ","to ",f]}):p.jsxs(p.Fragment,{children:[p.jsx("kbd",{className:"bg-muted text-foreground/70 inline-flex items-center rounded px-1.5 py-0.5 leading-none",children:"Tab"})," ","to use example"]})}),p.jsxs("span",{children:[g.length," chars"]})]})]}),p.jsx(sV,{type:f})]}),f==="curate"&&!L&&p.jsx(lV,{})]}),p.jsx(xV,{canSubmit:j,hasActiveProvider:R,inTour:L,isPending:N,onClose:n,onOpenDetailChange:x,onSubmit:A,openDetailAfter:y,type:f})]}),p.jsx(Px,{onOpenChange:S,open:v})]})}function SV(){const e=on(c=>c.tourActive),t=on(c=>c.tourStep),n=on(c=>c.advanceTour),r=on(c=>c.exitTour),o=qa(),a=e&&t==="connector",l=()=>{n(),o("/configuration")};return p.jsx($s,{onOpenChange:c=>!c&&r(),open:a,children:p.jsxs(Gs,{className:"flex flex-col gap-5 p-6 sm:max-w-[460px]",children:[p.jsx(u0,{label:"Step 4 of 4 · Optional"}),p.jsxs("div",{className:"flex flex-col gap-3",children:[p.jsx("div",{className:"bg-primary/12 text-primary-foreground grid size-10 place-items-center rounded-lg",children:p.jsx(MU,{className:"size-5"})}),p.jsx("h2",{className:"text-foreground text-base font-semibold",children:"Use ByteRover from your AI agent"}),p.jsxs("p",{className:"text-muted-foreground text-sm leading-relaxed",children:["Connect a tool like Claude Code, Cursor, or any MCP client and you can curate & query the context tree without leaving your chat. It's optional — you can always come back via the"," ",p.jsx("span",{className:"text-foreground font-medium",children:"Configuration"})," tab."]})]}),p.jsxs("div",{className:"border-border -mx-6 -mb-6 mt-2 flex items-center gap-2 border-t px-6 py-4",children:[p.jsx(De,{onClick:()=>n(),type:"button",variant:"ghost",children:"Maybe later"}),p.jsx("div",{className:"flex-1"}),p.jsxs(De,{onClick:l,type:"button",children:["Open Configuration",p.jsx(d9,{className:"size-4"})]})]})]})})}function CV(){return on.getState().tourStep==="provider"}const EV="JWT tokens expire after 24h. Refresh window is 7 days. Rotation happens on every successful refresh — old refresh token is invalidated immediately.",kV="What is our auth token expiration policy?";function TV(){const e=on(d=>d.tourActive),t=on(d=>d.tourStep),n=on(d=>d.tourTaskId),r=on(d=>d.exitTour),o=on(d=>d.advanceTour),a=on(d=>d.setTourTaskId),l=qa(),c=C.useRef(!1);if(!e||!t)return null;const f=(t==="curate"||t==="query")&&!n;return p.jsxs(p.Fragment,{children:[t==="provider"&&p.jsx(Px,{onOpenChange:d=>{d||CV()&&r()},onProviderActivated:()=>o(),open:!0,tourStepLabel:"Step 1 of 4"}),f&&p.jsx(R9,{initialContent:t==="curate"?EV:kV,initialType:t,onClose:()=>{if(c.current){c.current=!1;return}r()},onSubmitted:d=>{c.current=!0,a(d),l(`/tasks?task=${d}`)},open:!0,prefillNotice:"example",tourStepLabel:t==="curate"?"Step 2 of 4":"Step 3 of 4"},t),p.jsx(SV,{})]})}function AV(){const e=on(o=>o.seenWelcome),t=on(o=>o.dismissWelcome),n=on(o=>o.startTour),r=Be(o=>o.selectedProject);return e?null:p.jsx($s,{onOpenChange:o=>!o&&t(),open:!0,children:p.jsxs(Gs,{className:"flex max-w-[420px] flex-col items-center gap-6 p-8 text-center sm:max-w-[420px]",showCloseButton:!1,children:[p.jsx("img",{alt:"Byterover",className:"size-11",src:gx}),p.jsxs(ui,{className:"flex flex-col gap-2.5",children:[p.jsx(fi,{className:"text-foreground text-xl font-semibold tracking-tight",children:"Welcome to ByteRover"}),p.jsxs(Ff,{className:"text-muted-foreground text-sm leading-relaxed",children:["A 3-minute tour will get you from zero to your first answer. You can restart it any time from the"," ",p.jsx("span",{className:"text-foreground font-medium",children:"Help"})," menu in the top-right."]})]}),p.jsxs("div",{className:"flex w-full max-w-[300px] flex-col gap-2",children:[p.jsxs(De,{onClick:()=>n(),size:"lg",children:[p.jsx(PU,{className:"size-4"}),"Take the tour"]}),p.jsx(De,{className:"text-muted-foreground hover:text-foreground text-xs",onClick:()=>t(),variant:"link",children:"Skip — take me in"})]}),r&&p.jsx("p",{className:"text-identifier mono max-w-full truncate text-[10px] tracking-wider",title:r,children:r})]})})}function RV(){const e=on(o=>o.tourActive),t=on(o=>o.tourStep),n=on(o=>o.advanceTour),{data:r}=kx({queryConfig:{enabled:e&&t==="provider"}});C.useEffect(()=>{!e||t!=="provider"||r?.activeModel&&n()},[e,t,r?.activeModel,n])}const NV=()=>{const{apiClient:e}=Be.getState();return e?e.request(rr.STATUS):Promise.reject(new Error("Not connected"))},hi=()=>({queryFn:NV,queryKey:["vc","status"],refetchInterval:3e3,refetchIntervalInBackground:!1,staleTime:2e3}),Bx=({queryConfig:e}={})=>br({...hi(),...e}),OV=["both_added","both_modified","deleted_modified"];function jV(e){return OV.includes(e)?e:void 0}function N9(e){if(!e)return{staged:[],unmerged:[],unstaged:[]};const t=new Set(e.conflictMarkerFiles??[]),n=(e.unmerged??[]).map(({path:l,type:c})=>({conflictType:jV(c),hasMarkers:t.has(l),isStaged:!1,path:l,status:"unmerged"})),r=[...e.staged.added.map(l=>({isStaged:!0,path:l,status:"added"})),...e.staged.modified.map(l=>({isStaged:!0,path:l,status:"modified"})),...e.staged.deleted.map(l=>({isStaged:!0,path:l,status:"deleted"}))],o=[...e.unstaged.modified.map(l=>({isStaged:!1,path:l,status:"modified"})),...e.unstaged.deleted.map(l=>({isStaged:!1,path:l,status:"deleted"})),...e.untracked.map(l=>({isStaged:!1,path:l,status:"untracked"}))],a=(l,c)=>l.path.localeCompare(c.path);return{staged:r.sort(a),unmerged:n.sort(a),unstaged:o.sort(a)}}const MV="/assets/logo-byterover-DB7H7faH.svg",O9=C.createContext(void 0);function j9(){const e=C.useContext(O9);if(e===void 0)throw new Error(Gn(13));return e}const Hx={imageLoadingStatus:()=>null},LV=C.forwardRef(function(t,n){const{className:r,render:o,...a}=t,[l,c]=C.useState("idle"),f={imageLoadingStatus:l},d=C.useMemo(()=>({imageLoadingStatus:l,setImageLoadingStatus:c}),[l,c]),g=ln("span",t,{state:f,ref:n,props:a,stateAttributesMapping:Hx});return p.jsx(O9.Provider,{value:d,children:g})});function _V(e,{referrerPolicy:t,crossOrigin:n}){const[r,o]=C.useState("idle");return qe(()=>{if(!e)return o("error"),dr;let a=!0;const l=new window.Image,c=f=>()=>{a&&o(f)};return o("loading"),l.onload=c("loaded"),l.onerror=c("error"),t&&(l.referrerPolicy=t),l.crossOrigin=n??null,l.src=e,()=>{a=!1}},[e,n,t]),r}const DV={...Hx,...pc},IV=C.forwardRef(function(t,n){const{className:r,render:o,onLoadingStatusChange:a,referrerPolicy:l,crossOrigin:c,...f}=t,d=j9(),g=_V(t.src,{referrerPolicy:l,crossOrigin:c}),h=g==="loaded",{mounted:y,transitionStatus:x,setMounted:v}=Xy(h),S=C.useRef(null),E=st(R=>{a?.(R),d.setImageLoadingStatus(R)});qe(()=>{g!=="idle"&&E(g)},[g,E]);const k={imageLoadingStatus:g,transitionStatus:x};mc({open:h,ref:S,onComplete(){h||v(!1)}});const T=ln("img",t,{state:k,ref:[n,S],props:f,stateAttributesMapping:DV,enabled:y});return y?T:null}),zV=C.forwardRef(function(t,n){const{className:r,render:o,delay:a,...l}=t,{imageLoadingStatus:c}=j9(),[f,d]=C.useState(a===void 0),g=jr();return C.useEffect(()=>(a!==void 0&&g.start(a,()=>d(!0)),g.clear),[g,a]),ln("span",t,{state:{imageLoadingStatus:c},ref:n,props:l,stateAttributesMapping:Hx,enabled:c!=="loaded"&&f})});function f0({className:e,size:t="default",...n}){return p.jsx(LV,{"data-slot":"avatar","data-size":t,className:we("group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten",e),...n})}function Ux({className:e,...t}){return p.jsx(IV,{"data-slot":"avatar-image",className:we("aspect-square size-full rounded-full object-cover",e),...t})}function d0({className:e,...t}){return p.jsx(zV,{"data-slot":"avatar-fallback",className:we("flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs",e),...t})}const M9=C.createContext(void 0);function qx(e){const t=C.useContext(M9);if(t===void 0&&!e)throw new Error(Gn(33));return t}const L9=C.createContext(void 0);function Qo(e){const t=C.useContext(L9);if(t===void 0&&!e)throw new Error(Gn(36));return t}const PV=C.createContext(void 0);function h0(e=!0){const t=C.useContext(PV);if(t===void 0&&!e)throw new Error(Gn(25));return t}function FV(e){const{closeOnClick:t,highlighted:n,id:r,nodeId:o,store:a,typingRef:l,itemRef:c,itemMetadata:f}=e,{events:d}=a.useState("floatingTreeRoot"),g=h0(!0),h=g!==void 0;return C.useMemo(()=>({id:r,role:"menuitem",tabIndex:n?0:-1,onKeyDown(y){y.key===" "&&l?.current&&y.preventDefault()},onMouseMove(y){o&&d.emit("itemhover",{nodeId:o,target:y.currentTarget})},onClick(y){t&&d.emit("close",{domEvent:y,reason:t6})},onMouseUp(y){if(g){const x=g.initialCursorPointRef.current;if(g.initialCursorPointRef.current=null,h&&x&&Math.abs(y.clientX-x.x)<=1&&Math.abs(y.clientY-x.y)<=1||h&&!_k&&y.button===2)return}c.current&&a.context.allowMouseUpTriggerRef.current&&(!h||y.button===2)&&(!f||f.type==="regular-item")&&c.current.click()}}),[t,n,r,d,o,a,l,c,g,h,f])}const BV={type:"regular-item"};function _9(e){const{closeOnClick:t,disabled:n=!1,highlighted:r,id:o,store:a,typingRef:l=a.context.typingRef,nativeButton:c,itemMetadata:f,nodeId:d}=e,g=C.useRef(null),{getButtonProps:h,buttonRef:y}=zf({disabled:n,focusableWhenDisabled:!0,native:c,composite:!0}),x=FV({closeOnClick:t,highlighted:r,id:o,nodeId:d,store:a,typingRef:l,itemRef:g,itemMetadata:f}),v=C.useCallback(E=>Ba(x,{onMouseEnter(){f.type==="submenu-trigger"&&f.setActive()}},E,h),[x,h,f]),S=Ms(g,y);return C.useMemo(()=>({getItemProps:v,itemRef:S}),[v,S])}const D9=C.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});function HV(){return C.useContext(D9)}let UV=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function Vx(e={}){const{label:t,metadata:n,textRef:r,indexGuessBehavior:o,index:a}=e,{register:l,unregister:c,subscribeMapChange:f,elementsRef:d,labelsRef:g,nextIndexRef:h}=HV(),y=C.useRef(-1),[x,v]=C.useState(a??(o===UV.GuessFromOrder?()=>{if(y.current===-1){const k=h.current;h.current+=1,y.current=k}return y.current}:-1)),S=C.useRef(null),E=C.useCallback(k=>{if(S.current=k,x!==-1&&k!==null&&(d.current[x]=k,g)){const T=t!==void 0;g.current[x]=T?t:r?.current?.textContent??k.textContent}},[x,d,g,t,r]);return qe(()=>{if(a!=null)return;const k=S.current;if(k)return l(k,n),()=>{c(k)}},[a,l,c,n]),qe(()=>{if(a==null)return f(k=>{const T=S.current?k.get(S.current)?.index:null;T!=null&&v(T)})},[a,f,v]),C.useMemo(()=>({ref:E,index:x}),[x,E])}const I9=C.createContext(void 0);function qV(){const e=C.useContext(I9);if(e===void 0)throw new Error(Gn(31));return e}const VV=C.forwardRef(function(t,n){const{render:r,className:o,...a}=t,[l,c]=C.useState(void 0),f=C.useMemo(()=>({setLabelId:c}),[c]),d=ln("div",t,{ref:n,props:{role:"group","aria-labelledby":l,...a}});return p.jsx(I9.Provider,{value:f,children:d})}),$V=C.forwardRef(function(t,n){const{className:r,render:o,id:a,...l}=t,c=Gi(a),{setLabelId:f}=qV();return qe(()=>(f(c),()=>{f(void 0)}),[f,c]),ln("div",t,{ref:n,props:{id:c,role:"presentation",...l}})}),GV=C.forwardRef(function(t,n){const{render:r,className:o,id:a,label:l,nativeButton:c=!1,disabled:f=!1,closeOnClick:d=!0,...g}=t,h=Vx({label:l}),y=qx(!0),x=Gi(a),{store:v}=Qo(),S=v.useState("isActive",h.index),E=v.useState("itemProps"),{getItemProps:k,itemRef:T}=_9({closeOnClick:d,disabled:f,highlighted:S,id:x,store:v,nativeButton:c,nodeId:y?.nodeId,itemMetadata:BV});return ln("div",t,{state:{disabled:f,highlighted:S},props:[E,g,k],ref:[T,n,h.ref]})}),YV=C.createContext(void 0);function WV(e){return C.useContext(YV)}const KV={...qs,...pc},QV=C.forwardRef(function(t,n){const{render:r,className:o,finalFocus:a,...l}=t,{store:c}=Qo(),{side:f,align:d}=qx(),g=WV()!=null,h=c.useState("open"),y=c.useState("transitionStatus"),x=c.useState("popupProps"),v=c.useState("mounted"),S=c.useState("instantType"),E=c.useState("activeTriggerElement"),k=c.useState("parent"),T=c.useState("lastOpenChangeReason"),R=c.useState("rootId"),L=c.useState("floatingRootContext"),j=c.useState("floatingTreeRoot"),N=c.useState("closeDelay"),A=c.useState("activeTriggerElement"),D=k.type==="context-menu";mc({open:h,ref:c.context.popupRef,onComplete(){h&&c.context.onOpenChangeComplete?.(!0)}}),C.useEffect(()=>{function H(B){c.setOpen(!1,Et(B.reason,B.domEvent))}return j.events.on("close",H),()=>{j.events.off("close",H)}},[j.events,c]);const U=c.useState("hoverEnabled"),I=c.useState("disabled");P6(L,{enabled:U&&!I&&!D&&k.type!=="menubar",closeDelay:N});const q={transitionStatus:y,side:f,align:d,open:h,nested:k.type==="menu",instant:S},$=C.useCallback(H=>{c.set("popupElement",H)},[c]),V=ln("div",t,{state:q,ref:[n,c.context.popupRef,$],stateAttributesMapping:KV,props:[x,{onKeyDown(H){g&&n9.has(H.key)&&H.stopPropagation()}},i0(y),l,{"data-rootownerid":R}]});let Y=k.type===void 0||D;return(E||k.type==="menubar"&&T!==Uy)&&(Y=!0),p.jsx(x6,{context:L,modal:D,disabled:!v,returnFocus:a===void 0?Y:a,initialFocus:k.type!=="menu",restoreFocus:!0,externalTree:k.type!=="menubar"?j:void 0,previousFocusableElement:A,nextFocusableElement:k.type===void 0?c.context.triggerFocusTargetRef:void 0,beforeContentFocusGuardRef:k.type===void 0?c.context.beforeContentFocusGuardRef:void 0,children:V})}),z9=C.createContext(void 0);function XV(){const e=C.useContext(z9);if(e===void 0)throw new Error(Gn(32));return e}const ZV=C.forwardRef(function(t,n){const{keepMounted:r=!1,...o}=t,{store:a}=Qo();return a.useState("mounted")||r?p.jsx(z9.Provider,{value:r,children:p.jsx(h6,{ref:n,...o})}):null});function JV(e){const{children:t,elementsRef:n,labelsRef:r,onMapChange:o}=e,a=st(o),l=C.useRef(0),c=Zn(t$).current,f=Zn(e$).current,[d,g]=C.useState(0),h=C.useRef(d),y=st((k,T)=>{f.set(k,T??null),h.current+=1,g(h.current)}),x=st(k=>{f.delete(k),h.current+=1,g(h.current)}),v=C.useMemo(()=>{const k=new Map;return Array.from(f.keys()).filter(R=>R.isConnected).sort(n$).forEach((R,L)=>{const j=f.get(R)??{};k.set(R,{...j,index:L})}),k},[f,d]);qe(()=>{if(typeof MutationObserver!="function"||v.size===0)return;const k=new MutationObserver(T=>{const R=new Set,L=j=>R.has(j)?R.delete(j):R.add(j);T.forEach(j=>{j.removedNodes.forEach(L),j.addedNodes.forEach(L)}),R.size===0&&(h.current+=1,g(h.current))});return v.forEach((T,R)=>{R.parentElement&&k.observe(R.parentElement,{childList:!0})}),()=>{k.disconnect()}},[v]),qe(()=>{h.current===d&&(n.current.length!==v.size&&(n.current.length=v.size),r&&r.current.length!==v.size&&(r.current.length=v.size),l.current=v.size),a(v)},[a,v,n,r,d]),qe(()=>()=>{n.current=[]},[n]),qe(()=>()=>{r&&(r.current=[])},[r]);const S=st(k=>(c.add(k),()=>{c.delete(k)}));qe(()=>{c.forEach(k=>k(v))},[c,v]);const E=C.useMemo(()=>({register:y,unregister:x,subscribeMapChange:S,elementsRef:n,labelsRef:r,nextIndexRef:l}),[y,x,S,n,r,l]);return p.jsx(D9.Provider,{value:E,children:t})}function e$(){return new Map}function t$(){return new Set}function n$(e,t){const n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}const r$=C.forwardRef(function(t,n){const{anchor:r,positionMethod:o="absolute",className:a,render:l,side:c,align:f,sideOffset:d=0,alignOffset:g=0,collisionBoundary:h="clipping-ancestors",collisionPadding:y=5,arrowPadding:x=5,sticky:v=!1,disableAnchorTracking:S=!1,collisionAvoidance:E=P_,...k}=t,{store:T}=Qo(),R=XV(),L=h0(!0),j=T.useState("parent"),N=T.useState("floatingRootContext"),A=T.useState("floatingTreeRoot"),D=T.useState("mounted"),U=T.useState("open"),I=T.useState("modal"),q=T.useState("activeTriggerElement"),$=T.useState("transitionStatus"),V=T.useState("positionerElement"),Y=T.useState("instantType"),H=T.useState("hasViewport"),B=T.useState("lastOpenChangeReason"),F=T.useState("floatingNodeId"),G=T.useState("floatingParentNodeId"),ie=N.useState("domReferenceElement"),M=C.useRef(null),P=L6(V,!1,!1);let Q=r,_=d,ee=g,J=f,re=E;j.type==="context-menu"&&(Q=r??j.context?.anchor,J=J??"start",!c&&J!=="center"&&(ee=t.alignOffset??2,_=t.sideOffset??-5));let pe=c,fe=J;j.type==="menu"?(pe=pe??"inline-end",fe=fe??"start",re=t.collisionAvoidance??e6):j.type==="menubar"&&(pe=pe??"bottom",fe=fe??"start");const Ce=j.type==="context-menu",Ee=W6({anchor:Q,floatingRootContext:N,positionMethod:L?"fixed":o,mounted:D,side:pe,sideOffset:_,align:fe,alignOffset:ee,arrowPadding:Ce?0:x,collisionBoundary:h,collisionPadding:y,sticky:v,nodeId:F,keepMounted:R,disableAnchorTracking:S,collisionAvoidance:re,shiftCrossAxis:Ce&&!("side"in re&&re.side==="flip"),externalTree:A,adaptiveOrigin:H?G6:void 0}),Ie=C.useMemo(()=>{const Re={};return U||(Re.pointerEvents="none"),{role:"presentation",hidden:!D,style:{...Ee.positionerStyles,...Re}}},[U,D,Ee.positionerStyles]);C.useEffect(()=>{function Re(he){he.open&&(he.parentNodeId===F&&T.set("hoverEnabled",!1),he.nodeId!==F&&he.parentNodeId===T.select("floatingParentNodeId")&&T.setOpen(!1,Et(Fu)))}return A.events.on("menuopenchange",Re),()=>{A.events.off("menuopenchange",Re)}},[T,A.events,F]),C.useEffect(()=>{if(T.select("floatingParentNodeId")==null)return;function Re(he){if(he.open||he.nodeId!==T.select("floatingParentNodeId"))return;const Se=he.reason??Fu;T.setOpen(!1,Et(Se))}return A.events.on("menuopenchange",Re),()=>{A.events.off("menuopenchange",Re)}},[A.events,T]);const Ye=jr();C.useEffect(()=>{U||Ye.clear()},[U,Ye]),C.useEffect(()=>{function Re(he){if(!(!U||he.nodeId!==T.select("floatingParentNodeId")))if(he.target&&q&&q!==he.target){const Se=T.select("closeDelay");Se>0?Ye.isStarted()||Ye.start(Se,()=>{T.setOpen(!1,Et(Fu))}):T.setOpen(!1,Et(Fu))}else Ye.clear()}return A.events.on("itemhover",Re),()=>{A.events.off("itemhover",Re)}},[A.events,U,q,T,Ye]),C.useEffect(()=>{const Re={open:U,nodeId:F,parentNodeId:G,reason:T.select("lastOpenChangeReason")};A.events.emit("menuopenchange",Re)},[A.events,U,T,F,G]),qe(()=>{const Re=ie,he=M.current;if(Re&&(M.current=Re),he&&Re&&Re!==he){T.set("instantType",void 0);const Se=new AbortController;return P(()=>{T.set("instantType","trigger-change")},Se.signal),()=>{Se.abort()}}},[ie,P,T]);const je={open:U,side:Ee.side,align:Ee.align,anchorHidden:Ee.anchorHidden,nested:j.type==="menu",instant:Y},_e=C.useMemo(()=>({side:Ee.side,align:Ee.align,arrowRef:Ee.arrowRef,arrowUncentered:Ee.arrowUncentered,arrowStyles:Ee.arrowStyles,nodeId:Ee.context.nodeId}),[Ee.side,Ee.align,Ee.arrowRef,Ee.arrowUncentered,Ee.arrowStyles,Ee.context.nodeId]),ye=ln("div",t,{state:je,stateAttributesMapping:qs,ref:[n,T.useStateSetter("positionerElement")],props:[Ie,i0($),k]}),We=D&&j.type!=="menu"&&(j.type!=="menubar"&&I&&B!==Rr||j.type==="menubar"&&j.context.modal);let Te=null;return j.type==="menubar"?Te=j.context.contentElement:j.type===void 0&&(Te=q),p.jsxs(M9.Provider,{value:_e,children:[We&&p.jsx(r9,{ref:j.type==="context-menu"||j.type==="nested-context-menu"?j.context.internalBackdropRef:null,inert:K6(!U),cutout:Te}),p.jsx(xD,{id:F,children:p.jsx(JV,{elementsRef:T.context.itemDomElements,labelsRef:T.context.itemLabels,children:ye})})]})}),i$=C.createContext(null);function P9(e){return C.useContext(i$)}const o$={...tx,disabled:rt(e=>e.parent.type==="menubar"&&e.parent.context.disabled||e.disabled),modal:rt(e=>(e.parent.type===void 0||e.parent.type==="context-menu")&&(e.modal??!0)),allowMouseEnter:rt(e=>e.allowMouseEnter),stickIfOpen:rt(e=>e.stickIfOpen),parent:rt(e=>e.parent),rootId:rt(e=>e.parent.type==="menu"?e.parent.store.select("rootId"):e.parent.type!==void 0?e.parent.context.rootId:e.rootId),activeIndex:rt(e=>e.activeIndex),isActive:rt((e,t)=>e.activeIndex===t),hoverEnabled:rt(e=>e.hoverEnabled),instantType:rt(e=>e.instantType),lastOpenChangeReason:rt(e=>e.openChangeReason),floatingTreeRoot:rt(e=>e.parent.type==="menu"?e.parent.store.select("floatingTreeRoot"):e.floatingTreeRoot),floatingNodeId:rt(e=>e.floatingNodeId),floatingParentNodeId:rt(e=>e.floatingParentNodeId),itemProps:rt(e=>e.itemProps),closeDelay:rt(e=>e.closeDelay),hasViewport:rt(e=>e.hasViewport),keyboardEventRelay:rt(e=>{if(e.keyboardEventRelay)return e.keyboardEventRelay;if(e.parent.type==="menu")return e.parent.store.select("keyboardEventRelay")})};class $x extends n0{constructor(t){super({...a$(),...t},{positionerRef:C.createRef(),popupRef:C.createRef(),typingRef:{current:!1},itemDomElements:{current:[]},itemLabels:{current:[]},allowMouseUpTriggerRef:{current:!1},triggerFocusTargetRef:C.createRef(),beforeContentFocusGuardRef:C.createRef(),onOpenChangeComplete:void 0,triggerElements:new Mf},o$),this.unsubscribeParentListener=this.observe("parent",n=>{if(this.unsubscribeParentListener?.(),n.type==="menu"){let r=n.store.select("rootId"),o=n.store.select("floatingTreeRoot"),a=n.store.select("keyboardEventRelay");this.unsubscribeParentListener=n.store.subscribe(()=>{const l=n.store.select("rootId"),c=n.store.select("floatingTreeRoot"),f=n.store.select("keyboardEventRelay");r===l&&o===c&&a===f||(r=l,o=c,a=f,this.notifyAll())}),this.context.allowMouseUpTriggerRef=n.store.context.allowMouseUpTriggerRef;return}n.type!==void 0&&(this.context.allowMouseUpTriggerRef=n.context.allowMouseUpTriggerRef),this.unsubscribeParentListener=null})}setOpen(t,n){this.state.floatingRootContext.context.events.emit("setOpen",{open:t,eventDetails:n})}static useStore(t,n){const r=Zn(()=>new $x(n)).current;return t??r}unsubscribeParentListener=null}function a$(){return{...ex(),disabled:!1,modal:!0,allowMouseEnter:!1,stickIfOpen:!0,parent:{type:void 0},rootId:void 0,activeIndex:null,hoverEnabled:!0,instantType:void 0,openChangeReason:null,floatingTreeRoot:new Gy,floatingNodeId:void 0,floatingParentNodeId:null,itemProps:Ln,keyboardEventRelay:void 0,closeDelay:0,hasViewport:!1}}const F9=C.createContext(void 0);function B9(){return C.useContext(F9)}const H9=jy(function(t){const{children:n,open:r,onOpenChange:o,onOpenChangeComplete:a,defaultOpen:l=!1,disabled:c=!1,modal:f,loopFocus:d=!0,orientation:g="vertical",actionsRef:h,closeParentOnEsc:y=!1,handle:x,triggerId:v,defaultTriggerId:S=null,highlightItemOnHover:E=!0}=t,k=h0(!0),T=Qo(!0),R=P9(!0),L=B9(),j=C.useMemo(()=>L&&T?{type:"menu",store:T.store}:R?{type:"menubar",context:R}:k&&!T?{type:"context-menu",context:k}:{type:void 0},[k,T,R,L]),N=$x.useStore(x?.store,{open:l,openProp:r,activeTriggerId:S,triggerIdProp:v,parent:j});My(()=>{r===void 0&&N.state.open===!1&&l===!0&&N.update({open:!0,activeTriggerId:S})}),N.useControlledProp("openProp",r),N.useControlledProp("triggerIdProp",v),N.useContextCallback("onOpenChangeComplete",a);const A=N.useState("floatingTreeRoot"),D=y6(A),U=Go();qe(()=>{k&&!T?N.update({parent:{type:"context-menu",context:k},floatingNodeId:D,floatingParentNodeId:U}):T&&N.update({floatingNodeId:D,floatingParentNodeId:U})},[k,T,D,U,N]);const I=N.useState("open"),q=N.useState("activeTriggerElement"),$=N.useState("positionerElement"),V=N.useState("hoverEnabled"),Y=N.useState("modal"),H=N.useState("disabled"),B=N.useState("lastOpenChangeReason"),F=N.useState("parent"),G=N.useState("activeIndex"),ie=N.useState("payload"),M=N.useState("floatingParentNodeId"),P=C.useRef(null),Q=M!=null;let _;N.useSyncedValues({disabled:c,modal:F.type===void 0?f:void 0,rootId:Us()});const{openMethod:ee,triggerProps:J}=a9(I);Zy(N);const{forceUnmount:re}=Jy(I,N,()=>{N.update({allowMouseEnter:!1,stickIfOpen:!0})}),pe=C.useRef(F.type!=="context-menu"),fe=jr();C.useEffect(()=>{if(I||(P.current=null),F.type==="context-menu"){if(!I){fe.clear(),pe.current=!1;return}fe.start(500,()=>{pe.current=!0})}},[fe,I,F.type]),i9(I&&Y&&B!==Rr&&ee!=="touch",$),qe(()=>{!I&&!V&&N.set("hoverEnabled",!0)},[I,V,N]);const Ce=C.useRef(!0),Ee=jr(),Ie=st((Xe,Ve)=>{const pt=Ve.reason;if(I===Xe&&Ve.trigger===q&&B===pt||(Ve.preventUnmountOnClose=()=>{N.set("preventUnmountingOnClose",!0)},!Xe&&Ve.trigger==null&&(Ve.trigger=q??void 0),o?.(Xe,Ve),Ve.isCanceled))return;const mt={open:Xe,nativeEvent:Ve.event,reason:Ve.reason,nested:Q};_?.emit("openchange",mt);const Qe=Ve.event;if(Xe===!1&&Qe?.type==="click"&&Qe.pointerType==="touch"&&!Ce.current)return;if(!Xe&&G!==null){const fn=N.context.itemDomElements.current[G];queueMicrotask(()=>{fn?.setAttribute("tabindex","-1")})}Xe&&pt===Yl?(Ce.current=!1,Ee.start(300,()=>{Ce.current=!0})):(Ce.current=!0,Ee.clear());const yt=(pt===ic||pt===t6)&&Qe.detail===0&&Qe?.isTrusted,Pt=!Xe&&(pt===e0||pt==null),Wt={open:Xe,openChangeReason:pt};P.current=Ve.event??null;const yn=Ve.trigger?.id??null;(yn||Xe)&&(Wt.activeTriggerId=yn,Wt.activeTriggerElement=Ve.trigger??null),N.update(Wt),F.type==="menubar"&&(pt===Yl||pt===oc||pt===Rr||pt===qh||pt===Fu)?N.set("instantType","group"):yt||Pt?N.set("instantType",yt?"click":"dismiss"):N.set("instantType",void 0)}),Ye=C.useCallback(Xe=>{const Ve=Et(Xe);return Ve.preventUnmountOnClose=()=>{N.set("preventUnmountingOnClose",!0)},Ve},[N]),je=C.useCallback(()=>{N.setOpen(!1,Ye(qy))},[N,Ye]);C.useImperativeHandle(h,()=>({unmount:re,close:je}),[re,je]);let _e;F.type==="context-menu"&&(_e=F.context),C.useImperativeHandle(_e?.positionerRef,()=>$,[$]),C.useImperativeHandle(_e?.actionsRef,()=>({setOpen:Ie}),[Ie]);const ye=nx({popupStore:N,onOpenChange:Ie});_=ye.context.events,C.useEffect(()=>{const Xe=({open:Ve,eventDetails:pt})=>Ie(Ve,pt);return _.on("setOpen",Xe),()=>{_?.off("setOpen",Xe)}},[_,Ie]);const We=Wy(ye,{enabled:!H,bubbles:{escapeKey:y&&F.type==="menu"},outsidePress(){return F.type!=="context-menu"||P.current?.type==="contextmenu"?!0:pe.current},externalTree:Q?A:void 0}),Te=F6(ye,{role:"menu"}),Re=$6(),he=C.useCallback(Xe=>{N.select("activeIndex")!==Xe&&N.set("activeIndex",Xe)},[N]),Se=ez(ye,{enabled:!H,listRef:N.context.itemDomElements,activeIndex:G,nested:F.type!==void 0,loopFocus:d,orientation:g,parentOrientation:F.type==="menubar"?F.context.orientation:void 0,rtl:Re==="rtl",disabledIndices:w1,onNavigate:he,openOnArrowKeyDown:F.type!=="context-menu",externalTree:Q?A:void 0,focusItemOnHover:E}),ne=C.useCallback(Xe=>{N.context.typingRef.current=Xe},[N]),xe=nz(ye,{listRef:N.context.itemLabels,elementsRef:N.context.itemDomElements,activeIndex:G,resetMs:__,onMatch:Xe=>{I&&Xe!==G&&N.set("activeIndex",Xe)},onTypingChange:ne}),{getReferenceProps:ze,getFloatingProps:Ue,getItemProps:wt,getTriggerProps:ae}=Lf([We,Te,Se,xe]),ve=C.useMemo(()=>{const Xe=Ba(ze(),{onMouseMove(){N.set("allowMouseEnter",!0)}},J);return delete Xe.role,Xe},[ze,N,J]),Oe=C.useMemo(()=>{const Xe=ae();if(!Xe)return Xe;const Ve=Ba(Xe,J);return delete Ve.role,delete Ve["aria-controls"],Ve},[ae,J]),Me=C.useMemo(()=>Ue({onMouseMove(){N.set("allowMouseEnter",!0),F.type==="menu"&&N.set("hoverEnabled",!1)},onClick(){N.select("hoverEnabled")&&N.set("hoverEnabled",!1)},onKeyDown(Xe){const Ve=N.select("keyboardEventRelay");Ve&&!Xe.isPropagationStopped()&&Ve(Xe)}}),[Ue,F.type,N]),He=C.useMemo(()=>wt(),[wt]);N.useSyncedValues({floatingRootContext:ye,activeTriggerProps:ve,inactiveTriggerProps:Oe,popupProps:Me,itemProps:He});const kt=C.useMemo(()=>({store:N,parent:j}),[N,j]),Ft=p.jsx(L9.Provider,{value:kt,children:typeof n=="function"?n({payload:ie}):n});return F.type===void 0||F.type==="context-menu"?p.jsx(bD,{externalTree:A,children:Ft}):Ft});function s$(e){const t=Qo().store,n=C.useMemo(()=>({parentMenu:t}),[t]);return p.jsx(F9.Provider,{value:n,children:p.jsx(H9,{...e})})}function l$(e){const t=e.getBoundingClientRect(),n=window.getComputedStyle(e,"::before"),r=window.getComputedStyle(e,"::after");if(!(n.content!=="none"||r.content!=="none"))return t;const a=parseFloat(n.width)||0,l=parseFloat(n.height)||0,c=parseFloat(r.width)||0,f=parseFloat(r.height)||0,d=Math.max(t.width,a,c),g=Math.max(t.height,l,f),h=d-t.width,y=g-t.height;return{left:t.left-h/2,right:t.right+h/2,top:t.top-y/2,bottom:t.bottom+y/2}}function c$(e={}){const{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:r}=Rx(),{ref:o,index:a}=Vx(e),l=n===a,c=C.useRef(null),f=Ms(o,c);return{compositeProps:C.useMemo(()=>({tabIndex:l?0:-1,onFocus(){r(a)},onMouseMove(){const g=c.current;if(!t||!g)return;const h=g.hasAttribute("disabled")||g.ariaDisabled==="true";!l&&!h&&g.focus()}}),[l,r,a,t]),compositeRef:f,index:a}}function u$(e){const{render:t,className:n,state:r=Ln,props:o=w1,refs:a=w1,metadata:l,stateAttributesMapping:c,tag:f="div",...d}=e,{compositeProps:g,compositeRef:h}=c$({metadata:l});return ln(f,e,{state:r,ref:[...a,h],props:[g,...o,d],stateAttributesMapping:c})}function U9(e){if(Rn(e)&&e.hasAttribute("data-rootownerid"))return e.getAttribute("data-rootownerid")??void 0;if(!oo(e))return U9(fo(e))}function f$(e){const{enabled:t=!0,mouseDownAction:n,open:r}=e,o=C.useRef(!1);return C.useMemo(()=>t?{onMouseDown:a=>{(n==="open"&&!r||n==="close"&&r)&&(o.current=!0,Gt(a.currentTarget).addEventListener("click",()=>{o.current=!1},{once:!0}))},onClick:a=>{o.current&&(o.current=!1,a.preventBaseUIHandler())}}:Ln,[t,n,r])}const Th=2,d$=Tk(function(t,n){const{render:r,className:o,disabled:a=!1,nativeButton:l=!0,id:c,openOnHover:f,delay:d=100,closeDelay:g=0,handle:h,payload:y,...x}=t,v=Qo(!0),S=h?.store??v?.store;if(!S)throw new Error(Gn(85));const E=Gi(c),k=S.useState("isTriggerActive",E),T=S.useState("floatingRootContext"),R=S.useState("isOpenedByTrigger",E),L=C.useRef(null),j=p$(),N=Rx(!0),A=Ya(),D=C.useMemo(()=>A??new Gy,[A]),U=y6(D),I=Go(),{registerTrigger:q,isMountedByThisTrigger:$}=D6(E,L,S,{payload:y,closeDelay:g,parent:j,floatingTreeRoot:D,floatingNodeId:U,floatingParentNodeId:I,keyboardEventRelay:N?.relayKeyboardEvent}),V=j.type==="menubar",Y=S.useState("disabled"),H=a||Y||V&&j.context.disabled,{getButtonProps:B,buttonRef:F}=zf({disabled:H,native:l});C.useEffect(()=>{!R&&j.type===void 0&&(S.context.allowMouseUpTriggerRef.current=!1)},[S,R,j.type]);const G=C.useRef(null),ie=jr(),M=st(Te=>{if(!G.current)return;ie.clear(),S.context.allowMouseUpTriggerRef.current=!1;const Re=Te.target;if(ht(G.current,Re)||ht(S.select("positionerElement"),Re)||Re===G.current||Re!=null&&U9(Re)===S.select("rootId"))return;const he=l$(G.current);Te.clientX>=he.left-Th&&Te.clientX<=he.right+Th&&Te.clientY>=he.top-Th&&Te.clientY<=he.bottom+Th||D.events.emit("close",{domEvent:Te,reason:H_})});C.useEffect(()=>{R&&S.select("lastOpenChangeReason")===Rr&&Gt(G.current).addEventListener("mouseup",M,{once:!0})},[R,M,S]);const P=V&&j.context.hasSubmenuOpen,_=ox(T,{enabled:(f??P)&&!H&&j.type!=="context-menu"&&(!V||P&&!$),handleClose:ax({blockPointerEvents:!V}),mouseOnly:!0,move:!1,restMs:j.type===void 0?d:void 0,delay:{close:g},triggerElementRef:L,externalTree:D,isActiveTrigger:k}),ee=h$(R,S.select("lastOpenChangeReason")),J=b6(T,{enabled:!H&&j.type!=="context-menu",event:R&&V?"click":"mousedown",toggle:!0,ignoreMouse:!1,stickIfOpen:j.type===void 0?ee:!1}),re=I6(T,{enabled:!H&&P}),pe=f$({open:R,enabled:V,mouseDownAction:"open"}),fe=Lf([J,re]),Ce={disabled:H,open:R},Ee=S.useState("triggerProps",$),Ie=[G,n,F,q,L],Ye=[fe.getReferenceProps(),_??Ln,Ee,{"aria-haspopup":"menu",id:E,onMouseDown:Te=>{if(S.select("open"))return;ie.start(200,()=>{S.context.allowMouseUpTriggerRef.current=!0}),Gt(Te.currentTarget).addEventListener("mouseup",M,{once:!0})}},V?{role:"menuitem"}:{},pe,x,B],je=C.useRef(null),_e=st(Te=>{Mi.flushSync(()=>{S.setOpen(!1,Et(oc,Te.nativeEvent,Te.currentTarget))}),j_(je.current)?.focus()}),ye=st(Te=>{const Re=S.select("positionerElement");if(Re&&Gl(Te,Re))S.context.beforeContentFocusGuardRef.current?.focus();else{Mi.flushSync(()=>{S.setOpen(!1,Et(oc,Te.nativeEvent,Te.currentTarget))});let he=O_(S.context.triggerFocusTargetRef.current||L.current);for(;he!==null&&ht(Re,he);){const Se=he;if(he=Hy(he),he===Se)break}he?.focus()}}),We=ln("button",t,{enabled:!V,stateAttributesMapping:FS,state:Ce,ref:Ie,props:Ye});return V?p.jsx(u$,{tag:"button",render:r,className:o,state:Ce,refs:Ie,props:Ye,stateAttributesMapping:FS}):R?p.jsxs(C.Fragment,{children:[p.jsx(ac,{ref:je,onFocus:_e},`${E}-pre-focus-guard`),p.jsx(C.Fragment,{children:We},E),p.jsx(ac,{ref:S.context.triggerFocusTargetRef,onFocus:ye},`${E}-post-focus-guard`)]}):p.jsx(C.Fragment,{children:We},E)});function h$(e,t){const n=jr(),[r,o]=C.useState(!1);return qe(()=>{e&&t==="trigger-hover"?(o(!0),n.start(D_,()=>{o(!1)})):e||(n.clear(),o(!1))},[e,t,n]),r}function p$(){const e=h0(!0),t=Qo(!0),n=P9();return C.useMemo(()=>n?{type:"menubar",context:n}:e&&!t?{type:"context-menu",context:e}:{type:void 0},[e,t,n])}const m$=C.forwardRef(function(t,n){const{className:r,render:o,orientation:a="horizontal",...l}=t;return ln("div",t,{state:{orientation:a},ref:n,props:[{role:"separator","aria-orientation":a},l]})}),g$=C.forwardRef(function(t,n){const{render:r,className:o,label:a,id:l,nativeButton:c=!1,openOnHover:f=!0,delay:d=100,closeDelay:g=0,disabled:h=!1,...y}=t,x=Vx(),v=qx(),{store:S}=Qo(),E=Gi(l),k=S.useState("open"),T=S.useState("floatingRootContext"),R=S.useState("floatingTreeRoot"),L=_6(E,S),j=C.useCallback(J=>{const re=L(J);return J!==null&&S.select("open")&&S.select("activeTriggerId")==null&&S.update({activeTriggerId:E,activeTriggerElement:J,closeDelay:g}),re},[L,g,S,E]),N=C.useRef(null),A=C.useCallback(J=>{N.current=J,S.set("activeTriggerElement",J)},[S]),D=B9();if(!D?.parentMenu)throw new Error(Gn(37));S.useSyncedValue("closeDelay",g);const U=D.parentMenu,I=U.useState("itemProps"),q=U.useState("isActive",x.index),$=C.useMemo(()=>({type:"submenu-trigger",setActive(){U.set("activeIndex",x.index)}}),[U,x.index]),V=S.useState("disabled"),Y=h||V,{getItemProps:H,itemRef:B}=_9({closeOnClick:!1,disabled:Y,highlighted:q,id:E,store:S,typingRef:U.context.typingRef,nativeButton:c,itemMetadata:$,nodeId:v?.nodeId}),F=S.useState("hoverEnabled"),G=U.useState("allowMouseEnter"),ie=ox(T,{enabled:F&&f&&!Y,handleClose:ax({blockPointerEvents:!0}),mouseOnly:!0,move:!0,restMs:d,delay:G?{open:d,close:g}:0,triggerElementRef:N,externalTree:R}),M=b6(T,{enabled:!Y,event:"mousedown",toggle:!f,ignoreMouse:f,stickIfOpen:!1}),P=Lf([M]),Q=S.useState("triggerProps",!0);return delete Q.id,ln("div",t,{state:{disabled:Y,highlighted:q,open:k},stateAttributesMapping:B6,props:[P.getReferenceProps(),ie,Q,I,{tabIndex:k||q?0:-1,onBlur(){q&&U.set("activeIndex",null)}},y,H],ref:[n,x.ref,B,j,A]})});function Ws({...e}){return p.jsx(H9,{"data-slot":"dropdown-menu",...e})}function Ks({...e}){return p.jsx(d$,{"data-slot":"dropdown-menu-trigger",...e})}function Za({align:e="start",alignOffset:t=0,side:n="bottom",sideOffset:r=4,className:o,...a}){return p.jsx(ZV,{children:p.jsx(r$,{className:"isolate z-50 outline-none",align:e,alignOffset:t,side:n,sideOffset:r,children:p.jsx(QV,{"data-slot":"dropdown-menu-content",className:we("z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg border border-border bg-neutral-900 p-1 text-foreground shadow-md ring-0 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-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 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95",o),...a})})})}function Os({...e}){return p.jsx(VV,{"data-slot":"dropdown-menu-group",...e})}function Ql({className:e,inset:t,...n}){return p.jsx($V,{"data-slot":"dropdown-menu-label","data-inset":t,className:we("px-2 py-1.5 text-xs font-medium text-muted-foreground data-inset:pl-8",e),...n})}function _n({className:e,inset:t,variant:n="default",...r}){return p.jsx(GV,{"data-slot":"dropdown-menu-item","data-inset":t,"data-variant":n,className:we("group/dropdown-menu-item relative flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-sm text-foreground outline-hidden select-none hover:bg-neutral-800 focus:bg-neutral-800 not-data-[variant=destructive]:focus:**:text-foreground data-inset:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",e),...r})}function Gx({...e}){return p.jsx(s$,{"data-slot":"dropdown-menu-sub",...e})}function Yx({className:e,inset:t,children:n,...r}){return p.jsxs(g$,{"data-slot":"dropdown-menu-sub-trigger","data-inset":t,className:we("flex cursor-pointer items-center gap-2 rounded px-2 py-1.5 text-sm text-foreground outline-hidden select-none hover:bg-neutral-800 focus:bg-neutral-800 data-inset:pl-8 data-popup-open:bg-neutral-800 data-open:bg-neutral-800 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r,children:[n,p.jsx(VE,{className:"ml-auto"})]})}function Wx({align:e="start",alignOffset:t=-3,side:n="right",sideOffset:r=0,className:o,...a}){return p.jsx(Za,{"data-slot":"dropdown-menu-sub-content",className:we("w-auto min-w-24 rounded-lg border border-border bg-neutral-900 p-1 text-foreground shadow-lg ring-0 duration-100 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 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",o),align:e,alignOffset:t,side:n,sideOffset:r,...a})}function Fo({className:e,...t}){return p.jsx(m$,{"data-slot":"dropdown-menu-separator",className:we("-mx-1 my-1 h-px bg-border",e),...t})}function q9(e){const t=e.split(/[-_\s]+/).filter(Boolean);return t.length>=2?(t[0][0]+t[1][0]).toUpperCase():e.slice(0,2).toUpperCase()}const y$=()=>{const{apiClient:e}=Be.getState();return e?e.request(_f.LOGOUT):Promise.reject(new Error("Not connected"))},x$=({mutationConfig:e}={})=>{const t=cn(),{onSuccess:n,...r}=e??{};return wn({onSuccess(...o){t.invalidateQueries({queryKey:so().queryKey}),n?.(...o)},...r,mutationFn:y$})};function ja({className:e,size:t="default",...n}){return p.jsx("div",{"data-slot":"card","data-size":t,className:we("group/card flex flex-col gap-6 overflow-hidden rounded-xl bg-card py-6 text-sm text-card-foreground shadow-xs ring-1 ring-foreground/10 has-[>img:first-child]:pt-0 data-[size=sm]:gap-4 data-[size=sm]:py-4 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",e),...n})}function b$({className:e,...t}){return p.jsx("div",{"data-slot":"card-title",className:we("text-base leading-normal font-medium group-data-[size=sm]/card:text-sm",e),...t})}function Ah({className:e,...t}){return p.jsx("div",{"data-slot":"card-description",className:we("text-sm text-muted-foreground",e),...t})}const v$=2500;function w$({onOpenChange:e,open:t}){const n=cn(),r=ji(h=>h.isLoggingIn),o=ji(h=>h.setLoggingIn),a=Be(h=>h.connectionState),[l,c]=C.useState({type:"idle"});C.useEffect(()=>{t||(c({type:"idle"}),o(!1))},[t,o]),C.useEffect(()=>l.type!=="waiting"?void 0:S9(y=>{y.success&&y.user?(ut.success(`Logged in as ${y.user.email}`,{position:"top-center"}),n.invalidateQueries({queryKey:so().queryKey}),e(!1)):c({message:y.error??"Authentication failed",type:"error"}),o(!1)}),[e,n,o,l.type]),C.useEffect(()=>{if(l.type!=="waiting")return;let h=!1;async function y(){try{const v=await n.fetchQuery(so());if(h)return;v.isAuthorized&&v.user&&(ut.success(`Logged in as ${v.user.email}`,{position:"top-center"}),o(!1),e(!1))}catch{}}const x=globalThis.setInterval(y,v$);return()=>{h=!0,globalThis.clearInterval(x)}},[e,n,o,l.type]);async function f(){o(!0),c({type:"starting"});try{const h=await w9();if(!zx(h.authUrl))throw new Error("Received an unsafe OAuth URL from the daemon");window.open(h.authUrl,"_blank","noopener,noreferrer"),c({authUrl:h.authUrl,type:"waiting"})}catch(h){o(!1),c({message:h instanceof Error?h.message:"Unable to start login",type:"error"})}}function d(){c({type:"idle"})}const g=a!=="connected"||r;return p.jsx($s,{onOpenChange:e,open:t,children:p.jsxs(Gs,{children:[p.jsxs(ui,{children:[p.jsx(fi,{children:"Redirecting to ByteRover"}),p.jsxs(Ff,{children:["Please sign in to your ",p.jsx("span",{className:"text-foreground",children:"byterover.dev"})," account to continue."]})]}),l.type==="starting"&&p.jsx("div",{className:"rounded-lg border border-blue-500/20 bg-blue-500/5 p-3 text-sm text-blue-700",children:"Starting authentication…"}),l.type==="waiting"&&p.jsxs(ja,{className:"p-4 gap-2",children:[p.jsx("div",{children:"Finish signing in in the new tab."}),p.jsxs("div",{className:"text-xs text-muted-foreground",children:["If the tab didn’t open,"," ",p.jsx("a",{className:"underline underline-offset-2",href:l.authUrl,rel:"noopener noreferrer",target:"_blank",children:"click this link"}),"."]})]}),l.type==="error"&&p.jsx("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 p-3 text-sm text-destructive",children:l.message}),p.jsx(Qa,{children:l.type==="error"?p.jsxs(p.Fragment,{children:[p.jsx(H1,{render:p.jsx(De,{className:"cursor-pointer",variant:"ghost"}),children:"Cancel"}),p.jsx(De,{className:"cursor-pointer",onClick:d,children:"Try again"})]}):p.jsxs(p.Fragment,{children:[p.jsx(H1,{render:p.jsx(De,{className:"cursor-pointer",variant:"ghost"}),children:"Cancel"}),p.jsx(De,{className:"cursor-pointer",disabled:g,onClick:f,children:l.type==="waiting"?"Waiting for authentication…":"Proceed to Login"})]})})]})})}function S$(){const[e,t]=C.useState(!1);return p.jsxs(p.Fragment,{children:[p.jsx(De,{className:"h-auto rounded-full p-0 ml-2.5",onClick:()=>t(!0),variant:"ghost",children:p.jsx(f0,{children:p.jsx(d0,{className:"bg-transparent",children:p.jsx(Lx,{className:"size-4 shrink-0"})})})}),p.jsx(w$,{onOpenChange:t,open:e})]})}function C$(){const e=ji(o=>o.user),t=x$(),n=cn();if(C.useEffect(()=>{e||n.invalidateQueries({queryKey:so().queryKey}).catch(()=>{})},[n,e]),!e)return p.jsxs(De,{className:"ml-2.5",disabled:!0,size:"sm",variant:"outline",children:[p.jsx(Lx,{className:"size-4 shrink-0 text-muted-foreground"}),p.jsx("span",{children:"Signed in"})]});const r=e.name??e.email;return p.jsxs(Ws,{children:[p.jsx(Ks,{children:p.jsxs(f0,{className:"cursor-pointer",children:[p.jsx(Ux,{alt:r,src:e.avatarUrl}),p.jsx(d0,{children:q9(r)})]})}),p.jsxs(Za,{align:"start",className:"w-(--anchor-width) min-w-56",sideOffset:6,children:[p.jsx(Os,{children:p.jsxs(Ql,{className:"flex flex-col gap-0.5",children:[p.jsx("span",{className:"text-xs tracking-widest text-muted-foreground",children:"Signed in"}),p.jsx("span",{className:"truncate text-sm font-medium text-card-foreground!",children:e.email})]})}),p.jsx(Fo,{}),p.jsxs(_n,{disabled:t.isPending,onClick:()=>t.mutate(),children:[p.jsx(AU,{className:"size-4 text-muted-foreground!"}),p.jsx("span",{className:"text-sm",children:t.isPending?"Logging out…":"Log out"})]})]})]})}function E$(){const e=ji(n=>n.isAuthorized);return ji(n=>n.isLoadingInitial)?p.jsx(De,{className:"ml-2.5",disabled:!0,size:"icon",variant:"outline",children:p.jsx(Lx,{className:"size-4 shrink-0 text-muted-foreground animate-pulse"})}):e?p.jsx(C$,{}):p.jsx(S$,{})}function k$(){const e=on(o=>o.seenWelcome),t=on(o=>o.tourCompleted),n=on(o=>o.startTour),r=!e&&!t;return p.jsxs(Ws,{children:[p.jsx(Ks,{render:p.jsxs(De,{size:"sm",variant:"ghost",children:[p.jsx(ZH,{className:"size-4"}),"Help",r&&p.jsx("span",{"aria-hidden":!0,className:we("size-1.5 rounded-full bg-orange-500")})]})}),p.jsxs(Za,{align:"end",className:"w-56",children:[p.jsxs(_n,{className:"bg-primary/8 hover:bg-primary/12 focus:bg-primary/12",onClick:()=>n(),children:[p.jsx(QH,{className:"text-primary-foreground"}),p.jsx("span",{children:t?"Restart the tour":"Take the tour"})]}),p.jsx(Fo,{}),p.jsx(_n,{render:p.jsxs("a",{href:"https://docs.byterover.dev",rel:"noopener noreferrer",target:"_blank",children:[p.jsx(IH,{}),p.jsx("span",{children:"Documentation"})]})}),p.jsx(_n,{render:p.jsxs("a",{href:"https://github.com/campfirein/byterover-cli/issues",rel:"noopener noreferrer",target:"_blank",children:[p.jsx(PH,{}),p.jsx("span",{children:"Report an issue"})]})})]})]})}function T$(e){const{children:t,open:n,defaultOpen:r=!1,onOpenChange:o,onOpenChangeComplete:a,actionsRef:l,handle:c,triggerId:f,defaultTriggerId:d=null}=e,g=Ka(),h=!!g,y=Zn(()=>c?.store??new l9({open:r,openProp:n,activeTriggerId:d,triggerIdProp:f,modal:!0,disablePointerDismissal:!0,nested:h,role:"alertdialog"})).current;y.useControlledProp("openProp",n),y.useControlledProp("triggerIdProp",f),y.useSyncedValue("nested",h),y.useContextCallback("onOpenChange",o),y.useContextCallback("onOpenChangeComplete",a);const x=y.useState("payload");s9({store:y,actionsRef:l,parentContext:g?.store.context});const v=C.useMemo(()=>({store:y}),[y]);return p.jsx(Tx.Provider,{value:v,children:typeof t=="function"?t({payload:x}):t})}function p0({...e}){return p.jsx(T$,{"data-slot":"alert-dialog",...e})}function A$({...e}){return p.jsx(Ox,{"data-slot":"alert-dialog-portal",...e})}function R$({className:e,...t}){return p.jsx(Ax,{"data-slot":"alert-dialog-overlay",className:we("fixed inset-0 isolate z-50 bg-background/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",e),...t})}function m0({className:e,size:t="default",...n}){return p.jsxs(A$,{children:[p.jsx(R$,{}),p.jsx(Nx,{"data-slot":"alert-dialog-content","data-size":t,className:we("group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-6 rounded-xl bg-background p-6 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-lg data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...n})]})}function g0({className:e,...t}){return p.jsx("div",{"data-slot":"alert-dialog-header",className:we("grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-6 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",e),...t})}function y0({className:e,...t}){return p.jsx("div",{"data-slot":"alert-dialog-footer",className:we("flex flex-col-reverse gap-2 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",e),...t})}function x0({className:e,...t}){return p.jsx(u9,{"data-slot":"alert-dialog-title",className:we("text-lg font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",e),...t})}function b0({className:e,...t}){return p.jsx(WT,{"data-slot":"alert-dialog-description",className:we("text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...t})}function v0({className:e,variant:t="outline",size:n="default",...r}){return p.jsx(Pf,{"data-slot":"alert-dialog-cancel",className:we(e),render:p.jsx(De,{variant:t,size:n}),...r})}const N$="state:getProjectConfig",O$=e=>{const{apiClient:t}=Be.getState();return t?t.request(N$,{projectPath:e}):Promise.reject(new Error("Not connected"))},j$=e=>({enabled:e.length>0,queryFn:()=>O$(e),queryKey:["project-config",e]}),V9=({projectPath:e,queryConfig:t})=>br({...t,...j$(e)}),M$=()=>{const{apiClient:e}=Be.getState();return e?e.request(mB.GET):Promise.reject(new Error("Not connected"))},L$=()=>({queryFn:M$,queryKey:["projects"]}),$9=({queryConfig:e}={})=>br({...L$(),...e}),_$=/^(?:\/Users\/|\/home\/|[A-Za-z]:[/\\]Users[/\\])[^/\\]+([/\\].*)$/;function G9(e){const t=_$.exec(e);return t?`~${t[1]}`:e}function w0(e){return e.replace(/[/\\]+$/,"").split(/[/\\]/).at(-1)||e}const RC=["bg-gradient-to-br from-red-600 to-red-500 text-white","bg-gradient-to-br from-orange-400 to-pink-500 text-white","bg-gradient-to-br from-teal-500 to-emerald-500 text-white","bg-gradient-to-br from-blue-800 to-blue-600 text-white","bg-gradient-to-br from-sky-400 to-sky-300 text-white","bg-gradient-to-br from-purple-500 to-pink-500 text-white","bg-gradient-to-br from-green-500 to-lime-300 text-white","bg-gradient-to-br from-yellow-300 to-orange-400 text-white","bg-gradient-to-br from-orange-500 to-red-600 text-white","bg-gradient-to-br from-cyan-400 to-cyan-300 text-white"];function D$(e){let t=0;for(let n=0;n<e.length;n++){const r=e.codePointAt(n)??0;t=Math.abs(Math.trunc(t*31+r))}return RC[t%RC.length]}const I$={lg:"size-7 text-xs",md:"size-6 text-xs",sm:"size-5 text-[10px]"};function Kx({name:e,seed:t,size:n="md"}){return p.jsx("span",{className:we("relative flex shrink-0 items-center justify-center overflow-hidden rounded font-extrabold leading-4",'before:absolute before:inset-0 before:bg-black/10 before:content-[""]',I$[n],D$(t??e)),children:p.jsx("span",{className:"relative",children:q9(e)})})}function Y9({onClick:e,project:t}){const n=w0(t.projectPath);return p.jsxs("button",{className:"flex w-full items-center gap-2 rounded-md p-2 text-left transition-colors hover:bg-accent cursor-pointer",onClick:e,type:"button",children:[p.jsx(Kx,{name:n,seed:t.projectPath,size:"lg"}),p.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[p.jsx("span",{className:"truncate text-sm font-medium leading-5 text-card-foreground",children:n}),p.jsx("span",{className:"truncate text-xs leading-4 text-muted-foreground",children:G9(t.projectPath)})]})]})}function W9({onOpenChange:e,onSelect:t,open:n,projects:r}){const[o,a]=C.useState(""),l=C.useMemo(()=>{const f=o.trim().toLowerCase();return f?r.filter(d=>d.projectPath.toLowerCase().includes(f)):r},[r,o]);function c(f){t(f),e(!1)}return p.jsx($s,{onOpenChange:e,open:n,children:p.jsxs(Gs,{className:"gap-2 sm:max-w-lg",children:[p.jsxs(ui,{children:[p.jsx(fi,{children:"All projects"}),p.jsx(Ff,{children:p.jsxs("div",{className:"relative",children:[p.jsx(vc,{className:"absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),p.jsx(Ko,{autoFocus:!0,className:"pl-9",onChange:f=>a(f.target.value),placeholder:"Search...",value:o})]})})]}),p.jsx("div",{className:"-mx-4 no-scrollbar max-h-[60vh] min-h-[200px] overflow-y-auto px-4 mt-2",children:l.length===0?p.jsx("p",{className:"px-2 py-4 text-center text-xs text-muted-foreground",children:"No projects match your search."}):l.map(f=>p.jsx(Y9,{onClick:()=>c(f),project:f},f.projectPath))})]})})}const NC=5;function K9({name:e,project:t,remoteLabel:n}){return p.jsxs(p.Fragment,{children:[p.jsx(Kx,{name:e,seed:t.projectPath}),p.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[p.jsx("span",{className:"truncate text-sm font-medium leading-5 text-card-foreground!",children:e}),p.jsx("span",{className:"truncate text-xs leading-4 text-muted-foreground!",children:G9(t.projectPath)}),n&&p.jsx("span",{className:"text-muted-foreground! mono flex items-start gap-1 text-[10px] leading-4",children:p.jsxs("span",{className:"min-w-0 wrap-break-word",children:[p.jsx("span",{children:"Remote space: "}),p.jsx("span",{className:"text-primary-foreground! font-medium",children:n})]})})]})]})}function z$({onSelect:e,project:t,showRemote:n=!1}){const r=w0(t.projectPath),{data:o}=V9({projectPath:t.projectPath,queryConfig:{enabled:n}}),a=o?.brvConfig?.teamName,l=o?.brvConfig?.spaceName,c=a&&l?`${a} / ${l}`:void 0;return p.jsx(_n,{className:"gap-2 rounded-md",onClick:e,children:p.jsx(K9,{name:r,project:t,remoteLabel:c})})}function P$({isSelected:e,onSelect:t,project:n}){const r=w0(n.projectPath),{data:o}=V9({projectPath:n.projectPath}),a=o?.brvConfig?.teamName,l=o?.brvConfig?.spaceName,c=a&&l?`${a} / ${l}`:void 0,f=o?.remoteUrl&&zx(o.remoteUrl)?o.remoteUrl:void 0;return p.jsxs(Gx,{children:[p.jsx(Yx,{className:"gap-2 rounded-md",children:p.jsx(K9,{name:r,project:n,remoteLabel:c})}),p.jsxs(Wx,{className:"min-w-56",children:[p.jsxs(_n,{disabled:e,onClick:t,children:[p.jsx(NH,{className:"size-4"}),p.jsx("span",{className:"text-sm",children:e?"Current project":"Switch to this project"})]}),p.jsxs(_n,{disabled:!f,onClick:()=>{f&&window.open(f,"_blank","noopener,noreferrer")},children:[p.jsx(BU,{className:"size-4"}),p.jsx("span",{className:"text-sm",children:"Open Remote space"})]})]})]})}function F$(){const e=Be(v=>v.selectedProject),t=Be(v=>v.setSelectedProject),{data:n}=$9({queryConfig:{refetchInterval:3e3,refetchIntervalInBackground:!1,staleTime:30*1e3}}),r=C.useMemo(()=>n?.locations??[],[n]),{openProjects:o,recentProjects:a}=C.useMemo(()=>{const v=[],S=[];for(const E of r)E.isActive?v.push(E):S.push(E);return{openProjects:v,recentProjects:S}},[r]),[l,c]=C.useState(!1),[f,d]=C.useState(!1),[g,h]=C.useState(!1),y=w0(e);function x(v){v.projectPath!==e&&t(v.projectPath)}return p.jsxs(p.Fragment,{children:[p.jsxs(Ws,{onOpenChange:c,open:l,children:[p.jsxs(Ks,{render:p.jsx(De,{variant:"ghost"}),children:[e?p.jsx(Kx,{name:y,seed:e,size:"sm"}):null,p.jsx("span",{className:"truncate",children:y||"No project selected"}),p.jsx(Bf,{className:"size-4 shrink-0"})]}),p.jsxs(Za,{align:"start",className:"w-(--anchor-width) min-w-72",sideOffset:6,children:[p.jsxs(_n,{onClick:()=>d(!0),children:[p.jsx(fU,{className:"size-4"}),p.jsx("span",{className:"text-sm",children:"Open Project"})]}),p.jsx(Fo,{}),o.length>0&&p.jsxs(Os,{children:[p.jsx(Ql,{children:"Open Projects"}),o.map(v=>p.jsx(P$,{isSelected:v.projectPath===e,onSelect:()=>x(v),project:v},v.projectPath)),p.jsx(Fo,{})]}),a.length>0&&p.jsxs(Os,{children:[p.jsx(Ql,{children:"Recent Projects"}),a.slice(0,NC).map(v=>p.jsx(z$,{onSelect:()=>x(v),project:v},v.projectPath)),a.length>NC&&p.jsx(_n,{onClick:()=>h(!0),children:p.jsx("span",{className:"text-xs",children:"See all"})})]})]})]}),p.jsx(p0,{onOpenChange:d,open:f,children:p.jsxs(m0,{children:[p.jsxs(g0,{children:[p.jsx(x0,{children:"Add a project"}),p.jsxs(b0,{children:["To add a project, run ",p.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 text-sm",children:"brv webui"})," in that folder from your terminal. Once registered, it will appear here."]})]}),p.jsx(y0,{children:p.jsx(v0,{children:"Got it"})})]})}),p.jsx(W9,{onOpenChange:h,onSelect:x,open:g,projects:r})]})}const B$=()=>{const{apiClient:e}=Be.getState();return e?e.request(rr.BRANCH,{action:"list",all:!0}).then(t=>{if(t.action!=="list")throw new Error(`Unexpected branch response action: ${t.action}`);return t.branches}):Promise.reject(new Error("Not connected"))},Ja=()=>({queryFn:B$,queryKey:["vc","branches","all"],refetchInterval:1e4,refetchIntervalInBackground:!1,staleTime:5e3}),H$=({queryConfig:e}={})=>br({...Ja(),...e}),U$=e=>{const{apiClient:t}=Be.getState();return t?t.request(rr.BRANCH,{action:"set-upstream",upstream:e}):Promise.reject(new Error("Not connected"))},q$=({mutationConfig:e}={})=>{const t=cn(),{onSuccess:n,...r}=e??{};return wn({onSuccess(...o){t.invalidateQueries({queryKey:hi().queryKey}),t.invalidateQueries({queryKey:Ja().queryKey}),n?.(...o)},...r,mutationFn:U$})},V$=e=>{const{apiClient:t}=Be.getState();return t?t.request(rr.CHECKOUT,e):Promise.reject(new Error("Not connected"))},Q9=({mutationConfig:e}={})=>{const t=cn(),{onSuccess:n,...r}=e??{};return wn({onSuccess(...o){t.invalidateQueries({queryKey:hi().queryKey}),t.invalidateQueries({queryKey:Ja().queryKey}),n?.(...o)},...r,mutationFn:V$})},$$=(e={})=>{const{apiClient:t}=Be.getState();return t?t.request(rr.FETCH,e):Promise.reject(new Error("Not connected"))},G$=({mutationConfig:e}={})=>{const t=cn(),{onSuccess:n,...r}=e??{};return wn({onSuccess(...o){t.invalidateQueries({queryKey:hi().queryKey}),t.invalidateQueries({queryKey:Ja().queryKey}),n?.(...o)},...r,mutationFn:$$})},Y$=(e={})=>{const{apiClient:t}=Be.getState();return t?t.request(rr.PULL,e):Promise.reject(new Error("Not connected"))},X9=({mutationConfig:e}={})=>{const t=cn(),{onSuccess:n,...r}=e??{};return wn({onSuccess(...o){t.invalidateQueries({queryKey:hi().queryKey}),t.invalidateQueries({queryKey:Ja().queryKey}),n?.(...o)},...r,mutationFn:Y$})};function W$(e,t){const n=t.trim().toLowerCase();return n===""?[...e]:e.filter(r=>r.name.toLowerCase().includes(n))}const OC="refs/remotes/";function K$(e){const t=e.startsWith(OC)?e.slice(OC.length):e,n=t.indexOf("/");return n===-1?"unknown":t.slice(0,n)}function Q$(e){const t=[],n=new Map;for(const r of e)if(r.isRemote){const o=K$(r.name),a=n.get(o);a?a.push(r):n.set(o,[r])}else t.push(r);return{locals:t,remotesByHost:n}}function X$(e,t){return t?e.some(r=>!r.isRemote&&r.name===t)?[...e]:[{isCurrent:!0,isRemote:!1,name:t},...e]:[...e]}const Z$=e=>{const{apiClient:t}=Be.getState();return t?t.request(rr.BRANCH,{action:"delete",name:e}):Promise.reject(new Error("Not connected"))},J$=({mutationConfig:e}={})=>{const t=cn(),{onSuccess:n,...r}=e??{};return wn({onSuccess(...o){t.invalidateQueries({queryKey:Ja().queryKey}),n?.(...o)},...r,mutationFn:Z$})};function eG({branchName:e,onOpenChange:t,open:n}){const r=J$();async function o(){try{await r.mutateAsync(e),ut.success(`Deleted ${e}`,{position:"top-center"}),t(!1)}catch(a){ut.error(a instanceof Error?a.message:"Failed to delete branch",{position:"top-center"})}}return p.jsx(p0,{onOpenChange:t,open:n,children:p.jsxs(m0,{children:[p.jsxs(g0,{children:[p.jsx(x0,{children:"Delete branch?"}),p.jsxs(b0,{children:["Branch ",p.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 text-sm",children:e})," will be removed. Unmerged commits on this branch will be lost unless they are reachable from another ref."]})]}),p.jsxs(y0,{children:[p.jsx(v0,{children:"Cancel"}),p.jsx(De,{disabled:r.isPending,onClick:o,variant:"destructive",children:r.isPending?"Deleting…":"Delete branch"})]})]})})}const tG=()=>{const{apiClient:e}=Be.getState();return e?e.request(rr.INIT):Promise.reject(new Error("Not connected"))},nG=({mutationConfig:e}={})=>{const t=cn(),{onSuccess:n,...r}=e??{};return wn({onSuccess(...o){t.invalidateQueries({queryKey:hi().queryKey}),t.invalidateQueries({queryKey:Ja().queryKey}),n?.(...o)},...r,mutationFn:tG})};function Z9(){const e=nG();async function t(){try{const n=await e.mutateAsync();ut.success(n.reinitialized?"Reinitialized version control":"Initialized version control",{position:"top-center"})}catch(n){ut.error(n instanceof Error?n.message:"Failed to initialize",{position:"top-center"})}}return p.jsxs(De,{disabled:e.isPending,onClick:()=>{t().catch(()=>{})},size:"sm",variant:"outline",children:[p.jsx(jx,{className:"size-4 shrink-0"}),p.jsx("span",{children:e.isPending?"Initializing…":"Initialize Version Control"})]})}function rG({className:e,...t}){return p.jsx("label",{"data-slot":"label",className:we("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}const iG=o0("group/field flex w-full gap-3 data-[invalid=true]:text-destructive",{variants:{orientation:{vertical:"flex-col *:w-full [&>.sr-only]:w-auto",horizontal:"flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",responsive:"flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"}},defaultVariants:{orientation:"vertical"}});function oG({className:e,orientation:t="vertical",...n}){return p.jsx("div",{role:"group","data-slot":"field","data-orientation":t,className:we(iG({orientation:t}),e),...n})}function aG({className:e,...t}){return p.jsx(rG,{"data-slot":"field-label",className:we("group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-md has-[>[data-slot=field]]:border *:data-[slot=field]:p-3 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10","has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col",e),...t})}function sG({className:e,...t}){return p.jsx("p",{"data-slot":"field-description",className:we("text-left text-sm leading-normal font-normal text-muted-foreground group-has-data-horizontal/field:text-balance [[data-variant=legend]+&]:-mt-1.5","last:mt-0 nth-last-2:-mt-1","[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",e),...t})}function lG({initialName:e="",onOpenChange:t,open:n,startPoint:r}){const o=C.useId(),[a,l]=C.useState(e),[c,f]=C.useState(),d=Q9();C.useEffect(()=>{n&&(l(e),f(void 0))},[e,n]);async function g(){const h=a.trim();if(h){f(void 0);try{await d.mutateAsync({branch:h,create:!0,startPoint:r}),ut.success(r?`Created ${h} from ${r} and switched to it`:`Created and switched to ${h}`,{position:"top-center"}),t(!1)}catch(y){f(y instanceof Error?y.message:"Failed to create branch")}}}return p.jsx($s,{onOpenChange:t,open:n,children:p.jsxs(Gs,{children:[p.jsxs(ui,{children:[p.jsx(fi,{children:"New branch"}),p.jsx(Ff,{children:r?`Create a branch based on ${r} and switch to it.`:"Create a branch from the current HEAD and switch to it."})]}),p.jsxs(oG,{"data-invalid":!!c,children:[p.jsx(aG,{htmlFor:o,children:"Branch name"}),p.jsx(Ko,{"aria-invalid":!!c,autoFocus:!0,id:o,onChange:h=>{l(h.target.value),c&&f(void 0)},onKeyDown:h=>{h.key==="Enter"&&g()},placeholder:"Branch name",value:a}),p.jsx(sG,{children:c})]}),p.jsxs(Qa,{children:[p.jsx(H1,{render:p.jsx(De,{className:"cursor-pointer",variant:"ghost"}),children:"Cancel"}),p.jsx(De,{className:"cursor-pointer",disabled:a.trim().length===0||d.isPending,onClick:g,children:d.isPending?"Creating…":"Create branch"})]})]})})}const jl={position:"top-center"};function cG(e){return e?e.initialized?e.branch?e.branch:"detached":"No git repo":"branch"}function U1(e){const t=e.startsWith("refs/remotes/")?e.slice(13):e,n=t.indexOf("/");return n===-1?t:t.slice(n+1)}function uG(){const e=qa(),[t,n]=C.useState(!1),[r,o]=C.useState(""),[a,l]=C.useState(null),[c,f]=C.useState(""),[d,g]=C.useState(),[h,y]=C.useState(null),[x,v]=C.useState(new Set(["origin"])),S=Bx(),E=H$({queryConfig:{enabled:S.data?.initialized??!1}}),k=Q9(),T=G$(),R=X9(),L=q$(),{locals:j,remotesByHost:N}=C.useMemo(()=>{const _=X$(E.data??[],S.data?.branch),ee=r.trim()===""?_:W$(_,r);return Q$(ee)},[E.data,r,S.data?.branch]),{currentLocal:A,hasLocals:D,hasOtherLocals:U,otherLocals:I}=C.useMemo(()=>{let _;const ee=[];for(const J of j)J.isCurrent&&!_?_=J:ee.push(J);return{currentLocal:_,hasLocals:j.length>0,hasOtherLocals:ee.length>0,otherLocals:ee}},[j]),q=N.size>0;function $(_,ee=""){n(!1),f(ee),g(void 0),l(_)}function V(_){n(!1),f(U1(_)),g(_),l("new-branch")}async function Y(_,ee){n(!1);try{await k.mutateAsync({branch:_}),ut.success(ee,jl)}catch(J){ut.error("Failed to switch branch",{...jl,description:Cn(J)})}}function H(_){n(!1),y({branchName:_})}async function B(_){const ee=U1(_.name),J=(E.data??[]).find(re=>!re.isRemote&&re.name===ee);if(J){Y(J.name,`Switched to ${J.name}`).catch(()=>{});return}n(!1);try{await k.mutateAsync({branch:ee,create:!0,startPoint:_.name});try{await L.mutateAsync(_.name)}catch{}ut.success(`Switched to ${ee} (tracking ${_.name})`,jl)}catch(re){ut.error("Failed to checkout remote branch",{...jl,description:Cn(re)})}}function F(_){v(ee=>{const J=new Set(ee);return J.has(_)?J.delete(_):J.add(_),J})}function G(){n(!1),ut.promise(T.mutateAsync({}),{...jl,error:_=>({description:Cn(_),message:"Fetch failed"}),loading:"Fetching from remote…",success:"Fetched from remote"})}function ie(){n(!1),ut.promise(R.mutateAsync({}),{...jl,error:_=>({description:Cn(_),message:"Pull failed"}),loading:"Updating project…",success:_=>_.alreadyUpToDate?`${_.branch} is up to date`:`Pulled ${_.branch}`})}const M=S.data!==void 0,P=S.data?.initialized??!1,Q=cG(S.data);return M&&!P?p.jsx(Z9,{}):p.jsxs(p.Fragment,{children:[p.jsxs(Ws,{onOpenChange:n,open:t,children:[p.jsxs(Ks,{render:p.jsx(De,{disabled:!M,variant:"ghost"}),children:[p.jsx(jx,{className:"size-4 shrink-0"}),p.jsx("span",{className:"truncate max-w-40",children:Q}),p.jsx(Bf,{className:"size-4 shrink-0"})]}),p.jsxs(Za,{align:"start",className:"w-80 p-0",sideOffset:6,children:[p.jsxs("div",{className:"flex items-center gap-1.5 p-2 border-b border-border",children:[p.jsxs("div",{className:"relative min-w-0 flex-1",children:[p.jsx(vc,{className:"absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),p.jsx(Ko,{autoFocus:!0,className:"pl-8",onChange:_=>o(_.target.value),onKeyDown:_=>_.stopPropagation(),placeholder:"Search branches…",value:r})]}),p.jsx(De,{className:"shrink-0",disabled:T.isPending,onClick:G,size:"icon-sm",title:"Fetch",variant:"ghost",children:p.jsx(_H,{className:T.isPending?"size-4 animate-pulse":"size-4"})})]}),p.jsxs("div",{className:"max-h-[60vh] overflow-x-hidden overflow-y-auto py-1",children:[r.trim()===""&&p.jsxs(Os,{children:[p.jsxs(_n,{onClick:ie,children:[p.jsx(kH,{className:"size-5"}),p.jsx("span",{children:"Update Project"})]}),p.jsxs(_n,{onClick:()=>{n(!1),e("/changes")},children:[p.jsx(pU,{className:"size-5"}),p.jsx("span",{children:"Commit..."})]}),p.jsx(Fo,{}),p.jsxs(_n,{onClick:()=>$("new-branch",A?.name||""),children:[p.jsx(Xa,{className:"size-5"}),p.jsx("span",{children:"New Branch..."})]})]}),A?p.jsxs(p.Fragment,{children:[p.jsx(Fo,{}),p.jsxs(Os,{children:[p.jsx(Ql,{children:"Current"}),p.jsx(jC,{branch:A,onCheckout:()=>{Y(A.name,`Switched to ${A.name}`).catch(()=>{})},onDelete:()=>H(A.name),onNewBranchFrom:()=>V(A.name),trackingBranch:S.data?.trackingBranch})]})]}):null,U&&p.jsxs(p.Fragment,{children:[p.jsx(Fo,{}),p.jsxs(Os,{children:[p.jsx(Ql,{children:"Local"}),I.map(_=>p.jsx(jC,{branch:_,onCheckout:()=>{Y(_.name,`Switched to ${_.name}`).catch(()=>{})},onDelete:()=>H(_.name),onNewBranchFrom:()=>V(_.name)},_.name))]})]}),q&&p.jsxs(p.Fragment,{children:[p.jsx(Fo,{}),p.jsxs(Os,{children:[p.jsx(Ql,{children:"Remote"}),[...N.entries()].map(([_,ee])=>p.jsx(fG,{branches:ee,expanded:x.has(_),host:_,onBranchCheckout:B,onBranchNewBranchFrom:J=>V(J.name),onToggle:()=>F(_)},_))]})]}),!D&&!q&&p.jsx("p",{className:"px-3 py-4 text-center text-xs text-muted-foreground",children:r?"No branches match your search.":"No branches."})]})]})]}),p.jsx(lG,{initialName:c,onOpenChange:_=>_?null:l(null),open:a==="new-branch",startPoint:d}),p.jsx(eG,{branchName:h?.branchName??"",onOpenChange:_=>_?null:y(null),open:h!==null})]})}function jC({branch:e,onCheckout:t,onDelete:n,onNewBranchFrom:r,trackingBranch:o}){return p.jsxs(Gx,{children:[p.jsxs(Yx,{children:[p.jsx("span",{className:"flex size-4 shrink-0 items-center justify-center",children:e.isCurrent?p.jsx(Ys,{className:"size-4 text-primary"}):null}),p.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:e.name}),o?p.jsx("span",{className:"shrink-0 truncate max-w-32 text-xs text-muted-foreground",children:o}):null]}),p.jsxs(Wx,{className:"min-w-56",children:[!e.isCurrent&&p.jsx(_n,{onClick:t,children:"Checkout"}),p.jsx(_n,{onClick:r,children:p.jsxs("span",{className:"min-w-0 flex-1 truncate",children:["New Branch from '",e.name,"'..."]})}),!e.isCurrent&&p.jsxs(p.Fragment,{children:[p.jsx(Fo,{}),p.jsx(_n,{onClick:n,children:"Delete…"})]})]})]})}function fG({branches:e,expanded:t,host:n,onBranchCheckout:r,onBranchNewBranchFrom:o,onToggle:a}){return p.jsxs("div",{className:"flex min-w-0 flex-col",children:[p.jsxs("button",{className:"flex min-w-0 cursor-pointer items-center gap-2 px-3 py-1.5 text-sm text-foreground outline-none hover:bg-muted focus:bg-muted",onClick:a,type:"button",children:[p.jsx(h9,{className:`size-4 shrink-0 text-muted-foreground transition-transform ${t?"rotate-90":""}`}),p.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:n})]}),t?e.map(l=>p.jsx(dG,{branch:l,onCheckout:()=>r(l),onNewBranchFrom:()=>o(l)},l.name)):null]})}function dG({branch:e,onCheckout:t,onNewBranchFrom:n}){const r=U1(e.name);return p.jsxs(Gx,{children:[p.jsx(Yx,{className:"pl-15",children:p.jsx("span",{className:"min-w-0 flex-1 truncate text-left",children:r})}),p.jsxs(Wx,{className:"min-w-56",children:[p.jsx(_n,{onClick:t,children:"Checkout"}),p.jsx(_n,{onClick:n,children:p.jsxs("span",{className:"min-w-0 flex-1 truncate",children:["New Branch from '",e.name,"'..."]})})]})]})}function hG(){const e=Be(c=>c.version),[t,n]=C.useState(!1),{data:r}=VT(),{data:o}=kx(),a=r?.providers.find(c=>c.isCurrent),l=a?`${a.name}${o?.activeModel?` | ${o.activeModel}`:""}`:"No model configured";return p.jsxs("header",{className:"flex items-center gap-4 px-6 py-3.5",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsxs("div",{className:"flex items-center gap-1.5 mr-2.5",children:[p.jsx("img",{alt:"ByteRover",className:"w-32",src:MV}),e&&p.jsxs("span",{className:"text-primary-foreground text-xs font-medium",children:["v",e]})]}),p.jsx(F$,{}),p.jsx(uG,{}),p.jsxs(_s,{children:[p.jsxs(Ds,{render:p.jsx(Yo,{className:"border-primary-foreground/40 bg-primary-foreground/15 text-primary-foreground mono gap-1 px-1.5 text-[9px] leading-none font-semibold tracking-[0.16em] uppercase",variant:"outline"}),children:[p.jsx("span",{"aria-hidden":!0,className:"bg-primary-foreground size-1 shrink-0 rounded-full"}),p.jsx("span",{className:"leading-none",children:"Local"})]}),p.jsx(Is,{children:"You're viewing the local web UI, served from the daemon on your machine."})]})]}),p.jsx("div",{className:"flex-1"}),p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsxs(_s,{children:[p.jsxs(Ds,{render:p.jsx(De,{onClick:()=>n(!0),size:"sm",variant:"ghost"}),children:[p.jsx(IU,{className:"size-3.5 shrink-0 mr-1"}),l,!a&&p.jsx("span",{className:"size-1.5 shrink-0 rounded-full bg-amber-500"})]}),!a&&p.jsx(Is,{children:"Configure to use curate/query feature"})]}),p.jsx(Px,{onOpenChange:n,open:t}),p.jsx(k$,{}),p.jsx(E$,{})]})]})}function pG(){const{completed:e,inProgress:t,total:n}=BB(),r=n>0?`${e}/${n}`:void 0,o=t>0?"active":"idle";return[{label:"Context",path:"/contexts"},{label:"Changes",path:"/changes"},{badge:r,badgeTone:o,label:"Tasks",path:"/tasks"},{label:"Configuration",path:"/configuration"}]}function mG(){const{data:e}=Bx(),{staged:t,unmerged:n,unstaged:r}=N9(e),o=t.length+r.length+n.length;return o===0?null:p.jsx("span",{className:"ml-1.5 rounded-md bg-[#4f3422] p-1 text-xs font-semibold tabular-nums text-[#ffc53d]",children:o})}function gG(){const e=pG();return RV(),p.jsxs("div",{className:"flex h-screen flex-col",children:[p.jsx(hG,{}),p.jsx("nav",{className:"border-border flex gap-2 border-b px-6",children:e.map(t=>p.jsxs(Ck,{className:({isActive:n})=>we("flex items-center gap-1.5 border-b-2 px-2 pt-2 pb-3 text-sm transition-colors",{"border-primary-foreground text-primary-foreground font-medium":n,"border-transparent text-muted-foreground hover:text-foreground":!n}),to:t.path,children:[p.jsx("span",{children:t.label}),t.badge&&p.jsxs(Yo,{className:"tabular-nums",variant:"secondary",children:[t.badgeTone==="active"&&p.jsx("span",{"aria-hidden":!0,className:"bg-primary-foreground size-1.5 shrink-0 rounded-full"}),t.badge]}),t.path==="/changes"&&p.jsx(mG,{})]},t.path))}),p.jsx("main",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:p.jsx(bk,{})}),p.jsx(AV,{}),p.jsx(TV,{}),p.jsx(YB,{})]})}function yG(){return p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("section",{className:"grid gap-4 grid-cols-3",children:[p.jsxs(ja,{className:"gap-1 px-4 shadow-none ring-border/80",size:"sm",children:[p.jsx("div",{className:"text-xs tracking-wider uppercase text-muted-foreground",children:"Total tasks"}),p.jsx("strong",{className:"text-3xl leading-none",children:"0"}),p.jsx(Ah,{children:"Waiting for the skipped task-subscription issue."})]}),p.jsxs(ja,{className:"gap-1 px-4 shadow-none ring-border/80",size:"sm",children:[p.jsx("div",{className:"text-xs tracking-wider uppercase text-muted-foreground",children:"Success rate"}),p.jsx("strong",{className:"text-3xl leading-none",children:"0%"}),p.jsx(Ah,{children:"No client-side task history is wired into the web app yet."})]}),p.jsxs(ja,{className:"gap-1 px-4 shadow-none ring-border/80",size:"sm",children:[p.jsx("div",{className:"text-xs tracking-wider uppercase text-muted-foreground",children:"Average duration"}),p.jsx("strong",{className:"text-3xl leading-none",children:"0s"}),p.jsx(Ah,{children:"This will populate once task-store parity lands."})]})]}),p.jsxs(ja,{className:"min-h-56 items-start justify-center gap-3 px-5 shadow-sm ring-border/70",size:"sm",children:[p.jsx(Yo,{className:"rounded-sm border-yellow-500/20 bg-yellow-500/10 text-yellow-600",variant:"outline",children:"Empty state"}),p.jsx(b$,{className:"font-semibold",children:"No task data available yet"}),p.jsx(Ah,{children:"The plan explicitly skips the activity/task subscription issue. This page is wired as a placeholder so the route exists cleanly and can consume task-store data once that transport work lands."})]})]})}const xG="data:image/svg+xml,%3csvg%20width='120'%20height='120'%20viewBox='0%200%20120%20120'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M60%20120C93%20120%20120%2093%20120%2060C120%2027%2093%200%2060%200C27%200%200%2027%200%2060C0%2093%2027%20120%2060%20120Z'%20fill='url(%23paint0_linear_2037_60923)'%20fill-opacity='0.15'/%3e%3cpath%20d='M60%200.75C92.5858%200.75%20119.25%2027.4142%20119.25%2060C119.25%2092.5858%2092.5858%20119.25%2060%20119.25C27.4142%20119.25%200.75%2092.5858%200.75%2060C0.75%2027.4142%2027.4142%200.75%2060%200.75Z'%20stroke='url(%23paint1_linear_2037_60923)'%20stroke-opacity='0.5'%20stroke-width='1.5'/%3e%3cpath%20d='M87.3926%2037.6738C88.505%2036.4418%2090.2734%2036.4418%2091.3857%2037.6738C92.5382%2038.9504%2092.5381%2041.0486%2091.3857%2042.3252L51.6631%2086.3262C50.5507%2087.5582%2048.7823%2087.5582%2047.6699%2086.3262L29.6143%2066.3252C28.4621%2065.0486%2028.4621%2062.9514%2029.6143%2061.6748C30.7267%2060.4426%2032.495%2060.4426%2033.6074%2061.6748L47.625%2077.2021C48.717%2078.4118%2050.616%2078.4118%2051.708%2077.2021L87.3926%2037.6738Z'%20fill='url(%23paint2_linear_2037_60923)'%20stroke='%2300E275'%20stroke-width='1.5'/%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_2037_60923'%20x1='17.9848'%20y1='14.0983'%20x2='125.634'%20y2='103.845'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='white'/%3e%3cstop%20offset='1'%20stop-color='%23999999'%20stop-opacity='0.5'/%3e%3c/linearGradient%3e%3clinearGradient%20id='paint1_linear_2037_60923'%20x1='15.3936'%20y1='-1.63761e-06'%20x2='120'%20y2='90.8895'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='white'%20stop-opacity='0.5'/%3e%3cstop%20offset='1'%20stop-color='%23999999'%20stop-opacity='0'/%3e%3c/linearGradient%3e%3clinearGradient%20id='paint2_linear_2037_60923'%20x1='65.5979'%20y1='65.9795'%20x2='78.5737'%20y2='-56.684'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%2309814A'/%3e%3cstop%20offset='1'%20stop-color='%2300CC66'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e",bG=(e={})=>{const{apiClient:t}=Be.getState();return t?t.request(rr.ADD,e):Promise.reject(new Error("Not connected"))},vG=({mutationConfig:e}={})=>{const t=cn(),{onSuccess:n,...r}=e??{};return wn({onSuccess(...o){t.invalidateQueries({queryKey:hi().queryKey}),n?.(...o)},...r,mutationFn:bG})},wG=({addAll:e,filePaths:t,message:n})=>{const{apiClient:r}=Be.getState();if(!r)return Promise.reject(new Error("Not connected"));const o=()=>r.request(rr.COMMIT,{message:n});if(e||t&&t.length>0){const a=t?{filePaths:t}:{};return r.request(rr.ADD,a).then(o)}return o()},SG=({mutationConfig:e}={})=>{const t=cn(),{onSuccess:n,...r}=e??{};return wn({onSuccess(...o){t.invalidateQueries({queryKey:hi().queryKey}),n?.(...o)},...r,mutationFn:wG})},CG=()=>{const{apiClient:e}=Be.getState();return e?e.request(rr.MERGE,{action:"abort"}):Promise.reject(new Error("Not connected"))},EG=({mutationConfig:e}={})=>{const t=cn(),{onSuccess:n,...r}=e??{};return wn({onSuccess(...o){t.invalidateQueries({queryKey:hi().queryKey}),t.invalidateQueries({queryKey:["vc","diff"]}),t.invalidateQueries({queryKey:["vc","diffs"]}),n?.(...o)},...r,mutationFn:CG})},kG=e=>{const{apiClient:t}=Be.getState();return t?t.request(rr.MERGE,{action:"continue",message:e.message}):Promise.reject(new Error("Not connected"))},TG=({mutationConfig:e}={})=>{const t=cn(),{onSuccess:n,...r}=e??{};return wn({onSuccess(...o){t.invalidateQueries({queryKey:hi().queryKey}),t.invalidateQueries({queryKey:["vc","diff"]}),t.invalidateQueries({queryKey:["vc","diffs"]}),n?.(...o)},...r,mutationFn:kG})},AG=(e={})=>{const{apiClient:t}=Be.getState();return t?t.request(rr.PUSH,e):Promise.reject(new Error("Not connected"))},RG=({mutationConfig:e}={})=>{const t=cn(),{onSuccess:n,...r}=e??{};return wn({onSuccess(...o){t.invalidateQueries({queryKey:hi().queryKey}),t.invalidateQueries({queryKey:Ja().queryKey}),n?.(...o)},...r,mutationFn:AG})},NG=(e={})=>{const{apiClient:t}=Be.getState();return t?t.request(rr.RESET,e):Promise.reject(new Error("Not connected"))},OG=({mutationConfig:e}={})=>{const t=cn(),{onSuccess:n,...r}=e??{};return wn({onSuccess(...o){t.invalidateQueries({queryKey:hi().queryKey}),n?.(...o)},...r,mutationFn:NG})};function jG(e){return e.status==="unmerged"?"merge":e.isStaged?"staged":"unstaged"}function Zh(e){return`${jG(e)}:${e.path}`}const q1="Please sign in to use sync feature";function MC(e,t){return t?e:p.jsxs(_s,{children:[p.jsx(Ds,{render:p.jsx("span",{tabIndex:0}),children:e}),p.jsx(Is,{children:q1})]})}function MG({ahead:e=0,behind:t=0,branch:n,hasTracking:r,isAborting:o=!1,isAuthenticated:a,isPulling:l,isPushing:c,mergeInProgress:f=!1,onAbortMerge:d,onPull:g,onPush:h}){const y=l||c||o,x=a?r?"Pull from upstream":"No upstream tracking branch":q1,v=a?r?"Push to upstream":"Push and set upstream":q1,S=p.jsxs(De,{className:"h-7 gap-1 px-2 text-sm",disabled:y||!r||!a,onClick:g,size:"sm",title:x,variant:"ghost",children:[l?p.jsx(ai,{className:"size-3.5 animate-spin"}):p.jsx(AH,{className:"size-3.5"}),t>0&&p.jsx("span",{className:"text-sm tabular-nums",children:t})]}),E=p.jsxs(De,{className:"h-7 gap-1 px-2 text-sm",disabled:y||!a,onClick:h,size:"sm",title:v,variant:"ghost",children:[c?p.jsx(ai,{className:"size-3.5 animate-spin"}):p.jsx(MH,{className:"size-3.5"}),e>0&&p.jsx("span",{className:"text-sm tabular-nums",children:e})]});return p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"text-muted-foreground flex min-w-0 items-center gap-1.5",children:[p.jsx(jx,{className:"size-4 shrink-0"}),p.jsx("span",{className:"truncate text-sm font-medium",children:n??"(detached)"})]}),p.jsxs("div",{className:"flex items-center gap-0.5",children:[f&&d&&p.jsxs(De,{className:"text-destructive h-7 gap-1 px-2 text-sm hover:bg-destructive/10 hover:text-destructive",disabled:y,onClick:d,size:"sm",title:"Abort merge",variant:"ghost",children:[o?p.jsx(ai,{className:"size-3.5 animate-spin"}):p.jsx(eU,{className:"size-3.5"}),p.jsx("span",{children:"Abort"})]}),MC(S,a),MC(E,a)]})]})}function LG({canCommit:e,isCommitting:t,message:n,onCommit:r,onMessageChange:o}){const a=l=>{(l.metaKey||l.ctrlKey)&&l.key==="Enter"&&(l.preventDefault(),r())};return p.jsxs("div",{className:"flex flex-col gap-2",children:[p.jsx(Fx,{className:"min-h-20 resize-none",onChange:l=>o(l.target.value),onKeyDown:a,placeholder:"Commit message (Cmd/Ctrl+Enter to commit)",value:n}),p.jsx(De,{className:"w-full gap-2",disabled:!e||!n.trim()||t,onClick:r,size:"sm",children:"Commit"})]})}const _G=e=>{const{apiClient:t}=Be.getState();return t?t.request(rr.DIFF,e):Promise.reject(new Error("Not connected"))},DG=e=>({queryFn:()=>_G(e),queryKey:["vc","diff",e.path,e.side],staleTime:0}),IG=({enabled:e=!0,path:t,queryConfig:n,side:r})=>br({...DG({path:t,side:r}),enabled:e&&!!t,...n});function J9({file:e,onOpenFile:t,onStageToggle:n}){const r=e.isStaged?"Unstage":"Stage",o=e.isStaged?Mx:Xa,a=e.status==="deleted";return p.jsxs("div",{className:"border-border bg-muted sticky top-0 z-10 flex items-center gap-2 border-b px-3 py-1.5",children:[p.jsx(c0,{className:"text-primary-foreground size-4 shrink-0",strokeWidth:2}),p.jsx("span",{className:"text-foreground flex-1 truncate font-mono text-xs",children:e.path}),p.jsx(De,{className:"size-6 transition-colors hover:bg-foreground/15 dark:hover:bg-foreground/15 hover:text-foreground",disabled:a,onClick:t,size:"icon-xs",title:a?"File no longer exists":"Open file",variant:"ghost",children:p.jsx(aU,{className:"size-3"})}),p.jsx(De,{className:"size-6 transition-colors hover:bg-foreground/15 dark:hover:bg-foreground/15 hover:text-foreground",onClick:n,size:"icon-xs",title:r,variant:"ghost",children:p.jsx(o,{className:"size-3"})})]})}var T2={exports:{}};var LC;function zG(){return LC||(LC=1,(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var a="",l=0;l<arguments.length;l++){var c=arguments[l];c&&(a=o(a,r(c)))}return a}function r(a){if(typeof a=="string"||typeof a=="number")return a;if(typeof a!="object")return"";if(Array.isArray(a))return n.apply(null,a);if(a.toString!==Object.prototype.toString&&!a.toString.toString().includes("[native code]"))return a.toString();var l="";for(var c in a)t.call(a,c)&&a[c]&&(l=o(l,c));return l}function o(a,l){return l?a?a+" "+l:a+l:a}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(T2)),T2.exports}var PG=zG();const Hi=uc(PG);var _C=Number.isNaN||function(t){return typeof t=="number"&&t!==t};function FG(e,t){return!!(e===t||_C(e)&&_C(t))}function BG(e,t){if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(!FG(e[n],t[n]))return!1;return!0}function HG(e,t){t===void 0&&(t=BG);var n=null;function r(){for(var o=[],a=0;a<arguments.length;a++)o[a]=arguments[a];if(n&&n.lastThis===this&&t(o,n.lastArgs))return n.lastResult;var l=e.apply(this,o);return n={lastResult:l,lastArgs:o,lastThis:this},l}return r.clear=function(){n=null},r}function UG(e,t,n){let r=0,o;const a={},l=[];return e.forEach((c,f)=>{const d=t.some(g=>g>=f-n&&g<=f+n);!d&&o===void 0?(o={index:r,startLine:f,endLine:f,lines:1},l.push(o),a[f]=o.index,r++):!d&&o?(o.endLine=f,o.lines++,a[f]=o.index):o=void 0}),{lineBlocks:a,blocks:l}}class Xo{diff(t,n,r={}){let o;typeof r=="function"?(o=r,r={}):"callback"in r&&(o=r.callback);const a=this.castInput(t,r),l=this.castInput(n,r),c=this.removeEmpty(this.tokenize(a,r)),f=this.removeEmpty(this.tokenize(l,r));return this.diffWithOptionsObj(c,f,r,o)}diffWithOptionsObj(t,n,r,o){var a;const l=T=>{if(T=this.postProcess(T,r),o){setTimeout(function(){o(T)},0);return}else return T},c=n.length,f=t.length;let d=1,g=c+f;r.maxEditLength!=null&&(g=Math.min(g,r.maxEditLength));const h=(a=r.timeout)!==null&&a!==void 0?a:1/0,y=Date.now()+h,x=[{oldPos:-1,lastComponent:void 0}];let v=this.extractCommon(x[0],n,t,0,r);if(x[0].oldPos+1>=f&&v+1>=c)return l(this.buildValues(x[0].lastComponent,n,t));let S=-1/0,E=1/0;const k=()=>{for(let T=Math.max(S,-d);T<=Math.min(E,d);T+=2){let R;const L=x[T-1],j=x[T+1];L&&(x[T-1]=void 0);let N=!1;if(j){const D=j.oldPos-T;N=j&&0<=D&&D<c}const A=L&&L.oldPos+1<f;if(!N&&!A){x[T]=void 0;continue}if(!A||N&&L.oldPos<j.oldPos?R=this.addToPath(j,!0,!1,0,r):R=this.addToPath(L,!1,!0,1,r),v=this.extractCommon(R,n,t,T,r),R.oldPos+1>=f&&v+1>=c)return l(this.buildValues(R.lastComponent,n,t))||!0;x[T]=R,R.oldPos+1>=f&&(E=Math.min(E,T-1)),v+1>=c&&(S=Math.max(S,T+1))}d++};if(o)(function T(){setTimeout(function(){if(d>g||Date.now()>y)return o(void 0);k()||T()},0)})();else for(;d<=g&&Date.now()<=y;){const T=k();if(T)return T}}addToPath(t,n,r,o,a){const l=t.lastComponent;return l&&!a.oneChangePerToken&&l.added===n&&l.removed===r?{oldPos:t.oldPos+o,lastComponent:{count:l.count+1,added:n,removed:r,previousComponent:l.previousComponent}}:{oldPos:t.oldPos+o,lastComponent:{count:1,added:n,removed:r,previousComponent:l}}}extractCommon(t,n,r,o,a){const l=n.length,c=r.length;let f=t.oldPos,d=f-o,g=0;for(;d+1<l&&f+1<c&&this.equals(r[f+1],n[d+1],a);)d++,f++,g++,a.oneChangePerToken&&(t.lastComponent={count:1,previousComponent:t.lastComponent,added:!1,removed:!1});return g&&!a.oneChangePerToken&&(t.lastComponent={count:g,previousComponent:t.lastComponent,added:!1,removed:!1}),t.oldPos=f,d}equals(t,n,r){return r.comparator?r.comparator(t,n):t===n||!!r.ignoreCase&&t.toLowerCase()===n.toLowerCase()}removeEmpty(t){const n=[];for(let r=0;r<t.length;r++)t[r]&&n.push(t[r]);return n}castInput(t,n){return t}tokenize(t,n){return Array.from(t)}join(t){return t.join("")}postProcess(t,n){return t}get useLongestToken(){return!1}buildValues(t,n,r){const o=[];let a;for(;t;)o.push(t),a=t.previousComponent,delete t.previousComponent,t=a;o.reverse();const l=o.length;let c=0,f=0,d=0;for(;c<l;c++){const g=o[c];if(g.removed)g.value=this.join(r.slice(d,d+g.count)),d+=g.count;else{if(!g.added&&this.useLongestToken){let h=n.slice(f,f+g.count);h=h.map(function(y,x){const v=r[d+x];return v.length>y.length?v:y}),g.value=this.join(h)}else g.value=this.join(n.slice(f,f+g.count));f+=g.count,g.added||(d+=g.count)}}return o}}class qG extends Xo{}const e8=new qG;function VG(e,t,n){return e8.diff(e,t,n)}function DC(e,t){let n;for(n=0;n<e.length&&n<t.length;n++)if(e[n]!=t[n])return e.slice(0,n);return e.slice(0,n)}function IC(e,t){let n;if(!e||!t||e[e.length-1]!=t[t.length-1])return"";for(n=0;n<e.length&&n<t.length;n++)if(e[e.length-(n+1)]!=t[t.length-(n+1)])return e.slice(-n);return e.slice(-n)}function V1(e,t,n){if(e.slice(0,t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't start with prefix ${JSON.stringify(t)}; this is a bug`);return n+e.slice(t.length)}function $1(e,t,n){if(!t)return e+n;if(e.slice(-t.length)!=t)throw Error(`string ${JSON.stringify(e)} doesn't end with suffix ${JSON.stringify(t)}; this is a bug`);return e.slice(0,-t.length)+n}function ku(e,t){return V1(e,t,"")}function Rh(e,t){return $1(e,t,"")}function zC(e,t){return t.slice(0,$G(e,t))}function $G(e,t){let n=0;e.length>t.length&&(n=e.length-t.length);let r=t.length;e.length<t.length&&(r=e.length);const o=Array(r);let a=0;o[0]=0;for(let l=1;l<r;l++){for(t[l]==t[a]?o[l]=o[a]:o[l]=a;a>0&&t[l]!=t[a];)a=o[a];t[l]==t[a]&&a++}a=0;for(let l=n;l<e.length;l++){for(;a>0&&e[l]!=t[a];)a=o[a];e[l]==t[a]&&a++}return a}function GG(e){return e.includes(`\r
24
24
  `)&&!e.startsWith(`
25
25
  `)&&!e.match(/[^\r]\n/)}function YG(e){return!e.includes(`\r
26
26
  `)&&e.includes(`