@openchambery/web 1.18.2-beta.21 → 1.18.2-beta.22
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.
- package/dist/assets/{AssistantView-C00aiEHK.js → AssistantView-CtZBxoNs.js} +1 -1
- package/dist/assets/{ChatContainer-BDFeDKu-.js → ChatContainer-CUxixWbF.js} +4 -4
- package/dist/assets/{DiagramView-CUfSFI3e.js → DiagramView-B_URybL6.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-Cen6E9Lj.js → MarkdownRendererImpl-ClTZdXct.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-DILi0tN7.js → MobileDetailNavigation-Bg_QuPCN.js} +1 -1
- package/dist/assets/{MobileShareBridge-PZMRiieI.js → MobileShareBridge-DP4-LZKB.js} +1 -1
- package/dist/assets/{MobileSurface-BLYcR0tO.js → MobileSurface-DjE0DFPy.js} +1 -1
- package/dist/assets/{MultiRunWindow-D_2mWZyv.js → MultiRunWindow-BWJTp2mP.js} +1 -1
- package/dist/assets/{OverlayScrollbar-BgMLtMIq.js → OverlayScrollbar-D0aykf8w.js} +1 -1
- package/dist/assets/{SettingsView-CbDBfQp1.js → SettingsView-CxIn8jOU.js} +1 -1
- package/dist/assets/{SettingsWindow-Br7XLcSd.js → SettingsWindow-DjaNXoSr.js} +1 -1
- package/dist/assets/{TerminalView-CM5jRKlj.js → TerminalView-TfQ5AI2f.js} +1 -1
- package/dist/assets/{ToolOutputDialog-D3U6aTZ4.js → ToolOutputDialog-DwVj8WhR.js} +1 -1
- package/dist/assets/{appThemeRegistry-CDxBJNNB.js → appThemeRegistry-BTpLc0Dw.js} +2 -2
- package/dist/assets/assistant-guide-hero-wide-DiFIThB0.jpg +0 -0
- package/dist/assets/{context-menu-DBOMervd.js → context-menu-driZcAh3.js} +1 -1
- package/dist/assets/{gitApi-BQT3QXD2.js → gitApi-Cr1re1sZ.js} +1 -1
- package/dist/assets/{insertionBoundaries-9a0RuIDc.js → insertionBoundaries-BHK-Bd6c.js} +1 -1
- package/dist/assets/{main-CEqSDnE2.js → main-Bz4UukUL.js} +2 -2
- package/dist/assets/{main-BGfX81Y9.js → main-DzHN_R4D.js} +4 -4
- package/dist/assets/{miniChat-CKucSAhg.js → miniChat-CY_LkYn7.js} +2 -2
- package/dist/assets/{mobile-C4bTWKry.js → mobile-LsRJWpN7.js} +2 -2
- package/dist/assets/{multirun-DeNtSkgb.js → multirun-pSiFybLw.js} +1 -1
- package/dist/assets/{projectMeta-BunN9pH5.js → projectMeta-DH0IEQHg.js} +1 -1
- package/dist/assets/{radio-Bziafaje.js → radio-DsGscCu_.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-D8-FDgWE.js → renderElectronMiniChatApp-DTk_DBUw.js} +2 -2
- package/dist/assets/{renderMobileApp-CdU0aJ-e.js → renderMobileApp-ByumNb1Q.js} +5 -5
- package/dist/assets/{runtimeEndpointReset-CK1GhIsm.js → runtimeEndpointReset-CbZpulBG.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-pWlBorwQ.js → sortable-tabs-strip-qJ3tLNRa.js} +1 -1
- package/dist/assets/{src-8kQFmtjw.css → src-7UHu0sNZ.css} +1 -1
- package/dist/assets/{useAppFontEffects-IEUQDvE8.js → useAppFontEffects-DhfF1q-x.js} +2 -2
- package/dist/assets/{useDesktopWindowControlsLayout-MlqJX89k.js → useDesktopWindowControlsLayout-CrKo33uu.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-GbhkdO6m.js → useEffectiveDirectory-D5FMrbsN.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-DQHF_ETu.js → useMobileNavigationStore-HUex-0LO.js} +1 -1
- package/dist/assets/{useSessionAutoCleanup-BuU_S_Sh.js → useSessionAutoCleanup-D5Jpkm06.js} +1 -1
- package/dist/assets/{useWorkerHighlightedLines-Ca6OgNHF.js → useWorkerHighlightedLines-DcCyCsC2.js} +1 -1
- package/dist/index.html +2 -2
- package/dist/mini-chat.html +2 -2
- package/dist/mobile.html +2 -2
- package/package.json +1 -1
- package/dist/assets/assistant-guide-hero-BeUHQcxE.jpg +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{$t as t,Xt as n}from"./persistence-D1lIuyqO.js";import{nt as r,rt as i}from"./vendor-base-ui-CnHfUmDN.js";import{n as a}from"./vendor-react-DLPElpoQ.js";import{jo as o}from"./useMobileNavigationStore-DQHF_ETu.js";import{t as s}from"./utils-BxJEIWv5.js";var c=a(),l=e(i(),1),u={xs:0,sm:640,md:768,lg:1024,xl:1280,"2xl":1536},d={isMobile:!1,isTablet:!1,isDesktop:!0,deviceType:`desktop`,screenWidth:1024,breakpoint:`lg`,hasTouchInput:!1,hasTouchOnlyPointer:!1},ee=()=>typeof window>`u`?!1:new URLSearchParams(window.location.search).get(`surface`)===`desktop`,f=e=>{if(typeof navigator>`u`)return{isExplicitTablet:!1};let t=navigator.userAgent||``,n=navigator.platform||``,r=/iPad/i.test(t)||(/Macintosh|MacIntel/i.test(t)||/MacIntel/i.test(n))&&e>1,i=/Android/i.test(t)&&!/Mobile/i.test(t),a=/Tablet/i.test(t);return{isExplicitTablet:r||i||a}},p=(e,t,n)=>{if(typeof window>`u`)return;let r=document.documentElement,i=t===`mobile`,a=t===`tablet`;r.classList.remove(`device-mobile`,`device-tablet`,`device-desktop`),r.classList.add(t===`mobile`?`device-mobile`:t===`tablet`?`device-tablet`:`device-desktop`),e?(r.classList.add(`desktop-runtime`),r.style.setProperty(`--is-mobile`,`0`),r.style.setProperty(`--device-type`,`desktop`),r.style.setProperty(`--font-scale`,`1`),r.style.setProperty(`--has-coarse-pointer`,`0`),r.style.setProperty(`--has-touch-input`,`0`),r.classList.remove(`mobile-pointer`)):(r.classList.remove(`desktop-runtime`),r.style.setProperty(`--is-mobile`,i?`1`:`0`),r.style.setProperty(`--device-type`,t),r.style.setProperty(`--font-scale`,i?`0.9`:a?`0.95`:`1`),r.style.setProperty(`--has-coarse-pointer`,n?`1`:`0`),r.style.setProperty(`--has-touch-input`,n?`1`:`0`),n?r.classList.add(`mobile-pointer`):r.classList.remove(`mobile-pointer`))};function m(){let e=window.innerWidth,r=typeof window.matchMedia==`function`,i=r?window.matchMedia(`(pointer: coarse)`):null,a=r?window.matchMedia(`(hover: none)`):null,s=i?.matches??!1,c=a?.matches??!1,l=typeof navigator<`u`?navigator.maxTouchPoints??0:0,d=n()||t()||ee(),{isExplicitTablet:m}=f(l),h=s||c||l>0,g=s||c,_=e>u.md&&e<=u.lg,v=e<=u.md,y=h&&v,b=h&&!y&&(_||m),x=!h||!b&&e>u.lg,S=`desktop`;d?(y=!1,b=!1,x=!0,S=`desktop`):o()?(y=!0,b=!1,x=!1,S=`mobile`):y?S=`mobile`:b?S=`tablet`:(x=!0,S=`desktop`),p(d,S,h);let C=`xs`;for(let[t,n]of Object.entries(u))e>=n&&(C=t);return{isMobile:y,isTablet:b,isDesktop:x,deviceType:S,screenWidth:e,breakpoint:C,hasTouchInput:h,hasTouchOnlyPointer:g}}var h=(e,t)=>e.isMobile===t.isMobile&&e.isTablet===t.isTablet&&e.isDesktop===t.isDesktop&&e.deviceType===t.deviceType&&e.screenWidth===t.screenWidth&&e.breakpoint===t.breakpoint&&e.hasTouchInput===t.hasTouchInput&&e.hasTouchOnlyPointer===t.hasTouchOnlyPointer,g=new Set,_=null,v,y=null,b=()=>typeof window>`u`?d:(_||=m(),_),x=()=>{for(let e of g)e()},S=()=>{v=void 0;let e=m();_&&h(_,e)||(_=e,x())},C=()=>{typeof window>`u`||v!==void 0||(v=window.requestAnimationFrame(S))},w=(e,t)=>e?typeof e.addEventListener==`function`?(e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)):typeof e.addListener==`function`?(e.addListener(t),()=>e.removeListener(t)):()=>{}:()=>{},te=()=>{if(typeof window>`u`)return()=>{};_=m(),window.addEventListener(`resize`,C);let e=typeof window.matchMedia==`function`?window.matchMedia(`(pointer: coarse)`):null,t=typeof window.matchMedia==`function`?window.matchMedia(`(hover: none)`):null,n=w(e,C),r=w(t,C);return()=>{window.removeEventListener(`resize`,C),n(),r(),v!==void 0&&(window.cancelAnimationFrame(v),v=void 0)}},T=e=>typeof window>`u`?()=>{}:(g.add(e),y||=te(),()=>{g.delete(e),g.size===0&&y&&(y(),y=null,_=null)});function E(){if(typeof window>`u`||typeof window<`u`&&n())return!1;let e=document.documentElement,t=e.style.getPropertyValue(`--is-mobile`)||getComputedStyle(e).getPropertyValue(`--is-mobile`);return t===`1`||t===`true`}var D=()=>typeof window>`u`?!1:!!(navigator.standalone===!0||window.matchMedia?.(`(display-mode: standalone)`)?.matches||window.matchMedia?.(`(display-mode: fullscreen)`)?.matches),O=()=>{if(typeof window>`u`||n())return!1;let e=typeof navigator<`u`?navigator.maxTouchPoints??0:0;return D()&&e>0&&window.innerWidth>u.md};function ne(){let e=(0,c.c)(2),[t,n]=l.useState(re),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{if(typeof window>`u`)return;let e=()=>n(O()),t=window.matchMedia?.(`(display-mode: standalone)`),r=window.matchMedia?.(`(display-mode: fullscreen)`);e(),window.addEventListener(`resize`,e),window.addEventListener(`focus`,e);let i=t=>{t&&(typeof t.addEventListener==`function`?t.addEventListener(`change`,e):typeof t.addListener==`function`&&t.addListener(e))},a=t=>{t&&(typeof t.removeEventListener==`function`?t.removeEventListener(`change`,e):typeof t.removeListener==`function`&&t.removeListener(e))};return i(t),i(r),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`focus`,e),a(t),a(r)}},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),l.useEffect(r,i),t}function re(){return O()}var k=()=>typeof window>`u`?`portrait`:window.matchMedia?.(`(orientation: landscape)`)?.matches?`landscape`:`portrait`;function ie(){let e=(0,c.c)(2),[t,n]=l.useState(k),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(orientation: landscape)`),t=()=>n(e.matches?`landscape`:`portrait`);return t(),w(e,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),l.useEffect(r,i),t}function ae(){return l.useSyncExternalStore(T,b,A)}function A(){return d}var oe=r(),se=1e3,j=.5,ce={length:0,offset:0},le=(e,t)=>Math.abs(e.length-t.length)<j&&Math.abs(e.offset-t.offset)<j,M=e=>{let t=(0,c.c)(66),{containerRef:n,minThumbSize:r,hideDelayMs:i,className:a,disableHorizontal:o,observeMutations:u,suppressVisibility:d,userIntentOnly:ee}=e,f=r===void 0?32:r,p=i===void 0?1e3:i,m=o!==void 0&&o,h=u===void 0||u,g=d!==void 0&&d,_=ee!==void 0&&ee,[v,y]=l.useState(!1),b;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(b={length:0,offset:0},t[0]=b):b=t[0];let[x,S]=l.useState(b),C;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(C={length:0,offset:0},t[1]=C):C=t[1];let[w,te]=l.useState(C),T=l.useRef(null),E=l.useRef(null),D=l.useRef(null),O=l.useRef(!1),ne=l.useRef(!1),re=l.useRef(0),k;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(k={pointerX:0,pointerY:0,scrollTop:0,scrollLeft:0},t[2]=k):k=t[2];let ie=l.useRef(k),ae=l.useRef(null),A;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(A=new Set,t[3]=A):A=t[3];let j=l.useRef(A),M;t[4]!==n||t[5]!==m||t[6]!==f?(M=()=>{let e=n.current;if(!e)return;let{scrollHeight:t,clientHeight:r,scrollTop:i,scrollWidth:a,clientWidth:o,scrollLeft:s}=e,c=ce;if(t>r){let e=Math.max(r-16,0),n=r/t*e,a=Math.max(f,Math.min(e,n)),o=Math.max(e-a,0);c={length:a,offset:i/Math.max(t-r,1)*o}}S(e=>le(e,c)?e:c);let l=ce;if(!m&&a>o){let e=Math.max(o-16,0),t=o/a*e,n=Math.max(f,Math.min(e,t)),r=Math.max(e-n,0);l={length:n,offset:s/Math.max(a-o,1)*r}}te(e=>le(e,l)?e:l)},t[4]=n,t[5]=m,t[6]=f,t[7]=M):M=t[7];let N=M,ue;t[8]===N?ue=t[9]:(ue=()=>{D.current===null&&(D.current=requestAnimationFrame(()=>{D.current=null,N()}))},t[8]=N,t[9]=ue);let P=ue,F;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(F=(e,t)=>{if(!t){j.current.clear();return}let n=new Set;n.add(e),Array.from(e.children).forEach(e=>{n.add(e)}),j.current.forEach(e=>{n.has(e)||t.unobserve(e)}),n.forEach(e=>{j.current.has(e)||t.observe(e)}),j.current=n},t[10]=F):F=t[10];let de=F,I;t[11]===p?I=t[12]:(I=()=>{T.current&&clearTimeout(T.current),!ne.current&&(T.current=setTimeout(()=>y(!1),p))},t[11]=p,t[12]=I);let L=I,R;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(R=()=>{re.current=Date.now()},t[13]=R):R=t[13];let z=R,B;t[14]!==L||t[15]!==g||t[16]!==N||t[17]!==_?(B=()=>{E.current&&cancelAnimationFrame(E.current),E.current=requestAnimationFrame(()=>{if(N(),g&&!O.current){y(!1);return}if(_&&!O.current&&!(Date.now()-re.current<=se)){y(!1);return}y(!0),L()})},t[14]=L,t[15]=g,t[16]=N,t[17]=_,t[18]=B):B=t[18];let V=B,H,U;t[19]!==n||t[20]!==V||t[21]!==h||t[22]!==P||t[23]!==N||t[24]!==_?(H=()=>{let e=n.current;if(!e)return;N(),y(!1);let t=()=>V(),r=e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`PageUp`||e.key===`PageDown`||e.key===`Home`||e.key===`End`||e.key===` `)&&z()};e.addEventListener(`scroll`,t,{passive:!0}),_&&(e.addEventListener(`wheel`,z,{passive:!0}),e.addEventListener(`touchstart`,z,{passive:!0}),e.addEventListener(`touchmove`,z,{passive:!0}),e.addEventListener(`keydown`,r));let i=typeof ResizeObserver<`u`?new ResizeObserver(()=>{P()}):null;de(e,i);let a=h&&typeof MutationObserver<`u`?new MutationObserver(()=>{de(e,i),P()}):null;a?.observe(e,{childList:!0});let o=()=>P(),s=()=>P();return e.addEventListener(`input`,o,!0),e.addEventListener(`load`,s,!0),()=>{e.removeEventListener(`scroll`,t),e.removeEventListener(`input`,o,!0),e.removeEventListener(`load`,s,!0),_&&(e.removeEventListener(`wheel`,z),e.removeEventListener(`touchstart`,z),e.removeEventListener(`touchmove`,z),e.removeEventListener(`keydown`,r)),i?.disconnect(),a?.disconnect(),j.current.clear(),T.current&&clearTimeout(T.current),E.current&&cancelAnimationFrame(E.current),D.current&&cancelAnimationFrame(D.current)}},U=[n,V,z,h,P,de,N,_],t[19]=n,t[20]=V,t[21]=h,t[22]=P,t[23]=N,t[24]=_,t[25]=H,t[26]=U):(H=t[25],U=t[26]),l.useEffect(H,U);let W,fe;t[27]===g?(W=t[28],fe=t[29]):(W=()=>{g&&(O.current||(y(!1),T.current&&=(clearTimeout(T.current),null)))},fe=[g],t[27]=g,t[28]=W,t[29]=fe),l.useEffect(W,fe);let pe;t[30]===n?pe=t[31]:(pe=(e,t)=>{let r=n.current;r&&(O.current=!0,ie.current={pointerX:e.clientX,pointerY:e.clientY,scrollTop:r.scrollTop,scrollLeft:r.scrollLeft},ae.current=t,z(),y(!0),T.current&&clearTimeout(T.current),e.currentTarget.setPointerCapture(e.pointerId))},t[30]=n,t[31]=pe);let G=pe,me;t[32]!==n||t[33]!==w.length||t[34]!==x.length?(me=e=>{if(!O.current)return;let t=n.current;if(!t)return;let r=ae.current;if(r===`vertical`){let{pointerY:n,scrollTop:r}=ie.current,i=e.clientY-n,a=t.clientHeight,o=Math.max(a-x.length,1),s=Math.max(t.scrollHeight-t.clientHeight,1);t.scrollTop=r+i/o*s}else if(r===`horizontal`){let{pointerX:n,scrollLeft:r}=ie.current,i=e.clientX-n,a=t.clientWidth,o=Math.max(a-w.length,1),s=Math.max(t.scrollWidth-t.clientWidth,1);t.scrollLeft=r+i/o*s}},t[32]=n,t[33]=w.length,t[34]=x.length,t[35]=me):me=t[35];let K=me,he;t[36]===L?he=t[37]:(he=e=>{O.current&&(O.current=!1,e.currentTarget.releasePointerCapture(e.pointerId),L())},t[36]=L,t[37]=he);let q=he,ge;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(ge=()=>{ne.current=!0,T.current&&=(clearTimeout(T.current),null)},t[38]=ge):ge=t[38];let _e=ge,J;t[39]===L?J=t[40]:(J=()=>{ne.current=!1,L()},t[39]=L,t[40]=J);let Y=J,ve=x.length>0,ye=w.length>0;if(!ve&&!ye)return null;let X;t[41]===a?X=t[42]:(X=s(`overlay-scrollbar`,a),t[41]=a,t[42]=X);let be=+!!v,Z;t[43]===be?Z=t[44]:(Z={opacity:be},t[43]=be,t[44]=Z);let Q;t[45]!==G||t[46]!==K||t[47]!==q||t[48]!==Y||t[49]!==ve||t[50]!==x.length||t[51]!==x.offset?(Q=ve&&(0,oe.jsx)(`div`,{className:`overlay-scrollbar__thumb overlay-scrollbar__thumb--vertical`,"data-overlay-scrollbar-thumb":`vertical`,style:{height:`${x.length}px`,top:`${8+x.offset}px`,right:`4px`},onPointerDown:e=>G(e,`vertical`),onPointerMove:K,onPointerUp:q,onPointerCancel:q,onMouseEnter:_e,onMouseLeave:Y}),t[45]=G,t[46]=K,t[47]=q,t[48]=Y,t[49]=ve,t[50]=x.length,t[51]=x.offset,t[52]=Q):Q=t[52];let $;t[53]!==G||t[54]!==K||t[55]!==q||t[56]!==Y||t[57]!==w.length||t[58]!==w.offset||t[59]!==ye?($=ye&&(0,oe.jsx)(`div`,{className:`overlay-scrollbar__thumb overlay-scrollbar__thumb--horizontal`,"data-overlay-scrollbar-thumb":`horizontal`,style:{width:`${w.length}px`,left:`${8+w.offset}px`,bottom:`4px`},onPointerDown:e=>G(e,`horizontal`),onPointerMove:K,onPointerUp:q,onPointerCancel:q,onMouseEnter:_e,onMouseLeave:Y}),t[53]=G,t[54]=K,t[55]=q,t[56]=Y,t[57]=w.length,t[58]=w.offset,t[59]=ye,t[60]=$):$=t[60];let xe;return t[61]!==X||t[62]!==Z||t[63]!==Q||t[64]!==$?(xe=(0,oe.jsxs)(`div`,{className:X,"aria-hidden":`true`,style:Z,children:[Q,$]}),t[61]=X,t[62]=Z,t[63]=Q,t[64]=$,t[65]=xe):xe=t[65],xe};M.displayName=`OverlayScrollbar`;var N=M;export{ie as a,ae as i,m as n,ne as o,E as r,N as t};
|
|
1
|
+
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{$t as t,Xt as n}from"./persistence-D1lIuyqO.js";import{nt as r,rt as i}from"./vendor-base-ui-CnHfUmDN.js";import{n as a}from"./vendor-react-DLPElpoQ.js";import{jo as o}from"./useMobileNavigationStore-HUex-0LO.js";import{t as s}from"./utils-BxJEIWv5.js";var c=a(),l=e(i(),1),u={xs:0,sm:640,md:768,lg:1024,xl:1280,"2xl":1536},d={isMobile:!1,isTablet:!1,isDesktop:!0,deviceType:`desktop`,screenWidth:1024,breakpoint:`lg`,hasTouchInput:!1,hasTouchOnlyPointer:!1},ee=()=>typeof window>`u`?!1:new URLSearchParams(window.location.search).get(`surface`)===`desktop`,f=e=>{if(typeof navigator>`u`)return{isExplicitTablet:!1};let t=navigator.userAgent||``,n=navigator.platform||``,r=/iPad/i.test(t)||(/Macintosh|MacIntel/i.test(t)||/MacIntel/i.test(n))&&e>1,i=/Android/i.test(t)&&!/Mobile/i.test(t),a=/Tablet/i.test(t);return{isExplicitTablet:r||i||a}},p=(e,t,n)=>{if(typeof window>`u`)return;let r=document.documentElement,i=t===`mobile`,a=t===`tablet`;r.classList.remove(`device-mobile`,`device-tablet`,`device-desktop`),r.classList.add(t===`mobile`?`device-mobile`:t===`tablet`?`device-tablet`:`device-desktop`),e?(r.classList.add(`desktop-runtime`),r.style.setProperty(`--is-mobile`,`0`),r.style.setProperty(`--device-type`,`desktop`),r.style.setProperty(`--font-scale`,`1`),r.style.setProperty(`--has-coarse-pointer`,`0`),r.style.setProperty(`--has-touch-input`,`0`),r.classList.remove(`mobile-pointer`)):(r.classList.remove(`desktop-runtime`),r.style.setProperty(`--is-mobile`,i?`1`:`0`),r.style.setProperty(`--device-type`,t),r.style.setProperty(`--font-scale`,i?`0.9`:a?`0.95`:`1`),r.style.setProperty(`--has-coarse-pointer`,n?`1`:`0`),r.style.setProperty(`--has-touch-input`,n?`1`:`0`),n?r.classList.add(`mobile-pointer`):r.classList.remove(`mobile-pointer`))};function m(){let e=window.innerWidth,r=typeof window.matchMedia==`function`,i=r?window.matchMedia(`(pointer: coarse)`):null,a=r?window.matchMedia(`(hover: none)`):null,s=i?.matches??!1,c=a?.matches??!1,l=typeof navigator<`u`?navigator.maxTouchPoints??0:0,d=n()||t()||ee(),{isExplicitTablet:m}=f(l),h=s||c||l>0,g=s||c,_=e>u.md&&e<=u.lg,v=e<=u.md,y=h&&v,b=h&&!y&&(_||m),x=!h||!b&&e>u.lg,S=`desktop`;d?(y=!1,b=!1,x=!0,S=`desktop`):o()?(y=!0,b=!1,x=!1,S=`mobile`):y?S=`mobile`:b?S=`tablet`:(x=!0,S=`desktop`),p(d,S,h);let C=`xs`;for(let[t,n]of Object.entries(u))e>=n&&(C=t);return{isMobile:y,isTablet:b,isDesktop:x,deviceType:S,screenWidth:e,breakpoint:C,hasTouchInput:h,hasTouchOnlyPointer:g}}var h=(e,t)=>e.isMobile===t.isMobile&&e.isTablet===t.isTablet&&e.isDesktop===t.isDesktop&&e.deviceType===t.deviceType&&e.screenWidth===t.screenWidth&&e.breakpoint===t.breakpoint&&e.hasTouchInput===t.hasTouchInput&&e.hasTouchOnlyPointer===t.hasTouchOnlyPointer,g=new Set,_=null,v,y=null,b=()=>typeof window>`u`?d:(_||=m(),_),x=()=>{for(let e of g)e()},S=()=>{v=void 0;let e=m();_&&h(_,e)||(_=e,x())},C=()=>{typeof window>`u`||v!==void 0||(v=window.requestAnimationFrame(S))},w=(e,t)=>e?typeof e.addEventListener==`function`?(e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)):typeof e.addListener==`function`?(e.addListener(t),()=>e.removeListener(t)):()=>{}:()=>{},te=()=>{if(typeof window>`u`)return()=>{};_=m(),window.addEventListener(`resize`,C);let e=typeof window.matchMedia==`function`?window.matchMedia(`(pointer: coarse)`):null,t=typeof window.matchMedia==`function`?window.matchMedia(`(hover: none)`):null,n=w(e,C),r=w(t,C);return()=>{window.removeEventListener(`resize`,C),n(),r(),v!==void 0&&(window.cancelAnimationFrame(v),v=void 0)}},T=e=>typeof window>`u`?()=>{}:(g.add(e),y||=te(),()=>{g.delete(e),g.size===0&&y&&(y(),y=null,_=null)});function E(){if(typeof window>`u`||typeof window<`u`&&n())return!1;let e=document.documentElement,t=e.style.getPropertyValue(`--is-mobile`)||getComputedStyle(e).getPropertyValue(`--is-mobile`);return t===`1`||t===`true`}var D=()=>typeof window>`u`?!1:!!(navigator.standalone===!0||window.matchMedia?.(`(display-mode: standalone)`)?.matches||window.matchMedia?.(`(display-mode: fullscreen)`)?.matches),O=()=>{if(typeof window>`u`||n())return!1;let e=typeof navigator<`u`?navigator.maxTouchPoints??0:0;return D()&&e>0&&window.innerWidth>u.md};function ne(){let e=(0,c.c)(2),[t,n]=l.useState(re),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{if(typeof window>`u`)return;let e=()=>n(O()),t=window.matchMedia?.(`(display-mode: standalone)`),r=window.matchMedia?.(`(display-mode: fullscreen)`);e(),window.addEventListener(`resize`,e),window.addEventListener(`focus`,e);let i=t=>{t&&(typeof t.addEventListener==`function`?t.addEventListener(`change`,e):typeof t.addListener==`function`&&t.addListener(e))},a=t=>{t&&(typeof t.removeEventListener==`function`?t.removeEventListener(`change`,e):typeof t.removeListener==`function`&&t.removeListener(e))};return i(t),i(r),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`focus`,e),a(t),a(r)}},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),l.useEffect(r,i),t}function re(){return O()}var k=()=>typeof window>`u`?`portrait`:window.matchMedia?.(`(orientation: landscape)`)?.matches?`landscape`:`portrait`;function ie(){let e=(0,c.c)(2),[t,n]=l.useState(k),r,i;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(orientation: landscape)`),t=()=>n(e.matches?`landscape`:`portrait`);return t(),w(e,t)},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),l.useEffect(r,i),t}function ae(){return l.useSyncExternalStore(T,b,A)}function A(){return d}var oe=r(),se=1e3,j=.5,ce={length:0,offset:0},le=(e,t)=>Math.abs(e.length-t.length)<j&&Math.abs(e.offset-t.offset)<j,M=e=>{let t=(0,c.c)(66),{containerRef:n,minThumbSize:r,hideDelayMs:i,className:a,disableHorizontal:o,observeMutations:u,suppressVisibility:d,userIntentOnly:ee}=e,f=r===void 0?32:r,p=i===void 0?1e3:i,m=o!==void 0&&o,h=u===void 0||u,g=d!==void 0&&d,_=ee!==void 0&&ee,[v,y]=l.useState(!1),b;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(b={length:0,offset:0},t[0]=b):b=t[0];let[x,S]=l.useState(b),C;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(C={length:0,offset:0},t[1]=C):C=t[1];let[w,te]=l.useState(C),T=l.useRef(null),E=l.useRef(null),D=l.useRef(null),O=l.useRef(!1),ne=l.useRef(!1),re=l.useRef(0),k;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(k={pointerX:0,pointerY:0,scrollTop:0,scrollLeft:0},t[2]=k):k=t[2];let ie=l.useRef(k),ae=l.useRef(null),A;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(A=new Set,t[3]=A):A=t[3];let j=l.useRef(A),M;t[4]!==n||t[5]!==m||t[6]!==f?(M=()=>{let e=n.current;if(!e)return;let{scrollHeight:t,clientHeight:r,scrollTop:i,scrollWidth:a,clientWidth:o,scrollLeft:s}=e,c=ce;if(t>r){let e=Math.max(r-16,0),n=r/t*e,a=Math.max(f,Math.min(e,n)),o=Math.max(e-a,0);c={length:a,offset:i/Math.max(t-r,1)*o}}S(e=>le(e,c)?e:c);let l=ce;if(!m&&a>o){let e=Math.max(o-16,0),t=o/a*e,n=Math.max(f,Math.min(e,t)),r=Math.max(e-n,0);l={length:n,offset:s/Math.max(a-o,1)*r}}te(e=>le(e,l)?e:l)},t[4]=n,t[5]=m,t[6]=f,t[7]=M):M=t[7];let N=M,ue;t[8]===N?ue=t[9]:(ue=()=>{D.current===null&&(D.current=requestAnimationFrame(()=>{D.current=null,N()}))},t[8]=N,t[9]=ue);let P=ue,F;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(F=(e,t)=>{if(!t){j.current.clear();return}let n=new Set;n.add(e),Array.from(e.children).forEach(e=>{n.add(e)}),j.current.forEach(e=>{n.has(e)||t.unobserve(e)}),n.forEach(e=>{j.current.has(e)||t.observe(e)}),j.current=n},t[10]=F):F=t[10];let de=F,I;t[11]===p?I=t[12]:(I=()=>{T.current&&clearTimeout(T.current),!ne.current&&(T.current=setTimeout(()=>y(!1),p))},t[11]=p,t[12]=I);let L=I,R;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(R=()=>{re.current=Date.now()},t[13]=R):R=t[13];let z=R,B;t[14]!==L||t[15]!==g||t[16]!==N||t[17]!==_?(B=()=>{E.current&&cancelAnimationFrame(E.current),E.current=requestAnimationFrame(()=>{if(N(),g&&!O.current){y(!1);return}if(_&&!O.current&&!(Date.now()-re.current<=se)){y(!1);return}y(!0),L()})},t[14]=L,t[15]=g,t[16]=N,t[17]=_,t[18]=B):B=t[18];let V=B,H,U;t[19]!==n||t[20]!==V||t[21]!==h||t[22]!==P||t[23]!==N||t[24]!==_?(H=()=>{let e=n.current;if(!e)return;N(),y(!1);let t=()=>V(),r=e=>{(e.key===`ArrowUp`||e.key===`ArrowDown`||e.key===`PageUp`||e.key===`PageDown`||e.key===`Home`||e.key===`End`||e.key===` `)&&z()};e.addEventListener(`scroll`,t,{passive:!0}),_&&(e.addEventListener(`wheel`,z,{passive:!0}),e.addEventListener(`touchstart`,z,{passive:!0}),e.addEventListener(`touchmove`,z,{passive:!0}),e.addEventListener(`keydown`,r));let i=typeof ResizeObserver<`u`?new ResizeObserver(()=>{P()}):null;de(e,i);let a=h&&typeof MutationObserver<`u`?new MutationObserver(()=>{de(e,i),P()}):null;a?.observe(e,{childList:!0});let o=()=>P(),s=()=>P();return e.addEventListener(`input`,o,!0),e.addEventListener(`load`,s,!0),()=>{e.removeEventListener(`scroll`,t),e.removeEventListener(`input`,o,!0),e.removeEventListener(`load`,s,!0),_&&(e.removeEventListener(`wheel`,z),e.removeEventListener(`touchstart`,z),e.removeEventListener(`touchmove`,z),e.removeEventListener(`keydown`,r)),i?.disconnect(),a?.disconnect(),j.current.clear(),T.current&&clearTimeout(T.current),E.current&&cancelAnimationFrame(E.current),D.current&&cancelAnimationFrame(D.current)}},U=[n,V,z,h,P,de,N,_],t[19]=n,t[20]=V,t[21]=h,t[22]=P,t[23]=N,t[24]=_,t[25]=H,t[26]=U):(H=t[25],U=t[26]),l.useEffect(H,U);let W,fe;t[27]===g?(W=t[28],fe=t[29]):(W=()=>{g&&(O.current||(y(!1),T.current&&=(clearTimeout(T.current),null)))},fe=[g],t[27]=g,t[28]=W,t[29]=fe),l.useEffect(W,fe);let pe;t[30]===n?pe=t[31]:(pe=(e,t)=>{let r=n.current;r&&(O.current=!0,ie.current={pointerX:e.clientX,pointerY:e.clientY,scrollTop:r.scrollTop,scrollLeft:r.scrollLeft},ae.current=t,z(),y(!0),T.current&&clearTimeout(T.current),e.currentTarget.setPointerCapture(e.pointerId))},t[30]=n,t[31]=pe);let G=pe,me;t[32]!==n||t[33]!==w.length||t[34]!==x.length?(me=e=>{if(!O.current)return;let t=n.current;if(!t)return;let r=ae.current;if(r===`vertical`){let{pointerY:n,scrollTop:r}=ie.current,i=e.clientY-n,a=t.clientHeight,o=Math.max(a-x.length,1),s=Math.max(t.scrollHeight-t.clientHeight,1);t.scrollTop=r+i/o*s}else if(r===`horizontal`){let{pointerX:n,scrollLeft:r}=ie.current,i=e.clientX-n,a=t.clientWidth,o=Math.max(a-w.length,1),s=Math.max(t.scrollWidth-t.clientWidth,1);t.scrollLeft=r+i/o*s}},t[32]=n,t[33]=w.length,t[34]=x.length,t[35]=me):me=t[35];let K=me,he;t[36]===L?he=t[37]:(he=e=>{O.current&&(O.current=!1,e.currentTarget.releasePointerCapture(e.pointerId),L())},t[36]=L,t[37]=he);let q=he,ge;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(ge=()=>{ne.current=!0,T.current&&=(clearTimeout(T.current),null)},t[38]=ge):ge=t[38];let _e=ge,J;t[39]===L?J=t[40]:(J=()=>{ne.current=!1,L()},t[39]=L,t[40]=J);let Y=J,ve=x.length>0,ye=w.length>0;if(!ve&&!ye)return null;let X;t[41]===a?X=t[42]:(X=s(`overlay-scrollbar`,a),t[41]=a,t[42]=X);let be=+!!v,Z;t[43]===be?Z=t[44]:(Z={opacity:be},t[43]=be,t[44]=Z);let Q;t[45]!==G||t[46]!==K||t[47]!==q||t[48]!==Y||t[49]!==ve||t[50]!==x.length||t[51]!==x.offset?(Q=ve&&(0,oe.jsx)(`div`,{className:`overlay-scrollbar__thumb overlay-scrollbar__thumb--vertical`,"data-overlay-scrollbar-thumb":`vertical`,style:{height:`${x.length}px`,top:`${8+x.offset}px`,right:`4px`},onPointerDown:e=>G(e,`vertical`),onPointerMove:K,onPointerUp:q,onPointerCancel:q,onMouseEnter:_e,onMouseLeave:Y}),t[45]=G,t[46]=K,t[47]=q,t[48]=Y,t[49]=ve,t[50]=x.length,t[51]=x.offset,t[52]=Q):Q=t[52];let $;t[53]!==G||t[54]!==K||t[55]!==q||t[56]!==Y||t[57]!==w.length||t[58]!==w.offset||t[59]!==ye?($=ye&&(0,oe.jsx)(`div`,{className:`overlay-scrollbar__thumb overlay-scrollbar__thumb--horizontal`,"data-overlay-scrollbar-thumb":`horizontal`,style:{width:`${w.length}px`,left:`${8+w.offset}px`,bottom:`4px`},onPointerDown:e=>G(e,`horizontal`),onPointerMove:K,onPointerUp:q,onPointerCancel:q,onMouseEnter:_e,onMouseLeave:Y}),t[53]=G,t[54]=K,t[55]=q,t[56]=Y,t[57]=w.length,t[58]=w.offset,t[59]=ye,t[60]=$):$=t[60];let xe;return t[61]!==X||t[62]!==Z||t[63]!==Q||t[64]!==$?(xe=(0,oe.jsxs)(`div`,{className:X,"aria-hidden":`true`,style:Z,children:[Q,$]}),t[61]=X,t[62]=Z,t[63]=Q,t[64]=$,t[65]=xe):xe=t[65],xe};M.displayName=`OverlayScrollbar`;var N=M;export{ie as a,ae as i,m as n,ne as o,E as r,N as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-C0FnF6B9.js";import{$ as n,D as r,M as i,a,j as o,o as s,r as c,t as l,u,w as d,y as f}from"./useUIStore-5agS8bsW.js";import{$t as p,Bt as m,D as h,E as g,Ht as _,Kt as v,O as y,R as b,Ut as x,Vt as S,Xt as C,Yt as w,a as T,bn as E,cn as D,d as O,en as k,et as A,f as j,gn as M,hn as N,i as P,k as F,kn as I,l as L,mn as R,qt as z,r as B,u as V,un as H,xn as U}from"./persistence-D1lIuyqO.js";import{_ as W,a as ee,g as G,h as te,i as ne,l as re,m as ie,n as ae,p as oe,r as se,t as ce,u as le}from"./desktopHosts-ZK_vkdzL.js";import{r as ue}from"./desktopRelayRestore-CewM6-g5.js";import{a as de,i as fe,r as pe,t as me}from"./vendor-zustand-B4dlGEM2.js";import{nt as he,rt as ge}from"./vendor-base-ui-CnHfUmDN.js";import{kt as _e,yt as ve}from"./gitApiHttp-BxGAFLTf.js";import{n as ye}from"./vendor-react-DLPElpoQ.js";import{s as be}from"./vendor-tanstack-react-query-D7pys_c9.js";import{W as xe}from"./vendor-codemirror-autocomplete-DHomsvW7.js";import{r as Se}from"./vendor-sonner-DVzioF3d.js";import{c as Ce,n as we}from"./vendor-reactuses-core-DDoDDyM9.js";import{n as Te,r as Ee,t as De}from"./clipboard-BnElHSnO.js";import{$a as Oe,Aa as ke,Ao as Ae,Bi as je,Co as Me,Ea as Ne,Ga as Pe,Gi as Fe,Ja as Ie,Ka as Le,Oa as Re,Qa as ze,So as Be,Ui as Ve,Vi as He,Vt as Ue,Wi as We,Xa as Ge,Xi as Ke,Ya as qe,Za as Je,_o as Ye,ai as Xe,ao as Ze,ci as Qe,co as $e,do as et,eo as tt,fo as nt,go as rt,ho as it,hr as at,ii as ot,io as st,ja as ct,jo as lt,ka as ut,lo as dt,mo as ft,no as pt,oo as mt,pi as ht,po as gt,qa as _t,ro as vt,si as yt,so as bt,to as xt,uo as St,vr as K,wo as Ct,xo as wt,yo as Tt,zi as Et}from"./useMobileNavigationStore-DQHF_ETu.js";import{a as Dt,i as Ot,r as kt}from"./MobileShareBridge-PZMRiieI.js";import{_ as At,a as jt,c as Mt,f as Nt,g as Pt,h as Ft,i as It,t as Lt,y as Rt}from"./MobileDetailNavigation-DILi0tN7.js";import{i as zt}from"./useAssistantUIStore-Bq3cPj2x.js";import{t as Bt}from"./AgentAvatar-B4fj9PIe.js";import{i as Vt,t as q}from"./utils-BxJEIWv5.js";import{n as J}from"./Icon-DiIuWOuC.js";import{a as Ht,i as Ut,n as Wt,o as Gt,r as Kt,t as qt}from"./dialog-COrLBm9O.js";import{t as Y}from"./button-DaAoVF4X.js";import{A as Jt,E as Yt,M as Xt,N as Zt,S as Qt,a as $t,g as en,h as tn,i as nn,j as rn,n as an,o as on,v as sn,x as cn}from"./projectMeta-BunN9pH5.js";import{t as ln}from"./input-XiL2-2gG.js";import{i as un,n as dn,t as fn}from"./tooltip-BLugzWq-.js";import{C as pn,D as mn,E as hn,H as gn,K as _n,M as vn,N as yn,O as bn,R as xn,S as Sn,T as Cn,U as wn,V as Tn,W as En,a as Dn,b as On,c as kn,f as An,i as jn,j as Mn,p as Nn,q as Pn,s as Fn,t as In,u as X,w as Ln,x as Rn,y as zn,z as Bn}from"./useSessionAutoCleanup-BuU_S_Sh.js";import{n as Vn}from"./useThemeSystem-DMzWVJaW.js";import{A as Hn,D as Un,E as Wn,H as Gn,J as Kn,N as qn,O as Jn,Q as Yn,R as Xn,U as Zn,V as Qn,Y as $n,a as er,f as tr,h as nr,i as rr,j as ir,p as ar,q as or,r as sr,s as cr,t as lr}from"./radio-Bziafaje.js";import{i as ur,r as dr,t as fr}from"./OverlayScrollbar-BgMLtMIq.js";import{n as pr}from"./useRuntimeAPIs-DSLXJybW.js";import{c as mr,i as hr,n as gr}from"./appThemeRegistry-CDxBJNNB.js";import{a as _r}from"./url-DMs_PgIC.js";import{p as vr}from"./markdown-worker-BDyY0vt6.js";import{t as yr}from"./sortable-tabs-strip-pWlBorwQ.js";import{A as br,B as xr,C as Sr,D as Cr,E as wr,F as Tr,G as Er,H as Dr,I as Z,J as Or,K as kr,L as Ar,M as jr,N as Mr,O as Nr,P as Pr,R as Fr,S as Ir,T as Lr,U as Rr,V as zr,W as Br,X as Vr,Y as Hr,Z as Ur,_ as Wr,a as Gr,b as Kr,c as qr,d as Jr,f as Yr,h as Xr,j as Zr,k as Qr,l as $r,m as ei,n as ti,p as ni,q as ri,s as ii,u as ai,v as oi,w as si,y as ci,z as li}from"./MobileSurface-BLYcR0tO.js";import{a as ui,n as di,r as fi,t as pi}from"./context-menu-DBOMervd.js";import{n as mi,r as hi,t as gi}from"./collapsible-BmuQu0dq.js";import{n as _i,t as vi}from"./vendor-yaml-DIcAK3EC.js";import{t as yi}from"./vendor-qrcode-DAuVxiQR.js";var bi=ye(),Q=e(ge(),1),$=he(),xi=`https://github.com/yee94/openchamber`,Si=`https://discord.gg/ZYRSdnwwKA`,Ci=`https://x.com/openchamber_dev`,wi=800,Ti=({initialUpdateDialogOpen:e=!1})=>{let{t}=Te(),[n,r]=Q.useState(e),[i,a]=Q.useState(!1),[o,s]=Q.useState(null),[c,l]=Q.useState(null),[u,d]=Q.useState(null),f=xr(me(e=>({info:e.info,checking:e.checking,available:e.available,error:e.error,downloading:e.downloading,downloaded:e.downloaded,progress:e.progress,runtimeType:e.runtimeType,checkForUpdates:e.checkForUpdates,downloadUpdate:e.downloadUpdate,restartToUpdate:e.restartToUpdate}))),{isMobile:p}=ur(),[m,h]=Q.useState(!1),[g,_]=Q.useState(()=>Qe()),v=we(e=>{ht(e),_(e)}),y=o||t(`settings.openchamber.about.state.unknown`),b=we(async()=>{if(!m){h(!0);try{let{outcome:e,eventCount:n}=await yt();if(e===`cancelled`)return;if(e===`failed`){K.error(t(`settings.openchamber.about.diagnostics.toast.failed`));return}K.success(t(n>0?`settings.openchamber.about.diagnostics.toast.exported`:`settings.openchamber.about.diagnostics.toast.empty`))}catch{K.error(t(`settings.openchamber.about.diagnostics.toast.failed`))}finally{h(!1)}}});Q.useEffect(()=>{let e=!1;return zr().then(t=>{e||s(t)}),()=>{e=!0}},[]),Q.useEffect(()=>{let e=!1;return(async()=>{try{let t=await I(`/api/system/info`,{method:`GET`,headers:{Accept:`application/json`}});if(!t.ok)return;let n=await t.json().catch(()=>null),r=typeof n?.openchamberVersion==`string`&&n.openchamberVersion.trim().length>0?n.openchamberVersion.trim():null;e||l(r)}catch{e||l(null)}})(),()=>{e=!0}},[]),Q.useEffect(()=>{let e=!1;return(async()=>{try{let t=await I(`/api/opencode/upgrade-status`,{method:`GET`,headers:{Accept:`application/json`}});if(!t.ok)return;let n=await t.json().catch(()=>null),r=typeof n?.currentVersion==`string`&&n.currentVersion.trim().length>0?n.currentVersion.trim():null;e||d(r)}catch{e||d(null)}})(),()=>{e=!0}},[]);let x=Q.useRef(!1);Q.useEffect(()=>{if(f.checking)a(!0),x.current=!0;else if(i){let e=setTimeout(()=>{a(!1),x.current&&f.error?(K.error(t(`settings.openchamber.about.toast.checkFailed`),{description:f.error}),x.current=!1):x.current&&!f.available&&!f.error&&(K.success(t(`settings.openchamber.about.toast.latestVersion`)),x.current=!1)},wi);return()=>clearTimeout(e)}},[t,f.checking,i,f.available,f.error]);let S=f.checking||i;return p?(0,$.jsxs)(`div`,{className:`w-full space-y-6 pb-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,$.jsx)(Yn,{width:72,height:72}),(0,$.jsx)(`h2`,{className:`mt-4 typography-ui-header font-semibold text-foreground`,children:`OpenChamber`})]}),(0,$.jsxs)(Z,{children:[(0,$.jsx)(Ar,{label:t(`settings.openchamber.about.field.clientVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:y})}),(0,$.jsx)(Ar,{label:t(`settings.openchamber.about.field.instanceOpenChamberVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:c||t(`settings.openchamber.about.state.unknown`)})}),(0,$.jsx)(Ar,{label:t(`settings.openchamber.about.field.instanceOpenCodeVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:u||t(`settings.openchamber.about.state.unknown`)})}),(0,$.jsx)(Ar,{children:!S&&f.available?(0,$.jsxs)(Y,{type:`button`,variant:`default`,size:`sm`,onClick:()=>r(!0),children:[(0,$.jsx)(J,{name:`download`,className:`size-4`}),t(`settings.openchamber.about.actions.updateToVersion`,{version:f.info?.version||``})]}):(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>f.checkForUpdates(),disabled:S,children:[S?(0,$.jsx)(J,{name:`loader`,className:`size-4 animate-spin`}):(0,$.jsx)(J,{name:`refresh`,className:`size-4`}),t(S?`settings.openchamber.about.state.checking`:`settings.openchamber.about.actions.checkForUpdates`)]})}),f.error&&(0,$.jsx)(Ar,{children:(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:f.error})}),(0,$.jsx)(Fr,{itemId:`about.diagnostics`,checked:g,onChange:v,label:t(`settings.openchamber.about.diagnostics.label`),ariaLabel:t(`settings.openchamber.about.diagnostics.label`)}),g&&(0,$.jsx)(Ar,{itemId:`about.export-diagnostics`,label:t(`settings.openchamber.about.diagnostics.export`),children:(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`sm`,disabled:m,onClick:()=>void b(),children:t(m?`settings.openchamber.about.diagnostics.exporting`:`settings.openchamber.about.diagnostics.export`)})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-center`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-center gap-5`,children:[(0,$.jsxs)(`a`,{href:xi,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground`,children:[(0,$.jsx)(J,{name:`github-fill`,className:`size-5`}),(0,$.jsx)(`span`,{children:`GitHub`})]}),(0,$.jsxs)(`a`,{href:Si,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground`,children:[(0,$.jsx)(J,{name:`discord-fill`,className:`size-5`}),(0,$.jsx)(`span`,{children:`Discord`})]})]}),(0,$.jsxs)(`a`,{href:Ci,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground`,children:[(0,$.jsx)(J,{name:`twitter-xfill`,className:`size-5`}),(0,$.jsx)(`span`,{children:`@openchamber_dev`})]})]}),(0,$.jsx)(`p`,{className:`text-center typography-ui text-muted-foreground/60`,children:t(`aboutDialog.footerNote`)}),(0,$.jsx)(li,{open:n,onOpenChange:r,info:f.info,downloading:f.downloading,downloaded:f.downloaded,progress:f.progress,error:f.error,onDownload:f.downloadUpdate,onRestart:f.restartToUpdate,runtimeType:f.runtimeType})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Z,{label:t(`settings.openchamber.about.title`),children:[(0,$.jsx)(Ar,{label:t(`settings.openchamber.about.field.clientVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:y})}),(0,$.jsx)(Ar,{label:t(`settings.openchamber.about.field.instanceOpenChamberVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:c||t(`settings.openchamber.about.state.unknown`)})}),(0,$.jsx)(Ar,{label:t(`settings.openchamber.about.field.instanceOpenCodeVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:u||t(`settings.openchamber.about.state.unknown`)})}),(0,$.jsx)(Ar,{children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-3`,children:[f.checking&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,$.jsx)(J,{name:`loader`,className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{className:`typography-meta`,children:t(`settings.openchamber.about.state.checking`)})]}),!f.checking&&f.available&&(0,$.jsxs)(Y,{size:`sm`,variant:`default`,onClick:()=>r(!0),children:[(0,$.jsx)(J,{name:`download`,className:`h-4 w-4 mr-1`}),t(`settings.openchamber.about.actions.updateToVersion`,{version:f.info?.version||``})]}),!f.checking&&!f.available&&!f.error&&(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:t(`settings.openchamber.about.state.upToDate`)}),(0,$.jsx)(Y,{size:`sm`,variant:`outline`,onClick:()=>f.checkForUpdates(),disabled:f.checking,children:t(`settings.openchamber.about.actions.checkForUpdates`)})]})}),f.error&&(0,$.jsx)(Ar,{children:(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:f.error})}),(0,$.jsx)(Fr,{itemId:`about.diagnostics`,checked:g,onChange:v,label:t(`settings.openchamber.about.diagnostics.label`),ariaLabel:t(`settings.openchamber.about.diagnostics.label`)}),g&&(0,$.jsx)(Ar,{itemId:`about.export-diagnostics`,label:t(`settings.openchamber.about.diagnostics.export`),children:(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`sm`,disabled:m,onClick:()=>void b(),children:t(m?`settings.openchamber.about.diagnostics.exporting`:`settings.openchamber.about.diagnostics.export`)})}),(0,$.jsxs)(Ar,{controlClassName:`flex-wrap`,children:[(0,$.jsxs)(`a`,{href:xi,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 text-muted-foreground hover:text-foreground typography-meta transition-colors`,children:[(0,$.jsx)(J,{name:`github-fill`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:`GitHub`})]}),(0,$.jsxs)(`a`,{href:Ci,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 text-muted-foreground hover:text-foreground typography-meta transition-colors`,children:[(0,$.jsx)(J,{name:`twitter-xfill`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:`@openchamber_dev`})]})]})]}),(0,$.jsx)(li,{open:n,onOpenChange:r,info:f.info,downloading:f.downloading,downloaded:f.downloaded,progress:f.progress,error:f.error,onDownload:f.downloadUpdate,onRestart:f.restartToUpdate,runtimeType:f.runtimeType})]})},Ei=`/assets/android-direct-share-1a0lp154.jpg`,Di=`/assets/ios-share-sheet-B3Dlufnc.jpg`,Oi=`/assets/select-assistant-C89IRspC.jpg`,ki=`openchamber:assistant-share-welcome:v1`,Ai=[{image:Di,titleKey:`assistants.shareWelcome.example.chat.title`,descriptionKey:`assistants.shareWelcome.example.chat.description`},{image:Ei,titleKey:`assistants.shareWelcome.example.article.title`,descriptionKey:`assistants.shareWelcome.example.article.description`},{image:Oi,titleKey:`assistants.shareWelcome.example.note.title`,descriptionKey:`assistants.shareWelcome.example.note.description`}],ji=e=>{let t=(0,bi.c)(40),{enabled:n,open:r,onOpenChange:i}=e,a=n!==void 0&&n,{t:o}=Te(),[s,c]=Ce(ki,!1),l=r!==void 0,u=l?r:a&&s!==!0,d;t[0]!==l||t[1]!==i||t[2]!==c?(d=()=>{l||c(!0),i?.(!1)},t[0]=l,t[1]=i,t[2]=c,t[3]=d):d=t[3];let f=we(d),p;t[4]!==f||t[5]!==i?(p=e=>{e?i?.(!0):f()},t[4]=f,t[5]=i,t[6]=p):p=t[6];let m;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-interactive-selection text-interactive-selection-foreground sm:size-12`,children:(0,$.jsx)(J,{name:`share-2`,className:`size-5`})}),t[7]=m):m=t[7];let h;t[8]===o?h=t[9]:(h=o(`assistants.shareWelcome.title`),t[8]=o,t[9]=h);let g;t[10]===h?g=t[11]:(g=(0,$.jsx)(Gt,{className:`typography-ui-header text-left sm:text-3xl`,children:h}),t[10]=h,t[11]=g);let _;t[12]===o?_=t[13]:(_=o(`assistants.shareWelcome.description`),t[12]=o,t[13]=_);let v;t[14]===_?v=t[15]:(v=(0,$.jsx)(Kt,{className:`typography-ui text-left leading-6 sm:max-w-3xl sm:text-base sm:leading-7`,children:_}),t[14]=_,t[15]=v);let y;t[16]!==g||t[17]!==v?(y=(0,$.jsxs)(Ht,{className:`flex-row items-start gap-3 px-5 pb-5 pt-6 text-left sm:gap-4 sm:px-8 sm:pb-6 sm:pt-8`,children:[m,(0,$.jsxs)(`div`,{className:`min-w-0 space-y-1.5 sm:space-y-2`,children:[g,v]})]}),t[16]=g,t[17]=v,t[18]=y):y=t[18];let b;t[19]===o?b=t[20]:(b=o(`assistants.shareWelcome.examplesAria`),t[19]=o,t[20]=b);let x;t[21]===o?x=t[22]:(x=Ai.map((e,t)=>(0,$.jsxs)(`article`,{className:`w-[min(78vw,19rem)] shrink-0 snap-center overflow-hidden rounded-xl border border-border bg-background lg:w-auto lg:min-w-0`,children:[(0,$.jsxs)(`div`,{className:`relative overflow-hidden border-b border-border bg-muted`,children:[(0,$.jsx)(`img`,{src:e.image,alt:``,className:`h-72 w-full object-cover object-bottom lg:h-[min(38vh,23rem)]`}),(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`absolute left-3 top-3 flex size-7 items-center justify-center rounded-full bg-[var(--surface-elevated)] typography-meta font-semibold text-foreground shadow-sm`,children:t+1})]}),(0,$.jsxs)(`div`,{className:`space-y-1 px-4 py-3.5 lg:min-h-25`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:o(e.titleKey)}),(0,$.jsx)(`p`,{className:`typography-meta leading-5 text-muted-foreground`,children:o(e.descriptionKey)})]})]},e.titleKey)),t[21]=o,t[22]=x);let S;t[23]!==b||t[24]!==x?(S=(0,$.jsx)(`div`,{className:`overflow-hidden px-5 pb-5 sm:px-8 sm:pb-7`,children:(0,$.jsx)(`div`,{className:`flex snap-x snap-mandatory gap-3 overflow-x-auto pb-2 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden lg:grid lg:grid-cols-3 lg:overflow-visible lg:pb-0`,"aria-label":b,children:x})}),t[23]=b,t[24]=x,t[25]=S):S=t[25];let C;t[26]===o?C=t[27]:(C=o(`assistants.shareWelcome.action`),t[26]=o,t[27]=C);let w;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(J,{name:`arrow-right-s`,className:`size-4`}),t[28]=w):w=t[28];let T;t[29]!==f||t[30]!==C?(T=(0,$.jsx)(Ut,{className:`border-t border-border px-5 py-4 sm:px-8 sm:py-5`,children:(0,$.jsxs)(Y,{size:`lg`,className:`w-full lg:mx-auto lg:w-72`,onClick:f,children:[C,w]})}),t[29]=f,t[30]=C,t[31]=T):T=t[31];let E;t[32]!==S||t[33]!==T||t[34]!==y?(E=(0,$.jsxs)(Wt,{showCloseButton:!1,className:`w-[min(100%,31rem)] max-w-none gap-0 overflow-hidden rounded-2xl border-border bg-[var(--surface-elevated)] p-0 sm:w-[min(calc(100%-3rem),44rem)] lg:w-[min(calc(100%-4rem),74rem)]`,containerClassName:`fixed inset-0 z-50 flex items-end justify-center px-0 pt-8 sm:items-center sm:p-6`,children:[y,S,T]}),t[32]=S,t[33]=T,t[34]=y,t[35]=E):E=t[35];let D;return t[36]!==u||t[37]!==E||t[38]!==p?(D=(0,$.jsx)(qt,{open:u,onOpenChange:p,children:E}),t[36]=u,t[37]=E,t[38]=p,t[39]=D):D=t[39],D},Mi=`useCommandsStore`,Ni=new Set([`init`,`review`]),Pi=e=>new Promise(t=>setTimeout(t,e)),Fi=e=>Ni.has(e.name),Ii=async(e,t)=>{await gt(V,e,t),r()===t&&Be(`commands`,{source:Mi})},Li=de()(pe(fe(e=>({selectedCommandName:null,commandDraft:null,setSelectedCommand:t=>e({selectedCommandName:t}),setCommandDraft:t=>e({commandDraft:t}),loadCommands:async()=>{let e=ft(),t=r();try{return await gt(V,e,t),!0}catch{return!1}},createCommand:async t=>Ri(`POST`,t.name,t,e),updateCommand:async(t,n)=>Ri(`PATCH`,t,n,e),deleteCommand:async t=>Ri(`DELETE`,t,void 0,e),getCommandByName:e=>nt().find(t=>t.name===e)}),{name:`commands-store`,storage:f(),partialize:e=>({selectedCommandName:e.selectedCommandName})}),{name:`commands-store`}));async function Ri(e,t,n,i){Tt(`${{POST:`Creating`,PATCH:`Updating`,DELETE:`Deleting`}[e]} command configuration…`);let a=ft(),o=r(),s=!1;try{let r={};if(e===`POST`&&(r.template=n?.template||``,n?.description&&(r.description=n.description),n?.agent&&(r.agent=n.agent),n?.model&&(r.model=n.model),n?.scope&&(r.scope=n.scope)),e===`PATCH`)for(let e of[`description`,`agent`,`model`,`template`])n?.[e]!==void 0&&(r[e]=n[e]);let c=a?`?directory=${encodeURIComponent(a)}`:``,l=await I(`/api/config/commands/${encodeURIComponent(t)}${c}`,{method:e,headers:e===`DELETE`?a?{"x-opencode-directory":a}:void 0:{"Content-Type":`application/json`,...a?{"x-opencode-directory":a}:{}},...e===`DELETE`?{}:{body:JSON.stringify(r)}}),u=await l.json().catch(()=>null);if(!l.ok)throw Error(u?.error||`Failed to ${e.toLowerCase()} command`);return s=u?.requiresReload??!0,s?await zi(a,o,{message:u?.message,delayMs:u?.reloadDelayMs}):await Ii(a,o),e===`DELETE`&&i({selectedCommandName:null}),!0}catch(e){return console.error(`[CommandsStore] Command mutation failed:`,e),!1}finally{Ye()}}async function zi(e,t,n){n.delayMs&&await Pi(n.delayMs),wt(n.message||`Refreshing commands…`),await Ii(e,t)}typeof window<`u`&&(window.__zustand_commands_store__=Li),Ct(e=>{e.source!==Mi&&Me(e,`commands`)&&Li.getState().loadCommands()});var Bi=()=>{try{let e=rt.getState().getActiveProject?.();if(e?.path?.trim())return e.path.trim();let t=_e.getDirectory();if(t?.trim())return t.trim()}catch(e){console.warn(`[McpConfigStore] Error resolving config directory:`,e)}return null},Vi=e=>e?Object.entries(e).map(([e,t])=>({key:e,value:t})):[],Hi=e=>{let t=e.filter(e=>e.key.trim());if(t.length!==0)return Object.fromEntries(t.map(e=>[e.key.trim(),e.value]))},Ui=e=>{if(typeof e==`string`)return e.trim()||void 0},Wi=800,Gi=de()(pe(fe((e,t)=>({selectedMcpName:null,mcpDraft:null,setSelectedMcp:t=>e({selectedMcpName:t}),setMcpDraft:t=>e({mcpDraft:t}),loadMcpConfigs:async e=>{let t=Bi();try{return!e?.force&&Rr(V,t).length>0||await Er(V,t,r()),!0}catch(e){return console.error(`[McpConfigStore] Failed to load MCP configs:`,e),!1}},createMcp:async(e,t)=>{Tt(`Creating MCP server configuration…`);let n=!1,i=`directory`in(t??{})?t?.directory?.trim()||null:Bi(),a=t?.transportIdentity??r();try{let t=Ki(e),r=i?`?directory=${encodeURIComponent(i)}`:``,o=await I(`/api/config/mcp/${encodeURIComponent(e.name)}${r}`,{method:`POST`,headers:{"Content-Type":`application/json`,...i?{"x-opencode-directory":i}:{}},body:JSON.stringify(t)}),s=await o.json().catch(()=>null);if(!o.ok)throw Error(s?.error||`Failed to create MCP server`);return s?.requiresReload?(n=!0,await _t({message:s.message,delayMs:s.reloadDelayMs??Wi,scopes:[`mcp`],queryDirectory:i,transportIdentity:a}),await Er(V,i,a),await kr(V,i,a),{ok:!0,reloadFailed:s?.reloadFailed===!0,message:s?.message,warning:s?.warning}):(await Er(V,i,a),await kr(V,i,a),{ok:!0,reloadFailed:s?.reloadFailed===!0,message:s?.message,warning:s?.warning})}catch(e){return console.error(`[McpConfigStore] Failed to create MCP:`,e),{ok:!1}}finally{n||Ye()}},updateMcp:async(e,t,n)=>{Tt(`Updating MCP server configuration…`);let i=!1,a=`directory`in(n??{})?n?.directory?.trim()||null:Bi(),o=n?.transportIdentity??r();try{let n=Ki(t),r=a?`?directory=${encodeURIComponent(a)}`:``,s=await I(`/api/config/mcp/${encodeURIComponent(e)}${r}`,{method:`PATCH`,headers:{"Content-Type":`application/json`,...a?{"x-opencode-directory":a}:{}},body:JSON.stringify(n)}),c=await s.json().catch(()=>null);if(!s.ok)throw Error(c?.error||`Failed to update MCP server`);return c?.requiresReload?(i=!0,await _t({message:c.message,delayMs:c.reloadDelayMs??Wi,scopes:[`mcp`],queryDirectory:a,transportIdentity:o}),await Er(V,a,o),await kr(V,a,o),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}):(await Er(V,a,o),await kr(V,a,o),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning})}catch(e){throw console.error(`[McpConfigStore] Failed to update MCP:`,e),e}finally{i||Ye()}},deleteMcp:async(n,i)=>{Tt(`Deleting MCP server configuration…`);let a=!1,o=`directory`in(i??{})?i?.directory?.trim()||null:Bi(),s=i?.transportIdentity??r();try{let r=o?`?directory=${encodeURIComponent(o)}`:``,i=await I(`/api/config/mcp/${encodeURIComponent(n)}${r}`,{method:`DELETE`,headers:o?{"x-opencode-directory":o}:void 0}),c=await i.json().catch(()=>null);if(!i.ok)throw Error(c?.error||`Failed to delete MCP server`);return c?.requiresReload&&(a=!0,await _t({message:c.message,delayMs:c.reloadDelayMs??Wi,scopes:[`mcp`],queryDirectory:o,transportIdentity:s})),t().selectedMcpName===n&&e({selectedMcpName:null}),Dr.getState().clearDiagnostic(n,o,s),await Er(V,o,s),await kr(V,o,s),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}}catch(e){return console.error(`[McpConfigStore] Failed to delete MCP:`,e),{ok:!1}}finally{a||Ye()}}}),{name:`mcp-config-store`,storage:f(),partialize:e=>({selectedMcpName:e.selectedMcpName})}),{name:`mcp-config-store`}));function Ki(e){let t={};if(e.scope!==void 0&&(t.scope=e.scope),e.type!==void 0&&(t.type=e.type),(e.type===`local`||e.command!==void 0)&&(t.command=(e.command??[]).filter(e=>e.trim())),(e.type===`remote`||e.url!==void 0)&&(t.url=e.url?.trim()??``),e.environment!==void 0&&(t.environment=Hi(e.environment)??{}),e.headers!==void 0&&(t.headers=Hi(e.headers)??{}),e.oauthEnabled!==void 0||e.oauthClientId!==void 0||e.oauthClientSecret!==void 0||e.oauthScope!==void 0||e.oauthRedirectUri!==void 0)if(e.oauthEnabled===!1)t.oauth=!1;else{let n={clientId:Ui(e.oauthClientId),clientSecret:Ui(e.oauthClientSecret),scope:Ui(e.oauthScope),redirectUri:Ui(e.oauthRedirectUri)};t.oauth=n.clientId||n.clientSecret||n.scope||n.redirectUri?n:e.oauthEnabled?{}:!1}if(e.timeout!==void 0){let n=Number(e.timeout);t.timeout=Number.isFinite(n)&&n>0?n:null}return e.enabled!==void 0&&(t.enabled=e.enabled),t}var qi=()=>{let e=_e.getDirectory();if(typeof e==`string`&&e.trim().length>0)return e;try{let e=window.__zustand_directory_store__;if(e)return e.getState().currentDirectory}catch{}return null},Ji=`useSkillsStore`,Yi=e=>new Promise(t=>setTimeout(t,e)),Xi=e=>{if(e&&Object.prototype.hasOwnProperty.call(e,`directory`))return typeof e.directory==`string`&&e.directory.trim()||null;let t=qi();return typeof t==`string`&&t.trim()||null},Zi=2e4,Qi=300,$i=4,ea=800,ta=200,na=2e3,ra=de()(pe(fe((e,t)=>({selectedSkillName:null,skillDraft:null,setSelectedSkill:t=>{e({selectedSkillName:t})},setSkillDraft:t=>{e({skillDraft:t})},loadSkills:async()=>{try{return await Je(V,qi(),r()),!0}catch{return!1}},getSkillDetail:async e=>{try{let t=qi(),n=t?`?directory=${encodeURIComponent(t)}`:``,r=await I(`/api/config/skills/${encodeURIComponent(e)}${n}`);return r.ok?await r.json():null}catch{return null}},createSkill:async(e,t)=>{Tt(`Creating skill...`);let n=!1;try{let i={name:e.name,description:e.description};e.instructions&&(i.instructions=e.instructions),e.scope&&(i.scope=e.scope),e.source&&(i.source=e.source),e.supportingFiles&&(i.supportingFiles=e.supportingFiles);let a=Xi(t),o=r(),s=a?`?directory=${encodeURIComponent(a)}`:``,c=await I(`/api/config/skills/${encodeURIComponent(e.name)}${s}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)}),l=await c.json().catch(()=>null);if(!c.ok){let e=l?.error||`Failed to create skill`;throw Error(e)}return l?.requiresReload??!1?(n=!0,await aa({message:l?.message,delayMs:l?.reloadDelayMs,directory:a,transportIdentity:o}),!0):(await Je(V,a,o),await pt(V,a,o),Be(`skills`,{source:Ji}),!0)}catch{return!1}finally{n||Ye()}},updateSkill:async(e,t,n)=>{Tt(`Updating skill...`);let i=!1;try{let a={};t.description!==void 0&&(a.description=t.description),t.instructions!==void 0&&(a.instructions=t.instructions),t.supportingFiles!==void 0&&(a.supportingFiles=t.supportingFiles),t.targetPath!==void 0&&(a.targetPath=t.targetPath);let o=Xi(n),s=r(),c=o?`?directory=${encodeURIComponent(o)}`:``,l=await I(`/api/config/skills/${encodeURIComponent(e)}${c}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(a)}),u=await l.json().catch(()=>null);if(!l.ok){let e=u?.error||`Failed to update skill`;throw Error(e)}return u?.requiresReload??!1?(i=!0,await aa({message:u?.message,delayMs:u?.reloadDelayMs,directory:o,transportIdentity:s}),!0):(await Je(V,o,s),await pt(V,o,s),Be(`skills`,{source:Ji}),!0)}catch{return!1}finally{i||Ye()}},deleteSkill:async(n,i)=>{Tt(`Deleting skill...`);let a=!1;try{let o=Xi(i),s=r(),c=o?`?directory=${encodeURIComponent(o)}`:``,l=await I(`/api/config/skills/${encodeURIComponent(n)}${c}`,{method:`DELETE`}),u=await l.json().catch(()=>null);if(!l.ok){let e=u?.error||`Failed to delete skill`;throw Error(e)}return u?.requiresReload??!1?(a=!0,await aa({message:u?.message,delayMs:u?.reloadDelayMs,directory:o,transportIdentity:s}),!0):(await Je(V,o,s),await pt(V,o,s),Be(`skills`,{source:Ji}),t().selectedSkillName===n&&e({selectedSkillName:null}),!0)}catch{return!1}finally{a||Ye()}},getSkillByName:e=>Ge(V,qi()).find(t=>t.name===e),readSupportingFile:async(e,t)=>{try{let n=qi(),r=n?`&directory=${encodeURIComponent(n)}`:``,i=await I(`/api/config/skills/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}?${r.slice(1)}`);return i.ok?(await i.json()).content??null:null}catch{return null}},writeSupportingFile:async(e,t,n)=>{try{let r=qi(),i=r?`?directory=${encodeURIComponent(r)}`:``;return(await I(`/api/config/skills/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}${i}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({content:n})})).ok}catch{return!1}},deleteSupportingFile:async(e,t)=>{try{let n=qi(),r=n?`?directory=${encodeURIComponent(n)}`:``;return(await I(`/api/config/skills/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}${r}`,{method:`DELETE`})).ok}catch{return!1}}}),{name:`skills-store`,storage:f(),partialize:e=>({selectedSkillName:e.selectedSkillName})}),{name:`skills-store`}));typeof window<`u`&&(window.__zustand_skills_store__=ra);async function ia(e){let t=typeof e==`number`&&e>0?Math.min(e,Qi):0;t>0&&await Yi(t);let n=Date.now(),r=0,i=null;for(;Date.now()-n<Zi;){r+=1,wt(`Waiting for OpenCode… (attempt ${r})`);try{if(await _e.checkHealth())return;i=Error(`OpenCode health check reported not ready`)}catch(e){i=e}let e=Date.now()-n;await Yi(r<=$i&&e<1200?Qi:Math.min(ea+Math.max(0,r-$i)*ta,na))}throw i||Error(`OpenCode did not become ready in time`)}async function aa(e){let t=e&&`directory`in e?e.directory?.trim()||null:qi(),n=e?.transportIdentity??r();try{wt(e?.message||`Refreshing skills…`)}catch{}try{if(await ia(e?.delayMs),r()!==n||(wt(`Refreshing skills…`),await Je(V,t,n),r()!==n))return;await pt(V,t,n),Be(`skills`,{source:Ji})}catch(e){throw wt(`OpenCode refresh failed. Please retry.`),await Yi(1500),e}finally{Ye()}}var oa=null;oa||=Ct(e=>{if(e.source!==Ji&&Me(e,`skills`)){let e=qi(),t=r();Je(V,e,t).then(()=>pt(V,e,t)).catch(()=>void 0)}});var sa=e=>{let t=(0,bi.c)(37),{className:n}=e,{t:r}=Te(),i=rt(ca),a=rt(la),o=rt(ua),s=p(),c;t[0]===i?c=t[1]:(c=[...i].sort(da),t[0]=i,t[1]=c);let l=c,u;bb0:{if(l.length===0){u=null;break bb0}let e;t[2]!==a||t[3]!==l?(e=l.find(e=>e.id===a)??l[0],t[2]=a,t[3]=l,t[4]=e):e=t[4],u=e}let d=u;if(s||l.length===0)return null;let f;t[5]!==d?.path||t[6]!==r?(f=d?.path.split(`/`).filter(Boolean).pop()||d?.path||r(`settings.shared.projectSelector.fallbackProject`),t[5]=d?.path,t[6]=r,t[7]=f):f=t[7];let m=f,h;t[8]===n?h=t[9]:(h=q(n),t[8]=n,t[9]=h);let g;t[10]===r?g=t[11]:(g=r(`settings.shared.projectSelector.switchProjectAria`),t[10]=r,t[11]=g);let _;t[12]===r?_=t[13]:(_=r(`settings.shared.projectSelector.switchProjectTitle`),t[12]=r,t[13]=_);let v,y;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(v=q(`text-foreground border border-border/80 appearance-none flex h-8 w-full min-w-0 rounded-lg bg-transparent px-3 py-1 outline-none`,`hover:border-input focus-visible:ring-1 focus-visible:ring-primary/50 focus-visible:border-primary/70`,`flex items-center gap-1.5 text-left`),y=(0,$.jsx)(J,{name:`folder`,className:`h-4 w-4 text-muted-foreground`}),t[14]=v,t[15]=y):(v=t[14],y=t[15]);let b;t[16]===m?b=t[17]:(b=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label font-medium`,children:m}),t[16]=m,t[17]=b);let x;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(J,{name:`arrow-down-s`,className:`size-4 opacity-50`}),t[18]=x):x=t[18];let S;t[19]!==g||t[20]!==_||t[21]!==b?(S=(0,$.jsx)(qn,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,"aria-label":g,title:_,className:v,children:[y,b,x]})}),t[19]=g,t[20]=_,t[21]=b,t[22]=S):S=t[22];let C=d?.id??``,w;t[23]===o?w=t[24]:(w=e=>{e&&o(e)},t[23]=o,t[24]=w);let T;t[25]===l?T=t[26]:(T=l.map(fa),t[25]=l,t[26]=T);let E;t[27]!==C||t[28]!==w||t[29]!==T?(E=(0,$.jsx)(Un,{align:`start`,className:`w-auto`,children:(0,$.jsx)(Hn,{value:C,onValueChange:w,children:T})}),t[27]=C,t[28]=w,t[29]=T,t[30]=E):E=t[30];let D;t[31]!==S||t[32]!==E?(D=(0,$.jsxs)(Wn,{children:[S,E]}),t[31]=S,t[32]=E,t[33]=D):D=t[33];let O;return t[34]!==D||t[35]!==h?(O=(0,$.jsx)(`div`,{className:h,children:D}),t[34]=D,t[35]=h,t[36]=O):O=t[36],O};function ca(e){return e.projects}function la(e){return e.activeProjectId}function ua(e){return e.setActiveProject}function da(e,t){return(e.label||e.path).localeCompare(t.label||t.path)}function fa(e){let t=e.path.split(`/`).filter(Boolean).pop()||e.path;return(0,$.jsx)(ir,{value:e.id,children:(0,$.jsx)(`span`,{className:`min-w-0 truncate typography-ui`,children:t})},e.id)}function pa(e,t){return`opencode:sidebar-group:${e}:${t}`}var ma=e=>{let t=(0,bi.c)(57),{label:n,count:r,storageKey:i,defaultExpanded:a,variant:o,labelPrefix:s,children:c}=e,l=a===void 0||a,u=o===void 0?`sidebar`:o,d;t[0]!==n||t[1]!==i?(d=pa(i,n),t[0]=n,t[1]=i,t[2]=d):d=t[2];let f=d,p=Q.useId(),m;t[3]!==l||t[4]!==f?(m=()=>{try{let e=localStorage.getItem(f);if(e!==null)return e===`true`}catch{}return l},t[3]=l,t[4]=f,t[5]=m):m=t[5];let[h,g]=(0,Q.useState)(m),_,v;if(t[6]!==h||t[7]!==f?(_=()=>{try{localStorage.setItem(f,String(h))}catch{}},v=[f,h],t[6]=h,t[7]=f,t[8]=_,t[9]=v):(_=t[8],v=t[9]),(0,Q.useEffect)(_,v),u===`settings-card`){let e;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>g(ha),t[10]=e):e=t[10];let i;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(i=q(`flex w-full items-center gap-1 text-left`,`text-inherit transition-colors duration-150 hover:text-foreground`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`),t[11]=i):i=t[11];let a=!h&&`-rotate-90`,o;t[12]===a?o=t[13]:(o=q(`h-3.5 w-3.5 flex-shrink-0 transition-transform duration-200`,a),t[12]=a,t[13]=o);let l;t[14]===o?l=t[15]:(l=(0,$.jsx)(J,{name:`arrow-down-s`,className:o}),t[14]=o,t[15]=l);let u=s?`${s} · `:``,d;t[16]!==n||t[17]!==u?(d=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[u,n]}),t[16]=n,t[17]=u,t[18]=d):d=t[18];let f;t[19]===r?f=t[20]:(f=(0,$.jsx)(`span`,{className:`ml-1 tabular-nums opacity-60`,children:r}),t[19]=r,t[20]=f);let m;t[21]!==p||t[22]!==h||t[23]!==l||t[24]!==d||t[25]!==f?(m=(0,$.jsxs)(`button`,{type:`button`,onClick:e,"aria-expanded":h,"aria-controls":p,className:i,children:[l,d,f]}),t[21]=p,t[22]=h,t[23]=l,t[24]=d,t[25]=f,t[26]=m):m=t[26];let _=!h&&`hidden`,v;t[27]===_?v=t[28]:(v=q(_),t[27]=_,t[28]=v);let y;return t[29]!==c||t[30]!==p||t[31]!==m||t[32]!==v?(y=(0,$.jsx)(Z,{label:m,cardClassName:v,cardId:p,children:c}),t[29]=c,t[30]=p,t[31]=m,t[32]=v,t[33]=y):y=t[33],y}let y;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>g(ga),t[34]=y):y=t[34];let b;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(b=q(`flex w-full items-center gap-1 rounded-md px-2 py-1 text-left`,`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,`hover:bg-[var(--interactive-hover)] transition-colors duration-150`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`),t[35]=b):b=t[35];let x=!h&&`-rotate-90`,S;t[36]===x?S=t[37]:(S=q(`h-3.5 w-3.5 flex-shrink-0 transition-transform duration-200`,x),t[36]=x,t[37]=S);let C;t[38]===S?C=t[39]:(C=(0,$.jsx)(J,{name:`arrow-down-s`,className:S}),t[38]=S,t[39]=C);let w;t[40]===n?w=t[41]:(w=(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:n}),t[40]=n,t[41]=w);let T;t[42]===r?T=t[43]:(T=(0,$.jsx)(`span`,{className:`ml-1 tabular-nums opacity-60`,children:r}),t[42]=r,t[43]=T);let E;t[44]!==p||t[45]!==h||t[46]!==C||t[47]!==w||t[48]!==T?(E=(0,$.jsxs)(`button`,{type:`button`,onClick:y,"aria-expanded":h,"aria-controls":p,className:b,children:[C,w,T]}),t[44]=p,t[45]=h,t[46]=C,t[47]=w,t[48]=T,t[49]=E):E=t[49];let D=!h,O;t[50]!==c||t[51]!==p||t[52]!==D?(O=(0,$.jsx)(`div`,{id:p,hidden:D,className:`mt-0.5 space-y-0.5 ml-2 pl-3 border-l-2 border-[var(--interactive-border)]`,children:c}),t[50]=c,t[51]=p,t[52]=D,t[53]=O):O=t[53];let k;return t[54]!==E||t[55]!==O?(k=(0,$.jsxs)(`div`,{children:[E,O]}),t[54]=E,t[55]=O,t[56]=k):k=t[56],k};function ha(e){return!e}function ga(e){return!e}var _a=e=>{if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;typeof e.permission==`string`&&typeof e.pattern==`string`&&typeof e.action==`string`&&(e.action===`allow`||e.action===`ask`||e.action===`deny`)&&t.push({permission:e.permission,pattern:e.pattern,action:e.action})}return t},va=e=>{let t=new Map;for(let n of e)!n.permission||n.permission===`invalid`||n.pattern&&t.set(`${n.permission}::${n.pattern}`,n);return Array.from(t.values())},ya=e=>{let t=va(_a(e));if(t.length===0)return;let n={};for(let e of t)e.permission&&((n[e.permission]||={})[e.pattern]=e.action);let r={};for(let[e,t]of Object.entries(n)){let n=Object.keys(t);if(n.length===1&&n[0]===`*`){r[e]=t[`*`];continue}r[e]=t}return Object.keys(r).length>0?r:void 0},ba=({onItemSelect:e})=>{let{t}=Te(),[n,r]=Q.useState(null),[i,a]=Q.useState(``),[o,s]=Q.useState(null),[c,l]=Q.useState(null),[u,d]=Q.useState(!1),[f,p]=Q.useState(null),{selectedAgentName:m,setSelectedAgent:h,setAgentDraft:g,createAgent:_,deleteAgent:v,loadAgents:y}=qe(me(e=>({selectedAgentName:e.selectedAgentName,setSelectedAgent:e.setSelectedAgent,setAgentDraft:e.setAgentDraft,createAgent:e.createAgent,deleteAgent:e.deleteAgent,loadAgents:e.loadAgents}))),{data:b=[]}=dt();Q.useEffect(()=>{y()},[y]);let x=()=>{let t=`new-agent`,n=t,r=1;for(;b.some(e=>e.name===n);)n=`${t}-${r}`,r++;g({name:n,scope:`user`}),h(n),e?.()},S=async e=>{if(Pe(e)){K.error(t(`settings.agents.sidebar.toast.builtInCannotDelete`));return}s(e),l(`delete`)},C=async e=>{Pe(e)&&(s(e),l(`reset`))},w=()=>{s(null),l(null)},T=async()=>{if(!(!o||!c)){d(!0);try{let e=await v(o.name,o.scope);e.ok?(e.requiresManualRestart?K.warning(t(`settings.agents.page.toast.savedManualRestart`)):c===`delete`?K.success(t(`settings.agents.sidebar.toast.agentDeleted`,{name:o.name})):K.success(t(`settings.agents.sidebar.toast.agentReset`,{name:o.name})),w()):c===`delete`?K.error(t(`settings.agents.sidebar.toast.deleteFailed`)):K.error(t(`settings.agents.sidebar.toast.resetFailed`))}catch(e){let n=e instanceof Error?e.message:``,r=/built-in|not deletable|not found/i.test(n);c===`delete`?K.error(t(r?`settings.agents.sidebar.toast.definitionNotFound`:`settings.agents.sidebar.toast.deleteFailed`)):K.error(t(`settings.agents.sidebar.toast.resetFailed`))}d(!1)}},E=e=>{let t=e.name,n=1,r=`${t}-copy`;for(;b.some(e=>e.name===r);)n++,r=`${t}-copy-${n}`;let i=e,a=e.model?.providerID&&e.model?.modelID?`${e.model.providerID}/${e.model.modelID}`:null,o=e;g({name:r,scope:i.scope||`user`,description:e.description,model:a,variant:e.variant,temperature:e.temperature,top_p:e.topP,prompt:e.prompt,mode:e.mode,permission:ya(e.permission),disable:o.disable}),h(r)},D=e=>{a(e.name),r(e)},O=async()=>{if(!n)return;let e=i.trim().replace(/\s+/g,`-`);if(!e){K.error(t(`settings.agents.sidebar.toast.agentNameRequired`));return}if(e===n.name){r(null);return}if(b.some(t=>t.name===e)){K.error(t(`settings.agents.sidebar.toast.agentExists`));return}let a=n.model?.providerID&&n.model?.modelID?`${n.model.providerID}/${n.model.modelID}`:null,o=n,s=await _({name:e,description:n.description,model:a,variant:n.variant,temperature:n.temperature,top_p:n.topP,prompt:n.prompt,mode:n.mode,permission:ya(n.permission),disable:o.disable,scope:o.scope});if(s.ok){let r=await v(n.name,o.scope);r.ok?(s.requiresManualRestart||r.requiresManualRestart?K.warning(t(`settings.agents.page.toast.savedManualRestart`)):K.success(t(`settings.agents.sidebar.toast.agentRenamed`,{name:e})),h(e)):K.error(t(`settings.agents.sidebar.toast.removeOldAfterRenameFailed`))}else K.error(t(`settings.agents.sidebar.toast.renameFailed`));r(null)},k=e=>{switch(e){case`primary`:return(0,$.jsx)(J,{name:`ai-agent`,className:`h-3 w-3 text-primary`});case`all`:return(0,$.jsx)(J,{name:`ai-agent-fill`,className:`h-3 w-3 text-primary`});case`subagent`:return(0,$.jsx)(J,{name:`robot`,className:`h-3 w-3 text-primary`});default:return null}},A=b.filter(e=>!Le(e)),j=A.filter(Pe),M=A.filter(e=>!Pe(e)),{groupedCustomAgents:N,ungroupedCustomAgents:P}=(0,Q.useMemo)(()=>{let e={},t=[];for(let n of M){let r=n;r.group?(e[r.group]||(e[r.group]=[]),e[r.group].push(n)):t.push(n)}return{groupedCustomAgents:Object.keys(e).sort((e,t)=>e.localeCompare(t)).map(t=>({name:t,agents:e[t]})),ungroupedCustomAgents:t}},[M]),F=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{children:t(`settings.agents.sidebar.section.custom`)}),(0,$.jsx)(Y,{"data-settings-item":`agents.create`,size:`icon`,variant:`ghost`,onClick:x,"aria-label":t(`settings.agents.page.title.new`),children:(0,$.jsx)(J,{name:`add`,className:`h-4 w-4`})})]});return(0,$.jsxs)(`div`,{className:`oc-settings-page-content h-full overflow-y-auto bg-background p-3`,children:[(0,$.jsx)(sa,{}),(0,$.jsx)($.Fragment,{children:A.length===0?(0,$.jsx)(Z,{children:(0,$.jsxs)(`div`,{className:`oc-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`robot-2`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:t(`settings.agents.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:t(`settings.agents.sidebar.empty.description`)})]})}):(0,$.jsxs)($.Fragment,{children:[j.length>0&&(0,$.jsx)(Z,{label:t(`settings.agents.sidebar.section.builtIn`),children:j.map(t=>(0,$.jsx)(xa,{agent:t,isSelected:m===t.name,onSelect:()=>{h(t.name),e?.()},onReset:()=>C(t),onDuplicate:()=>E(t),getAgentModeIcon:k,isMenuOpen:f===t.name,onMenuOpenChange:e=>p(e?t.name:null)},t.name))}),M.length>0&&(0,$.jsxs)($.Fragment,{children:[N.map(({name:n,agents:r})=>(0,$.jsx)(ma,{label:n,count:r.length,storageKey:`agents`,variant:`settings-card`,labelPrefix:t(`settings.agents.sidebar.section.custom`),children:r.map(t=>(0,$.jsx)(xa,{agent:t,isSelected:m===t.name,onSelect:()=>{h(t.name),e?.()},onRename:()=>D(t),onDelete:()=>S(t),onDuplicate:()=>E(t),getAgentModeIcon:k,isMenuOpen:f===t.name,onMenuOpenChange:e=>p(e?t.name:null)},t.name))},n)),P.length>0?(0,$.jsx)(Z,{label:F,children:P.map(t=>(0,$.jsx)(xa,{agent:t,isSelected:m===t.name,onSelect:()=>{h(t.name),e?.()},onRename:()=>D(t),onDelete:()=>S(t),onDuplicate:()=>E(t),getAgentModeIcon:k,isMenuOpen:f===t.name,onMenuOpenChange:e=>p(e?t.name:null)},t.name))}):(0,$.jsx)(Z,{label:F,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]}),M.length===0&&(0,$.jsx)(Z,{label:F,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]})}),(0,$.jsx)(qt,{open:o!==null&&c!==null,onOpenChange:e=>{!e&&!u&&w()},children:(0,$.jsxs)(Wt,{className:`max-w-md`,children:[(0,$.jsxs)(Ht,{children:[(0,$.jsx)(Gt,{children:t(c===`delete`?`settings.agents.sidebar.dialog.deleteTitle`:`settings.agents.sidebar.dialog.resetTitle`)}),(0,$.jsx)(Kt,{children:t(c===`delete`?`settings.agents.sidebar.dialog.deleteDescription`:`settings.agents.sidebar.dialog.resetDescription`,{name:o?.name??``})})]}),(0,$.jsxs)(Ut,{children:[(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:w,disabled:u,children:t(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{size:`sm`,onClick:T,disabled:u,children:t(c===`delete`?`settings.common.actions.delete`:`settings.common.actions.reset`)})]})]})}),(0,$.jsx)(qt,{open:n!==null,onOpenChange:e=>!e&&r(null),children:(0,$.jsxs)(Wt,{children:[(0,$.jsxs)(Ht,{children:[(0,$.jsx)(Gt,{children:t(`settings.agents.sidebar.renameDialog.title`)}),(0,$.jsx)(Kt,{children:t(`settings.agents.sidebar.renameDialog.description`,{name:n?.name??``})})]}),(0,$.jsx)(ln,{value:i,onChange:e=>a(e.target.value),placeholder:t(`settings.agents.sidebar.renameDialog.placeholder`),className:`text-foreground placeholder:text-muted-foreground`,onKeyDown:e=>{e.key===`Enter`&&O()}}),(0,$.jsxs)(Ut,{children:[(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>r(null),children:t(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{size:`sm`,onClick:O,children:t(`settings.common.actions.rename`)})]})]})})]})},xa=e=>{let t=(0,bi.c)(52),{agent:n,isSelected:r,onSelect:i,onDelete:a,onReset:o,onRename:s,onDuplicate:c,getAgentModeIcon:l,isMenuOpen:u,onMenuOpenChange:d}=e,{t:f}=Te(),p=n,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=dr(),t[0]=m):m=t[0];let h=m,[g,_]=Q.useState(!1),v;t[1]!==a||t[2]!==c||t[3]!==s||t[4]!==o||t[5]!==f?(v=e=>(0,$.jsxs)($.Fragment,{children:[s&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),s()},children:[(0,$.jsx)(J,{name:`edit`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.rename`)]}),(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),c()},children:[(0,$.jsx)(J,{name:`file-copy`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.duplicate`)]}),o&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),o()},children:[(0,$.jsx)(J,{name:`restart`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.reset`)]}),a&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),a()},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(J,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.delete`)]})]}),t[1]=a,t[2]=c,t[3]=s,t[4]=o,t[5]=f,t[6]=v):v=t[6];let y=v,b=r?`bg-interactive-selection`:`hover:bg-interactive-hover`,x;t[7]===b?x=t[8]:(x=q(`oc-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,b),t[7]=b,t[8]=x);let S;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(S=h?void 0:e=>{e.preventDefault(),_(!0)},t[9]=S):S=t[9];let C;t[10]===x?C=t[11]:(C=(0,$.jsx)(`div`,{className:x,onContextMenu:S}),t[10]=x,t[11]=C);let w;t[12]===n.name?w=t[13]:(w=(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:n.name}),t[12]=n.name,t[13]=w);let T;t[14]!==n.mode||t[15]!==l?(T=l(n.mode),t[14]=n.mode,t[15]=l,t[16]=T):T=t[16];let E;t[17]!==n||t[18]!==p.scope||t[19]!==f?(E=(p.scope||Pe(n))&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:Pe(n)?f(`settings.agents.sidebar.badge.system`):p.scope}),t[17]=n,t[18]=p.scope,t[19]=f,t[20]=E):E=t[20];let D;t[21]!==w||t[22]!==T||t[23]!==E?(D=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[w,T,E]}),t[21]=w,t[22]=T,t[23]=E,t[24]=D):D=t[24];let O;t[25]===n.description?O=t[26]:(O=n.description&&(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight`,children:n.description}),t[25]=n.description,t[26]=O);let k;t[27]!==i||t[28]!==D||t[29]!==O?(k=(0,$.jsxs)(`button`,{onClick:i,className:`flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,tabIndex:0,children:[D,O]}),t[27]=i,t[28]=D,t[29]=O,t[30]=k):k=t[30];let A;t[31]===d?A=t[32]:(A=e=>{e&&_(!1),d(e)},t[31]=d,t[32]=A);let j;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(qn,{asChild:!0,children:(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,className:`h-6 w-6 px-0 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(J,{name:`more-2`,className:`h-3.5 w-3.5`})})}),t[33]=j):j=t[33];let M;t[34]===y?M=t[35]:(M=(0,$.jsx)(Un,{align:`end`,className:`w-fit min-w-20`,children:y(Jn)}),t[34]=y,t[35]=M);let N;t[36]!==u||t[37]!==A||t[38]!==M?(N=(0,$.jsxs)(Wn,{open:u,onOpenChange:A,children:[j,M]}),t[36]=u,t[37]=A,t[38]=M,t[39]=N):N=t[39];let P;t[40]!==k||t[41]!==N?(P=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[k,N]}),t[40]=k,t[41]=N,t[42]=P):P=t[42];let F;t[43]!==P||t[44]!==C?(F=(0,$.jsx)(ui,{render:C,children:P}),t[43]=P,t[44]=C,t[45]=F):F=t[45];let I;t[46]===y?I=t[47]:(I=(0,$.jsx)(di,{className:`w-fit min-w-20`,children:y(fi)}),t[46]=y,t[47]=I);let L;return t[48]!==g||t[49]!==F||t[50]!==I?(L=(0,$.jsxs)(pi,{open:g,onOpenChange:_,children:[F,I]}),t[48]=g,t[49]=F,t[50]=I,t[51]=L):L=t[51],L},Sa=e=>[...e].sort((e,t)=>{let n=e.permission.localeCompare(t.permission);return n===0?e.pattern.localeCompare(t.pattern):n}),Ca=(e,t)=>{let n=Sa(e),r=Sa(t);return n.length===r.length&&n.every((e,t)=>{let n=r[t];return e.permission===n.permission&&e.pattern===n.pattern&&e.action===n.action})},wa=(e,t)=>t?e.globalPermission!==t.globalPermission||!Ca(e.permissionRules,t.permissionRules):!1,Ta=e=>{let t=e.trim();return t===``?null:t},Ea=e=>{let t=e.trim();return t===``?null:t},Da=e=>e.trim()||void 0,Oa=e=>e.trim()||null,ka=({isNewAgent:e,agentName:t,draftScope:n,draftHasExplicitPermission:r,current:i,initial:a,permissionConfig:o})=>{if(e){let e=wa(i,a)||r,s=i.description.trim(),c=Ta(i.model),l=Ea(i.variant),u=Da(i.prompt);return{name:t,mode:i.mode,...s?{description:s}:{},...c?{model:c}:{},...l?{variant:l}:{},...i.temperature===void 0?{}:{temperature:i.temperature},...i.topP===void 0?{}:{top_p:i.topP},...u?{prompt:u}:{},...e?{permission:o}:{},...n?{scope:n}:{}}}let s={name:t};if(!a)return s;if(i.description!==a.description){let e=i.description.trim();e&&(s.description=e)}return i.mode!==a.mode&&(s.mode=i.mode),i.model!==a.model&&(s.model=Ta(i.model)),i.variant!==a.variant&&(s.variant=Ea(i.variant)??null),i.temperature!==a.temperature&&(s.temperature=i.temperature??null),i.topP!==a.topP&&(s.top_p=i.topP??null),i.prompt!==a.prompt&&(s.prompt=Oa(i.prompt)),wa(i,a)&&(s.permission=o),s},Aa=[`*`,`read`,`edit`,`glob`,`grep`,`list`,`bash`,`task`,`skill`,`lsp`,`todoread`,`todowrite`,`webfetch`,`websearch`,`codesearch`,`external_directory`,`doom_loop`,`question`,`plan_enter`,`plan_exit`],ja=e=>e===`allow`||e===`ask`||e===`deny`,Ma=(e,t)=>`${e}::${t}`,Na=e=>{let t=new Map;for(let n of e)!n.permission||n.permission===`invalid`||n.pattern&&ja(n.action)&&t.set(Ma(n.permission,n.pattern),{permission:n.permission,pattern:n.pattern,action:n.action});return Array.from(t.values())},Pa=e=>{let t=new Map;for(let n of Na(e))t.set(Ma(n.permission,n.pattern),n);return t},Fa=e=>[...e].sort((e,t)=>{let n=e.permission.localeCompare(t.permission);return n===0?e.pattern.localeCompare(t.pattern):n}),Ia=(e,t)=>{let n=Fa(Na(e)),r=Fa(Na(t));return n.length===r.length&&n.every((e,t)=>{let n=r[t];return e.permission===n.permission&&e.pattern===n.pattern&&e.action===n.action})},La=e=>e.find(e=>e.permission===`*`&&e.pattern===`*`)?.action??`allow`,Ra=(e,t)=>Na(e).filter(e=>e.permission!==`*`||e.pattern!==`*`).filter(e=>e.pattern!==`*`||e.action!==t),za=e=>{if(Array.isArray(e))return Na(e);if(ja(e))return[{permission:`*`,pattern:`*`,action:e}];if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=[];for(let[n,r]of Object.entries(e))if(n!==`__originalKeys`){if(ja(r)){t.push({permission:n,pattern:`*`,action:r});continue}if(r&&typeof r==`object`&&!Array.isArray(r))for(let[e,i]of Object.entries(r))ja(i)&&t.push({permission:n,pattern:e,action:i})}return t},Ba=(e,t)=>{let n=Na(t),r={};for(let e of n)(r[e.permission]||={})[e.pattern]=e.action;let i={};for(let[e,t]of Object.entries(r))if(e!==`*`){if(Object.keys(t).length===1&&t[`*`]){i[e]=t[`*`];continue}i[e]=t}return Object.keys(i).length===0?e:(e!==`allow`&&(i[`*`]=e),i)},Va=(e,t)=>{let n=ct(t);if(!n)return[];let r=e.find(e=>e.id===n.providerId)?.models?.find(e=>e.id===n.modelId);return r?.variants?Object.keys(r.variants):[]},Ha=()=>{let{t:e}=Te(),t=Ke(e=>e.providers),{selectedAgentName:n,getAgentByName:r,createAgent:i,updateAgent:a,agentDraft:o,setAgentDraft:s}=qe(me(e=>({selectedAgentName:e.selectedAgentName,getAgentByName:e.getAgentByName,createAgent:e.createAgent,updateAgent:e.updateAgent,agentDraft:e.agentDraft,setAgentDraft:e.setAgentDraft}))),{data:c=[]}=dt(),l=n?r(n):null,u=!!(o&&o.name===n&&!l),[d,f]=Q.useState(``),[p,m]=Q.useState(`user`),[h,g]=Q.useState(``),[_,v]=Q.useState(`subagent`),[y,b]=Q.useState(``),[x,S]=Q.useState(``),[C,w]=Q.useState(void 0),[T,E]=Q.useState(void 0),[D,O]=Q.useState(``),[k,A]=Q.useState(`allow`),[j,M]=Q.useState([]),[N,P]=Q.useState([]),[F,I]=Q.useState(``),[L,R]=Q.useState(`*`),[z,B]=Q.useState(!1),[V,H]=Q.useState(!1),U=Q.useRef(null),W=ve(e=>e.currentDirectory??null),[ee,G]=Q.useState([]),te=Q.useMemo(()=>Va(t,y),[y,t]),ne=te.length>0,re=Q.useMemo(()=>!x||!te.includes(x)?`__default`:x,[x,te]),ie=ne&&(!x||te.includes(x)),ae=Ue(e=>e.permission);Q.useEffect(()=>{let e=!1;return(async()=>{let t=await _e.listToolIds({directory:W});if(e)return;let n=new Set([`write`,`patch`,`multiedit`]),r=t.map(e=>typeof e==`string`?e.trim():``).filter(Boolean).filter(e=>e!==`*`).filter(e=>e!==`invalid`).filter(e=>!n.has(e));G(Array.from(new Set(r)).sort((e,t)=>e.localeCompare(t)))})(),()=>{e=!0}},[W]);let oe=Q.useMemo(()=>{let e=new Set;for(let t of c){let n=Na(za(t.permission));for(let t of n)t.permission&&t.permission!==`*`&&t.permission!==`invalid`&&e.add(t.permission)}for(let t of Object.values(ae))for(let n of t){let t=n.permission?.trim();t&&t!==`invalid`&&e.add(t)}for(let t of ee)e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[c,ae,ee]),se=Q.useMemo(()=>Pa(j),[j]),ce=Q.useMemo(()=>Pa(N),[N]),le=Q.useCallback(e=>ce.get(Ma(e,`*`))?.action,[ce]),ue=Q.useCallback(e=>N.filter(t=>t.permission===e&&t.pattern!==`*`).sort((e,t)=>e.pattern.localeCompare(t.pattern)),[N]),de=Q.useMemo(()=>{let e=new Set;for(let t of Aa)e.add(t);for(let t of oe)e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[oe]),fe=Q.useCallback(e=>{let t=e===`*`?k:le(e)??k,n=ue(e),r=n.reduce((e,t)=>(e[t.action]=(e[t.action]??0)+1,e),{allow:0,ask:0,deny:0}),i=[`allow`,`ask`,`deny`].filter(e=>r[e]>0).map(e=>`${r[e]} ${e}`).join(`, `);return{defaultAction:t,patternRulesCount:n.length,patternSummary:i,hasDefaultHint:!1}},[ue,le,k]),pe=Q.useCallback(t=>e(t===`allow`?`settings.common.permission.allow`:t===`deny`?`settings.common.permission.deny`:`settings.common.permission.ask`),[e]),he=Q.useCallback(t=>t===`global`?e(`settings.common.scope.global`):pe(t),[pe,e]),ge=Q.useMemo(()=>{let e=new Set;for(let t of Aa)e.add(t);for(let t of oe)e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[oe]),ye=Q.useCallback((e,t,n)=>{P(r=>{let i=Pa(r);return i.set(Ma(e,t),{permission:e,pattern:t,action:n}),Array.from(i.values())})},[]),be=Q.useCallback((e,t)=>{P(n=>{let r=Pa(n);return r.delete(Ma(e,t)),Array.from(r.values())})},[]),xe=Q.useCallback((e,t)=>{let n=se.get(Ma(e,t));if(n){ye(e,t,n.action);return}be(e,t)},[se,be,ye]),Se=Q.useCallback((e,t,n)=>{ye(e,t,n)},[ye]),Ce=Q.useCallback(e=>{A(e),P(t=>t.filter(t=>t.pattern!==`*`||t.action!==e))},[]),we=Q.useCallback(t=>{let n=F.trim();if(!n){K.error(e(`settings.agents.page.toast.permissionNameRequired`));return}let r=L.trim()||`*`;if(n===`*`&&r===`*`){Ce(t),I(``),R(`*`);return}r===`*`&&n!==`*`&&t===k?be(n,`*`):ye(n,r,t),I(``),R(`*`)},[k,F,L,be,Ce,e,ye]),Ee=Q.useCallback(t=>t===`*`?e(`settings.agents.page.permissions.defaultLabel`):t===`webfetch`?`WebFetch`:t===`websearch`?`WebSearch`:t===`codesearch`?`CodeSearch`:t===`doom_loop`?`Doom Loop`:t===`external_directory`?`External Directory`:t===`todowrite`?`TodoWrite`:t===`todoread`?`TodoRead`:t.split(/[_-]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `),[e]);Q.useEffect(()=>{I(``),R(`*`);let e=e=>{let t=Na(e),n=La(t),r=Ra(t,n);return A(n),M(r),P(r),{global:n,rules:r}};if(u&&o){let t=o.name||``,n=o.scope||`user`,r=o.description||``,i=o.mode||`subagent`,a=o.model||``,s=o.variant||``,c=o.temperature??void 0,l=o.top_p??void 0,u=o.prompt||``;f(t),m(n),g(r),v(i),b(a),S(s),w(c),E(l),O(u);let d=e(za(o.permission));U.current={draftName:t,draftScope:n,description:r,mode:i,model:a,variant:s,temperature:c,topP:l,prompt:u,globalPermission:d.global,permissionRules:d.rules};return}if(l&&n===l.name){let t=l.description||``,n=l.mode||`subagent`,r=l.model?.providerID&&l.model?.modelID?`${l.model.providerID}/${l.model.modelID}`:``,i=l.variant||``,a=l.temperature,o=l.topP,s=l.prompt||``;g(t),v(n),b(r),S(i),w(a),E(o),O(s);let c=e(za(l.permission));U.current={draftName:``,draftScope:`user`,description:t,mode:n,model:r,variant:i,temperature:a,topP:o,prompt:s,globalPermission:c.global,permissionRules:c.rules}}},[o,u,l,n]);let De=Q.useMemo(()=>{let e=U.current;return e?!!(u&&(d!==e.draftName||p!==e.draftScope)||h!==e.description||_!==e.mode||y!==e.model||x!==e.variant||C!==e.temperature||T!==e.topP||D!==e.prompt||k!==e.globalPermission||!Ia(N,e.permissionRules)):!1},[h,d,p,k,u,_,y,N,D,C,T,x]);return n?(0,$.jsx)(Jt,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(`div`,{className:`mb-4 flex items-center justify-between gap-4`,children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:u?e(`settings.agents.page.title.new`):n}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:e(u?`settings.agents.page.subtitle.new`:`settings.agents.page.subtitle.edit`)})]})}),(0,$.jsxs)(Z,{label:e(`settings.agents.page.section.identityRole`),children:[u&&(0,$.jsxs)(Ar,{itemId:`agents.name`,label:e(`settings.agents.page.field.agentName`),children:[(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground mr-1`,children:`@`}),(0,$.jsx)(ln,{value:d,onChange:e=>f(e.target.value),placeholder:e(`settings.agents.page.field.agentNamePlaceholder`),className:`h-7 w-40 px-2`})]}),(0,$.jsxs)(tn,{value:p,onValueChange:e=>m(e),children:[(0,$.jsx)(cn,{className:`w-fit min-w-[100px]`,children:(0,$.jsx)(Qt,{placeholder:e(`settings.agents.page.field.scopePlaceholder`)})}),(0,$.jsxs)(en,{align:`end`,children:[(0,$.jsx)(sn,{value:`user`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{name:`user-3`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.global`)})]})}),(0,$.jsx)(sn,{value:`project`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{name:`folder`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.project`)})]})})]})]})]}),(0,$.jsx)(Ar,{label:e(`settings.common.field.description`),className:`oc-settings-split-row-stacked`,children:(0,$.jsx)(on,{embedded:!0,value:h,onChange:e=>g(e.target.value),placeholder:e(`settings.agents.page.field.descriptionPlaceholder`),rows:2,className:`w-full resize-none min-h-[60px] bg-transparent`})}),(0,$.jsx)(Ar,{itemId:`agents.mode`,className:`oc-settings-agents-mode-row`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.field.mode`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.agents.page.field.modeTooltip`)})]})]}),children:(0,$.jsxs)(`div`,{className:`flex flex-nowrap items-center justify-end gap-1`,children:[(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":_===`primary`,onClick:()=>v(`primary`),className:`!font-normal shrink-0`,children:e(`settings.agents.page.mode.primary`)}),(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":_===`subagent`,onClick:()=>v(`subagent`),className:`!font-normal shrink-0`,children:e(`settings.agents.page.mode.subagent`)}),(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":_===`all`,onClick:()=>v(`all`),className:`!font-normal shrink-0`,children:e(`settings.agents.page.mode.all`)})]})})]}),(0,$.jsxs)(Z,{label:e(`settings.agents.page.section.modelParameters`),children:[(0,$.jsx)(Ar,{itemId:`agents.model`,label:e(`settings.agents.page.field.overrideModel`),children:(0,$.jsx)(ar,{providerId:ct(y)?.providerId??``,modelId:ct(y)?.modelId??``,onChange:(e,t)=>{b(e&&t?`${e}/${t}`:``),S(``)},className:`oc-settings-inline-value`})}),(0,$.jsx)(Ar,{itemId:`agents.variant`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.field.variant`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.agents.page.field.variantTooltip`)})]})]}),description:e(`settings.agents.page.field.variantHint`),children:ie?(0,$.jsxs)(tn,{value:re,onValueChange:e=>S(e===`__default`?``:e),children:[(0,$.jsx)(cn,{className:`w-fit min-w-[10rem] max-w-full`,children:(0,$.jsx)(Qt,{placeholder:e(`settings.agents.page.field.variantPlaceholder`),children:t=>t===`__default`?e(`chat.modelControls.default`):t})}),(0,$.jsxs)(en,{children:[(0,$.jsx)(sn,{value:`__default`,children:e(`chat.modelControls.default`)}),te.map(e=>(0,$.jsx)(sn,{value:e,children:e},e))]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ln,{value:x,onChange:e=>S(e.target.value),placeholder:e(`settings.agents.page.field.variantPlaceholder`),disabled:!y&&!x,className:`h-7 w-40 max-w-full`}),x&&(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>S(``),className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":e(`settings.common.actions.clear`),title:e(`settings.common.actions.clear`),children:(0,$.jsx)(J,{name:`close`,className:`h-3.5 w-3.5`})})]})}),(0,$.jsxs)(Ar,{itemId:`agents.temperature`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.field.temperature`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.agents.page.field.temperatureTooltip`)})]})]}),description:e(`settings.agents.page.field.temperatureRange`),children:[(0,$.jsx)(Pr,{value:C,fallbackValue:.7,onValueChange:w,onClear:()=>w(void 0),min:0,max:2,step:.1,inputMode:`decimal`,placeholder:`—`,emptyLabel:`—`,className:`w-16`}),C!==void 0&&(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>w(void 0),className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":e(`settings.agents.page.field.clearTemperatureAria`),title:e(`settings.common.actions.clear`),children:(0,$.jsx)(J,{name:`close`,className:`h-3.5 w-3.5`})})]}),(0,$.jsxs)(Ar,{itemId:`agents.top-p`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.field.topP`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.agents.page.field.topPTooltip`)})]})]}),description:e(`settings.agents.page.field.topPRange`),children:[(0,$.jsx)(Pr,{value:T,fallbackValue:.9,onValueChange:E,onClear:()=>E(void 0),min:0,max:1,step:.1,inputMode:`decimal`,placeholder:`—`,emptyLabel:`—`,className:`w-16`}),T!==void 0&&(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>E(void 0),className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":e(`settings.agents.page.field.clearTopPAria`),title:e(`settings.common.actions.clear`),children:(0,$.jsx)(J,{name:`close`,className:`h-3.5 w-3.5`})})]})]}),(0,$.jsx)(Tr,{itemId:`agents.system-prompt`,label:e(`settings.agents.page.section.systemPrompt`),className:`oc-settings-split-row-stacked`,children:(0,$.jsx)(on,{embedded:!0,value:D,onChange:e=>O(e.target.value),placeholder:e(`settings.agents.page.field.systemPromptPlaceholder`),rows:8,className:`w-full font-mono typography-meta min-h-[120px] max-h-[60vh] bg-transparent resize-y`})}),(0,$.jsx)(`div`,{"data-settings-item":`agents.permissions`,children:(0,$.jsx)(Z,{label:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.section.toolPermissions`)}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>B(e=>!e),children:e(z?`settings.agents.page.permissions.hideEditor`:`settings.agents.page.permissions.advancedEditor`)})]}),children:z?(0,$.jsxs)(`div`,{className:`space-y-6 p-2`,children:[(0,$.jsx)(Ar,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.permissions.globalDefault`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 font-mono`,children:`*`})]}),children:(0,$.jsxs)(tn,{value:k,onValueChange:e=>Ce(e),children:[(0,$.jsx)(cn,{className:`w-[100px]`,children:(0,$.jsx)(Qt,{children:pe(k)})}),(0,$.jsxs)(en,{children:[(0,$.jsx)(sn,{value:`allow`,children:e(`settings.common.permission.allow`)}),(0,$.jsx)(sn,{value:`ask`,children:e(`settings.common.permission.ask`)}),(0,$.jsx)(sn,{value:`deny`,children:e(`settings.common.permission.deny`)})]})]})}),(0,$.jsx)(`div`,{className:`space-y-4`,children:de.filter(e=>e!==`*`).map(t=>{let n=Ee(t),{defaultAction:r,patternRulesCount:i}=fe(t),a=le(t),o=a??`global`,s=ue(t),c=[`allow`,`ask`,`deny`].filter(e=>e!==k);return(0,$.jsxs)(`div`,{className:`border-t border-[var(--surface-subtle)] pt-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between py-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:n}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 font-mono`,children:t})]}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:i>0?e(`settings.agents.page.permissions.globalSummary`,{summary:r}):r})]}),(0,$.jsxs)(`div`,{className:`space-y-1 pl-2 mt-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 py-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:e(`settings.agents.page.permissions.pattern`)}),(0,$.jsx)(`span`,{className:`typography-micro font-mono text-foreground bg-[var(--surface-muted)] px-1 rounded`,children:`*`}),a&&(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>xe(t,`*`),className:`px-1.5 py-0 h-5`,children:(0,$.jsx)(J,{name:`subtract`,className:`h-3.5 w-3.5 text-muted-foreground hover:text-foreground`})})]}),(0,$.jsxs)(tn,{value:o,onValueChange:e=>{if(e===`global`){be(t,`*`);return}ye(t,`*`,e)},children:[(0,$.jsx)(cn,{className:`w-[90px]`,children:(0,$.jsx)(Qt,{children:he(o)})}),(0,$.jsxs)(en,{children:[(0,$.jsx)(sn,{value:`global`,children:e(`settings.common.scope.global`)}),c.map(e=>(0,$.jsx)(sn,{value:e,className:`capitalize`,children:pe(e)},e))]})]})]}),s.map(t=>{let n=Ma(t.permission,t.pattern),r=se.get(n),i=!r,a=!!(r&&r.action!==t.action);return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 py-0.5 border-t border-[var(--surface-subtle)]`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:e(`settings.agents.page.permissions.pattern`)}),(0,$.jsx)(`span`,{className:`typography-micro font-mono text-foreground bg-[var(--surface-muted)] px-1 rounded`,children:t.pattern}),i&&(0,$.jsx)(`span`,{className:`typography-micro text-[var(--status-success)]`,children:e(`settings.common.badge.new`)}),a&&(0,$.jsx)(`span`,{className:`typography-micro text-[var(--status-warning)]`,children:e(`settings.common.badge.modified`)}),(i||a)&&(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>i?be(t.permission,t.pattern):xe(t.permission,t.pattern),className:`px-1.5 py-0 h-5`,children:(0,$.jsx)(J,{name:`subtract`,className:`h-3.5 w-3.5 text-muted-foreground hover:text-foreground`})})]}),(0,$.jsxs)(tn,{value:t.action,onValueChange:e=>Se(t.permission,t.pattern,e),children:[(0,$.jsx)(cn,{className:`w-[90px]`,children:(0,$.jsx)(Qt,{children:pe(t.action)})}),(0,$.jsxs)(en,{children:[(0,$.jsx)(sn,{value:`allow`,children:e(`settings.common.permission.allow`)}),(0,$.jsx)(sn,{value:`ask`,children:e(`settings.common.permission.ask`)}),(0,$.jsx)(sn,{value:`deny`,children:e(`settings.common.permission.deny`)})]})]})]},n)})]})]},t)})}),(0,$.jsxs)(`div`,{className:`border-t border-[var(--surface-subtle)] pt-3`,children:[(0,$.jsx)(`h4`,{className:`typography-ui-label text-foreground mb-2`,children:e(`settings.agents.page.permissions.addCustomRule`)}),(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-end sm:items-center gap-2`,children:[(0,$.jsxs)(tn,{value:F,onValueChange:I,children:[(0,$.jsx)(cn,{className:`w-full sm:w-[160px]`,children:F?(0,$.jsx)(`span`,{className:`truncate`,children:Ee(F)}):(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e(`settings.agents.page.permissions.permissionPlaceholder`)})}),(0,$.jsx)(en,{children:ge.map(e=>(0,$.jsx)(sn,{value:e,children:(0,$.jsx)(`div`,{className:`flex items-center justify-between gap-2 w-full`,children:(0,$.jsx)(`span`,{children:Ee(e)})})},e))})]}),(0,$.jsx)(ln,{value:L,onChange:e=>R(e.target.value),placeholder:e(`settings.agents.page.permissions.patternPlaceholder`),className:`h-7 flex-1 font-mono text-xs`}),(0,$.jsxs)(`div`,{className:`flex gap-1`,children:[(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>we(`allow`),children:e(`settings.common.permission.allow`)}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>we(`ask`),children:e(`settings.common.permission.ask`)}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>we(`deny`),children:e(`settings.common.permission.deny`)})]})]})]})]}):(0,$.jsx)($.Fragment,{children:de.map(t=>{let{defaultAction:n,patternRulesCount:r,patternSummary:i,hasDefaultHint:a}=fe(t),o=Ee(t),s=a?`${n} (env blocked)`:n;return(0,$.jsx)(Ar,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:o}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 font-mono hidden sm:inline-block`,children:t})]}),children:(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[r>0?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-[var(--surface-muted)] px-1.5 py-0.5 rounded`,children:e(`settings.agents.page.permissions.globalSummary`,{summary:s})}):(0,$.jsx)(`span`,{className:q(`typography-micro capitalize px-1.5 py-0.5 rounded`,s===`allow`?`text-[var(--status-success)] bg-[var(--status-success)]/10`:s===`deny`?`text-[var(--status-error)] bg-[var(--status-error)]/10`:`text-[var(--status-warning)] bg-[var(--status-warning)]/10`),children:s}),r>0&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-[var(--surface-muted)] px-1.5 py-0.5 rounded`,children:e(`settings.agents.page.permissions.rulesSummary`,{summary:i})})]})},t)})})})}),(0,$.jsx)(`div`,{className:`px-2 py-1`,children:(0,$.jsx)(Y,{onClick:async()=>{let t=u?d.trim().replace(/\s+/g,`-`):n?.trim();if(!t){K.error(e(`settings.agents.sidebar.toast.agentNameRequired`));return}if(u&&c.some(e=>e.name===t)){K.error(e(`settings.agents.sidebar.toast.agentExists`));return}H(!0);try{let n={description:h,mode:_,model:y,variant:x,temperature:C,topP:T,prompt:D,globalPermission:k,permissionRules:N},r=U.current,c=r?{description:r.description,mode:r.mode,model:r.model,variant:r.variant,temperature:r.temperature,topP:r.topP,prompt:r.prompt,globalPermission:r.globalPermission,permissionRules:r.permissionRules}:null,l=ka({isNewAgent:u,agentName:t,draftScope:u?p:void 0,draftHasExplicitPermission:u&&o?.permission!==void 0,current:n,initial:c,permissionConfig:Ba(k,N)}),d;u?(d=await i(l),d.ok&&s(null)):d=await a(t,l),d.ok?d.requiresManualRestart?K.warning(e(`settings.agents.page.toast.savedManualRestart`)):K.success(e(u?`settings.agents.page.toast.created`:`settings.agents.page.toast.updated`)):K.error(e(u?`settings.agents.page.toast.createFailed`:`settings.agents.page.toast.updateFailed`))}catch(t){console.error(`Error saving agent:`,t);let n=t instanceof Error&&t.message?t.message:e(`settings.agents.page.toast.saveUnexpectedError`);K.error(n)}finally{H(!1)}},disabled:V||!De,size:`xs`,className:`!font-normal`,children:e(V?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)})})]})}):(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`robot-2`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.agents.page.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.agents.page.empty.description`)})]})})},Ua=e=>{let t=(0,bi.c)(23),{title:n,metadata:r,selected:i,onSelect:a,icon:o,actions:s,className:c}=e,l=i!==void 0&&i,u=s&&s.length>0,d=l?`bg-interactive-selection`:`hover:bg-interactive-hover`,f;t[0]!==c||t[1]!==d?(f=q(`oc-settings-group-row group relative flex items-center transition-colors duration-150`,d,c),t[0]=c,t[1]=d,t[2]=f):f=t[2];let p;t[3]===n?p=t[4]:(p=(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:n}),t[3]=n,t[4]=p);let m;t[5]!==o||t[6]!==p?(m=(0,$.jsxs)(`div`,{className:`flex max-w-full min-w-0 items-center gap-1.5`,children:[o,p]}),t[5]=o,t[6]=p,t[7]=m):m=t[7];let h;t[8]===r?h=t[9]:(h=r&&(0,$.jsx)(`div`,{className:`max-w-full truncate typography-micro leading-tight text-muted-foreground/60`,children:r}),t[8]=r,t[9]=h);let g;t[10]!==a||t[11]!==m||t[12]!==h?(g=(0,$.jsxs)(`button`,{onClick:a,"data-mobile-press-feedback":`soft`,className:`flex min-w-0 flex-1 self-stretch flex-col justify-center gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,tabIndex:0,children:[m,h]}),t[10]=a,t[11]=m,t[12]=h,t[13]=g):g=t[13];let _;t[14]!==s||t[15]!==u?(_=u&&(0,$.jsxs)(Wn,{children:[(0,$.jsx)(qn,{asChild:!0,children:(0,$.jsx)(Y,{size:`icon`,variant:`ghost`,className:`h-6 w-6 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(J,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(Un,{align:`end`,className:`w-fit min-w-20`,children:s.map(Wa)})]}),t[14]=s,t[15]=u,t[16]=_):_=t[16];let v;t[17]!==g||t[18]!==_?(v=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 self-stretch items-center`,children:[g,_]}),t[17]=g,t[18]=_,t[19]=v):v=t[19];let y;return t[20]!==f||t[21]!==v?(y=(0,$.jsx)(`div`,{className:f,children:v}),t[20]=f,t[21]=v,t[22]=y):y=t[22],y};function Wa(e){let t=e.icon;return(0,$.jsxs)(Jn,{onClick:t=>{t.stopPropagation(),e.onClick()},className:q(e.destructive&&`text-destructive focus:text-destructive`),children:[t&&(0,$.jsx)(J,{name:t,className:`h-4 w-4 mr-px`}),e.label]},e.label)}var Ga=e=>{let t=(0,bi.c)(8),{header:n,footer:r,children:i,className:a,variant:o}=e,s=o===void 0?`sidebar`:o,c=p(),l=s===`background`||c?`bg-background`:`bg-sidebar`,u;t[0]!==l||t[1]!==a?(u=q(`oc-settings-page-content h-full overflow-y-auto p-3`,l,a),t[0]=l,t[1]=a,t[2]=u):u=t[2];let d;return t[3]!==i||t[4]!==r||t[5]!==n||t[6]!==u?(d=(0,$.jsxs)(`div`,{className:u,children:[n,i,r]}),t[3]=i,t[4]=r,t[5]=n,t[6]=u,t[7]=d):d=t[7],d},Ka=`__managed_workspace__`,qa=`__current_workspace__`,Ja=()=>({enabled:!0,name:``,defaultPrompt:``,workspacePath:null,providerID:``,modelID:``,agent:null,mode:`continuous`}),Ya=e=>({enabled:e.enabled,name:e.name,defaultPrompt:e.defaultPrompt,workspacePath:e.workspacePath,providerID:e.providerID,modelID:e.modelID,agent:e.agent,mode:e.mode}),Xa=e=>e.label?.trim()||e.path.replace(/[\\/]+$/,``).split(/[\\/]/).filter(Boolean).at(-1)||e.path,Za=e=>{let t=(0,bi.c)(11),{name:n,path:r,icon:i}=e,a=i===void 0?`folder`:i,o;t[0]===a?o=t[1]:(o=(0,$.jsx)(J,{name:a,className:`size-4 shrink-0 text-muted-foreground`}),t[0]=a,t[1]=o);let s=r?`max-w-[40%] shrink-0 truncate typography-ui-label text-foreground`:`min-w-0 truncate typography-ui-label text-foreground`,c;t[2]!==n||t[3]!==s?(c=(0,$.jsx)(`span`,{className:s,children:n}),t[2]=n,t[3]=s,t[4]=c):c=t[4];let l;t[5]===r?l=t[6]:(l=r?(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-micro text-muted-foreground`,title:r,children:r}):null,t[5]=r,t[6]=l);let u;return t[7]!==o||t[8]!==c||t[9]!==l?(u=(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[o,c,l]}),t[7]=o,t[8]=c,t[9]=l,t[10]=u):u=t[10],u},Qa=e=>{let t=(0,bi.c)(82),{onItemSelect:n}=e,{t:r}=Te(),i=Rt(),a=At(),o=i.data,s=zt(eo),c=zt(to),l=zt(no),[u,d]=Q.useState(!1),f;t[0]!==n||t[1]!==c||t[2]!==s||t[3]!==o?(f=()=>{!n&&s===null&&o?.assistants[0]&&c(o.assistants[0].id)},t[0]=n,t[1]=c,t[2]=s,t[3]=o,t[4]=f):f=t[4];let p=o?.assistants,m;t[5]!==n||t[6]!==c||t[7]!==s||t[8]!==p?(m=[n,c,s,p],t[5]=n,t[6]=c,t[7]=s,t[8]=p,t[9]=m):m=t[9],Q.useEffect(f,m);let h;t[10]!==n||t[11]!==c||t[12]!==s||t[13]!==o?.assistants||t[14]!==i.isSuccess?(h=()=>{i.isSuccess&&s&&s!==`new`&&!o?.assistants.some(e=>e.id===s)&&c(n?null:o?.assistants[0]?.id??null)},t[10]=n,t[11]=c,t[12]=s,t[13]=o?.assistants,t[14]=i.isSuccess,t[15]=h):h=t[15];let g=o?.assistants,_;t[16]!==n||t[17]!==c||t[18]!==s||t[19]!==i.isSuccess||t[20]!==g?(_=[n,c,s,g,i.isSuccess],t[16]=n,t[17]=c,t[18]=s,t[19]=i.isSuccess,t[20]=g,t[21]=_):_=t[21],Q.useEffect(h,_);let v;t[22]!==n||t[23]!==l?(v=()=>{l(),n?.()},t[22]=n,t[23]=l,t[24]=v):v=t[24];let y=we(v),b;t[25]!==o||t[26]!==r?(b=async e=>{if(o)try{await Ft(e,o.revision)}catch{Se.error(r(`assistants.settings.toast.toggleFailed`))}},t[25]=o,t[26]=r,t[27]=b):b=t[27];let x=we(b);if(a.isSuccess&&!a.data.supported)return null;let S;t[28]===r?S=t[29]:(S=r(`assistants.settings.description`),t[28]=r,t[29]=S);let C;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{e.preventDefault(),d(!0)},t[30]=C):C=t[30];let w;t[31]===r?w=t[32]:(w=r(`assistants.settings.descriptionLearnMore`),t[31]=r,t[32]=w);let T;t[33]===w?T=t[34]:(T=(0,$.jsx)(`a`,{href:`#assistant-share-welcome`,className:`underline underline-offset-2`,onClick:C,children:w}),t[33]=w,t[34]=T);let E;t[35]!==T||t[36]!==S?(E=(0,$.jsxs)($.Fragment,{children:[S,T]}),t[35]=T,t[36]=S,t[37]=E):E=t[37];let D=o?.enabled??!1,O;t[38]===r?O=t[39]:(O=r(`assistants.settings.instanceEnabled`),t[38]=r,t[39]=O);let k;t[40]===r?k=t[41]:(k=r(`assistants.settings.instanceEnabled`),t[40]=r,t[41]=k);let A;t[42]!==D||t[43]!==O||t[44]!==k||t[45]!==x?(A=(0,$.jsx)(Fr,{itemId:`assistants.instance-enabled`,checked:D,onChange:x,label:O,ariaLabel:k}),t[42]=D,t[43]=O,t[44]=k,t[45]=x,t[46]=A):A=t[46];let j;t[47]!==E||t[48]!==A?(j=(0,$.jsx)(Z,{description:E,children:A}),t[47]=E,t[48]=A,t[49]=j):j=t[49];let M;t[50]===u?M=t[51]:(M=(0,$.jsx)(ji,{open:u,onOpenChange:d}),t[50]=u,t[51]=M);let N;t[52]!==j||t[53]!==M?(N=(0,$.jsxs)($.Fragment,{children:[j,M]}),t[52]=j,t[53]=M,t[54]=N):N=t[54];let P;t[55]===r?P=t[56]:(P=r(`assistants.settings.listTitle`),t[55]=r,t[56]=P);let F;t[57]===P?F=t[58]:(F=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:P}),t[57]=P,t[58]=F);let I;t[59]===r?I=t[60]:(I=r(`assistants.settings.create`),t[59]=r,t[60]=I);let L;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(J,{name:`add`,className:`size-4`}),t[61]=L):L=t[61];let R;t[62]!==y||t[63]!==I?(R=(0,$.jsx)(Y,{"data-settings-item":`assistants.create`,variant:`ghost`,size:`icon`,onClick:y,"aria-label":I,children:L}),t[62]=y,t[63]=I,t[64]=R):R=t[64];let z;t[65]!==F||t[66]!==R?(z=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[F,R]}),t[65]=F,t[66]=R,t[67]=z):z=t[67];let B;t[68]!==a.isPending||t[69]!==n||t[70]!==c||t[71]!==s||t[72]!==o||t[73]!==i.isPending||t[74]!==r?(B=i.isPending||a.isPending?(0,$.jsxs)(`div`,{className:`oc-settings-group-row flex items-center justify-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`loader-4`,className:`mr-2 size-4 animate-spin`}),r(`common.loading`)]}):o?.assistants.length?o.assistants.map(e=>{let t=Dt(e.name);return(0,$.jsx)(Ua,{title:t.displayName,selected:s===e.id,onSelect:()=>{c(e.id),n?.()},icon:(0,$.jsx)(Bt,{name:e.id,emoji:t.avatarEmoji,size:24,label:t.displayName||e.name})},e.id)}):(0,$.jsx)(`div`,{className:`oc-settings-group-row text-muted-foreground`,children:r(`assistants.settings.empty`)}),t[68]=a.isPending,t[69]=n,t[70]=c,t[71]=s,t[72]=o,t[73]=i.isPending,t[74]=r,t[75]=B):B=t[75];let V;t[76]!==z||t[77]!==B?(V=(0,$.jsx)(Z,{label:z,children:B}),t[76]=z,t[77]=B,t[78]=V):V=t[78];let H;return t[79]!==N||t[80]!==V?(H=(0,$.jsx)(Ga,{variant:`background`,header:N,children:V}),t[79]=N,t[80]=V,t[81]=H):H=t[81],H},$a=({onItemDeleted:e})=>{let{t}=Te(),n=Rt(),r=At(),i=n.data,a=rt(e=>e.projects),o=zt(e=>e.settingsSelectedAssistantID),s=zt(e=>e.selectSettingsAssistant),c=zt(e=>e.defaultShareAssistant),l=zt(e=>e.setDefaultShareAssistant),u=zt(e=>e.createRequestRevision),d=zt(e=>e.requestCreate),[f,p]=Q.useState(Ja),[m,h]=Q.useState(!1),g=Q.useRef(0),_=i?.assistants.find(e=>e.id===o)??null,v=_?Dt(_.name):null,y=Dt(f.name),b=f.workspacePath??_?.managedWorkspacePath??null,x=et(b,{enabled:!0}),S=St(b,{enabled:!0}),C=x.data??[],w=S.data??[];Q.useEffect(()=>{_&&p(Ya(_))},[_]),Q.useEffect(()=>{n.isSuccess&&o&&o!==`new`&&!_&&s(null)},[s,_,o,n.isSuccess]),Q.useEffect(()=>{o!==`new`||u<=g.current||(g.current=u,p(Ja()),window.requestAnimationFrame(()=>document.getElementById(`assistant-name`)?.focus()))},[u,o]),Q.useEffect(()=>{n.isSuccess&&r.data?.serverInstanceID&&c?.serverInstanceID===r.data.serverInstanceID&&!i?.assistants.some(e=>e.id===c.assistantID)&&l(null)},[r.data,c,l,i?.assistants,n.isSuccess]),Q.useEffect(()=>{n.isSuccess&&Ot()},[i?.revision,n.isSuccess]);let T=(e,t)=>{p(n=>({...n,[e]:t}))},E=we(()=>d()),D=we(async()=>{if(!f.name.trim()||!f.providerID||!f.modelID){Se.error(t(`assistants.settings.validation.required`));return}h(!0);try{let e=_?await Pt(_,f):await It(f);s(e.id),Se.success(t(`assistants.settings.toast.saved`))}catch{Se.error(t(`assistants.settings.toast.saveFailed`))}finally{h(!1)}}),O=we(async()=>{if(!(!_||!window.confirm(t(`assistants.settings.deleteConfirm`,{name:_.name})))){h(!0);try{if(await jt(_),c?.assistantID===_.id){let e=await Mt();e.serverInstanceID&&c.serverInstanceID===e.serverInstanceID&&l(null)}s(null),e?.(),Se.success(t(`assistants.settings.toast.deleted`))}catch{Se.error(t(`assistants.settings.toast.deleteFailed`))}finally{h(!1)}}}),k=we(async(e,n)=>{if(!n){l(null),kt();return}try{let t=await Mt();if(!t.supported||!t.serverInstanceID)return;l({serverInstanceID:t.serverInstanceID,assistantID:e}),await kt()}catch{Se.error(t(`assistants.settings.toast.toggleFailed`))}}),A=f.workspacePath===null?null:a.find(e=>e.path===f.workspacePath)??null,j=f.workspacePath!==null&&!A?f.workspacePath:null,M=f.workspacePath===null?Ka:A?A.id:qa,N=f.workspacePath===null?(0,$.jsx)(Za,{name:t(`assistants.settings.workspacePlaceholder`),icon:`cloud`}):A?(0,$.jsx)(Za,{name:Xa(A),path:A.path}):(0,$.jsx)(Za,{name:t(`assistants.settings.workspaceCurrentPath`),path:j??``,icon:`history`});return r.isSuccess&&!r.data.supported?null:n.isPending||r.isPending?(0,$.jsxs)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`loader-4`,className:`mr-2 size-4 animate-spin`}),t(`common.loading`)]}):n.isError&&!i?(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center`,children:[(0,$.jsx)(J,{name:`cloud-off`,className:`size-6 text-muted-foreground`}),(0,$.jsx)(`p`,{className:`typography-ui text-muted-foreground`,children:t(`assistants.state.unavailable`)}),(0,$.jsx)(Y,{variant:`outline`,size:`sm`,onClick:()=>void n.refetch(),children:t(`assistants.actions.retry`)})]}):(0,$.jsx)(Jt,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[n.isError&&i?(0,$.jsx)(`p`,{className:`mb-4 px-2 typography-meta text-[var(--status-warning)]`,children:t(`assistants.state.staleSnapshot`)}):null,o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`mb-4 flex items-center gap-3`,children:[(0,$.jsx)(Bt,{name:_?.id??`new`,emoji:y.avatarEmoji,size:38,label:y.displayName||f.name||t(`assistants.settings.create`)}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h2`,{className:`truncate typography-ui-header font-semibold text-foreground`,children:_?v?.displayName:t(`assistants.settings.create`)}),(0,$.jsx)(`p`,{className:`mt-0.5 typography-micro leading-none text-muted-foreground/70`,children:f.mode===`continuous`?t(`assistants.mode.continuous`):t(`assistants.mode.stateless`)})]}),_?(0,$.jsxs)(Y,{variant:`ghost`,size:`sm`,onClick:O,disabled:m,className:`text-[var(--status-error)]`,children:[(0,$.jsx)(J,{name:`delete-bin`,className:`size-4`}),t(`assistants.settings.delete`)]}):null]}),(0,$.jsxs)(Z,{children:[(0,$.jsx)(Ar,{itemId:`assistants.name`,label:t(`assistants.settings.name`),children:(0,$.jsx)(ln,{id:`assistant-name`,value:f.name,onChange:e=>T(`name`,e.target.value),className:`min-w-0 flex-1`})}),(0,$.jsx)(Ar,{label:t(`assistants.settings.enabled`),children:(0,$.jsx)(Zt,{checked:f.enabled,onChange:e=>T(`enabled`,e),ariaLabel:t(`assistants.settings.enabled`)})}),_?(0,$.jsx)(Ar,{itemId:`assistants.default-share`,label:t(`assistants.settings.defaultShare`),children:(0,$.jsx)(Zt,{checked:c?.assistantID===_.id&&c.serverInstanceID===r.data?.serverInstanceID,onChange:e=>void k(_.id,e),ariaLabel:t(`assistants.settings.defaultShare`)})}):null]}),(0,$.jsx)(Tr,{itemId:`assistants.prompt`,label:t(`assistants.settings.defaultPrompt`),className:`oc-settings-split-row-stacked`,children:(0,$.jsx)(on,{embedded:!0,id:`assistant-prompt`,value:f.defaultPrompt,onChange:e=>T(`defaultPrompt`,e.target.value),placeholder:t(`assistants.settings.defaultPromptPlaceholder`),rows:12,outerClassName:`min-h-[240px] max-h-[70vh]`})}),(0,$.jsxs)(Z,{label:t(`assistants.settings.runtime`),children:[(0,$.jsx)(Ar,{itemId:`assistants.model`,label:t(`assistants.settings.model`),children:(0,$.jsx)(ar,{providerId:f.providerID,modelId:f.modelID,providers:C,onChange:(e,t)=>p(n=>({...n,providerID:e,modelID:t})),className:`oc-settings-inline-value`})}),(0,$.jsx)(Ar,{itemId:`assistants.agent`,label:t(`assistants.settings.agent`),children:(0,$.jsx)(nr,{agentName:f.agent??``,agents:w,onChange:e=>T(`agent`,e||null),className:`oc-settings-inline-value`})}),(0,$.jsx)(Ar,{itemId:`assistants.mode`,label:t(`assistants.settings.mode`),description:f.mode===`stateless`?t(`assistants.conversation.statelessHint`):t(`assistants.conversation.continuousHint`),children:(0,$.jsx)(`div`,{className:`flex min-w-0 flex-wrap justify-end gap-2`,children:(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[`continuous`,`stateless`].map(e=>(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":f.mode===e,onClick:()=>T(`mode`,e),children:t(e===`continuous`?`assistants.mode.continuous`:`assistants.mode.stateless`)},e))})})})]}),(0,$.jsx)(Tr,{itemId:`assistants.workspace`,label:t(`assistants.settings.workspace`),description:t(`assistants.settings.workspaceChangeHint`),descriptionPlacement:`outside`,children:(0,$.jsxs)(tn,{value:M,onValueChange:e=>{if(e===Ka){T(`workspacePath`,null);return}let t=a.find(t=>t.id===e);t&&T(`workspacePath`,t.path)},children:[(0,$.jsx)(cn,{title:f.workspacePath??t(`assistants.settings.workspacePlaceholder`),className:`w-full max-w-xl [&_[data-slot=select-value]]:min-w-0 [&_[data-slot=select-value]]:flex-1 [&_[data-slot=select-value]]:overflow-hidden`,children:(0,$.jsx)(Qt,{children:N})}),(0,$.jsxs)(en,{align:`start`,className:`w-[min(32rem,calc(100vw-2rem))]`,children:[(0,$.jsx)(sn,{value:Ka,children:(0,$.jsx)(Za,{name:t(`assistants.settings.workspacePlaceholder`),icon:`cloud`})}),a.map(e=>(0,$.jsx)(sn,{value:e.id,children:(0,$.jsx)(Za,{name:Xa(e),path:e.path})},e.id)),j?(0,$.jsx)(sn,{value:qa,disabled:!0,children:(0,$.jsx)(Za,{name:t(`assistants.settings.workspaceCurrentPath`),path:j,icon:`history`})}):null]})]})}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsxs)(Y,{onClick:D,disabled:m,children:[m?(0,$.jsx)(J,{name:`loader-4`,className:`size-4 animate-spin`}):null,t(`assistants.settings.save`)]})})]}):(0,$.jsxs)(`div`,{className:`flex min-h-80 flex-col items-center justify-center gap-3 px-6 text-center text-muted-foreground`,children:[(0,$.jsx)(Bt,{name:`assistants-empty`,size:44}),(0,$.jsx)(`p`,{className:`typography-ui`,children:t(`assistants.settings.empty`)}),(0,$.jsxs)(Y,{"data-settings-item":`assistants.create`,size:`sm`,onClick:E,children:[(0,$.jsx)(J,{name:`add`,className:`size-4`}),t(`assistants.settings.create`)]})]})]})})};function eo(e){return e.settingsSelectedAssistantID}function to(e){return e.selectSettingsAssistant}function no(e){return e.requestCreate}var ro=`~/.config/opencode/AGENTS.md`,io=async(e,t)=>{let n=await e.json().catch(()=>null);return typeof n?.error==`string`&&n.error.trim()?n.error:t},ao=e=>e.length>0&&!e.endsWith(`
|
|
1
|
+
import{o as e,r as t}from"./rolldown-runtime-C0FnF6B9.js";import{$ as n,D as r,M as i,a,j as o,o as s,r as c,t as l,u,w as d,y as f}from"./useUIStore-5agS8bsW.js";import{$t as p,Bt as m,D as h,E as g,Ht as _,Kt as v,O as y,R as b,Ut as x,Vt as S,Xt as C,Yt as w,a as T,bn as E,cn as D,d as O,en as k,et as A,f as j,gn as M,hn as N,i as P,k as F,kn as I,l as L,mn as R,qt as z,r as B,u as V,un as H,xn as U}from"./persistence-D1lIuyqO.js";import{_ as W,a as ee,g as G,h as te,i as ne,l as re,m as ie,n as ae,p as oe,r as se,t as ce,u as le}from"./desktopHosts-ZK_vkdzL.js";import{r as ue}from"./desktopRelayRestore-CewM6-g5.js";import{a as de,i as fe,r as pe,t as me}from"./vendor-zustand-B4dlGEM2.js";import{nt as he,rt as ge}from"./vendor-base-ui-CnHfUmDN.js";import{kt as _e,yt as ve}from"./gitApiHttp-BxGAFLTf.js";import{n as ye}from"./vendor-react-DLPElpoQ.js";import{s as be}from"./vendor-tanstack-react-query-D7pys_c9.js";import{W as xe}from"./vendor-codemirror-autocomplete-DHomsvW7.js";import{r as Se}from"./vendor-sonner-DVzioF3d.js";import{c as Ce,n as we}from"./vendor-reactuses-core-DDoDDyM9.js";import{n as Te,r as Ee,t as De}from"./clipboard-BnElHSnO.js";import{$a as Oe,Aa as ke,Ao as Ae,Bi as je,Co as Me,Ea as Ne,Ga as Pe,Gi as Fe,Ja as Ie,Ka as Le,Oa as Re,Qa as ze,So as Be,Ui as Ve,Vi as He,Vt as Ue,Wi as We,Xa as Ge,Xi as Ke,Ya as qe,Za as Je,_o as Ye,ai as Xe,ao as Ze,ci as Qe,co as $e,do as et,eo as tt,fo as nt,go as rt,ho as it,hr as at,ii as ot,io as st,ja as ct,jo as lt,ka as ut,lo as dt,mo as ft,no as pt,oo as mt,pi as ht,po as gt,qa as _t,ro as vt,si as yt,so as bt,to as xt,uo as St,vr as K,wo as Ct,xo as wt,yo as Tt,zi as Et}from"./useMobileNavigationStore-HUex-0LO.js";import{a as Dt,i as Ot,r as kt}from"./MobileShareBridge-DP4-LZKB.js";import{_ as At,a as jt,c as Mt,f as Nt,g as Pt,h as Ft,i as It,t as Lt,y as Rt}from"./MobileDetailNavigation-Bg_QuPCN.js";import{i as zt}from"./useAssistantUIStore-Bq3cPj2x.js";import{t as Bt}from"./AgentAvatar-B4fj9PIe.js";import{i as Vt,t as q}from"./utils-BxJEIWv5.js";import{n as J}from"./Icon-DiIuWOuC.js";import{a as Ht,i as Ut,n as Wt,o as Gt,r as Kt,t as qt}from"./dialog-COrLBm9O.js";import{t as Y}from"./button-DaAoVF4X.js";import{A as Jt,E as Yt,M as Xt,N as Zt,S as Qt,a as $t,g as en,h as tn,i as nn,j as rn,n as an,o as on,v as sn,x as cn}from"./projectMeta-DH0IEQHg.js";import{t as ln}from"./input-XiL2-2gG.js";import{i as un,n as dn,t as fn}from"./tooltip-BLugzWq-.js";import{C as pn,D as mn,E as hn,H as gn,K as _n,M as vn,N as yn,O as bn,R as xn,S as Sn,T as Cn,U as wn,V as Tn,W as En,a as Dn,b as On,c as kn,f as An,i as jn,j as Mn,p as Nn,q as Pn,s as Fn,t as In,u as X,w as Ln,x as Rn,y as zn,z as Bn}from"./useSessionAutoCleanup-D5Jpkm06.js";import{n as Vn}from"./useThemeSystem-DMzWVJaW.js";import{A as Hn,D as Un,E as Wn,H as Gn,J as Kn,N as qn,O as Jn,Q as Yn,R as Xn,U as Zn,V as Qn,Y as $n,a as er,f as tr,h as nr,i as rr,j as ir,p as ar,q as or,r as sr,s as cr,t as lr}from"./radio-DsGscCu_.js";import{i as ur,r as dr,t as fr}from"./OverlayScrollbar-D0aykf8w.js";import{n as pr}from"./useRuntimeAPIs-DSLXJybW.js";import{c as mr,i as hr,n as gr}from"./appThemeRegistry-BTpLc0Dw.js";import{a as _r}from"./url-DMs_PgIC.js";import{p as vr}from"./markdown-worker-BDyY0vt6.js";import{t as yr}from"./sortable-tabs-strip-qJ3tLNRa.js";import{A as br,B as xr,C as Sr,D as Cr,E as wr,F as Tr,G as Er,H as Dr,I as Z,J as Or,K as kr,L as Ar,M as jr,N as Mr,O as Nr,P as Pr,R as Fr,S as Ir,T as Lr,U as Rr,V as zr,W as Br,X as Vr,Y as Hr,Z as Ur,_ as Wr,a as Gr,b as Kr,c as qr,d as Jr,f as Yr,h as Xr,j as Zr,k as Qr,l as $r,m as ei,n as ti,p as ni,q as ri,s as ii,u as ai,v as oi,w as si,y as ci,z as li}from"./MobileSurface-DjE0DFPy.js";import{a as ui,n as di,r as fi,t as pi}from"./context-menu-driZcAh3.js";import{n as mi,r as hi,t as gi}from"./collapsible-BmuQu0dq.js";import{n as _i,t as vi}from"./vendor-yaml-DIcAK3EC.js";import{t as yi}from"./vendor-qrcode-DAuVxiQR.js";var bi=ye(),Q=e(ge(),1),$=he(),xi=`https://github.com/yee94/openchamber`,Si=`https://discord.gg/ZYRSdnwwKA`,Ci=`https://x.com/openchamber_dev`,wi=800,Ti=({initialUpdateDialogOpen:e=!1})=>{let{t}=Te(),[n,r]=Q.useState(e),[i,a]=Q.useState(!1),[o,s]=Q.useState(null),[c,l]=Q.useState(null),[u,d]=Q.useState(null),f=xr(me(e=>({info:e.info,checking:e.checking,available:e.available,error:e.error,downloading:e.downloading,downloaded:e.downloaded,progress:e.progress,runtimeType:e.runtimeType,checkForUpdates:e.checkForUpdates,downloadUpdate:e.downloadUpdate,restartToUpdate:e.restartToUpdate}))),{isMobile:p}=ur(),[m,h]=Q.useState(!1),[g,_]=Q.useState(()=>Qe()),v=we(e=>{ht(e),_(e)}),y=o||t(`settings.openchamber.about.state.unknown`),b=we(async()=>{if(!m){h(!0);try{let{outcome:e,eventCount:n}=await yt();if(e===`cancelled`)return;if(e===`failed`){K.error(t(`settings.openchamber.about.diagnostics.toast.failed`));return}K.success(t(n>0?`settings.openchamber.about.diagnostics.toast.exported`:`settings.openchamber.about.diagnostics.toast.empty`))}catch{K.error(t(`settings.openchamber.about.diagnostics.toast.failed`))}finally{h(!1)}}});Q.useEffect(()=>{let e=!1;return zr().then(t=>{e||s(t)}),()=>{e=!0}},[]),Q.useEffect(()=>{let e=!1;return(async()=>{try{let t=await I(`/api/system/info`,{method:`GET`,headers:{Accept:`application/json`}});if(!t.ok)return;let n=await t.json().catch(()=>null),r=typeof n?.openchamberVersion==`string`&&n.openchamberVersion.trim().length>0?n.openchamberVersion.trim():null;e||l(r)}catch{e||l(null)}})(),()=>{e=!0}},[]),Q.useEffect(()=>{let e=!1;return(async()=>{try{let t=await I(`/api/opencode/upgrade-status`,{method:`GET`,headers:{Accept:`application/json`}});if(!t.ok)return;let n=await t.json().catch(()=>null),r=typeof n?.currentVersion==`string`&&n.currentVersion.trim().length>0?n.currentVersion.trim():null;e||d(r)}catch{e||d(null)}})(),()=>{e=!0}},[]);let x=Q.useRef(!1);Q.useEffect(()=>{if(f.checking)a(!0),x.current=!0;else if(i){let e=setTimeout(()=>{a(!1),x.current&&f.error?(K.error(t(`settings.openchamber.about.toast.checkFailed`),{description:f.error}),x.current=!1):x.current&&!f.available&&!f.error&&(K.success(t(`settings.openchamber.about.toast.latestVersion`)),x.current=!1)},wi);return()=>clearTimeout(e)}},[t,f.checking,i,f.available,f.error]);let S=f.checking||i;return p?(0,$.jsxs)(`div`,{className:`w-full space-y-6 pb-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,$.jsx)(Yn,{width:72,height:72}),(0,$.jsx)(`h2`,{className:`mt-4 typography-ui-header font-semibold text-foreground`,children:`OpenChamber`})]}),(0,$.jsxs)(Z,{children:[(0,$.jsx)(Ar,{label:t(`settings.openchamber.about.field.clientVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:y})}),(0,$.jsx)(Ar,{label:t(`settings.openchamber.about.field.instanceOpenChamberVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:c||t(`settings.openchamber.about.state.unknown`)})}),(0,$.jsx)(Ar,{label:t(`settings.openchamber.about.field.instanceOpenCodeVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:u||t(`settings.openchamber.about.state.unknown`)})}),(0,$.jsx)(Ar,{children:!S&&f.available?(0,$.jsxs)(Y,{type:`button`,variant:`default`,size:`sm`,onClick:()=>r(!0),children:[(0,$.jsx)(J,{name:`download`,className:`size-4`}),t(`settings.openchamber.about.actions.updateToVersion`,{version:f.info?.version||``})]}):(0,$.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>f.checkForUpdates(),disabled:S,children:[S?(0,$.jsx)(J,{name:`loader`,className:`size-4 animate-spin`}):(0,$.jsx)(J,{name:`refresh`,className:`size-4`}),t(S?`settings.openchamber.about.state.checking`:`settings.openchamber.about.actions.checkForUpdates`)]})}),f.error&&(0,$.jsx)(Ar,{children:(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:f.error})}),(0,$.jsx)(Fr,{itemId:`about.diagnostics`,checked:g,onChange:v,label:t(`settings.openchamber.about.diagnostics.label`),ariaLabel:t(`settings.openchamber.about.diagnostics.label`)}),g&&(0,$.jsx)(Ar,{itemId:`about.export-diagnostics`,label:t(`settings.openchamber.about.diagnostics.export`),children:(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`sm`,disabled:m,onClick:()=>void b(),children:t(m?`settings.openchamber.about.diagnostics.exporting`:`settings.openchamber.about.diagnostics.export`)})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 text-center`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-center gap-5`,children:[(0,$.jsxs)(`a`,{href:xi,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground`,children:[(0,$.jsx)(J,{name:`github-fill`,className:`size-5`}),(0,$.jsx)(`span`,{children:`GitHub`})]}),(0,$.jsxs)(`a`,{href:Si,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground`,children:[(0,$.jsx)(J,{name:`discord-fill`,className:`size-5`}),(0,$.jsx)(`span`,{children:`Discord`})]})]}),(0,$.jsxs)(`a`,{href:Ci,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground`,children:[(0,$.jsx)(J,{name:`twitter-xfill`,className:`size-5`}),(0,$.jsx)(`span`,{children:`@openchamber_dev`})]})]}),(0,$.jsx)(`p`,{className:`text-center typography-ui text-muted-foreground/60`,children:t(`aboutDialog.footerNote`)}),(0,$.jsx)(li,{open:n,onOpenChange:r,info:f.info,downloading:f.downloading,downloaded:f.downloaded,progress:f.progress,error:f.error,onDownload:f.downloadUpdate,onRestart:f.restartToUpdate,runtimeType:f.runtimeType})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Z,{label:t(`settings.openchamber.about.title`),children:[(0,$.jsx)(Ar,{label:t(`settings.openchamber.about.field.clientVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:y})}),(0,$.jsx)(Ar,{label:t(`settings.openchamber.about.field.instanceOpenChamberVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:c||t(`settings.openchamber.about.state.unknown`)})}),(0,$.jsx)(Ar,{label:t(`settings.openchamber.about.field.instanceOpenCodeVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:u||t(`settings.openchamber.about.state.unknown`)})}),(0,$.jsx)(Ar,{children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-3`,children:[f.checking&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,$.jsx)(J,{name:`loader`,className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{className:`typography-meta`,children:t(`settings.openchamber.about.state.checking`)})]}),!f.checking&&f.available&&(0,$.jsxs)(Y,{size:`sm`,variant:`default`,onClick:()=>r(!0),children:[(0,$.jsx)(J,{name:`download`,className:`h-4 w-4 mr-1`}),t(`settings.openchamber.about.actions.updateToVersion`,{version:f.info?.version||``})]}),!f.checking&&!f.available&&!f.error&&(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:t(`settings.openchamber.about.state.upToDate`)}),(0,$.jsx)(Y,{size:`sm`,variant:`outline`,onClick:()=>f.checkForUpdates(),disabled:f.checking,children:t(`settings.openchamber.about.actions.checkForUpdates`)})]})}),f.error&&(0,$.jsx)(Ar,{children:(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:f.error})}),(0,$.jsx)(Fr,{itemId:`about.diagnostics`,checked:g,onChange:v,label:t(`settings.openchamber.about.diagnostics.label`),ariaLabel:t(`settings.openchamber.about.diagnostics.label`)}),g&&(0,$.jsx)(Ar,{itemId:`about.export-diagnostics`,label:t(`settings.openchamber.about.diagnostics.export`),children:(0,$.jsx)(Y,{type:`button`,variant:`outline`,size:`sm`,disabled:m,onClick:()=>void b(),children:t(m?`settings.openchamber.about.diagnostics.exporting`:`settings.openchamber.about.diagnostics.export`)})}),(0,$.jsxs)(Ar,{controlClassName:`flex-wrap`,children:[(0,$.jsxs)(`a`,{href:xi,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 text-muted-foreground hover:text-foreground typography-meta transition-colors`,children:[(0,$.jsx)(J,{name:`github-fill`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:`GitHub`})]}),(0,$.jsxs)(`a`,{href:Ci,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 text-muted-foreground hover:text-foreground typography-meta transition-colors`,children:[(0,$.jsx)(J,{name:`twitter-xfill`,className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:`@openchamber_dev`})]})]})]}),(0,$.jsx)(li,{open:n,onOpenChange:r,info:f.info,downloading:f.downloading,downloaded:f.downloaded,progress:f.progress,error:f.error,onDownload:f.downloadUpdate,onRestart:f.restartToUpdate,runtimeType:f.runtimeType})]})},Ei=`/assets/android-direct-share-1a0lp154.jpg`,Di=`/assets/ios-share-sheet-B3Dlufnc.jpg`,Oi=`/assets/select-assistant-C89IRspC.jpg`,ki=`openchamber:assistant-share-welcome:v1`,Ai=[{image:Di,titleKey:`assistants.shareWelcome.example.chat.title`,descriptionKey:`assistants.shareWelcome.example.chat.description`},{image:Ei,titleKey:`assistants.shareWelcome.example.article.title`,descriptionKey:`assistants.shareWelcome.example.article.description`},{image:Oi,titleKey:`assistants.shareWelcome.example.note.title`,descriptionKey:`assistants.shareWelcome.example.note.description`}],ji=e=>{let t=(0,bi.c)(40),{enabled:n,open:r,onOpenChange:i}=e,a=n!==void 0&&n,{t:o}=Te(),[s,c]=Ce(ki,!1),l=r!==void 0,u=l?r:a&&s!==!0,d;t[0]!==l||t[1]!==i||t[2]!==c?(d=()=>{l||c(!0),i?.(!1)},t[0]=l,t[1]=i,t[2]=c,t[3]=d):d=t[3];let f=we(d),p;t[4]!==f||t[5]!==i?(p=e=>{e?i?.(!0):f()},t[4]=f,t[5]=i,t[6]=p):p=t[6];let m;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-interactive-selection text-interactive-selection-foreground sm:size-12`,children:(0,$.jsx)(J,{name:`share-2`,className:`size-5`})}),t[7]=m):m=t[7];let h;t[8]===o?h=t[9]:(h=o(`assistants.shareWelcome.title`),t[8]=o,t[9]=h);let g;t[10]===h?g=t[11]:(g=(0,$.jsx)(Gt,{className:`typography-ui-header text-left sm:text-3xl`,children:h}),t[10]=h,t[11]=g);let _;t[12]===o?_=t[13]:(_=o(`assistants.shareWelcome.description`),t[12]=o,t[13]=_);let v;t[14]===_?v=t[15]:(v=(0,$.jsx)(Kt,{className:`typography-ui text-left leading-6 sm:max-w-3xl sm:text-base sm:leading-7`,children:_}),t[14]=_,t[15]=v);let y;t[16]!==g||t[17]!==v?(y=(0,$.jsxs)(Ht,{className:`flex-row items-start gap-3 px-5 pb-5 pt-6 text-left sm:gap-4 sm:px-8 sm:pb-6 sm:pt-8`,children:[m,(0,$.jsxs)(`div`,{className:`min-w-0 space-y-1.5 sm:space-y-2`,children:[g,v]})]}),t[16]=g,t[17]=v,t[18]=y):y=t[18];let b;t[19]===o?b=t[20]:(b=o(`assistants.shareWelcome.examplesAria`),t[19]=o,t[20]=b);let x;t[21]===o?x=t[22]:(x=Ai.map((e,t)=>(0,$.jsxs)(`article`,{className:`w-[min(78vw,19rem)] shrink-0 snap-center overflow-hidden rounded-xl border border-border bg-background lg:w-auto lg:min-w-0`,children:[(0,$.jsxs)(`div`,{className:`relative overflow-hidden border-b border-border bg-muted`,children:[(0,$.jsx)(`img`,{src:e.image,alt:``,className:`h-72 w-full object-cover object-bottom lg:h-[min(38vh,23rem)]`}),(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`absolute left-3 top-3 flex size-7 items-center justify-center rounded-full bg-[var(--surface-elevated)] typography-meta font-semibold text-foreground shadow-sm`,children:t+1})]}),(0,$.jsxs)(`div`,{className:`space-y-1 px-4 py-3.5 lg:min-h-25`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:o(e.titleKey)}),(0,$.jsx)(`p`,{className:`typography-meta leading-5 text-muted-foreground`,children:o(e.descriptionKey)})]})]},e.titleKey)),t[21]=o,t[22]=x);let S;t[23]!==b||t[24]!==x?(S=(0,$.jsx)(`div`,{className:`overflow-hidden px-5 pb-5 sm:px-8 sm:pb-7`,children:(0,$.jsx)(`div`,{className:`flex snap-x snap-mandatory gap-3 overflow-x-auto pb-2 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden lg:grid lg:grid-cols-3 lg:overflow-visible lg:pb-0`,"aria-label":b,children:x})}),t[23]=b,t[24]=x,t[25]=S):S=t[25];let C;t[26]===o?C=t[27]:(C=o(`assistants.shareWelcome.action`),t[26]=o,t[27]=C);let w;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(J,{name:`arrow-right-s`,className:`size-4`}),t[28]=w):w=t[28];let T;t[29]!==f||t[30]!==C?(T=(0,$.jsx)(Ut,{className:`border-t border-border px-5 py-4 sm:px-8 sm:py-5`,children:(0,$.jsxs)(Y,{size:`lg`,className:`w-full lg:mx-auto lg:w-72`,onClick:f,children:[C,w]})}),t[29]=f,t[30]=C,t[31]=T):T=t[31];let E;t[32]!==S||t[33]!==T||t[34]!==y?(E=(0,$.jsxs)(Wt,{showCloseButton:!1,className:`w-[min(100%,31rem)] max-w-none gap-0 overflow-hidden rounded-2xl border-border bg-[var(--surface-elevated)] p-0 sm:w-[min(calc(100%-3rem),44rem)] lg:w-[min(calc(100%-4rem),74rem)]`,containerClassName:`fixed inset-0 z-50 flex items-end justify-center px-0 pt-8 sm:items-center sm:p-6`,children:[y,S,T]}),t[32]=S,t[33]=T,t[34]=y,t[35]=E):E=t[35];let D;return t[36]!==u||t[37]!==E||t[38]!==p?(D=(0,$.jsx)(qt,{open:u,onOpenChange:p,children:E}),t[36]=u,t[37]=E,t[38]=p,t[39]=D):D=t[39],D},Mi=`useCommandsStore`,Ni=new Set([`init`,`review`]),Pi=e=>new Promise(t=>setTimeout(t,e)),Fi=e=>Ni.has(e.name),Ii=async(e,t)=>{await gt(V,e,t),r()===t&&Be(`commands`,{source:Mi})},Li=de()(pe(fe(e=>({selectedCommandName:null,commandDraft:null,setSelectedCommand:t=>e({selectedCommandName:t}),setCommandDraft:t=>e({commandDraft:t}),loadCommands:async()=>{let e=ft(),t=r();try{return await gt(V,e,t),!0}catch{return!1}},createCommand:async t=>Ri(`POST`,t.name,t,e),updateCommand:async(t,n)=>Ri(`PATCH`,t,n,e),deleteCommand:async t=>Ri(`DELETE`,t,void 0,e),getCommandByName:e=>nt().find(t=>t.name===e)}),{name:`commands-store`,storage:f(),partialize:e=>({selectedCommandName:e.selectedCommandName})}),{name:`commands-store`}));async function Ri(e,t,n,i){Tt(`${{POST:`Creating`,PATCH:`Updating`,DELETE:`Deleting`}[e]} command configuration…`);let a=ft(),o=r(),s=!1;try{let r={};if(e===`POST`&&(r.template=n?.template||``,n?.description&&(r.description=n.description),n?.agent&&(r.agent=n.agent),n?.model&&(r.model=n.model),n?.scope&&(r.scope=n.scope)),e===`PATCH`)for(let e of[`description`,`agent`,`model`,`template`])n?.[e]!==void 0&&(r[e]=n[e]);let c=a?`?directory=${encodeURIComponent(a)}`:``,l=await I(`/api/config/commands/${encodeURIComponent(t)}${c}`,{method:e,headers:e===`DELETE`?a?{"x-opencode-directory":a}:void 0:{"Content-Type":`application/json`,...a?{"x-opencode-directory":a}:{}},...e===`DELETE`?{}:{body:JSON.stringify(r)}}),u=await l.json().catch(()=>null);if(!l.ok)throw Error(u?.error||`Failed to ${e.toLowerCase()} command`);return s=u?.requiresReload??!0,s?await zi(a,o,{message:u?.message,delayMs:u?.reloadDelayMs}):await Ii(a,o),e===`DELETE`&&i({selectedCommandName:null}),!0}catch(e){return console.error(`[CommandsStore] Command mutation failed:`,e),!1}finally{Ye()}}async function zi(e,t,n){n.delayMs&&await Pi(n.delayMs),wt(n.message||`Refreshing commands…`),await Ii(e,t)}typeof window<`u`&&(window.__zustand_commands_store__=Li),Ct(e=>{e.source!==Mi&&Me(e,`commands`)&&Li.getState().loadCommands()});var Bi=()=>{try{let e=rt.getState().getActiveProject?.();if(e?.path?.trim())return e.path.trim();let t=_e.getDirectory();if(t?.trim())return t.trim()}catch(e){console.warn(`[McpConfigStore] Error resolving config directory:`,e)}return null},Vi=e=>e?Object.entries(e).map(([e,t])=>({key:e,value:t})):[],Hi=e=>{let t=e.filter(e=>e.key.trim());if(t.length!==0)return Object.fromEntries(t.map(e=>[e.key.trim(),e.value]))},Ui=e=>{if(typeof e==`string`)return e.trim()||void 0},Wi=800,Gi=de()(pe(fe((e,t)=>({selectedMcpName:null,mcpDraft:null,setSelectedMcp:t=>e({selectedMcpName:t}),setMcpDraft:t=>e({mcpDraft:t}),loadMcpConfigs:async e=>{let t=Bi();try{return!e?.force&&Rr(V,t).length>0||await Er(V,t,r()),!0}catch(e){return console.error(`[McpConfigStore] Failed to load MCP configs:`,e),!1}},createMcp:async(e,t)=>{Tt(`Creating MCP server configuration…`);let n=!1,i=`directory`in(t??{})?t?.directory?.trim()||null:Bi(),a=t?.transportIdentity??r();try{let t=Ki(e),r=i?`?directory=${encodeURIComponent(i)}`:``,o=await I(`/api/config/mcp/${encodeURIComponent(e.name)}${r}`,{method:`POST`,headers:{"Content-Type":`application/json`,...i?{"x-opencode-directory":i}:{}},body:JSON.stringify(t)}),s=await o.json().catch(()=>null);if(!o.ok)throw Error(s?.error||`Failed to create MCP server`);return s?.requiresReload?(n=!0,await _t({message:s.message,delayMs:s.reloadDelayMs??Wi,scopes:[`mcp`],queryDirectory:i,transportIdentity:a}),await Er(V,i,a),await kr(V,i,a),{ok:!0,reloadFailed:s?.reloadFailed===!0,message:s?.message,warning:s?.warning}):(await Er(V,i,a),await kr(V,i,a),{ok:!0,reloadFailed:s?.reloadFailed===!0,message:s?.message,warning:s?.warning})}catch(e){return console.error(`[McpConfigStore] Failed to create MCP:`,e),{ok:!1}}finally{n||Ye()}},updateMcp:async(e,t,n)=>{Tt(`Updating MCP server configuration…`);let i=!1,a=`directory`in(n??{})?n?.directory?.trim()||null:Bi(),o=n?.transportIdentity??r();try{let n=Ki(t),r=a?`?directory=${encodeURIComponent(a)}`:``,s=await I(`/api/config/mcp/${encodeURIComponent(e)}${r}`,{method:`PATCH`,headers:{"Content-Type":`application/json`,...a?{"x-opencode-directory":a}:{}},body:JSON.stringify(n)}),c=await s.json().catch(()=>null);if(!s.ok)throw Error(c?.error||`Failed to update MCP server`);return c?.requiresReload?(i=!0,await _t({message:c.message,delayMs:c.reloadDelayMs??Wi,scopes:[`mcp`],queryDirectory:a,transportIdentity:o}),await Er(V,a,o),await kr(V,a,o),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}):(await Er(V,a,o),await kr(V,a,o),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning})}catch(e){throw console.error(`[McpConfigStore] Failed to update MCP:`,e),e}finally{i||Ye()}},deleteMcp:async(n,i)=>{Tt(`Deleting MCP server configuration…`);let a=!1,o=`directory`in(i??{})?i?.directory?.trim()||null:Bi(),s=i?.transportIdentity??r();try{let r=o?`?directory=${encodeURIComponent(o)}`:``,i=await I(`/api/config/mcp/${encodeURIComponent(n)}${r}`,{method:`DELETE`,headers:o?{"x-opencode-directory":o}:void 0}),c=await i.json().catch(()=>null);if(!i.ok)throw Error(c?.error||`Failed to delete MCP server`);return c?.requiresReload&&(a=!0,await _t({message:c.message,delayMs:c.reloadDelayMs??Wi,scopes:[`mcp`],queryDirectory:o,transportIdentity:s})),t().selectedMcpName===n&&e({selectedMcpName:null}),Dr.getState().clearDiagnostic(n,o,s),await Er(V,o,s),await kr(V,o,s),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}}catch(e){return console.error(`[McpConfigStore] Failed to delete MCP:`,e),{ok:!1}}finally{a||Ye()}}}),{name:`mcp-config-store`,storage:f(),partialize:e=>({selectedMcpName:e.selectedMcpName})}),{name:`mcp-config-store`}));function Ki(e){let t={};if(e.scope!==void 0&&(t.scope=e.scope),e.type!==void 0&&(t.type=e.type),(e.type===`local`||e.command!==void 0)&&(t.command=(e.command??[]).filter(e=>e.trim())),(e.type===`remote`||e.url!==void 0)&&(t.url=e.url?.trim()??``),e.environment!==void 0&&(t.environment=Hi(e.environment)??{}),e.headers!==void 0&&(t.headers=Hi(e.headers)??{}),e.oauthEnabled!==void 0||e.oauthClientId!==void 0||e.oauthClientSecret!==void 0||e.oauthScope!==void 0||e.oauthRedirectUri!==void 0)if(e.oauthEnabled===!1)t.oauth=!1;else{let n={clientId:Ui(e.oauthClientId),clientSecret:Ui(e.oauthClientSecret),scope:Ui(e.oauthScope),redirectUri:Ui(e.oauthRedirectUri)};t.oauth=n.clientId||n.clientSecret||n.scope||n.redirectUri?n:e.oauthEnabled?{}:!1}if(e.timeout!==void 0){let n=Number(e.timeout);t.timeout=Number.isFinite(n)&&n>0?n:null}return e.enabled!==void 0&&(t.enabled=e.enabled),t}var qi=()=>{let e=_e.getDirectory();if(typeof e==`string`&&e.trim().length>0)return e;try{let e=window.__zustand_directory_store__;if(e)return e.getState().currentDirectory}catch{}return null},Ji=`useSkillsStore`,Yi=e=>new Promise(t=>setTimeout(t,e)),Xi=e=>{if(e&&Object.prototype.hasOwnProperty.call(e,`directory`))return typeof e.directory==`string`&&e.directory.trim()||null;let t=qi();return typeof t==`string`&&t.trim()||null},Zi=2e4,Qi=300,$i=4,ea=800,ta=200,na=2e3,ra=de()(pe(fe((e,t)=>({selectedSkillName:null,skillDraft:null,setSelectedSkill:t=>{e({selectedSkillName:t})},setSkillDraft:t=>{e({skillDraft:t})},loadSkills:async()=>{try{return await Je(V,qi(),r()),!0}catch{return!1}},getSkillDetail:async e=>{try{let t=qi(),n=t?`?directory=${encodeURIComponent(t)}`:``,r=await I(`/api/config/skills/${encodeURIComponent(e)}${n}`);return r.ok?await r.json():null}catch{return null}},createSkill:async(e,t)=>{Tt(`Creating skill...`);let n=!1;try{let i={name:e.name,description:e.description};e.instructions&&(i.instructions=e.instructions),e.scope&&(i.scope=e.scope),e.source&&(i.source=e.source),e.supportingFiles&&(i.supportingFiles=e.supportingFiles);let a=Xi(t),o=r(),s=a?`?directory=${encodeURIComponent(a)}`:``,c=await I(`/api/config/skills/${encodeURIComponent(e.name)}${s}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i)}),l=await c.json().catch(()=>null);if(!c.ok){let e=l?.error||`Failed to create skill`;throw Error(e)}return l?.requiresReload??!1?(n=!0,await aa({message:l?.message,delayMs:l?.reloadDelayMs,directory:a,transportIdentity:o}),!0):(await Je(V,a,o),await pt(V,a,o),Be(`skills`,{source:Ji}),!0)}catch{return!1}finally{n||Ye()}},updateSkill:async(e,t,n)=>{Tt(`Updating skill...`);let i=!1;try{let a={};t.description!==void 0&&(a.description=t.description),t.instructions!==void 0&&(a.instructions=t.instructions),t.supportingFiles!==void 0&&(a.supportingFiles=t.supportingFiles),t.targetPath!==void 0&&(a.targetPath=t.targetPath);let o=Xi(n),s=r(),c=o?`?directory=${encodeURIComponent(o)}`:``,l=await I(`/api/config/skills/${encodeURIComponent(e)}${c}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(a)}),u=await l.json().catch(()=>null);if(!l.ok){let e=u?.error||`Failed to update skill`;throw Error(e)}return u?.requiresReload??!1?(i=!0,await aa({message:u?.message,delayMs:u?.reloadDelayMs,directory:o,transportIdentity:s}),!0):(await Je(V,o,s),await pt(V,o,s),Be(`skills`,{source:Ji}),!0)}catch{return!1}finally{i||Ye()}},deleteSkill:async(n,i)=>{Tt(`Deleting skill...`);let a=!1;try{let o=Xi(i),s=r(),c=o?`?directory=${encodeURIComponent(o)}`:``,l=await I(`/api/config/skills/${encodeURIComponent(n)}${c}`,{method:`DELETE`}),u=await l.json().catch(()=>null);if(!l.ok){let e=u?.error||`Failed to delete skill`;throw Error(e)}return u?.requiresReload??!1?(a=!0,await aa({message:u?.message,delayMs:u?.reloadDelayMs,directory:o,transportIdentity:s}),!0):(await Je(V,o,s),await pt(V,o,s),Be(`skills`,{source:Ji}),t().selectedSkillName===n&&e({selectedSkillName:null}),!0)}catch{return!1}finally{a||Ye()}},getSkillByName:e=>Ge(V,qi()).find(t=>t.name===e),readSupportingFile:async(e,t)=>{try{let n=qi(),r=n?`&directory=${encodeURIComponent(n)}`:``,i=await I(`/api/config/skills/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}?${r.slice(1)}`);return i.ok?(await i.json()).content??null:null}catch{return null}},writeSupportingFile:async(e,t,n)=>{try{let r=qi(),i=r?`?directory=${encodeURIComponent(r)}`:``;return(await I(`/api/config/skills/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}${i}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({content:n})})).ok}catch{return!1}},deleteSupportingFile:async(e,t)=>{try{let n=qi(),r=n?`?directory=${encodeURIComponent(n)}`:``;return(await I(`/api/config/skills/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}${r}`,{method:`DELETE`})).ok}catch{return!1}}}),{name:`skills-store`,storage:f(),partialize:e=>({selectedSkillName:e.selectedSkillName})}),{name:`skills-store`}));typeof window<`u`&&(window.__zustand_skills_store__=ra);async function ia(e){let t=typeof e==`number`&&e>0?Math.min(e,Qi):0;t>0&&await Yi(t);let n=Date.now(),r=0,i=null;for(;Date.now()-n<Zi;){r+=1,wt(`Waiting for OpenCode… (attempt ${r})`);try{if(await _e.checkHealth())return;i=Error(`OpenCode health check reported not ready`)}catch(e){i=e}let e=Date.now()-n;await Yi(r<=$i&&e<1200?Qi:Math.min(ea+Math.max(0,r-$i)*ta,na))}throw i||Error(`OpenCode did not become ready in time`)}async function aa(e){let t=e&&`directory`in e?e.directory?.trim()||null:qi(),n=e?.transportIdentity??r();try{wt(e?.message||`Refreshing skills…`)}catch{}try{if(await ia(e?.delayMs),r()!==n||(wt(`Refreshing skills…`),await Je(V,t,n),r()!==n))return;await pt(V,t,n),Be(`skills`,{source:Ji})}catch(e){throw wt(`OpenCode refresh failed. Please retry.`),await Yi(1500),e}finally{Ye()}}var oa=null;oa||=Ct(e=>{if(e.source!==Ji&&Me(e,`skills`)){let e=qi(),t=r();Je(V,e,t).then(()=>pt(V,e,t)).catch(()=>void 0)}});var sa=e=>{let t=(0,bi.c)(37),{className:n}=e,{t:r}=Te(),i=rt(ca),a=rt(la),o=rt(ua),s=p(),c;t[0]===i?c=t[1]:(c=[...i].sort(da),t[0]=i,t[1]=c);let l=c,u;bb0:{if(l.length===0){u=null;break bb0}let e;t[2]!==a||t[3]!==l?(e=l.find(e=>e.id===a)??l[0],t[2]=a,t[3]=l,t[4]=e):e=t[4],u=e}let d=u;if(s||l.length===0)return null;let f;t[5]!==d?.path||t[6]!==r?(f=d?.path.split(`/`).filter(Boolean).pop()||d?.path||r(`settings.shared.projectSelector.fallbackProject`),t[5]=d?.path,t[6]=r,t[7]=f):f=t[7];let m=f,h;t[8]===n?h=t[9]:(h=q(n),t[8]=n,t[9]=h);let g;t[10]===r?g=t[11]:(g=r(`settings.shared.projectSelector.switchProjectAria`),t[10]=r,t[11]=g);let _;t[12]===r?_=t[13]:(_=r(`settings.shared.projectSelector.switchProjectTitle`),t[12]=r,t[13]=_);let v,y;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(v=q(`text-foreground border border-border/80 appearance-none flex h-8 w-full min-w-0 rounded-lg bg-transparent px-3 py-1 outline-none`,`hover:border-input focus-visible:ring-1 focus-visible:ring-primary/50 focus-visible:border-primary/70`,`flex items-center gap-1.5 text-left`),y=(0,$.jsx)(J,{name:`folder`,className:`h-4 w-4 text-muted-foreground`}),t[14]=v,t[15]=y):(v=t[14],y=t[15]);let b;t[16]===m?b=t[17]:(b=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label font-medium`,children:m}),t[16]=m,t[17]=b);let x;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(J,{name:`arrow-down-s`,className:`size-4 opacity-50`}),t[18]=x):x=t[18];let S;t[19]!==g||t[20]!==_||t[21]!==b?(S=(0,$.jsx)(qn,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,"aria-label":g,title:_,className:v,children:[y,b,x]})}),t[19]=g,t[20]=_,t[21]=b,t[22]=S):S=t[22];let C=d?.id??``,w;t[23]===o?w=t[24]:(w=e=>{e&&o(e)},t[23]=o,t[24]=w);let T;t[25]===l?T=t[26]:(T=l.map(fa),t[25]=l,t[26]=T);let E;t[27]!==C||t[28]!==w||t[29]!==T?(E=(0,$.jsx)(Un,{align:`start`,className:`w-auto`,children:(0,$.jsx)(Hn,{value:C,onValueChange:w,children:T})}),t[27]=C,t[28]=w,t[29]=T,t[30]=E):E=t[30];let D;t[31]!==S||t[32]!==E?(D=(0,$.jsxs)(Wn,{children:[S,E]}),t[31]=S,t[32]=E,t[33]=D):D=t[33];let O;return t[34]!==D||t[35]!==h?(O=(0,$.jsx)(`div`,{className:h,children:D}),t[34]=D,t[35]=h,t[36]=O):O=t[36],O};function ca(e){return e.projects}function la(e){return e.activeProjectId}function ua(e){return e.setActiveProject}function da(e,t){return(e.label||e.path).localeCompare(t.label||t.path)}function fa(e){let t=e.path.split(`/`).filter(Boolean).pop()||e.path;return(0,$.jsx)(ir,{value:e.id,children:(0,$.jsx)(`span`,{className:`min-w-0 truncate typography-ui`,children:t})},e.id)}function pa(e,t){return`opencode:sidebar-group:${e}:${t}`}var ma=e=>{let t=(0,bi.c)(57),{label:n,count:r,storageKey:i,defaultExpanded:a,variant:o,labelPrefix:s,children:c}=e,l=a===void 0||a,u=o===void 0?`sidebar`:o,d;t[0]!==n||t[1]!==i?(d=pa(i,n),t[0]=n,t[1]=i,t[2]=d):d=t[2];let f=d,p=Q.useId(),m;t[3]!==l||t[4]!==f?(m=()=>{try{let e=localStorage.getItem(f);if(e!==null)return e===`true`}catch{}return l},t[3]=l,t[4]=f,t[5]=m):m=t[5];let[h,g]=(0,Q.useState)(m),_,v;if(t[6]!==h||t[7]!==f?(_=()=>{try{localStorage.setItem(f,String(h))}catch{}},v=[f,h],t[6]=h,t[7]=f,t[8]=_,t[9]=v):(_=t[8],v=t[9]),(0,Q.useEffect)(_,v),u===`settings-card`){let e;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>g(ha),t[10]=e):e=t[10];let i;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(i=q(`flex w-full items-center gap-1 text-left`,`text-inherit transition-colors duration-150 hover:text-foreground`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`),t[11]=i):i=t[11];let a=!h&&`-rotate-90`,o;t[12]===a?o=t[13]:(o=q(`h-3.5 w-3.5 flex-shrink-0 transition-transform duration-200`,a),t[12]=a,t[13]=o);let l;t[14]===o?l=t[15]:(l=(0,$.jsx)(J,{name:`arrow-down-s`,className:o}),t[14]=o,t[15]=l);let u=s?`${s} · `:``,d;t[16]!==n||t[17]!==u?(d=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[u,n]}),t[16]=n,t[17]=u,t[18]=d):d=t[18];let f;t[19]===r?f=t[20]:(f=(0,$.jsx)(`span`,{className:`ml-1 tabular-nums opacity-60`,children:r}),t[19]=r,t[20]=f);let m;t[21]!==p||t[22]!==h||t[23]!==l||t[24]!==d||t[25]!==f?(m=(0,$.jsxs)(`button`,{type:`button`,onClick:e,"aria-expanded":h,"aria-controls":p,className:i,children:[l,d,f]}),t[21]=p,t[22]=h,t[23]=l,t[24]=d,t[25]=f,t[26]=m):m=t[26];let _=!h&&`hidden`,v;t[27]===_?v=t[28]:(v=q(_),t[27]=_,t[28]=v);let y;return t[29]!==c||t[30]!==p||t[31]!==m||t[32]!==v?(y=(0,$.jsx)(Z,{label:m,cardClassName:v,cardId:p,children:c}),t[29]=c,t[30]=p,t[31]=m,t[32]=v,t[33]=y):y=t[33],y}let y;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>g(ga),t[34]=y):y=t[34];let b;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(b=q(`flex w-full items-center gap-1 rounded-md px-2 py-1 text-left`,`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,`hover:bg-[var(--interactive-hover)] transition-colors duration-150`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`),t[35]=b):b=t[35];let x=!h&&`-rotate-90`,S;t[36]===x?S=t[37]:(S=q(`h-3.5 w-3.5 flex-shrink-0 transition-transform duration-200`,x),t[36]=x,t[37]=S);let C;t[38]===S?C=t[39]:(C=(0,$.jsx)(J,{name:`arrow-down-s`,className:S}),t[38]=S,t[39]=C);let w;t[40]===n?w=t[41]:(w=(0,$.jsx)(`span`,{className:`flex-1 truncate`,children:n}),t[40]=n,t[41]=w);let T;t[42]===r?T=t[43]:(T=(0,$.jsx)(`span`,{className:`ml-1 tabular-nums opacity-60`,children:r}),t[42]=r,t[43]=T);let E;t[44]!==p||t[45]!==h||t[46]!==C||t[47]!==w||t[48]!==T?(E=(0,$.jsxs)(`button`,{type:`button`,onClick:y,"aria-expanded":h,"aria-controls":p,className:b,children:[C,w,T]}),t[44]=p,t[45]=h,t[46]=C,t[47]=w,t[48]=T,t[49]=E):E=t[49];let D=!h,O;t[50]!==c||t[51]!==p||t[52]!==D?(O=(0,$.jsx)(`div`,{id:p,hidden:D,className:`mt-0.5 space-y-0.5 ml-2 pl-3 border-l-2 border-[var(--interactive-border)]`,children:c}),t[50]=c,t[51]=p,t[52]=D,t[53]=O):O=t[53];let k;return t[54]!==E||t[55]!==O?(k=(0,$.jsxs)(`div`,{children:[E,O]}),t[54]=E,t[55]=O,t[56]=k):k=t[56],k};function ha(e){return!e}function ga(e){return!e}var _a=e=>{if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;typeof e.permission==`string`&&typeof e.pattern==`string`&&typeof e.action==`string`&&(e.action===`allow`||e.action===`ask`||e.action===`deny`)&&t.push({permission:e.permission,pattern:e.pattern,action:e.action})}return t},va=e=>{let t=new Map;for(let n of e)!n.permission||n.permission===`invalid`||n.pattern&&t.set(`${n.permission}::${n.pattern}`,n);return Array.from(t.values())},ya=e=>{let t=va(_a(e));if(t.length===0)return;let n={};for(let e of t)e.permission&&((n[e.permission]||={})[e.pattern]=e.action);let r={};for(let[e,t]of Object.entries(n)){let n=Object.keys(t);if(n.length===1&&n[0]===`*`){r[e]=t[`*`];continue}r[e]=t}return Object.keys(r).length>0?r:void 0},ba=({onItemSelect:e})=>{let{t}=Te(),[n,r]=Q.useState(null),[i,a]=Q.useState(``),[o,s]=Q.useState(null),[c,l]=Q.useState(null),[u,d]=Q.useState(!1),[f,p]=Q.useState(null),{selectedAgentName:m,setSelectedAgent:h,setAgentDraft:g,createAgent:_,deleteAgent:v,loadAgents:y}=qe(me(e=>({selectedAgentName:e.selectedAgentName,setSelectedAgent:e.setSelectedAgent,setAgentDraft:e.setAgentDraft,createAgent:e.createAgent,deleteAgent:e.deleteAgent,loadAgents:e.loadAgents}))),{data:b=[]}=dt();Q.useEffect(()=>{y()},[y]);let x=()=>{let t=`new-agent`,n=t,r=1;for(;b.some(e=>e.name===n);)n=`${t}-${r}`,r++;g({name:n,scope:`user`}),h(n),e?.()},S=async e=>{if(Pe(e)){K.error(t(`settings.agents.sidebar.toast.builtInCannotDelete`));return}s(e),l(`delete`)},C=async e=>{Pe(e)&&(s(e),l(`reset`))},w=()=>{s(null),l(null)},T=async()=>{if(!(!o||!c)){d(!0);try{let e=await v(o.name,o.scope);e.ok?(e.requiresManualRestart?K.warning(t(`settings.agents.page.toast.savedManualRestart`)):c===`delete`?K.success(t(`settings.agents.sidebar.toast.agentDeleted`,{name:o.name})):K.success(t(`settings.agents.sidebar.toast.agentReset`,{name:o.name})),w()):c===`delete`?K.error(t(`settings.agents.sidebar.toast.deleteFailed`)):K.error(t(`settings.agents.sidebar.toast.resetFailed`))}catch(e){let n=e instanceof Error?e.message:``,r=/built-in|not deletable|not found/i.test(n);c===`delete`?K.error(t(r?`settings.agents.sidebar.toast.definitionNotFound`:`settings.agents.sidebar.toast.deleteFailed`)):K.error(t(`settings.agents.sidebar.toast.resetFailed`))}d(!1)}},E=e=>{let t=e.name,n=1,r=`${t}-copy`;for(;b.some(e=>e.name===r);)n++,r=`${t}-copy-${n}`;let i=e,a=e.model?.providerID&&e.model?.modelID?`${e.model.providerID}/${e.model.modelID}`:null,o=e;g({name:r,scope:i.scope||`user`,description:e.description,model:a,variant:e.variant,temperature:e.temperature,top_p:e.topP,prompt:e.prompt,mode:e.mode,permission:ya(e.permission),disable:o.disable}),h(r)},D=e=>{a(e.name),r(e)},O=async()=>{if(!n)return;let e=i.trim().replace(/\s+/g,`-`);if(!e){K.error(t(`settings.agents.sidebar.toast.agentNameRequired`));return}if(e===n.name){r(null);return}if(b.some(t=>t.name===e)){K.error(t(`settings.agents.sidebar.toast.agentExists`));return}let a=n.model?.providerID&&n.model?.modelID?`${n.model.providerID}/${n.model.modelID}`:null,o=n,s=await _({name:e,description:n.description,model:a,variant:n.variant,temperature:n.temperature,top_p:n.topP,prompt:n.prompt,mode:n.mode,permission:ya(n.permission),disable:o.disable,scope:o.scope});if(s.ok){let r=await v(n.name,o.scope);r.ok?(s.requiresManualRestart||r.requiresManualRestart?K.warning(t(`settings.agents.page.toast.savedManualRestart`)):K.success(t(`settings.agents.sidebar.toast.agentRenamed`,{name:e})),h(e)):K.error(t(`settings.agents.sidebar.toast.removeOldAfterRenameFailed`))}else K.error(t(`settings.agents.sidebar.toast.renameFailed`));r(null)},k=e=>{switch(e){case`primary`:return(0,$.jsx)(J,{name:`ai-agent`,className:`h-3 w-3 text-primary`});case`all`:return(0,$.jsx)(J,{name:`ai-agent-fill`,className:`h-3 w-3 text-primary`});case`subagent`:return(0,$.jsx)(J,{name:`robot`,className:`h-3 w-3 text-primary`});default:return null}},A=b.filter(e=>!Le(e)),j=A.filter(Pe),M=A.filter(e=>!Pe(e)),{groupedCustomAgents:N,ungroupedCustomAgents:P}=(0,Q.useMemo)(()=>{let e={},t=[];for(let n of M){let r=n;r.group?(e[r.group]||(e[r.group]=[]),e[r.group].push(n)):t.push(n)}return{groupedCustomAgents:Object.keys(e).sort((e,t)=>e.localeCompare(t)).map(t=>({name:t,agents:e[t]})),ungroupedCustomAgents:t}},[M]),F=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{children:t(`settings.agents.sidebar.section.custom`)}),(0,$.jsx)(Y,{"data-settings-item":`agents.create`,size:`icon`,variant:`ghost`,onClick:x,"aria-label":t(`settings.agents.page.title.new`),children:(0,$.jsx)(J,{name:`add`,className:`h-4 w-4`})})]});return(0,$.jsxs)(`div`,{className:`oc-settings-page-content h-full overflow-y-auto bg-background p-3`,children:[(0,$.jsx)(sa,{}),(0,$.jsx)($.Fragment,{children:A.length===0?(0,$.jsx)(Z,{children:(0,$.jsxs)(`div`,{className:`oc-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`robot-2`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:t(`settings.agents.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:t(`settings.agents.sidebar.empty.description`)})]})}):(0,$.jsxs)($.Fragment,{children:[j.length>0&&(0,$.jsx)(Z,{label:t(`settings.agents.sidebar.section.builtIn`),children:j.map(t=>(0,$.jsx)(xa,{agent:t,isSelected:m===t.name,onSelect:()=>{h(t.name),e?.()},onReset:()=>C(t),onDuplicate:()=>E(t),getAgentModeIcon:k,isMenuOpen:f===t.name,onMenuOpenChange:e=>p(e?t.name:null)},t.name))}),M.length>0&&(0,$.jsxs)($.Fragment,{children:[N.map(({name:n,agents:r})=>(0,$.jsx)(ma,{label:n,count:r.length,storageKey:`agents`,variant:`settings-card`,labelPrefix:t(`settings.agents.sidebar.section.custom`),children:r.map(t=>(0,$.jsx)(xa,{agent:t,isSelected:m===t.name,onSelect:()=>{h(t.name),e?.()},onRename:()=>D(t),onDelete:()=>S(t),onDuplicate:()=>E(t),getAgentModeIcon:k,isMenuOpen:f===t.name,onMenuOpenChange:e=>p(e?t.name:null)},t.name))},n)),P.length>0?(0,$.jsx)(Z,{label:F,children:P.map(t=>(0,$.jsx)(xa,{agent:t,isSelected:m===t.name,onSelect:()=>{h(t.name),e?.()},onRename:()=>D(t),onDelete:()=>S(t),onDuplicate:()=>E(t),getAgentModeIcon:k,isMenuOpen:f===t.name,onMenuOpenChange:e=>p(e?t.name:null)},t.name))}):(0,$.jsx)(Z,{label:F,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]}),M.length===0&&(0,$.jsx)(Z,{label:F,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]})}),(0,$.jsx)(qt,{open:o!==null&&c!==null,onOpenChange:e=>{!e&&!u&&w()},children:(0,$.jsxs)(Wt,{className:`max-w-md`,children:[(0,$.jsxs)(Ht,{children:[(0,$.jsx)(Gt,{children:t(c===`delete`?`settings.agents.sidebar.dialog.deleteTitle`:`settings.agents.sidebar.dialog.resetTitle`)}),(0,$.jsx)(Kt,{children:t(c===`delete`?`settings.agents.sidebar.dialog.deleteDescription`:`settings.agents.sidebar.dialog.resetDescription`,{name:o?.name??``})})]}),(0,$.jsxs)(Ut,{children:[(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:w,disabled:u,children:t(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{size:`sm`,onClick:T,disabled:u,children:t(c===`delete`?`settings.common.actions.delete`:`settings.common.actions.reset`)})]})]})}),(0,$.jsx)(qt,{open:n!==null,onOpenChange:e=>!e&&r(null),children:(0,$.jsxs)(Wt,{children:[(0,$.jsxs)(Ht,{children:[(0,$.jsx)(Gt,{children:t(`settings.agents.sidebar.renameDialog.title`)}),(0,$.jsx)(Kt,{children:t(`settings.agents.sidebar.renameDialog.description`,{name:n?.name??``})})]}),(0,$.jsx)(ln,{value:i,onChange:e=>a(e.target.value),placeholder:t(`settings.agents.sidebar.renameDialog.placeholder`),className:`text-foreground placeholder:text-muted-foreground`,onKeyDown:e=>{e.key===`Enter`&&O()}}),(0,$.jsxs)(Ut,{children:[(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>r(null),children:t(`settings.common.actions.cancel`)}),(0,$.jsx)(Y,{size:`sm`,onClick:O,children:t(`settings.common.actions.rename`)})]})]})})]})},xa=e=>{let t=(0,bi.c)(52),{agent:n,isSelected:r,onSelect:i,onDelete:a,onReset:o,onRename:s,onDuplicate:c,getAgentModeIcon:l,isMenuOpen:u,onMenuOpenChange:d}=e,{t:f}=Te(),p=n,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=dr(),t[0]=m):m=t[0];let h=m,[g,_]=Q.useState(!1),v;t[1]!==a||t[2]!==c||t[3]!==s||t[4]!==o||t[5]!==f?(v=e=>(0,$.jsxs)($.Fragment,{children:[s&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),s()},children:[(0,$.jsx)(J,{name:`edit`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.rename`)]}),(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),c()},children:[(0,$.jsx)(J,{name:`file-copy`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.duplicate`)]}),o&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),o()},children:[(0,$.jsx)(J,{name:`restart`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.reset`)]}),a&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),a()},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(J,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),f(`settings.common.actions.delete`)]})]}),t[1]=a,t[2]=c,t[3]=s,t[4]=o,t[5]=f,t[6]=v):v=t[6];let y=v,b=r?`bg-interactive-selection`:`hover:bg-interactive-hover`,x;t[7]===b?x=t[8]:(x=q(`oc-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,b),t[7]=b,t[8]=x);let S;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(S=h?void 0:e=>{e.preventDefault(),_(!0)},t[9]=S):S=t[9];let C;t[10]===x?C=t[11]:(C=(0,$.jsx)(`div`,{className:x,onContextMenu:S}),t[10]=x,t[11]=C);let w;t[12]===n.name?w=t[13]:(w=(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:n.name}),t[12]=n.name,t[13]=w);let T;t[14]!==n.mode||t[15]!==l?(T=l(n.mode),t[14]=n.mode,t[15]=l,t[16]=T):T=t[16];let E;t[17]!==n||t[18]!==p.scope||t[19]!==f?(E=(p.scope||Pe(n))&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:Pe(n)?f(`settings.agents.sidebar.badge.system`):p.scope}),t[17]=n,t[18]=p.scope,t[19]=f,t[20]=E):E=t[20];let D;t[21]!==w||t[22]!==T||t[23]!==E?(D=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[w,T,E]}),t[21]=w,t[22]=T,t[23]=E,t[24]=D):D=t[24];let O;t[25]===n.description?O=t[26]:(O=n.description&&(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight`,children:n.description}),t[25]=n.description,t[26]=O);let k;t[27]!==i||t[28]!==D||t[29]!==O?(k=(0,$.jsxs)(`button`,{onClick:i,className:`flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,tabIndex:0,children:[D,O]}),t[27]=i,t[28]=D,t[29]=O,t[30]=k):k=t[30];let A;t[31]===d?A=t[32]:(A=e=>{e&&_(!1),d(e)},t[31]=d,t[32]=A);let j;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(qn,{asChild:!0,children:(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,className:`h-6 w-6 px-0 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(J,{name:`more-2`,className:`h-3.5 w-3.5`})})}),t[33]=j):j=t[33];let M;t[34]===y?M=t[35]:(M=(0,$.jsx)(Un,{align:`end`,className:`w-fit min-w-20`,children:y(Jn)}),t[34]=y,t[35]=M);let N;t[36]!==u||t[37]!==A||t[38]!==M?(N=(0,$.jsxs)(Wn,{open:u,onOpenChange:A,children:[j,M]}),t[36]=u,t[37]=A,t[38]=M,t[39]=N):N=t[39];let P;t[40]!==k||t[41]!==N?(P=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[k,N]}),t[40]=k,t[41]=N,t[42]=P):P=t[42];let F;t[43]!==P||t[44]!==C?(F=(0,$.jsx)(ui,{render:C,children:P}),t[43]=P,t[44]=C,t[45]=F):F=t[45];let I;t[46]===y?I=t[47]:(I=(0,$.jsx)(di,{className:`w-fit min-w-20`,children:y(fi)}),t[46]=y,t[47]=I);let L;return t[48]!==g||t[49]!==F||t[50]!==I?(L=(0,$.jsxs)(pi,{open:g,onOpenChange:_,children:[F,I]}),t[48]=g,t[49]=F,t[50]=I,t[51]=L):L=t[51],L},Sa=e=>[...e].sort((e,t)=>{let n=e.permission.localeCompare(t.permission);return n===0?e.pattern.localeCompare(t.pattern):n}),Ca=(e,t)=>{let n=Sa(e),r=Sa(t);return n.length===r.length&&n.every((e,t)=>{let n=r[t];return e.permission===n.permission&&e.pattern===n.pattern&&e.action===n.action})},wa=(e,t)=>t?e.globalPermission!==t.globalPermission||!Ca(e.permissionRules,t.permissionRules):!1,Ta=e=>{let t=e.trim();return t===``?null:t},Ea=e=>{let t=e.trim();return t===``?null:t},Da=e=>e.trim()||void 0,Oa=e=>e.trim()||null,ka=({isNewAgent:e,agentName:t,draftScope:n,draftHasExplicitPermission:r,current:i,initial:a,permissionConfig:o})=>{if(e){let e=wa(i,a)||r,s=i.description.trim(),c=Ta(i.model),l=Ea(i.variant),u=Da(i.prompt);return{name:t,mode:i.mode,...s?{description:s}:{},...c?{model:c}:{},...l?{variant:l}:{},...i.temperature===void 0?{}:{temperature:i.temperature},...i.topP===void 0?{}:{top_p:i.topP},...u?{prompt:u}:{},...e?{permission:o}:{},...n?{scope:n}:{}}}let s={name:t};if(!a)return s;if(i.description!==a.description){let e=i.description.trim();e&&(s.description=e)}return i.mode!==a.mode&&(s.mode=i.mode),i.model!==a.model&&(s.model=Ta(i.model)),i.variant!==a.variant&&(s.variant=Ea(i.variant)??null),i.temperature!==a.temperature&&(s.temperature=i.temperature??null),i.topP!==a.topP&&(s.top_p=i.topP??null),i.prompt!==a.prompt&&(s.prompt=Oa(i.prompt)),wa(i,a)&&(s.permission=o),s},Aa=[`*`,`read`,`edit`,`glob`,`grep`,`list`,`bash`,`task`,`skill`,`lsp`,`todoread`,`todowrite`,`webfetch`,`websearch`,`codesearch`,`external_directory`,`doom_loop`,`question`,`plan_enter`,`plan_exit`],ja=e=>e===`allow`||e===`ask`||e===`deny`,Ma=(e,t)=>`${e}::${t}`,Na=e=>{let t=new Map;for(let n of e)!n.permission||n.permission===`invalid`||n.pattern&&ja(n.action)&&t.set(Ma(n.permission,n.pattern),{permission:n.permission,pattern:n.pattern,action:n.action});return Array.from(t.values())},Pa=e=>{let t=new Map;for(let n of Na(e))t.set(Ma(n.permission,n.pattern),n);return t},Fa=e=>[...e].sort((e,t)=>{let n=e.permission.localeCompare(t.permission);return n===0?e.pattern.localeCompare(t.pattern):n}),Ia=(e,t)=>{let n=Fa(Na(e)),r=Fa(Na(t));return n.length===r.length&&n.every((e,t)=>{let n=r[t];return e.permission===n.permission&&e.pattern===n.pattern&&e.action===n.action})},La=e=>e.find(e=>e.permission===`*`&&e.pattern===`*`)?.action??`allow`,Ra=(e,t)=>Na(e).filter(e=>e.permission!==`*`||e.pattern!==`*`).filter(e=>e.pattern!==`*`||e.action!==t),za=e=>{if(Array.isArray(e))return Na(e);if(ja(e))return[{permission:`*`,pattern:`*`,action:e}];if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=[];for(let[n,r]of Object.entries(e))if(n!==`__originalKeys`){if(ja(r)){t.push({permission:n,pattern:`*`,action:r});continue}if(r&&typeof r==`object`&&!Array.isArray(r))for(let[e,i]of Object.entries(r))ja(i)&&t.push({permission:n,pattern:e,action:i})}return t},Ba=(e,t)=>{let n=Na(t),r={};for(let e of n)(r[e.permission]||={})[e.pattern]=e.action;let i={};for(let[e,t]of Object.entries(r))if(e!==`*`){if(Object.keys(t).length===1&&t[`*`]){i[e]=t[`*`];continue}i[e]=t}return Object.keys(i).length===0?e:(e!==`allow`&&(i[`*`]=e),i)},Va=(e,t)=>{let n=ct(t);if(!n)return[];let r=e.find(e=>e.id===n.providerId)?.models?.find(e=>e.id===n.modelId);return r?.variants?Object.keys(r.variants):[]},Ha=()=>{let{t:e}=Te(),t=Ke(e=>e.providers),{selectedAgentName:n,getAgentByName:r,createAgent:i,updateAgent:a,agentDraft:o,setAgentDraft:s}=qe(me(e=>({selectedAgentName:e.selectedAgentName,getAgentByName:e.getAgentByName,createAgent:e.createAgent,updateAgent:e.updateAgent,agentDraft:e.agentDraft,setAgentDraft:e.setAgentDraft}))),{data:c=[]}=dt(),l=n?r(n):null,u=!!(o&&o.name===n&&!l),[d,f]=Q.useState(``),[p,m]=Q.useState(`user`),[h,g]=Q.useState(``),[_,v]=Q.useState(`subagent`),[y,b]=Q.useState(``),[x,S]=Q.useState(``),[C,w]=Q.useState(void 0),[T,E]=Q.useState(void 0),[D,O]=Q.useState(``),[k,A]=Q.useState(`allow`),[j,M]=Q.useState([]),[N,P]=Q.useState([]),[F,I]=Q.useState(``),[L,R]=Q.useState(`*`),[z,B]=Q.useState(!1),[V,H]=Q.useState(!1),U=Q.useRef(null),W=ve(e=>e.currentDirectory??null),[ee,G]=Q.useState([]),te=Q.useMemo(()=>Va(t,y),[y,t]),ne=te.length>0,re=Q.useMemo(()=>!x||!te.includes(x)?`__default`:x,[x,te]),ie=ne&&(!x||te.includes(x)),ae=Ue(e=>e.permission);Q.useEffect(()=>{let e=!1;return(async()=>{let t=await _e.listToolIds({directory:W});if(e)return;let n=new Set([`write`,`patch`,`multiedit`]),r=t.map(e=>typeof e==`string`?e.trim():``).filter(Boolean).filter(e=>e!==`*`).filter(e=>e!==`invalid`).filter(e=>!n.has(e));G(Array.from(new Set(r)).sort((e,t)=>e.localeCompare(t)))})(),()=>{e=!0}},[W]);let oe=Q.useMemo(()=>{let e=new Set;for(let t of c){let n=Na(za(t.permission));for(let t of n)t.permission&&t.permission!==`*`&&t.permission!==`invalid`&&e.add(t.permission)}for(let t of Object.values(ae))for(let n of t){let t=n.permission?.trim();t&&t!==`invalid`&&e.add(t)}for(let t of ee)e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[c,ae,ee]),se=Q.useMemo(()=>Pa(j),[j]),ce=Q.useMemo(()=>Pa(N),[N]),le=Q.useCallback(e=>ce.get(Ma(e,`*`))?.action,[ce]),ue=Q.useCallback(e=>N.filter(t=>t.permission===e&&t.pattern!==`*`).sort((e,t)=>e.pattern.localeCompare(t.pattern)),[N]),de=Q.useMemo(()=>{let e=new Set;for(let t of Aa)e.add(t);for(let t of oe)e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[oe]),fe=Q.useCallback(e=>{let t=e===`*`?k:le(e)??k,n=ue(e),r=n.reduce((e,t)=>(e[t.action]=(e[t.action]??0)+1,e),{allow:0,ask:0,deny:0}),i=[`allow`,`ask`,`deny`].filter(e=>r[e]>0).map(e=>`${r[e]} ${e}`).join(`, `);return{defaultAction:t,patternRulesCount:n.length,patternSummary:i,hasDefaultHint:!1}},[ue,le,k]),pe=Q.useCallback(t=>e(t===`allow`?`settings.common.permission.allow`:t===`deny`?`settings.common.permission.deny`:`settings.common.permission.ask`),[e]),he=Q.useCallback(t=>t===`global`?e(`settings.common.scope.global`):pe(t),[pe,e]),ge=Q.useMemo(()=>{let e=new Set;for(let t of Aa)e.add(t);for(let t of oe)e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[oe]),ye=Q.useCallback((e,t,n)=>{P(r=>{let i=Pa(r);return i.set(Ma(e,t),{permission:e,pattern:t,action:n}),Array.from(i.values())})},[]),be=Q.useCallback((e,t)=>{P(n=>{let r=Pa(n);return r.delete(Ma(e,t)),Array.from(r.values())})},[]),xe=Q.useCallback((e,t)=>{let n=se.get(Ma(e,t));if(n){ye(e,t,n.action);return}be(e,t)},[se,be,ye]),Se=Q.useCallback((e,t,n)=>{ye(e,t,n)},[ye]),Ce=Q.useCallback(e=>{A(e),P(t=>t.filter(t=>t.pattern!==`*`||t.action!==e))},[]),we=Q.useCallback(t=>{let n=F.trim();if(!n){K.error(e(`settings.agents.page.toast.permissionNameRequired`));return}let r=L.trim()||`*`;if(n===`*`&&r===`*`){Ce(t),I(``),R(`*`);return}r===`*`&&n!==`*`&&t===k?be(n,`*`):ye(n,r,t),I(``),R(`*`)},[k,F,L,be,Ce,e,ye]),Ee=Q.useCallback(t=>t===`*`?e(`settings.agents.page.permissions.defaultLabel`):t===`webfetch`?`WebFetch`:t===`websearch`?`WebSearch`:t===`codesearch`?`CodeSearch`:t===`doom_loop`?`Doom Loop`:t===`external_directory`?`External Directory`:t===`todowrite`?`TodoWrite`:t===`todoread`?`TodoRead`:t.split(/[_-]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `),[e]);Q.useEffect(()=>{I(``),R(`*`);let e=e=>{let t=Na(e),n=La(t),r=Ra(t,n);return A(n),M(r),P(r),{global:n,rules:r}};if(u&&o){let t=o.name||``,n=o.scope||`user`,r=o.description||``,i=o.mode||`subagent`,a=o.model||``,s=o.variant||``,c=o.temperature??void 0,l=o.top_p??void 0,u=o.prompt||``;f(t),m(n),g(r),v(i),b(a),S(s),w(c),E(l),O(u);let d=e(za(o.permission));U.current={draftName:t,draftScope:n,description:r,mode:i,model:a,variant:s,temperature:c,topP:l,prompt:u,globalPermission:d.global,permissionRules:d.rules};return}if(l&&n===l.name){let t=l.description||``,n=l.mode||`subagent`,r=l.model?.providerID&&l.model?.modelID?`${l.model.providerID}/${l.model.modelID}`:``,i=l.variant||``,a=l.temperature,o=l.topP,s=l.prompt||``;g(t),v(n),b(r),S(i),w(a),E(o),O(s);let c=e(za(l.permission));U.current={draftName:``,draftScope:`user`,description:t,mode:n,model:r,variant:i,temperature:a,topP:o,prompt:s,globalPermission:c.global,permissionRules:c.rules}}},[o,u,l,n]);let De=Q.useMemo(()=>{let e=U.current;return e?!!(u&&(d!==e.draftName||p!==e.draftScope)||h!==e.description||_!==e.mode||y!==e.model||x!==e.variant||C!==e.temperature||T!==e.topP||D!==e.prompt||k!==e.globalPermission||!Ia(N,e.permissionRules)):!1},[h,d,p,k,u,_,y,N,D,C,T,x]);return n?(0,$.jsx)(Jt,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(`div`,{className:`mb-4 flex items-center justify-between gap-4`,children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:u?e(`settings.agents.page.title.new`):n}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:e(u?`settings.agents.page.subtitle.new`:`settings.agents.page.subtitle.edit`)})]})}),(0,$.jsxs)(Z,{label:e(`settings.agents.page.section.identityRole`),children:[u&&(0,$.jsxs)(Ar,{itemId:`agents.name`,label:e(`settings.agents.page.field.agentName`),children:[(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground mr-1`,children:`@`}),(0,$.jsx)(ln,{value:d,onChange:e=>f(e.target.value),placeholder:e(`settings.agents.page.field.agentNamePlaceholder`),className:`h-7 w-40 px-2`})]}),(0,$.jsxs)(tn,{value:p,onValueChange:e=>m(e),children:[(0,$.jsx)(cn,{className:`w-fit min-w-[100px]`,children:(0,$.jsx)(Qt,{placeholder:e(`settings.agents.page.field.scopePlaceholder`)})}),(0,$.jsxs)(en,{align:`end`,children:[(0,$.jsx)(sn,{value:`user`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{name:`user-3`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.global`)})]})}),(0,$.jsx)(sn,{value:`project`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{name:`folder`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.project`)})]})})]})]})]}),(0,$.jsx)(Ar,{label:e(`settings.common.field.description`),className:`oc-settings-split-row-stacked`,children:(0,$.jsx)(on,{embedded:!0,value:h,onChange:e=>g(e.target.value),placeholder:e(`settings.agents.page.field.descriptionPlaceholder`),rows:2,className:`w-full resize-none min-h-[60px] bg-transparent`})}),(0,$.jsx)(Ar,{itemId:`agents.mode`,className:`oc-settings-agents-mode-row`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.field.mode`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.agents.page.field.modeTooltip`)})]})]}),children:(0,$.jsxs)(`div`,{className:`flex flex-nowrap items-center justify-end gap-1`,children:[(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":_===`primary`,onClick:()=>v(`primary`),className:`!font-normal shrink-0`,children:e(`settings.agents.page.mode.primary`)}),(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":_===`subagent`,onClick:()=>v(`subagent`),className:`!font-normal shrink-0`,children:e(`settings.agents.page.mode.subagent`)}),(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":_===`all`,onClick:()=>v(`all`),className:`!font-normal shrink-0`,children:e(`settings.agents.page.mode.all`)})]})})]}),(0,$.jsxs)(Z,{label:e(`settings.agents.page.section.modelParameters`),children:[(0,$.jsx)(Ar,{itemId:`agents.model`,label:e(`settings.agents.page.field.overrideModel`),children:(0,$.jsx)(ar,{providerId:ct(y)?.providerId??``,modelId:ct(y)?.modelId??``,onChange:(e,t)=>{b(e&&t?`${e}/${t}`:``),S(``)},className:`oc-settings-inline-value`})}),(0,$.jsx)(Ar,{itemId:`agents.variant`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.field.variant`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.agents.page.field.variantTooltip`)})]})]}),description:e(`settings.agents.page.field.variantHint`),children:ie?(0,$.jsxs)(tn,{value:re,onValueChange:e=>S(e===`__default`?``:e),children:[(0,$.jsx)(cn,{className:`w-fit min-w-[10rem] max-w-full`,children:(0,$.jsx)(Qt,{placeholder:e(`settings.agents.page.field.variantPlaceholder`),children:t=>t===`__default`?e(`chat.modelControls.default`):t})}),(0,$.jsxs)(en,{children:[(0,$.jsx)(sn,{value:`__default`,children:e(`chat.modelControls.default`)}),te.map(e=>(0,$.jsx)(sn,{value:e,children:e},e))]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ln,{value:x,onChange:e=>S(e.target.value),placeholder:e(`settings.agents.page.field.variantPlaceholder`),disabled:!y&&!x,className:`h-7 w-40 max-w-full`}),x&&(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>S(``),className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":e(`settings.common.actions.clear`),title:e(`settings.common.actions.clear`),children:(0,$.jsx)(J,{name:`close`,className:`h-3.5 w-3.5`})})]})}),(0,$.jsxs)(Ar,{itemId:`agents.temperature`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.field.temperature`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.agents.page.field.temperatureTooltip`)})]})]}),description:e(`settings.agents.page.field.temperatureRange`),children:[(0,$.jsx)(Pr,{value:C,fallbackValue:.7,onValueChange:w,onClear:()=>w(void 0),min:0,max:2,step:.1,inputMode:`decimal`,placeholder:`—`,emptyLabel:`—`,className:`w-16`}),C!==void 0&&(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>w(void 0),className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":e(`settings.agents.page.field.clearTemperatureAria`),title:e(`settings.common.actions.clear`),children:(0,$.jsx)(J,{name:`close`,className:`h-3.5 w-3.5`})})]}),(0,$.jsxs)(Ar,{itemId:`agents.top-p`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.field.topP`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.agents.page.field.topPTooltip`)})]})]}),description:e(`settings.agents.page.field.topPRange`),children:[(0,$.jsx)(Pr,{value:T,fallbackValue:.9,onValueChange:E,onClear:()=>E(void 0),min:0,max:1,step:.1,inputMode:`decimal`,placeholder:`—`,emptyLabel:`—`,className:`w-16`}),T!==void 0&&(0,$.jsx)(Y,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>E(void 0),className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":e(`settings.agents.page.field.clearTopPAria`),title:e(`settings.common.actions.clear`),children:(0,$.jsx)(J,{name:`close`,className:`h-3.5 w-3.5`})})]})]}),(0,$.jsx)(Tr,{itemId:`agents.system-prompt`,label:e(`settings.agents.page.section.systemPrompt`),className:`oc-settings-split-row-stacked`,children:(0,$.jsx)(on,{embedded:!0,value:D,onChange:e=>O(e.target.value),placeholder:e(`settings.agents.page.field.systemPromptPlaceholder`),rows:8,className:`w-full font-mono typography-meta min-h-[120px] max-h-[60vh] bg-transparent resize-y`})}),(0,$.jsx)(`div`,{"data-settings-item":`agents.permissions`,children:(0,$.jsx)(Z,{label:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.section.toolPermissions`)}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>B(e=>!e),children:e(z?`settings.agents.page.permissions.hideEditor`:`settings.agents.page.permissions.advancedEditor`)})]}),children:z?(0,$.jsxs)(`div`,{className:`space-y-6 p-2`,children:[(0,$.jsx)(Ar,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:e(`settings.agents.page.permissions.globalDefault`)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 font-mono`,children:`*`})]}),children:(0,$.jsxs)(tn,{value:k,onValueChange:e=>Ce(e),children:[(0,$.jsx)(cn,{className:`w-[100px]`,children:(0,$.jsx)(Qt,{children:pe(k)})}),(0,$.jsxs)(en,{children:[(0,$.jsx)(sn,{value:`allow`,children:e(`settings.common.permission.allow`)}),(0,$.jsx)(sn,{value:`ask`,children:e(`settings.common.permission.ask`)}),(0,$.jsx)(sn,{value:`deny`,children:e(`settings.common.permission.deny`)})]})]})}),(0,$.jsx)(`div`,{className:`space-y-4`,children:de.filter(e=>e!==`*`).map(t=>{let n=Ee(t),{defaultAction:r,patternRulesCount:i}=fe(t),a=le(t),o=a??`global`,s=ue(t),c=[`allow`,`ask`,`deny`].filter(e=>e!==k);return(0,$.jsxs)(`div`,{className:`border-t border-[var(--surface-subtle)] pt-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between py-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:n}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 font-mono`,children:t})]}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:i>0?e(`settings.agents.page.permissions.globalSummary`,{summary:r}):r})]}),(0,$.jsxs)(`div`,{className:`space-y-1 pl-2 mt-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 py-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:e(`settings.agents.page.permissions.pattern`)}),(0,$.jsx)(`span`,{className:`typography-micro font-mono text-foreground bg-[var(--surface-muted)] px-1 rounded`,children:`*`}),a&&(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>xe(t,`*`),className:`px-1.5 py-0 h-5`,children:(0,$.jsx)(J,{name:`subtract`,className:`h-3.5 w-3.5 text-muted-foreground hover:text-foreground`})})]}),(0,$.jsxs)(tn,{value:o,onValueChange:e=>{if(e===`global`){be(t,`*`);return}ye(t,`*`,e)},children:[(0,$.jsx)(cn,{className:`w-[90px]`,children:(0,$.jsx)(Qt,{children:he(o)})}),(0,$.jsxs)(en,{children:[(0,$.jsx)(sn,{value:`global`,children:e(`settings.common.scope.global`)}),c.map(e=>(0,$.jsx)(sn,{value:e,className:`capitalize`,children:pe(e)},e))]})]})]}),s.map(t=>{let n=Ma(t.permission,t.pattern),r=se.get(n),i=!r,a=!!(r&&r.action!==t.action);return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 py-0.5 border-t border-[var(--surface-subtle)]`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:e(`settings.agents.page.permissions.pattern`)}),(0,$.jsx)(`span`,{className:`typography-micro font-mono text-foreground bg-[var(--surface-muted)] px-1 rounded`,children:t.pattern}),i&&(0,$.jsx)(`span`,{className:`typography-micro text-[var(--status-success)]`,children:e(`settings.common.badge.new`)}),a&&(0,$.jsx)(`span`,{className:`typography-micro text-[var(--status-warning)]`,children:e(`settings.common.badge.modified`)}),(i||a)&&(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>i?be(t.permission,t.pattern):xe(t.permission,t.pattern),className:`px-1.5 py-0 h-5`,children:(0,$.jsx)(J,{name:`subtract`,className:`h-3.5 w-3.5 text-muted-foreground hover:text-foreground`})})]}),(0,$.jsxs)(tn,{value:t.action,onValueChange:e=>Se(t.permission,t.pattern,e),children:[(0,$.jsx)(cn,{className:`w-[90px]`,children:(0,$.jsx)(Qt,{children:pe(t.action)})}),(0,$.jsxs)(en,{children:[(0,$.jsx)(sn,{value:`allow`,children:e(`settings.common.permission.allow`)}),(0,$.jsx)(sn,{value:`ask`,children:e(`settings.common.permission.ask`)}),(0,$.jsx)(sn,{value:`deny`,children:e(`settings.common.permission.deny`)})]})]})]},n)})]})]},t)})}),(0,$.jsxs)(`div`,{className:`border-t border-[var(--surface-subtle)] pt-3`,children:[(0,$.jsx)(`h4`,{className:`typography-ui-label text-foreground mb-2`,children:e(`settings.agents.page.permissions.addCustomRule`)}),(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-end sm:items-center gap-2`,children:[(0,$.jsxs)(tn,{value:F,onValueChange:I,children:[(0,$.jsx)(cn,{className:`w-full sm:w-[160px]`,children:F?(0,$.jsx)(`span`,{className:`truncate`,children:Ee(F)}):(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e(`settings.agents.page.permissions.permissionPlaceholder`)})}),(0,$.jsx)(en,{children:ge.map(e=>(0,$.jsx)(sn,{value:e,children:(0,$.jsx)(`div`,{className:`flex items-center justify-between gap-2 w-full`,children:(0,$.jsx)(`span`,{children:Ee(e)})})},e))})]}),(0,$.jsx)(ln,{value:L,onChange:e=>R(e.target.value),placeholder:e(`settings.agents.page.permissions.patternPlaceholder`),className:`h-7 flex-1 font-mono text-xs`}),(0,$.jsxs)(`div`,{className:`flex gap-1`,children:[(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>we(`allow`),children:e(`settings.common.permission.allow`)}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>we(`ask`),children:e(`settings.common.permission.ask`)}),(0,$.jsx)(Y,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>we(`deny`),children:e(`settings.common.permission.deny`)})]})]})]})]}):(0,$.jsx)($.Fragment,{children:de.map(t=>{let{defaultAction:n,patternRulesCount:r,patternSummary:i,hasDefaultHint:a}=fe(t),o=Ee(t),s=a?`${n} (env blocked)`:n;return(0,$.jsx)(Ar,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:o}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 font-mono hidden sm:inline-block`,children:t})]}),children:(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[r>0?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-[var(--surface-muted)] px-1.5 py-0.5 rounded`,children:e(`settings.agents.page.permissions.globalSummary`,{summary:s})}):(0,$.jsx)(`span`,{className:q(`typography-micro capitalize px-1.5 py-0.5 rounded`,s===`allow`?`text-[var(--status-success)] bg-[var(--status-success)]/10`:s===`deny`?`text-[var(--status-error)] bg-[var(--status-error)]/10`:`text-[var(--status-warning)] bg-[var(--status-warning)]/10`),children:s}),r>0&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-[var(--surface-muted)] px-1.5 py-0.5 rounded`,children:e(`settings.agents.page.permissions.rulesSummary`,{summary:i})})]})},t)})})})}),(0,$.jsx)(`div`,{className:`px-2 py-1`,children:(0,$.jsx)(Y,{onClick:async()=>{let t=u?d.trim().replace(/\s+/g,`-`):n?.trim();if(!t){K.error(e(`settings.agents.sidebar.toast.agentNameRequired`));return}if(u&&c.some(e=>e.name===t)){K.error(e(`settings.agents.sidebar.toast.agentExists`));return}H(!0);try{let n={description:h,mode:_,model:y,variant:x,temperature:C,topP:T,prompt:D,globalPermission:k,permissionRules:N},r=U.current,c=r?{description:r.description,mode:r.mode,model:r.model,variant:r.variant,temperature:r.temperature,topP:r.topP,prompt:r.prompt,globalPermission:r.globalPermission,permissionRules:r.permissionRules}:null,l=ka({isNewAgent:u,agentName:t,draftScope:u?p:void 0,draftHasExplicitPermission:u&&o?.permission!==void 0,current:n,initial:c,permissionConfig:Ba(k,N)}),d;u?(d=await i(l),d.ok&&s(null)):d=await a(t,l),d.ok?d.requiresManualRestart?K.warning(e(`settings.agents.page.toast.savedManualRestart`)):K.success(e(u?`settings.agents.page.toast.created`:`settings.agents.page.toast.updated`)):K.error(e(u?`settings.agents.page.toast.createFailed`:`settings.agents.page.toast.updateFailed`))}catch(t){console.error(`Error saving agent:`,t);let n=t instanceof Error&&t.message?t.message:e(`settings.agents.page.toast.saveUnexpectedError`);K.error(n)}finally{H(!1)}},disabled:V||!De,size:`xs`,className:`!font-normal`,children:e(V?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)})})]})}):(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`robot-2`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.agents.page.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.agents.page.empty.description`)})]})})},Ua=e=>{let t=(0,bi.c)(23),{title:n,metadata:r,selected:i,onSelect:a,icon:o,actions:s,className:c}=e,l=i!==void 0&&i,u=s&&s.length>0,d=l?`bg-interactive-selection`:`hover:bg-interactive-hover`,f;t[0]!==c||t[1]!==d?(f=q(`oc-settings-group-row group relative flex items-center transition-colors duration-150`,d,c),t[0]=c,t[1]=d,t[2]=f):f=t[2];let p;t[3]===n?p=t[4]:(p=(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:n}),t[3]=n,t[4]=p);let m;t[5]!==o||t[6]!==p?(m=(0,$.jsxs)(`div`,{className:`flex max-w-full min-w-0 items-center gap-1.5`,children:[o,p]}),t[5]=o,t[6]=p,t[7]=m):m=t[7];let h;t[8]===r?h=t[9]:(h=r&&(0,$.jsx)(`div`,{className:`max-w-full truncate typography-micro leading-tight text-muted-foreground/60`,children:r}),t[8]=r,t[9]=h);let g;t[10]!==a||t[11]!==m||t[12]!==h?(g=(0,$.jsxs)(`button`,{onClick:a,"data-mobile-press-feedback":`soft`,className:`flex min-w-0 flex-1 self-stretch flex-col justify-center gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,tabIndex:0,children:[m,h]}),t[10]=a,t[11]=m,t[12]=h,t[13]=g):g=t[13];let _;t[14]!==s||t[15]!==u?(_=u&&(0,$.jsxs)(Wn,{children:[(0,$.jsx)(qn,{asChild:!0,children:(0,$.jsx)(Y,{size:`icon`,variant:`ghost`,className:`h-6 w-6 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(J,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(Un,{align:`end`,className:`w-fit min-w-20`,children:s.map(Wa)})]}),t[14]=s,t[15]=u,t[16]=_):_=t[16];let v;t[17]!==g||t[18]!==_?(v=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 self-stretch items-center`,children:[g,_]}),t[17]=g,t[18]=_,t[19]=v):v=t[19];let y;return t[20]!==f||t[21]!==v?(y=(0,$.jsx)(`div`,{className:f,children:v}),t[20]=f,t[21]=v,t[22]=y):y=t[22],y};function Wa(e){let t=e.icon;return(0,$.jsxs)(Jn,{onClick:t=>{t.stopPropagation(),e.onClick()},className:q(e.destructive&&`text-destructive focus:text-destructive`),children:[t&&(0,$.jsx)(J,{name:t,className:`h-4 w-4 mr-px`}),e.label]},e.label)}var Ga=e=>{let t=(0,bi.c)(8),{header:n,footer:r,children:i,className:a,variant:o}=e,s=o===void 0?`sidebar`:o,c=p(),l=s===`background`||c?`bg-background`:`bg-sidebar`,u;t[0]!==l||t[1]!==a?(u=q(`oc-settings-page-content h-full overflow-y-auto p-3`,l,a),t[0]=l,t[1]=a,t[2]=u):u=t[2];let d;return t[3]!==i||t[4]!==r||t[5]!==n||t[6]!==u?(d=(0,$.jsxs)(`div`,{className:u,children:[n,i,r]}),t[3]=i,t[4]=r,t[5]=n,t[6]=u,t[7]=d):d=t[7],d},Ka=`__managed_workspace__`,qa=`__current_workspace__`,Ja=()=>({enabled:!0,name:``,defaultPrompt:``,workspacePath:null,providerID:``,modelID:``,agent:null,mode:`continuous`}),Ya=e=>({enabled:e.enabled,name:e.name,defaultPrompt:e.defaultPrompt,workspacePath:e.workspacePath,providerID:e.providerID,modelID:e.modelID,agent:e.agent,mode:e.mode}),Xa=e=>e.label?.trim()||e.path.replace(/[\\/]+$/,``).split(/[\\/]/).filter(Boolean).at(-1)||e.path,Za=e=>{let t=(0,bi.c)(11),{name:n,path:r,icon:i}=e,a=i===void 0?`folder`:i,o;t[0]===a?o=t[1]:(o=(0,$.jsx)(J,{name:a,className:`size-4 shrink-0 text-muted-foreground`}),t[0]=a,t[1]=o);let s=r?`max-w-[40%] shrink-0 truncate typography-ui-label text-foreground`:`min-w-0 truncate typography-ui-label text-foreground`,c;t[2]!==n||t[3]!==s?(c=(0,$.jsx)(`span`,{className:s,children:n}),t[2]=n,t[3]=s,t[4]=c):c=t[4];let l;t[5]===r?l=t[6]:(l=r?(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-micro text-muted-foreground`,title:r,children:r}):null,t[5]=r,t[6]=l);let u;return t[7]!==o||t[8]!==c||t[9]!==l?(u=(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[o,c,l]}),t[7]=o,t[8]=c,t[9]=l,t[10]=u):u=t[10],u},Qa=e=>{let t=(0,bi.c)(82),{onItemSelect:n}=e,{t:r}=Te(),i=Rt(),a=At(),o=i.data,s=zt(eo),c=zt(to),l=zt(no),[u,d]=Q.useState(!1),f;t[0]!==n||t[1]!==c||t[2]!==s||t[3]!==o?(f=()=>{!n&&s===null&&o?.assistants[0]&&c(o.assistants[0].id)},t[0]=n,t[1]=c,t[2]=s,t[3]=o,t[4]=f):f=t[4];let p=o?.assistants,m;t[5]!==n||t[6]!==c||t[7]!==s||t[8]!==p?(m=[n,c,s,p],t[5]=n,t[6]=c,t[7]=s,t[8]=p,t[9]=m):m=t[9],Q.useEffect(f,m);let h;t[10]!==n||t[11]!==c||t[12]!==s||t[13]!==o?.assistants||t[14]!==i.isSuccess?(h=()=>{i.isSuccess&&s&&s!==`new`&&!o?.assistants.some(e=>e.id===s)&&c(n?null:o?.assistants[0]?.id??null)},t[10]=n,t[11]=c,t[12]=s,t[13]=o?.assistants,t[14]=i.isSuccess,t[15]=h):h=t[15];let g=o?.assistants,_;t[16]!==n||t[17]!==c||t[18]!==s||t[19]!==i.isSuccess||t[20]!==g?(_=[n,c,s,g,i.isSuccess],t[16]=n,t[17]=c,t[18]=s,t[19]=i.isSuccess,t[20]=g,t[21]=_):_=t[21],Q.useEffect(h,_);let v;t[22]!==n||t[23]!==l?(v=()=>{l(),n?.()},t[22]=n,t[23]=l,t[24]=v):v=t[24];let y=we(v),b;t[25]!==o||t[26]!==r?(b=async e=>{if(o)try{await Ft(e,o.revision)}catch{Se.error(r(`assistants.settings.toast.toggleFailed`))}},t[25]=o,t[26]=r,t[27]=b):b=t[27];let x=we(b);if(a.isSuccess&&!a.data.supported)return null;let S;t[28]===r?S=t[29]:(S=r(`assistants.settings.description`),t[28]=r,t[29]=S);let C;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{e.preventDefault(),d(!0)},t[30]=C):C=t[30];let w;t[31]===r?w=t[32]:(w=r(`assistants.settings.descriptionLearnMore`),t[31]=r,t[32]=w);let T;t[33]===w?T=t[34]:(T=(0,$.jsx)(`a`,{href:`#assistant-share-welcome`,className:`underline underline-offset-2`,onClick:C,children:w}),t[33]=w,t[34]=T);let E;t[35]!==T||t[36]!==S?(E=(0,$.jsxs)($.Fragment,{children:[S,T]}),t[35]=T,t[36]=S,t[37]=E):E=t[37];let D=o?.enabled??!1,O;t[38]===r?O=t[39]:(O=r(`assistants.settings.instanceEnabled`),t[38]=r,t[39]=O);let k;t[40]===r?k=t[41]:(k=r(`assistants.settings.instanceEnabled`),t[40]=r,t[41]=k);let A;t[42]!==D||t[43]!==O||t[44]!==k||t[45]!==x?(A=(0,$.jsx)(Fr,{itemId:`assistants.instance-enabled`,checked:D,onChange:x,label:O,ariaLabel:k}),t[42]=D,t[43]=O,t[44]=k,t[45]=x,t[46]=A):A=t[46];let j;t[47]!==E||t[48]!==A?(j=(0,$.jsx)(Z,{description:E,children:A}),t[47]=E,t[48]=A,t[49]=j):j=t[49];let M;t[50]===u?M=t[51]:(M=(0,$.jsx)(ji,{open:u,onOpenChange:d}),t[50]=u,t[51]=M);let N;t[52]!==j||t[53]!==M?(N=(0,$.jsxs)($.Fragment,{children:[j,M]}),t[52]=j,t[53]=M,t[54]=N):N=t[54];let P;t[55]===r?P=t[56]:(P=r(`assistants.settings.listTitle`),t[55]=r,t[56]=P);let F;t[57]===P?F=t[58]:(F=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:P}),t[57]=P,t[58]=F);let I;t[59]===r?I=t[60]:(I=r(`assistants.settings.create`),t[59]=r,t[60]=I);let L;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(J,{name:`add`,className:`size-4`}),t[61]=L):L=t[61];let R;t[62]!==y||t[63]!==I?(R=(0,$.jsx)(Y,{"data-settings-item":`assistants.create`,variant:`ghost`,size:`icon`,onClick:y,"aria-label":I,children:L}),t[62]=y,t[63]=I,t[64]=R):R=t[64];let z;t[65]!==F||t[66]!==R?(z=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[F,R]}),t[65]=F,t[66]=R,t[67]=z):z=t[67];let B;t[68]!==a.isPending||t[69]!==n||t[70]!==c||t[71]!==s||t[72]!==o||t[73]!==i.isPending||t[74]!==r?(B=i.isPending||a.isPending?(0,$.jsxs)(`div`,{className:`oc-settings-group-row flex items-center justify-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`loader-4`,className:`mr-2 size-4 animate-spin`}),r(`common.loading`)]}):o?.assistants.length?o.assistants.map(e=>{let t=Dt(e.name);return(0,$.jsx)(Ua,{title:t.displayName,selected:s===e.id,onSelect:()=>{c(e.id),n?.()},icon:(0,$.jsx)(Bt,{name:e.id,emoji:t.avatarEmoji,size:24,label:t.displayName||e.name})},e.id)}):(0,$.jsx)(`div`,{className:`oc-settings-group-row text-muted-foreground`,children:r(`assistants.settings.empty`)}),t[68]=a.isPending,t[69]=n,t[70]=c,t[71]=s,t[72]=o,t[73]=i.isPending,t[74]=r,t[75]=B):B=t[75];let V;t[76]!==z||t[77]!==B?(V=(0,$.jsx)(Z,{label:z,children:B}),t[76]=z,t[77]=B,t[78]=V):V=t[78];let H;return t[79]!==N||t[80]!==V?(H=(0,$.jsx)(Ga,{variant:`background`,header:N,children:V}),t[79]=N,t[80]=V,t[81]=H):H=t[81],H},$a=({onItemDeleted:e})=>{let{t}=Te(),n=Rt(),r=At(),i=n.data,a=rt(e=>e.projects),o=zt(e=>e.settingsSelectedAssistantID),s=zt(e=>e.selectSettingsAssistant),c=zt(e=>e.defaultShareAssistant),l=zt(e=>e.setDefaultShareAssistant),u=zt(e=>e.createRequestRevision),d=zt(e=>e.requestCreate),[f,p]=Q.useState(Ja),[m,h]=Q.useState(!1),g=Q.useRef(0),_=i?.assistants.find(e=>e.id===o)??null,v=_?Dt(_.name):null,y=Dt(f.name),b=f.workspacePath??_?.managedWorkspacePath??null,x=et(b,{enabled:!0}),S=St(b,{enabled:!0}),C=x.data??[],w=S.data??[];Q.useEffect(()=>{_&&p(Ya(_))},[_]),Q.useEffect(()=>{n.isSuccess&&o&&o!==`new`&&!_&&s(null)},[s,_,o,n.isSuccess]),Q.useEffect(()=>{o!==`new`||u<=g.current||(g.current=u,p(Ja()),window.requestAnimationFrame(()=>document.getElementById(`assistant-name`)?.focus()))},[u,o]),Q.useEffect(()=>{n.isSuccess&&r.data?.serverInstanceID&&c?.serverInstanceID===r.data.serverInstanceID&&!i?.assistants.some(e=>e.id===c.assistantID)&&l(null)},[r.data,c,l,i?.assistants,n.isSuccess]),Q.useEffect(()=>{n.isSuccess&&Ot()},[i?.revision,n.isSuccess]);let T=(e,t)=>{p(n=>({...n,[e]:t}))},E=we(()=>d()),D=we(async()=>{if(!f.name.trim()||!f.providerID||!f.modelID){Se.error(t(`assistants.settings.validation.required`));return}h(!0);try{let e=_?await Pt(_,f):await It(f);s(e.id),Se.success(t(`assistants.settings.toast.saved`))}catch{Se.error(t(`assistants.settings.toast.saveFailed`))}finally{h(!1)}}),O=we(async()=>{if(!(!_||!window.confirm(t(`assistants.settings.deleteConfirm`,{name:_.name})))){h(!0);try{if(await jt(_),c?.assistantID===_.id){let e=await Mt();e.serverInstanceID&&c.serverInstanceID===e.serverInstanceID&&l(null)}s(null),e?.(),Se.success(t(`assistants.settings.toast.deleted`))}catch{Se.error(t(`assistants.settings.toast.deleteFailed`))}finally{h(!1)}}}),k=we(async(e,n)=>{if(!n){l(null),kt();return}try{let t=await Mt();if(!t.supported||!t.serverInstanceID)return;l({serverInstanceID:t.serverInstanceID,assistantID:e}),await kt()}catch{Se.error(t(`assistants.settings.toast.toggleFailed`))}}),A=f.workspacePath===null?null:a.find(e=>e.path===f.workspacePath)??null,j=f.workspacePath!==null&&!A?f.workspacePath:null,M=f.workspacePath===null?Ka:A?A.id:qa,N=f.workspacePath===null?(0,$.jsx)(Za,{name:t(`assistants.settings.workspacePlaceholder`),icon:`cloud`}):A?(0,$.jsx)(Za,{name:Xa(A),path:A.path}):(0,$.jsx)(Za,{name:t(`assistants.settings.workspaceCurrentPath`),path:j??``,icon:`history`});return r.isSuccess&&!r.data.supported?null:n.isPending||r.isPending?(0,$.jsxs)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`loader-4`,className:`mr-2 size-4 animate-spin`}),t(`common.loading`)]}):n.isError&&!i?(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center`,children:[(0,$.jsx)(J,{name:`cloud-off`,className:`size-6 text-muted-foreground`}),(0,$.jsx)(`p`,{className:`typography-ui text-muted-foreground`,children:t(`assistants.state.unavailable`)}),(0,$.jsx)(Y,{variant:`outline`,size:`sm`,onClick:()=>void n.refetch(),children:t(`assistants.actions.retry`)})]}):(0,$.jsx)(Jt,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[n.isError&&i?(0,$.jsx)(`p`,{className:`mb-4 px-2 typography-meta text-[var(--status-warning)]`,children:t(`assistants.state.staleSnapshot`)}):null,o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`mb-4 flex items-center gap-3`,children:[(0,$.jsx)(Bt,{name:_?.id??`new`,emoji:y.avatarEmoji,size:38,label:y.displayName||f.name||t(`assistants.settings.create`)}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h2`,{className:`truncate typography-ui-header font-semibold text-foreground`,children:_?v?.displayName:t(`assistants.settings.create`)}),(0,$.jsx)(`p`,{className:`mt-0.5 typography-micro leading-none text-muted-foreground/70`,children:f.mode===`continuous`?t(`assistants.mode.continuous`):t(`assistants.mode.stateless`)})]}),_?(0,$.jsxs)(Y,{variant:`ghost`,size:`sm`,onClick:O,disabled:m,className:`text-[var(--status-error)]`,children:[(0,$.jsx)(J,{name:`delete-bin`,className:`size-4`}),t(`assistants.settings.delete`)]}):null]}),(0,$.jsxs)(Z,{children:[(0,$.jsx)(Ar,{itemId:`assistants.name`,label:t(`assistants.settings.name`),children:(0,$.jsx)(ln,{id:`assistant-name`,value:f.name,onChange:e=>T(`name`,e.target.value),className:`min-w-0 flex-1`})}),(0,$.jsx)(Ar,{label:t(`assistants.settings.enabled`),children:(0,$.jsx)(Zt,{checked:f.enabled,onChange:e=>T(`enabled`,e),ariaLabel:t(`assistants.settings.enabled`)})}),_?(0,$.jsx)(Ar,{itemId:`assistants.default-share`,label:t(`assistants.settings.defaultShare`),children:(0,$.jsx)(Zt,{checked:c?.assistantID===_.id&&c.serverInstanceID===r.data?.serverInstanceID,onChange:e=>void k(_.id,e),ariaLabel:t(`assistants.settings.defaultShare`)})}):null]}),(0,$.jsx)(Tr,{itemId:`assistants.prompt`,label:t(`assistants.settings.defaultPrompt`),className:`oc-settings-split-row-stacked`,children:(0,$.jsx)(on,{embedded:!0,id:`assistant-prompt`,value:f.defaultPrompt,onChange:e=>T(`defaultPrompt`,e.target.value),placeholder:t(`assistants.settings.defaultPromptPlaceholder`),rows:12,outerClassName:`min-h-[240px] max-h-[70vh]`})}),(0,$.jsxs)(Z,{label:t(`assistants.settings.runtime`),children:[(0,$.jsx)(Ar,{itemId:`assistants.model`,label:t(`assistants.settings.model`),children:(0,$.jsx)(ar,{providerId:f.providerID,modelId:f.modelID,providers:C,onChange:(e,t)=>p(n=>({...n,providerID:e,modelID:t})),className:`oc-settings-inline-value`})}),(0,$.jsx)(Ar,{itemId:`assistants.agent`,label:t(`assistants.settings.agent`),children:(0,$.jsx)(nr,{agentName:f.agent??``,agents:w,onChange:e=>T(`agent`,e||null),className:`oc-settings-inline-value`})}),(0,$.jsx)(Ar,{itemId:`assistants.mode`,label:t(`assistants.settings.mode`),description:f.mode===`stateless`?t(`assistants.conversation.statelessHint`):t(`assistants.conversation.continuousHint`),children:(0,$.jsx)(`div`,{className:`flex min-w-0 flex-wrap justify-end gap-2`,children:(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[`continuous`,`stateless`].map(e=>(0,$.jsx)(Y,{variant:`chip`,size:`xs`,"aria-pressed":f.mode===e,onClick:()=>T(`mode`,e),children:t(e===`continuous`?`assistants.mode.continuous`:`assistants.mode.stateless`)},e))})})})]}),(0,$.jsx)(Tr,{itemId:`assistants.workspace`,label:t(`assistants.settings.workspace`),description:t(`assistants.settings.workspaceChangeHint`),descriptionPlacement:`outside`,children:(0,$.jsxs)(tn,{value:M,onValueChange:e=>{if(e===Ka){T(`workspacePath`,null);return}let t=a.find(t=>t.id===e);t&&T(`workspacePath`,t.path)},children:[(0,$.jsx)(cn,{title:f.workspacePath??t(`assistants.settings.workspacePlaceholder`),className:`w-full max-w-xl [&_[data-slot=select-value]]:min-w-0 [&_[data-slot=select-value]]:flex-1 [&_[data-slot=select-value]]:overflow-hidden`,children:(0,$.jsx)(Qt,{children:N})}),(0,$.jsxs)(en,{align:`start`,className:`w-[min(32rem,calc(100vw-2rem))]`,children:[(0,$.jsx)(sn,{value:Ka,children:(0,$.jsx)(Za,{name:t(`assistants.settings.workspacePlaceholder`),icon:`cloud`})}),a.map(e=>(0,$.jsx)(sn,{value:e.id,children:(0,$.jsx)(Za,{name:Xa(e),path:e.path})},e.id)),j?(0,$.jsx)(sn,{value:qa,disabled:!0,children:(0,$.jsx)(Za,{name:t(`assistants.settings.workspaceCurrentPath`),path:j,icon:`history`})}):null]})]})}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsxs)(Y,{onClick:D,disabled:m,children:[m?(0,$.jsx)(J,{name:`loader-4`,className:`size-4 animate-spin`}):null,t(`assistants.settings.save`)]})})]}):(0,$.jsxs)(`div`,{className:`flex min-h-80 flex-col items-center justify-center gap-3 px-6 text-center text-muted-foreground`,children:[(0,$.jsx)(Bt,{name:`assistants-empty`,size:44}),(0,$.jsx)(`p`,{className:`typography-ui`,children:t(`assistants.settings.empty`)}),(0,$.jsxs)(Y,{"data-settings-item":`assistants.create`,size:`sm`,onClick:E,children:[(0,$.jsx)(J,{name:`add`,className:`size-4`}),t(`assistants.settings.create`)]})]})]})})};function eo(e){return e.settingsSelectedAssistantID}function to(e){return e.selectSettingsAssistant}function no(e){return e.requestCreate}var ro=`~/.config/opencode/AGENTS.md`,io=async(e,t)=>{let n=await e.json().catch(()=>null);return typeof n?.error==`string`&&n.error.trim()?n.error:t},ao=e=>e.length>0&&!e.endsWith(`
|
|
2
2
|
`)?`${e}\n`:e,oo={prompt:``,responseStyleEnabled:!1,responseStylePreset:`concise`,responseStyleCustomInstructions:``},so=(e,t)=>e===`custom`?t:Re(e),co=e=>e===`custom`?`custom`:ut(e)?e:`concise`,lo={concise:`settings.behavior.page.responseStyle.option.concise`,detailed:`settings.behavior.page.responseStyle.option.detailed`,mentor:`settings.behavior.page.responseStyle.option.mentor`,pushback:`settings.behavior.page.responseStyle.option.pushback`,noFiller:`settings.behavior.page.responseStyle.option.noFiller`,matchEnergy:`settings.behavior.page.responseStyle.option.matchEnergy`,warmPeer:`settings.behavior.page.responseStyle.option.warmPeer`},uo=async(e,t)=>{let n=await I(`/api/config/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)});if(!n.ok)throw Error(await io(n,t));return n.json().catch(()=>null)},fo=()=>{let{t:e}=Te(),t=Q.useSyncExternalStore(o,r,r),[n,i]=Q.useState(``),[a,s]=Q.useState(oo.responseStyleEnabled),[c,l]=Q.useState(oo.responseStylePreset),[u,d]=Q.useState(oo.responseStyleCustomInstructions),[f,p]=Q.useState(!1),[m,h]=Q.useState(!1),[g,_]=Q.useState(!1),[v,y]=Q.useState(``),b=Q.useRef(null),x=Q.useRef(null),S=Q.useRef(0),C=Q.useRef(Promise.resolve());Q.useEffect(()=>{let e=!0;return h(!1),b.current=null,x.current=null,S.current+=1,P(t).then(n=>{if(!e||t!==r())return;let i={enabled:n.responseStyleEnabled===!0,preset:co(n.responseStylePreset),custom:typeof n.responseStyleCustomInstructions==`string`?n.responseStyleCustomInstructions:``};s(i.enabled),l(i.preset),d(i.custom),ke({enabled:i.enabled,preset:i.preset,customInstructions:i.custom},t),b.current=i,x.current=i,h(!0)}).catch(t=>{e&&t?.name!==`AbortError`&&console.warn(`Failed to load behavior settings:`,t)}),()=>{e=!1,S.current+=1}},[t]),Q.useEffect(()=>{let e=new AbortController,n=!0;return p(!1),_(!1),(async()=>{try{let a=await I(`/api/behavior/agents-md`,{method:`GET`,headers:{Accept:`application/json`},signal:e.signal});if(!a.ok)throw Error(`Behavior prompt request failed (${a.status})`);let o=await a.json().catch(()=>null);if(typeof o?.content!=`string`)throw Error(`Invalid behavior prompt response`);if(!n||t!==r())return;i(o.content),y(o.content),p(!0)}catch(e){n&&e?.name!==`AbortError`&&console.warn(`Failed to load behavior prompt:`,e)}})(),()=>{n=!1,e.abort()}},[t]),Q.useEffect(()=>{if(!m)return;let n={enabled:a,preset:c,custom:u},i=x.current;if(i&&i.enabled===n.enabled&&i.preset===n.preset&&i.custom===n.custom)return;x.current=n;let o=S.current+1;S.current=o;let f=setTimeout(()=>{let i=async()=>{if(t===r())try{let i=await uo({responseStyleEnabled:n.enabled,responseStylePreset:n.preset,responseStyleCustomInstructions:n.custom},e(`settings.behavior.page.toast.saveFailed`));if(t!==r())return;let a=j(i),c={enabled:a.responseStyleEnabled??n.enabled,preset:a.responseStylePreset??n.preset,custom:a.responseStyleCustomInstructions??n.custom};if(ke({enabled:c.enabled,preset:c.preset,customInstructions:c.custom},t),T({responseStyleEnabled:c.enabled,responseStylePreset:c.preset,responseStyleCustomInstructions:c.custom},t),b.current=c,o!==S.current)return;x.current=c,s(c.enabled),l(c.preset),d(c.custom)}catch(n){if(t===r()&&o===S.current){let t=b.current;x.current=t,t&&(s(t.enabled),l(t.preset),d(t.custom));let r=n instanceof Error?n.message:e(`settings.behavior.page.toast.saveFailed`);K.error(r)}}};C.current=C.current.then(i,i)},400);return()=>clearTimeout(f)},[a,c,u,m,e,t]);let w=so(c,u),E=n!==v;return(0,$.jsx)(Jt,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(`div`,{className:`space-y-1`,children:(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground`,children:e(`settings.behavior.page.title`)})}),(0,$.jsx)(Z,{itemId:`behavior.system-prompt`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.behavior.page.section.systemPrompt`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`p`,{className:`font-medium text-foreground`,children:e(`settings.behavior.page.warning.title`)}),(0,$.jsx)(`p`,{children:e(`settings.behavior.page.warning.description`,{path:ro})})]})})]})]}),children:(0,$.jsxs)(`div`,{className:`oc-settings-group-row flex flex-col gap-3`,children:[(0,$.jsx)(on,{embedded:!0,value:n,onChange:e=>i(e.target.value),placeholder:e(`settings.behavior.page.field.systemPromptPlaceholder`),rows:12,disabled:!f,outerClassName:`min-h-[160px] max-h-[70vh]`,className:`w-full font-mono typography-meta bg-transparent`}),(0,$.jsx)(Y,{onClick:async()=>{let a=t;if(a===r()){_(!0);try{let t=ao(n),o=await I(`/api/behavior/agents-md`,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({content:t})});if(!o.ok)throw Error(await io(o,e(`settings.behavior.page.toast.saveFailed`)));if(a!==r()||(await uo({globalBehaviorPrompt:t},e(`settings.behavior.page.toast.saveFailed`)),a!==r()))return;i(t),y(t),K.success(e(`settings.behavior.page.toast.saved`))}catch(t){if(a!==r())return;console.error(`Failed to save behavior:`,t);let n=t instanceof Error?t.message:e(`settings.behavior.page.toast.saveFailed`);K.error(n)}finally{a===r()&&_(!1)}}},disabled:g||!E||!f,size:`xs`,className:`!font-normal`,children:e(g?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)})]})}),(0,$.jsxs)(Z,{itemId:`behavior.response-style`,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.behavior.page.section.responseStyle`)}),(0,$.jsxs)(fn,{children:[(0,$.jsx)(un,{asChild:!0,children:(0,$.jsx)(J,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(dn,{sideOffset:8,className:`max-w-xs`,children:e(`settings.behavior.page.responseStyle.tooltip`)})]})]}),children:[(0,$.jsxs)(Ar,{label:e(`settings.behavior.page.responseStyle.enable`),children:[(0,$.jsx)(Zt,{checked:a,onChange:s,disabled:!m,ariaLabel:e(`settings.behavior.page.responseStyle.enableAria`)}),(0,$.jsxs)(tn,{value:c,onValueChange:e=>l(e),disabled:!m||!a,children:[(0,$.jsx)(cn,{className:`w-full sm:w-56`,children:(0,$.jsx)(Qt,{children:t=>t===`custom`?e(`settings.behavior.page.responseStyle.option.custom`):ut(t)?e(lo[t]):null})}),(0,$.jsxs)(en,{children:[Ne.map(t=>(0,$.jsx)(sn,{value:t,children:e(lo[t])},t)),(0,$.jsx)(sn,{value:`custom`,children:e(`settings.behavior.page.responseStyle.option.custom`)})]})]})]}),(0,$.jsx)(`div`,{className:`oc-settings-group-row`,children:(0,$.jsx)(on,{embedded:!0,value:w,onChange:e=>d(e.target.value),placeholder:e(`settings.behavior.page.responseStyle.customPlaceholder`),rows:5,disabled:!m||!a||c!==`custom`,outerClassName:`min-h-[120px]`,className:`w-full font-mono typography-meta bg-transparent`})})]})]})})},po=e=>{let t=(0,bi.c)(158),{onItemSelect:n}=e,{t:r}=Te(),[i,a]=Q.useState(null),[o,s]=Q.useState(``),[c,l]=Q.useState(null),[u,d]=Q.useState(null),[f,p]=Q.useState(!1),[m,h]=Q.useState(null),{selectedCommandName:g,setSelectedCommand:_,setCommandDraft:v,createCommand:y,deleteCommand:b}=Li(me(ho)),x=it(),S;t[0]===x.data?S=t[1]:(S=x.data??[],t[0]=x.data,t[1]=S);let C=S,w=Oe(),T;t[2]===w.data?T=t[3]:(T=w.data??[],t[2]=w.data,t[3]=T);let E=T,{refetch:D}=w,O,k;t[4]===D?(O=t[5],k=t[6]):(O=()=>{D()},k=[D],t[4]=D,t[5]=O,t[6]=k),Q.useEffect(O,k);let A;t[7]===E?A=t[8]:(A=new Set(E.map(go)),t[7]=E,t[8]=A);let j=A,M;if(t[9]!==C||t[10]!==j){let e;t[12]===j?e=t[13]:(e=e=>!j.has(e.name),t[12]=j,t[13]=e),M=C.filter(e),t[9]=C,t[10]=j,t[11]=M}else M=t[11];let N=M,P,F;t[14]!==g||t[15]!==_||t[16]!==j?(P=()=>{g&&j.has(g)&&_(null)},F=[g,_,j],t[14]=g,t[15]=_,t[16]=j,t[17]=P,t[18]=F):(P=t[17],F=t[18]),Q.useEffect(P,F);let I;t[19]!==C||t[20]!==n||t[21]!==v||t[22]!==_?(I=()=>{let e=`new-command`,t=1;for(;C.some(t=>t.name===e);)e=`new-command-${t}`,t++;v({name:e,scope:`user`}),_(e),n?.()},t[19]=C,t[20]=n,t[21]=v,t[22]=_,t[23]=I):I=t[23];let L=I,R;t[24]===r?R=t[25]:(R=async e=>{if(Fi(e)){K.error(r(`settings.commands.sidebar.toast.builtInCannotDelete`));return}l(e),d(`delete`)},t[24]=r,t[25]=R);let z=R,B;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(B=async e=>{Fi(e)&&(l(e),d(`reset`))},t[26]=B):B=t[26];let V=B,H;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(H=()=>{l(null),d(null)},t[27]=H):H=t[27];let U=H,W;t[28]!==c||t[29]!==u||t[30]!==b||t[31]!==r?(W=async()=>{!c||!u||(p(!0),await b(c.name)?(u===`delete`?K.success(r(`settings.commands.sidebar.toast.commandDeleted`,{name:c.name})):K.success(r(`settings.commands.sidebar.toast.commandReset`,{name:c.name})),U()):u===`delete`?K.error(r(`settings.commands.sidebar.toast.deleteFailed`)):K.error(r(`settings.commands.sidebar.toast.resetFailed`)),p(!1))},t[28]=c,t[29]=u,t[30]=b,t[31]=r,t[32]=W):W=t[32];let ee=W,G;t[33]!==C||t[34]!==v||t[35]!==_?(G=e=>{let t=e.name,n=1,r=`${t}-copy`;for(;C.some(e=>e.name===r);)n++,r=`${t}-copy-${n}`;v({name:r,scope:e.scope||`user`,description:e.description,template:e.template,agent:e.agent,model:e.model}),_(r)},t[33]=C,t[34]=v,t[35]=_,t[36]=G):G=t[36];let te=G,ne;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(ne=e=>{s(e.name),a(e)},t[37]=ne):ne=t[37];let re=ne,ie;t[38]!==C||t[39]!==y||t[40]!==b||t[41]!==i||t[42]!==o||t[43]!==_||t[44]!==r?(ie=async()=>{if(!i)return;let e=o.trim().replace(/\s+/g,`-`);if(!e){K.error(r(`settings.commands.sidebar.toast.commandNameRequired`));return}if(e===i.name){a(null);return}if(C.some(t=>t.name===e)){K.error(r(`settings.commands.sidebar.toast.commandExists`));return}await y({name:e,description:i.description,template:i.template,agent:i.agent,model:i.model})?await b(i.name)?(K.success(`Command renamed to "${e}"`),_(e)):K.error(r(`settings.commands.sidebar.toast.removeOldAfterRenameFailed`)):K.error(r(`settings.commands.sidebar.toast.renameFailed`)),a(null)},t[38]=C,t[39]=y,t[40]=b,t[41]=i,t[42]=o,t[43]=_,t[44]=r,t[45]=ie):ie=t[45];let ae=ie,oe,se,ce;if(t[46]!==N||t[47]!==L||t[48]!==z||t[49]!==te||t[50]!==n||t[51]!==m||t[52]!==g||t[53]!==_||t[54]!==r){let e=N.filter(Fi),i=N.filter(_o),a;t[58]===r?a=t[59]:(a=r(`settings.commands.sidebar.section.custom`),t[58]=r,t[59]=a);let o;t[60]===a?o=t[61]:(o=(0,$.jsx)(`span`,{children:a}),t[60]=a,t[61]=o);let s;t[62]===r?s=t[63]:(s=r(`settings.commands.page.title.new`),t[62]=r,t[63]=s);let c;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(J,{name:`add`,className:`h-4 w-4`}),t[64]=c):c=t[64];let l;t[65]!==L||t[66]!==s?(l=(0,$.jsx)(Y,{"data-settings-item":`commands.create`,size:`icon`,variant:`ghost`,onClick:L,"aria-label":s,children:c}),t[65]=L,t[66]=s,t[67]=l):l=t[67];let u;t[68]!==o||t[69]!==l?(u=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[o,l]}),t[68]=o,t[69]=l,t[70]=u):u=t[70];let d=u;oe=`oc-settings-page-content h-full overflow-y-auto bg-background p-3`,t[71]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,$.jsx)(Z,{children:(0,$.jsx)(`div`,{className:`oc-settings-group-row`,children:(0,$.jsx)(sa,{})})}),t[71]=se):se=t[71],ce=(0,$.jsx)($.Fragment,{children:N.length===0?(0,$.jsx)(Z,{label:d,children:(0,$.jsxs)(`div`,{className:`oc-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`terminal-box`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:r(`settings.commands.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:r(`settings.commands.sidebar.empty.description`)})]})}):(0,$.jsxs)($.Fragment,{children:[e.length>0&&(0,$.jsx)(Z,{label:r(`settings.commands.sidebar.section.builtIn`),children:[...e].sort(vo).map(e=>(0,$.jsx)(mo,{command:e,isSelected:g===e.name,onSelect:()=>{_(e.name),n?.()},onReset:()=>V(e),onDuplicate:()=>te(e),isMenuOpen:m===e.name,onMenuOpenChange:t=>h(t?e.name:null)},e.name))}),i.length>0?(0,$.jsx)(Z,{label:d,children:[...i].sort(yo).map(e=>(0,$.jsx)(mo,{command:e,isSelected:g===e.name,onSelect:()=>{_(e.name),n?.()},onRename:()=>re(e),onDelete:()=>z(e),onDuplicate:()=>te(e),isMenuOpen:m===e.name,onMenuOpenChange:t=>h(t?e.name:null)},e.name))}):(0,$.jsx)(Z,{label:d,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]})}),t[46]=N,t[47]=L,t[48]=z,t[49]=te,t[50]=n,t[51]=m,t[52]=g,t[53]=_,t[54]=r,t[55]=oe,t[56]=se,t[57]=ce}else oe=t[55],se=t[56],ce=t[57];let le=c!==null&&u!==null,ue;t[72]===f?ue=t[73]:(ue=e=>{!e&&!f&&U()},t[72]=f,t[73]=ue);let de;t[74]!==u||t[75]!==r?(de=r(u===`delete`?`settings.commands.sidebar.dialog.deleteTitle`:`settings.commands.sidebar.dialog.resetTitle`),t[74]=u,t[75]=r,t[76]=de):de=t[76];let fe;t[77]===de?fe=t[78]:(fe=(0,$.jsx)(Gt,{children:de}),t[77]=de,t[78]=fe);let pe;t[79]!==c?.name||t[80]!==u||t[81]!==r?(pe=r(u===`delete`?`settings.commands.sidebar.dialog.deleteDescription`:`settings.commands.sidebar.dialog.resetDescription`,{name:c?.name??``}),t[79]=c?.name,t[80]=u,t[81]=r,t[82]=pe):pe=t[82];let he;t[83]===pe?he=t[84]:(he=(0,$.jsx)(Kt,{children:pe}),t[83]=pe,t[84]=he);let ge;t[85]!==fe||t[86]!==he?(ge=(0,$.jsxs)(Ht,{children:[fe,he]}),t[85]=fe,t[86]=he,t[87]=ge):ge=t[87];let _e;t[88]===r?_e=t[89]:(_e=r(`settings.common.actions.cancel`),t[88]=r,t[89]=_e);let ve;t[90]!==f||t[91]!==_e?(ve=(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:U,disabled:f,children:_e}),t[90]=f,t[91]=_e,t[92]=ve):ve=t[92];let ye;t[93]!==u||t[94]!==r?(ye=r(u===`delete`?`settings.common.actions.delete`:`settings.common.actions.reset`),t[93]=u,t[94]=r,t[95]=ye):ye=t[95];let be;t[96]!==ee||t[97]!==f||t[98]!==ye?(be=(0,$.jsx)(Y,{size:`sm`,onClick:ee,disabled:f,children:ye}),t[96]=ee,t[97]=f,t[98]=ye,t[99]=be):be=t[99];let xe;t[100]!==ve||t[101]!==be?(xe=(0,$.jsxs)(Ut,{children:[ve,be]}),t[100]=ve,t[101]=be,t[102]=xe):xe=t[102];let Se;t[103]!==ge||t[104]!==xe?(Se=(0,$.jsxs)(Wt,{className:`max-w-md`,children:[ge,xe]}),t[103]=ge,t[104]=xe,t[105]=Se):Se=t[105];let Ce;t[106]!==le||t[107]!==ue||t[108]!==Se?(Ce=(0,$.jsx)(qt,{open:le,onOpenChange:ue,children:Se}),t[106]=le,t[107]=ue,t[108]=Se,t[109]=Ce):Ce=t[109];let we=i!==null,Ee;t[110]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=e=>!e&&a(null),t[110]=Ee):Ee=t[110];let De;t[111]===r?De=t[112]:(De=r(`settings.commands.sidebar.renameDialog.title`),t[111]=r,t[112]=De);let ke;t[113]===De?ke=t[114]:(ke=(0,$.jsx)(Gt,{children:De}),t[113]=De,t[114]=ke);let Ae=i?.name??``,je;t[115]!==r||t[116]!==Ae?(je=r(`settings.commands.sidebar.renameDialog.description`,{name:Ae}),t[115]=r,t[116]=Ae,t[117]=je):je=t[117];let Me;t[118]===je?Me=t[119]:(Me=(0,$.jsx)(Kt,{children:je}),t[118]=je,t[119]=Me);let Ne;t[120]!==ke||t[121]!==Me?(Ne=(0,$.jsxs)(Ht,{children:[ke,Me]}),t[120]=ke,t[121]=Me,t[122]=Ne):Ne=t[122];let Pe;t[123]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=e=>s(e.target.value),t[123]=Pe):Pe=t[123];let Fe;t[124]===r?Fe=t[125]:(Fe=r(`settings.commands.sidebar.renameDialog.placeholder`),t[124]=r,t[125]=Fe);let Ie;t[126]===ae?Ie=t[127]:(Ie=e=>{e.key===`Enter`&&ae()},t[126]=ae,t[127]=Ie);let Le;t[128]!==o||t[129]!==Fe||t[130]!==Ie?(Le=(0,$.jsx)(ln,{value:o,onChange:Pe,placeholder:Fe,className:`text-foreground placeholder:text-muted-foreground`,onKeyDown:Ie}),t[128]=o,t[129]=Fe,t[130]=Ie,t[131]=Le):Le=t[131];let Re;t[132]===Symbol.for(`react.memo_cache_sentinel`)?(Re=()=>a(null),t[132]=Re):Re=t[132];let ze;t[133]===r?ze=t[134]:(ze=r(`settings.common.actions.cancel`),t[133]=r,t[134]=ze);let Be;t[135]===ze?Be=t[136]:(Be=(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:Re,children:ze}),t[135]=ze,t[136]=Be);let Ve;t[137]===r?Ve=t[138]:(Ve=r(`settings.common.actions.rename`),t[137]=r,t[138]=Ve);let He;t[139]!==ae||t[140]!==Ve?(He=(0,$.jsx)(Y,{size:`sm`,onClick:ae,children:Ve}),t[139]=ae,t[140]=Ve,t[141]=He):He=t[141];let Ue;t[142]!==Be||t[143]!==He?(Ue=(0,$.jsxs)(Ut,{children:[Be,He]}),t[142]=Be,t[143]=He,t[144]=Ue):Ue=t[144];let We;t[145]!==Ne||t[146]!==Le||t[147]!==Ue?(We=(0,$.jsxs)(Wt,{children:[Ne,Le,Ue]}),t[145]=Ne,t[146]=Le,t[147]=Ue,t[148]=We):We=t[148];let Ge;t[149]!==we||t[150]!==We?(Ge=(0,$.jsx)(qt,{open:we,onOpenChange:Ee,children:We}),t[149]=we,t[150]=We,t[151]=Ge):Ge=t[151];let Ke;return t[152]!==oe||t[153]!==se||t[154]!==ce||t[155]!==Ce||t[156]!==Ge?(Ke=(0,$.jsxs)(`div`,{className:oe,children:[se,ce,Ce,Ge]}),t[152]=oe,t[153]=se,t[154]=ce,t[155]=Ce,t[156]=Ge,t[157]=Ke):Ke=t[157],Ke},mo=e=>{let t=(0,bi.c)(47),{command:n,isSelected:r,onSelect:i,onDelete:a,onReset:o,onRename:s,onDuplicate:c,isMenuOpen:l,onMenuOpenChange:u}=e,{t:d}=Te(),f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=dr(),t[0]=f):f=t[0];let p=f,[m,h]=Q.useState(!1),g;t[1]!==a||t[2]!==c||t[3]!==s||t[4]!==o||t[5]!==d?(g=e=>(0,$.jsxs)($.Fragment,{children:[s&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),s()},children:[(0,$.jsx)(J,{name:`edit`,className:`h-4 w-4 mr-px`}),d(`settings.common.actions.rename`)]}),(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),c()},children:[(0,$.jsx)(J,{name:`file-copy`,className:`h-4 w-4 mr-px`}),d(`settings.common.actions.duplicate`)]}),o&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),o()},children:[(0,$.jsx)(J,{name:`restart`,className:`h-4 w-4 mr-px`}),d(`settings.common.actions.reset`)]}),a&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),a()},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(J,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),d(`settings.common.actions.delete`)]})]}),t[1]=a,t[2]=c,t[3]=s,t[4]=o,t[5]=d,t[6]=g):g=t[6];let _=g,v=r?`bg-interactive-selection`:`hover:bg-interactive-hover`,y;t[7]===v?y=t[8]:(y=q(`oc-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,v),t[7]=v,t[8]=y);let b;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(b=p?void 0:e=>{e.preventDefault(),h(!0)},t[9]=b):b=t[9];let x;t[10]===y?x=t[11]:(x=(0,$.jsx)(`div`,{className:y,onContextMenu:b}),t[10]=y,t[11]=x);let S;t[12]===n.name?S=t[13]:(S=(0,$.jsxs)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:[`/`,n.name]}),t[12]=n.name,t[13]=S);let C;t[14]!==n||t[15]!==d?(C=(n.scope||Fi(n))&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded flex-shrink-0 leading-none pb-px border border-border/50`,children:Fi(n)?d(`settings.agents.sidebar.badge.system`):n.scope}),t[14]=n,t[15]=d,t[16]=C):C=t[16];let w;t[17]!==S||t[18]!==C?(w=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[S,C]}),t[17]=S,t[18]=C,t[19]=w):w=t[19];let T;t[20]===n.description?T=t[21]:(T=n.description&&(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight`,children:n.description}),t[20]=n.description,t[21]=T);let E;t[22]!==i||t[23]!==T||t[24]!==w?(E=(0,$.jsxs)(`button`,{onClick:i,className:`flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,tabIndex:0,children:[w,T]}),t[22]=i,t[23]=T,t[24]=w,t[25]=E):E=t[25];let D;t[26]===u?D=t[27]:(D=e=>{e&&h(!1),u(e)},t[26]=u,t[27]=D);let O;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(qn,{asChild:!0,children:(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,className:`h-6 w-6 px-0 flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(J,{name:`more-2`,className:`h-3.5 w-3.5`})})}),t[28]=O):O=t[28];let k;t[29]===_?k=t[30]:(k=(0,$.jsx)(Un,{align:`end`,className:`w-fit min-w-20`,children:_(Jn)}),t[29]=_,t[30]=k);let A;t[31]!==l||t[32]!==D||t[33]!==k?(A=(0,$.jsxs)(Wn,{open:l,onOpenChange:D,children:[O,k]}),t[31]=l,t[32]=D,t[33]=k,t[34]=A):A=t[34];let j;t[35]!==E||t[36]!==A?(j=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[E,A]}),t[35]=E,t[36]=A,t[37]=j):j=t[37];let M;t[38]!==j||t[39]!==x?(M=(0,$.jsx)(ui,{render:x,children:j}),t[38]=j,t[39]=x,t[40]=M):M=t[40];let N;t[41]===_?N=t[42]:(N=(0,$.jsx)(di,{className:`w-fit min-w-20`,children:_(fi)}),t[41]=_,t[42]=N);let P;return t[43]!==m||t[44]!==M||t[45]!==N?(P=(0,$.jsxs)(pi,{open:m,onOpenChange:h,children:[M,N]}),t[43]=m,t[44]=M,t[45]=N,t[46]=P):P=t[46],P};function ho(e){return{selectedCommandName:e.selectedCommandName,setSelectedCommand:e.setSelectedCommand,setCommandDraft:e.setCommandDraft,createCommand:e.createCommand,deleteCommand:e.deleteCommand}}function go(e){return e.name}function _o(e){return!Fi(e)}function vo(e,t){return e.name.localeCompare(t.name)}function yo(e,t){return e.name.localeCompare(t.name)}var bo=()=>{let{t:e}=Te(),{selectedCommandName:t,createCommand:n,updateCommand:r,commandDraft:i,setCommandDraft:a}=Li(me(e=>({selectedCommandName:e.selectedCommandName,createCommand:e.createCommand,updateCommand:e.updateCommand,commandDraft:e.commandDraft,setCommandDraft:e.setCommandDraft}))),o=it(),s=Q.useMemo(()=>o.data??[],[o.data]),c=t?s.find(e=>e.name===t):null,l=!!(i&&i.name===t&&!c),[u,d]=Q.useState(``),[f,p]=Q.useState(`user`),[m,h]=Q.useState(``),[g,_]=Q.useState(``),[v,y]=Q.useState(``),[b,x]=Q.useState(``),[S,C]=Q.useState(!1),w=Q.useRef(null);Q.useEffect(()=>{if(l&&i){let e=i.name||``,t=i.scope||`user`,n=i.description||``,r=i.agent||``,a=i.model||``,o=i.template||``;d(e),p(t),h(n),_(r),y(a),x(o),w.current={draftName:e,draftScope:t,description:n,agent:r,model:a,template:o}}else if(c){let e=c.description||``,t=c.agent||``,n=c.model||``,r=c.template||``;h(e),_(t),y(n),x(r),w.current={draftName:``,draftScope:`user`,description:e,agent:t,model:n,template:r}}},[c,l,t,s,i]);let T=Q.useMemo(()=>{let e=w.current;return e?!!(l&&(u!==e.draftName||f!==e.draftScope)||m!==e.description||g!==e.agent||v!==e.model||b!==e.template):!1},[g,m,u,f,l,v,b]);return t?(0,$.jsx)(Jt,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`oc-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(`div`,{className:`mb-4 flex items-center justify-between gap-4`,children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:l?e(`settings.commands.page.title.new`):`/${t}`}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:e(l?`settings.commands.page.subtitle.new`:`settings.commands.page.subtitle.edit`)})]})}),(0,$.jsxs)(Z,{label:e(`settings.commands.page.section.identity`),children:[l&&(0,$.jsxs)(Ar,{itemId:`commands.name`,label:e(`settings.commands.page.field.commandName`),children:[(0,$.jsxs)(`div`,{className:`flex items-center`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground mr-1`,children:`/`}),(0,$.jsx)(ln,{value:u,onChange:e=>d(e.target.value),placeholder:e(`settings.commands.page.field.commandNamePlaceholder`),className:`h-7 w-40 px-2`})]}),(0,$.jsxs)(tn,{value:f,onValueChange:e=>p(e),children:[(0,$.jsx)(cn,{className:`w-fit min-w-[100px]`,children:(0,$.jsx)(Qt,{placeholder:e(`settings.agents.page.field.scopePlaceholder`)})}),(0,$.jsxs)(en,{align:`end`,children:[(0,$.jsx)(sn,{value:`user`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{name:`user-3`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.global`)})]})}),(0,$.jsx)(sn,{value:`project`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(J,{name:`folder`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.project`)})]})})]})]})]}),(0,$.jsx)(Ar,{label:e(`settings.common.field.description`),className:`oc-settings-split-row-stacked`,children:(0,$.jsx)(on,{embedded:!0,value:m,onChange:e=>h(e.target.value),placeholder:e(`settings.commands.page.field.descriptionPlaceholder`),rows:2,className:`w-full resize-none min-h-[60px] bg-transparent`})})]}),(0,$.jsxs)(Z,{label:e(`settings.commands.page.section.executionContext`),children:[(0,$.jsx)(Ar,{itemId:`commands.agent`,label:e(`settings.commands.page.field.overrideAgent`),children:(0,$.jsx)(nr,{agentName:g,onChange:e=>_(e),className:`oc-settings-inline-value`})}),(0,$.jsx)(Ar,{itemId:`commands.model`,label:e(`settings.agents.page.field.overrideModel`),children:(0,$.jsx)(ar,{providerId:ct(v)?.providerId??``,modelId:ct(v)?.modelId??``,onChange:(e,t)=>{y(e&&t?`${e}/${t}`:``)},className:`oc-settings-inline-value`})})]}),(0,$.jsx)(Tr,{itemId:`commands.template`,label:e(`settings.commands.page.section.template`),description:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`code`,{className:`text-foreground`,children:`$ARGUMENTS`}),` `,e(`settings.commands.page.templateHint.userInput`),` ·`,` `,(0,$.jsx)(`code`,{className:`text-foreground`,children:"!`cmd`"}),` `,e(`settings.commands.page.templateHint.shellOutput`),` ·`,` `,(0,$.jsx)(`code`,{className:`text-foreground`,children:`@file`}),` `,e(`settings.commands.page.templateHint.fileContents`)]}),descriptionPlacement:`outside`,className:`oc-settings-split-row-stacked`,children:(0,$.jsx)(on,{embedded:!0,value:b,onChange:e=>x(e.target.value),placeholder:e(`settings.commands.page.field.templatePlaceholder`),rows:12,className:`w-full font-mono typography-meta min-h-[160px] max-h-[60vh] bg-transparent resize-y`})}),(0,$.jsx)(`div`,{className:`px-2 py-1`,children:(0,$.jsx)(Y,{onClick:async()=>{let i=l?u.trim().replace(/\s+/g,`-`):t?.trim();if(!i){K.error(e(`settings.commands.sidebar.toast.commandNameRequired`));return}if(!b.trim()){K.error(e(`settings.commands.page.toast.templateRequired`));return}if(l&&s.some(e=>e.name===i)){K.error(e(`settings.commands.sidebar.toast.commandExists`));return}C(!0);try{let t=g.trim(),o=v.trim(),s=b.trim(),c={name:i,description:m.trim()||void 0,agent:t===``?null:t,model:o===``?null:o,template:s,scope:l?f:void 0},u;l?(u=await n(c),u&&a(null)):u=await r(i,c),u?K.success(e(l?`settings.commands.page.toast.created`:`settings.commands.page.toast.updated`)):K.error(e(l?`settings.commands.page.toast.createFailed`:`settings.commands.page.toast.updateFailed`))}catch(t){console.error(`Error saving command:`,t),K.error(e(`settings.commands.page.toast.saveUnexpectedError`))}finally{C(!1)}},disabled:S||!T,size:`xs`,className:`!font-normal`,children:e(S?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)})})]})}):(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`terminal-box`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.commands.page.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.commands.page.empty.description`)})]})})},xo=[],So=e=>{switch(e){case`connected`:return`success`;case`failed`:return`error`;case`needs_auth`:case`needs_client_registration`:return`warning`;default:return`idle`}},Co=e=>{let t=(0,bi.c)(5),{tone:n,enabled:r}=e;if(!r){let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full bg-muted-foreground/30 flex-shrink-0`}),t[0]=e):e=t[0],e}let i;t[1]===n?i=t[2]:(i=q(`inline-block h-2 w-2 rounded-full flex-shrink-0`,{success:`bg-[var(--status-success)]`,error:`bg-[var(--status-error)]`,warning:`bg-[var(--status-warning)]`,idle:`bg-muted-foreground/40`}[n]),t[1]=n,t[2]=i);let a;return t[3]===i?a=t[4]:(a=(0,$.jsx)(`span`,{className:i}),t[3]=i,t[4]=a),a},wo=e=>{let t=(0,bi.c)(115),{onItemSelect:n}=e,{t:i}=Te(),{selectedMcpName:a,setSelectedMcp:o,setMcpDraft:s,deleteMcp:c}=Gi(me(To)),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=ri(),t[0]=l):l=t[0];let u=l,d=Or(u),f=Hr(u),p=d.data??xo,m;t[1]===f.data?m=t[2]:(m=f.data??{},t[1]=f.data,t[2]=m);let h=m,[g,_]=Q.useState(null),[v,y]=Q.useState(!1),[b,x]=Q.useState(null),[S,C]=Q.useState(null),[w,T]=Q.useState(!1),E;t[3]===p?E=t[4]:(E=p.filter(Eo),t[3]=p,t[4]=E);let D=E,O;t[5]===p?O=t[6]:(O=p.filter(Do),t[5]=p,t[6]=O);let k=O,A;t[7]===w?A=t[8]:(A=()=>{if(w)return;T(!0);let e=new Promise(Oo),t=r();Promise.all([kr(V,u,t),e]).catch(ko).finally(()=>{T(!1)})},t[7]=w,t[8]=A);let j=A,M;t[9]!==p||t[10]!==n||t[11]!==s||t[12]!==o?(M=()=>{let e=`new-mcp-server`,t=1;for(;p.some(t=>t.name===e);)e=`new-mcp-server-${t}`,t++;s({name:e,scope:`user`,type:`local`,command:[],url:``,environment:[],headers:[],oauthEnabled:!0,oauthClientId:``,oauthClientSecret:``,oauthScope:``,oauthRedirectUri:``,timeout:``,enabled:!0}),o(e),n?.()},t[9]=p,t[10]=n,t[11]=s,t[12]=o,t[13]=M):M=t[13];let N=M,P;t[14]!==c||t[15]!==g||t[16]!==i?(P=async()=>{if(!g)return;y(!0);let e=await c(g.name,{directory:ri(),transportIdentity:r()});e.ok?e.reloadFailed?K.warning(e.message||`MCP server "${g.name}" deleted, but OpenCode reload failed`,{description:e.warning||i(`settings.mcp.sidebar.toast.refreshListIfStale`)}):K.success(e.message||i(`settings.mcp.sidebar.toast.serverDeleted`,{name:g.name})):K.error(i(`settings.mcp.sidebar.toast.deleteFailed`)),_(null),y(!1)},t[14]=c,t[15]=g,t[16]=i,t[17]=P):P=t[17];let F=P,I;t[18]===i?I=t[19]:(I=(e,t)=>(0,$.jsxs)(t,{onClick:t=>{t.stopPropagation(),_(e)},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(J,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),i(`settings.common.actions.delete`)]}),t[18]=i,t[19]=I);let L=I,R;t[20]===i?R=t[21]:(R=i(`settings.mcp.sidebar.group.userServers`),t[20]=i,t[21]=R);let z;t[22]===R?z=t[23]:(z=(0,$.jsx)(`span`,{children:R}),t[22]=R,t[23]=z);let B;t[24]===i?B=t[25]:(B=i(`settings.mcp.sidebar.actions.refreshStatusAria`),t[24]=i,t[25]=B);let H;t[26]===i?H=t[27]:(H=i(`settings.mcp.sidebar.actions.refreshStatusTitle`),t[26]=i,t[27]=H);let U=w&&`animate-spin`,W;t[28]===U?W=t[29]:(W=q(`h-4 w-4`,U),t[28]=U,t[29]=W);let ee;t[30]===W?ee=t[31]:(ee=(0,$.jsx)(J,{name:`refresh`,className:W}),t[30]=W,t[31]=ee);let G;t[32]!==j||t[33]!==w||t[34]!==B||t[35]!==H||t[36]!==ee?(G=(0,$.jsx)(Y,{type:`button`,size:`icon`,variant:`ghost`,disabled:w,onClick:j,"aria-label":B,title:H,children:ee}),t[32]=j,t[33]=w,t[34]=B,t[35]=H,t[36]=ee,t[37]=G):G=t[37];let te;t[38]===i?te=t[39]:(te=i(`settings.mcp.sidebar.actions.addServerTitle`),t[38]=i,t[39]=te);let ne;t[40]===i?ne=t[41]:(ne=i(`settings.mcp.sidebar.actions.addServerTitle`),t[40]=i,t[41]=ne);let re;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,$.jsx)(J,{name:`add`,className:`h-4 w-4`}),t[42]=re):re=t[42];let ie;t[43]!==N||t[44]!==te||t[45]!==ne?(ie=(0,$.jsx)(Y,{"data-settings-item":`mcp.create`,size:`icon`,variant:`ghost`,onClick:N,"aria-label":te,title:ne,children:re}),t[43]=N,t[44]=te,t[45]=ne,t[46]=ie):ie=t[46];let ae;t[47]!==G||t[48]!==ie?(ae=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[G,ie]}),t[47]=G,t[48]=ie,t[49]=ae):ae=t[49];let oe;t[50]!==z||t[51]!==ae?(oe=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[z,ae]}),t[50]=z,t[51]=ae,t[52]=oe):oe=t[52];let se=oe,ce;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,$.jsx)(Z,{children:(0,$.jsx)(`div`,{className:`oc-settings-group-row`,children:(0,$.jsx)(sa,{})})}),t[53]=ce):ce=t[53];let le;t[54]!==d.data||t[55]!==d.error||t[56]!==d.isError||t[57]!==p.length||t[58]!==h||t[59]!==n||t[60]!==b||t[61]!==D||t[62]!==L||t[63]!==S||t[64]!==a||t[65]!==s||t[66]!==o||t[67]!==f.data||t[68]!==f.error||t[69]!==f.isError||t[70]!==i||t[71]!==k||t[72]!==se?(le=(0,$.jsx)($.Fragment,{children:d.isError&&!d.data?(0,$.jsx)(Z,{label:se,children:(0,$.jsx)(`div`,{className:`oc-settings-group-row py-12 text-center typography-meta text-[var(--status-error)]`,children:d.error.message})}):p.length===0?(0,$.jsx)(Z,{label:se,children:(0,$.jsxs)(`div`,{className:`oc-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(J,{name:`plug`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:i(`settings.mcp.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:i(`settings.mcp.sidebar.empty.description`)})]})}):(0,$.jsxs)($.Fragment,{children:[D.length>0&&(0,$.jsx)(Z,{label:i(`settings.mcp.sidebar.group.projectServers`),children:D.map(e=>{let t=So((h[e.name]??(f.isError&&!f.data?{status:`failed`,error:f.error.message}:void 0))?.status),r=a===e.name,c=dr();return(0,$.jsxs)(pi,{open:S===e.name,onOpenChange:t=>C(t?e.name:null),children:[(0,$.jsxs)(ui,{render:(0,$.jsx)(`div`,{className:q(`oc-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,r?`bg-interactive-selection`:`hover:bg-interactive-hover`),onContextMenu:c?void 0:t=>{t.preventDefault(),C(e.name)}}),children:[(0,$.jsxs)(`button`,{onClick:()=>{o(e.name),s(null),n?.()},className:`flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Co,{tone:t,enabled:e.enabled}),(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:e.name}),(0,$.jsx)(`span`,{title:e.type===`local`?i(`settings.mcp.sidebar.serverType.localTitle`):i(`settings.mcp.sidebar.serverType.remoteTitle`),children:e.type===`local`?(0,$.jsx)(J,{name:`server`,className:`h-3 w-3 text-muted-foreground/60 flex-shrink-0`}):(0,$.jsx)(J,{name:`global`,className:`h-3 w-3 text-muted-foreground/60 flex-shrink-0`})})]}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight pl-4`,children:e.type===`local`?e.command?.join(` `)??``:e.url??``})]}),(0,$.jsxs)(Wn,{open:b===e.name,onOpenChange:t=>{t&&C(null),x(t?e.name:null)},children:[(0,$.jsx)(qn,{asChild:!0,children:(0,$.jsx)(Y,{size:`xs`,variant:`ghost`,className:`flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(J,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(Un,{align:`end`,className:`w-fit min-w-20`,children:L(e,Jn)})]})]}),(0,$.jsx)(di,{className:`w-fit min-w-20`,children:L(e,fi)})]},e.name)})}),k.length>0&&(0,$.jsx)(Z,{label:se,children:k.map(e=>{let t=So((h[e.name]??(f.isError&&!f.data?{status:`failed`,error:f.error.message}:void 0))?.status),r=a===e.name,c=dr();return(0,$.jsxs)(pi,{open:S===e.name,onOpenChange:t=>C(t?e.name:null),children:[(0,$.jsxs)(ui,{render:(0,$.jsx)(`div`,{className:q(`oc-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,r?`bg-interactive-selection`:`hover:bg-interactive-hover`),onContextMenu:c?void 0:t=>{t.preventDefault(),C(e.name)}}),children:[(0,$.jsxs)(`button`,{onClick:()=>{o(e.name),s(null),n?.()},className:`flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Co,{tone:t,enabled:e.enabled}),(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:e.name}),(0,$.jsx)(`span`,{title:e.type===`local`?i(`settings.mcp.sidebar.serverType.localTitle`):i(`settings.mcp.sidebar.serverType.remoteTitle`),children:e.type===`local`?(0,$.jsx)(J,{name:`server`,className:`h-3 w-3 text-muted-foreground/60 flex-shrink-0`}):(0,$.jsx)(J,{name:`global`,className:`h-3 w-3 text-muted-foreground/60 flex-shrink-0`})})]}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight pl-4`,children:e.type===`local`?e.command?.join(` `)??``:e.url??``})]}),(0,$.jsxs)(Wn,{open:b===e.name,onOpenChange:t=>{t&&C(null),x(t?e.name:null)},children:[(0,$.jsx)(qn,{asChild:!0,children:(0,$.jsx)(Y,{size:`xs`,variant:`ghost`,className:`flex-shrink-0 -mr-1 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,children:(0,$.jsx)(J,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(Un,{align:`end`,className:`w-fit min-w-20`,children:L(e,Jn)})]})]}),(0,$.jsx)(di,{className:`w-fit min-w-20`,children:L(e,fi)})]},e.name)})}),k.length===0&&(0,$.jsx)(Z,{label:se,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]})}),t[54]=d.data,t[55]=d.error,t[56]=d.isError,t[57]=p.length,t[58]=h,t[59]=n,t[60]=b,t[61]=D,t[62]=L,t[63]=S,t[64]=a,t[65]=s,t[66]=o,t[67]=f.data,t[68]=f.error,t[69]=f.isError,t[70]=i,t[71]=k,t[72]=se,t[73]=le):le=t[73];let ue=g!==null,de;t[74]===v?de=t[75]:(de=e=>{!e&&!v&&_(null)},t[74]=v,t[75]=de);let fe;t[76]===i?fe=t[77]:(fe=i(`settings.mcp.sidebar.deleteDialog.title`),t[76]=i,t[77]=fe);let pe;t[78]===fe?pe=t[79]:(pe=(0,$.jsx)(Gt,{children:fe}),t[78]=fe,t[79]=pe);let he=g?.name||``,ge;t[80]!==i||t[81]!==he?(ge=i(`settings.mcp.sidebar.deleteDialog.descriptionPrefix`,{name:he}),t[80]=i,t[81]=he,t[82]=ge):ge=t[82];let _e;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,$.jsx)(`code`,{className:`text-foreground`,children:`opencode.json`}),t[83]=_e):_e=t[83];let ve;t[84]===ge?ve=t[85]:(ve=(0,$.jsxs)(Kt,{children:[ge,` `,_e,`.`]}),t[84]=ge,t[85]=ve);let ye;t[86]!==pe||t[87]!==ve?(ye=(0,$.jsxs)(Ht,{children:[pe,ve]}),t[86]=pe,t[87]=ve,t[88]=ye):ye=t[88];let be;t[89]===Symbol.for(`react.memo_cache_sentinel`)?(be=()=>_(null),t[89]=be):be=t[89];let xe;t[90]===i?xe=t[91]:(xe=i(`settings.common.actions.cancel`),t[90]=i,t[91]=xe);let Se;t[92]!==v||t[93]!==xe?(Se=(0,$.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:be,disabled:v,children:xe}),t[92]=v,t[93]=xe,t[94]=Se):Se=t[94];let Ce;t[95]!==v||t[96]!==i?(Ce=i(v?`settings.mcp.sidebar.actions.deleting`:`settings.common.actions.delete`),t[95]=v,t[96]=i,t[97]=Ce):Ce=t[97];let we;t[98]!==F||t[99]!==v||t[100]!==Ce?(we=(0,$.jsx)(Y,{size:`sm`,onClick:F,disabled:v,children:Ce}),t[98]=F,t[99]=v,t[100]=Ce,t[101]=we):we=t[101];let Ee;t[102]!==Se||t[103]!==we?(Ee=(0,$.jsxs)(Ut,{children:[Se,we]}),t[102]=Se,t[103]=we,t[104]=Ee):Ee=t[104];let De;t[105]!==ye||t[106]!==Ee?(De=(0,$.jsxs)(Wt,{className:`max-w-md`,children:[ye,Ee]}),t[105]=ye,t[106]=Ee,t[107]=De):De=t[107];let Oe;t[108]!==ue||t[109]!==de||t[110]!==De?(Oe=(0,$.jsx)(qt,{open:ue,onOpenChange:de,children:De}),t[108]=ue,t[109]=de,t[110]=De,t[111]=Oe):Oe=t[111];let ke;return t[112]!==le||t[113]!==Oe?(ke=(0,$.jsxs)(`div`,{className:`oc-settings-page-content h-full overflow-y-auto bg-background p-3`,children:[ce,le,Oe]}),t[112]=le,t[113]=Oe,t[114]=ke):ke=t[114],ke};function To(e){return{selectedMcpName:e.selectedMcpName,setSelectedMcp:e.setSelectedMcp,setMcpDraft:e.setMcpDraft,deleteMcp:e.deleteMcp}}function Eo(e){return e.scope===`project`}function Do(e){return e.scope!==`project`}function Oo(e){return setTimeout(e,500)}function ko(e){K.error(e instanceof Error?e.message:String(e))}function Ao(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function jo(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function Mo(e,t){return t===void 0?{ok:!1,error:e}:{ok:!1,error:e,parsed:t}}function No(e,t,n){return{ok:!0,name:e,type:t,command:Po(n),url:typeof n.url==`string`?n.url.trim():``,environment:Fo(n,`env`,`environment`),headers:Fo(n,`headers`),oauthEnabled:Io(n),oauthClientId:typeof n.oauth==`object`&&n.oauth!==null?String(n.oauth.clientId??``).trim():``,oauthClientSecret:typeof n.oauth==`object`&&n.oauth!==null?String(n.oauth.clientSecret??``).trim():``,oauthScope:typeof n.oauth==`object`&&n.oauth!==null?String(n.oauth.scope??``).trim():``,oauthRedirectUri:typeof n.oauth==`object`&&n.oauth!==null?String(n.oauth.redirectUri??``).trim():``,timeout:Lo(n),enabled:Ro(n)}}function Po(e){let t=e.command,n=e.args;if(jo(t)&&jo(n))return[...t,...n];if(jo(t))return t;if(typeof t==`string`&&t.trim()){let e=t.trim().split(/\s+/);return jo(n)?[...e,...n]:e}return jo(n)?n:[]}function Fo(e,...t){for(let n of t){let t=e[n];if(!Ao(t))continue;let r=Object.entries(t).filter(([e,t])=>e&&typeof t==`string`);if(r.length>0)return r.map(([e,t])=>({key:e,value:String(t)}))}return[]}function Io(e){if(e.oauth===!1||e.oauth===null||e.oauth===void 0||!Ao(e.oauth))return!1;let t=e.oauth;return!!(typeof t.clientId==`string`&&t.clientId.trim()||typeof t.clientSecret==`string`&&t.clientSecret.trim()||typeof t.scope==`string`&&t.scope.trim()||typeof t.redirectUri==`string`&&t.redirectUri.trim())}function Lo(e){let t=e.timeout;if(typeof t==`number`&&Number.isFinite(t)&&t>0)return String(Math.floor(t));if(typeof t==`string`&&t.trim()){let e=Number(t);if(Number.isFinite(e)&&e>0)return String(Math.floor(e))}return``}function Ro(e){return`disabled`in e&&e.disabled===!0?!1:`enabled`in e?!!e.enabled:!0}function zo(e){let t=e.mcpServers;if(Ao(t)){let e=Object.keys(t);if(e.length===1){let n=e[0],r=t[n];if(Ao(r))return{name:n,entry:r}}if(e.length>1)return null}let n=Object.keys(e).filter(t=>{let n=e[t];return t!==`mcpServers`&&Ao(n)});if(n.length===1){let t=n[0],r=e[t];if(Bo(r))return{name:t,entry:r}}return null}function Bo(e){return e.type===`local`||e.type===`remote`||Array.isArray(e.command)||typeof e.url==`string`||Array.isArray(e.args)}function Vo(e,t){let n;try{let t=e.trim();if(!t)return Mo(`No JSON content provided`);n=JSON.parse(t)}catch(e){return Mo(e instanceof Error?`Invalid JSON: ${e.message}`:`Invalid JSON`)}if(!Ao(n))return Mo(`Expected a JSON object, not an array or primitive`);let r=n,i=r.mcpServers;if(Ao(i)){let e=Object.keys(i);if(e.length===0)return Mo(`mcpServers object is empty`,n);if(e.length>1)return Mo(`Paste one server at a time. Found `+e.length+` servers in mcpServers`,n);let t=e[0],r=i[t];return Ao(r)?No(t,Ho(r),r):Mo(`Server entry is not a valid object`,n)}let a=r.mcp;if(Ao(a)){let e=Object.keys(a);if(e.length===0)return Mo(`mcp object is empty`,n);if(e.length>1)return Mo(`Paste one server at a time. Found `+e.length+` servers in mcp`,n);let t=e[0],r=a[t];return Ao(r)?No(t,Ho(r),r):Mo(`Server entry in mcp is not a valid object`,n)}let o=zo(r);if(o)return No(o.name,Ho(o.entry),o.entry);if(Bo(r)){let e=Ho(r);return No(typeof r.name==`string`&&r.name.trim()?r.name.trim():t?.fallbackName,e,r)}return Mo(`No recognizable MCP server configuration found in JSON`,n)}function Ho(e){return e.type===`remote`?`remote`:e.type===`local`?`local`:typeof e.url==`string`&&e.url.trim()?`remote`:(Array.isArray(e.command)||typeof e.command==`string`||Array.isArray(e.args),`local`)}function Uo(e,t,n){let r=n?.isNewServer??!1,i=e.name,a=r&&i?i:t.name??``;return{...t,name:a,type:e.type,command:e.type===`local`?e.command:[],url:e.type===`remote`?e.url:``,environment:e.environment,headers:e.type===`remote`?e.headers:[],oauthEnabled:e.type===`remote`&&e.oauthEnabled,oauthClientId:e.type===`remote`?e.oauthClientId:``,oauthClientSecret:e.type===`remote`?e.oauthClientSecret:``,oauthScope:e.type===`remote`?e.oauthScope:``,oauthRedirectUri:e.type===`remote`?e.oauthRedirectUri:``,timeout:e.type===`remote`?e.timeout:``,enabled:e.enabled}}function Wo(e){let t=[],n=``,r=!1,i=!1;for(let a=0;a<e.length;a++){let o=e[a];if(o===`'`&&!i){r=!r;continue}if(o===`"`&&!r){i=!i;continue}if((o===` `||o===` `)&&!r&&!i){n&&=(t.push(n),``);continue}n+=o}return n&&t.push(n),t}function Go(e){let t=e.trim();if(!t)return{code:null,context:null,stateKey:null};try{let e=new URL(t),n=e.searchParams.get(`code`);if(typeof n==`string`&&n.trim())return{code:n.trim(),context:jr(e.searchParams),stateKey:Mr(e.searchParams)}}catch{}return{code:t,context:null,stateKey:null}}var Ko=({value:e,onChange:t,pasteCommandTitle:n,pasteCommandLabel:r,pasteSuccess:i,clipboardReadFailed:a,preview:o})=>{let[s,c]=Q.useState(()=>e.join(`
|
|
3
3
|
`)),l=Q.useRef(e);Q.useEffect(()=>{JSON.stringify(l.current)!==JSON.stringify(e)&&(l.current=e,c(e.join(`
|
|
4
4
|
`)))},[e]);let u=e=>{t(e.split(`
|