@yuriai/web 0.1.20 → 0.1.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/{AgentAvatar-Dn3d91Bp.js → AgentAvatar-C2p8G_Xw.js} +1 -1
- package/dist/assets/{AssistantView-Mu5sPh2W.js → AssistantView-B-vEm0jN.js} +3 -3
- package/dist/assets/{DiagramView-bzCP60wE.js → DiagramView-DT5CPdtn.js} +1 -1
- package/dist/assets/{FadeInOnReveal-D7ifJQAw.js → FadeInOnReveal-DhAYqopy.js} +1 -1
- package/dist/assets/{Icon-DZmADJWp.js → Icon-DKFfVCeK.js} +1 -1
- package/dist/assets/{ImageLoadingPlaceholder-Dw4P79Ms.js → ImageLoadingPlaceholder-DD2g7FjK.js} +1 -1
- package/dist/assets/{LoadingImage-CCKvcYRc.js → LoadingImage-Dc7hnEQ7.js} +1 -1
- package/dist/assets/{MarkdownRenderer-IKfW9Cjc.js → MarkdownRenderer-kDYymiH3.js} +2 -2
- package/dist/assets/{MarkdownRendererImpl-CjP0s7aP.js → MarkdownRendererImpl-cS5FXxon.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-DwlqEaFC.js → MarkstreamRendererImpl-CO1AzJsB.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-B8LAq0IX.js → MobileDetailNavigation-RLH6AQBN.js} +1 -1
- package/dist/assets/{MobileShareBridge-Dr13-74t.js → MobileShareBridge-CijqYDMo.js} +1 -1
- package/dist/assets/{MobileTabPageHeader-a9_X2cyT.js → MobileTabPageHeader-BZKymEeY.js} +1 -1
- package/dist/assets/{MultiRunWindow-Cy2N-jeD.js → MultiRunWindow-BBADn01m.js} +1 -1
- package/dist/assets/{OnboardingScreen-DE2iB21m.js → OnboardingScreen-Dau5R5ew.js} +1 -1
- package/dist/assets/{OverlayScrollbar-BlzvB3ct.js → OverlayScrollbar-Dxdkid6A.js} +1 -1
- package/dist/assets/{SettingsView-DJz1My_v.js → SettingsView-BDw1UGgS.js} +3 -3
- package/dist/assets/{SettingsWindow-ClpYdemG.js → SettingsWindow-DQz1f-kO.js} +1 -1
- package/dist/assets/{TerminalView-CI09r9y5.js → TerminalView-CpGeHiw4.js} +1 -1
- package/dist/assets/{ToolOutputDialog-UMcI4Zho.js → ToolOutputDialog-qF2onmML.js} +1 -1
- package/dist/assets/{YuriLogo-Dm011NCM.js → YuriLogo-CgTkNYZf.js} +1 -1
- package/dist/assets/{appThemeRegistry-2SvgJE7r.js → appThemeRegistry-DmRKfJL3.js} +1 -1
- package/dist/assets/{button-CEcZQm-B.js → button-LPikURUk.js} +1 -1
- package/dist/assets/{capgoAdapter-D9f3CiJN.js → capgoAdapter-BmTEnR2_.js} +1 -1
- package/dist/assets/{collapsible-B6ON5Mai.js → collapsible-CbQmi7qt.js} +1 -1
- package/dist/assets/{diagram-9xxUjDb_.js → diagram-DWkoS1Uc.js} +1 -1
- package/dist/assets/{dialog-CjPdvmr0.js → dialog-D8AYQa70.js} +1 -1
- package/dist/assets/{dropdown-menu.styles-Cm3A3LAl.js → dropdown-menu.styles-BXRbrWW5.js} +1 -1
- package/dist/assets/{es-CqWNlkik.js → es-Le3f45R2.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-CFWWsHMy.js → fileMentionTouchSelection-FDObhofW.js} +1 -1
- package/dist/assets/{fr-CpxexYkk.js → fr-Knp2_Wkz.js} +1 -1
- package/dist/assets/{gitApi-BoCv5QK2.js → gitApi-D8IPglEo.js} +1 -1
- package/dist/assets/{input-yYSzMq8L.js → input-CAhwlkOT.js} +1 -1
- package/dist/assets/{insertionBoundaries-CecUkYvp.js → insertionBoundaries-DE8RyJf4.js} +1 -1
- package/dist/assets/{ja-ByTgQPSi.js → ja-_KJ_VLgM.js} +1 -1
- package/dist/assets/{ko-BGfRP-3B.js → ko-CmWIeRHF.js} +1 -1
- package/dist/assets/{main-CjoDtGqO.js → main-BLMeK7Ed.js} +4 -4
- package/dist/assets/{main-BtKG4Oot.js → main-Bh0kUjiw.js} +2 -2
- package/dist/assets/{markdownHeightCache-w0HDCLwk.js → markdownHeightCache-CylzGsAe.js} +1 -1
- package/dist/assets/{mcpQueries-CwkJ4NQA.js → mcpQueries-BFkB-7V_.js} +1 -1
- package/dist/assets/{miniChat-CW0R2U5t.js → miniChat-Ciy0u8ci.js} +2 -2
- package/dist/assets/{mobile-ClKyarOu.js → mobile-Bm0sCDXq.js} +2 -2
- package/dist/assets/{mobileBackNavigation-6jBA1pR0.js → mobileBackNavigation-BwxOTY4b.js} +1 -1
- package/dist/assets/{multirun-DJWMunGf.js → multirun-CyHj2_Qf.js} +1 -1
- package/dist/assets/{native-config-DPmta_0r.js → native-config-BDst1Okm.js} +1 -1
- package/dist/assets/{pl-DIwCzbXW.js → pl-BoXY-ki3.js} +1 -1
- package/dist/assets/{projectMeta-R1cugLKq.js → projectMeta-C75m7wMM.js} +1 -1
- package/dist/assets/{pt-BR-4MjIbbWQ.js → pt-BR-C3gsTrhe.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-Dof7xxix.js → renderElectronMiniChatApp-BSX59NyD.js} +2 -2
- package/dist/assets/{renderMobileApp-CMWkdtmy.js → renderMobileApp-BM8Bg3sb.js} +5 -5
- package/dist/assets/{runtimeConfig-HmoxZCZV.js → runtimeConfig-D0UDGecm.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-DRv3nf7i.js → runtimeEndpointReset-Df4Jlmne.js} +2 -2
- package/dist/assets/{scheduledTaskNavigation-BhsUww-K.js → scheduledTaskNavigation-BE3Okq7X.js} +1 -1
- package/dist/assets/{sessionChangeSummary-w0goW1R2.js → sessionChangeSummary-DkIJkqeG.js} +1 -1
- package/dist/assets/{sessionLookup-Clh1wb_a.js → sessionLookup-DhcUVJQR.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-MyKMqyvw.js → sortable-tabs-strip-CQR5TsUS.js} +1 -1
- package/dist/assets/speechSettingsQueries-BWIoMe5c.js +4 -0
- package/dist/assets/src-DlJVKekb.css +2 -0
- package/dist/assets/{store-JjNwX_aQ.js → store-CnVXA4NH.js} +2 -2
- package/dist/assets/{textarea-CO8JEdzP.js → textarea-pQCq-iLS.js} +1 -1
- package/dist/assets/{tooltip-Dmw1nU2I.js → tooltip-CFuO3PUH.js} +1 -1
- package/dist/assets/{types-DeOBiX60.js → types-2CUEL3Ja.js} +1 -1
- package/dist/assets/{uk-D9WsfZqn.js → uk-VUOVH9qH.js} +1 -1
- package/dist/assets/{useAppFontEffects-DGB_WT2K.js → useAppFontEffects-C9CPKD-1.js} +6 -6
- package/dist/assets/{useDesktopWindowControlsLayout-vZizIuQt.js → useDesktopWindowControlsLayout-Cw3ZRPXc.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-Cy8aGhAH.js → useEffectiveDirectory-Cw-vfohq.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-D-RlKHiM.js → useMobileNavigationStore-K23K6qFK.js} +6 -6
- package/dist/assets/{useWorkerHighlightedLines-DH3kJulm.js → useWorkerHighlightedLines-U3DE5CRZ.js} +1 -1
- package/dist/assets/{zh-CN-CAIBZPD7.js → zh-CN-CqOn122C.js} +1 -1
- package/dist/assets/{zh-TW-IpFLeeKe.js → zh-TW-53yr6Fdj.js} +1 -1
- package/dist/index.html +6 -6
- package/dist/mini-chat.html +6 -6
- package/dist/mobile.html +6 -6
- package/package.json +1 -1
- package/server/lib/config-sync/DOCUMENTATION.md +6 -2
- package/server/lib/config-sync/magpie.js +31 -6
- package/server/lib/config-sync/magpie.test.js +94 -1
- package/dist/assets/speechSettingsQueries-JZkjbbR5.js +0 -4
- package/dist/assets/src-Cyw451UY.css +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{E as n}from"./runtime-auth-ef9W7A43.js";import{c as r,i,l as a,n as o,r as s,t as c}from"./runtime-switch-CAZiOV2G.js";import{a as l,i as u,o as d,s as f,u as p}from"./queryRuntime-DKGLQtb9.js";import{$t as m,D as h,E as g,Gt as _,Ht as v,Kt as y,L as b,Tn as x,Wt as S,Xt as C,Zt as w,bn as T,en as E,hn as D,i as O,in as k,o as A,pn as j,qt as M,rn as N,s as P,tn as F,tt as I,u as L,xn as R,yn as z}from"./persistence-Dzooc9Xg.js";import{_ as B,a as V,d as ee,g as H,h as te,i as ne,m as U,n as re,r as ie,t as ae,u as oe}from"./desktopHosts-DW8THEMC.js";import{n as se}from"./desktopRelayRestore-BFn1FsR3.js";import{a as ce,i as le,r as ue,t as de}from"./vendor-zustand-o69pgTEK.js";import{it as fe,nt as pe,rt as me}from"./vendor-base-ui-CdzJ6My_.js";import{Ct as he,Ln as ge,Nt as _e,n as ve,t as ye}from"./platform-7bX6qtBV.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{b as be,d as xe,i as Se,n as W,o as Ce,s as we}from"./useUIStore-NMQx_cnG.js";import{n as Te}from"./vendor-react-BP2cRVqX.js";import{l as Ee,n as De,o as Oe,s as ke}from"./vendor-tanstack-react-query-CdqCAt40.js";import{A as Ae}from"./runtime-file-resource-C1k5nbWb.js";import{a as je,i as Me,n as Ne}from"./types-DeOBiX60.js";import{t as Pe}from"./native-config-DPmta_0r.js";import{H as Fe}from"./vendor-codemirror-autocomplete-7c2L_4dM.js";import{r as Ie}from"./vendor-sonner-ZS8XIOVl.js";import{a as Le,c as Re,n as ze,r as Be}from"./vendor-reactuses-core-BpfIZ1tg.js";import{d as Ve,f as He,n as Ue,o as We,p as Ge,r as G,t as K}from"./button-CEcZQm-B.js";import{a as Ke,i as qe,r as Je}from"./MobileShareBridge-Dr13-74t.js";import{S as Ye,_ as Xe,a as Ze,c as Qe,f as $e,g as et,h as tt,o as nt,t as rt,v as it,y as at}from"./MobileDetailNavigation-B8LAq0IX.js";import{$a as ot,Ai as st,Ba as ct,Ci as lt,Da as ut,Ga as dt,Gn as ft,Gt as pt,Ha as mt,Ja as ht,Ka as gt,Oa as _t,Pr as vt,Qa as yt,Rr as q,Ta as bt,Ti as xt,Ua as St,Va as Ct,Wa as wt,Wn as Tt,Xa as Et,Ya as Dt,Za as Ot,_a as kt,_o as At,ao as jt,bi as Mt,co as Nt,d as Pt,do as Ft,eo as It,fo as Lt,go as Rt,ha as J,ho as zt,io as Bt,jr as Vt,ka as Ht,lo as Ut,ma as Wt,no as Gt,o as Kt,oo as qt,pa as Jt,qa as Yt,ro as Xt,so as Zt,to as Qt,uo as $t,va as en,wa as tn,wi as nn,wr as rn,ya as an,yo as on}from"./useMobileNavigationStore-D-RlKHiM.js";import{i as sn}from"./useAssistantUIStore-D7JZlg_Q.js";import{t as cn}from"./AgentAvatar-Dn3d91Bp.js";import{n as ln}from"./useThemeSystem-8jhE4Zyk.js";import{n as Y}from"./Icon-DZmADJWp.js";import{a as un,i as dn,n as fn,o as pn,r as mn,t as hn}from"./dialog-CjPdvmr0.js";import{A as gn,T as _n,_ as vn,a as yn,b as bn,h as xn,i as Sn,m as Cn,n as wn,x as Tn}from"./projectMeta-R1cugLKq.js";import{t as En}from"./input-yYSzMq8L.js";import{i as Dn,n as On,t as kn}from"./tooltip-Dmw1nU2I.js";import{$t as An,A as jn,At as Mn,B as Nn,Bt as Pn,Ct as Fn,D as In,F as Ln,Ft as Rn,H as zn,It as Bn,J as Vn,K as Hn,L as Un,Lt as Wn,Mt as Gn,N as Kn,Nt as qn,O as Jn,Pt as Yn,R as Xn,Rt as Zn,St as Qn,Ut as $n,V as er,Vt as tr,Xt as nr,Zt as rr,an as ir,at as ar,bt as or,c as sr,ct as cr,dt as lr,en as ur,f as dr,gt as fr,ht as pr,in as mr,it as hr,j as gr,jt as _r,kt as vr,mt as yr,nn as br,o as xr,r as Sr,rt as Cr,s as wr,st as Tr,t as Er,tn as Dr,tt as Or,ut as kr,xt as Ar,z as jr,zt as Mr}from"./speechSettingsQueries-JZkjbbR5.js";import{t as Nr}from"./YuriLogo-Dm011NCM.js";import{i as Pr,r as Fr}from"./OverlayScrollbar-BlzvB3ct.js";import{a as Ir,o as Lr}from"./dropdown-menu.styles-Cm3A3LAl.js";import{n as Rr,t as zr}from"./textarea-CO8JEdzP.js";import{M as Br,k as Vr,n as Hr}from"./appThemeRegistry-2SvgJE7r.js";import{n as Ur}from"./MarkdownRenderer-IKfW9Cjc.js";import{a as Wr}from"./url-Be8VCT8M.js";import{l as Gr}from"./markdown-worker-7FvUo2nm.js";import{t as Kr}from"./sortable-tabs-strip-MyKMqyvw.js";import{B as qr,C as Jr,D as Yr,F as Xr,I as Zr,L as Qr,M as X,N as Z,P as $r,R as ei,S as ti,T as ni,V as ri,_ as ii,a as ai,b as oi,c as si,d as ci,f as li,g as ui,j as di,l as fi,m as pi,o as mi,p as hi,r as gi,s as _i,t as vi,v as yi,w as bi,x as xi,y as Si,z as Ci}from"./MobileTabPageHeader-a9_X2cyT.js";import{a as wi,c as Ti,i as Ei,l as Di,o as Oi,r as ki,s as Ai}from"./mcpQueries-CwkJ4NQA.js";import{a as ji,d as Mi,f as Ni,l as Pi,m as Fi,o as Ii,p as Li,s as Ri,t as zi}from"./scheduledTaskNavigation-BhsUww-K.js";import{n as Bi}from"./mobileBackNavigation-6jBA1pR0.js";import{n as Vi,r as Hi,t as Ui}from"./collapsible-B6ON5Mai.js";import{n as Wi,t as Gi}from"./vendor-yaml-C9KlJAlj.js";import{t as Ki}from"./vendor-qrcode-D7jBCyl-.js";var qi=Te(),Ji=t(pe(),1),Q=t(fe(),1),$=me(),Yi=`https://github.com/yee94/yuri`,Xi=`${Yi}/issues/new`,Zi=800,Qi={"manual-global":`settings.yuri.about.opencodeManagement.manual-global`,"manual-external":`settings.yuri.about.opencodeManagement.manual-external`,bundled:`settings.yuri.about.opencodeManagement.bundled`,"in-app":`settings.yuri.about.opencodeManagement.in-app`,none:`settings.yuri.about.opencodeManagement.none`},$i=e=>typeof e==`string`&&e.trim()?e.trim():null,ea=(e,t,n)=>({queryKey:[t,`about`,n,e],queryFn:async({signal:r})=>{if(t!==i()||n!==o())throw Error(`Stale About runtime`);let a=await p(e,{method:`GET`,headers:{Accept:`application/json`},signal:r});if(!a.ok)throw Error(`About snapshot: ${a.status}`);let s=await a.json();if(!s||typeof s!=`object`||Array.isArray(s))throw Error(`Invalid About snapshot`);if(r.aborted||t!==i()||n!==o())throw Error(`Stale About runtime`);return s},retry:!1,staleTime:3e4}),ta=({initialUpdateDialogOpen:e=!1})=>{let{t}=He(),[n,a]=Q.useState(e),[s,c]=Q.useState(!1),[l,u]=Q.useState(!1),[d,f]=Q.useState(null),[p,m]=Q.useState(null),h=Q.useSyncExternalStore(r,i,i),g=Q.useSyncExternalStore(r,o,o),_=ke(ea(`/api/system/info`,h,g)),y=ke(ea(`/api/opencode/upgrade-status`,h,g)),b=$i(_.data?.yuriVersion),x=y.data,S=$i(x?.serveVersion)??$i(x?.currentVersion),C=$i(x?.management),w=C&&Object.hasOwn(Qi,C)?Qi[C]:null,T=x?.canManage===!1&&w?t(w):null,E=S&&T?t(`settings.yuri.about.opencodeVersionWithManagement`,{version:S,management:T}):S,D=x?.canManage===!1?C===`manual-global`?t(`settings.yuri.about.opencodeGuidance.manualGlobal`):C===`manual-external`?t(`settings.yuri.about.opencodeGuidance.manualExternal`):C===`bundled`?t(`settings.yuri.about.opencodeGuidance.bundled`):null:null,O=Qr(de(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}))),k=W(e=>e.otaChannelOverride),A=W(e=>e.setOtaChannelOverride),j=ve(),[M,N]=Q.useState(`stable`);Q.useEffect(()=>{F()&&v().then(e=>N(e?.includes(`-`)?`beta`:`stable`))},[]);let P=ke({queryKey:[`native-update-config`],queryFn:Pe,enabled:j,staleTime:1/0,retry:!1}),I=P.data?.channel,L=k===`beta`||k===null&&(F()?M:I)===`beta`,[R,z]=Q.useState(!1),[B,V]=Q.useState(()=>xt()),ee=ze(e=>{st(e),V(e)}),H=ze(async e=>{if(e){A(`beta`),await Qr.getState().checkForUpdates();return}A(`stable`),await Qr.getState().checkForUpdates();let{info:t,otaDecision:n}=Qr.getState();t?.isChannelRollback===!0&&n?.primaryAction===`apply_ota`&&c(!0)}),te=ze(()=>{c(!1),A(`beta`),Qr.getState().checkForUpdates()}),ne=ze(()=>{c(!1),a(!0),Qr.getState().downloadUpdate()}),U=ze(e=>{e||te()}),re=d||t(`settings.yuri.about.state.unknown`),ie=ze(async()=>{if(!R){z(!0);try{let{outcome:e,eventCount:n}=await nn();if(e===`cancelled`)return;if(e===`failed`){q.error(t(`settings.yuri.about.diagnostics.toast.failed`));return}q.success(t(n>0?`settings.yuri.about.diagnostics.toast.exported`:`settings.yuri.about.diagnostics.toast.empty`))}catch{q.error(t(`settings.yuri.about.diagnostics.toast.failed`))}finally{z(!1)}}});Q.useEffect(()=>{let e=!1;return je().then(t=>{e||f(t)}),Me().then(t=>{e||m(t)}),()=>{e=!0}},[]);let ae=Ne(d,p)??re,oe=Q.useRef(!1);Q.useEffect(()=>{if(O.checking)u(!0),oe.current=!0;else if(l){let e=setTimeout(()=>{u(!1),oe.current&&O.error?(q.error(t(`settings.yuri.about.toast.checkFailed`),{description:O.error}),oe.current=!1):oe.current&&!O.available&&!O.error&&(q.success(t(`settings.yuri.about.toast.latestVersion`)),oe.current=!1)},Zi);return()=>clearTimeout(e)}},[t,O.checking,l,O.available,O.error]);let se=O.checking||l;return(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack w-full`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,$.jsx)(Nr,{width:72,height:72}),(0,$.jsx)(`h2`,{className:`mt-4 typography-ui-header font-semibold text-foreground`,children:`Yuri`})]}),(0,$.jsxs)(X,{className:`yuri-settings-about`,children:[(0,$.jsx)(Z,{label:t(`settings.yuri.about.field.clientVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:ae})}),(0,$.jsx)(Z,{label:t(`settings.yuri.about.field.instanceYuriVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:b||t(`settings.yuri.about.state.unknown`)})}),(0,$.jsx)(Z,{label:t(`settings.yuri.about.field.instanceOpenCodeVersion`),description:D,children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:E||t(`settings.yuri.about.state.unknown`)})}),(0,$.jsx)(Z,{className:`yuri-settings-split-row-stacked`,copyClassName:`hidden`,children:(0,$.jsxs)(`div`,{className:`flex w-full flex-wrap items-center justify-end gap-2`,children:[(0,$.jsx)(K,{asChild:!0,variant:`outline`,size:`sm`,className:`whitespace-nowrap`,"data-settings-item":`about.feedback`,children:(0,$.jsxs)(`a`,{href:Xi,target:`_blank`,rel:`noopener noreferrer`,children:[(0,$.jsx)(Y,{name:`question`,className:`size-4`}),t(`settings.yuri.about.actions.submitFeedback`)]})}),!se&&O.available?(0,$.jsxs)(K,{type:`button`,variant:`default`,size:`sm`,className:`whitespace-nowrap`,onClick:()=>a(!0),"data-settings-item":`about.check-updates`,children:[(0,$.jsx)(Y,{name:`download`,className:`size-4`}),O.info?.inAppApply?t(`settings.yuri.about.actions.applyOtaToVersion`,{version:O.info?.version||``}):O.info?.manualUpdate?t(`settings.yuri.about.actions.installNativeToVersion`,{version:O.info?.version||``}):t(`settings.yuri.about.actions.updateToVersion`,{version:O.info?.version||``})]}):(0,$.jsxs)(K,{type:`button`,variant:`outline`,size:`sm`,className:`whitespace-nowrap`,onClick:()=>O.checkForUpdates(),"data-settings-item":`about.check-updates`,disabled:se,children:[se?(0,$.jsx)(Y,{name:`loader`,className:`size-4 animate-spin`}):(0,$.jsx)(Y,{name:`refresh`,className:`size-4`}),t(se?`settings.yuri.about.state.checking`:`settings.yuri.about.actions.checkForUpdates`)]})]})}),O.error&&(0,$.jsx)(Z,{children:(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:O.error})}),(j||F())&&(0,$.jsx)($r,{itemId:`about.beta-updates`,checked:L,onChange:H,label:t(`settings.yuri.about.betaUpdates.label`),description:t(`settings.yuri.about.betaUpdates.description`),ariaLabel:t(`settings.yuri.about.betaUpdates.label`),disabled:se||j&&!P.data}),(0,$.jsx)($r,{itemId:`about.diagnostics`,checked:B,onChange:ee,label:t(`settings.yuri.about.diagnostics.label`),ariaLabel:t(`settings.yuri.about.diagnostics.label`)}),B&&(0,$.jsx)(Z,{itemId:`about.export-diagnostics`,label:t(`settings.yuri.about.diagnostics.export`),children:(0,$.jsx)(K,{type:`button`,variant:`outline`,size:`sm`,disabled:R,onClick:()=>void ie(),children:t(R?`settings.yuri.about.diagnostics.exporting`:`settings.yuri.about.diagnostics.export`)})})]}),(0,$.jsx)(`div`,{className:`flex flex-col items-center gap-3 text-center`,children:(0,$.jsx)(`div`,{className:`flex items-center justify-center gap-5`,children:(0,$.jsxs)(`a`,{href:Yi,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)(Y,{name:`github-fill`,className:`size-5`}),(0,$.jsx)(`span`,{children:`GitHub`})]})})}),(0,$.jsx)(`p`,{className:`text-center typography-ui text-muted-foreground/60`,children:t(`aboutDialog.footerNote`)}),(0,$.jsx)(Zr,{open:n,onOpenChange:a,info:O.info,downloading:O.downloading,downloaded:O.downloaded,progress:O.progress,error:O.error,onDownload:O.downloadUpdate,onRestart:O.restartToUpdate,runtimeType:O.runtimeType}),(0,$.jsx)(hn,{open:s,onOpenChange:U,children:(0,$.jsxs)(fn,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[(0,$.jsxs)(un,{children:[(0,$.jsx)(pn,{children:t(`settings.yuri.about.betaUpdates.rollback.title`)}),(0,$.jsx)(mn,{children:t(`settings.yuri.about.betaUpdates.rollback.description`,{version:O.info?.version||``})})]}),(0,$.jsxs)(dn,{children:[(0,$.jsx)(K,{type:`button`,size:`sm`,variant:`ghost`,onClick:te,children:t(`settings.yuri.about.betaUpdates.rollback.actions.cancel`)}),(0,$.jsx)(K,{type:`button`,size:`sm`,onClick:ne,children:t(`settings.yuri.about.betaUpdates.rollback.actions.confirm`)})]})]})})]})},na=16384,ra=globalThis,ia=e=>{if(ra.Buffer)return ra.Buffer.from(e,`utf8`).toString(`base64url`);let t=new TextEncoder().encode(e),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.slice(e,e+32768));return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)},aa=e=>{try{if(ra.Buffer)return ra.Buffer.from(e,`base64url`).toString(`utf8`);let t=e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(Math.ceil(e.length/4)*4,`=`),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e+=1)r[e]=n.charCodeAt(e);return new TextDecoder().decode(r)}catch{return null}},oa=e=>{if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;try{let e=new URL(t);return e.protocol!==`http:`&&e.protocol!==`https:`?null:(e.hash=``,e.toString().replace(/\/+$/g,``))}catch{return null}},sa=e=>{if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;try{let e=new URL(t);return e.protocol!==`ws:`&&e.protocol!==`wss:`||e.username||e.password?null:(e.username=``,e.password=``,e.hash=``,e.search=``,e.toString())}catch{return null}},ca=e=>typeof e==`string`&&e.length>0,la=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;return t.kty!==`EC`||t.crv!==`P-256`||!ca(t.x)||!ca(t.y)?null:{kty:`EC`,crv:`P-256`,x:t.x,y:t.y}},ua=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0,da=e=>{if(!e||typeof e!=`object`)return null;let t=e,n=ua(t.priority);if(t.type===`lan`||t.type===`tunnel`){let e=oa(t.url);return e?n===void 0?{type:t.type,url:e}:{type:t.type,url:e,priority:n}:null}if(t.type===`relay`){let e=sa(t.relayUrl);if(!e)return null;let r=typeof t.serverId==`string`?t.serverId.trim():``;if(!r)return null;let i=la(t.hostEncPubJwk);if(!i)return null;let a=typeof t.grant==`string`&&t.grant.trim()?t.grant.trim():void 0;return{type:`relay`,relayUrl:e,serverId:r,hostEncPubJwk:i,...a?{grant:a}:{},...n===void 0?{}:{priority:n}}}return null},fa=e=>{if(!e||typeof e!=`object`)return null;let t=e;if(t.v!==2)return null;let n=typeof t.pairingId==`string`?t.pairingId.trim():``,r=typeof t.secret==`string`?t.secret.trim():``;if(!n||!r)return null;let i=Array.isArray(t.candidates)?t.candidates.map(da).filter(e=>!!e):[];if(i.length===0)return null;let a=typeof t.expiresAt==`string`&&t.expiresAt.trim()?t.expiresAt.trim():void 0;if(a){let e=Date.parse(a);if(!Number.isFinite(e)||e<=Date.now())return null}let o=typeof t.label==`string`&&t.label.trim()?t.label.trim():void 0,s=typeof t.fingerprint==`string`&&t.fingerprint.trim()?t.fingerprint.trim():void 0;return{v:2,pairingId:n,secret:r,...o?{label:o}:{},...s?{fingerprint:s}:{},...a?{expiresAt:a}:{},candidates:i}},pa=e=>({v:2,pairingId:e.pairingId.trim(),secret:e.secret.trim(),...e.label?.trim()?{label:e.label.trim()}:{},...e.fingerprint?.trim()?{fingerprint:e.fingerprint.trim()}:{},...e.expiresAt?.trim()?{expiresAt:e.expiresAt.trim()}:{},candidates:e.candidates}),ma=e=>{let t=fa(e);if(!t)throw Error(`Invalid pairing connection payload`);let n=new URLSearchParams;return n.set(`v`,`2`),n.set(`p`,ia(JSON.stringify(t))),`yuri://connect?${n.toString()}`},ha=e=>{let t=e.trim();if(!t||t.length>na)return null;let n=t.indexOf(`?`);if(n===-1||!/^(?:yuri|openchamber|openchambery):\/\/connect\/?$/i.test(t.slice(0,n)))return null;let r=null,i=null;for(let e of t.slice(n+1).split(`&`)){let t=e.indexOf(`=`);if(t===-1)continue;let n=e.slice(0,t),a=e.slice(t+1);n===`v`?r=a:n===`p`&&(i=a)}if(r!==`2`||!i||i.length>na)return null;let a=aa(i);if(!a||a.length>na)return null;try{return fa(JSON.parse(a))}catch{return null}},ga=e=>{let t=e.trim();if(!t||t.length>na)return null;try{let e=new URL(t);if([`yuri:`,`openchamber:`,`openchambery:`].includes(e.protocol)&&e.hostname===`connect`){if(e.searchParams.get(`v`)!==`2`)return null;let t=e.searchParams.get(`p`)||``;if(!t||t.length>na)return null;let n=aa(t);return!n||n.length>na?null:fa(JSON.parse(n))}}catch{}return ha(t)},_a=`/assets/android-direct-share-1a0lp154.jpg`,va=`/assets/ios-share-sheet-B3Dlufnc.jpg`,ya=`/assets/select-assistant-C89IRspC.jpg`,ba=`yuri:assistant-share-welcome:v1`,xa=[{image:va,titleKey:`assistants.shareWelcome.example.chat.title`,descriptionKey:`assistants.shareWelcome.example.chat.description`},{image:_a,titleKey:`assistants.shareWelcome.example.article.title`,descriptionKey:`assistants.shareWelcome.example.article.description`},{image:ya,titleKey:`assistants.shareWelcome.example.note.title`,descriptionKey:`assistants.shareWelcome.example.note.description`}],Sa=e=>{let t=(0,qi.c)(40),{enabled:n,open:r,onOpenChange:i}=e,a=n!==void 0&&n,{t:o}=He(),[s,c]=Re(ba,!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=ze(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)(Y,{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)(pn,{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)(mn,{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)(un,{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=xa.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)(Y,{name:`arrow-right-s`,className:`size-4`}),t[28]=w):w=t[28];let T;t[29]!==f||t[30]!==C?(T=(0,$.jsx)(dn,{className:`border-t border-border px-5 py-4 sm:px-8 sm:py-5`,children:(0,$.jsxs)(K,{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)(fn,{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)(hn,{open:u,onOpenChange:p,children:E}),t[36]=u,t[37]=E,t[38]=p,t[39]=D):D=t[39],D},Ca=`useCommandsStore`,wa=new Set([`init`,`review`]),Ta=e=>wa.has(e.name),Ea=async(e,t)=>{await Ut(l,e,t),i()===t&&zt(`commands`,{source:Ca})},Da=ce()(ue(le(e=>({selectedCommandName:null,commandDraft:null,setSelectedCommand:t=>e({selectedCommandName:t}),setCommandDraft:t=>e({commandDraft:t}),loadCommands:async()=>{let e=$t(),t=i();try{return await Ut(l,e,t),!0}catch{return!1}},createCommand:async t=>Oa(`POST`,t.name,t,e),updateCommand:async(t,n)=>Oa(`PATCH`,t,n,e),deleteCommand:async t=>Oa(`DELETE`,t,void 0,e),getCommandByName:e=>Nt().find(t=>t.name===e)}),{name:`commands-store`,storage:be(),partialize:e=>({selectedCommandName:e.selectedCommandName})}),{name:`commands-store`}));async function Oa(e,t,n,r){let a=$t(),o=i();try{let s={};if(e===`POST`&&(s.template=n?.template||``,n?.description&&(s.description=n.description),n?.agent&&(s.agent=n.agent),n?.model&&(s.model=n.model),n?.scope&&(s.scope=n.scope)),e===`PATCH`)for(let e of[`description`,`agent`,`model`,`template`])n?.[e]!==void 0&&(s[e]=n[e]);let c=a?`?directory=${encodeURIComponent(a)}`:``,l=await p(`/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(s)}}),u=await l.json().catch(()=>null);if(!l.ok)throw Error(u?.error||`Failed to ${e.toLowerCase()} command`);return i()!==o||(await Ea(a,o),i()!==o)||e===`DELETE`&&r({selectedCommandName:null}),!0}catch(e){return console.error(`[CommandsStore] Command mutation failed:`,e),!1}}typeof window<`u`&&(window.__zustand_commands_store__=Da),At(e=>{e.source!==Ca&&Rt(e,`commands`)&&Da.getState().loadCommands()});var ka=()=>{try{let e=Lt.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},Aa=e=>e?Object.entries(e).map(([e,t])=>({key:e,value:t})):[],ja=e=>{let t=e.filter(e=>e.key.trim());if(t.length!==0)return Object.fromEntries(t.map(e=>[e.key.trim(),e.value]))},Ma=e=>{if(typeof e==`string`)return e.trim()||void 0},Na=ce()(ue(le((e,t)=>({selectedMcpName:null,mcpDraft:null,setSelectedMcp:t=>e({selectedMcpName:t}),setMcpDraft:t=>e({mcpDraft:t}),loadMcpConfigs:async e=>{let t=ka();try{return!e?.force&&ki(l,t).length>0||await wi(l,t,i()),!0}catch(e){return console.error(`[McpConfigStore] Failed to load MCP configs:`,e),!1}},createMcp:async(e,t)=>{let n=`directory`in(t??{})?t?.directory?.trim()||null:ka(),r=t?.transportIdentity??i();try{let t=Pa(e),a=n?`?directory=${encodeURIComponent(n)}`:``,o=await p(`/api/config/mcp/${encodeURIComponent(e.name)}${a}`,{method:`POST`,headers:{"Content-Type":`application/json`,...n?{"x-opencode-directory":n}:{}},body:JSON.stringify(t)}),s=await o.json().catch(()=>null);if(!o.ok)throw Error(s?.error||`Failed to create MCP server`);return i()===r?(await wi(l,n,r),await Oi(l,n,r),{ok:!0,reloadFailed:s?.reloadFailed===!0,message:s?.message,warning:s?.warning}):{ok:!0}}catch(e){return console.error(`[McpConfigStore] Failed to create MCP:`,e),{ok:!1}}},updateMcp:async(e,t,n)=>{let r=`directory`in(n??{})?n?.directory?.trim()||null:ka(),a=n?.transportIdentity??i();try{let n=Pa(t),o=r?`?directory=${encodeURIComponent(r)}`:``,s=await p(`/api/config/mcp/${encodeURIComponent(e)}${o}`,{method:`PATCH`,headers:{"Content-Type":`application/json`,...r?{"x-opencode-directory":r}:{}},body:JSON.stringify(n)}),c=await s.json().catch(()=>null);if(!s.ok)throw Error(c?.error||`Failed to update MCP server`);return i()===a?(await wi(l,r,a),await Oi(l,r,a),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}):{ok:!0}}catch(e){throw console.error(`[McpConfigStore] Failed to update MCP:`,e),e}},deleteMcp:async(n,r)=>{let a=`directory`in(r??{})?r?.directory?.trim()||null:ka(),o=r?.transportIdentity??i();try{let r=a?`?directory=${encodeURIComponent(a)}`:``,s=await p(`/api/config/mcp/${encodeURIComponent(n)}${r}`,{method:`DELETE`,headers:a?{"x-opencode-directory":a}:void 0}),c=await s.json().catch(()=>null);if(!s.ok)throw Error(c?.error||`Failed to delete MCP server`);return ei.getState().clearDiagnostic(n,a,o),i()===o?(t().selectedMcpName===n&&e({selectedMcpName:null}),await wi(l,a,o),await Oi(l,a,o),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}):{ok:!0}}catch(e){return console.error(`[McpConfigStore] Failed to delete MCP:`,e),{ok:!1}}}}),{name:`mcp-config-store`,storage:be(),partialize:e=>({selectedMcpName:e.selectedMcpName})}),{name:`mcp-config-store`}));function Pa(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=ja(e.environment)??{}),e.headers!==void 0&&(t.headers=ja(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:Ma(e.oauthClientId),clientSecret:Ma(e.oauthClientSecret),scope:Ma(e.oauthScope),redirectUri:Ma(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 Fa=()=>{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},Ia=`useSkillsStore`,La=e=>{if(e&&Object.prototype.hasOwnProperty.call(e,`directory`))return typeof e.directory==`string`&&e.directory.trim()||null;let t=Fa();return typeof t==`string`&&t.trim()||null},Ra=ce()(ue(le((e,t)=>({selectedSkillName:null,skillDraft:null,setSelectedSkill:t=>{e({selectedSkillName:t})},setSkillDraft:t=>{e({skillDraft:t})},loadSkills:async()=>{try{return await Yt(l,Fa(),i()),!0}catch{return!1}},getSkillDetail:async e=>{try{let t=Fa(),n=t?`?directory=${encodeURIComponent(t)}`:``,r=await p(`/api/config/skills/${encodeURIComponent(e)}${n}`);return r.ok?await r.json():null}catch{return null}},createSkill:async(e,t)=>{try{let n={name:e.name,description:e.description};e.instructions&&(n.instructions=e.instructions),e.scope&&(n.scope=e.scope),e.source&&(n.source=e.source),e.supportingFiles&&(n.supportingFiles=e.supportingFiles);let r=La(t),a=i(),o=r?`?directory=${encodeURIComponent(r)}`:``,s=await p(`/api/config/skills/${encodeURIComponent(e.name)}${o}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)}),c=await s.json().catch(()=>null);if(!s.ok){let e=c?.error||`Failed to create skill`;throw Error(e)}return await za({directory:r,transportIdentity:a}),!0}catch{return!1}},updateSkill:async(e,t,n)=>{try{let r={};t.description!==void 0&&(r.description=t.description),t.instructions!==void 0&&(r.instructions=t.instructions),t.supportingFiles!==void 0&&(r.supportingFiles=t.supportingFiles),t.targetPath!==void 0&&(r.targetPath=t.targetPath);let a=La(n),o=i(),s=a?`?directory=${encodeURIComponent(a)}`:``,c=await p(`/api/config/skills/${encodeURIComponent(e)}${s}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)}),l=await c.json().catch(()=>null);if(!c.ok){let e=l?.error||`Failed to update skill`;throw Error(e)}return await za({directory:a,transportIdentity:o}),!0}catch{return!1}},deleteSkill:async(n,r)=>{try{let a=La(r),o=i(),s=a?`?directory=${encodeURIComponent(a)}`:``,c=await p(`/api/config/skills/${encodeURIComponent(n)}${s}`,{method:`DELETE`}),l=await c.json().catch(()=>null);if(!c.ok){let e=l?.error||`Failed to delete skill`;throw Error(e)}return await za({directory:a,transportIdentity:o}),i()===o&&t().selectedSkillName===n&&e({selectedSkillName:null}),!0}catch{return!1}},getSkillByName:e=>gt(l,Fa()).find(t=>t.name===e),readSupportingFile:async(e,t)=>{try{let n=Fa(),r=n?`&directory=${encodeURIComponent(n)}`:``,i=await p(`/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=Fa(),i=r?`?directory=${encodeURIComponent(r)}`:``;return(await p(`/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=Fa(),r=n?`?directory=${encodeURIComponent(n)}`:``;return(await p(`/api/config/skills/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}${r}`,{method:`DELETE`})).ok}catch{return!1}}}),{name:`skills-store`,storage:be(),partialize:e=>({selectedSkillName:e.selectedSkillName})}),{name:`skills-store`}));typeof window<`u`&&(window.__zustand_skills_store__=Ra);async function za(e){let t=e&&`directory`in e?e.directory?.trim()||null:Fa(),n=e?.transportIdentity??i();i()===n&&(await Yt(l,t,n),i()===n&&(await yt(l,t,n),i()===n&&zt(`skills`,{source:Ia})))}var Ba=null;Ba||=At(e=>{if(e.source!==Ia&&Rt(e,`skills`)){let e=Fa(),t=i();Yt(l,e,t).then(()=>yt(l,e,t)).catch(()=>void 0)}});var Va=/^#[0-9a-fA-F]{6}$/,Ha=/^\{file:.+\}$/i,Ua=e=>[...e].sort((e,t)=>{let n=e.permission.localeCompare(t.permission);return n===0?e.pattern.localeCompare(t.pattern):n}),Wa=(e,t)=>{let n=Ua(e),r=Ua(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})},Ga=(e,t)=>t?e.globalPermission!==t.globalPermission||!Wa(e.permissionRules,t.permissionRules):!1,Ka=e=>e===`bash`?`shell`:e===`task`?`subagent`:e===`write`||e===`patch`?`edit`:e,qa=(e,t)=>{let n=[{action:`*`,resource:`*`,effect:e}];for(let e of t)!e.permission||!e.pattern||(e.permission!==`*`||e.pattern!==`*`)&&n.push({action:Ka(e.permission),resource:e.pattern,effect:e.action});return n},Ja=e=>{let t=e.trim();return t===``?null:t},Ya=({isNewAgent:e,agentName:t,draftScope:n,initialScope:r,draftHasExplicitPermission:i,current:a,initial:o,confirmDrop:s})=>{let c=qa(a.globalPermission,a.permissionRules);if(e){let e=a.description.trim(),r=Ja(a.model),l=a.system.trim(),u=Ga(a,o)||i;return{name:t,mode:a.mode,...e?{description:e}:{},...r?{model:r}:{},...l?{system:l}:{},...u?{permissions:c}:{},...n?{scope:n}:{},...s?{confirmDrop:!0}:{}}}let l={name:t,...s?{confirmDrop:!0}:{}};return o?(a.description!==o.description&&(l.description=a.description.trim()||null),a.mode!==o.mode&&(l.mode=a.mode),a.model!==o.model&&(l.model=Ja(a.model)),a.system!==o.system&&(l.system=a.system.trim()||null),Ga(a,o)&&(l.permissions=c),n&&r&&n!==r&&(l.scope=n),l):l},Xa=e=>{if(e){if(typeof e.prompt==`string`)return Ha.test(e.prompt.trim())?void 0:e.prompt;if(typeof e.system==`string`)return e.system}},Za=e=>{let t=e?.model?.providerID,n=e?.model?.modelID||e?.model?.id;if(!t||!n)return``;let r=e?.model?.variant||e?.variant;return r?`${t}/${n}#${r}`:`${t}/${n}`},Qa=e=>{let t=e.trim(),n=t.indexOf(`/`);if(n<=0||n>=t.length-1)return null;let r=t.slice(0,n),i=t.slice(n+1),a=i.indexOf(`#`);return a===-1?{providerId:r,modelId:i,variant:``}:{providerId:r,modelId:i.slice(0,a),variant:i.slice(a+1)}},$a=e=>Va.test(e.trim()),eo=e=>{let t=e.trim();return t&&t.charAt(0).toUpperCase()+t.slice(1)},to=e=>{let t=(0,qi.c)(37),{className:n}=e,{t:r}=He(),i=Lt(no),a=Lt(ro),o=Lt(io),s=N(),c;t[0]===i?c=t[1]:(c=[...i].sort(ao),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 p=f,m;t[8]===n?m=t[9]:(m=G(n),t[8]=n,t[9]=m);let h;t[10]===r?h=t[11]:(h=r(`settings.shared.projectSelector.switchProjectAria`),t[10]=r,t[11]=h);let g;t[12]===r?g=t[13]:(g=r(`settings.shared.projectSelector.switchProjectTitle`),t[12]=r,t[13]=g);let _,v;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(_=G(`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`),v=(0,$.jsx)(Y,{name:`folder`,className:`h-4 w-4 text-muted-foreground`}),t[14]=_,t[15]=v):(_=t[14],v=t[15]);let y;t[16]===p?y=t[17]:(y=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label font-medium`,children:p}),t[16]=p,t[17]=y);let b;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(Y,{name:`arrow-down-s`,className:`size-4 opacity-50`}),t[18]=b):b=t[18];let x;t[19]!==h||t[20]!==g||t[21]!==y?(x=(0,$.jsx)(kr,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,"aria-label":h,title:g,className:_,children:[v,y,b]})}),t[19]=h,t[20]=g,t[21]=y,t[22]=x):x=t[22];let S=d?.id??``,C;t[23]===o?C=t[24]:(C=e=>{e&&o(e)},t[23]=o,t[24]=C);let w;t[25]===l?w=t[26]:(w=l.map(oo),t[25]=l,t[26]=w);let T;t[27]!==S||t[28]!==C||t[29]!==w?(T=(0,$.jsx)(hr,{align:`start`,className:`w-auto`,children:(0,$.jsx)(Tr,{value:S,onValueChange:C,children:w})}),t[27]=S,t[28]=C,t[29]=w,t[30]=T):T=t[30];let E;t[31]!==x||t[32]!==T?(E=(0,$.jsxs)(Cr,{children:[x,T]}),t[31]=x,t[32]=T,t[33]=E):E=t[33];let D;return t[34]!==E||t[35]!==m?(D=(0,$.jsx)(`div`,{className:m,children:E}),t[34]=E,t[35]=m,t[36]=D):D=t[36],D};function no(e){return e.projects}function ro(e){return e.activeProjectId}function io(e){return e.setActiveProject}function ao(e,t){return(e.label||e.path).localeCompare(t.label||t.path)}function oo(e){let t=e.path.split(`/`).filter(Boolean).pop()||e.path;return(0,$.jsx)(cr,{value:e.id,children:(0,$.jsx)(`span`,{className:`min-w-0 truncate typography-ui`,children:t})},e.id)}function so(e,t){return`opencode:sidebar-group:${e}:${t}`}var co=e=>{let t=(0,qi.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=so(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(lo),t[10]=e):e=t[10];let i;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(i=G(`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=G(`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)(Y,{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=G(_),t[27]=_,t[28]=v);let y;return t[29]!==c||t[30]!==p||t[31]!==m||t[32]!==v?(y=(0,$.jsx)(X,{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(uo),t[34]=y):y=t[34];let b;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(b=G(`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=G(`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)(Y,{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 lo(e){return!e}function uo(e){return!e}var fo=e=>e===`bash`?`shell`:e===`task`?`subagent`:e===`write`||e===`patch`?`edit`:e,po=e=>{let t=zn(e).map(e=>({action:fo(e.action),resource:e.resource,effect:e.effect}));return t.length>0?t:void 0},mo=(e,t)=>{let n=e,r=ct(e)?void 0:typeof n.system==`string`?n.system:typeof e.prompt==`string`?e.prompt:void 0,i=typeof n.color==`string`&&$a(n.color)?n.color:void 0;return{name:t,scope:n.scope||`user`,description:e.description,model:Za(e)||null,...r?{system:r}:{},mode:e.mode,...typeof n.steps==`number`?{steps:n.steps}:{},...e.hidden===!0?{hidden:!0}:{},...n.disabledOverride?{disabled:!0}:{},...i?{color:i}:{},permissions:po(n.permissions??e.permission)}},ho=({onItemSelect:e})=>{let{t}=He(),[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}=dt(de(e=>({selectedAgentName:e.selectedAgentName,setSelectedAgent:e.setSelectedAgent,setAgentDraft:e.setAgentDraft,createAgent:e.createAgent,deleteAgent:e.deleteAgent,loadAgents:e.loadAgents}))),{data:b=[]}=jt();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(ct(e)){q.error(t(`settings.agents.sidebar.toast.builtInCannotDelete`));return}s(e),l(`delete`)},C=async e=>{ct(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?q.warning(t(`settings.agents.page.toast.savedManualRestart`)):c===`delete`?q.success(t(`settings.agents.sidebar.toast.agentDeleted`,{name:o.name})):q.success(t(`settings.agents.sidebar.toast.agentReset`,{name:o.name})),w()):c===`delete`?q.error(t(`settings.agents.sidebar.toast.deleteFailed`)):q.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`?q.error(t(r?`settings.agents.sidebar.toast.definitionNotFound`:`settings.agents.sidebar.toast.deleteFailed`)):q.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}`;g(mo(e,r)),h(r)},D=e=>{a(e.name),r(e)},O=async()=>{if(!n)return;let e=i.trim().replace(/\s+/g,`-`);if(!e){q.error(t(`settings.agents.sidebar.toast.agentNameRequired`));return}if(e===n.name){r(null);return}if(b.some(t=>t.name===e)){q.error(t(`settings.agents.sidebar.toast.agentExists`));return}let a=n,o=await _({...mo(n,e),scope:a.scope});if(o.ok){let r=await v(n.name,a.scope);r.ok?(o.requiresManualRestart||r.requiresManualRestart?q.warning(t(`settings.agents.page.toast.savedManualRestart`)):q.success(t(`settings.agents.sidebar.toast.agentRenamed`,{name:e})),h(e)):q.error(t(`settings.agents.sidebar.toast.removeOldAfterRenameFailed`))}else q.error(t(`settings.agents.sidebar.toast.renameFailed`));r(null)},k=e=>{switch(e){case`primary`:return(0,$.jsx)(Y,{name:`ai-agent`,className:`h-3 w-3 text-primary`});case`all`:return(0,$.jsx)(Y,{name:`ai-agent-fill`,className:`h-3 w-3 text-primary`});case`subagent`:return(0,$.jsx)(Y,{name:`robot`,className:`h-3 w-3 text-primary`});default:return null}},A=b.filter(e=>{let t=e;return!Ct(e)||!!t.scope||t.disabledOverride===!0}),j=A.filter(ct),M=A.filter(e=>!ct(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)(K,{"data-settings-item":`agents.create`,size:`icon`,variant:`ghost`,onClick:x,"aria-label":t(`settings.agents.page.title.new`),children:(0,$.jsx)(Y,{name:`add`,className:`h-4 w-4`})})]});return(0,$.jsxs)(`div`,{className:`yuri-settings-page-content h-full overflow-y-auto bg-background p-3`,children:[(0,$.jsx)(to,{}),(0,$.jsx)($.Fragment,{children:A.length===0?(0,$.jsx)(X,{children:(0,$.jsxs)(`div`,{className:`yuri-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(Y,{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)(X,{label:t(`settings.agents.sidebar.section.builtIn`),children:j.map(t=>(0,$.jsx)(go,{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)(co,{label:n,count:r.length,storageKey:`agents`,variant:`settings-card`,labelPrefix:t(`settings.agents.sidebar.section.custom`),children:r.map(t=>(0,$.jsx)(go,{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)(X,{label:F,children:P.map(t=>(0,$.jsx)(go,{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)(X,{label:F,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]}),M.length===0&&(0,$.jsx)(X,{label:F,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]})}),(0,$.jsx)(hn,{open:o!==null&&c!==null,onOpenChange:e=>{!e&&!u&&w()},children:(0,$.jsxs)(fn,{className:`max-w-md`,children:[(0,$.jsxs)(un,{children:[(0,$.jsx)(pn,{children:t(c===`delete`?`settings.agents.sidebar.dialog.deleteTitle`:`settings.agents.sidebar.dialog.resetTitle`)}),(0,$.jsx)(mn,{children:t(c===`delete`?`settings.agents.sidebar.dialog.deleteDescription`:`settings.agents.sidebar.dialog.resetDescription`,{name:o?.name??``})})]}),(0,$.jsxs)(dn,{children:[(0,$.jsx)(K,{size:`sm`,variant:`ghost`,onClick:w,disabled:u,children:t(`settings.common.actions.cancel`)}),(0,$.jsx)(K,{size:`sm`,onClick:T,disabled:u,children:t(c===`delete`?`settings.common.actions.delete`:`settings.common.actions.reset`)})]})]})}),(0,$.jsx)(hn,{open:n!==null,onOpenChange:e=>!e&&r(null),children:(0,$.jsxs)(fn,{children:[(0,$.jsxs)(un,{children:[(0,$.jsx)(pn,{children:t(`settings.agents.sidebar.renameDialog.title`)}),(0,$.jsx)(mn,{children:t(`settings.agents.sidebar.renameDialog.description`,{name:n?.name??``})})]}),(0,$.jsx)(En,{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)(dn,{children:[(0,$.jsx)(K,{size:`sm`,variant:`ghost`,onClick:()=>r(null),children:t(`settings.common.actions.cancel`)}),(0,$.jsx)(K,{size:`sm`,onClick:O,children:t(`settings.common.actions.rename`)})]})]})})]})},go=e=>{let t=(0,qi.c)(55),{agent:n,isSelected:r,onSelect:i,onDelete:a,onReset:o,onRename:s,onDuplicate:c,getAgentModeIcon:l,isMenuOpen:u,onMenuOpenChange:d}=e,{t:f}=He(),p=n,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=Fr(),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)(Y,{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)(Y,{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)(Y,{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)(Y,{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=G(`yuri-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=eo(n.name),t[12]=n.name,t[13]=w);let T;t[14]===w?T=t[15]:(T=(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:w}),t[14]=w,t[15]=T);let E;t[16]!==n.mode||t[17]!==l?(E=l(n.mode),t[16]=n.mode,t[17]=l,t[18]=E):E=t[18];let D;t[19]!==n||t[20]!==p.disabledOverride||t[21]!==p.scope||t[22]!==f?(D=(p.scope||ct(n)||p.disabledOverride)&&(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:p.disabledOverride?f(`settings.agents.sidebar.badge.disabled`):ct(n)?f(`settings.agents.sidebar.badge.system`):p.scope===`project`?f(`settings.common.scope.project`):f(`settings.common.scope.global`)}),t[19]=n,t[20]=p.disabledOverride,t[21]=p.scope,t[22]=f,t[23]=D):D=t[23];let O;t[24]!==D||t[25]!==T||t[26]!==E?(O=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[T,E,D]}),t[24]=D,t[25]=T,t[26]=E,t[27]=O):O=t[27];let k;t[28]===n.description?k=t[29]:(k=n.description&&(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight`,children:n.description}),t[28]=n.description,t[29]=k);let A;t[30]!==i||t[31]!==O||t[32]!==k?(A=(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:[O,k]}),t[30]=i,t[31]=O,t[32]=k,t[33]=A):A=t[33];let j;t[34]===d?j=t[35]:(j=e=>{e&&_(!1),d(e)},t[34]=d,t[35]=j);let M;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(kr,{asChild:!0,children:(0,$.jsx)(K,{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)(Y,{name:`more-2`,className:`h-3.5 w-3.5`})})}),t[36]=M):M=t[36];let N;t[37]===y?N=t[38]:(N=(0,$.jsx)(hr,{align:`end`,className:`w-fit min-w-20`,children:y(ar)}),t[37]=y,t[38]=N);let P;t[39]!==u||t[40]!==j||t[41]!==N?(P=(0,$.jsxs)(Cr,{open:u,onOpenChange:j,children:[M,N]}),t[39]=u,t[40]=j,t[41]=N,t[42]=P):P=t[42];let F;t[43]!==A||t[44]!==P?(F=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[A,P]}),t[43]=A,t[44]=P,t[45]=F):F=t[45];let I;t[46]!==F||t[47]!==C?(I=(0,$.jsx)(Pi,{render:C,children:F}),t[46]=F,t[47]=C,t[48]=I):I=t[48];let L;t[49]===y?L=t[50]:(L=(0,$.jsx)(Ii,{className:`w-fit min-w-20`,children:y(Ri)}),t[49]=y,t[50]=L);let R;return t[51]!==g||t[52]!==I||t[53]!==L?(R=(0,$.jsxs)(ji,{open:g,onOpenChange:_,children:[I,L]}),t[51]=g,t[52]=I,t[53]=L,t[54]=R):R=t[54],R};function _o(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function vo(e){return typeof e==`string`&&e.length>0?e:void 0}function yo(e){let t=_o(e)?e:null,n=t&&Array.isArray(t.data)?t.data:Array.isArray(e)?e:null;if(!n)throw Error(`permission saved: expected list payload`);return n.map(e=>{if(!_o(e))throw Error(`permission saved: invalid rule`);let t=vo(e.id),n=vo(e.projectID),r=vo(e.action),i=vo(e.resource);if(!t||!n||!r||!i)throw Error(`permission saved: invalid rule`);return{id:t,projectID:n,action:r,resource:i}})}async function bo(e,t){if(!e.trim())throw Error(`permission saved: directory required`);t?.throwIfAborted();let n=await _e.getApiClient().location.get({location:{directory:e}},{signal:t});t?.throwIfAborted();let r=vo(n?.project?.id);if(!r)throw Error(`permission saved: project ID required`);return r}async function xo(e){e.signal?.throwIfAborted();let t=await _e.getApiClient().permission.saved.list({projectID:e.projectID??void 0},{signal:e.signal});e.signal?.throwIfAborted();let n=yo(t);if(e.projectID&&n.some(t=>t.projectID!==e.projectID))throw Error(`permission saved: project mismatch`);return n}async function So(e){e.signal?.throwIfAborted(),await _e.getApiClient().permission.saved.remove({id:e.id},{signal:e.signal})}function Co(e){if(e.transport!==i()||e.generation!==o())throw Error(`Saved permission runtime changed`)}var wo=e=>Oe({queryKey:[e.transport,e.generation,`saved-permission-project`,e.directory],queryFn:async({signal:t})=>{Co(e);let n=await bo(e.directory,t);return Co(e),n},retry:!1}),To=e=>Oe({queryKey:[e.transport,e.generation,`saved-permissions`,e.directory,e.projectID],queryFn:async({signal:t})=>{if(Co(e),!e.directory||!e.projectID)throw Error(`Saved permission scope required`);let n=await xo({projectID:e.projectID,signal:t});return Co(e),n},retry:!1});function Eo(e){let t=(0,qi.c)(3),n=(0,Q.useSyncExternalStore)(r,o,o),a={transport:i(),generation:n,directory:e.trim()},s=ke({...wo(a),enabled:!!a.directory}),c={...a,projectID:s.data??``},l=To(c),u=!!(a.directory&&s.data)&&!s.isError,d;return t[0]!==l||t[1]!==u?(d={...l,enabled:u},t[0]=l,t[1]=u,t[2]=d):d=t[2],{project:s,list:ke(d),scope:c}}async function Do(e,t,n){Co(t);let r=To(t).queryKey;if(!e.getQueryData(r)?.some(e=>e.id===n&&e.projectID===t.projectID))throw Error(`Saved permission is outside the captured scope`);await So({id:n}),t.transport===i()&&t.generation===o()&&(await e.cancelQueries({queryKey:r,exact:!0}),t.transport===i()&&t.generation===o()&&e.setQueryData(r,e=>e?.filter(e=>e.id!==n)))}var Oo=()=>{let e=(0,qi.c)(49),{t}=He(),n=he(ko),r=Ee(),{project:i,list:a,scope:o}=Eo(n),s;e[0]===r?s=e[1]:(s={mutationFn:e=>{let{scope:t,id:n}=e;return Do(r,t,n)}},e[0]=r,e[1]=s);let c=De(s),l;e[2]!==c.variables||e[3]!==o?(l=c.variables&&JSON.stringify(c.variables.scope)===JSON.stringify(o),e[2]=c.variables,e[3]=o,e[4]=l):l=e[4];let u=l,d=i.isError||a.isError,f=!!o.directory&&(i.isPending||a.isPending)&&!d,p;e[5]===a.data?p=e[6]:(p=a.data??[],e[5]=a.data,e[6]=p);let m=p,h;e[7]!==c||e[8]!==o?(h=e=>c.mutate({scope:o,id:e}),e[7]=c,e[8]=o,e[9]=h):h=e[9];let g=ze(h),_;e[10]!==a||e[11]!==i?(_=()=>{i.isError?i.refetch():a.refetch()},e[10]=a,e[11]=i,e[12]=_):_=e[12];let v=ze(_);if(!d&&!f&&m.length===0)return null;let y;e[13]===t?y=e[14]:(y=t(`settings.permissions.saved.title`),e[13]=t,e[14]=y);let b;e[15]!==f||e[16]!==t?(b=f?t(`common.loading`):void 0,e[15]=f,e[16]=t,e[17]=b):b=e[17];let x;e[18]!==d||e[19]!==a.isFetching||e[20]!==i.isFetching||e[21]!==v||e[22]!==t?(x=d&&(0,$.jsx)(Z,{label:(0,$.jsx)(`span`,{role:`alert`,children:t(`settings.permissions.saved.loadFailed`)}),children:(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`xs`,onClick:v,disabled:i.isFetching||a.isFetching,children:t(`settings.permissions.saved.retry`)})}),e[18]=d,e[19]=a.isFetching,e[20]=i.isFetching,e[21]=v,e[22]=t,e[23]=x):x=e[23];let S;e[24]!==c.isError||e[25]!==u||e[26]!==t?(S=u&&c.isError&&(0,$.jsx)(Z,{label:(0,$.jsx)(`span`,{role:`alert`,children:t(`settings.permissions.saved.deleteFailed`)}),children:null}),e[24]=c.isError,e[25]=u,e[26]=t,e[27]=S):S=e[27];let C;if(e[28]!==c.isPending||e[29]!==d||e[30]!==g||e[31]!==m||e[32]!==f||e[33]!==u||e[34]!==t){let n;e[36]!==c.isPending||e[37]!==d||e[38]!==g||e[39]!==f||e[40]!==u||e[41]!==t?(n=e=>(0,$.jsx)(Z,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:e.action}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground font-mono`,children:e.resource})]}),children:(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`xs`,disabled:d||f||!!(u&&c.isPending),onClick:()=>void g(e.id),children:t(`settings.permissions.saved.delete`)})},e.id),e[36]=c.isPending,e[37]=d,e[38]=g,e[39]=f,e[40]=u,e[41]=t,e[42]=n):n=e[42],C=m.map(n),e[28]=c.isPending,e[29]=d,e[30]=g,e[31]=m,e[32]=f,e[33]=u,e[34]=t,e[35]=C}else C=e[35];let w;return e[43]!==y||e[44]!==b||e[45]!==x||e[46]!==S||e[47]!==C?(w=(0,$.jsx)(`div`,{"data-settings-item":`permissions.saved`,className:`mb-6`,children:(0,$.jsxs)(X,{label:y,description:b,children:[x,S,C]})}),e[43]=y,e[44]=b,e[45]=x,e[46]=S,e[47]=C,e[48]=w):w=e[48],w};function ko(e){return e.currentDirectory}var Ao=[`*`,`read`,`edit`,`glob`,`grep`,`shell`,`subagent`,`skill`,`webfetch`,`websearch`,`question`,`external_directory`,`execute`,`browser`],jo={"*":`settings.agents.page.permissions.defaultLabel`,shell:`settings.agents.page.permissions.shell`,bash:`settings.agents.page.permissions.shell`,subagent:`settings.agents.page.permissions.subagent`,task:`settings.agents.page.permissions.subagent`,edit:`settings.agents.page.permissions.edit`,write:`settings.agents.page.permissions.edit`,patch:`settings.agents.page.permissions.edit`,apply_patch:`settings.agents.page.permissions.edit`,multiedit:`settings.agents.page.permissions.edit`,external_directory:`settings.agents.page.permissions.externalDirectory`,question:`settings.agents.page.permissions.question`,read:`settings.agents.page.permissions.read`,glob:`settings.agents.page.permissions.glob`,grep:`settings.agents.page.permissions.grep`,skill:`settings.agents.page.permissions.skill`,webfetch:`settings.agents.page.permissions.webfetch`,websearch:`settings.agents.page.permissions.websearch`,execute:`settings.agents.page.permissions.execute`,browser:`settings.agents.page.permissions.browser`,session_rename:`chat.tools.display.session_rename`,session_move:`chat.tools.display.session_move`},Mo=e=>e===`allow`||e===`ask`||e===`deny`,No=(e,t)=>`${e}::${t}`,Po=e=>e===`bash`?`shell`:e===`task`?`subagent`:e===`write`||e===`patch`?`edit`:e,Fo=e=>{let t=new Map;for(let n of e){let e=Po(n.permission);!e||e===`invalid`||n.pattern&&Mo(n.action)&&t.set(No(e,n.pattern),{permission:e,pattern:n.pattern,action:n.action})}return Array.from(t.values())},Io=e=>{let t=new Map;for(let n of Fo(e))t.set(No(n.permission,n.pattern),n);return t},Lo=e=>[...e].sort((e,t)=>{let n=e.permission.localeCompare(t.permission);return n===0?e.pattern.localeCompare(t.pattern):n}),Ro=(e,t)=>{let n=Lo(Fo(e)),r=Lo(Fo(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})},zo=e=>e.find(e=>e.permission===`*`&&e.pattern===`*`)?.action??`allow`,Bo=(e,t)=>Fo(e).filter(e=>e.permission!==`*`||e.pattern!==`*`).filter(e=>e.pattern!==`*`||e.action!==t),Vo=e=>{if(Array.isArray(e))return Fo(e.flatMap(e=>!e||typeof e!=`object`||typeof e.action!=`string`||typeof e.resource!=`string`||!Mo(e.effect)?[]:[{permission:e.action,pattern:e.resource,action:e.effect}]));if(Mo(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(Mo(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))Mo(i)&&t.push({permission:n,pattern:e,action:i})}return t},Ho=()=>{let{t:e}=He(),{selectedAgentName:t,getAgentByName:n,createAgent:r,updateAgent:i,agentDraft:a,setAgentDraft:o}=dt(de(e=>({selectedAgentName:e.selectedAgentName,getAgentByName:e.getAgentByName,createAgent:e.createAgent,updateAgent:e.updateAgent,agentDraft:e.agentDraft,setAgentDraft:e.setAgentDraft}))),{data:s=[]}=jt(),c=t?n(t):null,l=!!(a&&a.name===t&&!c),[u,d]=Q.useState(``),[f,m]=Q.useState(`user`),[h,g]=Q.useState(``),[_,v]=Q.useState(`subagent`),[y,b]=Q.useState(``),[x,S]=Q.useState(``),[C,w]=Q.useState(!1),[T,E]=Q.useState(`allow`),[D,O]=Q.useState([]),[k,A]=Q.useState([]),[j,M]=Q.useState(``),[N,P]=Q.useState(`*`),[F,I]=Q.useState(!1),[L,R]=Q.useState(!1),z=Q.useRef(null),B=he(e=>e.currentDirectory??null),[V,ee]=Q.useState([]),H=pt(e=>e.permission);Q.useEffect(()=>{let e=!1;return(async()=>{let t=await _e.listToolIds({directory:B});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));ee(Array.from(new Set(r)).sort((e,t)=>e.localeCompare(t)))})(),()=>{e=!0}},[B]);let te=Q.useMemo(()=>{let e=new Set;for(let t of s){let n=Fo(Vo(t.permissions??t.permission));for(let t of n)t.permission&&t.permission!==`*`&&t.permission!==`invalid`&&e.add(t.permission)}for(let t of Object.values(H))for(let n of t){let t=n.permission?.trim();t&&t!==`invalid`&&e.add(t)}for(let t of V)e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[s,H,V]),ne=Q.useMemo(()=>Io(D),[D]),U=Q.useMemo(()=>Io(k),[k]),re=e=>U.get(No(e,`*`))?.action,ie=e=>k.filter(t=>t.permission===e&&t.pattern!==`*`).sort((e,t)=>e.pattern.localeCompare(t.pattern)),ae=Q.useMemo(()=>{let e=new Set;for(let t of Ao)e.add(t);for(let t of te)e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[te]),oe=e=>{let t=e===`*`?T:re(e)??T,n=ie(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}},se=t=>e(t===`allow`?`settings.common.permission.allow`:t===`deny`?`settings.common.permission.deny`:`settings.common.permission.ask`),ce=t=>t===`global`?e(`settings.common.scope.global`):se(t),le=Q.useMemo(()=>{let e=new Set;for(let t of Ao)e.add(t);for(let t of te)e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[te]),ue=(e,t,n)=>{A(r=>{let i=Io(r);return i.set(No(e,t),{permission:e,pattern:t,action:n}),Array.from(i.values())})},fe=(e,t)=>{A(n=>{let r=Io(n);return r.delete(No(e,t)),Array.from(r.values())})},pe=(e,t)=>{let n=ne.get(No(e,t));if(n){ue(e,t,n.action);return}fe(e,t)},me=(e,t,n)=>{ue(e,t,n)},ge=e=>{E(e),A(t=>t.filter(t=>t.pattern!==`*`||t.action!==e))},ve=t=>{let n=j.trim();if(!n){q.error(e(`settings.agents.page.toast.permissionNameRequired`));return}let r=N.trim()||`*`;if(n===`*`&&r===`*`){ge(t),M(``),P(`*`);return}r===`*`&&n!==`*`&&t===T?fe(n,`*`):ue(n,r,t),M(``),P(`*`)},ye=t=>{let n=jo[t];return n?e(n):t.split(/[_-]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)};Q.useEffect(()=>{M(``),P(`*`);let e=e=>{let t=Fo(e),n=zo(t),r=Bo(t,n);return E(n),O(r),A(r),{global:n,rules:r}};if(l&&a){let t=a.name||``,n=a.scope||`user`,r=a.description||``,i=a.mode||`subagent`,o=a.model||``,s=a.system||``;d(t),m(n),g(r),v(i),b(o),S(s),w(!1);let c=e(Vo(a.permissions));z.current={draftName:t,draftScope:n,description:r,mode:i,model:o,system:s,globalPermission:c.global,permissionRules:c.rules};return}if(c&&t===c.name){let t=c,n=c.description||``,r=c.mode||`subagent`,i=Za(c),a=t.scope===`project`?`project`:`user`;m(a),g(n),v(r),b(i),S(``),w(!1);let o=e(Vo(t.permissions??c.permission));z.current={draftName:``,draftScope:a,description:n,mode:r,model:i,system:``,globalPermission:o.global,permissionRules:o.rules}}},[a,l,c,t]),Q.useEffect(()=>{if(!t||l)return;let e=new AbortController,n=$t();return p(`/api/config/agents/${encodeURIComponent(t)}/config`,{signal:e.signal,headers:n?{"x-opencode-directory":n}:{}}).then(async t=>{if(!t.ok||e.signal.aborted)return;let n=Xa((await t.json()).config);e.signal.aborted||n===void 0||!z.current||(S(n),z.current={...z.current,system:n})}).catch(()=>void 0),()=>e.abort()},[l,t]);let be=Q.useMemo(()=>{let e=z.current;return e?!!(l&&u!==e.draftName||f!==e.draftScope||h!==e.description||_!==e.mode||y!==e.model||x!==e.system||T!==e.globalPermission||!Ro(k,e.permissionRules)):!1},[h,u,f,T,l,_,y,k,x]),xe=(!l&&c?c.document:void 0)?.dropped?.map(e=>e.key)??[],Se=!L&&be;return t?(0,$.jsx)(Rr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(Xr,{actions:(0,$.jsx)(K,{type:`button`,size:`sm`,onClick:async()=>{let n=l?u.trim().replace(/\s+/g,`-`):t?.trim();if(!n){q.error(e(`settings.agents.sidebar.toast.agentNameRequired`));return}if(l&&s.some(e=>e.name===n)){q.error(e(`settings.agents.sidebar.toast.agentExists`));return}R(!0);try{let t={description:h,mode:_,model:y,system:x,globalPermission:T,permissionRules:k},s=z.current,c=s?{description:s.description,mode:s.mode,model:s.model,system:s.system,globalPermission:s.globalPermission,permissionRules:s.permissionRules}:null,u=Ya({isNewAgent:l,agentName:n,draftScope:f,initialScope:s?.draftScope,draftHasExplicitPermission:l&&a?.permissions!==void 0,current:t,initial:c,confirmDrop:C}),d;l?(d=await r(u),d.ok&&o(null)):d=await i(n,u),d.ok?d.requiresManualRestart?q.warning(e(`settings.agents.page.toast.savedManualRestart`)):q.success(e(`settings.agents.page.toast.savedNextRequest`)):q.error(e(l?`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`);q.error(n)}finally{R(!1)}},disabled:!Se,"aria-busy":L,children:e(L?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)}),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.agents.page.title.new`):eo(t??``)}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:e(l?`settings.agents.page.subtitle.new`:`settings.agents.page.subtitle.edit`)})]})}),(0,$.jsx)(Oo,{}),xe.length>0?(0,$.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2`,children:[(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.agents.page.legacy.dropped`,{fields:xe.join(`, `)})}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 typography-meta text-foreground`,children:[(0,$.jsx)(gn,{checked:C,onChange:w,ariaLabel:e(`settings.agents.page.legacy.confirmDrop`)}),e(`settings.agents.page.legacy.confirmDrop`)]})]}):null,(0,$.jsxs)(X,{label:e(`settings.agents.page.section.identityRole`),children:[(0,$.jsx)(Z,{itemId:`agents.scope`,label:e(`settings.agents.page.field.scope`),children:(0,$.jsxs)(Cn,{value:f,onValueChange:e=>m(e),children:[(0,$.jsx)(bn,{className:`w-fit min-w-[100px]`,children:(0,$.jsx)(Tn,{placeholder:e(`settings.agents.page.field.scopePlaceholder`),children:t=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Y,{name:t===`project`?`folder`:`user-3`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(t===`project`?`settings.common.scope.project`:`settings.common.scope.global`)})]})})}),(0,$.jsxs)(xn,{align:`end`,children:[(0,$.jsx)(vn,{value:`user`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Y,{name:`user-3`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.global`)})]})}),(0,$.jsx)(vn,{value:`project`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Y,{name:`folder`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.project`)})]})})]})]})}),l&&(0,$.jsx)(Z,{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)(En,{value:u,onChange:e=>d(e.target.value),placeholder:e(`settings.agents.page.field.agentNamePlaceholder`),className:`h-7 w-40 px-2`})]})}),(0,$.jsx)(Z,{label:e(`settings.common.field.description`),className:`yuri-settings-split-row-stacked`,children:(0,$.jsx)(zr,{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)(Z,{itemId:`agents.mode`,className:`yuri-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)(kn,{children:[(0,$.jsx)(Dn,{asChild:!0,children:(0,$.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(On,{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)(K,{variant:`chip`,size:`xs`,"aria-pressed":_===`primary`,onClick:()=>v(`primary`),className:`!font-normal shrink-0`,children:e(`settings.agents.page.mode.primary`)}),(0,$.jsx)(K,{variant:`chip`,size:`xs`,"aria-pressed":_===`subagent`,onClick:()=>v(`subagent`),className:`!font-normal shrink-0`,children:e(`settings.agents.page.mode.subagent`)}),(0,$.jsx)(K,{variant:`chip`,size:`xs`,"aria-pressed":_===`all`,onClick:()=>v(`all`),className:`!font-normal shrink-0`,children:e(`settings.agents.page.mode.all`)})]})})]}),(0,$.jsx)(X,{label:e(`settings.agents.page.section.modelParameters`),children:(0,$.jsx)(Z,{itemId:`agents.model`,label:e(`settings.agents.page.field.overrideModel`),children:(0,$.jsx)(Vn,{providerId:Qa(y)?.providerId??``,modelId:Qa(y)?.modelId??``,variant:Qa(y)?.variant??``,onChange:(e,t,n)=>{b(e&&t?n?`${e}/${t}#${n}`:`${e}/${t}`:``)},className:`yuri-settings-inline-value`})})}),(0,$.jsx)(di,{itemId:`agents.system-prompt`,label:e(`settings.agents.page.section.systemPrompt`),className:`yuri-settings-split-row-stacked`,children:(0,$.jsx)(zr,{embedded:!0,value:x,onChange:e=>S(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)(X,{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)(K,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>I(e=>!e),children:e(F?`settings.agents.page.permissions.hideEditor`:`settings.agents.page.permissions.advancedEditor`)})]}),children:F?(0,$.jsxs)(`div`,{className:`space-y-6 p-2`,children:[(0,$.jsx)(Z,{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)(Cn,{value:T,onValueChange:e=>ge(e),children:[(0,$.jsx)(bn,{className:`w-[100px]`,children:(0,$.jsx)(Tn,{children:se(T)})}),(0,$.jsxs)(xn,{children:[(0,$.jsx)(vn,{value:`allow`,children:e(`settings.common.permission.allow`)}),(0,$.jsx)(vn,{value:`ask`,children:e(`settings.common.permission.ask`)}),(0,$.jsx)(vn,{value:`deny`,children:e(`settings.common.permission.deny`)})]})]})}),(0,$.jsx)(`div`,{className:`space-y-4`,children:ae.filter(e=>e!==`*`).map(t=>{let n=ye(t),{defaultAction:r,patternRulesCount:i}=oe(t),a=re(t),o=a??`global`,s=ie(t),c=[`allow`,`ask`,`deny`].filter(e=>e!==T);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 items-center justify-between gap-2 py-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap 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)(K,{size:`sm`,variant:`ghost`,onClick:()=>pe(t,`*`),className:`px-1.5 py-0 h-5`,children:(0,$.jsx)(Y,{name:`subtract`,className:`h-3.5 w-3.5 text-muted-foreground hover:text-foreground`})})]}),(0,$.jsxs)(Cn,{value:o,onValueChange:e=>{if(e===`global`){fe(t,`*`);return}ue(t,`*`,e)},children:[(0,$.jsx)(bn,{className:`w-[90px] shrink-0`,children:(0,$.jsx)(Tn,{children:ce(o)})}),(0,$.jsxs)(xn,{children:[(0,$.jsx)(vn,{value:`global`,children:e(`settings.common.scope.global`)}),c.map(e=>(0,$.jsx)(vn,{value:e,className:`capitalize`,children:se(e)},e))]})]})]}),s.map(t=>{let n=No(t.permission,t.pattern),r=ne.get(n),i=!r,a=!!(r&&r.action!==t.action);return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 py-0.5 border-t border-[var(--surface-subtle)]`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap 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:`min-w-0 break-all 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)(K,{size:`sm`,variant:`ghost`,onClick:()=>i?fe(t.permission,t.pattern):pe(t.permission,t.pattern),className:`px-1.5 py-0 h-5`,children:(0,$.jsx)(Y,{name:`subtract`,className:`h-3.5 w-3.5 text-muted-foreground hover:text-foreground`})})]}),(0,$.jsxs)(Cn,{value:t.action,onValueChange:e=>me(t.permission,t.pattern,e),children:[(0,$.jsx)(bn,{className:`w-[90px] shrink-0`,children:(0,$.jsx)(Tn,{children:se(t.action)})}),(0,$.jsxs)(xn,{children:[(0,$.jsx)(vn,{value:`allow`,children:e(`settings.common.permission.allow`)}),(0,$.jsx)(vn,{value:`ask`,children:e(`settings.common.permission.ask`)}),(0,$.jsx)(vn,{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-wrap items-center justify-end gap-2`,children:[(0,$.jsxs)(Cn,{value:j,onValueChange:M,children:[(0,$.jsx)(bn,{className:`w-auto max-w-full sm:w-[160px]`,children:j?(0,$.jsx)(`span`,{className:`truncate`,children:ye(j)}):(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e(`settings.agents.page.permissions.permissionPlaceholder`)})}),(0,$.jsx)(xn,{children:le.map(e=>(0,$.jsx)(vn,{value:e,children:(0,$.jsx)(`div`,{className:`flex items-center justify-between gap-2 w-full`,children:(0,$.jsx)(`span`,{children:ye(e)})})},e))})]}),(0,$.jsx)(En,{value:N,onChange:e=>P(e.target.value),placeholder:e(`settings.agents.page.permissions.patternPlaceholder`),className:`h-7 min-w-0 flex-1 basis-32 font-mono text-xs`}),(0,$.jsxs)(`div`,{className:`flex gap-1`,children:[(0,$.jsx)(K,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>ve(`allow`),children:e(`settings.common.permission.allow`)}),(0,$.jsx)(K,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>ve(`ask`),children:e(`settings.common.permission.ask`)}),(0,$.jsx)(K,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>ve(`deny`),children:e(`settings.common.permission.deny`)})]})]})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground px-3 pt-2`,children:e(`settings.agents.page.permissions.lastMatchHint`)}),er(zn(k)).map((e,t)=>(0,$.jsx)(Z,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground font-mono`,children:t+1}),(0,$.jsx)(`span`,{children:e.action}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 font-mono`,children:e.resource})]}),children:(0,$.jsx)(`span`,{className:G(`typography-micro capitalize px-1.5 py-0.5 rounded`,e.effect===`allow`?`text-[var(--status-success)] bg-[var(--status-success)]/10`:e.effect===`deny`?`text-[var(--status-error)] bg-[var(--status-error)]/10`:`text-[var(--status-warning)] bg-[var(--status-warning)]/10`),children:e.effect})},`${e.action}::${e.resource}::${t}`))]})})})]})}):(0,$.jsx)(Rr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(Oo,{}),(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(Y,{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`)})]})})]})})},Uo=e=>{let t=(0,qi.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=G(`yuri-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 min-w-0 font-normal whitespace-normal [overflow-wrap:anywhere] 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 whitespace-normal [overflow-wrap:anywhere] 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)(Cr,{children:[(0,$.jsx)(kr,{asChild:!0,children:(0,$.jsx)(K,{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)(Y,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(hr,{align:`end`,className:`w-fit min-w-20`,children:s.map(Wo)})]}),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 Wo(e){let t=e.icon;return(0,$.jsxs)(ar,{onClick:t=>{t.stopPropagation(),e.onClick()},className:G(e.destructive&&`text-destructive focus:text-destructive`),children:[t&&(0,$.jsx)(Y,{name:t,className:`h-4 w-4 mr-px`}),e.label]},e.label)}var Go=e=>{let t=(0,qi.c)(8),{header:n,footer:r,children:i,className:a,variant:o}=e,s=o===void 0?`sidebar`:o,c=N(),l=s===`background`||c?`bg-background`:`bg-sidebar`,u;t[0]!==l||t[1]!==a?(u=G(`yuri-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},Ko=`__managed_workspace__`,qo=`__current_workspace__`,Jo=`Yuri`,Yo=()=>{let e=tn.getState(),t=e.settingsDefaultModel??(e.currentModelId?void 0:e.opencodeDefaultModel);if(t){let n=Zt(t);if(n?.providerId&&n?.modelId)return{providerID:n.providerId,modelID:n.modelId,variant:n.variant??e.settingsDefaultVariant}}if(e.currentProviderId&&e.currentModelId)return{providerID:e.currentProviderId,modelID:e.currentModelId,variant:e.currentVariant};let n=e.providers;for(let e of n){let t=e.models;if(Array.isArray(t)&&t.length>0){let n=t[0];if(n?.id)return{providerID:e.id,modelID:n.id}}}return null},Xo=(e=``)=>{let t=Yo();return{enabled:!0,name:e,avatarSeed:crypto.randomUUID(),defaultPrompt:``,workspacePath:null,providerID:t?.providerID??``,modelID:t?.modelID??``,variant:t?.variant??null}},Zo=e=>({avatarSeed:e.avatarSeed??e.id,enabled:e.enabled,name:e.name,defaultPrompt:e.defaultPrompt,workspacePath:e.workspacePath,providerID:e.providerID,modelID:e.modelID,variant:e.variant}),Qo=e=>({avatarSeed:e.avatarSeed,enabled:e.enabled,name:e.name,defaultPrompt:e.defaultPrompt,workspacePath:e.workspacePath,providerID:e.providerID,modelID:e.modelID,variant:e.variant??null}),$o=e=>e.label?.trim()||e.path.replace(/[\\/]+$/,``).split(/[\\/]/).filter(Boolean).at(-1)||e.path,es=e=>{let t=Array.isArray(e.schedule.times)?e.schedule.times:e.schedule.time?[e.schedule.time]:[];return Array.from(new Set(t.filter(e=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(e)))).sort((e,t)=>e.localeCompare(t))},ts=e=>!!e&&typeof e==`object`&&!Array.isArray(e),ns=e=>{if(!ts(e)||!ts(e.schedule)||!ts(e.execution)||!ts(e.state))return!1;let t=e.schedule.times===void 0||Array.isArray(e.schedule.times)&&e.schedule.times.every(e=>typeof e==`string`),n=e.schedule.weekdays===void 0||Array.isArray(e.schedule.weekdays)&&e.schedule.weekdays.every(e=>typeof e==`number`),r=e.state.lastStatus===void 0||e.state.lastStatus===`idle`||e.state.lastStatus===`running`||e.state.lastStatus===`success`||e.state.lastStatus===`error`;return typeof e.id==`string`&&typeof e.name==`string`&&typeof e.enabled==`boolean`&&(e.schedule.kind===`daily`||e.schedule.kind===`weekly`||e.schedule.kind===`once`||e.schedule.kind===`cron`)&&t&&n&&r&&typeof e.execution.prompt==`string`&&typeof e.execution.providerID==`string`&&typeof e.execution.modelID==`string`},rs=(e,t)=>{let n=es(e).join(`, `)||`—`,r=e=>t(e===0?`sessions.scheduledTasks.dialog.schedule.weekdayShort.sun`:e===1?`sessions.scheduledTasks.dialog.schedule.weekdayShort.mon`:e===2?`sessions.scheduledTasks.dialog.schedule.weekdayShort.tue`:e===3?`sessions.scheduledTasks.dialog.schedule.weekdayShort.wed`:e===4?`sessions.scheduledTasks.dialog.schedule.weekdayShort.thu`:e===5?`sessions.scheduledTasks.dialog.schedule.weekdayShort.fri`:e===6?`sessions.scheduledTasks.dialog.schedule.weekdayShort.sat`:`sessions.scheduledTasks.dialog.schedule.weekdayShort.unknown`);if(e.schedule.kind===`daily`)return e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.dailyWithTimezone`,{time:n,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.daily`,{time:n});if(e.schedule.kind===`weekly`){let i=(e.schedule.weekdays??[]).map(r).join(`, `);return e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.weeklyWithTimezone`,{days:i,time:n,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.weekly`,{days:i,time:n})}if(e.schedule.kind===`once`){let n=e.schedule.date?.trim()||t(`sessions.scheduledTasks.dialog.schedule.unknownDate`),r=e.schedule.time?.trim()||`—`;return e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.onceWithTimezone`,{date:n,time:r,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.once`,{date:n,time:r})}return e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.cronWithTimezone`,{cron:e.schedule.cron??``,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.cron`,{cron:e.schedule.cron??``})},is={paused:{icon:`pause`,className:`text-muted-foreground`},idle:{icon:`pulse`,className:`text-muted-foreground`},running:{icon:`loader-4`,className:`text-[var(--status-warning)]`},success:{icon:`checkbox-circle`,className:`text-[var(--status-success)]`},error:{icon:`error-warning`,className:`text-[var(--status-error)]`}},as=e=>`${e.projectId}:${e.task.id}`,os=e=>{let t=(0,qi.c)(30),{assistantID:n}=e,{t:r}=He(),i=it(n),a=i.isError,o=Xe(n,a),s=Ye(a),c=new Set;for(let e of o.data?.messages??[])for(let t of e.cards)t.cardType===`schedule`&&c.add(`${t.projectID}:${t.taskID}`);let l=(i.data?.tasks??[]).flatMap(us),u;t[0]===i.data?.tasks?u=t[1]:(u=i.data?.tasks.some(ds),t[0]=i.data?.tasks,t[1]=u);let d=!!u,f=(s.data?.tasks??[]).filter(e=>c.has(as(e))),p=[...i.data?l:a?f:[]].sort(fs),m=(s.data?.failedProjectIds??[]).some(e=>Array.from(c).some(t=>t.startsWith(`${e}:`))),h=i.isPending||a&&(o.isPending||s.isPending),g=i.isError||o.isError||s.isError||m||d,_;t[2]!==o||t[3]!==a||t[4]!==s||t[5]!==i?(_=()=>{i.refetch(),a&&(o.refetch(),s.refetch())},t[2]=o,t[3]=a,t[4]=s,t[5]=i,t[6]=_):_=t[6];let v=ze(_),y=X,b;t[7]===r?b=t[8]:(b=r(`assistants.settings.scheduledTasks.title`),t[7]=r,t[8]=b);let x;t[9]===r?x=t[10]:(x=r(`assistants.settings.scheduledTasks.title`),t[9]=r,t[10]=x);let S=h&&p.length===0?(0,$.jsx)(Z,{label:r(`common.loading`),children:(0,$.jsx)(Y,{name:`loader-4`,className:`size-4 animate-spin text-muted-foreground`})}):null,C;t[11]===r?C=t[12]:(C=e=>{let t=e.task.enabled?e.task.state?.lastStatus??`idle`:`paused`,n=is[t],i=r(t===`paused`?`sessions.scheduledTasks.dialog.taskToggle.paused`:t===`running`?`sessions.scheduledTasks.dialog.status.running`:t===`success`?`sessions.scheduledTasks.dialog.status.success`:t===`error`?`sessions.scheduledTasks.dialog.status.error`:`sessions.scheduledTasks.dialog.status.idle`);return(0,$.jsxs)(Z,{className:`group relative cursor-pointer transition-colors hover:bg-interactive-hover`,label:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-lg bg-[var(--surface-muted)] text-muted-foreground`,children:(0,$.jsx)(Y,{name:`calendar`,className:`size-3.5`})}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block truncate typography-ui-label font-medium text-foreground`,children:e.task.name}),(0,$.jsx)(`span`,{className:`mt-0.5 block typography-micro truncate text-muted-foreground`,children:rs(e.task,r)})]})]}),controlClassName:`min-w-fit`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 typography-micro ${n.className}`,children:[(0,$.jsx)(Y,{name:n.icon,className:`size-3.5 ${t===`running`?`animate-spin`:``}`}),i]}),(0,$.jsx)(Y,{name:`arrow-right-s`,className:`size-4`})]}),(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute inset-0 z-10 h-auto w-auto rounded-none bg-transparent p-0 hover:bg-transparent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`,onClick:()=>zi(e.projectId,e.task.id),"aria-label":r(`assistants.settings.scheduledTasks.open`,{name:e.task.name}),children:(0,$.jsx)(`span`,{className:`sr-only`,children:r(`assistants.settings.scheduledTasks.open`,{name:e.task.name})})})]},as(e))},t[11]=r,t[12]=C);let w=p.map(C),T;t[13]!==g||t[14]!==v||t[15]!==r?(T=g?(0,$.jsx)(Z,{label:r(`assistants.settings.scheduledTasks.loadError`),children:(0,$.jsx)(K,{variant:`outline`,size:`sm`,onClick:v,children:r(`assistants.actions.retry`)})}):null,t[13]=g,t[14]=v,t[15]=r,t[16]=T):T=t[16];let E;t[17]!==g||t[18]!==h||t[19]!==r||t[20]!==p?(E=!h&&!g&&p.length===0?(0,$.jsx)(Z,{label:r(`assistants.settings.scheduledTasks.empty`),children:(0,$.jsx)(Y,{name:`calendar`,className:`size-4 text-muted-foreground`})}):null,t[17]=g,t[18]=h,t[19]=r,t[20]=p,t[21]=E):E=t[21];let D;return t[22]!==y||t[23]!==b||t[24]!==x||t[25]!==S||t[26]!==w||t[27]!==T||t[28]!==E?(D=(0,$.jsxs)(y,{label:b,ariaLabel:x,children:[S,w,T,E]}),t[22]=y,t[23]=b,t[24]=x,t[25]=S,t[26]=w,t[27]=T,t[28]=E,t[29]=D):D=t[29],D},ss=e=>{let t=(0,qi.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)(Y,{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},cs=e=>{let t=(0,qi.c)(67),{onItemSelect:n}=e,{t:r}=He(),i=at(),a=et(),o=i.data,s=sn(ps),c=sn(ms),l=sn(hs),[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=ze(v);if(a.isSuccess&&!a.data.supported)return null;let b;t[25]===r?b=t[26]:(b=r(`assistants.settings.description`),t[25]=r,t[26]=b);let x;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(x=e=>{e.preventDefault(),d(!0)},t[27]=x):x=t[27];let S;t[28]===r?S=t[29]:(S=r(`assistants.settings.descriptionLearnMore`),t[28]=r,t[29]=S);let C;t[30]===S?C=t[31]:(C=(0,$.jsx)(`a`,{href:`#assistant-share-welcome`,className:`underline underline-offset-2`,onClick:x,children:S}),t[30]=S,t[31]=C);let w;t[32]!==C||t[33]!==b?(w=(0,$.jsxs)(`p`,{className:`yuri-settings-group-description text-muted-foreground`,children:[b,C]}),t[32]=C,t[33]=b,t[34]=w):w=t[34];let T;t[35]===u?T=t[36]:(T=(0,$.jsx)(Sa,{open:u,onOpenChange:d}),t[35]=u,t[36]=T);let E;t[37]!==w||t[38]!==T?(E=(0,$.jsxs)($.Fragment,{children:[w,T]}),t[37]=w,t[38]=T,t[39]=E):E=t[39];let D;t[40]===r?D=t[41]:(D=r(`assistants.settings.listTitle`),t[40]=r,t[41]=D);let O;t[42]===D?O=t[43]:(O=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:D}),t[42]=D,t[43]=O);let k;t[44]===r?k=t[45]:(k=r(`assistants.settings.create`),t[44]=r,t[45]=k);let A;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(Y,{name:`add`,className:`size-4`}),t[46]=A):A=t[46];let j;t[47]!==y||t[48]!==k?(j=(0,$.jsx)(K,{"data-settings-item":`assistants.create`,variant:`ghost`,size:`icon`,onClick:y,"aria-label":k,children:A}),t[47]=y,t[48]=k,t[49]=j):j=t[49];let M;t[50]!==O||t[51]!==j?(M=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[O,j]}),t[50]=O,t[51]=j,t[52]=M):M=t[52];let N;t[53]!==a.isPending||t[54]!==n||t[55]!==c||t[56]!==s||t[57]!==o||t[58]!==i.isPending||t[59]!==r?(N=i.isPending||a.isPending?(0,$.jsxs)(`div`,{className:`yuri-settings-group-row flex items-center justify-center text-muted-foreground`,children:[(0,$.jsx)(Y,{name:`loader-4`,className:`mr-2 size-4 animate-spin`}),r(`common.loading`)]}):o?.assistants.length?o.assistants.map(e=>{let t=Ke(e.name);return(0,$.jsx)(Uo,{title:t.displayName,selected:s===e.id,onSelect:()=>{c(e.id),n?.()},icon:(0,$.jsx)(cn,{kind:`assistant`,name:e.avatarSeed??e.id,size:32,label:t.displayName||e.name,shape:`rounded`,className:`rounded-[0.5rem]`})},e.id)}):(0,$.jsx)(`div`,{className:`yuri-settings-group-row text-muted-foreground`,children:r(`assistants.settings.empty`)}),t[53]=a.isPending,t[54]=n,t[55]=c,t[56]=s,t[57]=o,t[58]=i.isPending,t[59]=r,t[60]=N):N=t[60];let P;t[61]!==M||t[62]!==N?(P=(0,$.jsx)(X,{label:M,children:N}),t[61]=M,t[62]=N,t[63]=P):P=t[63];let F;return t[64]!==E||t[65]!==P?(F=(0,$.jsx)(Go,{variant:`background`,header:E,children:P}),t[64]=E,t[65]=P,t[66]=F):F=t[66],F},ls=({onItemDeleted:e,assistantID:t,saveActionContainer:n})=>{let{t:r}=He(),i=at(),a=et(),o=i.data,s=Lt(e=>e.projects),c=sn(e=>t??e.settingsSelectedAssistantID),l=sn(e=>e.selectSettingsAssistant),u=sn(e=>e.defaultShareAssistant),d=sn(e=>e.setDefaultShareAssistant),f=sn(e=>e.createRequestRevision),p=sn(e=>e.requestCreate),[m,h]=Q.useState(Xo),[g,_]=Q.useState(!1),v=Q.useRef(0),y=o?.assistants.find(e=>e.id===c)??null,b=y?Ke(y.name):null,x=Ke(m.name),S=m.workspacePath??y?.managedWorkspacePath??null,C=qt(S,{enabled:!0}).data??[];Q.useEffect(()=>{y&&h(Zo(y))},[y]),Q.useEffect(()=>{t===void 0&&i.isSuccess&&c&&c!==`new`&&!y&&l(null)},[t,l,y,c,i.isSuccess]),Q.useEffect(()=>{c!==`new`||f<=v.current||(v.current=f,h(Xo(o?.assistants.length?``:Jo)),window.requestAnimationFrame(()=>document.getElementById(`assistant-name`)?.focus()))},[f,c,o?.assistants.length]),Q.useEffect(()=>{i.isSuccess&&a.data?.serverInstanceID&&u?.serverInstanceID===a.data.serverInstanceID&&!o?.assistants.some(e=>e.id===u.assistantID)&&d(null)},[a.data,u,d,o?.assistants,i.isSuccess]),Q.useEffect(()=>{i.isSuccess&&qe()},[o?.revision,i.isSuccess]);let w=(e,t)=>{h(n=>({...n,[e]:t}))},T=ze(()=>p()),E=ze(async()=>{if(!(t!==void 0&&!y)){if(!m.name.trim()||!m.providerID||!m.modelID){Ie.error(r(`assistants.settings.validation.required`));return}_(!0);try{let e=y?await tt(y,Qo(m)):await Ze(m);t===void 0&&l(e.id),Ie.success(r(`assistants.settings.toast.saved`))}catch{Ie.error(r(`assistants.settings.toast.saveFailed`))}finally{_(!1)}}}),D=ze(async()=>{if(!(!y||!window.confirm(r(`assistants.settings.deleteConfirm`,{name:y.name})))){_(!0);try{if(await nt(y),u?.assistantID===y.id){let e=await Qe();e.serverInstanceID&&u.serverInstanceID===e.serverInstanceID&&d(null)}t===void 0&&l(null),e?.(),Ie.success(r(`assistants.settings.toast.deleted`))}catch{Ie.error(r(`assistants.settings.toast.deleteFailed`))}finally{_(!1)}}}),O=ze(async(e,t)=>{if(!t){d(null),Je();return}try{let t=await Qe();if(!t.supported||!t.serverInstanceID)return;d({serverInstanceID:t.serverInstanceID,assistantID:e}),await Je()}catch{Ie.error(r(`assistants.settings.toast.toggleFailed`))}}),k=m.workspacePath===null?null:s.find(e=>e.path===m.workspacePath)??null,A=m.workspacePath!==null&&!k?m.workspacePath:null,j=m.workspacePath===null?Ko:k?k.id:qo,M=m.workspacePath===null?(0,$.jsx)(ss,{name:r(`assistants.settings.workspacePlaceholder`),icon:`cloud`}):k?(0,$.jsx)(ss,{name:$o(k),path:k.path}):(0,$.jsx)(ss,{name:r(`assistants.settings.workspaceCurrentPath`),path:A??``,icon:`history`});return a.isSuccess&&!a.data.supported?null:i.isPending||a.isPending?(0,$.jsxs)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:[(0,$.jsx)(Y,{name:`loader-4`,className:`mr-2 size-4 animate-spin`}),r(`common.loading`)]}):i.isError&&!o||t!==void 0&&!y?(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center`,children:[(0,$.jsx)(Y,{name:`cloud-off`,className:`size-6 text-muted-foreground`}),(0,$.jsx)(`p`,{className:`typography-ui text-muted-foreground`,children:r(`assistants.state.unavailable`)}),(0,$.jsx)(K,{variant:`outline`,size:`sm`,onClick:()=>void i.refetch(),children:r(`assistants.actions.retry`)})]}):(0,$.jsx)(Rr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[i.isError&&o?(0,$.jsx)(`p`,{className:`mb-4 px-2 typography-meta text-[var(--status-warning)]`,children:r(`assistants.state.staleSnapshot`)}):null,c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Xr,{actions:(0,$.jsxs)($.Fragment,{children:[y?(0,$.jsx)(K,{variant:`ghost`,size:`icon`,onClick:D,disabled:g,className:`text-[var(--status-error)]`,"aria-label":r(`assistants.settings.delete`),title:r(`assistants.settings.delete`),children:(0,$.jsx)(Y,{name:`delete-bin`,className:`size-4`})}):null,n?null:(0,$.jsxs)(K,{size:`sm`,onClick:E,disabled:g,"aria-busy":g,children:[g?(0,$.jsx)(Y,{name:`loader-4`,className:`size-4 animate-spin`}):null,r(`assistants.settings.save`)]})]}),children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,$.jsxs)(`div`,{className:`group/avatar relative shrink-0`,children:[(0,$.jsx)(cn,{kind:`assistant`,name:m.avatarSeed??y?.id??`new`,size:40,label:x.displayName||m.name||r(`assistants.settings.create`),shape:`rounded`,className:`rounded-[0.5rem]`}),(0,$.jsx)(K,{variant:`link`,size:`icon`,disabled:g,className:`absolute inset-0 h-full w-full p-0 text-muted-foreground opacity-0 transition-opacity hover:no-underline group-hover/avatar:opacity-100 group-focus-within/avatar:opacity-100 [@media(hover:none)]:opacity-100`,"aria-label":r(`assistants.settings.randomAvatar`),title:r(`assistants.settings.randomAvatar`),onClick:()=>w(`avatarSeed`,crypto.randomUUID()),children:(0,$.jsx)(`span`,{className:`absolute -right-1 -bottom-1 flex size-5 items-center justify-center rounded-full bg-[var(--yuri-settings-avatar-action-background)] text-[var(--yuri-settings-avatar-action-foreground)] shadow-sm`,children:(0,$.jsx)(Y,{name:`refresh`,className:`size-3.5`})})})]}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h2`,{className:`truncate typography-ui-header font-semibold text-foreground`,children:y?b?.displayName:r(`assistants.settings.create`)}),m.providerID&&m.modelID?(0,$.jsx)(`p`,{className:`mt-0.5 truncate typography-micro leading-none text-muted-foreground/70`,children:`${m.providerID}/${m.modelID}`}):null]})]})}),(0,$.jsxs)(X,{children:[(0,$.jsx)(Z,{itemId:`assistants.name`,label:r(`assistants.settings.name`),children:(0,$.jsx)(En,{id:`assistant-name`,value:m.name,onChange:e=>w(`name`,e.target.value),className:`min-w-0 flex-1`})}),(0,$.jsx)(Z,{label:r(`assistants.settings.enabled`),children:(0,$.jsx)(gn,{checked:m.enabled,onChange:e=>w(`enabled`,e),ariaLabel:r(`assistants.settings.enabled`)})}),y?(0,$.jsx)(Z,{itemId:`assistants.default-share`,label:r(`assistants.settings.defaultShare`),children:(0,$.jsx)(gn,{checked:u?.assistantID===y.id&&u.serverInstanceID===a.data?.serverInstanceID,onChange:e=>void O(y.id,e),ariaLabel:r(`assistants.settings.defaultShare`)})}):null]}),(0,$.jsx)(di,{itemId:`assistants.prompt`,label:r(`assistants.settings.defaultPrompt`),className:`yuri-settings-split-row-stacked`,children:(0,$.jsx)(zr,{embedded:!0,id:`assistant-prompt`,value:m.defaultPrompt,onChange:e=>w(`defaultPrompt`,e.target.value),placeholder:r(`assistants.settings.defaultPromptPlaceholder`),rows:12,outerClassName:`min-h-[240px] max-h-[70vh]`})}),(0,$.jsx)(X,{label:r(`assistants.settings.runtime`),children:(0,$.jsx)(Z,{itemId:`assistants.model`,label:r(`assistants.settings.model`),children:(0,$.jsx)(Vn,{providerId:m.providerID,modelId:m.modelID,variant:m.variant??``,providers:C,onChange:(e,t,n)=>h(r=>({...r,providerID:e,modelID:t,variant:n||null})),className:`yuri-settings-inline-value`})})}),(0,$.jsx)(di,{itemId:`assistants.workspace`,label:r(`assistants.settings.workspace`),description:r(`assistants.settings.workspaceChangeHint`),descriptionPlacement:`outside`,children:(0,$.jsxs)(Cn,{value:j,onValueChange:e=>{if(e===Ko){w(`workspacePath`,null);return}let t=s.find(t=>t.id===e);t&&w(`workspacePath`,t.path)},children:[(0,$.jsx)(bn,{title:m.workspacePath??r(`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)(Tn,{children:M})}),(0,$.jsxs)(xn,{align:`start`,className:`w-[min(32rem,calc(100vw-2rem))]`,children:[(0,$.jsx)(vn,{value:Ko,children:(0,$.jsx)(ss,{name:r(`assistants.settings.workspacePlaceholder`),icon:`cloud`})}),s.map(e=>(0,$.jsx)(vn,{value:e.id,children:(0,$.jsx)(ss,{name:$o(e),path:e.path})},e.id)),A?(0,$.jsx)(vn,{value:qo,disabled:!0,children:(0,$.jsx)(ss,{name:r(`assistants.settings.workspaceCurrentPath`),path:A,icon:`history`})}):null]})]})}),y?(0,$.jsx)(os,{assistantID:y.id}):null,n?(0,Ji.createPortal)((0,$.jsx)(K,{type:`button`,size:`mobileIcon`,onClick:E,disabled:g,"aria-label":r(`assistants.settings.save`),"aria-busy":g,children:(0,$.jsx)(Y,{name:g?`loader-4`:`check`,className:g?`size-5 animate-spin motion-reduce:animate-none`:`size-5`})}),n):null]}):(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)(cn,{kind:`assistant`,name:`assistants-empty`,size:44,shape:`rounded`,className:`rounded-[0.5rem]`}),(0,$.jsx)(`p`,{className:`typography-ui`,children:r(`assistants.settings.empty`)}),(0,$.jsxs)(K,{"data-settings-item":`assistants.create`,size:`sm`,onClick:T,children:[(0,$.jsx)(Y,{name:`add`,className:`size-4`}),r(`assistants.settings.create`)]})]})]})})};function us(e){return ns(e.task)?[{projectId:e.projectID,task:e.task}]:[]}function ds(e){return!ns(e.task)}function fs(e,t){return e.task.enabled===t.task.enabled?e.task.name.localeCompare(t.task.name):e.task.enabled?-1:1}function ps(e){return e.settingsSelectedAssistantID}function ms(e){return e.selectSettingsAssistant}function hs(e){return e.requestCreate}var gs=`~/.config/opencode/AGENTS.md`,_s=async(e,t)=>{let n=await e.json().catch(()=>null);return typeof n?.error==`string`&&n.error.trim()?n.error:t},vs=e=>e.length>0&&!e.endsWith(`
|
|
1
|
+
import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{E as n}from"./runtime-auth-ef9W7A43.js";import{c as r,i,l as a,n as o,r as s,t as c}from"./runtime-switch-CAZiOV2G.js";import{a as l,i as u,o as d,s as f,u as p}from"./queryRuntime-DKGLQtb9.js";import{$t as m,D as h,E as g,Gt as _,Ht as v,Kt as y,L as b,Tn as x,Wt as S,Xt as C,Zt as w,bn as T,en as E,hn as D,i as O,in as k,o as A,pn as j,qt as M,rn as N,s as P,tn as F,tt as I,u as L,xn as R,yn as z}from"./persistence-Dzooc9Xg.js";import{_ as B,a as V,d as ee,g as H,h as te,i as ne,m as U,n as re,r as ie,t as ae,u as oe}from"./desktopHosts-DW8THEMC.js";import{n as se}from"./desktopRelayRestore-BFn1FsR3.js";import{a as ce,i as le,r as ue,t as de}from"./vendor-zustand-o69pgTEK.js";import{it as fe,nt as pe,rt as me}from"./vendor-base-ui-CdzJ6My_.js";import{Ct as he,Ln as ge,Nt as _e,n as ve,t as ye}from"./platform-7bX6qtBV.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{b as be,d as xe,i as Se,n as W,o as Ce,s as we}from"./useUIStore-NMQx_cnG.js";import{n as Te}from"./vendor-react-BP2cRVqX.js";import{l as Ee,n as De,o as Oe,s as ke}from"./vendor-tanstack-react-query-CdqCAt40.js";import{A as Ae}from"./runtime-file-resource-C1k5nbWb.js";import{a as je,i as Me,n as Ne}from"./types-2CUEL3Ja.js";import{t as Pe}from"./native-config-BDst1Okm.js";import{H as Fe}from"./vendor-codemirror-autocomplete-7c2L_4dM.js";import{r as Ie}from"./vendor-sonner-ZS8XIOVl.js";import{a as Le,c as Re,n as ze,r as Be}from"./vendor-reactuses-core-BpfIZ1tg.js";import{d as Ve,f as He,n as Ue,o as We,p as Ge,r as G,t as K}from"./button-LPikURUk.js";import{a as Ke,i as qe,r as Je}from"./MobileShareBridge-CijqYDMo.js";import{S as Ye,_ as Xe,a as Ze,c as Qe,f as $e,g as et,h as tt,o as nt,t as rt,v as it,y as at}from"./MobileDetailNavigation-RLH6AQBN.js";import{$a as ot,Ai as st,Ba as ct,Ci as lt,Da as ut,Ga as dt,Gn as ft,Gt as pt,Ha as mt,Ja as ht,Ka as gt,Oa as _t,Pr as vt,Qa as yt,Rr as q,Ta as bt,Ti as xt,Ua as St,Va as Ct,Wa as wt,Wn as Tt,Xa as Et,Ya as Dt,Za as Ot,_a as kt,_o as At,ao as jt,bi as Mt,co as Nt,d as Pt,do as Ft,eo as It,fo as Lt,go as Rt,ha as J,ho as zt,io as Bt,jr as Vt,ka as Ht,lo as Ut,ma as Wt,no as Gt,o as Kt,oo as qt,pa as Jt,qa as Yt,ro as Xt,so as Zt,to as Qt,uo as $t,va as en,wa as tn,wi as nn,wr as rn,ya as an,yo as on}from"./useMobileNavigationStore-K23K6qFK.js";import{i as sn}from"./useAssistantUIStore-D7JZlg_Q.js";import{t as cn}from"./AgentAvatar-C2p8G_Xw.js";import{n as ln}from"./useThemeSystem-8jhE4Zyk.js";import{n as Y}from"./Icon-DKFfVCeK.js";import{a as un,i as dn,n as fn,o as pn,r as mn,t as hn}from"./dialog-D8AYQa70.js";import{A as gn,T as _n,_ as vn,a as yn,b as bn,h as xn,i as Sn,m as Cn,n as wn,x as Tn}from"./projectMeta-C75m7wMM.js";import{t as En}from"./input-CAhwlkOT.js";import{i as Dn,n as On,t as kn}from"./tooltip-CFuO3PUH.js";import{$t as An,A as jn,At as Mn,B as Nn,Bt as Pn,Ct as Fn,D as In,F as Ln,Ft as Rn,H as zn,It as Bn,J as Vn,K as Hn,L as Un,Lt as Wn,Mt as Gn,N as Kn,Nt as qn,O as Jn,Pt as Yn,R as Xn,Rt as Zn,St as Qn,Ut as $n,V as er,Vt as tr,Xt as nr,Zt as rr,an as ir,at as ar,bt as or,c as sr,ct as cr,dt as lr,en as ur,f as dr,gt as fr,ht as pr,in as mr,it as hr,j as gr,jt as _r,kt as vr,mt as yr,nn as br,o as xr,r as Sr,rt as Cr,s as wr,st as Tr,t as Er,tn as Dr,tt as Or,ut as kr,xt as Ar,z as jr,zt as Mr}from"./speechSettingsQueries-BWIoMe5c.js";import{t as Nr}from"./YuriLogo-CgTkNYZf.js";import{i as Pr,r as Fr}from"./OverlayScrollbar-Dxdkid6A.js";import{a as Ir,o as Lr}from"./dropdown-menu.styles-BXRbrWW5.js";import{n as Rr,t as zr}from"./textarea-pQCq-iLS.js";import{M as Br,k as Vr,n as Hr}from"./appThemeRegistry-DmRKfJL3.js";import{n as Ur}from"./MarkdownRenderer-kDYymiH3.js";import{a as Wr}from"./url-Be8VCT8M.js";import{l as Gr}from"./markdown-worker-7FvUo2nm.js";import{t as Kr}from"./sortable-tabs-strip-CQR5TsUS.js";import{B as qr,C as Jr,D as Yr,F as Xr,I as Zr,L as Qr,M as X,N as Z,P as $r,R as ei,S as ti,T as ni,V as ri,_ as ii,a as ai,b as oi,c as si,d as ci,f as li,g as ui,j as di,l as fi,m as pi,o as mi,p as hi,r as gi,s as _i,t as vi,v as yi,w as bi,x as xi,y as Si,z as Ci}from"./MobileTabPageHeader-BZKymEeY.js";import{a as wi,c as Ti,i as Ei,l as Di,o as Oi,r as ki,s as Ai}from"./mcpQueries-BFkB-7V_.js";import{a as ji,d as Mi,f as Ni,l as Pi,m as Fi,o as Ii,p as Li,s as Ri,t as zi}from"./scheduledTaskNavigation-BE3Okq7X.js";import{n as Bi}from"./mobileBackNavigation-BwxOTY4b.js";import{n as Vi,r as Hi,t as Ui}from"./collapsible-CbQmi7qt.js";import{n as Wi,t as Gi}from"./vendor-yaml-C9KlJAlj.js";import{t as Ki}from"./vendor-qrcode-D7jBCyl-.js";var qi=Te(),Ji=t(pe(),1),Q=t(fe(),1),$=me(),Yi=`https://github.com/yee94/yuri`,Xi=`${Yi}/issues/new`,Zi=800,Qi={"manual-global":`settings.yuri.about.opencodeManagement.manual-global`,"manual-external":`settings.yuri.about.opencodeManagement.manual-external`,bundled:`settings.yuri.about.opencodeManagement.bundled`,"in-app":`settings.yuri.about.opencodeManagement.in-app`,none:`settings.yuri.about.opencodeManagement.none`},$i=e=>typeof e==`string`&&e.trim()?e.trim():null,ea=(e,t,n)=>({queryKey:[t,`about`,n,e],queryFn:async({signal:r})=>{if(t!==i()||n!==o())throw Error(`Stale About runtime`);let a=await p(e,{method:`GET`,headers:{Accept:`application/json`},signal:r});if(!a.ok)throw Error(`About snapshot: ${a.status}`);let s=await a.json();if(!s||typeof s!=`object`||Array.isArray(s))throw Error(`Invalid About snapshot`);if(r.aborted||t!==i()||n!==o())throw Error(`Stale About runtime`);return s},retry:!1,staleTime:3e4}),ta=({initialUpdateDialogOpen:e=!1})=>{let{t}=He(),[n,a]=Q.useState(e),[s,c]=Q.useState(!1),[l,u]=Q.useState(!1),[d,f]=Q.useState(null),[p,m]=Q.useState(null),h=Q.useSyncExternalStore(r,i,i),g=Q.useSyncExternalStore(r,o,o),_=ke(ea(`/api/system/info`,h,g)),y=ke(ea(`/api/opencode/upgrade-status`,h,g)),b=$i(_.data?.yuriVersion),x=y.data,S=$i(x?.serveVersion)??$i(x?.currentVersion),C=$i(x?.management),w=C&&Object.hasOwn(Qi,C)?Qi[C]:null,T=x?.canManage===!1&&w?t(w):null,E=S&&T?t(`settings.yuri.about.opencodeVersionWithManagement`,{version:S,management:T}):S,D=x?.canManage===!1?C===`manual-global`?t(`settings.yuri.about.opencodeGuidance.manualGlobal`):C===`manual-external`?t(`settings.yuri.about.opencodeGuidance.manualExternal`):C===`bundled`?t(`settings.yuri.about.opencodeGuidance.bundled`):null:null,O=Qr(de(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}))),k=W(e=>e.otaChannelOverride),A=W(e=>e.setOtaChannelOverride),j=ve(),[M,N]=Q.useState(`stable`);Q.useEffect(()=>{F()&&v().then(e=>N(e?.includes(`-`)?`beta`:`stable`))},[]);let P=ke({queryKey:[`native-update-config`],queryFn:Pe,enabled:j,staleTime:1/0,retry:!1}),I=P.data?.channel,L=k===`beta`||k===null&&(F()?M:I)===`beta`,[R,z]=Q.useState(!1),[B,V]=Q.useState(()=>xt()),ee=ze(e=>{st(e),V(e)}),H=ze(async e=>{if(e){A(`beta`),await Qr.getState().checkForUpdates();return}A(`stable`),await Qr.getState().checkForUpdates();let{info:t,otaDecision:n}=Qr.getState();t?.isChannelRollback===!0&&n?.primaryAction===`apply_ota`&&c(!0)}),te=ze(()=>{c(!1),A(`beta`),Qr.getState().checkForUpdates()}),ne=ze(()=>{c(!1),a(!0),Qr.getState().downloadUpdate()}),U=ze(e=>{e||te()}),re=d||t(`settings.yuri.about.state.unknown`),ie=ze(async()=>{if(!R){z(!0);try{let{outcome:e,eventCount:n}=await nn();if(e===`cancelled`)return;if(e===`failed`){q.error(t(`settings.yuri.about.diagnostics.toast.failed`));return}q.success(t(n>0?`settings.yuri.about.diagnostics.toast.exported`:`settings.yuri.about.diagnostics.toast.empty`))}catch{q.error(t(`settings.yuri.about.diagnostics.toast.failed`))}finally{z(!1)}}});Q.useEffect(()=>{let e=!1;return je().then(t=>{e||f(t)}),Me().then(t=>{e||m(t)}),()=>{e=!0}},[]);let ae=Ne(d,p)??re,oe=Q.useRef(!1);Q.useEffect(()=>{if(O.checking)u(!0),oe.current=!0;else if(l){let e=setTimeout(()=>{u(!1),oe.current&&O.error?(q.error(t(`settings.yuri.about.toast.checkFailed`),{description:O.error}),oe.current=!1):oe.current&&!O.available&&!O.error&&(q.success(t(`settings.yuri.about.toast.latestVersion`)),oe.current=!1)},Zi);return()=>clearTimeout(e)}},[t,O.checking,l,O.available,O.error]);let se=O.checking||l;return(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack w-full`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,$.jsx)(Nr,{width:72,height:72}),(0,$.jsx)(`h2`,{className:`mt-4 typography-ui-header font-semibold text-foreground`,children:`Yuri`})]}),(0,$.jsxs)(X,{className:`yuri-settings-about`,children:[(0,$.jsx)(Z,{label:t(`settings.yuri.about.field.clientVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:ae})}),(0,$.jsx)(Z,{label:t(`settings.yuri.about.field.instanceYuriVersion`),children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:b||t(`settings.yuri.about.state.unknown`)})}),(0,$.jsx)(Z,{label:t(`settings.yuri.about.field.instanceOpenCodeVersion`),description:D,children:(0,$.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:E||t(`settings.yuri.about.state.unknown`)})}),(0,$.jsx)(Z,{className:`yuri-settings-split-row-stacked`,copyClassName:`hidden`,children:(0,$.jsxs)(`div`,{className:`flex w-full flex-wrap items-center justify-end gap-2`,children:[(0,$.jsx)(K,{asChild:!0,variant:`outline`,size:`sm`,className:`whitespace-nowrap`,"data-settings-item":`about.feedback`,children:(0,$.jsxs)(`a`,{href:Xi,target:`_blank`,rel:`noopener noreferrer`,children:[(0,$.jsx)(Y,{name:`question`,className:`size-4`}),t(`settings.yuri.about.actions.submitFeedback`)]})}),!se&&O.available?(0,$.jsxs)(K,{type:`button`,variant:`default`,size:`sm`,className:`whitespace-nowrap`,onClick:()=>a(!0),"data-settings-item":`about.check-updates`,children:[(0,$.jsx)(Y,{name:`download`,className:`size-4`}),O.info?.inAppApply?t(`settings.yuri.about.actions.applyOtaToVersion`,{version:O.info?.version||``}):O.info?.manualUpdate?t(`settings.yuri.about.actions.installNativeToVersion`,{version:O.info?.version||``}):t(`settings.yuri.about.actions.updateToVersion`,{version:O.info?.version||``})]}):(0,$.jsxs)(K,{type:`button`,variant:`outline`,size:`sm`,className:`whitespace-nowrap`,onClick:()=>O.checkForUpdates(),"data-settings-item":`about.check-updates`,disabled:se,children:[se?(0,$.jsx)(Y,{name:`loader`,className:`size-4 animate-spin`}):(0,$.jsx)(Y,{name:`refresh`,className:`size-4`}),t(se?`settings.yuri.about.state.checking`:`settings.yuri.about.actions.checkForUpdates`)]})]})}),O.error&&(0,$.jsx)(Z,{children:(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:O.error})}),(j||F())&&(0,$.jsx)($r,{itemId:`about.beta-updates`,checked:L,onChange:H,label:t(`settings.yuri.about.betaUpdates.label`),description:t(`settings.yuri.about.betaUpdates.description`),ariaLabel:t(`settings.yuri.about.betaUpdates.label`),disabled:se||j&&!P.data}),(0,$.jsx)($r,{itemId:`about.diagnostics`,checked:B,onChange:ee,label:t(`settings.yuri.about.diagnostics.label`),ariaLabel:t(`settings.yuri.about.diagnostics.label`)}),B&&(0,$.jsx)(Z,{itemId:`about.export-diagnostics`,label:t(`settings.yuri.about.diagnostics.export`),children:(0,$.jsx)(K,{type:`button`,variant:`outline`,size:`sm`,disabled:R,onClick:()=>void ie(),children:t(R?`settings.yuri.about.diagnostics.exporting`:`settings.yuri.about.diagnostics.export`)})})]}),(0,$.jsx)(`div`,{className:`flex flex-col items-center gap-3 text-center`,children:(0,$.jsx)(`div`,{className:`flex items-center justify-center gap-5`,children:(0,$.jsxs)(`a`,{href:Yi,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)(Y,{name:`github-fill`,className:`size-5`}),(0,$.jsx)(`span`,{children:`GitHub`})]})})}),(0,$.jsx)(`p`,{className:`text-center typography-ui text-muted-foreground/60`,children:t(`aboutDialog.footerNote`)}),(0,$.jsx)(Zr,{open:n,onOpenChange:a,info:O.info,downloading:O.downloading,downloaded:O.downloaded,progress:O.progress,error:O.error,onDownload:O.downloadUpdate,onRestart:O.restartToUpdate,runtimeType:O.runtimeType}),(0,$.jsx)(hn,{open:s,onOpenChange:U,children:(0,$.jsxs)(fn,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[(0,$.jsxs)(un,{children:[(0,$.jsx)(pn,{children:t(`settings.yuri.about.betaUpdates.rollback.title`)}),(0,$.jsx)(mn,{children:t(`settings.yuri.about.betaUpdates.rollback.description`,{version:O.info?.version||``})})]}),(0,$.jsxs)(dn,{children:[(0,$.jsx)(K,{type:`button`,size:`sm`,variant:`ghost`,onClick:te,children:t(`settings.yuri.about.betaUpdates.rollback.actions.cancel`)}),(0,$.jsx)(K,{type:`button`,size:`sm`,onClick:ne,children:t(`settings.yuri.about.betaUpdates.rollback.actions.confirm`)})]})]})})]})},na=16384,ra=globalThis,ia=e=>{if(ra.Buffer)return ra.Buffer.from(e,`utf8`).toString(`base64url`);let t=new TextEncoder().encode(e),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.slice(e,e+32768));return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)},aa=e=>{try{if(ra.Buffer)return ra.Buffer.from(e,`base64url`).toString(`utf8`);let t=e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(Math.ceil(e.length/4)*4,`=`),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e+=1)r[e]=n.charCodeAt(e);return new TextDecoder().decode(r)}catch{return null}},oa=e=>{if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;try{let e=new URL(t);return e.protocol!==`http:`&&e.protocol!==`https:`?null:(e.hash=``,e.toString().replace(/\/+$/g,``))}catch{return null}},sa=e=>{if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;try{let e=new URL(t);return e.protocol!==`ws:`&&e.protocol!==`wss:`||e.username||e.password?null:(e.username=``,e.password=``,e.hash=``,e.search=``,e.toString())}catch{return null}},ca=e=>typeof e==`string`&&e.length>0,la=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;return t.kty!==`EC`||t.crv!==`P-256`||!ca(t.x)||!ca(t.y)?null:{kty:`EC`,crv:`P-256`,x:t.x,y:t.y}},ua=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0,da=e=>{if(!e||typeof e!=`object`)return null;let t=e,n=ua(t.priority);if(t.type===`lan`||t.type===`tunnel`){let e=oa(t.url);return e?n===void 0?{type:t.type,url:e}:{type:t.type,url:e,priority:n}:null}if(t.type===`relay`){let e=sa(t.relayUrl);if(!e)return null;let r=typeof t.serverId==`string`?t.serverId.trim():``;if(!r)return null;let i=la(t.hostEncPubJwk);if(!i)return null;let a=typeof t.grant==`string`&&t.grant.trim()?t.grant.trim():void 0;return{type:`relay`,relayUrl:e,serverId:r,hostEncPubJwk:i,...a?{grant:a}:{},...n===void 0?{}:{priority:n}}}return null},fa=e=>{if(!e||typeof e!=`object`)return null;let t=e;if(t.v!==2)return null;let n=typeof t.pairingId==`string`?t.pairingId.trim():``,r=typeof t.secret==`string`?t.secret.trim():``;if(!n||!r)return null;let i=Array.isArray(t.candidates)?t.candidates.map(da).filter(e=>!!e):[];if(i.length===0)return null;let a=typeof t.expiresAt==`string`&&t.expiresAt.trim()?t.expiresAt.trim():void 0;if(a){let e=Date.parse(a);if(!Number.isFinite(e)||e<=Date.now())return null}let o=typeof t.label==`string`&&t.label.trim()?t.label.trim():void 0,s=typeof t.fingerprint==`string`&&t.fingerprint.trim()?t.fingerprint.trim():void 0;return{v:2,pairingId:n,secret:r,...o?{label:o}:{},...s?{fingerprint:s}:{},...a?{expiresAt:a}:{},candidates:i}},pa=e=>({v:2,pairingId:e.pairingId.trim(),secret:e.secret.trim(),...e.label?.trim()?{label:e.label.trim()}:{},...e.fingerprint?.trim()?{fingerprint:e.fingerprint.trim()}:{},...e.expiresAt?.trim()?{expiresAt:e.expiresAt.trim()}:{},candidates:e.candidates}),ma=e=>{let t=fa(e);if(!t)throw Error(`Invalid pairing connection payload`);let n=new URLSearchParams;return n.set(`v`,`2`),n.set(`p`,ia(JSON.stringify(t))),`yuri://connect?${n.toString()}`},ha=e=>{let t=e.trim();if(!t||t.length>na)return null;let n=t.indexOf(`?`);if(n===-1||!/^(?:yuri|openchamber|openchambery):\/\/connect\/?$/i.test(t.slice(0,n)))return null;let r=null,i=null;for(let e of t.slice(n+1).split(`&`)){let t=e.indexOf(`=`);if(t===-1)continue;let n=e.slice(0,t),a=e.slice(t+1);n===`v`?r=a:n===`p`&&(i=a)}if(r!==`2`||!i||i.length>na)return null;let a=aa(i);if(!a||a.length>na)return null;try{return fa(JSON.parse(a))}catch{return null}},ga=e=>{let t=e.trim();if(!t||t.length>na)return null;try{let e=new URL(t);if([`yuri:`,`openchamber:`,`openchambery:`].includes(e.protocol)&&e.hostname===`connect`){if(e.searchParams.get(`v`)!==`2`)return null;let t=e.searchParams.get(`p`)||``;if(!t||t.length>na)return null;let n=aa(t);return!n||n.length>na?null:fa(JSON.parse(n))}}catch{}return ha(t)},_a=`/assets/android-direct-share-1a0lp154.jpg`,va=`/assets/ios-share-sheet-B3Dlufnc.jpg`,ya=`/assets/select-assistant-C89IRspC.jpg`,ba=`yuri:assistant-share-welcome:v1`,xa=[{image:va,titleKey:`assistants.shareWelcome.example.chat.title`,descriptionKey:`assistants.shareWelcome.example.chat.description`},{image:_a,titleKey:`assistants.shareWelcome.example.article.title`,descriptionKey:`assistants.shareWelcome.example.article.description`},{image:ya,titleKey:`assistants.shareWelcome.example.note.title`,descriptionKey:`assistants.shareWelcome.example.note.description`}],Sa=e=>{let t=(0,qi.c)(40),{enabled:n,open:r,onOpenChange:i}=e,a=n!==void 0&&n,{t:o}=He(),[s,c]=Re(ba,!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=ze(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)(Y,{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)(pn,{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)(mn,{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)(un,{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=xa.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)(Y,{name:`arrow-right-s`,className:`size-4`}),t[28]=w):w=t[28];let T;t[29]!==f||t[30]!==C?(T=(0,$.jsx)(dn,{className:`border-t border-border px-5 py-4 sm:px-8 sm:py-5`,children:(0,$.jsxs)(K,{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)(fn,{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)(hn,{open:u,onOpenChange:p,children:E}),t[36]=u,t[37]=E,t[38]=p,t[39]=D):D=t[39],D},Ca=`useCommandsStore`,wa=new Set([`init`,`review`]),Ta=e=>wa.has(e.name),Ea=async(e,t)=>{await Ut(l,e,t),i()===t&&zt(`commands`,{source:Ca})},Da=ce()(ue(le(e=>({selectedCommandName:null,commandDraft:null,setSelectedCommand:t=>e({selectedCommandName:t}),setCommandDraft:t=>e({commandDraft:t}),loadCommands:async()=>{let e=$t(),t=i();try{return await Ut(l,e,t),!0}catch{return!1}},createCommand:async t=>Oa(`POST`,t.name,t,e),updateCommand:async(t,n)=>Oa(`PATCH`,t,n,e),deleteCommand:async t=>Oa(`DELETE`,t,void 0,e),getCommandByName:e=>Nt().find(t=>t.name===e)}),{name:`commands-store`,storage:be(),partialize:e=>({selectedCommandName:e.selectedCommandName})}),{name:`commands-store`}));async function Oa(e,t,n,r){let a=$t(),o=i();try{let s={};if(e===`POST`&&(s.template=n?.template||``,n?.description&&(s.description=n.description),n?.agent&&(s.agent=n.agent),n?.model&&(s.model=n.model),n?.scope&&(s.scope=n.scope)),e===`PATCH`)for(let e of[`description`,`agent`,`model`,`template`])n?.[e]!==void 0&&(s[e]=n[e]);let c=a?`?directory=${encodeURIComponent(a)}`:``,l=await p(`/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(s)}}),u=await l.json().catch(()=>null);if(!l.ok)throw Error(u?.error||`Failed to ${e.toLowerCase()} command`);return i()!==o||(await Ea(a,o),i()!==o)||e===`DELETE`&&r({selectedCommandName:null}),!0}catch(e){return console.error(`[CommandsStore] Command mutation failed:`,e),!1}}typeof window<`u`&&(window.__zustand_commands_store__=Da),At(e=>{e.source!==Ca&&Rt(e,`commands`)&&Da.getState().loadCommands()});var ka=()=>{try{let e=Lt.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},Aa=e=>e?Object.entries(e).map(([e,t])=>({key:e,value:t})):[],ja=e=>{let t=e.filter(e=>e.key.trim());if(t.length!==0)return Object.fromEntries(t.map(e=>[e.key.trim(),e.value]))},Ma=e=>{if(typeof e==`string`)return e.trim()||void 0},Na=ce()(ue(le((e,t)=>({selectedMcpName:null,mcpDraft:null,setSelectedMcp:t=>e({selectedMcpName:t}),setMcpDraft:t=>e({mcpDraft:t}),loadMcpConfigs:async e=>{let t=ka();try{return!e?.force&&ki(l,t).length>0||await wi(l,t,i()),!0}catch(e){return console.error(`[McpConfigStore] Failed to load MCP configs:`,e),!1}},createMcp:async(e,t)=>{let n=`directory`in(t??{})?t?.directory?.trim()||null:ka(),r=t?.transportIdentity??i();try{let t=Pa(e),a=n?`?directory=${encodeURIComponent(n)}`:``,o=await p(`/api/config/mcp/${encodeURIComponent(e.name)}${a}`,{method:`POST`,headers:{"Content-Type":`application/json`,...n?{"x-opencode-directory":n}:{}},body:JSON.stringify(t)}),s=await o.json().catch(()=>null);if(!o.ok)throw Error(s?.error||`Failed to create MCP server`);return i()===r?(await wi(l,n,r),await Oi(l,n,r),{ok:!0,reloadFailed:s?.reloadFailed===!0,message:s?.message,warning:s?.warning}):{ok:!0}}catch(e){return console.error(`[McpConfigStore] Failed to create MCP:`,e),{ok:!1}}},updateMcp:async(e,t,n)=>{let r=`directory`in(n??{})?n?.directory?.trim()||null:ka(),a=n?.transportIdentity??i();try{let n=Pa(t),o=r?`?directory=${encodeURIComponent(r)}`:``,s=await p(`/api/config/mcp/${encodeURIComponent(e)}${o}`,{method:`PATCH`,headers:{"Content-Type":`application/json`,...r?{"x-opencode-directory":r}:{}},body:JSON.stringify(n)}),c=await s.json().catch(()=>null);if(!s.ok)throw Error(c?.error||`Failed to update MCP server`);return i()===a?(await wi(l,r,a),await Oi(l,r,a),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}):{ok:!0}}catch(e){throw console.error(`[McpConfigStore] Failed to update MCP:`,e),e}},deleteMcp:async(n,r)=>{let a=`directory`in(r??{})?r?.directory?.trim()||null:ka(),o=r?.transportIdentity??i();try{let r=a?`?directory=${encodeURIComponent(a)}`:``,s=await p(`/api/config/mcp/${encodeURIComponent(n)}${r}`,{method:`DELETE`,headers:a?{"x-opencode-directory":a}:void 0}),c=await s.json().catch(()=>null);if(!s.ok)throw Error(c?.error||`Failed to delete MCP server`);return ei.getState().clearDiagnostic(n,a,o),i()===o?(t().selectedMcpName===n&&e({selectedMcpName:null}),await wi(l,a,o),await Oi(l,a,o),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}):{ok:!0}}catch(e){return console.error(`[McpConfigStore] Failed to delete MCP:`,e),{ok:!1}}}}),{name:`mcp-config-store`,storage:be(),partialize:e=>({selectedMcpName:e.selectedMcpName})}),{name:`mcp-config-store`}));function Pa(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=ja(e.environment)??{}),e.headers!==void 0&&(t.headers=ja(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:Ma(e.oauthClientId),clientSecret:Ma(e.oauthClientSecret),scope:Ma(e.oauthScope),redirectUri:Ma(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 Fa=()=>{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},Ia=`useSkillsStore`,La=e=>{if(e&&Object.prototype.hasOwnProperty.call(e,`directory`))return typeof e.directory==`string`&&e.directory.trim()||null;let t=Fa();return typeof t==`string`&&t.trim()||null},Ra=ce()(ue(le((e,t)=>({selectedSkillName:null,skillDraft:null,setSelectedSkill:t=>{e({selectedSkillName:t})},setSkillDraft:t=>{e({skillDraft:t})},loadSkills:async()=>{try{return await Yt(l,Fa(),i()),!0}catch{return!1}},getSkillDetail:async e=>{try{let t=Fa(),n=t?`?directory=${encodeURIComponent(t)}`:``,r=await p(`/api/config/skills/${encodeURIComponent(e)}${n}`);return r.ok?await r.json():null}catch{return null}},createSkill:async(e,t)=>{try{let n={name:e.name,description:e.description};e.instructions&&(n.instructions=e.instructions),e.scope&&(n.scope=e.scope),e.source&&(n.source=e.source),e.supportingFiles&&(n.supportingFiles=e.supportingFiles);let r=La(t),a=i(),o=r?`?directory=${encodeURIComponent(r)}`:``,s=await p(`/api/config/skills/${encodeURIComponent(e.name)}${o}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)}),c=await s.json().catch(()=>null);if(!s.ok){let e=c?.error||`Failed to create skill`;throw Error(e)}return await za({directory:r,transportIdentity:a}),!0}catch{return!1}},updateSkill:async(e,t,n)=>{try{let r={};t.description!==void 0&&(r.description=t.description),t.instructions!==void 0&&(r.instructions=t.instructions),t.supportingFiles!==void 0&&(r.supportingFiles=t.supportingFiles),t.targetPath!==void 0&&(r.targetPath=t.targetPath);let a=La(n),o=i(),s=a?`?directory=${encodeURIComponent(a)}`:``,c=await p(`/api/config/skills/${encodeURIComponent(e)}${s}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(r)}),l=await c.json().catch(()=>null);if(!c.ok){let e=l?.error||`Failed to update skill`;throw Error(e)}return await za({directory:a,transportIdentity:o}),!0}catch{return!1}},deleteSkill:async(n,r)=>{try{let a=La(r),o=i(),s=a?`?directory=${encodeURIComponent(a)}`:``,c=await p(`/api/config/skills/${encodeURIComponent(n)}${s}`,{method:`DELETE`}),l=await c.json().catch(()=>null);if(!c.ok){let e=l?.error||`Failed to delete skill`;throw Error(e)}return await za({directory:a,transportIdentity:o}),i()===o&&t().selectedSkillName===n&&e({selectedSkillName:null}),!0}catch{return!1}},getSkillByName:e=>gt(l,Fa()).find(t=>t.name===e),readSupportingFile:async(e,t)=>{try{let n=Fa(),r=n?`&directory=${encodeURIComponent(n)}`:``,i=await p(`/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=Fa(),i=r?`?directory=${encodeURIComponent(r)}`:``;return(await p(`/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=Fa(),r=n?`?directory=${encodeURIComponent(n)}`:``;return(await p(`/api/config/skills/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}${r}`,{method:`DELETE`})).ok}catch{return!1}}}),{name:`skills-store`,storage:be(),partialize:e=>({selectedSkillName:e.selectedSkillName})}),{name:`skills-store`}));typeof window<`u`&&(window.__zustand_skills_store__=Ra);async function za(e){let t=e&&`directory`in e?e.directory?.trim()||null:Fa(),n=e?.transportIdentity??i();i()===n&&(await Yt(l,t,n),i()===n&&(await yt(l,t,n),i()===n&&zt(`skills`,{source:Ia})))}var Ba=null;Ba||=At(e=>{if(e.source!==Ia&&Rt(e,`skills`)){let e=Fa(),t=i();Yt(l,e,t).then(()=>yt(l,e,t)).catch(()=>void 0)}});var Va=/^#[0-9a-fA-F]{6}$/,Ha=/^\{file:.+\}$/i,Ua=e=>[...e].sort((e,t)=>{let n=e.permission.localeCompare(t.permission);return n===0?e.pattern.localeCompare(t.pattern):n}),Wa=(e,t)=>{let n=Ua(e),r=Ua(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})},Ga=(e,t)=>t?e.globalPermission!==t.globalPermission||!Wa(e.permissionRules,t.permissionRules):!1,Ka=e=>e===`bash`?`shell`:e===`task`?`subagent`:e===`write`||e===`patch`?`edit`:e,qa=(e,t)=>{let n=[{action:`*`,resource:`*`,effect:e}];for(let e of t)!e.permission||!e.pattern||(e.permission!==`*`||e.pattern!==`*`)&&n.push({action:Ka(e.permission),resource:e.pattern,effect:e.action});return n},Ja=e=>{let t=e.trim();return t===``?null:t},Ya=({isNewAgent:e,agentName:t,draftScope:n,initialScope:r,draftHasExplicitPermission:i,current:a,initial:o,confirmDrop:s})=>{let c=qa(a.globalPermission,a.permissionRules);if(e){let e=a.description.trim(),r=Ja(a.model),l=a.system.trim(),u=Ga(a,o)||i;return{name:t,mode:a.mode,...e?{description:e}:{},...r?{model:r}:{},...l?{system:l}:{},...u?{permissions:c}:{},...n?{scope:n}:{},...s?{confirmDrop:!0}:{}}}let l={name:t,...s?{confirmDrop:!0}:{}};return o?(a.description!==o.description&&(l.description=a.description.trim()||null),a.mode!==o.mode&&(l.mode=a.mode),a.model!==o.model&&(l.model=Ja(a.model)),a.system!==o.system&&(l.system=a.system.trim()||null),Ga(a,o)&&(l.permissions=c),n&&r&&n!==r&&(l.scope=n),l):l},Xa=e=>{if(e){if(typeof e.prompt==`string`)return Ha.test(e.prompt.trim())?void 0:e.prompt;if(typeof e.system==`string`)return e.system}},Za=e=>{let t=e?.model?.providerID,n=e?.model?.modelID||e?.model?.id;if(!t||!n)return``;let r=e?.model?.variant||e?.variant;return r?`${t}/${n}#${r}`:`${t}/${n}`},Qa=e=>{let t=e.trim(),n=t.indexOf(`/`);if(n<=0||n>=t.length-1)return null;let r=t.slice(0,n),i=t.slice(n+1),a=i.indexOf(`#`);return a===-1?{providerId:r,modelId:i,variant:``}:{providerId:r,modelId:i.slice(0,a),variant:i.slice(a+1)}},$a=e=>Va.test(e.trim()),eo=e=>{let t=e.trim();return t&&t.charAt(0).toUpperCase()+t.slice(1)},to=e=>{let t=(0,qi.c)(37),{className:n}=e,{t:r}=He(),i=Lt(no),a=Lt(ro),o=Lt(io),s=N(),c;t[0]===i?c=t[1]:(c=[...i].sort(ao),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 p=f,m;t[8]===n?m=t[9]:(m=G(n),t[8]=n,t[9]=m);let h;t[10]===r?h=t[11]:(h=r(`settings.shared.projectSelector.switchProjectAria`),t[10]=r,t[11]=h);let g;t[12]===r?g=t[13]:(g=r(`settings.shared.projectSelector.switchProjectTitle`),t[12]=r,t[13]=g);let _,v;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(_=G(`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`),v=(0,$.jsx)(Y,{name:`folder`,className:`h-4 w-4 text-muted-foreground`}),t[14]=_,t[15]=v):(_=t[14],v=t[15]);let y;t[16]===p?y=t[17]:(y=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label font-medium`,children:p}),t[16]=p,t[17]=y);let b;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(Y,{name:`arrow-down-s`,className:`size-4 opacity-50`}),t[18]=b):b=t[18];let x;t[19]!==h||t[20]!==g||t[21]!==y?(x=(0,$.jsx)(kr,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,"aria-label":h,title:g,className:_,children:[v,y,b]})}),t[19]=h,t[20]=g,t[21]=y,t[22]=x):x=t[22];let S=d?.id??``,C;t[23]===o?C=t[24]:(C=e=>{e&&o(e)},t[23]=o,t[24]=C);let w;t[25]===l?w=t[26]:(w=l.map(oo),t[25]=l,t[26]=w);let T;t[27]!==S||t[28]!==C||t[29]!==w?(T=(0,$.jsx)(hr,{align:`start`,className:`w-auto`,children:(0,$.jsx)(Tr,{value:S,onValueChange:C,children:w})}),t[27]=S,t[28]=C,t[29]=w,t[30]=T):T=t[30];let E;t[31]!==x||t[32]!==T?(E=(0,$.jsxs)(Cr,{children:[x,T]}),t[31]=x,t[32]=T,t[33]=E):E=t[33];let D;return t[34]!==E||t[35]!==m?(D=(0,$.jsx)(`div`,{className:m,children:E}),t[34]=E,t[35]=m,t[36]=D):D=t[36],D};function no(e){return e.projects}function ro(e){return e.activeProjectId}function io(e){return e.setActiveProject}function ao(e,t){return(e.label||e.path).localeCompare(t.label||t.path)}function oo(e){let t=e.path.split(`/`).filter(Boolean).pop()||e.path;return(0,$.jsx)(cr,{value:e.id,children:(0,$.jsx)(`span`,{className:`min-w-0 truncate typography-ui`,children:t})},e.id)}function so(e,t){return`opencode:sidebar-group:${e}:${t}`}var co=e=>{let t=(0,qi.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=so(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(lo),t[10]=e):e=t[10];let i;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(i=G(`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=G(`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)(Y,{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=G(_),t[27]=_,t[28]=v);let y;return t[29]!==c||t[30]!==p||t[31]!==m||t[32]!==v?(y=(0,$.jsx)(X,{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(uo),t[34]=y):y=t[34];let b;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(b=G(`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=G(`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)(Y,{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 lo(e){return!e}function uo(e){return!e}var fo=e=>e===`bash`?`shell`:e===`task`?`subagent`:e===`write`||e===`patch`?`edit`:e,po=e=>{let t=zn(e).map(e=>({action:fo(e.action),resource:e.resource,effect:e.effect}));return t.length>0?t:void 0},mo=(e,t)=>{let n=e,r=ct(e)?void 0:typeof n.system==`string`?n.system:typeof e.prompt==`string`?e.prompt:void 0,i=typeof n.color==`string`&&$a(n.color)?n.color:void 0;return{name:t,scope:n.scope||`user`,description:e.description,model:Za(e)||null,...r?{system:r}:{},mode:e.mode,...typeof n.steps==`number`?{steps:n.steps}:{},...e.hidden===!0?{hidden:!0}:{},...n.disabledOverride?{disabled:!0}:{},...i?{color:i}:{},permissions:po(n.permissions??e.permission)}},ho=({onItemSelect:e})=>{let{t}=He(),[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}=dt(de(e=>({selectedAgentName:e.selectedAgentName,setSelectedAgent:e.setSelectedAgent,setAgentDraft:e.setAgentDraft,createAgent:e.createAgent,deleteAgent:e.deleteAgent,loadAgents:e.loadAgents}))),{data:b=[]}=jt();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(ct(e)){q.error(t(`settings.agents.sidebar.toast.builtInCannotDelete`));return}s(e),l(`delete`)},C=async e=>{ct(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?q.warning(t(`settings.agents.page.toast.savedManualRestart`)):c===`delete`?q.success(t(`settings.agents.sidebar.toast.agentDeleted`,{name:o.name})):q.success(t(`settings.agents.sidebar.toast.agentReset`,{name:o.name})),w()):c===`delete`?q.error(t(`settings.agents.sidebar.toast.deleteFailed`)):q.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`?q.error(t(r?`settings.agents.sidebar.toast.definitionNotFound`:`settings.agents.sidebar.toast.deleteFailed`)):q.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}`;g(mo(e,r)),h(r)},D=e=>{a(e.name),r(e)},O=async()=>{if(!n)return;let e=i.trim().replace(/\s+/g,`-`);if(!e){q.error(t(`settings.agents.sidebar.toast.agentNameRequired`));return}if(e===n.name){r(null);return}if(b.some(t=>t.name===e)){q.error(t(`settings.agents.sidebar.toast.agentExists`));return}let a=n,o=await _({...mo(n,e),scope:a.scope});if(o.ok){let r=await v(n.name,a.scope);r.ok?(o.requiresManualRestart||r.requiresManualRestart?q.warning(t(`settings.agents.page.toast.savedManualRestart`)):q.success(t(`settings.agents.sidebar.toast.agentRenamed`,{name:e})),h(e)):q.error(t(`settings.agents.sidebar.toast.removeOldAfterRenameFailed`))}else q.error(t(`settings.agents.sidebar.toast.renameFailed`));r(null)},k=e=>{switch(e){case`primary`:return(0,$.jsx)(Y,{name:`ai-agent`,className:`h-3 w-3 text-primary`});case`all`:return(0,$.jsx)(Y,{name:`ai-agent-fill`,className:`h-3 w-3 text-primary`});case`subagent`:return(0,$.jsx)(Y,{name:`robot`,className:`h-3 w-3 text-primary`});default:return null}},A=b.filter(e=>{let t=e;return!Ct(e)||!!t.scope||t.disabledOverride===!0}),j=A.filter(ct),M=A.filter(e=>!ct(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)(K,{"data-settings-item":`agents.create`,size:`icon`,variant:`ghost`,onClick:x,"aria-label":t(`settings.agents.page.title.new`),children:(0,$.jsx)(Y,{name:`add`,className:`h-4 w-4`})})]});return(0,$.jsxs)(`div`,{className:`yuri-settings-page-content h-full overflow-y-auto bg-background p-3`,children:[(0,$.jsx)(to,{}),(0,$.jsx)($.Fragment,{children:A.length===0?(0,$.jsx)(X,{children:(0,$.jsxs)(`div`,{className:`yuri-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(Y,{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)(X,{label:t(`settings.agents.sidebar.section.builtIn`),children:j.map(t=>(0,$.jsx)(go,{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)(co,{label:n,count:r.length,storageKey:`agents`,variant:`settings-card`,labelPrefix:t(`settings.agents.sidebar.section.custom`),children:r.map(t=>(0,$.jsx)(go,{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)(X,{label:F,children:P.map(t=>(0,$.jsx)(go,{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)(X,{label:F,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]}),M.length===0&&(0,$.jsx)(X,{label:F,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]})}),(0,$.jsx)(hn,{open:o!==null&&c!==null,onOpenChange:e=>{!e&&!u&&w()},children:(0,$.jsxs)(fn,{className:`max-w-md`,children:[(0,$.jsxs)(un,{children:[(0,$.jsx)(pn,{children:t(c===`delete`?`settings.agents.sidebar.dialog.deleteTitle`:`settings.agents.sidebar.dialog.resetTitle`)}),(0,$.jsx)(mn,{children:t(c===`delete`?`settings.agents.sidebar.dialog.deleteDescription`:`settings.agents.sidebar.dialog.resetDescription`,{name:o?.name??``})})]}),(0,$.jsxs)(dn,{children:[(0,$.jsx)(K,{size:`sm`,variant:`ghost`,onClick:w,disabled:u,children:t(`settings.common.actions.cancel`)}),(0,$.jsx)(K,{size:`sm`,onClick:T,disabled:u,children:t(c===`delete`?`settings.common.actions.delete`:`settings.common.actions.reset`)})]})]})}),(0,$.jsx)(hn,{open:n!==null,onOpenChange:e=>!e&&r(null),children:(0,$.jsxs)(fn,{children:[(0,$.jsxs)(un,{children:[(0,$.jsx)(pn,{children:t(`settings.agents.sidebar.renameDialog.title`)}),(0,$.jsx)(mn,{children:t(`settings.agents.sidebar.renameDialog.description`,{name:n?.name??``})})]}),(0,$.jsx)(En,{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)(dn,{children:[(0,$.jsx)(K,{size:`sm`,variant:`ghost`,onClick:()=>r(null),children:t(`settings.common.actions.cancel`)}),(0,$.jsx)(K,{size:`sm`,onClick:O,children:t(`settings.common.actions.rename`)})]})]})})]})},go=e=>{let t=(0,qi.c)(55),{agent:n,isSelected:r,onSelect:i,onDelete:a,onReset:o,onRename:s,onDuplicate:c,getAgentModeIcon:l,isMenuOpen:u,onMenuOpenChange:d}=e,{t:f}=He(),p=n,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=Fr(),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)(Y,{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)(Y,{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)(Y,{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)(Y,{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=G(`yuri-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=eo(n.name),t[12]=n.name,t[13]=w);let T;t[14]===w?T=t[15]:(T=(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate text-foreground`,children:w}),t[14]=w,t[15]=T);let E;t[16]!==n.mode||t[17]!==l?(E=l(n.mode),t[16]=n.mode,t[17]=l,t[18]=E):E=t[18];let D;t[19]!==n||t[20]!==p.disabledOverride||t[21]!==p.scope||t[22]!==f?(D=(p.scope||ct(n)||p.disabledOverride)&&(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:p.disabledOverride?f(`settings.agents.sidebar.badge.disabled`):ct(n)?f(`settings.agents.sidebar.badge.system`):p.scope===`project`?f(`settings.common.scope.project`):f(`settings.common.scope.global`)}),t[19]=n,t[20]=p.disabledOverride,t[21]=p.scope,t[22]=f,t[23]=D):D=t[23];let O;t[24]!==D||t[25]!==T||t[26]!==E?(O=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[T,E,D]}),t[24]=D,t[25]=T,t[26]=E,t[27]=O):O=t[27];let k;t[28]===n.description?k=t[29]:(k=n.description&&(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight`,children:n.description}),t[28]=n.description,t[29]=k);let A;t[30]!==i||t[31]!==O||t[32]!==k?(A=(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:[O,k]}),t[30]=i,t[31]=O,t[32]=k,t[33]=A):A=t[33];let j;t[34]===d?j=t[35]:(j=e=>{e&&_(!1),d(e)},t[34]=d,t[35]=j);let M;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(kr,{asChild:!0,children:(0,$.jsx)(K,{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)(Y,{name:`more-2`,className:`h-3.5 w-3.5`})})}),t[36]=M):M=t[36];let N;t[37]===y?N=t[38]:(N=(0,$.jsx)(hr,{align:`end`,className:`w-fit min-w-20`,children:y(ar)}),t[37]=y,t[38]=N);let P;t[39]!==u||t[40]!==j||t[41]!==N?(P=(0,$.jsxs)(Cr,{open:u,onOpenChange:j,children:[M,N]}),t[39]=u,t[40]=j,t[41]=N,t[42]=P):P=t[42];let F;t[43]!==A||t[44]!==P?(F=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[A,P]}),t[43]=A,t[44]=P,t[45]=F):F=t[45];let I;t[46]!==F||t[47]!==C?(I=(0,$.jsx)(Pi,{render:C,children:F}),t[46]=F,t[47]=C,t[48]=I):I=t[48];let L;t[49]===y?L=t[50]:(L=(0,$.jsx)(Ii,{className:`w-fit min-w-20`,children:y(Ri)}),t[49]=y,t[50]=L);let R;return t[51]!==g||t[52]!==I||t[53]!==L?(R=(0,$.jsxs)(ji,{open:g,onOpenChange:_,children:[I,L]}),t[51]=g,t[52]=I,t[53]=L,t[54]=R):R=t[54],R};function _o(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function vo(e){return typeof e==`string`&&e.length>0?e:void 0}function yo(e){let t=_o(e)?e:null,n=t&&Array.isArray(t.data)?t.data:Array.isArray(e)?e:null;if(!n)throw Error(`permission saved: expected list payload`);return n.map(e=>{if(!_o(e))throw Error(`permission saved: invalid rule`);let t=vo(e.id),n=vo(e.projectID),r=vo(e.action),i=vo(e.resource);if(!t||!n||!r||!i)throw Error(`permission saved: invalid rule`);return{id:t,projectID:n,action:r,resource:i}})}async function bo(e,t){if(!e.trim())throw Error(`permission saved: directory required`);t?.throwIfAborted();let n=await _e.getApiClient().location.get({location:{directory:e}},{signal:t});t?.throwIfAborted();let r=vo(n?.project?.id);if(!r)throw Error(`permission saved: project ID required`);return r}async function xo(e){e.signal?.throwIfAborted();let t=await _e.getApiClient().permission.saved.list({projectID:e.projectID??void 0},{signal:e.signal});e.signal?.throwIfAborted();let n=yo(t);if(e.projectID&&n.some(t=>t.projectID!==e.projectID))throw Error(`permission saved: project mismatch`);return n}async function So(e){e.signal?.throwIfAborted(),await _e.getApiClient().permission.saved.remove({id:e.id},{signal:e.signal})}function Co(e){if(e.transport!==i()||e.generation!==o())throw Error(`Saved permission runtime changed`)}var wo=e=>Oe({queryKey:[e.transport,e.generation,`saved-permission-project`,e.directory],queryFn:async({signal:t})=>{Co(e);let n=await bo(e.directory,t);return Co(e),n},retry:!1}),To=e=>Oe({queryKey:[e.transport,e.generation,`saved-permissions`,e.directory,e.projectID],queryFn:async({signal:t})=>{if(Co(e),!e.directory||!e.projectID)throw Error(`Saved permission scope required`);let n=await xo({projectID:e.projectID,signal:t});return Co(e),n},retry:!1});function Eo(e){let t=(0,qi.c)(3),n=(0,Q.useSyncExternalStore)(r,o,o),a={transport:i(),generation:n,directory:e.trim()},s=ke({...wo(a),enabled:!!a.directory}),c={...a,projectID:s.data??``},l=To(c),u=!!(a.directory&&s.data)&&!s.isError,d;return t[0]!==l||t[1]!==u?(d={...l,enabled:u},t[0]=l,t[1]=u,t[2]=d):d=t[2],{project:s,list:ke(d),scope:c}}async function Do(e,t,n){Co(t);let r=To(t).queryKey;if(!e.getQueryData(r)?.some(e=>e.id===n&&e.projectID===t.projectID))throw Error(`Saved permission is outside the captured scope`);await So({id:n}),t.transport===i()&&t.generation===o()&&(await e.cancelQueries({queryKey:r,exact:!0}),t.transport===i()&&t.generation===o()&&e.setQueryData(r,e=>e?.filter(e=>e.id!==n)))}var Oo=()=>{let e=(0,qi.c)(49),{t}=He(),n=he(ko),r=Ee(),{project:i,list:a,scope:o}=Eo(n),s;e[0]===r?s=e[1]:(s={mutationFn:e=>{let{scope:t,id:n}=e;return Do(r,t,n)}},e[0]=r,e[1]=s);let c=De(s),l;e[2]!==c.variables||e[3]!==o?(l=c.variables&&JSON.stringify(c.variables.scope)===JSON.stringify(o),e[2]=c.variables,e[3]=o,e[4]=l):l=e[4];let u=l,d=i.isError||a.isError,f=!!o.directory&&(i.isPending||a.isPending)&&!d,p;e[5]===a.data?p=e[6]:(p=a.data??[],e[5]=a.data,e[6]=p);let m=p,h;e[7]!==c||e[8]!==o?(h=e=>c.mutate({scope:o,id:e}),e[7]=c,e[8]=o,e[9]=h):h=e[9];let g=ze(h),_;e[10]!==a||e[11]!==i?(_=()=>{i.isError?i.refetch():a.refetch()},e[10]=a,e[11]=i,e[12]=_):_=e[12];let v=ze(_);if(!d&&!f&&m.length===0)return null;let y;e[13]===t?y=e[14]:(y=t(`settings.permissions.saved.title`),e[13]=t,e[14]=y);let b;e[15]!==f||e[16]!==t?(b=f?t(`common.loading`):void 0,e[15]=f,e[16]=t,e[17]=b):b=e[17];let x;e[18]!==d||e[19]!==a.isFetching||e[20]!==i.isFetching||e[21]!==v||e[22]!==t?(x=d&&(0,$.jsx)(Z,{label:(0,$.jsx)(`span`,{role:`alert`,children:t(`settings.permissions.saved.loadFailed`)}),children:(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`xs`,onClick:v,disabled:i.isFetching||a.isFetching,children:t(`settings.permissions.saved.retry`)})}),e[18]=d,e[19]=a.isFetching,e[20]=i.isFetching,e[21]=v,e[22]=t,e[23]=x):x=e[23];let S;e[24]!==c.isError||e[25]!==u||e[26]!==t?(S=u&&c.isError&&(0,$.jsx)(Z,{label:(0,$.jsx)(`span`,{role:`alert`,children:t(`settings.permissions.saved.deleteFailed`)}),children:null}),e[24]=c.isError,e[25]=u,e[26]=t,e[27]=S):S=e[27];let C;if(e[28]!==c.isPending||e[29]!==d||e[30]!==g||e[31]!==m||e[32]!==f||e[33]!==u||e[34]!==t){let n;e[36]!==c.isPending||e[37]!==d||e[38]!==g||e[39]!==f||e[40]!==u||e[41]!==t?(n=e=>(0,$.jsx)(Z,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:e.action}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground font-mono`,children:e.resource})]}),children:(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`xs`,disabled:d||f||!!(u&&c.isPending),onClick:()=>void g(e.id),children:t(`settings.permissions.saved.delete`)})},e.id),e[36]=c.isPending,e[37]=d,e[38]=g,e[39]=f,e[40]=u,e[41]=t,e[42]=n):n=e[42],C=m.map(n),e[28]=c.isPending,e[29]=d,e[30]=g,e[31]=m,e[32]=f,e[33]=u,e[34]=t,e[35]=C}else C=e[35];let w;return e[43]!==y||e[44]!==b||e[45]!==x||e[46]!==S||e[47]!==C?(w=(0,$.jsx)(`div`,{"data-settings-item":`permissions.saved`,className:`mb-6`,children:(0,$.jsxs)(X,{label:y,description:b,children:[x,S,C]})}),e[43]=y,e[44]=b,e[45]=x,e[46]=S,e[47]=C,e[48]=w):w=e[48],w};function ko(e){return e.currentDirectory}var Ao=[`*`,`read`,`edit`,`glob`,`grep`,`shell`,`subagent`,`skill`,`webfetch`,`websearch`,`question`,`external_directory`,`execute`,`browser`],jo={"*":`settings.agents.page.permissions.defaultLabel`,shell:`settings.agents.page.permissions.shell`,bash:`settings.agents.page.permissions.shell`,subagent:`settings.agents.page.permissions.subagent`,task:`settings.agents.page.permissions.subagent`,edit:`settings.agents.page.permissions.edit`,write:`settings.agents.page.permissions.edit`,patch:`settings.agents.page.permissions.edit`,apply_patch:`settings.agents.page.permissions.edit`,multiedit:`settings.agents.page.permissions.edit`,external_directory:`settings.agents.page.permissions.externalDirectory`,question:`settings.agents.page.permissions.question`,read:`settings.agents.page.permissions.read`,glob:`settings.agents.page.permissions.glob`,grep:`settings.agents.page.permissions.grep`,skill:`settings.agents.page.permissions.skill`,webfetch:`settings.agents.page.permissions.webfetch`,websearch:`settings.agents.page.permissions.websearch`,execute:`settings.agents.page.permissions.execute`,browser:`settings.agents.page.permissions.browser`,session_rename:`chat.tools.display.session_rename`,session_move:`chat.tools.display.session_move`},Mo=e=>e===`allow`||e===`ask`||e===`deny`,No=(e,t)=>`${e}::${t}`,Po=e=>e===`bash`?`shell`:e===`task`?`subagent`:e===`write`||e===`patch`?`edit`:e,Fo=e=>{let t=new Map;for(let n of e){let e=Po(n.permission);!e||e===`invalid`||n.pattern&&Mo(n.action)&&t.set(No(e,n.pattern),{permission:e,pattern:n.pattern,action:n.action})}return Array.from(t.values())},Io=e=>{let t=new Map;for(let n of Fo(e))t.set(No(n.permission,n.pattern),n);return t},Lo=e=>[...e].sort((e,t)=>{let n=e.permission.localeCompare(t.permission);return n===0?e.pattern.localeCompare(t.pattern):n}),Ro=(e,t)=>{let n=Lo(Fo(e)),r=Lo(Fo(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})},zo=e=>e.find(e=>e.permission===`*`&&e.pattern===`*`)?.action??`allow`,Bo=(e,t)=>Fo(e).filter(e=>e.permission!==`*`||e.pattern!==`*`).filter(e=>e.pattern!==`*`||e.action!==t),Vo=e=>{if(Array.isArray(e))return Fo(e.flatMap(e=>!e||typeof e!=`object`||typeof e.action!=`string`||typeof e.resource!=`string`||!Mo(e.effect)?[]:[{permission:e.action,pattern:e.resource,action:e.effect}]));if(Mo(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(Mo(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))Mo(i)&&t.push({permission:n,pattern:e,action:i})}return t},Ho=()=>{let{t:e}=He(),{selectedAgentName:t,getAgentByName:n,createAgent:r,updateAgent:i,agentDraft:a,setAgentDraft:o}=dt(de(e=>({selectedAgentName:e.selectedAgentName,getAgentByName:e.getAgentByName,createAgent:e.createAgent,updateAgent:e.updateAgent,agentDraft:e.agentDraft,setAgentDraft:e.setAgentDraft}))),{data:s=[]}=jt(),c=t?n(t):null,l=!!(a&&a.name===t&&!c),[u,d]=Q.useState(``),[f,m]=Q.useState(`user`),[h,g]=Q.useState(``),[_,v]=Q.useState(`subagent`),[y,b]=Q.useState(``),[x,S]=Q.useState(``),[C,w]=Q.useState(!1),[T,E]=Q.useState(`allow`),[D,O]=Q.useState([]),[k,A]=Q.useState([]),[j,M]=Q.useState(``),[N,P]=Q.useState(`*`),[F,I]=Q.useState(!1),[L,R]=Q.useState(!1),z=Q.useRef(null),B=he(e=>e.currentDirectory??null),[V,ee]=Q.useState([]),H=pt(e=>e.permission);Q.useEffect(()=>{let e=!1;return(async()=>{let t=await _e.listToolIds({directory:B});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));ee(Array.from(new Set(r)).sort((e,t)=>e.localeCompare(t)))})(),()=>{e=!0}},[B]);let te=Q.useMemo(()=>{let e=new Set;for(let t of s){let n=Fo(Vo(t.permissions??t.permission));for(let t of n)t.permission&&t.permission!==`*`&&t.permission!==`invalid`&&e.add(t.permission)}for(let t of Object.values(H))for(let n of t){let t=n.permission?.trim();t&&t!==`invalid`&&e.add(t)}for(let t of V)e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[s,H,V]),ne=Q.useMemo(()=>Io(D),[D]),U=Q.useMemo(()=>Io(k),[k]),re=e=>U.get(No(e,`*`))?.action,ie=e=>k.filter(t=>t.permission===e&&t.pattern!==`*`).sort((e,t)=>e.pattern.localeCompare(t.pattern)),ae=Q.useMemo(()=>{let e=new Set;for(let t of Ao)e.add(t);for(let t of te)e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[te]),oe=e=>{let t=e===`*`?T:re(e)??T,n=ie(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}},se=t=>e(t===`allow`?`settings.common.permission.allow`:t===`deny`?`settings.common.permission.deny`:`settings.common.permission.ask`),ce=t=>t===`global`?e(`settings.common.scope.global`):se(t),le=Q.useMemo(()=>{let e=new Set;for(let t of Ao)e.add(t);for(let t of te)e.add(t);return Array.from(e).sort((e,t)=>e.localeCompare(t))},[te]),ue=(e,t,n)=>{A(r=>{let i=Io(r);return i.set(No(e,t),{permission:e,pattern:t,action:n}),Array.from(i.values())})},fe=(e,t)=>{A(n=>{let r=Io(n);return r.delete(No(e,t)),Array.from(r.values())})},pe=(e,t)=>{let n=ne.get(No(e,t));if(n){ue(e,t,n.action);return}fe(e,t)},me=(e,t,n)=>{ue(e,t,n)},ge=e=>{E(e),A(t=>t.filter(t=>t.pattern!==`*`||t.action!==e))},ve=t=>{let n=j.trim();if(!n){q.error(e(`settings.agents.page.toast.permissionNameRequired`));return}let r=N.trim()||`*`;if(n===`*`&&r===`*`){ge(t),M(``),P(`*`);return}r===`*`&&n!==`*`&&t===T?fe(n,`*`):ue(n,r,t),M(``),P(`*`)},ye=t=>{let n=jo[t];return n?e(n):t.split(/[_-]+/g).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)};Q.useEffect(()=>{M(``),P(`*`);let e=e=>{let t=Fo(e),n=zo(t),r=Bo(t,n);return E(n),O(r),A(r),{global:n,rules:r}};if(l&&a){let t=a.name||``,n=a.scope||`user`,r=a.description||``,i=a.mode||`subagent`,o=a.model||``,s=a.system||``;d(t),m(n),g(r),v(i),b(o),S(s),w(!1);let c=e(Vo(a.permissions));z.current={draftName:t,draftScope:n,description:r,mode:i,model:o,system:s,globalPermission:c.global,permissionRules:c.rules};return}if(c&&t===c.name){let t=c,n=c.description||``,r=c.mode||`subagent`,i=Za(c),a=t.scope===`project`?`project`:`user`;m(a),g(n),v(r),b(i),S(``),w(!1);let o=e(Vo(t.permissions??c.permission));z.current={draftName:``,draftScope:a,description:n,mode:r,model:i,system:``,globalPermission:o.global,permissionRules:o.rules}}},[a,l,c,t]),Q.useEffect(()=>{if(!t||l)return;let e=new AbortController,n=$t();return p(`/api/config/agents/${encodeURIComponent(t)}/config`,{signal:e.signal,headers:n?{"x-opencode-directory":n}:{}}).then(async t=>{if(!t.ok||e.signal.aborted)return;let n=Xa((await t.json()).config);e.signal.aborted||n===void 0||!z.current||(S(n),z.current={...z.current,system:n})}).catch(()=>void 0),()=>e.abort()},[l,t]);let be=Q.useMemo(()=>{let e=z.current;return e?!!(l&&u!==e.draftName||f!==e.draftScope||h!==e.description||_!==e.mode||y!==e.model||x!==e.system||T!==e.globalPermission||!Ro(k,e.permissionRules)):!1},[h,u,f,T,l,_,y,k,x]),xe=(!l&&c?c.document:void 0)?.dropped?.map(e=>e.key)??[],Se=!L&&be;return t?(0,$.jsx)(Rr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(Xr,{actions:(0,$.jsx)(K,{type:`button`,size:`sm`,onClick:async()=>{let n=l?u.trim().replace(/\s+/g,`-`):t?.trim();if(!n){q.error(e(`settings.agents.sidebar.toast.agentNameRequired`));return}if(l&&s.some(e=>e.name===n)){q.error(e(`settings.agents.sidebar.toast.agentExists`));return}R(!0);try{let t={description:h,mode:_,model:y,system:x,globalPermission:T,permissionRules:k},s=z.current,c=s?{description:s.description,mode:s.mode,model:s.model,system:s.system,globalPermission:s.globalPermission,permissionRules:s.permissionRules}:null,u=Ya({isNewAgent:l,agentName:n,draftScope:f,initialScope:s?.draftScope,draftHasExplicitPermission:l&&a?.permissions!==void 0,current:t,initial:c,confirmDrop:C}),d;l?(d=await r(u),d.ok&&o(null)):d=await i(n,u),d.ok?d.requiresManualRestart?q.warning(e(`settings.agents.page.toast.savedManualRestart`)):q.success(e(`settings.agents.page.toast.savedNextRequest`)):q.error(e(l?`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`);q.error(n)}finally{R(!1)}},disabled:!Se,"aria-busy":L,children:e(L?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)}),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.agents.page.title.new`):eo(t??``)}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:e(l?`settings.agents.page.subtitle.new`:`settings.agents.page.subtitle.edit`)})]})}),(0,$.jsx)(Oo,{}),xe.length>0?(0,$.jsxs)(`div`,{className:`mt-3 flex flex-col gap-2`,children:[(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.agents.page.legacy.dropped`,{fields:xe.join(`, `)})}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 typography-meta text-foreground`,children:[(0,$.jsx)(gn,{checked:C,onChange:w,ariaLabel:e(`settings.agents.page.legacy.confirmDrop`)}),e(`settings.agents.page.legacy.confirmDrop`)]})]}):null,(0,$.jsxs)(X,{label:e(`settings.agents.page.section.identityRole`),children:[(0,$.jsx)(Z,{itemId:`agents.scope`,label:e(`settings.agents.page.field.scope`),children:(0,$.jsxs)(Cn,{value:f,onValueChange:e=>m(e),children:[(0,$.jsx)(bn,{className:`w-fit min-w-[100px]`,children:(0,$.jsx)(Tn,{placeholder:e(`settings.agents.page.field.scopePlaceholder`),children:t=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Y,{name:t===`project`?`folder`:`user-3`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(t===`project`?`settings.common.scope.project`:`settings.common.scope.global`)})]})})}),(0,$.jsxs)(xn,{align:`end`,children:[(0,$.jsx)(vn,{value:`user`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Y,{name:`user-3`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.global`)})]})}),(0,$.jsx)(vn,{value:`project`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Y,{name:`folder`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.project`)})]})})]})]})}),l&&(0,$.jsx)(Z,{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)(En,{value:u,onChange:e=>d(e.target.value),placeholder:e(`settings.agents.page.field.agentNamePlaceholder`),className:`h-7 w-40 px-2`})]})}),(0,$.jsx)(Z,{label:e(`settings.common.field.description`),className:`yuri-settings-split-row-stacked`,children:(0,$.jsx)(zr,{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)(Z,{itemId:`agents.mode`,className:`yuri-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)(kn,{children:[(0,$.jsx)(Dn,{asChild:!0,children:(0,$.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(On,{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)(K,{variant:`chip`,size:`xs`,"aria-pressed":_===`primary`,onClick:()=>v(`primary`),className:`!font-normal shrink-0`,children:e(`settings.agents.page.mode.primary`)}),(0,$.jsx)(K,{variant:`chip`,size:`xs`,"aria-pressed":_===`subagent`,onClick:()=>v(`subagent`),className:`!font-normal shrink-0`,children:e(`settings.agents.page.mode.subagent`)}),(0,$.jsx)(K,{variant:`chip`,size:`xs`,"aria-pressed":_===`all`,onClick:()=>v(`all`),className:`!font-normal shrink-0`,children:e(`settings.agents.page.mode.all`)})]})})]}),(0,$.jsx)(X,{label:e(`settings.agents.page.section.modelParameters`),children:(0,$.jsx)(Z,{itemId:`agents.model`,label:e(`settings.agents.page.field.overrideModel`),children:(0,$.jsx)(Vn,{providerId:Qa(y)?.providerId??``,modelId:Qa(y)?.modelId??``,variant:Qa(y)?.variant??``,onChange:(e,t,n)=>{b(e&&t?n?`${e}/${t}#${n}`:`${e}/${t}`:``)},className:`yuri-settings-inline-value`})})}),(0,$.jsx)(di,{itemId:`agents.system-prompt`,label:e(`settings.agents.page.section.systemPrompt`),className:`yuri-settings-split-row-stacked`,children:(0,$.jsx)(zr,{embedded:!0,value:x,onChange:e=>S(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)(X,{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)(K,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>I(e=>!e),children:e(F?`settings.agents.page.permissions.hideEditor`:`settings.agents.page.permissions.advancedEditor`)})]}),children:F?(0,$.jsxs)(`div`,{className:`space-y-6 p-2`,children:[(0,$.jsx)(Z,{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)(Cn,{value:T,onValueChange:e=>ge(e),children:[(0,$.jsx)(bn,{className:`w-[100px]`,children:(0,$.jsx)(Tn,{children:se(T)})}),(0,$.jsxs)(xn,{children:[(0,$.jsx)(vn,{value:`allow`,children:e(`settings.common.permission.allow`)}),(0,$.jsx)(vn,{value:`ask`,children:e(`settings.common.permission.ask`)}),(0,$.jsx)(vn,{value:`deny`,children:e(`settings.common.permission.deny`)})]})]})}),(0,$.jsx)(`div`,{className:`space-y-4`,children:ae.filter(e=>e!==`*`).map(t=>{let n=ye(t),{defaultAction:r,patternRulesCount:i}=oe(t),a=re(t),o=a??`global`,s=ie(t),c=[`allow`,`ask`,`deny`].filter(e=>e!==T);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 items-center justify-between gap-2 py-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap 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)(K,{size:`sm`,variant:`ghost`,onClick:()=>pe(t,`*`),className:`px-1.5 py-0 h-5`,children:(0,$.jsx)(Y,{name:`subtract`,className:`h-3.5 w-3.5 text-muted-foreground hover:text-foreground`})})]}),(0,$.jsxs)(Cn,{value:o,onValueChange:e=>{if(e===`global`){fe(t,`*`);return}ue(t,`*`,e)},children:[(0,$.jsx)(bn,{className:`w-[90px] shrink-0`,children:(0,$.jsx)(Tn,{children:ce(o)})}),(0,$.jsxs)(xn,{children:[(0,$.jsx)(vn,{value:`global`,children:e(`settings.common.scope.global`)}),c.map(e=>(0,$.jsx)(vn,{value:e,className:`capitalize`,children:se(e)},e))]})]})]}),s.map(t=>{let n=No(t.permission,t.pattern),r=ne.get(n),i=!r,a=!!(r&&r.action!==t.action);return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 py-0.5 border-t border-[var(--surface-subtle)]`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap 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:`min-w-0 break-all 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)(K,{size:`sm`,variant:`ghost`,onClick:()=>i?fe(t.permission,t.pattern):pe(t.permission,t.pattern),className:`px-1.5 py-0 h-5`,children:(0,$.jsx)(Y,{name:`subtract`,className:`h-3.5 w-3.5 text-muted-foreground hover:text-foreground`})})]}),(0,$.jsxs)(Cn,{value:t.action,onValueChange:e=>me(t.permission,t.pattern,e),children:[(0,$.jsx)(bn,{className:`w-[90px] shrink-0`,children:(0,$.jsx)(Tn,{children:se(t.action)})}),(0,$.jsxs)(xn,{children:[(0,$.jsx)(vn,{value:`allow`,children:e(`settings.common.permission.allow`)}),(0,$.jsx)(vn,{value:`ask`,children:e(`settings.common.permission.ask`)}),(0,$.jsx)(vn,{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-wrap items-center justify-end gap-2`,children:[(0,$.jsxs)(Cn,{value:j,onValueChange:M,children:[(0,$.jsx)(bn,{className:`w-auto max-w-full sm:w-[160px]`,children:j?(0,$.jsx)(`span`,{className:`truncate`,children:ye(j)}):(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e(`settings.agents.page.permissions.permissionPlaceholder`)})}),(0,$.jsx)(xn,{children:le.map(e=>(0,$.jsx)(vn,{value:e,children:(0,$.jsx)(`div`,{className:`flex items-center justify-between gap-2 w-full`,children:(0,$.jsx)(`span`,{children:ye(e)})})},e))})]}),(0,$.jsx)(En,{value:N,onChange:e=>P(e.target.value),placeholder:e(`settings.agents.page.permissions.patternPlaceholder`),className:`h-7 min-w-0 flex-1 basis-32 font-mono text-xs`}),(0,$.jsxs)(`div`,{className:`flex gap-1`,children:[(0,$.jsx)(K,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>ve(`allow`),children:e(`settings.common.permission.allow`)}),(0,$.jsx)(K,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>ve(`ask`),children:e(`settings.common.permission.ask`)}),(0,$.jsx)(K,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>ve(`deny`),children:e(`settings.common.permission.deny`)})]})]})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground px-3 pt-2`,children:e(`settings.agents.page.permissions.lastMatchHint`)}),er(zn(k)).map((e,t)=>(0,$.jsx)(Z,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground font-mono`,children:t+1}),(0,$.jsx)(`span`,{children:e.action}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 font-mono`,children:e.resource})]}),children:(0,$.jsx)(`span`,{className:G(`typography-micro capitalize px-1.5 py-0.5 rounded`,e.effect===`allow`?`text-[var(--status-success)] bg-[var(--status-success)]/10`:e.effect===`deny`?`text-[var(--status-error)] bg-[var(--status-error)]/10`:`text-[var(--status-warning)] bg-[var(--status-warning)]/10`),children:e.effect})},`${e.action}::${e.resource}::${t}`))]})})})]})}):(0,$.jsx)(Rr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(Oo,{}),(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(Y,{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`)})]})})]})})},Uo=e=>{let t=(0,qi.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=G(`yuri-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 min-w-0 font-normal whitespace-normal [overflow-wrap:anywhere] 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 whitespace-normal [overflow-wrap:anywhere] 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)(Cr,{children:[(0,$.jsx)(kr,{asChild:!0,children:(0,$.jsx)(K,{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)(Y,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(hr,{align:`end`,className:`w-fit min-w-20`,children:s.map(Wo)})]}),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 Wo(e){let t=e.icon;return(0,$.jsxs)(ar,{onClick:t=>{t.stopPropagation(),e.onClick()},className:G(e.destructive&&`text-destructive focus:text-destructive`),children:[t&&(0,$.jsx)(Y,{name:t,className:`h-4 w-4 mr-px`}),e.label]},e.label)}var Go=e=>{let t=(0,qi.c)(8),{header:n,footer:r,children:i,className:a,variant:o}=e,s=o===void 0?`sidebar`:o,c=N(),l=s===`background`||c?`bg-background`:`bg-sidebar`,u;t[0]!==l||t[1]!==a?(u=G(`yuri-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},Ko=`__managed_workspace__`,qo=`__current_workspace__`,Jo=`Yuri`,Yo=()=>{let e=tn.getState(),t=e.settingsDefaultModel??(e.currentModelId?void 0:e.opencodeDefaultModel);if(t){let n=Zt(t);if(n?.providerId&&n?.modelId)return{providerID:n.providerId,modelID:n.modelId,variant:n.variant??e.settingsDefaultVariant}}if(e.currentProviderId&&e.currentModelId)return{providerID:e.currentProviderId,modelID:e.currentModelId,variant:e.currentVariant};let n=e.providers;for(let e of n){let t=e.models;if(Array.isArray(t)&&t.length>0){let n=t[0];if(n?.id)return{providerID:e.id,modelID:n.id}}}return null},Xo=(e=``)=>{let t=Yo();return{enabled:!0,name:e,avatarSeed:crypto.randomUUID(),defaultPrompt:``,workspacePath:null,providerID:t?.providerID??``,modelID:t?.modelID??``,variant:t?.variant??null}},Zo=e=>({avatarSeed:e.avatarSeed??e.id,enabled:e.enabled,name:e.name,defaultPrompt:e.defaultPrompt,workspacePath:e.workspacePath,providerID:e.providerID,modelID:e.modelID,variant:e.variant}),Qo=e=>({avatarSeed:e.avatarSeed,enabled:e.enabled,name:e.name,defaultPrompt:e.defaultPrompt,workspacePath:e.workspacePath,providerID:e.providerID,modelID:e.modelID,variant:e.variant??null}),$o=e=>e.label?.trim()||e.path.replace(/[\\/]+$/,``).split(/[\\/]/).filter(Boolean).at(-1)||e.path,es=e=>{let t=Array.isArray(e.schedule.times)?e.schedule.times:e.schedule.time?[e.schedule.time]:[];return Array.from(new Set(t.filter(e=>/^([01]\d|2[0-3]):([0-5]\d)$/.test(e)))).sort((e,t)=>e.localeCompare(t))},ts=e=>!!e&&typeof e==`object`&&!Array.isArray(e),ns=e=>{if(!ts(e)||!ts(e.schedule)||!ts(e.execution)||!ts(e.state))return!1;let t=e.schedule.times===void 0||Array.isArray(e.schedule.times)&&e.schedule.times.every(e=>typeof e==`string`),n=e.schedule.weekdays===void 0||Array.isArray(e.schedule.weekdays)&&e.schedule.weekdays.every(e=>typeof e==`number`),r=e.state.lastStatus===void 0||e.state.lastStatus===`idle`||e.state.lastStatus===`running`||e.state.lastStatus===`success`||e.state.lastStatus===`error`;return typeof e.id==`string`&&typeof e.name==`string`&&typeof e.enabled==`boolean`&&(e.schedule.kind===`daily`||e.schedule.kind===`weekly`||e.schedule.kind===`once`||e.schedule.kind===`cron`)&&t&&n&&r&&typeof e.execution.prompt==`string`&&typeof e.execution.providerID==`string`&&typeof e.execution.modelID==`string`},rs=(e,t)=>{let n=es(e).join(`, `)||`—`,r=e=>t(e===0?`sessions.scheduledTasks.dialog.schedule.weekdayShort.sun`:e===1?`sessions.scheduledTasks.dialog.schedule.weekdayShort.mon`:e===2?`sessions.scheduledTasks.dialog.schedule.weekdayShort.tue`:e===3?`sessions.scheduledTasks.dialog.schedule.weekdayShort.wed`:e===4?`sessions.scheduledTasks.dialog.schedule.weekdayShort.thu`:e===5?`sessions.scheduledTasks.dialog.schedule.weekdayShort.fri`:e===6?`sessions.scheduledTasks.dialog.schedule.weekdayShort.sat`:`sessions.scheduledTasks.dialog.schedule.weekdayShort.unknown`);if(e.schedule.kind===`daily`)return e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.dailyWithTimezone`,{time:n,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.daily`,{time:n});if(e.schedule.kind===`weekly`){let i=(e.schedule.weekdays??[]).map(r).join(`, `);return e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.weeklyWithTimezone`,{days:i,time:n,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.weekly`,{days:i,time:n})}if(e.schedule.kind===`once`){let n=e.schedule.date?.trim()||t(`sessions.scheduledTasks.dialog.schedule.unknownDate`),r=e.schedule.time?.trim()||`—`;return e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.onceWithTimezone`,{date:n,time:r,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.once`,{date:n,time:r})}return e.schedule.timezone?t(`sessions.scheduledTasks.dialog.schedule.cronWithTimezone`,{cron:e.schedule.cron??``,timezone:e.schedule.timezone}):t(`sessions.scheduledTasks.dialog.schedule.cron`,{cron:e.schedule.cron??``})},is={paused:{icon:`pause`,className:`text-muted-foreground`},idle:{icon:`pulse`,className:`text-muted-foreground`},running:{icon:`loader-4`,className:`text-[var(--status-warning)]`},success:{icon:`checkbox-circle`,className:`text-[var(--status-success)]`},error:{icon:`error-warning`,className:`text-[var(--status-error)]`}},as=e=>`${e.projectId}:${e.task.id}`,os=e=>{let t=(0,qi.c)(30),{assistantID:n}=e,{t:r}=He(),i=it(n),a=i.isError,o=Xe(n,a),s=Ye(a),c=new Set;for(let e of o.data?.messages??[])for(let t of e.cards)t.cardType===`schedule`&&c.add(`${t.projectID}:${t.taskID}`);let l=(i.data?.tasks??[]).flatMap(us),u;t[0]===i.data?.tasks?u=t[1]:(u=i.data?.tasks.some(ds),t[0]=i.data?.tasks,t[1]=u);let d=!!u,f=(s.data?.tasks??[]).filter(e=>c.has(as(e))),p=[...i.data?l:a?f:[]].sort(fs),m=(s.data?.failedProjectIds??[]).some(e=>Array.from(c).some(t=>t.startsWith(`${e}:`))),h=i.isPending||a&&(o.isPending||s.isPending),g=i.isError||o.isError||s.isError||m||d,_;t[2]!==o||t[3]!==a||t[4]!==s||t[5]!==i?(_=()=>{i.refetch(),a&&(o.refetch(),s.refetch())},t[2]=o,t[3]=a,t[4]=s,t[5]=i,t[6]=_):_=t[6];let v=ze(_),y=X,b;t[7]===r?b=t[8]:(b=r(`assistants.settings.scheduledTasks.title`),t[7]=r,t[8]=b);let x;t[9]===r?x=t[10]:(x=r(`assistants.settings.scheduledTasks.title`),t[9]=r,t[10]=x);let S=h&&p.length===0?(0,$.jsx)(Z,{label:r(`common.loading`),children:(0,$.jsx)(Y,{name:`loader-4`,className:`size-4 animate-spin text-muted-foreground`})}):null,C;t[11]===r?C=t[12]:(C=e=>{let t=e.task.enabled?e.task.state?.lastStatus??`idle`:`paused`,n=is[t],i=r(t===`paused`?`sessions.scheduledTasks.dialog.taskToggle.paused`:t===`running`?`sessions.scheduledTasks.dialog.status.running`:t===`success`?`sessions.scheduledTasks.dialog.status.success`:t===`error`?`sessions.scheduledTasks.dialog.status.error`:`sessions.scheduledTasks.dialog.status.idle`);return(0,$.jsxs)(Z,{className:`group relative cursor-pointer transition-colors hover:bg-interactive-hover`,label:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`flex size-7 shrink-0 items-center justify-center rounded-lg bg-[var(--surface-muted)] text-muted-foreground`,children:(0,$.jsx)(Y,{name:`calendar`,className:`size-3.5`})}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block truncate typography-ui-label font-medium text-foreground`,children:e.task.name}),(0,$.jsx)(`span`,{className:`mt-0.5 block typography-micro truncate text-muted-foreground`,children:rs(e.task,r)})]})]}),controlClassName:`min-w-fit`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 typography-micro ${n.className}`,children:[(0,$.jsx)(Y,{name:n.icon,className:`size-3.5 ${t===`running`?`animate-spin`:``}`}),i]}),(0,$.jsx)(Y,{name:`arrow-right-s`,className:`size-4`})]}),(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,className:`absolute inset-0 z-10 h-auto w-auto rounded-none bg-transparent p-0 hover:bg-transparent focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`,onClick:()=>zi(e.projectId,e.task.id),"aria-label":r(`assistants.settings.scheduledTasks.open`,{name:e.task.name}),children:(0,$.jsx)(`span`,{className:`sr-only`,children:r(`assistants.settings.scheduledTasks.open`,{name:e.task.name})})})]},as(e))},t[11]=r,t[12]=C);let w=p.map(C),T;t[13]!==g||t[14]!==v||t[15]!==r?(T=g?(0,$.jsx)(Z,{label:r(`assistants.settings.scheduledTasks.loadError`),children:(0,$.jsx)(K,{variant:`outline`,size:`sm`,onClick:v,children:r(`assistants.actions.retry`)})}):null,t[13]=g,t[14]=v,t[15]=r,t[16]=T):T=t[16];let E;t[17]!==g||t[18]!==h||t[19]!==r||t[20]!==p?(E=!h&&!g&&p.length===0?(0,$.jsx)(Z,{label:r(`assistants.settings.scheduledTasks.empty`),children:(0,$.jsx)(Y,{name:`calendar`,className:`size-4 text-muted-foreground`})}):null,t[17]=g,t[18]=h,t[19]=r,t[20]=p,t[21]=E):E=t[21];let D;return t[22]!==y||t[23]!==b||t[24]!==x||t[25]!==S||t[26]!==w||t[27]!==T||t[28]!==E?(D=(0,$.jsxs)(y,{label:b,ariaLabel:x,children:[S,w,T,E]}),t[22]=y,t[23]=b,t[24]=x,t[25]=S,t[26]=w,t[27]=T,t[28]=E,t[29]=D):D=t[29],D},ss=e=>{let t=(0,qi.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)(Y,{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},cs=e=>{let t=(0,qi.c)(67),{onItemSelect:n}=e,{t:r}=He(),i=at(),a=et(),o=i.data,s=sn(ps),c=sn(ms),l=sn(hs),[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=ze(v);if(a.isSuccess&&!a.data.supported)return null;let b;t[25]===r?b=t[26]:(b=r(`assistants.settings.description`),t[25]=r,t[26]=b);let x;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(x=e=>{e.preventDefault(),d(!0)},t[27]=x):x=t[27];let S;t[28]===r?S=t[29]:(S=r(`assistants.settings.descriptionLearnMore`),t[28]=r,t[29]=S);let C;t[30]===S?C=t[31]:(C=(0,$.jsx)(`a`,{href:`#assistant-share-welcome`,className:`underline underline-offset-2`,onClick:x,children:S}),t[30]=S,t[31]=C);let w;t[32]!==C||t[33]!==b?(w=(0,$.jsxs)(`p`,{className:`yuri-settings-group-description text-muted-foreground`,children:[b,C]}),t[32]=C,t[33]=b,t[34]=w):w=t[34];let T;t[35]===u?T=t[36]:(T=(0,$.jsx)(Sa,{open:u,onOpenChange:d}),t[35]=u,t[36]=T);let E;t[37]!==w||t[38]!==T?(E=(0,$.jsxs)($.Fragment,{children:[w,T]}),t[37]=w,t[38]=T,t[39]=E):E=t[39];let D;t[40]===r?D=t[41]:(D=r(`assistants.settings.listTitle`),t[40]=r,t[41]=D);let O;t[42]===D?O=t[43]:(O=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:D}),t[42]=D,t[43]=O);let k;t[44]===r?k=t[45]:(k=r(`assistants.settings.create`),t[44]=r,t[45]=k);let A;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(Y,{name:`add`,className:`size-4`}),t[46]=A):A=t[46];let j;t[47]!==y||t[48]!==k?(j=(0,$.jsx)(K,{"data-settings-item":`assistants.create`,variant:`ghost`,size:`icon`,onClick:y,"aria-label":k,children:A}),t[47]=y,t[48]=k,t[49]=j):j=t[49];let M;t[50]!==O||t[51]!==j?(M=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[O,j]}),t[50]=O,t[51]=j,t[52]=M):M=t[52];let N;t[53]!==a.isPending||t[54]!==n||t[55]!==c||t[56]!==s||t[57]!==o||t[58]!==i.isPending||t[59]!==r?(N=i.isPending||a.isPending?(0,$.jsxs)(`div`,{className:`yuri-settings-group-row flex items-center justify-center text-muted-foreground`,children:[(0,$.jsx)(Y,{name:`loader-4`,className:`mr-2 size-4 animate-spin`}),r(`common.loading`)]}):o?.assistants.length?o.assistants.map(e=>{let t=Ke(e.name);return(0,$.jsx)(Uo,{title:t.displayName,selected:s===e.id,onSelect:()=>{c(e.id),n?.()},icon:(0,$.jsx)(cn,{kind:`assistant`,name:e.avatarSeed??e.id,size:32,label:t.displayName||e.name,shape:`rounded`,className:`rounded-[0.5rem]`})},e.id)}):(0,$.jsx)(`div`,{className:`yuri-settings-group-row text-muted-foreground`,children:r(`assistants.settings.empty`)}),t[53]=a.isPending,t[54]=n,t[55]=c,t[56]=s,t[57]=o,t[58]=i.isPending,t[59]=r,t[60]=N):N=t[60];let P;t[61]!==M||t[62]!==N?(P=(0,$.jsx)(X,{label:M,children:N}),t[61]=M,t[62]=N,t[63]=P):P=t[63];let F;return t[64]!==E||t[65]!==P?(F=(0,$.jsx)(Go,{variant:`background`,header:E,children:P}),t[64]=E,t[65]=P,t[66]=F):F=t[66],F},ls=({onItemDeleted:e,assistantID:t,saveActionContainer:n})=>{let{t:r}=He(),i=at(),a=et(),o=i.data,s=Lt(e=>e.projects),c=sn(e=>t??e.settingsSelectedAssistantID),l=sn(e=>e.selectSettingsAssistant),u=sn(e=>e.defaultShareAssistant),d=sn(e=>e.setDefaultShareAssistant),f=sn(e=>e.createRequestRevision),p=sn(e=>e.requestCreate),[m,h]=Q.useState(Xo),[g,_]=Q.useState(!1),v=Q.useRef(0),y=o?.assistants.find(e=>e.id===c)??null,b=y?Ke(y.name):null,x=Ke(m.name),S=m.workspacePath??y?.managedWorkspacePath??null,C=qt(S,{enabled:!0}).data??[];Q.useEffect(()=>{y&&h(Zo(y))},[y]),Q.useEffect(()=>{t===void 0&&i.isSuccess&&c&&c!==`new`&&!y&&l(null)},[t,l,y,c,i.isSuccess]),Q.useEffect(()=>{c!==`new`||f<=v.current||(v.current=f,h(Xo(o?.assistants.length?``:Jo)),window.requestAnimationFrame(()=>document.getElementById(`assistant-name`)?.focus()))},[f,c,o?.assistants.length]),Q.useEffect(()=>{i.isSuccess&&a.data?.serverInstanceID&&u?.serverInstanceID===a.data.serverInstanceID&&!o?.assistants.some(e=>e.id===u.assistantID)&&d(null)},[a.data,u,d,o?.assistants,i.isSuccess]),Q.useEffect(()=>{i.isSuccess&&qe()},[o?.revision,i.isSuccess]);let w=(e,t)=>{h(n=>({...n,[e]:t}))},T=ze(()=>p()),E=ze(async()=>{if(!(t!==void 0&&!y)){if(!m.name.trim()||!m.providerID||!m.modelID){Ie.error(r(`assistants.settings.validation.required`));return}_(!0);try{let e=y?await tt(y,Qo(m)):await Ze(m);t===void 0&&l(e.id),Ie.success(r(`assistants.settings.toast.saved`))}catch{Ie.error(r(`assistants.settings.toast.saveFailed`))}finally{_(!1)}}}),D=ze(async()=>{if(!(!y||!window.confirm(r(`assistants.settings.deleteConfirm`,{name:y.name})))){_(!0);try{if(await nt(y),u?.assistantID===y.id){let e=await Qe();e.serverInstanceID&&u.serverInstanceID===e.serverInstanceID&&d(null)}t===void 0&&l(null),e?.(),Ie.success(r(`assistants.settings.toast.deleted`))}catch{Ie.error(r(`assistants.settings.toast.deleteFailed`))}finally{_(!1)}}}),O=ze(async(e,t)=>{if(!t){d(null),Je();return}try{let t=await Qe();if(!t.supported||!t.serverInstanceID)return;d({serverInstanceID:t.serverInstanceID,assistantID:e}),await Je()}catch{Ie.error(r(`assistants.settings.toast.toggleFailed`))}}),k=m.workspacePath===null?null:s.find(e=>e.path===m.workspacePath)??null,A=m.workspacePath!==null&&!k?m.workspacePath:null,j=m.workspacePath===null?Ko:k?k.id:qo,M=m.workspacePath===null?(0,$.jsx)(ss,{name:r(`assistants.settings.workspacePlaceholder`),icon:`cloud`}):k?(0,$.jsx)(ss,{name:$o(k),path:k.path}):(0,$.jsx)(ss,{name:r(`assistants.settings.workspaceCurrentPath`),path:A??``,icon:`history`});return a.isSuccess&&!a.data.supported?null:i.isPending||a.isPending?(0,$.jsxs)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:[(0,$.jsx)(Y,{name:`loader-4`,className:`mr-2 size-4 animate-spin`}),r(`common.loading`)]}):i.isError&&!o||t!==void 0&&!y?(0,$.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3 px-6 text-center`,children:[(0,$.jsx)(Y,{name:`cloud-off`,className:`size-6 text-muted-foreground`}),(0,$.jsx)(`p`,{className:`typography-ui text-muted-foreground`,children:r(`assistants.state.unavailable`)}),(0,$.jsx)(K,{variant:`outline`,size:`sm`,onClick:()=>void i.refetch(),children:r(`assistants.actions.retry`)})]}):(0,$.jsx)(Rr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[i.isError&&o?(0,$.jsx)(`p`,{className:`mb-4 px-2 typography-meta text-[var(--status-warning)]`,children:r(`assistants.state.staleSnapshot`)}):null,c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Xr,{actions:(0,$.jsxs)($.Fragment,{children:[y?(0,$.jsx)(K,{variant:`ghost`,size:`icon`,onClick:D,disabled:g,className:`text-[var(--status-error)]`,"aria-label":r(`assistants.settings.delete`),title:r(`assistants.settings.delete`),children:(0,$.jsx)(Y,{name:`delete-bin`,className:`size-4`})}):null,n?null:(0,$.jsxs)(K,{size:`sm`,onClick:E,disabled:g,"aria-busy":g,children:[g?(0,$.jsx)(Y,{name:`loader-4`,className:`size-4 animate-spin`}):null,r(`assistants.settings.save`)]})]}),children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,$.jsxs)(`div`,{className:`group/avatar relative shrink-0`,children:[(0,$.jsx)(cn,{kind:`assistant`,name:m.avatarSeed??y?.id??`new`,size:40,label:x.displayName||m.name||r(`assistants.settings.create`),shape:`rounded`,className:`rounded-[0.5rem]`}),(0,$.jsx)(K,{variant:`link`,size:`icon`,disabled:g,className:`absolute inset-0 h-full w-full p-0 text-muted-foreground opacity-0 transition-opacity hover:no-underline group-hover/avatar:opacity-100 group-focus-within/avatar:opacity-100 [@media(hover:none)]:opacity-100`,"aria-label":r(`assistants.settings.randomAvatar`),title:r(`assistants.settings.randomAvatar`),onClick:()=>w(`avatarSeed`,crypto.randomUUID()),children:(0,$.jsx)(`span`,{className:`absolute -right-1 -bottom-1 flex size-5 items-center justify-center rounded-full bg-[var(--yuri-settings-avatar-action-background)] text-[var(--yuri-settings-avatar-action-foreground)] shadow-sm`,children:(0,$.jsx)(Y,{name:`refresh`,className:`size-3.5`})})})]}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h2`,{className:`truncate typography-ui-header font-semibold text-foreground`,children:y?b?.displayName:r(`assistants.settings.create`)}),m.providerID&&m.modelID?(0,$.jsx)(`p`,{className:`mt-0.5 truncate typography-micro leading-none text-muted-foreground/70`,children:`${m.providerID}/${m.modelID}`}):null]})]})}),(0,$.jsxs)(X,{children:[(0,$.jsx)(Z,{itemId:`assistants.name`,label:r(`assistants.settings.name`),children:(0,$.jsx)(En,{id:`assistant-name`,value:m.name,onChange:e=>w(`name`,e.target.value),className:`min-w-0 flex-1`})}),(0,$.jsx)(Z,{label:r(`assistants.settings.enabled`),children:(0,$.jsx)(gn,{checked:m.enabled,onChange:e=>w(`enabled`,e),ariaLabel:r(`assistants.settings.enabled`)})}),y?(0,$.jsx)(Z,{itemId:`assistants.default-share`,label:r(`assistants.settings.defaultShare`),children:(0,$.jsx)(gn,{checked:u?.assistantID===y.id&&u.serverInstanceID===a.data?.serverInstanceID,onChange:e=>void O(y.id,e),ariaLabel:r(`assistants.settings.defaultShare`)})}):null]}),(0,$.jsx)(di,{itemId:`assistants.prompt`,label:r(`assistants.settings.defaultPrompt`),className:`yuri-settings-split-row-stacked`,children:(0,$.jsx)(zr,{embedded:!0,id:`assistant-prompt`,value:m.defaultPrompt,onChange:e=>w(`defaultPrompt`,e.target.value),placeholder:r(`assistants.settings.defaultPromptPlaceholder`),rows:12,outerClassName:`min-h-[240px] max-h-[70vh]`})}),(0,$.jsx)(X,{label:r(`assistants.settings.runtime`),children:(0,$.jsx)(Z,{itemId:`assistants.model`,label:r(`assistants.settings.model`),children:(0,$.jsx)(Vn,{providerId:m.providerID,modelId:m.modelID,variant:m.variant??``,providers:C,onChange:(e,t,n)=>h(r=>({...r,providerID:e,modelID:t,variant:n||null})),className:`yuri-settings-inline-value`})})}),(0,$.jsx)(di,{itemId:`assistants.workspace`,label:r(`assistants.settings.workspace`),description:r(`assistants.settings.workspaceChangeHint`),descriptionPlacement:`outside`,children:(0,$.jsxs)(Cn,{value:j,onValueChange:e=>{if(e===Ko){w(`workspacePath`,null);return}let t=s.find(t=>t.id===e);t&&w(`workspacePath`,t.path)},children:[(0,$.jsx)(bn,{title:m.workspacePath??r(`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)(Tn,{children:M})}),(0,$.jsxs)(xn,{align:`start`,className:`w-[min(32rem,calc(100vw-2rem))]`,children:[(0,$.jsx)(vn,{value:Ko,children:(0,$.jsx)(ss,{name:r(`assistants.settings.workspacePlaceholder`),icon:`cloud`})}),s.map(e=>(0,$.jsx)(vn,{value:e.id,children:(0,$.jsx)(ss,{name:$o(e),path:e.path})},e.id)),A?(0,$.jsx)(vn,{value:qo,disabled:!0,children:(0,$.jsx)(ss,{name:r(`assistants.settings.workspaceCurrentPath`),path:A,icon:`history`})}):null]})]})}),y?(0,$.jsx)(os,{assistantID:y.id}):null,n?(0,Ji.createPortal)((0,$.jsx)(K,{type:`button`,size:`mobileIcon`,onClick:E,disabled:g,"aria-label":r(`assistants.settings.save`),"aria-busy":g,children:(0,$.jsx)(Y,{name:g?`loader-4`:`check`,className:g?`size-5 animate-spin motion-reduce:animate-none`:`size-5`})}),n):null]}):(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)(cn,{kind:`assistant`,name:`assistants-empty`,size:44,shape:`rounded`,className:`rounded-[0.5rem]`}),(0,$.jsx)(`p`,{className:`typography-ui`,children:r(`assistants.settings.empty`)}),(0,$.jsxs)(K,{"data-settings-item":`assistants.create`,size:`sm`,onClick:T,children:[(0,$.jsx)(Y,{name:`add`,className:`size-4`}),r(`assistants.settings.create`)]})]})]})})};function us(e){return ns(e.task)?[{projectId:e.projectID,task:e.task}]:[]}function ds(e){return!ns(e.task)}function fs(e,t){return e.task.enabled===t.task.enabled?e.task.name.localeCompare(t.task.name):e.task.enabled?-1:1}function ps(e){return e.settingsSelectedAssistantID}function ms(e){return e.selectSettingsAssistant}function hs(e){return e.requestCreate}var gs=`~/.config/opencode/AGENTS.md`,_s=async(e,t)=>{let n=await e.json().catch(()=>null);return typeof n?.error==`string`&&n.error.trim()?n.error:t},vs=e=>e.length>0&&!e.endsWith(`
|
|
2
2
|
`)?`${e}\n`:e,ys={prompt:``,responseStyleEnabled:!1,responseStylePreset:`concise`,responseStyleCustomInstructions:``},bs=(e,t)=>e===`custom`?t:ut(e),xs=e=>e===`custom`?`custom`:_t(e)?e:`concise`,Ss={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`},Cs=async(e,t)=>{let n=await p(`/api/config/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(e)});if(!n.ok)throw Error(await _s(n,t));return n.json().catch(()=>null)},ws=()=>{let{t:e}=He(),t=Q.useSyncExternalStore(r,i,i),[n,a]=Q.useState(``),[o,s]=Q.useState(ys.responseStyleEnabled),[c,l]=Q.useState(ys.responseStylePreset),[u,d]=Q.useState(ys.responseStyleCustomInstructions),[f,m]=Q.useState(!1),[h,g]=Q.useState(!1),[_,v]=Q.useState(!1),[y,b]=Q.useState(``),x=Q.useRef(null),S=Q.useRef(null),C=Q.useRef(0),w=Q.useRef(Promise.resolve());Q.useEffect(()=>{let e=!0;return g(!1),x.current=null,S.current=null,C.current+=1,A(t).then(n=>{if(!e||t!==i())return;let r={enabled:n.responseStyleEnabled===!0,preset:xs(n.responseStylePreset),custom:typeof n.responseStyleCustomInstructions==`string`?n.responseStyleCustomInstructions:``};s(r.enabled),l(r.preset),d(r.custom),Ht({enabled:r.enabled,preset:r.preset,customInstructions:r.custom},t),x.current=r,S.current=r,g(!0)}).catch(t=>{e&&t?.name!==`AbortError`&&console.warn(`Failed to load behavior settings:`,t)}),()=>{e=!1,C.current+=1}},[t]),Q.useEffect(()=>{let e=new AbortController,n=!0;return m(!1),v(!1),(async()=>{try{let r=await p(`/api/behavior/agents-md`,{method:`GET`,headers:{Accept:`application/json`},signal:e.signal});if(!r.ok)throw Error(`Behavior prompt request failed (${r.status})`);let o=await r.json().catch(()=>null);if(typeof o?.content!=`string`)throw Error(`Invalid behavior prompt response`);if(!n||t!==i())return;a(o.content),b(o.content),m(!0)}catch(e){n&&e?.name!==`AbortError`&&console.warn(`Failed to load behavior prompt:`,e)}})(),()=>{n=!1,e.abort()}},[t]),Q.useEffect(()=>{if(!h)return;let n={enabled:o,preset:c,custom:u},r=S.current;if(r&&r.enabled===n.enabled&&r.preset===n.preset&&r.custom===n.custom)return;S.current=n;let a=C.current+1;C.current=a;let f=setTimeout(()=>{let r=async()=>{if(t===i())try{let r=await Cs({responseStyleEnabled:n.enabled,responseStylePreset:n.preset,responseStyleCustomInstructions:n.custom},e(`settings.behavior.page.toast.saveFailed`));if(t!==i())return;let o=L(r),c={enabled:o.responseStyleEnabled??n.enabled,preset:o.responseStylePreset??n.preset,custom:o.responseStyleCustomInstructions??n.custom};if(Ht({enabled:c.enabled,preset:c.preset,customInstructions:c.custom},t),P({responseStyleEnabled:c.enabled,responseStylePreset:c.preset,responseStyleCustomInstructions:c.custom},t),x.current=c,a!==C.current)return;S.current=c,s(c.enabled),l(c.preset),d(c.custom)}catch(n){if(t===i()&&a===C.current){let t=x.current;S.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`);q.error(r)}}};w.current=w.current.then(r,r)},400);return()=>clearTimeout(f)},[o,c,u,h,e,t]);let T=bs(c,u),E=n!==y;return(0,$.jsx)(Rr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`yuri-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)(X,{itemId:`behavior.system-prompt`,actions:(0,$.jsx)(K,{onClick:async()=>{let r=t;if(r===i()){v(!0);try{let t=vs(n),o=await p(`/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 _s(o,e(`settings.behavior.page.toast.saveFailed`)));if(r!==i()||(await Cs({globalBehaviorPrompt:t},e(`settings.behavior.page.toast.saveFailed`)),r!==i()))return;a(t),b(t),q.success(e(`settings.behavior.page.toast.saved`))}catch(t){if(r!==i())return;console.error(`Failed to save behavior:`,t);let n=t instanceof Error?t.message:e(`settings.behavior.page.toast.saveFailed`);q.error(n)}finally{r===i()&&v(!1)}}},disabled:_||!E||!f,size:`sm`,"aria-busy":_,children:e(_?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)}),label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:e(`settings.behavior.page.section.systemPrompt`)}),(0,$.jsxs)(kn,{children:[(0,$.jsx)(Dn,{asChild:!0,children:(0,$.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(On,{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:gs})})]})})]})]}),children:(0,$.jsx)(`div`,{className:`yuri-settings-group-row flex flex-col gap-3`,children:(0,$.jsx)(zr,{embedded:!0,value:n,onChange:e=>a(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,$.jsxs)(X,{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)(kn,{children:[(0,$.jsx)(Dn,{asChild:!0,children:(0,$.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(On,{sideOffset:8,className:`max-w-xs`,children:e(`settings.behavior.page.responseStyle.tooltip`)})]})]}),children:[(0,$.jsxs)(Z,{label:e(`settings.behavior.page.responseStyle.enable`),children:[(0,$.jsx)(gn,{checked:o,onChange:s,disabled:!h,ariaLabel:e(`settings.behavior.page.responseStyle.enableAria`)}),(0,$.jsxs)(Cn,{value:c,onValueChange:e=>l(e),disabled:!h||!o,children:[(0,$.jsx)(bn,{className:`w-full sm:w-56`,children:(0,$.jsx)(Tn,{children:t=>t===`custom`?e(`settings.behavior.page.responseStyle.option.custom`):_t(t)?e(Ss[t]):null})}),(0,$.jsxs)(xn,{children:[bt.map(t=>(0,$.jsx)(vn,{value:t,children:e(Ss[t])},t)),(0,$.jsx)(vn,{value:`custom`,children:e(`settings.behavior.page.responseStyle.option.custom`)})]})]})]}),(0,$.jsx)(`div`,{className:`yuri-settings-group-row`,children:(0,$.jsx)(zr,{embedded:!0,value:T,onChange:e=>d(e.target.value),placeholder:e(`settings.behavior.page.responseStyle.customPlaceholder`),rows:5,disabled:!h||!o||c!==`custom`,outerClassName:`min-h-[120px]`,className:`w-full font-mono typography-meta bg-transparent`})})]})]})})},Ts=e=>{let t=(0,qi.c)(158),{onItemSelect:n}=e,{t:r}=He(),[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}=Da(de(Ds)),x=Ft(),S;t[0]===x.data?S=t[1]:(S=x.data??[],t[0]=x.data,t[1]=S);let C=S,w=Dt(),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(Os)),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(Ta(e)){q.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=>{Ta(e)&&(l(e),d(`reset`))},t[26]=B):B=t[26];let V=B,ee;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(ee=()=>{l(null),d(null)},t[27]=ee):ee=t[27];let H=ee,te;t[28]!==c||t[29]!==u||t[30]!==b||t[31]!==r?(te=async()=>{!c||!u||(p(!0),await b(c.name)?(u===`delete`?q.success(r(`settings.commands.sidebar.toast.commandDeleted`,{name:c.name})):q.success(r(`settings.commands.sidebar.toast.commandReset`,{name:c.name})),H()):u===`delete`?q.error(r(`settings.commands.sidebar.toast.deleteFailed`)):q.error(r(`settings.commands.sidebar.toast.resetFailed`)),p(!1))},t[28]=c,t[29]=u,t[30]=b,t[31]=r,t[32]=te):te=t[32];let ne=te,U;t[33]!==C||t[34]!==v||t[35]!==_?(U=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]=U):U=t[36];let re=U,ie;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(ie=e=>{s(e.name),a(e)},t[37]=ie):ie=t[37];let ae=ie,oe;t[38]!==C||t[39]!==y||t[40]!==b||t[41]!==i||t[42]!==o||t[43]!==_||t[44]!==r?(oe=async()=>{if(!i)return;let e=o.trim().replace(/\s+/g,`-`);if(!e){q.error(r(`settings.commands.sidebar.toast.commandNameRequired`));return}if(e===i.name){a(null);return}if(C.some(t=>t.name===e)){q.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)?(q.success(`Command renamed to "${e}"`),_(e)):q.error(r(`settings.commands.sidebar.toast.removeOldAfterRenameFailed`)):q.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]=oe):oe=t[45];let se=oe,ce,le,ue;if(t[46]!==N||t[47]!==L||t[48]!==z||t[49]!==re||t[50]!==n||t[51]!==m||t[52]!==g||t[53]!==_||t[54]!==r){let e=N.filter(Ta),i=N.filter(ks),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)(Y,{name:`add`,className:`h-4 w-4`}),t[64]=c):c=t[64];let l;t[65]!==L||t[66]!==s?(l=(0,$.jsx)(K,{"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;ce=`yuri-settings-page-content h-full overflow-y-auto bg-background p-3`,t[71]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,$.jsx)(X,{children:(0,$.jsx)(`div`,{className:`yuri-settings-group-row`,children:(0,$.jsx)(to,{})})}),t[71]=le):le=t[71],ue=(0,$.jsx)($.Fragment,{children:N.length===0?(0,$.jsx)(X,{label:d,children:(0,$.jsxs)(`div`,{className:`yuri-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(Y,{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)(X,{label:r(`settings.commands.sidebar.section.builtIn`),children:[...e].sort(As).map(e=>(0,$.jsx)(Es,{command:e,isSelected:g===e.name,onSelect:()=>{_(e.name),n?.()},onReset:()=>V(e),onDuplicate:()=>re(e),isMenuOpen:m===e.name,onMenuOpenChange:t=>h(t?e.name:null)},e.name))}),i.length>0?(0,$.jsx)(X,{label:d,children:[...i].sort(js).map(e=>(0,$.jsx)(Es,{command:e,isSelected:g===e.name,onSelect:()=>{_(e.name),n?.()},onRename:()=>ae(e),onDelete:()=>z(e),onDuplicate:()=>re(e),isMenuOpen:m===e.name,onMenuOpenChange:t=>h(t?e.name:null)},e.name))}):(0,$.jsx)(X,{label:d,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]})}),t[46]=N,t[47]=L,t[48]=z,t[49]=re,t[50]=n,t[51]=m,t[52]=g,t[53]=_,t[54]=r,t[55]=ce,t[56]=le,t[57]=ue}else ce=t[55],le=t[56],ue=t[57];let fe=c!==null&&u!==null,pe;t[72]===f?pe=t[73]:(pe=e=>{!e&&!f&&H()},t[72]=f,t[73]=pe);let me;t[74]!==u||t[75]!==r?(me=r(u===`delete`?`settings.commands.sidebar.dialog.deleteTitle`:`settings.commands.sidebar.dialog.resetTitle`),t[74]=u,t[75]=r,t[76]=me):me=t[76];let he;t[77]===me?he=t[78]:(he=(0,$.jsx)(pn,{children:me}),t[77]=me,t[78]=he);let ge;t[79]!==c?.name||t[80]!==u||t[81]!==r?(ge=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]=ge):ge=t[82];let _e;t[83]===ge?_e=t[84]:(_e=(0,$.jsx)(mn,{children:ge}),t[83]=ge,t[84]=_e);let ve;t[85]!==he||t[86]!==_e?(ve=(0,$.jsxs)(un,{children:[he,_e]}),t[85]=he,t[86]=_e,t[87]=ve):ve=t[87];let ye;t[88]===r?ye=t[89]:(ye=r(`settings.common.actions.cancel`),t[88]=r,t[89]=ye);let be;t[90]!==f||t[91]!==ye?(be=(0,$.jsx)(K,{size:`sm`,variant:`ghost`,onClick:H,disabled:f,children:ye}),t[90]=f,t[91]=ye,t[92]=be):be=t[92];let xe;t[93]!==u||t[94]!==r?(xe=r(u===`delete`?`settings.common.actions.delete`:`settings.common.actions.reset`),t[93]=u,t[94]=r,t[95]=xe):xe=t[95];let Se;t[96]!==ne||t[97]!==f||t[98]!==xe?(Se=(0,$.jsx)(K,{size:`sm`,onClick:ne,disabled:f,children:xe}),t[96]=ne,t[97]=f,t[98]=xe,t[99]=Se):Se=t[99];let W;t[100]!==be||t[101]!==Se?(W=(0,$.jsxs)(dn,{children:[be,Se]}),t[100]=be,t[101]=Se,t[102]=W):W=t[102];let Ce;t[103]!==ve||t[104]!==W?(Ce=(0,$.jsxs)(fn,{className:`max-w-md`,children:[ve,W]}),t[103]=ve,t[104]=W,t[105]=Ce):Ce=t[105];let we;t[106]!==fe||t[107]!==pe||t[108]!==Ce?(we=(0,$.jsx)(hn,{open:fe,onOpenChange:pe,children:Ce}),t[106]=fe,t[107]=pe,t[108]=Ce,t[109]=we):we=t[109];let Te=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 Oe;t[113]===De?Oe=t[114]:(Oe=(0,$.jsx)(pn,{children:De}),t[113]=De,t[114]=Oe);let ke=i?.name??``,Ae;t[115]!==r||t[116]!==ke?(Ae=r(`settings.commands.sidebar.renameDialog.description`,{name:ke}),t[115]=r,t[116]=ke,t[117]=Ae):Ae=t[117];let je;t[118]===Ae?je=t[119]:(je=(0,$.jsx)(mn,{children:Ae}),t[118]=Ae,t[119]=je);let Me;t[120]!==Oe||t[121]!==je?(Me=(0,$.jsxs)(un,{children:[Oe,je]}),t[120]=Oe,t[121]=je,t[122]=Me):Me=t[122];let Ne;t[123]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=e=>s(e.target.value),t[123]=Ne):Ne=t[123];let Pe;t[124]===r?Pe=t[125]:(Pe=r(`settings.commands.sidebar.renameDialog.placeholder`),t[124]=r,t[125]=Pe);let Fe;t[126]===se?Fe=t[127]:(Fe=e=>{e.key===`Enter`&&se()},t[126]=se,t[127]=Fe);let Ie;t[128]!==o||t[129]!==Pe||t[130]!==Fe?(Ie=(0,$.jsx)(En,{value:o,onChange:Ne,placeholder:Pe,className:`text-foreground placeholder:text-muted-foreground`,onKeyDown:Fe}),t[128]=o,t[129]=Pe,t[130]=Fe,t[131]=Ie):Ie=t[131];let Le;t[132]===Symbol.for(`react.memo_cache_sentinel`)?(Le=()=>a(null),t[132]=Le):Le=t[132];let Re;t[133]===r?Re=t[134]:(Re=r(`settings.common.actions.cancel`),t[133]=r,t[134]=Re);let ze;t[135]===Re?ze=t[136]:(ze=(0,$.jsx)(K,{size:`sm`,variant:`ghost`,onClick:Le,children:Re}),t[135]=Re,t[136]=ze);let Be;t[137]===r?Be=t[138]:(Be=r(`settings.common.actions.rename`),t[137]=r,t[138]=Be);let Ve;t[139]!==se||t[140]!==Be?(Ve=(0,$.jsx)(K,{size:`sm`,onClick:se,children:Be}),t[139]=se,t[140]=Be,t[141]=Ve):Ve=t[141];let Ue;t[142]!==ze||t[143]!==Ve?(Ue=(0,$.jsxs)(dn,{children:[ze,Ve]}),t[142]=ze,t[143]=Ve,t[144]=Ue):Ue=t[144];let We;t[145]!==Me||t[146]!==Ie||t[147]!==Ue?(We=(0,$.jsxs)(fn,{children:[Me,Ie,Ue]}),t[145]=Me,t[146]=Ie,t[147]=Ue,t[148]=We):We=t[148];let Ge;t[149]!==Te||t[150]!==We?(Ge=(0,$.jsx)(hn,{open:Te,onOpenChange:Ee,children:We}),t[149]=Te,t[150]=We,t[151]=Ge):Ge=t[151];let G;return t[152]!==ce||t[153]!==le||t[154]!==ue||t[155]!==we||t[156]!==Ge?(G=(0,$.jsxs)(`div`,{className:ce,children:[le,ue,we,Ge]}),t[152]=ce,t[153]=le,t[154]=ue,t[155]=we,t[156]=Ge,t[157]=G):G=t[157],G},Es=e=>{let t=(0,qi.c)(47),{command:n,isSelected:r,onSelect:i,onDelete:a,onReset:o,onRename:s,onDuplicate:c,isMenuOpen:l,onMenuOpenChange:u}=e,{t:d}=He(),f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=Fr(),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)(Y,{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)(Y,{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)(Y,{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)(Y,{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=G(`yuri-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||Ta(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:Ta(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)(kr,{asChild:!0,children:(0,$.jsx)(K,{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)(Y,{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)(hr,{align:`end`,className:`w-fit min-w-20`,children:_(ar)}),t[29]=_,t[30]=k);let A;t[31]!==l||t[32]!==D||t[33]!==k?(A=(0,$.jsxs)(Cr,{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)(Pi,{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)(Ii,{className:`w-fit min-w-20`,children:_(Ri)}),t[41]=_,t[42]=N);let P;return t[43]!==m||t[44]!==M||t[45]!==N?(P=(0,$.jsxs)(ji,{open:m,onOpenChange:h,children:[M,N]}),t[43]=m,t[44]=M,t[45]=N,t[46]=P):P=t[46],P};function Ds(e){return{selectedCommandName:e.selectedCommandName,setSelectedCommand:e.setSelectedCommand,setCommandDraft:e.setCommandDraft,createCommand:e.createCommand,deleteCommand:e.deleteCommand}}function Os(e){return e.name}function ks(e){return!Ta(e)}function As(e,t){return e.name.localeCompare(t.name)}function js(e,t){return e.name.localeCompare(t.name)}var Ms=()=>{let{t:e}=He(),{selectedCommandName:t,createCommand:n,updateCommand:r,commandDraft:i,setCommandDraft:a}=Da(de(e=>({selectedCommandName:e.selectedCommandName,createCommand:e.createCommand,updateCommand:e.updateCommand,commandDraft:e.commandDraft,setCommandDraft:e.setCommandDraft}))),o=Ft(),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)(Rr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(Xr,{actions:(0,$.jsxs)(K,{onClick:async()=>{let i=l?u.trim().replace(/\s+/g,`-`):t?.trim();if(!i){q.error(e(`settings.commands.sidebar.toast.commandNameRequired`));return}if(!b.trim()){q.error(e(`settings.commands.page.toast.templateRequired`));return}if(l&&s.some(e=>e.name===i)){q.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?q.success(e(l?`settings.commands.page.toast.created`:`settings.commands.page.toast.updated`)):q.error(e(l?`settings.commands.page.toast.createFailed`:`settings.commands.page.toast.updateFailed`))}catch(t){console.error(`Error saving command:`,t),q.error(e(`settings.commands.page.toast.saveUnexpectedError`))}finally{C(!1)}},disabled:S||!T,size:`sm`,"aria-busy":S,children:[S?(0,$.jsx)(Y,{name:`loader-4`,className:`size-4 animate-spin motion-reduce:animate-none`}):null,e(S?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)]}),children:(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,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)(X,{label:e(`settings.commands.page.section.identity`),children:[l&&(0,$.jsxs)(Z,{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)(En,{value:u,onChange:e=>d(e.target.value),placeholder:e(`settings.commands.page.field.commandNamePlaceholder`),className:`h-7 w-40 px-2`})]}),(0,$.jsxs)(Cn,{value:f,onValueChange:e=>p(e),children:[(0,$.jsx)(bn,{className:`w-fit min-w-[100px]`,children:(0,$.jsx)(Tn,{placeholder:e(`settings.agents.page.field.scopePlaceholder`)})}),(0,$.jsxs)(xn,{align:`end`,children:[(0,$.jsx)(vn,{value:`user`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Y,{name:`user-3`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.global`)})]})}),(0,$.jsx)(vn,{value:`project`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Y,{name:`folder`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:e(`settings.common.scope.project`)})]})})]})]})]}),(0,$.jsx)(Z,{label:e(`settings.common.field.description`),className:`yuri-settings-split-row-stacked`,children:(0,$.jsx)(zr,{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)(X,{label:e(`settings.commands.page.section.executionContext`),children:[(0,$.jsx)(Z,{itemId:`commands.agent`,label:e(`settings.commands.page.field.overrideAgent`),children:(0,$.jsx)(Or,{agentName:g,onChange:e=>_(e),className:`yuri-settings-inline-value`})}),(0,$.jsx)(Z,{itemId:`commands.model`,label:e(`settings.agents.page.field.overrideModel`),children:(0,$.jsx)(Vn,{providerId:Zt(v)?.providerId??``,modelId:Zt(v)?.modelId??``,onChange:(e,t)=>{y(e&&t?`${e}/${t}`:``)},className:`yuri-settings-inline-value`})})]}),(0,$.jsx)(di,{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:`yuri-settings-split-row-stacked`,children:(0,$.jsx)(zr,{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:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(Y,{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`)})]})})},Ns=[],Ps=e=>{switch(e){case`connected`:return`success`;case`failed`:return`error`;case`needs_auth`:case`needs_client_registration`:return`warning`;default:return`idle`}},Fs=e=>{let t=(0,qi.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=G(`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},Is=e=>{let t=(0,qi.c)(115),{onItemSelect:n}=e,{t:r}=He(),{selectedMcpName:a,setSelectedMcp:o,setMcpDraft:s,deleteMcp:c}=Na(de(Ls)),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=Ai(),t[0]=u):u=t[0];let d=u,f=Ti(d),p=Di(d),m=f.data??Ns,h;t[1]===p.data?h=t[2]:(h=p.data??{},t[1]=p.data,t[2]=h);let g=h,[_,v]=Q.useState(null),[y,b]=Q.useState(!1),[x,S]=Q.useState(null),[C,w]=Q.useState(null),[T,E]=Q.useState(!1),D;t[3]===m?D=t[4]:(D=m.filter(Rs),t[3]=m,t[4]=D);let O=D,k;t[5]===m?k=t[6]:(k=m.filter(zs),t[5]=m,t[6]=k);let A=k,j;t[7]===T?j=t[8]:(j=()=>{if(T)return;E(!0);let e=new Promise(Bs),t=i();Promise.all([Oi(l,d,t),e]).catch(Vs).finally(()=>{E(!1)})},t[7]=T,t[8]=j);let M=j,N;t[9]!==m||t[10]!==n||t[11]!==s||t[12]!==o?(N=()=>{let e=`new-mcp-server`,t=1;for(;m.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]=m,t[10]=n,t[11]=s,t[12]=o,t[13]=N):N=t[13];let P=N,F;t[14]!==c||t[15]!==_||t[16]!==r?(F=async()=>{if(!_)return;b(!0);let e=await c(_.name,{directory:Ai(),transportIdentity:i()});e.ok?e.reloadFailed?q.warning(e.message||`MCP server "${_.name}" deleted, but OpenCode reload failed`,{description:e.warning||r(`settings.mcp.sidebar.toast.refreshListIfStale`)}):q.success(e.message||r(`settings.mcp.sidebar.toast.serverDeleted`,{name:_.name})):q.error(r(`settings.mcp.sidebar.toast.deleteFailed`)),v(null),b(!1)},t[14]=c,t[15]=_,t[16]=r,t[17]=F):F=t[17];let I=F,L;t[18]===r?L=t[19]:(L=(e,t)=>(0,$.jsxs)(t,{onClick:t=>{t.stopPropagation(),v(e)},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(Y,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),r(`settings.common.actions.delete`)]}),t[18]=r,t[19]=L);let R=L,z;t[20]===r?z=t[21]:(z=r(`settings.mcp.sidebar.group.userServers`),t[20]=r,t[21]=z);let B;t[22]===z?B=t[23]:(B=(0,$.jsx)(`span`,{children:z}),t[22]=z,t[23]=B);let V;t[24]===r?V=t[25]:(V=r(`settings.mcp.sidebar.actions.refreshStatusAria`),t[24]=r,t[25]=V);let ee;t[26]===r?ee=t[27]:(ee=r(`settings.mcp.sidebar.actions.refreshStatusTitle`),t[26]=r,t[27]=ee);let H=T&&`animate-spin`,te;t[28]===H?te=t[29]:(te=G(`h-4 w-4`,H),t[28]=H,t[29]=te);let ne;t[30]===te?ne=t[31]:(ne=(0,$.jsx)(Y,{name:`refresh`,className:te}),t[30]=te,t[31]=ne);let U;t[32]!==M||t[33]!==T||t[34]!==V||t[35]!==ee||t[36]!==ne?(U=(0,$.jsx)(K,{type:`button`,size:`icon`,variant:`ghost`,disabled:T,onClick:M,"aria-label":V,title:ee,children:ne}),t[32]=M,t[33]=T,t[34]=V,t[35]=ee,t[36]=ne,t[37]=U):U=t[37];let re;t[38]===r?re=t[39]:(re=r(`settings.mcp.sidebar.actions.addServerTitle`),t[38]=r,t[39]=re);let ie;t[40]===r?ie=t[41]:(ie=r(`settings.mcp.sidebar.actions.addServerTitle`),t[40]=r,t[41]=ie);let ae;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,$.jsx)(Y,{name:`add`,className:`h-4 w-4`}),t[42]=ae):ae=t[42];let oe;t[43]!==P||t[44]!==re||t[45]!==ie?(oe=(0,$.jsx)(K,{"data-settings-item":`mcp.create`,size:`icon`,variant:`ghost`,onClick:P,"aria-label":re,title:ie,children:ae}),t[43]=P,t[44]=re,t[45]=ie,t[46]=oe):oe=t[46];let se;t[47]!==U||t[48]!==oe?(se=(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[U,oe]}),t[47]=U,t[48]=oe,t[49]=se):se=t[49];let ce;t[50]!==B||t[51]!==se?(ce=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[B,se]}),t[50]=B,t[51]=se,t[52]=ce):ce=t[52];let le=ce,ue;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,$.jsx)(X,{children:(0,$.jsx)(`div`,{className:`yuri-settings-group-row`,children:(0,$.jsx)(to,{})})}),t[53]=ue):ue=t[53];let fe;t[54]!==f.data||t[55]!==f.error||t[56]!==f.isError||t[57]!==m.length||t[58]!==g||t[59]!==n||t[60]!==x||t[61]!==O||t[62]!==R||t[63]!==C||t[64]!==a||t[65]!==s||t[66]!==o||t[67]!==p.data||t[68]!==p.error||t[69]!==p.isError||t[70]!==r||t[71]!==A||t[72]!==le?(fe=(0,$.jsx)($.Fragment,{children:f.isError&&!f.data?(0,$.jsx)(X,{label:le,children:(0,$.jsx)(`div`,{className:`yuri-settings-group-row py-12 text-center typography-meta text-[var(--status-error)]`,children:f.error.message})}):m.length===0?(0,$.jsx)(X,{label:le,children:(0,$.jsxs)(`div`,{className:`yuri-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(Y,{name:`plug`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:r(`settings.mcp.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:r(`settings.mcp.sidebar.empty.description`)})]})}):(0,$.jsxs)($.Fragment,{children:[O.length>0&&(0,$.jsx)(X,{label:r(`settings.mcp.sidebar.group.projectServers`),children:O.map(e=>{let t=Ps((g[e.name]??(p.isError&&!p.data?{status:`failed`,error:p.error.message}:void 0))?.status),i=a===e.name,c=Fr();return(0,$.jsxs)(ji,{open:C===e.name,onOpenChange:t=>w(t?e.name:null),children:[(0,$.jsxs)(Pi,{render:(0,$.jsx)(`div`,{className:G(`yuri-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,i?`bg-interactive-selection`:`hover:bg-interactive-hover`),onContextMenu:c?void 0:t=>{t.preventDefault(),w(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)(Fs,{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`?r(`settings.mcp.sidebar.serverType.localTitle`):r(`settings.mcp.sidebar.serverType.remoteTitle`),children:e.type===`local`?(0,$.jsx)(Y,{name:`server`,className:`h-3 w-3 text-muted-foreground/60 flex-shrink-0`}):(0,$.jsx)(Y,{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)(Cr,{open:x===e.name,onOpenChange:t=>{t&&w(null),S(t?e.name:null)},children:[(0,$.jsx)(kr,{asChild:!0,children:(0,$.jsx)(K,{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)(Y,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(hr,{align:`end`,className:`w-fit min-w-20`,children:R(e,ar)})]})]}),(0,$.jsx)(Ii,{className:`w-fit min-w-20`,children:R(e,Ri)})]},e.name)})}),A.length>0&&(0,$.jsx)(X,{label:le,children:A.map(e=>{let t=Ps((g[e.name]??(p.isError&&!p.data?{status:`failed`,error:p.error.message}:void 0))?.status),i=a===e.name,c=Fr();return(0,$.jsxs)(ji,{open:C===e.name,onOpenChange:t=>w(t?e.name:null),children:[(0,$.jsxs)(Pi,{render:(0,$.jsx)(`div`,{className:G(`yuri-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,i?`bg-interactive-selection`:`hover:bg-interactive-hover`),onContextMenu:c?void 0:t=>{t.preventDefault(),w(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)(Fs,{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`?r(`settings.mcp.sidebar.serverType.localTitle`):r(`settings.mcp.sidebar.serverType.remoteTitle`),children:e.type===`local`?(0,$.jsx)(Y,{name:`server`,className:`h-3 w-3 text-muted-foreground/60 flex-shrink-0`}):(0,$.jsx)(Y,{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)(Cr,{open:x===e.name,onOpenChange:t=>{t&&w(null),S(t?e.name:null)},children:[(0,$.jsx)(kr,{asChild:!0,children:(0,$.jsx)(K,{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)(Y,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(hr,{align:`end`,className:`w-fit min-w-20`,children:R(e,ar)})]})]}),(0,$.jsx)(Ii,{className:`w-fit min-w-20`,children:R(e,Ri)})]},e.name)})}),A.length===0&&(0,$.jsx)(X,{label:le,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})})]})}),t[54]=f.data,t[55]=f.error,t[56]=f.isError,t[57]=m.length,t[58]=g,t[59]=n,t[60]=x,t[61]=O,t[62]=R,t[63]=C,t[64]=a,t[65]=s,t[66]=o,t[67]=p.data,t[68]=p.error,t[69]=p.isError,t[70]=r,t[71]=A,t[72]=le,t[73]=fe):fe=t[73];let pe=_!==null,me;t[74]===y?me=t[75]:(me=e=>{!e&&!y&&v(null)},t[74]=y,t[75]=me);let he;t[76]===r?he=t[77]:(he=r(`settings.mcp.sidebar.deleteDialog.title`),t[76]=r,t[77]=he);let ge;t[78]===he?ge=t[79]:(ge=(0,$.jsx)(pn,{children:he}),t[78]=he,t[79]=ge);let _e=_?.name||``,ve;t[80]!==r||t[81]!==_e?(ve=r(`settings.mcp.sidebar.deleteDialog.descriptionPrefix`,{name:_e}),t[80]=r,t[81]=_e,t[82]=ve):ve=t[82];let ye;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(ye=(0,$.jsx)(`code`,{className:`text-foreground`,children:`opencode.json`}),t[83]=ye):ye=t[83];let be;t[84]===ve?be=t[85]:(be=(0,$.jsxs)(mn,{children:[ve,` `,ye,`.`]}),t[84]=ve,t[85]=be);let xe;t[86]!==ge||t[87]!==be?(xe=(0,$.jsxs)(un,{children:[ge,be]}),t[86]=ge,t[87]=be,t[88]=xe):xe=t[88];let Se;t[89]===Symbol.for(`react.memo_cache_sentinel`)?(Se=()=>v(null),t[89]=Se):Se=t[89];let W;t[90]===r?W=t[91]:(W=r(`settings.common.actions.cancel`),t[90]=r,t[91]=W);let Ce;t[92]!==y||t[93]!==W?(Ce=(0,$.jsx)(K,{size:`sm`,variant:`ghost`,onClick:Se,disabled:y,children:W}),t[92]=y,t[93]=W,t[94]=Ce):Ce=t[94];let we;t[95]!==y||t[96]!==r?(we=r(y?`settings.mcp.sidebar.actions.deleting`:`settings.common.actions.delete`),t[95]=y,t[96]=r,t[97]=we):we=t[97];let Te;t[98]!==I||t[99]!==y||t[100]!==we?(Te=(0,$.jsx)(K,{size:`sm`,onClick:I,disabled:y,children:we}),t[98]=I,t[99]=y,t[100]=we,t[101]=Te):Te=t[101];let Ee;t[102]!==Ce||t[103]!==Te?(Ee=(0,$.jsxs)(dn,{children:[Ce,Te]}),t[102]=Ce,t[103]=Te,t[104]=Ee):Ee=t[104];let De;t[105]!==xe||t[106]!==Ee?(De=(0,$.jsxs)(fn,{className:`max-w-md`,children:[xe,Ee]}),t[105]=xe,t[106]=Ee,t[107]=De):De=t[107];let Oe;t[108]!==pe||t[109]!==me||t[110]!==De?(Oe=(0,$.jsx)(hn,{open:pe,onOpenChange:me,children:De}),t[108]=pe,t[109]=me,t[110]=De,t[111]=Oe):Oe=t[111];let ke;return t[112]!==fe||t[113]!==Oe?(ke=(0,$.jsxs)(`div`,{className:`yuri-settings-page-content h-full overflow-y-auto bg-background p-3`,children:[ue,fe,Oe]}),t[112]=fe,t[113]=Oe,t[114]=ke):ke=t[114],ke};function Ls(e){return{selectedMcpName:e.selectedMcpName,setSelectedMcp:e.setSelectedMcp,setMcpDraft:e.setMcpDraft,deleteMcp:e.deleteMcp}}function Rs(e){return e.scope===`project`}function zs(e){return e.scope!==`project`}function Bs(e){return setTimeout(e,500)}function Vs(e){q.error(e instanceof Error?e.message:String(e))}function Hs(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Us(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function Ws(e,t){return t===void 0?{ok:!1,error:e}:{ok:!1,error:e,parsed:t}}function Gs(e,t,n){return{ok:!0,name:e,type:t,command:Ks(n),url:typeof n.url==`string`?n.url.trim():``,environment:qs(n,`env`,`environment`),headers:qs(n,`headers`),oauthEnabled:Js(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:Ys(n),enabled:Xs(n)}}function Ks(e){let t=e.command,n=e.args;if(Us(t)&&Us(n))return[...t,...n];if(Us(t))return t;if(typeof t==`string`&&t.trim()){let e=t.trim().split(/\s+/);return Us(n)?[...e,...n]:e}return Us(n)?n:[]}function qs(e,...t){for(let n of t){let t=e[n];if(!Hs(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 Js(e){if(e.oauth===!1||e.oauth===null||e.oauth===void 0||!Hs(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 Ys(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 Xs(e){return`disabled`in e&&e.disabled===!0?!1:`enabled`in e?!!e.enabled:!0}function Zs(e){let t=e.mcpServers;if(Hs(t)){let e=Object.keys(t);if(e.length===1){let n=e[0],r=t[n];if(Hs(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`&&Hs(n)});if(n.length===1){let t=n[0],r=e[t];if(Qs(r))return{name:t,entry:r}}return null}function Qs(e){return e.type===`local`||e.type===`remote`||Array.isArray(e.command)||typeof e.url==`string`||Array.isArray(e.args)}function $s(e,t){let n;try{let t=e.trim();if(!t)return Ws(`No JSON content provided`);n=JSON.parse(t)}catch(e){return Ws(e instanceof Error?`Invalid JSON: ${e.message}`:`Invalid JSON`)}if(!Hs(n))return Ws(`Expected a JSON object, not an array or primitive`);let r=n,i=r.mcpServers;if(Hs(i)){let e=Object.keys(i);if(e.length===0)return Ws(`mcpServers object is empty`,n);if(e.length>1)return Ws(`Paste one server at a time. Found `+e.length+` servers in mcpServers`,n);let t=e[0],r=i[t];return Hs(r)?Gs(t,ec(r),r):Ws(`Server entry is not a valid object`,n)}let a=r.mcp;if(Hs(a)){let e=Object.keys(a);if(e.length===0)return Ws(`mcp object is empty`,n);if(e.length>1)return Ws(`Paste one server at a time. Found `+e.length+` servers in mcp`,n);let t=e[0],r=a[t];return Hs(r)?Gs(t,ec(r),r):Ws(`Server entry in mcp is not a valid object`,n)}let o=Zs(r);if(o)return Gs(o.name,ec(o.entry),o.entry);if(Qs(r)){let e=ec(r);return Gs(typeof r.name==`string`&&r.name.trim()?r.name.trim():t?.fallbackName,e,r)}return Ws(`No recognizable MCP server configuration found in JSON`,n)}function ec(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 tc(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 nc(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 rc(e){let t=e.trim();if(!t)return{code:null};try{let e=new URL(t).searchParams.get(`code`);if(typeof e==`string`&&e.trim())return{code:e.trim()}}catch{}return{code:t}}var ic=({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(`
|
|
@@ -19,8 +19,8 @@ postgresql://user:pass@host/db`,rows:Math.max(4,e.length+1),className:`font-mono
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
}`,rows:8,className:`font-mono typography-meta resize-y`,spellCheck:!1,"data-bwignore":`true`,"data-1p-ignore":`true`}),Ge&&(0,$.jsx)(`p`,{className:`typography-micro text-[var(--status-error)]`,children:Ge}),(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,$.jsxs)(K,{variant:`outline`,size:`xs`,className:`!font-normal gap-1`,onClick:Qe,type:`button`,children:[(0,$.jsx)(Y,{name:`clipboard`,className:`h-3.5 w-3.5`}),e(`settings.mcp.page.importDialog.pasteFromClipboard`)]})})]}),(0,$.jsxs)(dn,{children:[(0,$.jsx)(K,{variant:`outline`,onClick:()=>{Be(!1),We(``),Ke(null)},className:`text-foreground`,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(K,{onClick:$e,disabled:!Ue.trim(),size:`sm`,children:e(`settings.common.actions.import`)})]})]})}),(0,$.jsx)(hn,{open:me,onOpenChange:e=>{!e&&!ge&&he(!1)},children:(0,$.jsxs)(fn,{className:`max-w-md`,children:[(0,$.jsxs)(un,{children:[(0,$.jsx)(pn,{children:e(`settings.mcp.page.deleteDialog.title`,{name:n??``})}),(0,$.jsxs)(mn,{children:[e(`settings.mcp.page.deleteDialog.descriptionPrefix`),` `,(0,$.jsx)(`code`,{className:`text-foreground`,children:`opencode.json`}),`.`,` `,e(`settings.mcp.page.deleteDialog.descriptionSuffix`)]})]}),(0,$.jsxs)(dn,{children:[(0,$.jsx)(K,{variant:`outline`,onClick:()=>he(!1),disabled:ge,className:`text-foreground`,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(K,{variant:`destructive`,size:`sm`,onClick:nt,disabled:ge,children:e(ge?`settings.mcp.page.actions.deleting`:`settings.common.actions.delete`)})]})]})})]})},mc=Q.memo(function(e){let t=(0,qi.c)(24),{checked:n,onChange:r,disabled:i,ariaLabel:a,className:o,iconClassName:s}=e,c=i!==void 0&&i,l;t[0]!==n||t[1]!==c||t[2]!==r?(l=e=>{e.preventDefault(),e.stopPropagation(),!c&&!n&&r()},t[0]=n,t[1]=c,t[2]=r,t[3]=l):l=t[3];let u=l,d;t[4]!==n||t[5]!==c||t[6]!==r?(d=e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),!c&&!n&&r())},t[4]=n,t[5]=c,t[6]=r,t[7]=d):d=t[7];let f=d,p=n?`bg-[color-mix(in_srgb,var(--primary-base)_80%,transparent)] shadow-none hover:bg-[var(--primary-base)]`:`bg-[var(--surface-muted)] shadow-[inset_0_0_0_1px_var(--interactive-border)] hover:bg-[var(--interactive-hover)]`,m;t[8]!==o||t[9]!==p?(m=G(`group/radio relative flex h-[14px] w-[14px] min-h-[14px] min-w-[14px] shrink-0 self-center items-center justify-center rounded-full outline-none`,`transition-[background-color,box-shadow] duration-200 ease-out`,p,`focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-1 focus-visible:ring-offset-background`,`disabled:cursor-not-allowed disabled:opacity-50`,o),t[8]=o,t[9]=p,t[10]=m):m=t[10];let h=!n&&`opacity-0`,g;t[11]!==s||t[12]!==h?(g=G(`block h-[5px] w-[5px] rounded-full bg-white`,h,s),t[11]=s,t[12]=h,t[13]=g):g=t[13];let _;t[14]===g?_=t[15]:(_=(0,$.jsx)(`span`,{"aria-hidden":!0,className:g}),t[14]=g,t[15]=_);let v;return t[16]!==a||t[17]!==n||t[18]!==c||t[19]!==u||t[20]!==f||t[21]!==m||t[22]!==_?(v=(0,$.jsx)(`button`,{type:`button`,role:`radio`,onClick:u,onKeyDown:f,disabled:c,"aria-checked":n,"aria-label":a,className:m,children:_}),t[16]=a,t[17]=n,t[18]=c,t[19]=u,t[20]=f,t[21]=m,t[22]=_,t[23]=v):v=t[23],v}),hc=e=>{let t=e?.trim();return t?{location:{directory:t}}:void 0},gc=()=>{let e=_e.getSdkClient().plugin;if(!e?.list||!e.check||!e.update)throw Error(`OpenCode plugin status is not available`);return e},_c=e=>{switch(e.type){case`package`:return{kind:`package`,target:e.target,version:e.version??null,outdated:e.outdated===!0,updating:e.updating===!0};case`local`:return{kind:`local`,path:e.path};case`builtin`:case`sdk`:return{kind:`builtin`};default:throw Error(`Unexpected plugin source: ${JSON.stringify(e)}`)}},vc=e=>{if(e.status===`active`)return{kind:`active`};if(e.status===`failed`)return{kind:`failed`,error:e.error,ref:e.ref??null};throw Error(`Unexpected plugin state: ${JSON.stringify(e)}`)},yc=e=>({source:_c(e.source),state:vc(e.state)}),bc=e=>{if(!Array.isArray(e))throw Error(`OpenCode plugin status payload is invalid`);return e.map(e=>yc(e))};async function xc(e,t){return bc((await gc().list(hc(e),t?{signal:t}:void 0))?.data)}async function Sc(e,t){return bc((await gc().check(hc(e),t?{signal:t}:void 0))?.data)}async function Cc(e,t,n){let r=t.trim();if(!r)throw Error(`plugin.update requires a target`);await gc().update({...hc(e),targets:[r]},n?{signal:n}:void 0)}function wc(e){return e instanceof Error&&e.message.trim()?e.message:typeof e==`string`&&e.trim()?e:`plugin operation failed`}var Tc=1500,Ec=e=>e?.trim()||null,Dc=(e,t=i())=>d.plugins.list(e,t),Oc=(e,t,n=!1,r=i())=>d.plugins.registry(e,t,n,r),kc=(e,t=i())=>d.plugins.runtime(e,t),Ac=0,jc=()=>(Ac+=1,Ac),Mc=()=>{Ac+=1},Nc=(e,t,n)=>e.getQueryData(kc(t,n)),Pc=(e=$t(),t=i())=>{let n=Ec(e);return{queryKey:Dc(n,t),queryFn:async({signal:e})=>{let t=await p(Kc(`/api/config/plugins`,n),{headers:Yc(n),signal:e});if(!t.ok)throw Error(`Failed to load plugins`);let r=await t.json();return{entries:r.entries??[],files:r.files??[]}},staleTime:5e3,retry:2}},Fc=(e,t,n=!1,r=i())=>{let a=Ec(e),o=u(t);return{queryKey:Oc(a,o,n,r),queryFn:async({signal:e})=>{let t={};for(let r of Jc(o)){let i=await p(qc(r,n,a),{headers:Yc(a),signal:e});if(!i.ok)throw Error(`Failed to load plugin registry info`);let o=await i.json();for(let e of o.results??[])t[e.spec]=e}return t},staleTime:n?0:3e5,retry:2}},Ic=(e=$t(),t=i())=>{let n=Ec(e);return{queryKey:kc(n,t),queryFn:async({signal:e})=>{let r=jc(),i=await xc(n,e);if(r!==Ac){let e=Nc(l,n,t);if(e)return e;throw Error(`Stale plugin runtime read`)}return i},staleTime:5e3,retry:!1}},Lc=(e,t,n=i())=>JSON.stringify([n,Ec(e)??``,t]),Rc=e=>{let t=(0,qi.c)(7),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let r=n,i=Lt(Xc),a;t[2]===i?a=t[3]:(a=Pc(Ec(i)??Ec(_e.getDirectory())),t[2]=i,t[3]=a);let o;return t[4]!==r.enabled||t[5]!==a?(o={...a,enabled:r.enabled},t[4]=r.enabled,t[5]=a,t[6]=o):o=t[6],ke(o)},zc=(e,t)=>{let n=(0,qi.c)(6),r=t!==void 0&&t,i=Lt(Zc),a;n[0]!==i||n[1]!==r||n[2]!==e?(a=Fc(Ec(i)??Ec(_e.getDirectory()),e,r),n[0]=i,n[1]=r,n[2]=e,n[3]=a):a=n[3];let o;return n[4]===a?o=n[5]:(o={...a},n[4]=a,n[5]=o),ke(o)},Bc=()=>{let e=(0,qi.c)(2),t=Lt(Qc),n;return e[0]===t?n=e[1]:(n=Ec(t)??Ec(_e.getDirectory()),e[0]=t,e[1]=n),n},Vc=e=>{let t=(0,qi.c)(7),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let r=n,i=Bc(),a;t[2]===i?a=t[3]:(a=Ic(i),t[2]=i,t[3]=a);let o;return t[4]!==r.enabled||t[5]!==a?(o={...a,enabled:r.enabled},t[4]=r.enabled,t[5]=a,t[6]=o):o=t[6],ke(o)},Hc=async(e,t,n)=>{let r=Ec(t);return i()===n?e.fetchQuery({...Pc(r,n),staleTime:0}):e.getQueryData(Dc(r,n))??{entries:[],files:[]}},Uc=async(e=l,t,n)=>{let r=Ec(t),a=i(),o=await Fc(r,n,!0,a).queryFn({signal:new AbortController().signal});return e.setQueryData(Oc(r,n,!1,a),o),o},Wc=async(e,t,n)=>{let r=Ec(t);if(i()!==n)return Nc(e,r,n);let a=jc(),o=await xc(r);return a!==Ac||i()!==n?Nc(e,r,n):(e.setQueryData(kc(r,n),o),o)},Gc=async(e=$t(),t=l)=>{let n=Ec(e),r=i(),a=await Sc(n);return Mc(),i()===r&&t.setQueryData(kc(n,r),a),a};function Kc(e,t){return`${e}${t?`?directory=${encodeURIComponent(t)}`:``}`}function qc(e,t,n){let r=new URLSearchParams;t&&r.set(`refresh`,`true`),n&&r.set(`directory`,n);let i=r.toString();return`/api/config/plugins/registry?${`specs=${e.map(encodeURIComponent).join(`,`)}`}${i?`&${i}`:``}`}function Jc(e){let t=[],n=[],r=0;for(let i of e){let e=encodeURIComponent(i),a=n.length===0?e.length:r+1+e.length;if(n.length>0&&a>Tc){t.push(n),n=[i],r=e.length;continue}n.push(i),r=a}return n.length>0&&t.push(n),t}function Yc(e){return e?{"x-opencode-directory":e}:void 0}function Xc(e){return e.getActiveProject?.()?.path??null}function Zc(e){return e.getActiveProject?.()?.path??null}function Qc(e){return e.getActiveProject?.()?.path??null}var $c=()=>{try{let e=Lt.getState().getActiveProject?.();if(e?.path?.trim())return e.path.trim();let t=_e.getDirectory();if(t?.trim())return t.trim()}catch(e){console.warn(`[PluginsStore] Error resolving config directory:`,e)}return null},el=5e3,tl=`__default__`,nl=new Map,rl=new Map,il=1500,al=e=>e?.trim()||tl,ol=e=>{nl.delete(al(e))},sl=ce()(ue(le((e,t)=>({entries:[],files:[],selectedId:null,isLoading:!1,registryInfo:{},isLoadingRegistry:!1,draft:null,packageUpdates:{},setSelected:t=>e({selectedId:t}),setDraft:t=>e({draft:t}),loadPlugins:async n=>{let r=$c(),a=i(),s=o(),c=()=>a===i()&&s===o()&&r===$c(),u=al(r),d=Date.now(),f=nl.get(u)??0,p=t().entries.length>0||t().files.length>0;if(!n?.force&&p&&d-f<el)return!0;let m=rl.get(u);if(!n?.force&&m)return m;let h=(async()=>{e({isLoading:!0});try{let i=n?.force?await Hc(l,r,a):await l.fetchQuery(Pc(r,a));return c()?(e({entries:i.entries??[],files:i.files??[],isLoading:!1}),nl.set(u,Date.now()),n?.force||t().loadRegistryInfo(),!0):!1}catch(t){return console.error(`[PluginsStore] Failed to load plugins:`,t),c()&&e({isLoading:!1}),!1}})();rl.set(u,h);try{return await h}finally{rl.delete(u)}},loadRegistryInfo:async n=>{let r=ul(n?.specs??t().entries.map(e=>e.spec));if(r.length===0){e({isLoadingRegistry:!1});return}e({isLoadingRegistry:!0});try{let i=$c(),a={...t().registryInfo};for(let e of dl(r)){let t=await p(ll(e,n?.force===!0,i),{headers:fl(i)});if(!t.ok)throw Error(`Failed to load plugin registry info`);let r=await gl(t);for(let e of r.results??[])a[e.spec]=e}e({registryInfo:a,isLoadingRegistry:!1})}catch(t){console.error(`[PluginsStore] Failed to load plugin registry info:`,t),e({isLoadingRegistry:!1})}},updateToLatest:async e=>{let n=t().entries.find(t=>t.id===e);if(!n)return{ok:!1};let r=t().registryInfo[n.spec];return!r||r.kind!==`npm-ok`||!r.hasUpdate||!r.latestVersion?{ok:!1}:await t().updateEntry(e,{spec:`${r.name}@${r.latestVersion}`})},updatePackage:async n=>{let r=$c(),a=i(),o=Lc(r,n,a);if(t().packageUpdates[o]?.kind===`running`)return!1;e({packageUpdates:{...t().packageUpdates,[o]:{kind:`running`}}});try{if(await Cc(r,n),i()===a)try{await Wc(l,r,a)}catch(e){console.error(`[PluginsStore] Plugin updated, but status could not be reread:`,e)}let s={...t().packageUpdates};return delete s[o],e({packageUpdates:s}),!0}catch(n){return console.error(`[PluginsStore] Failed to update plugin package:`,n),e({packageUpdates:{...t().packageUpdates,[o]:{kind:`failed`,error:wc(n)}}}),!1}},createEntry:async e=>{let n=await hl(async t=>await p(cl(`/api/config/plugins/entry`,t),{method:`POST`,headers:pl(t),body:JSON.stringify(ml(e))}));return n.ok&&t().loadRegistryInfo({specs:[e.spec],force:!0}),n},updateEntry:async(e,n)=>{let r=t().entries.find(t=>t.id===e)?.spec,i=n.spec??r,a=await hl(async t=>await p(cl(`/api/config/plugins/entry/${encodeURIComponent(e)}`,t),{method:`PATCH`,headers:pl(t),body:JSON.stringify(ml(n))}));return a.ok&&i&&t().loadRegistryInfo({specs:[i],force:!0}),a},deleteEntry:async n=>{let r=t().entries.find(e=>e.id===n),i=await hl(async e=>await p(cl(`/api/config/plugins/entry/${encodeURIComponent(n)}`,e),{method:`DELETE`,headers:fl(e)}));if(i.ok&&t().selectedId===n&&e({selectedId:null}),i.ok&&r){let n={...t().registryInfo};delete n[r.spec],e({registryInfo:n})}return i},readFile:async e=>{try{let t=$c(),n=await p(cl(`/api/config/plugins/file/${encodeURIComponent(e)}`,t),{headers:fl(t)});if(!n.ok)throw Error(`Failed to read plugin file`);return await gl(n)}catch(e){return console.error(`[PluginsStore] Failed to read plugin file:`,e),null}},createFile:async e=>hl(async t=>await p(cl(`/api/config/plugins/file`,t),{method:`POST`,headers:pl(t),body:JSON.stringify(e)})),updateFile:async(e,t)=>hl(async n=>await p(cl(`/api/config/plugins/file/${encodeURIComponent(e)}`,n),{method:`PUT`,headers:pl(n),body:JSON.stringify(t)})),deleteFile:async n=>{let r=await hl(async e=>await p(cl(`/api/config/plugins/file/${encodeURIComponent(n)}`,e),{method:`DELETE`,headers:fl(e)}));return r.ok&&t().selectedId===n&&e({selectedId:null}),r},getById:e=>t().entries.find(t=>t.id===e)??t().files.find(t=>t.id===e)}),{name:`plugins-store`,storage:be(),partialize:e=>({selectedId:e.selectedId})}),{name:`plugins-store`}));function cl(e,t){return`${e}${t?`?directory=${encodeURIComponent(t)}`:``}`}function ll(e,t,n){let r=new URLSearchParams;t&&r.set(`refresh`,`true`),n&&r.set(`directory`,n);let i=r.toString();return`/api/config/plugins/registry?${`specs=${e.map(encodeURIComponent).join(`,`)}`}${i?`&${i}`:``}`}function ul(e){return Array.from(new Set(e.map(e=>e.trim()).filter(Boolean)))}function dl(e){let t=[],n=[],r=0;for(let i of e){let e=encodeURIComponent(i),a=n.length===0?e.length:r+1+e.length;n.length>0&&a>il?(t.push(n),n=[i],r=e.length):(n.push(i),r=a)}return n.length>0&&t.push(n),t}function fl(e){return e?{"x-opencode-directory":e}:void 0}function pl(e){return{"Content-Type":`application/json`,...e?{"x-opencode-directory":e}:{}}}function ml(e){let t={};return e.spec!==void 0&&(t.spec=e.spec),e.options!==void 0&&(t.options=e.options),e.scope!==void 0&&(t.scope=e.scope),t}async function hl(e){let t=i(),n=o();try{let r=$c(),a=await e(r),s=await gl(a).catch(()=>null);if(!a.ok)throw Error(s?.error||`Failed to update plugin configuration`);if(t!==i()||n!==o())return{ok:!0};ol(r);let c=await Hc(l,r,t);return r===$c()&&t===i()&&n===o()&&(sl.setState({entries:c.entries,files:c.files}),nl.set(al(r),Date.now())),{ok:!0,reloadFailed:s?.reloadFailed===!0,message:s?.message,warning:s?.warning}}catch(e){return console.error(`[PluginsStore] Failed to update plugin configuration:`,e),{ok:!1}}}async function gl(e){return await e.json()}var _l=/^[a-z0-9][a-z0-9-_.]*\.(js|ts|mjs|cjs)$/;function vl(e){let t=e.trim();if(t===``)return{ok:!0,value:void 0};try{let e=JSON.parse(t);return typeof e!=`object`||!e||Array.isArray(e)?{ok:!1}:{ok:!0,value:e}}catch{return{ok:!1}}}var yl=({open:e,onOpenChange:t,defaultScope:n=`user`})=>{let{t:r}=He(),i=sl(e=>e.createEntry),a=sl(e=>e.createFile),[o,s]=Q.useState(`npm`),[c,l]=Q.useState(``),[u,d]=Q.useState(``),[f,p]=Q.useState(``),[m,h]=Q.useState(``),[g,_]=Q.useState(n),[v,y]=Q.useState(!1),b=Q.useCallback(()=>{l(``),d(``),p(``),h(``),_(n)},[n]);Q.useEffect(()=>{e&&(s(`npm`),b())},[e,b]);let x=e=>{e!==o&&(s(e),b())},S=Q.useMemo(()=>vl(u),[u]),C=!S.ok,w=o===`file`&&f.trim()!==``&&!_l.test(f.trim()),T=(o===`npm`||o===`path`)&&c.trim()===``,E=o===`file`&&m.trim()===``,D=o===`file`&&f.trim()===``,O=v||C||o===`npm`&&T||o===`path`&&T||o===`file`&&(D||w||E),k=async()=>{if(!O){y(!0);try{let e;e=o===`file`?await a({fileName:f.trim(),content:m,scope:g}):await i({spec:c.trim(),options:S.ok?S.value:void 0,scope:g}),e.ok?(q.success(e.message||r(`settings.plugins.toast.created`)),e.reloadFailed&&q.warning(r(`settings.plugins.toast.reloadFailed`)),t(!1)):q.error(e.message||r(`settings.plugins.sidebar.toast.deleteFailed`))}finally{y(!1)}}},A=Q.useMemo(()=>[{id:`npm`,label:r(`settings.plugins.dialog.add.tab.npm`)},{id:`path`,label:r(`settings.plugins.dialog.add.tab.path`)},{id:`file`,label:r(`settings.plugins.dialog.add.tab.file`)}],[r]);return(0,$.jsx)(hn,{open:e,onOpenChange:e=>{!e&&v||t(e)},children:(0,$.jsxs)(fn,{className:`max-w-xl`,children:[(0,$.jsxs)(un,{children:[(0,$.jsx)(pn,{children:r(`settings.plugins.dialog.add.title`)}),(0,$.jsx)(mn,{children:r(`settings.plugins.sidebar.empty.description`)})]}),(0,$.jsx)(Kr,{items:A,activeId:o,onSelect:e=>x(e),layoutMode:`fit`,variant:`active-pill`,activePillLowercase:!1,className:`h-10`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(o===`npm`||o===`path`)&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{"data-settings-item":`plugins.spec`,className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`plugin-spec`,className:`typography-ui-label text-foreground`,children:r(`settings.plugins.page.field.spec`)}),(0,$.jsx)(En,{id:`plugin-spec`,value:c,onChange:e=>l(e.target.value),placeholder:r(`settings.plugins.page.field.spec.placeholder`),"aria-invalid":!T&&void 0,disabled:v}),T&&(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:r(`settings.plugins.validation.specRequired`)})]}),(0,$.jsxs)(`div`,{"data-settings-item":`plugins.options`,className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`plugin-options`,className:`typography-ui-label text-foreground`,children:r(`settings.plugins.page.field.options`)}),(0,$.jsx)(zr,{id:`plugin-options`,value:u,onChange:e=>d(e.target.value),rows:5,className:`font-mono`,hasError:C,disabled:v}),C&&(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:r(`settings.plugins.page.field.options.invalidJson`)})]})]}),o===`file`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{"data-settings-item":`plugins.content`,className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`plugin-filename`,className:`typography-ui-label text-foreground`,children:r(`settings.plugins.page.field.fileName`)}),(0,$.jsx)(En,{id:`plugin-filename`,value:f,onChange:e=>p(e.target.value),placeholder:`my-plugin.ts`,"aria-invalid":w||void 0,disabled:v}),w&&(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:r(`settings.plugins.validation.fileName`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`plugin-content`,className:`typography-ui-label text-foreground`,children:r(`settings.plugins.page.field.content`)}),(0,$.jsx)(zr,{id:`plugin-content`,value:m,onChange:e=>h(e.target.value),rows:16,className:`font-mono`,disabled:v})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:r(`settings.plugins.page.field.scope`)}),(0,$.jsx)(`div`,{className:`flex items-center gap-4`,children:[`user`,`project`].map(e=>{let t=g===e,n=r(e===`user`?`settings.plugins.scope.user`:`settings.plugins.scope.project`);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>_(e),disabled:v,className:`flex items-center gap-2 py-1 text-left disabled:opacity-50`,children:[(0,$.jsx)(mc,{checked:t,onChange:()=>_(e),ariaLabel:n}),(0,$.jsx)(`span`,{className:G(`typography-ui-label font-normal`,t?`text-foreground`:`text-foreground/60`),children:n})]},e)})})]})]}),(0,$.jsxs)(dn,{children:[(0,$.jsx)(K,{size:`sm`,variant:`ghost`,onClick:()=>t(!1),disabled:v,children:r(`settings.plugins.dialog.add.action.cancel`)}),(0,$.jsxs)(K,{size:`sm`,onClick:()=>{k()},disabled:O,children:[v?(0,$.jsx)(Y,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin`}):null,r(`settings.plugins.dialog.add.action.submit`)]})]})]})})},bl=e=>{let t=(0,qi.c)(31),{info:n}=e,{t:r}=He();if(!n)return null;let i=xl;switch(n.kind){case`npm-ok`:{if(!n.hasUpdate||!n.latestVersion)return null;let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Y,{name:`arrow-up-s`,className:`h-3 w-3`}),t[0]=e):e=t[0];let a;t[1]===n.latestVersion?a=t[2]:(a=(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-[var(--status-success)]`,children:[e,n.latestVersion]}),t[1]=n.latestVersion,t[2]=a);let o;return t[3]!==n.currentVersion||t[4]!==n.latestVersion||t[5]!==r||t[6]!==a?(o=i(a,r(`settings.plugins.registry.badge.update.tooltip`,{current:n.currentVersion??``,latest:n.latestVersion})),t[3]=n.currentVersion,t[4]=n.latestVersion,t[5]=r,t[6]=a,t[7]=o):o=t[7],o}case`npm-missing-version`:{let e;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Y,{name:`error-warning`,className:`h-3 w-3 text-[var(--status-warning)]`}),t[8]=e):e=t[8];let a;return t[9]!==n.currentVersion||t[10]!==n.name||t[11]!==r?(a=i(e,r(`settings.plugins.registry.badge.missingVersion.tooltip`,{version:n.currentVersion,name:n.name})),t[9]=n.currentVersion,t[10]=n.name,t[11]=r,t[12]=a):a=t[12],a}case`npm-missing-package`:{let e;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Y,{name:`error-warning`,className:`h-3 w-3 text-[var(--status-error)]`}),t[13]=e):e=t[13];let a;return t[14]!==n.name||t[15]!==r?(a=i(e,r(`settings.plugins.registry.badge.missingPackage.tooltip`,{name:n.name})),t[14]=n.name,t[15]=r,t[16]=a):a=t[16],a}case`npm-malformed`:{let e;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Y,{name:`error-warning`,className:`h-3 w-3 text-[var(--status-error)]`}),t[17]=e):e=t[17];let n;return t[18]===r?n=t[19]:(n=i(e,r(`settings.plugins.registry.badge.malformed.tooltip`)),t[18]=r,t[19]=n),n}case`npm-network`:{let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Y,{name:`cloud-off`,className:`h-3 w-3 text-muted-foreground`}),t[20]=e):e=t[20];let n;return t[21]===r?n=t[22]:(n=i(e,r(`settings.plugins.registry.badge.network.tooltip`)),t[21]=r,t[22]=n),n}case`path-missing`:{let e;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Y,{name:`error-warning`,className:`h-3 w-3 text-[var(--status-error)]`}),t[23]=e):e=t[23];let a;return t[24]!==n.absolutePath||t[25]!==r?(a=i(e,r(`settings.plugins.registry.badge.pathMissing.tooltip`,{path:n.absolutePath})),t[24]=n.absolutePath,t[25]=r,t[26]=a):a=t[26],a}case`path-unreadable`:{let e;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Y,{name:`error-warning`,className:`h-3 w-3 text-[var(--status-warning)]`}),t[27]=e):e=t[27];let a;return t[28]!==n.absolutePath||t[29]!==r?(a=i(e,r(`settings.plugins.registry.badge.pathUnreadable.tooltip`,{path:n.absolutePath})),t[28]=n.absolutePath,t[29]=r,t[30]=a):a=t[30],a}case`path-ok`:return null;default:return null}};function xl(e,t){return(0,$.jsxs)(kn,{children:[(0,$.jsx)(Dn,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex shrink-0 items-center gap-0.5 text-xs`,children:e})}),(0,$.jsx)(On,{children:t})]})}var Sl=e=>e.startsWith(`/`)||/^[A-Za-z]:[\\/]/.test(e),Cl=e=>{let t=e.replace(/\\/g,`/`),n=[],[r,...i]=t.split(`/`);for(let e of i)if(e!==``&&e!==`.`){if(e===`..`){n.pop();continue}n.push(e)}return`${/^[A-Za-z]:$/.test(r)?`${r.toUpperCase()}/`:`/`}${n.join(`/`)}`},wl=e=>Cl(`${e.replace(/\\/g,`/`)}/..`),Tl=e=>{try{let t=decodeURIComponent(new URL(e).pathname);return/^\/[A-Za-z]:\//.test(t)?t.slice(1):t}catch{return null}};function El(e,t){if(e.startsWith(`file://`)){let t=Tl(e);return t?{kind:`local`,path:Cl(t)}:null}return e.startsWith(`./`)||e.startsWith(`../`)?t?{kind:`local`,path:Cl(`${wl(t)}/${e}`)}:null:Sl(e)?{kind:`local`,path:Cl(e)}:{kind:`package`,target:e}}function Dl(e){return e?{kind:`local`,path:Cl(e)}:null}var Ol=(e,t)=>{if(e.kind===`package`)return t.source.kind===`package`&&t.source.target===e.target;if(t.source.kind!==`local`)return!1;let n=Cl(t.source.path);return n===e.path||n.startsWith(`${e.path}/`)};function kl(e,t){return t.filter(t=>Ol(e,t))}function Al(e){let t=e.find(e=>e.state.kind===`failed`);if(t&&t.state.kind===`failed`)return{kind:`failed`,error:t.state.error,ref:t.state.ref};let n=e[0];return n?{kind:`active`,version:n.source.kind===`package`?n.source.version:null}:{kind:`notReported`}}function jl(e){let t=e.flatMap(e=>e.source.kind===`package`?[e.source]:[]);return t.some(e=>e.updating)?`updating`:t.some(e=>e.outdated)?`available`:`none`}function Ml(e){let t=(0,qi.c)(18),n=Vc(),r;t[0]===n?r=t[1]:(r=()=>{n.refetch()},t[0]=n,t[1]=r);let i=ze(r),a;bb0:{if(n.isPending&&n.data===void 0){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e={kind:`loading`},t[2]=e):e=t[2],a=e;break bb0}if(n.data===void 0||!e){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e={kind:`unknown`},t[3]=e):e=t[3],a=e;break bb0}let r,i,o;if(t[4]!==n.data||t[5]!==e){let a=kl(e,n.data);r=`known`,i=Al(a),o=jl(a),t[4]=n.data,t[5]=e,t[6]=r,t[7]=i,t[8]=o}else r=t[6],i=t[7],o=t[8];let s;t[9]!==r||t[10]!==i||t[11]!==o||t[12]!==e?(s={kind:r,load:i,update:o,target:e},t[9]=r,t[10]=i,t[11]=o,t[12]=e,t[13]=s):s=t[13],a=s}let o=a,s;return t[14]!==n.isFetching||t[15]!==i||t[16]!==o?(s={status:o,retry:i,isRefreshing:n.isFetching},t[14]=n.isFetching,t[15]=i,t[16]=o,t[17]=s):s=t[17],s}function Nl(e){let t=(0,qi.c)(5),n=Bc(),r;t[0]!==n||t[1]!==e?(r=e?.kind===`package`?Lc(n,e.target):null,t[0]=n,t[1]=e,t[2]=r):r=t[2];let i=r,a;return t[3]===i?a=t[4]:(a=e=>i?e.packageUpdates[i]??null:null,t[3]=i,t[4]=a),sl(a)}var Pl=e=>{let t=(0,qi.c)(35),{target:n}=e,{t:r}=He(),{status:i}=Ml(n),a=Nl(n);if(i.kind!==`known`)return null;let o;bb0:{if(i.update===`updating`||a?.kind===`running`){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Y,{name:`loader-4`,className:`h-3 w-3 animate-spin text-muted-foreground`}),t[0]=e):e=t[0];let n;t[1]===r?n=t[2]:(n=r(`settings.plugins.update.running`),t[1]=r,t[2]=n);let i;t[3]===n?i=t[4]:(i={icon:e,label:n},t[3]=n,t[4]=i),o=i;break bb0}if(i.load.kind===`failed`){let e;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Y,{name:`error-warning`,className:`h-3 w-3 text-[var(--status-error)]`}),t[5]=e):e=t[5];let n;t[6]===r?n=t[7]:(n=r(`settings.plugins.status.failed.title`),t[6]=r,t[7]=n);let i;t[8]===n?i=t[9]:(i={icon:e,label:n},t[8]=n,t[9]=i),o=i;break bb0}if(i.load.kind===`notReported`){let e;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Y,{name:`time`,className:`h-3 w-3 text-muted-foreground`}),t[10]=e):e=t[10];let n;t[11]===r?n=t[12]:(n=r(`settings.plugins.status.notReported.title`),t[11]=r,t[12]=n);let i;t[13]===n?i=t[14]:(i={icon:e,label:n},t[13]=n,t[14]=i),o=i;break bb0}if(i.update===`available`){let e;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Y,{name:`arrow-up-s`,className:`h-3 w-3 text-[var(--status-success)]`}),t[15]=e):e=t[15];let n;t[16]===r?n=t[17]:(n=r(`settings.plugins.update.available.title`),t[16]=r,t[17]=n);let i;t[18]===n?i=t[19]:(i={icon:e,label:n},t[18]=n,t[19]=i),o=i;break bb0}let e;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Y,{name:`checkbox-circle`,className:`h-3 w-3 text-[var(--status-success)]`}),t[20]=e):e=t[20];let n;t[21]!==i.load.version||t[22]!==r?(n=i.load.version?r(`settings.plugins.status.loadedVersion`,{version:i.load.version}):r(`settings.plugins.status.loaded`),t[21]=i.load.version,t[22]=r,t[23]=n):n=t[23];let s;t[24]===n?s=t[25]:(s={icon:e,label:n},t[24]=n,t[25]=s),o=s}let s=o,c;t[26]!==s.icon||t[27]!==s.label||t[28]!==i.load.kind?(c=(0,$.jsx)(Dn,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex shrink-0 items-center`,"aria-label":s.label,"data-plugin-load-state":i.load.kind,children:s.icon})}),t[26]=s.icon,t[27]=s.label,t[28]=i.load.kind,t[29]=c):c=t[29];let l;t[30]===s.label?l=t[31]:(l=(0,$.jsx)(On,{children:s.label}),t[30]=s.label,t[31]=l);let u;return t[32]!==c||t[33]!==l?(u=(0,$.jsxs)(kn,{children:[c,l]}),t[32]=c,t[33]=l,t[34]=u):u=t[34],u},Fl=e=>e.parsedKind===`npm`?`code-box`:`folder`,Il=e=>{let t=(0,qi.c)(167),{onItemSelect:n,onAddClick:r}=e,{t:i}=He(),{selectedId:a,setSelected:o,deleteEntry:s,deleteFile:c,loadPlugins:l,updateEntry:u,updatePackage:d,packageUpdates:f}=sl(de(Ll)),p=Rc();p.data?.entries;let m;t[0]===p.data?.entries?m=t[1]:(m=p.data?.entries??[],t[0]=p.data?.entries,t[1]=m);let h=m,g;t[2]===p.data?.files?g=t[3]:(g=()=>p.data?.files??[],t[2]=p.data?.files,t[3]=g),p.data?.files;let _;t[4]===g?_=t[5]:(_=g(),t[4]=g,t[5]=_);let v=_,y;t[6]===h?y=t[7]:(y=h.map(Rl),t[6]=h,t[7]=y);let b=y,{data:x,isFetching:S}=zc(b,!1),C;t[8]===x?C=t[9]:(C=x??{},t[8]=x,t[9]=C);let w=C,T=Bc(),E=Vc(),D=E.isError&&E.data===void 0,[O,k]=Q.useState(!1),[A,j]=Q.useState(null),[M,N]=Q.useState(!1),[P,F]=Q.useState(!1),I,L;t[10]===l?(I=t[11],L=t[12]):(I=()=>{l()},L=[l],t[10]=l,t[11]=I,t[12]=L),Q.useEffect(I,L);let R,z;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(R=()=>{let e=()=>F(!0);return window.addEventListener(`yuri:settings-open-plugin-add`,e),()=>window.removeEventListener(`yuri:settings-open-plugin-add`,e)},z=[],t[13]=R,t[14]=z):(R=t[13],z=t[14]),Q.useEffect(R,z);let B;if(t[15]!==h||t[16]!==v){B=new Map;for(let e of h)B.set(e.id,El(e.spec,e.sourcePath));for(let e of v)B.set(e.id,Dl(e.absolutePath));t[15]=h,t[16]=v,t[17]=B}else B=t[17];let V=B,ee;if(t[18]!==T||t[19]!==h||t[20]!==f||t[21]!==E.data||t[22]!==V){bb0:{let e=E.data,t=new Map;if(!e){ee=t;break bb0}for(let n of h){let r=V.get(n.id);r?.kind===`package`&&f[Lc(T,r.target)]?.kind!==`running`&&jl(kl(r,e))===`available`&&t.set(n.id,r.target)}ee=t}t[18]=T,t[19]=h,t[20]=f,t[21]=E.data,t[22]=V,t[23]=ee}else ee=t[23];let H=ee,te;if(t[24]!==h||t[25]!==H||t[26]!==w){te={userEntries:0,projectEntries:0};for(let e of h){let t=w[e.spec];(t?.kind===`npm-ok`&&t.hasUpdate||H.has(e.id))&&(e.scope===`user`?te.userEntries+=1:e.scope===`project`&&(te.projectEntries+=1))}t[24]=h,t[25]=H,t[26]=w,t[27]=te}else te=t[27];let ne=te,U;t[28]===h?U=t[29]:(U=h.filter(zl),t[28]=h,t[29]=U);let re=U,ie;t[30]===h?ie=t[31]:(ie=h.filter(Bl),t[30]=h,t[31]=ie);let ae=ie,oe;t[32]===v?oe=t[33]:(oe=v.filter(Vl),t[32]=v,t[33]=oe);let se=oe,ce;t[34]===v?ce=t[35]:(ce=v.filter(Hl),t[34]=v,t[35]=ce);let le=ce,ue=h.length+v.length===0,fe;t[36]===r?fe=t[37]:(fe=()=>{r?r():F(!0)},t[36]=r,t[37]=fe);let pe=fe,me;t[38]!==n||t[39]!==o?(me=e=>{o(e),n?.()},t[38]=n,t[39]=o,t[40]=me):me=t[40];let he=me,ge;t[41]!==h||t[42]!==w||t[43]!==i||t[44]!==u?(ge=async e=>{let t=h.find(t=>t.id===e);if(!t)return;let n=w[t.spec];if(!n||n.kind!==`npm-ok`||!n.hasUpdate||!n.latestVersion)return;let r=n.latestVersion;(await u(e,{spec:`${n.name}@${r}`})).ok?q.success(i(`settings.plugins.toast.updatedToLatest`,{version:r})):q.error(i(`settings.plugins.toast.refreshFailed`))},t[41]=h,t[42]=w,t[43]=i,t[44]=u,t[45]=ge):ge=t[45];let _e=ge,ve;t[46]!==i||t[47]!==d?(ve=async(e,t)=>{await d(e)?q.success(i(`settings.plugins.update.toast.done`,{name:t})):q.error(i(`settings.plugins.update.toast.failed`,{name:t}))},t[46]=i,t[47]=d,t[48]=ve):ve=t[48];let ye=ze(ve),be;t[49]!==T||t[50]!==b||t[51]!==i?(be=async()=>{q.info(i(`settings.plugins.toast.refreshing`)),k(!0);let e=await Uc(void 0,$t(),b).then(Ul).catch(Wl),t=await Gc(T).then(Gl).catch(Kl);k(!1),e||q.error(i(`settings.plugins.toast.refreshFailed`)),t||q.error(i(`settings.plugins.toast.checkFailed`))},t[49]=T,t[50]=b,t[51]=i,t[52]=be):be=t[52];let xe=ze(be),Se;t[53]!==s||t[54]!==c||t[55]!==A||t[56]!==i?(Se=async()=>{if(!A)return;N(!0);let e=A.kind===`entry`?await s(A.id):await c(A.id);e.ok?q.success(e.message||i(`settings.plugins.sidebar.toast.deleted`,{name:A.label})):q.error(i(`settings.plugins.sidebar.toast.deleteFailed`)),j(null),N(!1)},t[53]=s,t[54]=c,t[55]=A,t[56]=i,t[57]=Se):Se=t[57];let W=Se,Ce;t[58]!==ye||t[59]!==he||t[60]!==_e||t[61]!==H||t[62]!==w||t[63]!==V||t[64]!==a||t[65]!==i?(Ce=e=>{let t=w[e.spec],n=t?.kind===`npm-ok`&&t.hasUpdate&&!!t.latestVersion,r=H.get(e.id)??null,o=[];return r?o.push({label:i(`settings.plugins.update.action`),icon:`arrow-up-s`,onClick:()=>void ye(r,e.spec)}):n&&o.push({label:i(`settings.plugins.sidebar.actions.updateToLatest`),icon:`arrow-up-s`,onClick:()=>void _e(e.id)}),o.push({label:i(`settings.common.actions.delete`),icon:`delete-bin`,destructive:!0,onClick:()=>j({kind:`entry`,id:e.id,label:e.spec})}),(0,$.jsx)(Uo,{title:(0,$.jsx)(`span`,{title:e.spec,children:e.spec}),metadata:(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[(0,$.jsx)(Pl,{target:V.get(e.id)??null}),(0,$.jsx)(`span`,{children:e.parsedKind===`npm`?i(`settings.plugins.sidebar.kind.npm`):i(`settings.plugins.sidebar.kind.path`)}),(0,$.jsx)(bl,{info:t})]}),selected:a===e.id,onSelect:()=>he(e.id),icon:(0,$.jsx)(Y,{name:Fl(e),className:`h-4 w-4 flex-shrink-0 text-muted-foreground/70`}),actions:o},e.id)},t[58]=ye,t[59]=he,t[60]=_e,t[61]=H,t[62]=w,t[63]=V,t[64]=a,t[65]=i,t[66]=Ce):Ce=t[66];let we=Ce,Te;t[67]!==he||t[68]!==V||t[69]!==a||t[70]!==i?(Te=e=>(0,$.jsx)(Uo,{title:(0,$.jsx)(`span`,{title:e.fileName,children:e.fileName}),metadata:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(Pl,{target:V.get(e.id)??null}),(0,$.jsx)(`span`,{children:i(`settings.plugins.sidebar.kind.file`)})]}),selected:a===e.id,onSelect:()=>he(e.id),icon:(0,$.jsx)(Y,{name:`file-text`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground/70`}),actions:[{label:i(`settings.common.actions.delete`),icon:`delete-bin`,destructive:!0,onClick:()=>j({kind:`file`,id:e.id,label:e.fileName})}]},e.id),t[67]=he,t[68]=V,t[69]=a,t[70]=i,t[71]=Te):Te=t[71];let Ee=Te,De;t[72]===i?De=t[73]:(De=(e,t,n,r,a)=>{let o=n===void 0?0:n;return(0,$.jsx)(X,{cardClassName:a!==void 0&&a?`hidden`:void 0,label:(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`min-w-0`,children:[e,o>0&&(0,$.jsx)(`span`,{className:`block text-[var(--status-success)]`,children:i(o===1?`settings.plugins.sidebar.group.updatesAvailable_one`:`settings.plugins.sidebar.group.updatesAvailable_other`,{count:o})})]}),r]}),children:t})},t[72]=i,t[73]=De);let Oe=De,ke;t[74]===xe?ke=t[75]:(ke=()=>void xe(),t[74]=xe,t[75]=ke);let Ae=S||E.isFetching||O,je;t[76]===i?je=t[77]:(je=i(`settings.plugins.sidebar.actions.refresh`),t[76]=i,t[77]=je);let Me;t[78]===i?Me=t[79]:(Me=i(`settings.plugins.sidebar.actions.refresh`),t[78]=i,t[79]=Me);let Ne=S||E.isFetching||O?`size-4 animate-spin`:`size-4`,Pe;t[80]===Ne?Pe=t[81]:(Pe=(0,$.jsx)(Y,{name:`refresh`,className:Ne}),t[80]=Ne,t[81]=Pe);let Fe;t[82]!==ke||t[83]!==Ae||t[84]!==je||t[85]!==Me||t[86]!==Pe?(Fe=(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,onClick:ke,disabled:Ae,"aria-label":je,title:Me,children:Pe}),t[82]=ke,t[83]=Ae,t[84]=je,t[85]=Me,t[86]=Pe,t[87]=Fe):Fe=t[87];let Ie;t[88]===i?Ie=t[89]:(Ie=i(`settings.plugins.sidebar.actions.addTitle`),t[88]=i,t[89]=Ie);let Le;t[90]===i?Le=t[91]:(Le=i(`settings.plugins.sidebar.actions.addTitle`),t[90]=i,t[91]=Le);let Re;t[92]===Symbol.for(`react.memo_cache_sentinel`)?(Re=(0,$.jsx)(Y,{name:`add`,className:`size-4`}),t[92]=Re):Re=t[92];let Be;t[93]!==pe||t[94]!==Ie||t[95]!==Le?(Be=(0,$.jsx)(K,{"data-settings-item":`plugins.create`,type:`button`,variant:`ghost`,size:`icon`,onClick:pe,"aria-label":Ie,title:Le,children:Re}),t[93]=pe,t[94]=Ie,t[95]=Le,t[96]=Be):Be=t[96];let Ve;t[97]!==Fe||t[98]!==Be?(Ve=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[Fe,Be]}),t[97]=Fe,t[98]=Be,t[99]=Ve):Ve=t[99];let Ue=Ve,We;t[100]!==D||t[101]!==i?(We=D?(0,$.jsxs)(`p`,{className:`typography-micro mb-2 flex items-center gap-1 text-muted-foreground`,role:`status`,children:[(0,$.jsx)(Y,{name:`question`,className:`size-3 shrink-0`}),i(`settings.plugins.status.sidebar.unavailable`)]}):void 0,t[100]=D,t[101]=i,t[102]=We):We=t[102];let Ge;t[103]!==Ue||t[104]!==we||t[105]!==Oe||t[106]!==i||t[107]!==ne||t[108]!==re?(Ge=re.length>0?Oe(i(`settings.plugins.sidebar.group.userEntries`),re.map(we),ne.userEntries,Ue):Oe(i(`settings.plugins.sidebar.group.userEntries`),(0,$.jsx)(`span`,{}),0,Ue,!0),t[103]=Ue,t[104]=we,t[105]=Oe,t[106]=i,t[107]=ne,t[108]=re,t[109]=Ge):Ge=t[109];let G;t[110]!==ue||t[111]!==ae||t[112]!==le||t[113]!==we||t[114]!==Ee||t[115]!==Oe||t[116]!==i||t[117]!==ne||t[118]!==se?(G=ue?(0,$.jsx)(X,{children:(0,$.jsxs)(`div`,{className:`yuri-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(Y,{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.plugins.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:i(`settings.plugins.sidebar.empty.description`)})]})}):(0,$.jsxs)($.Fragment,{children:[se.length>0&&Oe(i(`settings.plugins.sidebar.group.userFiles`),se.map(Ee)),ae.length>0&&Oe(i(`settings.plugins.sidebar.group.projectEntries`),ae.map(we),ne.projectEntries),le.length>0&&Oe(i(`settings.plugins.sidebar.group.projectFiles`),le.map(Ee))]}),t[110]=ue,t[111]=ae,t[112]=le,t[113]=we,t[114]=Ee,t[115]=Oe,t[116]=i,t[117]=ne,t[118]=se,t[119]=G):G=t[119];let Ke;t[120]!==We||t[121]!==Ge||t[122]!==G?(Ke=(0,$.jsxs)(Go,{variant:`background`,header:We,children:[Ge,G]}),t[120]=We,t[121]=Ge,t[122]=G,t[123]=Ke):Ke=t[123];let qe;t[124]===P?qe=t[125]:(qe=(0,$.jsx)(yl,{open:P,onOpenChange:F}),t[124]=P,t[125]=qe);let Je=A!==null,Ye;t[126]===M?Ye=t[127]:(Ye=e=>{!e&&!M&&j(null)},t[126]=M,t[127]=Ye);let Xe;t[128]===i?Xe=t[129]:(Xe=i(`settings.plugins.sidebar.deleteDialog.title`),t[128]=i,t[129]=Xe);let Ze;t[130]===Xe?Ze=t[131]:(Ze=(0,$.jsx)(pn,{children:Xe}),t[130]=Xe,t[131]=Ze);let Qe=A?.label??``,$e;t[132]!==i||t[133]!==Qe?($e=i(`settings.plugins.sidebar.deleteDialog.description`,{name:Qe}),t[132]=i,t[133]=Qe,t[134]=$e):$e=t[134];let et;t[135]===$e?et=t[136]:(et=(0,$.jsx)(mn,{children:$e}),t[135]=$e,t[136]=et);let tt;t[137]!==Ze||t[138]!==et?(tt=(0,$.jsxs)(un,{children:[Ze,et]}),t[137]=Ze,t[138]=et,t[139]=tt):tt=t[139];let nt;t[140]===Symbol.for(`react.memo_cache_sentinel`)?(nt=()=>j(null),t[140]=nt):nt=t[140];let rt;t[141]===i?rt=t[142]:(rt=i(`settings.common.actions.cancel`),t[141]=i,t[142]=rt);let it;t[143]!==M||t[144]!==rt?(it=(0,$.jsx)(K,{size:`sm`,variant:`ghost`,onClick:nt,disabled:M,children:rt}),t[143]=M,t[144]=rt,t[145]=it):it=t[145];let at;t[146]!==M||t[147]!==i?(at=i(M?`settings.plugins.sidebar.actions.deleting`:`settings.common.actions.delete`),t[146]=M,t[147]=i,t[148]=at):at=t[148];let ot;t[149]!==W||t[150]!==M||t[151]!==at?(ot=(0,$.jsx)(K,{size:`sm`,variant:`destructive`,onClick:W,disabled:M,children:at}),t[149]=W,t[150]=M,t[151]=at,t[152]=ot):ot=t[152];let st;t[153]!==it||t[154]!==ot?(st=(0,$.jsxs)(dn,{children:[it,ot]}),t[153]=it,t[154]=ot,t[155]=st):st=t[155];let ct;t[156]!==tt||t[157]!==st?(ct=(0,$.jsxs)(fn,{className:`max-w-md`,children:[tt,st]}),t[156]=tt,t[157]=st,t[158]=ct):ct=t[158];let lt;t[159]!==Je||t[160]!==Ye||t[161]!==ct?(lt=(0,$.jsx)(hn,{open:Je,onOpenChange:Ye,children:ct}),t[159]=Je,t[160]=Ye,t[161]=ct,t[162]=lt):lt=t[162];let ut;return t[163]!==Ke||t[164]!==qe||t[165]!==lt?(ut=(0,$.jsxs)($.Fragment,{children:[Ke,qe,lt]}),t[163]=Ke,t[164]=qe,t[165]=lt,t[166]=ut):ut=t[166],ut};function Ll(e){return{selectedId:e.selectedId,setSelected:e.setSelected,deleteEntry:e.deleteEntry,deleteFile:e.deleteFile,loadPlugins:e.loadPlugins,updateEntry:e.updateEntry,updatePackage:e.updatePackage,packageUpdates:e.packageUpdates}}function Rl(e){return e.spec}function zl(e){return e.scope===`user`}function Bl(e){return e.scope===`project`}function Vl(e){return e.scope===`user`}function Hl(e){return e.scope===`project`}function Ul(){return!0}function Wl(){return!1}function Gl(){return!0}function Kl(){return!1}var ql=e=>{let t=(0,qi.c)(10),{children:n,className:r,outerClassName:i}=e,a;t[0]===i?a=t[1]:(a=G(`h-full`,i),t[0]=i,t[1]=a);let o;t[2]===r?o=t[3]:(o=G(`yuri-settings-page-content mx-auto max-w-3xl p-3 sm:p-6 sm:pt-8`,r),t[2]=r,t[3]=o);let s;t[4]!==n||t[5]!==o?(s=(0,$.jsx)(`div`,{className:o,children:n}),t[4]=n,t[5]=o,t[6]=s):s=t[6];let c;return t[7]!==a||t[8]!==s?(c=(0,$.jsx)(Rr,{outerClassName:a,className:`w-full`,children:s}),t[7]=a,t[8]=s,t[9]=c):c=t[9],c},Jl=({entryId:e,spec:t})=>{let{t:n}=He(),{data:r}=zc([t]),i=r?.[t],a=sl(e=>e.updateEntry),[o,s]=Q.useState(!1);if(!i)return null;if(i.kind===`npm-ok`){if(!i.hasUpdate||!i.latestVersion)return null;let t=i.latestVersion,r=i.currentVersion??``,c=async()=>{s(!0);try{(await a(e,{spec:`${i.name}@latest`})).ok?q.success(n(`settings.plugins.toast.updatedToLatest`,{version:t})):q.error(n(`settings.plugins.toast.refreshFailed`))}finally{s(!1)}};return(0,$.jsxs)(`div`,{className:`rounded-md border border-border bg-card p-3 flex items-start gap-3`,children:[(0,$.jsx)(Y,{name:`arrow-up`,className:`h-5 w-5 text-[var(--status-success)] shrink-0 mt-0.5`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`p`,{className:`typography-label text-[var(--status-success)]`,children:n(`settings.plugins.registry.banner.updateAvailable.title`)}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground mt-0.5`,children:n(`settings.plugins.registry.banner.updateAvailable.description`,{current:r,latest:t})})]}),(0,$.jsx)(K,{variant:`default`,size:`sm`,onClick:()=>void c(),disabled:o,children:n(`settings.plugins.registry.banner.updateAvailable.action`,{latest:t})})]})}if(i.kind===`path-ok`)return null;if(i.kind===`npm-network`)return(0,$.jsxs)(`div`,{className:`rounded-md border border-border bg-card p-3 flex items-start gap-3`,children:[(0,$.jsx)(Y,{name:`cloud-off`,className:`h-5 w-5 text-muted-foreground shrink-0 mt-0.5`}),(0,$.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:n(`settings.plugins.registry.badge.network.tooltip`)})})]});let c=i.kind===`path-unreadable`,l=c?`var(--status-warning)`:`var(--status-error)`,u=c?`alert`:`error-warning`,d=(()=>{switch(i.kind){case`npm-missing-version`:return n(`settings.plugins.registry.banner.invalid.missingVersion`);case`npm-missing-package`:return n(`settings.plugins.registry.banner.invalid.missingPackage`);case`npm-malformed`:return n(`settings.plugins.registry.banner.invalid.malformed`);case`path-missing`:return n(`settings.plugins.registry.banner.invalid.pathMissing`);case`path-unreadable`:return n(`settings.plugins.registry.banner.invalid.pathUnreadable`)}})();return(0,$.jsxs)(`div`,{className:`rounded-md border border-border bg-card p-3 flex items-start gap-3`,children:[(0,$.jsx)(Y,{name:u,className:`h-5 w-5 shrink-0 mt-0.5`,style:{color:l}}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`p`,{className:`typography-label`,style:{color:l},children:n(`settings.plugins.registry.banner.invalid.title`)}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground mt-0.5`,children:d})]})]})},Yl=e=>{let t=(0,qi.c)(69),{target:n,name:r}=e,{t:i}=He(),{status:a,retry:o,isRefreshing:s}=Ml(n),c=Nl(n),l=sl(Xl),u=a.kind===`known`&&a.target.kind===`package`?a.target.target:null,d=a.kind===`known`&&(a.update===`updating`||c?.kind===`running`),f;t[0]===o?f=t[1]:(f=()=>{o()},t[0]=o,t[1]=f);let p=ze(f),m;t[2]!==r||t[3]!==u||t[4]!==i||t[5]!==l?(m=async()=>{u&&(await l(u)?q.success(i(`settings.plugins.update.toast.done`,{name:r})):q.error(i(`settings.plugins.update.toast.failed`,{name:r})))},t[2]=r,t[3]=u,t[4]=i,t[5]=l,t[6]=m):m=t[6];let h=ze(m);if(a.kind===`loading`)return null;if(a.kind===`unknown`){let e;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Y,{name:`question`,className:`mt-0.5 h-5 w-5 shrink-0 text-muted-foreground`}),t[7]=e):e=t[7];let n;t[8]===i?n=t[9]:(n=i(`settings.plugins.status.unknown.title`),t[8]=i,t[9]=n);let r;t[10]===n?r=t[11]:(r=(0,$.jsx)(`p`,{className:`typography-label text-foreground`,children:n}),t[10]=n,t[11]=r);let a;t[12]===i?a=t[13]:(a=i(`settings.plugins.status.unknown.description`),t[12]=i,t[13]=a);let o;t[14]===a?o=t[15]:(o=(0,$.jsx)(`p`,{className:`typography-micro mt-0.5 text-muted-foreground`,children:a}),t[14]=a,t[15]=o);let c;t[16]!==r||t[17]!==o?(c=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[r,o]}),t[16]=r,t[17]=o,t[18]=c):c=t[18];let l;t[19]===i?l=t[20]:(l=i(`settings.plugins.status.retry`),t[19]=i,t[20]=l);let u;t[21]!==p||t[22]!==s||t[23]!==l?(u=(0,$.jsx)(K,{variant:`outline`,size:`sm`,onClick:p,disabled:s,children:l}),t[21]=p,t[22]=s,t[23]=l,t[24]=u):u=t[24];let d;return t[25]!==u||t[26]!==c?(d=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3 rounded-md border border-border bg-card p-3`,role:`status`,"data-plugin-load-state":`unknown`,children:[e,c,u]}),t[25]=u,t[26]=c,t[27]=d):d=t[27],d}let{load:g,update:_}=a,v=u!==null&&(_!==`none`||c!==null),y;bb0:{switch(g.kind){case`active`:{let e;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Y,{name:`checkbox-circle`,className:`h-4 w-4 text-[var(--status-success)]`}),t[28]=e):e=t[28];let n;t[29]!==g.version||t[30]!==i?(n=g.version?i(`settings.plugins.status.loadedVersion`,{version:g.version}):i(`settings.plugins.status.loaded`),t[29]=g.version,t[30]=i,t[31]=n):n=t[31];let r;t[32]===n?r=t[33]:(r=(0,$.jsxs)(`p`,{className:`typography-meta flex items-center gap-1.5 text-muted-foreground`,role:`status`,"data-plugin-load-state":`active`,children:[e,n]}),t[32]=n,t[33]=r),y=r;break bb0}case`notReported`:{let e;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Y,{name:`time`,className:`mt-0.5 h-5 w-5 shrink-0 text-muted-foreground`}),t[34]=e):e=t[34];let n;t[35]===i?n=t[36]:(n=i(`settings.plugins.status.notReported.title`),t[35]=i,t[36]=n);let r;t[37]===n?r=t[38]:(r=(0,$.jsx)(`p`,{className:`typography-label text-foreground`,children:n}),t[37]=n,t[38]=r);let a;t[39]===i?a=t[40]:(a=i(`settings.plugins.status.notReported.description`),t[39]=i,t[40]=a);let o;t[41]===a?o=t[42]:(o=(0,$.jsx)(`p`,{className:`typography-micro mt-0.5 text-muted-foreground`,children:a}),t[41]=a,t[42]=o);let s;t[43]!==r||t[44]!==o?(s=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3 rounded-md border border-border bg-card p-3`,role:`status`,"data-plugin-load-state":`notReported`,children:[e,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[r,o]})]}),t[43]=r,t[44]=o,t[45]=s):s=t[45],y=s;break bb0}case`failed`:{let e;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Y,{name:`error-warning`,className:`mt-0.5 h-5 w-5 shrink-0 text-[var(--status-error)]`}),t[46]=e):e=t[46];let n;t[47]===i?n=t[48]:(n=i(`settings.plugins.status.failed.title`),t[47]=i,t[48]=n);let r;t[49]===n?r=t[50]:(r=(0,$.jsx)(`p`,{className:`typography-label text-[var(--status-error)]`,children:n}),t[49]=n,t[50]=r);let a;t[51]===g.error?a=t[52]:(a=(0,$.jsx)(`p`,{className:`typography-micro mt-1 whitespace-pre-wrap break-words font-mono text-foreground`,children:g.error}),t[51]=g.error,t[52]=a);let o;t[53]!==g.ref||t[54]!==i?(o=g.ref?(0,$.jsx)(`p`,{className:`typography-micro mt-1 text-muted-foreground`,children:i(`settings.plugins.status.failed.ref`,{ref:g.ref})}):null,t[53]=g.ref,t[54]=i,t[55]=o):o=t[55];let s;t[56]!==r||t[57]!==a||t[58]!==o?(s=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3 rounded-md border border-border bg-card p-3`,role:`alert`,"data-plugin-load-state":`failed`,children:[e,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[r,a,o]})]}),t[56]=r,t[57]=a,t[58]=o,t[59]=s):s=t[59],y=s;break bb0}}y=void 0}let b=y,x;t[60]!==h||t[61]!==d||t[62]!==c||t[63]!==v||t[64]!==i?(x=v?(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3 rounded-md border border-border bg-card p-3`,children:[(0,$.jsx)(Y,{name:`arrow-up`,className:`mt-0.5 h-5 w-5 shrink-0 text-[var(--status-success)]`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`typography-label text-[var(--status-success)]`,children:i(`settings.plugins.update.available.title`)}),(0,$.jsx)(`p`,{className:`typography-micro mt-0.5 text-muted-foreground`,children:i(`settings.plugins.update.available.description`)}),c?.kind===`failed`?(0,$.jsxs)(`div`,{className:`mt-2`,role:`alert`,children:[(0,$.jsx)(`p`,{className:`typography-micro text-[var(--status-error)]`,children:i(`settings.plugins.update.failed.title`)}),(0,$.jsx)(`p`,{className:`typography-micro mt-0.5 whitespace-pre-wrap break-words font-mono text-foreground`,children:c.error})]}):null]}),(0,$.jsx)(K,{variant:`default`,size:`sm`,onClick:()=>void h(),disabled:d,children:d?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Y,{name:`loader-4`,className:`size-4 animate-spin`}),i(`settings.plugins.update.running`)]}):i(`settings.plugins.update.action`)})]}):null,t[60]=h,t[61]=d,t[62]=c,t[63]=v,t[64]=i,t[65]=x):x=t[65];let S;return t[66]!==b||t[67]!==x?(S=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[b,x]}),t[66]=b,t[67]=x,t[68]=S):S=t[68],S};function Xl(e){return e.updatePackage}function Zl(e){let t=e.trim();if(t.length===0)return{ok:!0,value:void 0};try{let e=JSON.parse(t);return typeof e!=`object`||!e||Array.isArray(e)?{ok:!1}:{ok:!0,value:e}}catch{return{ok:!1}}}function Ql(e){return!e||Object.keys(e).length===0?``:JSON.stringify(e,null,2)}function $l(e){return{mode:`entry`,scope:e.scope,spec:e.spec,optionsJson:Ql(e.options),fileName:``,content:``}}function eu(e,t){return{mode:`file`,scope:e.scope,spec:``,optionsJson:``,fileName:e.fileName,content:t}}var tu=e=>{let t=(0,qi.c)(4),{scope:n,label:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=G(`typography-micro font-medium rounded-full px-2 py-0.5`,`bg-[var(--surface-elevated)] text-muted-foreground`,`border border-[var(--interactive-border)]`),t[0]=i):i=t[0];let a;return t[1]!==r||t[2]!==n?(a=(0,$.jsx)(`span`,{className:i,"data-scope":n,children:r}),t[1]=r,t[2]=n,t[3]=a):a=t[3],a},nu=()=>{let{t:e}=He(),t=sl(e=>e.selectedId),n=Rc(),r=Q.useMemo(()=>n.data?.entries??[],[n.data?.entries]),i=Q.useMemo(()=>n.data?.files??[],[n.data?.files]),a=sl(e=>e.draft),o=sl(e=>e.setDraft),s=sl(e=>e.updateEntry),c=sl(e=>e.updateFile),l=sl(e=>e.readFile),u=Q.useMemo(()=>t?r.find(e=>e.id===t)??null:null,[r,t]),d=Q.useMemo(()=>t?i.find(e=>e.id===t)??null:null,[i,t]),f=Q.useMemo(()=>u?El(u.spec,u.sourcePath):null,[u]),p=Q.useMemo(()=>d?Dl(d.absolutePath):null,[d]),[m,h]=Q.useState(!1),[g,_]=Q.useState(!1),v=Q.useRef(new Map);if(Q.useEffect(()=>{let e=!1;return u?(o($l(u)),()=>{e=!0}):d?(_(!0),(async()=>{let t=await l(d.id);if(e)return;_(!1);let n=t?.content??``;v.current.set(d.id,n),o(eu(d,n))})(),()=>{e=!0}):(o(null),()=>{e=!0})},[u,d,l,o]),!t)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(Y,{name:`plug`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.plugins.page.empty.select`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.plugins.page.empty.add`)})]})});if(u&&a&&a.mode===`entry`){let t=Zl(a.optionsJson),n=t.ok,r=a.spec!==u.spec||a.optionsJson!==Ql(u.options),i=()=>{o($l(u))},c=async()=>{if(!n)return;let r=a.spec.trim();if(!r){q.error(e(`settings.plugins.validation.specRequired`));return}h(!0);try{let n=await s(u.id,{spec:r,options:t.value});n.ok?n.reloadFailed?q.warning(n.message||e(`settings.plugins.toast.reloadFailed`),{description:n.warning}):q.success(n.message||e(`settings.plugins.toast.updated`)):q.error(n.message||e(`settings.plugins.toast.reloadFailed`))}finally{h(!1)}};return(0,$.jsxs)(ql,{children:[(0,$.jsx)(Xr,{actions:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{variant:`outline`,size:`sm`,onClick:i,disabled:!r||m,children:e(`settings.plugins.page.action.discard`)}),(0,$.jsx)(K,{size:`sm`,onClick:()=>void c(),disabled:!r||!n||m,"aria-busy":m,children:e(`settings.plugins.page.action.save`)})]}),children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground break-all`,children:u.spec}),(0,$.jsx)(tu,{scope:u.scope,label:u.scope===`project`?e(`settings.plugins.sidebar.group.projectEntries`):e(`settings.plugins.sidebar.group.userEntries`)})]})}),(0,$.jsx)(Yl,{target:f,name:u.spec}),(0,$.jsx)(Jl,{entryId:u.id,spec:u.spec}),(0,$.jsx)(`div`,{"data-settings-item":`plugins.spec`,children:(0,$.jsx)(X,{label:e(`settings.plugins.page.field.spec`),cardClassName:`p-3`,children:(0,$.jsx)(En,{value:a.spec,"aria-label":e(`settings.plugins.page.field.spec`),onChange:e=>o({...a,spec:e.target.value}),placeholder:e(`settings.plugins.page.field.spec.placeholder`),className:`font-mono typography-meta`,spellCheck:!1})})}),(0,$.jsx)(`div`,{"data-settings-item":`plugins.options`,children:(0,$.jsx)(X,{label:e(`settings.plugins.page.field.options`),description:n?void 0:e(`settings.plugins.page.field.options.invalidJson`),cardClassName:`p-3`,children:(0,$.jsx)(zr,{embedded:!0,value:a.optionsJson,"aria-label":e(`settings.plugins.page.field.options`),"aria-invalid":!n,onChange:e=>o({...a,optionsJson:e.target.value}),rows:6,className:G(`font-mono typography-meta min-h-[144px] resize-y`,!n&&`border-[var(--status-error-border)]`),spellCheck:!1,placeholder:`{ }`})})})]})}if(d&&a&&a.mode===`file`){let t=v.current.get(d.id)??``,n=a.content!==t||a.fileName!==d.fileName,r=()=>{(async()=>{_(!0);let e=(await l(d.id))?.content??``;_(!1),v.current.set(d.id,e),o(eu(d,e))})()},i=async()=>{h(!0);try{let t=await c(d.id,{content:a.content});t.ok?(v.current.set(d.id,a.content),t.reloadFailed?q.warning(t.message||e(`settings.plugins.toast.reloadFailed`),{description:t.warning}):q.success(t.message||e(`settings.plugins.toast.updated`))):q.error(t.message||e(`settings.plugins.toast.reloadFailed`))}finally{h(!1)}};return(0,$.jsxs)(ql,{children:[(0,$.jsx)(Xr,{actions:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{variant:`outline`,size:`sm`,onClick:r,disabled:m||g,children:e(`settings.plugins.page.action.discard`)}),(0,$.jsx)(K,{size:`sm`,onClick:()=>void i(),disabled:!n||m||g,"aria-busy":m,children:e(`settings.plugins.page.action.save`)})]}),children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0 flex-wrap`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground break-all`,children:d.fileName}),(0,$.jsx)(tu,{scope:d.scope,label:d.scope===`project`?e(`settings.plugins.sidebar.group.projectFiles`):e(`settings.plugins.sidebar.group.userFiles`)})]})}),(0,$.jsx)(Yl,{target:p,name:d.fileName}),(0,$.jsx)(`div`,{"data-settings-item":`plugins.content`,children:(0,$.jsx)(X,{label:e(`settings.plugins.page.field.content`),cardClassName:`p-3`,children:(0,$.jsx)(zr,{embedded:!0,value:a.content,"aria-label":e(`settings.plugins.page.field.content`),onChange:e=>o({...a,content:e.target.value}),rows:16,className:`font-mono typography-meta min-h-[320px]`,spellCheck:!1,disabled:g})})})]})}return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsx)(`div`,{className:`text-center text-muted-foreground`,children:(0,$.jsx)(Y,{name:`loader-4`,className:`mx-auto mb-3 h-6 w-6 animate-spin opacity-50`})})})},ru={opencode:`OpenCode`,"oh-my-opencode-slim":`oh-my-opencode-slim`,"oh-my-openagent":`oh-my-openagent`};async function iu(e,t){let n=await e.json().catch(()=>null);return typeof n?.error==`string`&&n.error.trim()?n.error:t}function au(){let{t:e}=He(),{currentTheme:t}=ln(),[n,r]=Q.useState([]),[i,a]=Q.useState(null),[o,s]=Q.useState(``),[c,l]=Q.useState(``),[u,d]=Q.useState(``),[f,m]=Q.useState(!0),[h,g]=Q.useState(!1),[_,v]=Q.useState(!1),[y,b]=Q.useState(!1),x=Q.useMemo(()=>{let e=u||`opencode.json`,n=e.endsWith(`.jsonc`)?`jsonc`:`json`,r=[bi(t,{syntaxColors:!1})],i=ni(e);return i&&r.push(i),r.push(Jr({language:n,themeName:t.metadata.id,theme:Hr(t)})),r},[t,u]),S=Q.useCallback(async t=>{m(!0);try{let n=await p(`/api/config/global/${t}`);if(!n.ok)throw Error(await iu(n,e(`settings.globalConfig.toast.loadFailed`)));let r=await n.json(),i=typeof r.content==`string`?r.content:``;s(i),l(i),d(typeof r.fileName==`string`?r.fileName:``)}catch(t){s(``),l(``),d(``),q.error(t instanceof Error?t.message:e(`settings.globalConfig.toast.loadFailed`))}finally{m(!1)}},[e]);Q.useEffect(()=>{let t=!1;return(async()=>{m(!0);try{let n=await p(`/api/config/global`);if(!n.ok)throw Error(await iu(n,e(`settings.globalConfig.toast.loadFailed`)));let i=await n.json(),o=Array.isArray(i.targets)?i.targets.flatMap(e=>{if(!e||typeof e!=`object`)return[];let t=e;if(typeof t.target!=`string`||typeof t.fileName!=`string`||!(t.target in ru))return[];let n=t.target;return[{id:n,label:ru[n],fileName:t.fileName}]}):[];if(t)return;r(o),a(e=>o.some(t=>t.id===e)?e:o[0]?.id||null)}catch(n){t||(r([]),a(null),q.error(n instanceof Error?n.message:e(`settings.globalConfig.toast.loadFailed`)))}finally{t||m(!1)}})(),()=>{t=!0}},[e]),Q.useEffect(()=>{i&&S(i)},[S,i]);let C=async()=>{if(i){g(!0);try{let t=await p(`/api/config/global/${i}`,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({content:o})});if(!t.ok)throw Error(await iu(t,e(`settings.globalConfig.toast.saveFailed`)));let n=await t.json(),r=typeof n.content==`string`?n.content:o;s(r),l(r),q.success(e(`settings.globalConfig.toast.saved`)),v(n.requiresManualRestart===!0)}catch(t){q.error(t instanceof Error?t.message:e(`settings.globalConfig.toast.saveFailed`))}finally{g(!1)}}},w=async()=>{b(!0);try{await wt({message:e(`settings.view.actions.reloadOpenCode`),mode:`projects`,scopes:[`all`]}),v(!1)}catch(t){q.error(t instanceof Error?t.message:e(`settings.view.actions.reloadOpenCode`))}finally{b(!1)}};return(0,$.jsxs)(Rr,{outerClassName:`h-full`,className:`w-full`,children:[(0,$.jsx)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-4xl p-3 sm:p-6 sm:pt-8`,children:(0,$.jsx)(X,{itemId:`global-config.editor`,actions:i?(0,$.jsx)(K,{onClick:C,disabled:f||h||o===c,size:`sm`,"aria-busy":h,children:e(h?`settings.common.actions.saving`:`settings.common.actions.saveChanges`)}):void 0,label:e(`settings.globalConfig.title`),description:e(`settings.globalConfig.description`),cardClassName:`p-3`,children:n.length>0?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-1`,children:n.map(e=>(0,$.jsx)(K,{variant:`chip`,size:`xs`,"aria-pressed":i===e.id,onClick:()=>a(e.id),children:e.label},e.id))}),(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3 px-1`,children:[(0,$.jsx)(`span`,{className:`typography-meta truncate text-muted-foreground`,children:u}),i&&(0,$.jsx)(K,{variant:`ghost`,size:`xs`,onClick:()=>void S(i),disabled:f||h,children:e(`settings.globalConfig.actions.reload`)})]}),i&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`h-[clamp(420px,62dvh,760px)] overflow-hidden bg-background`,children:(0,$.jsx)(Yr,{value:o,onChange:s,readOnly:f,extensions:x,className:`h-full`,enableSearch:!0})}),(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-3`,children:i!==`opencode`&&(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.globalConfig.restartHint`)})})]})]}):(0,$.jsx)(`div`,{className:`min-h-12`,"aria-busy":f})})}),(0,$.jsx)(hn,{open:_,onOpenChange:e=>!y&&v(e),children:(0,$.jsxs)(fn,{className:`max-w-md`,children:[(0,$.jsxs)(un,{children:[(0,$.jsx)(pn,{children:e(`settings.view.actions.reloadOpenCode`)}),(0,$.jsx)(mn,{children:e(`settings.globalConfig.restartHint`)})]}),(0,$.jsxs)(dn,{children:[(0,$.jsx)(K,{variant:`ghost`,size:`sm`,onClick:()=>v(!1),disabled:y,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(K,{size:`sm`,onClick:()=>void w(),disabled:y,children:e(`settings.view.actions.reloadOpenCode`)})]})]})})]})}var ou=`<built-in>`,su=e=>e?.path===ou,cu=e=>{let t=(0,qi.c)(172),{onItemSelect:n}=e,{t:r}=He(),[i,a]=Q.useState(null),[o,s]=Q.useState(``),[c,l]=Q.useState(null),[u,d]=Q.useState(!1),[f,p]=Q.useState(null),{selectedSkillName:m,setSelectedSkill:h,setSkillDraft:g,createSkill:_,deleteSkill:v,getSkillDetail:y}=Ra(de(uu)),b=Dt(),x;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(x=ht(),t[0]=x):x=t[0];let S=x,C;t[1]===b.data?C=t[2]:(C=b.data??[],t[1]=b.data,t[2]=C);let w=C,T;t[3]!==n||t[4]!==h||t[5]!==g||t[6]!==w?(T=()=>{let e=`new-skill`,t=1;for(;w.some(t=>t.name===e);)e=`new-skill-${t}`,t++;g({name:e,scope:`user`,source:`opencode`,description:``}),h(e),n?.()},t[3]=n,t[4]=h,t[5]=g,t[6]=w,t[7]=T):T=t[7];let E=T,D;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(D=async e=>{su(e)||l(e)},t[8]=D):D=t[8];let O=D,k;t[9]!==c||t[10]!==v||t[11]!==r?(k=async()=>{if(c){if(su(c)){l(null);return}d(!0),await v(c.name,{directory:S})?(q.success(r(`settings.skills.sidebar.toast.skillDeleted`,{name:c.name})),l(null)):q.error(r(`settings.skills.sidebar.toast.deleteSkillFailed`)),d(!1)}},t[9]=c,t[10]=v,t[11]=r,t[12]=k):k=t[12];let A=k,j;t[13]!==y||t[14]!==h||t[15]!==g||t[16]!==w||t[17]!==r?(j=async e=>{if(su(e))return;let t=e.name,n=1,i=`${t}-copy`;for(;w.some(e=>e.name===i);)n++,i=`${t}-copy-${n}`;let a=await y(e.name);if(!a){q.error(r(`settings.skills.sidebar.toast.duplicateLoadFailed`));return}g({name:i,scope:e.scope||`user`,source:e.source||`opencode`,description:(a.sources.md.fields.includes(`description`),``),instructions:``}),h(i)},t[13]=y,t[14]=h,t[15]=g,t[16]=w,t[17]=r,t[18]=j):j=t[18];let M=j,N;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(N=e=>{su(e)||(s(e.name),a(e))},t[19]=N):N=t[19];let P=N,F;t[20]!==_||t[21]!==v||t[22]!==y||t[23]!==i||t[24]!==o||t[25]!==h||t[26]!==w||t[27]!==r?(F=async()=>{if(!i)return;if(su(i)){a(null);return}let e=o.trim().replace(/\s+/g,`-`).toLowerCase();if(!e){q.error(r(`settings.skills.page.toast.skillNameRequired`));return}if(e===i.name){a(null);return}if(w.some(t=>t.name===e)){q.error(r(`settings.skills.page.toast.skillExists`));return}if(!await y(i.name)){q.error(r(`settings.skills.sidebar.toast.renameLoadFailed`)),a(null);return}await _({name:e,description:`Renamed skill`,scope:i.scope,source:i.source},{directory:S})?await v(i.name,{directory:S})?(q.success(`Skill renamed to "${e}"`),h(e)):q.error(r(`settings.skills.sidebar.toast.removeOldAfterRenameFailed`)):q.error(r(`settings.skills.sidebar.toast.renameFailed`)),a(null)},t[20]=_,t[21]=v,t[22]=y,t[23]=i,t[24]=o,t[25]=h,t[26]=w,t[27]=r,t[28]=F):F=t[28];let I=F,L;t[29]===w?L=t[30]:(L=w.filter(du),t[29]=w,t[30]=L);let R=L,z;t[31]===w?z=t[32]:(z=w.filter(fu),t[31]=w,t[32]=z);let B=z,V;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(V=function(e){let t={},n=[];for(let r of e)r.group?(t[r.group]||(t[r.group]=[]),t[r.group].push(r)):n.push(r);let r=Object.keys(t).sort(pu).map(e=>({name:e,skills:[...t[e]].sort(mu)}));return n.sort(hu),{sortedGroups:r,ungrouped:n}},t[33]=V):V=t[33];let ee=V,H;t[34]===R?H=t[35]:(H=ee(R),t[34]=R,t[35]=H);let te=H,ne;t[36]===B?ne=t[37]:(ne=ee(B),t[36]=B,t[37]=ne);let U=ne,re;t[38]===r?re=t[39]:(re=r(`settings.skills.sidebar.section.project`),t[38]=r,t[39]=re);let ie=re,ae;t[40]===r?ae=t[41]:(ae=r(`settings.skills.sidebar.section.user`),t[40]=r,t[41]=ae);let oe=ae,se;t[42]===ie?se=t[43]:(se=(0,$.jsx)(`span`,{children:ie}),t[42]=ie,t[43]=se);let ce;t[44]===r?ce=t[45]:(ce=r(`settings.skills.page.title.newSkill`),t[44]=r,t[45]=ce);let le;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,$.jsx)(Y,{name:`add`,className:`h-4 w-4`}),t[46]=le):le=t[46];let ue;t[47]!==E||t[48]!==ce?(ue=(0,$.jsx)(K,{"data-settings-item":`skills.create`,size:`icon`,variant:`ghost`,"aria-label":ce,onClick:E,children:le}),t[47]=E,t[48]=ce,t[49]=ue):ue=t[49];let fe;t[50]!==se||t[51]!==ue?(fe=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[se,ue]}),t[50]=se,t[51]=ue,t[52]=fe):fe=t[52];let pe=fe,me;t[53]!==M||t[54]!==n||t[55]!==f||t[56]!==m||t[57]!==h?(me=e=>(0,$.jsx)(lu,{skill:e,isSelected:m===e.name,onSelect:()=>{h(e.name),n?.()},onRename:()=>P(e),onDelete:()=>O(e),onDuplicate:()=>M(e),isMenuOpen:f===e.name,onMenuOpenChange:t=>p(t?e.name:null)},e.name),t[53]=M,t[54]=n,t[55]=f,t[56]=m,t[57]=h,t[58]=me):me=t[58];let he=me,ge,_e;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(ge=G(`yuri-settings-page-content h-full overflow-y-auto p-3`,`bg-background`),_e=(0,$.jsx)(to,{}),t[59]=ge,t[60]=_e):(ge=t[59],_e=t[60]);let ve;t[61]!==w.length||t[62]!==r?(ve=w.length===0?(0,$.jsx)(X,{children:(0,$.jsxs)(`div`,{className:`yuri-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(Y,{name:`book-open`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:r(`settings.skills.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:r(`settings.skills.sidebar.empty.description`)})]})}):null,t[61]=w.length,t[62]=r,t[63]=ve):ve=t[63];let ye;t[64]!==te.ungrouped||t[65]!==pe||t[66]!==he?(ye=te.ungrouped.length>0?(0,$.jsx)(X,{label:pe,children:te.ungrouped.map(he)}):(0,$.jsx)(X,{label:pe,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})}),t[64]=te.ungrouped,t[65]=pe,t[66]=he,t[67]=ye):ye=t[67];let be;if(t[68]!==te.sortedGroups||t[69]!==ie||t[70]!==he){let e;t[72]!==ie||t[73]!==he?(e=e=>{let{name:t,skills:n}=e;return(0,$.jsx)(co,{label:t,labelPrefix:ie,count:n.length,storageKey:`project-skills`,variant:`settings-card`,children:n.map(he)},t)},t[72]=ie,t[73]=he,t[74]=e):e=t[74],be=te.sortedGroups.map(e),t[68]=te.sortedGroups,t[69]=ie,t[70]=he,t[71]=be}else be=t[71];let xe;t[75]!==U.ungrouped||t[76]!==he||t[77]!==oe?(xe=U.ungrouped.length>0?(0,$.jsx)(X,{label:oe,children:U.ungrouped.map(he)}):null,t[75]=U.ungrouped,t[76]=he,t[77]=oe,t[78]=xe):xe=t[78];let Se;if(t[79]!==U.sortedGroups||t[80]!==he||t[81]!==oe){let e;t[83]!==he||t[84]!==oe?(e=e=>{let{name:t,skills:n}=e;return(0,$.jsx)(co,{label:t,labelPrefix:oe,count:n.length,storageKey:`user-skills`,variant:`settings-card`,children:n.map(he)},t)},t[83]=he,t[84]=oe,t[85]=e):e=t[85],Se=U.sortedGroups.map(e),t[79]=U.sortedGroups,t[80]=he,t[81]=oe,t[82]=Se}else Se=t[82];let W=c!==null,Ce;t[86]===u?Ce=t[87]:(Ce=e=>{!e&&!u&&l(null)},t[86]=u,t[87]=Ce);let we;t[88]===r?we=t[89]:(we=r(`settings.skills.sidebar.deleteDialog.title`),t[88]=r,t[89]=we);let Te;t[90]===we?Te=t[91]:(Te=(0,$.jsx)(pn,{children:we}),t[90]=we,t[91]=Te);let Ee=c?.name??``,De;t[92]!==r||t[93]!==Ee?(De=r(`settings.skills.sidebar.deleteDialog.description`,{name:Ee}),t[92]=r,t[93]=Ee,t[94]=De):De=t[94];let Oe;t[95]===De?Oe=t[96]:(Oe=(0,$.jsx)(mn,{children:De}),t[95]=De,t[96]=Oe);let ke;t[97]!==Te||t[98]!==Oe?(ke=(0,$.jsxs)(un,{children:[Te,Oe]}),t[97]=Te,t[98]=Oe,t[99]=ke):ke=t[99];let Ae;t[100]===Symbol.for(`react.memo_cache_sentinel`)?(Ae=()=>l(null),t[100]=Ae):Ae=t[100];let je;t[101]===r?je=t[102]:(je=r(`settings.common.actions.cancel`),t[101]=r,t[102]=je);let Me;t[103]!==u||t[104]!==je?(Me=(0,$.jsx)(K,{size:`sm`,className:`text-foreground hover:bg-interactive-hover hover:text-foreground`,variant:`ghost`,onClick:Ae,disabled:u,children:je}),t[103]=u,t[104]=je,t[105]=Me):Me=t[105];let Ne;t[106]===r?Ne=t[107]:(Ne=r(`settings.common.actions.delete`),t[106]=r,t[107]=Ne);let Pe;t[108]!==A||t[109]!==u||t[110]!==Ne?(Pe=(0,$.jsx)(K,{size:`sm`,onClick:A,disabled:u,children:Ne}),t[108]=A,t[109]=u,t[110]=Ne,t[111]=Pe):Pe=t[111];let Fe;t[112]!==Me||t[113]!==Pe?(Fe=(0,$.jsxs)(dn,{children:[Me,Pe]}),t[112]=Me,t[113]=Pe,t[114]=Fe):Fe=t[114];let Ie;t[115]!==ke||t[116]!==Fe?(Ie=(0,$.jsxs)(fn,{className:`max-w-md`,children:[ke,Fe]}),t[115]=ke,t[116]=Fe,t[117]=Ie):Ie=t[117];let Le;t[118]!==W||t[119]!==Ce||t[120]!==Ie?(Le=(0,$.jsx)(hn,{open:W,onOpenChange:Ce,children:Ie}),t[118]=W,t[119]=Ce,t[120]=Ie,t[121]=Le):Le=t[121];let Re=i!==null,ze;t[122]===Symbol.for(`react.memo_cache_sentinel`)?(ze=e=>!e&&a(null),t[122]=ze):ze=t[122];let Be;t[123]===r?Be=t[124]:(Be=r(`settings.skills.sidebar.renameDialog.title`),t[123]=r,t[124]=Be);let Ve;t[125]===Be?Ve=t[126]:(Ve=(0,$.jsx)(pn,{children:Be}),t[125]=Be,t[126]=Ve);let Ue=i?.name??``,We;t[127]!==r||t[128]!==Ue?(We=r(`settings.skills.sidebar.renameDialog.description`,{name:Ue}),t[127]=r,t[128]=Ue,t[129]=We):We=t[129];let Ge;t[130]===We?Ge=t[131]:(Ge=(0,$.jsx)(mn,{children:We}),t[130]=We,t[131]=Ge);let Ke;t[132]!==Ve||t[133]!==Ge?(Ke=(0,$.jsxs)(un,{children:[Ve,Ge]}),t[132]=Ve,t[133]=Ge,t[134]=Ke):Ke=t[134];let qe;t[135]===Symbol.for(`react.memo_cache_sentinel`)?(qe=e=>s(e.target.value),t[135]=qe):qe=t[135];let Je;t[136]===r?Je=t[137]:(Je=r(`settings.skills.sidebar.renameDialog.placeholder`),t[136]=r,t[137]=Je);let Ye;t[138]===I?Ye=t[139]:(Ye=e=>{e.key===`Enter`&&I()},t[138]=I,t[139]=Ye);let Xe;t[140]!==o||t[141]!==Je||t[142]!==Ye?(Xe=(0,$.jsx)(En,{value:o,onChange:qe,placeholder:Je,className:`text-foreground placeholder:text-muted-foreground`,onKeyDown:Ye}),t[140]=o,t[141]=Je,t[142]=Ye,t[143]=Xe):Xe=t[143];let Ze;t[144]===Symbol.for(`react.memo_cache_sentinel`)?(Ze=()=>a(null),t[144]=Ze):Ze=t[144];let Qe;t[145]===r?Qe=t[146]:(Qe=r(`settings.common.actions.cancel`),t[145]=r,t[146]=Qe);let $e;t[147]===Qe?$e=t[148]:($e=(0,$.jsx)(K,{size:`sm`,className:`text-foreground hover:bg-interactive-hover hover:text-foreground`,variant:`ghost`,onClick:Ze,children:Qe}),t[147]=Qe,t[148]=$e);let et;t[149]===r?et=t[150]:(et=r(`settings.common.actions.rename`),t[149]=r,t[150]=et);let tt;t[151]!==I||t[152]!==et?(tt=(0,$.jsx)(K,{size:`sm`,onClick:I,children:et}),t[151]=I,t[152]=et,t[153]=tt):tt=t[153];let nt;t[154]!==$e||t[155]!==tt?(nt=(0,$.jsxs)(dn,{children:[$e,tt]}),t[154]=$e,t[155]=tt,t[156]=nt):nt=t[156];let rt;t[157]!==Ke||t[158]!==Xe||t[159]!==nt?(rt=(0,$.jsxs)(fn,{children:[Ke,Xe,nt]}),t[157]=Ke,t[158]=Xe,t[159]=nt,t[160]=rt):rt=t[160];let it;t[161]!==Re||t[162]!==rt?(it=(0,$.jsx)(hn,{open:Re,onOpenChange:ze,children:rt}),t[161]=Re,t[162]=rt,t[163]=it):it=t[163];let at;return t[164]!==ve||t[165]!==ye||t[166]!==be||t[167]!==xe||t[168]!==Se||t[169]!==Le||t[170]!==it?(at=(0,$.jsxs)(`div`,{className:ge,children:[_e,ve,ye,be,xe,Se,Le,it]}),t[164]=ve,t[165]=ye,t[166]=be,t[167]=xe,t[168]=Se,t[169]=Le,t[170]=it,t[171]=at):at=t[171],at},lu=e=>{let t=(0,qi.c)(51),{skill:n,isSelected:r,onSelect:i,onDelete:a,onRename:o,onDuplicate:s,isMenuOpen:c,onMenuOpenChange:l}=e,{t:u}=He(),d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=Fr(),t[0]=d):d=t[0];let f=d,p;t[1]!==n.source||t[2]!==u?(p=n.source===`claude`?u(`settings.skills.sidebar.badge.claude`):n.source===`agents`?u(`settings.skills.sidebar.badge.agents`):u(`settings.skills.sidebar.badge.opencode`),t[1]=n.source,t[2]=u,t[3]=p):p=t[3];let m=p,h;t[4]===n?h=t[5]:(h=su(n),t[4]=n,t[5]=h);let g=h,[_,v]=Q.useState(!1),y;t[6]!==a||t[7]!==s||t[8]!==o||t[9]!==u?(y=e=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),o()},children:[(0,$.jsx)(Y,{name:`edit`,className:`h-4 w-4 mr-px`}),u(`settings.common.actions.rename`)]}),(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),s()},children:[(0,$.jsx)(Y,{name:`file-copy`,className:`h-4 w-4 mr-px`}),u(`settings.common.actions.duplicate`)]}),(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),a()},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(Y,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),u(`settings.common.actions.delete`)]})]}),t[6]=a,t[7]=s,t[8]=o,t[9]=u,t[10]=y):y=t[10];let b=y,x=!g&&_,S=r?`bg-interactive-selection`:`hover:bg-interactive-hover`,C;t[11]===S?C=t[12]:(C=G(`yuri-settings-group-row group relative flex items-center transition-colors duration-150 select-none`,S),t[11]=S,t[12]=C);let w;t[13]===g?w=t[14]:(w=!f&&!g?e=>{e.preventDefault(),v(!0)}:void 0,t[13]=g,t[14]=w);let T;t[15]!==C||t[16]!==w?(T=(0,$.jsx)(`div`,{className:C,onContextMenu:w}),t[15]=C,t[16]=w,t[17]=T):T=t[17];let E;t[18]===n.name?E=t[19]:(E=(0,$.jsx)(`span`,{className:`typography-ui-label font-normal whitespace-normal [overflow-wrap:anywhere] text-foreground`,children:n.name}),t[18]=n.name,t[19]=E);let D;t[20]===n.scope?D=t[21]:(D=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-[var(--surface-muted)] px-1 rounded flex-shrink-0 leading-none pb-px border border-[var(--interactive-border)]/50`,children:n.scope}),t[20]=n.scope,t[21]=D);let O;t[22]===m?O=t[23]:(O=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-[var(--surface-muted)] px-1 rounded flex-shrink-0 leading-none pb-px border border-[var(--interactive-border)]/50`,children:m}),t[22]=m,t[23]=O);let k;t[24]!==D||t[25]!==O?(k=(0,$.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1.5`,children:[D,O]}),t[24]=D,t[25]=O,t[26]=k):k=t[26];let A;t[27]!==E||t[28]!==k?(A=(0,$.jsxs)(`div`,{className:`flex min-w-0 max-w-full flex-col items-start gap-1.5`,children:[E,k]}),t[27]=E,t[28]=k,t[29]=A):A=t[29];let j;t[30]!==i||t[31]!==A?(j=(0,$.jsx)(`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:A}),t[30]=i,t[31]=A,t[32]=j):j=t[32];let M;t[33]!==g||t[34]!==c||t[35]!==l||t[36]!==b?(M=g?null:(0,$.jsxs)(Cr,{open:c,onOpenChange:e=>{e&&v(!1),l(e)},children:[(0,$.jsx)(kr,{asChild:!0,children:(0,$.jsx)(K,{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)(Y,{name:`more-2`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(hr,{align:`end`,className:`w-fit min-w-20`,children:b(ar)})]}),t[33]=g,t[34]=c,t[35]=l,t[36]=b,t[37]=M):M=t[37];let N;t[38]!==j||t[39]!==M?(N=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:[j,M]}),t[38]=j,t[39]=M,t[40]=N):N=t[40];let P;t[41]!==N||t[42]!==T?(P=(0,$.jsx)(Pi,{render:T,children:N}),t[41]=N,t[42]=T,t[43]=P):P=t[43];let F;t[44]!==g||t[45]!==b?(F=g?null:(0,$.jsx)(Ii,{className:`w-fit min-w-20`,children:b(Ri)}),t[44]=g,t[45]=b,t[46]=F):F=t[46];let I;return t[47]!==P||t[48]!==F||t[49]!==x?(I=(0,$.jsxs)(ji,{open:x,onOpenChange:v,children:[P,F]}),t[47]=P,t[48]=F,t[49]=x,t[50]=I):I=t[50],I};function uu(e){return{selectedSkillName:e.selectedSkillName,setSelectedSkill:e.setSelectedSkill,setSkillDraft:e.setSkillDraft,createSkill:e.createSkill,deleteSkill:e.deleteSkill,getSkillDetail:e.getSkillDetail}}function du(e){return e.scope===`project`}function fu(e){return e.scope===`user`}function pu(e,t){return e.localeCompare(t)}function mu(e,t){return e.name.localeCompare(t.name)}function hu(e,t){return e.name.localeCompare(t.name)}var gu=()=>{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},_u=ce()(ue(e=>({selectedSourceId:Et[0]?.id??null,isScanning:!1,isInstalling:!1,lastScanError:null,lastInstallError:null,scanResults:null,setSelectedSource:t=>e({selectedSourceId:t}),scanRepo:async(t,n)=>{e({isScanning:!0,lastScanError:null,scanResults:null});try{let r=n&&Object.prototype.hasOwnProperty.call(n,`directory`)?typeof n?.directory==`string`&&n.directory.trim()||null:gu(),i=r?`?directory=${encodeURIComponent(r)}`:``,a=await p(`/api/config/skills/scan${i}`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(t)}),o=await a.json().catch(()=>null);if(!a.ok||!o){let t=o?.error||{kind:`unknown`,message:`Failed to scan repository`};return e({lastScanError:t}),{ok:!1,error:t}}return o.ok?(e({scanResults:o.items||[]}),o):(e({lastScanError:o.error||{kind:`unknown`,message:`Failed to scan repository`}}),o)}finally{e({isScanning:!1})}},installSkills:async(t,n)=>{let r=n&&Object.prototype.hasOwnProperty.call(n,`directory`)?typeof n?.directory==`string`&&n.directory.trim()||null:gu(),a=n?.transportIdentity??i();if(i()!==a)return{ok:!1,error:{kind:`unknown`,message:`Failed to install skills`}};e({isInstalling:!0,lastInstallError:null});try{let n=r?`?directory=${encodeURIComponent(r)}`:``,o=await p(`/api/config/skills/install${n}`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify(t)}),s=await o.json().catch(()=>null);if(!s){let t={kind:`unknown`,message:`Failed to install skills`};return e({lastInstallError:t}),{ok:!1,error:t}}if(!o.ok||!s.ok){let t=s.error||{kind:`unknown`,message:`Failed to install skills`};return e({lastInstallError:t}),{ok:!1,error:t}}return i()===a?(await Yt(l,r,a),i()===a&&await yt(l,r,a),s):s}catch(t){let n={kind:`unknown`,message:t instanceof Error?t.message:String(t)};return e({lastInstallError:n}),{ok:!1,error:n}}finally{e({isInstalling:!1})}}}),{name:`skills-catalog-store`})),vu=()=>`custom:${Date.now()}-${Math.random().toString(16).slice(2)}`,yu=e=>{let t=e.trim(),n=t.startsWith(`https://`)?`https`:t.startsWith(`git@`)?`ssh`:`shorthand`;if(n===`ssh`)return`${t.split(`:`)[1].replace(/\.git$/i,``)}`;if(n===`https`)return t.split(`/`).slice(3).filter(Boolean).join(`/`).replace(/\.git$/i,``);let r=t.match(/^([^/\s]+)\/([^/\s]+)(?:\/.+)?$/);return r?`${r[1]}/${r[2].replace(/\.git$/i,``)}`:t},bu=async()=>{try{let e=f()?.settings;if(e)return(await e.load())?.settings||{};let t=await p(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});return t.ok?await t.json().catch(()=>null):null}catch{return null}},xu=e=>{let t=(0,qi.c)(158),{open:n,onOpenChange:r}=e,{t:a}=He(),o=_u(Su),s=_u(Cu),c=_u(wu),u=xi(Tu),d=xi(Eu),[f,p]=Q.useState(``),[m,h]=Q.useState(``),[g,_]=Q.useState(``),v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v=[],t[0]=v):v=t[0];let[y,b]=Q.useState(v),[x,S]=Q.useState(null),[C,w]=Q.useState(!1),T;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(T=[],t[1]=T):T=t[1];let[E,D]=Q.useState(T),[k,A]=Q.useState(null),j=Q.useRef(0),M=Q.useRef(null),P;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(P=e=>{j.current+=1,w(!1),S(null),M.current=null,e?.clearIdentity&&(D([]),A(null))},t[2]=P):P=t[2];let F=P,I,L;t[3]!==d||t[4]!==n?(I=()=>{n&&(j.current+=1,p(``),h(``),_(``),S(null),w(!1),M.current=null,D([]),A(null),d(),(async()=>{let e=await bu(),t=Array.isArray(e?.skillCatalogs)?e?.skillCatalogs:[];b(t||[])})())},L=[n,d],t[3]=d,t[4]=n,t[5]=I,t[6]=L):(I=t[5],L=t[6]),Q.useEffect(I,L);let R;t[7]===m?R=t[8]:(R=m.trim(),t[7]=m,t[8]=R);let z=R,B;t[9]===g?B=t[10]:(B=g.trim(),t[9]=g,t[10]=B);let V=B,ee;if(t[11]!==y||t[12]!==z||t[13]!==V){let e;t[15]!==z||t[16]!==V?(e=e=>{let t=(e.source||``).trim(),n=(e.subpath||``).trim();return t===z&&n===V},t[15]=z,t[16]=V,t[17]=e):e=t[17],ee=y.some(e),t[11]=y,t[12]=z,t[13]=V,t[14]=ee}else ee=t[14];let H=ee,te;t[18]!==u||t[19]!==k||t[20]!==f||t[21]!==o||t[22]!==m||t[23]!==g||t[24]!==a?(te=async()=>{let e=m.trim();if(!e){q.error(a(`settings.skills.catalog.add.toast.repositoryRequired`));return}f.trim()||p(yu(e)),w(!1),S(null);let t=j.current+1;j.current=t;let n=Qt(),r=i(),s=await o({source:e,subpath:g.trim()||void 0,gitIdentityId:k||void 0},{directory:n});if(j.current!==t||i()!==r||Qt()!==n)return;if(!s.ok){if(s.error?.kind===`authRequired`){if(N()){q.error(a(`settings.skills.catalog.shared.toast.privateRepoNotSupportedVsCode`));return}let e=s.error.identities||[];if(D(e),!k&&e.length>0){let t=u&&u!==`global`&&e.some(e=>e.id===u)?u:e[0].id;A(t)}q.error(a(`settings.skills.catalog.add.toast.authenticationRequiredScan`));return}q.error(s.error?.message||a(`settings.skills.catalog.add.toast.scanFailed`));return}let c=s.items?.length||0;if(S(c),c===0){q.error(a(`settings.skills.catalog.add.toast.noSkillsFound`)),w(!1);return}D([]),w(!0),M.current={directory:n,transport:r},q.success(a(`settings.skills.catalog.shared.toast.foundSkills`,{count:c}))},t[18]=u,t[19]=k,t[20]=f,t[21]=o,t[22]=m,t[23]=g,t[24]=a,t[25]=te):te=t[25];let ne=te,U;t[26]!==y||t[27]!==k||t[28]!==H||t[29]!==f||t[30]!==r||t[31]!==C||t[32]!==s||t[33]!==m||t[34]!==g||t[35]!==a?(U=async()=>{let e=f.trim(),t=m.trim(),n=g.trim();if(!e){q.error(a(`settings.skills.catalog.add.toast.catalogNameRequired`));return}if(!t){q.error(a(`settings.skills.catalog.add.toast.repositoryRequired`));return}let o=Qt(),c=i();if(!C||M.current?.directory!==o||M.current?.transport!==c){w(!1),M.current=null,q.error(a(`settings.skills.catalog.add.toast.scanBeforeAdd`));return}if(H){q.error(a(`settings.skills.catalog.add.toast.catalogAlreadyExists`));return}let u={id:vu(),label:e,source:t,...n?{subpath:n}:{},...k?{gitIdentityId:k}:{}},d=[...y,u],p=Qt(),h=i();try{await O({skillCatalogs:d}),b(d),q.success(a(`settings.skills.catalog.add.toast.catalogAdded`)),await l.invalidateQueries({queryKey:[h,`skillsCatalog`,`sources`],exact:!1}),await It(l,p,h),await ot(l,p,u.id,h),i()===h&&(s(u.id),r(!1))}catch(e){let t=e;q.error(t instanceof Error?t.message:a(`settings.skills.catalog.add.toast.saveFailed`))}},t[26]=y,t[27]=k,t[28]=H,t[29]=f,t[30]=r,t[31]=C,t[32]=s,t[33]=m,t[34]=g,t[35]=a,t[36]=U):U=t[36];let re=U,ie;t[37]===a?ie=t[38]:(ie=a(`settings.skills.catalog.add.title`),t[37]=a,t[38]=ie);let ae;t[39]===ie?ae=t[40]:(ae=(0,$.jsx)(pn,{children:ie}),t[39]=ie,t[40]=ae);let oe;t[41]===a?oe=t[42]:(oe=a(`settings.skills.catalog.add.descriptionPrefix`),t[41]=a,t[42]=oe);let se;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,$.jsx)(`code`,{className:`font-mono`,children:`SKILL.md`}),t[43]=se):se=t[43];let ce;t[44]===a?ce=t[45]:(ce=a(`settings.skills.catalog.add.descriptionSuffix`),t[44]=a,t[45]=ce);let le;t[46]!==oe||t[47]!==ce?(le=(0,$.jsxs)(mn,{children:[oe,` `,se,ce]}),t[46]=oe,t[47]=ce,t[48]=le):le=t[48];let ue;t[49]!==ae||t[50]!==le?(ue=(0,$.jsxs)(un,{children:[ae,le]}),t[49]=ae,t[50]=le,t[51]=ue):ue=t[51];let de;t[52]===a?de=t[53]:(de=a(`settings.skills.catalog.add.field.catalogName`),t[52]=a,t[53]=de);let fe;t[54]===de?fe=t[55]:(fe=(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:de}),t[54]=de,t[55]=fe);let pe;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(pe=e=>p(e.target.value),t[56]=pe):pe=t[56];let me;t[57]===a?me=t[58]:(me=a(`settings.skills.catalog.add.field.catalogNamePlaceholder`),t[57]=a,t[58]=me);let he;t[59]!==f||t[60]!==me?(he=(0,$.jsx)(En,{value:f,onChange:pe,placeholder:me}),t[59]=f,t[60]=me,t[61]=he):he=t[61];let ge;t[62]!==fe||t[63]!==he?(ge=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[fe,he]}),t[62]=fe,t[63]=he,t[64]=ge):ge=t[64];let _e;t[65]===a?_e=t[66]:(_e=a(`settings.skills.catalog.add.field.repository`),t[65]=a,t[66]=_e);let ve;t[67]===_e?ve=t[68]:(ve=(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:_e}),t[67]=_e,t[68]=ve);let ye;t[69]===Symbol.for(`react.memo_cache_sentinel`)?(ye=e=>{h(e.target.value),F({clearIdentity:!0})},t[69]=ye):ye=t[69];let be;t[70]===a?be=t[71]:(be=a(`settings.skills.catalog.shared.field.repositoryPlaceholder`),t[70]=a,t[71]=be);let xe;t[72]!==m||t[73]!==be?(xe=(0,$.jsx)(En,{value:m,onChange:ye,placeholder:be}),t[72]=m,t[73]=be,t[74]=xe):xe=t[74];let Se;t[75]===a?Se=t[76]:(Se=a(`settings.skills.catalog.add.field.repositoryHint`),t[75]=a,t[76]=Se);let W;t[77]===Se?W=t[78]:(W=(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:Se}),t[77]=Se,t[78]=W);let Ce;t[79]!==ve||t[80]!==xe||t[81]!==W?(Ce=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[ve,xe,W]}),t[79]=ve,t[80]=xe,t[81]=W,t[82]=Ce):Ce=t[82];let we;t[83]===a?we=t[84]:(we=a(`settings.skills.catalog.add.field.optionalSubpath`),t[83]=a,t[84]=we);let Te;t[85]===we?Te=t[86]:(Te=(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:we}),t[85]=we,t[86]=Te);let Ee;t[87]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=e=>{_(e.target.value),F({clearIdentity:!0})},t[87]=Ee):Ee=t[87];let De;t[88]===a?De=t[89]:(De=a(`settings.skills.catalog.shared.field.subpathPlaceholder`),t[88]=a,t[89]=De);let Oe;t[90]!==g||t[91]!==De?(Oe=(0,$.jsx)(En,{value:g,onChange:Ee,placeholder:De}),t[90]=g,t[91]=De,t[92]=Oe):Oe=t[92];let ke;t[93]!==Te||t[94]!==Oe?(ke=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[Te,Oe]}),t[93]=Te,t[94]=Oe,t[95]=ke):ke=t[95];let Ae;t[96]!==k||t[97]!==E||t[98]!==a?(Ae=E.length>0&&!N()?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-[var(--status-warning)]`,children:a(`settings.skills.catalog.shared.auth.title`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground ml-2`,children:a(`settings.skills.catalog.shared.auth.description`)})]}),(0,$.jsxs)(Cn,{value:k||``,onValueChange:e=>{A(e),F()},children:[(0,$.jsx)(bn,{className:`w-fit`,children:(0,$.jsx)(`span`,{children:E.find(e=>e.id===k)?.name||a(`settings.skills.catalog.shared.auth.chooseIdentity`)})}),(0,$.jsx)(xn,{align:`start`,children:E.map(Du)})]}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:a(`settings.skills.catalog.shared.auth.footerHint`)})]}):null,t[96]=k,t[97]=E,t[98]=a,t[99]=Ae):Ae=t[99];let je;t[100]!==x||t[101]!==a?(je=x===null?null:(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:a(`settings.skills.catalog.add.scanResult`,{count:x})}),t[100]=x,t[101]=a,t[102]=je):je=t[102];let Me;t[103]!==H||t[104]!==a?(Me=H?(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:a(`settings.skills.catalog.add.duplicateMessage`)}):null,t[103]=H,t[104]=a,t[105]=Me):Me=t[105];let Ne;t[106]!==ge||t[107]!==Ce||t[108]!==ke||t[109]!==Ae||t[110]!==je||t[111]!==Me?(Ne=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[ge,Ce,ke,Ae,je,Me]}),t[106]=ge,t[107]=Ce,t[108]=ke,t[109]=Ae,t[110]=je,t[111]=Me,t[112]=Ne):Ne=t[112];let Pe;t[113]===r?Pe=t[114]:(Pe=()=>r(!1),t[113]=r,t[114]=Pe);let Fe;t[115]===a?Fe=t[116]:(Fe=a(`settings.common.actions.cancel`),t[115]=a,t[116]=Fe);let Ie;t[117]!==Pe||t[118]!==Fe?(Ie=(0,$.jsx)(K,{size:`sm`,variant:`ghost`,onClick:Pe,children:Fe}),t[117]=Pe,t[118]=Fe,t[119]=Ie):Ie=t[119];let Le;t[120]===ne?Le=t[121]:(Le=()=>void ne(),t[120]=ne,t[121]=Le);let Re;t[122]!==c||t[123]!==m?(Re=c||!m.trim(),t[122]=c,t[123]=m,t[124]=Re):Re=t[124];let ze;t[125]===Symbol.for(`react.memo_cache_sentinel`)?(ze=(0,$.jsx)(Y,{name:`git-repository`,className:`h-4 w-4`}),t[125]=ze):ze=t[125];let Be;t[126]!==c||t[127]!==a?(Be=a(c?`settings.skills.catalog.shared.actions.scanning`:`settings.skills.catalog.shared.actions.scan`),t[126]=c,t[127]=a,t[128]=Be):Be=t[128];let Ve;t[129]!==Le||t[130]!==Re||t[131]!==Be?(Ve=(0,$.jsxs)(K,{size:`sm`,className:`gap-2`,variant:`ghost`,onClick:Le,disabled:Re,children:[ze,Be]}),t[129]=Le,t[130]=Re,t[131]=Be,t[132]=Ve):Ve=t[132];let Ue;t[133]===re?Ue=t[134]:(Ue=()=>void re(),t[133]=re,t[134]=Ue);let We;t[135]!==H||t[136]!==f||t[137]!==C||t[138]!==m?(We=!C||H||!f.trim()||!m.trim(),t[135]=H,t[136]=f,t[137]=C,t[138]=m,t[139]=We):We=t[139];let Ge;t[140]===a?Ge=t[141]:(Ge=a(`settings.skills.catalog.add.actions.addCatalog`),t[140]=a,t[141]=Ge);let G;t[142]!==Ue||t[143]!==We||t[144]!==Ge?(G=(0,$.jsx)(K,{size:`sm`,onClick:Ue,disabled:We,children:Ge}),t[142]=Ue,t[143]=We,t[144]=Ge,t[145]=G):G=t[145];let Ke;t[146]!==Ie||t[147]!==Ve||t[148]!==G?(Ke=(0,$.jsxs)(dn,{children:[Ie,Ve,G]}),t[146]=Ie,t[147]=Ve,t[148]=G,t[149]=Ke):Ke=t[149];let qe;t[150]!==ue||t[151]!==Ne||t[152]!==Ke?(qe=(0,$.jsxs)(fn,{className:`max-w-xl`,children:[ue,Ne,Ke]}),t[150]=ue,t[151]=Ne,t[152]=Ke,t[153]=qe):qe=t[153];let Je;return t[154]!==r||t[155]!==n||t[156]!==qe?(Je=(0,$.jsx)(hn,{open:n,onOpenChange:r,children:qe}),t[154]=r,t[155]=n,t[156]=qe,t[157]=Je):Je=t[157],Je};function Su(e){return e.scanRepo}function Cu(e){return e.setSelectedSource}function wu(e){return e.isScanning}function Tu(e){return e.defaultGitIdentityId}function Eu(e){return e.loadDefaultGitIdentityId}function Du(e){return(0,$.jsx)(vn,{value:e.id,children:e.name},e.id)}var Ou=e=>{let t=(0,qi.c)(85),{open:n,onOpenChange:r,conflicts:i,onConfirm:a}=e,{t:o}=He(),s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={},t[0]=s):s=t[0];let[c,l]=Q.useState(s),u,d;t[1]!==i||t[2]!==n?(u=()=>{if(!n)return;let e={};for(let t of i)e[t.skillName]=`skip`;l(e)},d=[n,i],t[1]=i,t[2]=n,t[3]=u,t[4]=d):(u=t[3],d=t[4]),Q.useEffect(u,d);let f;t[5]===i?f=t[6]:(f=e=>{let t={};for(let n of i)t[n.skillName]=e;l(t)},t[5]=i,t[6]=f);let p=f,m;t[7]!==i||t[8]!==c?(m=i.length>0&&i.every(e=>c[e.skillName]),t[7]=i,t[8]=c,t[9]=m):m=t[9];let h=m,g;t[10]===o?g=t[11]:(g=o(`settings.skills.catalog.conflicts.title`),t[10]=o,t[11]=g);let _;t[12]===g?_=t[13]:(_=(0,$.jsx)(pn,{children:g}),t[12]=g,t[13]=_);let v;t[14]===o?v=t[15]:(v=o(`settings.skills.catalog.conflicts.description`),t[14]=o,t[15]=v);let y;t[16]===v?y=t[17]:(y=(0,$.jsx)(mn,{children:v}),t[16]=v,t[17]=y);let b;t[18]!==_||t[19]!==y?(b=(0,$.jsxs)(un,{children:[_,y]}),t[18]=_,t[19]=y,t[20]=b):b=t[20];let x;t[21]!==i.length||t[22]!==o?(x=o(`settings.skills.catalog.conflicts.count`,{count:i.length}),t[21]=i.length,t[22]=o,t[23]=x):x=t[23];let S;t[24]===x?S=t[25]:(S=(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:x}),t[24]=x,t[25]=S);let C;t[26]===p?C=t[27]:(C=()=>p(`skip`),t[26]=p,t[27]=C);let w;t[28]===o?w=t[29]:(w=o(`settings.skills.catalog.conflicts.actions.skipAll`),t[28]=o,t[29]=w);let T;t[30]!==C||t[31]!==w?(T=(0,$.jsx)(K,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:C,children:w}),t[30]=C,t[31]=w,t[32]=T):T=t[32];let E;t[33]===p?E=t[34]:(E=()=>p(`overwrite`),t[33]=p,t[34]=E);let D;t[35]===o?D=t[36]:(D=o(`settings.skills.catalog.conflicts.actions.overwriteAll`),t[35]=o,t[36]=D);let O;t[37]!==E||t[38]!==D?(O=(0,$.jsx)(K,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:E,children:D}),t[37]=E,t[38]=D,t[39]=O):O=t[39];let k;t[40]!==T||t[41]!==O?(k=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[T,O]}),t[40]=T,t[41]=O,t[42]=k):k=t[42];let A;t[43]!==S||t[44]!==k?(A=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[S,k]}),t[43]=S,t[44]=k,t[45]=A):A=t[45];let j;if(t[46]!==i||t[47]!==c||t[48]!==o){let e;t[50]!==c||t[51]!==o?(e=e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label truncate`,children:e.skillName}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:o(`settings.skills.catalog.conflicts.installedIn`,{scope:e.scope===`project`?o(`settings.skills.catalog.conflicts.scope.project`):o(`settings.skills.catalog.conflicts.scope.user`),source:e.source===`agents`?o(`settings.skills.catalog.conflicts.source.agents`):o(`settings.skills.catalog.conflicts.source.opencode`)})})]}),(0,$.jsxs)(Cn,{value:c[e.skillName]||`skip`,onValueChange:t=>l(n=>({...n,[e.skillName]:t})),children:[(0,$.jsx)(bn,{className:`w-fit`,children:(0,$.jsx)(`span`,{className:`capitalize`,children:(c[e.skillName]||`skip`)===`overwrite`?o(`settings.skills.catalog.conflicts.decision.overwrite`):o(`settings.skills.catalog.conflicts.decision.skip`)})}),(0,$.jsxs)(xn,{align:`end`,children:[(0,$.jsx)(vn,{value:`skip`,className:`pr-2 [&>span:first-child]:hidden`,children:o(`settings.skills.catalog.conflicts.decision.skip`)}),(0,$.jsx)(vn,{value:`overwrite`,className:`pr-2 [&>span:first-child]:hidden`,children:o(`settings.skills.catalog.conflicts.decision.overwrite`)})]})]})]},e.skillName),t[50]=c,t[51]=o,t[52]=e):e=t[52],j=i.map(e),t[46]=i,t[47]=c,t[48]=o,t[49]=j}else j=t[49];let M;t[53]===j?M=t[54]:(M=(0,$.jsx)(`div`,{className:`space-y-2`,children:j}),t[53]=j,t[54]=M);let N;t[55]!==A||t[56]!==M?(N=(0,$.jsxs)(`div`,{className:`space-y-3`,children:[A,M]}),t[55]=A,t[56]=M,t[57]=N):N=t[57];let P;t[58]===r?P=t[59]:(P=()=>r(!1),t[58]=r,t[59]=P);let F;t[60]===o?F=t[61]:(F=o(`settings.common.actions.cancel`),t[60]=o,t[61]=F);let I;t[62]!==P||t[63]!==F?(I=(0,$.jsx)(K,{size:`sm`,variant:`ghost`,onClick:P,children:F}),t[62]=P,t[63]=F,t[64]=I):I=t[64];let L;t[65]!==c||t[66]!==a?(L=()=>a(c),t[65]=c,t[66]=a,t[67]=L):L=t[67];let R=!h,z;t[68]===o?z=t[69]:(z=o(`settings.skills.catalog.conflicts.actions.continue`),t[68]=o,t[69]=z);let B;t[70]!==L||t[71]!==R||t[72]!==z?(B=(0,$.jsx)(K,{size:`sm`,onClick:L,disabled:R,children:z}),t[70]=L,t[71]=R,t[72]=z,t[73]=B):B=t[73];let V;t[74]!==I||t[75]!==B?(V=(0,$.jsxs)(dn,{children:[I,B]}),t[74]=I,t[75]=B,t[76]=V):V=t[76];let ee;t[77]!==b||t[78]!==N||t[79]!==V?(ee=(0,$.jsxs)(fn,{className:`max-w-2xl`,children:[b,N,V]}),t[77]=b,t[78]=N,t[79]=V,t[80]=ee):ee=t[80];let H;return t[81]!==r||t[82]!==n||t[83]!==ee?(H=(0,$.jsx)(hn,{open:n,onOpenChange:r,children:ee}),t[81]=r,t[82]=n,t[83]=ee,t[84]=H):H=t[84],H},ku=[{value:`user-opencode`,scope:`user`,source:`opencode`,label:`User / OpenCode`,description:`Global OpenCode config location`},{value:`project-opencode`,scope:`project`,source:`opencode`,label:`Project / OpenCode`,description:`Current project .opencode location`},{value:`user-agents`,scope:`user`,source:`agents`,label:`User / Agents`,description:`Global .agents compatibility location`},{value:`project-agents`,scope:`project`,source:`agents`,label:`Project / Agents`,description:`Current project .agents compatibility location`}];function Au(e,t){return e===`project`&&t===`claude`?`project-claude`:e===`project`&&t===`agents`?`project-agents`:t===`claude`?`user-claude`:e===`project`?`project-opencode`:t===`agents`?`user-agents`:`user-opencode`}function ju(e){if(e===`user-claude`)return{scope:`user`,source:`claude`};if(e===`project-claude`)return{scope:`project`,source:`claude`};let t=ku.find(t=>t.value===e);return t?{scope:t.scope,source:t.source}:{scope:`user`,source:`opencode`}}var Mu=e=>{let t=(0,qi.c)(124),{open:n,onOpenChange:r,item:a}=e,{t:o}=He(),s=_u(Nu),c=_u(Pu),[l,u]=Q.useState(`user`),[d,f]=Q.useState(`opencode`),p=Lt(Fu),m=Lt(Iu),[h,g]=Q.useState(null),[_,v]=Q.useState(!1),y;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(y=[],t[0]=y):y=t[0];let[b,x]=Q.useState(y),[S,C]=Q.useState(null),w,T;t[1]!==m||t[2]!==n?(w=()=>{n&&(u(`user`),f(`opencode`),g(m),v(!1),x([]),C(null))},T=[n,m],t[1]=m,t[2]=n,t[3]=w,t[4]=T):(w=t[3],T=t[4]),Q.useEffect(w,T);let E;t[5]===o?E=t[6]:(E=e=>{switch(e){case`project-opencode`:return o(`settings.skills.location.option.projectOpencode.label`);case`user-agents`:return o(`settings.skills.location.option.userAgents.label`);case`project-agents`:return o(`settings.skills.location.option.projectAgents.label`);default:return o(`settings.skills.location.option.userOpencode.label`)}},t[5]=o,t[6]=E);let D=E,O;t[7]===o?O=t[8]:(O=e=>{switch(e){case`project-opencode`:return o(`settings.skills.location.option.projectOpencode.description`);case`user-agents`:return o(`settings.skills.location.option.userAgents.description`);case`project-agents`:return o(`settings.skills.location.option.projectAgents.description`);default:return o(`settings.skills.location.option.userOpencode.description`)}},t[7]=o,t[8]=O);let k=O,A;bb0:{if(p.length===0){A=null;break bb0}if(h&&p.some(e=>e.id===h)){A=h;break bb0}if(m&&p.some(e=>e.id===m)){A=m;break bb0}A=p[0]?.id??null}let j=A,M;bb1:{if(l!==`project`){M=null;break bb1}let e=j;if(!e){M=null;break bb1}let n;if(t[9]!==e||t[10]!==p){let r;t[12]===e?r=t[13]:(r=t=>t.id===e,t[12]=e,t[13]=r),n=p.find(r),t[9]=e,t[10]=p,t[11]=n}else n=t[11];M=n?.path??null}let N=M,P;t[14]!==s||t[15]!==a||t[16]!==r||t[17]!==o?(P=async e=>{let t={skillDir:e.skillDir};a?.clawdhub&&(t.clawdhub={slug:a.clawdhub.slug,version:a.clawdhub.version});let n=await s({source:e.source,subpath:e.subpath,gitIdentityId:a?.gitIdentityId,scope:e.scope,targetSource:e.targetSource,selections:[t],conflictPolicy:`prompt`,conflictDecisions:e.conflictDecisions},{directory:e.effectiveDirectory,transportIdentity:e.transportIdentity});if(n.ok){q.success(o(`settings.skills.catalog.installSkill.toast.installed`)),r(!1);return}if(n.error?.kind===`conflicts`){C({source:e.source,subpath:e.subpath,scope:e.scope,targetSource:e.targetSource,skillDir:e.skillDir,directoryOverride:e.directoryOverride??null,effectiveDirectory:e.effectiveDirectory,transportIdentity:e.transportIdentity}),x(n.error.conflicts),v(!0);return}if(n.error?.kind===`authRequired`){q.error(n.error.message||o(`settings.skills.catalog.installSkill.toast.authRequired`));return}q.error(n.error?.message||o(`settings.skills.catalog.installSkill.toast.installFailed`))},t[14]=s,t[15]=a,t[16]=r,t[17]=o,t[18]=P):P=t[18];let F=P;if(!a)return null;let I;t[19]===o?I=t[20]:(I=o(`settings.skills.catalog.installSkill.title`),t[19]=o,t[20]=I);let L;t[21]===I?L=t[22]:(L=(0,$.jsx)(pn,{children:I}),t[21]=I,t[22]=L);let R;t[23]===o?R=t[24]:(R=o(`settings.skills.catalog.installSkill.descriptionPrefix`),t[23]=o,t[24]=R);let z;t[25]===a.skillName?z=t[26]:(z=(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:a.skillName}),t[25]=a.skillName,t[26]=z);let B;t[27]===o?B=t[28]:(B=o(`settings.skills.catalog.installSkill.descriptionSuffix`),t[27]=o,t[28]=B);let V;t[29]!==R||t[30]!==z||t[31]!==B?(V=(0,$.jsxs)(mn,{children:[R,` `,z,` `,B]}),t[29]=R,t[30]=z,t[31]=B,t[32]=V):V=t[32];let ee;t[33]!==L||t[34]!==V?(ee=(0,$.jsxs)(un,{children:[L,V]}),t[33]=L,t[34]=V,t[35]=ee):ee=t[35];let H;t[36]===o?H=t[37]:(H=o(`settings.skills.catalog.installSkill.field.destination`),t[36]=o,t[37]=H);let te;t[38]===H?te=t[39]:(te=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:H}),t[38]=H,t[39]=te);let ne;t[40]!==l||t[41]!==d?(ne=Au(l,d),t[40]=l,t[41]=d,t[42]=ne):ne=t[42];let U;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(U=e=>{let t=ju(e);u(t.scope),f(t.source===`agents`?`agents`:`opencode`)},t[43]=U):U=t[43];let re;t[44]===l?re=t[45]:(re=l===`user`?(0,$.jsx)(Y,{name:`user-3`,className:`h-3.5 w-3.5`}):(0,$.jsx)(Y,{name:`folder`,className:`h-3.5 w-3.5`}),t[44]=l,t[45]=re);let ie;t[46]===d?ie=t[47]:(ie=d===`agents`?(0,$.jsx)(Y,{name:`robot-2`,className:`h-3.5 w-3.5`}):null,t[46]=d,t[47]=ie);let ae;t[48]!==D||t[49]!==l||t[50]!==d?(ae=D(Au(l,d)),t[48]=D,t[49]=l,t[50]=d,t[51]=ae):ae=t[51];let oe;t[52]===ae?oe=t[53]:(oe=(0,$.jsx)(`span`,{children:ae}),t[52]=ae,t[53]=oe);let se;t[54]!==re||t[55]!==ie||t[56]!==oe?(se=(0,$.jsxs)(bn,{className:`w-fit gap-1.5`,children:[re,ie,oe]}),t[54]=re,t[55]=ie,t[56]=oe,t[57]=se):se=t[57];let ce;t[58]!==k||t[59]!==D?(ce=ku.map(e=>(0,$.jsx)(vn,{value:e.value,className:`pr-2 [&>span:first-child]:hidden`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.scope===`user`?(0,$.jsx)(Y,{name:`user-3`,className:`h-3.5 w-3.5`}):(0,$.jsx)(Y,{name:`folder`,className:`h-3.5 w-3.5`}),e.source===`agents`?(0,$.jsx)(Y,{name:`robot-2`,className:`h-3.5 w-3.5`}):null,(0,$.jsx)(`span`,{children:D(e.value)})]}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground ml-5`,children:k(e.value)})]})},e.value)),t[58]=k,t[59]=D,t[60]=ce):ce=t[60];let le;t[61]===ce?le=t[62]:(le=(0,$.jsx)(xn,{align:`start`,children:ce}),t[61]=ce,t[62]=le);let ue;t[63]!==ne||t[64]!==se||t[65]!==le?(ue=(0,$.jsxs)(Cn,{value:ne,onValueChange:U,children:[se,le]}),t[63]=ne,t[64]=se,t[65]=le,t[66]=ue):ue=t[66];let de;t[67]!==te||t[68]!==ue?(de=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[te,ue]}),t[67]=te,t[68]=ue,t[69]=de):de=t[69];let fe;t[70]!==p||t[71]!==j||t[72]!==l||t[73]!==o?(fe=l===`project`&&(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.skills.catalog.installSkill.field.project`)}),p.length===0?(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:o(`settings.skills.catalog.installSkill.field.noProjects`)}):(0,$.jsxs)(Cn,{value:j??``,onValueChange:e=>g(e),disabled:p.length===1,children:[(0,$.jsx)(bn,{className:`w-fit`,children:(0,$.jsx)(Tn,{placeholder:o(`settings.skills.catalog.installSkill.field.chooseProjectPlaceholder`)})}),(0,$.jsx)(xn,{align:`start`,children:p.map(Lu)})]})]}),t[70]=p,t[71]=j,t[72]=l,t[73]=o,t[74]=fe):fe=t[74];let pe;t[75]===a.warnings?pe=t[76]:(pe=a.warnings?.length?(0,$.jsx)(`div`,{className:`typography-micro text-[var(--status-warning)] bg-[var(--status-warning)]/10 px-2 py-1.5 rounded`,children:a.warnings.join(` · `)}):null,t[75]=a.warnings,t[76]=pe);let me;t[77]!==de||t[78]!==fe||t[79]!==pe?(me=(0,$.jsxs)(`div`,{className:`mt-2 space-y-3`,children:[de,fe,pe]}),t[77]=de,t[78]=fe,t[79]=pe,t[80]=me):me=t[80];let he;t[81]===r?he=t[82]:(he=()=>r(!1),t[81]=r,t[82]=he);let ge;t[83]===o?ge=t[84]:(ge=o(`settings.common.actions.cancel`),t[83]=o,t[84]=ge);let _e;t[85]!==he||t[86]!==ge?(_e=(0,$.jsx)(K,{size:`sm`,variant:`ghost`,onClick:he,children:ge}),t[85]=he,t[86]=ge,t[87]=_e):_e=t[87];let ve=c||!a.installable||l===`project`&&!N,ye;t[88]!==N||t[89]!==F||t[90]!==a.repoSource||t[91]!==a.repoSubpath||t[92]!==a.skillDir||t[93]!==l||t[94]!==d?(ye=()=>void F({source:a.repoSource,subpath:a.repoSubpath,scope:l,targetSource:d,skillDir:a.skillDir,directoryOverride:N,effectiveDirectory:N??Qt(),transportIdentity:i()}),t[88]=N,t[89]=F,t[90]=a.repoSource,t[91]=a.repoSubpath,t[92]=a.skillDir,t[93]=l,t[94]=d,t[95]=ye):ye=t[95];let be;t[96]!==c||t[97]!==o?(be=o(c?`settings.skills.catalog.installSkill.actions.installing`:`settings.skills.catalog.installSkill.actions.install`),t[96]=c,t[97]=o,t[98]=be):be=t[98];let xe;t[99]!==ve||t[100]!==ye||t[101]!==be?(xe=(0,$.jsx)(K,{size:`sm`,disabled:ve,onClick:ye,children:be}),t[99]=ve,t[100]=ye,t[101]=be,t[102]=xe):xe=t[102];let Se;t[103]!==_e||t[104]!==xe?(Se=(0,$.jsxs)(dn,{children:[_e,xe]}),t[103]=_e,t[104]=xe,t[105]=Se):Se=t[105];let W;t[106]!==ee||t[107]!==me||t[108]!==Se?(W=(0,$.jsxs)(fn,{className:`max-w-md`,children:[ee,me,Se]}),t[106]=ee,t[107]=me,t[108]=Se,t[109]=W):W=t[109];let Ce;t[110]!==r||t[111]!==n||t[112]!==W?(Ce=(0,$.jsx)(hn,{open:n,onOpenChange:r,children:W}),t[110]=r,t[111]=n,t[112]=W,t[113]=Ce):Ce=t[113];let we;t[114]!==S||t[115]!==F?(we=e=>{S&&(F({source:S.source,subpath:S.subpath,scope:S.scope,targetSource:S.targetSource,skillDir:S.skillDir,conflictDecisions:e,directoryOverride:S.directoryOverride??null,effectiveDirectory:S.effectiveDirectory,transportIdentity:S.transportIdentity}),v(!1))},t[114]=S,t[115]=F,t[116]=we):we=t[116];let Te;t[117]!==b||t[118]!==_||t[119]!==we?(Te=(0,$.jsx)(Ou,{open:_,onOpenChange:v,conflicts:b,onConfirm:we}),t[117]=b,t[118]=_,t[119]=we,t[120]=Te):Te=t[120];let Ee;return t[121]!==Ce||t[122]!==Te?(Ee=(0,$.jsxs)($.Fragment,{children:[Ce,Te]}),t[121]=Ce,t[122]=Te,t[123]=Ee):Ee=t[123],Ee};function Nu(e){return e.installSkills}function Pu(e){return e.isInstalling}function Fu(e){return e.projects}function Iu(e){return e.activeProjectId}function Lu(e){return(0,$.jsx)(vn,{value:e.id,children:e.label||e.path},e.id)}var Ru=async()=>{try{let e=f()?.settings;if(e)return(await e.load())?.settings||{};let t=await p(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});return t.ok?await t.json().catch(()=>null):null}catch{return null}},zu=({mode:e,onModeChange:t,showModeTabs:n=!0})=>{let{t:r}=He(),{selectedSourceId:a,setSelectedSource:o}=_u(de(e=>({selectedSourceId:e.selectedSourceId,setSelectedSource:e.setSelectedSource}))),s=Xt(),c=s.data??Et,u=c.some(e=>e.id===a)?a:null,d=Gt(u??``,{enabled:!!u}),[f,p]=Q.useState(``),[m,h]=Q.useState(!1),[g,_]=Q.useState(!1),[v,y]=Q.useState(null),[b,x]=Q.useState(!1),[S,C]=Q.useState(!1),[w,T]=Q.useState(!1),[E,D]=Q.useState(null);Q.useEffect(()=>{!s.data&&s.isFetching||c.some(e=>e.id===a)||o(c[0]?.id??null)},[a,o,c,s.data,s.isFetching]);let k=Qt(),A=i();Q.useEffect(()=>{D(null)},[u,k,A]);let j=Q.useMemo(()=>Ot(d.data?.pages??[]),[d.data]),M=Q.useMemo(()=>{let e=f.trim().toLowerCase();return e?j.filter(t=>{let n=t.skillName.toLowerCase(),r=(t.description||``).toLowerCase(),i=(t.frontmatterName||``).toLowerCase();return n.includes(e)||r.includes(e)||i.includes(e)}):j},[j,f]),N=Q.useMemo(()=>c.find(e=>e.id===u)||null,[c,u]),P=!!(u&&u.startsWith(`custom:`)),F=N?.source===`clawdhub:registry`||N?.sourceType===`clawdhub`,I=s.isLoading&&!s.data,L=d.isLoading&&!d.data,R=d.isFetchingNextPage,z=E??s.error??d.error,B=async()=>{if(!u||!P)return;let e=Qt(),t=i();x(!0),D(null);try{let n=await Ru(),r=(Array.isArray(n?.skillCatalogs)?n?.skillCatalogs:[]).filter(e=>e.id!==u);await O({skillCatalogs:r}),l.setQueriesData({queryKey:[t,`skillsCatalog`,`sources`],exact:!1},e=>e?.filter(e=>e.id!==u)),l.removeQueries({queryKey:[t,`skillsCatalog`,`source`],exact:!1,predicate:e=>e.queryKey[4]===u}),i()===t&&(o(null),C(!1)),await It(l,e,t)}catch(n){i()===t&&Qt()===e&&D(n instanceof Error?n:Error(String(n)))}finally{x(!1)}},V=async()=>{let e=Qt(),t=i(),n=u;T(!0),D(null);try{n?await ot(l,e,n,t):await It(l,e,t)}catch(r){let a=_u.getState().selectedSourceId;i()===t&&Qt()===e&&a===n&&D(r instanceof Error?r:Error(String(r)))}finally{T(!1)}};return(0,$.jsx)(Rr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[n&&(0,$.jsx)(`div`,{className:`h-10`,children:(0,$.jsx)(Kr,{items:[{id:`manual`,label:r(`settings.skills.catalog.page.mode.manual`)},{id:`external`,label:r(`settings.skills.catalog.page.mode.external`)}],activeId:e,onSelect:e=>t(e),layoutMode:`fit`,variant:`animated`,animateActivePill:!1,className:`h-full`})}),(0,$.jsx)(X,{itemId:`skills.catalog.source`,label:r(`settings.skills.catalog.page.section.sourceRepository`),children:(0,$.jsxs)(`div`,{className:`yuri-settings-group-row flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(Cn,{value:u||``,onValueChange:e=>o(e),children:[(0,$.jsx)(bn,{className:`w-fit min-w-0 max-w-full`,"aria-label":r(`settings.skills.catalog.page.section.sourceRepository`),children:(0,$.jsx)(Tn,{placeholder:r(`settings.skills.catalog.page.field.selectSourcePlaceholder`),children:N?.label})}),(0,$.jsx)(xn,{align:`start`,children:c.map(e=>(0,$.jsx)(vn,{value:e.id,children:e.label},e.id))})]}),(0,$.jsx)(K,{variant:`ghost`,size:`icon`,onClick:()=>void V(),disabled:w,title:r(`settings.skills.catalog.page.actions.refreshTitle`),"aria-label":r(`settings.skills.catalog.page.actions.refreshTitle`),children:(0,$.jsx)(Y,{name:`refresh`,className:G(`h-3.5 w-3.5`,w&&`animate-spin`)})}),P&&(0,$.jsx)(K,{variant:`ghost`,size:`icon`,className:`text-[var(--status-error)] hover:text-[var(--status-error)]`,onClick:()=>C(!0),disabled:b,title:r(`settings.skills.catalog.page.actions.removeCatalogTitle`),"aria-label":r(`settings.skills.catalog.page.actions.removeCatalogTitle`),children:(0,$.jsx)(Y,{name:`delete-bin`,className:`h-3.5 w-3.5`})}),(0,$.jsxs)(K,{"data-settings-item":`skills.catalog.add-catalog`,size:`sm`,className:`ml-auto`,onClick:()=>h(!0),children:[(0,$.jsx)(Y,{name:`add`,className:`h-3.5 w-3.5`}),` `,r(`settings.skills.catalog.page.actions.addCatalog`)]})]})}),z&&(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-4 py-3`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label font-medium text-[var(--status-error)]`,children:r(`settings.skills.catalog.page.error.catalogTitle`)}),(0,$.jsx)(`div`,{className:`typography-meta text-[var(--status-error)]/80 mt-1`,children:z.message})]}),(0,$.jsxs)(`div`,{className:`min-w-0 space-y-3`,children:[(0,$.jsxs)(`div`,{"data-settings-item":`skills.catalog.search`,className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,$.jsxs)(`div`,{className:`relative min-w-0 flex-1 basis-48`,children:[(0,$.jsx)(Y,{name:`search`,className:`pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 size-4 text-muted-foreground`}),(0,$.jsx)(En,{value:f,onChange:e=>p(e.target.value),placeholder:r(`settings.skills.catalog.shared.field.searchSkillsPlaceholder`),"aria-label":r(`settings.skills.catalog.shared.field.searchSkillsPlaceholder`),className:`w-full pl-9`})]}),(0,$.jsx)(`span`,{className:`typography-meta shrink-0 text-muted-foreground tabular-nums`,role:`status`,children:I||L?r(`settings.skills.catalog.page.loading.catalog`):r(`settings.skills.catalog.page.foundCount`,{count:M.length})})]}),(0,$.jsx)(X,{children:M.length===0&&!L?(0,$.jsxs)(`div`,{className:`py-8 text-center text-muted-foreground`,children:[(0,$.jsx)(`p`,{className:`typography-body`,children:r(`settings.skills.catalog.page.empty.noSkillsTitle`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:r(`settings.skills.catalog.page.empty.noSkillsDescription`)})]}):L?(0,$.jsxs)(`div`,{className:`py-8 text-center text-muted-foreground`,children:[(0,$.jsx)(Y,{name:`refresh`,className:`mx-auto mb-3 h-5 w-5 animate-spin opacity-50`}),(0,$.jsx)(`p`,{className:`typography-meta`,children:r(`settings.skills.catalog.page.loading.skills`)})]}):(0,$.jsx)($.Fragment,{children:M.map(e=>{let t=e.installed?.isInstalled,n=e.installed?.scope;return(0,$.jsx)(`div`,{className:`yuri-settings-group-row`,children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-medium text-foreground [overflow-wrap:anywhere]`,children:e.skillName}),t&&(0,$.jsx)(`span`,{className:`typography-micro text-[var(--status-success)] bg-[var(--status-success)]/10 px-1.5 py-0.5 rounded flex-shrink-0`,children:r(`settings.skills.catalog.page.badge.installed`,{scope:n||r(`settings.skills.catalog.page.badge.unknown`)})}),!e.installable&&(0,$.jsx)(`span`,{className:`typography-micro text-[var(--status-warning)] bg-[var(--status-warning)]/10 px-1.5 py-0.5 rounded flex-shrink-0`,children:r(`settings.skills.catalog.page.badge.notInstallable`)})]}),e.description?(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-1 line-clamp-2 max-w-prose [overflow-wrap:anywhere]`,children:e.description}):(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground/50 mt-0.5 italic`,children:r(`settings.skills.catalog.shared.noDescription`)}),e.clawdhub&&(0,$.jsxs)(`div`,{className:`typography-micro text-muted-foreground mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1 [overflow-wrap:anywhere]`,children:[e.clawdhub.owner&&(0,$.jsxs)(`span`,{children:[r(`settings.skills.catalog.page.byOwnerPrefix`),` `,(0,$.jsx)(`span`,{className:`font-medium text-foreground/80`,children:e.clawdhub.owner})]}),(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(Y,{name:`download`,className:`h-3 w-3`}),e.clawdhub.downloads?.toLocaleString()??0]}),(e.clawdhub.stars??0)>0&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(Y,{name:`star`,className:`h-3 w-3`}),e.clawdhub.stars]}),(0,$.jsxs)(`span`,{className:`bg-[var(--surface-muted)] px-1.5 py-0.5 rounded`,children:[`v`,e.clawdhub.version]})]}),e.warnings?.length?(0,$.jsx)(`div`,{className:`typography-micro text-[var(--status-warning)] mt-1.5 bg-[var(--status-warning)]/10 px-2 py-1 rounded w-fit [overflow-wrap:anywhere]`,children:e.warnings.join(` · `)}):null]}),(0,$.jsx)(K,{size:`sm`,className:`shrink-0`,disabled:!e.installable,onClick:()=>{y(e),_(!0)},children:r(`settings.skills.catalog.shared.actions.install`)})]})},`${e.sourceId}:${e.skillDir}`)})})}),F&&d.hasNextPage&&!L&&M.length>0&&(0,$.jsx)(`div`,{className:`flex justify-center mt-2 px-2`,children:(0,$.jsx)(K,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void d.fetchNextPage(),disabled:R,children:r(R?`settings.skills.catalog.page.loading.more`:`settings.skills.catalog.page.actions.loadMoreSkills`)})})]}),(0,$.jsx)(xu,{open:m,onOpenChange:h}),(0,$.jsx)(Mu,{open:g,onOpenChange:_,item:v}),(0,$.jsx)(hn,{open:S,onOpenChange:e=>{b||C(e)},children:(0,$.jsxs)(fn,{className:`max-w-md`,children:[(0,$.jsxs)(un,{children:[(0,$.jsx)(pn,{children:r(`settings.skills.catalog.page.removeDialog.title`)}),(0,$.jsx)(mn,{children:r(`settings.skills.catalog.page.removeDialog.description`)})]}),(0,$.jsxs)(dn,{children:[(0,$.jsx)(K,{size:`sm`,variant:`ghost`,onClick:()=>C(!1),disabled:b,children:r(`settings.common.actions.cancel`)}),(0,$.jsx)(K,{size:`sm`,variant:`destructive`,onClick:()=>void B(),disabled:b,children:r(`settings.skills.catalog.page.actions.removeCatalog`)})]})]})})]})})},Bu=()=>{let e=(0,qi.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(zu,{mode:`external`,onModeChange:Yu,showModeTabs:!1}),e[0]=t):t=e[0],t},Vu=`SKILL.md`,Hu=`h-[clamp(320px,58dvh,680px)] min-h-[260px] max-h-[calc(100dvh-220px)]`,Uu=(e,t)=>{let n=Wi({description:e}).trimEnd(),r=t.trimStart();return`---\n${n}\n---${r?`\n\n${r}`:`
|
|
22
|
-
`}`},Wu=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Gu=e=>{let t=e.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)([\s\S]*)$/);if(!t)return{description:null,instructions:e};let n=null;try{let e=Gi(t[1]);if(Wu(e)){let t=e.description;typeof t==`string`&&(n=t)}}catch{n=null}return{description:n,instructions:t[2].replace(/^\r?\n/,``)}},Ku=(e,t)=>Uu(t,Gu(e).instructions),qu=()=>{let{t:e}=He(),{currentTheme:t}=ln(),{selectedSkillName:n,getSkillDetail:r,createSkill:i,updateSkill:a,skillDraft:o,setSkillDraft:s,setSelectedSkill:c}=Ra(de(e=>({selectedSkillName:e.selectedSkillName,getSkillDetail:e.getSkillDetail,createSkill:e.createSkill,updateSkill:e.updateSkill,skillDraft:e.skillDraft,setSkillDraft:e.setSkillDraft,setSelectedSkill:e.setSelectedSkill}))),l=Dt(),u=ht(),d=Q.useMemo(()=>l.data??[],[l.data]),f=n?d.find(e=>e.name===n)??null:null,p=!!(o&&o.name===n&&!f),m=!!(n&&!f&&!o),h=f?.path===`<built-in>`;Q.useEffect(()=>{m&&c(null)},[m,c]);let[g,_]=Q.useState(``),[v,y]=Q.useState(`user`),[b,x]=Q.useState(`opencode`),[S,C]=Q.useState(``),[w,T]=Q.useState(``),[E,D]=Q.useState(()=>Uu(``,``)),[O,k]=Q.useState(`edit`),[A,j]=Q.useState([]),[M,N]=Q.useState([]),[P,F]=Q.useState(!1),[I,L]=Q.useState(!1),[R,z]=Q.useState(``),[B,V]=Q.useState(``),[ee,H]=Q.useState(!1),[te,ne]=Q.useState(``),[U,re]=Q.useState(``),[ie,ae]=Q.useState(null),[oe,se]=Q.useState(!1),[ce,le]=Q.useState(``),[ue,fe]=Q.useState(null),[pe,me]=Q.useState(!1),he=p?g.trim()!==``||S.trim()!==``||w.trim()!==``||M.length>0:S!==R||w!==B,ge=ie?U!==ce:te.trim()!==``,_e=Q.useCallback(t=>{switch(t){case`project-opencode`:return e(`settings.skills.location.option.projectOpencode.label`);case`user-claude`:return e(`settings.skills.location.option.userClaude.label`);case`project-claude`:return e(`settings.skills.location.option.projectClaude.label`);case`user-agents`:return e(`settings.skills.location.option.userAgents.label`);case`project-agents`:return e(`settings.skills.location.option.projectAgents.label`);default:return e(`settings.skills.location.option.userOpencode.label`)}},[e]),ve=Q.useCallback(t=>{switch(t){case`project-opencode`:return e(`settings.skills.location.option.projectOpencode.description`);case`user-claude`:return e(`settings.skills.location.option.userClaude.description`);case`project-claude`:return e(`settings.skills.location.option.projectClaude.description`);case`user-agents`:return e(`settings.skills.location.option.userAgents.description`);case`project-agents`:return e(`settings.skills.location.option.projectAgents.description`);default:return e(`settings.skills.location.option.userOpencode.description`)}},[e]);Q.useEffect(()=>{(async()=>{if(p&&o){let e=o.description||``,t=o.instructions||``;_(o.name||``),y(o.scope||`user`),x(o.source===`agents`?`agents`:`opencode`),C(e),T(t),D(Uu(e,t)),z(``),V(``),j([]),N(o.pendingFiles||[])}else if(n&&f){L(!0);try{let e=await r(n);if(e){let t=e.sources.md,n=t.description||``,r=t.instructions||``;C(n),T(r),D(Uu(n,r)),z(n),V(r),j(t.supportingFiles||[])}}catch(e){console.error(`Failed to load skill details:`,e)}finally{L(!1)}}})()},[f,p,n,d,o,r]);let ye=W(e=>e.editorFontSize),be=Q.useMemo(()=>{let e=[bi(t,{fontSize:ye})],n=ni(Vu);return n&&e.push(n),e.push(Fe.lineWrapping),e},[t,ye]),xe=Q.useMemo(()=>{let e=te.trim()||`supporting-file.md`,n=Gr(e),r=!!n&&n!==`markdown`,i=[bi(t,r?{syntaxColors:!1,fontSize:ye}:{fontSize:ye})],a=ni(e);return a&&i.push(a),r&&n&&i.push(Jr({language:n,themeName:t.metadata.id,theme:Hr(t)})),i.push(Fe.lineWrapping),i},[t,te,ye]),Se=Q.useCallback(e=>{C(e),D(t=>Ku(t,e))},[]),Ce=Q.useCallback(e=>{D(e);let t=Gu(e);C(t.description??``),T(t.instructions)},[]),we=async()=>{let t=p?g.trim().replace(/\s+/g,`-`).toLowerCase():n?.trim();if(!t){q.error(e(`settings.skills.page.toast.skillNameRequired`));return}if(!/^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$/.test(t)||t.length>64){q.error(e(`settings.skills.page.toast.invalidSkillName`));return}if(!S.trim()){q.error(e(`settings.skills.page.toast.descriptionRequired`));return}if(p&&d.some(e=>e.name===t)){q.error(e(`settings.skills.page.toast.skillExists`));return}F(!0);try{let n={name:t,description:S.trim(),instructions:w.trim()||void 0,scope:p?v:void 0,source:p?b:void 0,targetPath:p?void 0:f?.path,supportingFiles:p&&M.length>0?M:void 0},r;p?(r=await i(n,{directory:u}),r&&(s(null),N([]),c(t))):(r=await a(t,n,{directory:u}),r&&(z(S.trim()),V(w.trim()))),r?q.success(e(p?`settings.skills.page.toast.skillCreated`:`settings.skills.page.toast.skillUpdated`)):q.error(e(p?`settings.skills.page.toast.createSkillFailed`:`settings.skills.page.toast.updateSkillFailed`))}catch(t){console.error(`Error saving skill:`,t),q.error(e(`settings.skills.page.toast.saveUnexpectedError`))}finally{F(!1)}},Te=()=>{ae(null),ne(``),re(``),le(``),H(!0)},Ee=async t=>{if(ae(t),ne(t),p){let e=M.find(e=>e.path===t)?.content||``;re(e),le(e),H(!0);return}if(n){se(!0),H(!0);try{let{readSupportingFile:e}=Ra.getState(),r=await e(n,t);re(r||``),le(r||``)}catch{q.error(e(`settings.skills.page.toast.loadFileContentFailed`)),re(``),le(``)}finally{se(!1)}}},De=async()=>{if(!te.trim()){q.error(e(`settings.skills.page.toast.fileNameRequired`));return}let t=te.trim(),i=ie!==null;if(p){if(i)N(e=>e.map(e=>e.path===ie?{path:t,content:U}:e)),q.success(e(`settings.skills.page.toast.fileUpdated`,{path:t}));else{if(M.some(e=>e.path===t)){q.error(e(`settings.skills.page.toast.fileExists`));return}N(e=>[...e,{path:t,content:U}]),q.success(e(`settings.skills.page.toast.fileAdded`,{path:t}))}H(!1),ae(null);return}if(!n){q.error(e(`settings.skills.page.toast.noSkillSelected`));return}let{writeSupportingFile:a}=Ra.getState();if(await a(n,t,U)){q.success(e(i?`settings.skills.page.toast.fileUpdated`:`settings.skills.page.toast.fileCreated`,{path:t})),H(!1),ae(null);let a=await r(n);a&&j(a.sources.md.supportingFiles||[])}else q.error(e(i?`settings.skills.page.toast.updateFileFailed`:`settings.skills.page.toast.createFileFailed`))},Oe=t=>{if(p){N(e=>e.filter(e=>e.path!==t)),q.success(e(`settings.skills.page.toast.fileRemoved`,{path:t}));return}n&&fe(t)};return!n&&!o||m?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-4`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(Y,{name:`book-open`,className:`mx-auto mb-3 h-10 w-10 sm:h-12 sm:w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.skills.page.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.skills.page.empty.description`)})]})}):I?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-4`,children:(0,$.jsx)(`div`,{className:`text-center text-muted-foreground`,children:(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.skills.page.loading.details`)})})}):(0,$.jsxs)(Rr,{outerClassName:`h-full`,className:`w-full`,children:[(0,$.jsxs)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(Xr,{actions:(0,$.jsx)(K,{onClick:we,disabled:h||P||!he,size:`sm`,"aria-busy":P,children:e(P?`settings.common.actions.saving`:p?`settings.skills.page.actions.createSkill`:`settings.common.actions.saveChanges`)}),children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate flex items-center gap-2`,children:p?e(`settings.skills.page.title.newSkill`):n}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:f?e(`settings.skills.page.subtitle.skillLocation`,{location:_e(Au(f.scope,f.source))}):e(`settings.skills.page.subtitle.newSkill`)})]})}),(0,$.jsx)(`div`,{"data-settings-item":`skills.basic-information`,children:(0,$.jsx)(X,{label:e(`settings.skills.page.section.basicInformation`),cardClassName:`p-3`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[p&&(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.skills.page.field.skillNameLocation`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground ml-2`,children:e(`settings.skills.page.field.skillNameHint`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[(0,$.jsx)(En,{value:g,onChange:e=>_(e.target.value.toLowerCase().replace(/\s+/g,`-`)),placeholder:e(`settings.skills.page.field.skillNamePlaceholder`),className:`h-7 w-40 px-2`}),(0,$.jsxs)(Cn,{value:Au(v,b),onValueChange:e=>{let t=ju(e);y(t.scope),x(t.source===`agents`?`agents`:`opencode`)},children:[(0,$.jsxs)(bn,{className:`w-fit gap-1.5`,children:[v===`user`?(0,$.jsx)(Y,{name:`user-3`,className:`h-3.5 w-3.5`}):(0,$.jsx)(Y,{name:`folder`,className:`h-3.5 w-3.5`}),b===`agents`?(0,$.jsx)(Y,{name:`robot-2`,className:`h-3.5 w-3.5`}):null,(0,$.jsx)(`span`,{children:_e(Au(v,b))})]}),(0,$.jsx)(xn,{align:`start`,children:ku.map(e=>(0,$.jsx)(vn,{value:e.value,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.scope===`user`?(0,$.jsx)(Y,{name:`user-3`,className:`h-3.5 w-3.5`}):(0,$.jsx)(Y,{name:`folder`,className:`h-3.5 w-3.5`}),e.source===`agents`?(0,$.jsx)(Y,{name:`robot-2`,className:`h-3.5 w-3.5`}):null,(0,$.jsx)(`span`,{children:_e(e.value)})]}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground ml-6`,children:ve(e.value)})]})},e.value))})]})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`span`,{className:`typography-ui-label text-foreground`,children:[e(`settings.common.field.description`),` `,(0,$.jsx)(`span`,{className:`text-[var(--status-error)]`,children:`*`})]}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground ml-2`,children:e(`settings.skills.page.field.descriptionHint`)}),(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(zr,{embedded:!0,value:S,onChange:e=>Se(e.target.value),placeholder:e(`settings.skills.page.field.descriptionPlaceholder`),rows:2,className:`w-full resize-none min-h-[60px] max-h-32 bg-transparent`,disabled:h})})]})]})})}),(0,$.jsx)(`div`,{"data-settings-item":`skills.instructions`,children:(0,$.jsx)(X,{label:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{children:e(`settings.skills.page.section.instructions`)}),(0,$.jsx)(ti,{currentMode:O===`preview`?`preview`:`edit`,onToggle:()=>k(e=>e===`preview`?`edit`:`preview`)})]}),cardClassName:`p-3`,children:(0,$.jsx)(`div`,{className:G(`overflow-hidden bg-background`,Hu),children:O===`preview`?(0,$.jsx)(Rr,{outerClassName:`h-full`,className:`h-full`,children:(0,$.jsx)(`div`,{className:`min-h-full px-4 py-3`,children:(0,$.jsx)(Ur,{content:E,className:`typography-markdown-body`,stripFrontmatter:!0,enableFileReferences:!1})})}):(0,$.jsx)(Yr,{value:E,onChange:Ce,readOnly:h,extensions:be,className:`h-full`,enableSearch:!0})})})}),(0,$.jsx)(`div`,{"data-settings-item":`skills.supporting-files`,children:(0,$.jsx)(X,{label:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{children:e(`settings.skills.page.section.supportingFiles`)}),(0,$.jsxs)(K,{variant:`outline`,size:`xs`,className:`!font-normal gap-1`,onClick:Te,disabled:h,children:[(0,$.jsx)(Y,{name:`add`,className:`h-3.5 w-3.5`}),` `,e(`settings.skills.page.actions.addFile`)]})]}),cardClassName:`p-3`,children:(()=>{let t=p?M:A;return t.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground py-1.5`,children:e(`settings.skills.page.supportingFiles.empty`)}):(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:t.map(t=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2 py-1.5 cursor-pointer group`,onClick:()=>Ee(t.path),children:[(0,$.jsx)(Y,{name:`file`,className:`h-3.5 w-3.5 text-muted-foreground flex-shrink-0`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:t.path}),p&&(0,$.jsx)(`span`,{className:`typography-micro text-[var(--status-warning)] bg-[var(--status-warning)]/10 px-1.5 py-0.5 rounded flex-shrink-0`,children:e(`settings.skills.page.badge.pending`)}),!h&&(0,$.jsx)(K,{size:`sm`,variant:`ghost`,className:`h-5 w-5 px-0 flex-shrink-0 text-muted-foreground hover:text-[var(--status-error)] opacity-0 group-hover:opacity-100 transition-opacity`,onClick:e=>{e.stopPropagation(),Oe(t.path)},children:(0,$.jsx)(Y,{name:`delete-bin`,className:`h-3 w-3`})})]},t.path))})})()})})]}),(0,$.jsx)(hn,{open:ue!==null,onOpenChange:e=>{!e&&!pe&&fe(null)},children:(0,$.jsxs)(fn,{className:`max-w-md`,children:[(0,$.jsxs)(un,{children:[(0,$.jsx)(pn,{children:e(`settings.skills.page.deleteFileDialog.title`)}),(0,$.jsx)(mn,{children:e(`settings.skills.page.deleteFileDialog.description`,{path:ue??``})})]}),(0,$.jsxs)(dn,{children:[(0,$.jsx)(K,{size:`sm`,variant:`ghost`,onClick:()=>fe(null),disabled:pe,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(K,{size:`sm`,variant:`destructive`,onClick:async()=>{if(!ue||!n)return;me(!0);let{deleteSupportingFile:t}=Ra.getState();if(await t(n,ue)){q.success(e(`settings.skills.page.toast.fileDeleted`,{path:ue}));let t=await r(n);t&&j(t.sources.md.supportingFiles||[]),fe(null)}else q.error(e(`settings.skills.page.toast.deleteFileFailed`));me(!1)},disabled:pe,children:e(`settings.common.actions.delete`)})]})]})}),(0,$.jsx)(hn,{open:ee,onOpenChange:e=>{H(e),e||ae(null)},children:(0,$.jsxs)(fn,{className:`max-w-3xl max-h-[85vh] flex flex-col`,children:[(0,$.jsx)(Xr,{className:`pr-8`,actions:(0,$.jsx)(K,{size:`sm`,onClick:De,disabled:oe||!ge,children:e(ie?`settings.common.actions.saveChanges`:`settings.skills.page.actions.createFile`)}),children:(0,$.jsxs)(un,{className:`flex-shrink-0`,children:[(0,$.jsx)(pn,{children:e(ie?`settings.skills.page.fileDialog.titleEdit`:`settings.skills.page.fileDialog.titleAdd`)}),(0,$.jsx)(mn,{children:e(ie?`settings.skills.page.fileDialog.descriptionEdit`:`settings.skills.page.fileDialog.descriptionAdd`)})]})}),oe?(0,$.jsx)(`div`,{className:`flex-1 flex items-center justify-center py-8`,children:(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:e(`settings.skills.page.loading.fileContent`)})}):(0,$.jsxs)(`div`,{className:`space-y-4 flex-1 min-h-0 flex flex-col pt-2`,children:[(0,$.jsxs)(`div`,{className:`space-y-2 flex-shrink-0`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label font-medium text-foreground`,children:e(`settings.skills.page.fileDialog.field.filePath`)}),(0,$.jsx)(En,{value:te,onChange:e=>ne(e.target.value),placeholder:e(`settings.skills.page.fileDialog.field.filePathPlaceholder`),className:`text-foreground placeholder:text-muted-foreground focus-visible:ring-[var(--primary-base)]`,disabled:ie!==null}),!ie&&(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:e(`settings.skills.page.fileDialog.field.filePathHint`)})]}),(0,$.jsxs)(`div`,{className:`space-y-2 flex-1 min-h-0 flex flex-col`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label font-medium text-foreground flex-shrink-0`,children:e(`settings.skills.page.fileDialog.field.content`)}),(0,$.jsx)(`div`,{className:`h-[45vh] min-h-[250px] max-h-[55vh] overflow-hidden rounded-md border border-[var(--surface-subtle)] bg-background`,children:(0,$.jsx)(Yr,{value:U,onChange:re,extensions:xe,className:`h-full`,enableSearch:!0})})]})]}),(0,$.jsx)(dn,{className:`mt-4`,children:(0,$.jsx)(K,{size:`sm`,variant:`ghost`,onClick:()=>{H(!1),ae(null)},children:e(`settings.common.actions.cancel`)})})]})})]})},Ju=e=>{let t=(0,qi.c)(2),{view:n}=e,r=n===void 0?`installed`:n,i;return t[0]===r?i=t[1]:(i=r===`catalog`?(0,$.jsx)(Bu,{}):(0,$.jsx)(qu,{}),t[0]=r,t[1]=i),i};function Yu(){}var Xu=e=>{let t=(0,qi.c)(26),{onItemSelect:n}=e,{t:r}=He(),i=Lt(Zu),a=Lt(Qu),o=W($u),s=W(ed),c=Q.useRef(null),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=new Set,t[0]=l):l=t[0];let u=Q.useRef(l),d;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(d=N(),t[1]=d):d=t[1];let f=d,p=td,m,h;t[2]!==a||t[3]!==i||t[4]!==o||t[5]!==s?(m=()=>{let e=new Set(i.map(nd)),t=c.current;if(t)for(let n of e)t.has(n)||u.current.add(n);if(c.current=e,a&&u.current.delete(a)){s(a);return}if(i.length===0){o!==null&&s(null);return}o&&i.some(e=>e.id===o)||s(i[0].id)},h=[a,i,o,s],t[2]=a,t[3]=i,t[4]=o,t[5]=s,t[6]=m,t[7]=h):(m=t[6],h=t[7]),Q.useEffect(m,h);let g;t[8]!==i.length||t[9]!==r?(g=r(`settings.projects.sidebar.total`,{count:i.length}),t[8]=i.length,t[9]=r,t[10]=g):g=t[10];let _;t[11]===g?_=t[12]:(_=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:g}),t[11]=g,t[12]=_);let v;t[13]===r?v=t[14]:(v=!f&&(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7 -my-1 text-muted-foreground`,onClick:p,"aria-label":r(`settings.projects.sidebar.actions.addProject`),children:(0,$.jsx)(Y,{name:`add`,className:`size-4`})}),t[13]=r,t[14]=v);let y;t[15]!==_||t[16]!==v?(y=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2 px-[var(--yuri-settings-row-inset)]`,children:[_,v]}),t[15]=_,t[16]=v,t[17]=y):y=t[17];let b;t[18]!==n||t[19]!==i||t[20]!==o||t[21]!==s?(b=i.length>0?(0,$.jsx)(X,{children:i.map(e=>{let t=e.id===o,r=e.icon?Sn[e.icon]:null,i=e.color?wn[e.color]:void 0,a=(0,$.jsx)(Y,{name:r??`folder`,className:`h-4 w-4`,style:i?{color:i}:void 0}),c=(0,$.jsx)(`span`,{className:G(`flex size-5 shrink-0 items-center justify-center overflow-hidden`,t?`text-foreground`:`text-muted-foreground`),children:e.iconImage?(0,$.jsx)(yn,{project:e,className:`size-full object-contain`,fallback:a}):a});return(0,$.jsx)(Uo,{title:e.path.split(/[\\/]/).filter(Boolean).at(-1)||e.path,icon:c,selected:t,onSelect:()=>{s(e.id),n?.()}},e.id)})}):null,t[18]=n,t[19]=i,t[20]=o,t[21]=s,t[22]=b):b=t[22];let x;return t[23]!==y||t[24]!==b?(x=(0,$.jsx)(Go,{variant:`background`,header:y,children:b}),t[23]=y,t[24]=b,t[25]=x):x=t[25],x};function Zu(e){return e.projects}function Qu(e){return e.activeProjectId}function $u(e){return e.settingsProjectsSelectedId}function ed(e){return e.setSettingsProjectsSelectedId}function td(){Mt.requestDirectoryDialog()}function nd(e){return e.id}var rd=()=>{let e=(0,qi.c)(18),{t}=He(),n=Lt(id),r=Lt(ad),i=W(od),a=W(sd),o;bb0:{if(!i){o=null;break bb0}let t;e[0]!==n||e[1]!==i?(t=n.find(e=>e.id===i)??null,e[0]=n,e[1]=i,e[2]=t):t=e[2],o=t}let s=o,c,l;e[3]!==n||e[4]!==i||e[5]!==a?(c=()=>{if(n.length===0){a(null);return}i&&n.some(e=>e.id===i)||a(n[0].id)},l=[n,i,a],e[3]=n,e[4]=i,e[5]=a,e[6]=c,e[7]=l):(c=e[6],l=e[7]),Q.useEffect(c,l);let u;e[8]!==s||e[9]!==r?(u=async e=>{s&&r(s.id,{label:e.label,icon:e.icon,color:e.color,iconBackground:e.iconBackground,defaultModel:e.defaultModel??null})},e[8]=s,e[9]=r,e[10]=u):u=e[10];let d=u;if(!s){let n;e[11]===t?n=e[12]:(n=t(`settings.projects.page.empty.noProjects`),e[11]=t,e[12]=n);let r;return e[13]===n?r=e[14]:(r=(0,$.jsx)(Rr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-4xl p-3 sm:p-6 sm:pt-8`,children:(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:n})})}),e[13]=n,e[14]=r),r}let f;return e[15]!==d||e[16]!==s?(f=(0,$.jsx)(Rr,{outerClassName:`h-full`,className:`w-full bg-background`,children:(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-4xl p-3 sm:p-6 sm:pt-8`,children:(0,$.jsx)(Si,{project:s,onIdentitySave:d})})}),e[15]=d,e[16]=s,e[17]=f):f=e[17],f};function id(e){return e.projects}function ad(e){return e.updateProjectMeta}function od(e){return e.settingsProjectsSelectedId}function sd(e){return e.setSettingsProjectsSelectedId}var cd=t(Ki(),1),ld={justNowMinutes:1,minutes:60,hours:24,days:30,months:12},ud=6e4,dd=60*ud,fd=24*dd,pd=30*fd;function md(e,t={}){if(typeof e!=`number`||!Number.isFinite(e))return``;let n=t.now??Date.now(),r=t.buckets??ld,i=e-n,a=Math.abs(i),o=new Intl.RelativeTimeFormat(t.locale,{numeric:`auto`});return a<r.justNowMinutes*ud?o.format(0,`second`):a<r.minutes*ud?o.format(Math.round(i/ud),`minute`):a<r.hours*dd?o.format(Math.round(i/dd),`hour`):a<r.days*fd?o.format(Math.round(i/fd),`day`):a<r.months*pd?o.format(Math.round(i/pd),`month`):o.format(Math.round(i/(12*pd)),`year`)}var hd=`relay_identity_changed`,gd=class extends Error{code=hd;expectedServerId;actualServerId;constructor(e,t){super(`Relay identity changed (expected ${e}, got ${t||`unknown`})`),this.name=`RelayIdentityChangedError`,this.expectedServerId=e,this.actualServerId=t}},_d=new Map,vd=e=>{let t=e.trim();if(!t)throw Error(`Relay serverId is required`);return`relay:${t}`},yd=e=>{let t={Accept:`application/json`},n=typeof e.clientToken==`string`?e.clientToken.trim():``;if(n&&(t.Authorization=`Bearer ${n}`),e.requestHeaders)for(let[n,r]of Object.entries(e.requestHeaders))!n.trim()||!r.trim()||n.trim().toLowerCase()!==`authorization`&&(t[n.trim()]=r.trim());return t},bd=e=>({files:e?.files?.length??0,directories:e?.directories?.length??0,deletes:e?.deletes?.length??0,totalBytes:e?.totalBytes??0}),xd=async e=>{C()&&await w(`desktop_sync_runs_append`,{record:e})},Sd=async(e,t)=>{if(!t)return;let n=await t().catch(()=>null),r=typeof n?.serverId==`string`?n.serverId.trim():``;if(r&&r!==e)throw new gd(e,r)},Cd=e=>({ok:!0,files:0,directories:0,deletes:e.deletes.length,totalBytes:0,agentsRoot:null,providerCredentials:null,plan:e}),wd=e=>{let t=e?.selectionShape;if(!t)throw Error(`Local sync inventory missing selectionShape (update the Yuri desktop app)`);return t},Td=(e,t)=>{let n=$n(e,{includeProviderCredentials:!1}),r=t.selections;return{fileGroups:r?.fileGroups??n.fileGroups,singleFiles:r?.singleFiles??n.singleFiles,directories:r?.directories??n.directories,agentsRoot:r?.agentsRoot!==!1,providerCredentials:r?.providerCredentials===!0,magpie:r?.magpie===!0}},Ed=(e,t,n)=>{let r=e.inventory&&typeof e.inventory==`object`?e.inventory:null;if(n.providerCredentials&&(!r||!Object.hasOwn(r,`providerCredentials`)))throw Error(`Provider credential inventory is missing`);if(n.magpie&&!r?.magpie?.available)throw Error(`Magpie source configuration is unavailable`);return{direction:`pull`,magpieAvailable:r?.magpie?.available===!0,magpie:n.magpie&&r?.magpie?.available?{bytes:0}:null,files:r?.files??t?.files??[],directories:r?.directories??t?.directories??[],agentsRoot:n.agentsRoot?r?.agentsRoot??null:null,providerCredentials:n.providerCredentials?r?.providerCredentials??null:null,deletes:t?.deletes??[],totalBytes:t?.totalBytes??0,selections:n}},Dd=(e,t)=>({...e,direction:`push`,providerCredentials:t.providerCredentials?e.providerCredentials:null,magpie:t.magpie?e.magpie:null,agentsRoot:t.agentsRoot?e.agentsRoot:null,selections:t}),Od=e=>e.files.length>0||e.directories.length>0||!!e.agentsRoot||!!e.providerCredentials||!!e.magpie,kd=(e,t)=>{let r=n({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk}),i=yd(t),a=async(e,t,n)=>{let a=await r.fetch(t,{method:e,headers:{...i,...n===void 0?{}:{"Content-Type":`application/json`}},body:n===void 0?void 0:JSON.stringify(n)}),o=await a.json().catch(()=>({}));if(!a.ok){let n=Error(typeof o.error==`string`?o.error:`Relay sync ${e} ${t} failed (${a.status})`);throw typeof o.code==`string`&&(n.code=o.code),n}return o};return{tunnel:r,async probe(e){let t=await a(`POST`,`/api/yuri/config-sync/probe`,{plan:e});return{remoteExisting:Array.isArray(t.remoteExisting)?t.remoteExisting:[],remoteAgentsRootExists:t.remoteAgentsRootExists===!0,remoteProviderCredentialsExists:t.remoteProviderCredentialsExists===!0,inventory:t.inventory}},async prepare(e,t){await a(`POST`,`/api/yuri/config-sync/prepare`,{plan:e,syncRunId:t})},async putTar(e,t,n){let a=await r.fetch(`/api/yuri/config-sync/put/${encodeURIComponent(e)}?syncRunId=${encodeURIComponent(n)}`,{method:`PUT`,headers:{...i,"Content-Type":e===`credentials`||e===`magpie`?`application/octet-stream`:`application/gzip`},body:new Blob([new Uint8Array(t)],{type:e===`credentials`||e===`magpie`?`application/octet-stream`:`application/gzip`})}),o=await a.json().catch(()=>({}));if(!a.ok){let t=Error(typeof o.error==`string`?o.error:`Relay sync put ${e} failed (${a.status})`);throw typeof o.code==`string`&&(t.code=o.code),t}},async download(e){let t=await r.fetch(`/api/yuri/config-sync/download/${encodeURIComponent(e)}`,{method:`GET`,headers:i});if(!t.ok){let n=await t.json().catch(()=>({})),r=Error(typeof n.error==`string`?n.error:`Relay sync download ${e} failed (${t.status})`);throw typeof n.code==`string`&&(r.code=n.code),r}return new Uint8Array(await t.arrayBuffer())},async finalize(e){let t=await a(`POST`,`/api/yuri/config-sync/finalize`,{syncRunId:e});return Array.isArray(t.magpieWarnings)?t.magpieWarnings.filter(e=>e===`sign_in_required`||e===`agent_settings_skipped`):[]},async abort(e){await a(`POST`,`/api/yuri/config-sync/abort`,{syncRunId:e}).catch(()=>void 0)},close(){r.close()}}},Ad=async(e,t,n,r)=>{if(_d.has(e)){let t=Error(`Config sync already in progress for ${e}`);throw t.code=`sync_in_progress`,t}let i=crypto.randomUUID(),a=new Date().toISOString();_d.set(e,i);try{let o=await r({syncRunId:i});return await xd({syncRunId:i,targetId:e,stage:t,direction:n,startedAt:a,endedAt:new Date().toISOString(),result:`success`,summary:bd(o.plan)}),{...o,syncRunId:i}}catch(r){throw await xd({syncRunId:i,targetId:e,stage:t,direction:n,startedAt:a,endedAt:new Date().toISOString(),result:`failure`,summary:bd(null),error:r instanceof Error?r.message:String(r)}).catch(()=>void 0),r}finally{_d.get(e)===i&&_d.delete(e)}},jd=async(e,t)=>{let n=await ur({direction:e,targetKind:`relay`}),r=wd(n),i=Td(r,t),a=e===`push`?await ur({direction:e,selections:i,targetKind:`relay`}):n;if(e===`push`&&!a)throw Error(`Local sync inventory unavailable`);return{selectionShape:r,selections:i,localPlan:a}},Md=async(e,t={},n={})=>{let r=e.relay,i=vd(r.serverId),a=t.direction===`pull`?`pull`:`push`;return Ad(i,`preview`,a,async()=>{await Sd(r.serverId,n.refreshCandidates);let{selectionShape:i,selections:o,localPlan:s}=await jd(a,t),c=kd(r,e);try{if(a===`pull`){let e=await c.probe({selections:o});return{plan:Ed(e,s,o),remoteExisting:e.remoteExisting,remoteAgentsRootExists:e.remoteAgentsRootExists,remoteProviderCredentialsExists:e.remoteProviderCredentialsExists,selectionShape:i}}let e=Dd(s,o),t=await c.probe(e);return{plan:e,remoteExisting:t.remoteExisting,remoteAgentsRootExists:t.remoteAgentsRootExists,remoteProviderCredentialsExists:t.remoteProviderCredentialsExists,selectionShape:s?.selectionShape??i}}finally{c.close()}})},Nd=async(e,t={},n={})=>{let r=e.relay,i=vd(r.serverId),a=t.direction===`pull`?`pull`:`push`;return Ad(i,`apply`,a,async({syncRunId:i})=>{await Sd(r.serverId,n.refreshCandidates);let{selections:o,localPlan:s}=await jd(a,t),c=kd(r,e);try{if(a===`pull`){let e=Ed(await c.probe({selections:o}),s,o);if(!Od(e))return Cd(e);let t=e.files.length>0||e.directories.length>0?await c.download(`config`):null,n=e.agentsRoot?await c.download(`agents`):null,r=e.providerCredentials?await c.download(`credentials`):null,a=e.magpie?await c.download(`magpie`):null;if(!C())throw Error(`Relay pull apply requires the Yuri desktop app`);let l=await w(`desktop_relay_sync_apply_local`,{syncRunId:i,plan:e,configTar:t,agentsTar:n,credentialPayload:r,magpiePayload:a});if(!l?.ok)throw Error(`Relay pull local apply failed`);return{...l,plan:e}}let e=Dd(s,o);if(!Od(e))return Cd(e);if(!C())throw Error(`Relay push apply requires the Yuri desktop app`);let t=await w(`desktop_relay_sync_pack_local`,{plan:e});if(!t)throw Error(`Relay push local pack failed`);await c.prepare(e,i);let n=[];try{if(e.magpie){if(!t.magpiePayload?.byteLength)throw Error(`Magpie transfer incomplete`);await c.putTar(`magpie`,t.magpiePayload,i)}t.configTar&&t.configTar.byteLength>0&&await c.putTar(`config`,t.configTar,i),t.agentsTar&&t.agentsTar.byteLength>0&&await c.putTar(`agents`,t.agentsTar,i),t.credentialPayload&&t.credentialPayload.byteLength>0&&await c.putTar(`credentials`,t.credentialPayload,i),n=await c.finalize(i)}catch(e){throw await c.abort(i),e}return{ok:!0,files:e.files.length,directories:e.directories.length,deletes:e.deletes.length,totalBytes:e.totalBytes,agentsRoot:e.agentsRoot?{fileCount:e.agentsRoot.fileCount}:null,providerCredentials:e.providerCredentials?{bytes:e.providerCredentials.bytes}:null,...n.length?{magpieWarnings:n}:{},plan:e}}finally{c.close()}})},Pd=()=>{let{t:e}=He(),t=E()&&m(),[n,r]=Q.useState(!1),[i,a]=Q.useState(!1),[o,s]=Q.useState(``),[l,u]=Q.useState(``),[d,f]=Q.useState(!1),[h,g]=Q.useState(null),[v,y]=Q.useState(!0),[b,x]=Q.useState(!1),[S,C]=Q.useState(null),[w,T]=Q.useState(null);Q.useEffect(()=>{if(!t){y(!1);return}let n=!1;return(async()=>{try{let t=await p(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(!t.ok)throw Error(e(`settings.yuri.desktopNetwork.error.loadFailed`));let i=await t.json().catch(()=>null);if(n)return;let o=i?.desktopLanAccessEnabled===!0,c=typeof i?.desktopUiPassword==`string`?i.desktopUiPassword:``;r(o),a(o),s(c),u(c),f(i?.desktopLanAccessActive===!0),g(typeof i?.desktopLanAccessBlockedReason==`string`?i.desktopLanAccessBlockedReason:null),C(null)}catch(t){n||C(t instanceof Error?t.message:e(`settings.yuri.desktopNetwork.error.loadFailed`))}finally{n||y(!1)}})(),()=>{n=!0}},[t,e]),Q.useEffect(()=>{if(!t||!i){T(null);return}let e=!1;return(async()=>{let t=await _();e||T(t)})(),()=>{e=!0}},[i,t]);let O=i!==n||l!==o,k=Q.useMemo(()=>{if(typeof window>`u`)return null;let e=c()||window.location.href,t=0;try{t=Number(new URL(e).port)}catch{t=Number(window.location.port)}return Number.isFinite(t)&&t>0?t:null},[]),A=i&&d&&w&&k?`http://${w}:${k}`:null,j=i&&!l.trim(),M=n&&!d&&h===`missing-password`,N=v||b||!O||j,P=Q.useCallback(()=>{a(e=>!e)},[]),F=Q.useCallback(e=>{u(e),e.trim()||a(!1)},[]),I=Q.useCallback(async()=>{if(O){x(!0),C(null);try{if(!(await p(`/api/config/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({desktopLanAccessEnabled:i,desktopUiPassword:l})})).ok)throw Error(e(`settings.yuri.desktopNetwork.error.saveFailed`));if(r(i),s(l),!await D())throw Error(e(`settings.yuri.desktopNetwork.error.savedRestartFailed`))}catch(t){C(t instanceof Error?t.message:e(`settings.yuri.desktopNetwork.error.saveFailed`)),x(!1)}}},[l,i,O,e]);return t?(0,$.jsxs)(X,{className:`yuri-settings-detail-group`,label:e(`settings.yuri.desktopNetwork.title`),actions:(0,$.jsx)(K,{type:`button`,size:`sm`,onClick:I,disabled:N,"aria-busy":b,children:e(b?`settings.common.actions.saving`:`settings.yuri.desktopNetwork.actions.saveAndRestart`)}),children:[(0,$.jsx)(Z,{itemId:`remote-instances.desktop-ui-password`,label:(0,$.jsx)(`label`,{htmlFor:`desktop-ui-password`,children:e(`settings.yuri.desktopPassword.field.password`)}),description:e(`settings.yuri.desktopPassword.field.passwordDescription`),children:(0,$.jsx)(En,{id:`desktop-ui-password`,type:`password`,className:`max-w-sm`,value:l,onChange:e=>F(e.target.value),placeholder:e(`settings.yuri.desktopPassword.field.passwordPlaceholder`),disabled:v||b,required:i,"aria-invalid":j})}),(0,$.jsxs)(`div`,{"data-settings-item":`remote-instances.desktop-lan-access`,className:`yuri-settings-group-row yuri-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,onClick:P,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),P())},children:[(0,$.jsxs)(`div`,{className:`yuri-settings-split-row-copy`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.yuri.desktopNetwork.field.allowLanAccess`)}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:e(`settings.yuri.desktopNetwork.field.allowLanAccessDescription`)}),(0,$.jsx)(`div`,{className:`typography-meta text-[var(--status-warning)]/85`,children:e(`settings.yuri.desktopNetwork.field.warning`)}),j||M?(0,$.jsx)(`div`,{className:`typography-meta text-[var(--status-warning)]/85`,children:e(`settings.yuri.desktopNetwork.field.passwordRequiredWarning`)}):null]}),(0,$.jsx)(`div`,{className:`yuri-settings-split-row-control`,children:(0,$.jsx)(gn,{checked:i,onChange:P,ariaLabel:e(`settings.yuri.desktopNetwork.field.allowLanAccessAria`),disabled:v||b})})]}),S?(0,$.jsx)(`div`,{className:`yuri-settings-group-row typography-meta text-[var(--status-error)]`,children:S}):null,A?(0,$.jsxs)(`div`,{className:`yuri-settings-group-row typography-meta text-muted-foreground`,children:[e(O&&!n?`settings.yuri.desktopNetwork.hint.openAfterRestart`:`settings.yuri.desktopNetwork.hint.openNow`),(0,$.jsx)(`span`,{className:`font-mono text-foreground`,children:A})]}):null]}):null},Fd=`wss://relay.openchamber.dev/ws`,Id=`yuri.pairing.relayUrl.v1`,Ld=e=>{if(typeof e!=`string`||!e.trim())return null;try{let t=new URL(e.trim());return t.protocol!==`ws:`&&t.protocol!==`wss:`||t.username||t.password?null:(t.username=``,t.password=``,t.hash=``,t.search=``,t.toString())}catch{return null}},Rd=(e=typeof window>`u`?null:window.localStorage)=>{if(!e)return null;try{return Ld(e.getItem(Id))}catch{return null}},zd=(e,t=typeof window>`u`?null:window.localStorage)=>{if(!t)return;let n=Ld(e);if(n)try{t.setItem(Id,n)}catch{}},Bd=`https://github.com/yee94/yuri/tree/main/packages/relay-server`,Vd=()=>Math.floor(2e4+Math.random()*3e4),Hd=e=>{if(!Number.isFinite(e)||e<0)return`0 B`;if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`,`TB`],n=e/1024;for(let e of t){if(n<1024||e===t[t.length-1])return`${n.toFixed(n>=10?0:1)} ${e}`;n/=1024}return`${e} B`},Ud={fileGroups:[],singleFiles:[],directories:[],agentsRoot:!0,providerCredentials:!1},Wd=e=>{let t=e.selectionShape;if(!t||typeof t!=`object`)return null;let n=typeof t.fileGroups==`number`?t.fileGroups:null,r=typeof t.singleFiles==`number`?t.singleFiles:null,i=typeof t.directories==`number`?t.directories:null;return n===null||r===null||i===null||n<0||r<0||i<0?null:{fileGroups:n,singleFiles:r,directories:i}},Gd=(e,t)=>e.fileGroups.length===t.fileGroups&&e.singleFiles.length===t.singleFiles&&e.directories.length===t.directories,Kd=[`settings.remoteInstances.page.sync.step.scanLocal`,`settings.remoteInstances.page.sync.step.compareRemote`,`settings.remoteInstances.page.sync.step.confirm`],qd=({open:e,instanceId:t,targetKind:n=`ssh`,relayHost:r=null,onOpenChange:i})=>{let{t:a}=He(),[o,s]=Q.useState(1),[c,l]=Q.useState(`scanning-local`),[u,d]=Q.useState(`push`),[f,p]=Q.useState(Ud),[m,h]=Q.useState(null),[g,_]=Q.useState(null),[v,y]=Q.useState(null),[b,x]=Q.useState(null),[S,C]=Q.useState(null),w=Q.useRef(Ud),T=m!=null&&Gd(f,m),E=ze(()=>{s(1),l(`scanning-local`),d(`push`),p(Ud),h(null),_(null),y(null),x(null),C(null),w.current=Ud}),D=ze(async(e=u,i=f)=>{if(t){s(2),l(`comparing-remote`),x(null),C(null),y(null);try{let o=n===`relay`?r?await Md(r,{direction:e,selections:i}):null:await Dr(t,{targetKind:n,direction:e,selections:i});if(!o){x(a(`settings.remoteInstances.page.sync.state.unavailable`)),C(2),l(`error`);return}y(o),w.current=i,s(3),l(`review`)}catch(e){console.error(`[remote-instances] config sync compare-remote failed`,e),x(e instanceof Error?e.message:String(e)),C(2),l(`error`)}}}),O=ze(async(e=u,r=f)=>{if(t){s(1),l(`scanning-local`),x(null),C(null),_(null),y(null);try{let t=m!=null&&Gd(r,m),i=await ur(t?{targetKind:n,direction:e,selections:r}:{targetKind:n,direction:e});if(!i){h(null),x(a(`settings.remoteInstances.page.sync.state.unavailable`)),C(1),l(`error`);return}let o=Wd(i);if(!o){h(null),p(Ud),x(a(`settings.remoteInstances.page.sync.state.unavailable`)),C(1),l(`error`);return}h(o);let s=t?r:$n(o,{includeProviderCredentials:!1});p(s),_(i),await D(e,s)}catch(e){console.error(`[remote-instances] config sync scan-local failed`,e),x(e instanceof Error?e.message:String(e)),C(1),l(`error`)}}});Q.useEffect(()=>{!e||!t||O(`push`)},[e,t]),Q.useEffect(()=>{e||E()},[e]);let k=Q.useMemo(()=>new Set(v?.remoteExisting??[]),[v]),A=v?.plan??g,j=!!(A&&(A.files.length>0||A.directories.length>0||A.agentsRoot!=null||A.providerCredentials!=null||A.magpie!=null)),M=c===`applying`,N=c===`review`||c===`applying`&&o===3,P=A?A.deletes.length+(A.agentsRoot&&v?.remoteAgentsRootExists?1:0):0,F=ze(()=>{if(S===2){D(u,f);return}O(u,f)}),I=ze(e=>{if(e===u||M)return;d(e),y(null),_(null);let t={...f,magpie:!1};p(t),O(e,t)}),L=ze(async()=>{if(!(!t||!j||M||c!==`review`)){l(`applying`);try{let e=n===`relay`?r?await Nd(r,{direction:u,selections:w.current}):null:await An(t,{targetKind:n,direction:u,selections:w.current});if(!e)throw Error(`Sync bridge unavailable`);let o=[...e.magpieWarnings?.includes(`sign_in_required`)?[a(`settings.remoteInstances.page.sync.magpie.signInRequired`)]:[],...e.magpieWarnings?.includes(`agent_settings_skipped`)?[a(`settings.remoteInstances.page.sync.magpie.agentsSkipped`)]:[]];o.length?q.warning(a(`settings.remoteInstances.page.sync.toast.success`),{description:o.join(`
|
|
23
|
-
`)}):q.success(a(`settings.remoteInstances.page.sync.toast.success`)),i(!1)}catch(e){console.error(`[remote-instances] config sync apply failed`,e),q.error(a(`settings.remoteInstances.page.sync.toast.failed`),{description:e instanceof Error?e.message:String(e)}),l(`review`)}}}),R=e=>c===`error`&&S!=null?e<S?`done`:e===S?`active`:`pending`:c===`review`||c===`applying`||e<o?`done`:e===o?`active`:`pending`;return(0,$.jsx)(hn,{open:e,onOpenChange:i,children:(0,$.jsxs)(fn,{className:`min-h-0 sm:max-w-2xl`,children:[(0,$.jsxs)(un,{children:[(0,$.jsx)(pn,{children:a(`settings.remoteInstances.page.sync.title`)}),(0,$.jsx)(mn,{children:a(`settings.remoteInstances.page.sync.description`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(K,{type:`button`,size:`xs`,variant:u===`push`?`default`:`outline`,className:`!font-normal`,"aria-pressed":u===`push`,disabled:M||c===`comparing-remote`||c===`scanning-local`,onClick:()=>I(`push`),children:a(`settings.remoteInstances.page.sync.direction.push`)}),(0,$.jsx)(K,{type:`button`,size:`xs`,variant:u===`pull`?`default`:`outline`,className:`!font-normal`,"aria-pressed":u===`pull`,disabled:M||c===`comparing-remote`||c===`scanning-local`,onClick:()=>I(`pull`),children:a(`settings.remoteInstances.page.sync.direction.pull`)})]}),(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-border/60 p-2`,children:[(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:a(`settings.remoteInstances.page.sync.scope.title`)}),T?null:(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:a(c===`scanning-local`||c===`comparing-remote`?`settings.remoteInstances.page.sync.step.scanLocal`:`settings.remoteInstances.page.sync.state.unavailable`)}),[{key:`config`,label:`config.json / opencode.json(c)`,index:0,kind:`fileGroups`},{key:`oh-slim`,label:`oh-my-opencode-slim.json(c)`,index:1,kind:`fileGroups`},{key:`oh-agent`,label:`oh-my-openagent.json(c)`,index:2,kind:`fileGroups`},{key:`agents-md`,label:`AGENTS.md`,index:0,kind:`singleFiles`},{key:`cursor-models`,label:`cursor-models.json`,index:1,kind:`singleFiles`},{key:`agents`,label:`agents/`,index:0,kind:`directories`},{key:`commands`,label:`commands/`,index:1,kind:`directories`},{key:`skills`,label:`skills/`,index:2,kind:`directories`},{key:`plugins`,label:`plugins/`,index:5,kind:`directories`}].filter(e=>m!=null&&e.index<m[e.kind]).map(e=>{let t=f[e.kind][e.index]!==!1;return(0,$.jsxs)(`label`,{className:`flex items-center gap-2 typography-meta`,children:[(0,$.jsx)(gn,{checked:t,disabled:M||!T,ariaLabel:e.label,onChange:t=>{if(!T)return;let n=[...f[e.kind]];n[e.index]=t;let r={...f,[e.kind]:n};p(r),c===`review`&&D(u,r)}}),(0,$.jsx)(`span`,{className:`font-mono`,children:e.label})]},e.key)}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 typography-meta`,children:[(0,$.jsx)(gn,{checked:f.agentsRoot,disabled:M||!T,ariaLabel:a(`settings.remoteInstances.page.sync.section.agentsRoot`),onChange:e=>{if(!T)return;let t={...f,agentsRoot:e};p(t),c===`review`&&D(u,t)}}),a(`settings.remoteInstances.page.sync.section.agentsRoot`)]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 typography-meta`,children:[(0,$.jsx)(gn,{checked:f.providerCredentials,disabled:M||!T,ariaLabel:a(`settings.remoteInstances.page.sync.section.providerCredentials`),onChange:e=>{if(!T)return;let t={...f,providerCredentials:e};p(t),c===`review`&&D(u,t)}}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:a(`settings.remoteInstances.page.sync.section.providerCredentials`)}),(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:a(`settings.remoteInstances.page.sync.hint.providerCredentials`)})]})]}),v?.plan.magpieAvailable?(0,$.jsxs)(`label`,{className:`flex items-center gap-2 typography-meta`,children:[(0,$.jsx)(gn,{checked:f.magpie===!0,disabled:M,ariaLabel:a(`settings.remoteInstances.page.sync.section.magpie`),onChange:e=>{let t={...f,magpie:e};p(t),D(u,t)}}),(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:a(`settings.remoteInstances.page.sync.section.magpie`)}),(0,$.jsx)(`span`,{className:`truncate typography-micro text-muted-foreground`,children:a(`settings.remoteInstances.page.sync.hint.magpie`)})]})]}):null]}),(0,$.jsx)(`div`,{className:`space-y-2`,children:Kd.map((e,t)=>{let n=t+1,r=R(n);return(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r===`done`?(0,$.jsx)(Y,{name:`check`,className:`h-3.5 w-3.5 shrink-0 text-[var(--status-success)]`}):r===`active`?(0,$.jsx)(Y,{name:`refresh`,className:`h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground`}):(0,$.jsx)(`span`,{className:`flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-full border border-border/60 typography-micro text-muted-foreground`,children:n}),(0,$.jsx)(`span`,{className:G(`typography-meta`,r===`pending`?`text-muted-foreground`:`text-foreground`),children:a(e)})]},e)})}),c===`error`?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{className:`typography-meta text-[var(--status-error)]`,children:a(`settings.remoteInstances.page.sync.state.error`,{message:b||``})}),(0,$.jsxs)(K,{type:`button`,variant:`outline`,size:`sm`,className:`!font-normal`,onClick:F,children:[(0,$.jsx)(Y,{name:`refresh`,className:`h-3.5 w-3.5`}),a(`settings.remoteInstances.sidebar.actions.retry`)]})]}):null,N&&!j?(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:a(`settings.remoteInstances.page.sync.state.empty`)}):null,N&&j&&A?(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-3`,children:[(0,$.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-border/60 bg-[var(--surface-elevated)]`,children:(0,$.jsx)(Rr,{fillContainer:!1,disableHorizontal:!0,outerClassName:`max-h-80`,className:`max-h-80`,children:(0,$.jsxs)(`div`,{className:`divide-y divide-border/60`,children:[A.files.map(e=>{let t=k.has(e.path);return(0,$.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2`,children:[(0,$.jsx)(Y,{name:`file-text`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono typography-micro text-foreground`,title:e.path,children:[(0,$.jsxs)(`span`,{className:`sr-only`,children:[a(`settings.remoteInstances.page.sync.section.files`),`: `]}),e.path]}),(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums typography-micro text-muted-foreground`,children:Hd(e.bytes)}),(0,$.jsx)(`span`,{className:G(`shrink-0 typography-micro`,t?`text-[var(--status-warning)]`:`text-[var(--status-success)]`),children:a(t?`settings.remoteInstances.page.sync.status.overwrite`:`settings.remoteInstances.page.sync.status.add`)})]},`file:${e.path}`)}),A.directories.map(e=>{let t=k.has(e.path);return(0,$.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2`,children:[(0,$.jsx)(Y,{name:`folder-3-fill`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono typography-micro text-foreground`,title:e.path,children:[(0,$.jsxs)(`span`,{className:`sr-only`,children:[a(`settings.remoteInstances.page.sync.section.directories`),`: `]}),e.path]}),(0,$.jsxs)(`span`,{className:`shrink-0 tabular-nums typography-micro text-muted-foreground`,children:[Hd(e.bytes),` · `,e.fileCount]}),(0,$.jsx)(`span`,{className:G(`shrink-0 typography-micro`,t?`text-[var(--status-warning)]`:`text-[var(--status-success)]`),children:a(t?`settings.remoteInstances.page.sync.status.overwrite`:`settings.remoteInstances.page.sync.status.add`)})]},`dir:${e.path}`)}),A.providerCredentials?(0,$.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2`,children:[(0,$.jsx)(Y,{name:`shield-keyhole`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate typography-micro text-foreground`,children:[(0,$.jsxs)(`span`,{className:`sr-only`,children:[a(`settings.remoteInstances.page.sync.section.providerCredentials`),`: `]}),a(`settings.remoteInstances.page.sync.section.providerCredentials`),(0,$.jsx)(`span`,{className:`ml-2 typography-micro text-muted-foreground`,children:a(`settings.remoteInstances.page.sync.hint.providerCredentials`)})]}),(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums typography-micro text-muted-foreground`,children:Hd(A.providerCredentials.bytes)}),(0,$.jsx)(`span`,{className:G(`shrink-0 typography-micro`,v?.remoteProviderCredentialsExists?`text-[var(--status-warning)]`:`text-[var(--status-success)]`),children:v?.remoteProviderCredentialsExists?a(`settings.remoteInstances.page.sync.status.overwrite`):a(`settings.remoteInstances.page.sync.status.add`)})]}):null,A.magpie?(0,$.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2`,children:[(0,$.jsx)(Y,{name:`tools`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate typography-micro text-foreground`,title:a(`settings.remoteInstances.page.sync.hint.magpie`),children:[a(`settings.remoteInstances.page.sync.section.magpie`),(0,$.jsx)(`span`,{className:`ml-2 typography-micro text-muted-foreground`,children:a(`settings.remoteInstances.page.sync.hint.magpie`)})]})]}):null,A.agentsRoot?(0,$.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2`,children:[(0,$.jsx)(Y,{name:`tools`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono typography-micro text-foreground`,title:`~/.agents`,children:[(0,$.jsxs)(`span`,{className:`sr-only`,children:[a(`settings.remoteInstances.page.sync.section.agentsRoot`),`: `]}),`~/.agents`]}),(0,$.jsxs)(`span`,{className:`shrink-0 tabular-nums typography-micro text-muted-foreground`,children:[Hd(A.agentsRoot.bytes),` · `,a(`settings.remoteInstances.page.sync.section.agentsRootCount`,{count:A.agentsRoot.fileCount})]}),(0,$.jsx)(`span`,{className:G(`shrink-0 typography-micro`,v?.remoteAgentsRootExists?`text-[var(--status-warning)]`:`text-[var(--status-success)]`),children:v?.remoteAgentsRootExists?a(`settings.remoteInstances.page.sync.status.overwrite`):a(`settings.remoteInstances.page.sync.status.add`)})]}):null]})})}),(0,$.jsxs)(`div`,{className:`space-y-1 typography-micro text-muted-foreground`,children:[P>0?(0,$.jsx)(`div`,{children:a(`settings.remoteInstances.page.sync.note.deletes`,{count:P})}):null,(0,$.jsx)(`div`,{children:a(`settings.remoteInstances.page.sync.note.backup`)}),(0,$.jsx)(`div`,{children:a(`settings.remoteInstances.page.sync.note.excluded`)})]})]}):null,(0,$.jsxs)(dn,{className:`shrink-0`,children:[(0,$.jsx)(K,{type:`button`,variant:`outline`,size:`sm`,className:`!font-normal`,onClick:()=>i(!1),disabled:M,children:a(`settings.remoteInstances.page.sync.actions.cancel`)}),(0,$.jsxs)(K,{type:`button`,size:`sm`,className:`!font-normal`,onClick:()=>void L(),disabled:!j||M||c!==`review`,children:[(0,$.jsx)(Y,{name:`refresh`,className:G(`h-3.5 w-3.5`,M?`animate-spin`:``)}),a(M?`settings.remoteInstances.page.sync.applying`:`settings.remoteInstances.page.sync.actions.syncNow`)]})]})]})})},Jd=e=>{let t=(e instanceof Error?e.message:String(e)).toLowerCase();return t.includes(`address already in use`)||t.includes(`eaddrinuse`)||t.includes(`port already in use`)},Yd=()=>{if(typeof navigator>`u`)return;let e=(navigator.userAgent||``).toLowerCase();if(e.includes(`mac`))return`macos`;if(e.includes(`win`))return`windows`;if(e.includes(`linux`))return`linux`},Xd=e=>{switch((e||``).toLowerCase()){case`ios`:return`iOS`;case`android`:return`Android`;case`macos`:case`darwin`:return`macOS`;case`windows`:case`win32`:return`Windows`;case`linux`:return`Linux`;default:return null}},Zd=e=>{switch((e||``).toLowerCase()){case`ios`:return`device-ios`;case`android`:return`device-android`;case`macos`:case`darwin`:return`device-macos`;case`windows`:case`win32`:return`device-windows`;case`linux`:return`device-linux`;default:return null}},Qd=e=>{switch(e){case`config_resolved`:return`settings.remoteInstances.page.phase.resolvingConfiguration`;case`auth_check`:return`settings.remoteInstances.page.phase.checkingAuth`;case`master_connecting`:return`settings.remoteInstances.page.phase.establishingSsh`;case`remote_probe`:return`settings.remoteInstances.page.phase.probingRemote`;case`installing`:return`settings.remoteInstances.page.phase.installingYuri`;case`updating`:return`settings.remoteInstances.page.phase.updatingYuri`;case`server_detecting`:return`settings.remoteInstances.page.phase.detectingServer`;case`server_starting`:return`settings.remoteInstances.page.phase.startingServer`;case`forwarding`:return`settings.remoteInstances.page.phase.forwardingPorts`;case`ready`:return`settings.remoteInstances.sidebar.phase.ready`;case`degraded`:return`settings.remoteInstances.page.phase.reconnecting`;case`error`:return`settings.remoteInstances.sidebar.phase.error`;default:return`settings.remoteInstances.sidebar.phase.idle`}},$d=new Set([`config_resolved`,`auth_check`,`master_connecting`,`remote_probe`,`installing`,`updating`,`server_detecting`,`server_starting`,`forwarding`]),ef=e=>!!(e&&$d.has(e)),tf=e=>e===`ready`?`bg-[var(--status-success)] animate-pulse`:e===`error`?`bg-[var(--status-error)] animate-pulse`:e===`degraded`||ef(e)?`bg-[var(--status-warning)] animate-pulse`:`bg-muted-foreground/40`,nf=e=>e.type===`dynamic`?`${e.localHost||`127.0.0.1`}:${e.localPort||0}`:e.type===`remote`?`${e.remoteHost||`127.0.0.1`}:${e.remotePort||0} -> ${e.localHost||`127.0.0.1`}:${e.localPort||0}`:`${e.localHost||`127.0.0.1`}:${e.localPort||0} -> ${e.remoteHost||`127.0.0.1`}:${e.remotePort||0}`,rf=()=>({id:`forward-${Date.now()}-${Math.random().toString(16).slice(2)}`,enabled:!0,type:`local`,localHost:`127.0.0.1`,localPort:Vd(),remoteHost:`127.0.0.1`,remotePort:80}),af=e=>{let t=(0,qi.c)(10),{itemId:n,label:r,description:i,action:a,children:o}=e,s;t[0]!==a||t[1]!==r?(s=a?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsx)(`div`,{className:`min-w-0`,children:r}),(0,$.jsx)(`div`,{className:`shrink-0`,children:a})]}):r,t[0]=a,t[1]=r,t[2]=s):s=t[2];let c;t[3]===o?c=t[4]:(c=(0,$.jsx)(`div`,{className:`yuri-settings-group-row`,children:o}),t[3]=o,t[4]=c);let l;return t[5]!==i||t[6]!==n||t[7]!==s||t[8]!==c?(l=(0,$.jsx)(X,{itemId:n,className:`yuri-settings-detail-group`,label:s,description:i,children:c}),t[5]=i,t[6]=n,t[7]=s,t[8]=c,t[9]=l):l=t[9],l},of=e=>{switch(e){case`remote`:return`settings.remoteInstances.page.forwardTypeDescription.remote`;case`dynamic`:return`settings.remoteInstances.page.forwardTypeDescription.dynamic`;default:return`settings.remoteInstances.page.forwardTypeDescription.local`}},sf=(e,t)=>{let n=(e||``).trim();return`${!n||n===`127.0.0.1`||n===`::1`?`localhost`:n}:${t||0}`},cf=e=>{let t=(e||``).trim();return!t||t===`0.0.0.0`||t===`::`?`127.0.0.1`:t},lf=e=>{let t=e.match(/^\[(\d{10,})\]\s*(?:\[([A-Z]+)\]\s*)?(.*)$/);if(!t)return e;let n=Number(t[1]);return`[${Number.isFinite(n)?new Date(n).toISOString():t[1]}] [${(t[2]||`INFO`).toUpperCase()}] ${t[3]||``}`},uf=()=>{if(typeof window>`u`)return null;let e=c()||window.location.href;try{let t=Number(new URL(e).port||window.location.port);return Number.isFinite(t)&&t>0?t:null}catch{let e=Number(window.location.port);return Number.isFinite(e)&&e>0?e:null}},df=e=>{try{let t=new URL(e).hostname.toLowerCase();return t===`localhost`||t===`127.0.0.1`||t===`::1`||t===`[::1]`}catch{return!1}},ff=async()=>{let e=U(c())||window.location.origin;if(!E()||!m())return e;let t;try{t=await p(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}})}catch{return e}if(!t.ok||(await t.json().catch(()=>null))?.desktopLanAccessActive!==!0)return e;let n=await _(),r=uf();return!n||!r?e:`http://${n}:${r}`},pf=e=>{let t=e.trim();if(t)try{window.location.assign(t)}catch{window.location.href=t}},mf=e=>{let t=e.sshCommand.trim(),n=e.nickname?.trim(),r=e.portForwards.map(e=>({...e,localHost:e.localHost?.trim()||`127.0.0.1`,localPort:typeof e.localPort==`number`?Math.max(1,Math.min(65535,Math.round(e.localPort))):void 0,remoteHost:e.remoteHost?.trim(),remotePort:typeof e.remotePort==`number`?Math.max(1,Math.min(65535,Math.round(e.remotePort))):void 0}));return{...e,sshCommand:t,...n?{nickname:n}:{nickname:void 0},connectionTimeoutSec:Math.max(5,Math.min(240,Math.round(e.connectionTimeoutSec||60))),localForward:{...e.localForward,bindHost:e.localForward.bindHost===`localhost`||e.localForward.bindHost===`0.0.0.0`?e.localForward.bindHost:`127.0.0.1`,preferredLocalPort:typeof e.localForward.preferredLocalPort==`number`?Math.max(1,Math.min(65535,Math.round(e.localForward.preferredLocalPort))):void 0},remoteYuri:{...e.remoteYuri,preferredPort:typeof e.remoteYuri.preferredPort==`number`?Math.max(1,Math.min(65535,Math.round(e.remoteYuri.preferredPort))):void 0},portForwards:r}},hf=()=>{let{t:e}=He(),{clientAuth:t}=Ae(),i=C(),o=oi(e=>e.instances),l=oi(e=>e.statusesById),u=oi(e=>e.isLoading),d=oi(e=>e.isSaving),f=oi(e=>e.error),p=oi(e=>e.load),m=oi(e=>e.loadImports),h=oi(e=>e.refreshStatuses),g=oi(e=>e.upsertInstance),_=oi(e=>e.createFromCommand),v=oi(e=>e.removeInstance),y=oi(e=>e.connect),b=oi(e=>e.disconnect),x=oi(e=>e.retry),S=W(e=>e.settingsRemoteInstancesSelectedId),w=W(e=>e.setSettingsRemoteInstancesSelectedId),T=Q.useMemo(()=>S&&o.find(e=>e.id===S)||null,[o,S]),[D,O]=Q.useState(null),[k,A]=Q.useState([]),[j,M]=Q.useState(!1),[N,P]=Q.useState(!1),[F,L]=Q.useState(null),[R,z]=Q.useState([]),[ce,le]=Q.useState(!1),[ue,de]=Q.useState(null),[fe,pe]=Q.useState(`ssh`),[me,he]=Q.useState(null),[ge,_e]=Q.useState(null),[ve,ye]=Q.useState(``),[be,xe]=Q.useState(!1),[Se,Ce]=Q.useState({}),[we,Te]=Q.useState(!1),[Ee,De]=Q.useState(!1),[Oe,ke]=Q.useState(()=>Date.now()),[je,Me]=Q.useState([]),[Ne,Pe]=Q.useState({}),[Fe,Ie]=Q.useState(`local`),[Le,Re]=Q.useState(!1),[Be,Ue]=Q.useState(!1),[We,Ke]=Q.useState(0),qe=ir(),[Je,Ye]=Q.useState(``),[Xe,Ze]=Q.useState(null),[Qe,$e]=Q.useState(!1),[et,tt]=Q.useState([]),[nt,rt]=Q.useState([]),[it,at]=Q.useState(!1),[ot,st]=Q.useState(``),ct=Q.useRef(!1),[lt,ut]=Q.useState(null),[dt,ft]=Q.useState(null),[pt,mt]=Q.useState(!1),[ht,gt]=Q.useState(null),[_t,vt]=Q.useState(null),[yt,bt]=Q.useState(null),[xt,St]=Q.useState(null),[Ct,wt]=Q.useState(!1),[Tt,Et]=Q.useState(!1),[Dt,Ot]=Q.useState(`configure`),[kt,At]=Q.useState(!1),[jt,Mt]=Q.useState(`relay`),[Nt,Pt]=Q.useState(!0),[Ft,It]=Q.useState(Fd),[Lt,Rt]=Q.useState(null),[J,zt]=Q.useState(!1),[Bt,Vt]=Q.useState(!1),Ht=Q.useRef(null);Q.useEffect(()=>{J&&Lt&&Ht.current?.focus()},[J,Lt]);let[Ut,Wt]=Q.useState(null),Gt=Q.useMemo(()=>et.filter(e=>!!e.revokedAt).length,[et]),[Kt,qt]=Q.useState(!1),[Jt,Yt]=Q.useState(`ssh user@example.com`),[Xt,Zt]=Q.useState(``);Q.useEffect(()=>{p(),m()},[p,m]);let Qt=Q.useCallback(async()=>{Re(!0);try{let e=await ie();Me(e.hosts||[]),Ie(e.defaultHostId||`local`)}catch(t){q.error(e(`desktopHostSwitcher.error.failedToLoad`),{description:t instanceof Error?t.message:String(t)})}finally{Re(!1)}},[e]);Q.useEffect(()=>{Qt()},[Qt]);let $t=Object.values(l).filter(e=>e.phase===`ready`).map(e=>`${e.id}:${e.localUrl||``}`).sort().join(`|`);Q.useEffect(()=>{$t&&Qt()},[Qt,$t]);let en=Q.useCallback(async(t,n=Fe)=>{Ue(!0);try{return await ne({hosts:t,defaultHostId:n,initialHostChoiceCompleted:!0}),Me(t),Ie(n),!0}catch(t){return q.error(e(`desktopHostSwitcher.error.failedToSave`),{description:t instanceof Error?t.message:String(t)}),!1}finally{Ue(!1)}},[Fe,e]),tn=Q.useMemo(()=>new Set(o.map(e=>e.id)),[o]),nn=Q.useMemo(()=>je.filter(e=>ee(e,tn)),[je,tn]),rn=ze(async()=>{Ze(null);let t=ga(Je);if(!t){Ze(e(`settings.remoteInstances.direct.error.invalidConnectLink`));return}let r=await V().catch(()=>``),i={method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({pairingId:t.pairingId,secret:t.secret,clientLabel:t.label||`Yuri Desktop`,clientKind:`desktop`,deviceName:`Yuri Desktop`,devicePlatform:Yd(),...r?{dedupeKey:`desktop:${r}`}:{}})},a=async e=>{if(!e.ok)return null;let t=await e.json().catch(()=>null);return(typeof t?.clientToken==`string`?t.clientToken.trim():``)||null},o=[...t.candidates].sort((e,t)=>(e.type===`relay`)-+(t.type===`relay`)),s=null;for(let e of o){if(e.type===`relay`){let t=n({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk,...e.grant?{grant:e.grant}:{}});try{let n=await a(await t.fetch(`/api/client-auth/pairing/redeem`,i));if(n){s={kind:`relay`,relay:{relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk},token:n,tunnel:t},t.close();break}}catch{}t.close();continue}let t=U(e.url);if(t)try{let e=await a(await fetch(`${t}/api/client-auth/pairing/redeem`,i));if(e){s={kind:`direct`,url:t,token:e};break}}catch{}}if(!s){Ze(e(`settings.remoteInstances.direct.error.pairingFailed`));return}let c=()=>I(),l=t.candidates.find(e=>e.type===`relay`),u=s.kind===`relay`?s.relay:l?{relayUrl:l.relayUrl,serverId:l.serverId,hostEncPubJwk:l.hostEncPubJwk}:void 0,d=t.candidates.filter(e=>e.type!==`relay`),f=d.map(e=>U(e.url)).find(e=>!!e),p=d.filter(e=>e.type===`lan`).map(e=>U(e.url)).find(e=>!!e),m=s.kind===`direct`?s.url:p||f||null,{token:h}=s,g=m||(u?B(u.serverId):null);if(!g){Ze(e(`settings.remoteInstances.direct.error.invalidConnectLink`));return}let _={url:g,apiUrl:m||void 0,clientToken:h,source:ae,...u?{relay:u}:{}},v=je.find(e=>u?e.relay?.serverId===u.serverId&&e.relay?.relayUrl===u.relayUrl:!e.relay&&U(e.apiUrl||e.url)===g);if(v){let e=je.map(e=>e.id===v.id?{...e,label:t.label||e.label,..._}:e);if(!await en(e,Fe))return}else if(!await en([{id:c(),label:t.label||H(g),..._},...je],Fe))return;Ye(``),Ze(null),$e(!1)}),an=Q.useCallback(async e=>{let t=je.filter(t=>t.id!==e);await en(t,Fe===e?`local`:Fe)},[Fe,je,en]),on=Q.useCallback(async()=>{let t=Jt.trim();if(!t){q.error(e(`settings.remoteInstances.page.toast.sshCommandRequired`));return}let n=`ssh-${Date.now()}-${Math.random().toString(16).slice(2)}`;try{await _(n,t,Xt.trim()||void 0),w(n),qt(!1),Yt(`ssh user@example.com`),Zt(``),q.success(e(`settings.remoteInstances.page.toast.instanceCreated`))}catch(t){q.error(e(`settings.remoteInstances.sidebar.toast.createFailed`),{description:t instanceof Error?t.message:String(t)})}},[_,w,Jt,Xt,e]),sn=Q.useCallback(async e=>{await en(je,e)},[je,en]),cn=ze(async e=>{if(se(e)||qe)return;let t=await mr({host:e,cachedProbe:Ne[e.id]||null});Pe(n=>({...n,[e.id]:t.status}))}),ln=ze(async t=>{if(qe)return;let n=t.nickname?.trim()||t.sshParsed?.destination||t.id,r=je;try{let e=await ie();r=e.hosts||[],Me(r),Ie(e.defaultHostId||`local`)}catch(t){q.error(e(`desktopHostSwitcher.toast.instanceUnreachable`,{host:n}),{description:t instanceof Error?t.message:String(t)});return}let i=r.find(e=>e.id===t.id)??null;if(!i||!oe(i)||!i.clientToken){q.error(e(`desktopHostSwitcher.toast.instanceUnreachable`,{host:n}));return}se(i)||await mr({host:i})});Q.useEffect(()=>{if(i)return r(()=>{Ke(e=>e+1)})},[i]),Q.useEffect(()=>{if(!i||nn.length===0)return;let e=!1;return Promise.all(nn.map(async e=>{let t=async()=>{let t=await te(e.relay,{clientToken:e.clientToken||null}).catch(()=>({status:`unreachable`,latencyMs:0}));return t.status===`ok`?{status:t.status,latencyMs:t.latencyMs,via:`relay`}:{status:t.status,latencyMs:t.latencyMs}};if(e.relay&&!e.apiUrl)return[e.id,await t()];let n=U(oe(e));if(!n)return[e.id,e.relay?await t():{status:`unreachable`,latencyMs:0}];let r=await re(n,{clientToken:e.clientToken||null,requestHeaders:e.requestHeaders||null}).catch(()=>({status:`unreachable`,latencyMs:0}));if(r.status===`unreachable`&&e.relay){let n=await t();if(n.status===`ok`)return[e.id,n]}return[e.id,r]})).then(t=>{e||Pe(Object.fromEntries(t))}),()=>{e=!0}},[nn,i]);let _n=Q.useCallback(async e=>{if(t){e?.silent||at(!0),e?.silent||ut(null);try{let[e,n]=await Promise.all([t.listClients(),t.listPendingPairings().catch(()=>null)]);tt(e),n&&rt(n)}catch(t){e?.silent||ut(t instanceof Error?t.message:String(t))}finally{e?.silent||at(!1)}}},[t]),yn=Q.useRef(!1);Q.useEffect(()=>{if(!(!Tt||Dt!==`result`||!yt)){if(nt.some(e=>e.id===yt)){yn.current=!0;return}yn.current&&(bt(null),Et(!1),et.some(e=>e.pairingId===yt)&&q.success(e(`settings.remoteInstances.clientAuth.addDevice.connectedToast`)))}},[Tt,Dt,yt,nt,et,e]);let Sn=Q.useCallback(async e=>{if(t)try{await t.cancelPairing(e),rt(t=>t.filter(t=>t.id!==e)),await _n({silent:!0})}catch(e){ut(e instanceof Error?e.message:String(e))}},[t,_n]);Q.useEffect(()=>{if(!t)return;_n();let e=window.setInterval(()=>{typeof document<`u`&&document.visibilityState!==`visible`||_n({silent:!0})},5e3);return()=>window.clearInterval(e)},[t,_n]);let wn=Q.useCallback(async()=>{let e=s()!==`local`;if(t?.getPairingTransports)try{let n=await t.getPairingTransports(),r=Ld(n.relayUrl),i=Array.from(new Set([...Array.isArray(n.relayUrls)?n.relayUrls:[],...r?[r]:[]].map(e=>Ld(e)).filter(e=>!!e)));return{serverName:n.serverName,localUrl:n.local,lanUrl:n.lan,relayAvailable:n.relayAvailable,relayUrl:r,relayUrls:n.relayAvailable?i:[],relayUrlLocked:n.relayUrlLocked===!0,remoteHost:e}}catch{}let n=uf(),r=n?`http://127.0.0.1:${n}`:df(window.location.origin)?window.location.origin:null,i=null;try{let e=U(await ff());i=e&&!df(e)?e:null}catch{}return{localUrl:r,lanUrl:i,relayAvailable:!1,relayUrl:null,relayUrls:[],relayUrlLocked:!1,remoteHost:e}},[t]),An=ze(async()=>{ct.current=!1,st(``),ut(null),vt(null),St(null),wt(!1),bt(null),Rt(null),Ot(`configure`),zt(!1),Pt(!0),Et(!0);let e=await wn();ct.current||st(e.serverName||``),Wt(e),Vt(!1);let t=e.remoteHost?null:Rd();It((e.relayUrlLocked||e.remoteHost?e.relayUrl:t||e.relayUrl)||`wss://relay.openchamber.dev/ws`),Mt(e.relayAvailable?`relay`:e.lanUrl?`lan`:`local`)}),jn=W(e=>e.devicePairingRequested);Q.useEffect(()=>{!jn||!t||(W.setState({devicePairingRequested:!1}),An())},[jn,t,An]);let Mn=ze(async()=>{if(!(!t?.createPairingSession||!Ut)){ut(null),At(!0);try{let n=ot.trim()||void 0,r,i,a=!0;jt===`local`?(r=Ut.localUrl??void 0,i=!1):jt===`lan`?(r=Ut.lanUrl??void 0,i=Nt):Nt&&Ut.lanUrl?(r=Ut.lanUrl,i=!0):(a=!1,i=!0),Ut.relayAvailable||(i=!1);let o=i?Ld(Ft):null;if(i&&!o){Rt(e(`settings.remoteInstances.clientAuth.addDevice.relayUrlInvalid`)),zt(!0);return}Rt(null);let{pairing:s,server:c}=await t.createPairingSession({label:n,allowedClientKinds:[`mobile`,`desktop`],serverUrl:r,includeRelay:i,includeDirect:a,...o?{relayUrl:o}:{}}),l=pa({pairingId:s.id,secret:s.secret,label:n||c.label,fingerprint:s.fingerprint??void 0,expiresAt:s.expiresAt,candidates:c.candidates}),u=l.candidates.find(e=>e.type===`relay`);u&&(It(u.relayUrl),Ut?.remoteHost!==!0&&zd(u.relayUrl));let d=ma(l);vt(d),St(await cd.toDataURL(d,{width:1024,margin:2,errorCorrectionLevel:`L`})),wt(!1),yn.current=!1,bt(s.id),Ot(`result`),await _n({silent:!0})}catch(e){ut(e instanceof Error?e.message:String(e))}finally{At(!1)}}}),Nn=Q.useCallback(()=>{_t&&Ve(_t).then(e=>{e.ok&&(wt(!0),window.setTimeout(()=>wt(!1),2e3))})},[_t]),Fn=ze(async()=>{if(!(!t||!dt||pt||!dt.label.trim())){mt(!0),gt(null);try{let e=await t.renameClient(dt.id,dt.label.trim());tt(t=>t.map(t=>t.id===e.id?e:t)),ft(null),await _n({silent:!0})}catch(e){gt(e instanceof Error?e.message:String(e))}finally{mt(!1)}}}),In=Q.useCallback(async e=>{if(!t)return;let n=e.clientKind===`desktop-local`;ut(null);try{if(await t.revokeClient(e.id),n&&E()){let t=await ie();await ne({hosts:t.hosts,defaultHostId:t.defaultHostId,initialHostChoiceCompleted:t.initialHostChoiceCompleted,localClientToken:null}),tt(t=>t.map(t=>t.id===e.id?{...t,revokedAt:new Date().toISOString()}:t)),a({apiBaseUrl:c(),clientToken:null,runtimeKey:`local`});return}await _n()}catch(e){ut(e instanceof Error?e.message:String(e))}},[t,_n]),Ln=Q.useCallback(async()=>{if(t){ut(null);try{await t.purgeRevokedClients(),await _n()}catch(e){ut(e instanceof Error?e.message:String(e))}}},[t,_n]);Q.useEffect(()=>{O(T)},[T]),Q.useEffect(()=>{let e=!1;return!S||T?.remoteYuri?.mode!==`managed`?(A([]),()=>{e=!0}):(br(S).then(t=>{e||A(t.slice(-5).reverse())}).catch(()=>{e||A([])}),()=>{e=!0})},[S,T?.remoteYuri?.mode,ce]),Q.useEffect(()=>{if(!S)return;let e=window.setInterval(()=>{typeof document<`u`&&document.visibilityState!==`visible`||h()},2e3);return()=>{window.clearInterval(e)}},[h,S]),Q.useEffect(()=>{let e=null,t=Date.now(),n=()=>{let r=Date.now();r-t>=1e3&&(ke(r),t=r),e=requestAnimationFrame(n)};(typeof document>`u`||document.visibilityState===`visible`)&&(e=requestAnimationFrame(n));let r=()=>{document.visibilityState===`visible`&&e===null?e=requestAnimationFrame(n):document.visibilityState!==`visible`&&e!==null&&(cancelAnimationFrame(e),e=null)};return document.addEventListener(`visibilitychange`,r),()=>{document.removeEventListener(`visibilitychange`,r),e!==null&&cancelAnimationFrame(e)}},[]);let Rn=S?l[S]:null,zn=Rn?.phase,Bn=zn===`ready`,Vn=zn===`degraded`,Hn=ef(zn),Un=Bn||Hn||Vn,Wn=Rn?Math.max(0,Oe-Rn.updatedAtMs):0,Gn=Vn&&Wn>12e3,Kn=Q.useMemo(()=>!D||!T?!1:JSON.stringify(D)!==JSON.stringify(T),[D,T]),qn=Q.useCallback(e=>{O(t=>t&&e(t))},[]),Jn=Q.useCallback(async()=>{if(!D)return;let t=mf(D);if(!t.sshCommand.trim()){q.error(e(`settings.remoteInstances.page.toast.sshCommandRequired`));return}if(!(t.localForward.bindHost===`0.0.0.0`&&!window.confirm(e(`settings.remoteInstances.page.confirm.bindAllInterfaces`)))){if(t.auth.sshPassword?.enabled&&t.auth.sshPassword.value?.trim()&&t.auth.sshPassword.store!==`settings`){let n=window.confirm(e(`settings.remoteInstances.page.confirm.storeSshPasswordPlaintext`));t.auth.sshPassword.store=n?`settings`:`never`,n||(t.auth.sshPassword.value=void 0)}if(t.auth.yuriPassword?.enabled&&t.auth.yuriPassword.value?.trim()&&t.auth.yuriPassword.store!==`settings`){let n=window.confirm(e(`settings.remoteInstances.page.confirm.storeUiPasswordPlaintext`));t.auth.yuriPassword.store=n?`settings`:`never`,n||(t.auth.yuriPassword.value=void 0)}try{await g(t),q.success(e(`settings.remoteInstances.page.toast.instanceSaved`))}catch(t){q.error(e(`settings.remoteInstances.page.toast.saveFailed`),{description:t instanceof Error?t.message:String(t)})}}},[D,e,g]),Yn=Q.useCallback(async(t,n)=>{let r=`ssh-${Date.now()}-${Math.random().toString(16).slice(2)}`;try{return await _(r,`ssh ${n}`,t),w(r),q.success(e(`settings.remoteInstances.page.toast.instanceCreated`)),!0}catch(t){return q.error(e(`settings.remoteInstances.sidebar.toast.createFailed`),{description:t instanceof Error?t.message:String(t)}),!1}},[_,w,e]),Xn=Q.useCallback(()=>{be||(_e(null),ye(``))},[be]),Qn=Q.useCallback(async()=>{let t=ge,n=ve.trim();if(t){if(!n){q.error(e(`settings.remoteInstances.page.toast.destinationRequired`));return}xe(!0);try{await Yn(t,n)&&(_e(null),ye(``))}finally{xe(!1)}}},[Yn,ve,ge,e]),$n=Q.useCallback(async()=>{if(T)try{await y(T.id);return}catch(t){if(!Jd(t)||!window.confirm(e(`settings.remoteInstances.sidebar.confirm.localPortInUseRetry`)))throw t;let n={...T,localForward:{...T.localForward,preferredLocalPort:Vd()}};await g(n),await y(n.id),q.success(e(`settings.remoteInstances.sidebar.toast.retriedWithRandomPort`))}},[y,T,e,g]),er=Q.useCallback(async e=>(await nr(e,600)).map(e=>lf(e)),[]),ar=Q.useCallback(async()=>{if(D){M(!0),P(!0),L(null);try{let e=await er(D.id);z(e)}catch(e){z([]),L(e instanceof Error?e.message:String(e))}finally{P(!1)}}},[D,er]);Q.useEffect(()=>{if(!j||!D)return;let e=!1,t=async()=>{try{let t=await er(D.id);e||(z(t),L(null))}catch(t){e||L(t instanceof Error?t.message:String(t))}};t();let n=window.setInterval(()=>{typeof document<`u`&&document.visibilityState!==`visible`||t()},1e3);return()=>{e=!0,window.clearInterval(n)}},[D,j,er]);let or=Q.useMemo(()=>R.join(`
|
|
22
|
+
`}`},Wu=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Gu=e=>{let t=e.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)([\s\S]*)$/);if(!t)return{description:null,instructions:e};let n=null;try{let e=Gi(t[1]);if(Wu(e)){let t=e.description;typeof t==`string`&&(n=t)}}catch{n=null}return{description:n,instructions:t[2].replace(/^\r?\n/,``)}},Ku=(e,t)=>Uu(t,Gu(e).instructions),qu=()=>{let{t:e}=He(),{currentTheme:t}=ln(),{selectedSkillName:n,getSkillDetail:r,createSkill:i,updateSkill:a,skillDraft:o,setSkillDraft:s,setSelectedSkill:c}=Ra(de(e=>({selectedSkillName:e.selectedSkillName,getSkillDetail:e.getSkillDetail,createSkill:e.createSkill,updateSkill:e.updateSkill,skillDraft:e.skillDraft,setSkillDraft:e.setSkillDraft,setSelectedSkill:e.setSelectedSkill}))),l=Dt(),u=ht(),d=Q.useMemo(()=>l.data??[],[l.data]),f=n?d.find(e=>e.name===n)??null:null,p=!!(o&&o.name===n&&!f),m=!!(n&&!f&&!o),h=f?.path===`<built-in>`;Q.useEffect(()=>{m&&c(null)},[m,c]);let[g,_]=Q.useState(``),[v,y]=Q.useState(`user`),[b,x]=Q.useState(`opencode`),[S,C]=Q.useState(``),[w,T]=Q.useState(``),[E,D]=Q.useState(()=>Uu(``,``)),[O,k]=Q.useState(`edit`),[A,j]=Q.useState([]),[M,N]=Q.useState([]),[P,F]=Q.useState(!1),[I,L]=Q.useState(!1),[R,z]=Q.useState(``),[B,V]=Q.useState(``),[ee,H]=Q.useState(!1),[te,ne]=Q.useState(``),[U,re]=Q.useState(``),[ie,ae]=Q.useState(null),[oe,se]=Q.useState(!1),[ce,le]=Q.useState(``),[ue,fe]=Q.useState(null),[pe,me]=Q.useState(!1),he=p?g.trim()!==``||S.trim()!==``||w.trim()!==``||M.length>0:S!==R||w!==B,ge=ie?U!==ce:te.trim()!==``,_e=Q.useCallback(t=>{switch(t){case`project-opencode`:return e(`settings.skills.location.option.projectOpencode.label`);case`user-claude`:return e(`settings.skills.location.option.userClaude.label`);case`project-claude`:return e(`settings.skills.location.option.projectClaude.label`);case`user-agents`:return e(`settings.skills.location.option.userAgents.label`);case`project-agents`:return e(`settings.skills.location.option.projectAgents.label`);default:return e(`settings.skills.location.option.userOpencode.label`)}},[e]),ve=Q.useCallback(t=>{switch(t){case`project-opencode`:return e(`settings.skills.location.option.projectOpencode.description`);case`user-claude`:return e(`settings.skills.location.option.userClaude.description`);case`project-claude`:return e(`settings.skills.location.option.projectClaude.description`);case`user-agents`:return e(`settings.skills.location.option.userAgents.description`);case`project-agents`:return e(`settings.skills.location.option.projectAgents.description`);default:return e(`settings.skills.location.option.userOpencode.description`)}},[e]);Q.useEffect(()=>{(async()=>{if(p&&o){let e=o.description||``,t=o.instructions||``;_(o.name||``),y(o.scope||`user`),x(o.source===`agents`?`agents`:`opencode`),C(e),T(t),D(Uu(e,t)),z(``),V(``),j([]),N(o.pendingFiles||[])}else if(n&&f){L(!0);try{let e=await r(n);if(e){let t=e.sources.md,n=t.description||``,r=t.instructions||``;C(n),T(r),D(Uu(n,r)),z(n),V(r),j(t.supportingFiles||[])}}catch(e){console.error(`Failed to load skill details:`,e)}finally{L(!1)}}})()},[f,p,n,d,o,r]);let ye=W(e=>e.editorFontSize),be=Q.useMemo(()=>{let e=[bi(t,{fontSize:ye})],n=ni(Vu);return n&&e.push(n),e.push(Fe.lineWrapping),e},[t,ye]),xe=Q.useMemo(()=>{let e=te.trim()||`supporting-file.md`,n=Gr(e),r=!!n&&n!==`markdown`,i=[bi(t,r?{syntaxColors:!1,fontSize:ye}:{fontSize:ye})],a=ni(e);return a&&i.push(a),r&&n&&i.push(Jr({language:n,themeName:t.metadata.id,theme:Hr(t)})),i.push(Fe.lineWrapping),i},[t,te,ye]),Se=Q.useCallback(e=>{C(e),D(t=>Ku(t,e))},[]),Ce=Q.useCallback(e=>{D(e);let t=Gu(e);C(t.description??``),T(t.instructions)},[]),we=async()=>{let t=p?g.trim().replace(/\s+/g,`-`).toLowerCase():n?.trim();if(!t){q.error(e(`settings.skills.page.toast.skillNameRequired`));return}if(!/^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$/.test(t)||t.length>64){q.error(e(`settings.skills.page.toast.invalidSkillName`));return}if(!S.trim()){q.error(e(`settings.skills.page.toast.descriptionRequired`));return}if(p&&d.some(e=>e.name===t)){q.error(e(`settings.skills.page.toast.skillExists`));return}F(!0);try{let n={name:t,description:S.trim(),instructions:w.trim()||void 0,scope:p?v:void 0,source:p?b:void 0,targetPath:p?void 0:f?.path,supportingFiles:p&&M.length>0?M:void 0},r;p?(r=await i(n,{directory:u}),r&&(s(null),N([]),c(t))):(r=await a(t,n,{directory:u}),r&&(z(S.trim()),V(w.trim()))),r?q.success(e(p?`settings.skills.page.toast.skillCreated`:`settings.skills.page.toast.skillUpdated`)):q.error(e(p?`settings.skills.page.toast.createSkillFailed`:`settings.skills.page.toast.updateSkillFailed`))}catch(t){console.error(`Error saving skill:`,t),q.error(e(`settings.skills.page.toast.saveUnexpectedError`))}finally{F(!1)}},Te=()=>{ae(null),ne(``),re(``),le(``),H(!0)},Ee=async t=>{if(ae(t),ne(t),p){let e=M.find(e=>e.path===t)?.content||``;re(e),le(e),H(!0);return}if(n){se(!0),H(!0);try{let{readSupportingFile:e}=Ra.getState(),r=await e(n,t);re(r||``),le(r||``)}catch{q.error(e(`settings.skills.page.toast.loadFileContentFailed`)),re(``),le(``)}finally{se(!1)}}},De=async()=>{if(!te.trim()){q.error(e(`settings.skills.page.toast.fileNameRequired`));return}let t=te.trim(),i=ie!==null;if(p){if(i)N(e=>e.map(e=>e.path===ie?{path:t,content:U}:e)),q.success(e(`settings.skills.page.toast.fileUpdated`,{path:t}));else{if(M.some(e=>e.path===t)){q.error(e(`settings.skills.page.toast.fileExists`));return}N(e=>[...e,{path:t,content:U}]),q.success(e(`settings.skills.page.toast.fileAdded`,{path:t}))}H(!1),ae(null);return}if(!n){q.error(e(`settings.skills.page.toast.noSkillSelected`));return}let{writeSupportingFile:a}=Ra.getState();if(await a(n,t,U)){q.success(e(i?`settings.skills.page.toast.fileUpdated`:`settings.skills.page.toast.fileCreated`,{path:t})),H(!1),ae(null);let a=await r(n);a&&j(a.sources.md.supportingFiles||[])}else q.error(e(i?`settings.skills.page.toast.updateFileFailed`:`settings.skills.page.toast.createFileFailed`))},Oe=t=>{if(p){N(e=>e.filter(e=>e.path!==t)),q.success(e(`settings.skills.page.toast.fileRemoved`,{path:t}));return}n&&fe(t)};return!n&&!o||m?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-4`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(Y,{name:`book-open`,className:`mx-auto mb-3 h-10 w-10 sm:h-12 sm:w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.skills.page.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.skills.page.empty.description`)})]})}):I?(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-4`,children:(0,$.jsx)(`div`,{className:`text-center text-muted-foreground`,children:(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.skills.page.loading.details`)})})}):(0,$.jsxs)(Rr,{outerClassName:`h-full`,className:`w-full`,children:[(0,$.jsxs)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(Xr,{actions:(0,$.jsx)(K,{onClick:we,disabled:h||P||!he,size:`sm`,"aria-busy":P,children:e(P?`settings.common.actions.saving`:p?`settings.skills.page.actions.createSkill`:`settings.common.actions.saveChanges`)}),children:(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate flex items-center gap-2`,children:p?e(`settings.skills.page.title.newSkill`):n}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:f?e(`settings.skills.page.subtitle.skillLocation`,{location:_e(Au(f.scope,f.source))}):e(`settings.skills.page.subtitle.newSkill`)})]})}),(0,$.jsx)(`div`,{"data-settings-item":`skills.basic-information`,children:(0,$.jsx)(X,{label:e(`settings.skills.page.section.basicInformation`),cardClassName:`p-3`,children:(0,$.jsxs)(`div`,{className:`space-y-3`,children:[p&&(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.skills.page.field.skillNameLocation`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground ml-2`,children:e(`settings.skills.page.field.skillNameHint`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[(0,$.jsx)(En,{value:g,onChange:e=>_(e.target.value.toLowerCase().replace(/\s+/g,`-`)),placeholder:e(`settings.skills.page.field.skillNamePlaceholder`),className:`h-7 w-40 px-2`}),(0,$.jsxs)(Cn,{value:Au(v,b),onValueChange:e=>{let t=ju(e);y(t.scope),x(t.source===`agents`?`agents`:`opencode`)},children:[(0,$.jsxs)(bn,{className:`w-fit gap-1.5`,children:[v===`user`?(0,$.jsx)(Y,{name:`user-3`,className:`h-3.5 w-3.5`}):(0,$.jsx)(Y,{name:`folder`,className:`h-3.5 w-3.5`}),b===`agents`?(0,$.jsx)(Y,{name:`robot-2`,className:`h-3.5 w-3.5`}):null,(0,$.jsx)(`span`,{children:_e(Au(v,b))})]}),(0,$.jsx)(xn,{align:`start`,children:ku.map(e=>(0,$.jsx)(vn,{value:e.value,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.scope===`user`?(0,$.jsx)(Y,{name:`user-3`,className:`h-3.5 w-3.5`}):(0,$.jsx)(Y,{name:`folder`,className:`h-3.5 w-3.5`}),e.source===`agents`?(0,$.jsx)(Y,{name:`robot-2`,className:`h-3.5 w-3.5`}):null,(0,$.jsx)(`span`,{children:_e(e.value)})]}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground ml-6`,children:ve(e.value)})]})},e.value))})]})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`span`,{className:`typography-ui-label text-foreground`,children:[e(`settings.common.field.description`),` `,(0,$.jsx)(`span`,{className:`text-[var(--status-error)]`,children:`*`})]}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground ml-2`,children:e(`settings.skills.page.field.descriptionHint`)}),(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(zr,{embedded:!0,value:S,onChange:e=>Se(e.target.value),placeholder:e(`settings.skills.page.field.descriptionPlaceholder`),rows:2,className:`w-full resize-none min-h-[60px] max-h-32 bg-transparent`,disabled:h})})]})]})})}),(0,$.jsx)(`div`,{"data-settings-item":`skills.instructions`,children:(0,$.jsx)(X,{label:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{children:e(`settings.skills.page.section.instructions`)}),(0,$.jsx)(ti,{currentMode:O===`preview`?`preview`:`edit`,onToggle:()=>k(e=>e===`preview`?`edit`:`preview`)})]}),cardClassName:`p-3`,children:(0,$.jsx)(`div`,{className:G(`overflow-hidden bg-background`,Hu),children:O===`preview`?(0,$.jsx)(Rr,{outerClassName:`h-full`,className:`h-full`,children:(0,$.jsx)(`div`,{className:`min-h-full px-4 py-3`,children:(0,$.jsx)(Ur,{content:E,className:`typography-markdown-body`,stripFrontmatter:!0,enableFileReferences:!1})})}):(0,$.jsx)(Yr,{value:E,onChange:Ce,readOnly:h,extensions:be,className:`h-full`,enableSearch:!0})})})}),(0,$.jsx)(`div`,{"data-settings-item":`skills.supporting-files`,children:(0,$.jsx)(X,{label:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{children:e(`settings.skills.page.section.supportingFiles`)}),(0,$.jsxs)(K,{variant:`outline`,size:`xs`,className:`!font-normal gap-1`,onClick:Te,disabled:h,children:[(0,$.jsx)(Y,{name:`add`,className:`h-3.5 w-3.5`}),` `,e(`settings.skills.page.actions.addFile`)]})]}),cardClassName:`p-3`,children:(()=>{let t=p?M:A;return t.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground py-1.5`,children:e(`settings.skills.page.supportingFiles.empty`)}):(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:t.map(t=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2 py-1.5 cursor-pointer group`,onClick:()=>Ee(t.path),children:[(0,$.jsx)(Y,{name:`file`,className:`h-3.5 w-3.5 text-muted-foreground flex-shrink-0`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:t.path}),p&&(0,$.jsx)(`span`,{className:`typography-micro text-[var(--status-warning)] bg-[var(--status-warning)]/10 px-1.5 py-0.5 rounded flex-shrink-0`,children:e(`settings.skills.page.badge.pending`)}),!h&&(0,$.jsx)(K,{size:`sm`,variant:`ghost`,className:`h-5 w-5 px-0 flex-shrink-0 text-muted-foreground hover:text-[var(--status-error)] opacity-0 group-hover:opacity-100 transition-opacity`,onClick:e=>{e.stopPropagation(),Oe(t.path)},children:(0,$.jsx)(Y,{name:`delete-bin`,className:`h-3 w-3`})})]},t.path))})})()})})]}),(0,$.jsx)(hn,{open:ue!==null,onOpenChange:e=>{!e&&!pe&&fe(null)},children:(0,$.jsxs)(fn,{className:`max-w-md`,children:[(0,$.jsxs)(un,{children:[(0,$.jsx)(pn,{children:e(`settings.skills.page.deleteFileDialog.title`)}),(0,$.jsx)(mn,{children:e(`settings.skills.page.deleteFileDialog.description`,{path:ue??``})})]}),(0,$.jsxs)(dn,{children:[(0,$.jsx)(K,{size:`sm`,variant:`ghost`,onClick:()=>fe(null),disabled:pe,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(K,{size:`sm`,variant:`destructive`,onClick:async()=>{if(!ue||!n)return;me(!0);let{deleteSupportingFile:t}=Ra.getState();if(await t(n,ue)){q.success(e(`settings.skills.page.toast.fileDeleted`,{path:ue}));let t=await r(n);t&&j(t.sources.md.supportingFiles||[]),fe(null)}else q.error(e(`settings.skills.page.toast.deleteFileFailed`));me(!1)},disabled:pe,children:e(`settings.common.actions.delete`)})]})]})}),(0,$.jsx)(hn,{open:ee,onOpenChange:e=>{H(e),e||ae(null)},children:(0,$.jsxs)(fn,{className:`max-w-3xl max-h-[85vh] flex flex-col`,children:[(0,$.jsx)(Xr,{className:`pr-8`,actions:(0,$.jsx)(K,{size:`sm`,onClick:De,disabled:oe||!ge,children:e(ie?`settings.common.actions.saveChanges`:`settings.skills.page.actions.createFile`)}),children:(0,$.jsxs)(un,{className:`flex-shrink-0`,children:[(0,$.jsx)(pn,{children:e(ie?`settings.skills.page.fileDialog.titleEdit`:`settings.skills.page.fileDialog.titleAdd`)}),(0,$.jsx)(mn,{children:e(ie?`settings.skills.page.fileDialog.descriptionEdit`:`settings.skills.page.fileDialog.descriptionAdd`)})]})}),oe?(0,$.jsx)(`div`,{className:`flex-1 flex items-center justify-center py-8`,children:(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:e(`settings.skills.page.loading.fileContent`)})}):(0,$.jsxs)(`div`,{className:`space-y-4 flex-1 min-h-0 flex flex-col pt-2`,children:[(0,$.jsxs)(`div`,{className:`space-y-2 flex-shrink-0`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label font-medium text-foreground`,children:e(`settings.skills.page.fileDialog.field.filePath`)}),(0,$.jsx)(En,{value:te,onChange:e=>ne(e.target.value),placeholder:e(`settings.skills.page.fileDialog.field.filePathPlaceholder`),className:`text-foreground placeholder:text-muted-foreground focus-visible:ring-[var(--primary-base)]`,disabled:ie!==null}),!ie&&(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground`,children:e(`settings.skills.page.fileDialog.field.filePathHint`)})]}),(0,$.jsxs)(`div`,{className:`space-y-2 flex-1 min-h-0 flex flex-col`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label font-medium text-foreground flex-shrink-0`,children:e(`settings.skills.page.fileDialog.field.content`)}),(0,$.jsx)(`div`,{className:`h-[45vh] min-h-[250px] max-h-[55vh] overflow-hidden rounded-md border border-[var(--surface-subtle)] bg-background`,children:(0,$.jsx)(Yr,{value:U,onChange:re,extensions:xe,className:`h-full`,enableSearch:!0})})]})]}),(0,$.jsx)(dn,{className:`mt-4`,children:(0,$.jsx)(K,{size:`sm`,variant:`ghost`,onClick:()=>{H(!1),ae(null)},children:e(`settings.common.actions.cancel`)})})]})})]})},Ju=e=>{let t=(0,qi.c)(2),{view:n}=e,r=n===void 0?`installed`:n,i;return t[0]===r?i=t[1]:(i=r===`catalog`?(0,$.jsx)(Bu,{}):(0,$.jsx)(qu,{}),t[0]=r,t[1]=i),i};function Yu(){}var Xu=e=>{let t=(0,qi.c)(26),{onItemSelect:n}=e,{t:r}=He(),i=Lt(Zu),a=Lt(Qu),o=W($u),s=W(ed),c=Q.useRef(null),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=new Set,t[0]=l):l=t[0];let u=Q.useRef(l),d;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(d=N(),t[1]=d):d=t[1];let f=d,p=td,m,h;t[2]!==a||t[3]!==i||t[4]!==o||t[5]!==s?(m=()=>{let e=new Set(i.map(nd)),t=c.current;if(t)for(let n of e)t.has(n)||u.current.add(n);if(c.current=e,a&&u.current.delete(a)){s(a);return}if(i.length===0){o!==null&&s(null);return}o&&i.some(e=>e.id===o)||s(i[0].id)},h=[a,i,o,s],t[2]=a,t[3]=i,t[4]=o,t[5]=s,t[6]=m,t[7]=h):(m=t[6],h=t[7]),Q.useEffect(m,h);let g;t[8]!==i.length||t[9]!==r?(g=r(`settings.projects.sidebar.total`,{count:i.length}),t[8]=i.length,t[9]=r,t[10]=g):g=t[10];let _;t[11]===g?_=t[12]:(_=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:g}),t[11]=g,t[12]=_);let v;t[13]===r?v=t[14]:(v=!f&&(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`icon`,className:`h-7 w-7 -my-1 text-muted-foreground`,onClick:p,"aria-label":r(`settings.projects.sidebar.actions.addProject`),children:(0,$.jsx)(Y,{name:`add`,className:`size-4`})}),t[13]=r,t[14]=v);let y;t[15]!==_||t[16]!==v?(y=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2 px-[var(--yuri-settings-row-inset)]`,children:[_,v]}),t[15]=_,t[16]=v,t[17]=y):y=t[17];let b;t[18]!==n||t[19]!==i||t[20]!==o||t[21]!==s?(b=i.length>0?(0,$.jsx)(X,{children:i.map(e=>{let t=e.id===o,r=e.icon?Sn[e.icon]:null,i=e.color?wn[e.color]:void 0,a=(0,$.jsx)(Y,{name:r??`folder`,className:`h-4 w-4`,style:i?{color:i}:void 0}),c=(0,$.jsx)(`span`,{className:G(`flex size-5 shrink-0 items-center justify-center overflow-hidden`,t?`text-foreground`:`text-muted-foreground`),children:e.iconImage?(0,$.jsx)(yn,{project:e,className:`size-full object-contain`,fallback:a}):a});return(0,$.jsx)(Uo,{title:e.path.split(/[\\/]/).filter(Boolean).at(-1)||e.path,icon:c,selected:t,onSelect:()=>{s(e.id),n?.()}},e.id)})}):null,t[18]=n,t[19]=i,t[20]=o,t[21]=s,t[22]=b):b=t[22];let x;return t[23]!==y||t[24]!==b?(x=(0,$.jsx)(Go,{variant:`background`,header:y,children:b}),t[23]=y,t[24]=b,t[25]=x):x=t[25],x};function Zu(e){return e.projects}function Qu(e){return e.activeProjectId}function $u(e){return e.settingsProjectsSelectedId}function ed(e){return e.setSettingsProjectsSelectedId}function td(){Mt.requestDirectoryDialog()}function nd(e){return e.id}var rd=()=>{let e=(0,qi.c)(18),{t}=He(),n=Lt(id),r=Lt(ad),i=W(od),a=W(sd),o;bb0:{if(!i){o=null;break bb0}let t;e[0]!==n||e[1]!==i?(t=n.find(e=>e.id===i)??null,e[0]=n,e[1]=i,e[2]=t):t=e[2],o=t}let s=o,c,l;e[3]!==n||e[4]!==i||e[5]!==a?(c=()=>{if(n.length===0){a(null);return}i&&n.some(e=>e.id===i)||a(n[0].id)},l=[n,i,a],e[3]=n,e[4]=i,e[5]=a,e[6]=c,e[7]=l):(c=e[6],l=e[7]),Q.useEffect(c,l);let u;e[8]!==s||e[9]!==r?(u=async e=>{s&&r(s.id,{label:e.label,icon:e.icon,color:e.color,iconBackground:e.iconBackground,defaultModel:e.defaultModel??null})},e[8]=s,e[9]=r,e[10]=u):u=e[10];let d=u;if(!s){let n;e[11]===t?n=e[12]:(n=t(`settings.projects.page.empty.noProjects`),e[11]=t,e[12]=n);let r;return e[13]===n?r=e[14]:(r=(0,$.jsx)(Rr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-4xl p-3 sm:p-6 sm:pt-8`,children:(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:n})})}),e[13]=n,e[14]=r),r}let f;return e[15]!==d||e[16]!==s?(f=(0,$.jsx)(Rr,{outerClassName:`h-full`,className:`w-full bg-background`,children:(0,$.jsx)(`div`,{className:`mx-auto w-full max-w-4xl p-3 sm:p-6 sm:pt-8`,children:(0,$.jsx)(Si,{project:s,onIdentitySave:d})})}),e[15]=d,e[16]=s,e[17]=f):f=e[17],f};function id(e){return e.projects}function ad(e){return e.updateProjectMeta}function od(e){return e.settingsProjectsSelectedId}function sd(e){return e.setSettingsProjectsSelectedId}var cd=t(Ki(),1),ld={justNowMinutes:1,minutes:60,hours:24,days:30,months:12},ud=6e4,dd=60*ud,fd=24*dd,pd=30*fd;function md(e,t={}){if(typeof e!=`number`||!Number.isFinite(e))return``;let n=t.now??Date.now(),r=t.buckets??ld,i=e-n,a=Math.abs(i),o=new Intl.RelativeTimeFormat(t.locale,{numeric:`auto`});return a<r.justNowMinutes*ud?o.format(0,`second`):a<r.minutes*ud?o.format(Math.round(i/ud),`minute`):a<r.hours*dd?o.format(Math.round(i/dd),`hour`):a<r.days*fd?o.format(Math.round(i/fd),`day`):a<r.months*pd?o.format(Math.round(i/pd),`month`):o.format(Math.round(i/(12*pd)),`year`)}var hd=`relay_identity_changed`,gd=class extends Error{code=hd;expectedServerId;actualServerId;constructor(e,t){super(`Relay identity changed (expected ${e}, got ${t||`unknown`})`),this.name=`RelayIdentityChangedError`,this.expectedServerId=e,this.actualServerId=t}},_d=new Map,vd=e=>{let t=e.trim();if(!t)throw Error(`Relay serverId is required`);return`relay:${t}`},yd=e=>{let t={Accept:`application/json`},n=typeof e.clientToken==`string`?e.clientToken.trim():``;if(n&&(t.Authorization=`Bearer ${n}`),e.requestHeaders)for(let[n,r]of Object.entries(e.requestHeaders))!n.trim()||!r.trim()||n.trim().toLowerCase()!==`authorization`&&(t[n.trim()]=r.trim());return t},bd=e=>({files:e?.files?.length??0,directories:e?.directories?.length??0,deletes:e?.deletes?.length??0,totalBytes:e?.totalBytes??0}),xd=async e=>{C()&&await w(`desktop_sync_runs_append`,{record:e})},Sd=async(e,t)=>{if(!t)return;let n=await t().catch(()=>null),r=typeof n?.serverId==`string`?n.serverId.trim():``;if(r&&r!==e)throw new gd(e,r)},Cd=e=>({ok:!0,files:0,directories:0,deletes:e.deletes.length,totalBytes:0,agentsRoot:null,providerCredentials:null,plan:e}),wd=e=>{let t=e?.selectionShape;if(!t)throw Error(`Local sync inventory missing selectionShape (update the Yuri desktop app)`);return t},Td=(e,t)=>{let n=$n(e,{includeProviderCredentials:!1}),r=t.selections;return{fileGroups:r?.fileGroups??n.fileGroups,singleFiles:r?.singleFiles??n.singleFiles,directories:r?.directories??n.directories,agentsRoot:r?.agentsRoot!==!1,providerCredentials:r?.providerCredentials===!0,magpie:r?.magpie===!0}},Ed=(e,t,n)=>{let r=e.inventory&&typeof e.inventory==`object`?e.inventory:null;if(n.providerCredentials&&(!r||!Object.hasOwn(r,`providerCredentials`)))throw Error(`Provider credential inventory is missing`);if(n.magpie&&!r?.magpie?.available)throw Error(`Magpie source configuration is unavailable`);return{direction:`pull`,magpieAvailable:r?.magpie?.available===!0,magpie:n.magpie&&r?.magpie?.available?{bytes:0}:null,files:r?.files??t?.files??[],directories:r?.directories??t?.directories??[],agentsRoot:n.agentsRoot?r?.agentsRoot??null:null,providerCredentials:n.providerCredentials?r?.providerCredentials??null:null,deletes:t?.deletes??[],totalBytes:t?.totalBytes??0,selections:n}},Dd=(e,t)=>({...e,direction:`push`,providerCredentials:t.providerCredentials?e.providerCredentials:null,magpie:t.magpie?e.magpie:null,agentsRoot:t.agentsRoot?e.agentsRoot:null,selections:t}),Od=e=>e.files.length>0||e.directories.length>0||!!e.agentsRoot||!!e.providerCredentials||!!e.magpie,kd=(e,t)=>{let r=n({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk}),i=yd(t),a=async(e,t,n)=>{let a=await r.fetch(t,{method:e,headers:{...i,...n===void 0?{}:{"Content-Type":`application/json`}},body:n===void 0?void 0:JSON.stringify(n)}),o=await a.json().catch(()=>({}));if(!a.ok){let n=Error(typeof o.error==`string`?o.error:`Relay sync ${e} ${t} failed (${a.status})`);throw typeof o.code==`string`&&(n.code=o.code),n}return o};return{tunnel:r,async probe(e){let t=await a(`POST`,`/api/yuri/config-sync/probe`,{plan:e});return{remoteExisting:Array.isArray(t.remoteExisting)?t.remoteExisting:[],remoteAgentsRootExists:t.remoteAgentsRootExists===!0,remoteProviderCredentialsExists:t.remoteProviderCredentialsExists===!0,inventory:t.inventory}},async prepare(e,t){await a(`POST`,`/api/yuri/config-sync/prepare`,{plan:e,syncRunId:t})},async putTar(e,t,n){let a=await r.fetch(`/api/yuri/config-sync/put/${encodeURIComponent(e)}?syncRunId=${encodeURIComponent(n)}`,{method:`PUT`,headers:{...i,"Content-Type":e===`credentials`||e===`magpie`?`application/octet-stream`:`application/gzip`},body:new Blob([new Uint8Array(t)],{type:e===`credentials`||e===`magpie`?`application/octet-stream`:`application/gzip`})}),o=await a.json().catch(()=>({}));if(!a.ok){let t=Error(typeof o.error==`string`?o.error:`Relay sync put ${e} failed (${a.status})`);throw typeof o.code==`string`&&(t.code=o.code),t}},async download(e){let t=await r.fetch(`/api/yuri/config-sync/download/${encodeURIComponent(e)}`,{method:`GET`,headers:i});if(!t.ok){let n=await t.json().catch(()=>({})),r=Error(typeof n.error==`string`?n.error:`Relay sync download ${e} failed (${t.status})`);throw typeof n.code==`string`&&(r.code=n.code),r}return new Uint8Array(await t.arrayBuffer())},async finalize(e){let t=await a(`POST`,`/api/yuri/config-sync/finalize`,{syncRunId:e});return Array.isArray(t.magpieWarnings)?t.magpieWarnings.filter(e=>e===`sign_in_required`||e===`plugin_install_failed`||e===`agent_settings_skipped`):[]},async abort(e){await a(`POST`,`/api/yuri/config-sync/abort`,{syncRunId:e}).catch(()=>void 0)},close(){r.close()}}},Ad=async(e,t,n,r)=>{if(_d.has(e)){let t=Error(`Config sync already in progress for ${e}`);throw t.code=`sync_in_progress`,t}let i=crypto.randomUUID(),a=new Date().toISOString();_d.set(e,i);try{let o=await r({syncRunId:i});return await xd({syncRunId:i,targetId:e,stage:t,direction:n,startedAt:a,endedAt:new Date().toISOString(),result:`success`,summary:bd(o.plan)}),{...o,syncRunId:i}}catch(r){throw await xd({syncRunId:i,targetId:e,stage:t,direction:n,startedAt:a,endedAt:new Date().toISOString(),result:`failure`,summary:bd(null),error:r instanceof Error?r.message:String(r)}).catch(()=>void 0),r}finally{_d.get(e)===i&&_d.delete(e)}},jd=async(e,t)=>{let n=await ur({direction:e,targetKind:`relay`}),r=wd(n),i=Td(r,t),a=e===`push`?await ur({direction:e,selections:i,targetKind:`relay`}):n;if(e===`push`&&!a)throw Error(`Local sync inventory unavailable`);return{selectionShape:r,selections:i,localPlan:a}},Md=async(e,t={},n={})=>{let r=e.relay,i=vd(r.serverId),a=t.direction===`pull`?`pull`:`push`;return Ad(i,`preview`,a,async()=>{await Sd(r.serverId,n.refreshCandidates);let{selectionShape:i,selections:o,localPlan:s}=await jd(a,t),c=kd(r,e);try{if(a===`pull`){let e=await c.probe({selections:o});return{plan:Ed(e,s,o),remoteExisting:e.remoteExisting,remoteAgentsRootExists:e.remoteAgentsRootExists,remoteProviderCredentialsExists:e.remoteProviderCredentialsExists,selectionShape:i}}let e=Dd(s,o),t=await c.probe(e);return{plan:e,remoteExisting:t.remoteExisting,remoteAgentsRootExists:t.remoteAgentsRootExists,remoteProviderCredentialsExists:t.remoteProviderCredentialsExists,selectionShape:s?.selectionShape??i}}finally{c.close()}})},Nd=async(e,t={},n={})=>{let r=e.relay,i=vd(r.serverId),a=t.direction===`pull`?`pull`:`push`;return Ad(i,`apply`,a,async({syncRunId:i})=>{await Sd(r.serverId,n.refreshCandidates);let{selections:o,localPlan:s}=await jd(a,t),c=kd(r,e);try{if(a===`pull`){let e=Ed(await c.probe({selections:o}),s,o);if(!Od(e))return Cd(e);let t=e.files.length>0||e.directories.length>0?await c.download(`config`):null,n=e.agentsRoot?await c.download(`agents`):null,r=e.providerCredentials?await c.download(`credentials`):null,a=e.magpie?await c.download(`magpie`):null;if(!C())throw Error(`Relay pull apply requires the Yuri desktop app`);let l=await w(`desktop_relay_sync_apply_local`,{syncRunId:i,plan:e,configTar:t,agentsTar:n,credentialPayload:r,magpiePayload:a});if(!l?.ok)throw Error(`Relay pull local apply failed`);return{...l,plan:e}}let e=Dd(s,o);if(!Od(e))return Cd(e);if(!C())throw Error(`Relay push apply requires the Yuri desktop app`);let t=await w(`desktop_relay_sync_pack_local`,{plan:e});if(!t)throw Error(`Relay push local pack failed`);await c.prepare(e,i);let n=[];try{if(e.magpie){if(!t.magpiePayload?.byteLength)throw Error(`Magpie transfer incomplete`);await c.putTar(`magpie`,t.magpiePayload,i)}t.configTar&&t.configTar.byteLength>0&&await c.putTar(`config`,t.configTar,i),t.agentsTar&&t.agentsTar.byteLength>0&&await c.putTar(`agents`,t.agentsTar,i),t.credentialPayload&&t.credentialPayload.byteLength>0&&await c.putTar(`credentials`,t.credentialPayload,i),n=await c.finalize(i)}catch(e){throw await c.abort(i),e}return{ok:!0,files:e.files.length,directories:e.directories.length,deletes:e.deletes.length,totalBytes:e.totalBytes,agentsRoot:e.agentsRoot?{fileCount:e.agentsRoot.fileCount}:null,providerCredentials:e.providerCredentials?{bytes:e.providerCredentials.bytes}:null,...n.length?{magpieWarnings:n}:{},plan:e}}finally{c.close()}})},Pd=()=>{let{t:e}=He(),t=E()&&m(),[n,r]=Q.useState(!1),[i,a]=Q.useState(!1),[o,s]=Q.useState(``),[l,u]=Q.useState(``),[d,f]=Q.useState(!1),[h,g]=Q.useState(null),[v,y]=Q.useState(!0),[b,x]=Q.useState(!1),[S,C]=Q.useState(null),[w,T]=Q.useState(null);Q.useEffect(()=>{if(!t){y(!1);return}let n=!1;return(async()=>{try{let t=await p(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(!t.ok)throw Error(e(`settings.yuri.desktopNetwork.error.loadFailed`));let i=await t.json().catch(()=>null);if(n)return;let o=i?.desktopLanAccessEnabled===!0,c=typeof i?.desktopUiPassword==`string`?i.desktopUiPassword:``;r(o),a(o),s(c),u(c),f(i?.desktopLanAccessActive===!0),g(typeof i?.desktopLanAccessBlockedReason==`string`?i.desktopLanAccessBlockedReason:null),C(null)}catch(t){n||C(t instanceof Error?t.message:e(`settings.yuri.desktopNetwork.error.loadFailed`))}finally{n||y(!1)}})(),()=>{n=!0}},[t,e]),Q.useEffect(()=>{if(!t||!i){T(null);return}let e=!1;return(async()=>{let t=await _();e||T(t)})(),()=>{e=!0}},[i,t]);let O=i!==n||l!==o,k=Q.useMemo(()=>{if(typeof window>`u`)return null;let e=c()||window.location.href,t=0;try{t=Number(new URL(e).port)}catch{t=Number(window.location.port)}return Number.isFinite(t)&&t>0?t:null},[]),A=i&&d&&w&&k?`http://${w}:${k}`:null,j=i&&!l.trim(),M=n&&!d&&h===`missing-password`,N=v||b||!O||j,P=Q.useCallback(()=>{a(e=>!e)},[]),F=Q.useCallback(e=>{u(e),e.trim()||a(!1)},[]),I=Q.useCallback(async()=>{if(O){x(!0),C(null);try{if(!(await p(`/api/config/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({desktopLanAccessEnabled:i,desktopUiPassword:l})})).ok)throw Error(e(`settings.yuri.desktopNetwork.error.saveFailed`));if(r(i),s(l),!await D())throw Error(e(`settings.yuri.desktopNetwork.error.savedRestartFailed`))}catch(t){C(t instanceof Error?t.message:e(`settings.yuri.desktopNetwork.error.saveFailed`)),x(!1)}}},[l,i,O,e]);return t?(0,$.jsxs)(X,{className:`yuri-settings-detail-group`,label:e(`settings.yuri.desktopNetwork.title`),actions:(0,$.jsx)(K,{type:`button`,size:`sm`,onClick:I,disabled:N,"aria-busy":b,children:e(b?`settings.common.actions.saving`:`settings.yuri.desktopNetwork.actions.saveAndRestart`)}),children:[(0,$.jsx)(Z,{itemId:`remote-instances.desktop-ui-password`,label:(0,$.jsx)(`label`,{htmlFor:`desktop-ui-password`,children:e(`settings.yuri.desktopPassword.field.password`)}),description:e(`settings.yuri.desktopPassword.field.passwordDescription`),children:(0,$.jsx)(En,{id:`desktop-ui-password`,type:`password`,className:`max-w-sm`,value:l,onChange:e=>F(e.target.value),placeholder:e(`settings.yuri.desktopPassword.field.passwordPlaceholder`),disabled:v||b,required:i,"aria-invalid":j})}),(0,$.jsxs)(`div`,{"data-settings-item":`remote-instances.desktop-lan-access`,className:`yuri-settings-group-row yuri-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,onClick:P,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),P())},children:[(0,$.jsxs)(`div`,{className:`yuri-settings-split-row-copy`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.yuri.desktopNetwork.field.allowLanAccess`)}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:e(`settings.yuri.desktopNetwork.field.allowLanAccessDescription`)}),(0,$.jsx)(`div`,{className:`typography-meta text-[var(--status-warning)]/85`,children:e(`settings.yuri.desktopNetwork.field.warning`)}),j||M?(0,$.jsx)(`div`,{className:`typography-meta text-[var(--status-warning)]/85`,children:e(`settings.yuri.desktopNetwork.field.passwordRequiredWarning`)}):null]}),(0,$.jsx)(`div`,{className:`yuri-settings-split-row-control`,children:(0,$.jsx)(gn,{checked:i,onChange:P,ariaLabel:e(`settings.yuri.desktopNetwork.field.allowLanAccessAria`),disabled:v||b})})]}),S?(0,$.jsx)(`div`,{className:`yuri-settings-group-row typography-meta text-[var(--status-error)]`,children:S}):null,A?(0,$.jsxs)(`div`,{className:`yuri-settings-group-row typography-meta text-muted-foreground`,children:[e(O&&!n?`settings.yuri.desktopNetwork.hint.openAfterRestart`:`settings.yuri.desktopNetwork.hint.openNow`),(0,$.jsx)(`span`,{className:`font-mono text-foreground`,children:A})]}):null]}):null},Fd=`wss://relay.openchamber.dev/ws`,Id=`yuri.pairing.relayUrl.v1`,Ld=e=>{if(typeof e!=`string`||!e.trim())return null;try{let t=new URL(e.trim());return t.protocol!==`ws:`&&t.protocol!==`wss:`||t.username||t.password?null:(t.username=``,t.password=``,t.hash=``,t.search=``,t.toString())}catch{return null}},Rd=(e=typeof window>`u`?null:window.localStorage)=>{if(!e)return null;try{return Ld(e.getItem(Id))}catch{return null}},zd=(e,t=typeof window>`u`?null:window.localStorage)=>{if(!t)return;let n=Ld(e);if(n)try{t.setItem(Id,n)}catch{}},Bd=`https://github.com/yee94/yuri/tree/main/packages/relay-server`,Vd=()=>Math.floor(2e4+Math.random()*3e4),Hd=e=>{if(!Number.isFinite(e)||e<0)return`0 B`;if(e<1024)return`${e} B`;let t=[`KB`,`MB`,`GB`,`TB`],n=e/1024;for(let e of t){if(n<1024||e===t[t.length-1])return`${n.toFixed(n>=10?0:1)} ${e}`;n/=1024}return`${e} B`},Ud={fileGroups:[],singleFiles:[],directories:[],agentsRoot:!0,providerCredentials:!1},Wd=e=>{let t=e.selectionShape;if(!t||typeof t!=`object`)return null;let n=typeof t.fileGroups==`number`?t.fileGroups:null,r=typeof t.singleFiles==`number`?t.singleFiles:null,i=typeof t.directories==`number`?t.directories:null;return n===null||r===null||i===null||n<0||r<0||i<0?null:{fileGroups:n,singleFiles:r,directories:i}},Gd=(e,t)=>e.fileGroups.length===t.fileGroups&&e.singleFiles.length===t.singleFiles&&e.directories.length===t.directories,Kd=[`settings.remoteInstances.page.sync.step.scanLocal`,`settings.remoteInstances.page.sync.step.compareRemote`,`settings.remoteInstances.page.sync.step.confirm`],qd=({open:e,instanceId:t,targetKind:n=`ssh`,relayHost:r=null,onOpenChange:i})=>{let{t:a}=He(),[o,s]=Q.useState(1),[c,l]=Q.useState(`scanning-local`),[u,d]=Q.useState(`push`),[f,p]=Q.useState(Ud),[m,h]=Q.useState(null),[g,_]=Q.useState(null),[v,y]=Q.useState(null),[b,x]=Q.useState(null),[S,C]=Q.useState(null),w=Q.useRef(Ud),T=Q.useRef(0),E=Q.useRef(Promise.resolve()),D=m!=null&&Gd(f,m),O=ze(()=>{T.current+=1,s(1),l(`scanning-local`),d(`push`),p(Ud),h(null),_(null),y(null),x(null),C(null),w.current=Ud}),k=ze(async(e=u,i=f)=>{if(!t)return;let o=++T.current,c=E.current,d;E.current=new Promise(e=>{d=e}),v||s(2),l(`comparing-remote`),x(null),C(null);try{if(await c,o!==T.current)return;let u=n===`relay`?r?await Md(r,{direction:e,selections:i}):null:await Dr(t,{targetKind:n,direction:e,selections:i});if(o!==T.current)return;if(!u){x(a(`settings.remoteInstances.page.sync.state.unavailable`)),C(2),l(`error`);return}y(u),w.current=i,s(3),l(`review`)}catch(e){if(o!==T.current)return;console.error(`[remote-instances] config sync compare-remote failed`,e),x(e instanceof Error?e.message:String(e)),C(2),l(`error`)}finally{d()}}),A=ze(async(e=u,r=f)=>{if(!t)return;s(1);let i=++T.current;l(`scanning-local`),x(null),C(null),_(null),y(null);try{let t=m!=null&&Gd(r,m),o=await ur(t?{targetKind:n,direction:e,selections:r}:{targetKind:n,direction:e});if(i!==T.current)return;if(!o){h(null),x(a(`settings.remoteInstances.page.sync.state.unavailable`)),C(1),l(`error`);return}let s=Wd(o);if(!s){h(null),p(Ud),x(a(`settings.remoteInstances.page.sync.state.unavailable`)),C(1),l(`error`);return}h(s);let c=t?r:$n(s,{includeProviderCredentials:!1});p(c),_(o),await k(e,c)}catch(e){if(i!==T.current)return;console.error(`[remote-instances] config sync scan-local failed`,e),x(e instanceof Error?e.message:String(e)),C(1),l(`error`)}});Q.useEffect(()=>{if(!(!e||!t))return A(`push`),()=>{T.current+=1}},[e,t,n,r,A]),Q.useEffect(()=>{e||O()},[e,O]);let j=Q.useMemo(()=>new Set(v?.remoteExisting??[]),[v]),M=v?.plan??g,N=!!(M&&(M.files.length>0||M.directories.length>0||M.agentsRoot!=null||M.providerCredentials!=null||M.magpie!=null)),P=c===`applying`,F=v!=null,I=M?M.deletes.length+(M.agentsRoot&&v?.remoteAgentsRootExists?1:0):0,L=ze(()=>{if(S===2){k(u,f);return}A(u,f)}),R=ze(e=>{if(e===u||P)return;d(e),y(null),_(null);let t={...f,magpie:!1};p(t),A(e,t)}),z=ze(async()=>{if(!(!t||!N||P||c!==`review`)){l(`applying`);try{let e=n===`relay`?r?await Nd(r,{direction:u,selections:w.current}):null:await An(t,{targetKind:n,direction:u,selections:w.current});if(!e)throw Error(`Sync bridge unavailable`);let o=[...e.magpieWarnings?.includes(`sign_in_required`)?[a(`settings.remoteInstances.page.sync.magpie.signInRequired`)]:[],...e.magpieWarnings?.includes(`plugin_install_failed`)?[a(`settings.remoteInstances.page.sync.magpie.pluginInstallFailed`)]:[],...e.magpieWarnings?.includes(`agent_settings_skipped`)?[a(`settings.remoteInstances.page.sync.magpie.agentsSkipped`)]:[]];o.length?q.warning(a(`settings.remoteInstances.page.sync.toast.success`),{description:o.join(`
|
|
23
|
+
`)}):q.success(a(`settings.remoteInstances.page.sync.toast.success`)),i(!1)}catch(e){console.error(`[remote-instances] config sync apply failed`,e),q.error(a(`settings.remoteInstances.page.sync.toast.failed`),{description:e instanceof Error?e.message:String(e)}),l(`review`)}}}),B=e=>c===`error`&&S!=null?e<S?`done`:e===S?`active`:`pending`:c===`review`||c===`applying`||e<o?`done`:e===o?`active`:`pending`;return(0,$.jsx)(hn,{open:e,onOpenChange:i,children:(0,$.jsxs)(fn,{className:`min-h-0 sm:max-w-2xl`,children:[(0,$.jsxs)(un,{className:`shrink-0`,children:[(0,$.jsx)(pn,{children:a(`settings.remoteInstances.page.sync.title`)}),(0,$.jsx)(mn,{children:a(`settings.remoteInstances.page.sync.description`)})]}),(0,$.jsxs)(`div`,{className:`shrink-0 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(K,{type:`button`,size:`xs`,variant:u===`push`?`default`:`outline`,className:`!font-normal`,"aria-pressed":u===`push`,disabled:P||c===`comparing-remote`||c===`scanning-local`,onClick:()=>R(`push`),children:a(`settings.remoteInstances.page.sync.direction.push`)}),(0,$.jsx)(K,{type:`button`,size:`xs`,variant:u===`pull`?`default`:`outline`,className:`!font-normal`,"aria-pressed":u===`pull`,disabled:P||c===`comparing-remote`||c===`scanning-local`,onClick:()=>R(`pull`),children:a(`settings.remoteInstances.page.sync.direction.pull`)})]}),(0,$.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-border/60 p-2`,children:[(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:a(`settings.remoteInstances.page.sync.scope.title`)}),D?null:(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:a(c===`scanning-local`||c===`comparing-remote`?`settings.remoteInstances.page.sync.step.scanLocal`:`settings.remoteInstances.page.sync.state.unavailable`)}),[{key:`config`,label:`config.json / opencode.json(c)`,index:0,kind:`fileGroups`},{key:`oh-slim`,label:`oh-my-opencode-slim.json(c)`,index:1,kind:`fileGroups`},{key:`oh-agent`,label:`oh-my-openagent.json(c)`,index:2,kind:`fileGroups`},{key:`agents-md`,label:`AGENTS.md`,index:0,kind:`singleFiles`},{key:`cursor-models`,label:`cursor-models.json`,index:1,kind:`singleFiles`},{key:`agents`,label:`agents/`,index:0,kind:`directories`},{key:`commands`,label:`commands/`,index:1,kind:`directories`},{key:`skills`,label:`skills/`,index:2,kind:`directories`},{key:`plugins`,label:`plugins/`,index:5,kind:`directories`}].filter(e=>m!=null&&e.index<m[e.kind]).map(e=>{let t=f[e.kind][e.index]!==!1;return(0,$.jsxs)(`label`,{className:`flex items-center gap-2 typography-meta`,children:[(0,$.jsx)(gn,{checked:t,disabled:P||!D||!v,ariaLabel:e.label,onChange:t=>{if(!D)return;let n=[...f[e.kind]];n[e.index]=t;let r={...f,[e.kind]:n};p(r),k(u,r)}}),(0,$.jsx)(`span`,{className:`font-mono`,children:e.label})]},e.key)}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 typography-meta`,children:[(0,$.jsx)(gn,{checked:f.agentsRoot,disabled:P||!D||!v,ariaLabel:a(`settings.remoteInstances.page.sync.section.agentsRoot`),onChange:e=>{if(!D)return;let t={...f,agentsRoot:e};p(t),k(u,t)}}),a(`settings.remoteInstances.page.sync.section.agentsRoot`)]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 typography-meta`,children:[(0,$.jsx)(gn,{checked:f.providerCredentials,disabled:P||!D||!v,ariaLabel:a(`settings.remoteInstances.page.sync.section.providerCredentials`),onChange:e=>{if(!D)return;let t={...f,providerCredentials:e};p(t),k(u,t)}}),(0,$.jsx)(`span`,{className:`min-w-0`,title:a(`settings.remoteInstances.page.sync.hint.providerCredentials`),children:(0,$.jsx)(`span`,{className:`truncate`,children:a(`settings.remoteInstances.page.sync.section.providerCredentials`)})})]}),v?.plan.magpieAvailable?(0,$.jsxs)(`label`,{className:`flex items-center gap-2 typography-meta`,children:[(0,$.jsx)(gn,{checked:f.magpie===!0,disabled:P,ariaLabel:a(`settings.remoteInstances.page.sync.section.magpie`),onChange:e=>{let t={...f,magpie:e};p(t),k(u,t)}}),(0,$.jsx)(`span`,{className:`min-w-0`,title:a(`settings.remoteInstances.page.sync.hint.magpie`),children:(0,$.jsx)(`span`,{className:`truncate`,children:a(`settings.remoteInstances.page.sync.section.magpie`)})})]}):null]}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-2`,"aria-busy":c===`scanning-local`||c===`comparing-remote`,children:Kd.map((e,t)=>{let n=t+1,r=B(n);return(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[r===`done`?(0,$.jsx)(Y,{name:`check`,className:`h-3.5 w-3.5 shrink-0 text-[var(--status-success)]`}):r===`active`?(0,$.jsx)(Y,{name:`refresh`,className:`h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground`}):(0,$.jsx)(`span`,{className:`flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-full border border-border/60 typography-micro text-muted-foreground`,children:n}),(0,$.jsx)(`span`,{className:G(`typography-meta`,r===`pending`?`text-muted-foreground`:`text-foreground`),children:a(e)})]},e)})}),c===`error`?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{className:`typography-meta text-[var(--status-error)]`,children:a(`settings.remoteInstances.page.sync.state.error`,{message:b||``})}),(0,$.jsxs)(K,{type:`button`,variant:`outline`,size:`sm`,className:`!font-normal`,onClick:L,children:[(0,$.jsx)(Y,{name:`refresh`,className:`h-3.5 w-3.5`}),a(`settings.remoteInstances.sidebar.actions.retry`)]})]}):null,F&&!N?(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:a(`settings.remoteInstances.page.sync.state.empty`)}):null,F&&N&&M?(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-col gap-3`,children:[(0,$.jsx)(`div`,{className:`overflow-hidden rounded-lg border border-border/60 bg-[var(--surface-elevated)]`,children:(0,$.jsxs)(`div`,{className:`divide-y divide-border/60`,children:[M.files.map(e=>{let t=j.has(e.path);return(0,$.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2`,children:[(0,$.jsx)(Y,{name:`file-text`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono typography-micro text-foreground`,title:e.path,children:[(0,$.jsxs)(`span`,{className:`sr-only`,children:[a(`settings.remoteInstances.page.sync.section.files`),`: `]}),e.path]}),(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums typography-micro text-muted-foreground`,children:Hd(e.bytes)}),(0,$.jsx)(`span`,{className:G(`shrink-0 typography-micro`,t?`text-[var(--status-warning)]`:`text-[var(--status-success)]`),children:a(t?`settings.remoteInstances.page.sync.status.overwrite`:`settings.remoteInstances.page.sync.status.add`)})]},`file:${e.path}`)}),M.directories.map(e=>{let t=j.has(e.path);return(0,$.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2`,children:[(0,$.jsx)(Y,{name:`folder-3-fill`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono typography-micro text-foreground`,title:e.path,children:[(0,$.jsxs)(`span`,{className:`sr-only`,children:[a(`settings.remoteInstances.page.sync.section.directories`),`: `]}),e.path]}),(0,$.jsxs)(`span`,{className:`shrink-0 tabular-nums typography-micro text-muted-foreground`,children:[Hd(e.bytes),` · `,e.fileCount]}),(0,$.jsx)(`span`,{className:G(`shrink-0 typography-micro`,t?`text-[var(--status-warning)]`:`text-[var(--status-success)]`),children:a(t?`settings.remoteInstances.page.sync.status.overwrite`:`settings.remoteInstances.page.sync.status.add`)})]},`dir:${e.path}`)}),M.providerCredentials?(0,$.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2`,children:[(0,$.jsx)(Y,{name:`shield-keyhole`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate typography-micro text-foreground`,children:[(0,$.jsxs)(`span`,{className:`sr-only`,children:[a(`settings.remoteInstances.page.sync.section.providerCredentials`),`: `]}),a(`settings.remoteInstances.page.sync.section.providerCredentials`),(0,$.jsx)(`span`,{className:`ml-2 typography-micro text-muted-foreground`,children:a(`settings.remoteInstances.page.sync.hint.providerCredentials`)})]}),(0,$.jsx)(`span`,{className:`shrink-0 tabular-nums typography-micro text-muted-foreground`,children:Hd(M.providerCredentials.bytes)}),(0,$.jsx)(`span`,{className:G(`shrink-0 typography-micro`,v?.remoteProviderCredentialsExists?`text-[var(--status-warning)]`:`text-[var(--status-success)]`),children:v?.remoteProviderCredentialsExists?a(`settings.remoteInstances.page.sync.status.overwrite`):a(`settings.remoteInstances.page.sync.status.add`)})]}):null,M.magpie?(0,$.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2`,children:[(0,$.jsx)(Y,{name:`tools`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate typography-micro text-foreground`,title:a(`settings.remoteInstances.page.sync.hint.magpie`),children:[a(`settings.remoteInstances.page.sync.section.magpie`),(0,$.jsx)(`span`,{className:`ml-2 typography-micro text-muted-foreground`,children:a(`settings.remoteInstances.page.sync.hint.magpie`)})]})]}):null,M.agentsRoot?(0,$.jsxs)(`div`,{className:`flex h-8 items-center gap-2 px-2`,children:[(0,$.jsx)(Y,{name:`tools`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate font-mono typography-micro text-foreground`,title:`~/.agents`,children:[(0,$.jsxs)(`span`,{className:`sr-only`,children:[a(`settings.remoteInstances.page.sync.section.agentsRoot`),`: `]}),`~/.agents`]}),(0,$.jsxs)(`span`,{className:`shrink-0 tabular-nums typography-micro text-muted-foreground`,children:[Hd(M.agentsRoot.bytes),` · `,a(`settings.remoteInstances.page.sync.section.agentsRootCount`,{count:M.agentsRoot.fileCount})]}),(0,$.jsx)(`span`,{className:G(`shrink-0 typography-micro`,v?.remoteAgentsRootExists?`text-[var(--status-warning)]`:`text-[var(--status-success)]`),children:v?.remoteAgentsRootExists?a(`settings.remoteInstances.page.sync.status.overwrite`):a(`settings.remoteInstances.page.sync.status.add`)})]}):null]})}),(0,$.jsx)(`div`,{className:`space-y-1 typography-micro text-muted-foreground`,children:I>0?(0,$.jsx)(`div`,{children:a(`settings.remoteInstances.page.sync.note.deletes`,{count:I})}):null})]}):null]}),(0,$.jsxs)(`div`,{className:`shrink-0 space-y-1 typography-micro text-muted-foreground`,children:[(0,$.jsx)(`div`,{children:a(`settings.remoteInstances.page.sync.note.backup`)}),(0,$.jsx)(`div`,{children:a(`settings.remoteInstances.page.sync.note.excluded`)})]}),(0,$.jsxs)(dn,{className:`shrink-0`,children:[(0,$.jsx)(K,{type:`button`,variant:`outline`,size:`sm`,className:`!font-normal`,onClick:()=>i(!1),disabled:P,children:a(`settings.remoteInstances.page.sync.actions.cancel`)}),(0,$.jsxs)(K,{type:`button`,size:`sm`,className:`!font-normal`,onClick:()=>void z(),disabled:!N||P||c!==`review`,children:[(0,$.jsx)(Y,{name:`refresh`,className:G(`h-3.5 w-3.5`,P?`animate-spin`:``)}),a(P?`settings.remoteInstances.page.sync.applying`:`settings.remoteInstances.page.sync.actions.syncNow`)]})]})]})})},Jd=e=>{let t=(e instanceof Error?e.message:String(e)).toLowerCase();return t.includes(`address already in use`)||t.includes(`eaddrinuse`)||t.includes(`port already in use`)},Yd=()=>{if(typeof navigator>`u`)return;let e=(navigator.userAgent||``).toLowerCase();if(e.includes(`mac`))return`macos`;if(e.includes(`win`))return`windows`;if(e.includes(`linux`))return`linux`},Xd=e=>{switch((e||``).toLowerCase()){case`ios`:return`iOS`;case`android`:return`Android`;case`macos`:case`darwin`:return`macOS`;case`windows`:case`win32`:return`Windows`;case`linux`:return`Linux`;default:return null}},Zd=e=>{switch((e||``).toLowerCase()){case`ios`:return`device-ios`;case`android`:return`device-android`;case`macos`:case`darwin`:return`device-macos`;case`windows`:case`win32`:return`device-windows`;case`linux`:return`device-linux`;default:return null}},Qd=e=>{switch(e){case`config_resolved`:return`settings.remoteInstances.page.phase.resolvingConfiguration`;case`auth_check`:return`settings.remoteInstances.page.phase.checkingAuth`;case`master_connecting`:return`settings.remoteInstances.page.phase.establishingSsh`;case`remote_probe`:return`settings.remoteInstances.page.phase.probingRemote`;case`installing`:return`settings.remoteInstances.page.phase.installingYuri`;case`updating`:return`settings.remoteInstances.page.phase.updatingYuri`;case`server_detecting`:return`settings.remoteInstances.page.phase.detectingServer`;case`server_starting`:return`settings.remoteInstances.page.phase.startingServer`;case`forwarding`:return`settings.remoteInstances.page.phase.forwardingPorts`;case`ready`:return`settings.remoteInstances.sidebar.phase.ready`;case`degraded`:return`settings.remoteInstances.page.phase.reconnecting`;case`error`:return`settings.remoteInstances.sidebar.phase.error`;default:return`settings.remoteInstances.sidebar.phase.idle`}},$d=new Set([`config_resolved`,`auth_check`,`master_connecting`,`remote_probe`,`installing`,`updating`,`server_detecting`,`server_starting`,`forwarding`]),ef=e=>!!(e&&$d.has(e)),tf=e=>e===`ready`?`bg-[var(--status-success)] animate-pulse`:e===`error`?`bg-[var(--status-error)] animate-pulse`:e===`degraded`||ef(e)?`bg-[var(--status-warning)] animate-pulse`:`bg-muted-foreground/40`,nf=e=>e.type===`dynamic`?`${e.localHost||`127.0.0.1`}:${e.localPort||0}`:e.type===`remote`?`${e.remoteHost||`127.0.0.1`}:${e.remotePort||0} -> ${e.localHost||`127.0.0.1`}:${e.localPort||0}`:`${e.localHost||`127.0.0.1`}:${e.localPort||0} -> ${e.remoteHost||`127.0.0.1`}:${e.remotePort||0}`,rf=()=>({id:`forward-${Date.now()}-${Math.random().toString(16).slice(2)}`,enabled:!0,type:`local`,localHost:`127.0.0.1`,localPort:Vd(),remoteHost:`127.0.0.1`,remotePort:80}),af=e=>{let t=(0,qi.c)(10),{itemId:n,label:r,description:i,action:a,children:o}=e,s;t[0]!==a||t[1]!==r?(s=a?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-3`,children:[(0,$.jsx)(`div`,{className:`min-w-0`,children:r}),(0,$.jsx)(`div`,{className:`shrink-0`,children:a})]}):r,t[0]=a,t[1]=r,t[2]=s):s=t[2];let c;t[3]===o?c=t[4]:(c=(0,$.jsx)(`div`,{className:`yuri-settings-group-row`,children:o}),t[3]=o,t[4]=c);let l;return t[5]!==i||t[6]!==n||t[7]!==s||t[8]!==c?(l=(0,$.jsx)(X,{itemId:n,className:`yuri-settings-detail-group`,label:s,description:i,children:c}),t[5]=i,t[6]=n,t[7]=s,t[8]=c,t[9]=l):l=t[9],l},of=e=>{switch(e){case`remote`:return`settings.remoteInstances.page.forwardTypeDescription.remote`;case`dynamic`:return`settings.remoteInstances.page.forwardTypeDescription.dynamic`;default:return`settings.remoteInstances.page.forwardTypeDescription.local`}},sf=(e,t)=>{let n=(e||``).trim();return`${!n||n===`127.0.0.1`||n===`::1`?`localhost`:n}:${t||0}`},cf=e=>{let t=(e||``).trim();return!t||t===`0.0.0.0`||t===`::`?`127.0.0.1`:t},lf=e=>{let t=e.match(/^\[(\d{10,})\]\s*(?:\[([A-Z]+)\]\s*)?(.*)$/);if(!t)return e;let n=Number(t[1]);return`[${Number.isFinite(n)?new Date(n).toISOString():t[1]}] [${(t[2]||`INFO`).toUpperCase()}] ${t[3]||``}`},uf=()=>{if(typeof window>`u`)return null;let e=c()||window.location.href;try{let t=Number(new URL(e).port||window.location.port);return Number.isFinite(t)&&t>0?t:null}catch{let e=Number(window.location.port);return Number.isFinite(e)&&e>0?e:null}},df=e=>{try{let t=new URL(e).hostname.toLowerCase();return t===`localhost`||t===`127.0.0.1`||t===`::1`||t===`[::1]`}catch{return!1}},ff=async()=>{let e=U(c())||window.location.origin;if(!E()||!m())return e;let t;try{t=await p(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}})}catch{return e}if(!t.ok||(await t.json().catch(()=>null))?.desktopLanAccessActive!==!0)return e;let n=await _(),r=uf();return!n||!r?e:`http://${n}:${r}`},pf=e=>{let t=e.trim();if(t)try{window.location.assign(t)}catch{window.location.href=t}},mf=e=>{let t=e.sshCommand.trim(),n=e.nickname?.trim(),r=e.portForwards.map(e=>({...e,localHost:e.localHost?.trim()||`127.0.0.1`,localPort:typeof e.localPort==`number`?Math.max(1,Math.min(65535,Math.round(e.localPort))):void 0,remoteHost:e.remoteHost?.trim(),remotePort:typeof e.remotePort==`number`?Math.max(1,Math.min(65535,Math.round(e.remotePort))):void 0}));return{...e,sshCommand:t,...n?{nickname:n}:{nickname:void 0},connectionTimeoutSec:Math.max(5,Math.min(240,Math.round(e.connectionTimeoutSec||60))),localForward:{...e.localForward,bindHost:e.localForward.bindHost===`localhost`||e.localForward.bindHost===`0.0.0.0`?e.localForward.bindHost:`127.0.0.1`,preferredLocalPort:typeof e.localForward.preferredLocalPort==`number`?Math.max(1,Math.min(65535,Math.round(e.localForward.preferredLocalPort))):void 0},remoteYuri:{...e.remoteYuri,preferredPort:typeof e.remoteYuri.preferredPort==`number`?Math.max(1,Math.min(65535,Math.round(e.remoteYuri.preferredPort))):void 0},portForwards:r}},hf=()=>{let{t:e}=He(),{clientAuth:t}=Ae(),i=C(),o=oi(e=>e.instances),l=oi(e=>e.statusesById),u=oi(e=>e.isLoading),d=oi(e=>e.isSaving),f=oi(e=>e.error),p=oi(e=>e.load),m=oi(e=>e.loadImports),h=oi(e=>e.refreshStatuses),g=oi(e=>e.upsertInstance),_=oi(e=>e.createFromCommand),v=oi(e=>e.removeInstance),y=oi(e=>e.connect),b=oi(e=>e.disconnect),x=oi(e=>e.retry),S=W(e=>e.settingsRemoteInstancesSelectedId),w=W(e=>e.setSettingsRemoteInstancesSelectedId),T=Q.useMemo(()=>S&&o.find(e=>e.id===S)||null,[o,S]),[D,O]=Q.useState(null),[k,A]=Q.useState([]),[j,M]=Q.useState(!1),[N,P]=Q.useState(!1),[F,L]=Q.useState(null),[R,z]=Q.useState([]),[ce,le]=Q.useState(!1),[ue,de]=Q.useState(null),[fe,pe]=Q.useState(`ssh`),[me,he]=Q.useState(null),[ge,_e]=Q.useState(null),[ve,ye]=Q.useState(``),[be,xe]=Q.useState(!1),[Se,Ce]=Q.useState({}),[we,Te]=Q.useState(!1),[Ee,De]=Q.useState(!1),[Oe,ke]=Q.useState(()=>Date.now()),[je,Me]=Q.useState([]),[Ne,Pe]=Q.useState({}),[Fe,Ie]=Q.useState(`local`),[Le,Re]=Q.useState(!1),[Be,Ue]=Q.useState(!1),[We,Ke]=Q.useState(0),qe=ir(),[Je,Ye]=Q.useState(``),[Xe,Ze]=Q.useState(null),[Qe,$e]=Q.useState(!1),[et,tt]=Q.useState([]),[nt,rt]=Q.useState([]),[it,at]=Q.useState(!1),[ot,st]=Q.useState(``),ct=Q.useRef(!1),[lt,ut]=Q.useState(null),[dt,ft]=Q.useState(null),[pt,mt]=Q.useState(!1),[ht,gt]=Q.useState(null),[_t,vt]=Q.useState(null),[yt,bt]=Q.useState(null),[xt,St]=Q.useState(null),[Ct,wt]=Q.useState(!1),[Tt,Et]=Q.useState(!1),[Dt,Ot]=Q.useState(`configure`),[kt,At]=Q.useState(!1),[jt,Mt]=Q.useState(`relay`),[Nt,Pt]=Q.useState(!0),[Ft,It]=Q.useState(Fd),[Lt,Rt]=Q.useState(null),[J,zt]=Q.useState(!1),[Bt,Vt]=Q.useState(!1),Ht=Q.useRef(null);Q.useEffect(()=>{J&&Lt&&Ht.current?.focus()},[J,Lt]);let[Ut,Wt]=Q.useState(null),Gt=Q.useMemo(()=>et.filter(e=>!!e.revokedAt).length,[et]),[Kt,qt]=Q.useState(!1),[Jt,Yt]=Q.useState(`ssh user@example.com`),[Xt,Zt]=Q.useState(``);Q.useEffect(()=>{p(),m()},[p,m]);let Qt=Q.useCallback(async()=>{Re(!0);try{let e=await ie();Me(e.hosts||[]),Ie(e.defaultHostId||`local`)}catch(t){q.error(e(`desktopHostSwitcher.error.failedToLoad`),{description:t instanceof Error?t.message:String(t)})}finally{Re(!1)}},[e]);Q.useEffect(()=>{Qt()},[Qt]);let $t=Object.values(l).filter(e=>e.phase===`ready`).map(e=>`${e.id}:${e.localUrl||``}`).sort().join(`|`);Q.useEffect(()=>{$t&&Qt()},[Qt,$t]);let en=Q.useCallback(async(t,n=Fe)=>{Ue(!0);try{return await ne({hosts:t,defaultHostId:n,initialHostChoiceCompleted:!0}),Me(t),Ie(n),!0}catch(t){return q.error(e(`desktopHostSwitcher.error.failedToSave`),{description:t instanceof Error?t.message:String(t)}),!1}finally{Ue(!1)}},[Fe,e]),tn=Q.useMemo(()=>new Set(o.map(e=>e.id)),[o]),nn=Q.useMemo(()=>je.filter(e=>ee(e,tn)),[je,tn]),rn=ze(async()=>{Ze(null);let t=ga(Je);if(!t){Ze(e(`settings.remoteInstances.direct.error.invalidConnectLink`));return}let r=await V().catch(()=>``),i={method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({pairingId:t.pairingId,secret:t.secret,clientLabel:t.label||`Yuri Desktop`,clientKind:`desktop`,deviceName:`Yuri Desktop`,devicePlatform:Yd(),...r?{dedupeKey:`desktop:${r}`}:{}})},a=async e=>{if(!e.ok)return null;let t=await e.json().catch(()=>null);return(typeof t?.clientToken==`string`?t.clientToken.trim():``)||null},o=[...t.candidates].sort((e,t)=>(e.type===`relay`)-+(t.type===`relay`)),s=null;for(let e of o){if(e.type===`relay`){let t=n({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk,...e.grant?{grant:e.grant}:{}});try{let n=await a(await t.fetch(`/api/client-auth/pairing/redeem`,i));if(n){s={kind:`relay`,relay:{relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk},token:n,tunnel:t},t.close();break}}catch{}t.close();continue}let t=U(e.url);if(t)try{let e=await a(await fetch(`${t}/api/client-auth/pairing/redeem`,i));if(e){s={kind:`direct`,url:t,token:e};break}}catch{}}if(!s){Ze(e(`settings.remoteInstances.direct.error.pairingFailed`));return}let c=()=>I(),l=t.candidates.find(e=>e.type===`relay`),u=s.kind===`relay`?s.relay:l?{relayUrl:l.relayUrl,serverId:l.serverId,hostEncPubJwk:l.hostEncPubJwk}:void 0,d=t.candidates.filter(e=>e.type!==`relay`),f=d.map(e=>U(e.url)).find(e=>!!e),p=d.filter(e=>e.type===`lan`).map(e=>U(e.url)).find(e=>!!e),m=s.kind===`direct`?s.url:p||f||null,{token:h}=s,g=m||(u?B(u.serverId):null);if(!g){Ze(e(`settings.remoteInstances.direct.error.invalidConnectLink`));return}let _={url:g,apiUrl:m||void 0,clientToken:h,source:ae,...u?{relay:u}:{}},v=je.find(e=>u?e.relay?.serverId===u.serverId&&e.relay?.relayUrl===u.relayUrl:!e.relay&&U(e.apiUrl||e.url)===g);if(v){let e=je.map(e=>e.id===v.id?{...e,label:t.label||e.label,..._}:e);if(!await en(e,Fe))return}else if(!await en([{id:c(),label:t.label||H(g),..._},...je],Fe))return;Ye(``),Ze(null),$e(!1)}),an=Q.useCallback(async e=>{let t=je.filter(t=>t.id!==e);await en(t,Fe===e?`local`:Fe)},[Fe,je,en]),on=Q.useCallback(async()=>{let t=Jt.trim();if(!t){q.error(e(`settings.remoteInstances.page.toast.sshCommandRequired`));return}let n=`ssh-${Date.now()}-${Math.random().toString(16).slice(2)}`;try{await _(n,t,Xt.trim()||void 0),w(n),qt(!1),Yt(`ssh user@example.com`),Zt(``),q.success(e(`settings.remoteInstances.page.toast.instanceCreated`))}catch(t){q.error(e(`settings.remoteInstances.sidebar.toast.createFailed`),{description:t instanceof Error?t.message:String(t)})}},[_,w,Jt,Xt,e]),sn=Q.useCallback(async e=>{await en(je,e)},[je,en]),cn=ze(async e=>{if(se(e)||qe)return;let t=await mr({host:e,cachedProbe:Ne[e.id]||null});Pe(n=>({...n,[e.id]:t.status}))}),ln=ze(async t=>{if(qe)return;let n=t.nickname?.trim()||t.sshParsed?.destination||t.id,r=je;try{let e=await ie();r=e.hosts||[],Me(r),Ie(e.defaultHostId||`local`)}catch(t){q.error(e(`desktopHostSwitcher.toast.instanceUnreachable`,{host:n}),{description:t instanceof Error?t.message:String(t)});return}let i=r.find(e=>e.id===t.id)??null;if(!i||!oe(i)||!i.clientToken){q.error(e(`desktopHostSwitcher.toast.instanceUnreachable`,{host:n}));return}se(i)||await mr({host:i})});Q.useEffect(()=>{if(i)return r(()=>{Ke(e=>e+1)})},[i]),Q.useEffect(()=>{if(!i||nn.length===0)return;let e=!1;return Promise.all(nn.map(async e=>{let t=async()=>{let t=await te(e.relay,{clientToken:e.clientToken||null}).catch(()=>({status:`unreachable`,latencyMs:0}));return t.status===`ok`?{status:t.status,latencyMs:t.latencyMs,via:`relay`}:{status:t.status,latencyMs:t.latencyMs}};if(e.relay&&!e.apiUrl)return[e.id,await t()];let n=U(oe(e));if(!n)return[e.id,e.relay?await t():{status:`unreachable`,latencyMs:0}];let r=await re(n,{clientToken:e.clientToken||null,requestHeaders:e.requestHeaders||null}).catch(()=>({status:`unreachable`,latencyMs:0}));if(r.status===`unreachable`&&e.relay){let n=await t();if(n.status===`ok`)return[e.id,n]}return[e.id,r]})).then(t=>{e||Pe(Object.fromEntries(t))}),()=>{e=!0}},[nn,i]);let _n=Q.useCallback(async e=>{if(t){e?.silent||at(!0),e?.silent||ut(null);try{let[e,n]=await Promise.all([t.listClients(),t.listPendingPairings().catch(()=>null)]);tt(e),n&&rt(n)}catch(t){e?.silent||ut(t instanceof Error?t.message:String(t))}finally{e?.silent||at(!1)}}},[t]),yn=Q.useRef(!1);Q.useEffect(()=>{if(!(!Tt||Dt!==`result`||!yt)){if(nt.some(e=>e.id===yt)){yn.current=!0;return}yn.current&&(bt(null),Et(!1),et.some(e=>e.pairingId===yt)&&q.success(e(`settings.remoteInstances.clientAuth.addDevice.connectedToast`)))}},[Tt,Dt,yt,nt,et,e]);let Sn=Q.useCallback(async e=>{if(t)try{await t.cancelPairing(e),rt(t=>t.filter(t=>t.id!==e)),await _n({silent:!0})}catch(e){ut(e instanceof Error?e.message:String(e))}},[t,_n]);Q.useEffect(()=>{if(!t)return;_n();let e=window.setInterval(()=>{typeof document<`u`&&document.visibilityState!==`visible`||_n({silent:!0})},5e3);return()=>window.clearInterval(e)},[t,_n]);let wn=Q.useCallback(async()=>{let e=s()!==`local`;if(t?.getPairingTransports)try{let n=await t.getPairingTransports(),r=Ld(n.relayUrl),i=Array.from(new Set([...Array.isArray(n.relayUrls)?n.relayUrls:[],...r?[r]:[]].map(e=>Ld(e)).filter(e=>!!e)));return{serverName:n.serverName,localUrl:n.local,lanUrl:n.lan,relayAvailable:n.relayAvailable,relayUrl:r,relayUrls:n.relayAvailable?i:[],relayUrlLocked:n.relayUrlLocked===!0,remoteHost:e}}catch{}let n=uf(),r=n?`http://127.0.0.1:${n}`:df(window.location.origin)?window.location.origin:null,i=null;try{let e=U(await ff());i=e&&!df(e)?e:null}catch{}return{localUrl:r,lanUrl:i,relayAvailable:!1,relayUrl:null,relayUrls:[],relayUrlLocked:!1,remoteHost:e}},[t]),An=ze(async()=>{ct.current=!1,st(``),ut(null),vt(null),St(null),wt(!1),bt(null),Rt(null),Ot(`configure`),zt(!1),Pt(!0),Et(!0);let e=await wn();ct.current||st(e.serverName||``),Wt(e),Vt(!1);let t=e.remoteHost?null:Rd();It((e.relayUrlLocked||e.remoteHost?e.relayUrl:t||e.relayUrl)||`wss://relay.openchamber.dev/ws`),Mt(e.relayAvailable?`relay`:e.lanUrl?`lan`:`local`)}),jn=W(e=>e.devicePairingRequested);Q.useEffect(()=>{!jn||!t||(W.setState({devicePairingRequested:!1}),An())},[jn,t,An]);let Mn=ze(async()=>{if(!(!t?.createPairingSession||!Ut)){ut(null),At(!0);try{let n=ot.trim()||void 0,r,i,a=!0;jt===`local`?(r=Ut.localUrl??void 0,i=!1):jt===`lan`?(r=Ut.lanUrl??void 0,i=Nt):Nt&&Ut.lanUrl?(r=Ut.lanUrl,i=!0):(a=!1,i=!0),Ut.relayAvailable||(i=!1);let o=i?Ld(Ft):null;if(i&&!o){Rt(e(`settings.remoteInstances.clientAuth.addDevice.relayUrlInvalid`)),zt(!0);return}Rt(null);let{pairing:s,server:c}=await t.createPairingSession({label:n,allowedClientKinds:[`mobile`,`desktop`],serverUrl:r,includeRelay:i,includeDirect:a,...o?{relayUrl:o}:{}}),l=pa({pairingId:s.id,secret:s.secret,label:n||c.label,fingerprint:s.fingerprint??void 0,expiresAt:s.expiresAt,candidates:c.candidates}),u=l.candidates.find(e=>e.type===`relay`);u&&(It(u.relayUrl),Ut?.remoteHost!==!0&&zd(u.relayUrl));let d=ma(l);vt(d),St(await cd.toDataURL(d,{width:1024,margin:2,errorCorrectionLevel:`L`})),wt(!1),yn.current=!1,bt(s.id),Ot(`result`),await _n({silent:!0})}catch(e){ut(e instanceof Error?e.message:String(e))}finally{At(!1)}}}),Nn=Q.useCallback(()=>{_t&&Ve(_t).then(e=>{e.ok&&(wt(!0),window.setTimeout(()=>wt(!1),2e3))})},[_t]),Fn=ze(async()=>{if(!(!t||!dt||pt||!dt.label.trim())){mt(!0),gt(null);try{let e=await t.renameClient(dt.id,dt.label.trim());tt(t=>t.map(t=>t.id===e.id?e:t)),ft(null),await _n({silent:!0})}catch(e){gt(e instanceof Error?e.message:String(e))}finally{mt(!1)}}}),In=Q.useCallback(async e=>{if(!t)return;let n=e.clientKind===`desktop-local`;ut(null);try{if(await t.revokeClient(e.id),n&&E()){let t=await ie();await ne({hosts:t.hosts,defaultHostId:t.defaultHostId,initialHostChoiceCompleted:t.initialHostChoiceCompleted,localClientToken:null}),tt(t=>t.map(t=>t.id===e.id?{...t,revokedAt:new Date().toISOString()}:t)),a({apiBaseUrl:c(),clientToken:null,runtimeKey:`local`});return}await _n()}catch(e){ut(e instanceof Error?e.message:String(e))}},[t,_n]),Ln=Q.useCallback(async()=>{if(t){ut(null);try{await t.purgeRevokedClients(),await _n()}catch(e){ut(e instanceof Error?e.message:String(e))}}},[t,_n]);Q.useEffect(()=>{O(T)},[T]),Q.useEffect(()=>{let e=!1;return!S||T?.remoteYuri?.mode!==`managed`?(A([]),()=>{e=!0}):(br(S).then(t=>{e||A(t.slice(-5).reverse())}).catch(()=>{e||A([])}),()=>{e=!0})},[S,T?.remoteYuri?.mode,ce]),Q.useEffect(()=>{if(!S)return;let e=window.setInterval(()=>{typeof document<`u`&&document.visibilityState!==`visible`||h()},2e3);return()=>{window.clearInterval(e)}},[h,S]),Q.useEffect(()=>{let e=null,t=Date.now(),n=()=>{let r=Date.now();r-t>=1e3&&(ke(r),t=r),e=requestAnimationFrame(n)};(typeof document>`u`||document.visibilityState===`visible`)&&(e=requestAnimationFrame(n));let r=()=>{document.visibilityState===`visible`&&e===null?e=requestAnimationFrame(n):document.visibilityState!==`visible`&&e!==null&&(cancelAnimationFrame(e),e=null)};return document.addEventListener(`visibilitychange`,r),()=>{document.removeEventListener(`visibilitychange`,r),e!==null&&cancelAnimationFrame(e)}},[]);let Rn=S?l[S]:null,zn=Rn?.phase,Bn=zn===`ready`,Vn=zn===`degraded`,Hn=ef(zn),Un=Bn||Hn||Vn,Wn=Rn?Math.max(0,Oe-Rn.updatedAtMs):0,Gn=Vn&&Wn>12e3,Kn=Q.useMemo(()=>!D||!T?!1:JSON.stringify(D)!==JSON.stringify(T),[D,T]),qn=Q.useCallback(e=>{O(t=>t&&e(t))},[]),Jn=Q.useCallback(async()=>{if(!D)return;let t=mf(D);if(!t.sshCommand.trim()){q.error(e(`settings.remoteInstances.page.toast.sshCommandRequired`));return}if(!(t.localForward.bindHost===`0.0.0.0`&&!window.confirm(e(`settings.remoteInstances.page.confirm.bindAllInterfaces`)))){if(t.auth.sshPassword?.enabled&&t.auth.sshPassword.value?.trim()&&t.auth.sshPassword.store!==`settings`){let n=window.confirm(e(`settings.remoteInstances.page.confirm.storeSshPasswordPlaintext`));t.auth.sshPassword.store=n?`settings`:`never`,n||(t.auth.sshPassword.value=void 0)}if(t.auth.yuriPassword?.enabled&&t.auth.yuriPassword.value?.trim()&&t.auth.yuriPassword.store!==`settings`){let n=window.confirm(e(`settings.remoteInstances.page.confirm.storeUiPasswordPlaintext`));t.auth.yuriPassword.store=n?`settings`:`never`,n||(t.auth.yuriPassword.value=void 0)}try{await g(t),q.success(e(`settings.remoteInstances.page.toast.instanceSaved`))}catch(t){q.error(e(`settings.remoteInstances.page.toast.saveFailed`),{description:t instanceof Error?t.message:String(t)})}}},[D,e,g]),Yn=Q.useCallback(async(t,n)=>{let r=`ssh-${Date.now()}-${Math.random().toString(16).slice(2)}`;try{return await _(r,`ssh ${n}`,t),w(r),q.success(e(`settings.remoteInstances.page.toast.instanceCreated`)),!0}catch(t){return q.error(e(`settings.remoteInstances.sidebar.toast.createFailed`),{description:t instanceof Error?t.message:String(t)}),!1}},[_,w,e]),Xn=Q.useCallback(()=>{be||(_e(null),ye(``))},[be]),Qn=Q.useCallback(async()=>{let t=ge,n=ve.trim();if(t){if(!n){q.error(e(`settings.remoteInstances.page.toast.destinationRequired`));return}xe(!0);try{await Yn(t,n)&&(_e(null),ye(``))}finally{xe(!1)}}},[Yn,ve,ge,e]),$n=Q.useCallback(async()=>{if(T)try{await y(T.id);return}catch(t){if(!Jd(t)||!window.confirm(e(`settings.remoteInstances.sidebar.confirm.localPortInUseRetry`)))throw t;let n={...T,localForward:{...T.localForward,preferredLocalPort:Vd()}};await g(n),await y(n.id),q.success(e(`settings.remoteInstances.sidebar.toast.retriedWithRandomPort`))}},[y,T,e,g]),er=Q.useCallback(async e=>(await nr(e,600)).map(e=>lf(e)),[]),ar=Q.useCallback(async()=>{if(D){M(!0),P(!0),L(null);try{let e=await er(D.id);z(e)}catch(e){z([]),L(e instanceof Error?e.message:String(e))}finally{P(!1)}}},[D,er]);Q.useEffect(()=>{if(!j||!D)return;let e=!1,t=async()=>{try{let t=await er(D.id);e||(z(t),L(null))}catch(t){e||L(t instanceof Error?t.message:String(t))}};t();let n=window.setInterval(()=>{typeof document<`u`&&document.visibilityState!==`visible`||t()},1e3);return()=>{e=!0,window.clearInterval(n)}},[D,j,er]);let or=Q.useMemo(()=>R.join(`
|
|
24
24
|
`),[R]),sr=Q.useCallback(()=>{if(!or.trim()){q.error(e(`settings.remoteInstances.page.toast.noLogsToCopy`));return}Ve(or).then(t=>{t.ok&&q.success(e(`settings.remoteInstances.page.toast.logsCopied`))})},[or,e]),cr=Q.useCallback(async()=>{if(D)try{await rr(D.id),z([]),q.success(e(`settings.remoteInstances.page.toast.logsCleared`))}catch(t){q.error(e(`settings.remoteInstances.page.toast.clearLogsFailed`),{description:t instanceof Error?t.message:String(t)})}},[D,e]),lr=Q.useCallback(async()=>{if(!Rn?.localUrl){q.error(e(`settings.remoteInstances.page.toast.instanceUrlUnavailable`));return}let t=Rn.localUrl.trim();if(!t){q.error(e(`settings.remoteInstances.page.toast.instanceUrlUnavailable`));return}pf(t)},[Rn?.localUrl,e]),ur=Q.useCallback((e,t=`ssh`,n=null)=>{de(e),pe(t),he(n),le(!0)},[]),dr=Q.useCallback(()=>{if(!D)return;let t=Un,n=D.id;Te(!0),(t?b(n):$n()).catch(n=>{let r=t?Bn?`settings.remoteInstances.page.toast.disconnectFailed`:`settings.remoteInstances.page.toast.cancelConnectionFailed`:`settings.remoteInstances.page.toast.connectFailed`,i=Rn?.detail||(n instanceof Error?n.message:String(n)),a=Pn(Rn?.errorCode,i);q.error(e(r),{description:t?n instanceof Error?n.message:String(n):Mr(e(tr(a)),a,i)})}).finally(()=>{Te(!1)})},[Un,$n,b,D,Bn,Rn,e]),fr=Q.useCallback(()=>{D&&(Hn||(De(!0),(Vn?b(D.id).then(()=>$n()):x(D.id)).catch(t=>{let n=Rn?.detail||(t instanceof Error?t.message:String(t)),r=Pn(Rn?.errorCode,n);q.error(e(`settings.remoteInstances.page.toast.retryFailed`),{description:Mr(e(tr(r)),r,n)})}).finally(()=>{De(!1)})))},[$n,b,D,Hn,Vn,x,Rn,e]),pr=e(Hn?`settings.remoteInstances.page.actions.connecting`:Vn?Gn?`settings.remoteInstances.page.actions.reconnectNow`:`settings.remoteInstances.page.actions.reconnecting`:`settings.remoteInstances.sidebar.actions.retry`),hr=!we&&!Ee&&(zn===`error`||zn===`idle`||!zn||Vn&&Gn)&&!Hn,gr=e(Bn?`settings.remoteInstances.sidebar.actions.disconnect`:Un?`settings.remoteInstances.page.actions.cancel`:`settings.remoteInstances.sidebar.actions.connect`);if(!D)return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(ql,{children:[t?(0,$.jsxs)(af,{itemId:`remote-instances.client-auth`,label:e(`settings.remoteInstances.clientAuth.title`),action:(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pt-0.5`,children:[(0,$.jsx)(K,{type:`button`,size:`xs`,className:`!font-normal`,onClick:()=>{Ze(null),$e(!0)},disabled:Be,children:e(`settings.remoteInstances.direct.import.action`)}),(0,$.jsxs)(K,{type:`button`,size:`xs`,className:`!font-normal`,onClick:()=>void An(),children:[(0,$.jsx)(Y,{name:`add`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.clientAuth.actions.addDevice`)]}),Gt>0?(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void Ln(),children:e(`settings.remoteInstances.clientAuth.actions.clearRevoked`)}):null]}),children:[(0,$.jsx)(`div`,{className:`space-y-1`,children:it&&et.length===0&&nt.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.clientAuth.state.loading`)}):et.length===0&&nt.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.clientAuth.state.empty`)}):(0,$.jsxs)($.Fragment,{children:[nt.map(t=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full bg-[var(--status-warning)] animate-pulse`}),(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground truncate`,children:t.label||e(`settings.remoteInstances.clientAuth.field.labelPlaceholder`)}),t.usesRelay?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground bg-muted px-1 rounded shrink-0 leading-none pb-px border border-border/50`,children:e(`settings.remoteInstances.clientAuth.state.viaRelay`)}):null]}),(0,$.jsx)(`p`,{className:`typography-micro text-muted-foreground truncate`,children:e(`settings.remoteInstances.clientAuth.state.pending`)})]}),(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void Sn(t.id),children:e(`settings.common.actions.cancel`)})]},`pending-${t.id}`)),et.map(t=>{let n=t.clientKind===`desktop-local`,r=t.lastUsedAt?Date.parse(t.lastUsedAt):NaN,i=!t.revokedAt&&(n||Number.isFinite(r)&&Date.now()-r<9e4),a=t.revokedAt?e(`settings.remoteInstances.clientAuth.state.revoked`):i?t.lastTransport===`relay`&&!n?e(`settings.remoteInstances.clientAuth.state.connectedRelay`):e(`settings.remoteInstances.clientAuth.state.connectedDirect`):t.lastUsedAt?e(`settings.remoteInstances.clientAuth.lastUsed`,{date:md(r,{locale:Ge()})}):e(`settings.remoteInstances.clientAuth.neverUsed`),o=Number.isFinite(r)?new Date(r).toLocaleString(Ge()):void 0;return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 basis-48`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:G(`h-2 w-2 shrink-0 rounded-full`,t.revokedAt?`bg-muted-foreground/20`:i?`bg-[var(--status-success)]`:`bg-muted-foreground/30`)}),(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground truncate`,children:t.label}),(()=>{let e=Xd(t.devicePlatform),n=Zd(t.devicePlatform);return e&&n?(0,$.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 rounded-full border border-border/50 px-1.5 py-px text-muted-foreground`,title:e,"aria-label":e,children:[(0,$.jsx)(Y,{name:n,className:`h-3 w-3`}),(0,$.jsx)(`span`,{className:`typography-micro leading-none`,children:e})]}):null})(),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:e(`settings.remoteInstances.clientAuth.state.thisDevice`)}):null]}),(0,$.jsx)(`p`,{className:G(`typography-micro truncate`,i&&!t.revokedAt?`text-[var(--status-success)]`:`text-muted-foreground`),title:o,children:a})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>{gt(null),ft({id:t.id,label:t.label})},disabled:pt,children:e(`settings.remoteInstances.clientAuth.edit.action`)}),(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void In(t),disabled:!!t.revokedAt||pt,children:e(`settings.remoteInstances.clientAuth.actions.revoke`)})]})]},t.id)})]})}),lt?(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:lt}):null]}):null,i?(0,$.jsx)(af,{itemId:`remote-instances.instances`,label:e(`settings.remoteInstances.sidebar.title`),action:nn.length>0||o.length>0?(0,$.jsx)(`div`,{className:`flex shrink-0 items-center gap-2 pt-0.5`,children:(0,$.jsxs)(K,{type:`button`,variant:`secondary`,size:`xs`,className:`!font-normal`,onClick:()=>qt(!0),children:[(0,$.jsx)(Y,{name:`add`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.sidebar.actions.addSshInstance`)]})}):void 0,children:(0,$.jsx)(`div`,{className:`space-y-1`,children:Le||u?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.direct.state.loading`)}):nn.length===0&&o.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center px-6 py-10 text-center`,children:[(0,$.jsx)(Y,{name:`device-desktop`,className:`mb-5 size-16 text-muted-foreground/45`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium text-foreground`,children:e(`settings.remoteInstances.quick.sshTitle`)}),(0,$.jsx)(`p`,{className:`mt-2 max-w-sm typography-meta leading-relaxed text-muted-foreground`,children:e(`settings.remoteInstances.quick.sshHint`)}),(0,$.jsxs)(K,{type:`button`,variant:`secondary`,size:`sm`,className:`mt-6 gap-2 rounded-xl`,onClick:()=>qt(!0),children:[(0,$.jsx)(Y,{name:`add`,className:`size-4`}),e(`settings.remoteInstances.sidebar.actions.addSshInstance`)]})]}):(0,$.jsxs)($.Fragment,{children:[nn.map(t=>{let n=Ne[t.id],r=n?n.status===`ok`?`desktopHostSwitcher.status.connected`:n.status===`auth`?`desktopHostSwitcher.status.authRequired`:n.status===`update-recommended`?`desktopHostSwitcher.status.updateRecommended`:n.status===`incompatible`?`desktopHostSwitcher.status.incompatible`:n.status===`wrong-service`?`desktopHostSwitcher.status.wrongService`:`desktopHostSwitcher.status.unreachable`:`desktopHostSwitcher.status.checking`,i=n?.status===`ok`,a=se(t),o=a||qe||Be;return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:G(`h-2 w-2 shrink-0 rounded-full`,n?i||a?`bg-[var(--status-success)]`:`bg-[var(--status-error)]`:`bg-muted-foreground/30 animate-pulse`)}),(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground truncate`,children:H(t.label)}),(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:e(`settings.remoteInstances.channel.link`)}),a?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:e(`desktopHostSwitcher.header.current`)}):null,Fe===t.id?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:e(`desktopHostSwitcher.header.default`)}):null,(0,$.jsxs)(`span`,{className:G(`typography-micro shrink-0`,i||a?`text-[var(--status-success)]`:`text-muted-foreground`),children:[e(r),i&&typeof n?.latencyMs==`number`?e(`desktopHostSwitcher.status.ping`,{ms:Math.max(0,Math.round(n.latencyMs))}):``]})]}),(0,$.jsx)(`p`,{className:G(`typography-micro text-muted-foreground truncate`,t.apiUrl&&`font-mono`),children:t.relay&&!t.apiUrl?e(`mobile.connect.relay.badge`):H(t.apiUrl||t.url)})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,$.jsxs)(K,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void cn(t),disabled:o,"aria-label":e(`desktopHostSwitcher.actions.switchToAria`,{instance:H(t.label)}),children:[(0,$.jsx)(Y,{name:`arrow-left-right`,className:`h-3.5 w-3.5`}),e(a?`desktopHostSwitcher.header.current`:`desktopHostSwitcher.actions.switchInstance`)]}),(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void sn(t.id),disabled:Be||Fe===t.id,"aria-label":e(`desktopHostSwitcher.actions.setAsDefaultAria`),children:Fe===t.id?(0,$.jsx)(Y,{name:`star-fill`,className:`h-3.5 w-3.5`}):(0,$.jsx)(Y,{name:`star`,className:`h-3.5 w-3.5`})}),(()=>{let n=oe(t),r=!!n&&!n.startsWith(`relay://`)&&!t.relay;return t.relay?.serverId&&t.relay?.relayUrl&&t.relay?.hostEncPubJwk&&t.clientToken&&t.relay?(0,$.jsxs)(K,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>ur(t.id,`relay`,t),"aria-label":e(`settings.remoteInstances.page.sync.title`),children:[(0,$.jsx)(Y,{name:`refresh`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.sync.actions.syncNow`)]}):r?(0,$.jsxs)(K,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>ur(t.id,`direct`),"aria-label":e(`settings.remoteInstances.page.sync.title`),children:[(0,$.jsx)(Y,{name:`refresh`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.sync.actions.syncNow`)]}):null})(),(0,$.jsxs)(K,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void an(t.id),disabled:Be||qe,children:[(0,$.jsx)(Y,{name:`delete-bin`,className:`h-3.5 w-3.5`}),e(`settings.common.actions.delete`)]})]})]},`link:${t.id}`)}),o.map(t=>{let n=l[t.id],r=t.nickname?.trim()||t.sshParsed?.destination||t.id,i=n?.phase,a=i===`ready`,o=je.find(e=>e.id===t.id),s=se({id:t.id,label:r,url:n?.localUrl||o?.url||``}),c=(0,$.jsxs)(K,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>void ln(t),disabled:s||qe||!a,"aria-label":e(`desktopHostSwitcher.actions.switchToAria`,{instance:r}),children:[(0,$.jsx)(Y,{name:`arrow-left-right`,className:`h-3.5 w-3.5`}),e(s?`desktopHostSwitcher.header.current`:`desktopHostSwitcher.actions.switchInstance`)]});return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1.5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${tf(i)}`}),(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground truncate`,children:r}),(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:e(`settings.remoteInstances.channel.ssh`)}),s?(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:e(`desktopHostSwitcher.header.current`)}):null]}),(0,$.jsxs)(`p`,{className:`typography-micro text-muted-foreground truncate`,children:[e(Qd(i)),n?.localUrl?` · ${n.localUrl}`:``]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,$.jsxs)(K,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>{(a?b(t.id):y(t.id)).catch(t=>{let r=n?.detail||(t instanceof Error?t.message:String(t)),i=Pn(n?.errorCode,r);q.error(e(a?`settings.remoteInstances.sidebar.toast.disconnectFailed`:`settings.remoteInstances.sidebar.toast.connectFailed`),{description:a?t instanceof Error?t.message:String(t):Mr(e(tr(i)),i,r)})})},children:[a?(0,$.jsx)(Y,{name:`stop`,className:`h-3.5 w-3.5`}):(0,$.jsx)(Y,{name:`plug-2`,className:`h-3.5 w-3.5`}),e(a?`settings.remoteInstances.sidebar.actions.disconnect`:`settings.remoteInstances.sidebar.actions.connect`)]}),a?c:(0,$.jsxs)(kn,{children:[(0,$.jsx)(Dn,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex`,children:c})}),(0,$.jsx)(On,{sideOffset:8,className:`max-w-xs`,children:e(`settings.remoteInstances.sidebar.actions.switchInstanceDisabled`)})]}),a&&t.remoteYuri?.mode!==`external`?(0,$.jsxs)(K,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>ur(t.id),children:[(0,$.jsx)(Y,{name:`refresh`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.sidebar.actions.syncConfig`)]}):(0,$.jsxs)(kn,{children:[(0,$.jsx)(Dn,{asChild:!0,children:(0,$.jsx)(`span`,{className:`inline-flex`,children:(0,$.jsxs)(K,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,disabled:!0,"aria-label":e(`settings.remoteInstances.sidebar.actions.syncConfigDisabled`),children:[(0,$.jsx)(Y,{name:`refresh`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.sidebar.actions.syncConfig`)]})})}),(0,$.jsx)(On,{sideOffset:8,className:`max-w-xs`,children:e(`settings.remoteInstances.sidebar.actions.syncConfigDisabled`)})]}),(0,$.jsxs)(K,{type:`button`,variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:()=>w(t.id),children:[(0,$.jsx)(Y,{name:`pencil`,className:`h-3.5 w-3.5`}),e(`desktopHostSwitcher.actions.edit`)]})]})]},`ssh:${t.id}`)})]})})}):null,(0,$.jsx)(hn,{open:dt!==null,onOpenChange:e=>{!e&&!pt&&ft(null)},children:(0,$.jsxs)(fn,{className:`sm:max-w-sm`,showCloseButton:!pt,children:[(0,$.jsx)(un,{children:(0,$.jsx)(pn,{children:e(`settings.remoteInstances.clientAuth.edit.title`)})}),(0,$.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e.preventDefault(),Fn()},children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`label`,{htmlFor:`remote-client-name`,className:`typography-ui-label text-muted-foreground`,children:e(`settings.remoteInstances.clientAuth.edit.name`)}),(0,$.jsx)(En,{id:`remote-client-name`,className:`text-left`,autoFocus:!0,value:dt?.label??``,maxLength:80,disabled:pt,onChange:e=>ft(t=>t?{...t,label:e.target.value}:null),onKeyDown:e=>{e.key===`Enter`&&e.nativeEvent.isComposing&&e.preventDefault()},"aria-invalid":!!ht,"aria-describedby":ht?`remote-client-name-error`:void 0}),ht?(0,$.jsx)(`p`,{id:`remote-client-name-error`,role:`alert`,className:`typography-meta text-[var(--status-error)]`,children:ht}):null]}),(0,$.jsxs)(dn,{children:[(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>ft(null),disabled:pt,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(K,{type:`submit`,size:`sm`,disabled:pt||!dt?.label.trim(),children:e(`settings.common.actions.saveChanges`)})]})]})]})}),i?(0,$.jsx)(hn,{open:Qe,onOpenChange:e=>{$e(e),Ze(null)},children:(0,$.jsxs)(fn,{className:`sm:max-w-lg`,children:[(0,$.jsxs)(un,{children:[(0,$.jsx)(pn,{children:e(`settings.remoteInstances.direct.import.action`)}),(0,$.jsx)(mn,{children:e(`settings.remoteInstances.direct.import.description`)})]}),(0,$.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e.preventDefault(),rn()},children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(En,{value:Je,onChange:e=>{Ye(e.target.value),Ze(null)},placeholder:e(`settings.remoteInstances.direct.import.placeholder`),"aria-label":e(`settings.remoteInstances.direct.import.action`),"aria-invalid":!!Xe,"aria-describedby":Xe?`remote-import-error`:void 0,disabled:Be,autoFocus:!0}),Xe?(0,$.jsx)(`div`,{id:`remote-import-error`,role:`alert`,className:`rounded-lg bg-[var(--status-error-background)] px-3 py-2.5 typography-meta leading-relaxed text-[var(--status-error)] break-words`,children:Xe}):null]}),(0,$.jsxs)(dn,{children:[(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{$e(!1),Ze(null)},disabled:Be,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(K,{type:`submit`,size:`sm`,disabled:Be||!Je.trim(),children:e(`settings.remoteInstances.direct.import.action`)})]})]})]})}):null,(0,$.jsx)(hn,{open:Tt,onOpenChange:Et,children:(0,$.jsxs)(fn,{className:`sm:max-w-xl`,children:[(0,$.jsxs)(un,{className:`items-center pt-4 text-center sm:text-center`,children:[Dt===`configure`?(0,$.jsx)(Y,{name:`devices-connected`,className:`mb-3 size-20 text-muted-foreground`}):null,(0,$.jsx)(pn,{className:`text-xl`,children:e(Dt===`result`?`settings.remoteInstances.clientAuth.qrDialogTitle`:`settings.remoteInstances.clientAuth.actions.addDevice`)}),(0,$.jsx)(mn,{className:`max-w-sm text-center leading-relaxed`,children:e(Dt===`result`?`settings.remoteInstances.clientAuth.qrScanHint`:`settings.remoteInstances.quick.emptyHint`)})]}),Dt===`configure`?(0,$.jsxs)(`ol`,{className:`grid grid-cols-3 gap-3 py-4 text-center`,children:[(0,$.jsxs)(`li`,{className:`flex min-w-0 flex-col items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-6 shrink-0 items-center justify-center rounded-full bg-[var(--surface-muted)] typography-micro text-muted-foreground`,"aria-hidden":`true`,children:`1`}),(0,$.jsxs)(`a`,{href:`https://github.com/yee94/yuri/releases`,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>{e.preventDefault(),Wr(`https://github.com/yee94/yuri/releases`)},className:`inline-flex items-center justify-center gap-1 whitespace-nowrap typography-meta text-foreground underline decoration-[var(--interactive-border)] underline-offset-4 hover:decoration-current`,children:[e(`settings.remoteInstances.pairing.downloadStep`),(0,$.jsx)(Y,{name:`external-link`,className:`size-3 shrink-0`})]})]}),(0,$.jsxs)(`li`,{className:`flex min-w-0 flex-col items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-6 shrink-0 items-center justify-center rounded-full bg-[var(--surface-muted)] typography-micro text-muted-foreground`,"aria-hidden":`true`,children:`2`}),(0,$.jsx)(`p`,{className:`typography-meta text-foreground`,children:e(`settings.remoteInstances.clientAuth.addDevice.create`)})]}),(0,$.jsxs)(`li`,{className:`flex min-w-0 flex-col items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-6 shrink-0 items-center justify-center rounded-full bg-[var(--surface-muted)] typography-micro text-muted-foreground`,"aria-hidden":`true`,children:`3`}),(0,$.jsx)(`p`,{className:`typography-meta text-foreground`,children:e(`settings.remoteInstances.clientAuth.qrDialogTitle`)})]})]}):null,Dt===`configure`?(0,$.jsxs)(`form`,{className:`space-y-4`,onSubmit:e=>{e.preventDefault(),Mn()},children:[(0,$.jsxs)(`label`,{className:`block space-y-3 rounded-2xl bg-[var(--surface-muted)] p-4`,children:[(0,$.jsxs)(`span`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.remoteInstances.pairing.name`)}),(0,$.jsx)(`span`,{id:`add-device-instance-name-hint`,className:`font-normal text-muted-foreground`,style:{fontSize:`var(--form-helper-font-size)`,lineHeight:`var(--form-helper-line-height)`},children:e(`settings.remoteInstances.clientAuth.field.labelHint`)})]}),(0,$.jsx)(En,{className:`w-full hover:[&:not(:focus)]:ring-border/60`,value:ot,onChange:e=>{ct.current=!0,st(e.target.value)},placeholder:e(`settings.remoteInstances.clientAuth.field.labelPlaceholder`),"aria-describedby":`add-device-instance-name-hint`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:e(`settings.remoteInstances.clientAuth.addDevice.transportLabel`)}),(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":e(`settings.remoteInstances.clientAuth.addDevice.transportLabel`),className:`grid grid-cols-3 gap-2 pt-2`,children:[{key:`relay`,label:e(`settings.remoteInstances.clientAuth.addDevice.transport.relay`),hint:e(`settings.remoteInstances.pairing.anywhere`),available:!!Ut?.relayAvailable},{key:`lan`,label:e(`settings.remoteInstances.clientAuth.addDevice.transport.lan`),hint:e(`settings.remoteInstances.pairing.lan`),available:!!Ut?.lanUrl},{key:`local`,label:e(`settings.remoteInstances.clientAuth.addDevice.transport.local`),hint:e(`settings.remoteInstances.pairing.local`),available:!!Ut?.localUrl}].map(e=>{let t=jt===e.key;return(0,$.jsxs)(`div`,{className:G(`flex min-w-0 flex-col gap-2 rounded-xl border p-3 transition-colors`,t?`border-[var(--interactive-selection)] bg-[var(--interactive-selection)]`:`border-[var(--interactive-border)]`,e.available?`cursor-pointer hover:bg-interactive-hover`:`opacity-45`),onClick:()=>{e.available&&Mt(e.key)},role:`presentation`,children:[(0,$.jsx)(mc,{checked:t,disabled:!e.available,onChange:()=>Mt(e.key),ariaLabel:e.label,className:`shrink-0 !self-start`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:G(`typography-ui-label font-normal`,t?`text-foreground`:`text-foreground/70`),children:e.label}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e.hint})]})]},e.key)})}),jt===`lan`?(0,$.jsxs)(`label`,{className:`flex w-fit cursor-pointer items-center gap-2 pt-1`,children:[(0,$.jsx)(gn,{checked:Nt,onChange:Pt,ariaLabel:e(`settings.remoteInstances.clientAuth.addDevice.fallback.relay`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.clientAuth.addDevice.fallback.relay`)})]}):null,jt===`relay`&&Ut?.lanUrl?(0,$.jsxs)(`label`,{className:`flex w-fit cursor-pointer items-center gap-2 pt-1`,children:[(0,$.jsx)(gn,{checked:Nt,onChange:Pt,ariaLabel:e(`settings.remoteInstances.clientAuth.addDevice.fallback.preferLocal`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.clientAuth.addDevice.fallback.preferLocal`)})]}):null,(0,$.jsxs)(Ui,{open:J,onOpenChange:zt,className:`pt-3`,children:[(0,$.jsxs)(Hi,{className:`px-0 hover:bg-transparent`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label`,children:e(`settings.remoteInstances.pairing.advanced`)}),(0,$.jsx)(Y,{name:J?`arrow-up-s`:`arrow-down-s`,className:`size-4 text-muted-foreground`})]}),(0,$.jsx)(`p`,{className:`mt-1 font-normal text-muted-foreground`,style:{fontSize:`var(--form-helper-font-size)`,lineHeight:`var(--form-helper-line-height)`},children:e(`settings.remoteInstances.pairing.relayHint`)}),(0,$.jsx)(Vi,{children:(()=>{let t=Array.from(new Set([...Ut?.relayUrls??[],...Ut?.relayUrl?[Ut.relayUrl]:[]])),n=t.length>1,r=Ut?.relayUrlLocked!==!0,i=n&&!Bt;return(0,$.jsxs)(`label`,{className:`block space-y-1.5 pt-2`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.remoteInstances.clientAuth.addDevice.relayUrlLabel`)}),i?(0,$.jsxs)(Cn,{value:t.includes(Ft)?Ft:t[0],onValueChange:e=>{if(e===`__custom__`){Vt(!0);return}It(e),Rt(null)},children:[(0,$.jsx)(bn,{className:`h-8 w-full font-mono`,"aria-label":e(`settings.remoteInstances.clientAuth.addDevice.relayUrlLabel`),children:(0,$.jsx)(Tn,{})}),(0,$.jsxs)(xn,{children:[t.map(e=>(0,$.jsx)(vn,{value:e,className:`font-mono`,children:(0,$.jsx)(`span`,{className:`block max-w-[420px] truncate`,children:e})},e)),r?(0,$.jsx)(vn,{value:`__custom__`,children:e(`settings.remoteInstances.clientAuth.addDevice.relayUrlCustomOption`)}):null]})]}):(0,$.jsx)(En,{ref:Ht,className:`h-8 font-mono`,value:Ft,onChange:e=>{It(e.target.value),Rt(null)},placeholder:Fd,readOnly:Ut?.relayUrlLocked===!0,"aria-readonly":Ut?.relayUrlLocked===!0||void 0,"aria-invalid":!!Lt||void 0,"aria-describedby":Lt?`add-device-relay-url-hint add-device-relay-url-error`:`add-device-relay-url-hint`,spellCheck:!1,autoCapitalize:`none`,autoCorrect:`off`}),(0,$.jsx)(`span`,{id:`add-device-relay-url-hint`,className:`block typography-meta text-muted-foreground`,children:Ut?.relayUrlLocked?e(`settings.remoteInstances.clientAuth.addDevice.relayUrlLockedHint`):e(`settings.remoteInstances.clientAuth.addDevice.relayUrlHint`)}),(0,$.jsx)(`a`,{href:Bd,target:`_blank`,rel:`noopener noreferrer`,className:`block typography-meta text-muted-foreground underline underline-offset-2 hover:text-foreground`,onClick:e=>{e.preventDefault(),Wr(Bd)},children:e(`settings.remoteInstances.clientAuth.addDevice.relayUrlDeployLink`)}),Lt?(0,$.jsx)(`span`,{id:`add-device-relay-url-error`,role:`alert`,"aria-live":`polite`,className:`block typography-meta text-[var(--status-error)]`,children:Lt}):null]})})()})]})]}),lt?(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:lt}):null,(0,$.jsxs)(`div`,{className:`flex justify-end gap-3 pt-4`,children:[(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`sm`,className:`!font-normal`,onClick:()=>Et(!1),disabled:kt,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(K,{type:`submit`,variant:`default`,size:`sm`,className:`!font-normal`,disabled:kt||!Ut,children:e(`settings.remoteInstances.clientAuth.addDevice.create`)})]})]}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[xt?(0,$.jsx)(`div`,{className:`flex justify-center`,children:(0,$.jsx)(`img`,{src:xt,alt:e(`settings.remoteInstances.clientAuth.qrAlt`),className:`w-full max-w-[420px] rounded-md bg-white p-4`})}):null,(0,$.jsxs)(`a`,{href:`https://github.com/yee94/yuri/releases`,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>{e.preventDefault(),Wr(`https://github.com/yee94/yuri/releases`)},className:`flex items-center justify-center gap-1.5 typography-meta text-muted-foreground hover:text-foreground`,children:[(0,$.jsx)(Y,{name:`download`,className:`size-3.5`}),e(`settings.remoteInstances.quick.download`),(0,$.jsx)(Y,{name:`external-link`,className:`size-3`})]}),_t?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-[var(--interactive-border)] p-2`,children:[(0,$.jsx)(`code`,{className:`min-w-0 flex-1 truncate typography-code text-muted-foreground`,children:_t}),(0,$.jsxs)(K,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal shrink-0`,onClick:Nn,children:[(0,$.jsx)(Y,{name:Ct?`check`:`file-copy`,className:G(`h-3.5 w-3.5`,Ct&&`text-[var(--status-success)]`)}),e(Ct?`settings.remoteInstances.clientAuth.actions.copied`:`settings.common.actions.copyAll`)]})]}):null,(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(K,{type:`button`,size:`xs`,className:`!font-normal`,onClick:()=>Et(!1),children:e(`settings.remoteInstances.clientAuth.addDevice.done`)})})]})]})}),i?(0,$.jsx)(hn,{open:Kt,onOpenChange:qt,children:(0,$.jsxs)(fn,{className:`sm:max-w-lg`,children:[(0,$.jsxs)(un,{children:[(0,$.jsx)(pn,{children:e(`settings.remoteInstances.sidebar.actions.addSshInstance`)}),(0,$.jsx)(mn,{children:e(`settings.remoteInstances.page.section.instanceDescription`)})]}),(0,$.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),on()},children:[(0,$.jsx)(En,{className:`h-8`,value:Xt,onChange:e=>Zt(e.target.value),placeholder:e(`settings.remoteInstances.page.field.nicknamePlaceholder`),disabled:d}),(0,$.jsx)(En,{className:`h-8`,value:Jt,onChange:e=>Yt(e.target.value),placeholder:e(`settings.remoteInstances.page.field.sshCommandPlaceholder`),disabled:d,autoFocus:!0}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(K,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>qt(!1),disabled:d,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(K,{type:`submit`,size:`xs`,className:`!font-normal`,disabled:d||!Jt.trim(),children:e(`settings.common.actions.create`)})]})]})]})}):null,(0,$.jsx)(Pd,{}),(0,$.jsx)(hn,{open:!!ge,onOpenChange:e=>{e||Xn()},children:(0,$.jsxs)(fn,{className:`sm:max-w-md`,children:[(0,$.jsxs)(un,{children:[(0,$.jsx)(pn,{children:e(`settings.remoteInstances.page.patternDialog.title`)}),(0,$.jsx)(mn,{children:ge?e(`settings.remoteInstances.page.patternDialog.descriptionWithHost`,{host:ge}):e(`settings.remoteInstances.page.patternDialog.description`)})]}),(0,$.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),Qn()},children:[(0,$.jsx)(En,{value:ve,onChange:e=>ye(e.target.value),placeholder:e(`settings.remoteInstances.page.patternDialog.destinationPlaceholder`),autoFocus:!0}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,$.jsx)(K,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:Xn,disabled:be,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(K,{type:`submit`,size:`xs`,className:`!font-normal`,disabled:be,children:e(`settings.remoteInstances.page.actions.create`)})]})]})]})})]}),(0,$.jsx)(qd,{open:ce,instanceId:ue,targetKind:fe,relayHost:me,onOpenChange:e=>{le(e),e||(de(null),pe(`ssh`),he(null))}})]});let _r=D.remoteYuri.mode===`managed`,vr=D.nickname?.trim()||D.sshParsed?.destination||D.id;return(0,$.jsx)(hn,{open:!!D,onOpenChange:e=>{e||w(null)},children:(0,$.jsxs)(fn,{className:`yuri-settings-workspace yuri-settings-workspace-desktop yuri-settings-section-stack sm:max-w-4xl max-h-[90vh] overflow-auto`,children:[(0,$.jsx)(Xr,{className:`pr-8`,actions:(0,$.jsx)(K,{type:`button`,size:`sm`,onClick:()=>void Jn(),disabled:!Kn||d,"aria-busy":d,children:e(`settings.common.actions.saveChanges`)}),children:(0,$.jsxs)(un,{className:`gap-1`,children:[(0,$.jsx)(pn,{className:`truncate`,children:vr}),(0,$.jsxs)(mn,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full ${tf(zn)}`}),(0,$.jsx)(`span`,{children:e(Qd(zn))}),Rn?.localUrl?(0,$.jsx)(`span`,{className:`font-mono text-foreground/80`,children:Rn.localUrl}):null,Gn?(0,$.jsx)(`span`,{children:e(`settings.remoteInstances.page.status.reconnectStale`)}):null]})]})}),zn===`error`?(0,$.jsx)(Zn,{errorCode:Rn?.errorCode,detail:Rn?.detail}):null,(0,$.jsxs)(X,{label:e(`settings.remoteInstances.page.section.actions`),children:[(0,$.jsxs)(`div`,{className:`yuri-settings-group-row flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(K,{type:`button`,variant:Un?`outline`:`default`,size:`xs`,className:`!font-normal`,onClick:dr,disabled:we||Ee,children:[Un?(0,$.jsx)(Y,{name:`stop`,className:`h-3.5 w-3.5`}):(0,$.jsx)(Y,{name:`plug-2`,className:`h-3.5 w-3.5`}),gr]}),(0,$.jsxs)(K,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:fr,disabled:!hr,children:[(0,$.jsx)(Y,{name:`refresh`,className:`h-3.5 w-3.5 ${Hn||Vn&&!Gn?`animate-spin`:``}`}),pr]}),(0,$.jsxs)(K,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>{ar()},children:[(0,$.jsx)(Y,{name:`terminal-window`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.actions.logs`)]}),(0,$.jsxs)(K,{type:`button`,variant:`destructive`,size:`xs`,className:`!font-normal`,onClick:()=>{window.confirm(e(`settings.remoteInstances.page.confirm.removeInstance`))&&v(D.id).then(()=>{w(null),q.success(e(`settings.remoteInstances.page.toast.instanceRemoved`))}).catch(t=>{q.error(e(`settings.remoteInstances.page.toast.removeInstanceFailed`),{description:t instanceof Error?t.message:String(t)})})},children:[(0,$.jsx)(Y,{name:`delete-bin`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.sidebar.actions.remove`)]})]}),Rn?.localUrl?(0,$.jsx)(Z,{label:e(`settings.remoteInstances.page.status.currentLocalUrl`),children:(0,$.jsx)(`span`,{className:`font-mono text-foreground/90`,children:Rn.localUrl})}):null]}),(0,$.jsxs)(X,{label:e(`settings.remoteInstances.page.section.instance`),children:[(0,$.jsx)(Z,{label:e(`settings.remoteInstances.page.field.sshCommand`),className:`yuri-settings-ssh-command-row`,children:(0,$.jsx)(En,{value:D.sshCommand,onChange:e=>qn(t=>({...t,sshCommand:e.target.value})),placeholder:e(`settings.remoteInstances.page.field.sshCommandPlaceholder`)})}),(0,$.jsx)(Z,{label:e(`settings.remoteInstances.page.field.nickname`),children:(0,$.jsx)(En,{value:D.nickname||``,onChange:e=>qn(t=>({...t,nickname:e.target.value})),placeholder:e(`settings.remoteInstances.page.field.nicknamePlaceholder`)})}),(0,$.jsx)(Z,{label:e(`settings.remoteInstances.page.field.connectionTimeoutSeconds`),children:(0,$.jsx)(yi,{min:5,max:240,step:1,className:`tabular-nums`,value:D.connectionTimeoutSec,onValueChange:e=>{qn(t=>({...t,connectionTimeoutSec:Number.isFinite(e)?e:t.connectionTimeoutSec}))}})})]}),(0,$.jsxs)(X,{label:e(`settings.remoteInstances.page.section.remoteServer`),children:[(0,$.jsx)(Z,{label:e(`settings.remoteInstances.page.field.mode`),children:(0,$.jsxs)(Cn,{value:D.remoteYuri.mode,onValueChange:e=>qn(t=>({...t,remoteYuri:{...t.remoteYuri,mode:e===`external`?`external`:`managed`}})),children:[(0,$.jsx)(bn,{children:(0,$.jsx)(Tn,{placeholder:e(`settings.remoteInstances.page.field.modePlaceholder`)})}),(0,$.jsxs)(xn,{children:[(0,$.jsx)(vn,{value:`managed`,children:e(`settings.remoteInstances.page.field.modeManaged`)}),(0,$.jsx)(vn,{value:`external`,children:e(`settings.remoteInstances.page.field.modeExternal`)})]})]})}),(0,$.jsx)(Z,{label:e(`settings.remoteInstances.page.field.preferredRemotePort`),children:(0,$.jsx)(yi,{min:1,max:65535,step:1,className:`tabular-nums`,value:D.remoteYuri.preferredPort,onValueChange:e=>{qn(t=>({...t,remoteYuri:{...t.remoteYuri,preferredPort:Number.isFinite(e)&&e>0?e:void 0}}))},onClear:()=>{qn(e=>({...e,remoteYuri:{...e.remoteYuri,preferredPort:void 0}}))},emptyLabel:e(`settings.remoteInstances.page.field.auto`)})}),_r?(0,$.jsx)(Z,{label:e(`settings.remoteInstances.page.field.installMethod`),children:(0,$.jsxs)(Cn,{value:D.remoteYuri.installMethod,onValueChange:e=>qn(t=>({...t,remoteYuri:{...t.remoteYuri,installMethod:e===`npm`||e===`download_release`||e===`upload_bundle`?e:`bun`}})),children:[(0,$.jsx)(bn,{children:(0,$.jsx)(Tn,{placeholder:e(`settings.remoteInstances.page.field.selectInstallMethodPlaceholder`)})}),(0,$.jsxs)(xn,{children:[(0,$.jsx)(vn,{value:`bun`,children:`bun`}),(0,$.jsx)(vn,{value:`npm`,children:`npm`}),(0,$.jsx)(vn,{value:`download_release`,children:e(`settings.remoteInstances.page.field.installMethodDownloadRelease`)}),(0,$.jsx)(vn,{value:`upload_bundle`,children:e(`settings.remoteInstances.page.field.installMethodUploadBundle`)})]})]})}):null,_r?(0,$.jsx)($r,{checked:D.remoteYuri.keepRunning,onChange:e=>qn(t=>({...t,remoteYuri:{...t.remoteYuri,keepRunning:e}})),label:e(`settings.remoteInstances.page.field.keepServerRunning`),ariaLabel:e(`settings.remoteInstances.page.field.keepServerRunning`)}):null]}),(0,$.jsxs)(X,{label:e(`settings.remoteInstances.page.section.mainTunnel`),children:[(0,$.jsx)(Z,{label:e(`settings.remoteInstances.page.field.bindHost`),children:(0,$.jsxs)(Cn,{value:D.localForward.bindHost,onValueChange:t=>{t===`0.0.0.0`&&!window.confirm(e(`settings.remoteInstances.page.confirm.bindAllInterfaces`))||qn(e=>({...e,localForward:{...e.localForward,bindHost:t===`localhost`||t===`0.0.0.0`?t:`127.0.0.1`}}))},children:[(0,$.jsx)(bn,{children:(0,$.jsx)(Tn,{placeholder:e(`settings.remoteInstances.page.field.selectBindHostPlaceholder`)})}),(0,$.jsxs)(xn,{children:[(0,$.jsx)(vn,{value:`127.0.0.1`,children:`127.0.0.1`}),(0,$.jsx)(vn,{value:`localhost`,children:`localhost`}),(0,$.jsx)(vn,{value:`0.0.0.0`,children:`0.0.0.0`})]})]})}),(0,$.jsxs)(Z,{label:e(`settings.remoteInstances.page.field.preferredLocalPort`),children:[(0,$.jsx)(yi,{min:1,max:65535,step:1,className:`tabular-nums`,value:D.localForward.preferredLocalPort,onValueChange:e=>{qn(t=>({...t,localForward:{...t.localForward,preferredLocalPort:Number.isFinite(e)&&e>0?e:void 0}}))},onClear:()=>{qn(e=>({...e,localForward:{...e.localForward,preferredLocalPort:void 0}}))},emptyLabel:e(`settings.remoteInstances.page.field.auto`)}),(0,$.jsx)(K,{type:`button`,variant:`outline`,size:`icon`,"aria-label":e(`settings.remoteInstances.page.actions.pickRandomPort`),onClick:()=>qn(e=>({...e,localForward:{...e.localForward,preferredLocalPort:Vd()}})),children:(0,$.jsx)(Y,{name:`shuffle`,className:`size-4`})})]})]}),(0,$.jsxs)(X,{label:e(`settings.remoteInstances.page.section.authentication`),children:[(0,$.jsx)(Z,{label:e(`settings.remoteInstances.page.field.sshPasswordOptional`),children:(0,$.jsx)(En,{type:`password`,value:D.auth.sshPassword?.value||``,onChange:e=>qn(t=>({...t,auth:{...t.auth,sshPassword:{enabled:e.target.value.trim().length>0,value:e.target.value,store:t.auth.sshPassword?.store||`never`}}})),placeholder:e(`settings.remoteInstances.page.field.sshPasswordPlaceholder`)})}),(0,$.jsx)(Z,{label:e(`settings.remoteInstances.page.field.uiPasswordOptional`),children:(0,$.jsx)(En,{type:`password`,value:D.auth.yuriPassword?.value||``,onChange:e=>qn(t=>({...t,auth:{...t.auth,yuriPassword:{enabled:e.target.value.trim().length>0,value:e.target.value,store:t.auth.yuriPassword?.store||`never`}}})),placeholder:e(`settings.remoteInstances.page.field.uiPasswordPlaceholder`)})})]}),_r?(0,$.jsx)(X,{label:e(`settings.remoteInstances.page.sync.runs.title`),children:k.length===0?(0,$.jsx)(`div`,{className:`yuri-settings-group-row typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.page.sync.runs.empty`)}):k.map(t=>(0,$.jsxs)(`div`,{className:`yuri-settings-group-row flex items-center gap-2 typography-meta`,children:[(0,$.jsx)(`span`,{className:G(`shrink-0`,t.result===`success`?`text-[var(--status-success)]`:`text-[var(--status-error)]`),children:t.result===`success`?e(`settings.remoteInstances.page.sync.runs.result.success`):e(`settings.remoteInstances.page.sync.runs.result.failure`)}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground`,children:[t.direction===`pull`?e(`settings.remoteInstances.page.sync.direction.pull`):e(`settings.remoteInstances.page.sync.direction.push`),t.endedAt?` · ${t.endedAt}`:``]})]},t.syncRunId))}):null,(0,$.jsxs)(X,{label:e(`settings.remoteInstances.page.section.portForwards`),children:[D.portForwards.length===0?(0,$.jsx)(`div`,{className:`yuri-settings-group-row typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.page.empty.noExtraForwards`)}):null,D.portForwards.map((t,n)=>{let r=e=>{qn(t=>({...t,portForwards:t.portForwards.map((t,r)=>r===n?e(t):t)}))},i=t.type===`remote`?e(`settings.remoteInstances.page.field.localTarget`):e(`settings.remoteInstances.page.field.localListen`),a=t.type===`remote`?e(`settings.remoteInstances.page.field.remoteListen`):e(`settings.remoteInstances.page.field.remoteTarget`),o=sf(t.localHost||`localhost`,t.localPort),s=sf(t.remoteHost||`localhost`,t.remotePort),c=t.type===`local`&&typeof t.localPort==`number`&&t.localPort>0,l=c?`http://${cf(t.localHost)}:${t.localPort}`:``,u=!!Se[t.id],d=t.type===`local`?e(`settings.remoteInstances.page.forwardType.local`):t.type===`remote`?e(`settings.remoteInstances.page.forwardType.remote`):e(`settings.remoteInstances.page.forwardType.dynamic`);return(0,$.jsxs)(Ui,{open:u,onOpenChange:e=>{Ce(n=>({...n,[t.id]:e}))},className:`yuri-settings-group-row`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex items-center gap-2`,children:(0,$.jsxs)(Hi,{className:`flex items-center gap-2 group`,children:[(0,$.jsx)(Y,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground transition-transform ${u?`rotate-180`:``}`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:nf(t)}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 shrink-0`,children:d})]})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(gn,{checked:t.enabled,onChange:e=>r(t=>({...t,enabled:e})),ariaLabel:e(`settings.remoteInstances.page.actions.enableForwardAria`)}),(0,$.jsx)(K,{type:`button`,variant:`destructive`,size:`icon`,"aria-label":e(`settings.remoteInstances.sidebar.actions.remove`),onClick:()=>qn(e=>({...e,portForwards:e.portForwards.filter(e=>e.id!==t.id)})),children:(0,$.jsx)(Y,{name:`delete-bin`,className:`size-4`})})]})]}),(0,$.jsx)(Vi,{className:`pt-2`,children:(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(Z,{label:e(`settings.remoteInstances.page.field.forwardType`),description:e(of(t.type)),children:(0,$.jsxs)(Cn,{value:t.type,onValueChange:e=>r(t=>({...t,type:e===`dynamic`||e===`remote`?e:`local`})),children:[(0,$.jsx)(bn,{children:(0,$.jsx)(Tn,{placeholder:e(`settings.remoteInstances.page.field.typePlaceholder`)})}),(0,$.jsxs)(xn,{children:[(0,$.jsx)(vn,{value:`local`,children:e(`settings.remoteInstances.page.forwardType.local`)}),(0,$.jsx)(vn,{value:`remote`,children:e(`settings.remoteInstances.page.forwardType.remote`)}),(0,$.jsx)(vn,{value:`dynamic`,children:e(`settings.remoteInstances.page.forwardType.dynamic`)})]})]})}),(0,$.jsx)(Z,{label:i,className:`yuri-settings-ssh-endpoint-row`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(En,{className:`min-w-0`,value:t.localHost||`127.0.0.1`,onChange:e=>r(t=>({...t,localHost:e.target.value})),placeholder:e(`settings.remoteInstances.page.field.localHostPlaceholder`)}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`:`}),(0,$.jsx)(yi,{min:1,max:65535,step:1,className:`tabular-nums`,value:t.localPort,onValueChange:e=>{r(t=>({...t,localPort:Number.isFinite(e)&&e>0?e:void 0}))},onClear:()=>{r(e=>({...e,localPort:void 0}))},emptyLabel:e(`settings.remoteInstances.page.field.auto`)})]})}),t.type===`dynamic`?null:(0,$.jsx)(Z,{label:a,className:`yuri-settings-ssh-endpoint-row`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(En,{className:`min-w-0`,value:t.remoteHost||``,onChange:e=>r(t=>({...t,remoteHost:e.target.value})),placeholder:e(`settings.remoteInstances.page.field.remoteHostPlaceholder`)}),(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:`:`}),(0,$.jsx)(yi,{min:1,max:65535,step:1,className:`tabular-nums`,value:t.remotePort,onValueChange:e=>{r(t=>({...t,remotePort:Number.isFinite(e)&&e>0?e:void 0}))},onClear:()=>{r(e=>({...e,remotePort:void 0}))},emptyLabel:e(`settings.remoteInstances.page.field.auto`)})]})}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 pt-2`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 typography-micro text-muted-foreground/80`,children:t.type===`dynamic`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Y,{name:`computer`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`font-mono text-foreground`,children:o}),(0,$.jsx)(`span`,{children:e(`settings.remoteInstances.page.preview.localSocks5`)})]}):t.type===`remote`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Y,{name:`server`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`font-mono text-foreground`,children:s}),(0,$.jsx)(`span`,{children:e(`settings.remoteInstances.page.preview.remote`)}),(0,$.jsx)(Y,{name:`arrow-right`,className:`h-3.5 w-3.5`}),(0,$.jsx)(Y,{name:`computer`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`font-mono text-foreground`,children:o}),(0,$.jsx)(`span`,{children:e(`settings.remoteInstances.page.preview.local`)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Y,{name:`computer`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`font-mono text-foreground`,children:o}),(0,$.jsx)(`span`,{children:e(`settings.remoteInstances.page.preview.local`)}),(0,$.jsx)(Y,{name:`arrow-right`,className:`h-3.5 w-3.5`}),(0,$.jsx)(Y,{name:`server`,className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`font-mono text-foreground`,children:s}),(0,$.jsx)(`span`,{children:e(`settings.remoteInstances.page.preview.remote`)})]})}),c?(0,$.jsxs)(K,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>{Wr(l).then(t=>{t||q.error(e(`settings.remoteInstances.page.toast.openLocalEndpointFailed`))})},children:[(0,$.jsx)(Y,{name:`external-link`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.actions.openLocal`)]}):null]})]})})]},t.id)}),(0,$.jsx)(`div`,{className:`yuri-settings-group-row`,children:(0,$.jsxs)(K,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>{let e=rf();qn(t=>({...t,portForwards:[...t.portForwards,e]})),Ce(t=>({...t,[e.id]:!0}))},children:[(0,$.jsx)(Y,{name:`add`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.actions.addForward`)]})})]}),(0,$.jsxs)(dn,{className:`flex-wrap`,children:[f?(0,$.jsx)(`div`,{className:`sm:mr-auto typography-meta text-[var(--status-error)]`,children:f}):null,Rn?.localUrl?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(K,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>{lr()},children:[(0,$.jsx)(Y,{name:`external-link`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.actions.open`)]}),(0,$.jsxs)(K,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>{Ve(Rn.localUrl||``).then(t=>{t.ok&&q.success(e(`settings.remoteInstances.page.toast.localUrlCopied`))})},children:[(0,$.jsx)(Y,{name:`file-copy`,className:`h-3.5 w-3.5`}),e(`settings.remoteInstances.page.actions.copyLocalUrl`)]})]}):null]}),(0,$.jsx)(qd,{open:ce,instanceId:ue,targetKind:fe,relayHost:me,onOpenChange:e=>{le(e),e||(de(null),pe(`ssh`),he(null))}}),(0,$.jsx)(hn,{open:j,onOpenChange:M,children:(0,$.jsxs)(fn,{className:`sm:max-w-2xl`,children:[(0,$.jsxs)(un,{children:[(0,$.jsx)(pn,{children:e(`settings.remoteInstances.page.logsDialog.title`)}),(0,$.jsx)(mn,{children:D?.nickname?.trim()||D?.sshParsed?.destination||D?.id||e(`settings.remoteInstances.page.logsDialog.selectedInstanceFallback`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,$.jsxs)(K,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:sr,disabled:N||!or.trim(),children:[(0,$.jsx)(Y,{name:`file-copy`,className:`h-3.5 w-3.5`}),e(`settings.common.actions.copyAll`)]}),(0,$.jsxs)(K,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void cr(),disabled:N,children:[(0,$.jsx)(Y,{name:`delete-bin`,className:`h-3.5 w-3.5`}),e(`settings.common.actions.clear`)]})]}),N?(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:e(`settings.remoteInstances.page.logsDialog.loading`)}):F?(0,$.jsx)(`div`,{className:`typography-meta text-[var(--status-error)]`,children:F}):(0,$.jsx)(`pre`,{className:`max-h-[55vh] overflow-auto rounded-md border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-3 typography-micro text-foreground whitespace-pre-wrap break-words`,children:R.length>0?R.join(`
|
|
25
25
|
`):e(`settings.remoteInstances.page.logsDialog.empty`)})]})}),(0,$.jsx)(hn,{open:!!ge,onOpenChange:e=>{e||Xn()},children:(0,$.jsxs)(fn,{className:`sm:max-w-md`,children:[(0,$.jsxs)(un,{children:[(0,$.jsx)(pn,{children:e(`settings.remoteInstances.page.patternDialog.title`)}),(0,$.jsx)(mn,{children:ge?e(`settings.remoteInstances.page.patternDialog.descriptionWithHost`,{host:ge}):e(`settings.remoteInstances.page.patternDialog.description`)})]}),(0,$.jsxs)(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),Qn()},children:[(0,$.jsx)(En,{value:ve,onChange:e=>ye(e.target.value),placeholder:e(`settings.remoteInstances.page.patternDialog.destinationPlaceholder`),autoFocus:!0}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,$.jsx)(K,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:Xn,disabled:be,children:e(`settings.common.actions.cancel`)}),(0,$.jsx)(K,{type:`submit`,size:`xs`,className:`!font-normal`,disabled:be,children:e(`settings.common.actions.create`)})]})]})]})})]})})},gf=`__add_provider__`,_f=()=>{let e=_e.getDirectory();return typeof e==`string`&&e.trim().length>0?e.trim():null},vf=({onItemSelect:e})=>{let{t}=He(),n=tn(e=>e.providers),r=tn(e=>e.selectedProviderId),i=tn(e=>e.setSelectedProvider),a=Lt(e=>e.activeProjectId),[o,s]=Q.useState({}),c=Q.useMemo(()=>_f(),[a]);Q.useEffect(()=>{if(n.length===0){s({});return}let e=!1;return(async()=>{let t=n.map(async t=>{try{let n=c?`?directory=${encodeURIComponent(c)}`:``,r=await p(`/api/provider/${encodeURIComponent(t.id)}/source${n}`,{method:`GET`,headers:{Accept:`application/json`}});if(!r.ok)return;let i=await r.json().catch(()=>null),a=i?.sources??i?.data?.sources;if(!a||e)return;s(e=>({...e,[t.id]:a}))}catch{}});await Promise.all(t)})(),()=>{e=!0}},[c,n]);let l=Q.useMemo(()=>n.filter(e=>!!o[e.id]?.project?.exists),[n,o]),u=Q.useMemo(()=>n.filter(e=>!o[e.id]?.project?.exists),[n,o]),d=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{children:t(`settings.providers.sidebar.section.userProviders`)}),(0,$.jsx)(K,{size:`icon`,variant:`ghost`,onClick:()=>{i(gf),e?.()},"aria-label":t(`settings.providers.sidebar.actions.connectProviderAria`),title:t(`settings.providers.sidebar.actions.connectProviderTitle`),children:(0,$.jsx)(Y,{name:`add`,className:`h-4 w-4`})})]});return(0,$.jsxs)(`div`,{className:`yuri-settings-page-content h-full overflow-y-auto bg-background p-3`,children:[(0,$.jsx)(to,{}),(0,$.jsx)($.Fragment,{children:n.length===0?(0,$.jsx)(X,{label:d,children:(0,$.jsxs)(`div`,{className:`yuri-settings-group-row py-12 text-center text-muted-foreground`,children:[(0,$.jsx)(Y,{name:`stack`,className:`mx-auto mb-3 h-10 w-10 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-ui-label font-medium`,children:t(`settings.providers.sidebar.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:t(`settings.providers.sidebar.empty.description`)})]})}):(0,$.jsxs)($.Fragment,{children:[u.length>0?(0,$.jsx)(X,{label:d,children:u.map(t=>(0,$.jsx)(yf,{provider:t,selectedProviderId:r,onSelect:()=>{i(t.id),e?.()}},t.id))}):(0,$.jsx)(X,{label:d,cardClassName:`hidden`,children:(0,$.jsx)(`span`,{})}),l.length>0&&(0,$.jsx)(X,{label:t(`settings.providers.sidebar.section.projectProviders`),children:l.map(t=>(0,$.jsx)(yf,{provider:t,selectedProviderId:r,onSelect:()=>{i(t.id),e?.()}},t.id))})]})})]})},yf=e=>{let t=(0,qi.c)(17),{provider:n,selectedProviderId:r,onSelect:i}=e,a=Array.isArray(n.models)?n.models.length:0,o=n.id===r,s=n.id,c=o?`bg-interactive-selection`:`hover:bg-interactive-hover`,l;t[0]===c?l=t[1]:(l=G(`yuri-settings-group-row group relative flex items-center transition-colors duration-150 !min-h-0 py-2`,c),t[0]=c,t[1]=l);let u;t[2]===n.id?u=t[3]:(u=(0,$.jsx)(_n,{providerId:n.id,className:`h-3.5 w-3.5 flex-shrink-0`}),t[2]=n.id,t[3]=u);let d=n.name||n.id,f;t[4]===d?f=t[5]:(f=(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate flex-1 min-w-0 text-foreground`,children:d}),t[4]=d,t[5]=f);let p;t[6]===a?p=t[7]:(p=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/60 flex-shrink-0`,children:a}),t[6]=a,t[7]=p);let m;t[8]!==i||t[9]!==u||t[10]!==f||t[11]!==p?(m=(0,$.jsxs)(`button`,{type:`button`,onClick:i,className:`flex min-w-0 flex-1 items-center gap-1.5 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,tabIndex:0,children:[u,f,p]}),t[8]=i,t[9]=u,t[10]=f,t[11]=p,t[12]=m):m=t[12];let h;return t[13]!==n.id||t[14]!==l||t[15]!==m?(h=(0,$.jsx)(`div`,{className:l,children:m},s),t[13]=n.id,t[14]=l,t[15]=m,t[16]=h):h=t[16],h},bf=(e,t)=>e.flatMap((e,n)=>t(e)?[{method:e,methodIndex:n}]:[]),xf=(e=_e.getDirectory())=>Oe({queryKey:[i(),o(),`provider-connections`,e??null],queryFn:async({signal:t})=>{let n=_e.getSdkClient(),r=e?{directory:e}:void 0,[i,a]=await Promise.all([n.provider.list({location:r},{signal:t}),n.integration.list({location:r},{signal:t})]);return{providers:i.data,integrations:a.data}}});function Sf(e){let t=_e.getSdkClient(),n=o(),r=_e.getDirectory(),i=r?{directory:r}:void 0,a=new AbortController,s,c,l,u=!1,d=!1,f=!1,p=()=>!a.signal.aborted&&n===o()&&r===_e.getDirectory(),m=()=>{clearTimeout(c),clearTimeout(l)},h=()=>{s&&!d&&!f&&n===o()&&(f=!0,t.integration.oauth.cancel({integrationID:e.integrationID,attemptID:s.attemptID,location:i}).catch(()=>void 0))},g=()=>{a.abort(),m(),h()},_=t=>{p()&&(g(),e.onError(t))},v=async()=>{p()&&(d=!0,m(),await e.onSuccess())},y=async()=>{if(!(!p()||!s))try{let n=await t.integration.oauth.status({integrationID:e.integrationID,attemptID:s.attemptID,location:i},{signal:a.signal});if(!p())return;if(n.data.status===`complete`){await v();return}if(n.data.status!==`pending`){_(`complete`);return}c=setTimeout(()=>{y()},1500)}catch{_(`complete`)}};return{cancel:g,isCurrent:p,async start(n){l=setTimeout(()=>_(`start`),3e4);try{if(s=(await t.integration.oauth.connect({integrationID:e.integrationID,methodID:n,location:i},{signal:a.signal})).data,!p()){h();return}if(clearTimeout(l),!s.attemptID||![`auto`,`code`].includes(s.mode)){_(`start`);return}let r=Math.min(6e5,(s.time?.expires??Date.now()+6e5)-Date.now());if(r<=0){_(`complete`);return}l=setTimeout(()=>_(`complete`),r),e.onAttempt(s),s.mode===`auto`&&y()}catch{_(`start`)}},async complete(n){if(!(!p()||!s||s.mode!==`code`||u||!n.trim())){u=!0;try{await t.integration.oauth.complete({integrationID:e.integrationID,attemptID:s.attemptID,code:n.trim(),location:i},{signal:a.signal}),await v()}catch{_(`complete`)}}}}}var Cf=`opencode`;function wf(e){return e===`opencode-go`?Cf:e}function Tf(e,t){let n=wf(e);return t?.find(e=>e.id===n)}function Ef(e){return(e?.connections??[]).some(e=>e.type===`credential`&&e.method===`oauth`)}function Df(e){return(e?.methods??[]).flatMap(e=>e.type===`oauth`&&typeof e.id==`string`&&e.id?[{id:e.id,label:e.label??e.name}]:[])}function Of(e,t){return t[wf(e)]??t[e]??[]}function kf(e,t){let n=wf(e);return n===e?t[e]||e:t[n]||n}var Af=({providerId:e,providerName:t})=>{let{t:n}=He(),[r,i]=Q.useState(null),[a,o]=Q.useState({}),[s,c]=Q.useState(!1),[l,u]=Q.useState(null),[d,f]=Q.useState(``),[m,h]=Q.useState(!1),g=Q.useRef(null),_=ke({...xf(),enabled:e===`opencode-go`}),v=`/api/quota/credentials/${e}`,y=e===`opencode-go`?Tf(e,_.data?.integrations):void 0,b=Ef(y),x=Df(y);Q.useEffect(()=>{p(v).then(async e=>{if(!e.ok)throw Error();let t=await e.json();i(t),o(t.workspaceId?{workspaceId:t.workspaceId}:{})}).catch(()=>i({configured:!1}))},[v]);let S=ze(()=>{g.current?.cancel(),g.current=null,u(null),f(``),h(!1)});Q.useEffect(()=>()=>{g.current?.cancel(),g.current=null},[]);let C=async(e,r,a)=>{c(!0);try{let s=await p(e,{method:r,headers:a?{"Content-Type":`application/json`}:void 0,body:a?JSON.stringify(a):void 0}),c=await s.json().catch(()=>null);if(!s.ok)throw Error(c?.error);c?.configured!==void 0&&i(c),o(e=>e.workspaceId?{workspaceId:e.workspaceId}:{}),q.success(n(`settings.providers.page.quotaCredentials.saved`,{provider:t}))}catch(e){q.error(e instanceof Error&&e.message?e.message:n(`settings.providers.page.openCodeGo.saveFailed`))}finally{c(!1)}},w=ze(async e=>{let t=wf(`opencode-go`);if(!e||t===`opencode-go`){q.error(n(`settings.providers.page.toast.oauthStartFailed`));return}S(),h(!0);let r=Sf({integrationID:t,onAttempt:({mode:t,url:r,instructions:i})=>{u({methodID:e,mode:t,url:r,instructions:i,userCode:/[A-Z0-9]{4}-[A-Z0-9]{4,5}/.exec(i)?.[0]}),t===`code`&&h(!1),r&&Wr(r),q.message(n(`settings.providers.page.toast.completeOAuthInBrowser`))},onSuccess:async()=>{u(null),f(``),h(!1);try{if(await mt({scopes:[`providers`],mode:`active`}),!r.isCurrent()||g.current!==r)return;await _.refetch({throwOnError:!0})}catch{r.isCurrent()&&g.current===r&&q.error(n(`settings.providers.page.toast.authMethodsLoadFailed`))}!r.isCurrent()||g.current!==r||q.success(n(`settings.providers.page.toast.oauthCompleted`))},onError:e=>{h(!1),u(null),f(``),q.error(n(e===`start`?`settings.providers.page.toast.oauthStartFailed`:`settings.providers.page.toast.oauthCompleteFailed`))}});g.current=r,await r.start(e)}),T=ze(async()=>{!d.trim()||l?.mode!==`code`||(h(!0),await g.current?.complete(d))}),E=ze(async(e,t,r)=>{(await Ve(e)).ok?q.success(n(t)):q.error(n(r))}),D=(e,t,n)=>(0,$.jsx)(Z,{label:t,children:(0,$.jsx)(En,{className:`w-full font-mono text-xs`,type:e===`workspaceId`?`text`:`password`,autoComplete:`off`,value:a[e]??``,onChange:t=>o(n=>({...n,[e]:t.target.value})),placeholder:r?.secretMasked??n})});return(0,$.jsx)(`div`,{"data-settings-item":`providers.${e}-credentials`,children:(0,$.jsxs)(X,{label:t,className:`yuri-settings-detail-group`,children:[e===`opencode-go`&&(0,$.jsx)($.Fragment,{children:_.isPending?(0,$.jsx)(`div`,{className:`yuri-settings-group-row`,children:(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:n(`settings.providers.page.auth.loadingMethods`)})}):b?(0,$.jsxs)(`div`,{className:`yuri-settings-group-row flex items-center gap-1.5`,role:`status`,children:[(0,$.jsx)(Y,{name:`check`,className:`h-4 w-4 shrink-0 text-[var(--status-success)]`}),(0,$.jsx)(`p`,{className:`min-w-0 typography-ui-label text-foreground`,children:n(`settings.providers.page.openCodeGo.consoleConnected`)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`yuri-settings-group-row`,children:(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:n(`settings.providers.page.openCodeGo.consoleHint`)})}),(x.length>0?x:[{id:``,label:void 0}]).map(e=>{let t=l?.methodID===e.id;return(0,$.jsxs)(`div`,{className:`yuri-settings-group-row`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`min-w-0 typography-ui-label text-foreground`,children:e.label||n(`settings.providers.page.openCodeGo.consoleSignIn`)}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(K,{size:`xs`,className:`!font-normal w-full sm:w-auto`,"aria-busy":m,disabled:m||!e.id,onClick:()=>void w(e.id),children:m&&l?.mode===`auto`?n(`settings.providers.page.state.loading`):n(`settings.providers.page.openCodeGo.consoleSignIn`)}),t&&(0,$.jsx)(K,{variant:`ghost`,size:`xs`,className:`!font-normal`,onClick:S,children:n(`settings.common.actions.cancel`)})]})]}),t&&l?.instructions&&(0,$.jsx)(`p`,{className:`mt-2 typography-meta text-[var(--primary-base)] bg-[var(--primary-base)]/10 px-2 py-1.5 rounded`,children:l.instructions}),t&&l?.userCode&&(0,$.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,$.jsx)(En,{value:l.userCode,readOnly:!0,className:`min-w-0 flex-1 font-mono text-center tracking-widest`}),(0,$.jsx)(K,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void E(l.userCode??``,`settings.providers.page.toast.deviceCodeCopied`,`settings.providers.page.toast.deviceCodeCopyFailed`),children:n(`settings.providers.page.actions.copyCode`)})]}),t&&l?.url&&(0,$.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,$.jsx)(En,{value:l.url,readOnly:!0,className:`min-w-0 flex-1 text-xs text-muted-foreground`}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[(0,$.jsx)(K,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>Wr(l.url??``),children:n(`settings.providers.page.actions.open`)}),(0,$.jsx)(K,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>void E(l.url??``,`settings.providers.page.toast.oauthLinkCopied`,`settings.providers.page.toast.oauthLinkCopyFailed`),children:n(`settings.providers.page.actions.copy`)})]})]}),t&&l?.mode===`code`&&(0,$.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,$.jsx)(En,{value:d,onChange:e=>f(e.target.value),placeholder:n(`settings.providers.page.auth.pasteAuthorizationCodePlaceholder`),className:`min-w-0 flex-1 font-mono text-xs`,"aria-label":n(`settings.providers.page.auth.pasteAuthorizationCodePlaceholder`)}),(0,$.jsx)(K,{size:`xs`,className:`!font-normal`,onClick:()=>void T(),disabled:m||!d.trim(),children:n(m?`settings.providers.page.actions.saving`:`settings.providers.page.actions.complete`)})]})]},e.id||`console`)})]})}),e===`opencode-go`&&D(`workspaceId`,n(`settings.providers.page.openCodeGo.workspaceId`),`wrk_...`),e===`opencode-go`&&D(`authCookie`,n(`settings.providers.page.openCodeGo.authCookie`),`auth=...`),e===`ollama-cloud`&&D(`cookie`,n(`settings.providers.page.openCodeGo.authCookie`),`session=...`),e===`cursor`&&D(`accessToken`,n(`settings.providers.page.auth.apiKeyLabel`),n(`settings.providers.page.auth.apiKeyPlaceholder`)),e===`cursor`&&D(`refreshToken`,n(`settings.providers.page.auth.apiKeyLabel`),n(`settings.providers.page.auth.apiKeyPlaceholder`)),(0,$.jsxs)(`div`,{className:`yuri-settings-group-row flex flex-wrap gap-2`,children:[(0,$.jsx)(K,{size:`xs`,disabled:s,onClick:()=>C(v,`PUT`,a),children:r?.configured?n(`settings.providers.page.openCodeGo.replace`):n(`settings.providers.page.openCodeGo.save`)}),r?.configured&&(0,$.jsx)(K,{variant:`outline`,size:`xs`,disabled:s,onClick:()=>C(`${v}/validate`,`POST`),children:n(`settings.providers.page.openCodeGo.validate`)}),e===`cursor`&&(0,$.jsx)(K,{variant:`outline`,size:`xs`,disabled:s,onClick:()=>C(`${v}/import`,`POST`),children:n(`settings.providers.page.actions.connect`)}),r?.configured&&(0,$.jsx)(K,{variant:`destructive`,size:`xs`,disabled:s,onClick:()=>C(v,`DELETE`),children:n(`settings.providers.page.openCodeGo.delete`)})]})]})})},jf=e=>{let t=(0,qi.c)(13),{itemId:n,label:r,description:i,action:a,rows:o,children:s}=e,c=o!==void 0&&o,l;t[0]!==a||t[1]!==r?(l=a?(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:`min-w-0`,children:r}),(0,$.jsx)(`div`,{className:`shrink-0`,children:a})]}):r,t[0]=a,t[1]=r,t[2]=l):l=t[2];let u;t[3]!==s||t[4]!==c?(u=c?s:(0,$.jsx)(`div`,{className:`yuri-settings-group-row`,children:s}),t[3]=s,t[4]=c,t[5]=u):u=t[5];let d;t[6]!==i||t[7]!==l||t[8]!==u?(d=(0,$.jsx)(X,{className:`yuri-settings-detail-group`,label:l,description:i,children:u}),t[6]=i,t[7]=l,t[8]=u,t[9]=d):d=t[9];let f;return t[10]!==n||t[11]!==d?(f=(0,$.jsx)(`div`,{"data-settings-item":n,children:d}),t[10]=n,t[11]=d,t[12]=f):f=t[12],f},Mf=e=>new Intl.NumberFormat(Ge(),{notation:`compact`,compactDisplay:`short`,maximumFractionDigits:1,minimumFractionDigits:0}).format(e),Nf=e=>{if(typeof e!=`number`||Number.isNaN(e))return null;if(e===0)return`0`;let t=Mf(e);return t.endsWith(`.0`)?t.slice(0,-2):t},Pf=`__add_provider__`,Ff=e=>{let t=typeof e.type==`string`?e.type:``,n=`${t} ${`${e.name??``} ${e.label??``}`.toLowerCase()}`.toLowerCase();return n.includes(`oauth`)?`oauth`:n.includes(`api`)?`api`:t.toLowerCase()},If=(e,t,n)=>{let r=t.find(t=>t.id===e);return typeof r?.integrationID==`string`&&r.integrationID?r.integrationID:(n.some(t=>t.id===e),e)},Lf=(e,t)=>{let n={},r={},i=new Map(t.filter(e=>typeof e.id==`string`&&e.id.length>0).map(e=>[e.id,e])),a=(e,t)=>{r[e]=t.id??e,n[e]=(t.methods??[]).map(e=>({type:e.type,id:e.id,name:e.label??e.name,label:e.label??e.name}))};for(let n of e){if(typeof n.id!=`string`||!n.id)continue;let r=If(n.id,e,t),o=i.get(r);o&&a(n.id,o)}for(let e of t)typeof e.id!=`string`||!e.id||n[e.id]||a(e.id,e);return{methodsByProvider:n,integrationIdByProvider:r}},Rf=()=>{let e=(0,qi.c)(2),t=`${Q.useSyncExternalStore(r,o,o)}:${he(Bf)}`,n;return e[0]===t?n=e[1]:(n=(0,$.jsx)(zf,{},t),e[0]=t,e[1]=n),n},zf=()=>{let{t:e}=He(),t=tn(e=>e.providers),n=tn(e=>e.selectedProviderId),r=tn(e=>e.setSelectedProvider),a=tn(e=>e.getModelMetadata),s=W(e=>e.hiddenModels),c=W(e=>e.toggleHiddenModel),l=W(e=>e.hideAllModels),u=W(e=>e.showAllModels),d=ke(xf()),{methodsByProvider:f,integrationIdByProvider:m}=Q.useMemo(()=>Lf(d.data?.providers??[],d.data?.integrations??[]),[d.data]),h=d.isPending;Q.useEffect(()=>{d.isError&&q.error(e(`settings.providers.page.toast.authMethodsLoadFailed`))},[d.isError,e]);let[g,_]=Q.useState({}),[v,y]=Q.useState(null),[b,x]=Q.useState(``),[S,C]=Q.useState(null),[w,T]=Q.useState({}),[E,D]=Q.useState({}),O=d.isPending,k=d.isError?e(`settings.providers.page.state.unableToLoadProviderList`):null,[A,j]=Q.useState(``),[M,N]=Q.useState(``),[P,F]=Q.useState(!1),[I,L]=Q.useState({}),[R,z]=Q.useState(!1),B=n===Pf,V=Q.useRef(null);Q.useEffect(()=>{let e=new AbortController;return V.current=e,()=>e.abort()},[]);let ee=ze(()=>{let e=V.current;if(!e||e.signal.aborted)return null;let t=_e.getDirectory(),n=o();return{directory:t,location:t?{directory:t}:void 0,transportIdentity:i(),signal:e.signal,isCurrent:()=>V.current===e&&!e.signal.aborted&&o()===n&&_e.getDirectory()===t}}),H=Q.useRef(null),te=ze(()=>{H.current?.cancel(),H.current=null,C(null),D({}),T({}),y(null)});Q.useEffect(()=>(te(),()=>{H.current?.cancel(),H.current=null}),[n,A,te]),Q.useEffect(()=>{!n&&t.length>0&&r(t[0].id)},[t,n,r]);let ne=Q.useMemo(()=>(d.data?.integrations??[]).filter(e=>!e.id.startsWith(`mcp_`)&&e.connections.length===0).sort((e,t)=>{let n=(e.name||e.id).toLowerCase(),r=(t.name||t.id).toLowerCase();return n.localeCompare(r)}),[d.data]);Q.useEffect(()=>{n===Pf&&A&&!ne.some(e=>e.id===A)&&j(``)},[n,A,ne]),Q.useEffect(()=>{if(n===Pf){z(!0);return}z(!1)},[n,e]),Q.useEffect(()=>{if(!n||n===Pf)return;let t=!1;return(async()=>{try{let r=await p(`/api/provider/${encodeURIComponent(n)}/source`,{method:`GET`,headers:{Accept:`application/json`}}),i=await r.json().catch(()=>null);if(!r.ok)throw Error(i?.error||e(`settings.providers.page.toast.providerSourcesLoadFailed`));let a=i?.sources??i?.data?.sources;!t&&a&&L(e=>({...e,[n]:a}))}catch(e){t||console.error(`Failed to load provider sources:`,e)}})(),()=>{t=!0}},[n,e]);let U=t.find(e=>e.id===n),re=n?I[n]:void 0,ie=ze(async t=>{let n=g[t]?.trim()??``;if(!n){q.error(e(`settings.providers.page.toast.apiKeyRequired`));return}let i=ee();if(!i)return;let a=`api:${t}`;y(a);try{let a=m[t]||t;if(await _e.getSdkClient().integration.connect.key({integrationID:a,key:n,location:i.location},{signal:i.signal}),!i.isCurrent()||(_(e=>({...e,[t]:``})),await mt({scopes:[`providers`],mode:`active`,queryDirectory:i.directory,transportIdentity:i.transportIdentity}),!i.isCurrent()))return;let o=await d.refetch({throwOnError:!0});if(!i.isCurrent())return;let s=o.data?.providers.find(e=>e.id===t||e.integrationID===a);s&&r(s.id),q.success(e(`settings.providers.page.toast.apiKeySaved`))}catch{i.isCurrent()&&q.error(e(`settings.providers.page.toast.apiKeySaveFailed`))}finally{i.isCurrent()&&y(null)}}),ae=ze(async(t,n)=>{te();let i=`oauth:${t}:${n}`;y(i);let a=Of(t,f)[n],o=typeof a?.id==`string`?a.id:``;if(!o){y(null),q.error(e(`settings.providers.page.toast.oauthStartFailed`));return}let s=kf(t,m),c=m[t]||t,l=Sf({integrationID:s,onAttempt:({attemptID:r,mode:i,url:a,instructions:c})=>{D({[`${t}:${n}`]:{url:a,instructions:c,mode:i,userCode:/[A-Z0-9]{4}-[A-Z0-9]{4,5}/.exec(c)?.[0]}}),C({providerId:t,methodIndex:n,methodID:o,attemptID:r,mode:i}),i===`code`&&y(null),a&&s!==`claude-code`&&Wr(a),q.message(e(`settings.providers.page.toast.completeOAuthInBrowser`))},onSuccess:async()=>{if(C(null),D({}),T({}),await mt({scopes:[`providers`],mode:`active`}),!l.isCurrent()||H.current!==l)return;let n=await d.refetch({throwOnError:!0});if(!l.isCurrent()||H.current!==l)return;q.success(e(`settings.providers.page.toast.oauthCompleted`));let i=n.data?.providers.find(e=>e.id===t)??(s===c?n.data?.providers.find(e=>e.integrationID===s):void 0);i&&r(i.id),y(null)},onError:t=>{y(null),C(null),D({}),T({}),q.error(e(t===`start`?`settings.providers.page.toast.oauthStartFailed`:`settings.providers.page.toast.oauthCompleteFailed`))}});H.current=l,await l.start(o)}),oe=ze(async(e,t)=>{let n=`${e}:${t}`,r=w[n]?.trim();!r||S?.mode!==`code`||S.providerId!==e||S.methodIndex!==t||(y(`oauth-complete:${e}:${t}`),await H.current?.complete(r))}),se=async t=>{if((await Ve(t)).ok){q.success(e(`settings.providers.page.toast.oauthLinkCopied`));return}q.error(e(`settings.providers.page.toast.oauthLinkCopyFailed`))},ce=async t=>{if((await Ve(t)).ok){q.success(e(`settings.providers.page.toast.deviceCodeCopied`));return}q.error(e(`settings.providers.page.toast.deviceCodeCopyFailed`))},le=ze(async t=>{let n=ee();if(!n)return;let r=`disconnect:${t}`;y(r);try{let r=_e.getSdkClient(),i=m[t]||t,a=await r.integration.get({integrationID:i,location:n.location},{signal:n.signal});if(!n.isCurrent())return;let o=(Array.isArray(a.data?.connections)?a.data.connections:[]).flatMap(e=>e.type===`credential`&&typeof e.id==`string`&&e.id?[e.id]:[]);if(o.length===0)throw Error(e(`settings.providers.page.toast.providerDisconnectFailed`));if(await Promise.all(o.map(e=>r.credential.remove({credentialID:e},{signal:n.signal}))),!n.isCurrent()||(await mt({scopes:[`providers`],mode:`active`,queryDirectory:n.directory,transportIdentity:n.transportIdentity}),!n.isCurrent())||(await d.refetch({throwOnError:!0}),!n.isCurrent()))return;q.success(e(`settings.providers.page.toast.providerDisconnected`))}catch{n.isCurrent()&&q.error(e(`settings.providers.page.toast.providerDisconnectFailed`))}finally{n.isCurrent()&&y(null)}});if(!B&&t.length===0)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(Y,{name:`stack`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.providers.page.empty.noProvidersDetected`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.providers.page.empty.checkOpenCodeConfiguration`)})]})});if(B)return(0,$.jsx)(Rr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsx)(`div`,{"data-settings-item":`providers.connect`,children:(0,$.jsx)(`h1`,{className:`typography-ui-header font-semibold text-foreground`,children:e(`settings.providers.page.connect.title`)})}),(0,$.jsxs)(jf,{label:e(`settings.providers.page.connect.selectProviderTitle`),children:[k&&(0,$.jsx)(`p`,{role:`alert`,className:`typography-meta text-muted-foreground`,children:k}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 py-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.providers.page.connect.providerField`)}),O?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.providers.page.state.loading`)}):k&&!d.data?(0,$.jsx)(K,{variant:`outline`,size:`xs`,onClick:()=>void d.refetch(),children:e(`settings.providers.page.actions.reconnect`)}):ne.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.providers.page.connect.allProvidersConnected`)}):(0,$.jsxs)(Cr,{open:P,onOpenChange:e=>{F(e),e||N(``)},children:[(0,$.jsx)(kr,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:G(`flex items-center justify-between gap-2 rounded-lg border border-input bg-transparent px-2 py-2 typography-ui-label whitespace-nowrap shadow-none outline-none hover:bg-interactive-hover h-6 w-fit`),children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2 min-w-0`,children:[A?(0,$.jsx)(_n,{providerId:A,className:`h-3.5 w-3.5 flex-shrink-0`}):null,(0,$.jsx)(`span`,{className:G(`truncate typography-ui-label font-normal`,A?`text-foreground`:`text-muted-foreground`),children:A?ne.find(e=>e.id===A)?.name||A:e(`settings.providers.page.connect.selectProviderPlaceholder`)})]}),(0,$.jsx)(Y,{name:`arrow-down-s`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground/50`})]})}),(0,$.jsxs)(hr,{align:`start`,className:`w-[280px] p-0`,onCloseAutoFocus:e=>e.preventDefault(),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-[var(--surface-subtle)] px-3 py-2`,onKeyDown:e=>e.stopPropagation(),children:[(0,$.jsx)(Y,{name:`search`,className:`h-4 w-4 text-muted-foreground`}),(0,$.jsx)(`input`,{type:`text`,value:M,onChange:e=>N(e.target.value),onKeyDown:e=>e.stopPropagation(),placeholder:e(`settings.providers.page.connect.searchProvidersPlaceholder`),className:`flex-1 bg-transparent typography-meta outline-none placeholder:text-muted-foreground`,autoFocus:!0})]}),(0,$.jsx)(Rr,{outerClassName:`max-h-[240px]`,className:`p-1`,children:(()=>{let t=ne.filter(e=>{let t=M.toLowerCase();return(e.name||e.id).toLowerCase().includes(t)||e.id.toLowerCase().includes(t)});return t.length===0?(0,$.jsx)(`p`,{className:`py-4 text-center typography-meta text-muted-foreground`,children:e(`settings.providers.page.connect.noProvidersFound`)}):t.map(e=>(0,$.jsxs)(ar,{onSelect:()=>{j(e.id),F(!1),N(``)},className:`flex items-center justify-between`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(_n,{providerId:e.id,className:`h-4 w-4 flex-shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.name||e.id})]}),A===e.id&&(0,$.jsx)(Y,{name:`check`,className:`h-4 w-4 text-[var(--primary-base)]`})]},e.id))})()})]})]})]})]}),A&&(0,$.jsx)(jf,{itemId:`providers.auth`,label:e(`settings.providers.page.auth.title`),rows:!h,children:h?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.providers.page.auth.loadingMethods`)}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{className:`yuri-settings-split-row-stacked`,label:(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[e(`settings.providers.page.auth.apiKeyLabel`),(0,$.jsxs)(kn,{children:[(0,$.jsx)(Dn,{asChild:!0,children:(0,$.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(On,{sideOffset:8,className:`max-w-xs`,children:e(`settings.providers.page.auth.apiKeyTooltip`)})]})]}),children:(0,$.jsxs)(`div`,{className:`yuri-settings-value-inline`,children:[(0,$.jsx)(En,{type:`password`,value:g[A]??``,onChange:e=>_(t=>({...t,[A]:e.target.value})),placeholder:e(`settings.providers.page.auth.apiKeyPlaceholder`),className:`yuri-settings-value-inline-input font-mono text-xs`}),(0,$.jsx)(K,{size:`xs`,className:`!font-normal`,onClick:()=>ie(A),disabled:v===`api:${A}`,children:v===`api:${A}`?e(`settings.providers.page.actions.saving`):e(`settings.providers.page.actions.saveKey`)})]})}),(()=>{let t=bf(Of(A,f),e=>Ff(e)===`oauth`);return t.length===0?null:(0,$.jsx)(`div`,{className:`yuri-settings-group-row space-y-4`,children:t.map(({method:t,methodIndex:n},r)=>{let i=t.label||t.name||e(`settings.providers.page.auth.oauthMethodFallback`,{index:String(r+1)}),a=`${A}:${n}`,o=S?.providerId===A&&S?.methodIndex===n;return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:i}),(t.description||t.help)&&(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:String(t.description||t.help)})]}),(0,$.jsx)(K,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>ae(A,n),disabled:v===`oauth:${A}:${n}`||v===`oauth-complete:${A}:${n}`,children:o&&S.mode===`auto`?e(`settings.providers.page.state.loading`):e(`settings.providers.page.actions.connect`)}),o&&(0,$.jsx)(K,{variant:`ghost`,size:`xs`,onClick:te,children:e(`settings.common.actions.cancel`)})]}),E[a]?.instructions&&(0,$.jsx)(`p`,{className:`typography-meta text-[var(--primary-base)] bg-[var(--primary-base)]/10 px-2 py-1.5 rounded`,children:E[a]?.instructions}),E[a]?.userCode&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,$.jsx)(En,{value:E[a]?.userCode,readOnly:!0,className:`font-mono text-center tracking-widest`}),(0,$.jsx)(K,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>ce(E[a]?.userCode??``),children:e(`settings.providers.page.actions.copyCode`)})]}),E[a]?.url&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,$.jsx)(En,{value:E[a]?.url,readOnly:!0,className:`text-xs text-muted-foreground`}),(0,$.jsxs)(`div`,{className:`flex gap-1 shrink-0`,children:[(0,$.jsx)(K,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>Wr(E[a]?.url??``),children:e(`settings.providers.page.actions.open`)}),(0,$.jsx)(K,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>se(E[a]?.url??``),children:e(`settings.providers.page.actions.copy`)})]})]}),o&&S?.mode===`code`&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,$.jsx)(En,{value:w[a]??``,onChange:e=>T(t=>({...t,[a]:e.target.value})),placeholder:e(`settings.providers.page.auth.pasteAuthorizationCodePlaceholder`),className:`font-mono text-xs`}),(0,$.jsx)(K,{size:`xs`,className:`!font-normal`,onClick:()=>oe(A,n),disabled:v===`oauth-complete:${A}:${n}`,children:v===`oauth-complete:${A}:${n}`?e(`settings.providers.page.actions.saving`):e(`settings.providers.page.actions.complete`)})]})]},`${A}-${i}`)})})})()]})})]})});if(!U)return(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,$.jsx)(Y,{name:`stack`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.providers.page.empty.selectProviderFromSidebar`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:e(`settings.providers.page.empty.reviewDetailsAndConfigureAuth`)})]})});let ue=Array.isArray(U.models)?U.models:[],de=bf(Of(U.id,f),e=>Ff(e)===`oauth`),fe=ue.filter(e=>{let t=typeof e?.name==`string`?e.name:``,n=typeof e?.id==`string`?e.id:``,r=b.trim().toLowerCase();return!r||t.toLowerCase().includes(r)||n.toLowerCase().includes(r)});return(0,$.jsx)(Rr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(_n,{providerId:U.id,className:`h-5 w-5 shrink-0`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:U.name||U.id}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:(0,$.jsx)(`span`,{className:`font-mono`,children:U.id})})]})]}),(0,$.jsx)(jf,{itemId:`providers.auth`,rows:R&&!h,label:e(`settings.providers.page.auth.title`),action:(0,$.jsx)(K,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>{te(),z(e=>!e)},children:e(R?`settings.common.actions.cancel`:`settings.providers.page.actions.reconnect`)}),children:R?h?(0,$.jsx)(`div`,{className:`py-1.5 typography-meta text-muted-foreground`,children:e(`settings.providers.page.auth.loadingMethods`)}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{className:`yuri-settings-split-row-stacked`,label:(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[e(`settings.providers.page.auth.apiKeyLabel`),(0,$.jsxs)(kn,{children:[(0,$.jsx)(Dn,{asChild:!0,children:(0,$.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(On,{sideOffset:8,className:`max-w-xs`,children:e(`settings.providers.page.auth.apiKeyTooltip`)})]})]}),children:(0,$.jsxs)(`div`,{className:`yuri-settings-value-inline`,children:[(0,$.jsx)(En,{type:`password`,value:g[U.id]??``,onChange:e=>_(t=>({...t,[U.id]:e.target.value})),placeholder:e(`settings.providers.page.auth.apiKeyPlaceholder`),className:`yuri-settings-value-inline-input font-mono text-xs`}),(0,$.jsx)(K,{size:`xs`,className:`!font-normal`,onClick:()=>ie(U.id),disabled:v===`api:${U.id}`,children:v===`api:${U.id}`?e(`settings.providers.page.actions.saving`):e(`settings.providers.page.actions.saveKey`)})]})}),de.length>0&&(0,$.jsx)(`div`,{className:`yuri-settings-group-row space-y-4`,children:de.map(({method:t,methodIndex:n},r)=>{let i=t.label||t.name||e(`settings.providers.page.auth.oauthMethodFallback`,{index:String(r+1)}),a=`${U.id}:${n}`,o=S?.providerId===U.id&&S?.methodIndex===n;return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:i}),(t.description||t.help)&&(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:String(t.description||t.help)})]}),(0,$.jsx)(K,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>ae(U.id,n),disabled:v===`oauth:${U.id}:${n}`||v===`oauth-complete:${U.id}:${n}`,children:o&&S.mode===`auto`?e(`settings.providers.page.state.loading`):e(`settings.providers.page.actions.connect`)}),o&&(0,$.jsx)(K,{variant:`ghost`,size:`xs`,onClick:te,children:e(`settings.common.actions.cancel`)})]}),E[a]?.instructions&&(0,$.jsx)(`p`,{className:`typography-meta text-[var(--primary-base)] bg-[var(--primary-base)]/10 px-2 py-1.5 rounded`,children:E[a]?.instructions}),E[a]?.userCode&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,$.jsx)(En,{value:E[a]?.userCode,readOnly:!0,className:`font-mono text-center tracking-widest`}),(0,$.jsx)(K,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>ce(E[a]?.userCode??``),children:e(`settings.providers.page.actions.copyCode`)})]}),E[a]?.url&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,$.jsx)(En,{value:E[a]?.url,readOnly:!0,className:`text-xs text-muted-foreground`}),(0,$.jsxs)(`div`,{className:`flex gap-1 shrink-0`,children:[(0,$.jsx)(K,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>Wr(E[a]?.url??``),children:e(`settings.providers.page.actions.open`)}),(0,$.jsx)(K,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>se(E[a]?.url??``),children:e(`settings.providers.page.actions.copy`)})]})]}),o&&S?.mode===`code`&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,$.jsx)(En,{value:w[a]??``,onChange:e=>T(t=>({...t,[a]:e.target.value})),placeholder:e(`settings.providers.page.auth.pasteAuthorizationCodePlaceholder`),className:`font-mono text-xs`}),(0,$.jsx)(K,{size:`xs`,className:`!font-normal`,onClick:()=>oe(U.id,n),disabled:v===`oauth-complete:${U.id}:${n}`,children:v===`oauth-complete:${U.id}:${n}`?e(`settings.providers.page.actions.saving`):e(`settings.providers.page.actions.complete`)})]})]},`${U.id}-${i}`)})})]}):(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 py-1.5`,children:[(0,$.jsx)(Y,{name:`check`,className:`w-4 h-4 text-[var(--status-success)] shrink-0`}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.providers.page.auth.connected`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground ml-1`,children:e(`settings.providers.page.auth.useReconnectHint`)})]})}),(U.id===`opencode`||U.id===`opencode-go`)&&(0,$.jsx)(Af,{providerId:`opencode-go`,providerName:`OpenCode Go`}),(U.id===`ollama`||U.id===`ollama-cloud`)&&(0,$.jsx)(Af,{providerId:`ollama-cloud`,providerName:`Ollama Cloud`}),U.id===`cursor`&&(0,$.jsx)(Af,{providerId:`cursor`,providerName:`Cursor`}),(0,$.jsx)(jf,{itemId:`providers.connection-details`,label:e(`settings.providers.page.connectionDetails.title`),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 py-1.5 sm:flex-row sm:items-center sm:justify-between sm:gap-8`,children:[(0,$.jsx)(`div`,{className:`flex min-w-0 flex-col`,children:re&&(re.auth.exists||re.user.exists||re.project.exists||re.custom?.exists)?(0,$.jsxs)(`span`,{className:`typography-meta text-muted-foreground`,children:[e(`settings.providers.page.connectionDetails.configuredIn`),` `,[re.auth.exists?e(`settings.providers.page.connectionDetails.source.authCredentials`):null,re.user.exists?e(`settings.providers.page.connectionDetails.source.userConfig`):null,re.project.exists?e(`settings.providers.page.connectionDetails.source.projectConfig`):null,re.custom?.exists?e(`settings.providers.page.connectionDetails.source.customConfig`):null].filter(Boolean).join(`, `)]}):(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:e(`settings.providers.page.connectionDetails.noActiveSource`)})}),(0,$.jsx)(K,{variant:`ghost`,size:`xs`,className:`!font-normal text-[var(--status-error)] hover:text-[var(--status-error)]`,onClick:()=>le(U.id),disabled:v===`disconnect:${U.id}`,children:v===`disconnect:${U.id}`?e(`settings.providers.page.actions.disconnecting`):e(`settings.providers.page.actions.disconnect`)})]})}),(0,$.jsxs)(jf,{itemId:`providers.models`,label:(0,$.jsxs)($.Fragment,{children:[e(`settings.providers.page.models.title`),ue.length>0&&(0,$.jsxs)(`span`,{className:`ml-1.5 typography-micro text-muted-foreground font-normal`,children:[`(`,ue.length,`)`]})]}),action:(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(K,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>{let e=ue.map(e=>typeof e?.id==`string`?e.id:``).filter(e=>e.length>0);l(U.id,e)},children:e(`settings.providers.page.actions.hideAll`)}),(0,$.jsx)(K,{variant:`outline`,size:`xs`,className:`!font-normal`,onClick:()=>u(U.id),children:e(`settings.providers.page.actions.showAll`)})]}),children:[(0,$.jsxs)(`div`,{className:`relative mb-2`,children:[(0,$.jsx)(Y,{name:`search`,className:`absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,$.jsx)(En,{value:b,onChange:e=>x(e.target.value),placeholder:e(`settings.providers.page.models.filterPlaceholder`),className:`h-7 pl-8 w-full`})]}),fe.length===0?(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground py-4 text-center`,children:e(`settings.providers.page.models.noModelsMatchFilter`)}):(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:fe.map(t=>{let n=typeof t?.id==`string`?t.id:``,r=typeof t?.name==`string`?t.name:n,i=n?a(U.id,n):void 0,o=s.some(e=>e.providerID===U.id&&e.modelID===n),l=Nf(i?.limit?.context),u=Nf(i?.limit?.output),d=[];return i?.tool_call&&d.push({key:`tools`,icon:`tools`,label:e(`settings.providers.page.models.capability.toolCalling`)}),i?.reasoning&&d.push({key:`reasoning`,icon:`brain-ai-3`,label:e(`settings.providers.page.models.capability.reasoning`)}),i?.attachment&&d.push({key:`image`,icon:`file-image`,label:e(`settings.providers.page.models.capability.imageInput`)}),(0,$.jsx)(`div`,{className:`py-1.5`,children:(0,$.jsxs)(`div`,{className:G(`flex flex-wrap items-center gap-x-3 gap-y-1.5 md:flex-nowrap md:gap-3`,o&&`opacity-50`),children:[(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground truncate w-full min-w-0 md:w-auto md:flex-1`,children:r}),(0,$.jsxs)(`div`,{className:`flex w-full flex-wrap items-center gap-2 flex-shrink-0 md:w-auto md:flex-nowrap`,children:[(l||u)&&(0,$.jsxs)(`span`,{className:`typography-micro text-muted-foreground flex-shrink-0 bg-[var(--surface-muted)] px-1.5 py-0.5 rounded`,children:[l?`${l} ${e(`settings.providers.page.models.tokenBadge.context`)}`:``,l&&u?` · `:``,u?`${u} ${e(`settings.providers.page.models.tokenBadge.output`)}`:``]}),d.length>0&&(0,$.jsx)(`div`,{className:`flex items-center gap-1 flex-shrink-0`,children:d.map(({key:e,icon:t,label:n})=>(0,$.jsx)(`span`,{className:`flex h-5 w-5 rounded items-center justify-center text-muted-foreground bg-[var(--surface-muted)]`,title:n,"aria-label":n,children:(0,$.jsx)(Y,{name:t,className:`h-3 w-3`})},e))}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>c(U.id,n),className:`ml-auto flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50 md:ml-0`,title:e(o?`settings.providers.page.models.actions.showModelInSelectors`:`settings.providers.page.models.actions.hideModelFromSelectors`),"aria-label":e(o?`settings.providers.page.models.actions.showModel`:`settings.providers.page.models.actions.hideModel`),children:o?(0,$.jsx)(Y,{name:`eye-off`,className:`h-3.5 w-3.5`}):(0,$.jsx)(Y,{name:`eye`,className:`h-3.5 w-3.5`})})]})]})},n)})})]})]})})};function Bf(e){return e.currentDirectory}function Vf(){let{t:e}=He(),t=li(e=>e.magpieUsageUrl),n=li(e=>e.magpieSources),r=li(e=>e.magpieError),a=li(e=>e.fetchMagpieQuotas),[o,s]=Q.useState(null),[c,l]=Q.useState(!1),[u,d]=Q.useState(!1),f=Q.useId(),p=n.reduce((e,t)=>e+t.results.length,0),m=i();Q.useEffect(()=>{s(null),d(!1)},[m]);let h=ze(async()=>{let e=i(),n=(o??t).trim();l(!0),d(!1);try{if(n){let e=new URL(n);if(![`http:`,`https:`].includes(e.protocol)||e.username||e.password||e.search||e.hash)throw Error(`Invalid URL`)}if(await O({magpieUsageUrl:n}),e!==i())return;li.setState({magpieUsageUrl:n}),s(null),await a()}catch{e===i()&&d(!0)}finally{l(!1)}});return(0,$.jsx)(X,{label:`Magpie`,itemId:`usage.magpie`,actions:(0,$.jsx)(K,{size:`sm`,onClick:h,disabled:c||o===null||o===t,"aria-busy":c,children:e(`settings.usage.magpie.save`)}),children:(0,$.jsxs)(`div`,{className:`yuri-settings-group-row min-w-0`,children:[(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground break-words`,children:p>0?e(`settings.usage.magpie.connected`,{count:p}):e(`settings.usage.magpie.description`)}),(r||n.some(e=>e.identified&&e.error))&&(0,$.jsx)(`p`,{role:`status`,className:`typography-meta text-muted-foreground`,children:e(`settings.usage.magpie.unavailable`)}),(0,$.jsxs)(`details`,{className:`mt-2 min-w-0`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer typography-meta text-muted-foreground hover:text-foreground`,children:e(`settings.usage.magpie.manual`)}),(0,$.jsxs)(`div`,{className:`mt-3 flex min-w-0 flex-col gap-2`,children:[(0,$.jsx)(`label`,{htmlFor:f,className:`typography-meta text-muted-foreground`,children:e(`settings.usage.magpie.url`)}),(0,$.jsx)(En,{id:f,className:`w-full min-w-0`,value:o??t,disabled:c,onChange:e=>s(e.target.value),"aria-label":e(`settings.usage.magpie.url`)}),u&&(0,$.jsx)(`p`,{role:`alert`,className:`typography-meta text-[var(--status-error)]`,children:e(`settings.usage.page.state.refreshFailedTitle`)})]})]})]})})}var Hf=e=>{let t=e?.windows??{},n=Object.values(t).map(e=>e.usedPercent).filter(e=>typeof e==`number`);return n.length===0?null:Math.max(...n)},Uf=e=>{let t=(0,qi.c)(122),{onItemSelect:n,children:r}=e,{t:i}=He(),a=li(Wf),o=li(Gf),s=li(Kf),c=li(qf),l=li(Jf),u=li(Yf),d=li(Xf),f=li(Zf),p=li(Qf),m=li($f),h=li(ep),g=li(tp),_=li(np),v=li(rp),y,b;t[0]===v?(y=t[1],b=t[2]):(y=()=>{v()},b=[v],t[0]=v,t[1]=y,t[2]=b),Q.useEffect(y,b);let x=ip,S;t[3]===p?S=t[4]:(S=e=>{p(e),x({usageAutoRefresh:e})},t[3]=p,t[4]=S);let C=S,w;t[5]===m?w=t[6]:(w=e=>{let t=Number(e);Number.isFinite(t)&&(m(t),x({usageRefreshIntervalMs:t}))},t[5]=m,t[6]=w);let T=w,E;t[7]===h?E=t[8]:(E=e=>{(e===`usage`||e===`remaining`)&&(h(e),x({usageDisplayMode:e}))},t[7]=h,t[8]=E);let D=E,O;t[9]===_?O=t[10]:(O=e=>{_(e),x({usageShowPredValues:e})},t[9]=_,t[10]=O);let k=O,A=r?`yuri-settings-usage-workspace`:`yuri-settings-usage-sidebar`,j;t[11]===A?j=t[12]:(j=G(`yuri-settings-page-content h-full min-w-0 overflow-y-auto bg-background p-3`,A),t[11]=A,t[12]=j);let M;t[13]===i?M=t[14]:(M=i(`settings.usage.sidebar.title`),t[13]=i,t[14]=M);let N;t[15]===c?N=t[16]:(N=()=>c(),t[15]=c,t[16]=N);let P;t[17]===i?P=t[18]:(P=i(`settings.usage.sidebar.actions.refreshAria`),t[17]=i,t[18]=P);let F;t[19]===i?F=t[20]:(F=i(`settings.usage.sidebar.actions.refreshTitle`),t[19]=i,t[20]=F);let I=l&&`animate-spin`,L;t[21]===I?L=t[22]:(L=G(`h-3.5 w-3.5`,I),t[21]=I,t[22]=L);let R;t[23]===L?R=t[24]:(R=(0,$.jsx)(Y,{name:`refresh`,className:L}),t[23]=L,t[24]=R);let z;t[25]!==l||t[26]!==N||t[27]!==P||t[28]!==F||t[29]!==R?(z=(0,$.jsx)(K,{size:`icon`,variant:`ghost`,className:`text-muted-foreground`,onClick:N,"aria-label":P,title:F,disabled:l,children:R}),t[25]=l,t[26]=N,t[27]=P,t[28]=F,t[29]=R,t[30]=z):z=t[30];let B;t[31]!==z||t[32]!==M?(B=(0,$.jsx)(Z,{label:M,children:z}),t[31]=z,t[32]=M,t[33]=B):B=t[33];let V;t[34]===i?V=t[35]:(V=i(`settings.usage.sidebar.field.autoRefresh`),t[34]=i,t[35]=V);let ee;t[36]===i?ee=t[37]:(ee=i(`settings.usage.sidebar.actions.toggleAutoRefreshAria`),t[36]=i,t[37]=ee);let H;t[38]!==C||t[39]!==ee||t[40]!==u?(H=(0,$.jsx)(gn,{checked:u,onChange:C,ariaLabel:ee}),t[38]=C,t[39]=ee,t[40]=u,t[41]=H):H=t[41];let te;t[42]!==V||t[43]!==H?(te=(0,$.jsx)(Z,{label:V,children:H}),t[42]=V,t[43]=H,t[44]=te):te=t[44];let ne;t[45]===i?ne=t[46]:(ne=i(`settings.usage.sidebar.field.refreshInterval`),t[45]=i,t[46]=ne);let U=String(d),re=!u,ie;t[47]===i?ie=t[48]:(ie=i(`settings.usage.sidebar.field.intervalPlaceholder`),t[47]=i,t[48]=ie);let ae;t[49]===ie?ae=t[50]:(ae=(0,$.jsx)(bn,{className:`w-fit`,children:(0,$.jsx)(Tn,{placeholder:ie,children:ap})}),t[49]=ie,t[50]=ae);let oe;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,$.jsxs)(xn,{children:[(0,$.jsx)(vn,{value:`30000`,children:`30s`}),(0,$.jsx)(vn,{value:`60000`,children:`1m`}),(0,$.jsx)(vn,{value:`300000`,children:`5m`})]}),t[51]=oe):oe=t[51];let se;t[52]!==T||t[53]!==U||t[54]!==re||t[55]!==ae?(se=(0,$.jsxs)(Cn,{value:U,onValueChange:T,disabled:re,children:[ae,oe]}),t[52]=T,t[53]=U,t[54]=re,t[55]=ae,t[56]=se):se=t[56];let ce;t[57]!==ne||t[58]!==se?(ce=(0,$.jsx)(Z,{label:ne,children:se}),t[57]=ne,t[58]=se,t[59]=ce):ce=t[59];let le;t[60]===i?le=t[61]:(le=i(`settings.usage.sidebar.field.display`),t[60]=i,t[61]=le);let ue;t[62]===i?ue=t[63]:(ue=i(`settings.usage.sidebar.field.displayModePlaceholder`),t[62]=i,t[63]=ue);let de;t[64]===i?de=t[65]:(de=e=>e===`usage`?i(`settings.usage.sidebar.field.displayModeUsage`):e===`remaining`?i(`settings.usage.sidebar.field.displayModeRemaining`):e,t[64]=i,t[65]=de);let fe;t[66]!==ue||t[67]!==de?(fe=(0,$.jsx)(bn,{className:`w-fit`,children:(0,$.jsx)(Tn,{placeholder:ue,children:de})}),t[66]=ue,t[67]=de,t[68]=fe):fe=t[68];let pe;t[69]===i?pe=t[70]:(pe=i(`settings.usage.sidebar.field.displayModeUsage`),t[69]=i,t[70]=pe);let me;t[71]===pe?me=t[72]:(me=(0,$.jsx)(vn,{value:`usage`,children:pe}),t[71]=pe,t[72]=me);let he;t[73]===i?he=t[74]:(he=i(`settings.usage.sidebar.field.displayModeRemaining`),t[73]=i,t[74]=he);let ge;t[75]===he?ge=t[76]:(ge=(0,$.jsx)(vn,{value:`remaining`,children:he}),t[75]=he,t[76]=ge);let _e;t[77]!==me||t[78]!==ge?(_e=(0,$.jsxs)(xn,{children:[me,ge]}),t[77]=me,t[78]=ge,t[79]=_e):_e=t[79];let ve;t[80]!==D||t[81]!==fe||t[82]!==_e||t[83]!==f?(ve=(0,$.jsxs)(Cn,{value:f,onValueChange:D,children:[fe,_e]}),t[80]=D,t[81]=fe,t[82]=_e,t[83]=f,t[84]=ve):ve=t[84];let ye;t[85]!==le||t[86]!==ve?(ye=(0,$.jsx)(Z,{label:le,children:ve}),t[85]=le,t[86]=ve,t[87]=ye):ye=t[87];let be;t[88]===i?be=t[89]:(be=i(`settings.usage.sidebar.field.showPredictions`),t[88]=i,t[89]=be);let xe;t[90]===i?xe=t[91]:(xe=i(`settings.usage.sidebar.field.showPredictions`),t[90]=i,t[91]=xe);let Se;t[92]!==k||t[93]!==g||t[94]!==be||t[95]!==xe?(Se=(0,$.jsx)($r,{checked:g,onChange:k,label:be,ariaLabel:xe}),t[92]=k,t[93]=g,t[94]=be,t[95]=xe,t[96]=Se):Se=t[96];let W;t[97]!==B||t[98]!==te||t[99]!==ce||t[100]!==ye||t[101]!==Se?(W=(0,$.jsxs)(X,{children:[B,te,ce,ye,Se]}),t[97]=B,t[98]=te,t[99]=ce,t[100]=ye,t[101]=Se,t[102]=W):W=t[102];let Ce;t[103]===Symbol.for(`react.memo_cache_sentinel`)?(Ce=(0,$.jsx)(Vf,{}),t[103]=Ce):Ce=t[103];let we=r?`yuri-settings-usage-results`:void 0,Te;t[104]!==n||t[105]!==a||t[106]!==o||t[107]!==s||t[108]!==i?(Te=ri(a).map(e=>{let t=a.find(t=>t?.providerId===e.id),r=Hf(t?.usage),c=Ln(r),l=e.id===o,u=t?.configured??!1,d=u?c===`critical`?{backgroundColor:`var(--status-error)`}:c===`warn`?{backgroundColor:`var(--status-warning)`}:{backgroundColor:`var(--status-success)`}:{backgroundColor:`var(--surface-muted-foreground)`,opacity:.4};return(0,$.jsx)(`div`,{className:G(`yuri-settings-group-row group relative flex items-center transition-colors duration-150`,l?`bg-interactive-selection`:`hover:bg-interactive-hover`),children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{s(e.id),n?.()},className:`flex min-w-0 flex-1 items-center gap-2 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,children:[(0,$.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full flex-shrink-0`,style:d}),(0,$.jsx)(_n,{providerId:e.id,className:`h-4 w-4 flex-shrink-0`}),(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate flex-1 min-w-0 text-foreground`,children:e.name}),!u&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/60 flex-shrink-0`,children:i(`settings.usage.sidebar.status.notSet`)})]})},e.id)}),t[104]=n,t[105]=a,t[106]=o,t[107]=s,t[108]=i,t[109]=Te):Te=t[109];let Ee;t[110]===Te?Ee=t[111]:(Ee=(0,$.jsx)(X,{children:Te}),t[110]=Te,t[111]=Ee);let De;t[112]===r?De=t[113]:(De=r&&(0,$.jsx)(`div`,{className:`yuri-settings-usage-detail min-w-0`,children:r}),t[112]=r,t[113]=De);let Oe;t[114]!==we||t[115]!==Ee||t[116]!==De?(Oe=(0,$.jsxs)(`div`,{className:we,children:[Ee,De]}),t[114]=we,t[115]=Ee,t[116]=De,t[117]=Oe):Oe=t[117];let ke;return t[118]!==W||t[119]!==Oe||t[120]!==j?(ke=(0,$.jsxs)(`div`,{className:j,children:[W,Ce,Oe]}),t[118]=W,t[119]=Oe,t[120]=j,t[121]=ke):ke=t[121],ke};function Wf(e){return e.results}function Gf(e){return e.selectedProviderId}function Kf(e){return e.setSelectedProvider}function qf(e){return e.fetchAllQuotas}function Jf(e){return e.isLoading}function Yf(e){return e.autoRefresh}function Xf(e){return e.refreshIntervalMs}function Zf(e){return e.displayMode}function Qf(e){return e.setAutoRefresh}function $f(e){return e.setRefreshInterval}function ep(e){return e.setDisplayMode}function tp(e){return e.showPredValues}function np(e){return e.setShowPredValues}function rp(e){return e.loadSettings}async function ip(e){try{await O(e)}catch(e){console.warn(`Failed to save usage settings:`,e)}}function ap(e){return e===`30000`?`30s`:e===`60000`?`1m`:e===`300000`?`5m`:e}var op=e=>{let t=(0,qi.c)(54),{title:n,window:r,subtitle:i,showToggle:a,toggleEnabled:o,onToggle:s}=e,c=a!==void 0&&a,l=o!==void 0&&o,{locale:u}=He(),[d,f]=Q.useState(Date.now),p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>f(Date.now()),t[0]=p):p=t[0],Le(p,r.disablePace&&r.resetAt?3e4:null);let m=r.resetAt?Math.max(0,Math.ceil((r.resetAt-d)/6e4)):null,h;t[1]!==u||t[2]!==m?(h=m===null?``:[{unit:`day`,value:Math.floor(m/1440)},{unit:`hour`,value:Math.floor(m%1440/60)},{unit:`minute`,value:m%60}].filter(e=>{let{unit:t,value:n}=e;return n>0||t===`minute`&&m===0}).map(e=>{let{unit:t,value:n}=e;return new Intl.NumberFormat(u,{style:`unit`,unit:t,unitDisplay:`long`}).format(n)}).join(` `),t[1]=u,t[2]=m,t[3]=h):h=t[3];let g=h,_=li(sp),v=li(cp),y=W(lp),b=_===`remaining`?r.remainingPercent:r.usedPercent,x=_===`remaining`?`remaining`:`used`,S;t[4]!==b||t[5]!==r.disablePace||t[6]!==r.valueLabel?(S=r.disablePace&&r.valueLabel&&b!==null?`${gr(null,b)} · ${r.valueLabel}`:gr(r.valueLabel,b),t[4]=b,t[5]=r.disablePace,t[6]=r.valueLabel,t[7]=S):S=t[7];let C=S,w=r.resetAfterFormatted??r.resetAtFormatted,T;t[8]!==w||t[9]!==y||t[10]!==r.resetAt?(T=jn(r.resetAt,w,y),t[8]=w,t[9]=y,t[10]=r.resetAt,t[11]=T):T=t[11];let E=T,D;t[12]===n?D=t[13]:(D=Kn(n),t[12]=n,t[13]=D);let O=D,k;t[14]!==n||t[15]!==r.disablePace||t[16]!==r.resetAt||t[17]!==r.usedPercent||t[18]!==r.windowSeconds?(k=r.disablePace?null:Jn(r.usedPercent,r.resetAt,r.windowSeconds,n),t[14]=n,t[15]=r.disablePace,t[16]=r.resetAt,t[17]=r.usedPercent,t[18]=r.windowSeconds,t[19]=k):k=t[19];let A=k,j;bb0:{if(!A||A.dailyAllocationPercent===null){j=null;break bb0}let e=In(A.elapsedRatio);j=_===`remaining`?100-e:e}let M=j,N;t[20]!==s||t[21]!==c||t[22]!==l?(N=c&&(0,$.jsx)(gn,{checked:l,onChange:e=>s?.(e),ariaLabel:`Show in dropdown`}),t[20]=s,t[21]=c,t[22]=l,t[23]=N):N=t[23];let P;t[24]===O?P=t[25]:(P=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:O}),t[24]=O,t[25]=P);let F;t[26]===i?F=t[27]:(F=i&&(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground truncate`,children:i}),t[26]=i,t[27]=F);let I;t[28]!==P||t[29]!==F?(I=(0,$.jsxs)(`div`,{className:`min-w-0 flex flex-col`,children:[P,F]}),t[28]=P,t[29]=F,t[30]=I):I=t[30];let L;t[31]!==N||t[32]!==I?(L=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 flex items-center gap-2`,children:[N,I]}),t[31]=N,t[32]=I,t[33]=L):L=t[33];let R=C===`-`?``:C,z;t[34]===R?z=t[35]:(z=(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground tabular-nums flex items-center justify-end`,children:R}),t[34]=R,t[35]=z);let B;t[36]!==L||t[37]!==z?(B=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[L,z]}),t[36]=L,t[37]=z,t[38]=B):B=t[38];let V;t[39]!==x||t[40]!==g||t[41]!==b||t[42]!==M||t[43]!==E||t[44]!==r.disablePace||t[45]!==r.usedPercent?(V=(!r.disablePace||b!==null||E)&&(0,$.jsxs)(`div`,{className:`mt-2.5`,children:[(!r.disablePace||b!==null)&&(0,$.jsx)(fi,{percent:b,tonePercent:r.usedPercent,expectedMarkerPercent:M,className:`h-1.5`}),(0,$.jsxs)(`div`,{className:`mt-1 flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:E?r.disablePace?`${E} (${g})`:`Resets ${E}`:``}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:r.disablePace&&b===null?``:x})]})]}),t[39]=x,t[40]=g,t[41]=b,t[42]=M,t[43]=E,t[44]=r.disablePace,t[45]=r.usedPercent,t[46]=V):V=t[46];let ee;t[47]!==A||t[48]!==v?(ee=A&&v&&(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(si,{paceInfo:A})}),t[47]=A,t[48]=v,t[49]=ee):ee=t[49];let H;return t[50]!==B||t[51]!==V||t[52]!==ee?(H=(0,$.jsxs)(`div`,{className:`py-3`,children:[B,V,ee]}),t[50]=B,t[51]=V,t[52]=ee,t[53]=H):H=t[53],H};function sp(e){return e.displayMode}function cp(e){return e.showPredValues}function lp(e){return e.timeFormatPreference}var up=(e,t)=>{if(!e)return`-`;try{return Un(e,t,{fallback:`-`})}catch{return`-`}},dp=()=>{let{t:e}=He(),t=W(e=>e.timeFormatPreference),n=li(e=>e.results),r=li(e=>e.selectedProviderId),i=li(e=>e.setSelectedProvider),a=li(e=>e.loadSettings),o=li(e=>e.fetchAllQuotas),s=li(e=>e.isLoading),c=li(e=>e.lastUpdated),l=li(e=>e.error),u=li(e=>e.dropdownProviderIds),d=li(e=>e.setDropdownProviderIds),f=li(e=>e.selectedModels),p=li(e=>e.toggleModelSelected),m=li(e=>e.applyDefaultSelections);ci(),Q.useEffect(()=>{a(),o()},[a,o]),Q.useEffect(()=>{if(r&&(!r.startsWith(`magpie:`)||n.some(e=>e.providerId===r))||n.length===0)return;let e=n.find(e=>e?.configured)?.providerId;i(e??qr[0]?.id??null)},[n,r,i]);let h=n.find(e=>e?.providerId===r)??null,g=qr.find(e=>e.id===r),_=h?.providerName??g?.name??r??e(`settings.usage.sidebar.title`),v=h?.usage,y=r?u.includes(r):!1,b=Q.useCallback(e=>{if(!r)return;let t=e?Array.from(new Set([...u,r])):u.filter(e=>e!==r);d(t),O({usageDropdownProviders:t,magpieHiddenProviders:li.getState().magpieHiddenProviders})},[u,r,d]),x=Q.useMemo(()=>v?.models?Object.entries(v.models).map(([e,t])=>({name:e,windows:t})).filter(e=>Object.keys(e.windows.windows).length>0):[],[v?.models]);Q.useEffect(()=>{r&&x.length>0&&m(r,x.map(e=>e.name))},[r,x,m]);let S=Q.useMemo(()=>!r||x.length===0?new Map:ui(x,e=>e.name,r),[x,r]),C=Q.useMemo(()=>{if(!r)return[];let e=hi(r);return ii(e)},[r]),[w,T]=Q.useState(()=>({})),E=Q.useCallback(e=>{T(t=>({...t,[e]:!t[e]}))},[]),D=Q.useCallback(e=>{if(!r)return;p(r,e);let t=f[r]??[],n=t.includes(e)?t.filter(t=>t!==e):[...t,e],i={...f,[r]:n};O({usageSelectedModels:i})},[r,f,p]),k=r?f[r]??[]:[];return r?(0,$.jsx)(Rr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(_n,{providerId:r,className:`h-5 w-5 shrink-0`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:e(`settings.usage.page.header.providerUsage`,{provider:_})}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground truncate`,children:s?(0,$.jsx)(`span`,{className:`animate-pulse`,children:e(`settings.usage.page.header.refreshing`)}):e(`settings.usage.page.header.lastUpdated`,{time:up(c,t)})})]})]}),(0,$.jsx)(X,{children:(0,$.jsxs)(`div`,{"data-settings-item":`usage.header-menu`,className:`yuri-settings-group-row yuri-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,"aria-pressed":y,onClick:()=>b(!y),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),b(!y))},children:[(0,$.jsx)(`div`,{className:`yuri-settings-split-row-copy`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.usage.page.options.showInHeader`)}),(0,$.jsxs)(kn,{children:[(0,$.jsx)(Dn,{asChild:!0,children:(0,$.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 cursor-help text-muted-foreground/60`})}),(0,$.jsx)(On,{sideOffset:8,className:`max-w-xs`,children:e(`settings.usage.page.options.showInHeaderTooltip`)})]})]})}),(0,$.jsx)(`div`,{"data-settings-value":``,className:`yuri-settings-split-row-control`,children:(0,$.jsx)(gn,{checked:y,onChange:b,ariaLabel:e(`settings.usage.page.options.showInHeaderAria`)})})]})}),!h&&(0,$.jsx)(`div`,{className:`px-2`,children:(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:e(`settings.usage.page.state.noData`)})}),l&&(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-medium text-[var(--status-error)]`,children:e(`settings.usage.page.state.refreshFailedTitle`)}),(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]/80 mt-1`,children:l})]}),h?.configured&&!h.ok&&h.error&&(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-medium text-[var(--status-error)]`,children:e(`settings.usage.page.state.refreshFailedTitle`)}),(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]/80 mt-1`,children:h.error})]}),h&&!h.configured&&(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label font-medium text-[var(--status-warning)]`,children:e(`settings.usage.page.state.providerNotConfiguredTitle`)}),(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-warning)]/80 mt-1`,children:e(`settings.usage.page.state.providerNotConfiguredDescription`)})]}),v?.accounts?.map((n,r)=>(0,$.jsx)(X,{label:n.name,children:(0,$.jsxs)(`div`,{className:`yuri-settings-group-row`,children:[(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground break-words`,children:[n.user,n.plan,n.from].filter(Boolean).join(` · `)}),n.readAt&&(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.usage.page.header.lastUpdated`,{time:up(n.readAt,t)})}),n.stale&&(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e(`settings.usage.magpie.cached`)}),n.error&&(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:e(`settings.usage.page.state.refreshFailedTitle`)}),(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:Object.entries(n.windows).map(([e,t])=>(0,$.jsx)(op,{title:t.label??e,window:t},e))})]})},`${n.id}:${r}`)),!v?.accounts&&v?.windows&&Object.keys(v.windows).length>0&&(0,$.jsx)(X,{children:(0,$.jsx)(`div`,{"data-settings-item":`usage.model-quotas`,className:`yuri-settings-group-row`,children:(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)]`,children:Object.entries(v.windows).map(([e,t])=>(0,$.jsx)(op,{title:e,window:t},e))})})}),x.length>0&&(0,$.jsxs)(X,{label:e(`settings.usage.page.section.modelQuotas`),children:[C.map(e=>{let t=S.get(e.id)??[];if(t.length===0)return null;let n=w[e.id]??!1;return(0,$.jsx)(`div`,{className:`yuri-settings-group-row`,children:(0,$.jsxs)(Ui,{open:!n,onOpenChange:()=>E(e.id),children:[(0,$.jsxs)(Hi,{className:`flex w-full items-center justify-between py-0.5 group`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-left`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-normal text-foreground`,children:e.label}),(0,$.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[`(`,t.length,`)`]})]}),n?(0,$.jsx)(Y,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors`}):(0,$.jsx)(Y,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors`})]}),(0,$.jsx)(Vi,{children:(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)] mt-1`,children:t.map(e=>{let t=Object.entries(e.windows.windows);if(t.length===0)return null;let[n,r]=t[0],i=k.includes(e.name);return(0,$.jsx)(op,{title:n,subtitle:pi(e.name),window:r,showToggle:!0,toggleEnabled:i,onToggle:()=>D(e.name)},e.name)})})})]})},e.id)}),(()=>{let t=S.get(null)??[];if(t.length===0)return null;let n=w.other??!1;return(0,$.jsx)(`div`,{className:`yuri-settings-group-row`,children:(0,$.jsxs)(Ui,{open:!n,onOpenChange:()=>E(`other`),children:[(0,$.jsxs)(Hi,{className:`flex w-full items-center justify-between py-0.5 group`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-left`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label font-normal text-foreground`,children:e(`settings.usage.page.section.otherModels`)}),(0,$.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[`(`,t.length,`)`]})]}),n?(0,$.jsx)(Y,{name:`arrow-right-s`,className:`h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors`}):(0,$.jsx)(Y,{name:`arrow-down-s`,className:`h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors`})]}),(0,$.jsx)(Vi,{children:(0,$.jsx)(`div`,{className:`divide-y divide-[var(--surface-subtle)] mt-1`,children:t.map(e=>{let t=Object.entries(e.windows.windows);if(t.length===0)return null;let[n,r]=t[0],i=k.includes(e.name);return(0,$.jsx)(op,{title:n,subtitle:pi(e.name),window:r,showToggle:!0,toggleEnabled:i,onToggle:()=>D(e.name)},e.name)})})})]})})})()]}),h?.configured&&v&&Object.keys(v.windows??{}).length===0&&x.length===0&&(0,$.jsxs)(`div`,{className:`px-2`,children:[(0,$.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:e(`settings.usage.page.state.noQuotaWindowsTitle`)}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground mt-1`,children:e(`settings.usage.page.state.noQuotaWindowsDescription`)})]})]})}):(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:(0,$.jsx)(`p`,{className:`typography-body`,children:e(`settings.usage.page.empty.selectProvider`)})})},fp=`git.commit.generate`,pp=ce(e=>({selectedPromptId:fp,setSelectedPromptId:t=>{e(e=>e.selectedPromptId===t?e:{selectedPromptId:t})}})),mp=e=>{let t=(0,qi.c)(22),{onItemSelect:n}=e,{t:r}=He(),i=pp(hp),a=pp(gp),o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={groupKey:`settings.magicPrompts.sidebar.group.git`,items:[{id:`git.commit.generate`,titleKey:`settings.magicPrompts.sidebar.item.gitCommitGenerate`},{id:`git.pr.generate`,titleKey:`settings.magicPrompts.sidebar.item.gitPrGenerate`},{id:`git.conflict.resolve`,titleKey:`settings.magicPrompts.sidebar.item.gitConflictResolve`},{id:`git.integrate.cherrypick.resolve`,titleKey:`settings.magicPrompts.sidebar.item.gitCherrypickConflictResolve`}]},t[0]=o):o=t[0];let s;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(s={groupKey:`settings.magicPrompts.sidebar.group.github`,items:[{id:`github.pr.review`,titleKey:`settings.magicPrompts.sidebar.item.githubPrReview`},{id:`github.issue.review`,titleKey:`settings.magicPrompts.sidebar.item.githubIssueReview`},{id:`github.pr.checks.review`,titleKey:`settings.magicPrompts.sidebar.item.githubPrFailedChecksReview`},{id:`github.pr.comments.review`,titleKey:`settings.magicPrompts.sidebar.item.githubPrCommentsReview`},{id:`github.pr.comment.single`,titleKey:`settings.magicPrompts.sidebar.item.githubSinglePrCommentReview`}]},t[1]=s):s=t[1];let c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=[o,s,{groupKey:`settings.magicPrompts.sidebar.group.session`,items:[{id:`session.explore`,titleKey:`settings.magicPrompts.sidebar.item.sessionExplore`},{id:`session.summary`,titleKey:`settings.magicPrompts.sidebar.item.sessionSummary`},{id:`session.review`,titleKey:`settings.magicPrompts.sidebar.item.sessionWorkspaceReview`},{id:`session.craftGoal`,titleKey:`settings.magicPrompts.sidebar.item.sessionCraftGoal`},{id:`session.catchup`,titleKey:`settings.magicPrompts.sidebar.item.sessionCatchUp`},{id:`session.debug`,titleKey:`settings.magicPrompts.sidebar.item.sessionDebug`},{id:`session.weigh`,titleKey:`settings.magicPrompts.sidebar.item.sessionWeigh`},{id:`session.fusion`,titleKey:`settings.magicPrompts.sidebar.item.sessionFusion`}]}],t[2]=c):c=t[2];let l=c,u;t[3]===r?u=t[4]:(u=r(`settings.magicPrompts.sidebar.title`),t[3]=r,t[4]=u);let d;t[5]===u?d=t[6]:(d=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:u}),t[5]=u,t[6]=d);let f;t[7]===r?f=t[8]:(f=r(`settings.magicPrompts.sidebar.description`),t[7]=r,t[8]=f);let p;t[9]===f?p=t[10]:(p=(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:f}),t[9]=f,t[10]=p);let m;t[11]!==d||t[12]!==p?(m=(0,$.jsxs)(`div`,{className:`flex flex-col justify-center gap-1 px-2`,children:[d,p]}),t[11]=d,t[12]=p,t[13]=m):m=t[13];let h;t[14]!==n||t[15]!==i||t[16]!==a||t[17]!==r?(h=l.map(e=>(0,$.jsx)(X,{label:r(e.groupKey),children:e.items.map(e=>{let t=i===e.id;return(0,$.jsx)(`button`,{type:`button`,onClick:()=>{a(e.id),n?.()},className:G(`yuri-settings-group-row flex w-full items-center text-left transition-colors`,t?`bg-interactive-selection text-foreground`:`text-foreground hover:bg-interactive-hover`),children:(0,$.jsx)(`span`,{className:`typography-ui-label truncate font-normal`,children:r(e.titleKey)})},e.id)})},e.groupKey)),t[14]=n,t[15]=i,t[16]=a,t[17]=r,t[18]=h):h=t[18];let g;return t[19]!==m||t[20]!==h?(g=(0,$.jsxs)(`div`,{className:`yuri-settings-page-content h-full overflow-y-auto bg-background p-3`,children:[m,h]}),t[19]=m,t[20]=h,t[21]=g):g=t[21],g};function hp(e){return e.selectedPromptId}function gp(e){return e.setSelectedPromptId}var _p={"git.commit.generate":{titleKey:`settings.magicPrompts.page.group.gitCommitGenerate.title`,descriptionKey:`settings.magicPrompts.page.group.gitCommitGenerate.description`,blocks:[{id:`git.commit.generate.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`git.commit.generate.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"git.pr.generate":{titleKey:`settings.magicPrompts.page.group.gitPrGenerate.title`,descriptionKey:`settings.magicPrompts.page.group.gitPrGenerate.description`,blocks:[{id:`git.pr.generate.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`git.pr.generate.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"github.pr.review":{titleKey:`settings.magicPrompts.page.group.githubPrReview.title`,descriptionKey:`settings.magicPrompts.page.group.githubPrReview.description`,blocks:[{id:`github.pr.review.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`github.pr.review.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"github.issue.review":{titleKey:`settings.magicPrompts.page.group.githubIssueReview.title`,descriptionKey:`settings.magicPrompts.page.group.githubIssueReview.description`,blocks:[{id:`github.issue.review.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`github.issue.review.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"github.pr.checks.review":{titleKey:`settings.magicPrompts.page.group.githubPrFailedChecksReview.title`,descriptionKey:`settings.magicPrompts.page.group.githubPrFailedChecksReview.description`,blocks:[{id:`github.pr.checks.review.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`github.pr.checks.review.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"github.pr.comments.review":{titleKey:`settings.magicPrompts.page.group.githubPrCommentsReview.title`,descriptionKey:`settings.magicPrompts.page.group.githubPrCommentsReview.description`,blocks:[{id:`github.pr.comments.review.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`github.pr.comments.review.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"github.pr.comment.single":{titleKey:`settings.magicPrompts.page.group.githubSinglePrCommentReview.title`,descriptionKey:`settings.magicPrompts.page.group.githubSinglePrCommentReview.description`,blocks:[{id:`github.pr.comment.single.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`github.pr.comment.single.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"git.conflict.resolve":{titleKey:`settings.magicPrompts.page.group.gitConflictResolve.title`,descriptionKey:`settings.magicPrompts.page.group.gitConflictResolve.description`,blocks:[{id:`git.conflict.resolve.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`git.conflict.resolve.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"git.integrate.cherrypick.resolve":{titleKey:`settings.magicPrompts.page.group.gitCherrypickConflictResolve.title`,descriptionKey:`settings.magicPrompts.page.group.gitCherrypickConflictResolve.description`,blocks:[{id:`git.integrate.cherrypick.resolve.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`git.integrate.cherrypick.resolve.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.summary":{titleKey:`settings.magicPrompts.page.group.sessionSummary.title`,descriptionKey:`settings.magicPrompts.page.group.sessionSummary.description`,blocks:[{id:`session.summary.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.summary.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.review":{titleKey:`settings.magicPrompts.page.group.sessionWorkspaceReview.title`,descriptionKey:`settings.magicPrompts.page.group.sessionWorkspaceReview.description`,blocks:[{id:`session.review.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.review.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.craftGoal":{titleKey:`settings.magicPrompts.page.group.sessionCraftGoal.title`,descriptionKey:`settings.magicPrompts.page.group.sessionCraftGoal.description`,blocks:[{id:`session.craftGoal.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.craftGoal.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.catchup":{titleKey:`settings.magicPrompts.page.group.sessionCatchUp.title`,descriptionKey:`settings.magicPrompts.page.group.sessionCatchUp.description`,blocks:[{id:`session.catchup.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.catchup.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.debug":{titleKey:`settings.magicPrompts.page.group.sessionDebug.title`,descriptionKey:`settings.magicPrompts.page.group.sessionDebug.description`,blocks:[{id:`session.debug.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.debug.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.weigh":{titleKey:`settings.magicPrompts.page.group.sessionWeigh.title`,descriptionKey:`settings.magicPrompts.page.group.sessionWeigh.description`,blocks:[{id:`session.weigh.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.weigh.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.explore":{titleKey:`settings.magicPrompts.page.group.sessionExplore.title`,descriptionKey:`settings.magicPrompts.page.group.sessionExplore.description`,blocks:[{id:`session.explore.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.explore.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]},"session.fusion":{titleKey:`settings.magicPrompts.page.group.sessionFusion.title`,descriptionKey:`settings.magicPrompts.page.group.sessionFusion.description`,blocks:[{id:`session.fusion.visible`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`},{id:`session.fusion.instructions`,titleKey:`settings.magicPrompts.page.block.instructions`}]}},vp=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),yp=e=>e.endsWith(`.visible`),bp=()=>{let{t:e}=He(),t=Q.useCallback(t=>e(t),[e]),n=pp(e=>e.selectedPromptId),[r,i]=Q.useState(!0),[a,o]=Q.useState({}),[s,c]=Q.useState({}),[l,u]=Q.useState({}),[d,f]=Q.useState({}),[p,m]=Q.useState(!1);Q.useEffect(()=>{let t=!0;return(async()=>{i(!0);try{let e=await Jt();if(!t)return;o(e)}catch(t){console.warn(`Failed to load magic prompts:`,t),q.error(e(`settings.magicPrompts.page.toast.loadFailed`))}finally{t&&i(!1)}})(),()=>{t=!1}},[e]);let h=_p[n]??_p[`git.commit.generate`],g=Q.useCallback(e=>vp(a,e)?a[e]:Wt(e),[a]),_=Q.useCallback(e=>s[e]??g(e),[s,g]),v=Q.useCallback((e,t)=>{c(n=>n[e]===t?n:{...n,[e]:t})},[]),y=Q.useCallback(async t=>{let n=_(t);if(yp(t)&&n.trim().length===0){q.error(e(`settings.magicPrompts.page.toast.visiblePromptRequired`));return}u(e=>({...e,[t]:!0}));try{let r=n===Wt(t)?await en(t):await an(t,n);o(r.overrides),q.success(e(`settings.magicPrompts.page.toast.saved`))}catch(t){let n=t instanceof Error?t.message:String(t);q.error(e(`settings.magicPrompts.page.toast.saveFailed`),{description:n})}finally{u(e=>({...e,[t]:!1}))}},[_,e]),b=Q.useCallback(async t=>{f(e=>({...e,[t]:!0}));try{let n=await en(t);o(n.overrides),c(e=>({...e,[t]:Wt(t)})),q.success(e(`settings.magicPrompts.page.toast.resetSuccess`))}catch(t){let n=t instanceof Error?t.message:String(t);q.error(e(`settings.magicPrompts.page.toast.resetFailed`),{description:n})}finally{f(e=>({...e,[t]:!1}))}},[e]),x=Q.useCallback(async()=>{m(!0);try{let t=await kt();o(t.overrides),c({}),q.success(e(`settings.magicPrompts.page.toast.resetAllSuccess`))}catch(t){let n=t instanceof Error?t.message:String(t);q.error(e(`settings.magicPrompts.page.toast.resetAllFailed`),{description:n})}finally{m(!1)}},[e]);return r?(0,$.jsxs)(`div`,{className:`py-6 px-6 flex items-center gap-2 text-muted-foreground`,children:[(0,$.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-current animate-busy-pulse`,"aria-label":e(`settings.magicPrompts.page.loading.aria`)}),(0,$.jsx)(`span`,{className:`typography-ui`,children:e(`settings.magicPrompts.page.loading.text`)})]}):(0,$.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,$.jsxs)(`div`,{className:`yuri-settings-page-content mx-auto w-full max-w-4xl px-6 py-6`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,$.jsx)(`div`,{className:`space-y-1`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground`,children:t(h.titleKey)}),(0,$.jsxs)(kn,{children:[(0,$.jsx)(Dn,{asChild:!0,children:(0,$.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(On,{sideOffset:8,className:`max-w-xs`,children:t(h.descriptionKey)})]})]})}),(0,$.jsx)(K,{"data-settings-item":`magic-prompts.reset-overrides`,variant:`outline`,size:`sm`,onClick:()=>{x()},disabled:p||Object.keys(a).length===0,children:e(p?`settings.magicPrompts.page.actions.resetting`:`settings.magicPrompts.page.actions.resetAllOverrides`)})]}),h.blocks.map(n=>{let r=J(n.id),i=g(n.id),o=_(n.id),s=vp(a,n.id),c=o!==i,u=yp(n.id)&&o.trim().length===0,f=l[n.id]===!0,p=d[n.id]===!0;return(0,$.jsx)(X,{actions:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{variant:`outline`,size:`sm`,onClick:()=>void b(n.id),disabled:!s||f||p,children:e(p?`settings.magicPrompts.page.actions.resetting`:`settings.magicPrompts.page.actions.resetToDefault`)}),(0,$.jsx)(K,{size:`sm`,onClick:()=>void y(n.id),disabled:!c||f||p||u,"aria-busy":f,children:e(f?`settings.common.actions.saving`:`settings.magicPrompts.page.actions.save`)})]}),label:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{children:t(n.titleKey)}),(0,$.jsxs)(kn,{children:[(0,$.jsx)(Dn,{asChild:!0,children:(0,$.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(On,{sideOffset:8,className:`max-w-xs`,children:r.description})]})]}),cardClassName:`p-3`,children:(0,$.jsxs)(`div`,{"data-settings-item":yp(n.id)?`magic-prompts.visible-prompt`:`magic-prompts.instructions`,className:`space-y-3`,children:[r.placeholders&&r.placeholders.length>0&&(0,$.jsxs)(`div`,{className:`typography-micro text-muted-foreground`,children:[e(`settings.magicPrompts.page.placeholdersLabel`),` `,r.placeholders.map(e=>`{{${e.key}}}`).join(`, `)]}),(0,$.jsx)(zr,{embedded:!0,value:o,onChange:e=>v(n.id,e.target.value),className:`min-h-[220px] font-mono text-sm`}),u&&(0,$.jsx)(`div`,{className:`typography-micro text-[var(--status-error)]`,children:e(`settings.magicPrompts.page.validation.visiblePromptRequired`)}),(0,$.jsx)(`div`,{className:`flex items-center justify-between gap-2`,children:(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:e(c?`settings.magicPrompts.page.status.unsavedChanges`:s?`settings.magicPrompts.page.status.usingSavedOverride`:`settings.magicPrompts.page.status.usingBuiltinDefault`)})})]})},n.id)})]})})},xp=()=>{let{t:e}=He(),t=tn(e=>e.settingsGitmojiEnabled),n=tn(e=>e.setSettingsGitmojiEnabled),r=h(),i=W(e=>e.gitChangesViewMode),a=W(e=>e.setGitChangesViewMode),[o,s]=Q.useState(!0),c=Q.useMemo(()=>[{id:`flat`,label:e(`settings.yuri.git.option.flatList`)},{id:`tree`,label:e(`settings.yuri.git.option.treeView`)}],[e]);Q.useEffect(()=>{(async()=>{try{let e=null;if(!e){let t=f()?.settings;if(t)try{let n=(await t.load())?.settings;n&&(e={gitmojiEnabled:typeof n.gitmojiEnabled==`boolean`?n.gitmojiEnabled:void 0,gitChangesViewMode:n.gitChangesViewMode===`flat`||n.gitChangesViewMode===`tree`?n.gitChangesViewMode:void 0})}catch{}}if(!e){let t=await p(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});t.ok&&(e=await t.json())}e&&(typeof e.gitmojiEnabled==`boolean`&&n(e.gitmojiEnabled),(e.gitChangesViewMode===`flat`||e.gitChangesViewMode===`tree`)&&a(e.gitChangesViewMode))}catch(e){console.warn(`Failed to load git settings:`,e)}finally{s(!1)}})()},[a,n]);let l=Q.useCallback(async e=>{n(e);try{await O({gitmojiEnabled:e})}catch(e){console.warn(`Failed to save gitmoji setting:`,e)}},[n]),u=Q.useCallback(e=>{e!==i&&(a(e),O({gitChangesViewMode:e}))},[i,a]);return o?null:(0,$.jsxs)(X,{label:e(`settings.yuri.git.title`),children:[(0,$.jsx)(Z,{itemId:`git.changes-view`,label:e(`settings.yuri.git.changesViewTitle`),controlClassName:`items-end`,children:(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":e(`settings.yuri.git.changesViewAria`),className:`mt-0.5 space-y-0`,children:c.map(t=>{let n=i===t.id;return(0,$.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-pressed":n,onClick:()=>{u(t.id)},onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),u(t.id))},className:`flex w-full items-center gap-2 py-0 text-left`,children:[(0,$.jsx)(mc,{checked:n,onChange:()=>{u(t.id)},ariaLabel:e(`settings.yuri.git.optionAria`,{option:t.label})}),(0,$.jsx)(`span`,{className:n?`typography-ui-label font-normal text-foreground`:`typography-ui-label font-normal text-foreground/50`,children:t.label})]},t.id)})})}),(0,$.jsxs)(`div`,{"data-settings-item":`git.gitmoji`,className:`yuri-settings-group-row group flex cursor-pointer items-center gap-2`,role:`button`,tabIndex:0,"aria-pressed":t,onClick:()=>{l(!t)},onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),l(!t))},children:[(0,$.jsx)(gn,{checked:t,onChange:e=>{l(e)},ariaLabel:e(`settings.yuri.git.enableGitmojiAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.yuri.git.enableGitmoji`)})]}),(0,$.jsxs)(`div`,{"data-settings-item":`git.gitignored-files`,className:`yuri-settings-group-row group flex cursor-pointer items-center gap-2`,role:`button`,tabIndex:0,"aria-pressed":r,onClick:()=>g(!r),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),g(!r))},children:[(0,$.jsx)(gn,{checked:r,onChange:g,ariaLabel:e(`settings.yuri.git.showGitignoredAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.yuri.git.showGitignored`)})]})]})},Sp=({itemId:e})=>{let{t}=He(),{isMobile:n}=Pr(),r=f()?.github,i=Hn(),a=i.data??null,o=i.isLoading&&!i.data,s=i.isFetched,c=_i(e=>e.refreshStatus),l=_i(e=>e.setStatus),u=Q.useCallback(async e=>{await Wr(e)},[]),[d,m]=Q.useState(!1),[h,g]=Q.useState(null),[_,v]=Q.useState(null),y=Q.useRef(null),b=Q.useRef(0),x=Q.useCallback(()=>{y.current!=null&&(window.clearTimeout(y.current),y.current=null),v(null)},[]);Q.useEffect(()=>((async()=>{try{s||await c(r)}catch(e){console.warn(`Failed to load GitHub auth status:`,e)}})(),()=>{x()}),[s,c,r,x]);let S=Q.useCallback(async()=>{m(!0);try{let e=r?await r.authStart():await(async()=>{let e=await p(`/api/github/auth/start`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({})}),t=await e.json().catch(()=>null);if(!e.ok||!t||!(`deviceCode`in t))throw Error(t?.error||e.statusText);return t})();g(e),b.current=Date.now(),v(Math.max(1,e.interval)*1e3);let t=e.verificationUriComplete||e.verificationUri;u(t)}catch(e){console.error(`Failed to start GitHub connect:`,e),q.error(t(`settings.github.page.toast.startConnectFailed`))}finally{m(!1)}},[u,r,t]),C=Q.useCallback(async e=>{if(r)return r.authComplete(e);let t=await p(`/api/github/auth/complete`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({deviceCode:e})}),n=await t.json().catch(()=>null);if(!t.ok||!n)throw Error(n?.error||t.statusText);return n},[r]);Q.useEffect(()=>{if(!h?.deviceCode||!_||y.current!=null)return;let e=!1,n=b.current+h.expiresIn*1e3,i=async()=>{if(Date.now()>=n){q.error(t(`settings.github.page.toast.authorizationFailed`)),g(null),x();return}try{let n=await C(h.deviceCode);if(e)return;if(n.connected){q.success(t(`settings.github.page.toast.connected`)),g(null),x(),await c(r,{force:!0});return}if(n.status===`slow_down`){v(e=>e?e+5e3:5e3);return}if(n.status===`expired_token`||n.status===`access_denied`){q.error(n.error||t(`settings.github.page.toast.authorizationFailed`)),g(null),x();return}}catch(t){if(e)return;console.warn(`GitHub polling failed:`,t)}y.current=window.setTimeout(()=>void i(),_)};return y.current=window.setTimeout(()=>void i(),_),()=>{e=!0,y.current!=null&&(window.clearTimeout(y.current),y.current=null)}},[h,_,C,c,r,x,t]);let w=Q.useCallback(async e=>{m(!0);try{if(r)await r.authSetGhCliDisabled(e);else{let t=await p(`/api/github/auth/gh-cli`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({disabled:e})}),n=await t.json().catch(()=>null);if(!t.ok)throw Error(n?.error||t.statusText)}q.success(t(e?`settings.github.page.toast.ghCliDisabled`:`settings.github.page.toast.ghCliEnabled`)),await c(r,{force:!0})}catch(e){console.error(`Failed to update gh CLI setting:`,e),q.error(t(`settings.github.page.toast.ghCliUpdateFailed`))}finally{m(!1)}},[c,r,t]),T=Q.useCallback(async()=>{m(!0);try{if(x(),g(null),r)await r.authDisconnect();else{let e=await p(`/api/github/auth`,{method:`DELETE`,headers:{Accept:`application/json`}});if(!e.ok)throw Error(e.statusText)}q.success(t(`settings.github.page.toast.disconnected`)),await c(r,{force:!0})}catch(e){console.error(`Failed to disconnect GitHub:`,e),q.error(t(`settings.github.page.toast.disconnectFailed`))}finally{m(!1)}},[c,r,x,t]),E=Q.useCallback(async e=>{if(e){m(!0);try{let n=r?await r.authActivate(e):await(async()=>{let t=await p(`/api/github/auth/activate`,{method:`POST`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({accountId:e})}),n=await t.json().catch(()=>null);if(!t.ok||!n)throw Error(n?.error||t.statusText);return n})();l(n),q.success(t(`settings.github.page.toast.accountSwitched`))}catch(e){console.error(`Failed to switch GitHub account:`,e),q.error(t(`settings.github.page.toast.accountSwitchFailed`))}finally{m(!1)}}},[r,l,t]);if(o)return null;if(i.isError&&!i.data)return(0,$.jsx)(`div`,{className:`yuri-settings-group-description text-[var(--status-error)]`,children:i.error.message});let D=!!a?.connected,O=a?.user,k=(a?.accounts??[]).filter(e=>!e.current),A=a?.ghCli??null,j=A?.active?t(`settings.github.page.accountSource.cli`):t(`settings.github.page.accountSource.oauth`);return(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[(0,$.jsxs)(X,{itemId:e,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:t(`settings.github.page.oauth.title`)}),(0,$.jsxs)(kn,{children:[(0,$.jsx)(Dn,{asChild:!0,children:(0,$.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(On,{sideOffset:8,className:`max-w-xs`,children:t(`settings.github.page.tooltip.connectAccount`)})]})]}),children:[(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[D?(0,$.jsxs)(`div`,{className:G(`yuri-settings-group-row`,n?`flex flex-col items-stretch gap-3`:`flex items-center justify-between gap-4`),children:[(0,$.jsxs)(`div`,{className:G(`flex min-w-0 items-center gap-3`,n?`w-full`:void 0),children:[O?.avatarUrl?(0,$.jsx)(`img`,{src:O.avatarUrl,alt:O.login?t(`settings.github.page.avatarAlt.withLogin`,{login:O.login}):t(`settings.github.page.avatarAlt.fallback`),className:`h-10 w-10 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)] object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(`div`,{className:`h-10 w-10 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)]`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:O?.name?.trim()||O?.login||`GitHub`}),(0,$.jsxs)(`div`,{className:G(`flex items-center gap-2 typography-meta text-muted-foreground mt-0.5`,n?`flex-wrap`:`truncate`),children:[(0,$.jsx)(Y,{name:`github-fill`,className:`h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`font-mono`,children:O?.login||t(`settings.github.page.label.unknownUser`)}),O?.email&&(0,$.jsx)(`span`,{className:`opacity-50`,children:`•`}),O?.email&&(0,$.jsx)(`span`,{children:O.email}),(0,$.jsx)(`span`,{className:`opacity-50`,children:`•`}),(0,$.jsx)(`span`,{children:j})]}),a?.scope&&(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70 mt-0.5`,children:t(`settings.github.page.label.scopes`,{value:a.scope})}),A?.active&&(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70 mt-0.5`,children:t(`settings.github.page.ghCli.activeDescription`)})]})]}),A?.active?(0,$.jsx)(K,{size:`sm`,variant:`outline`,onClick:()=>w(!0),disabled:d,className:G(n?`w-full`:void 0),children:t(`settings.github.page.ghCli.actions.disable`)}):(0,$.jsx)(K,{size:`sm`,variant:`outline`,onClick:T,disabled:d,className:G(`text-[var(--status-error)] hover:text-[var(--status-error)]`,n?`w-full`:void 0),children:t(`settings.github.page.actions.disconnect`)})]}):(0,$.jsxs)(`div`,{className:G(`yuri-settings-group-row`,n?`flex flex-col items-stretch gap-3`:`flex items-center justify-between gap-4`),children:[(0,$.jsx)(`div`,{className:`flex min-w-0 flex-col`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:t(`settings.github.page.status.notConnected`)})}),(0,$.jsx)(K,{size:`sm`,variant:`default`,onClick:S,disabled:d,className:G(n?`w-full`:void 0),children:t(`settings.github.page.actions.connect`)})]}),k.length>0&&(0,$.jsxs)(`div`,{className:`yuri-settings-group-row flex flex-col gap-2`,children:[(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:t(`settings.github.page.label.otherAccounts`)}),k.map(e=>{let n=e.user,r=e.source===`gh-cli`?t(`settings.github.page.accountSource.cli`):t(`settings.github.page.accountSource.oauth`);return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[n?.avatarUrl?(0,$.jsx)(`img`,{src:n.avatarUrl,alt:n.login?t(`settings.github.page.avatarAlt.withLogin`,{login:n.login}):t(`settings.github.page.avatarAlt.fallback`),className:`h-6 w-6 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)] object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(`div`,{className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)]`,children:(0,$.jsx)(Y,{name:`github-fill`,className:`h-3 w-3 text-muted-foreground`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex flex-col`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:n?.name?.trim()||n?.login||`GitHub`}),n?.login&&(0,$.jsxs)(`span`,{className:`typography-micro text-muted-foreground truncate`,children:[(0,$.jsx)(`span`,{className:`font-mono`,children:n.login}),(0,$.jsx)(`span`,{className:`mx-1 opacity-50`,children:`·`}),(0,$.jsx)(`span`,{children:r})]})]})]}),(0,$.jsx)(K,{size:`sm`,variant:`ghost`,onClick:()=>E(e.id),disabled:d,children:t(`settings.github.page.actions.switchTo`)})]},e.id)})]})]}),D&&(0,$.jsx)(`div`,{className:`yuri-settings-group-row flex justify-end`,children:(0,$.jsx)(K,{size:`sm`,variant:`outline`,onClick:S,disabled:d,className:G(n?`w-full`:void 0),children:t(`settings.github.page.actions.addAccount`)})})]}),h&&(0,$.jsxs)(`div`,{className:`mt-4 rounded-lg bg-[var(--surface-elevated)]/70 p-4 border border-[var(--interactive-border)]`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`h4`,{className:`typography-ui-label text-foreground`,children:t(`settings.github.page.flow.title`)}),(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.github.page.flow.description`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 mt-4`,children:[(0,$.jsx)(`div`,{className:`font-mono text-xl tracking-widest text-foreground bg-[var(--surface-muted)] px-3 py-1.5 rounded-md border border-[var(--interactive-border)]`,children:h.userCode}),(0,$.jsx)(K,{size:`sm`,asChild:!0,children:(0,$.jsx)(`a`,{href:h.verificationUriComplete||h.verificationUri,target:`_blank`,rel:`noopener noreferrer`,children:t(`settings.github.page.actions.openGithub`)})})]}),(0,$.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground animate-pulse`,children:t(`settings.github.page.flow.waiting`)}),(0,$.jsx)(K,{size:`sm`,variant:`ghost`,disabled:d,onClick:()=>{x(),g(null)},children:t(`settings.common.actions.cancel`)})]})]}),A?.available&&!A?.active&&(!A.user||A.disabled)&&(0,$.jsx)(X,{label:t(`settings.github.page.ghCli.title`),children:(0,$.jsx)(`div`,{className:`yuri-settings-group-row`,children:(0,$.jsxs)(`div`,{className:G(n?`flex flex-col gap-3`:`flex items-center justify-between gap-4`),children:[(0,$.jsxs)(`div`,{className:G(`flex min-w-0 items-center gap-3`,n?`w-full`:void 0),children:[A.user?.avatarUrl?(0,$.jsx)(`img`,{src:A.user.avatarUrl,alt:A.user.login?t(`settings.github.page.avatarAlt.withLogin`,{login:A.user.login}):t(`settings.github.page.avatarAlt.fallback`),className:`h-10 w-10 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)] object-cover`,loading:`lazy`,referrerPolicy:`no-referrer`}):(0,$.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)]`,children:(0,$.jsx)(Y,{name:`github-fill`,className:`h-4 w-4 text-muted-foreground`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[!A.disabled&&A.user&&(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground truncate`,children:A.user.name?.trim()||A.user.login||`GitHub`}),!A.disabled&&A.user?.login&&(0,$.jsxs)(`div`,{className:G(`flex items-center gap-2 typography-meta text-muted-foreground mt-0.5`,n?`flex-wrap`:`truncate`),children:[(0,$.jsx)(Y,{name:`github-fill`,className:`h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`font-mono`,children:A.user.login}),A.user.email&&(0,$.jsx)(`span`,{className:`opacity-50`,children:`•`}),A.user.email&&(0,$.jsx)(`span`,{children:A.user.email})]}),(0,$.jsx)(`div`,{className:G(`typography-meta text-muted-foreground`,A.disabled?`opacity-60`:void 0),children:A.disabled?t(`settings.github.page.ghCli.disabledDescription`):t(`settings.github.page.ghCli.fallbackDescription`)})]})]}),(0,$.jsx)(K,{size:`sm`,variant:`outline`,onClick:()=>w(!A.disabled),disabled:d,className:G(n?`w-full`:void 0),children:A.disabled?t(`settings.github.page.ghCli.actions.enable`):t(`settings.github.page.ghCli.actions.disable`)})]})})})]})},Cp=[{key:`keyword`,label:`Green`,cssVar:`var(--syntax-keyword)`},{key:`error`,label:`Red`,cssVar:`var(--status-error)`},{key:`string`,label:`Cyan`,cssVar:`var(--syntax-string)`},{key:`function`,label:`Orange`,cssVar:`var(--syntax-function)`},{key:`type`,label:`Yellow`,cssVar:`var(--syntax-type)`}],wp=[{key:`branch`,Icon:`git-branch`,label:`Branch`},{key:`briefcase`,Icon:`briefcase`,label:`Work`},{key:`house`,Icon:`home`,label:`Personal`},{key:`graduation`,Icon:`graduation-cap`,label:`School`},{key:`code`,Icon:`code`,label:`Code`}],Tp=({open:e,onOpenChange:t,profileId:n,importData:r})=>{let{t:i}=He(),a=xi(e=>e.getProfileById),o=xi(e=>e.createProfile),s=xi(e=>e.updateProfile),c=xi(e=>e.deleteProfile),l=Q.useMemo(()=>n&&n!==`new`&&!r?a(n):null,[n,a,r]),u=n===`new`||r!=null,d=n===`global`,[f,p]=Q.useState(``),[m,h]=Q.useState(``),[g,_]=Q.useState(``),[v,y]=Q.useState(`ssh`),[b,x]=Q.useState(``),[S,C]=Q.useState(!1),[w,T]=Q.useState(``),[E,D]=Q.useState(``),[O,k]=Q.useState(`keyword`),[A,j]=Q.useState(`branch`),[M,N]=Q.useState(!1),[P,F]=Q.useState(!1),[I,L]=Q.useState(!1);Q.useEffect(()=>{if(e){if(r){let e=r.host.split(`/`),t=e.length>=3?e[e.length-1]:r.host;p(t),h(r.username),_(``),y(`token`),x(``),C(!1),T(``),D(r.host),k(`string`),j(`code`)}else if(u)p(``),h(``),_(``),y(`ssh`),x(``),C(!1),T(``),D(``),k(`keyword`),j(`branch`);else if(l)p(l.name),h(l.userName),_(l.userEmail),y(l.authType||`ssh`),x(l.sshKey||``),C(l.signCommits===!0),T(l.signingKey||``),D(l.host||``),k(l.color||`keyword`),j(l.icon||`branch`);else if(d){let e=a(`global`);e&&(p(e.name),h(e.userName),_(e.userEmail),y(e.authType||`ssh`),x(e.sshKey||``),C(!1),T(``),D(e.host||``),k(e.color||`keyword`),j(e.icon||`branch`))}}},[e,n,l,u,r,d,a]);let R=async()=>{if(!m.trim()||!g.trim()){q.error(i(`settings.gitIdentities.editor.toast.userNameEmailRequired`));return}if(v===`token`&&!E.trim()){q.error(i(`settings.gitIdentities.editor.toast.hostRequiredForToken`));return}if(S&&!w.trim()){q.error(i(`settings.gitIdentities.editor.toast.signingKeyRequired`));return}N(!0);try{let e={name:f.trim()||m.trim(),userName:m.trim(),userEmail:g.trim(),authType:v,sshKey:v===`ssh`&&b.trim()||null,signCommits:S,signingKey:w.trim()||null,host:v===`token`&&E.trim()||null,color:O,icon:A},r;if(u)r=await o(e);else if(n)r=await s(n,e);else return;r?(q.success(i(u?`settings.gitIdentities.editor.toast.profileCreated`:`settings.gitIdentities.editor.toast.profileUpdated`)),t(!1)):q.error(i(u?`settings.gitIdentities.editor.toast.createProfileFailed`:`settings.gitIdentities.editor.toast.updateProfileFailed`))}catch(e){console.error(`Error saving profile:`,e),q.error(i(`settings.gitIdentities.editor.toast.saveUnexpectedError`))}finally{N(!1)}},z=async()=>{if(!(!n||u)){L(!0);try{await c(n)?(q.success(i(`settings.gitIdentities.editor.toast.profileDeleted`)),F(!1),t(!1)):q.error(i(`settings.gitIdentities.editor.toast.deleteProfileFailed`))}catch(e){console.error(`Error deleting profile:`,e),q.error(i(`settings.gitIdentities.editor.toast.deleteUnexpectedError`))}finally{L(!1)}}},B=Q.useMemo(()=>Cp.find(e=>e.key===O)?.cssVar||`var(--syntax-keyword)`,[O]),V=r?i(`settings.gitIdentities.editor.title.importCredential`):u?i(`settings.gitIdentities.editor.title.newIdentity`):d?i(`settings.gitIdentities.editor.title.globalIdentity`):l?.name||i(`settings.gitIdentities.editor.title.editIdentity`);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(hn,{open:e,onOpenChange:t,children:(0,$.jsxs)(fn,{className:`max-w-lg max-h-[85vh] overflow-y-auto`,children:[(0,$.jsx)(Xr,{className:`pr-8`,actions:d?null:(0,$.jsxs)($.Fragment,{children:[u?null:(0,$.jsx)(K,{variant:`ghost`,size:`icon`,onClick:()=>F(!0),disabled:M,"aria-label":i(`settings.common.actions.delete`),title:i(`settings.common.actions.delete`),className:`text-[var(--status-error)]`,children:(0,$.jsx)(Y,{name:`delete-bin`,className:`size-4`})}),(0,$.jsx)(K,{size:`sm`,onClick:R,disabled:M,"aria-busy":M,children:i(M?`settings.common.actions.saving`:u?`settings.gitIdentities.editor.actions.create`:`settings.gitIdentities.editor.actions.save`)})]}),children:(0,$.jsxs)(un,{children:[(0,$.jsx)(pn,{children:V}),(0,$.jsx)(mn,{children:i(d?`settings.gitIdentities.editor.description.globalReadOnly`:u?`settings.gitIdentities.editor.description.newProfile`:`settings.gitIdentities.editor.description.editProfile`)})]})}),(0,$.jsxs)(`div`,{className:`space-y-5 py-2`,children:[!d&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground block mb-1.5`,children:i(`settings.gitIdentities.editor.field.profileName`)}),(0,$.jsx)(En,{value:f,onChange:e=>p(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.profileNamePlaceholder`),className:`h-8`})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.color`)}),(0,$.jsx)(`div`,{className:`flex gap-1.5`,children:Cp.map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>k(e.key),className:G(`w-6 h-6 rounded-md border-2 transition-all cursor-pointer`,O===e.key?`border-foreground scale-110`:`border-transparent hover:border-border`),style:{backgroundColor:e.cssVar},title:e.label},e.key))})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.icon`)}),(0,$.jsx)(`div`,{className:`flex gap-1.5`,children:wp.map(e=>{let t=e.Icon;return(0,$.jsx)(`button`,{type:`button`,onClick:()=>j(e.key),className:G(`w-7 h-7 rounded-md border-2 transition-all flex items-center justify-center cursor-pointer`,A===e.key?`border-[var(--interactive-border)] bg-[var(--surface-muted)]`:`border-transparent hover:border-[var(--interactive-border)] hover:bg-[var(--surface-muted)]/50`),title:e.label,children:(0,$.jsx)(Y,{name:t,className:`w-3.5 h-3.5`,style:{color:A===e.key?B:`var(--surface-muted-foreground)`}})},e.key)})})]})]}),!d&&(0,$.jsx)(`div`,{className:`border-t border-border/40`}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.userName`)}),!d&&(0,$.jsx)(`span`,{className:`text-[var(--status-error)] text-xs`,children:`*`}),(0,$.jsxs)(kn,{children:[(0,$.jsx)(Dn,{asChild:!0,children:(0,$.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(On,{sideOffset:8,className:`max-w-xs`,children:i(`settings.gitIdentities.editor.field.userNameTooltip`)})]})]}),(0,$.jsx)(En,{value:m,onChange:e=>h(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.userNamePlaceholder`),required:!d,readOnly:d,disabled:d,className:`h-8`})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.emailAddress`)}),!d&&(0,$.jsx)(`span`,{className:`text-[var(--status-error)] text-xs`,children:`*`}),(0,$.jsxs)(kn,{children:[(0,$.jsx)(Dn,{asChild:!0,children:(0,$.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(On,{sideOffset:8,className:`max-w-xs`,children:i(`settings.gitIdentities.editor.field.emailAddressTooltip`)})]})]}),(0,$.jsx)(En,{type:`email`,value:g,onChange:e=>_(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.emailAddressPlaceholder`),required:!d,readOnly:d,disabled:d,className:`h-8`})]})]}),!d&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`border-t border-border/40`}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.authMethod`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsxs)(K,{size:`sm`,type:`button`,variant:`chip`,"aria-pressed":v===`ssh`,onClick:()=>y(`ssh`),children:[(0,$.jsx)(Y,{name:`lock-2`,className:`w-3.5 h-3.5 mr-1`}),` SSH`]}),(0,$.jsxs)(K,{size:`sm`,type:`button`,variant:`chip`,"aria-pressed":v===`token`,onClick:()=>y(`token`),children:[(0,$.jsx)(Y,{name:`key`,className:`w-3.5 h-3.5 mr-1`}),` `,i(`settings.gitIdentities.editor.field.authToken`)]})]})]}),v===`ssh`&&(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.sshKeyPath`)}),(0,$.jsxs)(kn,{children:[(0,$.jsx)(Dn,{asChild:!0,children:(0,$.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(On,{sideOffset:8,className:`max-w-xs`,children:i(`settings.gitIdentities.editor.field.sshKeyPathTooltip`)})]})]}),(0,$.jsx)(En,{value:b,onChange:e=>x(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.sshKeyPathPlaceholder`),className:`h-8 font-mono text-xs`})]}),(0,$.jsxs)(`div`,{className:`border-t border-border/40 pt-3 space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(gn,{checked:S,onChange:C,ariaLabel:i(`settings.gitIdentities.editor.field.signCommits`)}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.signCommits`)}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:i(`settings.gitIdentities.editor.section.commitSigning`)})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.signingKey`)})}),(0,$.jsx)(En,{value:w,onChange:e=>T(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.signingKeyPlaceholder`),disabled:!S,className:`h-8 font-mono text-xs`})]})]}),v===`token`&&(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,$.jsx)(`label`,{className:`typography-ui-label text-foreground`,children:i(`settings.gitIdentities.editor.field.host`)}),(0,$.jsx)(`span`,{className:`text-[var(--status-error)] text-xs`,children:`*`}),(0,$.jsxs)(kn,{children:[(0,$.jsx)(Dn,{asChild:!0,children:(0,$.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(On,{sideOffset:8,className:`max-w-xs`,children:i(`settings.gitIdentities.editor.field.hostTooltip`)})]})]}),(0,$.jsx)(En,{value:E,onChange:e=>D(e.target.value),placeholder:i(`settings.gitIdentities.editor.field.hostPlaceholder`),required:!0,className:`h-8 font-mono text-xs`})]})]})]})]}),(0,$.jsx)(dn,{className:`gap-2`,children:(0,$.jsx)(K,{variant:`ghost`,size:`sm`,onClick:()=>t(!1),className:`text-foreground hover:bg-interactive-hover hover:text-foreground`,children:i(d?`settings.gitIdentities.editor.actions.close`:`settings.common.actions.cancel`)})})]})}),(0,$.jsx)(hn,{open:P,onOpenChange:e=>{I||F(e)},children:(0,$.jsxs)(fn,{className:`max-w-md`,children:[(0,$.jsxs)(un,{children:[(0,$.jsx)(pn,{children:i(`settings.gitIdentities.page.deleteDialog.title`)}),(0,$.jsx)(mn,{children:i(`settings.gitIdentities.page.deleteDialog.description`,{name:l?.name||f})})]}),(0,$.jsxs)(dn,{children:[(0,$.jsx)(K,{variant:`ghost`,onClick:()=>F(!1),disabled:I,children:i(`settings.common.actions.cancel`)}),(0,$.jsx)(K,{size:`sm`,variant:`destructive`,onClick:()=>void z(),disabled:I,children:i(`settings.common.actions.delete`)})]})]})})]})},Ep={branch:`git-branch`,briefcase:`briefcase`,house:`home`,graduation:`graduation-cap`,code:`code`,heart:`heart`},Dp={keyword:`var(--syntax-keyword)`,error:`var(--status-error)`,string:`var(--syntax-string)`,function:`var(--syntax-function)`,type:`var(--syntax-type)`},Op=()=>{let e=(0,qi.c)(116),{t}=He(),{profiles:n,globalIdentity:r,defaultGitIdentityId:i,deleteProfile:a,loadProfiles:o,loadGlobalIdentity:s,loadDiscoveredCredentials:c,loadDefaultGitIdentityId:l,setDefaultGitIdentityId:u,getUnimportedCredentials:d}=xi(de(jp)),[f,p]=Q.useState(!1),[m,h]=Q.useState(null),[g,_]=Q.useState(null),[v,y]=Q.useState(null),[b,x]=Q.useState(!1),S,C;e[0]!==l||e[1]!==c||e[2]!==s||e[3]!==o?(S=()=>{o(),s(),c(),l()},C=[o,s,c,l],e[0]=l,e[1]=c,e[2]=s,e[3]=o,e[4]=S,e[5]=C):(S=e[4],C=e[5]),Q.useEffect(S,C);let w,T,E,D,O,k,A,j,M,N,P,F,I,L;if(e[6]!==i||e[7]!==v||e[8]!==a||e[9]!==d||e[10]!==r||e[11]!==n||e[12]!==u||e[13]!==t){let o=d(),s;e[28]===Symbol.for(`react.memo_cache_sentinel`)?(s=(e,t)=>{h(e),_(t??null),p(!0)},e[28]=s):s=e[28];let c=s,l;e[29]!==i||e[30]!==u||e[31]!==t?(l=async e=>{let n=i===e?null:e;if(!await u(n)){q.error(t(`settings.gitIdentities.page.toast.updateDefaultFailed`));return}q.success(t(n?`settings.gitIdentities.page.toast.defaultUpdated`:`settings.gitIdentities.page.toast.defaultUnset`))},e[29]=i,e[30]=u,e[31]=t,e[32]=l):l=e[32];let f=l,m;e[33]!==v||e[34]!==a||e[35]!==t?(m=async()=>{v&&(x(!0),await a(v.id)?(q.success(t(`settings.gitIdentities.page.toast.profileDeleted`,{name:v.name})),y(null)):q.error(t(`settings.gitIdentities.page.toast.deleteProfileFailed`)),x(!1))},e[33]=v,e[34]=a,e[35]=t,e[36]=m):m=e[36],E=m,T=Rr,O=`h-full`,k=`w-full bg-background`,L=`yuri-settings-page-content mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,e[37]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(Sp,{itemId:`git.github-account`}),e[37]=D):D=e[37],w=X,A=`git.identities`;let g;e[38]===t?g=e[39]:(g=t(`settings.gitIdentities.page.section.title`),e[38]=t,e[39]=g);let b;e[40]===g?b=e[41]:(b=(0,$.jsx)(`span`,{children:g}),e[40]=g,e[41]=b);let S,C;e[42]===Symbol.for(`react.memo_cache_sentinel`)?(S=()=>c(`new`),C=(0,$.jsx)(Y,{name:`add`,className:`mr-1 size-3.5`}),e[42]=S,e[43]=C):(S=e[42],C=e[43]);let R;e[44]===t?R=e[45]:(R=t(`settings.common.badge.new`),e[44]=t,e[45]=R);let z;e[46]===R?z=e[47]:(z=(0,$.jsxs)(K,{size:`sm`,variant:`ghost`,onClick:S,children:[C,` `,R]}),e[46]=R,e[47]=z),e[48]!==b||e[49]!==z?(j=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[b,z]}),e[48]=b,e[49]=z,e[50]=j):j=e[50],M=`flex flex-col`,N=r&&(0,$.jsx)(kp,{profile:r,isDefault:i===`global`,onEdit:()=>c(`global`),onToggleDefault:()=>f(`global`),isReadOnly:!0,hasBorder:n.length>0||o.length>0}),P=n.map((e,t)=>(0,$.jsx)(kp,{profile:e,isDefault:i===e.id,onEdit:()=>c(e.id),onToggleDefault:()=>f(e.id),onDelete:()=>y(e),hasBorder:t<n.length-1||o.length>0},e.id)),F=!r&&n.length===0&&o.length===0&&(0,$.jsxs)(`div`,{className:`py-8 px-4 text-center text-muted-foreground`,children:[(0,$.jsx)(Y,{name:`shield-keyhole`,className:`mx-auto mb-2 h-8 w-8 opacity-40`}),(0,$.jsx)(`p`,{className:`typography-ui-label`,children:t(`settings.gitIdentities.page.empty.title`)}),(0,$.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:t(`settings.gitIdentities.page.empty.description`)})]}),I=o.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`px-4 py-2 border-t border-[var(--surface-subtle)]`,children:(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:t(`settings.gitIdentities.page.discoveredCredentials.title`)})}),o.map((e,t)=>(0,$.jsx)(Ap,{credential:e,onImport:()=>c(`new`,{host:e.host,username:e.username}),hasBorder:t<o.length-1},`${e.host}-${e.username}`))]}),e[6]=i,e[7]=v,e[8]=a,e[9]=d,e[10]=r,e[11]=n,e[12]=u,e[13]=t,e[14]=w,e[15]=T,e[16]=E,e[17]=D,e[18]=O,e[19]=k,e[20]=A,e[21]=j,e[22]=M,e[23]=N,e[24]=P,e[25]=F,e[26]=I,e[27]=L}else w=e[14],T=e[15],E=e[16],D=e[17],O=e[18],k=e[19],A=e[20],j=e[21],M=e[22],N=e[23],P=e[24],F=e[25],I=e[26],L=e[27];let R;e[51]!==w||e[52]!==A||e[53]!==j||e[54]!==M||e[55]!==N||e[56]!==P||e[57]!==F||e[58]!==I?(R=(0,$.jsxs)(w,{itemId:A,label:j,cardClassName:M,children:[N,P,F,I]}),e[51]=w,e[52]=A,e[53]=j,e[54]=M,e[55]=N,e[56]=P,e[57]=F,e[58]=I,e[59]=R):R=e[59];let z;e[60]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,$.jsx)(xp,{}),e[60]=z):z=e[60];let B;e[61]!==D||e[62]!==R||e[63]!==L?(B=(0,$.jsxs)(`div`,{className:L,children:[D,R,z]}),e[61]=D,e[62]=R,e[63]=L,e[64]=B):B=e[64];let V;e[65]!==T||e[66]!==O||e[67]!==k||e[68]!==B?(V=(0,$.jsx)(T,{outerClassName:O,className:k,children:B}),e[65]=T,e[66]=O,e[67]=k,e[68]=B,e[69]=V):V=e[69];let ee;e[70]!==g||e[71]!==f||e[72]!==m?(ee=(0,$.jsx)(Tp,{open:f,onOpenChange:p,profileId:m,importData:g}),e[70]=g,e[71]=f,e[72]=m,e[73]=ee):ee=e[73];let H=v!==null,te;e[74]===b?te=e[75]:(te=e=>{b||e||y(null)},e[74]=b,e[75]=te);let ne;e[76]===t?ne=e[77]:(ne=t(`settings.gitIdentities.page.deleteDialog.title`),e[76]=t,e[77]=ne);let U;e[78]===ne?U=e[79]:(U=(0,$.jsx)(pn,{children:ne}),e[78]=ne,e[79]=U);let re=v?.name??``,ie;e[80]!==t||e[81]!==re?(ie=t(`settings.gitIdentities.page.deleteDialog.description`,{name:re}),e[80]=t,e[81]=re,e[82]=ie):ie=e[82];let ae;e[83]===ie?ae=e[84]:(ae=(0,$.jsx)(mn,{children:ie}),e[83]=ie,e[84]=ae);let oe;e[85]!==U||e[86]!==ae?(oe=(0,$.jsxs)(un,{children:[U,ae]}),e[85]=U,e[86]=ae,e[87]=oe):oe=e[87];let se;e[88]===Symbol.for(`react.memo_cache_sentinel`)?(se=()=>y(null),e[88]=se):se=e[88];let ce;e[89]===t?ce=e[90]:(ce=t(`settings.common.actions.cancel`),e[89]=t,e[90]=ce);let le;e[91]!==b||e[92]!==ce?(le=(0,$.jsx)(K,{variant:`ghost`,onClick:se,disabled:b,children:ce}),e[91]=b,e[92]=ce,e[93]=le):le=e[93];let ue;e[94]===E?ue=e[95]:(ue=()=>void E(),e[94]=E,e[95]=ue);let fe;e[96]===t?fe=e[97]:(fe=t(`settings.common.actions.delete`),e[96]=t,e[97]=fe);let pe;e[98]!==b||e[99]!==ue||e[100]!==fe?(pe=(0,$.jsx)(K,{size:`sm`,variant:`destructive`,onClick:ue,disabled:b,children:fe}),e[98]=b,e[99]=ue,e[100]=fe,e[101]=pe):pe=e[101];let me;e[102]!==le||e[103]!==pe?(me=(0,$.jsxs)(dn,{children:[le,pe]}),e[102]=le,e[103]=pe,e[104]=me):me=e[104];let he;e[105]!==oe||e[106]!==me?(he=(0,$.jsxs)(fn,{className:`max-w-md`,children:[oe,me]}),e[105]=oe,e[106]=me,e[107]=he):he=e[107];let ge;e[108]!==H||e[109]!==te||e[110]!==he?(ge=(0,$.jsx)(hn,{open:H,onOpenChange:te,children:he}),e[108]=H,e[109]=te,e[110]=he,e[111]=ge):ge=e[111];let _e;return e[112]!==V||e[113]!==ee||e[114]!==ge?(_e=(0,$.jsxs)($.Fragment,{children:[V,ee,ge]}),e[112]=V,e[113]=ee,e[114]=ge,e[115]=_e):_e=e[115],_e},kp=e=>{let t=(0,qi.c)(56),{profile:n,isDefault:r,onEdit:i,onToggleDefault:a,onDelete:o,isReadOnly:s,hasBorder:c}=e,{t:l}=He(),[u,d]=Q.useState(!1),f=Ep[n.icon||`branch`]||`git-branch`,p=Dp[n.color||``],m=n.authType||`ssh`,h;t[0]===i?h=t[1]:(h=e=>{e.currentTarget===e.target&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),i())},t[0]=i,t[1]=h);let g=h,_;t[2]!==r||t[3]!==s||t[4]!==o||t[5]!==a||t[6]!==l?(_=e=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(e,{onClick:e=>{e.stopPropagation(),a()},children:l(r?`settings.gitIdentities.page.actions.unsetDefault`:`settings.gitIdentities.page.actions.setAsDefault`)}),!s&&o&&(0,$.jsxs)(e,{onClick:e=>{e.stopPropagation(),o()},className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(Y,{name:`delete-bin`,className:`h-4 w-4 mr-px`}),l(`settings.common.actions.delete`)]})]}),t[2]=r,t[3]=s,t[4]=o,t[5]=a,t[6]=l,t[7]=_):_=t[7];let v=_,y=c&&`border-b border-[var(--surface-subtle)]`,b;t[8]===y?b=t[9]:(b=G(`group flex items-center justify-between gap-3 px-4 py-2.5 transition-colors hover:bg-[var(--interactive-hover)]/30 cursor-pointer`,y),t[8]=y,t[9]=b);let x;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(x=e=>{e.preventDefault(),d(!0)},t[10]=x):x=t[10];let S;t[11]!==g||t[12]!==i||t[13]!==b?(S=(0,$.jsx)(`div`,{className:b,onClick:i,role:`button`,tabIndex:0,onKeyDown:g,onContextMenu:x}),t[11]=g,t[12]=i,t[13]=b,t[14]=S):S=t[14];let C;t[15]===p?C=t[16]:(C={color:p},t[15]=p,t[16]=C);let w;t[17]!==f||t[18]!==C?(w=(0,$.jsx)(Y,{name:f,className:`w-4 h-4 shrink-0`,style:C}),t[17]=f,t[18]=C,t[19]=w):w=t[19];let T;t[20]===n.name?T=t[21]:(T=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:n.name}),t[20]=n.name,t[21]=T);let E;t[22]===m?E=t[23]:(E=(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:m}),t[22]=m,t[23]=E);let D;t[24]!==r||t[25]!==l?(D=r&&(0,$.jsx)(`span`,{className:`typography-micro text-primary bg-primary/12 px-1 rounded flex-shrink-0 leading-none pb-px border border-primary/25`,children:l(`settings.gitIdentities.page.badge.default`)}),t[24]=r,t[25]=l,t[26]=D):D=t[26];let O;t[27]!==s||t[28]!==l?(O=s&&(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:l(`settings.agents.sidebar.badge.system`)}),t[27]=s,t[28]=l,t[29]=O):O=t[29];let k;t[30]!==E||t[31]!==D||t[32]!==O||t[33]!==T?(k=(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[T,E,D,O]}),t[30]=E,t[31]=D,t[32]=O,t[33]=T,t[34]=k):k=t[34];let A=m===`token`&&n.host?n.host:n.userEmail,j;t[35]===A?j=t[36]:(j=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/60 truncate leading-tight`,children:A}),t[35]=A,t[36]=j);let M;t[37]!==k||t[38]!==j?(M=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[k,j]}),t[37]=k,t[38]=j,t[39]=M):M=t[39];let N;t[40]!==M||t[41]!==w?(N=(0,$.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[w,M]}),t[40]=M,t[41]=w,t[42]=N):N=t[42];let P;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(kr,{asChild:!0,children:(0,$.jsx)(K,{size:`icon`,variant:`ghost`,className:`h-6 w-6 shrink-0 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100`,onClick:Mp,children:(0,$.jsx)(Y,{name:`more-2`,className:`h-3.5 w-3.5`})})}),t[43]=P):P=t[43];let F;t[44]===v?F=t[45]:(F=(0,$.jsxs)(Cr,{children:[P,(0,$.jsx)(hr,{align:`end`,className:`w-fit min-w-28`,children:v(ar)})]}),t[44]=v,t[45]=F);let I;t[46]!==N||t[47]!==F||t[48]!==S?(I=(0,$.jsxs)(Pi,{render:S,children:[N,F]}),t[46]=N,t[47]=F,t[48]=S,t[49]=I):I=t[49];let L;t[50]===v?L=t[51]:(L=(0,$.jsx)(Ii,{className:`w-fit min-w-28`,children:v(Ri)}),t[50]=v,t[51]=L);let R;return t[52]!==u||t[53]!==I||t[54]!==L?(R=(0,$.jsxs)(ji,{open:u,onOpenChange:d,children:[I,L]}),t[52]=u,t[53]=I,t[54]=L,t[55]=R):R=t[55],R},Ap=e=>{let t=(0,qi.c)(21),{credential:n,onImport:r,hasBorder:i}=e,{t:a}=He(),o;t[0]===n.host?o=t[1]:(o=n.host.split(`/`),t[0]=n.host,t[1]=o);let s=o,c=s.length>=3?s[s.length-1]:n.host,l=n.host.includes(`/`),u=i&&`border-b border-[var(--surface-subtle)]`,d;t[2]===u?d=t[3]:(d=G(`flex items-center justify-between gap-3 px-4 py-2.5 transition-colors hover:bg-[var(--interactive-hover)]/30`,u),t[2]=u,t[3]=d);let f;t[4]===c?f=t[5]:(f=(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate block`,children:c}),t[4]=c,t[5]=f);let p=l?n.host:n.username,m;t[6]===p?m=t[7]:(m=(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/60 truncate block leading-tight`,children:p}),t[6]=p,t[7]=m);let h;t[8]!==f||t[9]!==m?(h=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[f,m]}),t[8]=f,t[9]=m,t[10]=h):h=t[10];let g;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(Y,{name:`download`,className:`h-3 w-3`}),t[11]=g):g=t[11];let _;t[12]===a?_=t[13]:(_=a(`settings.gitIdentities.page.actions.import`),t[12]=a,t[13]=_);let v;t[14]!==r||t[15]!==_?(v=(0,$.jsxs)(K,{size:`sm`,variant:`ghost`,onClick:r,className:`gap-1 shrink-0`,children:[g,_]}),t[14]=r,t[15]=_,t[16]=v):v=t[16];let y;return t[17]!==v||t[18]!==d||t[19]!==h?(y=(0,$.jsxs)(`div`,{className:d,children:[h,v]}),t[17]=v,t[18]=d,t[19]=h,t[20]=y):y=t[20],y};function jp(e){return{profiles:e.profiles,globalIdentity:e.globalIdentity,defaultGitIdentityId:e.defaultGitIdentityId,deleteProfile:e.deleteProfile,loadProfiles:e.loadProfiles,loadGlobalIdentity:e.loadGlobalIdentity,loadDiscoveredCredentials:e.loadDiscoveredCredentials,loadDefaultGitIdentityId:e.loadDefaultGitIdentityId,setDefaultGitIdentityId:e.setDefaultGitIdentityId,getUnimportedCredentials:e.getUnimportedCredentials}}function Mp(e){return e.stopPropagation()}function Np(){let e=(0,qi.c)(32),{t}=He(),{settings:n}=Ae(),r=ft(),i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=o(),e[0]=i):i=e[0];let a=i,s;e[1]===n?s=e[2]:(s={mutationFn:async e=>{let t=o();if(await n.save({questionAutoDelegateEnabled:e}),t!==o())throw Error(`Runtime changed`);await Tt()}},e[1]=n,e[2]=s);let c=De(s,l),u=c.reset,d,f;e[3]===u?(d=e[4],f=e[5]):(d=()=>{u()},f=[a,u],e[3]=u,e[4]=d,e[5]=f),(0,Q.useEffect)(d,f);let p;e[6]===t?p=e[7]:(p=t(`settings.chat.questionDelegate.label`),e[6]=t,e[7]=p);let m;e[8]===t?m=e[9]:(m=t(`settings.chat.questionDelegate.label`),e[8]=t,e[9]=m);let h;e[10]===t?h=e[11]:(h=t(`settings.chat.questionDelegate.description`),e[10]=t,e[11]=h);let g=r.data?.snapshot.enabled??!0,_=c.isPending||!r.data||r.isError,v;e[12]===c?v=e[13]:(v=e=>c.mutate(e),e[12]=c,e[13]=v);let y;e[14]!==p||e[15]!==m||e[16]!==h||e[17]!==g||e[18]!==_||e[19]!==v?(y=(0,$.jsx)($r,{label:p,ariaLabel:m,description:h,checked:g,disabled:_,onChange:v}),e[14]=p,e[15]=m,e[16]=h,e[17]=g,e[18]=_,e[19]=v,e[20]=y):y=e[20];let b;e[21]!==c.isPending||e[22]!==t?(b=c.isPending?(0,$.jsx)(`div`,{className:`yuri-settings-group-row typography-meta text-muted-foreground`,role:`status`,children:t(`settings.common.actions.saving`)}):null,e[21]=c.isPending,e[22]=t,e[23]=b):b=e[23];let x;e[24]!==r||e[25]!==c||e[26]!==t?(x=r.isError||c.isError?(0,$.jsxs)(`div`,{className:`yuri-settings-group-row flex flex-wrap items-center gap-2`,role:`alert`,children:[(0,$.jsx)(`span`,{className:`typography-meta text-[var(--status-error)]`,children:t(c.isError?`settings.chat.questionDelegate.saveFailed`:`chat.questionDelegate.loadFailed`)}),(0,$.jsx)(K,{variant:`ghost`,size:`xs`,disabled:c.isPending,onClick:()=>c.isError?c.mutate(c.variables??!0):void r.refetch(),children:t(`chat.questionDelegate.retry`)})]}):null,e[24]=r,e[25]=c,e[26]=t,e[27]=x):x=e[27];let S;return e[28]!==y||e[29]!==b||e[30]!==x?(S=(0,$.jsxs)($.Fragment,{children:[y,b,x]}),e[28]=y,e[29]=b,e[30]=x,e[31]=S):S=e[31],S}var Pp=e=>{let t=(0,qi.c)(12),{isMobile:n,itemId:r,label:i,description:a,descriptionPlacement:o,children:s,className:c,copyClassName:l,controlClassName:u}=e,d=n&&`yuri-mobile-settings-detail-group`,f;t[0]===d?f=t[1]:(f=G(`yuri-settings-detail-group`,d),t[0]=d,t[1]=f);let p;return t[2]!==s||t[3]!==c||t[4]!==u||t[5]!==l||t[6]!==a||t[7]!==o||t[8]!==r||t[9]!==i||t[10]!==f?(p=(0,$.jsx)(di,{itemId:r,label:i,description:a,descriptionPlacement:o,groupClassName:f,className:c,copyClassName:l,controlClassName:u,children:s}),t[2]=s,t[3]=c,t[4]=u,t[5]=l,t[6]=a,t[7]=o,t[8]=r,t[9]=i,t[10]=f,t[11]=p):p=t[11],p},Fp=e=>{let t=(0,qi.c)(9),{isMobile:n,label:r,children:i,description:a,className:o,cardClassName:s}=e,c=n&&`yuri-mobile-settings-detail-group`,l;t[0]!==o||t[1]!==c?(l=G(`yuri-settings-detail-group`,c,o),t[0]=o,t[1]=c,t[2]=l):l=t[2];let u;return t[3]!==s||t[4]!==i||t[5]!==a||t[6]!==r||t[7]!==l?(u=(0,$.jsx)(X,{label:r,description:a,className:l,cardClassName:s,children:i}),t[3]=s,t[4]=i,t[5]=a,t[6]=r,t[7]=l,t[8]=u):u=t[8],u},Ip=e=>{let t=(0,qi.c)(8),{isMobile:n,itemId:r,label:i,mobileLabel:a,description:o,children:s,className:c,copyClassName:l,controlClassName:u}=e,d=n&&a!==void 0?a:i,f;return t[0]!==s||t[1]!==c||t[2]!==u||t[3]!==l||t[4]!==o||t[5]!==r||t[6]!==d?(f=(0,$.jsx)(Z,{itemId:r,label:d,description:o,className:c,copyClassName:l,controlClassName:u,children:s}),t[0]=s,t[1]=c,t[2]=u,t[3]=l,t[4]=o,t[5]=r,t[6]=d,t[7]=f):f=t[7],f},Lp=e=>{let t=(0,qi.c)(17),{selected:n,onSelect:r,label:i,ariaLabel:a}=e,o;t[0]===r?o=t[1]:(o=e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),r())},t[0]=r,t[1]=o);let s;t[2]!==a||t[3]!==r||t[4]!==n?(s=(0,$.jsx)(mc,{checked:n,onChange:r,ariaLabel:a}),t[2]=a,t[3]=r,t[4]=n,t[5]=s):s=t[5];let c=n?`text-foreground`:`text-foreground/50`,l;t[6]===c?l=t[7]:(l=G(`typography-ui-label font-normal`,c),t[6]=c,t[7]=l);let u;t[8]!==i||t[9]!==l?(u=(0,$.jsx)(`span`,{className:l,children:i}),t[8]=i,t[9]=l,t[10]=u):u=t[10];let d;return t[11]!==r||t[12]!==n||t[13]!==o||t[14]!==s||t[15]!==u?(d=(0,$.jsxs)(`div`,{className:`yuri-settings-group-row group flex cursor-pointer items-center gap-2 text-left`,role:`button`,tabIndex:0,"aria-pressed":n,onClick:r,onKeyDown:o,children:[s,u]}),t[11]=r,t[12]=n,t[13]=o,t[14]=s,t[15]=u,t[16]=d):d=t[16],d},Rp=[{value:`system`,labelKey:`settings.yuri.visual.option.themeMode.system`},{value:`light`,labelKey:`settings.yuri.visual.option.themeMode.light`},{value:`dark`,labelKey:`settings.yuri.visual.option.themeMode.dark`}],zp=[{id:`dynamic`,labelKey:`settings.yuri.visual.option.diffLayout.auto.label`,descriptionKey:`settings.yuri.visual.option.diffLayout.auto.description`},{id:`inline`,labelKey:`settings.yuri.visual.option.diffLayout.inline.label`,descriptionKey:`settings.yuri.visual.option.diffLayout.inline.description`},{id:`side-by-side`,labelKey:`settings.yuri.visual.option.diffLayout.sideBySide.label`,descriptionKey:`settings.yuri.visual.option.diffLayout.sideBySide.description`}],Bp=`Yuri - AI Coding Assistant`,Vp=[{id:`system`,labelKey:`settings.yuri.visual.option.pwaOrientation.system.label`,descriptionKey:`settings.yuri.visual.option.pwaOrientation.system.description`},{id:`portrait`,labelKey:`settings.yuri.visual.option.pwaOrientation.portrait.label`,descriptionKey:`settings.yuri.visual.option.pwaOrientation.portrait.description`},{id:`landscape`,labelKey:`settings.yuri.visual.option.pwaOrientation.landscape.label`,descriptionKey:`settings.yuri.visual.option.pwaOrientation.landscape.description`}],Hp=[{id:`native`,labelKey:`settings.yuri.visual.option.mobileKeyboardMode.native.label`,descriptionKey:`settings.yuri.visual.option.mobileKeyboardMode.native.description`},{id:`resize-content`,labelKey:`settings.yuri.visual.option.mobileKeyboardMode.resizeContent.label`,descriptionKey:`settings.yuri.visual.option.mobileKeyboardMode.resizeContent.description`}],Up=[{id:`steer`,labelKey:`settings.yuri.visual.option.followUpBehavior.steer.label`},{id:`queue`,labelKey:`settings.yuri.visual.option.followUpBehavior.queue.label`}],Wp=e=>e===`portrait`||e===`landscape`?e:`system`,Gp=[{id:`sorted`,labelKey:`settings.yuri.visual.option.chatRenderMode.sorted.label`,descriptionKey:`settings.yuri.visual.option.chatRenderMode.sorted.description`},{id:`live`,labelKey:`settings.yuri.visual.option.chatRenderMode.live.label`,descriptionKey:`settings.yuri.visual.option.chatRenderMode.live.description`}],Kp=[{id:`auto`,labelKey:`settings.yuri.visual.option.messageTransport.auto.label`,descriptionKey:`settings.yuri.visual.option.messageTransport.auto.description`},{id:`ws`,labelKey:`settings.yuri.visual.option.messageTransport.ws.label`,descriptionKey:`settings.yuri.visual.option.messageTransport.ws.description`},{id:`sse`,labelKey:`settings.yuri.visual.option.messageTransport.sse.label`,descriptionKey:`settings.yuri.visual.option.messageTransport.sse.description`}],qp=[{id:`auto`,labelKey:`settings.yuri.visual.option.timeFormat.auto.label`,descriptionKey:`settings.yuri.visual.option.timeFormat.auto.description`},{id:`24h`,labelKey:`settings.yuri.visual.option.timeFormat.24h.label`,descriptionKey:`settings.yuri.visual.option.timeFormat.24h.description`},{id:`12h`,labelKey:`settings.yuri.visual.option.timeFormat.12h.label`,descriptionKey:`settings.yuri.visual.option.timeFormat.12h.description`}],Jp=[{id:`auto`,labelKey:`settings.yuri.visual.option.weekStart.auto.label`,descriptionKey:`settings.yuri.visual.option.weekStart.auto.description`},{id:`monday`,labelKey:`settings.yuri.visual.option.weekStart.monday.label`},{id:`sunday`,labelKey:`settings.yuri.visual.option.weekStart.sunday.label`}],Yp=({visibleSettings:e,mobile:t})=>{let{locale:n,locales:r,setLocale:i,label:a,t:o}=He(),s=Q.useCallback(e=>o(e),[o]),{isMobile:c}=Pr(),l=t??c,{browserTab:u}=mi(),d=W(e=>e.showReasoningTraces),f=W(e=>e.sessionTitleRefreshEnabled),m=W(e=>e.setSessionTitleRefreshEnabled),h=W(e=>e.sessionGoalEnabled),g=W(e=>e.setSessionGoalEnabled),_=W(e=>e.sessionGoalDefaultBudgetEnabled),v=W(e=>e.setSessionGoalDefaultBudgetEnabled),y=W(e=>e.sessionGoalDefaultBudget),x=W(e=>e.setSessionGoalDefaultBudget),S=W(e=>e.setShowReasoningTraces),C=W(e=>e.collapsibleThinkingBlocks),T=W(e=>e.setCollapsibleThinkingBlocks),D=W(e=>e.collapsibleUserMessages),A=W(e=>e.setCollapsibleUserMessages),j=W(e=>e.expandedEditorToolbar),M=W(e=>e.setExpandedEditorToolbar),P=Br(e=>e.enabled),F=Br(e=>e.setEnabled),I=W(e=>e.chatRenderMode),L=W(e=>e.setChatRenderMode),R=W(e=>e.fontSize),z=W(e=>e.setFontSize),B=W(e=>e.codeFontSize),V=W(e=>e.setCodeFontSize),ee=W(e=>e.terminalFontSize),H=W(e=>e.setTerminalFontSize),te=W(e=>e.editorFontSize),ne=W(e=>e.setEditorFontSize),U=W(e=>e.uiFont),re=W(e=>e.setUiFont),ie=W(e=>e.monoFont),ae=W(e=>e.setMonoFont),oe=W(e=>e.padding),se=W(e=>e.setPadding),ce=W(e=>e.inputBarOffset),le=W(e=>e.setInputBarOffset),ue=W(e=>e.mobileKeyboardMode),de=W(e=>e.setMobileKeyboardMode),fe=W(e=>e.diffLayoutPreference),pe=W(e=>e.setDiffLayoutPreference),me=W(e=>e.showTerminalQuickKeysOnDesktop),he=W(e=>e.setShowTerminalQuickKeysOnDesktop),ge=W(e=>e.fileEditorKeymap),_e=W(e=>e.setFileEditorKeymap),ve=b(e=>e.followUpBehavior),ye=b(e=>e.setFollowUpBehavior),be=W(e=>e.persistChatDraft),Te=W(e=>e.setPersistChatDraft),Ee=W(e=>e.inputSpellcheckEnabled),De=W(e=>e.setInputSpellcheckEnabled),Oe=W(e=>e.showSubagentTaskDetails),ke=W(e=>e.setShowSubagentTaskDetails),Ae=W(e=>e.timeFormatPreference),je=W(e=>e.setTimeFormatPreference),Me=W(e=>e.weekStartPreference),Ne=W(e=>e.setWeekStartPreference),Pe=W(e=>e.showSplitAssistantMessageActions),Fe=W(e=>e.setShowSplitAssistantMessageActions),Ie=W(e=>e.showAssistantTps),Le=W(e=>e.setShowAssistantTps),Re=ai(e=>e.sidebarBrandName),ze=ai(e=>e.setSidebarBrandName),Be=W(e=>e.allowPromptingSubagentSessions),Ve=W(e=>e.setAllowPromptingSubagentSessions),Ue=tn(e=>e.settingsMessageStreamTransport),We=tn(e=>e.setSettingsMessageStreamTransport),Ge=Ue,Ke=W(e=>e.isSettingsDialogOpen),{themeMode:qe,setThemeMode:Je,availableThemes:Ye,customThemesLoading:Xe,reloadCustomThemes:Ze,lightThemeId:Qe,darkThemeId:$e,setLightThemePreference:et,setDarkThemePreference:tt}=ln(),[nt,rt]=Q.useState(!1),[it,at]=Q.useState(!1),[ot,st]=Q.useState(!1),ct=Q.useMemo(()=>E()&&typeof window<`u`&&window.__YURI_ELECTRON__?.macVibrancySupported===!0,[]),ut=typeof window<`u`&&window.__YURI_ELECTRON__?.macVibrancy===!0,[dt,ft]=Q.useState(ut),[pt,mt]=Q.useState(!1),ht=Q.useMemo(()=>E()&&typeof window<`u`&&window.__YURI_PLATFORM__===`darwin`,[]),gt=W(e=>e.dockBadgeEnabled),_t=W(e=>e.setDockBadgeEnabled),[vt,yt]=Q.useState(0),bt=W(e=>e.reportUsage),xt=W(e=>e.setReportUsage),St=Q.useCallback(e=>{xt(e),O({reportUsage:e})},[xt]),Ct=Ke&&(!e||e.includes(`chatRenderMode`));Q.useEffect(()=>{if(!Ct)return;let e=null,t=Date.now(),n=()=>{let r=Date.now();r-t>=420&&(yt(e=>(e+1)%24),t=r),e=requestAnimationFrame(n)};(typeof document>`u`||document.visibilityState===`visible`)&&(e=requestAnimationFrame(n));let r=()=>{document.visibilityState===`visible`&&e===null?e=requestAnimationFrame(n):document.visibilityState!==`visible`&&e!==null&&(cancelAnimationFrame(e),e=null)};return document.addEventListener(`visibilitychange`,r),()=>{document.removeEventListener(`visibilitychange`,r),e!==null&&cancelAnimationFrame(e)}},[Ct]);let wt=Q.useCallback(e=>{M(e),O({expandedEditorToolbar:e})},[M]),Tt=Q.useCallback(e=>{A(e),O({collapsibleUserMessages:e})},[A]),Et=Q.useCallback(e=>{Fe(e),O({showSplitAssistantMessageActions:e})},[Fe]),Dt=Q.useCallback(e=>{Le(e),O({showAssistantTps:e})},[Le]),Ot=Q.useCallback(e=>{De(e),O({inputSpellcheckEnabled:e})},[De]),kt=Q.useCallback(e=>{L(e),O({chatRenderMode:e})},[L]),At=Q.useCallback(e=>{We(e),O({messageStreamTransport:e})},[We]),jt=Q.useCallback(e=>{ke(e),O({showSubagentTaskDetails:e})},[ke]),Mt=Q.useCallback(e=>{je(e),O({timeFormatPreference:e})},[je]),Nt=Q.useCallback(e=>{Ne(e),O({weekStartPreference:e})},[Ne]),Pt=Q.useMemo(()=>Ye.filter(e=>e.metadata.variant===`light`).sort((e,t)=>e.metadata.name.localeCompare(t.metadata.name)),[Ye]),Ft=Q.useMemo(()=>Ye.filter(e=>e.metadata.variant===`dark`).sort((e,t)=>e.metadata.name.localeCompare(t.metadata.name)),[Ye]),It=Q.useMemo(()=>Pt.find(e=>e.metadata.id===Qe)??Pt[0],[Pt,Qe]),Lt=Q.useMemo(()=>Ft.find(e=>e.metadata.id===$e)??Ft[0],[Ft,$e]),Rt=Q.useCallback((e,t)=>{let n=t===`dark`?` Dark`:` Light`;return e.endsWith(n)?e.slice(0,-n.length):e},[]),J=t=>t===`splitAssistantMessageActions`?!1:!e||e.includes(t),zt=async()=>{if(!ot){st(!0);try{await lt(),at(!1),q.success(o(`settings.yuri.visual.transcriptCache.toast.cleared`))}catch{q.error(o(`settings.yuri.visual.transcriptCache.toast.failed`))}finally{st(!1)}}},Bt=N(),Vt=Vr()&&J(`iosNativeUi`),Ht=J(`theme`)&&!Bt,Ut=J(`theme`)||J(`timeFormat`)||J(`weekStart`),Wt=Bt?Ut||J(`sidebarBrand`):J(`theme`)||J(`sidebarBrand`)||J(`pwaInstallName`)||J(`pwaOrientation`)||J(`mobileKeyboardMode`)||J(`timeFormat`)||J(`weekStart`)||Vt,Gt=J(`fontSize`)||J(`codeFontSize`)||J(`terminalFontSize`)||J(`editorFontSize`)||J(`spacing`)||J(`inputBarOffset`),Kt=J(`terminalQuickKeys`)&&!l||J(`fileEditorKeymap`)||J(`expandedEditorToolbar`),qt=J(`questionAutoDelegate`)||J(`chatRenderMode`)||J(`messageTransport`)||J(`collapsibleUserMessages`)||J(`splitAssistantMessageActions`)||J(`showAssistantTps`)||J(`subagentReadOnlyBanner`)||J(`diffLayout`)||J(`reasoning`)||J(`followUpBehavior`)||J(`persistDraft`)||J(`showSubagentTaskDetails`)||!l&&J(`inputSpellcheck`),Jt=J(`pwaInstallName`)&&k()&&u&&!E()&&!Bt,Yt=J(`pwaOrientation`)&&k()&&!E()&&!Bt,Xt=J(`mobileKeyboardMode`)&&k()&&!E()&&!Bt&&Ce(),[Zt,Qt]=Q.useState(``),[$t,en]=Q.useState(`system`),nn=Q.useMemo(()=>{let e=qp.find(e=>e.id===Ae);return s(e?.labelKey??`settings.yuri.visual.option.timeFormat.auto.label`)},[Ae,s]),rn=Q.useMemo(()=>{let e=Jp.find(e=>e.id===Me);return s(e?.labelKey??`settings.yuri.visual.option.weekStart.auto.label`)},[Me,s]),an=Q.useMemo(()=>{let e=Vp.find(e=>e.id===$t);return e?s(e.labelKey):void 0},[$t,s]),on=Q.useMemo(()=>{let e=Hp.find(e=>e.id===ue);return e?s(e.labelKey):void 0},[ue,s]),sn=Q.useCallback(async e=>{if(typeof window>`u`)return;let t=window,n=e.trim().replace(/\s+/g,` `).slice(0,64);if(await O({pwaAppName:n}),typeof t.__YURI_SET_PWA_INSTALL_NAME__==`function`){let e=t.__YURI_SET_PWA_INSTALL_NAME__(n);Qt(e);return}Qt(n||Bp),t.__YURI_UPDATE_PWA_MANIFEST__?.()},[]),cn=Q.useCallback(async e=>{if(typeof window>`u`)return;let t=window,n=Wp(e);if(await O({pwaOrientation:n}),typeof t.__YURI_SET_PWA_ORIENTATION__==`function`){let e=t.__YURI_SET_PWA_ORIENTATION__(n);en(e);return}en(n),t.__YURI_UPDATE_PWA_MANIFEST__?.()},[]);return Q.useEffect(()=>{if(typeof window>`u`||!Jt&&!Yt&&!Xt)return;let e=!1;return(async()=>{try{let t=await p(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`},cache:`no-store`});if(!t.ok){e||Qt(Bp);return}let n=await t.json().catch(()=>({})),r=(typeof n?.pwaAppName==`string`?n.pwaAppName:``).trim().replace(/\s+/g,` `).slice(0,64),i=Wp(n?.pwaOrientation),a=Se(n?.mobileKeyboardMode);e||(Jt&&Qt(r||Bp),Yt&&en(i),Xt&&de(a))}catch{e||(Jt&&Qt(Bp),Yt&&en(`system`),Xt&&de(`native`))}})(),()=>{e=!0}},[de,Xt,Jt,Yt]),(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[Wt&&(0,$.jsxs)($.Fragment,{children:[Ht&&(0,$.jsxs)(Fp,{isMobile:l,label:(0,$.jsxs)(`div`,{className:`flex w-full min-w-0 items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{children:o(`settings.yuri.visual.section.colorMode`)}),(0,$.jsxs)(`div`,{className:`inline-flex shrink-0 items-center gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,"data-settings-item":`appearance.reload-themes`,disabled:Xe||nt,onClick:()=>{let e=Date.now();rt(!0),Ze().finally(()=>{let t=Date.now()-e;if(t<500){window.setTimeout(()=>{rt(!1)},500-t);return}rt(!1)})},className:`inline-flex items-center typography-micro font-normal text-muted-foreground underline decoration-[1px] underline-offset-2 hover:text-foreground disabled:cursor-not-allowed disabled:text-muted-foreground/60`,children:o(nt?`settings.yuri.visual.actions.reloadingThemes`:`settings.yuri.visual.actions.reloadThemes`)}),(0,$.jsxs)(kn,{children:[(0,$.jsx)(Dn,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`flex items-center justify-center rounded-md p-0.5 text-muted-foreground/70 hover:text-foreground`,"aria-label":o(`settings.yuri.visual.field.themeImportInfoAria`),children:(0,$.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5`})})}),(0,$.jsx)(On,{sideOffset:8,children:o(`settings.yuri.visual.field.themeImportInfoTooltip`)})]})]})]}),children:[(0,$.jsx)(Ip,{isMobile:l,itemId:`appearance.color-mode`,label:o(`settings.yuri.visual.field.themeMode`),children:(0,$.jsx)(`div`,{className:`flex flex-nowrap items-center justify-end gap-1`,role:`group`,"aria-label":o(`settings.yuri.visual.field.themeMode`),children:Rp.map(e=>(0,$.jsx)(K,{variant:`chip`,size:`xs`,"aria-pressed":qe===e.value,className:`yuri-mobile-settings-chip shrink-0 !font-normal`,onClick:()=>Je(e.value),children:s(e.labelKey)},e.value))})}),(0,$.jsx)(Ip,{isMobile:l,itemId:`appearance.light-theme`,label:o(`settings.yuri.visual.field.lightTheme`),children:(0,$.jsxs)(Cn,{value:It?.metadata.id??``,onValueChange:et,children:[(0,$.jsx)(bn,{"aria-label":o(`settings.yuri.visual.field.selectLightThemeAria`),className:`w-fit`,children:(0,$.jsx)(Tn,{placeholder:o(`settings.yuri.visual.field.selectThemePlaceholder`),children:It?Rt(It.metadata.name,`light`):void 0})}),(0,$.jsx)(xn,{children:Pt.map(e=>(0,$.jsx)(vn,{value:e.metadata.id,children:Rt(e.metadata.name,`light`)},e.metadata.id))})]})}),(0,$.jsx)(Ip,{isMobile:l,itemId:`appearance.dark-theme`,label:o(`settings.yuri.visual.field.darkTheme`),children:(0,$.jsxs)(Cn,{value:Lt?.metadata.id??``,onValueChange:tt,children:[(0,$.jsx)(bn,{"aria-label":o(`settings.yuri.visual.field.selectDarkThemeAria`),className:`w-fit`,children:(0,$.jsx)(Tn,{placeholder:o(`settings.yuri.visual.field.selectThemePlaceholder`),children:Lt?Rt(Lt.metadata.name,`dark`):void 0})}),(0,$.jsx)(xn,{children:Ft.map(e=>(0,$.jsx)(vn,{value:e.metadata.id,children:Rt(e.metadata.name,`dark`)},e.metadata.id))})]})}),ct&&(0,$.jsxs)(`div`,{"data-settings-item":`appearance.window-transparency`,className:`yuri-settings-group-row flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`group flex cursor-pointer items-start gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":dt,onClick:()=>{pt||ft(!dt)},onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),pt||ft(!dt))},children:[(0,$.jsx)(gn,{checked:dt,onChange:ft,disabled:pt,ariaLabel:o(`settings.yuri.visual.field.macVibrancy`)}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.yuri.visual.field.macVibrancy`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:o(`settings.yuri.visual.field.macVibrancyHint`)})]})]}),dt!==ut&&(0,$.jsx)(`div`,{className:`pl-6`,children:(0,$.jsx)(K,{variant:`outline`,size:`sm`,disabled:pt,onClick:()=>{mt(!0),w(`desktop_set_vibrancy`,{enabled:dt})},children:o(pt?`settings.yuri.visual.actions.restarting`:`settings.yuri.visual.actions.saveAndRestart`)})})]}),ht&&(0,$.jsx)(`div`,{"data-settings-item":`appearance.dock-badge`,className:`yuri-settings-group-row flex flex-col gap-1.5`,children:(0,$.jsxs)(`div`,{className:`group flex cursor-pointer items-start gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":gt,onClick:()=>_t(!gt),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),_t(!gt))},children:[(0,$.jsx)(gn,{checked:gt,onChange:_t,ariaLabel:o(`settings.yuri.visual.field.dockBadge`)}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.yuri.visual.field.dockBadge`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:o(`settings.yuri.visual.field.dockBadgeHint`)})]})]})})]}),Vt&&(0,$.jsx)(Fp,{isMobile:l,children:(0,$.jsx)($r,{itemId:`appearance.ios-native-ui`,checked:P,onChange:F,label:o(`settings.yuri.visual.field.iosNativeUi`),description:o(`settings.yuri.visual.field.iosNativeUiHint`),ariaLabel:o(`settings.yuri.visual.field.iosNativeUi`)})}),Ut&&(0,$.jsxs)(Fp,{isMobile:l,label:o(`settings.yuri.visual.section.localization`),children:[(0,$.jsx)(Ip,{isMobile:l,itemId:`appearance.language`,label:o(`settings.appearance.language.label`),description:o(`settings.appearance.language.description`),children:(0,$.jsxs)(Cn,{value:n,onValueChange:e=>i(e),children:[(0,$.jsx)(bn,{"aria-label":o(`settings.appearance.language.select`),className:`w-fit`,children:(0,$.jsx)(Tn,{children:a(n)})}),(0,$.jsx)(xn,{children:r.map(e=>(0,$.jsx)(vn,{value:e,children:a(e)},e))})]})}),(J(`timeFormat`)||J(`weekStart`))&&(0,$.jsxs)($.Fragment,{children:[J(`timeFormat`)&&(0,$.jsx)(Ip,{isMobile:l,itemId:`appearance.time-format`,label:o(`settings.yuri.visual.field.timeFormat`),children:(0,$.jsxs)(Cn,{value:Ae,onValueChange:e=>Mt(e),children:[(0,$.jsx)(bn,{"aria-label":o(`settings.yuri.visual.field.selectTimeFormatAria`),className:`w-fit`,children:(0,$.jsx)(Tn,{children:nn})}),(0,$.jsx)(xn,{children:qp.map(e=>(0,$.jsx)(vn,{value:e.id,children:s(e.labelKey)},e.id))})]})}),J(`weekStart`)&&(0,$.jsx)(Ip,{isMobile:l,itemId:`appearance.week-start`,label:o(`settings.yuri.visual.field.weekStartsOn`),children:(0,$.jsxs)(Cn,{value:Me,onValueChange:e=>Nt(e),children:[(0,$.jsx)(bn,{"aria-label":o(`settings.yuri.visual.field.selectWeekStartAria`),className:`w-fit`,children:(0,$.jsx)(Tn,{children:rn})}),(0,$.jsx)(xn,{children:Jp.map(e=>(0,$.jsx)(vn,{value:e.id,children:s(e.labelKey)},e.id))})]})})]})]}),J(`sidebarBrand`)&&(0,$.jsx)(Pp,{isMobile:l,itemId:`appearance.sidebar-brand`,label:o(`settings.yuri.visual.field.sidebarBrand`),description:o(`settings.yuri.visual.field.sidebarBrandHint`),descriptionPlacement:`outside`,children:(0,$.jsx)(En,{value:Re,onChange:e=>ze(e.target.value),maxLength:64,"aria-label":o(`settings.yuri.visual.field.sidebarBrandAria`)})}),(Jt||Yt||Xt)&&(0,$.jsxs)($.Fragment,{children:[Jt&&(0,$.jsxs)(Pp,{isMobile:l,itemId:`appearance.pwa-install-name`,label:o(`settings.yuri.visual.field.installAppName`),description:o(`settings.yuri.visual.field.installAppNameHint`),children:[(0,$.jsx)(En,{value:Zt,onChange:e=>{Qt(e.target.value)},onBlur:()=>{sn(Zt)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),sn(Zt))},maxLength:64,"aria-label":o(`settings.yuri.visual.field.pwaInstallAppNameAria`)}),(0,$.jsx)(K,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>{Qt(Bp),sn(``)},className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.yuri.visual.actions.resetInstallAppNameAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(Y,{name:`restart`,className:`h-3.5 w-3.5`})})]}),Yt&&(0,$.jsxs)(Pp,{isMobile:l,itemId:`appearance.pwa-orientation`,label:o(`settings.yuri.visual.field.installOrientation`),description:o(`settings.yuri.visual.field.installOrientationHint`),descriptionPlacement:`outside`,children:[(0,$.jsxs)(Cn,{value:$t,onValueChange:e=>{let t=Wp(e);en(t),cn(t)},children:[(0,$.jsx)(bn,{"aria-label":o(`settings.yuri.visual.field.pwaInstallOrientationAria`),className:`w-full`,children:(0,$.jsx)(Tn,{placeholder:o(`settings.yuri.visual.field.selectOrientationPlaceholder`),children:an})}),(0,$.jsx)(xn,{children:Vp.map(e=>(0,$.jsx)(vn,{value:e.id,children:s(e.labelKey)},e.id))})]}),(0,$.jsx)(K,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>{en(`system`),cn(`system`)},disabled:$t===`system`,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.yuri.visual.actions.resetInstallOrientationAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(Y,{name:`restart`,className:`h-3.5 w-3.5`})})]}),Xt&&(0,$.jsxs)(Pp,{isMobile:l,itemId:`appearance.mobile-keyboard-mode`,label:o(`settings.yuri.visual.field.mobileKeyboardMode`),description:o(`settings.yuri.visual.field.mobileKeyboardModeHint`),descriptionPlacement:`outside`,children:[(0,$.jsxs)(Cn,{value:ue,onValueChange:e=>{let t=Se(e);de(t),O({mobileKeyboardMode:t})},children:[(0,$.jsx)(bn,{"aria-label":o(`settings.yuri.visual.field.mobileKeyboardModeAria`),className:`w-full`,children:(0,$.jsx)(Tn,{placeholder:o(`settings.yuri.visual.field.selectMobileKeyboardModePlaceholder`),children:on})}),(0,$.jsx)(xn,{children:Hp.map(e=>(0,$.jsx)(vn,{value:e.id,children:s(e.labelKey)},e.id))})]}),(0,$.jsx)(K,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>{de(`native`),O({mobileKeyboardMode:`native`})},disabled:ue===`native`,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.yuri.visual.actions.resetMobileKeyboardModeAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(Y,{name:`restart`,className:`h-3.5 w-3.5`})})]})]})]}),Gt&&(0,$.jsx)($.Fragment,{children:(0,$.jsx)(Fp,{isMobile:l,label:o(`settings.yuri.visual.section.spacingAndLayout`),children:(0,$.jsxs)($.Fragment,{children:[J(`fontSize`)&&!l&&(0,$.jsxs)(Ip,{isMobile:l,label:o(`settings.yuri.visual.field.interfaceFont`),children:[(0,$.jsxs)(Cn,{value:U,onValueChange:e=>re(e),children:[(0,$.jsx)(bn,{"aria-label":o(`settings.yuri.visual.field.selectInterfaceFontAria`),className:`w-[13rem]`,children:(0,$.jsx)(Tn,{children:xe.find(e=>e.id===U)?.label})}),(0,$.jsx)(xn,{children:xe.map(e=>(0,$.jsx)(vn,{value:e.id,children:(0,$.jsx)(`span`,{style:{fontFamily:e.stack},children:e.label})},e.id))})]}),(0,$.jsx)(K,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>re(`system`),disabled:U===`system`,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.yuri.visual.actions.resetInterfaceFontAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(Y,{name:`restart`,className:`h-3.5 w-3.5`})})]}),J(`terminalFontSize`)&&(0,$.jsxs)(Ip,{isMobile:l,itemId:`appearance.code-font`,label:o(`settings.yuri.visual.field.codeFont`),children:[(0,$.jsxs)(Cn,{value:ie,onValueChange:e=>ae(e),children:[(0,$.jsx)(bn,{"aria-label":o(`settings.yuri.visual.field.selectCodeFontAria`),className:`w-full max-w-[13rem]`,children:(0,$.jsx)(Tn,{children:we.find(e=>e.id===ie)?.label})}),(0,$.jsx)(xn,{children:we.map(e=>(0,$.jsx)(vn,{value:e.id,children:(0,$.jsx)(`span`,{style:{fontFamily:e.stack},children:e.label})},e.id))})]}),(0,$.jsx)(K,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>ae(`system-mono`),disabled:ie===`system-mono`,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.yuri.visual.actions.resetCodeFontAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(Y,{name:`restart`,className:`h-3.5 w-3.5`})})]}),J(`fontSize`)&&(0,$.jsxs)(Ip,{isMobile:l,itemId:`appearance.interface-font-size`,label:o(`settings.yuri.visual.field.interfaceFontSize`),children:[(0,$.jsx)(yi,{value:R,onValueChange:z,min:50,max:200,step:5,"aria-label":o(`settings.yuri.visual.field.fontSizePercentageAria`),className:`w-16`}),(0,$.jsx)(K,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>z(100),disabled:R===100,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.yuri.visual.actions.resetFontSizeAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(Y,{name:`restart`,className:`h-3.5 w-3.5`})})]}),J(`codeFontSize`)&&(0,$.jsxs)(Ip,{isMobile:l,itemId:`appearance.code-font-size`,label:o(`settings.yuri.visual.field.codeFontSize`),children:[(0,$.jsx)(yi,{value:B,onValueChange:V,min:50,max:200,step:5,"aria-label":o(`settings.yuri.visual.field.codeFontSizePercentageAria`),className:`w-16`}),(0,$.jsx)(K,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>V(100),disabled:B===100,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.yuri.visual.actions.resetCodeFontSizeAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(Y,{name:`restart`,className:`h-3.5 w-3.5`})})]}),J(`terminalFontSize`)&&(0,$.jsxs)(Ip,{isMobile:l,itemId:`appearance.terminal-font-size`,label:o(`settings.yuri.visual.field.terminalFontSize`),children:[(0,$.jsx)(yi,{value:ee,onValueChange:H,min:9,max:52,step:1,className:`w-16`}),(0,$.jsx)(K,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>H(13),disabled:ee===13,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.yuri.visual.actions.resetTerminalFontSizeAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(Y,{name:`restart`,className:`h-3.5 w-3.5`})})]}),J(`editorFontSize`)&&(0,$.jsxs)(Ip,{isMobile:l,itemId:`appearance.editor-font-size`,label:o(`settings.yuri.visual.field.editorFontSize`),children:[(0,$.jsx)(yi,{value:te,onValueChange:ne,min:9,max:32,step:1,className:`w-16`}),(0,$.jsx)(K,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>ne(13),disabled:te===13,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.yuri.visual.actions.resetEditorFontSizeAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(Y,{name:`restart`,className:`h-3.5 w-3.5`})})]}),J(`spacing`)&&(0,$.jsxs)(Ip,{isMobile:l,itemId:`appearance.spacing-density`,label:o(`settings.yuri.visual.field.spacingDensity`),children:[(0,$.jsx)(yi,{value:oe,onValueChange:se,min:50,max:200,step:5,className:`w-16`}),(0,$.jsx)(K,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>se(100),disabled:oe===100,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.yuri.visual.actions.resetSpacingAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(Y,{name:`restart`,className:`h-3.5 w-3.5`})})]}),J(`inputBarOffset`)&&(0,$.jsxs)(Ip,{isMobile:l,itemId:`appearance.input-bar-offset`,label:(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:o(`settings.yuri.visual.field.inputBarOffset`)}),(0,$.jsxs)(kn,{children:[(0,$.jsx)(Dn,{asChild:!0,children:(0,$.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(On,{sideOffset:8,className:`max-w-xs`,children:o(`settings.yuri.visual.field.inputBarOffsetTooltip`)})]})]}),children:[(0,$.jsx)(yi,{value:ce,onValueChange:le,min:0,max:100,step:5,className:`w-16`}),(0,$.jsx)(K,{size:`sm`,type:`button`,variant:`ghost`,onClick:()=>le(0),disabled:ce===0,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":o(`settings.yuri.visual.actions.resetInputBarOffsetAria`),title:o(`settings.common.actions.reset`),children:(0,$.jsx)(Y,{name:`restart`,className:`h-3.5 w-3.5`})})]})]})})}),Kt&&(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(Fp,{isMobile:l,label:o(`settings.yuri.visual.section.navigation`),children:[J(`fileEditorKeymap`)&&(0,$.jsx)(Ip,{isMobile:l,itemId:`appearance.file-editor-keymap`,label:o(`settings.yuri.visual.field.fileEditorKeymap`),children:(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":o(`settings.yuri.visual.field.fileEditorKeymap`),className:`flex flex-wrap items-center justify-end gap-x-3 gap-y-1`,children:[`default`,`vim`].map(e=>{let t=ge===e,n=o(`settings.yuri.visual.option.fileEditorKeymap.${e}`);return(0,$.jsxs)(`button`,{type:`button`,className:`flex cursor-pointer items-center gap-2 py-0.5 text-left`,role:`radio`,"aria-checked":t,onClick:()=>_e(e),children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:G(`relative flex h-[14px] w-[14px] min-h-[14px] min-w-[14px] shrink-0 self-center items-center justify-center rounded-full transition-[background-color,box-shadow] duration-200 ease-out`,t?`bg-[color-mix(in_srgb,var(--primary-base)_80%,transparent)] shadow-none`:`bg-[var(--surface-muted)] shadow-[inset_0_0_0_1px_var(--interactive-border)]`),children:(0,$.jsx)(`span`,{className:G(`block h-[5px] w-[5px] rounded-full bg-white`,!t&&`opacity-0`)})}),(0,$.jsx)(`span`,{className:G(`typography-ui-label font-normal`,t?`text-foreground`:`text-foreground/50`),children:n})]},e)})})}),J(`expandedEditorToolbar`)&&(0,$.jsx)(Ip,{isMobile:l,itemId:`appearance.expanded-editor-toolbar`,label:o(`settings.yuri.visual.field.expandedEditorToolbar`),children:(0,$.jsx)(gn,{checked:j,onChange:wt,ariaLabel:o(`settings.yuri.visual.field.expandedEditorToolbarAria`)})}),J(`terminalQuickKeys`)&&!l&&!E()&&(0,$.jsx)(Ip,{isMobile:l,itemId:`appearance.terminal-quick-keys`,label:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:o(`settings.yuri.visual.field.terminalQuickKeys`)}),(0,$.jsxs)(kn,{children:[(0,$.jsx)(Dn,{asChild:!0,children:(0,$.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(On,{sideOffset:8,className:`max-w-xs`,children:o(`settings.yuri.visual.field.terminalQuickKeysTooltip`)})]})]}),children:(0,$.jsx)(gn,{checked:me,onChange:he,ariaLabel:o(`settings.yuri.visual.field.terminalQuickKeysAria`)})})]})}),qt&&(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[(J(`chatRenderMode`)||J(`messageTransport`)||J(`diffLayout`)&&!Bt)&&(0,$.jsxs)(`div`,{className:`grid w-full grid-cols-1 gap-y-[var(--yuri-settings-section-stack-gap)]`,children:[J(`chatRenderMode`)&&(0,$.jsx)(Fp,{isMobile:l,label:o(`settings.yuri.visual.section.chatRenderMode`),className:`w-full`,cardClassName:`!border-0 !bg-transparent !rounded-none overflow-visible`,children:(0,$.jsx)(`div`,{"data-settings-item":`chat.render-mode`,className:`min-w-0 w-full`,children:(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":o(`settings.yuri.visual.section.chatRenderModeAria`),className:`grid w-full grid-cols-1 gap-3 sm:grid-cols-2`,children:Gp.map(e=>{let t=I===e.id,n=vt%12;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>kt(e.id),"aria-pressed":t,className:G(`flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors`,t?`border-primary bg-primary/5`:`border-border hover:border-border/80 hover:bg-muted/50`),children:[(0,$.jsx)(`span`,{className:G(`typography-ui-label`,t?`text-foreground`:`text-muted-foreground`),children:s(e.labelKey)}),(0,$.jsx)(`div`,{className:`mt-2 w-full rounded-md border border-border/60 bg-muted/30 p-2`,children:e.id===`live`?(0,$.jsx)(`div`,{className:`space-y-1.5`,children:[0,1,2].map(e=>{let t=e*3+1,r=n-t+1,i=r<=0?0:r===1?42:r===2?68:92;return(0,$.jsxs)(`div`,{className:G(`flex items-center gap-1.5 transition-all duration-300 motion-reduce:transition-none`,i>0?`translate-y-0 opacity-100`:`translate-y-1 opacity-0`),children:[(0,$.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full bg-muted-foreground/55`}),(0,$.jsx)(`span`,{className:`h-1.5 rounded bg-muted-foreground/30 transition-all duration-300 motion-reduce:transition-none`,style:{width:`${i}%`}})]},e)})}):(0,$.jsx)(`div`,{className:`space-y-1.5`,children:[0,1,2].map(e=>{let t=n>=(e+1)*3;return(0,$.jsxs)(`div`,{className:G(`flex items-center gap-1.5 transition-all duration-300 motion-reduce:transition-none`,t?`translate-y-0 opacity-100`:`translate-y-1 opacity-0`),children:[(0,$.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full bg-muted-foreground/55`}),(0,$.jsx)(`span`,{className:`h-1.5 rounded bg-muted-foreground/30`,style:{width:`92%`}})]},e)})})})]},e.id)})})})}),J(`messageTransport`)&&(0,$.jsx)(Fp,{isMobile:l,label:o(`settings.yuri.visual.section.messageStreamTransport`),className:`w-full`,children:(0,$.jsxs)(`div`,{"data-settings-item":`chat.message-transport`,className:`yuri-settings-group-row flex flex-col gap-2`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-1`,children:Kp.map(e=>(0,$.jsx)(K,{variant:`chip`,size:`xs`,"aria-pressed":Ge===e.id,className:`!font-normal`,onClick:()=>At(e.id),children:s(e.labelKey)},e.id))}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:(()=>{let e=Kp.find(e=>e.id===Ge);return e?.descriptionKey?s(e.descriptionKey):``})()})]})}),J(`diffLayout`)&&!Bt&&(0,$.jsx)(Fp,{isMobile:l,label:o(`settings.yuri.visual.section.diffLayout`),className:`w-full`,children:(0,$.jsx)(`div`,{"data-settings-item":`chat.diff-layout`,role:`radiogroup`,"aria-label":o(`settings.yuri.visual.section.diffLayoutAria`),children:zp.map(e=>{let t=fe===e.id;return(0,$.jsx)(Lp,{selected:t,onSelect:()=>pe(e.id),label:s(e.labelKey),ariaLabel:o(`settings.yuri.visual.field.diffLayoutAria`,{option:s(e.labelKey)})},e.id)})})})]}),J(`sessionGoal`)&&!Bt&&(0,$.jsxs)(Fp,{isMobile:l,label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:o(`settings.yuri.visual.goal.sectionTitle`)}),(0,$.jsxs)(kn,{children:[(0,$.jsx)(Dn,{asChild:!0,children:(0,$.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 cursor-help text-muted-foreground/60`})}),(0,$.jsx)(On,{sideOffset:8,className:`max-w-sm`,children:o(`settings.yuri.visual.goal.description`)})]})]}),children:[(0,$.jsx)(Ip,{isMobile:l,itemId:`chat.session-goal`,label:o(`settings.yuri.visual.field.sessionGoal`),children:(0,$.jsx)(gn,{checked:h,onChange:g,ariaLabel:o(`settings.yuri.visual.field.sessionGoalAria`)})}),(0,$.jsxs)(Ip,{isMobile:l,itemId:`chat.session-goal-budget`,label:o(`settings.yuri.visual.goal.budgetLabel`),children:[(0,$.jsx)(gn,{checked:_,onChange:v,disabled:!h,ariaLabel:o(`settings.yuri.visual.goal.budgetAria`)}),h&&_?(0,$.jsx)(yi,{value:y,onValueChange:e=>{typeof e==`number`&&Number.isFinite(e)&&e>0&&x(Math.floor(e))},min:1e3,max:1e8,step:5e4}):null]})]}),(J(`sessionAssist`)||J(`collapsibleUserMessages`)||J(`splitAssistantMessageActions`)||J(`showAssistantTps`)||J(`subagentReadOnlyBanner`)||J(`persistDraft`)||J(`showSubagentTaskDetails`)||!l&&J(`inputSpellcheck`)||J(`reasoning`))&&(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[(J(`sessionAssist`)||J(`questionAutoDelegate`)||J(`subagentReadOnlyBanner`))&&(0,$.jsxs)(Fp,{isMobile:l,label:(0,$.jsx)(`span`,{"data-settings-item":`chat.session-assistance`,children:o(`settings.yuri.visual.section.sessionAssistance`)}),children:[J(`sessionAssist`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.session-title-refresh`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":f,onClick:()=>m(!f),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),m(!f))},children:[(0,$.jsx)(gn,{checked:f,onChange:m,ariaLabel:o(`settings.yuri.visual.field.sessionTitleRefreshAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.yuri.visual.field.sessionTitleRefresh`)})]}),J(`subagentReadOnlyBanner`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.subagent-read-only-banner`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":Be,onClick:()=>Ve(!Be),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),Ve(!Be))},children:[(0,$.jsx)(gn,{checked:Be,onChange:Ve,ariaLabel:o(`settings.yuri.visual.field.allowPromptingSubagentSessionsAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.yuri.visual.field.allowPromptingSubagentSessions`)})]}),J(`questionAutoDelegate`)&&(0,$.jsx)(`div`,{"data-settings-item":`chat.question-auto-delegate`,className:`yuri-settings-group-row`,children:(0,$.jsx)(Np,{})})]}),(J(`collapsibleUserMessages`)||J(`splitAssistantMessageActions`)||J(`showAssistantTps`)||J(`reasoning`))&&(0,$.jsxs)(Fp,{isMobile:l,label:(0,$.jsx)(`span`,{"data-settings-item":`chat.message-appearance`,children:o(`settings.yuri.visual.section.messageAppearance`)}),children:[J(`reasoning`)&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{"data-settings-item":`chat.reasoning`,className:`hidden`,"aria-hidden":!0}),(0,$.jsx)($r,{checked:d,onChange:S,label:o(`settings.yuri.visual.field.showReasoningTraces`),description:o(`settings.yuri.visual.field.showReasoningTracesHint`),ariaLabel:o(`settings.yuri.visual.field.showReasoningTracesAria`)}),d&&(0,$.jsxs)(`div`,{className:`yuri-settings-group-row group flex cursor-pointer items-center gap-2`,role:`button`,tabIndex:0,"aria-pressed":C,onClick:()=>T(!C),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),T(!C))},children:[(0,$.jsx)(gn,{checked:C,onChange:T,ariaLabel:o(`settings.yuri.visual.field.collapsibleThinkingBlocksAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.yuri.visual.field.collapsibleThinkingBlocks`)})]})]}),J(`collapsibleUserMessages`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.collapsible-user-messages`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":D,onClick:()=>Tt(!D),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),Tt(!D))},children:[(0,$.jsx)(gn,{checked:D,onChange:Tt,ariaLabel:o(`settings.yuri.visual.field.collapsibleUserMessagesAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.yuri.visual.field.collapsibleUserMessages`)})]}),J(`splitAssistantMessageActions`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.inline-assistant-actions`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":Pe,onClick:()=>Et(!Pe),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),Et(!Pe))},children:[(0,$.jsx)(gn,{checked:Pe,onChange:Et,ariaLabel:o(`settings.yuri.visual.field.showSplitAssistantMessageActionsAria`)}),(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.yuri.visual.field.showSplitAssistantMessageActions`)}),(0,$.jsxs)(kn,{children:[(0,$.jsx)(Dn,{asChild:!0,children:(0,$.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 cursor-help text-muted-foreground/60`})}),(0,$.jsx)(On,{sideOffset:8,className:`max-w-xs`,children:o(`settings.yuri.visual.field.showSplitAssistantMessageActionsTooltip`)})]})]})]}),J(`showAssistantTps`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.assistant-tps`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":Ie,onClick:()=>Dt(!Ie),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),Dt(!Ie))},children:[(0,$.jsx)(gn,{checked:Ie,onChange:Dt,ariaLabel:o(`settings.yuri.visual.field.showAssistantTpsAria`)}),(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.yuri.visual.field.showAssistantTps`)}),(0,$.jsxs)(kn,{children:[(0,$.jsx)(Dn,{asChild:!0,children:(0,$.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 cursor-help text-muted-foreground/60`})}),(0,$.jsx)(On,{sideOffset:8,className:`max-w-xs`,children:o(`settings.yuri.visual.field.showAssistantTpsTooltip`)})]})]})]})]}),J(`showSubagentTaskDetails`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.subagent-task-details`,className:`group flex cursor-pointer items-start gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":Oe,onClick:()=>jt(!Oe),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),jt(!Oe))},children:[(0,$.jsx)(gn,{checked:Oe,onChange:jt,ariaLabel:o(`settings.yuri.visual.field.showSubagentTaskDetailsAria`),className:`mt-0.5`}),(0,$.jsxs)(`span`,{className:`min-w-0 flex flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.yuri.visual.field.showSubagentTaskDetails`)}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:o(`settings.yuri.visual.field.showSubagentTaskDetailsHint`)})]})]}),J(`showSubagentTaskDetails`)&&(0,$.jsx)(Fp,{isMobile:l,children:(0,$.jsx)($r,{itemId:`chat.subagent-task-details`,checked:Oe,onChange:jt,label:o(`settings.yuri.visual.field.showSubagentTaskDetails`),description:o(`settings.yuri.visual.field.showSubagentTaskDetailsHint`),ariaLabel:o(`settings.yuri.visual.field.showSubagentTaskDetailsAria`)})}),(J(`persistDraft`)||J(`followUpBehavior`)||!l&&J(`inputSpellcheck`))&&(0,$.jsxs)(Fp,{isMobile:l,label:(0,$.jsx)(`span`,{"data-settings-item":`chat.composer`,children:o(`settings.yuri.visual.section.composer`)}),children:[J(`followUpBehavior`)&&(0,$.jsx)(Ip,{isMobile:l,itemId:`chat.follow-up-behavior`,label:o(`settings.yuri.visual.field.followUpBehavior`),description:o(`settings.yuri.visual.field.followUpBehaviorDescription`),children:(0,$.jsxs)(Cn,{value:ve,onValueChange:e=>ye(e===`steer`?`steer`:`queue`),children:[(0,$.jsx)(bn,{"aria-label":o(`settings.yuri.visual.field.followUpBehaviorAria`),className:`w-fit`,children:(0,$.jsx)(Tn,{children:o(`settings.yuri.visual.option.followUpBehavior.${ve}.label`)})}),(0,$.jsx)(xn,{children:Up.map(e=>(0,$.jsx)(vn,{value:e.id,children:s(e.labelKey)},e.id))})]})}),J(`persistDraft`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.persist-drafts`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":be,onClick:()=>Te(!be),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),Te(!be))},children:[(0,$.jsx)(gn,{checked:be,onChange:Te,ariaLabel:o(`settings.yuri.visual.field.persistDraftMessagesAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.yuri.visual.field.persistDraftMessages`)})]}),!l&&J(`inputSpellcheck`)&&(0,$.jsxs)(`div`,{"data-settings-item":`chat.spellcheck`,className:`group flex cursor-pointer items-center gap-2 py-0.5`,role:`button`,tabIndex:0,"aria-pressed":Ee,onClick:()=>Ot(!Ee),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),Ot(!Ee))},children:[(0,$.jsx)(gn,{checked:Ee,onChange:Ot,ariaLabel:o(`settings.yuri.visual.field.enableSpellcheckInTextInputsAria`)}),(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:o(`settings.yuri.visual.field.enableSpellcheckInTextInputs`)})]})]})]})]}),J(`reportUsage`)&&(0,$.jsxs)(Fp,{isMobile:l,label:o(`settings.yuri.visual.section.privacy`),children:[J(`reportUsage`)&&(0,$.jsx)(Ip,{isMobile:l,itemId:`appearance.usage-reports`,label:o(`settings.yuri.visual.field.sendAnonymousUsageReports`),description:o(`settings.yuri.visual.field.sendAnonymousUsageReportsHint`),children:(0,$.jsx)(gn,{checked:bt,onChange:St,ariaLabel:o(`settings.yuri.visual.field.sendAnonymousUsageReportsAria`)})}),J(`reportUsage`)&&(0,$.jsx)(Ip,{isMobile:l,itemId:`appearance.transcript-cache`,label:o(`settings.yuri.visual.transcriptCache.label`),description:o(`settings.yuri.visual.transcriptCache.description`),children:(0,$.jsx)(K,{type:`button`,variant:`destructive`,size:`sm`,disabled:ot,onClick:()=>at(!0),children:o(`settings.yuri.visual.transcriptCache.action`)})})]})]}),(0,$.jsx)(hn,{open:it,onOpenChange:e=>{ot||at(e)},children:(0,$.jsxs)(fn,{className:`max-w-[min(480px,100vw-2rem)]`,children:[(0,$.jsxs)(un,{children:[(0,$.jsx)(pn,{children:o(`settings.yuri.visual.transcriptCache.dialog.title`)}),(0,$.jsx)(mn,{children:o(`settings.yuri.visual.transcriptCache.dialog.description`)})]}),(0,$.jsxs)(dn,{children:[(0,$.jsx)(K,{type:`button`,variant:`ghost`,disabled:ot,onClick:()=>at(!1),children:o(`settings.common.actions.cancel`)}),(0,$.jsx)(K,{type:`button`,variant:`destructive`,disabled:ot,"aria-busy":ot||void 0,onClick:()=>void zt(),children:o(ot?`settings.yuri.visual.transcriptCache.dialog.clearing`:`settings.yuri.visual.transcriptCache.action`)})]})]})})]})},Xp=864e5,Zp=5,Qp=864e5,$p=e=>e.time?.updated??e.time?.created??0,em=({sessions:e,currentSessionId:t,cutoffDays:n,keepRecent:r=Zp,now:i=Date.now()})=>{if(!Array.isArray(e)||n<=0)return[];let a=i-n*Xp,o=[...e].sort((e,t)=>$p(t)-$p(e)),s=new Set(o.slice(0,r).map(e=>e.id));return o.filter(e=>{if(!e?.id||s.has(e.id)||e.id===t||e.share)return!1;let n=$p(e);return n?n<a:!1}).map(e=>e.id)},tm=e=>{let t=typeof e==`object`?e:void 0,n=t?.autoRun!==!1,r=typeof e==`boolean`?e:t?.enabled??!0,i=Pt(e=>e.currentSessionId),a=Pt(e=>e.isLoading),o=vt(e=>e.activeSessions),s=vt(e=>e.hasLoadedFullCatalog),c=W(e=>e.autoDeleteEnabled),l=W(e=>e.autoDeleteAfterDays),u=W(e=>e.sessionRetentionAction),d=W(e=>e.autoDeleteLastRunAt),f=W(e=>e.setAutoDeleteLastRunAt),[p,m]=Q.useState(!1),h=Q.useRef(!1);Q.useEffect(()=>{if(!r||!n||!c||l<=0)return;let e=window.setTimeout(()=>{rn(ge())},8e3);return()=>window.clearTimeout(e)},[l,c,n,r]);let g=Q.useMemo(()=>l<=0?[]:em({sessions:o,currentSessionId:i,cutoffDays:l}),[l,i,o]),_=Q.useCallback(async({force:e=!1}={})=>{if(h.current)return{completedIds:[],failedIds:[],action:u,skippedReason:`running`};if((!c||l<=0)&&!e)return{completedIds:[],failedIds:[],action:u,skippedReason:`disabled`};if(a)return{completedIds:[],failedIds:[],action:u,skippedReason:`loading`};let t=Date.now();if(!e&&d&&t-d<Qp)return{completedIds:[],failedIds:[],action:u,skippedReason:`cooldown`};let{activeSessions:n}=await rn(ge());if(n.length===0)return{completedIds:[],failedIds:[],action:u,skippedReason:`no-candidates`};let r=em({sessions:n,currentSessionId:i,cutoffDays:l,now:t});if(r.length===0)return f(t),{completedIds:[],failedIds:[],action:u,skippedReason:`no-candidates`};h.current=!0,m(!0);try{let e=new Map(n.map(e=>[e.id,e])),t=[],i=[];for(let n of r){let r=e.get(n),a=r?Vt(r):null;if(!a){i.push(n);continue}try{u===`archive`?await _e.updateSession(n,{time:{archived:Date.now()}},a):await _e.deleteSession(n,a),t.push(n)}catch{i.push(n)}}return u===`archive`?vt.getState().archiveSessions(t):vt.getState().removeSessions(t),{completedIds:t,failedIds:i,action:u}}finally{h.current=!1,m(!1),f(Date.now())}},[l,c,d,i,a,u,f]);return Q.useEffect(()=>{r&&n&&(!c||l<=0||a||!s||o.length===0||d&&Date.now()-d<Qp||_())},[l,c,d,n,r,s,o.length,a,_]),{candidates:g,isRunning:p,runCleanup:_,keepRecentCount:Zp,action:u}},nm=1,rm=365,im=30,am=[{value:`archive`,labelKey:`settings.yuri.sessionRetention.action.archive`},{value:`delete`,labelKey:`settings.yuri.sessionRetention.action.delete`}],om=()=>{let e=(0,qi.c)(101),{t}=He(),n=W(sm),r=W(cm),i=W(lm),a=W(um),o=W(dm),s=W(fm),c;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(c={autoRun:!1},e[0]=c):c=e[0];let{candidates:l,isRunning:u,runCleanup:d,action:f}=tm(c),p=l.length,m;e[1]!==d||e[2]!==t?(m=async()=>{let e=await d({force:!0});if(e.completedIds.length===0&&e.failedIds.length===0){q.message(e.action===`archive`?t(`settings.yuri.sessionRetention.toast.noneEligibleArchive`):t(`settings.yuri.sessionRetention.toast.noneEligibleDelete`));return}e.completedIds.length>0&&q.success(e.action===`archive`?t(`settings.yuri.sessionRetention.toast.archivedCount`,{count:e.completedIds.length}):t(`settings.yuri.sessionRetention.toast.deletedCount`,{count:e.completedIds.length})),e.failedIds.length>0&&q.error(e.action===`archive`?t(`settings.yuri.sessionRetention.toast.failedArchiveCount`,{count:e.failedIds.length}):t(`settings.yuri.sessionRetention.toast.failedDeleteCount`,{count:e.failedIds.length}))},e[1]=d,e[2]=t,e[3]=m):m=e[3];let h=m,g;e[4]===t?g=e[5]:(g=t(`settings.yuri.sessionRetention.title`),e[4]=t,e[5]=g);let _;e[6]===g?_=e[7]:(_=(0,$.jsx)(`span`,{children:g}),e[6]=g,e[7]=_);let v;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(Dn,{asChild:!0,children:(0,$.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 cursor-help text-muted-foreground/60`})}),e[8]=v):v=e[8];let y;e[9]===t?y=e[10]:(y=t(`settings.yuri.sessionRetention.tooltip`),e[9]=t,e[10]=y);let b;e[11]===y?b=e[12]:(b=(0,$.jsxs)(kn,{children:[v,(0,$.jsx)(On,{sideOffset:8,className:`max-w-xs`,children:y})]}),e[11]=y,e[12]=b);let x;e[13]!==_||e[14]!==b?(x=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[_,b]}),e[13]=_,e[14]=b,e[15]=x):x=e[15];let S,C;e[16]!==n||e[17]!==a?(S=()=>a(!n),C=e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),a(!n))},e[16]=n,e[17]=a,e[18]=S,e[19]=C):(S=e[18],C=e[19]);let w;e[20]===t?w=e[21]:(w=t(`settings.yuri.sessionRetention.field.enableAutoCleanup`),e[20]=t,e[21]=w);let T;e[22]===w?T=e[23]:(T=(0,$.jsx)(`div`,{className:`yuri-settings-split-row-copy`,children:(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:w})}),e[22]=w,e[23]=T);let E;e[24]===t?E=e[25]:(E=t(`settings.yuri.sessionRetention.field.enableAutoCleanupAria`),e[24]=t,e[25]=E);let D;e[26]!==n||e[27]!==a||e[28]!==E?(D=(0,$.jsx)(`div`,{className:`yuri-settings-split-row-control`,children:(0,$.jsx)(gn,{checked:n,onChange:a,ariaLabel:E})}),e[26]=n,e[27]=a,e[28]=E,e[29]=D):D=e[29];let O;e[30]!==n||e[31]!==T||e[32]!==D||e[33]!==S||e[34]!==C?(O=(0,$.jsxs)(`div`,{"data-settings-item":`sessions.auto-cleanup`,className:`yuri-settings-group-row yuri-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,"aria-pressed":n,onClick:S,onKeyDown:C,children:[T,D]}),e[30]=n,e[31]=T,e[32]=D,e[33]=S,e[34]=C,e[35]=O):O=e[35];let k;e[36]===t?k=e[37]:(k=t(`settings.yuri.sessionRetention.field.retentionPeriod`),e[36]=t,e[37]=k);let A;e[38]===t?A=e[39]:(A=t(`settings.yuri.sessionRetention.field.retentionPeriodAria`),e[38]=t,e[39]=A);let j;e[40]!==r||e[41]!==o||e[42]!==A?(j=(0,$.jsx)(yi,{value:r,onValueChange:o,min:nm,max:rm,step:1,"aria-label":A,className:`w-20 tabular-nums`}),e[40]=r,e[41]=o,e[42]=A,e[43]=j):j=e[43];let M;e[44]===t?M=e[45]:(M=t(`settings.yuri.sessionRetention.field.days`),e[44]=t,e[45]=M);let N;e[46]===M?N=e[47]:(N=(0,$.jsx)(`span`,{className:`typography-ui-label text-muted-foreground`,children:M}),e[46]=M,e[47]=N);let P;e[48]===o?P=e[49]:(P=()=>o(im),e[48]=o,e[49]=P);let F=r===im,I;e[50]===t?I=e[51]:(I=t(`settings.yuri.sessionRetention.actions.resetRetentionAria`),e[50]=t,e[51]=I);let L;e[52]===t?L=e[53]:(L=t(`settings.common.actions.reset`),e[52]=t,e[53]=L);let R;e[54]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(Y,{name:`restart`,className:`h-3.5 w-3.5`}),e[54]=R):R=e[54];let z;e[55]!==P||e[56]!==F||e[57]!==I||e[58]!==L?(z=(0,$.jsx)(K,{size:`sm`,type:`button`,variant:`ghost`,onClick:P,disabled:F,className:`h-7 w-7 px-0 text-muted-foreground hover:text-foreground`,"aria-label":I,title:L,children:R}),e[55]=P,e[56]=F,e[57]=I,e[58]=L,e[59]=z):z=e[59];let B;e[60]!==k||e[61]!==j||e[62]!==N||e[63]!==z?(B=(0,$.jsxs)(Z,{itemId:`sessions.retention-period`,label:k,children:[j,N,z]}),e[60]=k,e[61]=j,e[62]=N,e[63]=z,e[64]=B):B=e[64];let V;e[65]===t?V=e[66]:(V=t(`settings.yuri.sessionRetention.field.whenSessionsExpire`),e[65]=t,e[66]=V);let ee;e[67]!==i||e[68]!==s||e[69]!==t?(ee=am.map(e=>(0,$.jsx)(K,{type:`button`,variant:`chip`,size:`xs`,"aria-pressed":i===e.value,className:`!font-normal`,onClick:()=>s(e.value),children:t(e.labelKey)},e.value)),e[67]=i,e[68]=s,e[69]=t,e[70]=ee):ee=e[70];let H;e[71]===ee?H=e[72]:(H=(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,children:ee}),e[71]=ee,e[72]=H);let te;e[73]!==V||e[74]!==H?(te=(0,$.jsx)(Z,{itemId:`sessions.retention-action`,label:V,children:H}),e[73]=V,e[74]=H,e[75]=te):te=e[75];let ne;e[76]!==O||e[77]!==B||e[78]!==te||e[79]!==x?(ne=(0,$.jsxs)(X,{label:x,children:[O,B,te]}),e[76]=O,e[77]=B,e[78]=te,e[79]=x,e[80]=ne):ne=e[80];let U;e[81]===t?U=e[82]:(U=t(`settings.yuri.sessionRetention.manualCleanup.title`),e[81]=t,e[82]=U);let re;e[83]!==f||e[84]!==p||e[85]!==t?(re=t(f===`archive`?`settings.yuri.sessionRetention.manualCleanup.eligibleArchiveNow`:`settings.yuri.sessionRetention.manualCleanup.eligibleDeleteNow`,{count:p}),e[83]=f,e[84]=p,e[85]=t,e[86]=re):re=e[86];let ie;e[87]!==u||e[88]!==t?(ie=t(u?`settings.yuri.sessionRetention.actions.cleaningUp`:`settings.yuri.sessionRetention.actions.runCleanupNow`),e[87]=u,e[88]=t,e[89]=ie):ie=e[89];let ae;e[90]!==h||e[91]!==u||e[92]!==ie?(ae=(0,$.jsx)(K,{type:`button`,variant:`outline`,size:`xs`,onClick:h,disabled:u,className:`!font-normal`,children:ie}),e[90]=h,e[91]=u,e[92]=ie,e[93]=ae):ae=e[93];let oe;e[94]!==U||e[95]!==re||e[96]!==ae?(oe=(0,$.jsx)(di,{label:U,description:re,descriptionPlacement:`outside`,children:ae}),e[94]=U,e[95]=re,e[96]=ae,e[97]=oe):oe=e[97];let se;return e[98]!==ne||e[99]!==oe?(se=(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[ne,oe]}),e[98]=ne,e[99]=oe,e[100]=se):se=e[100],se};function sm(e){return e.autoDeleteEnabled}function cm(e){return e.autoDeleteAfterDays}function lm(e){return e.sessionRetentionAction}function um(e){return e.setAutoDeleteEnabled}function dm(e){return e.setAutoDeleteAfterDays}function fm(e){return e.setSessionRetentionAction}var pm=(e,t,n)=>!e||!Number.isFinite(e)?t:new Intl.DateTimeFormat(Ge(),{dateStyle:`medium`,timeStyle:`short`,hour12:n===`auto`?void 0:n===`12h`}).format(e),mm=()=>{let{t:e}=He(),t=W(e=>e.timeFormatPreference),[n,r]=Q.useState(!1),[i,a]=Q.useState(!0),[o,s]=Q.useState(!1),[c,l]=Q.useState(null),[u,d]=Q.useState(!1),[f,p]=Q.useState([]),[m,h]=Q.useState(Mn),[g,_]=Q.useState(``),v=Q.useMemo(()=>qn(),[]),y=Q.useCallback(async()=>{a(!0),_(``);try{let e=await Gn();p(e)}catch(t){let n=t instanceof Error?t.message:e(`settings.yuri.passkeys.toast.loadFailed`);_(n)}finally{a(!1)}},[e]);Q.useEffect(()=>{let e=!1;return(async()=>{try{if(!v.supported){e||(r(!1),a(!1));return}e||r(!0)}catch{e||r(!1)}if(!e){let e=await _r();if(h(e),!e.enabled){p([]),a(!1);return}await y()}})(),()=>{e=!0,vr()}},[y,v.supported]);let b=Q.useCallback(async()=>{if(!m.enabled){let t=e(`settings.yuri.passkeys.toast.enableUiPasswordFirst`);_(t),q.message(t);return}if(!n){_(v.reason),q.message(v.reason);return}if(o){vr(),s(!1);return}_(``),s(!0);try{await Rn(),h(await _r()),await y(),q.success(e(`settings.yuri.passkeys.toast.added`))}catch(t){if(Yn(t)){q.message(e(`settings.yuri.passkeys.toast.setupCanceled`));return}let n=t instanceof Error?t.message:e(`settings.yuri.passkeys.toast.addFailed`);_(n),q.error(n)}finally{s(!1)}},[o,y,m.enabled,v.reason,n,e]),x=Q.useCallback(async t=>{l(t),_(``);try{await Wn(t),h(await _r()),await y(),q.success(e(`settings.yuri.passkeys.toast.removed`))}catch(t){let n=t instanceof Error?t.message:e(`settings.yuri.passkeys.toast.removeFailed`);_(n),q.error(n)}finally{l(null)}},[y,e]),S=Q.useCallback(async()=>{d(!0),_(``);try{await Bn(),window.location.reload()}catch(t){let n=t instanceof Error?t.message:e(`settings.yuri.passkeys.toast.clearAuthFailed`);_(n),q.error(n),d(!1)}},[e]);return(0,$.jsxs)(X,{label:e(`settings.yuri.passkeys.title`),children:[(0,$.jsx)(Z,{label:e(`settings.yuri.passkeys.field.currentDevice`),children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[(0,$.jsx)(K,{type:`button`,variant:o?`secondary`:`outline`,size:`xs`,onClick:()=>void b(),disabled:i||u,className:`!font-normal`,children:e(o?`settings.yuri.passkeys.actions.cancelSetup`:`settings.yuri.passkeys.actions.add`)}),(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`xs`,onClick:()=>void S(),disabled:i||o||u,className:`!font-normal text-muted-foreground hover:text-foreground`,children:e(u?`settings.yuri.passkeys.actions.signingOut`:`settings.yuri.passkeys.actions.signOutEverywhere`)})]})}),!m.enabled&&(0,$.jsx)(`p`,{className:`yuri-settings-group-row typography-meta text-muted-foreground`,children:e(`settings.yuri.passkeys.state.uiPasswordRequired`)}),m.enabled&&!n&&(0,$.jsx)(`p`,{className:`yuri-settings-group-row typography-meta text-muted-foreground`,children:v.reason}),i?(0,$.jsx)(`p`,{className:`yuri-settings-group-row typography-meta text-muted-foreground`,children:e(`settings.yuri.passkeys.state.loading`)}):f.length===0?(0,$.jsx)(`p`,{className:`yuri-settings-group-row typography-meta text-muted-foreground`,children:e(`settings.yuri.passkeys.state.noneSaved`)}):(0,$.jsx)($.Fragment,{children:f.map(n=>(0,$.jsx)(Z,{label:n.label,copyClassName:`truncate`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground truncate`,children:n.lastUsedAt?e(`settings.yuri.passkeys.item.lastUsed`,{time:pm(n.lastUsedAt,e(`settings.yuri.passkeys.time.neverUsed`),t)}):e(`settings.yuri.passkeys.item.added`,{time:pm(n.createdAt,e(`settings.yuri.passkeys.time.neverUsed`),t)})}),(0,$.jsx)(K,{type:`button`,variant:`ghost`,size:`xs`,onClick:()=>void x(n.id),disabled:c===n.id,className:`!font-normal text-muted-foreground hover:text-foreground`,children:c===n.id?e(`settings.yuri.passkeys.actions.removing`):e(`settings.common.actions.delete`)})]})},n.id))}),g&&(0,$.jsx)(`div`,{className:`yuri-settings-group-row`,children:(0,$.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:g})})]})},hm=e=>Zt(e)||{providerId:``,modelId:``},gm=()=>{let{t:e}=He(),t=tn(e=>e.setProvider),n=tn(e=>e.setModel),r=tn(e=>e.setAgent),i=tn(e=>e.setCurrentVariant),a=tn(e=>e.setSettingsDefaultModel),o=tn(e=>e.setSettingsDefaultVariant),s=tn(e=>e.setSettingsDefaultAgent),c=W(e=>e.showDeletionDialog),l=W(e=>e.setShowDeletionDialog),u=tn(e=>e.providers),[d,m]=Q.useState(),[h,g]=Q.useState(),[_,v]=Q.useState(),[y,b]=Q.useState(!0),x=Q.useMemo(()=>hm(d),[d]);Q.useEffect(()=>{(async()=>{try{let e=null;if(!e){let t=f()?.settings;if(t)try{let n=(await t.load())?.settings;if(n){let t=n;e={defaultModel:typeof n.defaultModel==`string`?n.defaultModel:void 0,defaultVariant:typeof t.defaultVariant==`string`?t.defaultVariant:void 0,defaultAgent:typeof n.defaultAgent==`string`?n.defaultAgent:void 0}}}catch{}}if(!e){let t=await p(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});t.ok&&(e=await t.json())}if(e){let t=typeof e.defaultModel==`string`&&e.defaultModel.trim().length>0?e.defaultModel.trim():void 0,n=typeof e.defaultVariant==`string`&&e.defaultVariant.trim().length>0?e.defaultVariant.trim():void 0,r=typeof e.defaultAgent==`string`&&e.defaultAgent.trim().length>0?e.defaultAgent.trim():void 0;t!==void 0&&m(t),n!==void 0&&g(n),r!==void 0&&v(r)}}catch(e){console.warn(`Failed to load defaults settings:`,e)}finally{b(!1)}})()},[]);let S=Q.useCallback(async(e,r)=>{let s=e&&r?`${e}/${r}`:void 0;m(s),g(void 0),o(void 0),i(void 0),a(s),e&&r&&u.find(t=>t.id===e)&&(t(e),n(r));try{await O({defaultModel:s??``,defaultVariant:``});let e=await p(`/api/config/settings`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({defaultModel:s})});e.ok||console.warn(`Failed to save default model to server:`,e.status,e.statusText)}catch(e){console.warn(`Failed to save default model:`,e)}},[u,i,n,t,a,o]),C=`__default__`,w=Q.useCallback(t=>t===C?e(`settings.yuri.defaults.option.default`):t.charAt(0).toUpperCase()+t.slice(1),[e]),T=Q.useCallback(async e=>{let t=e===C?void 0:e||void 0;g(t),o(t),i(t);try{await O({defaultVariant:t??``})}catch(e){console.warn(`Failed to save default variant:`,e)}},[i,o]),E=Q.useCallback(async e=>{let t=e||void 0;v(t),s(t),e&&r(e);try{await O({defaultAgent:t??``})}catch(e){console.warn(`Failed to save default agent:`,e)}},[r,s]),D=Q.useMemo(()=>{if(!x.providerId||!x.modelId)return[];let e=u.find(e=>e.id===x.providerId)?.models.find(e=>e.id===x.modelId)?.variants;return e?Object.keys(e):[]},[x.modelId,x.providerId,u]),k=D.length>0;return Q.useEffect(()=>{!k&&h&&(g(void 0),o(void 0),i(void 0),O({defaultVariant:``}).catch(()=>{}))},[h,i,o,k]),y?null:(0,$.jsxs)(X,{label:e(`settings.yuri.defaults.title`),description:(0,$.jsxs)($.Fragment,{children:[e(`settings.yuri.defaults.summaryPrefix`),` `,x.providerId?(0,$.jsxs)(`span`,{className:`text-foreground`,children:[x.providerId,`/`,x.modelId,k?` (${h??e(`settings.yuri.defaults.option.defaultLowercase`)})`:``]}):(0,$.jsx)(`span`,{className:`text-foreground`,children:e(`settings.yuri.defaults.summaryOpenCodeDefault`)}),_&&(0,$.jsxs)($.Fragment,{children:[` / `,(0,$.jsx)(`span`,{className:`text-foreground`,children:_})]})]}),children:[(0,$.jsx)(Z,{itemId:`sessions.default-model`,label:e(`settings.yuri.defaults.field.defaultModel`),children:(0,$.jsx)(Vn,{providerId:x.providerId,modelId:x.modelId,onChange:S,className:`yuri-settings-inline-value`})}),(0,$.jsx)(Z,{itemId:`sessions.default-thinking`,label:e(`settings.yuri.defaults.field.defaultThinking`),children:(0,$.jsxs)(Cn,{value:h??C,onValueChange:T,disabled:!k,children:[(0,$.jsx)(bn,{className:`w-fit min-w-[120px]`,children:(0,$.jsx)(Tn,{placeholder:e(`settings.yuri.defaults.field.thinkingPlaceholder`),children:w(h??C)})}),(0,$.jsxs)(xn,{children:[(0,$.jsx)(vn,{value:C,children:e(`settings.yuri.defaults.option.default`)}),D.map(e=>(0,$.jsx)(vn,{value:e,children:w(e)},e))]})]})}),(0,$.jsx)(Z,{itemId:`sessions.default-agent`,label:e(`settings.yuri.defaults.field.defaultAgent`),children:(0,$.jsx)(Or,{agentName:_||``,onChange:E,className:`yuri-settings-inline-value`})}),(0,$.jsxs)(`div`,{"data-settings-item":`sessions.deletion-dialog`,className:`yuri-settings-group-row yuri-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,"aria-pressed":c,onClick:()=>l(!c),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),l(!c))},children:[(0,$.jsx)(`div`,{className:`yuri-settings-split-row-copy`,children:(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.yuri.defaults.field.showDeletionDialog`)})}),(0,$.jsx)(`div`,{className:`yuri-settings-split-row-control`,children:(0,$.jsx)(gn,{checked:c,onChange:l,ariaLabel:e(`settings.yuri.defaults.field.showDeletionDialogAria`)})})]})]})},_m=`You are generating a Conventional Commits subject line from the diffs of the selected files.`,vm=[`You are a title generator. Output ONLY a thread title.`,`Name the main subject of the work.`,`Keep that subject across follow-ups, polish, commit, push, tidy, and review.`,`Switch only when the user clearly starts a different topic.`,`One line, no explanation.`,`Hard limit: never exceed 6 CJK characters (or 6 words for English). No modifiers. No verbs.`,`Use the language of the user messages.`,`Keep technical terms, numbers, filenames, and HTTP codes exact.`,`Never include tool names, summarizing, or generating.`,`Always output a meaningful title.`].join(`
|
|
26
26
|
`),ym=`summary-custom-model-suggestions`,bm=e=>{let t=e.trim();if(!t)return null;try{let e=new URL(t);return e.protocol!==`https:`&&e.protocol!==`http:`||e.username||e.password?null:e.toString().replace(/\/+$/,``)}catch{return null}},xm=()=>{let{t:e}=He(),{currentTheme:t}=ln(),[n,r]=Q.useState(`provider`),[i,a]=Q.useState(``),[o,s]=Q.useState(``),[c,l]=Q.useState(``),[u,d]=Q.useState(``),[m,h]=Q.useState(``),[g,_]=Q.useState(!1),[v,y]=Q.useState(_m),[b,x]=Q.useState(vm),[S,C]=Q.useState([]),[w,T]=Q.useState(!0),[E,D]=Q.useState(!1),[k,A]=Q.useState(!1),[j,M]=Q.useState(null),N=Q.useMemo(()=>[bi(t,{syntaxColors:!1})],[t]);Q.useEffect(()=>{let e=!0;return(async()=>{try{let t=null,n=f()?.settings;if(n){let e=(await n.load())?.settings;e&&(t=e)}if(!t){let e=await p(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});e.ok&&(t=await e.json())}if(!e||!t)return;t.summaryModelMode&&r(t.summaryModelMode),typeof t.summaryProviderID==`string`&&a(t.summaryProviderID),typeof t.summaryModelID==`string`&&s(t.summaryModelID),typeof t.summaryCustomModelID==`string`&&t.summaryCustomModelID?l(t.summaryCustomModelID):t.summaryModelMode===`custom`&&typeof t.summaryModelID==`string`&&l(t.summaryModelID),typeof t.summaryCustomBaseURL==`string`&&d(t.summaryCustomBaseURL),typeof t.hasSummaryCustomAPIToken==`boolean`&&_(t.hasSummaryCustomAPIToken),y(t.summaryCommitPrompt??_m),x(t.summarySessionTitlePrompt??vm)}catch(e){console.warn(`Failed to load summary settings:`,e)}finally{e&&T(!1)}})(),()=>{e=!1}},[]),Q.useEffect(()=>{if(n!==`custom`){C([]);return}let e=bm(u);if(!e||!m.trim()&&!g){C([]);return}let t=!0,r=window.setTimeout(()=>{(async()=>{try{let n=await(await p(`/api/small-model/custom-models`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({baseURL:e,...m.trim()?{apiToken:m}:{}})})).json().catch(()=>null),r=Array.isArray(n?.models)?n.models.filter(e=>typeof e==`string`&&e.length>0):[];t&&C(r)}catch{t&&C([])}})()},400);return()=>{t=!1,window.clearTimeout(r)}},[g,m,u,n]);let P=()=>bm(u)?!c.trim()||!m.trim()&&!g?`incomplete`:null:u.trim()?`baseURL`:`incomplete`,F=t=>e(t===`token`?`settings.yuri.defaults.summary.testError.token`:t===`model`?`settings.yuri.defaults.summary.testError.model`:t===`baseURL`?`settings.yuri.defaults.summary.testError.baseUrl`:`settings.yuri.defaults.summary.testError.incomplete`),I=ze(async()=>{if(n===`custom`){let e=P();if(e){q.error(F(e));return}}D(!0);try{let e={summaryModelMode:n,summaryCommitPrompt:v,summarySessionTitlePrompt:b};n===`provider`?(e.summaryProviderID=i.trim(),e.summaryModelID=o.trim()):(e.summaryCustomBaseURL=u,e.summaryCustomModelID=c.trim(),m.trim()&&(e.summaryCustomAPIToken=m)),await O(e),m.trim()&&_(!0),h(``)}catch(e){console.warn(`Failed to save summary settings:`,e)}finally{D(!1)}}),L=ze(async()=>{D(!0);try{await O({summaryCustomAPIToken:``}),h(``),_(!1)}catch(e){console.warn(`Failed to clear summary API token:`,e)}finally{D(!1)}}),R=ze(async()=>{if(k)return;M(null);let t=n,r=t===`custom`?P():null;if(r){M(F(r));return}A(!0);try{let n=await p(`/api/small-model/test`,{method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify(t===`provider`?{mode:t,providerID:i,modelID:o}:{baseURL:u,modelID:c,...m.trim()?{apiToken:m}:{}})}),r=await n.json().catch(()=>null);if(n.ok&&r?.ok===!0){q.success(e(`settings.yuri.defaults.summary.testConnectionOk`));return}if(t===`provider`){let t=e(`settings.yuri.defaults.summary.testError.provider`,{code:typeof r?.code==`string`?r.code:`generation_failed`});M(typeof r?.message==`string`&&r.message.trim()?`${t}\n${r.message}`:t);return}let a=r?.code===`token`||r?.code===`model`||r?.code===`baseURL`||r?.code===`incomplete`?r.code:`baseURL`,s=F(a);M(typeof r?.message==`string`&&r.message.trim()?`${s}\n${r.message}`:s)}catch{M(t===`provider`?e(`settings.yuri.defaults.summary.testError.provider`,{code:`network_error`}):F(`baseURL`))}finally{A(!1)}});return w?null:(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[(0,$.jsx)(Xr,{actions:(0,$.jsx)(K,{size:`sm`,onClick:()=>void I(),disabled:E,"aria-busy":E,children:e(E?`settings.common.actions.saving`:`settings.yuri.defaults.summary.save`)}),children:(0,$.jsx)(`h2`,{className:`truncate typography-ui-header font-semibold text-foreground`,children:e(`settings.yuri.defaults.summary.title`)})}),(0,$.jsxs)(X,{description:(0,$.jsxs)(`span`,{className:`flex flex-col gap-2`,children:[(0,$.jsxs)(`span`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{children:e(`settings.yuri.defaults.summary.description`)}),(0,$.jsx)(K,{"data-settings-item":`summary-ai.test-connection`,variant:`outline`,size:`sm`,onClick:()=>void R(),disabled:E||k,children:e(k?`settings.yuri.defaults.summary.testingConnection`:`settings.yuri.defaults.summary.testConnection`)})]}),j?(0,$.jsx)(`span`,{role:`alert`,className:`whitespace-pre-wrap break-words text-[var(--status-error)]`,children:j}):null]}),children:[(0,$.jsx)(Z,{itemId:`summary-ai.configuration`,label:e(`settings.yuri.defaults.summary.modelSourceTitle`),className:`yuri-settings-summary-model-source-row`,controlClassName:`items-start`,children:(0,$.jsxs)(`div`,{role:`radiogroup`,"aria-label":e(`settings.yuri.defaults.summary.modelSourceAria`),className:`flex flex-col gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2 py-0.5`,children:[(0,$.jsx)(mc,{checked:n===`provider`,onChange:()=>r(`provider`),ariaLabel:e(`settings.yuri.defaults.summary.provider`)}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:n===`provider`?`typography-ui-label text-foreground`:`typography-ui-label text-foreground/50`,children:e(`settings.yuri.defaults.summary.provider`)}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:e(`settings.yuri.defaults.summary.providerDescription`)})]})]}),(0,$.jsxs)(`div`,{className:`flex items-start gap-2 py-0.5`,children:[(0,$.jsx)(mc,{checked:n===`custom`,onChange:()=>r(`custom`),ariaLabel:e(`settings.yuri.defaults.summary.custom`)}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:n===`custom`?`typography-ui-label text-foreground`:`typography-ui-label text-foreground/50`,children:e(`settings.yuri.defaults.summary.custom`)}),(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:e(`settings.yuri.defaults.summary.customDescription`)})]})]})]})}),n===`provider`?(0,$.jsx)(Z,{label:e(`settings.yuri.defaults.summary.providerModel`),children:(0,$.jsx)(Vn,{providerId:i,modelId:o,placeholder:e(`settings.yuri.defaults.summary.providerModelDefault`),onChange:(e,t)=>{a(e),s(t)},className:`yuri-settings-inline-value`})}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{label:e(`settings.yuri.defaults.summary.baseUrl`),children:(0,$.jsx)(En,{value:u,onChange:e=>d(e.target.value),placeholder:e(`settings.yuri.defaults.summary.baseUrlPlaceholder`)})}),(0,$.jsx)(Z,{label:e(`settings.yuri.defaults.summary.modelId`),children:(0,$.jsxs)(`div`,{className:`w-full`,children:[(0,$.jsx)(En,{value:c,onChange:e=>l(e.target.value),placeholder:e(`settings.yuri.defaults.summary.modelIdPlaceholder`),list:S.length>0?ym:void 0}),S.length>0?(0,$.jsx)(`datalist`,{id:ym,children:S.map(e=>(0,$.jsx)(`option`,{value:e},e))}):null]})}),(0,$.jsx)(Z,{label:e(`settings.yuri.defaults.summary.apiToken`),children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(En,{type:`password`,value:m,onChange:e=>h(e.target.value),placeholder:e(g?`settings.yuri.defaults.summary.apiTokenStored`:`settings.yuri.defaults.summary.apiTokenPlaceholder`),className:`max-w-xl`}),g?(0,$.jsx)(K,{variant:`outline`,size:`sm`,onClick:()=>void L(),disabled:E,children:e(`settings.yuri.defaults.summary.clearToken`)}):null]})})]})]}),(0,$.jsxs)(X,{label:e(`settings.yuri.defaults.summary.promptTitle`),children:[(0,$.jsx)(Z,{label:e(`settings.yuri.defaults.summary.commitPrompt`),description:e(`settings.yuri.defaults.summary.commitPromptDescription`),className:`yuri-settings-split-row-stacked`,controlClassName:`w-full max-w-none justify-self-stretch`,children:(0,$.jsx)(`div`,{className:`h-64 w-full overflow-hidden bg-background`,children:(0,$.jsx)(Yr,{value:v,onChange:y,extensions:N,className:`h-full`,enableSearch:!0})})}),(0,$.jsx)(Z,{label:e(`settings.yuri.defaults.summary.sessionTitlePrompt`),description:e(`settings.yuri.defaults.summary.sessionTitlePromptDescription`),className:`yuri-settings-split-row-stacked`,controlClassName:`w-full max-w-none justify-self-stretch`,children:(0,$.jsx)(`div`,{className:`h-64 w-full overflow-hidden bg-background`,children:(0,$.jsx)(Yr,{value:b,onChange:x,extensions:N,className:`h-full`,enableSearch:!0})})})]})]})},Sm={completion:{titleKey:`settings.notifications.page.template.defaults.completion.title`,messageKey:`settings.notifications.page.template.defaults.completion.message`},error:{titleKey:`settings.notifications.page.template.defaults.error.title`,messageKey:`settings.notifications.page.template.defaults.error.message`},question:{titleKey:`settings.notifications.page.template.defaults.question.title`,messageKey:`settings.notifications.page.template.defaults.question.message`},subtask:{titleKey:`settings.notifications.page.template.defaults.subtask.title`,messageKey:`settings.notifications.page.template.defaults.subtask.message`}},Cm={completion:`settings.notifications.page.template.event.completion`,subtask:`settings.notifications.page.template.event.subtask`,error:`settings.notifications.page.template.event.error`,question:`settings.notifications.page.template.event.question`},wm=()=>{let{t:e}=He(),t=Q.useMemo(()=>E(),[]),n=Q.useMemo(()=>N(),[]),r=Q.useMemo(()=>typeof window>`u`?!1:window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol===`capacitor:`,[]),i=!t&&!n&&!r,a=W(e=>e.nativeNotificationsEnabled),o=W(e=>e.setNativeNotificationsEnabled),s=W(e=>e.notificationMode),c=W(e=>e.setNotificationMode),l=W(e=>e.notifyOnSubtasks),u=W(e=>e.setNotifyOnSubtasks),d=W(e=>e.notifyOnCompletion),p=W(e=>e.setNotifyOnCompletion),m=W(e=>e.notifyOnError),h=W(e=>e.setNotifyOnError),g=W(e=>e.notifyOnQuestion),_=W(e=>e.setNotifyOnQuestion),v=W(e=>e.notifyOnPermission),y=W(e=>e.setNotifyOnPermission),b=W(e=>e.notifyOnScheduledTasks),x=W(e=>e.setNotifyOnScheduledTasks),S=W(e=>e.notifyOnAssistants),C=W(e=>e.setNotifyOnAssistants),w=W(e=>e.notifyOnGoals),T=W(e=>e.setNotifyOnGoals),D=W(e=>e.notificationTemplates),O=W(e=>e.setNotificationTemplates),[k,A]=Q.useState(`default`),[j,M]=Q.useState(!1),[P,F]=Q.useState(!1),[I,L]=Q.useState(!1);Q.useEffect(()=>{if(!i){M(!1),F(!1);return}typeof Notification<`u`&&A(Notification.permission);let e=typeof window<`u`&&`serviceWorker`in navigator&&`PushManager`in window&&`Notification`in window;M(e),(async()=>{if(!e){F(!1);return}try{let e=await navigator.serviceWorker.getRegistration();if(!e){F(!1);return}let t=await e.pushManager.getSubscription();F(!!t)}catch{F(!1)}})()},[i]);let R=async n=>{if(t){o(n);return}if(!i){o(n);return}if(n&&typeof Notification<`u`&&Notification.permission==="default")try{let t=await Notification.requestPermission();A(t),t===`granted`?o(!0):q.error(e(`settings.notifications.page.toast.permissionDenied.title`),{description:e(`settings.notifications.page.toast.permissionDenied.description`)})}catch(t){console.error(`Failed to request notification permission:`,t),q.error(e(`settings.notifications.page.toast.requestPermissionFailed`))}else o(!!(n&&k===`granted`))},z=t||n||r||i&&typeof Notification<`u`&&Notification.permission===`granted`,B=(e,t,n)=>{O({...D,[e]:{...D[e],[t]:n}})},V=e=>{let t=(e+`=`.repeat((4-e.length%4)%4)).replace(/-/g,`+`).replace(/_/g,`/`),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e+=1)r[e]=n.charCodeAt(e);return r},ee=async(e,t,n)=>{let r=null,i=new Promise((e,i)=>{r=setTimeout(()=>{i(Error(n))},t)});try{return await Promise.race([e,i])}finally{r&&clearTimeout(r)}},H=async e=>{if(e.active)return;let t=e.installing||e.waiting;t&&t.state!==`activated`&&await ee(new Promise(e=>{let n=()=>{t.state===`activated`&&(t.removeEventListener(`statechange`,n),e())};t.addEventListener(`statechange`,n),n()}),15e3,`Service worker activation timed out`)},te=async()=>{if(typeof navigator.serviceWorker.register!=`function`)throw Error(`navigator.serviceWorker.register unavailable`);let e=[{label:`no-options`,opts:null},{label:`scope-root`,opts:{scope:`/`}},{label:`type-classic`,opts:{type:`classic`}},{label:`type-classic-scope`,opts:{type:`classic`,scope:`/`}},{label:`updateViaCache-none`,opts:{type:`classic`,updateViaCache:`none`,scope:`/`}}],t=null;for(let n of e)try{let e=n.opts?navigator.serviceWorker.register(`/sw.js`,n.opts):navigator.serviceWorker.register(`/sw.js`);return await ee(e,1e4,`Service worker registration timed out (${n.label})`)}catch(e){t=e}throw t instanceof Error?t:Error(`Service worker registration failed`)},ne=async()=>{if(!(`serviceWorker`in navigator))throw Error(`Service worker not supported`);let e=await navigator.serviceWorker.getRegistration();if(e)return e;let t=await te();try{await t.update()}catch{}return await H(t),t},U=e=>{let t=e,n=[`type=${typeof e}`,`toString=${String(e)}`,`name=${String(t?.name??``)}`,`message=${String(t?.message??``)}`],r=``;try{r=JSON.stringify(e)}catch{}return{summary:n.filter(Boolean).join(` | `),json:r,stack:typeof t?.stack==`string`?t.stack:``}},re=async()=>{let t=f();if(!t?.notifications){q.error(e(`settings.notifications.page.toast.notificationsApiUnavailable`));return}try{await t.notifications.notifyAgentCompletion({title:e(`settings.notifications.page.testNotification.title`),body:e(`settings.notifications.page.testNotification.body`),tag:`yuri-test`})?q.success(e(`settings.notifications.page.toast.testNotificationSent`)):q.error(e(`settings.notifications.page.toast.testNotificationFailed`))}catch(t){console.error(`Test notification failed:`,t),q.error(e(`settings.notifications.page.toast.testNotificationFailed`))}},ie=async()=>{if(!j){q.error(e(`settings.notifications.page.toast.pushUnsupported`));return}let t=f();if(!t?.push){q.error(e(`settings.notifications.page.toast.pushApiUnavailable`));return}L(!0);try{if(typeof Notification<`u`&&Notification.permission==="default"){let t=await Notification.requestPermission();if(A(t),t!==`granted`){q.error(e(`settings.notifications.page.toast.permissionDenied.title`),{description:e(`settings.notifications.page.toast.permissionDenied.enableInBrowser`)});return}}if(typeof Notification<`u`&&Notification.permission!==`granted`){q.error(e(`settings.notifications.page.toast.permissionDenied.title`),{description:e(`settings.notifications.page.toast.permissionDenied.enableInBrowser`)});return}let n=await t.push.getVapidPublicKey();if(!n?.publicKey){q.error(e(`settings.notifications.page.toast.pushKeyLoadFailed`));return}let r=await ne();await H(r);let i=await r.pushManager.getSubscription();if(!(`pushManager`in r)||!r.pushManager)throw Error(`PushManager unavailable (requires installed PWA + iOS 16.4+)`);let a=(i??await ee(r.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:V(n.publicKey)}),15e3,`Push subscription timed out`)).toJSON(),o=a.keys;if(!a.endpoint||!o?.p256dh||!o.auth)throw Error(`Push subscription missing keys`);if(!(await ee(t.push.subscribe({endpoint:a.endpoint,keys:{p256dh:o.p256dh,auth:o.auth},origin:typeof window<`u`?window.location.origin:void 0,platform:ye()}),15e3,`Push subscribe request timed out`))?.ok){q.error(e(`settings.notifications.page.toast.enableBackgroundFailed`));return}F(!0),q.success(e(`settings.notifications.page.toast.backgroundEnabled`))}catch(t){console.error(`[Push] Enable failed:`,t);let n=U(t);q.error(e(`settings.notifications.page.toast.enableBackgroundFailed`),{description:n.summary})}finally{L(!1)}},ae=async()=>{if(!j){F(!1);return}let t=f();if(!t?.push){q.error(e(`settings.notifications.page.toast.pushApiUnavailable`));return}L(!0);try{let n=await(await ne()).pushManager.getSubscription();if(!n){F(!1);return}let r=n.endpoint;await n.unsubscribe(),await t.push.unsubscribe({endpoint:r}),F(!1),q.success(e(`settings.notifications.page.toast.backgroundDisabled`))}finally{L(!1)}},oe=i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:`block`,children:e(`settings.notifications.page.delivery.browserPermissionHint`)}),k===`denied`?(0,$.jsx)(`span`,{className:`mt-1 block text-[var(--status-error)]`,children:e(`settings.notifications.page.delivery.permissionDenied`)}):null,k===`granted`&&!a?(0,$.jsx)(`span`,{className:`mt-1 block`,children:e(`settings.notifications.page.delivery.permissionGrantedButDisabled`)}):null]}):n?e(`settings.notifications.page.delivery.vscodeHint`):void 0;return(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[(0,$.jsxs)(X,{label:e(`settings.notifications.page.delivery.title`),description:oe,className:`yuri-settings-detail-group`,children:[(0,$.jsx)($r,{itemId:`notifications.delivery`,checked:a&&z,onChange:e=>{R(e)},label:e(`settings.notifications.page.delivery.enableLabel`),ariaLabel:e(`settings.notifications.page.delivery.enableAria`)}),a&&z&&!r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)($r,{checked:s===`always`,onChange:e=>c(e?`always`:`hidden-only`),label:e(`settings.notifications.page.delivery.focusedLabel`),ariaLabel:e(`settings.notifications.page.delivery.focusedAria`)}),(0,$.jsx)(`div`,{className:`yuri-settings-group-row flex items-center`,children:(0,$.jsx)(K,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>void re(),children:e(`settings.notifications.page.delivery.testAction`)})})]}):null]}),a&&z?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(X,{label:e(`settings.notifications.page.events.title`),className:`yuri-settings-detail-group`,children:[(0,$.jsx)($r,{itemId:`notifications.events`,checked:d,onChange:p,label:e(`settings.notifications.page.events.completionLabel`),ariaLabel:e(`settings.notifications.page.events.completionAria`)}),(0,$.jsx)($r,{checked:l,onChange:u,label:e(`settings.notifications.page.events.subtaskLabel`),ariaLabel:e(`settings.notifications.page.events.subtaskAria`)}),(0,$.jsx)($r,{checked:m,onChange:h,label:e(`settings.notifications.page.events.errorLabel`),ariaLabel:e(`settings.notifications.page.events.errorAria`)}),(0,$.jsx)($r,{checked:g,onChange:_,label:e(`settings.notifications.page.events.questionLabel`),ariaLabel:e(`settings.notifications.page.events.questionAria`)}),(0,$.jsx)($r,{checked:v,onChange:y,label:e(`settings.notifications.page.events.permissionLabel`),ariaLabel:e(`settings.notifications.page.events.permissionAria`)}),(0,$.jsx)($r,{checked:b,onChange:x,label:e(`settings.notifications.page.events.scheduledTasksLabel`),ariaLabel:e(`settings.notifications.page.events.scheduledTasksAria`)}),(0,$.jsx)($r,{checked:S,onChange:C,label:e(`settings.notifications.page.events.assistantsLabel`),ariaLabel:e(`settings.notifications.page.events.assistantsAria`)}),(0,$.jsx)($r,{checked:w,onChange:T,label:e(`settings.notifications.page.events.goalsLabel`),ariaLabel:e(`settings.notifications.page.events.goalsAria`)})]}),r?null:(0,$.jsx)(X,{label:e(`settings.notifications.page.template.title`),description:(0,$.jsxs)($.Fragment,{children:[e(`settings.notifications.page.template.variablesLabel`),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{project_name}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{worktree}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{branch}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{session_name}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{agent_name}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{model_name}`}),` `,(0,$.jsx)(`code`,{className:`text-[var(--primary-base)]`,children:`{last_message}`})]}),className:`yuri-settings-detail-group`,children:[`completion`,`subtask`,`error`,`question`].map(t=>(0,$.jsxs)(`div`,{className:`yuri-settings-group-row`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label block font-normal text-foreground`,children:e(Cm[t])}),(0,$.jsxs)(`div`,{className:`mt-2 grid grid-cols-1 gap-2 md:grid-cols-2 md:gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`label`,{className:`typography-micro mb-1 block text-muted-foreground`,children:e(`settings.notifications.page.template.field.title`)}),(0,$.jsx)(En,{value:D[t].title,onChange:e=>B(t,`title`,e.target.value),className:`w-full`,placeholder:e(Sm[t].titleKey)})]}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`label`,{className:`typography-micro mb-1 block text-muted-foreground`,children:e(`settings.notifications.page.template.field.message`)}),(0,$.jsx)(En,{value:D[t].message,onChange:e=>B(t,`message`,e.target.value),className:`w-full`,placeholder:e(Sm[t].messageKey)})]})]})]},t))})]}):null,i?(0,$.jsx)(X,{label:e(`settings.notifications.page.push.title`),className:`yuri-settings-detail-group`,children:(0,$.jsx)($r,{itemId:`notifications.push`,checked:j?P:!1,disabled:!j||I,onChange:e=>{e?ie():ae()},ariaLabel:e(`settings.notifications.page.push.enableAria`),label:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:G(`typography-ui-label`,j?`text-foreground`:`text-muted-foreground`),children:e(`settings.notifications.page.push.enableLabel`)}),I&&(0,$.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full bg-current text-muted-foreground animate-busy-pulse`,"aria-label":e(`settings.notifications.page.push.loadingAria`)})]}),description:e(j?`settings.notifications.page.push.supportedHint`:`settings.notifications.page.push.unsupportedHint`)})}):null]})},Tm=e=>{if(!e)return;e.pause();let{src:t}=e;t.startsWith(`blob:`)&&URL.revokeObjectURL(t),e.removeAttribute(`src`),e.load()};function Em(e){let t=(0,qi.c)(82),{onClose:n}=e,{t:i}=He(),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(!1),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l={onTranscript:o},t[0]=l):l=t[0];let u=Ir(l),d;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(d=Lr(),t[1]=d):d=t[1];let f=d,p=u.status===`recording`,m=u.status===`uploading`,h=u.status===`failed`,g;t[2]!==u||t[3]!==h?(g=()=>{c(!1),o(``),h?u.discardFailedDictation():u.cancelDictation()},t[2]=u,t[3]=h,t[4]=g):g=t[4];let _=ze(g),v;t[5]!==_||t[6]!==n?(v=()=>{_(),n()},t[5]=_,t[6]=n,t[7]=v):v=t[7];let y=ze(v),b,x;t[8]===y?(b=t[9],x=t[10]):(b=()=>r(y),x=[y],t[8]=y,t[9]=b,t[10]=x),(0,Q.useEffect)(b,x);let S;t[11]===_?S=t[12]:(S=()=>{document.visibilityState===`hidden`&&_()},t[11]=_,t[12]=S),Be(`visibilitychange`,S,document);let C=u.partialTranscript||a,w;t[13]!==u.error||t[14]!==s||t[15]!==m||t[16]!==p||t[17]!==i||t[18]!==C?(w=f?s&&!p&&!m&&!u.error&&!C?i(`settings.voice.volcengine.silence`):``:i(`settings.voice.volcengine.recordingUnsupported`),t[13]=u.error,t[14]=s,t[15]=m,t[16]=p,t[17]=i,t[18]=C,t[19]=w):w=t[19];let T=w,E=h?`chat.dictation.retry`:p?`settings.voice.volcengine.finishRecording`:m?`chat.dictation.processing`:`settings.voice.volcengine.startRecording`,D;t[20]!==i||t[21]!==E?(D=i(E),t[20]=i,t[21]=E,t[22]=D):D=t[22];let O=D,k;t[23]!==u||t[24]!==h||t[25]!==m||t[26]!==p?(k=()=>{if(!(m||!f)){if(h){u.retryFailedDictation();return}if(p){c(!0),u.confirmDictation();return}o(``),c(!1),u.startDictation()}},t[23]=u,t[24]=h,t[25]=m,t[26]=p,t[27]=k):k=t[27];let A=ze(k),j;t[28]===y?j=t[29]:(j=e=>{e||y()},t[28]=y,t[29]=j);let M;t[30]===i?M=t[31]:(M=i(`settings.voice.volcengine.asrTest`),t[30]=i,t[31]=M);let N;t[32]===M?N=t[33]:(N=(0,$.jsx)(pn,{className:`typography-ui-label font-medium`,children:M}),t[32]=M,t[33]=N);let P;t[34]===i?P=t[35]:(P=i(`settings.voice.volcengine.testHelp`),t[34]=i,t[35]=P);let F;t[36]===P?F=t[37]:(F=(0,$.jsx)(mn,{className:`sr-only`,children:P}),t[36]=P,t[37]=F);let I;t[38]!==N||t[39]!==F?(I=(0,$.jsxs)(un,{className:`items-center pt-2 text-center`,children:[N,F]}),t[38]=N,t[39]=F,t[40]=I):I=t[40];let L;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(`circle`,{cx:`72`,cy:`72`,r:`68`,stroke:`currentColor`,strokeWidth:`0.75`,opacity:`0.12`}),t[41]=L):L=t[41];let R=p&&`text-[var(--primary-base)]`,z;t[42]===R?z=t[43]:(z=G(R),t[42]=R,t[43]=z);let B=p?.5:.18,V;t[44]!==z||t[45]!==B?(V=(0,$.jsxs)(`svg`,{viewBox:`0 0 144 144`,className:`pointer-events-none absolute inset-0 size-full text-foreground`,fill:`none`,"aria-hidden":`true`,children:[L,(0,$.jsx)(`circle`,{cx:`72`,cy:`72`,r:`59`,stroke:`currentColor`,strokeWidth:`0.75`,strokeDasharray:`24 161.35`,strokeLinecap:`round`,transform:`rotate(-102 72 72)`,className:z,opacity:B})]}),t[44]=z,t[45]=B,t[46]=V):V=t[46];let ee=p&&`text-[var(--primary-base)]`,H;t[47]===ee?H=t[48]:(H=G(`relative size-28 max-h-full rounded-full !bg-transparent text-foreground shadow-none transition-transform duration-200 hover:scale-105 active:scale-95 motion-reduce:transform-none motion-reduce:transition-none`,ee),t[47]=ee,t[48]=H);let te=!f||m,ne=m||h?`refresh`:p?`stop`:`mic`,U=m&&`animate-spin motion-reduce:animate-none`,re;t[49]===U?re=t[50]:(re=G(`size-12`,U),t[49]=U,t[50]=re);let ie;t[51]!==ne||t[52]!==re?(ie=(0,$.jsx)(Y,{name:ne,className:re}),t[51]=ne,t[52]=re,t[53]=ie):ie=t[53];let ae;t[54]===O?ae=t[55]:(ae=(0,$.jsx)(`span`,{className:`sr-only`,children:O}),t[54]=O,t[55]=ae);let oe;t[56]!==A||t[57]!==O||t[58]!==p||t[59]!==H||t[60]!==te||t[61]!==ie||t[62]!==ae?(oe=(0,$.jsxs)(K,{variant:`ghost`,size:`icon`,className:H,disabled:te,"aria-label":O,"aria-pressed":p,onClick:A,children:[ie,ae]}),t[56]=A,t[57]=O,t[58]=p,t[59]=H,t[60]=te,t[61]=ie,t[62]=ae,t[63]=oe):oe=t[63];let se;t[64]!==V||t[65]!==oe?(se=(0,$.jsxs)(`div`,{className:`relative flex size-36 shrink-0 items-center justify-center`,children:[V,oe]}),t[64]=V,t[65]=oe,t[66]=se):se=t[66];let ce;t[67]!==u.error||t[68]!==O||t[69]!==p||t[70]!==T||t[71]!==C?(ce=(0,$.jsx)(`div`,{className:`flex h-12 w-full shrink-0 items-center justify-center overflow-hidden px-2`,children:u.error?(0,$.jsx)(`p`,{role:`alert`,className:`max-h-full overflow-y-auto break-words text-center typography-meta text-[var(--status-error)]`,children:u.error}):(0,$.jsx)(`div`,{role:`log`,"aria-live":`polite`,title:C,className:`line-clamp-2 max-h-full break-words text-center typography-ui-label leading-6 text-muted-foreground`,children:C?p&&C.length>80?`…${C.slice(-80)}`:C:T||O})}),t[67]=u.error,t[68]=O,t[69]=p,t[70]=T,t[71]=C,t[72]=ce):ce=t[72];let le;t[73]!==se||t[74]!==ce?(le=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-col items-center justify-center gap-3 overflow-y-auto pt-3`,children:[se,ce]}),t[73]=se,t[74]=ce,t[75]=le):le=t[75];let ue;t[76]!==I||t[77]!==le?(ue=(0,$.jsxs)(fn,{className:`h-[min(19rem,calc(100dvh-2rem))] grid-rows-[auto_minmax(0,1fr)] gap-0 overflow-hidden rounded-3xl sm:max-w-[22rem]`,children:[I,le]}),t[76]=I,t[77]=le,t[78]=ue):ue=t[78];let de;return t[79]!==j||t[80]!==ue?(de=(0,$.jsx)(hn,{open:!0,onOpenChange:j,children:ue}),t[79]=j,t[80]=ue,t[81]=de):de=t[81],de}var Dm=[{value:`seed-tts-2.0`,label:`Seed TTS 2.0`},{value:`seed-icl-2.0`,label:`Seed ICL 2.0`}],Om=[{value:`zh_female_vv_uranus_bigtts`,label:`Vivi 2.0`},{value:`zh_female_xiaohe_uranus_bigtts`,label:`小何 2.0`},{value:`zh_male_m191_uranus_bigtts`,label:`云舟 2.0`},{value:`zh_male_taocheng_uranus_bigtts`,label:`小天 2.0`},{value:`zh_male_liufei_uranus_bigtts`,label:`刘飞 2.0`},{value:`zh_female_sophie_uranus_bigtts`,label:`魅力苏菲 2.0`},{value:`zh_female_qingxinnvsheng_uranus_bigtts`,label:`清新女声 2.0`},{value:`zh_female_cancan_uranus_bigtts`,label:`知性灿灿 2.0`},{value:`zh_female_sajiaoxuemei_uranus_bigtts`,label:`撒娇学妹 2.0`},{value:`zh_female_tianmeixiaoyuan_uranus_bigtts`,label:`甜美小源 2.0`},{value:`zh_female_tianmeitaozi_uranus_bigtts`,label:`甜美桃子 2.0`},{value:`zh_female_shuangkuaisisi_uranus_bigtts`,label:`爽快思思 2.0`},{value:`zh_female_peiqi_uranus_bigtts`,label:`佩奇猪 2.0`},{value:`zh_female_linjianvhai_uranus_bigtts`,label:`邻家女孩 2.0`},{value:`zh_male_shaonianzixin_uranus_bigtts`,label:`少年梓辛 2.0`},{value:`zh_male_sunwukong_uranus_bigtts`,label:`猴哥 2.0`},{value:`zh_female_yingyujiaoxue_uranus_bigtts`,label:`Tina老师 2.0`},{value:`zh_female_kefunvsheng_uranus_bigtts`,label:`暖阳女声 2.0`},{value:`zh_female_xiaoxue_uranus_bigtts`,label:`儿童绘本 2.0`},{value:`zh_male_dayi_uranus_bigtts`,label:`大壹 2.0`},{value:`zh_female_mizai_uranus_bigtts`,label:`黑猫侦探社咪仔 2.0`},{value:`zh_female_jitangnv_uranus_bigtts`,label:`鸡汤女 2.0`},{value:`zh_female_meilinvyou_uranus_bigtts`,label:`魅力女友 2.0`},{value:`zh_female_liuchangnv_uranus_bigtts`,label:`流畅女声 2.0`},{value:`zh_male_ruyayichen_uranus_bigtts`,label:`儒雅逸辰 2.0`},{value:`en_male_tim_uranus_bigtts`,label:`Tim`},{value:`en_female_dacey_uranus_bigtts`,label:`Dacey`},{value:`en_female_stokie_uranus_bigtts`,label:`Stokie`}],km=`$custom`,Am=[{value:`volc.seedasr.sauc.duration`,label:`Seed ASR 2.0 · duration`},{value:`volc.seedasr.sauc.concurrent`,label:`Seed ASR 2.0 · concurrent`},{value:`volc.bigasr.sauc.duration`,label:`Big ASR 1.0 · duration`},{value:`volc.bigasr.sauc.concurrent`,label:`Big ASR 1.0 · concurrent`}];function jm(e){let t=(0,qi.c)(42),{value:n,onChange:r,options:i,label:a,allowCustom:o,disabled:s}=e,c=o===void 0||o,l=s!==void 0&&s,{t:u}=He(),[d,f]=(0,Q.useState)(!1),p;if(t[0]!==i||t[1]!==n){let e;t[3]===n?e=t[4]:(e=e=>e.value===n,t[3]=n,t[4]=e),p=i.some(e),t[0]=i,t[1]=n,t[2]=p}else p=t[2];let m=p,h=c&&(d||!m),g=h?km:n,_;t[5]===r?_=t[6]:(_=e=>{f(e===km),e!==km&&r(e)},t[5]=r,t[6]=_);let v;t[7]!==i||t[8]!==u?(v=(0,$.jsx)(Tn,{children:e=>e===km?u(`settings.voice.volcengine.custom`):i.find(t=>t.value===e)?.label??e}),t[7]=i,t[8]=u,t[9]=v):v=t[9];let y;t[10]!==a||t[11]!==v?(y=(0,$.jsx)(bn,{className:`w-full min-w-0`,"aria-label":a,children:v}),t[10]=a,t[11]=v,t[12]=y):y=t[12];let b;t[13]===i?b=t[14]:(b=i.map(Mm),t[13]=i,t[14]=b);let x;t[15]!==c||t[16]!==m||t[17]!==n?(x=!c&&!m&&n&&(0,$.jsx)(vn,{value:n,children:n}),t[15]=c,t[16]=m,t[17]=n,t[18]=x):x=t[18];let S;t[19]!==c||t[20]!==u?(S=c&&(0,$.jsx)(vn,{value:km,children:u(`settings.voice.volcengine.custom`)}),t[19]=c,t[20]=u,t[21]=S):S=t[21];let C;t[22]!==S||t[23]!==b||t[24]!==x?(C=(0,$.jsxs)(xn,{children:[b,x,S]}),t[22]=S,t[23]=b,t[24]=x,t[25]=C):C=t[25];let w;t[26]!==l||t[27]!==C||t[28]!==g||t[29]!==_||t[30]!==y?(w=(0,$.jsxs)(Cn,{disabled:l,value:g,onValueChange:_,children:[y,C]}),t[26]=l,t[27]=C,t[28]=g,t[29]=_,t[30]=y,t[31]=w):w=t[31];let T;t[32]!==h||t[33]!==l||t[34]!==a||t[35]!==r||t[36]!==u||t[37]!==n?(T=h&&(0,$.jsx)(En,{disabled:l,value:n,onChange:e=>r(e.target.value),"aria-label":`${a} (${u(`settings.voice.volcengine.custom`)})`}),t[32]=h,t[33]=l,t[34]=a,t[35]=r,t[36]=u,t[37]=n,t[38]=T):T=t[38];let E;return t[39]!==w||t[40]!==T?(E=(0,$.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col items-end gap-2`,children:[w,T]}),t[39]=w,t[40]=T,t[41]=E):E=t[41],E}function Mm(e){return(0,$.jsx)(vn,{value:e.value,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,$.jsx)(`span`,{children:e.label}),(0,$.jsx)(`span`,{className:`break-all typography-meta text-muted-foreground`,children:e.description??e.value})]})},e.value)}function Nm(e){let t=(0,qi.c)(60),{mode:n,form:r}=e,{t:i}=He(),a=(0,Q.useRef)(!0),o,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>(a.current=!0,()=>{a.current=!1}),s=[],t[0]=o,t[1]=s):(o=t[0],s=t[1]),(0,Q.useEffect)(o,s);let{values:c,draft:l,saving:u,edit:d,save:f}=r,{voice:p,resourceId:m,asrResourceId:h}=c,g;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g={enabled:!1},t[2]=g):g=t[2];let{speak:_,stop:v,isPlaying:y,error:b}=Nn(g),[x,S]=(0,Q.useState)(!1),C;t[3]!==y||t[4]!==n||t[5]!==f||t[6]!==u||t[7]!==_||t[8]!==v||t[9]!==i?(C=async()=>{if(n===`tts`&&y){v();return}if(u)return;let e=await f();if(!(!e||!a.current)){if(!e.configured){Ie.error(i(`settings.providers.page.toast.apiKeyRequired`));return}n===`asr`?S(!0):_(i(`settings.voice.page.preview.voiceLine`,{voiceName:`Yuri`}))}},t[3]=y,t[4]=n,t[5]=f,t[6]=u,t[7]=_,t[8]=v,t[9]=i,t[10]=C):C=t[10];let w=C,T=`voice.volcengine-${n}-key`,E;t[11]===i?E=t[12]:(E=i(`settings.voice.page.field.apiKey`),t[11]=i,t[12]=E);let D;t[13]===i?D=t[14]:(D=i(`settings.voice.volcengine.keyHelp`),t[13]=i,t[14]=D);let O;t[15]===i?O=t[16]:(O=i(`settings.voice.volcengine.openLink`),t[15]=i,t[16]=O);let k;t[17]===O?k=t[18]:(k=(0,$.jsx)(`a`,{href:`https://console.volcengine.com/speech/new`,target:`_blank`,rel:`noreferrer`,className:`text-primary underline`,children:O}),t[17]=O,t[18]=k);let A;t[19]!==D||t[20]!==k?(A=(0,$.jsxs)($.Fragment,{children:[D,` `,k]}),t[19]=D,t[20]=k,t[21]=A):A=t[21];let j=c.configured&&l.apiKey===void 0?`••••••••`:`API Key`,M=l.apiKey??``,N;t[22]===d?N=t[23]:(N=e=>d({apiKey:e.target.value}),t[22]=d,t[23]=N);let P;t[24]===i?P=t[25]:(P=i(`settings.voice.page.field.apiKey`),t[24]=i,t[25]=P);let F;t[26]!==u||t[27]!==j||t[28]!==M||t[29]!==N||t[30]!==P?(F=(0,$.jsx)(En,{type:`password`,autoComplete:`off`,disabled:u,placeholder:j,value:M,onChange:N,"aria-label":P}),t[26]=u,t[27]=j,t[28]=M,t[29]=N,t[30]=P,t[31]=F):F=t[31];let I;t[32]!==A||t[33]!==F||t[34]!==T||t[35]!==E?(I=(0,$.jsx)(Z,{itemId:T,label:E,description:A,children:F}),t[32]=A,t[33]=F,t[34]=T,t[35]=E,t[36]=I):I=t[36];let L;t[37]!==d||t[38]!==b||t[39]!==y||t[40]!==n||t[41]!==m||t[42]!==u||t[43]!==i||t[44]!==w||t[45]!==p?(L=n===`tts`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{itemId:`voice.volcengine-resource`,label:i(`settings.voice.volcengine.resource`),children:(0,$.jsx)(jm,{value:m,disabled:u,onChange:e=>d({resourceId:e}),options:Dm,label:i(`settings.voice.volcengine.resource`)})}),(0,$.jsx)(Z,{itemId:`voice.volcengine-speaker`,label:i(`settings.voice.volcengine.speaker`),children:(0,$.jsx)(jm,{value:p,disabled:u,onChange:e=>d({voice:e}),options:m===`seed-tts-2.0`?Om:[],label:i(`settings.voice.volcengine.speaker`)},m)}),(0,$.jsxs)(Z,{label:i(`settings.voice.page.actions.preview`),children:[(0,$.jsx)(K,{variant:`outline`,size:`sm`,disabled:!y&&u,"aria-busy":u,onClick:()=>void w(),children:i(y?`settings.voice.volcengine.stop`:`settings.voice.page.actions.preview`)}),b&&(0,$.jsx)(`span`,{role:`alert`,className:`text-[var(--status-error)]`,children:b})]})]}),t[37]=d,t[38]=b,t[39]=y,t[40]=n,t[41]=m,t[42]=u,t[43]=i,t[44]=w,t[45]=p,t[46]=L):L=t[46];let R;t[47]!==h||t[48]!==d||t[49]!==n||t[50]!==u||t[51]!==c.asrContext||t[52]!==i||t[53]!==w||t[54]!==x?(R=n===`asr`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{itemId:`voice.volcengine-asr-resource`,label:i(`settings.voice.volcengine.asrResource`),children:(0,$.jsx)(jm,{value:h,disabled:u,onChange:e=>d({asrResourceId:e}),options:Am.map(e=>({...e,description:i(e.value.endsWith(`.duration`)?`settings.voice.volcengine.durationHelp`:`settings.voice.volcengine.concurrentHelp`)})),label:i(`settings.voice.volcengine.asrResource`),allowCustom:!1})}),(0,$.jsx)(Z,{itemId:`voice.volcengine-asr-context`,className:`yuri-settings-split-row-stacked`,label:i(`settings.voice.volcengine.asrContext`),description:i(`settings.voice.volcengine.asrContextHelp`),children:(0,$.jsx)(zr,{rows:5,maxLength:2e3,disabled:u,value:c.asrContext,onChange:e=>d({asrContext:e.target.value}),"aria-label":i(`settings.voice.volcengine.asrContext`)})}),(0,$.jsx)(Z,{itemId:`voice.volcengine-asr-test`,label:i(`settings.voice.volcengine.asrTest`),description:i(`settings.voice.volcengine.testHelp`),children:(0,$.jsx)(K,{variant:`outline`,size:`sm`,disabled:u,"aria-busy":u,onClick:()=>void w(),children:i(`settings.voice.volcengine.asrTest`)})}),x&&(0,$.jsx)(Em,{onClose:()=>S(!1)})]}),t[47]=h,t[48]=d,t[49]=n,t[50]=u,t[51]=c.asrContext,t[52]=i,t[53]=w,t[54]=x,t[55]=R):R=t[55];let z;return t[56]!==I||t[57]!==L||t[58]!==R?(z=(0,$.jsxs)($.Fragment,{children:[I,L,R]}),t[56]=I,t[57]=L,t[58]=R,t[59]=z):z=t[59],z}function Pm(e){let{t}=He(),[n,r]=(0,Q.useState)({}),a=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>(a.current=!0,()=>{a.current=!1}),[]);let s=De({mutationFn:({patch:e,generation:t,transport:n})=>Er(e,t,n),networkMode:`always`,retry:!1,gcTime:0}),c=async()=>{if(s.isPending)return null;let e=o(),c=n;try{let t=await s.mutateAsync({patch:n,generation:e,transport:i()});return!a.current||e!==o()?null:(r(e=>e===c?{}:Object.fromEntries(Object.entries(e).filter(([e,t])=>!Object.is(t,c[e])))),t)}catch{return a.current&&e===o()&&Ie.error(t(`settings.voice.volcengine.saveFailed`)),null}finally{s.reset()}};return{values:{...e,...n},draft:n,saving:s.isPending,edit:e=>r(t=>({...t,...e})),save:c}}var Fm=[{id:`parakeet-tdt-0.6b-v2-int8`,labelKey:`settings.voice.page.stt.model.parakeetV2`,badgeKey:`settings.voice.page.stt.badge.bestForEnglish`,accuracy:5,speed:5,size:`460 MB`},{id:`parakeet-tdt-0.6b-v3-int8`,labelKey:`settings.voice.page.stt.model.parakeetV3`,badgeKey:`settings.voice.page.stt.badge.bestForMultilingual`,accuracy:5,speed:4,size:`465 MB`},{id:`whisper-base-int8`,labelKey:`settings.voice.page.stt.model.whisperBase`,badgeKey:null,accuracy:3,speed:3,size:`200 MB`},{id:`whisper-tiny-int8`,labelKey:`settings.voice.page.stt.model.whisperTiny`,badgeKey:null,accuracy:2,speed:4,size:`115 MB`}],Im=e=>{let t=(0,qi.c)(8),{value:n,label:r}=e,i=`${r}: ${n}/5`,a=`${n/5*100}%`,o;t[0]===a?o=t[1]:(o=(0,$.jsx)(`span`,{className:`h-1.5 w-12 flex-shrink-0 overflow-hidden rounded-full bg-[var(--interactive-border)]`,"aria-hidden":`true`,children:(0,$.jsx)(`span`,{className:`block h-full rounded-full bg-[var(--primary-base)]`,style:{width:a}})}),t[0]=a,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,$.jsx)(`span`,{className:`typography-ui-compact text-muted-foreground`,children:r}),t[2]=r,t[3]=s);let c;return t[4]!==i||t[5]!==o||t[6]!==s?(c=(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,title:i,children:[o,s]}),t[4]=i,t[5]=o,t[6]=s,t[7]=c):c=t[7],c},Lm=({selectedModelId:e,onSelect:t})=>{let{t:n}=He(),r=(0,Q.useCallback)(e=>n(e),[n]),[i,a]=(0,Q.useState)(new Map),[o,s]=(0,Q.useState)(null),c=(0,Q.useCallback)(async()=>{try{let e=await p(`/api/dictation/status`,{query:{provider:`local`}});if(!e.ok)return;let t=await e.json();Array.isArray(t?.models)&&a(new Map(t.models.map(e=>[e.id,e])))}catch{}},[]);(0,Q.useEffect)(()=>{c()},[c]);let l=Array.from(i.values()).some(e=>e.downloading);(0,Q.useEffect)(()=>{if(!l)return;let e=setInterval(()=>{c()},2e3);return()=>clearInterval(e)},[l,c]);let u=async e=>{s(e);try{await p(`/api/dictation/models/${encodeURIComponent(e)}/download`,{method:`POST`}),await c()}catch{}finally{s(null)}},d=async e=>{s(e);try{await p(`/api/dictation/models/${encodeURIComponent(e)}`,{method:`DELETE`}),await c()}catch{}finally{s(null)}};return(0,$.jsx)(`div`,{role:`radiogroup`,"aria-label":n(`settings.voice.page.field.model`),className:`mt-1 w-full min-w-0 space-y-0`,children:Fm.map(a=>{let s=e===a.id,c=i.get(a.id)??null;return(0,$.jsxs)(`div`,{className:`flex w-full items-start gap-2 py-1.5`,children:[(0,$.jsx)(`div`,{className:`pt-0.5`,children:(0,$.jsx)(mc,{checked:s,onChange:()=>t(a.id),ariaLabel:r(a.labelKey)})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 cursor-pointer`,role:`button`,tabIndex:0,onClick:()=>t(a.id),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),t(a.id))},children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,$.jsx)(`span`,{className:G(`typography-ui-label font-normal`,s?`text-foreground`:`text-foreground/50`),children:r(a.labelKey)}),a.badgeKey?(0,$.jsx)(`span`,{className:`rounded px-1 text-[9px] font-medium uppercase leading-[14px] tracking-wide`,style:{backgroundColor:`var(--status-success-background)`,color:`var(--status-success)`,border:`1px solid var(--status-success-border)`},children:r(a.badgeKey)}):null]}),(0,$.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-x-4 gap-y-0.5`,children:[(0,$.jsx)(Im,{value:a.accuracy,label:n(`settings.voice.page.stt.meta.accuracy`)}),(0,$.jsx)(Im,{value:a.speed,label:n(`settings.voice.page.stt.meta.speed`)}),(0,$.jsx)(`span`,{className:`typography-ui-compact tabular-nums text-muted-foreground`,children:a.size})]}),c?.downloadError?(0,$.jsx)(`p`,{className:`mt-0.5 typography-meta text-[var(--status-error)]`,children:c.downloadError}):null]}),(0,$.jsx)(`div`,{className:`flex w-14 flex-shrink-0 items-center justify-end gap-1 pt-0.5`,children:c?.installed?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(K,{variant:`ghost`,size:`xs`,className:`h-6 w-6 p-0 text-muted-foreground hover:text-[var(--status-error)]`,disabled:o===a.id,onClick:()=>{d(a.id)},title:n(`settings.voice.page.stt.modelDelete`),"aria-label":n(`settings.voice.page.stt.modelDelete`),children:(0,$.jsx)(Y,{name:`delete-bin`,className:`h-4 w-4`})}),(0,$.jsx)(Y,{name:`checkbox-circle`,className:`h-4 w-4 flex-shrink-0 text-[var(--status-success)]`,"aria-label":n(`settings.voice.page.stt.modelInstalled`)})]}):c?.downloading?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(Y,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin text-muted-foreground`}),(0,$.jsx)(`span`,{className:`typography-ui-compact tabular-nums text-muted-foreground`,children:typeof c.downloadProgress==`number`?`${c.downloadProgress}%`:``})]}):(0,$.jsx)(K,{variant:`ghost`,size:`xs`,className:`h-6 w-6 p-0`,disabled:o===a.id,onClick:()=>{u(a.id)},title:n(`settings.voice.page.stt.modelDownload`),"aria-label":n(`settings.voice.page.stt.modelDownload`),children:(0,$.jsx)(Y,{name:`download`,className:`h-4 w-4`})})})]},a.id)})})},Rm=[{id:0,label:`Alloy (af)`},{id:1,label:`Bella (af)`},{id:2,label:`Nicole (af)`},{id:3,label:`Sarah (af)`},{id:4,label:`Sky (af)`},{id:5,label:`Adam (am)`},{id:6,label:`Michael (am)`},{id:7,label:`Emma (bf)`},{id:8,label:`Isabella (bf)`},{id:9,label:`George (bm)`},{id:10,label:`Lewis (bm)`}],zm=`kokoro-en-v0_19`,Bm=()=>{let{t:e}=He(),[t,n]=(0,Q.useState)(null),[r,i]=(0,Q.useState)(!1),a=(0,Q.useCallback)(async()=>{try{let e=await p(`/api/dictation/status`,{query:{provider:`local`}});if(!e.ok)return;let t=await e.json(),r=Array.isArray(t?.ttsModels)?t.ttsModels.find(e=>e.id===zm):null;r&&n(r)}catch{}},[]);(0,Q.useEffect)(()=>{a()},[a]),(0,Q.useEffect)(()=>{if(!t?.downloading)return;let e=setInterval(()=>{a()},2e3);return()=>clearInterval(e)},[t?.downloading,a]);let o=async e=>{i(!0);try{await p(e===`POST`?`/api/dictation/models/${zm}/download`:`/api/dictation/models/${zm}`,{method:e}),await a()}catch{}finally{i(!1)}};return t?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 py-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:`Kokoro`}),(0,$.jsx)(`span`,{className:`typography-ui-compact tabular-nums text-muted-foreground`,children:`305 MB`}),t.installed?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Y,{name:`checkbox-circle`,className:`h-4 w-4 text-[var(--status-success)]`,"aria-label":e(`settings.voice.page.stt.modelInstalled`)}),(0,$.jsx)(K,{variant:`ghost`,size:`xs`,className:`h-6 w-6 p-0 text-muted-foreground hover:text-[var(--status-error)]`,disabled:r,onClick:()=>{o(`DELETE`)},title:e(`settings.voice.page.stt.modelDelete`),"aria-label":e(`settings.voice.page.stt.modelDelete`),children:(0,$.jsx)(Y,{name:`delete-bin`,className:`h-4 w-4`})})]}):t.downloading?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(Y,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin text-muted-foreground`}),(0,$.jsx)(`span`,{className:`typography-ui-compact tabular-nums text-muted-foreground`,children:typeof t.downloadProgress==`number`?`${t.downloadProgress}%`:``})]}):(0,$.jsx)(K,{variant:`ghost`,size:`xs`,className:`h-6 w-6 p-0`,disabled:r,onClick:()=>{o(`POST`)},title:e(`settings.voice.page.stt.modelDownload`),"aria-label":e(`settings.voice.page.stt.modelDownload`),children:(0,$.jsx)(Y,{name:`download`,className:`h-4 w-4`})}),t.downloadError?(0,$.jsx)(`span`,{className:`typography-meta text-[var(--status-error)]`,children:t.downloadError}):null]}):null},Vm=[{value:`alloy`,label:`Alloy`},{value:`ash`,label:`Ash`},{value:`ballad`,label:`Ballad`},{value:`coral`,label:`Coral`},{value:`echo`,label:`Echo`},{value:`fable`,label:`Fable`},{value:`nova`,label:`Nova`},{value:`onyx`,label:`Onyx`},{value:`sage`,label:`Sage`},{value:`shimmer`,label:`Shimmer`},{value:`verse`,label:`Verse`},{value:`marin`,label:`Marin`},{value:`cedar`,label:`Cedar`}],Hm=()=>{let e=(0,qi.c)(2),t=(0,Q.useSyncExternalStore)(r,o,o),n;return e[0]===t?n=e[1]:(n=(0,$.jsx)(Um,{},t),e[0]=t,e[1]=n),n};function Um(){let e=(0,qi.c)(8),{t}=He(),n=Sr(),r;e[0]!==n||e[1]!==t?(r=n.isError&&(0,$.jsx)(Z,{label:t(`settings.voice.volcengine.loadFailed`),children:(0,$.jsx)(K,{variant:`outline`,size:`sm`,onClick:()=>void n.refetch(),children:t(`settings.voice.volcengine.retry`)})}),e[0]=n,e[1]=t,e[2]=r):r=e[2];let i=n.data??on,a;e[3]===i?a=e[4]:(a=(0,$.jsx)(Wm,{settings:i}),e[3]=i,e[4]=a);let o;return e[5]!==r||e[6]!==a?(o=(0,$.jsxs)($.Fragment,{children:[r,a]}),e[5]=r,e[6]=a,e[7]=o):o=e[7],o}var Wm=({settings:e})=>{let{t}=He(),{isMobile:n}=Pr(),r=Pm(e),i=Pm(e),{voiceProvider:a,speechRate:o,speechPitch:s,speechVolume:c,sayVoice:l,localTtsVoiceId:u,browserVoice:d,openaiVoice:f,openaiApiKey:m,openaiCompatibleUrl:h,openaiCompatibleApiKey:g,openaiCompatibleVoice:_,openaiCompatibleTtsModel:v,showMessageTTSButtons:y,ttsInputMode:b}=r.values,{sttProvider:x,sttServerUrl:S,sttApiKey:C,sttModel:w,sttLocalModel:T,sttLanguage:E,dictationEnabled:D}=i.values,O=e=>r.edit({voiceProvider:e}),k=e=>r.edit({speechRate:e}),A=e=>r.edit({speechPitch:e}),j=e=>r.edit({speechVolume:e}),M=e=>r.edit({sayVoice:e}),N=e=>r.edit({localTtsVoiceId:e}),P=e=>r.edit({browserVoice:e}),F=e=>r.edit({openaiVoice:e}),I=e=>r.edit({openaiApiKey:e}),L=e=>r.edit({openaiCompatibleUrl:e}),R=e=>r.edit({openaiCompatibleApiKey:e}),z=e=>r.edit({openaiCompatibleVoice:e}),B=e=>r.edit({openaiCompatibleTtsModel:e}),V=e=>r.edit({ttsInputMode:e}),ee=e=>r.edit({showMessageTTSButtons:e}),H=e=>i.edit({dictationEnabled:e}),te=e=>i.edit({sttProvider:e}),ne=e=>i.edit({sttServerUrl:e}),U=e=>i.edit({sttApiKey:e}),re=e=>i.edit({sttModel:e}),ie=e=>i.edit({sttLocalModel:e}),ae=e=>i.edit({sttLanguage:e}),{speak:oe,stop:se,isPlaying:ce,error:le}=jr(),ue=ze(async()=>{if(ce){se();return}if(!await r.save())return;let e=Rm.find(e=>e.id===u)?.label??String(u);oe(t(`settings.voice.page.preview.voiceLine`,{voiceName:e}))}),[de,fe]=(0,Q.useState)(!1),[pe,me]=(0,Q.useState)([]),[he,ge]=(0,Q.useState)(!1),[_e,ve]=(0,Q.useState)(null),[ye,be]=(0,Q.useState)(!1),[xe,Se]=(0,Q.useState)(!1),[W,Ce]=(0,Q.useState)(null),[we,Te]=(0,Q.useState)(!1),[Ee,De]=(0,Q.useState)(null),[Oe,ke]=(0,Q.useState)([]),[Ae,je]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>((async()=>{let e=await Xn.waitForVoices();ke(e)})(),`speechSynthesis`in window&&(window.speechSynthesis.onvoiceschanged=()=>{ke(window.speechSynthesis.getVoices())}),()=>{`speechSynthesis`in window&&(window.speechSynthesis.onvoiceschanged=null)}),[]);let Me=(0,Q.useMemo)(()=>Oe.filter(e=>e.lang).sort((e,t)=>{let n=e.lang.startsWith(`en`),r=t.lang.startsWith(`en`);if(n&&!r)return-1;if(!n&&r)return 1;let i=e.lang.localeCompare(t.lang);return i===0?e.name.localeCompare(t.name):i}),[Oe]),Ne=ze(async()=>{if(Ae){Xn.cancelSpeech(),je(!1);return}if(!await r.save())return;let e=Oe.find(e=>e.name===d),n=e?.name??t(`settings.voice.page.preview.browserVoiceFallback`),i=t(`settings.voice.page.preview.voiceLine`,{voiceName:n});je(!0);let a=new SpeechSynthesisUtterance(i);a.rate=o,a.pitch=s,a.volume=c,e&&(a.voice=e,a.lang=e.lang),a.onend=()=>je(!1),a.onerror=()=>je(!1),window.speechSynthesis.cancel(),window.speechSynthesis.speak(a)});(0,Q.useEffect)(()=>()=>{Ae&&Xn.cancelSpeech()},[Ae]),(0,Q.useEffect)(()=>{if(!y||a!==`openai`&&a!==`openai-compatible`){be(m.trim().length>0||e.openaiApiKeyConfigured);return}(async()=>{try{let t=(await(await p(`/api/tts/status`)).json()).available,n=m.trim().length>0||e.openaiApiKeyConfigured;be(t||n)}catch{be(m.trim().length>0||e.openaiApiKeyConfigured)}})()},[m,e.openaiApiKeyConfigured,y,a]),(0,Q.useEffect)(()=>{if(!y){fe(!1),me([]);return}p(`/api/tts/say/status`).then(e=>e.json()).then(e=>{if(fe(e.available),e.voices){let t=e.voices.filter((e,t,n)=>n.findIndex(t=>t.name===e.name)===t).sort((e,t)=>e.name.localeCompare(t.name));me(t)}}).catch(()=>{fe(!1)})},[y]);let Pe=ze(async()=>{if(_e){Tm(_e),ve(null),ge(!1);return}if(!await r.save())return;ge(!0);let e=null;try{let n=await p(`/api/tts/say/speak`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:t(`settings.voice.page.preview.voiceLine`,{voiceName:l})})});if(!n.ok)throw Error(`Preview failed`);let r=await n.blob(),i=URL.createObjectURL(r);e=new Audio(i),e.onended=()=>{Tm(e),ve(null),ge(!1)},e.onerror=()=>{Tm(e),ve(null),ge(!1)},ve(e),await e.play()}catch{Tm(e),ve(null),ge(!1)}});(0,Q.useEffect)(()=>()=>{Tm(_e)},[_e]);let Fe=ze(async()=>{if(W){Tm(W),Ce(null),Se(!1);return}if(!await r.save())return;Se(!0);let e=null;try{let n=await p(`/api/tts/speak`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:t(`settings.voice.page.preview.voiceLine`,{voiceName:f})})});if(!n.ok){let e=await n.json().catch(()=>({error:`Unknown error`}));throw Error(e.error||`HTTP ${n.status}`)}let r=await n.blob(),i=URL.createObjectURL(r);e=new Audio(i),e.onended=()=>{Tm(e),Ce(null),Se(!1)},e.onerror=()=>{Tm(e),Ce(null),Se(!1)},Ce(e),await e.play()}catch{Tm(e),Ce(null),Se(!1)}});(0,Q.useEffect)(()=>()=>{Tm(W)},[W]);let Ie=ze(async()=>{if(Ee){Tm(Ee),De(null),Te(!1);return}if(!h.trim()||!await r.save())return;Te(!0);let e=null;try{let n=await p(`/api/tts/speak`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:t(`settings.voice.page.preview.customServerLine`)})});if(!n.ok){let e=await n.json().catch(()=>({error:`Unknown error`}));throw Error(e.error||`HTTP ${n.status}`)}let r=await n.blob(),i=URL.createObjectURL(r);e=new Audio(i),e.onended=()=>{Tm(e),De(null),Te(!1)},e.onerror=()=>{Tm(e),De(null),Te(!1)},De(e),await e.play()}catch{Tm(e),De(null),Te(!1)}});(0,Q.useEffect)(()=>()=>{Tm(Ee)},[Ee]);let Le=`flex-1 min-w-0 h-1.5 bg-[var(--interactive-border)] rounded-full appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-[var(--primary-base)] [&::-moz-range-thumb]:w-4 [&::-moz-range-thumb]:h-4 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:bg-[var(--primary-base)] [&::-moz-range-thumb]:border-0 disabled:opacity-50`;return(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[(0,$.jsx)(`div`,{className:`space-y-1`,children:(0,$.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground`,children:t(`settings.page.voice.title`)})}),(0,$.jsx)(`div`,{"data-settings-item":`voice.playback`,children:(0,$.jsxs)(X,{label:t(`settings.voice.page.section.playbackAndSummary`),actions:(0,$.jsx)(K,{size:`sm`,disabled:r.saving,"aria-busy":r.saving,onClick:()=>{r.saving||r.save()},children:t(`settings.voice.volcengine.save`)}),children:[(0,$.jsx)(Z,{label:t(`settings.voice.page.field.messageReadAloudButton`),children:(0,$.jsx)(gn,{checked:y,onChange:ee,ariaLabel:t(`settings.voice.page.field.messageReadAloudButtonAria`)})}),y&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:t(`settings.voice.page.field.provider`)}),(0,$.jsxs)(kn,{children:[(0,$.jsx)(Dn,{asChild:!0,children:(0,$.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(On,{sideOffset:8,className:`max-w-xs`,children:(0,$.jsxs)(`ul`,{className:`space-y-1`,children:[(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`strong`,{children:t(`settings.voice.page.provider.browser`)}),` `,t(`settings.voice.page.tooltip.browser`)]}),(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`strong`,{children:t(`settings.voice.page.provider.local`)}),` `,t(`settings.voice.page.tooltip.localTts`)]}),(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`strong`,{children:`OpenAI:`}),` `,t(`settings.voice.page.tooltip.openai`)]}),(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`strong`,{children:t(`settings.voice.page.provider.custom`)}),` `,t(`settings.voice.page.tooltip.custom`)]}),(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`strong`,{children:t(`settings.voice.page.provider.say`)}),` `,t(`settings.voice.page.tooltip.say`)]})]})})]})]}),children:(0,$.jsxs)(Cn,{value:a,onValueChange:e=>{(e===`browser`||e===`local`||e===`openai`||e===`openai-compatible`||e===`volcengine`||e===`say`&&de)&&O(e)},children:[(0,$.jsx)(bn,{"aria-label":t(`settings.voice.page.field.provider`),children:(0,$.jsx)(Tn,{children:{browser:t(`settings.voice.page.provider.browser`),volcengine:t(`settings.voice.volcengine.providerOption`),local:t(`settings.voice.page.provider.local`),openai:`OpenAI`,"openai-compatible":t(`settings.voice.page.provider.custom`),say:t(`settings.voice.page.provider.say`)}[a]})}),(0,$.jsxs)(xn,{children:[(0,$.jsx)(vn,{value:`browser`,children:t(`settings.voice.page.provider.browser`)}),(0,$.jsx)(vn,{value:`volcengine`,children:t(`settings.voice.volcengine.providerOption`)}),(0,$.jsx)(vn,{value:`local`,children:t(`settings.voice.page.provider.local`)}),(0,$.jsx)(vn,{value:`openai`,children:`OpenAI`}),(0,$.jsx)(vn,{value:`openai-compatible`,children:t(`settings.voice.page.provider.custom`)}),de&&(0,$.jsx)(vn,{value:`say`,children:t(`settings.voice.page.provider.say`)})]})]})}),a===`volcengine`&&(0,$.jsx)(Nm,{mode:`tts`,form:r}),a===`openai`&&(0,$.jsx)(Z,{label:(0,$.jsx)(`span`,{className:G(!ye&&`text-[var(--status-error)]`),children:t(`settings.voice.page.field.apiKey`)}),description:(0,$.jsx)(`span`,{className:G(!ye&&`text-[var(--status-error)]/80`),children:t(ye&&!m?`settings.voice.page.field.apiKeyHintUsingConfig`:ye?`settings.voice.page.field.apiKeyHintProvide`:`settings.voice.page.field.apiKeyHintRequired`)}),children:(0,$.jsxs)(`div`,{className:`relative w-full`,children:[(0,$.jsx)(En,{type:`password`,value:m,onChange:e=>I(e.target.value),placeholder:e.openaiApiKeyConfigured&&r.draft.openaiApiKey===void 0?`••••••••`:`sk-...`,className:`w-full pr-8`}),m&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>I(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(Y,{name:`close`,className:`w-3.5 h-3.5`})})]})}),a===`openai-compatible`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{label:(0,$.jsx)(`span`,{className:G(!h.trim()&&`text-[var(--status-error)]`),children:t(`settings.voice.page.field.serverUrl`)}),description:t(`settings.voice.page.field.serverUrlHint`),children:(0,$.jsxs)(`div`,{className:`relative w-full`,children:[(0,$.jsx)(En,{type:`text`,value:h,onChange:e=>L(e.target.value),placeholder:`http://localhost:8880/v1`,className:`w-full pr-8`}),h&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>L(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(Y,{name:`close`,className:`w-3.5 h-3.5`})})]})}),(0,$.jsx)(Z,{label:`API Key`,description:`Optional`,children:(0,$.jsxs)(`div`,{className:`relative w-full`,children:[(0,$.jsx)(En,{type:`password`,value:g,onChange:e=>R(e.target.value),placeholder:e.openaiCompatibleApiKeyConfigured&&r.draft.openaiCompatibleApiKey===void 0?`••••••••`:`sk-...`,className:`w-full pr-8`}),g&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>R(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(Y,{name:`close`,className:`w-3.5 h-3.5`})})]})}),(0,$.jsx)(Z,{label:t(`settings.voice.page.field.model`),children:(0,$.jsx)(`div`,{className:`relative w-full`,children:(0,$.jsx)(En,{type:`text`,value:v,onChange:e=>B(e.target.value),placeholder:`speaches-ai/Kokoro-82M-v1.0-ONNX`,className:`w-full`})})}),(0,$.jsx)(Z,{label:t(`settings.voice.page.field.voice`),description:t(`settings.voice.page.field.voiceIdentifierHint`),children:(0,$.jsxs)(`div`,{className:`flex w-full items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`relative min-w-0 flex-1`,children:(0,$.jsx)(En,{type:`text`,value:_,onChange:e=>z(e.target.value),placeholder:`af_sky`,className:`w-full`})}),(0,$.jsx)(K,{size:`xs`,variant:`ghost`,onClick:Ie,title:t(`settings.voice.page.actions.preview`),disabled:!h.trim(),children:we?(0,$.jsx)(Y,{name:`stop`,className:`w-3.5 h-3.5`}):(0,$.jsx)(Y,{name:`play`,className:`w-3.5 h-3.5`})})]})})]}),a===`local`&&(0,$.jsx)(Bm,{}),a!==`volcengine`&&(0,$.jsxs)(Z,{label:t(`settings.voice.page.field.voice`),children:[a===`local`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Cn,{value:String(u),onValueChange:e=>N(Number.parseInt(e,10)||0),children:[(0,$.jsx)(bn,{className:`w-fit`,children:(0,$.jsx)(Tn,{placeholder:t(`settings.voice.page.field.selectVoicePlaceholder`),children:e=>Rm.find(t=>String(t.id)===e)?.label??e})}),(0,$.jsx)(xn,{children:Rm.map(e=>(0,$.jsx)(vn,{value:String(e.id),children:e.label},e.id))})]}),(0,$.jsx)(K,{size:`xs`,variant:`ghost`,onClick:ue,title:t(`settings.voice.page.actions.preview`),children:ce?(0,$.jsx)(Y,{name:`stop`,className:`w-3.5 h-3.5`}):(0,$.jsx)(Y,{name:`play`,className:`w-3.5 h-3.5`})}),le?(0,$.jsx)(`span`,{className:`typography-meta text-[var(--status-error)]`,children:le}):null]}),a===`openai`&&ye&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Cn,{value:f,onValueChange:F,children:[(0,$.jsx)(bn,{className:`w-fit`,children:(0,$.jsx)(Tn,{placeholder:t(`settings.voice.page.field.selectVoicePlaceholder`)})}),(0,$.jsx)(xn,{children:Vm.map(e=>(0,$.jsx)(vn,{value:e.value,children:e.label},e.value))})]}),(0,$.jsx)(K,{size:`xs`,variant:`ghost`,onClick:Fe,title:t(`settings.voice.page.actions.preview`),children:xe?(0,$.jsx)(Y,{name:`stop`,className:`w-3.5 h-3.5`}):(0,$.jsx)(Y,{name:`play`,className:`w-3.5 h-3.5`})})]}),a===`openai-compatible`&&(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:t(`settings.voice.page.field.configuredAbove`)}),a===`say`&&de&&pe.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Cn,{value:l,onValueChange:M,children:[(0,$.jsx)(bn,{className:`w-fit`,children:(0,$.jsx)(Tn,{placeholder:t(`settings.voice.page.field.selectVoicePlaceholder`)})}),(0,$.jsx)(xn,{children:pe.map(e=>(0,$.jsx)(vn,{value:e.name,children:e.name},e.name))})]}),(0,$.jsx)(K,{size:`xs`,variant:`ghost`,onClick:Pe,title:t(`settings.voice.page.actions.preview`),children:he?(0,$.jsx)(Y,{name:`stop`,className:`w-3.5 h-3.5`}):(0,$.jsx)(Y,{name:`play`,className:`w-3.5 h-3.5`})})]}),a===`browser`&&Me.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Cn,{value:d||`$auto`,onValueChange:e=>P(e===`$auto`?``:e),children:[(0,$.jsx)(bn,{className:`w-fit max-w-[200px]`,children:(0,$.jsx)(Tn,{placeholder:t(`settings.voice.page.field.auto`)})}),(0,$.jsxs)(xn,{children:[(0,$.jsx)(vn,{value:`$auto`,children:t(`settings.voice.page.field.auto`)}),Me.map(e=>(0,$.jsxs)(vn,{value:e.name,children:[e.name,` (`,e.lang,`)`]},e.name))]})]}),(0,$.jsx)(K,{size:`xs`,variant:`ghost`,onClick:Ne,title:t(`settings.voice.page.actions.preview`),children:Ae?(0,$.jsx)(Y,{name:`stop`,className:`w-3.5 h-3.5`}):(0,$.jsx)(Y,{name:`play`,className:`w-3.5 h-3.5`})})]})]}),(0,$.jsxs)(Z,{label:t(`settings.voice.page.field.speechRate`),children:[!n&&(0,$.jsx)(`input`,{type:`range`,min:.5,max:2,step:.1,value:o,onChange:e=>k(Number(e.target.value)),className:Le}),(0,$.jsx)(yi,{value:o,onValueChange:k,min:.5,max:2,step:.1,className:`w-16 tabular-nums`})]}),(0,$.jsxs)(Z,{label:t(`settings.voice.page.field.speechPitch`),children:[!n&&(0,$.jsx)(`input`,{type:`range`,min:.5,max:2,step:.1,value:s,onChange:e=>A(Number(e.target.value)),className:Le}),(0,$.jsx)(yi,{value:s,onValueChange:A,min:.5,max:2,step:.1,className:`w-16 tabular-nums`})]}),(0,$.jsxs)(Z,{label:t(`settings.voice.page.field.speechVolume`),children:[!n&&(0,$.jsx)(`input`,{type:`range`,min:0,max:1,step:.1,value:c,onChange:e=>j(Number(e.target.value)),className:Le}),n?(0,$.jsx)(yi,{value:Math.round(c*100),onValueChange:e=>j(e/100),min:0,max:100,step:10,className:`w-16 tabular-nums`}):(0,$.jsxs)(`span`,{className:`typography-ui-label text-foreground tabular-nums min-w-[3rem] text-right`,children:[Math.round(c*100),`%`]})]}),(0,$.jsx)(Z,{label:t(`settings.voice.page.field.ttsInputMode`),children:(0,$.jsxs)(Cn,{value:b,onValueChange:e=>{(e===`final`||e===`sanitized`||e===`raw`||e===`summarized`)&&V(e)},children:[(0,$.jsx)(bn,{className:`w-fit max-w-full`,"aria-label":t(`settings.voice.page.field.ttsInputMode`),children:(0,$.jsx)(Tn,{children:()=>t(b===`final`?`settings.voice.page.field.ttsInputModeFinal`:b===`raw`?`settings.voice.page.field.ttsInputModeRaw`:b===`summarized`?`settings.voice.page.field.ttsInputModeSummarized`:`settings.voice.page.field.ttsInputModeSanitized`)})}),(0,$.jsx)(xn,{children:[[`final`,`settings.voice.page.field.ttsInputModeFinal`,`settings.voice.page.field.ttsInputModeFinalDescription`],[`sanitized`,`settings.voice.page.field.ttsInputModeSanitized`,`settings.voice.page.field.ttsInputModeSanitizedDescription`],[`raw`,`settings.voice.page.field.ttsInputModeRaw`,`settings.voice.page.field.ttsInputModeRawDescription`],[`summarized`,`settings.voice.page.field.ttsInputModeSummarized`,`settings.voice.page.field.ttsInputModeSummarizedDescription`]].map(([e,n,r])=>(0,$.jsx)(vn,{value:e,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-1 text-left`,children:[(0,$.jsx)(`span`,{children:t(n)}),(0,$.jsx)(`span`,{className:`max-w-64 whitespace-normal typography-meta text-muted-foreground`,children:t(r)})]})},e))})]})})]})]})}),(0,$.jsx)(`div`,{"data-settings-item":`voice.speech-recognition`,children:(0,$.jsxs)(X,{label:t(`settings.voice.page.section.speechRecognition`),actions:(0,$.jsx)(K,{size:`sm`,disabled:i.saving,"aria-busy":i.saving,onClick:()=>{i.saving||i.save()},children:t(`settings.voice.volcengine.save`)}),children:[(0,$.jsx)(Z,{label:t(`settings.voice.page.field.enableVoiceInput`),children:(0,$.jsx)(gn,{checked:D,onChange:H,ariaLabel:t(`settings.voice.page.field.enableVoiceInputAria`)})}),D&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{label:(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{children:t(`settings.voice.page.field.provider`)}),(0,$.jsxs)(kn,{children:[(0,$.jsx)(Dn,{asChild:!0,children:(0,$.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,$.jsx)(On,{sideOffset:8,className:`max-w-xs`,children:(0,$.jsxs)(`ul`,{className:`space-y-1`,children:[(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`strong`,{children:t(`settings.voice.page.provider.local`)}),` `,t(`settings.voice.page.tooltip.sttLocal`)]}),(0,$.jsxs)(`li`,{children:[(0,$.jsx)(`strong`,{children:t(`settings.voice.page.provider.server`)}),` `,t(`settings.voice.page.tooltip.sttServer`)]})]})})]})]}),children:(0,$.jsxs)(Cn,{value:x,onValueChange:e=>{(e===`local`||e===`openai-compatible`||e===`volcengine`)&&te(e)},children:[(0,$.jsx)(bn,{"aria-label":t(`settings.voice.page.field.provider`),children:(0,$.jsx)(Tn,{children:{local:t(`settings.voice.page.provider.local`),volcengine:t(`settings.voice.volcengine.providerOption`),"openai-compatible":t(`settings.voice.page.provider.server`)}[x]})}),(0,$.jsxs)(xn,{children:[(0,$.jsx)(vn,{value:`local`,children:t(`settings.voice.page.provider.local`)}),(0,$.jsx)(vn,{value:`volcengine`,children:t(`settings.voice.volcengine.providerOption`)}),(0,$.jsx)(vn,{value:`openai-compatible`,children:t(`settings.voice.page.provider.server`)})]})]})}),x===`volcengine`&&(0,$.jsx)(Nm,{mode:`asr`,form:i}),x===`local`&&(0,$.jsx)(Z,{label:t(`settings.voice.page.field.model`),className:`yuri-settings-split-row-stacked`,children:(0,$.jsx)(Lm,{selectedModelId:T,onSelect:ie})}),x===`openai-compatible`&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{label:(0,$.jsx)(`span`,{className:G(!S.trim()&&`text-[var(--status-error)]`),children:t(`settings.voice.page.field.serverUrl`)}),description:t(`settings.voice.page.field.sttServerUrlHint`),children:(0,$.jsxs)(`div`,{className:`relative w-full`,children:[(0,$.jsx)(En,{type:`text`,value:S,onChange:e=>ne(e.target.value),placeholder:`http://localhost:8001/v1`,className:`w-full pr-8`}),S&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>ne(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(Y,{name:`close`,className:`w-3.5 h-3.5`})})]})}),(0,$.jsx)(Z,{label:`API Key`,description:`Optional`,children:(0,$.jsxs)(`div`,{className:`relative w-full`,children:[(0,$.jsx)(En,{type:`password`,value:C,onChange:e=>U(e.target.value),placeholder:e.sttApiKeyConfigured&&i.draft.sttApiKey===void 0?`••••••••`:`sk-...`,className:`w-full pr-8`}),C&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>U(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,$.jsx)(Y,{name:`close`,className:`w-3.5 h-3.5`})})]})}),(0,$.jsx)(Z,{label:t(`settings.voice.page.field.model`),children:(0,$.jsx)(`div`,{className:`relative w-full`,children:(0,$.jsx)(En,{type:`text`,value:w,onChange:e=>re(e.target.value),placeholder:`deepdml/faster-whisper-large-v3-turbo-ct2`,className:`w-full`})})}),(0,$.jsx)(Z,{label:t(`settings.voice.page.field.language`),description:t(`settings.voice.page.field.sttLanguageHint`),children:(0,$.jsx)(`div`,{className:`relative w-full`,children:(0,$.jsx)(En,{type:`text`,value:E,onChange:e=>ae(e.target.value),placeholder:`auto`,className:`w-full`})})})]})]})]})})]})},Gm=e=>{let t=(0,qi.c)(45),{className:n}=e,{t:r}=He(),i=wr(),a=sr(),o;t[0]===i.data?.providers?o=t[1]:(o=i.data?.providers??[],t[0]=i.data?.providers,t[1]=o);let s=o,c=i.data?.selectedId??null,l=dr(i.data),u;t[2]!==s||t[3]!==c||t[4]!==a||t[5]!==r?(u=e=>{!s.some(t=>t.id===e)||e===c||a.mutate(e,{onError:()=>{q.error(r(`settings.yuri.browserProvider.toast.selectFailed`))}})},t[2]=s,t[3]=c,t[4]=a,t[5]=r,t[6]=u):u=t[6];let d=ze(u);if(!l)return null;let f;t[7]!==s||t[8]!==c?(f=s.find(e=>e.id===c)??null,t[7]=s,t[8]=c,t[9]=f):f=t[9];let p=f,m;t[10]===r?m=t[11]:(m=r(`settings.yuri.browserProvider.label`),t[10]=r,t[11]=m);let h;t[12]===r?h=t[13]:(h=r(`settings.yuri.browserProvider.info`),t[12]=r,t[13]=h);let g;t[14]===r?g=t[15]:(g=r(`settings.yuri.browserProvider.aria`),t[14]=r,t[15]=g);let _=p?.id,v=a.isPending,y;t[16]===r?y=t[17]:(y=r(`settings.yuri.browserProvider.aria`),t[16]=r,t[17]=y);let b;t[18]===r?b=t[19]:(b=r(`settings.yuri.browserProvider.placeholder`),t[18]=r,t[19]=b);let x;t[20]!==p?.name||t[21]!==r?(x=p?.name??r(`settings.yuri.browserProvider.placeholder`),t[20]=p?.name,t[21]=r,t[22]=x):x=t[22];let S;t[23]!==b||t[24]!==x?(S=(0,$.jsx)(Tn,{placeholder:b,children:x}),t[23]=b,t[24]=x,t[25]=S):S=t[25];let C;t[26]!==S||t[27]!==y?(C=(0,$.jsx)(bn,{className:`yuri-settings-inline-value w-fit max-w-full`,"aria-label":y,children:S}),t[26]=S,t[27]=y,t[28]=C):C=t[28];let w;t[29]===s?w=t[30]:(w=s.map(Km),t[29]=s,t[30]=w);let T;t[31]===w?T=t[32]:(T=(0,$.jsx)(xn,{children:w}),t[31]=w,t[32]=T);let E;t[33]!==d||t[34]!==a.isPending||t[35]!==C||t[36]!==T||t[37]!==_?(E=(0,$.jsxs)(Cn,{value:_,onValueChange:d,disabled:v,children:[C,T]}),t[33]=d,t[34]=a.isPending,t[35]=C,t[36]=T,t[37]=_,t[38]=E):E=t[38];let D;return t[39]!==n||t[40]!==E||t[41]!==m||t[42]!==h||t[43]!==g?(D=(0,$.jsx)(di,{itemId:`sessions.browser-provider`,label:m,description:h,descriptionPlacement:`outside`,groupClassName:n,ariaLabel:g,children:E}),t[39]=n,t[40]=E,t[41]=m,t[42]=h,t[43]=g,t[44]=D):D=t[44],D};function Km(e){return(0,$.jsx)(vn,{value:e.id,children:e.name},e.id)}var qm=()=>{let{t:e}=He(),[t,n]=Q.useState(``),[r,i]=Q.useState(!0),[a,o]=Q.useState(!1),s=W(e=>e.showOpenCodeUpdateNotifications),c=W(e=>e.setShowOpenCodeUpdateNotifications);Q.useEffect(()=>{let e=!1;return(async()=>{try{let t=await p(`/api/config/settings`,{method:`GET`,headers:{Accept:`application/json`}});if(!t.ok)return;let r=await t.json().catch(()=>null);if(e||!r)return;let i=typeof r.opencodeBinary==`string`?r.opencodeBinary.trim():``;n(i)}catch{}finally{e||i(!1)}})(),()=>{e=!0}},[]);let l=Q.useCallback(async()=>{if(!(typeof window>`u`)&&E())try{let e=await j();e.success&&e.path&&e.path.trim().length>0&&n(e.path.trim())}catch{}},[]),u=Q.useCallback(async()=>{o(!0);try{let n=t.trim(),r=n.length>=2&&(n.startsWith(`"`)&&n.endsWith(`"`)||n.startsWith(`'`)&&n.endsWith(`'`))?n.slice(1,-1).trim():n;await O({opencodeBinary:r}),await wt({message:e(`settings.yuri.opencodeCli.actions.restartingOpenCode`),mode:`projects`,scopes:[`all`]})}finally{o(!1)}},[e,t]),d=Q.useCallback(e=>{c(e),O({showOpenCodeUpdateNotifications:e})},[c]);return(0,$.jsxs)(X,{actions:(0,$.jsx)(K,{type:`button`,size:`sm`,onClick:u,disabled:r||a,"aria-busy":a,children:e(a?`settings.common.actions.saving`:`settings.yuri.opencodeCli.actions.saveAndReload`)}),label:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:e(`settings.yuri.opencodeCli.title`)}),(0,$.jsxs)(kn,{children:[(0,$.jsx)(Dn,{asChild:!0,children:(0,$.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 cursor-help text-muted-foreground/60`})}),(0,$.jsxs)(On,{sideOffset:8,className:`max-w-xs`,children:[e(`settings.yuri.opencodeCli.tooltipPrefix`),` `,(0,$.jsx)(`code`,{className:`font-mono text-xs`,children:`opencode`}),e(`settings.yuri.opencodeCli.tooltipSuffix`)]})]})]}),description:(0,$.jsxs)($.Fragment,{children:[e(`settings.yuri.opencodeCli.tipPrefix`),` `,(0,$.jsx)(`span`,{className:`font-mono`,children:`OPENCODE_BINARY`}),` `,e(`settings.yuri.opencodeCli.tipMiddle`),` `,(0,$.jsx)(`span`,{className:`font-mono`,children:`~/.config/yuri/settings.json`}),`.`]}),children:[(0,$.jsx)(Z,{itemId:`sessions.opencode-binary`,label:e(`settings.yuri.opencodeCli.field.binaryPath`),children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center justify-end gap-2`,children:[(0,$.jsx)(En,{value:t,onChange:e=>n(e.target.value),placeholder:e(`settings.yuri.opencodeCli.field.binaryPathPlaceholder`),disabled:r||a,className:`h-7 min-w-0 flex-1 font-mono text-xs`}),(0,$.jsx)(K,{type:`button`,variant:`outline`,size:`xs`,onClick:l,disabled:r||a||!E(),className:`h-7 w-7 p-0`,"aria-label":e(`settings.yuri.opencodeCli.actions.browseAria`),title:e(`settings.yuri.opencodeCli.actions.browse`),children:(0,$.jsx)(Y,{name:`folder`,className:`h-4 w-4`})})]})}),(0,$.jsxs)(`label`,{"data-settings-item":`sessions.opencode-update-notifications`,className:`yuri-settings-group-row yuri-settings-split-row cursor-pointer`,children:[(0,$.jsx)(`div`,{className:`yuri-settings-split-row-copy`,children:(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e(`settings.yuri.opencodeCli.field.showUpdateNotifications`)})}),(0,$.jsx)(`div`,{className:`yuri-settings-split-row-control`,children:(0,$.jsx)(gn,{checked:s,onChange:d,ariaLabel:e(`settings.yuri.opencodeCli.field.showUpdateNotificationsAria`)})})]})]})},Jm=[{id:`auto`,labelKey:`settings.yuri.desktopNetwork.option.windowControlsAuto`},{id:`left`,labelKey:`settings.yuri.desktopNetwork.option.windowControlsLeft`},{id:`right`,labelKey:`settings.yuri.desktopNetwork.option.windowControlsRight`}],Ym=()=>{let{t:e}=He(),t=Q.useCallback(t=>e(t),[e]),n=E()&&m(),r=x(),i=W(e=>e.desktopWindowControlsPosition),a=W(e=>e.setDesktopWindowControlsPosition),[o,s]=Q.useState(!1),[c,l]=Q.useState(!1),[u,d]=Q.useState(!1),[f,p]=Q.useState(!1),[h,g]=Q.useState(!1),[_,v]=Q.useState(!1),[b,C]=Q.useState(!1),[w,D]=Q.useState(!1),[k,A]=Q.useState(!1),[j,N]=Q.useState(null);Q.useEffect(()=>{if(!n){s(!1);return}let e=!1;return(async()=>{let t=await y();e||(s(t?.supported===!0),l(t?.enabled===!0))})(),()=>{e=!0}},[n]),Q.useEffect(()=>{if(!n){p(!1);return}let e=!1;return(async()=>{let t=await M();e||(p(t?.supported===!0),g(t?.enabled===!0))})(),()=>{e=!0}},[n]),Q.useEffect(()=>{if(!n){C(!1);return}let e=!1;return(async()=>{let t=await S();e||(C(t?.supported===!0),D(t?.enabled===!0))})(),()=>{e=!0}},[n]);let P=Q.useCallback(e=>{a(e),O({desktopWindowControlsPosition:e})},[a]),F=Q.useCallback(async()=>{if(!o||u)return;let t=!c;l(t),d(!0),N(null);try{let n=await T(t);if(!n?.supported)throw Error(e(`settings.yuri.desktopNetwork.error.launchAtLoginUnsupported`));l(n.enabled)}catch(n){l(!t),N(n instanceof Error?n.message:e(`settings.yuri.desktopNetwork.error.launchAtLoginSaveFailed`))}finally{d(!1)}},[u,c,o,e]),I=Q.useCallback(async()=>{if(!f||_)return;let t=!h;g(t),v(!0),N(null);try{let n=await R(t);if(!n)throw Error(e(`settings.yuri.desktopNetwork.error.minimizeToTraySaveFailed`));if(!n.supported)throw Error(e(`settings.yuri.desktopNetwork.error.minimizeToTrayUnsupported`));g(n.enabled)}catch(n){g(!t),N(n instanceof Error?n.message:e(`settings.yuri.desktopNetwork.error.minimizeToTraySaveFailed`))}finally{v(!1)}},[_,h,f,e]),L=Q.useCallback(async()=>{if(!b||k)return;let t=!w;D(t),A(!0),N(null);try{let n=await z(t);if(!n?.supported)throw Error(e(`settings.yuri.desktopNetwork.error.keepAwakeUnsupported`));D(n.enabled)}catch(n){D(!t),N(n instanceof Error?n.message:e(`settings.yuri.desktopNetwork.error.keepAwakeSaveFailed`))}finally{A(!1)}},[k,w,b,e]);return!n&&!r?null:(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[r?(0,$.jsx)(X,{label:e(`settings.yuri.desktopNetwork.field.windowControlsPosition`),children:(0,$.jsx)(Z,{itemId:`sessions.desktop-window-controls-position`,label:e(`settings.yuri.desktopNetwork.field.windowControlsPosition`),description:e(`settings.yuri.desktopNetwork.field.windowControlsPositionDescription`),children:(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,role:`group`,"aria-label":e(`settings.yuri.desktopNetwork.field.windowControlsPositionAria`),children:Jm.map(e=>(0,$.jsx)(K,{type:`button`,variant:`chip`,size:`xs`,className:`!font-normal`,"aria-pressed":i===e.id,onClick:()=>P(e.id),children:t(e.labelKey)},e.id))})})}):null,!n||!(o||f||b||j)?null:(0,$.jsxs)(X,{label:e(`settings.yuri.desktopNetwork.title`),children:[o?(0,$.jsxs)(`div`,{"data-settings-item":`sessions.desktop-launch-at-login`,className:`yuri-settings-group-row yuri-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,onClick:F,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),F())},children:[(0,$.jsxs)(`div`,{className:`yuri-settings-split-row-copy`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.yuri.desktopNetwork.field.launchAtLogin`)}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:e(`settings.yuri.desktopNetwork.field.launchAtLoginDescription`)})]}),(0,$.jsx)(`div`,{className:`yuri-settings-split-row-control`,children:(0,$.jsx)(gn,{checked:c,onChange:F,ariaLabel:e(`settings.yuri.desktopNetwork.field.launchAtLoginAria`),disabled:u})})]}):null,f?(0,$.jsxs)(`div`,{"data-settings-item":`sessions.desktop-minimize-to-tray`,className:`yuri-settings-group-row yuri-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,onClick:I,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),I())},children:[(0,$.jsxs)(`div`,{className:`yuri-settings-split-row-copy`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.yuri.desktopNetwork.field.minimizeToTray`)}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:e(`settings.yuri.desktopNetwork.field.minimizeToTrayDescription`)})]}),(0,$.jsx)(`div`,{className:`yuri-settings-split-row-control`,children:(0,$.jsx)(gn,{checked:h,onChange:I,ariaLabel:e(`settings.yuri.desktopNetwork.field.minimizeToTrayAria`),disabled:_})})]}):null,b?(0,$.jsxs)(`div`,{"data-settings-item":`sessions.desktop-keep-awake`,className:`yuri-settings-group-row yuri-settings-split-row group cursor-pointer`,role:`button`,tabIndex:0,onClick:L,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),L())},children:[(0,$.jsxs)(`div`,{className:`yuri-settings-split-row-copy`,children:[(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:e(`settings.yuri.desktopNetwork.field.keepAwake`)}),(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground`,children:e(`settings.yuri.desktopNetwork.field.keepAwakeDescription`)})]}),(0,$.jsx)(`div`,{className:`yuri-settings-split-row-control`,children:(0,$.jsx)(gn,{checked:w,onChange:L,ariaLabel:e(`settings.yuri.desktopNetwork.field.keepAwakeAria`),disabled:k})})]}):null,j?(0,$.jsx)(`div`,{className:`yuri-settings-group-row typography-meta text-[var(--status-error)]`,children:j}):null]})]})},Xm=new Set([`shift`,`control`,`alt`,`meta`]),Zm=e=>{if(Xm.has(e.key.toLowerCase()))return null;let t=[];(e.metaKey||e.ctrlKey)&&t.push(`mod`),e.shiftKey&&t.push(`shift`),e.altKey&&t.push(`alt`);let n=Ar(e.key);return n?(t.push(n),Qn(t.join(`+`))):null},Qm=()=>{let e=(0,qi.c)(59),{t}=He(),n;e[0]===t?n=e[1]:(n=e=>t(e),e[0]=t,e[1]=n);let r=n,i=W($m),a=W(eh),o=W(th),s=W(nh),c;if(e[2]===Symbol.for(`react.memo_cache_sentinel`)){bb0:{let e=pr();if(!N()){c=e;break bb0}c=e.filter(rh)}e[2]=c}else c=e[2];let l=c,u;e[3]===r?u=e[4]:(u=(e,t)=>{let n=`settings.yuri.keyboardShortcuts.action.${e}.label`,i=r(n);return i===n?t:i},e[3]=r,e[4]=u);let d=u,[f,p]=Q.useState(null),m;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(m={},e[5]=m):m=e[5];let[h,g]=Q.useState(m),[_,v]=Q.useState(``),[y,b]=Q.useState(``),[x,S]=Q.useState(null),C=ih,w;e[6]===i?w=e[7]:(w=(e,t)=>{let n=Qn(t);for(let t of l){if(t.id===e)continue;let r=fr(t.id,i);if(Qn(r)===n)return t.id}return null},e[6]=i,e[7]=w);let T=w,E;e[8]!==T||e[9]!==a||e[10]!==i||e[11]!==t?(E=(e,n)=>{let r=Qn(n),o=T(e,r);if(o){S({actionId:e,combo:r,conflictActionId:o}),v(``);return}let s={...i,[e]:r};a(e,r),C(s),S(null),v(``),b(or(r)?t(`settings.yuri.keyboardShortcuts.warning.riskyBrowserShortcut`):``),g(t=>{let n={...t};return delete n[e],n})},e[8]=T,e[9]=a,e[10]=i,e[11]=t,e[12]=E):E=e[12];let D=E,O;e[13]!==x||e[14]!==a||e[15]!==i||e[16]!==t?(O=()=>{if(!x)return;let e={...i,[x.conflictActionId]:lr,[x.actionId]:x.combo};a(x.conflictActionId,lr),a(x.actionId,x.combo),C(e),S(null),v(``),b(or(x.combo)?t(`settings.yuri.keyboardShortcuts.warning.riskyBrowserShortcut`):``),g(e=>{let t={...e};return delete t[x.actionId],t})},e[13]=x,e[14]=a,e[15]=i,e[16]=t,e[17]=O):O=e[17];let k=O,A;e[18]!==o||e[19]!==i?(A=e=>{let t={...i};delete t[e],o(e),C(t),g(t=>{let n={...t};return delete n[e],n}),S(null),v(``),b(``)},e[18]=o,e[19]=i,e[20]=A):A=e[20];let j=A,M;e[21]===t?M=e[22]:(M=t(`settings.yuri.keyboardShortcuts.title`),e[21]=t,e[22]=M);let P;e[23]===M?P=e[24]:(P=(0,$.jsx)(`span`,{children:M}),e[23]=M,e[24]=P);let F;e[25]===s?F=e[26]:(F=()=>{s(),C({}),g({}),S(null),v(``),b(``)},e[25]=s,e[26]=F);let I;e[27]===t?I=e[28]:(I=t(`settings.yuri.keyboardShortcuts.actions.resetAll`),e[27]=t,e[28]=I);let L;e[29]!==F||e[30]!==I?(L=(0,$.jsx)(K,{type:`button`,variant:`outline`,size:`xs`,className:`!font-normal`,onClick:F,children:I}),e[29]=F,e[30]=I,e[31]=L):L=e[31];let R;e[32]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,$.jsx)(Dn,{asChild:!0,children:(0,$.jsx)(Y,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),e[32]=R):R=e[32];let z;e[33]===t?z=e[34]:(z=t(`settings.yuri.keyboardShortcuts.tooltip`),e[33]=t,e[34]=z);let B;e[35]===z?B=e[36]:(B=(0,$.jsxs)(kn,{children:[R,(0,$.jsx)(On,{sideOffset:8,className:`max-w-xs`,children:z})]}),e[35]=z,e[36]=B);let V;e[37]!==L||e[38]!==B||e[39]!==P?(V=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[P,L,B]}),e[37]=L,e[38]=B,e[39]=P,e[40]=V):V=e[40];let ee;e[41]!==k||e[42]!==_||e[43]!==x||e[44]!==t||e[45]!==y?(ee=(_||y||x)&&(0,$.jsxs)(`div`,{className:`mb-2 space-y-2 px-1`,children:[x&&(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] p-3 flex flex-col sm:flex-row sm:items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`typography-meta text-foreground`,children:t(`settings.yuri.keyboardShortcuts.overwritePrompt`)}),(0,$.jsxs)(`div`,{className:`flex gap-2 shrink-0`,children:[(0,$.jsx)(K,{type:`button`,size:`xs`,className:`!font-normal`,onClick:k,children:t(`settings.yuri.keyboardShortcuts.actions.overwrite`)}),(0,$.jsx)(K,{type:`button`,size:`xs`,className:`!font-normal`,variant:`ghost`,onClick:()=>S(null),children:t(`settings.common.actions.cancel`)})]})]}),_&&(0,$.jsx)(`div`,{className:`rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] p-3 typography-meta text-foreground`,children:_}),y&&(0,$.jsx)(`div`,{className:`rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] p-3 typography-meta text-foreground`,children:y})]}),e[41]=k,e[42]=_,e[43]=x,e[44]=t,e[45]=y,e[46]=ee):ee=e[46];let H;e[47]!==d||e[48]!==f||e[49]!==h||e[50]!==j||e[51]!==D||e[52]!==i||e[53]!==t?(H=l.map(e=>{let n=fr(e.id,i),r=h[e.id],a=r??n,o=typeof r==`string`&&Qn(r)!==Qn(n);return(0,$.jsxs)(Z,{label:d(e.id,e.label),children:[(0,$.jsx)(En,{readOnly:!0,value:f===e.id?t(`settings.yuri.keyboardShortcuts.field.pressKeys`):yr(a),onFocus:()=>{p(e.id),v(``)},onBlur:()=>{f===e.id&&p(null)},onKeyDown:t=>{if(t.preventDefault(),t.stopPropagation(),t.key===`Escape`){p(null);return}let n=Zm(t);n&&(g(t=>({...t,[e.id]:n})),p(null),S(null),v(``))},className:`w-40 min-w-0 typography-ui-label text-right`}),(0,$.jsx)(K,{type:`button`,variant:`secondary`,size:`xs`,className:`!font-normal`,onClick:()=>{let n=h[e.id];if(!n){v(t(`settings.yuri.keyboardShortcuts.error.captureFirst`));return}D(e.id,n)},disabled:!o,children:t(`settings.common.actions.saveChanges`)}),(0,$.jsx)(K,{type:`button`,size:`xs`,className:`!font-normal`,variant:`ghost`,onClick:()=>j(e.id),children:t(`settings.common.actions.reset`)})]},e.id)}),e[47]=d,e[48]=f,e[49]=h,e[50]=j,e[51]=D,e[52]=i,e[53]=t,e[54]=H):H=e[54];let te;return e[55]!==V||e[56]!==ee||e[57]!==H?(te=(0,$.jsxs)(X,{itemId:`shortcuts.keyboard-shortcuts`,label:V,children:[ee,H]}),e[55]=V,e[56]=ee,e[57]=H,e[58]=te):te=e[58],te};function $m(e){return e.shortcutOverrides}function eh(e){return e.setShortcutOverride}function th(e){return e.clearShortcutOverride}function nh(e){return e.resetAllShortcutOverrides}function rh(e){return e.id!==`toggle_prompt_navigator`}function ih(e){O({shortcutOverrides:e})}var ah=()=>{let e=(0,qi.c)(2),[t,n]=Q.useState(0),i,a;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>r(()=>n(hh)),a=[],e[0]=i,e[1]=a):(i=e[0],a=e[1]),Q.useEffect(i,a),t},oh=e=>{let t=(0,qi.c)(25),{section:n,flowMobile:r}=e,i=r!==void 0&&r,{isMobile:a}=Pr();ah();let o;t[0]===a?o=t[1]:(o=a&&k(),t[0]=a,t[1]=o);let s=o,c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=N(),t[2]=c):c=t[2];let l=c,u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=E()&&(m()||x()),t[3]=u):u=t[3];let d=u;if(!n){let e;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Yp,{}),t[4]=e):e=t[4];let n;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{className:`yuri-settings-page-section`,children:(0,$.jsx)(gm,{})}),t[5]=n):n=t[5];let r,i,a,o;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(`div`,{className:`yuri-settings-page-section`,children:(0,$.jsx)(xm,{})}),a=d&&(0,$.jsx)(`div`,{className:`yuri-settings-page-section`,children:(0,$.jsx)(Ym,{})}),o=!l&&(0,$.jsx)(`div`,{className:`yuri-settings-page-section`,children:(0,$.jsx)(qm,{})}),r=(0,$.jsx)(Gm,{className:`yuri-settings-page-section`}),t[6]=r,t[7]=i,t[8]=a,t[9]=o):(r=t[6],i=t[7],a=t[8],o=t[9]);let c;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(`div`,{className:`yuri-settings-page-section`,children:(0,$.jsx)(om,{})}),t[10]=c):c=t[10];let u;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(`div`,{className:`yuri-settings-page-section`,children:(0,$.jsx)(mm,{})}),t[11]=u):u=t[11];let f;t[12]===s?f=t[13]:(f=s&&(0,$.jsx)(`div`,{className:`yuri-settings-page-section`,children:(0,$.jsx)(ta,{})}),t[12]=s,t[13]=f);let p;return t[14]===f?p=t[15]:(p=(0,$.jsx)(Rr,{outerClassName:`h-full`,className:`w-full`,children:(0,$.jsxs)(`div`,{className:`yuri-settings-page-content yuri-page-body mx-auto max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[e,n,i,a,o,r,c,u,f]})}),t[14]=f,t[15]=p),p}let f;t[16]!==i||t[17]!==n?(f=()=>{switch(n){case`visual`:return(0,$.jsx)(ch,{mobile:i});case`chat`:return(0,$.jsx)(lh,{});case`sessions`:return(0,$.jsx)(uh,{});case`summary-ai`:return(0,$.jsx)(xm,{});case`shortcuts`:return(0,$.jsx)(sh,{});case`git`:return(0,$.jsx)(dh,{});case`github`:return(0,$.jsx)(fh,{});case`notifications`:return(0,$.jsx)(ph,{});case`voice`:return(0,$.jsx)(mh,{});default:return null}},t[16]=i,t[17]=n,t[18]=f):f=t[18];let p=f,h;t[19]===p?h=t[20]:(h=p(),t[19]=p,t[20]=h);let g;t[21]===h?g=t[22]:(g=(0,$.jsx)(`div`,{className:`yuri-settings-page-content yuri-page-body mx-auto max-w-3xl p-3 sm:p-6 sm:pt-8`,children:h}),t[21]=h,t[22]=g);let _=g;if(i)return _;let v;return t[23]===_?v=t[24]:(v=(0,$.jsx)(Rr,{outerClassName:`h-full`,className:`w-full`,children:_}),t[23]=_,t[24]=v),v},sh=()=>{let e=(0,qi.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Qm,{}),e[0]=t):t=e[0],t},ch=e=>{let t=(0,qi.c)(5),{mobile:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=N(),t[0]=r):r=t[0];let i=r,a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=i?[]:[`weekStart`],t[1]=a):a=t[1];let o;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=[`theme`,`sidebarBrand`,`pwaInstallName`,`pwaOrientation`,`mobileKeyboardMode`,`timeFormat`,...a,`iosNativeUi`,`fontSize`,`codeFontSize`,`terminalFontSize`,`editorFontSize`,`fileEditorKeymap`,`spacing`,`inputBarOffset`,`expandedEditorToolbar`,...i?[]:[`terminalQuickKeys`],`reportUsage`],t[2]=o):o=t[2];let s;return t[3]===n?s=t[4]:(s=(0,$.jsx)(Yp,{mobile:n,visibleSettings:o}),t[3]=n,t[4]=s),s},lh=()=>{let e=(0,qi.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Yp,{visibleSettings:[`chatRenderMode`,`messageTransport`,`diffLayout`,`followUpBehavior`,`sessionGoal`,`questionAutoDelegate`,`sessionAssist`,`subagentReadOnlyBanner`,`reasoning`,`collapsibleUserMessages`,`showAssistantTps`,`persistDraft`,`inputSpellcheck`]}),e[0]=t):t=e[0],t},uh=()=>{let e=(0,qi.c)(8),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=N(),e[0]=t):t=e[0];let n=t;ah();let r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=E()&&(m()||x()),e[1]=r):r=e[1];let i=r,a,o,s,c;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,$.jsx)(gm,{}),o=i&&(0,$.jsx)(`div`,{className:`yuri-settings-page-section`,children:(0,$.jsx)(Ym,{})}),s=!n&&(0,$.jsx)(`div`,{className:`yuri-settings-page-section`,children:(0,$.jsx)(qm,{})}),c=(0,$.jsx)(Gm,{}),e[2]=a,e[3]=o,e[4]=s,e[5]=c):(a=e[2],o=e[3],s=e[4],c=e[5]);let l;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(`div`,{className:`yuri-settings-page-section`,children:(0,$.jsx)(om,{})}),e[6]=l):l=e[6];let u;return e[7]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[a,o,s,c,l,(0,$.jsx)(`div`,{className:`yuri-settings-page-section`,children:(0,$.jsx)(mm,{})})]}),e[7]=u):u=e[7],u},dh=()=>{let e=(0,qi.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:`yuri-settings-section-stack`,children:(0,$.jsx)(xp,{})}),e[0]=t):t=e[0],t},fh=()=>{let e=(0,qi.c)(1);if(N())return null;let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Sp,{}),e[0]=t):t=e[0],t},ph=()=>{let e=(0,qi.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(wm,{}),e[0]=t):t=e[0],t},mh=()=>{let e=(0,qi.c)(1);if(N())return null;let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Hm,{}),e[0]=t):t=e[0],t};function hh(e){return e+1}var gh=()=>{let e=(0,qi.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(ql,{children:(0,$.jsx)(gi,{mode:`page`})}),e[0]=t):t=e[0],t},_h=[{id:`chat.question-auto-delegate`,page:`chat`,titleKey:`settings.chat.questionDelegate.label`,descriptionKey:`settings.chat.questionDelegate.description`,keywords:[`question`,`auto`,`delegate`,`30`,`subagent`,`托管`,`倒计时`]},{id:`instances.manage`,page:`instances`,titleKey:`mobile.settings.switchInstance`,keywords:[`instance`,`server`,`connection`,`switch`],isAvailable:e=>e.isMobile},{id:`global-config.editor`,page:`global-config`,titleKey:`settings.globalConfig.title`,descriptionKey:`settings.globalConfig.description`,keywords:[`opencode.json`,`opencode.jsonc`,`oh-my-opencode-slim`,`oh-my-openagent`,`json`,`jsonc`]},{id:`appearance.language`,page:`appearance`,titleKey:`settings.appearance.language.label`,descriptionKey:`settings.appearance.language.description`,keywords:[`locale`,`translation`,`ui language`]},{id:`appearance.time-format`,page:`appearance`,titleKey:`settings.yuri.visual.field.timeFormat`,keywords:[`clock`,`12h`,`24h`]},{id:`appearance.week-start`,page:`appearance`,titleKey:`settings.yuri.visual.field.weekStartsOn`,keywords:[`calendar`,`monday`,`sunday`],isAvailable:e=>!e.isVSCode},{id:`appearance.light-theme`,page:`appearance`,titleKey:`settings.yuri.visual.field.lightTheme`,keywords:[`theme`,`color`,`light mode`],isAvailable:e=>!e.isVSCode},{id:`appearance.dark-theme`,page:`appearance`,titleKey:`settings.yuri.visual.field.darkTheme`,keywords:[`theme`,`color`,`dark mode`],isAvailable:e=>!e.isVSCode},{id:`appearance.window-transparency`,page:`appearance`,titleKey:`settings.yuri.visual.field.macVibrancy`,descriptionKey:`settings.yuri.visual.field.macVibrancyHint`,keywords:[`transparent`,`transparency`,`vibrancy`,`blur`,`macos`,`opaque`],isAvailable:e=>e.isDesktopLocalOrigin},{id:`appearance.dock-badge`,page:`appearance`,titleKey:`settings.yuri.visual.field.dockBadge`,descriptionKey:`settings.yuri.visual.field.dockBadgeHint`,keywords:[`dock`,`badge`,`unread`,`unseen`,`counter`,`count`,`notification`,`macos`],isAvailable:e=>e.isMac},{id:`appearance.sidebar-brand`,page:`appearance`,titleKey:`settings.yuri.visual.field.sidebarBrand`,descriptionKey:`settings.yuri.visual.field.sidebarBrandHint`,keywords:[`logo`,`brand`,`wordmark`,`sidebar`]},{id:`appearance.pwa-install-name`,page:`appearance`,titleKey:`settings.yuri.visual.field.installAppName`,descriptionKey:`settings.yuri.visual.field.installAppNameHint`,keywords:[`pwa`,`installed app`],isAvailable:e=>e.isWeb&&!e.isDesktop&&!e.isVSCode},{id:`appearance.pwa-orientation`,page:`appearance`,titleKey:`settings.yuri.visual.field.installOrientation`,descriptionKey:`settings.yuri.visual.field.installOrientationHint`,keywords:[`pwa`,`portrait`,`landscape`],isAvailable:e=>e.isWeb&&!e.isDesktop&&!e.isVSCode},{id:`appearance.mobile-keyboard-mode`,page:`appearance`,titleKey:`settings.yuri.visual.field.mobileKeyboardMode`,descriptionKey:`settings.yuri.visual.field.mobileKeyboardModeHint`,keywords:[`mobile`,`keyboard`,`resize`],isAvailable:e=>e.isMobile&&e.isWeb&&!e.isDesktop&&!e.isVSCode},{id:`appearance.ios-native-ui`,page:`appearance`,titleKey:`settings.yuri.visual.field.iosNativeUi`,descriptionKey:`settings.yuri.visual.field.iosNativeUiHint`,keywords:[`ios`,`native`,`webview`,`composer`,`tab bar`,`live activity`],isAvailable:()=>Vr()},{id:`appearance.interface-font-size`,page:`appearance`,titleKey:`settings.yuri.visual.field.interfaceFontSize`,keywords:[`font`,`text size`,`ui scale`]},{id:`appearance.code-font-size`,page:`appearance`,titleKey:`settings.yuri.visual.field.codeFontSize`,keywords:[`code`,`font`,`text size`,`diff`]},{id:`appearance.terminal-font-size`,page:`appearance`,titleKey:`settings.yuri.visual.field.terminalFontSize`,keywords:[`terminal`,`font`,`text size`]},{id:`appearance.editor-font-size`,page:`appearance`,titleKey:`settings.yuri.visual.field.editorFontSize`,keywords:[`editor`,`font`,`text size`,`code`]},{id:`appearance.spacing-density`,page:`appearance`,titleKey:`settings.yuri.visual.field.spacingDensity`,keywords:[`density`,`compact`,`comfortable`,`spacing`]},{id:`appearance.input-bar-offset`,page:`appearance`,titleKey:`settings.yuri.visual.field.inputBarOffset`,descriptionKey:`settings.yuri.visual.field.inputBarOffsetTooltip`,keywords:[`input`,`home bar`,`offset`]},{id:`appearance.expanded-editor-toolbar`,page:`appearance`,titleKey:`settings.yuri.visual.field.expandedEditorToolbar`,keywords:[`editor`,`toolbar`,`tabs`,`docked`,`files`]},{id:`appearance.file-editor-keymap`,page:`appearance`,titleKey:`settings.yuri.visual.field.fileEditorKeymap`,keywords:[`editor`,`vim`,`keymap`]},{id:`appearance.terminal-quick-keys`,page:`appearance`,titleKey:`settings.yuri.visual.field.terminalQuickKeys`,descriptionKey:`settings.yuri.visual.field.terminalQuickKeysTooltip`,keywords:[`terminal`,`keyboard`,`esc`,`ctrl`,`arrows`],isAvailable:e=>!e.isMobile&&!e.isDesktop&&!e.isVSCode},{id:`about.check-updates`,page:`about`,titleKey:`settings.yuri.about.actions.checkForUpdates`,keywords:[`updates`,`version`,`ota`]},{id:`about.feedback`,page:`about`,titleKey:`settings.yuri.about.actions.submitFeedback`,keywords:[`feedback`,`issues`,`bugs`,`github`]},{id:`about.beta-updates`,page:`about`,titleKey:`settings.yuri.about.betaUpdates.label`,descriptionKey:`settings.yuri.about.betaUpdates.description`,keywords:[`beta`,`updates`,`channel`,`ota`],isAvailable:e=>e.isDesktop||ve()},{id:`about.diagnostics`,page:`about`,titleKey:`settings.yuri.about.diagnostics.label`,keywords:[`diagnostics`,`logs`,`feat`,`transcript`,`task`]},{id:`about.export-diagnostics`,page:`about`,titleKey:`settings.yuri.about.diagnostics.export`,keywords:[`diagnostics`,`logs`,`export`,`feat`,`transcript`,`task`],isAvailable:()=>xt()},{id:`appearance.usage-reports`,page:`appearance`,titleKey:`settings.yuri.visual.field.sendAnonymousUsageReports`,descriptionKey:`settings.yuri.visual.field.sendAnonymousUsageReportsHint`,keywords:[`telemetry`,`analytics`]},{id:`appearance.transcript-cache`,page:`appearance`,titleKey:`settings.yuri.visual.transcriptCache.label`,descriptionKey:`settings.yuri.visual.transcriptCache.description`,keywords:[`cache`,`local data`,`conversation history`,`transcript`,`privacy`]},{id:`chat.render-mode`,page:`chat`,titleKey:`settings.yuri.visual.section.chatRenderMode`,keywords:[`messages`,`conversation`,`rendering`]},{id:`chat.message-transport`,page:`chat`,titleKey:`settings.yuri.visual.section.messageStreamTransport`,keywords:[`streaming`,`sse`,`websocket`]},{id:`chat.session-assistance`,page:`chat`,titleKey:`settings.yuri.visual.section.sessionAssistance`,keywords:[`title`,`assist`,`subagent`]},{id:`chat.session-title-refresh`,page:`chat`,titleKey:`settings.yuri.visual.field.sessionTitleRefresh`,keywords:[`title`,`rename`,`refresh`,`throttle`,`small model`,`summary`]},{id:`chat.session-goal`,page:`chat`,titleKey:`settings.yuri.visual.field.sessionGoal`,keywords:[`goal`,`objective`,`auto continue`,`small model`],isAvailable:e=>!e.isVSCode},{id:`chat.session-goal-budget`,page:`chat`,titleKey:`settings.yuri.visual.goal.budgetLabel`,keywords:[`goal`,`budget`,`tokens`,`limit`],isAvailable:e=>!e.isVSCode},{id:`chat.reasoning-traces`,page:`chat`,titleKey:`settings.yuri.visual.field.showReasoningTraces`,descriptionKey:`settings.yuri.visual.field.showReasoningTracesHint`,keywords:[`thinking`,`reasoning`,`mobile`,`fetch time`]},{id:`chat.reasoning`,page:`chat`,titleKey:`settings.yuri.visual.section.reasoning`,keywords:[`thinking`,`traces`]},{id:`chat.diff-layout`,page:`chat`,titleKey:`settings.yuri.visual.section.diffLayout`,keywords:[`diff`,`inline`,`side by side`,`layout`],isAvailable:e=>!e.isVSCode},{id:`chat.collapsible-user-messages`,page:`chat`,titleKey:`settings.yuri.visual.field.collapsibleUserMessages`,keywords:[`collapse`,`expand`,`clamp`,`long messages`,`user messages`]},{id:`chat.message-appearance`,page:`chat`,titleKey:`settings.yuri.visual.section.messageAppearance`,keywords:[`layout`,`messages`,`appearance`]},{id:`chat.inline-assistant-actions`,page:`chat`,titleKey:`settings.yuri.visual.field.showSplitAssistantMessageActions`,descriptionKey:`settings.yuri.visual.field.showSplitAssistantMessageActionsTooltip`,keywords:[`copy`,`read aloud`],isAvailable:()=>!1},{id:`chat.assistant-tps`,page:`chat`,titleKey:`settings.yuri.visual.field.showAssistantTps`,descriptionKey:`settings.yuri.visual.field.showAssistantTpsTooltip`,keywords:[`tps`,`tokens`,`speed`,`rate`,`tok/s`,`throughput`]},{id:`chat.subagent-read-only-banner`,page:`chat`,titleKey:`settings.yuri.visual.field.allowPromptingSubagentSessions`,keywords:[`subagent`,`read only`,`prompt`,`banner`]},{id:`chat.follow-up-behavior`,page:`chat`,titleKey:`settings.yuri.visual.field.followUpBehavior`,descriptionKey:`settings.yuri.visual.field.followUpBehaviorDescription`,keywords:[`follow up`,`queue`,`steer`,`send immediately`]},{id:`chat.persist-drafts`,page:`chat`,titleKey:`settings.yuri.visual.field.persistDraftMessages`,keywords:[`draft`,`message`]},{id:`chat.composer`,page:`chat`,titleKey:`settings.yuri.visual.section.composer`,keywords:[`input`,`draft`,`spellcheck`]},{id:`chat.spellcheck`,page:`chat`,titleKey:`settings.yuri.visual.field.enableSpellcheckInTextInputs`,keywords:[`spelling`,`input`],isAvailable:e=>!e.isMobile},{id:`sessions.default-model`,page:`sessions`,titleKey:`settings.yuri.defaults.field.defaultModel`,keywords:[`model`,`provider`,`new sessions`]},{id:`sessions.default-thinking`,page:`sessions`,titleKey:`settings.yuri.defaults.field.defaultThinking`,keywords:[`thinking`,`reasoning`,`variant`]},{id:`sessions.default-agent`,page:`sessions`,titleKey:`settings.yuri.defaults.field.defaultAgent`,keywords:[`agent`,`new sessions`]},{id:`sessions.browser-provider`,page:`sessions`,titleKey:`settings.yuri.browserProvider.label`,descriptionKey:`settings.yuri.browserProvider.info`,keywords:[`browser`,`extension`,`provider`,`live view`],isAvailable:()=>dr(xr())},{id:`sessions.deletion-dialog`,page:`sessions`,titleKey:`settings.yuri.defaults.field.showDeletionDialog`,keywords:[`delete`,`confirmation`]},{id:`summary-ai.configuration`,page:`summary-ai`,titleKey:`settings.yuri.defaults.summary.title`,descriptionKey:`settings.yuri.defaults.summary.description`,keywords:[`summary`,`commit`,`session title`,`prompt`,`provider`,`custom api`,`base url`,`api token`]},{id:`summary-ai.test-connection`,page:`summary-ai`,titleKey:`settings.yuri.defaults.summary.testConnection`,keywords:[`summary`,`connection`,`test`,`provider`,`api`]},{id:`sessions.auto-cleanup`,page:`sessions`,titleKey:`settings.yuri.sessionRetention.field.enableAutoCleanup`,descriptionKey:`settings.yuri.sessionRetention.tooltip`,keywords:[`retention`,`archive`,`delete`]},{id:`sessions.retention-period`,page:`sessions`,titleKey:`settings.yuri.sessionRetention.field.retentionPeriod`,keywords:[`days`,`cleanup`,`retention`]},{id:`sessions.retention-action`,page:`sessions`,titleKey:`settings.yuri.sessionRetention.field.whenSessionsExpire`,keywords:[`archive`,`delete`,`expire`]},{id:`archived-sessions.manage`,page:`archived-sessions`,titleKey:`settings.yuri.archivedSessions.title`,descriptionKey:`settings.yuri.archivedSessions.description`,keywords:[`archive`,`archived`,`restore`,`preview`,`history`]},{id:`sessions.desktop-launch-at-login`,page:`sessions`,titleKey:`settings.yuri.desktopNetwork.field.launchAtLogin`,descriptionKey:`settings.yuri.desktopNetwork.field.launchAtLoginDescription`,keywords:[`desktop`,`startup`,`login`],isAvailable:e=>e.isDesktopLocalOrigin},{id:`sessions.desktop-window-controls-position`,page:`sessions`,titleKey:`settings.yuri.desktopNetwork.field.windowControlsPosition`,descriptionKey:`settings.yuri.desktopNetwork.field.windowControlsPositionDescription`,keywords:[`desktop`,`window`,`controls`,`minimize`,`maximize`,`close`,`titlebar`,`linux`,`windows`],isAvailable:e=>e.isDesktop&&(e.isWindows||!e.isMac)},{id:`sessions.desktop-minimize-to-tray`,page:`sessions`,titleKey:`settings.yuri.desktopNetwork.field.minimizeToTray`,descriptionKey:`settings.yuri.desktopNetwork.field.minimizeToTrayDescription`,keywords:[`desktop`,`tray`,`system tray`,`minimize`,`close`,`background`,`windows`],isAvailable:e=>e.isDesktopLocalOrigin&&e.isWindows},{id:`sessions.desktop-keep-awake`,page:`sessions`,titleKey:`settings.yuri.desktopNetwork.field.keepAwake`,descriptionKey:`settings.yuri.desktopNetwork.field.keepAwakeDescription`,keywords:[`desktop`,`sleep`,`awake`,`server`,`mobile`,`phone`],isAvailable:e=>e.isDesktopLocalOrigin},{id:`remote-instances.desktop-ui-password`,page:`remote-instances`,titleKey:`settings.yuri.desktopPassword.field.password`,descriptionKey:`settings.yuri.desktopPassword.field.passwordDescription`,keywords:[`desktop`,`password`,`auth`,`login`],isAvailable:e=>e.isDesktopLocalOrigin},{id:`remote-instances.desktop-lan-access`,page:`remote-instances`,titleKey:`settings.yuri.desktopNetwork.field.allowLanAccess`,descriptionKey:`settings.yuri.desktopNetwork.field.allowLanAccessDescription`,keywords:[`desktop`,`lan`,`network`,`phone`,`tablet`],isAvailable:e=>e.isDesktopLocalOrigin},{id:`sessions.opencode-binary`,page:`sessions`,titleKey:`settings.yuri.opencodeCli.field.binaryPath`,keywords:[`opencode`,`cli`,`binary`,`path`],isAvailable:e=>!e.isVSCode},{id:`sessions.opencode-update-notifications`,page:`sessions`,titleKey:`settings.yuri.opencodeCli.field.showUpdateNotifications`,keywords:[`opencode`,`cli`,`updates`],isAvailable:e=>!e.isVSCode},{id:`git.github-account`,page:`git`,titleKey:`settings.github.page.actions.connect`,keywords:[`github`,`account`,`oauth`,`prs`,`issues`]},{id:`git.identities`,page:`git`,titleKey:`settings.gitIdentities.page.section.title`,descriptionKey:`settings.gitIdentities.page.empty.description`,keywords:[`identity`,`profile`,`author`,`email`,`credentials`,`signing`,`commit signing`,`ssh signing`,`gpg`]},{id:`git.changes-view`,page:`git`,titleKey:`settings.yuri.git.changesViewTitle`,keywords:[`changes`,`flat list`,`tree view`]},{id:`git.gitmoji`,page:`git`,titleKey:`settings.yuri.git.enableGitmoji`,keywords:[`commit`,`emoji`]},{id:`git.gitignored-files`,page:`git`,titleKey:`settings.yuri.git.showGitignored`,keywords:[`ignored`,`files`,`gitignore`]},{id:`usage.magpie`,page:`usage`,titleKey:`settings.usage.magpie.url`,descriptionKey:`settings.usage.magpie.description`,keywords:[`magpie`,`quota`,`gateway`]},{id:`usage.header-menu`,page:`usage`,titleKey:`settings.usage.page.options.showInHeader`,descriptionKey:`settings.usage.page.options.showInHeaderTooltip`,keywords:[`quota`,`header`,`dropdown`]},{id:`usage.model-quotas`,page:`usage`,titleKey:`settings.usage.page.section.modelQuotas`,keywords:[`models`,`quota`,`limits`,`tokens`]},{id:`projects.name`,page:`projects`,titleKey:`settings.projects.page.field.projectName`,keywords:[`label`,`display name`,`project metadata`]},{id:`projects.accent-color`,page:`projects`,titleKey:`settings.projects.page.field.accentColor`,keywords:[`color`,`appearance`,`project metadata`]},{id:`projects.icon`,page:`projects`,titleKey:`settings.projects.page.field.projectIcon`,keywords:[`icon`,`favicon`,`upload`,`project metadata`]},{id:`projects.worktree`,page:`projects`,titleKey:`settings.projects.page.section.worktree`,keywords:[`worktree`,`branch`,`repository`]},{id:`projects.worktree.setup.wait`,page:`projects`,titleKey:`settings.yuri.worktrees.setup.waitForCommands`,keywords:[`worktree`,`setup commands`,`bootstrap`,`wait`]},{id:`remote-instances.client-auth`,page:`remote-instances`,titleKey:`settings.remoteInstances.clientAuth.title`,descriptionKey:`settings.remoteInstances.clientAuth.description`,keywords:[`pairing link`,`client token`,`connect desktop`,`remote access`,`relay`,`devices`,`connect from anywhere`],isAvailable:e=>!e.isVSCode},{id:`remote-instances.instances`,page:`remote-instances`,titleKey:`settings.remoteInstances.sidebar.title`,descriptionKey:`settings.remoteInstances.sidebar.description`,keywords:[`import link`,`pairing link`,`connect link`,`ssh`,`remote instance`,`host switcher`],isAvailable:e=>e.isDesktop},{id:`behavior.system-prompt`,page:`behavior`,titleKey:`settings.behavior.page.section.systemPrompt`,descriptionKey:`settings.behavior.page.warning.title`,keywords:[`agents.md`,`global instructions`,`system prompt`]},{id:`behavior.response-style`,page:`behavior`,titleKey:`settings.behavior.page.section.responseStyle`,descriptionKey:`settings.behavior.page.responseStyle.tooltip`,keywords:[`tone`,`concise`,`detailed`,`custom instructions`]},{id:`agents.create`,page:`agents`,titleKey:`settings.agents.page.title.new`,keywords:[`create`,`add`,`new agent`]},{id:`assistants.create`,page:`assistants`,titleKey:`assistants.settings.create`,keywords:[`assistant`,`new`,`add`]},{id:`assistants.name`,page:`assistants`,titleKey:`assistants.settings.name`,keywords:[`assistant`,`name`]},{id:`assistants.default-share`,page:`assistants`,titleKey:`assistants.settings.defaultShare`,keywords:[`share`,`default`,`mobile`]},{id:`assistants.prompt`,page:`assistants`,titleKey:`assistants.settings.defaultPrompt`,keywords:[`prompt`,`instructions`]},{id:`assistants.model`,page:`assistants`,titleKey:`assistants.settings.model`,keywords:[`provider`,`model`]},{id:`assistants.workspace`,page:`assistants`,titleKey:`assistants.settings.workspace`,keywords:[`path`,`directory`,`workspace`]},{id:`agents.name`,page:`agents`,titleKey:`settings.agents.page.field.agentName`,keywords:[`agent`,`name`]},{id:`agents.mode`,page:`agents`,titleKey:`settings.agents.page.field.mode`,descriptionKey:`settings.agents.page.field.modeTooltip`,keywords:[`primary`,`subagent`,`visibility`]},{id:`agents.scope`,page:`agents`,titleKey:`settings.agents.page.field.scope`,keywords:[`scope`,`project`,`user`,`global`]},{id:`agents.model`,page:`agents`,titleKey:`settings.agents.page.field.overrideModel`,keywords:[`model`,`provider`,`variant`]},{id:`agents.system-prompt`,page:`agents`,titleKey:`settings.agents.page.section.systemPrompt`,keywords:[`prompt`,`instructions`]},{id:`agents.permissions`,page:`agents`,titleKey:`settings.agents.page.section.toolPermissions`,keywords:[`tools`,`permissions`,`allow`,`ask`,`deny`]},{id:`commands.create`,page:`commands`,titleKey:`settings.commands.page.title.new`,keywords:[`create`,`add`,`new command`]},{id:`commands.name`,page:`commands`,titleKey:`settings.commands.page.field.commandName`,keywords:[`slash command`,`name`]},{id:`commands.agent`,page:`commands`,titleKey:`settings.commands.page.field.overrideAgent`,keywords:[`agent`,`execution`]},{id:`commands.model`,page:`commands`,titleKey:`settings.agents.page.field.overrideModel`,keywords:[`model`,`provider`]},{id:`commands.template`,page:`commands`,titleKey:`settings.commands.page.section.template`,keywords:[`prompt`,`template`,`arguments`,`shell`,`file`]},{id:`mcp.create`,page:`mcp`,titleKey:`settings.mcp.sidebar.actions.addServerTitle`,keywords:[`create`,`add`,`server`]},{id:`mcp.server`,page:`mcp`,titleKey:`settings.mcp.page.server.title`,keywords:[`server`,`name`,`transport`]},{id:`mcp.command`,page:`mcp`,titleKey:`settings.mcp.page.connection.command`,keywords:[`stdio`,`local`,`command`]},{id:`mcp.environment`,page:`mcp`,titleKey:`settings.mcp.page.env.title`,keywords:[`env`,`variables`,`api key`]},{id:`mcp.advanced`,page:`mcp`,titleKey:`settings.mcp.page.advanced.title`,keywords:[`oauth`,`headers`,`timeout`]},{id:`plugins.create`,page:`plugins`,titleKey:`settings.plugins.sidebar.actions.addTitle`,keywords:[`add`,`plugin`,`npm`,`path`,`file`]},{id:`plugins.spec`,page:`plugins`,titleKey:`settings.plugins.page.field.spec`,keywords:[`npm`,`package`,`path`]},{id:`plugins.options`,page:`plugins`,titleKey:`settings.plugins.page.field.options`,keywords:[`json`,`configuration`]},{id:`plugins.content`,page:`plugins`,titleKey:`settings.plugins.page.field.content`,keywords:[`file`,`code`]},{id:`providers.connect`,page:`providers`,titleKey:`settings.providers.page.connect.title`,keywords:[`add provider`,`connect provider`,`credentials`]},{id:`providers.auth`,page:`providers`,titleKey:`settings.providers.page.auth.title`,keywords:[`api key`,`oauth`,`credentials`]},{id:`providers.connection-details`,page:`providers`,titleKey:`settings.providers.page.connectionDetails.title`,keywords:[`config`,`source`,`disconnect`]},{id:`providers.models`,page:`providers`,titleKey:`settings.providers.page.models.title`,keywords:[`models`,`hide`,`show`]},{id:`skills.create`,page:`skills.installed`,titleKey:`settings.skills.page.title.newSkill`,keywords:[`create`,`add`,`new skill`]},{id:`skills.basic-information`,page:`skills.installed`,titleKey:`settings.skills.page.section.basicInformation`,keywords:[`name`,`location`,`description`]},{id:`skills.instructions`,page:`skills.installed`,titleKey:`settings.skills.page.section.instructions`,keywords:[`markdown`,`skill.md`,`content`]},{id:`skills.supporting-files`,page:`skills.installed`,titleKey:`settings.skills.page.section.supportingFiles`,keywords:[`files`,`resources`]},{id:`skills.catalog.source`,page:`skills.catalog`,titleKey:`settings.skills.catalog.page.section.sourceRepository`,keywords:[`catalog`,`repository`,`source`,`refresh`]},{id:`skills.catalog.search`,page:`skills.catalog`,titleKey:`settings.skills.catalog.shared.field.searchSkillsPlaceholder`,keywords:[`find skills`,`install skills`,`catalog search`]},{id:`skills.catalog.add-catalog`,page:`skills.catalog`,titleKey:`settings.skills.catalog.page.actions.addCatalog`,keywords:[`external repository`,`add source`,`catalog`]},{id:`magic-prompts.visible-prompt`,page:`magic-prompts`,titleKey:`settings.magicPrompts.page.block.visiblePrompt`,keywords:[`prompt text`,`user message`,`template`],isAvailable:e=>!e.isVSCode},{id:`magic-prompts.instructions`,page:`magic-prompts`,titleKey:`settings.magicPrompts.page.block.instructions`,keywords:[`hidden prompt`,`instructions`,`template`],isAvailable:e=>!e.isVSCode},{id:`magic-prompts.reset-overrides`,page:`magic-prompts`,titleKey:`settings.magicPrompts.page.actions.resetAllOverrides`,keywords:[`reset`,`default prompts`,`overrides`],isAvailable:e=>!e.isVSCode},{id:`shortcuts.keyboard-shortcuts`,page:`shortcuts`,titleKey:`settings.yuri.keyboardShortcuts.title`,descriptionKey:`settings.yuri.keyboardShortcuts.tooltip`,keywords:[`keyboard`,`hotkeys`,`bindings`]},{id:`voice.playback`,page:`voice`,titleKey:`settings.voice.page.section.playbackAndSummary`,keywords:[`tts`,`read aloud`,`voice`,`provider`,`speech rate`,`speech pitch`,`speech volume`,`tts input mode`,`markdown`,`volcengine`,`doubao`,`火山`,`豆包`,`seed-tts`,`音色`,`api key`]},{id:`voice.speech-recognition`,page:`voice`,titleKey:`settings.voice.page.section.speechRecognition`,keywords:[`stt`,`dictation`,`voice input`,`transcribe`,`whisper`,`parakeet`,`microphone`,`volcengine`,`doubao`,`火山`,`豆包`,`asr`,`实时字幕`,`识别`,`api key`,`recognition context`,`terminology`,`语境`,`上下文`,`中英文`]},{id:`notifications.delivery`,page:`notifications`,titleKey:`settings.notifications.page.delivery.title`,keywords:[`desktop notifications`,`system notifications`]},{id:`notifications.events`,page:`notifications`,titleKey:`settings.notifications.page.events.title`,keywords:[`completion`,`subtasks`,`errors`,`questions`]},{id:`notifications.push`,page:`notifications`,titleKey:`settings.notifications.page.push.title`,keywords:[`background`,`push`],isAvailable:e=>e.isWeb&&!e.isDesktop&&!e.isVSCode}];function vh(e){return e.trim().toLocaleLowerCase()}function yh({query:e,runtimeCtx:t,visiblePageSlugs:n,t:r,getPageTitle:i}){let a=vh(e);if(!a)return[];let o=n?new Set(n):null,s=a.split(/\s+/).filter(Boolean);return _h.flatMap(e=>{if(o&&!o.has(e.page))return[];let n=Ni(e.page);if(!n||n.isAvailable&&!n.isAvailable(t)||e.isAvailable&&!e.isAvailable(t))return[];let a=r(e.titleKey),c=e.descriptionKey?r(e.descriptionKey):null,l=vh([a,c,i(e.page),...e.keywords??[]].filter(Boolean).join(` `));return s.every(e=>l.includes(e))?[{...e,title:a,description:c,pageTitle:i(e.page)}]:[]})}function bh(e){let t=(0,qi.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({asChild:i,className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i!==void 0&&i?Ue:`div`,o;t[4]===n?o=t[5]:(o=G(`yuri-mobile-floating-surface`,n),t[4]=n,t[5]=o);let s;return t[6]!==a||t[7]!==r||t[8]!==o?(s=(0,$.jsx)(a,{className:o,...r}),t[6]=a,t[7]=r,t[8]=o,t[9]=s):s=t[9],s}function xh(e){let t=(0,qi.c)(20),n,r,i,a,o,s;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5],s=t[6]):({as:o,children:n,className:r,variant:s,surfaceProps:a,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o,t[6]=s);let c=o===void 0?`div`:o,l=s===void 0?`actions`:s,u;t[7]===r?u=t[8]:(u=G(`yuri-mobile-floating-bottom-bar-frame`,r),t[7]=r,t[8]=u);let d=l===`navigation`?`yuri-mobile-floating-bottom-bar-navigation`:`yuri-mobile-floating-bottom-bar-actions`,f;t[9]===d?f=t[10]:(f=G(`yuri-mobile-floating-bottom-bar`,d),t[9]=d,t[10]=f);let p;t[11]!==n||t[12]!==a||t[13]!==f?(p=(0,$.jsx)(bh,{...a,className:f,children:n}),t[11]=n,t[12]=a,t[13]=f,t[14]=p):p=t[14];let m;return t[15]!==c||t[16]!==i||t[17]!==u||t[18]!==p?(m=(0,$.jsx)(c,{className:u,...i,children:p}),t[15]=c,t[16]=i,t[17]=u,t[18]=p,t[19]=m):m=t[19],m}function Sh(e){let t=(0,qi.c)(17),{title:n,children:r,surface:i,scrollsWithPage:a,showHeader:o,trailing:s,className:c,surfaceClassName:l,surfaceAriaLabel:u}=e,d=i===void 0||i,f=a!==void 0&&a,p=o===void 0||o,m=f&&`yuri-mobile-tab-page-flow`,h=!p&&`gap-0`,g;t[0]!==c||t[1]!==m||t[2]!==h?(g=G(`yuri-mobile-tab-page`,m,h,c),t[0]=c,t[1]=m,t[2]=h,t[3]=g):g=t[3];let _;t[4]!==p||t[5]!==n||t[6]!==s?(_=p?(0,$.jsx)(vi,{title:n,trailing:s}):null,t[4]=p,t[5]=n,t[6]=s,t[7]=_):_=t[7];let v;t[8]!==r||t[9]!==d||t[10]!==u||t[11]!==l?(v=d?(0,$.jsx)(bh,{className:G(`yuri-mobile-tab-page-surface`,l),"aria-label":u,children:r}):(0,$.jsx)(`div`,{className:G(`yuri-mobile-tab-page-content`,l),"aria-label":u,children:r}),t[8]=r,t[9]=d,t[10]=u,t[11]=l,t[12]=v):v=t[12];let y;return t[13]!==g||t[14]!==_||t[15]!==v?(y=(0,$.jsxs)(`div`,{className:g,children:[_,v]}),t[13]=g,t[14]=_,t[15]=v,t[16]=y):y=t[16],y}function Ch(e){let t=(0,qi.c)(12),{label:n,children:r,className:i,cardClassName:a,ariaLabel:o}=e,s;t[0]!==a||t[1]!==i?(s=G(`yuri-mobile-labeled-surface-group`,a,i),t[0]=a,t[1]=i,t[2]=s):s=t[2];let c;t[3]===n?c=t[4]:(c=(0,$.jsx)(`div`,{className:`yuri-mobile-labeled-surface-group-label`,children:n}),t[3]=n,t[4]=c);let l;t[5]===r?l=t[6]:(l=r?(0,$.jsx)(`div`,{className:`yuri-mobile-labeled-surface-group-content`,children:r}):null,t[5]=r,t[6]=l);let u;return t[7]!==o||t[8]!==s||t[9]!==c||t[10]!==l?(u=(0,$.jsxs)(`section`,{className:s,"aria-label":o,children:[c,l]}),t[7]=o,t[8]=s,t[9]=c,t[10]=l,t[11]=u):u=t[11],u}function wh(e){let t=(0,qi.c)(10),{label:n,children:r,ariaLabel:i,className:a,borderless:o}=e,s=o!==void 0&&o,c;t[0]===a?c=t[1]:(c=G(`yuri-mobile-settings-group`,a),t[0]=a,t[1]=c);let l=s&&`yuri-mobile-settings-card-borderless`,u;t[2]===l?u=t[3]:(u=G(`yuri-mobile-settings-card`,l),t[2]=l,t[3]=u);let d;return t[4]!==i||t[5]!==r||t[6]!==n||t[7]!==c||t[8]!==u?(d=(0,$.jsx)(X,{label:n,ariaLabel:i,className:c,cardClassName:u,children:r}),t[4]=i,t[5]=r,t[6]=n,t[7]=c,t[8]=u,t[9]=d):d=t[9],d}var Th=e({SettingsView:()=>Bh,getSettingsNavIcon:()=>Rh}),Eh=176,Dh=280,Oh=8,kh=`__yuriSettingsDetail`;function Ah(e){return Math.min(Dh,Math.max(Eh,e))}var jh=`__add_provider__`;function Mh(e,t){return{isVSCode:N(),isWeb:!e&&k(),isDesktop:e,isMobile:t}}function Nh(e,t){return!e.isAvailable||e.isAvailable(t)}function Ph(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Fh(e,t){let n=new Set(t),r=e,i=1;for(;n.has(r);)r=`${e}-${i}`,i+=1;return r}function Ih(e){if(!Ph(e))return null;let t=e[kh];if(!Ph(t))return null;let n=t.page,r=t.stage;return typeof n!=`string`||r!==`page-content`?null:{page:Fi(n),stage:r}}function Lh(){return typeof window>`u`||!Ph(window.history.state)?{}:window.history.state}function Rh(e){switch(e){case`projects`:return`folders`;case`instances`:return`server`;case`remote-instances`:return`server`;case`appearance`:return`palette`;case`chat`:return`chat-ai-3`;case`magic-prompts`:return`ai-generate-2`;case`notifications`:return`notification-3`;case`shortcuts`:return`command`;case`sessions`:return`chat-history`;case`archived-sessions`:return`archive`;case`summary-ai`:return`ai-generate-2`;case`providers`:return`cloud`;case`agents`:return`node-tree`;case`assistants`:return`robot-2`;case`behavior`:return`brain`;case`commands`:return`slash-commands-2`;case`mcp`:return null;case`plugins`:return`code-box`;case`global-config`:return`settings-3`;case`skills.installed`:return`book-open`;case`skills.catalog`:return`book`;case`git`:return`git-branch`;case`usage`:return`bar-chart-2`;case`voice`:return`mic`;case`about`:return`information`;case`home`:return null;default:return`robot-2`}}var zh=e=>{let t=(0,qi.c)(95),{onOpen:n}=e,{t:r}=He(),i;t[0]===r?i=t[1]:(i=r(`settings.view.home.title`),t[0]=r,t[1]=i);let a;t[2]===i?a=t[3]:(a=(0,$.jsx)(`h1`,{className:`typography-ui-header font-semibold text-foreground`,children:i}),t[2]=i,t[3]=a);let o;t[4]===r?o=t[5]:(o=r(`settings.view.home.description`),t[4]=r,t[5]=o);let s;t[6]===o?s=t[7]:(s=(0,$.jsx)(`p`,{className:`typography-ui text-muted-foreground`,children:o}),t[6]=o,t[7]=s);let c;t[8]!==a||t[9]!==s?(c=(0,$.jsxs)(`div`,{className:`space-y-1`,children:[a,s]}),t[8]=a,t[9]=s,t[10]=c):c=t[10];let l;t[11]===n?l=t[12]:(l=()=>n(`providers`),t[11]=n,t[12]=l);let u;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(u=G(`rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left`,`hover:bg-[var(--interactive-hover)] transition-colors`),t[13]=u):u=t[13];let d;t[14]===r?d=t[15]:(d=r(`settings.view.home.cards.providers.title`),t[14]=r,t[15]=d);let f;t[16]===d?f=t[17]:(f=(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:d}),t[16]=d,t[17]=f);let p;t[18]===r?p=t[19]:(p=r(`settings.view.home.cards.providers.description`),t[18]=r,t[19]=p);let m;t[20]===p?m=t[21]:(m=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:p}),t[20]=p,t[21]=m);let h;t[22]!==m||t[23]!==l||t[24]!==f?(h=(0,$.jsxs)(`button`,{type:`button`,onClick:l,className:u,children:[f,m]}),t[22]=m,t[23]=l,t[24]=f,t[25]=h):h=t[25];let g;t[26]===n?g=t[27]:(g=()=>n(`agents`),t[26]=n,t[27]=g);let _;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(_=G(`rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left`,`hover:bg-[var(--interactive-hover)] transition-colors`),t[28]=_):_=t[28];let v;t[29]===r?v=t[30]:(v=r(`settings.view.home.cards.agents.title`),t[29]=r,t[30]=v);let y;t[31]===v?y=t[32]:(y=(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:v}),t[31]=v,t[32]=y);let b;t[33]===r?b=t[34]:(b=r(`settings.view.home.cards.agents.description`),t[33]=r,t[34]=b);let x;t[35]===b?x=t[36]:(x=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:b}),t[35]=b,t[36]=x);let S;t[37]!==g||t[38]!==y||t[39]!==x?(S=(0,$.jsxs)(`button`,{type:`button`,onClick:g,className:_,children:[y,x]}),t[37]=g,t[38]=y,t[39]=x,t[40]=S):S=t[40];let C;t[41]===n?C=t[42]:(C=()=>n(`skills.catalog`),t[41]=n,t[42]=C);let w;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(w=G(`rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left`,`hover:bg-[var(--interactive-hover)] transition-colors`),t[43]=w):w=t[43];let T;t[44]===r?T=t[45]:(T=r(`settings.view.home.cards.skillsCatalog.title`),t[44]=r,t[45]=T);let E;t[46]===T?E=t[47]:(E=(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:T}),t[46]=T,t[47]=E);let D;t[48]===r?D=t[49]:(D=r(`settings.view.home.cards.skillsCatalog.description`),t[48]=r,t[49]=D);let O;t[50]===D?O=t[51]:(O=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:D}),t[50]=D,t[51]=O);let k;t[52]!==C||t[53]!==E||t[54]!==O?(k=(0,$.jsxs)(`button`,{type:`button`,onClick:C,className:w,children:[E,O]}),t[52]=C,t[53]=E,t[54]=O,t[55]=k):k=t[55];let A;t[56]===n?A=t[57]:(A=()=>n(`mcp`),t[56]=n,t[57]=A);let j;t[58]===Symbol.for(`react.memo_cache_sentinel`)?(j=G(`rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left`,`hover:bg-[var(--interactive-hover)] transition-colors`),t[58]=j):j=t[58];let M;t[59]===r?M=t[60]:(M=r(`settings.view.home.cards.mcp.title`),t[59]=r,t[60]=M);let N;t[61]===M?N=t[62]:(N=(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:M}),t[61]=M,t[62]=N);let P;t[63]===r?P=t[64]:(P=r(`settings.view.home.cards.mcp.description`),t[63]=r,t[64]=P);let F;t[65]===P?F=t[66]:(F=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:P}),t[65]=P,t[66]=F);let I;t[67]!==A||t[68]!==N||t[69]!==F?(I=(0,$.jsxs)(`button`,{type:`button`,onClick:A,className:j,children:[N,F]}),t[67]=A,t[68]=N,t[69]=F,t[70]=I):I=t[70];let L;t[71]===n?L=t[72]:(L=()=>n(`usage`),t[71]=n,t[72]=L);let R;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(R=G(`rounded-lg border border-border bg-[var(--surface-elevated)] p-4 text-left`,`hover:bg-[var(--interactive-hover)] transition-colors`),t[73]=R):R=t[73];let z;t[74]===r?z=t[75]:(z=r(`settings.view.home.cards.usage.title`),t[74]=r,t[75]=z);let B;t[76]===z?B=t[77]:(B=(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground`,children:z}),t[76]=z,t[77]=B);let V;t[78]===r?V=t[79]:(V=r(`settings.view.home.cards.usage.description`),t[78]=r,t[79]=V);let ee;t[80]===V?ee=t[81]:(ee=(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground/70`,children:V}),t[80]=V,t[81]=ee);let H;t[82]!==L||t[83]!==B||t[84]!==ee?(H=(0,$.jsxs)(`button`,{type:`button`,onClick:L,className:R,children:[B,ee]}),t[82]=L,t[83]=B,t[84]=ee,t[85]=H):H=t[85];let te;t[86]!==h||t[87]!==S||t[88]!==k||t[89]!==I||t[90]!==H?(te=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[h,S,k,I,H]}),t[86]=h,t[87]=S,t[88]=k,t[89]=I,t[90]=H,t[91]=te):te=t[91];let ne;return t[92]!==te||t[93]!==c?(ne=(0,$.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,$.jsxs)(`div`,{className:`mx-auto w-full max-w-3xl px-6 py-6 space-y-6`,children:[c,te]})}),t[92]=te,t[93]=c,t[94]=ne):ne=t[94],ne},Bh=e=>{let t=(0,qi.c)(183),{onClose:n,mobileInstancesPage:r,forceMobile:i,isWindowed:a,visiblePageSlugs:o,hideMobileHeader:s,flowMobile:c,autoOpenMobilePage:u,initialMobileStage:d,onMobileStageChange:f}=e,p=s!==void 0&&s,h=c!==void 0&&c,g=u===void 0||u,_=d===void 0?`nav`:d,{t:v}=He(),y;t[0]===v?y=t[1]:(y={mutationFn:St,onError:()=>Ie.error(v(`chat.chatInput.toast.reloadFailed`))},t[0]=v,t[1]=y);let b=De(y),x;t[2]===b?x=t[3]:(x=()=>{b.isPending||b.mutate()},t[2]=b,t[3]=x);let S=ze(x),C=Pr(),w=i??C.isMobile,T=W(Vh),D=W(Hh),O=W(Uh),k;t[4]===T?k=t[5]:(k=Fi(T),t[4]=T,t[5]=k);let A=k;wr();let j=A===`commands`,M;t[6]===j?M=t[7]:(M={enabled:j},t[6]=j,t[7]=M);let{refetch:N}=Ft(M),P,F;t[8]!==N||t[9]!==A?(P=()=>{A===`commands`&&N()},F=[N,A],t[8]=N,t[9]=A,t[10]=P,t[11]=F):(P=t[10],F=t[11]),Q.useEffect(P,F);let[I,L]=Q.useState(_),R=p&&I===`nav`,z=w&&h,B=Q.useRef(null),V=Q.useRef(0),ee=sn(Wh),H,te;t[12]!==w||t[13]!==ee||t[14]!==O||t[15]!==A?(H=()=>{if(!w||ee<=V.current)return;let e=sn.getState().settingsSelectedAssistantID;if(!(!e||e===`new`)){if(A!==`assistants`){O(`assistants`);return}V.current=ee,B.current=`assistants`,L(`page-content`)}},te=[w,ee,O,A],t[12]=w,t[13]=ee,t[14]=O,t[15]=A,t[16]=H,t[17]=te):(H=t[16],te=t[17]),Q.useEffect(H,te);let ne,U;t[18]!==I||t[19]!==f?(ne=()=>{f?.(I)},U=[I,f],t[18]=I,t[19]=f,t[20]=ne,t[21]=U):(ne=t[20],U=t[21]),Q.useEffect(ne,U);let[re,ie]=Q.useState(216),[ae,oe]=Q.useState(null),[se,ce]=Q.useState(``),[le,ue]=Q.useState(null),[de,fe]=Q.useState(0),[pe,me]=Q.useState(!1),[he,ge]=Q.useState(!1),_e=Q.useRef(0),ye=Q.useRef(re),be=Q.useRef(null),xe=Q.useRef(null),Se=Q.useRef(null),Ce=Q.useRef(null),we=Q.useRef(null),Te=Q.useRef(null),Ee;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=[],t[22]=Ee):Ee=t[22];let Oe=Q.useRef(Ee),ke=Q.useRef(0),Ae=Q.useRef(!1),je;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(je=E(),t[23]=je):je=t[23];let Me=je,Ne;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(Ne=E()&&m(),t[24]=Ne):Ne=t[24];let Pe=Ne,Fe;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(Fe=E()&&typeof window<`u`&&window.__YURI_PLATFORM__===`darwin`,t[25]=Fe):Fe=t[25];let Le=Fe,Re;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(Re=E()&&typeof window<`u`&&window.__YURI_PLATFORM__===`win32`,t[26]=Re):Re=t[26];let Be=Re,Ve;t[27]===w?Ve=t[28]:(Ve=Mh(Me,w),t[27]=w,t[28]=Ve);let Ue=Ve,Ge;if(t[29]!==w||t[30]!==r||t[31]!==Ue||t[32]!==o){let e=o?new Set(o):null,n;t[34]===Ue?n=t[35]:(n=e=>Nh(e,Ue),t[34]=Ue,t[35]=n);let i;t[36]===r?i=t[37]:(i=e=>e.slug!==`instances`||!!r,t[36]=r,t[37]=i);let a;t[38]===Ue.isVSCode?a=t[39]:(a=e=>!(Ue.isVSCode&&e.slug===`projects`),t[38]=Ue.isVSCode,t[39]=a);let s;t[40]===w?s=t[41]:(s=e=>!(w&&e.slug===`shortcuts`),t[40]=w,t[41]=s),Ge=Mi.filter(Gh).filter(t=>!e||e.has(t.slug)).filter(n).filter(i).filter(a).filter(s),t[29]=w,t[30]=r,t[31]=Ue,t[32]=o,t[33]=Ge}else Ge=t[33];let Ke=Ge,qe;t[42]===Ke?qe=t[43]:(qe=Li(Ke),t[42]=Ke,t[43]=qe);let Je=qe,Ye=Lt(Kh),Xe,Ze;t[44]===pe?(Xe=t[45],Ze=t[46]):(Xe=()=>{if(typeof window>`u`)return;let e=()=>{if(!pe){let e=Ah(Math.floor(window.innerWidth*.12));ie(e)}};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},Ze=[pe],t[44]=pe,t[45]=Xe,t[46]=Ze),Q.useEffect(Xe,Ze);let Qe,$e;t[47]===he?(Qe=t[48],$e=t[49]):(Qe=()=>{if(!he)return;let e=e=>{let t=e.clientX-_e.current,n=Ah(ye.current+t);ie(n),me(!0)},t=()=>ge(!1);return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,t,{once:!0}),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t)}},$e=[he],t[47]=he,t[48]=Qe,t[49]=$e),Q.useEffect(Qe,$e);let et;t[50]===re?et=t[51]:(et=e=>{ge(!0),_e.current=e.clientX,ye.current=re,e.preventDefault()},t[50]=re,t[51]=et);let tt=et,nt;t[52]===re?nt=t[53]:(nt=e=>{let t=e.shiftKey?32:Oh,n;bb160:switch(e.key){case`ArrowLeft`:n=re-t;break bb160;case`ArrowRight`:n=re+t;break bb160;case`Home`:n=Eh;break bb160;case`End`:n=Dh;break bb160;default:return}e.preventDefault(),ie(Ah(n)),me(!0)},t[52]=re,t[53]=nt);let it=nt,at;t[54]!==D||t[55]!==a||t[56]!==Ue.isVSCode||t[57]!==A?(at=()=>{if(!(!D&&!Ue.isVSCode&&!a)){if(A===`agents`){dt.getState().loadAgents();return}if(A!==`commands`&&A!==`mcp`){if(A===`plugins`){sl.getState().loadPlugins();return}(A===`skills.installed`||A===`skills.catalog`)&&Yt(l,ht())}}},t[54]=D,t[55]=a,t[56]=Ue.isVSCode,t[57]=A,t[58]=at):at=t[58];let ot;t[59]!==Ye||t[60]!==D||t[61]!==a||t[62]!==Ue.isVSCode||t[63]!==A?(ot=[Ye,D,a,Ue.isVSCode,A],t[59]=Ye,t[60]=D,t[61]=a,t[62]=Ue.isVSCode,t[63]=A,t[64]=ot):ot=t[64],Q.useEffect(at,ot);let st;t[65]!==w||t[66]!==O?(st=e=>{if(O(e),B.current=e,!w)return;let t=Ni(e);if(!t||t.slug===`home`){L(`nav`);return}L(t.kind===`split`?`page-sidebar`:`page-content`)},t[65]=w,t[66]=O,t[67]=st):st=t[67];let ct=st,lt;t[68]===A?lt=t[69]:(lt=Ni(A),t[68]=A,t[69]=lt);let ut=lt,ft;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(ft={appearance:`visual`,chat:`chat`,shortcuts:`shortcuts`,sessions:`sessions`,"summary-ai":`summary-ai`,notifications:`notifications`,voice:`voice`},t[70]=ft):ft=t[70];let pt=ft,mt;t[71]===v?mt=t[72]:(mt=e=>{switch(e){case`projects`:return v(`settings.page.projects.title`);case`instances`:return v(`mobile.settings.switchInstance`);case`remote-instances`:return v(`settings.page.remoteInstances.title`);case`providers`:return v(`settings.page.providers.title`);case`usage`:return v(`settings.page.usage.title`);case`agents`:return v(`settings.page.agents.title`);case`assistants`:return v(`settings.page.assistants.title`);case`behavior`:return v(`settings.page.behavior.title`);case`commands`:return v(`settings.page.commands.title`);case`mcp`:return v(`settings.page.mcp.title`);case`plugins`:return v(`settings.page.plugins.title`);case`global-config`:return v(`settings.globalConfig.title`);case`skills.installed`:return v(`settings.page.skills.title`);case`skills.catalog`:return v(`settings.page.skillsCatalog.title`);case`git`:return v(`settings.page.git.title`);case`appearance`:return v(`settings.page.appearance.title`);case`chat`:return v(`settings.page.chat.title`);case`shortcuts`:return v(`settings.page.shortcuts.title`);case`sessions`:return v(`settings.page.sessions.title`);case`archived-sessions`:return v(`settings.page.archivedSessions.title`);case`summary-ai`:return v(`settings.page.summaryAI.title`);case`magic-prompts`:return v(`settings.page.magicPrompts.title`);case`notifications`:return v(`settings.page.notifications.title`);case`voice`:return v(`settings.page.voice.title`);case`about`:return v(`settings.page.about.title`);default:return v(`settings.view.home.title`)}},t[71]=v,t[72]=mt);let gt=mt,_t;t[73]!==gt||t[74]!==Ue||t[75]!==se||t[76]!==v||t[77]!==Ke?(_t=yh({query:se,runtimeCtx:{...Ue,isDesktopLocalOrigin:Pe,isMac:Le,isWindows:Be},visiblePageSlugs:Ke.map(qh),t:v,getPageTitle:gt}),t[73]=gt,t[74]=Ue,t[75]=se,t[76]=v,t[77]=Ke,t[78]=_t):_t=t[78];let vt=_t,yt=Qh,q;if(t[79]!==vt){q=[];let e=new Map;for(let t of vt){let n=e.get(t.page);n||(n={page:t.page,pageTitle:t.pageTitle,results:[]},e.set(t.page,n),q.push(n)),n.results.push(t)}t[79]=vt,t[80]=q}else q=t[80];let bt=q,xt;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(xt=()=>{fe(0),ke.current=0,Ae.current=!1},t[81]=xt):xt=t[81];let Ct;t[82]===se?Ct=t[83]:(Ct=[se],t[82]=se,t[83]=Ct),Q.useEffect(xt,Ct);let wt,Tt;t[84]===de?(wt=t[85],Tt=t[86]):(wt=()=>{ke.current=de},Tt=[de],t[84]=de,t[85]=wt,t[86]=Tt),Q.useEffect(wt,Tt);let Et,Dt;t[87]===de?(Et=t[88],Dt=t[89]):(Et=()=>{Oe.current[de]?.scrollIntoView({block:`nearest`})},Dt=[de],t[87]=de,t[88]=Et,t[89]=Dt),Q.useEffect(Et,Dt);let Ot,kt;t[90]!==de||t[91]!==vt.length?(Ot=()=>{de>=vt.length&&fe(Math.max(0,vt.length-1)),Oe.current.length=vt.length},kt=[de,vt.length],t[90]=de,t[91]=vt.length,t[92]=Ot,t[93]=kt):(Ot=t[92],kt=t[93]),Q.useEffect(Ot,kt);let At;t[94]!==w||t[95]!==ct?(At=e=>{let t=yt(e);ue(t),ct(e.page),w&&L(`page-content`),e.id===`plugins.create`&&typeof window<`u`&&window.setTimeout($h,50)},t[94]=w,t[95]=ct,t[96]=At):At=t[96];let jt=At,Mt;t[97]!==jt||t[98]!==se||t[99]!==vt?(Mt=e=>{if(se.trim()){if(e.key===`Escape`){e.preventDefault(),ce(``);return}if(vt.length!==0){if(e.key===`ArrowDown`){e.preventDefault(),Ae.current=!0,fe(e=>(e+1)%vt.length);return}if(e.key===`ArrowUp`){e.preventDefault(),Ae.current=!0,fe(e=>(e-1+vt.length)%vt.length);return}if(e.key===`Enter`){e.preventDefault();let t=(ke.current%vt.length+vt.length)%vt.length,n=vt[t]??vt[0];n&&jt(n)}}}},t[97]=jt,t[98]=se,t[99]=vt,t[100]=Mt):Mt=t[100];let Nt=Mt,Pt;t[101]===le?Pt=t[102]:(Pt=()=>{let e=le;if(!e)return;let t=!1,n=window.requestAnimationFrame(()=>{if(t)return;let n=typeof CSS<`u`&&CSS.escape?CSS.escape(e):e.replace(/[^a-zA-Z0-9_-]/g,`\\$&`),r=be.current?.querySelector(`[data-settings-item="${n}"]`);r&&(ue(null),r.scrollIntoView({block:`center`,behavior:`smooth`}),r.setAttribute(`data-settings-search-highlight`,`true`),window.setTimeout(()=>{r.removeAttribute(`data-settings-search-highlight`)},1600))});return()=>{t=!0,window.cancelAnimationFrame(n)}},t[101]=le,t[102]=Pt);let It;t[103]!==le||t[104]!==A?(It=[le,A],t[103]=le,t[104]=A,t[105]=It):It=t[105],Q.useEffect(Pt,It);let Rt;t[106]===v?Rt=t[107]:(Rt=()=>(0,$.jsx)(`div`,{className:`flex h-full items-center justify-center px-6`,children:(0,$.jsxs)(`div`,{className:`max-w-md text-center`,children:[(0,$.jsx)(`div`,{className:`typography-ui-header font-semibold text-foreground`,children:v(`settings.view.unavailable.title`)}),(0,$.jsx)(`p`,{className:`typography-ui text-muted-foreground mt-1`,children:v(`settings.view.unavailable.description`)})]})}),t[106]=v,t[107]=Rt);let J=Rt,zt=eg,Bt;t[108]!==w||t[109]!==Ue.isVSCode||t[110]!==A?(Bt=()=>{if(w){if(ve()||Ue.isVSCode){L(`page-sidebar`);return}if((typeof window<`u`?Ih(window.history.state):null)?.page===A){window.history.back();return}L(`page-sidebar`)}},t[108]=w,t[109]=Ue.isVSCode,t[110]=A,t[111]=Bt):Bt=t[111];let Vt=Bt,Ht;t[112]!==ae||t[113]!==Vt||t[114]!==w||t[115]!==z||t[116]!==r||t[117]!==ct||t[118]!==J||t[119]!==Ue?(Ht=e=>{let t=Ni(e);if(t&&!Nh(t,Ue))return J();switch(e){case`home`:return(0,$.jsx)(zh,{onOpen:ct});case`projects`:return(0,$.jsx)(rd,{});case`instances`:return r??J();case`remote-instances`:return(0,$.jsx)(hf,{});case`agents`:return(0,$.jsx)(Ho,{});case`assistants`:return(0,$.jsx)(ls,{onItemDeleted:w?Vt:void 0,saveActionContainer:w?ae:void 0});case`behavior`:return(0,$.jsx)(ws,{});case`commands`:return(0,$.jsx)(Ms,{});case`mcp`:return(0,$.jsx)(pc,{});case`plugins`:return(0,$.jsx)(nu,{});case`global-config`:return(0,$.jsx)(au,{});case`skills.installed`:return(0,$.jsx)(Ju,{view:`installed`});case`skills.catalog`:return(0,$.jsx)(Ju,{view:`catalog`});case`providers`:return(0,$.jsx)(Rf,{});case`usage`:return(0,$.jsx)(dp,{});case`about`:return(0,$.jsx)(`div`,{className:G(`h-full overflow-auto px-5 py-6`,z&&`h-auto overflow-visible p-3`),children:(0,$.jsx)(ta,{})});case`magic-prompts`:return(0,$.jsx)(bp,{});case`git`:return(0,$.jsx)(Op,{});case`archived-sessions`:return(0,$.jsx)(gh,{});case`appearance`:case`chat`:case`shortcuts`:case`sessions`:case`summary-ai`:case`notifications`:case`voice`:{let t=pt[e]??`visual`;return(0,$.jsx)(oh,{section:t,flowMobile:z})}default:return(0,$.jsx)(zh,{onOpen:ct})}},t[112]=ae,t[113]=Vt,t[114]=w,t[115]=z,t[116]=r,t[117]=ct,t[118]=J,t[119]=Ue,t[120]=Ht):Ht=t[120];let Ut=Ht,Wt,Gt;t[121]!==g||t[122]!==w||t[123]!==I||t[124]!==A?(Wt=()=>{if(!w||!g||I!==`nav`||A===`home`||B.current===A)return;let e=Ni(A);!e||e.slug===`home`||(B.current=A,L(e.kind===`split`?`page-sidebar`:`page-content`))},Gt=[g,w,I,A],t[121]=g,t[122]=w,t[123]=I,t[124]=A,t[125]=Wt,t[126]=Gt):(Wt=t[125],Gt=t[126]),Q.useEffect(Wt,Gt);let qt,Jt;t[127]!==h||t[128]!==A?(qt=()=>{!h||A!==`home`||(B.current=null,L(`nav`))},Jt=[h,A],t[127]=h,t[128]=A,t[129]=qt,t[130]=Jt):(qt=t[129],Jt=t[130]),Q.useEffect(qt,Jt);let Xt=w&&I!==`nav`,Zt=w&&I===`page-content`&&ut?.kind===`split`,Qt=I===`page-content`&&ut?.kind===`split`&&!Zt,$t;t[131]!==Zt||t[132]!==Xt||t[133]!==v?($t=v(Zt?`settings.view.actions.back`:Xt?`settings.view.actions.backToSettings`:`settings.view.actions.closeSettings`),t[131]=Zt,t[132]=Xt,t[133]=v,t[134]=$t):$t=t[134];let en=$t,tn=We(),nn;t[135]===Ue.isVSCode?nn=t[136]:(nn=e=>{if(typeof window>`u`||Ue.isVSCode||ve())return;let t=Ih(window.history.state);(t?.page!==e||t.stage!==`page-content`)&&window.history.pushState({...Lh(),[kh]:{page:e,stage:`page-content`}},``,window.location.href)},t[135]=Ue.isVSCode,t[136]=nn);let rn=nn,an;t[137]!==rn||t[138]!==A?(an=()=>{L(`page-content`),rn(A)},t[137]=rn,t[138]=A,t[139]=an):an=t[139];let on=an,cn;t[140]!==Zt||t[141]!==h||t[142]!==Vt||t[143]!==O?(cn=()=>{if(h&&Kt.getState().settingsReturnTo){B.current=null,L(`nav`),O(`home`),Kt.getState().restoreSettingsReturnTo();return}if(Zt){Vt();return}L(`nav`)},t[140]=Zt,t[141]=h,t[142]=Vt,t[143]=O,t[144]=cn):cn=t[144];let ln=cn,un;t[145]!==ut?.kind||t[146]!==I?(un=()=>{if(I===`page-content`){we.current=Ce.current,Te.current=ut?.kind===`split`?Se.current:xe.current;return}we.current=Se.current,Te.current=xe.current},t[145]=ut?.kind,t[146]=I,t[147]=un):un=t[147];let dn=ut?.kind,fn;t[148]!==I||t[149]!==dn?(fn=[dn,I],t[148]=I,t[149]=dn,t[150]=fn):fn=t[150],Q.useLayoutEffect(un,fn);let pn=`mobile-settings:${A}`,mn=z&&I!==`nav`,hn;t[151]!==ln||t[152]!==pn||t[153]!==mn?(hn={id:pn,active:mn,onBack:ln,surfaceRef:we,underlayRef:Te},t[151]=ln,t[152]=pn,t[153]=mn,t[154]=hn):hn=t[154],Bi(hn);let gn,_n;t[155]!==w||t[156]!==Ue.isVSCode||t[157]!==A?(gn=()=>{if(!w||Ue.isVSCode||ve())return;let e=e=>{if(Ni(A)?.kind===`split`){if(Ih(e.state)?.page===A){L(`page-content`);return}L(tg)}};return window.addEventListener(`popstate`,e),()=>{window.removeEventListener(`popstate`,e)}},_n=[w,Ue.isVSCode,A],t[155]=w,t[156]=Ue.isVSCode,t[157]=A,t[158]=gn,t[159]=_n):(gn=t[158],_n=t[159]),Q.useEffect(gn,_n);let vn;t[160]===Symbol.for(`react.memo_cache_sentinel`)?(vn=()=>{L(`page-sidebar`)},t[160]=vn):vn=t[160];let yn=vn,bn=()=>{let e=se.trim().length>0;return(0,$.jsxs)(`div`,{className:G(`flex h-full flex-col overflow-hidden`,w&&`yuri-settings-navigation-content`,z&&`h-auto w-full overflow-visible`),children:[(0,$.jsx)(`div`,{className:G(`px-2 pt-3`,w&&`yuri-mobile-settings-search`),children:(0,$.jsxs)(`div`,{className:G(`flex h-10 items-center gap-1.5 rounded-md border border-border bg-background/70 px-2 text-muted-foreground focus-within:ring-2 focus-within:ring-primary/40 sm:h-8`,w&&`yuri-mobile-settings-search-field`),children:[(0,$.jsx)(Y,{name:`search`,className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`input`,{value:se,onChange:e=>ce(e.target.value),onKeyDown:Nt,placeholder:v(`settings.view.search.placeholder`),"aria-label":v(`settings.view.search.aria`),className:`typography-ui min-w-0 flex-1 bg-transparent text-foreground outline-none placeholder:text-muted-foreground/70`}),e&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>ce(``),"aria-label":v(`settings.view.search.clear`),className:`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-interactive-hover hover:text-foreground sm:h-5 sm:w-5`,children:(0,$.jsx)(Y,{name:`close`,className:`h-3.5 w-3.5`})})]})}),(0,$.jsx)(`div`,{className:G(`flex-1 min-h-0 overflow-y-auto overflow-x-hidden`,z&&`w-full flex-none overflow-visible`),children:(0,$.jsx)(`div`,{className:G(w?`yuri-mobile-settings-nav-list flex min-w-0 flex-col`:`flex flex-col gap-0.5 px-2 pb-2 pt-4`),children:e?vt.length>0?(()=>{let e=0;return bt.map(t=>{let n=t.results.map(t=>{let n=e;e+=1;let r=n===de,i=!!t.description;return(0,$.jsxs)(`button`,{type:`button`,ref:e=>{Oe.current[n]=e},onMouseMove:()=>{Ae.current=!1,fe(n)},onClick:()=>jt(t),className:G(w?`yuri-mobile-settings-row yuri-mobile-settings-search-result`:`flex w-full flex-col rounded-md px-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50`,i?`min-h-11 py-1.5`:`py-2`,r?`bg-interactive-selection`:`hover:bg-interactive-hover`),children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsx)(`span`,{className:`typography-ui-label text-foreground truncate`,children:t.title}),i&&(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground/70 line-clamp-2`,children:t.description})]}),w?(0,$.jsx)(Y,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground/60`}):null]},t.id)});return w?(0,$.jsx)(wh,{label:t.pageTitle,ariaLabel:t.pageTitle,children:n},t.page):(0,$.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,$.jsx)(`div`,{className:`px-2 pb-0.5 pt-2 typography-micro font-medium text-muted-foreground/70`,children:t.pageTitle}),n]},t.page)})})():(0,$.jsx)(`div`,{className:`px-2 py-6 text-center typography-ui text-muted-foreground`,children:v(`settings.view.search.noResults`)}):(0,$.jsx)($.Fragment,{children:Je.map((e,t)=>{let{group:n,pages:r}=e,i=v(`settings.view.navigation.groups.${n}`),a=r.map(e=>{let t=A===e.slug,n=Rh(e.slug);return!n&&e.slug!==`mcp`?null:(0,$.jsx)(kn,{children:(0,$.jsx)(Dn,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>ct(e.slug),"aria-current":t?`page`:void 0,className:G(w?`yuri-mobile-settings-row`:`flex h-8 w-full items-center gap-2 overflow-hidden rounded-md px-2 text-left`,t&&!w?`bg-interactive-selection text-foreground`:`text-foreground hover:bg-interactive-hover`),children:[e.slug===`mcp`?(0,$.jsx)(Ci,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Y,{name:n,className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{className:`flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden whitespace-nowrap transition-opacity duration-150 opacity-100`,children:(0,$.jsx)(`span`,{className:`typography-ui-label font-normal truncate`,children:gt(e.slug)})}),w?(0,$.jsx)(Y,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground/60`}):null]})})},e.slug)});return w?(0,$.jsx)(wh,{label:i,ariaLabel:i,children:a},n):(0,$.jsxs)(`div`,{className:G(`space-y-0.5`,t>0&&`pt-3`),children:[(0,$.jsx)(`div`,{className:`px-2 pb-0.5 typography-micro font-medium text-muted-foreground/70`,children:i}),a]},n)})})})}),(0,$.jsx)(`div`,{className:G(`overflow-hidden transition-opacity duration-150 opacity-100`,w&&`yuri-mobile-settings-footer`),children:(0,$.jsx)(`div`,{className:G(`border-t-[0.5px] border-border/40 bg-sidebar px-2 py-1 space-y-0.5`,w&&`yuri-mobile-floating-surface yuri-mobile-settings-card`),children:!Ue.isVSCode&&(0,$.jsxs)(K,{type:`button`,variant:`ghost`,size:`sm`,disabled:b.isPending,"aria-busy":b.isPending,className:G(w?`yuri-mobile-settings-row`:`w-full justify-start overflow-hidden`,`text-sm font-semibold text-sidebar-foreground/90`,`hover:text-sidebar-foreground hover:bg-interactive-hover`),onClick:S,children:[(0,$.jsx)(Y,{name:`restart`,className:G(`h-4 w-4 shrink-0`,b.isPending&&`animate-spin`)}),(0,$.jsx)(`span`,{children:v(`settings.view.actions.reloadOpenCode`)})]})})})]})},xn=()=>(0,$.jsx)(`div`,{className:G(`flex-1 min-h-0 overflow-hidden`,z?`w-full flex-none overflow-visible bg-transparent`:Ue.isVSCode?`bg-background`:`bg-sidebar`),children:(0,$.jsx)(`div`,{className:G(`flex h-full min-h-0 flex-col`,z&&`h-auto w-full overflow-visible`),children:(0,$.jsx)(Fn,{children:bn()})})}),Sn=e=>{let t=e===void 0?I:e;if(t===`nav`)return xn();let n=G(`flex-1 min-h-0 overflow-hidden bg-transparent`,z?`w-full flex-none overflow-visible`:`px-[var(--yuri-mobile-page-inline-inset)]`);if(!ut)return(0,$.jsx)(`div`,{className:n});if(t===`page-sidebar`){if(ut.kind!==`split`){let e=Ut(A);return(0,$.jsx)(`div`,{className:n,children:(0,$.jsx)(bh,{className:`yuri-mobile-settings-detail-card`,children:(0,$.jsx)(Fn,{children:e})})})}return(0,$.jsx)(`div`,{className:n,children:(0,$.jsx)(bh,{className:`yuri-mobile-settings-detail-card`,children:(0,$.jsx)(Fn,{children:zt(A,{onItemSelect:on})})})})}let r=Ut(A);return(0,$.jsx)(`div`,{className:n,children:(0,$.jsx)(bh,{className:`yuri-mobile-settings-detail-card`,children:(0,$.jsx)(Fn,{children:r})})})},Cn;t[161]!==ut||t[162]!==ct||t[163]!==Ut||t[164]!==Ue.isVSCode||t[165]!==A?(Cn=()=>!ut||A===`home`?(0,$.jsx)(zh,{onOpen:ct}):A===`usage`?(0,$.jsx)(Uf,{children:(0,$.jsx)(Fn,{children:(0,$.jsx)(dp,{})})}):ut.kind===`split`?(0,$.jsxs)(`div`,{className:`yuri-settings-entity-split flex h-full min-h-0 overflow-hidden`,children:[(0,$.jsx)(`div`,{className:G(`yuri-settings-entity-list min-h-0 border-r-[0.5px] border-border/40`,Ue.isVSCode?`bg-background`:`bg-sidebar`),children:(0,$.jsx)(Fn,{children:zt(A,{})})}),(0,$.jsx)(`div`,{className:`flex-1 min-w-0 min-h-0 overflow-hidden bg-background`,children:(0,$.jsx)(Fn,{children:Ut(A)})})]}):(0,$.jsx)(`div`,{className:`h-full min-h-0 overflow-hidden bg-background`,children:(0,$.jsx)(Fn,{children:Ut(A)})}),t[161]=ut,t[162]=ct,t[163]=Ut,t[164]=Ue.isVSCode,t[165]=A,t[166]=Cn):Cn=t[166];let wn=Cn,Tn=e=>{let t=e===void 0?I:e;return(0,$.jsx)(rt,{sticky:!0,title:t===`nav`?v(`settings.view.home.title`):ut?gt(ut.slug):v(`settings.view.home.title`),backAriaLabel:en,onBack:Xt?ln:n,trailing:t===`page-content`&&A===`assistants`?(0,$.jsx)(`div`,{ref:oe}):void 0,actions:[...Qt?[{icon:`list-unordered`,ariaLabel:v(`settings.view.actions.openSectionList`),onClick:yn}]:[],...n?[{icon:`close`,ariaLabel:v(`settings.view.actions.closeSettings`),title:v(`settings.view.actions.closeSettingsWithShortcut`,{shortcut:tn}),onClick:n}]:[]]})};if(z){let e=I!==`nav`,n=e&&ut?.kind===`split`,r=I===`page-content`,i=I===`page-sidebar`,a=r&&ut?.kind===`split`,o=e&&!a,s;t[167]===v?s=t[168]:(s=v(`mobile.settings.placeholder.title`),t[167]=v,t[168]=s);let c;return t[169]===s?c=t[170]:(c=(0,$.jsx)(vi,{title:s}),t[169]=s,t[170]=c),(0,$.jsxs)(`div`,{ref:be,"data-settings-view":`true`,"data-mobile-settings-detail-active":e?`true`:void 0,className:`yuri-settings-workspace yuri-settings-workspace-mobile h-auto w-full min-w-0 overflow-visible bg-transparent`,children:[(0,$.jsxs)(`div`,{ref:xe,"data-mobile-settings-stage":`nav`,"data-mobile-navigation-underlay":o?`true`:void 0,"aria-hidden":e?`true`:void 0,inert:e?!0:void 0,className:`yuri-mobile-settings-root-surface fixed inset-0 z-20 flex h-[100dvh] w-full min-w-0 max-w-full flex-col gap-[var(--yuri-mobile-page-gap)] overflow-y-auto overflow-x-hidden overscroll-contain px-[var(--yuri-mobile-page-inline-inset)] pb-[calc(var(--yuri-mobile-dock-height)+2.5rem+var(--yuri-safe-area-bottom,env(safe-area-inset-bottom,0px)))] pt-[calc(var(--yuri-safe-area-top,env(safe-area-inset-top,0px))+1rem)] [contain:layout_paint]`,children:[c,xn()]}),n?(0,$.jsxs)(`div`,{ref:Se,"data-mobile-settings-stage":`page-sidebar`,"data-mobile-navigation-underlay":a?`true`:void 0,"data-mobile-settings-push-surface":`true`,"aria-hidden":i?void 0:`true`,inert:!i||void 0,className:`fixed inset-0 z-40 flex h-[100dvh] w-full min-w-0 max-w-full touch-pan-y flex-col overflow-hidden bg-background [contain:layout_paint]`,children:[Tn(`page-sidebar`),(0,$.jsx)(`div`,{className:`min-h-0 w-full flex-1 overflow-y-auto overflow-x-hidden overscroll-contain px-[var(--yuri-mobile-page-inline-inset)]`,children:Sn(`page-sidebar`)})]}):null,r?(0,$.jsxs)(`div`,{ref:Ce,"data-mobile-settings-stage":`page-content`,"data-mobile-settings-push-surface":`true`,className:`fixed inset-0 z-50 flex h-[100dvh] w-full min-w-0 max-w-full touch-pan-y flex-col overflow-hidden bg-background [contain:layout_paint]`,children:[Tn(`page-content`),(0,$.jsx)(`div`,{className:`min-h-0 w-full flex-1 overflow-y-auto overflow-x-hidden overscroll-contain px-[var(--yuri-mobile-page-inline-inset)]`,children:Sn(`page-content`)})]}):null]})}let En=w?`yuri-settings-workspace-mobile bg-transparent`:`yuri-settings-workspace-desktop bg-background`,On=z&&`h-auto w-full overflow-visible`,An;t[171]!==En||t[172]!==On?(An=G(`yuri-settings-workspace relative flex h-full min-h-0 flex-col overflow-hidden`,En,On),t[171]=En,t[172]=On,t[173]=An):An=t[173];let jn=w&&!R?Tn():w?null:(0,$.jsxs)($.Fragment,{children:[Xt&&(0,$.jsx)(`div`,{className:G(`absolute left-3 z-50`,a?`top-2`:`top-3`),children:(0,$.jsx)(`button`,{type:`button`,onClick:ln,"aria-label":v(`settings.view.actions.back`),className:`inline-flex h-9 w-9 items-center justify-center rounded-lg p-2 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,children:(0,$.jsx)(Y,{name:`arrow-left-s`,className:`h-5 w-5`})})}),n&&(0,$.jsx)(`div`,{className:G(`absolute right-0.5 z-50`,a?`top-0.5`:`top-1`),children:(0,$.jsx)(`button`,{type:`button`,onClick:n,"aria-label":v(`settings.view.actions.closeSettings`),title:v(`settings.view.actions.closeSettingsWithShortcut`,{shortcut:tn}),className:`inline-flex h-7 w-7 items-center justify-center rounded-md p-0.5 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,children:(0,$.jsx)(Y,{name:`close`,className:`h-5 w-5`})})})]}),Mn=z&&`w-full flex-none overflow-visible`,Nn;t[174]===Mn?Nn=t[175]:(Nn=G(`flex flex-1 min-h-0 overflow-hidden`,Mn),t[174]=Mn,t[175]=Nn);let Pn=w?Sn():(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:G(`relative flex h-full min-h-0 flex-col overflow-hidden border-r-[0.5px] border-border/40`,Me?`bg-sidebar`:Ue.isVSCode?`bg-background`:`bg-sidebar`,he?``:`transition-[width,min-width] duration-200 ease-[cubic-bezier(0.25,0.1,0.25,1)]`),style:{width:`${re}px`,minWidth:`${re}px`},children:[(0,$.jsx)(`div`,{className:G(`absolute right-0 top-0 z-20 h-full w-[6px] -mr-[3px] cursor-col-resize`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,he?`bg-primary/30`:`bg-transparent hover:bg-primary/20`),tabIndex:0,onPointerDown:tt,onKeyDown:it,role:`separator`,"aria-orientation":`vertical`,"aria-valuemin":Eh,"aria-valuemax":Dh,"aria-valuenow":re,"aria-label":v(`settings.view.actions.resizeNavigation`)}),(0,$.jsx)(Fn,{children:bn()})]}),(0,$.jsx)(`div`,{className:`yuri-settings-detail-pane flex-1 overflow-hidden bg-background`,children:wn()})]}),In;t[176]!==Nn||t[177]!==Pn?(In=(0,$.jsx)(`div`,{className:Nn,children:Pn}),t[176]=Nn,t[177]=Pn,t[178]=In):In=t[178];let Ln;return t[179]!==An||t[180]!==jn||t[181]!==In?(Ln=(0,$.jsxs)(`div`,{ref:be,"data-settings-view":`true`,className:An,children:[jn,In]}),t[179]=An,t[180]=jn,t[181]=In,t[182]=Ln):Ln=t[182],Ln};function Vh(e){return e.settingsPage}function Hh(e){return e.isSettingsDialogOpen}function Uh(e){return e.setSettingsPage}function Wh(e){return e.openSettingsRequestRevision}function Gh(e){return e.slug!==`home`}function Kh(e){return e.activeProjectId}function qh(e){return e.slug}function Jh(e){return e.name}function Yh(e){return e.name}function Xh(e){return e.name}function Zh(e){return e.name}function Qh(e){if(e.id.startsWith(`assistants.`)){if(e.id===`assistants.default-share`){let t=sn.getState(),n=$e()?.assistants??[],r=n.some(e=>e.id===t.settingsSelectedAssistantID);return t.selectSettingsAssistant(r?t.settingsSelectedAssistantID:n[0]?.id??null),e.id}return sn.getState().requestCreate(),e.id===`assistants.create`?`assistants.name`:e.id}if(e.id.startsWith(`agents.`)){let t=dt.getState(),n=Fh(`new-agent`,Bt().map(Jh));return t.setAgentDraft({name:n,scope:`user`}),t.setSelectedAgent(n),e.id===`agents.create`?`agents.name`:e.id}if(e.id.startsWith(`commands.`)){let t=Da.getState(),n=Fh(`new-command`,Nt().map(Yh));return t.setCommandDraft({name:n,scope:`user`}),t.setSelectedCommand(n),e.id===`commands.create`?`commands.name`:e.id}if(e.id.startsWith(`mcp.`)){let t=Na.getState(),n=Fh(`new-mcp-server`,ki().map(Xh));return t.setMcpDraft({name:n,scope:`user`,type:`local`,command:[],url:``,environment:[],headers:[],oauthEnabled:!0,oauthClientId:``,oauthClientSecret:``,oauthScope:``,oauthRedirectUri:``,timeout:``,enabled:!0}),t.setSelectedMcp(n),e.id===`mcp.create`?`mcp.server`:e.id}if(e.id.startsWith(`skills.`)){let t=gt(l),n=Ra.getState(),r=Fh(`new-skill`,t.map(Zh));return n.setSkillDraft({name:r,scope:`user`,source:`opencode`,description:``,instructions:``}),n.setSelectedSkill(r),e.id===`skills.create`?`skills.basic-information`:e.id}return e.id===`providers.connect`&&tn.getState().setSelectedProvider(jh),e.id===`plugins.create`?`plugins.spec`:e.id}function $h(){window.dispatchEvent(new CustomEvent(`yuri:settings-open-plugin-add`))}function eg(e,t){switch(e){case`projects`:return(0,$.jsx)(Xu,{onItemSelect:t.onItemSelect});case`agents`:return(0,$.jsx)(ho,{onItemSelect:t.onItemSelect});case`assistants`:return(0,$.jsx)(cs,{onItemSelect:t.onItemSelect});case`commands`:return(0,$.jsx)(Ts,{onItemSelect:t.onItemSelect});case`mcp`:return(0,$.jsx)(Is,{onItemSelect:t.onItemSelect});case`plugins`:return(0,$.jsx)(Il,{onItemSelect:t.onItemSelect});case`skills.installed`:return(0,$.jsx)(cu,{onItemSelect:t.onItemSelect});case`providers`:return(0,$.jsx)(vf,{onItemSelect:t.onItemSelect});case`usage`:return(0,$.jsx)(Uf,{onItemSelect:t.onItemSelect});case`magic-prompts`:return(0,$.jsx)(mp,{onItemSelect:t.onItemSelect});default:return null}}function tg(e){return e===`page-content`?`page-sidebar`:e}export{Ch as a,Na as c,va as d,_a as f,bh as i,Sa as l,ta as m,Th as n,Sh as o,ga as p,xh as r,ls as s,Bh as t,ya as u};
|