@openchamber/web 2.0.4 → 2.1.0
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/{CodeMirrorCommentWidgets-C_zL-eri.js → CodeMirrorCommentWidgets-qlshRzAf.js} +1 -1
- package/dist/assets/{DiffView-BeN2_YYF.js → DiffView-BI_YgdKl.js} +3 -3
- package/dist/assets/FilesView-B_NJFLBH.js +17 -0
- package/dist/assets/{GitView-DLDazOo1.js → GitView-BWKg6TNS.js} +4 -4
- package/dist/assets/{GuestAttachDialog-C0xe_Lyy.js → GuestAttachDialog-DO4x4vIR.js} +1 -1
- package/dist/assets/{GuestSurfacePane-BdaurnDr.js → GuestSurfacePane-4PY11vEP.js} +1 -1
- package/dist/assets/JsonTreeView-u4yx65zn.js +1 -0
- package/dist/assets/{LinearIssuesView-BryoAHow.js → LinearIssuesView-C4gGBhU8.js} +1 -1
- package/dist/assets/{MarkdownImageGallery-DfuEoaGq.js → MarkdownImageGallery-fqVRCTdC.js} +1 -1
- package/dist/assets/MarkdownRendererImpl-Cfb5fTnq.js +39 -0
- package/dist/assets/OnboardingScreen-CiTV2_OT.js +1 -0
- package/dist/assets/PatchDiff-BrjhzXDM.js +1 -0
- package/dist/assets/{PierreDiffViewer-BC950e3F.js → PierreDiffViewer-CVx2e1cx.js} +5 -5
- package/dist/assets/{PlanView-B7Xgihqk.js → PlanView-DP9DOnI-.js} +4 -4
- package/dist/assets/{PluginPane-2C71F8uF.js → PluginPane-rZvoMQSi.js} +3 -3
- package/dist/assets/SettingsView-Dp9jubRs.js +30 -0
- package/dist/assets/SettingsWindow-Dst0yiV7.js +1 -0
- package/dist/assets/{SubmoduleDiffSummary-BSA9gnIO.js → SubmoduleDiffSummary-CixkM4fI.js} +1 -1
- package/dist/assets/{ToolOutputDialog-DprkVKcj.js → ToolOutputDialog-f0cS2DIf.js} +6 -6
- package/dist/assets/ToolPartDiffPreview-CFFIAFFY.js +8 -0
- package/dist/assets/{VirtualizedFileDiff-Kp8hKJdT.js → VirtualizedFileDiff-B-U_aQwV.js} +4 -4
- package/dist/assets/{WalkthroughView-DGnTzqIU.js → WalkthroughView-C1uB3Pl3.js} +2 -2
- package/dist/assets/{appThemeRegistry-BdEHBA4s.js → appThemeRegistry-DU-UKEHq.js} +1 -1
- package/dist/assets/{commitAndPush-LwtVa2Oc.js → commitAndPush-CtWGqrtW.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-6V1xNpO9.js → computeVirtualFileMetrics-BmhViPMt.js} +1 -1
- package/dist/assets/de-D4hpTCNY.js +10 -0
- package/dist/assets/es-Bw9m3H62.js +16 -0
- package/dist/assets/fileTreeStatus-CvPnAWSi.js +1 -0
- package/dist/assets/fr-Bhll42P0.js +14 -0
- package/dist/assets/index-Btd2mmYT.js +42 -0
- package/dist/assets/index-C-7hQnEc.css +1 -0
- package/dist/assets/{index-CmNPYddV.js → index-DwtCnbiK.js} +1 -1
- package/dist/assets/{isDiffPlainText-1bXcWCrw.js → isDiffPlainText-CPDhzF1K.js} +1 -1
- package/dist/assets/{isFilePlainText-CBAppvy1.js → isFilePlainText-n8k0lMTZ.js} +1 -1
- package/dist/assets/ja-CsHoT43d.js +16 -0
- package/dist/assets/ko-BBNdtFa4.js +16 -0
- package/dist/assets/{main-CzjTMTfW.js → main-D6rlXjug.js} +2 -2
- package/dist/assets/main-kYkr_urz.js +1000 -0
- package/dist/assets/markdownCore-CHm8ycaW.js +7 -0
- package/dist/assets/{miniChat-CP68IL8Q.js → miniChat-2JY8K3Qw.js} +2 -2
- package/dist/assets/mobile-CviaXnnU.js +2 -0
- package/dist/assets/nl-DszyktfH.js +16 -0
- package/dist/assets/openSessionFromRoute-BIlcJIf3.js +1 -0
- package/dist/assets/{web-components-ngpHPEDU.js → parseDiffFromFile-DeZzEah8.js} +5 -5
- package/dist/assets/{patchFileDiff-pqRSHLHI.js → patchFileDiff-BnEHIdM2.js} +2 -2
- package/dist/assets/pl-Bk9_mUXc.js +16 -0
- package/dist/assets/pt-BR-BIXmm3Gw.js +16 -0
- package/dist/assets/{renderElectronMiniChatApp-DKIilR7N.js → renderElectronMiniChatApp-DvUphkjj.js} +2 -2
- package/dist/assets/renderMobileApp-Cdc49X8Y.js +25 -0
- package/dist/assets/runtimeEndpointReset-Cu6RUve4.js +56 -0
- package/dist/assets/shikiHighlight-CcVzlYit.js +1 -0
- package/dist/assets/space-apply-CgJ5JYPK.js +1 -0
- package/dist/assets/space-close-C1tL-_0t.js +1 -0
- package/dist/assets/{textMateThemeFromAppTheme-BSUFChBY.js → textMateThemeFromAppTheme-CAOCeVjl.js} +1 -1
- package/dist/assets/tr-C_13w7CX.js +7 -0
- package/dist/assets/uk-BZTsG-q_.js +16 -0
- package/dist/assets/{useAppFontEffects-Dsl_sLrj.js → useAppFontEffects-CeMgbeVa.js} +185 -177
- package/dist/assets/{useInlineCommentController-d5vntsQ_.js → useInlineCommentController-U97JJifS.js} +2 -2
- package/dist/assets/useRootScrollLock-DMBY2aTT.js +2 -0
- package/dist/assets/{vendor-base-ui-DnNniUWp.js → vendor-base-ui-DWgyZK2k.js} +1 -1
- package/dist/assets/vendor-codemirror-autocomplete-DetzHhtC.js +1 -0
- package/dist/assets/{vendor-codemirror-commands-B7H_j0iU.js → vendor-codemirror-commands-ConqfjLn.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-angular-DEPs2M5t.js → vendor-codemirror-lang-angular-Dbpx8qe-.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-cpp-DhkseaMo.js → vendor-codemirror-lang-cpp-TRtQWrpl.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-css-O0cZX78y.js → vendor-codemirror-lang-css-DY4CGDG2.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-go-fMdQYcON.js → vendor-codemirror-lang-go-CLKXh6B8.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-html-CfgK872x.js → vendor-codemirror-lang-html-CQnNjmg9.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-java-CQj4S3zl.js → vendor-codemirror-lang-java-CokZKqls.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-javascript-Cc2ZYbgX.js → vendor-codemirror-lang-javascript-Kgp6fZRE.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-jinja-BmZZv8g-.js → vendor-codemirror-lang-jinja-DZchyrN1.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-json-CMBS2tG9.js → vendor-codemirror-lang-json-CkdBRvqj.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-less-C6Eo8hVS.js → vendor-codemirror-lang-less-_k-GKz0A.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-liquid-DSTR47-H.js → vendor-codemirror-lang-liquid-DuHUMKoh.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-markdown-BPGOH9ye.js → vendor-codemirror-lang-markdown-CdG1RXm1.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-php-DD9udfPH.js → vendor-codemirror-lang-php-Ca15KQSA.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-python-HahnQaAS.js → vendor-codemirror-lang-python-B4MRHRva.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-rust-nLTovbjv.js → vendor-codemirror-lang-rust-8fLJdxQA.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sass-pL2Yc72v.js → vendor-codemirror-lang-sass-CASr_yQ1.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-sql-BVBnan19.js → vendor-codemirror-lang-sql-Dc4ER-re.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-vue-BqGzJVm1.js → vendor-codemirror-lang-vue-fu2BqdK2.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-wast-B0_m5DqU.js → vendor-codemirror-lang-wast-BkCOgSpV.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-xml-Dj3voadT.js → vendor-codemirror-lang-xml-7e-kPepH.js} +1 -1
- package/dist/assets/{vendor-codemirror-lang-yaml-yu-9Z5u7.js → vendor-codemirror-lang-yaml-Cq3p_9DI.js} +1 -1
- package/dist/assets/vendor-codemirror-language-CZcLdzDM.js +3 -0
- package/dist/assets/{vendor-codemirror-language-data-B1EetJur.js → vendor-codemirror-language-data-B8HKnqZy.js} +2 -2
- package/dist/assets/vendor-codemirror-search-BZNojiZO.js +2 -0
- package/dist/assets/{vendor-codemirror-state-C9awkmn-.js → vendor-codemirror-state--21VQleR.js} +1 -1
- package/dist/assets/vendor-codemirror-view-8PpN-8l4.js +4 -0
- package/dist/assets/vendor-opencode-client-Byb4ZSqI.js +12 -0
- package/dist/assets/vendor-remend-DcBOpbSu.js +24 -0
- package/dist/assets/{vendor-replit-codemirror-vim-B2DJlAhT.js → vendor-replit-codemirror-vim-EX7OnecQ.js} +1 -1
- package/dist/assets/zh-CN-C62wm2Tg.js +16 -0
- package/dist/assets/zh-TW-BgGTiQA6.js +16 -0
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +4 -4
- package/dist/mobile.html +4 -4
- package/package.json +4 -4
- package/server/index.js +58 -1
- package/server/lib/browser-control/DOCUMENTATION.md +8 -1
- package/server/lib/dev-tunnel/DOCUMENTATION.md +6 -0
- package/server/lib/dev-tunnel/runtime.js +94 -38
- package/server/lib/dev-tunnel/tunnel.test.js +16 -2
- package/server/lib/dictation/DOCUMENTATION.md +23 -10
- package/server/lib/dictation/audio.js +28 -0
- package/server/lib/dictation/local/sherpa-recognizer.js +33 -7
- package/server/lib/dictation/local/sherpa-recognizer.test.js +94 -0
- package/server/lib/dictation/local/worker-client.js +28 -10
- package/server/lib/dictation/local/worker-process.js +25 -1
- package/server/lib/dictation/stream-manager.js +160 -53
- package/server/lib/dictation/stream-manager.test.js +108 -7
- package/server/lib/enterprise-mode.d.ts +2 -0
- package/server/lib/enterprise-mode.js +84 -9
- package/server/lib/enterprise-mode.test.js +115 -0
- package/server/lib/fs/DOCUMENTATION.md +3 -2
- package/server/lib/fs/routes.js +28 -1
- package/server/lib/fs/routes.test.js +31 -5
- package/server/lib/git/DOCUMENTATION.md +1 -1
- package/server/lib/git/service.js +61 -2
- package/server/lib/git/service.test.js +141 -0
- package/server/lib/github/DOCUMENTATION.md +18 -0
- package/server/lib/github/checks-summary.js +76 -0
- package/server/lib/github/pr-summaries.js +282 -0
- package/server/lib/github/pr-summaries.test.js +209 -0
- package/server/lib/github/routes.js +42 -77
- package/server/lib/github/routes.test.js +77 -0
- package/server/lib/inherited-env.js +51 -0
- package/server/lib/inherited-env.test.js +59 -0
- package/server/lib/message-search/DOCUMENTATION.md +83 -0
- package/server/lib/message-search/indexer.js +336 -0
- package/server/lib/message-search/indexer.test.js +341 -0
- package/server/lib/message-search/routes.js +92 -0
- package/server/lib/message-search/runtime.js +234 -0
- package/server/lib/message-search/runtime.test.js +108 -0
- package/server/lib/message-search/sqlite.js +74 -0
- package/server/lib/message-search/store.js +289 -0
- package/server/lib/openchamber-control/DOCUMENTATION.md +6 -1
- package/server/lib/openchamber-control/actions.js +1 -1
- package/server/lib/openchamber-control/service.js +21 -2
- package/server/lib/openchamber-control/service.test.js +50 -0
- package/server/lib/openchamber-sessions/routes.js +15 -0
- package/server/lib/openchamber-sessions/routes.test.js +31 -0
- package/server/lib/opencode/DOCUMENTATION.md +43 -38
- package/server/lib/opencode/auth.d.ts +24 -0
- package/server/lib/opencode/auth.js +130 -66
- package/server/lib/opencode/auth.test.js +114 -70
- package/server/lib/opencode/compatibility.js +4 -3
- package/server/lib/opencode/compatibility.test.js +10 -10
- package/server/lib/opencode/feature-routes-runtime.js +3 -0
- package/server/lib/opencode/lifecycle.js +21 -12
- package/server/lib/opencode/lifecycle.test.js +38 -5
- package/server/lib/opencode/provider-source-route.test.js +55 -2
- package/server/lib/opencode/routes.js +17 -4
- package/server/lib/opencode/settings-helpers.js +6 -0
- package/server/lib/opencode/settings-helpers.test.js +1 -1
- package/server/lib/opencode/settings-registry.json +16 -0
- package/server/lib/opencode/settings-runtime.js +9 -0
- package/server/lib/opencode/shutdown-runtime.js +2 -0
- package/server/lib/opencode/v1-migration-topup.js +13 -3
- package/server/lib/opencode/v2-install.test.js +13 -13
- package/server/lib/quota/DOCUMENTATION.md +11 -5
- package/server/lib/quota/providers/claude/auth.js +19 -6
- package/server/lib/quota/providers/claude/auth.test.js +22 -9
- package/server/lib/quota/providers/claude/index.js +3 -3
- package/server/lib/quota/providers/claude/index.test.js +3 -2
- package/server/lib/quota/providers/cline-pass.js +4 -4
- package/server/lib/quota/providers/codex.js +3 -4
- package/server/lib/quota/providers/codex.test.js +1 -1
- package/server/lib/quota/providers/copilot.js +4 -5
- package/server/lib/quota/providers/copilot.test.js +1 -1
- package/server/lib/quota/providers/deepseek.js +3 -4
- package/server/lib/quota/providers/deepseek.test.js +1 -1
- package/server/lib/quota/providers/google/auth.js +1 -3
- package/server/lib/quota/providers/google/index.js +3 -2
- package/server/lib/quota/providers/hyper.js +4 -4
- package/server/lib/quota/providers/index.js +9 -2
- package/server/lib/quota/providers/index.test.js +5 -3
- package/server/lib/quota/providers/kimi.js +16 -11
- package/server/lib/quota/providers/kimi.test.js +81 -38
- package/server/lib/quota/providers/minimax-shared.js +3 -4
- package/server/lib/quota/providers/nanogpt.js +3 -4
- package/server/lib/quota/providers/neuralwatt.js +3 -4
- package/server/lib/quota/providers/neuralwatt.test.js +1 -1
- package/server/lib/quota/providers/openai.js +2 -8
- package/server/lib/quota/providers/opencode-go.js +5 -5
- package/server/lib/quota/providers/opencode-go.test.js +1 -1
- package/server/lib/quota/providers/openrouter.js +30 -6
- package/server/lib/quota/providers/openrouter.test.js +122 -1
- package/server/lib/quota/providers/wafer.js +3 -4
- package/server/lib/quota/providers/xai.js +12 -12
- package/server/lib/quota/providers/zai.js +3 -4
- package/server/lib/quota/providers/zai.test.js +1 -1
- package/server/lib/quota/providers/zhipuai-coding-plan.js +5 -6
- package/server/lib/quota/providers/zhipuai-coding-plan.test.js +1 -1
- package/server/lib/quota/routes.js +1 -1
- package/server/lib/routing/DOCUMENTATION.md +4 -0
- package/server/lib/routing/runtime.js +45 -4
- package/server/lib/routing/runtime.test.js +35 -6
- package/server/lib/scheduled-tasks/DOCUMENTATION.md +27 -0
- package/server/lib/scheduled-tasks/chats-scope.js +50 -0
- package/server/lib/scheduled-tasks/runtime.js +57 -23
- package/server/lib/scheduled-tasks/runtime.test.js +103 -1
- package/server/lib/scheduled-tasks/service.js +37 -29
- package/server/lib/scheduled-tasks/service.test.js +39 -0
- package/server/lib/spaces/DOCUMENTATION.md +54 -9
- package/server/lib/spaces/host.js +24 -3
- package/server/lib/spaces/journey.js +111 -11
- package/server/lib/spaces/journey.test.js +189 -8
- package/server/lib/spaces/places/docker-disk.js +151 -0
- package/server/lib/spaces/places/docker-disk.test.js +167 -0
- package/server/lib/spaces/places/docker-tools.js +11 -1
- package/server/lib/spaces/places/docker.js +4 -2
- package/server/lib/spaces/places/fake-docker.js +36 -2
- package/server/lib/spaces/routes.js +21 -4
- package/server/lib/spaces/routes.test.js +6 -2
- package/server/lib/spaces/space-archive.js +275 -0
- package/server/lib/spaces/space-archive.test.js +194 -0
- package/server/lib/spaces/space-opencode.js +139 -6
- package/server/lib/spaces/space-opencode.test.js +82 -1
- package/server/lib/spaces/space-records.js +3 -0
- package/server/lib/spaces/space-setup.js +10 -5
- package/server/lib/spaces/space-setup.test.js +8 -2
- package/server/lib/terminal/DOCUMENTATION.md +1 -0
- package/server/lib/terminal/runtime.js +6 -1
- package/server/lib/terminal/runtime.test.js +19 -0
- package/server/lib/tts/routes.js +2 -2
- package/server/lib/tts/service.js +8 -8
- package/dist/assets/FilesView-CN34wm_N.js +0 -17
- package/dist/assets/JsonTreeView-B1Xq-k2t.js +0 -1
- package/dist/assets/MarkdownRendererImpl-B_ZcWOvX.js +0 -12
- package/dist/assets/OnboardingScreen-C22bGmnP.js +0 -1
- package/dist/assets/PatchDiff-0xd6UeFB.js +0 -1
- package/dist/assets/SettingsView-m_zoFiaT.js +0 -30
- package/dist/assets/SettingsWindow-CofS020b.js +0 -1
- package/dist/assets/ToolPartDiffPreview-Dq0go_fX.js +0 -8
- package/dist/assets/de-DlgBHUAI.js +0 -10
- package/dist/assets/es-BC8G41U8.js +0 -16
- package/dist/assets/fr-I0z3vVjy.js +0 -14
- package/dist/assets/index-CgR5rJq_.js +0 -41
- package/dist/assets/index-adyy_sEk.css +0 -1
- package/dist/assets/ja-BIElEsY8.js +0 -16
- package/dist/assets/ko-DRnnHetA.js +0 -16
- package/dist/assets/main-DVX34beR.js +0 -886
- package/dist/assets/markdownCore-Cxbkn5NR.js +0 -7
- package/dist/assets/mobile-BrlBrNfZ.js +0 -2
- package/dist/assets/nl-DzUV-kwp.js +0 -16
- package/dist/assets/pl-Bb-cb7k7.js +0 -16
- package/dist/assets/pt-BR-CyIWrTcE.js +0 -16
- package/dist/assets/renderMobileApp-B0z6-x58.js +0 -25
- package/dist/assets/runtimeEndpointReset-uu1DBwLL.js +0 -52
- package/dist/assets/scheduledTasksApi-BuzWT445.js +0 -1
- package/dist/assets/shikiHighlight-BWGrY5YU.js +0 -1
- package/dist/assets/tr-DXEDSoYO.js +0 -7
- package/dist/assets/uk-C8hN--q_.js +0 -16
- package/dist/assets/useRootScrollLock-2rd5Y6gR.js +0 -2
- package/dist/assets/vendor-codemirror-autocomplete-DzPz9Wgq.js +0 -1
- package/dist/assets/vendor-codemirror-language-BgPj_McA.js +0 -3
- package/dist/assets/vendor-codemirror-search-BmS-GmcX.js +0 -2
- package/dist/assets/vendor-codemirror-view-CiLROUVV.js +0 -4
- package/dist/assets/vendor-opencode-client-DSZl7jSi.js +0 -12
- package/dist/assets/vendor-remend-BWYYytN3.js +0 -22
- package/dist/assets/zh-CN-CtzXdjMZ.js +0 -16
- package/dist/assets/zh-TW-Ds0CADSz.js +0 -16
- package/server/lib/opencode/credential-db.js +0 -144
- package/server/lib/opencode/credential-db.test.js +0 -104
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-capacitor-app-BrDJj9I_.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-capacitor-core-B4EWRrHz.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{R as l,j as s,f as Be,r as at}from"./vendor-react-BUCujlKS.js";import{f as qe,B as V,I as $,o as Gs,bt as qn,t as U,O as hu,hE as xu,eZ as He,hF as Pt,g as qa,eH as Jc,b as hn,T as ba,h as Ne,aE as bu,hG as Ko,hH as vu,cv as Jt,cu as Tt,cx as gt,cw as Et,ct as Dt,a1 as Ge,eO as Hn,hI as Qc,hJ as yu,ae as go,hK as Ha,hL as va,ci as Ds,cc as _t,cd as $t,ce as Vt,cf as Ht,cg as qt,ch as as,hM as Mr,aF as Gn,br as xn,aD as Wn,aC as Jn,hN as mr,hO as Pn,an as Un,am as pn,f3 as Gt,hP as Xs,hQ as Rr,hR as ds,l as ct,hS as hi,fk as _n,hT as Yc,fh as Ct,fe as Qt,hU as Kt,cy as Rs,ea as pa,fg as Zs,fi as fn,hV as hs,eg as js,hW as ws,d4 as bt,hX as Zc,hY as ju,hZ as ku,h_ as yi,h$ as wu,i0 as rs,eY as Es,i1 as Js,gS as Ya,gY as rn,i2 as Ga,i3 as Xc,i4 as Or,eb as Lr,ar as ga,i5 as pr,af as sa,i6 as pl,i7 as Nu,cq as bn,cB as vn,cr as yn,i8 as gl,i9 as An,ia as zt,ib as Fr,ic as Kr,id as ra,ie as ed,ig as zn,cG as zr,ih as fl,aI as Su,cz as Cu,dl as Iu,U as Pu,V as Au,W as Tu,a4 as Ur,ii as Eu,ij as Du,co as Mu,cA as gr,ik as td,eQ as es,P as $n,il as fr,im as Ms,fj as sd,io as Ru,n as cs,eu as so,y as nd,x as Ou,i as Lu,j as Fu,ev as Ku,p as zu,ip as Uu,iq as _u,ir as hl,eh as ad,is as $u,it as zo,iu as xl,iv as Bu,iw as Vu,ix as Hu,iy as qu,iz as no,iA as ys,iB as Ss,dt as id,c7 as od,du as rd,c8 as Ks,iC as gn,iD as _r,aR as ta,aS as Fa,iE as ld,iF as Gu,iG as Za,aK as Wu,iH as Fn,ec as cd,iI as dd,eX as Ju,eW as Qu,eF as Yu,iJ as la,iK as zs,iL as Qs,gL as ca,iM as Cs,iN as Zu,iO as bl,iP as ud,iQ as da,iR as Xu,iS as em,R as md,dm as tm,dg as sm,dh as nm,cT as am,eR as im,di as om,db as rm,bz as lm,iT as $r,iU as ha,fd as Ka,iV as vl,iW as za,iX as Ua,c9 as xa,iY as cm,iZ as dm,i_ as um,i$ as mm,j0 as Uo,j1 as yl,j2 as pm,j3 as gm,j4 as fm,j5 as hm,j6 as jl,j7 as xm,z as bm,m as kl,e9 as vm,j8 as ym,j9 as _o,ao as pd,ap as gd,aq as jm,ez as km,ja as fo,jb as wm,jc as Nm,jd as Sm,je as Cm,jf as Im,jg as $o,d5 as Pm,ca as fd,aL as Xn,aM as Am}from"./useAppFontEffects-Dsl_sLrj.js";import{h as It,i as Br,u as re,Q as ps,d$ as Tm,e0 as wl,bd as Em,x as kt,aF as En,D as Ts,a as ln,H as us,R as Nl,d1 as Sl,d8 as Cl,W as oi,p as Dm,e1 as Mm,k as Rm,d0 as Ba,e2 as Om,an as Lm,d5 as Fm,e3 as Km,e4 as zm,s as Um,e as ki,d6 as _m,I as wi,e5 as hd,aE as os,a0 as $m,e6 as Bm,a5 as xd,e7 as bd,bo as vd,z as Wa,bh as yd,ah as Vm,ai as Hm,a_ as Vr,e8 as qm,A as ho,$ as Gm,q as Il,b3 as Pl,bs as zi,b4 as Wm,e9 as Jm,ad as fa,ea as Qm,eb as Al,d_ as Tl,ec as El,b1 as Dl,ed as Ym,ee as Zm,ef as Xm,eg as ep,eh as Ml,b as tp,ei as sp,ej as np,ek as ap,el as ip,em as op,en as rp,ay as lp}from"./index-CgR5rJq_.js";import{u as cp,a9 as Rl,aB as dp,aC as up,aD as mp,ab as Xa,ad as ei,ae as ti,af as si,ag as ya,v as Hr,aE as ua,al as pp,W as As,aF as hr,aG as gp,az as fp,aj as hp,aH as Va,aI as xr,ah as xp,ai as bp,ak as vp}from"./runtimeEndpointReset-uu1DBwLL.js";import{u as _s,c as yp}from"./vendor-zustand-BAGL70zf.js";import{o as Os,s as Rt,b as qr,l as jp,r as Bn,c as br,a as ja,_ as Gr,u as vr}from"./vendor-zod-CxRSdNoV.js";import{s as kp,p as wp}from"./vendor-yaml-3778uTud.js";import{c as Ol,s as Np,C as Ll,P as Sp}from"./shikiHighlight-BWGrY5YU.js";import{getResolvedShikiTheme as Cp}from"./appThemeRegistry-BdEHBA4s.js";import{E as Fl}from"./vendor-codemirror-view-CiLROUVV.js";import{Q as jd}from"./vendor-qrcode-DTJ12-WC.js";import{u as Bo,s as Ip,d as Pp,b as Ap,A as Tp,c as Ep,e as Dp,f as Mp,h as Rp,i as xi,j as Op}from"./PluginPane-2C71F8uF.js";import{toast as Ja}from"./vendor-sonner-DFyL3AvE.js";import{s as Lp}from"./vendor-strip-json-comments-5dJlOkP1.js";import{Y as Fp,U as Kp,X as zp,W as Up,V as _p}from"./vendor-base-ui-DnNniUWp.js";import{_ as $p}from"./vendor-vite-runtime-DD1OZmLC.js";const Kl=()=>{const{t}=qe(),[e,a]=l.useState(null);l.useEffect(()=>{let i=!1;const o=typeof AbortController<"u"?new AbortController:void 0;return(async()=>{try{const d=await It("/api/system/info",{signal:o?.signal,headers:{Accept:"application/json"}});if(!d.ok)return;const c=await d.json().catch(()=>null);if(!c||i)return;const g=typeof c.port=="number"&&Number.isFinite(c.port)&&c.port>0?c.port:null,m=typeof c.tunnelUrl=="string"&&c.tunnelUrl.trim().length>0?c.tunnelUrl.trim():null;a({port:g,tunnelUrl:m})}catch{}})(),()=>{i=!0,o?.abort()}},[]);const n=[];return e?.port!==null&&e?.port!==void 0&&n.push({key:"application",label:t("settings.openchamber.about.field.applicationUrl"),url:`http://localhost:${e.port}/`}),e?.tunnelUrl&&n.push({key:"tunnel",label:t("settings.openchamber.about.field.tunnelUrl"),url:e.tunnelUrl}),n.length===0?null:s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:n.map(i=>s.jsxs(V,{type:"button",variant:"outline",size:"sm",title:i.label,className:"max-w-full gap-1.5 px-2.5",onClick:()=>{Gs(i.url)},children:[s.jsx($,{name:"external-link",className:"size-3.5 shrink-0"}),s.jsx("span",{className:"max-w-64 truncate font-mono typography-micro",children:i.url})]},i.key))})},zl="https://github.com/openchamber/openchamber",Bp="https://discord.gg/ZYRSdnwwKA",Ul="https://x.com/openchamber_dev",Vp=800,Hp={info:null,checking:!1,available:!1,error:null};function qp(t){const e=Be.c(5),[a,n]=l.useState(Hp);let i;e[0]!==t?(i=async()=>{if(t){n(Gp);try{const d=await dp();n({info:d,checking:!1,available:d.available,error:null})}catch(d){const c=d;n({info:null,checking:!1,available:!1,error:c instanceof Error?c.message:String(c)})}}},e[0]=t,e[1]=i):i=e[1];const o=i;let r;return e[2]!==o||e[3]!==a?(r={...a,check:o},e[2]=o,e[3]=a,e[4]=r):r=e[4],r}function Gp(t){return{...t,checking:!0,error:null}}function Wp(t){const e=Be.c(11),[a,n]=l.useState(null);let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={kind:"idle"},e[0]=i):i=e[0];const[o,r]=l.useState(i);let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=async()=>{try{const v=await up();return n(v),v}catch{return null}},e[1]=d):d=e[1];const c=d;let g,m;e[2]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{c()},m=[c],e[2]=g,e[3]=m):(g=e[2],m=e[3]),l.useEffect(g,m);let h;e[4]!==t?(h=async()=>{r({kind:"upgrading"});try{const v=await mp(t);r({kind:"installed",version:v})}catch(v){const k=v;r({kind:"failed",error:k instanceof Error?k.message:t})}},e[4]=t,e[5]=h):h=e[5];const f=h;let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=async v=>{await v().catch(Jp);const k=await c();k?.currentVersion&&r(u=>u.kind!=="installed"||u.version&&u.version.replace(/^v/,"")!==k.currentVersion?u:{kind:"idle"})},e[6]=p):p=e[6];const b=p;let C;return e[7]!==o||e[8]!==a||e[9]!==f?(C={status:a,phase:o,refresh:c,upgrade:f,reloadAfterUpgrade:b},e[7]=o,e[8]=a,e[9]=f,e[10]=C):C=e[10],C}function Jp(){}function Qp(t){const[e,a]=l.useState(null);return l.useEffect(()=>{if(!t)return;let n=!1;return $p(async()=>{const{App:i}=await import("./vendor-capacitor-app-BrDJj9I_.js");return{App:i}},__vite__mapDeps([0,1,2])).then(({App:i})=>i.getInfo()).then(i=>{n||a(i.version.trim()||null)}).catch(()=>{}),()=>{n=!0}},[t]),e}const kd=({initialUpdateDialogOpen:t=!1})=>{const{t:e}=qe(),[a,n]=l.useState(t),[i,o]=l.useState(!1),[r,d]=l.useState(null),c=cp(_s(L=>({info:L.info,checking:L.checking,available:L.available,error:L.error,downloading:L.downloading,downloaded:L.downloaded,progress:L.progress,runtimeType:L.runtimeType,checkForUpdates:L.checkForUpdates,downloadUpdate:L.downloadUpdate,restartToUpdate:L.restartToUpdate}))),{isMobile:g}=qn(),m=l.useMemo(()=>Br(),[]),h=qp(m),f=Qp(m),p=m?{info:h.info,checking:h.checking,available:h.available,error:h.error,checkForUpdates:h.check,runtimeType:"web"}:{info:c.info,checking:c.checking,available:c.available,error:c.error,checkForUpdates:c.checkForUpdates,runtimeType:c.runtimeType},b=r||p.info?.currentVersion||"unknown",C=Wp(e("opencodeUpdate.toast.failed.description")),v=C.status?.currentVersion??null,k=C.phase.kind==="installed"?null:C.status?.availableVersion??null,[u,y]=l.useState(!1),S=(()=>{const L=p.info?.version||"";return m?p.info?.packageManager==="electron"?e("settings.openchamber.about.actions.updateDesktopToVersion",{version:L}):e("settings.openchamber.about.actions.updateServerToVersion",{version:L}):e("settings.openchamber.about.actions.updateOpenChamberToVersion",{version:L})})(),N=p.available&&p.info?.installBlocked==="service-manager",w=p.info?.updateCommand||"openchamber update",A=()=>{p.checkForUpdates(),C.refresh()},x=async()=>{(await qa(w)).ok&&(y(!0),setTimeout(()=>y(!1),2e3))},T=()=>{C.reloadAfterUpgrade(async()=>{await Jc({message:e("opencodeUpdate.toast.reload.message"),mode:"projects",scopes:["all"]})})},M=N?s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.serviceManagerUpdate",{version:p.info?.version||""})}),s.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-surface-elevated/50 p-1 pl-3",children:[s.jsx("code",{className:"flex-1 overflow-x-auto whitespace-nowrap font-mono text-sm text-foreground",children:w}),s.jsx(V,{type:"button",variant:"ghost",size:"icon",onClick:()=>{x()},"aria-label":e(u?"updateDialog.actions.copied":"updateDialog.actions.copyCommand"),children:s.jsx($,{name:u?"check":"clipboard",className:"size-4"})})]})]}):null,E=(()=>{const{phase:L}=C;if(L.kind==="installed")return s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:L.version?e("settings.openchamber.about.openCode.installedVersion",{version:L.version}):e("settings.openchamber.about.openCode.installed")}),s.jsx(V,{type:"button",size:"sm",variant:"outline",onClick:T,children:e("opencodeUpdate.toast.actions.reload")})]});if(!k)return null;if(!C.status?.supported)return s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.openCode.manualUpdate",{version:k})});const P=L.kind==="upgrading";return s.jsxs("div",{className:"space-y-2",children:[s.jsxs(V,{type:"button",size:"sm",variant:"outline",onClick:()=>{C.upgrade()},disabled:P,children:[s.jsx($,{name:P?"loader":"download",className:P?"size-4 animate-spin":"size-4"}),P?e("opencodeUpdate.toast.upgrading.title"):e("settings.openchamber.about.actions.updateOpenCodeToVersion",{version:k})]}),L.kind==="failed"&&s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:L.error})]})})();l.useEffect(()=>{let L=!1;return(async()=>{try{const j=await It("/api/system/info",{method:"GET",headers:{Accept:"application/json"}});if(!j.ok)return;const O=await j.json().catch(()=>null),K=typeof O?.openchamberVersion=="string"&&O.openchamberVersion.trim().length>0?O.openchamberVersion.trim():null;L||d(K)}catch{L||d(null)}})(),()=>{L=!0}},[]);const D=l.useRef(!1);l.useEffect(()=>{if(p.checking)o(!0),D.current=!0;else if(i){const L=setTimeout(()=>{o(!1),D.current&&!p.available&&!p.error&&(U.success(e(m?"settings.openchamber.about.toast.serverLatestVersion":"settings.openchamber.about.toast.latestVersion")),D.current=!1)},Vp);return()=>clearTimeout(L)}},[e,m,p.checking,i,p.available,p.error]);const F=p.checking||i;return g?s.jsxs("div",{className:"w-full space-y-6 pb-2",children:[s.jsxs("div",{className:"flex flex-col items-center text-center",children:[s.jsx(hu,{width:72,height:72}),s.jsx("h2",{className:`mt-4 ${xu}`,children:"OpenChamber"}),s.jsx("div",{className:"mt-2 space-y-1 typography-ui text-muted-foreground",children:m?s.jsxs(s.Fragment,{children:[s.jsx("p",{children:e("settings.openchamber.about.native.serverOpenChamberVersion",{version:b})}),s.jsx("p",{children:e("settings.openchamber.about.native.serverOpenCodeVersion",{version:v||e("settings.openchamber.about.state.unknown")})}),f&&s.jsx("p",{children:e("settings.openchamber.about.native.appVersion",{version:f})})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{children:e("aboutDialog.openChamberVersionLabel",{version:b})}),s.jsx("p",{children:e("aboutDialog.openCodeVersionLabel",{version:v||e("settings.openchamber.about.state.unknown")})})]})}),s.jsx(Kl,{})]}),s.jsxs("div",{className:"flex justify-center",children:[!p.available&&!p.error&&s.jsxs(V,{type:"button",variant:"outline",size:"sm",onClick:A,disabled:F,className:"h-10 w-auto justify-center gap-2 rounded-xl px-4",children:[F?s.jsx($,{name:"loader",className:"size-4 animate-spin"}):s.jsx($,{name:"refresh",className:"size-4"}),e(F?"settings.openchamber.about.state.checking":m?"settings.openchamber.about.actions.checkServerForUpdates":"settings.openchamber.about.actions.checkForUpdates")]}),!F&&p.available&&!N&&s.jsxs(V,{type:"button",variant:"default",size:"sm",onClick:()=>n(!0),className:"h-10 w-auto justify-center gap-2 rounded-xl px-4",children:[s.jsx($,{name:"download",className:"size-4"}),S]})]}),M,E&&s.jsx("div",{className:"flex justify-center text-center",children:E}),p.error&&s.jsx("p",{className:"rounded-xl border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-3 py-2 typography-meta text-[var(--status-error)]",children:p.error}),s.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[s.jsxs("div",{className:"flex items-center justify-center gap-5",children:[s.jsxs("a",{href:zl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground",children:[s.jsx($,{name:"github-fill",className:"size-5"}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:Bp,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground",children:[s.jsx($,{name:"discord-fill",className:"size-5"}),s.jsx("span",{children:"Discord"})]})]}),s.jsxs("a",{href:Ul,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground",children:[s.jsx($,{name:"twitter-xfill",className:"size-5"}),s.jsx("span",{children:"@openchamber_dev"})]})]}),s.jsx("p",{className:"text-center typography-ui text-muted-foreground/60",children:e("aboutDialog.footerNote")}),s.jsx(Rl,{open:a,onOpenChange:n,info:p.info,downloading:c.downloading,downloaded:c.downloaded,progress:c.progress,error:p.error,onDownload:c.downloadUpdate,onRestart:c.restartToUpdate,runtimeType:p.runtimeType})]}):s.jsxs(He,{divider:!1,children:[s.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 overflow-hidden flex flex-col",children:[s.jsxs("div",{className:"flex flex-col @xl:flex-row @xl:items-center justify-between gap-4 px-4 py-3 border-b border-border/40",children:[s.jsxs("div",{className:"flex min-w-0 flex-col",children:[s.jsx("span",{className:Pt,children:e("settings.openchamber.about.field.version")}),s.jsx("span",{className:"typography-meta text-muted-foreground font-mono",children:b})]}),s.jsxs("div",{className:"flex min-w-0 flex-col",children:[s.jsx("span",{className:Pt,children:e("settings.openchamber.about.field.openCodeVersion")}),s.jsx("span",{className:"typography-meta text-muted-foreground font-mono",children:v||e("settings.openchamber.about.state.unknown")})]}),s.jsxs("div",{className:"flex items-center gap-3",children:[p.checking&&s.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[s.jsx($,{name:"loader",className:"h-4 w-4 animate-spin"}),s.jsx("span",{className:"typography-meta",children:e("settings.openchamber.about.state.checking")})]}),!p.checking&&p.available&&!N&&s.jsxs(V,{size:"sm",variant:"default",onClick:()=>n(!0),children:[s.jsx($,{name:"download",className:"h-4 w-4 mr-1"}),S]}),!p.checking&&!p.available&&!p.error&&s.jsx("span",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.about.state.upToDate")}),s.jsx(V,{size:"sm",variant:"outline",onClick:A,disabled:p.checking,children:e("settings.openchamber.about.actions.checkForUpdates")})]})]}),M&&s.jsx("div",{className:"px-4 py-3 border-b border-border/40",children:M}),E&&s.jsx("div",{className:"px-4 py-3 border-b border-border/40",children:E}),p.error&&s.jsx("div",{className:"px-3 py-2 border-b border-border/40",children:s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:p.error})}),s.jsxs("div",{className:"flex flex-col gap-2 border-b border-border/40 px-4 py-3 @xl:flex-row @xl:items-center @xl:justify-between",children:[s.jsx("span",{className:Pt,children:e("settings.openchamber.about.field.instanceUrls")}),s.jsx(Kl,{})]}),s.jsxs("div",{className:"flex items-center gap-4 px-4 py-4",children:[s.jsxs("a",{href:zl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-muted-foreground hover:text-foreground typography-meta transition-colors",children:[s.jsx($,{name:"github-fill",className:"h-4 w-4"}),s.jsx("span",{children:"GitHub"})]}),s.jsxs("a",{href:Ul,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-muted-foreground hover:text-foreground typography-meta transition-colors",children:[s.jsx($,{name:"twitter-xfill",className:"h-4 w-4"}),s.jsx("span",{children:"@openchamber_dev"})]})]})]}),s.jsx(Rl,{open:a,onOpenChange:n,info:p.info,downloading:c.downloading,downloaded:c.downloaded,progress:c.progress,error:p.error,onDownload:c.downloadUpdate,onRestart:c.restartToUpdate,runtimeType:p.runtimeType})]})},Yp=(t,e,a)=>t&&e.some(i=>i.path===t)?t:(e.find(i=>i.id===a)??e[0])?.path??null,en=()=>{const t=Be.c(4),e=re(Zp),a=hn(Xp),n=hn(eg);let i;return t[0]!==n||t[1]!==a||t[2]!==e?(i=Yp(e,a,n),t[0]=n,t[1]=a,t[2]=e,t[3]=i):i=t[3],i};function Zp(t){return t.settingsProjectPath}function Xp(t){return t.projects}function eg(t){return t.activeProjectId}const tg=t=>[...t].sort((e,a)=>(e.label||e.path).localeCompare(a.label||a.path)),Ni=t=>{const e=Be.c(75),{className:a}=t,{t:n}=qe(),{currentTheme:i}=ba(),o=re(sg),[r,d]=l.useState(!1),c=hn(ng),g=en(),m=re(ag),h=ps();let f;e[0]!==c?(f=tg(c),e[0]=c,e[1]=f):f=e[1];const p=f;let b;e[2]!==g||e[3]!==p?(b=p.find(F=>F.path===g)??p[0]??null,e[2]=g,e[3]=p,e[4]=b):b=e[4];const C=b;if(h||!C)return null;let v;e[5]!==m||e[6]!==p?(v=F=>{const L=p.find(P=>P.id===F);L&&m(L.path)},e[5]=m,e[6]=p,e[7]=v):v=e[7];const k=v;if(o){let F;e[8]!==a?(F=Ne(a),e[8]=a,e[9]=F):F=e[9];let L;e[10]!==n?(L=n("settings.shared.projectSelector.switchProjectAria"),e[10]=n,e[11]=L):L=e[11];let P;e[12]!==n?(P=n("settings.shared.projectSelector.switchProjectTitle"),e[12]=n,e[13]=P):P=e[13];let j,O;e[14]===Symbol.for("react.memo_cache_sentinel")?(j=()=>d(!0),O=Ne(bu({size:"touch"}),"w-full min-w-0"),e[14]=j,e[15]=O):(j=e[14],O=e[15]);let K;e[16]!==C||e[17]!==i?(K=s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label font-medium",children:s.jsx(Ko,{project:C,theme:i})}),e[16]=C,e[17]=i,e[18]=K):K=e[18];let H;e[19]===Symbol.for("react.memo_cache_sentinel")?(H=s.jsx($,{name:"arrow-down-s",className:"size-4 opacity-50"}),e[19]=H):H=e[19];let q;e[20]!==r||e[21]!==L||e[22]!==P||e[23]!==O||e[24]!==K?(q=s.jsxs("button",{type:"button","aria-label":L,title:P,"aria-haspopup":"dialog","aria-expanded":r,onClick:j,className:O,children:[K,H]}),e[20]=r,e[21]=L,e[22]=P,e[23]=O,e[24]=K,e[25]=q):q=e[25];let Z;e[26]!==q||e[27]!==F?(Z=s.jsx("div",{className:F,children:q}),e[26]=q,e[27]=F,e[28]=Z):Z=e[28];let ae;e[29]===Symbol.for("react.memo_cache_sentinel")?(ae=()=>d(!1),e[29]=ae):ae=e[29];const B=C.id;let G;e[30]!==n?(G=n("settings.shared.projectSelector.sheetTitle"),e[30]=n,e[31]=G):G=e[31];let _;e[32]!==n?(_=n("settings.shared.projectSelector.searchPlaceholder"),e[32]=n,e[33]=_):_=e[33];let z;e[34]!==C.id||e[35]!==i||e[36]!==k||e[37]!==r||e[38]!==p||e[39]!==G||e[40]!==_?(z=s.jsx(vu,{open:r,onClose:ae,projects:p,selectedProjectId:B,onSelectProject:k,theme:i,title:G,searchPlaceholder:_}),e[34]=C.id,e[35]=i,e[36]=k,e[37]=r,e[38]=p,e[39]=G,e[40]=_,e[41]=z):z=e[41];let te;return e[42]!==Z||e[43]!==z?(te=s.jsxs(s.Fragment,{children:[Z,z]}),e[42]=Z,e[43]=z,e[44]=te):te=e[44],te}let u;e[45]!==a?(u=Ne(a),e[45]=a,e[46]=u):u=e[46];const y=C.id;let S;e[47]!==k?(S=F=>{F&&k(F)},e[47]=k,e[48]=S):S=e[48];let N;e[49]!==n?(N=n("settings.shared.projectSelector.switchProjectAria"),e[49]=n,e[50]=N):N=e[50];let w;e[51]!==n?(w=n("settings.shared.projectSelector.switchProjectTitle"),e[51]=n,e[52]=w):w=e[52];let A;e[53]!==C||e[54]!==i?(A=s.jsx(Jt,{children:s.jsx(Ko,{project:C,theme:i})}),e[53]=C,e[54]=i,e[55]=A):A=e[55];let x;e[56]!==N||e[57]!==w||e[58]!==A?(x=s.jsx(Tt,{size:"settings",className:"w-full","aria-label":N,title:w,children:A}),e[56]=N,e[57]=w,e[58]=A,e[59]=x):x=e[59];let T;if(e[60]!==i||e[61]!==p){let F;e[63]!==i?(F=L=>s.jsx(gt,{value:L.id,className:"max-w-[24rem] truncate",children:s.jsx(Ko,{project:L,theme:i})},L.id),e[63]=i,e[64]=F):F=e[64],T=p.map(F),e[60]=i,e[61]=p,e[62]=T}else T=e[62];let M;e[65]!==T?(M=s.jsx(Et,{fitContent:!0,children:T}),e[65]=T,e[66]=M):M=e[66];let E;e[67]!==C.id||e[68]!==x||e[69]!==M||e[70]!==S?(E=s.jsxs(Dt,{value:y,onValueChange:S,children:[x,M]}),e[67]=C.id,e[68]=x,e[69]=M,e[70]=S,e[71]=E):E=e[71];let D;return e[72]!==E||e[73]!==u?(D=s.jsx("div",{className:u,children:E}),e[72]=E,e[73]=u,e[74]=D):D=e[74],D};function sg(t){return t.isMobile}function ng(t){return t.projects}function ag(t){return t.setSettingsProjectPath}const Wr=t=>{const e=Be.c(16),{value:a,onChange:n}=t,{t:i}=qe();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx($,{name:"search",className:"pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground","aria-hidden":!0}),e[0]=o):o=e[0];let r;e[1]!==n?(r=h=>n(h.target.value),e[1]=n,e[2]=r):r=e[2];let d;e[3]!==n||e[4]!==a?(d=h=>{h.key==="Escape"&&a&&(h.preventDefault(),h.stopPropagation(),n(""))},e[3]=n,e[4]=a,e[5]=d):d=e[5];let c;e[6]!==i?(c=i("settings.common.sidebar.searchPlaceholder"),e[6]=i,e[7]=c):c=e[7];let g;e[8]!==i?(g=i("settings.common.sidebar.searchPlaceholder"),e[8]=i,e[9]=g):g=e[9];let m;return e[10]!==r||e[11]!==d||e[12]!==c||e[13]!==g||e[14]!==a?(m=s.jsxs("div",{className:"relative mt-3",children:[o,s.jsx(Ge,{value:a,onChange:r,onKeyDown:d,placeholder:c,"aria-label":g,className:"h-8 pl-7 typography-meta"})]}),e[10]=r,e[11]=d,e[12]=c,e[13]=g,e[14]=a,e[15]=m):m=e[15],m},Jr=t=>{const e=Be.c(5),{query:a}=t,{t:n}=qe();let i;e[0]!==a||e[1]!==n?(i=n("settings.common.sidebar.noMatches",{query:a.trim()}),e[0]=a,e[1]=n,e[2]=i):i=e[2];let o;return e[3]!==i?(o=s.jsx("p",{className:"px-2 py-6 text-center typography-meta text-muted-foreground",children:i}),e[3]=i,e[4]=o):o=e[4],o};function ig(t,e){return`opencode:sidebar-group:${t}:${e}`}const yr=t=>{const e=Be.c(33),{label:a,count:n,storageKey:i,defaultExpanded:o,children:r}=t,d=o===void 0?!0:o;let c;e[0]!==a||e[1]!==i?(c=ig(i,a),e[0]=a,e[1]=i,e[2]=c):c=e[2];const g=c,m=l.useId();let h;e[3]!==d||e[4]!==g?(h=()=>{try{const E=localStorage.getItem(g);if(E!==null)return E==="true"}catch{}return d},e[3]=d,e[4]=g,e[5]=h):h=e[5];const[f,p]=at.useState(h);let b,C;e[6]!==f||e[7]!==g?(b=()=>{try{localStorage.setItem(g,String(f))}catch{}},C=[g,f],e[6]=f,e[7]=g,e[8]=b,e[9]=C):(b=e[8],C=e[9]),at.useEffect(b,C);let v;e[10]===Symbol.for("react.memo_cache_sentinel")?(v=()=>p(og),e[10]=v):v=e[10];let k;e[11]===Symbol.for("react.memo_cache_sentinel")?(k=Ne("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-ring"),e[11]=k):k=e[11];const u=!f&&"-rotate-90";let y;e[12]!==u?(y=Ne("h-3.5 w-3.5 flex-shrink-0 transition-transform duration-200",u),e[12]=u,e[13]=y):y=e[13];let S;e[14]!==y?(S=s.jsx($,{name:"arrow-down-s",className:y}),e[14]=y,e[15]=S):S=e[15];let N;e[16]!==a?(N=s.jsx("span",{className:"flex-1 truncate",children:a}),e[16]=a,e[17]=N):N=e[17];let w;e[18]!==n?(w=s.jsx("span",{className:"ml-1 tabular-nums opacity-60",children:n}),e[18]=n,e[19]=w):w=e[19];let A;e[20]!==m||e[21]!==f||e[22]!==S||e[23]!==N||e[24]!==w?(A=s.jsxs("button",{type:"button",onClick:v,"aria-expanded":f,"aria-controls":m,className:k,children:[S,N,w]}),e[20]=m,e[21]=f,e[22]=S,e[23]=N,e[24]=w,e[25]=A):A=e[25];const x=!f;let T;e[26]!==r||e[27]!==m||e[28]!==x?(T=s.jsx("div",{id:m,hidden:x,className:"mt-0.5 space-y-0.5 ml-2 pl-3 border-l-2 border-[var(--interactive-border)]",children:r}),e[26]=r,e[27]=m,e[28]=x,e[29]=T):T=e[29];let M;return e[30]!==A||e[31]!==T?(M=s.jsxs("div",{children:[A,T]}),e[30]=A,e[31]=T,e[32]=M):M=e[32],M};function og(t){return!t}const rg=({onItemSelect:t})=>{const{t:e}=qe(),[a,n]=l.useState(""),[i,o]=l.useState(null),[r,d]=l.useState(""),[c,g]=l.useState(null),[m,h]=l.useState(null),[f,p]=l.useState(!1),[b,C]=l.useState(null),{selectedAgentName:v,setSelectedAgent:k,setAgentDraft:u,createAgent:y,deleteAgent:S,loadAgents:N,fetchAgentEntity:w}=Hn(_s(_=>({selectedAgentName:_.selectedAgentName,setSelectedAgent:_.setSelectedAgent,setAgentDraft:_.setAgentDraft,createAgent:_.createAgent,deleteAgent:_.deleteAgent,loadAgents:_.loadAgents,fetchAgentEntity:_.fetchAgentEntity}))),A=en(),x=Hn(_=>Qc(_,A));l.useEffect(()=>{N(A)},[N,A]);const T="bg-background",M=()=>{const _="new-agent";let z=_,te=1;for(;x.some(Q=>Q.name===z);)z=`${_}-${te}`,te++;u({name:z,scope:"user"}),k(z),t?.()},E=async _=>{if(Ha(_)){U.error(e("settings.agents.sidebar.toast.builtInCannotDelete"));return}g(_),h("delete")},D=async _=>{Ha(_)&&(g(_),h("reset"))},F=()=>{g(null),h(null)},L=async()=>{if(!(!c||!m)){p(!0);try{(await S(c.name,c.scope,A)).ok?(m==="delete"?U.success(e("settings.agents.sidebar.toast.agentDeleted",{name:c.name})):U.success(e("settings.agents.sidebar.toast.agentReset",{name:c.name})),F()):m==="delete"?U.error(e("settings.agents.sidebar.toast.deleteFailed")):U.error(e("settings.agents.sidebar.toast.resetFailed"))}catch(_){const z=_ instanceof Error?_.message:"",te=/built-in|not deletable|not found/i.test(z);m==="delete"?U.error(e(te?"settings.agents.sidebar.toast.definitionNotFound":"settings.agents.sidebar.toast.deleteFailed")):U.error(e("settings.agents.sidebar.toast.resetFailed"))}p(!1)}},P=async _=>{const z=_.name;let te=1,Q=`${z}-copy`;for(;x.some(fe=>fe.name===Q);)te++,Q=`${z}-copy-${te}`;const X=_,pe=await w(_.name,A);if(!pe){U.error(e("settings.agents.sidebar.toast.renameFailed"));return}const je=pe.config.request?.body;u({name:Q,scope:pe.scope??X.scope??"user",description:pe.config.description??void 0,model:pe.config.model??null,system:pe.config.system??void 0,steps:pe.config.steps??void 0,temperature:je?.temperature,top_p:je?.top_p,mode:pe.config.mode??X.mode,permissions:pe.config.permissions??void 0}),k(Q),t?.()},j=_=>{d(_.name),o(_)},O=async()=>{if(!i)return;const _=r.trim().replace(/\s+/g,"-");if(!_){U.error(e("settings.agents.sidebar.toast.agentNameRequired"));return}if(_===i.name){o(null);return}if(x.some(X=>X.name===_)){U.error(e("settings.agents.sidebar.toast.agentExists"));return}const z=i,te=await w(i.name,A);if(!te){U.error(e("settings.agents.sidebar.toast.renameFailed"));return}(await y({...te.config,name:_,scope:te.scope??z.scope},A)).ok?(await S(i.name,z.scope,A)).ok?(U.success(e("settings.agents.sidebar.toast.agentRenamed",{name:_})),k(_)):U.error(e("settings.agents.sidebar.toast.removeOldAfterRenameFailed")):U.error(e("settings.agents.sidebar.toast.renameFailed")),o(null)},K=_=>{switch(_){case"primary":return s.jsx($,{name:"ai-agent",className:"h-3 w-3 text-primary"});case"all":return s.jsx($,{name:"ai-agent-fill",className:"h-3 w-3 text-primary"});case"subagent":return s.jsx($,{name:"robot",className:"h-3 w-3 text-primary"});default:return null}},H=x.filter(_=>!yu(_)),q=H.filter(_=>go([_.name,_.description],a)),Z=q.filter(Ha),ae=q.filter(_=>!Ha(_)),{groupedCustomAgents:B,ungroupedCustomAgents:G}=at.useMemo(()=>{const _={},z=[];for(const Q of ae){const X=Q;X.group?(_[X.group]||(_[X.group]=[]),_[X.group].push(Q)):z.push(Q)}return{groupedCustomAgents:Object.keys(_).sort((Q,X)=>Q.localeCompare(X)).map(Q=>({name:Q,agents:_[Q]})),ungroupedCustomAgents:z}},[ae]);return s.jsxs("div",{className:Ne("flex h-full flex-col",T),children:[s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[s.jsx("h2",{className:`${va} mb-3`,children:e("settings.agents.sidebar.title")}),s.jsx(Ni,{className:"mb-3"}),s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:e("settings.agents.sidebar.total",{count:H.length})}),s.jsx(V,{size:"sm","data-settings-item":"agents.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:M,children:s.jsx($,{name:"add",className:"h-3.5 w-3.5"})})]}),H.length>0?s.jsx(Wr,{value:a,onChange:n}):null]}),s.jsx(Ds,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:H.length===0?s.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[s.jsx($,{name:"robot-2",className:"mx-auto mb-3 h-10 w-10 opacity-50"}),s.jsx("p",{className:"typography-ui-label font-medium",children:e("settings.agents.sidebar.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:e("settings.agents.sidebar.empty.description")})]}):q.length===0?s.jsx(Jr,{query:a}):s.jsxs(s.Fragment,{children:[Z.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:e("settings.agents.sidebar.section.builtIn")}),Z.map(_=>s.jsx(Vo,{agent:_,isSelected:v===_.name,onSelect:()=>{k(_.name),t?.()},onReset:()=>D(_),onDuplicate:()=>{P(_)},getAgentModeIcon:K,isMenuOpen:b===_.name,onMenuOpenChange:z=>C(z?_.name:null)},_.name))]}),ae.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:e("settings.agents.sidebar.section.custom")}),B.map(({name:_,agents:z})=>s.jsx(yr,{label:_,count:z.length,storageKey:"agents",children:z.map(te=>s.jsx(Vo,{agent:te,isSelected:v===te.name,onSelect:()=>{k(te.name),t?.()},onRename:()=>j(te),onDelete:()=>E(te),onDuplicate:()=>{P(te)},getAgentModeIcon:K,isMenuOpen:b===te.name,onMenuOpenChange:Q=>C(Q?te.name:null)},te.name))},_)),G.map(_=>s.jsx(Vo,{agent:_,isSelected:v===_.name,onSelect:()=>{k(_.name),t?.()},onRename:()=>j(_),onDelete:()=>E(_),onDuplicate:()=>{P(_)},getAgentModeIcon:K,isMenuOpen:b===_.name,onMenuOpenChange:z=>C(z?_.name:null)},_.name))]})]})}),s.jsx(_t,{open:c!==null&&m!==null,onOpenChange:_=>{!_&&!f&&F()},children:s.jsxs($t,{className:"max-w-md",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:e(m==="delete"?"settings.agents.sidebar.dialog.deleteTitle":"settings.agents.sidebar.dialog.resetTitle")}),s.jsx(qt,{children:m==="delete"?e("settings.agents.sidebar.dialog.deleteDescription",{name:c?.name??""}):e("settings.agents.sidebar.dialog.resetDescription",{name:c?.name??""})})]}),s.jsxs(as,{children:[s.jsx(V,{size:"sm",variant:"ghost",onClick:F,disabled:f,children:e("settings.common.actions.cancel")}),s.jsx(V,{size:"sm",onClick:L,disabled:f,children:e(m==="delete"?"settings.common.actions.delete":"settings.common.actions.reset")})]})]})}),s.jsx(_t,{open:i!==null,onOpenChange:_=>!_&&o(null),children:s.jsxs($t,{children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:e("settings.agents.sidebar.renameDialog.title")}),s.jsx(qt,{children:e("settings.agents.sidebar.renameDialog.description",{name:i?.name??""})})]}),s.jsx(Ge,{value:r,onChange:_=>d(_.target.value),placeholder:e("settings.agents.sidebar.renameDialog.placeholder"),className:"text-foreground placeholder:text-muted-foreground",onKeyDown:_=>{_.key==="Enter"&&O()}}),s.jsxs(as,{children:[s.jsx(V,{size:"sm",variant:"ghost",onClick:()=>o(null),children:e("settings.common.actions.cancel")}),s.jsx(V,{size:"sm",onClick:O,children:e("settings.common.actions.rename")})]})]})})]})},Vo=t=>{const e=Be.c(52),{agent:a,isSelected:n,onSelect:i,onDelete:o,onReset:r,onRename:d,onDuplicate:c,getAgentModeIcon:g,isMenuOpen:m,onMenuOpenChange:h}=t,{t:f}=qe(),p=a;let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=Mr(),e[0]=b):b=e[0];const C=b,[v,k]=l.useState(!1);let u;e[1]!==o||e[2]!==c||e[3]!==d||e[4]!==r||e[5]!==f?(u=ae=>s.jsxs(s.Fragment,{children:[d&&s.jsxs(ae,{onClick:B=>{B.stopPropagation(),d()},children:[s.jsx($,{name:"edit",className:"h-4 w-4 mr-px"}),f("settings.common.actions.rename")]}),s.jsxs(ae,{onClick:B=>{B.stopPropagation(),c()},children:[s.jsx($,{name:"file-copy",className:"h-4 w-4 mr-px"}),f("settings.common.actions.duplicate")]}),r&&s.jsxs(ae,{onClick:B=>{B.stopPropagation(),r()},children:[s.jsx($,{name:"restart",className:"h-4 w-4 mr-px"}),f("settings.common.actions.reset")]}),o&&s.jsxs(ae,{onClick:B=>{B.stopPropagation(),o()},className:"text-destructive focus:text-destructive",children:[s.jsx($,{name:"delete-bin",className:"h-4 w-4 mr-px"}),f("settings.common.actions.delete")]})]}),e[1]=o,e[2]=c,e[3]=d,e[4]=r,e[5]=f,e[6]=u):u=e[6];const y=u,S=n?"bg-interactive-selection":"hover:bg-interactive-hover";let N;e[7]!==S?(N=Ne("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",S),e[7]=S,e[8]=N):N=e[8];let w;e[9]===Symbol.for("react.memo_cache_sentinel")?(w=C?void 0:ae=>{ae.preventDefault(),k(!0)},e[9]=w):w=e[9];let A;e[10]!==N?(A=s.jsx("div",{className:N,onContextMenu:w}),e[10]=N,e[11]=A):A=e[11];let x;e[12]!==a.name?(x=s.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:a.name}),e[12]=a.name,e[13]=x):x=e[13];let T;e[14]!==a.mode||e[15]!==g?(T=g(a.mode),e[14]=a.mode,e[15]=g,e[16]=T):T=e[16];let M;e[17]!==a||e[18]!==p.scope||e[19]!==f?(M=(p.scope||Ha(a))&&s.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:Ha(a)?f("settings.agents.sidebar.badge.system"):p.scope}),e[17]=a,e[18]=p.scope,e[19]=f,e[20]=M):M=e[20];let E;e[21]!==x||e[22]!==T||e[23]!==M?(E=s.jsxs("div",{className:"flex items-center gap-1.5",children:[x,T,M]}),e[21]=x,e[22]=T,e[23]=M,e[24]=E):E=e[24];let D;e[25]!==a.description?(D=a.description&&s.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:a.description}),e[25]=a.description,e[26]=D):D=e[26];let F;e[27]!==i||e[28]!==E||e[29]!==D?(F=s.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-ring",tabIndex:0,children:[E,D]}),e[27]=i,e[28]=E,e[29]=D,e[30]=F):F=e[30];let L;e[31]!==h?(L=ae=>{ae&&k(!1),h(ae)},e[31]=h,e[32]=L):L=e[32];let P;e[33]===Symbol.for("react.memo_cache_sentinel")?(P=s.jsx(Wn,{asChild:!0,children:s.jsx(V,{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:s.jsx($,{name:"more-2",className:"h-3.5 w-3.5"})})}),e[33]=P):P=e[33];let j;e[34]!==y?(j=s.jsx(Gn,{align:"end",className:"w-fit min-w-20",children:y(xn)}),e[34]=y,e[35]=j):j=e[35];let O;e[36]!==m||e[37]!==L||e[38]!==j?(O=s.jsxs(Jn,{open:m,onOpenChange:L,children:[P,j]}),e[36]=m,e[37]=L,e[38]=j,e[39]=O):O=e[39];let K;e[40]!==F||e[41]!==O?(K=s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[F,O]}),e[40]=F,e[41]=O,e[42]=K):K=e[42];let H;e[43]!==K||e[44]!==A?(H=s.jsx(ti,{render:A,children:K}),e[43]=K,e[44]=A,e[45]=H):H=e[45];let q;e[46]!==y?(q=s.jsx(Xa,{className:"w-fit min-w-20",children:y(ei)}),e[46]=y,e[47]=q):q=e[47];let Z;return e[48]!==v||e[49]!==H||e[50]!==q?(Z=s.jsxs(si,{open:v,onOpenChange:k,children:[H,q]}),e[48]=v,e[49]=H,e[50]=q,e[51]=Z):Z=e[51],Z},ns=t=>{const e=Be.c(22),{children:a,className:n,outerClassName:i,title:o,titleLeading:r,titleAccessory:d,description:c,headerEnd:g,showSaveStatus:m,onBlurCapture:h}=t,f=m===void 0?!1:m,p=o!=null||c!=null||g!=null||f,b=typeof o=="string"||typeof o=="number",C=r!=null||d!=null;let v;e[0]!==i?(v=Ne("h-full overlay-scrollbar-wrapper--stable-gutter",i),e[0]=i,e[1]=v):v=e[1];let k;e[2]!==n?(k=Ne("mx-auto max-w-[840px] space-y-0 px-6 py-6 @3xl:px-12 @3xl:py-8","[&>section:first-of-type]:border-t-0 [&>section:first-of-type]:pt-0",n),e[2]=n,e[3]=k):k=e[3];let u;e[4]!==c||e[5]!==p||e[6]!==C||e[7]!==g||e[8]!==b||e[9]!==f||e[10]!==o||e[11]!==d||e[12]!==r?(u=p&&s.jsxs("div",{className:"mb-2 flex flex-wrap items-start justify-between gap-x-4 gap-y-3 pb-6",children:[s.jsxs("div",{className:"min-w-0 flex-1 basis-64 space-y-1",children:[o!=null?b?C?s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[r,s.jsx("h1",{"data-settings-page-heading":!0,tabIndex:-1,className:Ne(mr,"min-w-0 truncate"),children:o}),s.jsx("span",{className:"shrink-0",children:d})]}):s.jsx("h1",{"data-settings-page-heading":!0,tabIndex:-1,className:mr,children:o}):o:null,c!=null?typeof c=="string"||typeof c=="number"?s.jsx("p",{className:Pn,children:c}):c:null]}),s.jsxs("div",{className:"flex shrink-0 flex-wrap items-center justify-end gap-3",children:[g,f&&s.jsx(cg,{})]})]}),e[4]=c,e[5]=p,e[6]=C,e[7]=g,e[8]=b,e[9]=f,e[10]=o,e[11]=d,e[12]=r,e[13]=u):u=e[13];let y;e[14]!==a||e[15]!==h||e[16]!==k||e[17]!==u?(y=s.jsxs("div",{className:k,onBlurCapture:h,children:[u,a]}),e[14]=a,e[15]=h,e[16]=k,e[17]=u,e[18]=y):y=e[18];let S;return e[19]!==v||e[20]!==y?(S=s.jsx(Ds,{outerClassName:v,className:"w-full @container",children:y}),e[19]=v,e[20]=y,e[21]=S):S=e[21],S},lg=500,cg=()=>{const t=Be.c(13),{t:e}=qe(),a=l.useSyncExternalStore(Tm,wl,wl),[n,i]=l.useState(!1);let o,r;if(t[0]!==a?(o=()=>{if(a!=="saving"){i(!1);return}const m=setTimeout(()=>i(!0),lg);return()=>clearTimeout(m)},r=[a],t[0]=a,t[1]=o,t[2]=r):(o=t[1],r=t[2]),l.useEffect(o,r),a==="error"){let m;t[3]===Symbol.for("react.memo_cache_sentinel")?(m=s.jsx($,{name:"error-warning",className:"size-3.5"}),t[3]=m):m=t[3];let h;t[4]!==e?(h=e("settings.common.status.saveFailed"),t[4]=e,t[5]=h):h=t[5];let f;return t[6]!==h?(f=s.jsxs("div",{"aria-live":"assertive",className:"flex shrink-0 items-center gap-1.5 typography-meta text-[var(--status-error)]",children:[m,s.jsx("span",{children:h})]}),t[6]=h,t[7]=f):f=t[7],f}if(a!=="saving"||!n)return null;let d;t[8]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx($,{name:"loader-4",className:"size-3.5 animate-spin"}),t[8]=d):d=t[8];let c;t[9]!==e?(c=e("settings.common.actions.saving"),t[9]=e,t[10]=c):c=t[10];let g;return t[11]!==c?(g=s.jsxs("div",{"aria-live":"polite",className:"flex shrink-0 items-center gap-1.5 typography-meta text-muted-foreground",children:[d,s.jsx("span",{children:c})]}),t[11]=c,t[12]=g):g=t[12],g},Us={ok:!0,changed:!1},Tn={ok:!0,changed:!0},xs=t=>({ok:!1,reason:t}),dg=t=>t instanceof HTMLElement?t.matches('input, textarea, [contenteditable="true"]'):!1,ni=t=>{const{t:e}=qe(),[a,n]=l.useState(0),i=l.useRef(t);i.current=t;const o=l.useRef(e);o.current=e;const r=l.useRef(!1),d=l.useRef(!1),c=l.useRef(!1),g=l.useCallback(()=>{n(f=>f+1)},[]),m=l.useCallback(f=>{dg(f.target)&&g()},[g]),h=l.useCallback(async()=>{r.current=!0;try{for(;;){d.current=!1;let f;try{f=await i.current()}catch(p){f={ok:!1,reason:p instanceof Error?p.message:String(p)}}if(!c.current)return;if(!d.current){f.ok||U.error(o.current("settings.common.status.saveFailedReason",{reason:f.reason}));return}}}finally{r.current=!1}},[]);return l.useEffect(()=>(c.current=!0,()=>{c.current=!1}),[]),l.useEffect(()=>{if(a!==0){if(r.current){d.current=!0;return}h()}},[a,h]),{requestSave:g,onBlurCapture:m}},ug=["allow","ask","deny"],mg=["shell","edit","read","glob","grep","patch","webfetch","websearch","skill","subagent","question","external_directory"],pg=["openchamber","openchamber_web","openchamber_memory","openchamber_notify"],gg=new Set(["bash","task","write","list","lsp","todowrite","todoread","multiedit","doom_loop","plan_enter","plan_exit"]),wd=t=>gg.has(t),fg=[{action:"*",resource:"*",effect:"allow"},{action:"external_directory",resource:"*",effect:"ask"},{action:"read",resource:"*.env",effect:"ask"},{action:"read",resource:"*.env.*",effect:"ask"},{action:"read",resource:"*.env.example",effect:"allow"}],_l=()=>({global:null,keys:{},source:[]}),ia=t=>({global:t.global,source:t.source,keys:Object.fromEntries(Object.entries(t.keys).map(([e,a])=>[e,{effect:a.effect,patterns:a.patterns.map(n=>({...n}))}]))}),hg=t=>{const e={global:null,keys:{},source:t.map(a=>({...a}))};for(const a of t){if(wd(a.action))continue;if(a.action==="*"){a.resource==="*"&&(e.global=a.effect);continue}const n=e.keys[a.action]??{effect:null,patterns:[]};if(a.resource==="*")n.effect=a.effect;else{const i=n.patterns.findIndex(o=>o.pattern===a.resource);i>=0?n.patterns[i]={pattern:a.resource,effect:a.effect}:n.patterns.push({pattern:a.resource,effect:a.effect})}e.keys[a.action]=n}return e},xg=t=>t.action!=="*"||t.resource==="*",ma=(t,e)=>`${t}\0${e}`,bg=t=>{const e=new Map;t.global!==null&&e.set(ma("*","*"),t.global);for(const[a,n]of Object.entries(t.keys)){n.effect!==null&&e.set(ma(a,"*"),n.effect);for(const i of n.patterns){const o=i.pattern.trim();o.length!==0&&e.set(ma(a,o),i.effect)}}return e},jr=t=>{const e=bg(t),a=new Set,n=[];for(const o of t.source){if(wd(o.action))continue;if(!xg(o)){n.push({...o});continue}const r=ma(o.action,o.resource),d=e.get(r);d!==void 0&&(n.push({action:o.action,resource:o.resource,effect:d}),a.add(r))}const i=ma("*","*");t.global!==null&&!a.has(i)&&n.unshift({action:"*",resource:"*",effect:t.global});for(const[o,r]of Object.entries(t.keys)){const d=ma(o,"*");if(r.effect!==null&&!a.has(d)){const c=n.findIndex(m=>m.action===o),g={action:o,resource:"*",effect:r.effect};c>=0?n.splice(c,0,g):n.push(g)}for(const c of r.patterns){const g=c.pattern.trim();if(g.length===0)continue;const m=ma(o,g),h=e.get(m);h===void 0||a.has(m)||(a.add(m),n.push({action:o,resource:g,effect:h}))}}return n},vg=(t,e)=>JSON.stringify(jr(t))===JSON.stringify(jr(e)),yg=(t,e)=>{const a=[...fg,...e.global,...e.agentGlobal?[{action:"*",resource:"*",effect:e.agentGlobal}]:[]];let n="ask";for(const i of a)i.resource==="*"&&(i.action==="*"||i.action===t)&&(n=i.effect);return n},jg=t=>t.split(/[_-]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),kg=new Set(["shell","edit","read","glob","grep","patch","webfetch","skill","subagent","external_directory"]),wg={effect:null,patterns:[]},Ng=t=>{const e=Be.c(163),{agent:a,registerSave:n,requestSave:i}=t,{t:o}=qe(),r=Hn(Sg),d=Hn(Cg);let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=[],e[0]=c):c=e[0];const[g,m]=l.useState(c),[h,f]=l.useState(_l),[p,b]=l.useState(_l),[C,v]=l.useState(!0),[k,u]=l.useState(!1);let y;e[1]===Symbol.for("react.memo_cache_sentinel")?(y={},e[1]=y):y=e[1];const[S,N]=l.useState(y),[w,A]=l.useState(""),[x,T]=l.useState(0),M=a.name,E=en(),D=Un(Ig);let F;e[2]!==E?(F=ze=>Rr(ze,E),e[2]=E,e[3]=F):F=e[3];const L=Un(F);let P;e[4]!==E?(P=ze=>ze.getStatusForDirectory(E),e[4]=E,e[5]=P):P=e[5];const j=pn(P);let O,K;e[6]!==D||e[7]!==E?(O=()=>{D({directory:E})},K=[D,E],e[6]=D,e[7]=E,e[8]=O,e[9]=K):(O=e[8],K=e[9]),l.useEffect(O,K);let H;e[10]!==M||e[11]!==d||e[12]!==E?(H=()=>{let ze=!1;return v(!0),u(!1),(async()=>{const Ze=await d(M,E);if(ze)return;if(!Ze){u(!0),v(!1);return}const tt=hg(Ze.agent);m(Ze.global),f(ia(tt)),b(tt),N({}),v(!1)})(),()=>{ze=!0}},e[10]=M,e[11]=d,e[12]=E,e[13]=H):H=e[13];let q;e[14]!==M||e[15]!==d||e[16]!==x||e[17]!==E?(q=[M,d,x,E],e[14]=M,e[15]=d,e[16]=x,e[17]=E,e[18]=q):q=e[18],l.useEffect(H,q);let Z;e[19]!==M||e[20]!==h||e[21]!==p||e[22]!==E||e[23]!==o||e[24]!==r?(Z=async()=>vg(p,h)?Us:(await r(M,{permissions:jr(p)},E)).ok?(f(ia(p)),Tn):xs(o("settings.agents.page.permissionsEditor.toast.saveFailed")),e[19]=M,e[20]=h,e[21]=p,e[22]=E,e[23]=o,e[24]=r,e[25]=Z):Z=e[25];const ae=Z;let B,G;e[26]!==n||e[27]!==ae?(B=()=>(n(ae),()=>n(null)),G=[n,ae],e[26]=n,e[27]=ae,e[28]=B,e[29]=G):(B=e[28],G=e[29]),l.useEffect(B,G);let _;e[30]!==L?(_=L.map(Pg),e[30]=L,e[31]=_):_=e[31];const z=_;let te;if(e[32]!==z||e[33]!==p.keys){te=[...mg,...pg];const ze=new Set(z.map(Ag));let Ze;e[35]!==p.keys?(Ze=Object.keys(p.keys),e[35]=p.keys,e[36]=Ze):Ze=e[36];for(const tt of Ze)!te.includes(tt)&&!ze.has(tt)&&te.push(tt);e[32]=z,e[33]=p.keys,e[34]=te}else te=e[34];const Q=te;let X;e[37]!==j||e[38]!==o?(X=ze=>{switch(j?.[ze]?.status.status){case"connected":return o("settings.mcp.page.status.label.connected");case"failed":return o("settings.mcp.page.status.label.failed");case"needs_auth":return o("settings.mcp.page.status.label.needsAuth");case"disabled":return o("settings.agents.page.permissionsEditor.mcpStatus.disabled");case"pending":return o("settings.agents.page.permissionsEditor.mcpStatus.pending");default:return null}},e[37]=j,e[38]=o,e[39]=X):X=e[39];const pe=X;let je;e[40]!==g||e[41]!==p.global?(je=ze=>yg(ze,{global:g,agentGlobal:p.global}),e[40]=g,e[41]=p.global,e[42]=je):je=e[42];const fe=je;let ke;e[43]!==i?(ke=ze=>{b(Ze=>({...Ze,global:ze})),i()},e[43]=i,e[44]=ke):ke=e[44];const be=ke;let De;e[45]!==i?(De=(ze,Ze)=>{b(tt=>{const lt=ia(tt),J=lt.keys[ze]??{effect:null,patterns:[]};return J.effect=Ze,J.effect===null&&J.patterns.length===0?delete lt.keys[ze]:lt.keys[ze]=J,lt}),i()},e[45]=i,e[46]=De):De=e[46];const oe=De;let ee;e[47]!==i?(ee=(ze,Ze,tt,lt,J)=>{b(nt=>{const ot=ia(nt),it=ot.keys[ze]??{effect:null,patterns:[]};return it.patterns[Ze]={pattern:tt,effect:lt},ot.keys[ze]=it,ot}),J&&i()},e[47]=i,e[48]=ee):ee=e[48];const ce=ee;let ue;e[49]===Symbol.for("react.memo_cache_sentinel")?(ue=ze=>{b(Ze=>{const tt=ia(Ze),lt=tt.keys[ze]??{effect:null,patterns:[]};return lt.patterns.push({pattern:"",effect:"allow"}),tt.keys[ze]=lt,tt}),N(Ze=>({...Ze,[ze]:!0}))},e[49]=ue):ue=e[49];const Ie=ue;let ve;e[50]!==i?(ve=(ze,Ze)=>{b(tt=>{const lt=ia(tt),J=lt.keys[ze];return J?(J.patterns.splice(Ze,1),J.effect===null&&J.patterns.length===0&&delete lt.keys[ze],lt):tt}),i()},e[50]=i,e[51]=ve):ve=e[51];const Re=ve;let Me;e[52]!==w||e[53]!==i?(Me=()=>{const ze=w.trim();!ze||ze==="*"||(b(Ze=>{if(Ze.keys[ze])return Ze;const tt=ia(Ze);return tt.keys[ze]={effect:"ask",patterns:[]},tt}),A(""),i())},e[52]=w,e[53]=i,e[54]=Me):Me=e[54];const me=Me;let Te;e[55]!==o?(Te=ze=>o(ze==="allow"?"settings.agents.page.permissionsEditor.action.allow":ze==="ask"?"settings.agents.page.permissionsEditor.action.ask":"settings.agents.page.permissionsEditor.action.deny"),e[55]=o,e[56]=Te):Te=e[56];const Oe=Te;let ge,xe,ne,ie,he,Ee,Ke,Le,Se;if(e[57]!==Oe||e[58]!==fe||e[59]!==S||e[60]!==C||e[61]!==k||e[62]!==z||e[63]!==pe||e[64]!==p.global||e[65]!==p.keys||e[66]!==Re||e[67]!==be||e[68]!==oe||e[69]!==ce||e[70]!==o||e[71]!==Q){Se=Symbol.for("react.early_return_sentinel");e:{const ze=o("settings.agents.page.permissionsEditor.action.inherit"),Ze=o("settings.agents.page.permissionsEditor.action.default");let tt;e[81]!==Oe?(tt=Xe=>[...Xe?[{value:"inherit",label:Xe}]:[],...ug.map(mt=>({value:mt,label:Oe(mt)}))],e[81]=Oe,e[82]=tt):tt=e[82];const lt=tt,J=(Xe,mt,Fe,W)=>{const ye=W===void 0?ze:W;return s.jsx(Xs,{value:Xe??"inherit",options:lt(ye),onChange:Ae=>mt(Ae==="inherit"?null:Ae),"aria-label":Fe})};if(C){let Xe;e[83]!==o?(Xe=o("settings.agents.page.section.toolPermissions"),e[83]=o,e[84]=Xe):Xe=e[84];let mt;e[85]!==o?(mt=o("common.loading"),e[85]=o,e[86]=mt):mt=e[86];let Fe;e[87]!==mt?(Fe=s.jsx("p",{className:ds,children:mt}),e[87]=mt,e[88]=Fe):Fe=e[88];let W;e[89]!==Xe||e[90]!==Fe?(W=s.jsx(He,{title:Xe,children:Fe}),e[89]=Xe,e[90]=Fe,e[91]=W):W=e[91],Se=W;break e}if(k){let Xe;e[92]!==o?(Xe=o("settings.agents.page.section.toolPermissions"),e[92]=o,e[93]=Xe):Xe=e[93];let mt;e[94]!==o?(mt=o("settings.agents.page.permissionsEditor.state.loadFailed"),e[94]=o,e[95]=mt):mt=e[95];let Fe;e[96]!==mt?(Fe=s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:mt}),e[96]=mt,e[97]=Fe):Fe=e[97];let W;e[98]===Symbol.for("react.memo_cache_sentinel")?(W=()=>T(Tg),e[98]=W):W=e[98];let ye;e[99]!==o?(ye=o("settings.agents.page.permissionsEditor.actions.retry"),e[99]=o,e[100]=ye):ye=e[100];let Ae;e[101]!==ye?(Ae=s.jsx(V,{variant:"outline",size:"xs",onClick:W,children:ye}),e[101]=ye,e[102]=Ae):Ae=e[102];let Y;e[103]!==Fe||e[104]!==Ae?(Y=s.jsxs("div",{className:"flex items-center gap-3",children:[Fe,Ae]}),e[103]=Fe,e[104]=Ae,e[105]=Y):Y=e[105];let Pe;e[106]!==Xe||e[107]!==Y?(Pe=s.jsx(He,{title:Xe,children:Y}),e[106]=Xe,e[107]=Y,e[108]=Pe):Pe=e[108],Se=Pe;break e}const nt=(Xe,mt,Fe)=>{const W=p.keys[Xe]??wg,ye=kg.has(Xe)||W.patterns.length>0,Ae=S[Xe]===!0;return s.jsxs("div",{className:"border-t border-border/40 py-2",children:[s.jsxs("div",{className:"flex flex-col gap-2 @xl:flex-row @xl:items-center @xl:justify-between",children:[s.jsxs("button",{type:"button",onClick:ye?()=>N(Y=>({...Y,[Xe]:!Ae})):void 0,className:Ne("flex min-w-0 items-center gap-1.5 text-left",!ye&&"cursor-default"),"aria-expanded":ye?Ae:void 0,children:[s.jsx($,{name:Ae&&ye?"arrow-down-s":"arrow-right-s",className:Ne("h-3.5 w-3.5 shrink-0 text-muted-foreground",!ye&&"opacity-0")}),s.jsx("span",{className:Pt,children:mt}),s.jsx("span",{className:"typography-micro font-mono text-muted-foreground/70",children:Xe}),Fe&&s.jsx("span",{className:"typography-micro rounded bg-muted px-1 text-muted-foreground",children:Fe}),W.effect===null&&s.jsx("span",{className:"typography-micro text-muted-foreground",children:o("settings.agents.page.permissionsEditor.effectiveHint",{action:Oe(fe(Xe))})}),W.patterns.length>0&&s.jsx("span",{className:"typography-micro rounded bg-muted px-1 text-muted-foreground",children:o("settings.agents.page.permissionsEditor.ruleCount",{count:String(W.patterns.length)})})]}),J(W.effect,Y=>oe(Xe,Y),o("settings.agents.page.permissionsEditor.keyAria",{key:Xe}))]}),Ae&&ye&&s.jsxs("div",{className:"mt-2 space-y-2 pl-5",children:[W.patterns.map((Y,Pe)=>s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(Ge,{value:Y.pattern,onChange:Je=>ce(Xe,Pe,Je.target.value,Y.effect,!1),placeholder:o("settings.agents.page.permissionsEditor.patternPlaceholder"),"aria-label":o("settings.agents.page.permissionsEditor.patternActionAria",{key:Xe}),className:"h-8 w-full max-w-[24rem] min-w-0 flex-1 font-mono text-xs"}),s.jsx(Xs,{value:Y.effect,options:lt(),onChange:Je=>ce(Xe,Pe,Y.pattern,Je,!0),"aria-label":o("settings.agents.page.permissionsEditor.patternActionAria",{key:Xe})}),s.jsx(V,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive",onClick:()=>Re(Xe,Pe),"aria-label":o("settings.agents.page.permissionsEditor.actions.removeRuleAria"),children:s.jsx($,{name:"close",className:"h-3.5 w-3.5"})})]},Pe)),s.jsxs(V,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Ie(Xe),children:[s.jsx($,{name:"add",className:"mr-1 h-3.5 w-3.5"}),o("settings.agents.page.permissionsEditor.actions.addRule")]})]})]},Xe)};ge=He,e[109]!==o?(xe=o("settings.agents.page.section.toolPermissions"),e[109]=o,e[110]=xe):xe=e[110],ne="agents.permissions",e[111]!==o?(ie=o("settings.agents.page.permissionsEditor.sectionInfo"),e[111]=o,e[112]=ie):ie=e[112],he="space-y-4";let ot;e[113]!==o?(ot=o("settings.agents.page.permissionsEditor.defaultLabel"),e[113]=o,e[114]=ot):ot=e[114];let it;e[115]!==ot?(it=s.jsx("span",{className:Pt,children:ot}),e[115]=ot,e[116]=it):it=e[116];let ft;e[117]!==o?(ft=o("settings.agents.page.permissionsEditor.defaultInfo"),e[117]=o,e[118]=ft):ft=e[118];let xt;e[119]!==ft?(xt=s.jsx(Gt,{children:ft}),e[119]=ft,e[120]=xt):xt=e[120];let ht;e[121]!==Oe||e[122]!==fe||e[123]!==p.global||e[124]!==o?(ht=p.global===null&&s.jsx("span",{className:"typography-micro text-muted-foreground",children:o("settings.agents.page.permissionsEditor.effectiveHint",{action:Oe(fe("*"))})}),e[121]=Oe,e[122]=fe,e[123]=p.global,e[124]=o,e[125]=ht):ht=e[125];let St;e[126]!==it||e[127]!==xt||e[128]!==ht?(St=s.jsxs("div",{className:"flex items-center gap-1.5",children:[it,xt,ht]}),e[126]=it,e[127]=xt,e[128]=ht,e[129]=St):St=e[129];const At=p.global;let _e;e[130]!==o?(_e=o("settings.agents.page.permissionsEditor.defaultAria"),e[130]=o,e[131]=_e):_e=e[131],Ee=s.jsxs("div",{className:"flex flex-col gap-2 pb-2 @xl:flex-row @xl:items-center @xl:justify-between",children:[St,J(At,be,_e,Ze)]}),Ke=s.jsx("div",{children:Q.map(Xe=>nt(Xe,jg(Xe),null))}),Le=z.length>0&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1.5 border-t border-border/40 pt-3 pb-1",children:[s.jsx("span",{className:Pt,children:o("settings.agents.page.permissionsEditor.mcpTitle")}),s.jsx(Gt,{children:o("settings.agents.page.permissionsEditor.mcpInfo")})]}),z.map(Xe=>nt(Xe.key,Xe.server,pe(Xe.server)))]})}e[57]=Oe,e[58]=fe,e[59]=S,e[60]=C,e[61]=k,e[62]=z,e[63]=pe,e[64]=p.global,e[65]=p.keys,e[66]=Re,e[67]=be,e[68]=oe,e[69]=ce,e[70]=o,e[71]=Q,e[72]=ge,e[73]=xe,e[74]=ne,e[75]=ie,e[76]=he,e[77]=Ee,e[78]=Ke,e[79]=Le,e[80]=Se}else ge=e[72],xe=e[73],ne=e[74],ie=e[75],he=e[76],Ee=e[77],Ke=e[78],Le=e[79],Se=e[80];if(Se!==Symbol.for("react.early_return_sentinel"))return Se;let $e;e[132]===Symbol.for("react.memo_cache_sentinel")?($e=ze=>A(ze.target.value),e[132]=$e):$e=e[132];let Ye;e[133]!==me?(Ye=ze=>{ze.key==="Enter"&&(ze.preventDefault(),me())},e[133]=me,e[134]=Ye):Ye=e[134];let pt;e[135]!==o?(pt=o("settings.agents.page.permissionsEditor.customKeyPlaceholder"),e[135]=o,e[136]=pt):pt=e[136];let vt;e[137]!==w||e[138]!==Ye||e[139]!==pt?(vt=s.jsx(Ge,{value:w,onChange:$e,onKeyDown:Ye,placeholder:pt,className:"h-8 w-full max-w-[16rem] font-mono text-xs"}),e[137]=w,e[138]=Ye,e[139]=pt,e[140]=vt):vt=e[140];let wt;e[141]!==w?(wt=w.trim(),e[141]=w,e[142]=wt):wt=e[142];const yt=!wt;let st;e[143]===Symbol.for("react.memo_cache_sentinel")?(st=s.jsx($,{name:"add",className:"mr-1 h-3.5 w-3.5"}),e[143]=st):st=e[143];let rt;e[144]!==o?(rt=o("settings.agents.page.permissionsEditor.actions.addKey"),e[144]=o,e[145]=rt):rt=e[145];let de;e[146]!==me||e[147]!==yt||e[148]!==rt?(de=s.jsxs(V,{variant:"outline",size:"xs",className:"!font-normal",onClick:me,disabled:yt,children:[st,rt]}),e[146]=me,e[147]=yt,e[148]=rt,e[149]=de):de=e[149];let Ue;e[150]!==vt||e[151]!==de?(Ue=s.jsxs("div",{className:"flex flex-wrap items-center gap-2 border-t border-border/40 pt-3",children:[vt,de]}),e[150]=vt,e[151]=de,e[152]=Ue):Ue=e[152];let et;return e[153]!==ge||e[154]!==xe||e[155]!==ne||e[156]!==ie||e[157]!==he||e[158]!==Ee||e[159]!==Ke||e[160]!==Le||e[161]!==Ue?(et=s.jsxs(ge,{title:xe,settingsItem:ne,info:ie,contentClassName:he,children:[Ee,Ke,Le,Ue]}),e[153]=ge,e[154]=xe,e[155]=ne,e[156]=ie,e[157]=he,e[158]=Ee,e[159]=Ke,e[160]=Le,e[161]=Ue,e[162]=et):et=e[162],et};function Sg(t){return t.updateAgent}function Cg(t){return t.fetchAgentPermissions}function Ig(t){return t.loadMcpConfigs}function Pg(t){return{key:`${t.name}_*`,server:t.name}}function Ag(t){return t.key}function Tg(t){return t+1}const Qr=t=>{const e=Be.c(11),{legacy:a,path:n,className:i}=t,{t:o}=qe();if(!a)return null;let r;e[0]!==i?(r=Ne("mb-4 flex items-start gap-1.5",ds,i),e[0]=i,e[1]=r):r=e[1];const d=n??void 0;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx($,{name:"information",className:"mt-[0.2em] h-3.5 w-3.5 shrink-0 opacity-70"}),e[2]=c):c=e[2];let g;e[3]!==o?(g=o("settings.common.legacyFormat.note"),e[3]=o,e[4]=g):g=e[4];let m;e[5]!==g?(m=s.jsx("span",{children:g}),e[5]=g,e[6]=m):m=e[6];let h;return e[7]!==r||e[8]!==d||e[9]!==m?(h=s.jsxs("p",{className:r,title:d,children:[c,m]}),e[7]=r,e[8]=d,e[9]=m,e[10]=h):h=e[10],h},Eg=(t,e)=>{const a=_n(e);if(!a)return[];const n=t.find(o=>o.id===a.providerId);return Em(n?.models,a.modelId)?.variants.map(o=>o.id)??[]},Dg=()=>{const{t}=qe(),e=ct(me=>me.providers),{selectedAgentName:a,getAgentByName:n,createAgent:i,updateAgent:o,fetchAgentEntity:r,agentDraft:d,setAgentDraft:c,setSelectedAgent:g}=Hn(_s(me=>({selectedAgentName:me.selectedAgentName,getAgentByName:me.getAgentByName,createAgent:me.createAgent,updateAgent:me.updateAgent,fetchAgentEntity:me.fetchAgentEntity,agentDraft:me.agentDraft,setAgentDraft:me.setAgentDraft,setSelectedAgent:me.setSelectedAgent}))),m=en(),h=Hn(me=>Qc(me,m)),f=a?n(a,m):null,p=!!(d&&d.name===a&&!f),b=p?"":f?.description?.trim()??"",C=p?"":f?.system?.trim()??"",[v,k]=l.useState(""),[u,y]=l.useState("user"),[S,N]=l.useState(""),[w,A]=l.useState("subagent"),[x,T]=l.useState(""),[M,E]=l.useState(""),[D,F]=l.useState(void 0),[L,P]=l.useState(void 0),[j,O]=l.useState(void 0),[K,H]=l.useState(""),[q,Z]=l.useState(!1),[ae,B]=l.useState(null),G=l.useRef({}),_=l.useRef(null),z=l.useCallback(me=>{_.current=me},[]),te=l.useRef(null),Q=JSON.stringify([a,m,p]),X=l.useRef(Q);X.current=Q;const pe=l.useRef(null),je={description:S,mode:w,model:x,variant:M,steps:D,temperature:L,topP:j,system:K},fe=l.useRef(je);fe.current=je;const ke=l.useMemo(()=>Eg(e,x),[x,e]),be=ke.length>0,De=M||"__default",oe=be,ee=l.useMemo(()=>M&&!ke.includes(M)?[M,...ke]:ke,[M,ke]);l.useEffect(()=>{if(!p||!d)return;pe.current=null;const me=hi(d.model),Te=d.name||"",Oe=d.scope||"user",ge=d.description||"",xe=d.mode||"subagent",ne=me?`${me.providerID}/${me.modelID}`:"",ie=me?.variant||"",he=d.steps??void 0,Ee=d.temperature??void 0,Ke=d.top_p??void 0,Le=d.system||"";G.current={},B(null),k(Te),y(Oe),N(ge),A(xe),T(ne),E(ie),F(he),P(Ee),O(Ke),H(Le),te.current={draftName:Te,draftScope:Oe,description:ge,mode:xe,model:ne,variant:ie,steps:he,temperature:Ee,topP:Ke,system:Le}},[d,p]),l.useEffect(()=>{if(p||!a)return;let me=!1;return(async()=>{const Te=await r(a,m);if(me||X.current!==Q||!Te)return;const Oe=Te.config;G.current=Oe;const ge=hi(Oe.model),xe=Oe.request?.body,ne={draftName:"",draftScope:"user",description:Oe.description||"",mode:Oe.mode||f?.mode||"subagent",model:ge?`${ge.providerID}/${ge.modelID}`:"",variant:ge?.variant||"",steps:Oe.steps??void 0,temperature:xe?.temperature,topP:xe?.top_p,system:Oe.system||""},ie=te.current,he=fe.current,Ee=ie!==null&&(he.description!==ie.description||he.mode!==ie.mode||he.model!==ie.model||he.variant!==ie.variant||he.steps!==ie.steps||he.temperature!==ie.temperature||he.topP!==ie.topP||he.system!==ie.system);B({legacy:Te.legacy===!0,path:Te.path,source:Te.source}),!(pe.current===Q&&Ee)&&(pe.current=Q,N(ne.description),A(ne.mode),T(ne.model),E(ne.variant),F(ne.steps),P(ne.temperature),O(ne.topP),H(ne.system),te.current=ne)})(),()=>{me=!0}},[r,p,f,a,m,Q]);const ce=l.useCallback(me=>{const Te=_n(x.trim()),Oe=Te?Yc({providerID:Te.providerId,modelID:Te.modelId,variant:M.trim()||void 0}):null,ge=G.current.request,xe={...ge?.body};L===void 0?delete xe.temperature:xe.temperature=L,j===void 0?delete xe.top_p:xe.top_p=j;const ne=ge?.headers,ie={};ne&&Object.keys(ne).length>0&&(ie.headers=ne),Object.keys(xe).length>0&&(ie.body=xe);const he=S.trim(),Ee=K.trim(),Ke={name:me,mode:w,model:Oe,steps:D??null,system:Ee||(p?void 0:null),request:Object.keys(ie).length>0?ie:null};return he&&(Ke.description=he),p&&u&&(Ke.scope=u),p&&d?.permissions?.length&&(Ke.permissions=d.permissions),Ke},[d,S,u,p,w,x,D,K,L,j,M]),ue=l.useCallback(async()=>{const me=te.current,Te=a?.trim();if(p||!me||!Te)return Us;const Oe=_.current?await _.current():Us;if(S===me.description&&w===me.mode&&x===me.model&&M===me.variant&&D===me.steps&&L===me.temperature&&j===me.topP&&K===me.system||!Oe.ok)return Oe;const xe=ce(Te);return(await o(Te,xe,m)).ok?(X.current!==Q||(G.current={...G.current,model:xe.model,system:xe.system??void 0,steps:xe.steps,request:xe.request??void 0},te.current={...me,description:S,mode:w,model:x,variant:M,steps:D,temperature:L,topP:j,system:K}),Tn):xs(t("settings.agents.page.toast.updateFailed"))},[ce,S,p,w,x,a,Q,m,D,K,t,L,j,o,M]),Ie=ni(ue),{requestSave:ve}=Ie,Re=async()=>{const me=v.trim().replace(/\s+/g,"-");if(!me){U.error(t("settings.agents.sidebar.toast.agentNameRequired"));return}if(h.some(Te=>Te.name===me)){U.error(t("settings.agents.sidebar.toast.agentExists"));return}Z(!0);try{(await i(ce(me),m)).ok?(c(null),U.success(t("settings.agents.page.toast.created"))):U.error(t("settings.agents.page.toast.createFailed"))}catch(Te){console.error("Error creating agent:",Te);const Oe=Te instanceof Error&&Te.message?Te.message:t("settings.agents.page.toast.saveUnexpectedError");U.error(Oe)}finally{Z(!1)}},Me=()=>{c(null),g(null)};return a?s.jsxs(ns,{title:p?t("settings.agents.page.title.new"):a,description:t(p?"settings.agents.page.subtitle.new":"settings.agents.page.subtitle.edit"),onBlurCapture:Ie.onBlurCapture,children:[!p&&ae&&s.jsx(Qr,{legacy:ae.legacy,path:ae.path}),!p&&ae?.source==="none"&&s.jsxs("p",{className:`mb-4 flex items-start gap-1.5 ${ds}`,children:[s.jsx($,{name:"information",className:"mt-[0.2em] h-3.5 w-3.5 shrink-0 opacity-70"}),s.jsx("span",{children:t("settings.agents.page.runtimeProvided.note")})]}),s.jsxs(He,{title:t("settings.agents.page.section.identityRole"),divider:!1,contentClassName:"space-y-0",children:[p&&s.jsxs(Ct,{settingsItem:"agents.name",label:t("settings.agents.page.field.agentName"),children:[s.jsxs("div",{className:"flex items-center",children:[s.jsx("span",{className:"typography-ui-label text-muted-foreground mr-1",children:"@"}),s.jsx(Ge,{value:v,onChange:me=>k(me.target.value),placeholder:t("settings.agents.page.field.agentNamePlaceholder"),className:"h-7 w-40 px-2"})]}),s.jsxs(Dt,{value:u,onValueChange:me=>y(me),children:[s.jsx(Tt,{size:Qt,className:"w-fit min-w-[100px]",children:s.jsx(Jt,{placeholder:t("settings.agents.page.field.scopePlaceholder")})}),s.jsxs(Et,{align:"end",children:[s.jsx(gt,{value:"user",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx($,{name:"user-3",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.common.scope.global")})]})}),s.jsx(gt,{value:"project",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx($,{name:"folder",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.common.scope.project")})]})})]})]})]}),s.jsx(Kt,{label:t("settings.common.field.description"),controlClassName:"w-full max-w-none",children:s.jsx(Rs,{value:S,onChange:me=>N(me.target.value),placeholder:b||t("settings.agents.page.field.descriptionPlaceholder"),rows:2,className:"w-full resize-none min-h-[60px] bg-transparent"})}),s.jsx(Kt,{settingsItem:"agents.mode",label:t("settings.agents.page.field.mode"),info:t("settings.agents.page.field.modeTooltip"),children:s.jsx(Xs,{"aria-label":t("settings.agents.page.field.mode"),value:w,onChange:me=>{A(me),ve()},options:[{value:"primary",label:t("settings.agents.page.mode.primary")},{value:"subagent",label:t("settings.agents.page.mode.subagent")},{value:"all",label:t("settings.agents.page.mode.all")}]})})]}),s.jsxs(He,{title:t("settings.agents.page.section.modelParameters"),contentClassName:"space-y-3",children:[s.jsx(Ct,{settingsItem:"agents.model",label:t("settings.agents.page.field.overrideModel"),children:s.jsx(pa,{providerId:_n(x)?.providerId??"",modelId:_n(x)?.modelId??"",onChange:(me,Te)=>{T(me&&Te?`${me}/${Te}`:""),E(""),ve()},className:Zs})}),s.jsx(Ct,{settingsItem:"agents.variant",label:t("settings.agents.page.field.variant"),info:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{children:t("settings.agents.page.field.variantTooltip")}),s.jsx("p",{children:t("settings.agents.page.field.variantHint")})]}),children:oe?s.jsxs(Dt,{value:De,onValueChange:me=>{E(me==="__default"?"":me),ve()},children:[s.jsx(Tt,{size:Qt,className:fn,children:s.jsx(Jt,{placeholder:t("settings.agents.page.field.variantPlaceholder"),children:me=>me==="__default"?t("chat.modelControls.default"):me})}),s.jsxs(Et,{children:[s.jsx(gt,{value:"__default",children:t("chat.modelControls.default")}),ee.map(me=>s.jsx(gt,{value:me,children:me},me))]})]}):s.jsxs(s.Fragment,{children:[s.jsx(Ge,{value:M,onChange:me=>E(me.target.value),placeholder:t("settings.agents.page.field.variantPlaceholder"),disabled:!x&&!M,className:"h-8 w-40 rounded-md px-3"}),M&&s.jsx(V,{size:"sm",type:"button",variant:"ghost",onClick:()=>{E(""),ve()},className:hs,"aria-label":t("settings.common.actions.clear"),title:t("settings.common.actions.clear"),children:s.jsx($,{name:"close",className:"h-3.5 w-3.5"})})]})}),s.jsxs(Ct,{settingsItem:"agents.temperature",label:t("settings.agents.page.field.temperature"),info:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{children:t("settings.agents.page.field.temperatureTooltip")}),s.jsx("p",{children:t("settings.agents.page.field.temperatureRange")})]}),children:[s.jsx(js,{value:L,fallbackValue:.7,onValueChange:P,onClear:()=>{P(void 0),ve()},min:0,max:2,step:.1,inputMode:"decimal",placeholder:"—",emptyLabel:"—",className:ws}),L!==void 0&&s.jsx(V,{size:"sm",type:"button",variant:"ghost",onClick:()=>{P(void 0),ve()},className:hs,"aria-label":t("settings.agents.page.field.clearTemperatureAria"),title:t("settings.common.actions.clear"),children:s.jsx($,{name:"close",className:"h-3.5 w-3.5"})})]}),s.jsxs(Ct,{settingsItem:"agents.top-p",label:t("settings.agents.page.field.topP"),info:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{children:t("settings.agents.page.field.topPTooltip")}),s.jsx("p",{children:t("settings.agents.page.field.topPRange")})]}),children:[s.jsx(js,{value:j,fallbackValue:.9,onValueChange:O,onClear:()=>{O(void 0),ve()},min:0,max:1,step:.1,inputMode:"decimal",placeholder:"—",emptyLabel:"—",className:ws}),j!==void 0&&s.jsx(V,{size:"sm",type:"button",variant:"ghost",onClick:()=>{O(void 0),ve()},className:hs,"aria-label":t("settings.agents.page.field.clearTopPAria"),title:t("settings.common.actions.clear"),children:s.jsx($,{name:"close",className:"h-3.5 w-3.5"})})]}),s.jsxs(Ct,{settingsItem:"agents.steps",label:t("settings.agents.page.field.steps"),info:t("settings.agents.page.field.stepsTooltip"),children:[s.jsx(js,{value:D,fallbackValue:20,onValueChange:F,onClear:()=>{F(void 0),ve()},min:1,max:1e3,step:1,inputMode:"numeric",placeholder:"—",emptyLabel:"—",className:ws}),D!==void 0&&s.jsx(V,{size:"sm",type:"button",variant:"ghost",onClick:()=>{F(void 0),ve()},className:hs,"aria-label":t("settings.agents.page.field.clearStepsAria"),title:t("settings.common.actions.clear"),children:s.jsx($,{name:"close",className:"h-3.5 w-3.5"})})]})]}),s.jsx(He,{title:t("settings.agents.page.section.systemPrompt"),settingsItem:"agents.system-prompt",children:s.jsx(Rs,{value:K,onChange:me=>H(me.target.value),placeholder:C||t("settings.agents.page.field.systemPromptPlaceholder"),rows:8,className:"w-full font-mono typography-meta min-h-[120px] max-h-[60vh] bg-transparent"})}),!p&&f&&s.jsx(Ng,{agent:f,registerSave:z,requestSave:ve}),p&&s.jsxs("div",{className:"flex items-center gap-2 pb-8",children:[s.jsx(V,{onClick:()=>{Re()},disabled:q||!v.trim(),size:"xs",className:"!font-normal",children:t(q?"settings.common.actions.saving":"settings.common.actions.create")}),s.jsx(V,{variant:"ghost",onClick:Me,disabled:q,size:"xs",className:"!font-normal",children:t("settings.common.actions.cancel")})]})]}):s.jsx("div",{className:"flex h-full items-center justify-center",children:s.jsxs("div",{className:"text-center text-muted-foreground",children:[s.jsx($,{name:"robot-2",className:"mx-auto mb-3 h-12 w-12 opacity-50"}),s.jsx("p",{className:"typography-body",children:t("settings.agents.page.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:t("settings.agents.page.empty.description")})]})})};function Mg(t,e){return t.kind==="file"?t.content:e??""}const $l=Os({content:Rt(),exists:qr(),path:Rt().min(1).optional()}),Rg=async(t,e)=>{const a=await t.json().catch(()=>null);return typeof a?.error=="string"&&a.error.trim()?a.error:e},Og=t=>t.length>0&&!t.endsWith(`
|
|
3
|
-
`)?`${t}
|
|
4
|
-
`:t,Ui={prompt:"",responseStyleEnabled:!1,responseStylePreset:"concise",responseStyleCustomInstructions:""},Lg=(t,e)=>t==="custom"?e:ku(t),Fg=t=>t==="custom"?"custom":Zc(t)?t:"concise",Bl={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"},Kg=()=>{const{t}=qe(),[e,a]=l.useState(""),[n,i]=l.useState("AGENTS.md"),[o,r]=l.useState(Ui.responseStyleEnabled),[d,c]=l.useState(Ui.responseStylePreset),[g,m]=l.useState(Ui.responseStyleCustomInstructions),[h,f]=l.useState(!0),p=l.useRef(null),b=l.useRef(null);l.useEffect(()=>{const S=new AbortController;return(async()=>{try{const[w,A]=await Promise.all([En(),It("/api/behavior/agents-md",{method:"GET",headers:{Accept:"application/json"},signal:S.signal})]);let x=Ui,T;w&&(x={...x,responseStyleEnabled:w.responseStyleEnabled===!0,responseStylePreset:Fg(w.responseStylePreset),responseStyleCustomInstructions:w.responseStyleCustomInstructions??""},w.globalBehaviorPrompt!==void 0&&(T=w.globalBehaviorPrompt));let M={kind:"missing"};if(A.ok){const E=$l.parse(await A.json());if(S.signal.aborted)return;i(E.path??"AGENTS.md"),b.current=E.exists?E.content:null,E.exists&&(M={kind:"file",content:E.content})}x={...x,prompt:Mg(M,T)},a(x.prompt),r(x.responseStyleEnabled),c(x.responseStylePreset),m(x.responseStyleCustomInstructions),p.current=x}catch(w){w.name!=="AbortError"&&console.warn("Failed to load behavior settings:",w)}finally{f(!1)}})(),()=>S.abort()},[]);const C=l.useRef(e);C.current=e,l.useEffect(()=>{let S=null;const N=async()=>{if(document.visibilityState!=="visible"||!p.current)return;S?.abort();const A=new AbortController;S=A;try{const x=await It("/api/behavior/agents-md",{method:"GET",headers:{Accept:"application/json"},signal:A.signal});if(!x.ok)return;const T=$l.parse(await x.json()),M=p.current;if(A.signal.aborted||!M||!T.exists||T.content===b.current||C.current!==M.prompt)return;b.current=T.content,p.current={...M,prompt:T.content},a(T.content)}catch(x){x instanceof DOMException&&x.name==="AbortError"||console.warn("Failed to refresh AGENTS.md:",x)}},w=()=>{N()};return window.addEventListener("focus",w),document.addEventListener("visibilitychange",w),()=>{S?.abort(),window.removeEventListener("focus",w),document.removeEventListener("visibilitychange",w)}},[]);const v=l.useCallback(async()=>{const S=p.current;if(!S||h)return Us;const N=e!==S.prompt,w=o!==S.responseStyleEnabled||d!==S.responseStylePreset||g!==S.responseStyleCustomInstructions;if(!N&&!w)return Us;const A=N?Og(e):S.prompt;if(N){const T=await It("/api/behavior/agents-md",{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({content:A,expectedContent:b.current})});if(T.status===409)return xs(t("settings.behavior.page.toast.agentsMdChangedOnDisk"));if(!T.ok)return xs(await Rg(T,t("settings.behavior.page.toast.saveFailed")));b.current=A,a(M=>M===e?A:M)}return(await kt({...N?{globalBehaviorPrompt:A}:{},responseStyleEnabled:o,responseStylePreset:d,responseStyleCustomInstructions:g})).ok?(p.current={prompt:A,responseStyleEnabled:o,responseStylePreset:d,responseStyleCustomInstructions:g},Tn):xs(t("settings.behavior.page.toast.saveFailed"))},[h,e,g,o,d,t]),k=ni(v),{requestSave:u}=k,y=Lg(d,g);return s.jsxs(ns,{title:t("settings.behavior.page.title"),description:t("settings.page.behavior.description"),onBlurCapture:k.onBlurCapture,children:[s.jsx(He,{title:t("settings.behavior.page.section.systemPrompt"),divider:!1,info:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:"font-medium text-foreground",children:t("settings.behavior.page.warning.title")}),s.jsx("p",{children:t("settings.behavior.page.warning.description",{path:n})})]}),settingsItem:"behavior.system-prompt",contentClassName:"space-y-3",children:s.jsx(Rs,{value:e,onChange:S=>a(S.target.value),placeholder:t("settings.behavior.page.field.systemPromptPlaceholder"),rows:12,disabled:h,outerClassName:"min-h-[160px] max-h-[70vh]",className:"w-full font-mono typography-meta bg-transparent"})}),s.jsxs(He,{title:t("settings.behavior.page.section.responseStyle"),info:t("settings.behavior.page.responseStyle.tooltip"),settingsItem:"behavior.response-style",contentClassName:"space-y-3",children:[s.jsx(bt,{checked:o,onChange:S=>{r(S),u()},disabled:h,label:t("settings.behavior.page.responseStyle.enable"),ariaLabel:t("settings.behavior.page.responseStyle.enableAria")}),s.jsx(Ct,{label:t("settings.behavior.page.responseStyle.preset"),alignEnd:!1,children:s.jsxs(Dt,{value:d,onValueChange:S=>{c(S),u()},disabled:h||!o,children:[s.jsx(Tt,{size:Qt,className:fn,children:s.jsx(Jt,{children:S=>S==="custom"?t("settings.behavior.page.responseStyle.option.custom"):Zc(S)?t(Bl[S]):null})}),s.jsxs(Et,{children:[ju.map(S=>s.jsx(gt,{value:S,children:t(Bl[S])},S)),s.jsx(gt,{value:"custom",children:t("settings.behavior.page.responseStyle.option.custom")})]})]})}),s.jsx(Rs,{value:y,onChange:S=>m(S.target.value),placeholder:t("settings.behavior.page.responseStyle.customPlaceholder"),rows:5,disabled:h||!o||d!=="custom",outerClassName:"min-h-[120px]",className:"w-full font-mono typography-meta bg-transparent"})]})]})},zg=(t,e)=>t.kind===e.kind&&(t.kind!=="provider"||e.kind==="provider"&&t.id===e.id),Ug=t=>{const e=Be.c(73),{snapshot:a}=t,{t:n}=qe(),i=yi(Vg),o=a.selection,r=a.projectOverride!==null;let d;e[0]!==r||e[1]!==o||e[2]!==i||e[3]!==n?(d=L=>{r||zg(L,o)||i(L).then(P=>{P||U.error(n("settings.webSearch.toast.saveFailed"))})},e[0]=r,e[1]=o,e[2]=i,e[3]=n,e[4]=d):d=e[4];const c=d,g=o.kind==="provider"&&!a.providers.some(L=>L.id===o.id)?o.id:null;let m;e[5]!==n?(m=n("settings.webSearch.section.provider"),e[5]=n,e[6]=m):m=e[6];let h;e[7]!==n?(h=n("settings.webSearch.section.providerInfo"),e[7]=n,e[8]=h):h=e[8];let f;e[9]!==n?(f=n("settings.webSearch.section.provider"),e[9]=n,e[10]=f):f=e[10];const p=o.kind==="default";let b;e[11]!==c?(b=()=>c({kind:"default"}),e[11]=c,e[12]=b):b=e[12];let C;e[13]!==n?(C=n("settings.webSearch.option.default"),e[13]=n,e[14]=C):C=e[14];let v;e[15]!==n?(v=n("settings.webSearch.option.defaultDescription"),e[15]=n,e[16]=v):v=e[16];let k;e[17]!==r||e[18]!==p||e[19]!==b||e[20]!==C||e[21]!==v?(k=s.jsx(rs,{selected:p,onSelect:b,disabled:r,label:C,description:v}),e[17]=r,e[18]=p,e[19]=b,e[20]=C,e[21]=v,e[22]=k):k=e[22];let u;e[23]!==c||e[24]!==r||e[25]!==o.kind||e[26]!==a.providers.length||e[27]!==n?(u=a.providers.length>0?s.jsx(rs,{selected:o.kind==="random",onSelect:()=>c({kind:"random"}),disabled:r,label:n("settings.webSearch.option.random"),description:n("settings.webSearch.option.randomDescription")}):null,e[23]=c,e[24]=r,e[25]=o.kind,e[26]=a.providers.length,e[27]=n,e[28]=u):u=e[28];let y;if(e[29]!==c||e[30]!==r||e[31]!==o.id||e[32]!==o.kind||e[33]!==a.providers){let L;e[35]!==c||e[36]!==r||e[37]!==o.id||e[38]!==o.kind?(L=P=>s.jsx(rs,{selected:o.kind==="provider"&&o.id===P.id,onSelect:()=>c({kind:"provider",id:P.id}),disabled:r,label:P.name},P.id),e[35]=c,e[36]=r,e[37]=o.id,e[38]=o.kind,e[39]=L):L=e[39],y=a.providers.map(L),e[29]=c,e[30]=r,e[31]=o.id,e[32]=o.kind,e[33]=a.providers,e[34]=y}else y=e[34];let S;e[40]!==g||e[41]!==n?(S=g?s.jsx(rs,{selected:!0,onSelect:Hg,label:g,description:n("settings.webSearch.option.missing")}):null,e[40]=g,e[41]=n,e[42]=S):S=e[42];const N=o.kind==="off";let w;e[43]!==c?(w=()=>c({kind:"off"}),e[43]=c,e[44]=w):w=e[44];let A;e[45]!==n?(A=n("settings.webSearch.option.off"),e[45]=n,e[46]=A):A=e[46];let x;e[47]!==r||e[48]!==N||e[49]!==w||e[50]!==A?(x=s.jsx(rs,{selected:N,onSelect:w,disabled:r,label:A}),e[47]=r,e[48]=N,e[49]=w,e[50]=A,e[51]=x):x=e[51];let T;e[52]!==u||e[53]!==y||e[54]!==S||e[55]!==x||e[56]!==f||e[57]!==k?(T=s.jsxs(Js,{"aria-label":f,children:[k,u,y,S,x]}),e[52]=u,e[53]=y,e[54]=S,e[55]=x,e[56]=f,e[57]=k,e[58]=T):T=e[58];let M;e[59]!==a.projectOverride||e[60]!==n?(M=a.projectOverride?s.jsx("p",{className:`${ds} mt-2 break-all`,children:n("settings.webSearch.state.projectOverride",{path:a.projectOverride})}):null,e[59]=a.projectOverride,e[60]=n,e[61]=M):M=e[61];let E;e[62]!==a.providers.length||e[63]!==n?(E=a.providers.length===0?s.jsx("p",{className:`${ds} mt-2`,children:n("settings.webSearch.state.noProviders")}):null,e[62]=a.providers.length,e[63]=n,e[64]=E):E=e[64];let D;e[65]!==T||e[66]!==M||e[67]!==E?(D=s.jsxs("div",{children:[T,M,E]}),e[65]=T,e[66]=M,e[67]=E,e[68]=D):D=e[68];let F;return e[69]!==m||e[70]!==D||e[71]!==h?(F=s.jsx(He,{title:m,info:h,divider:!1,settingsItem:"web-search.provider",children:D}),e[69]=m,e[70]=D,e[71]=h,e[72]=F):F=e[72],F},_g=t=>{const e=Be.c(27),{provider:a,access:n,locked:i}=t,{t:o}=qe(),r=yi(qg),d=yi(Gg),[c,g]=l.useState(""),[m,h]=l.useState(!1);let f;e[0]!==n.envNames||e[1]!==o?(f=n.envNames.length>0?o("settings.webSearch.keys.envHint",{names:n.envNames.join(", ")}):void 0,e[0]=n.envNames,e[1]=o,e[2]=f):f=e[2];const p=f;let b;e[3]!==c||e[4]!==a.id||e[5]!==a.name||e[6]!==r||e[7]!==o?(b=async()=>{const N=c.trim();if(!N)return;h(!0);const w=await r(a.id,N);h(!1),w?(g(""),U.success(o("settings.webSearch.toast.keySaved",{provider:a.name}))):U.error(o("settings.webSearch.toast.keySaveFailed"))},e[3]=c,e[4]=a.id,e[5]=a.name,e[6]=r,e[7]=o,e[8]=b):b=e[8];const C=b;let v;e[9]!==a.id||e[10]!==d||e[11]!==o?(v=async()=>{h(!0);const N=await d(a.id);h(!1),N||U.error(o("settings.webSearch.toast.keyRemoveFailed"))},e[9]=a.id,e[10]=d,e[11]=o,e[12]=v):v=e[12];const k=v,u=n.key;let y;e[13]!==m||e[14]!==c||e[15]!==k||e[16]!==C||e[17]!==i||e[18]!==a.name||e[19]!==u.kind||e[20]!==u.name||e[21]!==o?(y=u.kind==="stored"?s.jsxs("div",{className:`${Es} flex items-center justify-end gap-2`,children:[s.jsx("span",{className:"typography-meta text-muted-foreground",children:o("settings.webSearch.keys.saved")}),s.jsx(V,{variant:"outline",size:"xs",disabled:m,onClick:()=>{k()},children:o("settings.webSearch.keys.remove")})]}):u.kind==="env"?s.jsx("span",{className:"typography-meta text-muted-foreground",children:o("settings.webSearch.keys.fromEnv",{name:u.name})}):i?null:s.jsxs("div",{className:`${Es} flex items-center gap-2`,children:[s.jsx(Ge,{type:"password",value:c,onChange:N=>g(N.target.value),onKeyDown:N=>{N.key==="Enter"&&C()},placeholder:o("settings.webSearch.keys.placeholder"),"aria-label":o("settings.webSearch.keys.inputAria",{provider:a.name}),className:"h-8 min-w-0 flex-1 rounded-md px-3 font-mono text-xs"}),s.jsx(V,{size:"xs",disabled:m||c.trim().length===0,onClick:()=>{C()},children:o("settings.webSearch.keys.save")})]}),e[13]=m,e[14]=c,e[15]=k,e[16]=C,e[17]=i,e[18]=a.name,e[19]=u.kind,e[20]=u.name,e[21]=o,e[22]=y):y=e[22];let S;return e[23]!==p||e[24]!==a.name||e[25]!==y?(S=s.jsx(Ct,{label:a.name,info:p,children:y}),e[23]=p,e[24]=a.name,e[25]=y,e[26]=S):S=e[26],S},$g=t=>{const e=Be.c(29),{snapshot:a}=t,{t:n}=qe(),i=ya(),o=a.access;let r,d,c,g,m,h,f,p;if(e[0]!==o||e[1]!==i||e[2]!==a.providers||e[3]!==n){p=Symbol.for("react.early_return_sentinel");e:{const v=o?a.providers.flatMap(k=>{const u=o[k.id];return u&&u.key.kind!=="unsupported"?[{provider:k,access:u}]:[]}):[];if(o&&v.length===0){p=null;break e}r=He,e[12]!==n?(m=n("settings.webSearch.section.keys"),e[12]=n,e[13]=m):m=e[13],e[14]!==n?(h=n("settings.webSearch.section.keysInfo"),e[14]=n,e[15]=h):h=e[15],f="web-search.keys",d="space-y-4",e[16]!==i||e[17]!==n?(c=i?s.jsx("p",{className:ds,children:n("settings.webSearch.keys.enterpriseMode")}):null,e[16]=i,e[17]=n,e[18]=c):c=e[18],g=o===null?s.jsx("p",{className:ds,children:n("settings.webSearch.state.keysUnavailable")}):v.map(k=>{const{provider:u,access:y}=k;return s.jsx(_g,{provider:u,access:y,locked:i},u.id)})}e[0]=o,e[1]=i,e[2]=a.providers,e[3]=n,e[4]=r,e[5]=d,e[6]=c,e[7]=g,e[8]=m,e[9]=h,e[10]=f,e[11]=p}else r=e[4],d=e[5],c=e[6],g=e[7],m=e[8],h=e[9],f=e[10],p=e[11];if(p!==Symbol.for("react.early_return_sentinel"))return p;let b;e[19]!==d||e[20]!==c||e[21]!==g?(b=s.jsxs("div",{className:d,children:[c,g]}),e[19]=d,e[20]=c,e[21]=g,e[22]=b):b=e[22];let C;return e[23]!==r||e[24]!==m||e[25]!==h||e[26]!==f||e[27]!==b?(C=s.jsx(r,{title:m,info:h,settingsItem:f,children:b}),e[23]=r,e[24]=m,e[25]=h,e[26]=f,e[27]=b,e[28]=C):C=e[28],C},Bg=()=>{const t=Be.c(17),{t:e}=qe(),a=yi(Wg),n=yi(Jg);let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=wu(),t[0]=i):i=t[0];const o=i;let r,d;t[1]!==n?(r=()=>{n()},d=[n,o],t[1]=n,t[2]=r,t[3]=d):(r=t[2],d=t[3]),l.useEffect(r,d);const c=a.kind==="ready"&&a.snapshot.scope===o?a.snapshot:null;let g;t[4]!==e?(g=e("settings.page.webSearch.title"),t[4]=e,t[5]=g):g=t[5];let m;t[6]!==e?(m=e("settings.page.webSearch.description"),t[6]=e,t[7]=m):m=t[7];let h;t[8]!==n||t[9]!==c||t[10]!==a.kind||t[11]!==e?(h=c?s.jsxs(s.Fragment,{children:[s.jsx(Ug,{snapshot:c}),s.jsx($g,{snapshot:c})]}):a.kind==="failed"?s.jsx(He,{divider:!1,children:s.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:e("settings.webSearch.state.loadFailed")}),s.jsx(V,{variant:"outline",size:"xs",onClick:()=>{n()},children:e("settings.webSearch.actions.retry")})]})}):s.jsx(He,{divider:!1,children:s.jsx("p",{className:ds,children:e("settings.webSearch.state.loading")})}),t[8]=n,t[9]=c,t[10]=a.kind,t[11]=e,t[12]=h):h=t[12];let f;return t[13]!==g||t[14]!==m||t[15]!==h?(f=s.jsx(ns,{title:g,description:m,showSaveStatus:!0,children:h}),t[13]=g,t[14]=m,t[15]=h,t[16]=f):f=t[16],f};function Vg(t){return t.setSelection}function Hg(){}function qg(t){return t.saveKey}function Gg(t){return t.removeKey}function Wg(t){return t.state}function Jg(t){return t.load}const Qg=t=>{const e=Be.c(183),{onItemSelect:a}=t,{t:n}=qe(),[i,o]=l.useState(""),[r,d]=l.useState(null),[c,g]=l.useState(""),[m,h]=l.useState(null),[f,p]=l.useState(null),[b,C]=l.useState(!1),[v,k]=l.useState(null),{selectedCommandName:u,setSelectedCommand:y,setCommandDraft:S,createCommand:N,deleteCommand:w,loadCommands:A}=Ya(_s(Yg)),x=en();let T;e[0]!==x?(T=_e=>Xc(_e,x),e[0]=x,e[1]=T):T=e[1];const M=Ya(T);let E;e[2]!==x?(E=_e=>Or(_e,x),e[2]=x,e[3]=E):E=e[3];const D=rn(E),F=rn(Zg);let L,P;e[4]!==A||e[5]!==F||e[6]!==x?(L=()=>{A(x),F(x)},P=[A,F,x],e[4]=A,e[5]=F,e[6]=x,e[7]=L,e[8]=P):(L=e[7],P=e[8]),l.useEffect(L,P);let j;e[9]!==D?(j=new Set(D.map(Xg)),e[9]=D,e[10]=j):j=e[10];const O=j;let K;if(e[11]!==M||e[12]!==O){let _e;e[14]!==O?(_e=Xe=>!O.has(Xe.name),e[14]=O,e[15]=_e):_e=e[15],K=M.filter(_e),e[11]=M,e[12]=O,e[13]=K}else K=e[13];const H=K;let q,Z;e[16]!==u||e[17]!==y||e[18]!==O?(q=()=>{u&&O.has(u)&&y(null)},Z=[u,y,O],e[16]=u,e[17]=y,e[18]=O,e[19]=q,e[20]=Z):(q=e[19],Z=e[20]),l.useEffect(q,Z);let ae;e[21]!==M||e[22]!==a||e[23]!==S||e[24]!==y?(ae=()=>{let _e="new-command",Xe=1;for(;M.some(mt=>mt.name===_e);)_e=`new-command-${Xe}`,Xe++;S({name:_e,scope:"user"}),y(_e),a?.()},e[21]=M,e[22]=a,e[23]=S,e[24]=y,e[25]=ae):ae=e[25];const B=ae;let G;e[26]!==n?(G=async _e=>{if(Ga(_e)){U.error(n("settings.commands.sidebar.toast.builtInCannotDelete"));return}h(_e),p("delete")},e[26]=n,e[27]=G):G=e[27];const _=G;let z;e[28]===Symbol.for("react.memo_cache_sentinel")?(z=async _e=>{Ga(_e)&&(h(_e),p("reset"))},e[28]=z):z=e[28];const te=z;let Q;e[29]===Symbol.for("react.memo_cache_sentinel")?(Q=()=>{h(null),p(null)},e[29]=Q):Q=e[29];const X=Q;let pe;e[30]!==m||e[31]!==f||e[32]!==w||e[33]!==x||e[34]!==n?(pe=async()=>{if(!m||!f)return;C(!0),await w(m.name,x)?(f==="delete"?U.success(n("settings.commands.sidebar.toast.commandDeleted",{name:m.name})):U.success(n("settings.commands.sidebar.toast.commandReset",{name:m.name})),X()):f==="delete"?U.error(n("settings.commands.sidebar.toast.deleteFailed")):U.error(n("settings.commands.sidebar.toast.resetFailed")),C(!1)},e[30]=m,e[31]=f,e[32]=w,e[33]=x,e[34]=n,e[35]=pe):pe=e[35];const je=pe;let fe;e[36]!==M||e[37]!==S||e[38]!==y?(fe=_e=>{const Xe=_e.name;let mt=1,Fe=`${Xe}-copy`;for(;M.some(W=>W.name===Fe);)mt++,Fe=`${Xe}-copy-${mt}`;S({name:Fe,scope:_e.scope||"user",description:_e.description,template:_e.template,agent:_e.agent,model:_e.model,subagent:_e.subagent}),y(Fe)},e[36]=M,e[37]=S,e[38]=y,e[39]=fe):fe=e[39];const ke=fe;let be;e[40]===Symbol.for("react.memo_cache_sentinel")?(be=_e=>{g(_e.name),d(_e)},e[40]=be):be=e[40];const De=be;let oe;e[41]!==M||e[42]!==N||e[43]!==w||e[44]!==r||e[45]!==c||e[46]!==y||e[47]!==x||e[48]!==n?(oe=async()=>{if(!r)return;const _e=c.trim().replace(/\s+/g,"-");if(!_e){U.error(n("settings.commands.sidebar.toast.commandNameRequired"));return}if(_e===r.name){d(null);return}if(M.some(mt=>mt.name===_e)){U.error(n("settings.commands.sidebar.toast.commandExists"));return}await N({name:_e,description:r.description,template:r.template,agent:r.agent,model:r.model,subagent:r.subagent,scope:r.scope},x)?await w(r.name,x)?(U.success(`Command renamed to "${_e}"`),y(_e)):U.error(n("settings.commands.sidebar.toast.removeOldAfterRenameFailed")):U.error(n("settings.commands.sidebar.toast.renameFailed")),d(null)},e[41]=M,e[42]=N,e[43]=w,e[44]=r,e[45]=c,e[46]=y,e[47]=x,e[48]=n,e[49]=oe):oe=e[49];const ee=oe;let ce,ue,Ie,ve,Re,Me;if(e[50]!==H||e[51]!==B||e[52]!==_||e[53]!==ke||e[54]!==a||e[55]!==v||e[56]!==i||e[57]!==u||e[58]!==y||e[59]!==n){let _e;e[66]!==i?(_e=Ce=>go([Ce.name,Ce.description],i),e[66]=i,e[67]=_e):_e=e[67];const Xe=H.filter(_e),mt=Xe.filter(Ga),Fe=Xe.filter(ef);e[68]===Symbol.for("react.memo_cache_sentinel")?(Re=Ne("flex h-full flex-col","bg-background"),e[68]=Re):Re=e[68];let W;e[69]!==n?(W=n("settings.commands.sidebar.title"),e[69]=n,e[70]=W):W=e[70];let ye;e[71]!==W?(ye=s.jsx("h2",{className:`${va} mb-3`,children:W}),e[71]=W,e[72]=ye):ye=e[72];let Ae;e[73]===Symbol.for("react.memo_cache_sentinel")?(Ae=s.jsx(Ni,{className:"mb-3"}),e[73]=Ae):Ae=e[73];let Y;e[74]!==H.length||e[75]!==n?(Y=n("settings.commands.sidebar.total",{count:H.length}),e[74]=H.length,e[75]=n,e[76]=Y):Y=e[76];let Pe;e[77]!==Y?(Pe=s.jsx("span",{className:"typography-meta text-muted-foreground",children:Y}),e[77]=Y,e[78]=Pe):Pe=e[78];let Je;e[79]===Symbol.for("react.memo_cache_sentinel")?(Je=s.jsx($,{name:"add",className:"h-3.5 w-3.5"}),e[79]=Je):Je=e[79];let se;e[80]!==B?(se=s.jsx(V,{size:"sm","data-settings-item":"commands.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:B,children:Je}),e[80]=B,e[81]=se):se=e[81];let We;e[82]!==Pe||e[83]!==se?(We=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[Pe,se]}),e[82]=Pe,e[83]=se,e[84]=We):We=e[84];let ut;e[85]!==H.length||e[86]!==i?(ut=H.length>0?s.jsx(Wr,{value:i,onChange:o}):null,e[85]=H.length,e[86]=i,e[87]=ut):ut=e[87],e[88]!==ye||e[89]!==We||e[90]!==ut?(Me=s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[ye,Ae,We,ut]}),e[88]=ye,e[89]=We,e[90]=ut,e[91]=Me):Me=e[91],ce=Ds,ue="flex-1 min-h-0",Ie="space-y-1 px-3 py-2",ve=H.length===0?s.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[s.jsx($,{name:"terminal-box",className:"mx-auto mb-3 h-10 w-10 opacity-50"}),s.jsx("p",{className:"typography-ui-label font-medium",children:n("settings.commands.sidebar.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:n("settings.commands.sidebar.empty.description")})]}):Xe.length===0?s.jsx(Jr,{query:i}):s.jsxs(s.Fragment,{children:[mt.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:n("settings.commands.sidebar.section.builtIn")}),[...mt].sort(tf).map(Ce=>s.jsx(Vl,{command:Ce,isSelected:u===Ce.name,onSelect:()=>{y(Ce.name),a?.()},onReset:()=>te(Ce),onDuplicate:()=>ke(Ce),isMenuOpen:v===Ce.name,onMenuOpenChange:Ve=>k(Ve?Ce.name:null)},Ce.name))]}),Fe.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:n("settings.commands.sidebar.section.custom")}),[...Fe].sort(sf).map(Ce=>s.jsx(Vl,{command:Ce,isSelected:u===Ce.name,onSelect:()=>{y(Ce.name),a?.()},onRename:()=>De(Ce),onDelete:()=>_(Ce),onDuplicate:()=>ke(Ce),isMenuOpen:v===Ce.name,onMenuOpenChange:Ve=>k(Ve?Ce.name:null)},Ce.name))]})]}),e[50]=H,e[51]=B,e[52]=_,e[53]=ke,e[54]=a,e[55]=v,e[56]=i,e[57]=u,e[58]=y,e[59]=n,e[60]=ce,e[61]=ue,e[62]=Ie,e[63]=ve,e[64]=Re,e[65]=Me}else ce=e[60],ue=e[61],Ie=e[62],ve=e[63],Re=e[64],Me=e[65];let me;e[92]!==ce||e[93]!==ue||e[94]!==Ie||e[95]!==ve?(me=s.jsx(ce,{outerClassName:ue,className:Ie,children:ve}),e[92]=ce,e[93]=ue,e[94]=Ie,e[95]=ve,e[96]=me):me=e[96];const Te=m!==null&&f!==null;let Oe;e[97]!==b?(Oe=_e=>{!_e&&!b&&X()},e[97]=b,e[98]=Oe):Oe=e[98];let ge;e[99]!==f||e[100]!==n?(ge=n(f==="delete"?"settings.commands.sidebar.dialog.deleteTitle":"settings.commands.sidebar.dialog.resetTitle"),e[99]=f,e[100]=n,e[101]=ge):ge=e[101];let xe;e[102]!==ge?(xe=s.jsx(Ht,{children:ge}),e[102]=ge,e[103]=xe):xe=e[103];let ne;e[104]!==m?.name||e[105]!==f||e[106]!==n?(ne=f==="delete"?n("settings.commands.sidebar.dialog.deleteDescription",{name:m?.name??""}):n("settings.commands.sidebar.dialog.resetDescription",{name:m?.name??""}),e[104]=m?.name,e[105]=f,e[106]=n,e[107]=ne):ne=e[107];let ie;e[108]!==ne?(ie=s.jsx(qt,{children:ne}),e[108]=ne,e[109]=ie):ie=e[109];let he;e[110]!==xe||e[111]!==ie?(he=s.jsxs(Vt,{children:[xe,ie]}),e[110]=xe,e[111]=ie,e[112]=he):he=e[112];let Ee;e[113]!==n?(Ee=n("settings.common.actions.cancel"),e[113]=n,e[114]=Ee):Ee=e[114];let Ke;e[115]!==b||e[116]!==Ee?(Ke=s.jsx(V,{size:"sm",variant:"ghost",onClick:X,disabled:b,children:Ee}),e[115]=b,e[116]=Ee,e[117]=Ke):Ke=e[117];let Le;e[118]!==f||e[119]!==n?(Le=n(f==="delete"?"settings.common.actions.delete":"settings.common.actions.reset"),e[118]=f,e[119]=n,e[120]=Le):Le=e[120];let Se;e[121]!==je||e[122]!==b||e[123]!==Le?(Se=s.jsx(V,{size:"sm",onClick:je,disabled:b,children:Le}),e[121]=je,e[122]=b,e[123]=Le,e[124]=Se):Se=e[124];let $e;e[125]!==Ke||e[126]!==Se?($e=s.jsxs(as,{children:[Ke,Se]}),e[125]=Ke,e[126]=Se,e[127]=$e):$e=e[127];let Ye;e[128]!==he||e[129]!==$e?(Ye=s.jsxs($t,{className:"max-w-md",children:[he,$e]}),e[128]=he,e[129]=$e,e[130]=Ye):Ye=e[130];let pt;e[131]!==Te||e[132]!==Oe||e[133]!==Ye?(pt=s.jsx(_t,{open:Te,onOpenChange:Oe,children:Ye}),e[131]=Te,e[132]=Oe,e[133]=Ye,e[134]=pt):pt=e[134];const vt=r!==null;let wt;e[135]===Symbol.for("react.memo_cache_sentinel")?(wt=_e=>!_e&&d(null),e[135]=wt):wt=e[135];let yt;e[136]!==n?(yt=n("settings.commands.sidebar.renameDialog.title"),e[136]=n,e[137]=yt):yt=e[137];let st;e[138]!==yt?(st=s.jsx(Ht,{children:yt}),e[138]=yt,e[139]=st):st=e[139];const rt=r?.name??"";let de;e[140]!==n||e[141]!==rt?(de=n("settings.commands.sidebar.renameDialog.description",{name:rt}),e[140]=n,e[141]=rt,e[142]=de):de=e[142];let Ue;e[143]!==de?(Ue=s.jsx(qt,{children:de}),e[143]=de,e[144]=Ue):Ue=e[144];let et;e[145]!==st||e[146]!==Ue?(et=s.jsxs(Vt,{children:[st,Ue]}),e[145]=st,e[146]=Ue,e[147]=et):et=e[147];let ze;e[148]===Symbol.for("react.memo_cache_sentinel")?(ze=_e=>g(_e.target.value),e[148]=ze):ze=e[148];let Ze;e[149]!==n?(Ze=n("settings.commands.sidebar.renameDialog.placeholder"),e[149]=n,e[150]=Ze):Ze=e[150];let tt;e[151]!==ee?(tt=_e=>{_e.key==="Enter"&&ee()},e[151]=ee,e[152]=tt):tt=e[152];let lt;e[153]!==c||e[154]!==Ze||e[155]!==tt?(lt=s.jsx(Ge,{value:c,onChange:ze,placeholder:Ze,className:"text-foreground placeholder:text-muted-foreground",onKeyDown:tt}),e[153]=c,e[154]=Ze,e[155]=tt,e[156]=lt):lt=e[156];let J;e[157]===Symbol.for("react.memo_cache_sentinel")?(J=()=>d(null),e[157]=J):J=e[157];let nt;e[158]!==n?(nt=n("settings.common.actions.cancel"),e[158]=n,e[159]=nt):nt=e[159];let ot;e[160]!==nt?(ot=s.jsx(V,{size:"sm",variant:"ghost",onClick:J,children:nt}),e[160]=nt,e[161]=ot):ot=e[161];let it;e[162]!==n?(it=n("settings.common.actions.rename"),e[162]=n,e[163]=it):it=e[163];let ft;e[164]!==ee||e[165]!==it?(ft=s.jsx(V,{size:"sm",onClick:ee,children:it}),e[164]=ee,e[165]=it,e[166]=ft):ft=e[166];let xt;e[167]!==ot||e[168]!==ft?(xt=s.jsxs(as,{children:[ot,ft]}),e[167]=ot,e[168]=ft,e[169]=xt):xt=e[169];let ht;e[170]!==et||e[171]!==lt||e[172]!==xt?(ht=s.jsxs($t,{children:[et,lt,xt]}),e[170]=et,e[171]=lt,e[172]=xt,e[173]=ht):ht=e[173];let St;e[174]!==vt||e[175]!==ht?(St=s.jsx(_t,{open:vt,onOpenChange:wt,children:ht}),e[174]=vt,e[175]=ht,e[176]=St):St=e[176];let At;return e[177]!==Re||e[178]!==Me||e[179]!==me||e[180]!==pt||e[181]!==St?(At=s.jsxs("div",{className:Re,children:[Me,me,pt,St]}),e[177]=Re,e[178]=Me,e[179]=me,e[180]=pt,e[181]=St,e[182]=At):At=e[182],At},Vl=t=>{const e=Be.c(47),{command:a,isSelected:n,onSelect:i,onDelete:o,onReset:r,onRename:d,onDuplicate:c,isMenuOpen:g,onMenuOpenChange:m}=t,{t:h}=qe();let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=Mr(),e[0]=f):f=e[0];const p=f,[b,C]=l.useState(!1);let v;e[1]!==o||e[2]!==c||e[3]!==d||e[4]!==r||e[5]!==h?(v=H=>s.jsxs(s.Fragment,{children:[d&&s.jsxs(H,{onClick:q=>{q.stopPropagation(),d()},children:[s.jsx($,{name:"edit",className:"h-4 w-4 mr-px"}),h("settings.common.actions.rename")]}),s.jsxs(H,{onClick:q=>{q.stopPropagation(),c()},children:[s.jsx($,{name:"file-copy",className:"h-4 w-4 mr-px"}),h("settings.common.actions.duplicate")]}),r&&s.jsxs(H,{onClick:q=>{q.stopPropagation(),r()},children:[s.jsx($,{name:"restart",className:"h-4 w-4 mr-px"}),h("settings.common.actions.reset")]}),o&&s.jsxs(H,{onClick:q=>{q.stopPropagation(),o()},className:"text-destructive focus:text-destructive",children:[s.jsx($,{name:"delete-bin",className:"h-4 w-4 mr-px"}),h("settings.common.actions.delete")]})]}),e[1]=o,e[2]=c,e[3]=d,e[4]=r,e[5]=h,e[6]=v):v=e[6];const k=v,u=n?"bg-interactive-selection":"hover:bg-interactive-hover";let y;e[7]!==u?(y=Ne("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",u),e[7]=u,e[8]=y):y=e[8];let S;e[9]===Symbol.for("react.memo_cache_sentinel")?(S=p?void 0:H=>{H.preventDefault(),C(!0)},e[9]=S):S=e[9];let N;e[10]!==y?(N=s.jsx("div",{className:y,onContextMenu:S}),e[10]=y,e[11]=N):N=e[11];let w;e[12]!==a.name?(w=s.jsxs("span",{className:"typography-ui-label font-normal truncate text-foreground",children:["/",a.name]}),e[12]=a.name,e[13]=w):w=e[13];let A;e[14]!==a||e[15]!==h?(A=(a.scope||Ga(a))&&s.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:Ga(a)?h("settings.agents.sidebar.badge.system"):a.scope}),e[14]=a,e[15]=h,e[16]=A):A=e[16];let x;e[17]!==w||e[18]!==A?(x=s.jsxs("div",{className:"flex items-center gap-2",children:[w,A]}),e[17]=w,e[18]=A,e[19]=x):x=e[19];let T;e[20]!==a.description?(T=a.description&&s.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:a.description}),e[20]=a.description,e[21]=T):T=e[21];let M;e[22]!==i||e[23]!==T||e[24]!==x?(M=s.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-ring",tabIndex:0,children:[x,T]}),e[22]=i,e[23]=T,e[24]=x,e[25]=M):M=e[25];let E;e[26]!==m?(E=H=>{H&&C(!1),m(H)},e[26]=m,e[27]=E):E=e[27];let D;e[28]===Symbol.for("react.memo_cache_sentinel")?(D=s.jsx(Wn,{asChild:!0,children:s.jsx(V,{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:s.jsx($,{name:"more-2",className:"h-3.5 w-3.5"})})}),e[28]=D):D=e[28];let F;e[29]!==k?(F=s.jsx(Gn,{align:"end",className:"w-fit min-w-20",children:k(xn)}),e[29]=k,e[30]=F):F=e[30];let L;e[31]!==g||e[32]!==E||e[33]!==F?(L=s.jsxs(Jn,{open:g,onOpenChange:E,children:[D,F]}),e[31]=g,e[32]=E,e[33]=F,e[34]=L):L=e[34];let P;e[35]!==M||e[36]!==L?(P=s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[M,L]}),e[35]=M,e[36]=L,e[37]=P):P=e[37];let j;e[38]!==P||e[39]!==N?(j=s.jsx(ti,{render:N,children:P}),e[38]=P,e[39]=N,e[40]=j):j=e[40];let O;e[41]!==k?(O=s.jsx(Xa,{className:"w-fit min-w-20",children:k(ei)}),e[41]=k,e[42]=O):O=e[42];let K;return e[43]!==b||e[44]!==j||e[45]!==O?(K=s.jsxs(si,{open:b,onOpenChange:C,children:[j,O]}),e[43]=b,e[44]=j,e[45]=O,e[46]=K):K=e[46],K};function Yg(t){return{selectedCommandName:t.selectedCommandName,setSelectedCommand:t.setSelectedCommand,setCommandDraft:t.setCommandDraft,createCommand:t.createCommand,deleteCommand:t.deleteCommand,loadCommands:t.loadCommands}}function Zg(t){return t.loadSkills}function Xg(t){return t.name}function ef(t){return!Ga(t)}function tf(t,e){return t.name.localeCompare(e.name)}function sf(t,e){return t.name.localeCompare(e.name)}const nf=()=>{const{t}=qe(),{selectedCommandName:e,getCommandByName:a,createCommand:n,updateCommand:i,commandDraft:o,setCommandDraft:r,setSelectedCommand:d}=Ya(_s(G=>({selectedCommandName:G.selectedCommandName,getCommandByName:G.getCommandByName,createCommand:G.createCommand,updateCommand:G.updateCommand,commandDraft:G.commandDraft,setCommandDraft:G.setCommandDraft,setSelectedCommand:G.setSelectedCommand}))),c=en(),g=Ya(G=>Xc(G,c)),m=e?a(e,c):null,h=!!(o&&o.name===e&&!m),[f,p]=l.useState(""),[b,C]=l.useState("user"),[v,k]=l.useState(""),[u,y]=l.useState(""),[S,N]=l.useState(""),[w,A]=l.useState(""),[x,T]=l.useState(!1),[M,E]=l.useState(""),[D,F]=l.useState(!1),L=l.useRef(null),P=JSON.stringify([c,e]),j=l.useRef(null),O=l.useRef(null);l.useEffect(()=>{const G=j.current===P;if(j.current=P,h&&o){const _=o.name||"",z=o.scope||"user",te=o.description||"",Q=o.agent||"",X=hi(o.model),pe=X?`${X.providerID}/${X.modelID}`:"",je=X?.variant||"",fe=o.subagent===!0,ke=o.template||"";p(_),C(z),k(te),y(Q),N(pe),A(je),T(fe),E(ke),L.current={draftName:_,draftScope:z,description:te,agent:Q,model:pe,variant:je,subagent:fe,template:ke}}else if(m){const _=m.description||"",z=m.agent||"",te=hi(m.model),Q=te?`${te.providerID}/${te.modelID}`:"",X=te?.variant||"",pe=m.subagent===!0,je=m.template||"",fe=O.current,ke=[L.current,fe?.identity===P?fe.form:null];if(G&&ke.some(be=>be&&be.description===_&&be.agent===z&&be.model===Q&&be.variant===X&&be.subagent===pe&&be.template===je))return;k(_),y(z),N(Q),A(X),T(pe),E(je),L.current={draftName:"",draftScope:"user",description:_,agent:z,model:Q,variant:X,subagent:pe,template:je}}},[m,h,e,g,o,P]);const K=l.useCallback(G=>{const _=u.trim(),z=_n(S.trim()),te=z?Yc({providerID:z.providerId,modelID:z.modelId,variant:w.trim()||void 0}):null;return{name:G,description:v.trim()||void 0,agent:_===""?null:_,model:te,subagent:x,template:M.trim(),scope:h?b:void 0}},[u,v,b,h,S,x,M,w]),H=l.useCallback(async()=>{const G=L.current,_=e?.trim();if(h||!G||!_||v.trim()===G.description.trim()&&u.trim()===G.agent.trim()&&S.trim()===G.model.trim()&&w.trim()===G.variant.trim()&&x===G.subagent&&M.trim()===G.template.trim())return Us;if(!M.trim())return xs(t("settings.commands.page.toast.templateRequired"));const te=K(_),Q=hi(te.model),X={identity:P,form:{...G,description:te.description||"",agent:te.agent||"",model:Q?`${Q.providerID}/${Q.modelID}`:"",variant:Q?.variant||"",subagent:te.subagent===!0,template:te.template||""}};O.current=X;try{return await i(_,te,c)?(j.current===P&&(L.current=X.form),Tn):xs(t("settings.commands.page.toast.updateFailed"))}finally{O.current===X&&(O.current=null)}},[u,K,v,P,h,S,e,c,x,t,M,i,w]),q=ni(H),{requestSave:Z}=q,ae=async()=>{const G=f.trim().replace(/\s+/g,"-");if(!G){U.error(t("settings.commands.sidebar.toast.commandNameRequired"));return}if(!M.trim()){U.error(t("settings.commands.page.toast.templateRequired"));return}if(g.some(_=>_.name===G)){U.error(t("settings.commands.sidebar.toast.commandExists"));return}F(!0);try{await n(K(G),c)?(r(null),U.success(t("settings.commands.page.toast.created"))):U.error(t("settings.commands.page.toast.createFailed"))}catch(_){console.error("Error creating command:",_),U.error(t("settings.commands.page.toast.saveUnexpectedError"))}finally{F(!1)}},B=()=>{r(null),d(null)};return e?s.jsxs(ns,{title:h?t("settings.commands.page.title.new"):`/${e}`,description:t(h?"settings.commands.page.subtitle.new":"settings.commands.page.subtitle.edit"),onBlurCapture:q.onBlurCapture,children:[!h&&m&&s.jsx(Qr,{legacy:m.legacy===!0,path:m.path}),s.jsxs(He,{title:t("settings.commands.page.section.identity"),divider:!1,contentClassName:"space-y-0",children:[h&&s.jsxs(Ct,{settingsItem:"commands.name",label:t("settings.commands.page.field.commandName"),children:[s.jsxs("div",{className:"flex items-center",children:[s.jsx("span",{className:"typography-ui-label text-muted-foreground mr-1",children:"/"}),s.jsx(Ge,{value:f,onChange:G=>p(G.target.value),placeholder:t("settings.commands.page.field.commandNamePlaceholder"),className:"h-7 w-40 px-2"})]}),s.jsxs(Dt,{value:b,onValueChange:G=>C(G),children:[s.jsx(Tt,{size:Qt,className:"w-fit min-w-[100px]",children:s.jsx(Jt,{placeholder:t("settings.agents.page.field.scopePlaceholder")})}),s.jsxs(Et,{align:"end",children:[s.jsx(gt,{value:"user",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx($,{name:"user-3",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.common.scope.global")})]})}),s.jsx(gt,{value:"project",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx($,{name:"folder",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.common.scope.project")})]})})]})]})]}),s.jsxs("div",{className:"py-1.5",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:t("settings.common.field.description")}),s.jsx("div",{className:"mt-1.5",children:s.jsx(Rs,{value:v,onChange:G=>k(G.target.value),placeholder:t("settings.commands.page.field.descriptionPlaceholder"),rows:2,className:"w-full resize-none min-h-[60px] bg-transparent"})})]})]}),s.jsxs(He,{title:t("settings.commands.page.section.executionContext"),contentClassName:"space-y-0",children:[s.jsx(Ct,{settingsItem:"commands.agent",label:t("settings.commands.page.field.overrideAgent"),children:s.jsx(Lr,{agentName:u,onChange:G=>{y(G),Z()},className:Zs})}),s.jsx(Ct,{settingsItem:"commands.model",label:t("settings.agents.page.field.overrideModel"),children:s.jsx(pa,{providerId:_n(S)?.providerId??"",modelId:_n(S)?.modelId??"",onChange:(G,_)=>{N(G&&_?`${G}/${_}`:""),Z()},className:Zs})}),s.jsx(Ct,{settingsItem:"commands.variant",label:t("settings.agents.page.field.variant"),info:t("settings.agents.page.field.variantTooltip"),children:s.jsx(Ge,{value:w,onChange:G=>A(G.target.value),placeholder:t("settings.agents.page.field.variantPlaceholder"),disabled:!S&&!w,className:"h-8 w-40 rounded-md px-3"})}),s.jsx(Ct,{settingsItem:"commands.subagent",label:t("settings.commands.page.field.subagent"),info:t("settings.commands.page.field.subagentTooltip"),children:s.jsx(ga,{checked:x,onCheckedChange:G=>{T(G),Z()},"aria-label":t("settings.commands.page.field.subagent")})})]}),s.jsxs(He,{title:t("settings.commands.page.section.template"),settingsItem:"commands.template",children:[s.jsx(Rs,{value:M,onChange:G=>E(G.target.value),placeholder:t("settings.commands.page.field.templatePlaceholder"),rows:12,className:"w-full font-mono typography-meta min-h-[160px] max-h-[60vh] bg-transparent"}),s.jsxs("p",{className:"mt-2 typography-meta text-muted-foreground",children:[s.jsx("code",{className:"text-foreground",children:"$ARGUMENTS"})," ",t("settings.commands.page.templateHint.userInput")," ·"," ",s.jsx("code",{className:"text-foreground",children:"!`cmd`"})," ",t("settings.commands.page.templateHint.shellOutput")," ·"," ",s.jsx("code",{className:"text-foreground",children:"@file"})," ",t("settings.commands.page.templateHint.fileContents")]}),h&&s.jsxs("div",{className:"flex items-center gap-2 pt-3",children:[s.jsx(V,{onClick:()=>{ae()},disabled:D||!f.trim()||!M.trim(),size:"xs",className:"!font-normal",children:t(D?"settings.common.actions.saving":"settings.common.actions.create")}),s.jsx(V,{variant:"ghost",onClick:B,disabled:D,size:"xs",className:"!font-normal",children:t("settings.common.actions.cancel")})]})]})]}):s.jsx("div",{className:"flex h-full items-center justify-center",children:s.jsxs("div",{className:"text-center text-muted-foreground",children:[s.jsx($,{name:"terminal-box",className:"mx-auto mb-3 h-12 w-12 opacity-50"}),s.jsx("p",{className:"typography-body",children:t("settings.commands.page.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:t("settings.commands.page.empty.description")})]})})};function Ys(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function ri(t){return Array.isArray(t)&&t.every(e=>typeof e=="string")}function Cn(t,e){return e!==void 0?{ok:!1,error:t,parsed:e}:{ok:!1,error:t}}function _i(t,e,a){const n=of(a),i=typeof a.url=="string"?a.url.trim():"",o=Hl(a,"env","environment"),r=Hl(a,"headers"),d=Ys(a.oauth)?a.oauth:null,c=li(d,"client_id","clientId"),g=li(d,"client_secret","clientSecret"),m=li(d,"scope"),h=li(d,"redirect_uri","redirectUri"),f=af(d,"callback_port","callbackPort"),p=li(d,"auth_server_metadata_url","authServerMetadataUrl"),b=a.oauth===!1||a.oauth===null||a.oauth===void 0?!1:!!d&&!!(c||g||m||h||f||p),C=rf(a);return{ok:!0,name:t,type:e,command:n,url:i,environment:o,headers:r,oauthEnabled:b,oauthClientId:c,oauthClientSecret:g,oauthScope:m,oauthRedirectUri:h,oauthCallbackPort:f,oauthAuthServerMetadataUrl:p,timeoutStartup:C.startup,timeoutCatalog:C.catalog,timeoutExecution:C.execution,codemode:a.codemode===!0?"on":a.codemode===!1?"off":"default",disabled:lf(a),protocol:pr.find(v=>v===a.protocol)??"legacy"}}function li(t,...e){if(!t)return"";for(const a of e){const n=t[a];if(typeof n=="string"&&n.trim())return n.trim()}return""}function af(t,...e){if(!t)return"";for(const a of e){const n=gi(t[a]);if(n)return n}return""}function gi(t){if(typeof t=="number"&&Number.isFinite(t)&&t>0)return String(Math.floor(t));if(typeof t=="string"&&t.trim()){const e=Number(t);if(Number.isFinite(e)&&e>0)return String(Math.floor(e))}return""}function of(t){const e=t.command,a=t.args;if(ri(e)&&ri(a))return[...e,...a];if(ri(e))return e;if(typeof e=="string"&&e.trim()){const n=e.trim().split(/\s+/);return ri(a)?[...n,...a]:n}return ri(a)?a:[]}function Hl(t,...e){for(const a of e){const n=t[a];if(!Ys(n))continue;const i=Object.entries(n).filter(([o,r])=>o&&typeof r=="string");if(i.length>0)return i.map(([o,r])=>({key:o,value:String(r)}))}return[]}function rf(t){return Ys(t.timeout)?{startup:gi(t.timeout.startup),catalog:gi(t.timeout.catalog),execution:gi(t.timeout.execution)}:{startup:"",catalog:"",execution:gi(t.timeout)}}function lf(t){return t.disabled===!0?!0:t.disabled===!1?!1:"enabled"in t?!t.enabled:!1}function cf(t){const e=t.mcpServers;if(Ys(e)){const n=Object.keys(e);if(n.length===1){const i=n[0],o=e[i];if(Ys(o))return{name:i,entry:o}}if(n.length>1)return null}const a=Object.keys(t).filter(n=>{const i=t[n];return n!=="mcpServers"&&Ys(i)});if(a.length===1){const n=a[0],i=t[n];if(Nd(i))return{name:n,entry:i}}return null}function Nd(t){return t.type==="local"||t.type==="remote"||Array.isArray(t.command)||typeof t.url=="string"||Array.isArray(t.args)}function df(t,e){let a;try{const c=t.trim();if(!c)return Cn("No JSON content provided");a=JSON.parse(c)}catch(c){return Cn(c instanceof Error?`Invalid JSON: ${c.message}`:"Invalid JSON")}if(!Ys(a))return Cn("Expected a JSON object, not an array or primitive");const n=a,i=n.mcpServers;if(Ys(i)){const c=Object.keys(i);if(c.length===0)return Cn("mcpServers object is empty",a);if(c.length>1)return Cn("Paste one server at a time. Found "+c.length+" servers in mcpServers",a);const g=c[0],m=i[g];return Ys(m)?_i(g,$i(m),m):Cn("Server entry is not a valid object",a)}const o=n.mcp,r=Ys(o)&&Ys(o.servers)?o.servers:o;if(Ys(r)){const c=Object.keys(r);if(c.length===0)return Cn("mcp object is empty",a);if(c.length>1)return Cn("Paste one server at a time. Found "+c.length+" servers in mcp",a);const g=c[0],m=r[g];return Ys(m)?_i(g,$i(m),m):Cn("Server entry in mcp is not a valid object",a)}const d=cf(n);if(d)return _i(d.name,$i(d.entry),d.entry);if(Nd(n)){const c=$i(n),g=typeof n.name=="string"&&n.name.trim()?n.name.trim():e?.fallbackName;return _i(g,c,n)}return Cn("No recognizable MCP server configuration found in JSON",a)}function $i(t){return t.type==="remote"?"remote":t.type==="local"?"local":typeof t.url=="string"&&t.url.trim()?"remote":(Array.isArray(t.command)||typeof t.command=="string"||Array.isArray(t.args),"local")}function uf(t,e,a){const n=a?.isNewServer??!1,i=t.name,o=n&&i?i:e.name??"";return{...e,name:o,type:t.type,command:t.type==="local"?t.command:[],url:t.type==="remote"?t.url:"",environment:t.environment,headers:t.type==="remote"?t.headers:[],oauthEnabled:t.type==="remote"?t.oauthEnabled:!1,oauthClientId:t.type==="remote"?t.oauthClientId:"",oauthClientSecret:t.type==="remote"?t.oauthClientSecret:"",oauthScope:t.type==="remote"?t.oauthScope:"",oauthRedirectUri:t.type==="remote"?t.oauthRedirectUri:"",oauthCallbackPort:t.type==="remote"?t.oauthCallbackPort:"",oauthAuthServerMetadataUrl:t.type==="remote"?t.oauthAuthServerMetadataUrl:"",timeoutStartup:t.type==="local"?t.timeoutStartup:"",timeoutCatalog:t.timeoutCatalog,timeoutExecution:t.timeoutExecution,codemode:t.codemode,disabled:t.disabled,protocol:t.protocol}}const mf=(t,e)=>!!e&&t!=="claude-code",pf=/[A-Z0-9]{4}-[A-Z0-9]{4,5}/,gf=t=>pf.exec(t)?.[0]??void 0,Si=t=>t.type!=="external",Bi=t=>t.title??t.key,ff=(t,e)=>{if(e===void 0)return!1;const a=String(e),n=String(t.value);return t.op==="eq"?a===n:a!==n},hf=(t,e)=>Si(t)?(t.when??[]).every(a=>ff(a,e[a.key])):!0,Yr=(t,e)=>{const a={},n=[];for(const i of t){if(!hf(i,a))continue;n.push(i);const o=e[i.key];Si(i)&&o!==void 0&&(a[i.key]=o)}return n},xf=t=>{const e={};for(const a of t)switch(a.type){case"external":break;case"boolean":e[a.key]=a.default??!1;break;case"number":case"integer":typeof a.default=="number"&&(e[a.key]=a.default);break;case"multiselect":e[a.key]=a.default??[];break;case"string":e[a.key]=a.default??a.options?.[0]?.value??"";break}return e},Sd=t=>t===void 0?!0:typeof t=="string"?t.trim().length===0:Array.isArray(t)?t.length===0:!1,bf=(t,e)=>Yr(t,e).find(a=>Si(a)&&a.required===!0&&Sd(e[a.key]))??null,vf=(t,e)=>{const a={};for(const n of Yr(t,e)){if(!Si(n))continue;const i=e[n.key];Sd(i)||i===void 0||(a[n.key]=typeof i=="string"?i.trim():i)}return a},ql=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),Gl=t=>typeof t=="string"&&t.length>0?t:void 0,yf=(t,e,a)=>{const n=ql(t)?t:{},i=ql(n.data)?n.data:{};switch(n.name){case"IntegrationOauthAttemptMissing":return e("settings.providers.page.auth.oauth.error.sessionExpired");case"IntegrationOauthCodeMissing":return e("settings.providers.page.auth.oauth.error.codeRequired");case"IntegrationOauthFailed":return e("settings.providers.page.auth.oauth.error.declined");case"IntegrationValidationFailed":return Gl(i.message)??e("settings.providers.page.auth.oauth.error.invalidInput");default:return Gl(n.message)??e(a)}},Ho={phase:"idle"},jf=1500,kr=({integrationId:t,methods:e,onConnected:a,directory:n,className:i})=>{const{t:o}=qe(),r=l.useCallback(()=>n?Ts.getScopedSdkClient(n):Ts.getSdkClient(),[n]),[d,c]=l.useState(Ho),[g,m]=l.useState({}),[h,f]=l.useState(""),p=l.useRef(null),b=l.useCallback(D=>{p.current=null,r().integration.oauth.cancel({integrationID:t,attemptID:D}).catch(()=>{})},[t,r]);l.useEffect(()=>()=>{const D=p.current;D&&b(D)},[b]);const C=d.phase==="idle"?null:d.methodID,v=d.phase==="connecting"||d.phase==="waiting"||d.phase==="awaitingCode"&&d.submitting,k=async(D,F,L)=>{const P=await qa(D);if(P.ok){U.success(o(F));return}console.error("Failed to copy OAuth value:",P.error),U.error(o(L))},u=async()=>{p.current=null,c(Ho),U.success(o("settings.providers.page.toast.oauthCompleted")),await a()},y=(D,F,L)=>{p.current=null,console.error("OAuth flow failed:",F),c({phase:"failed",methodID:D,message:yf(F,o,L)})},S=async(D,F)=>{const L=r();for(;p.current===F;){if(await new Promise(P=>setTimeout(P,jf)),p.current!==F)return;try{const{data:P}=await L.integration.oauth.status({integrationID:t,attemptID:F});if(p.current!==F)return;if(P.status==="complete"){await u();return}if(P.status==="failed"){c({phase:"failed",methodID:D,message:P.message}),p.current=null;return}}catch(P){if(p.current!==F)return;y(D,P,"settings.providers.page.toast.oauthCompleteFailed");return}}},N=async(D,F)=>{c({phase:"connecting",methodID:D.id});let L;try{const{data:P}=await r().integration.oauth.connect({integrationID:t,methodID:D.id,...Object.keys(F).length>0?{answer:F}:{}});L={attemptID:P.attemptID,mode:P.mode,url:P.url,instructions:P.instructions}}catch(P){y(D.id,P,"settings.providers.page.toast.oauthStartFailed");return}if(p.current=L.attemptID,mf(t,L.url)&&Gs(L.url),L.mode==="code"){f(""),c({phase:"awaitingCode",methodID:D.id,attempt:L,submitting:!1});return}c({phase:"waiting",methodID:D.id,attempt:L}),await S(D.id,L.attemptID)},w=D=>{const F=(D.form??[]).filter(Si);if(F.length===0){N(D,{});return}m(xf(F)),c({phase:"prompting",methodID:D.id,fields:F,error:null})},A=D=>{if(d.phase!=="prompting")return;const F=bf(d.fields,g);if(F){c({...d,error:o("settings.providers.page.auth.oauth.promptRequired",{field:Bi(F)})});return}N(D,vf(d.fields,g))},x=async()=>{if(d.phase!=="awaitingCode")return;const D=h.trim();if(!D)return;const{methodID:F,attempt:L}=d;c({...d,submitting:!0});try{await r().integration.oauth.complete({integrationID:t,attemptID:L.attemptID,code:D}),await u()}catch(P){y(F,P,"settings.providers.page.toast.oauthCompleteFailed")}},T=()=>{(d.phase==="waiting"||d.phase==="awaitingCode")&&b(d.attempt.attemptID),c(Ho)},M=D=>{if(D.type==="external")return s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"typography-ui-label text-foreground",children:Bi(D)}),s.jsx(V,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Gs(D.url)},children:o("settings.providers.page.actions.open")})]},D.key);const F=g[D.key],L=typeof F=="string"?F:"",P=O=>m(K=>({...K,[D.key]:O})),j=D.type==="string"||D.type==="multiselect"?D.options??[]:[];return s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"typography-ui-label text-foreground",children:Bi(D)}),D.description&&s.jsx("p",{className:"typography-meta text-muted-foreground",children:D.description}),j.length>0?s.jsxs(Dt,{value:L,onValueChange:P,children:[s.jsx(Tt,{size:Qt,className:fn,children:s.jsx(Jt,{children:O=>j.find(K=>K.value===O)?.label??null})}),s.jsx(Et,{children:j.map(O=>s.jsx(gt,{value:O.value,children:O.description?`${O.label} · ${O.description}`:O.label},O.value))})]}):D.type==="boolean"?s.jsx("input",{type:"checkbox",checked:F===!0,onChange:O=>P(O.target.checked),"aria-label":Bi(D)}):s.jsx(Ge,{value:L,onChange:O=>P(O.target.value),placeholder:D.type==="string"?D.placeholder:void 0,className:"max-w-[24rem] text-xs"})]},D.key)},E=D=>{const F=gf(D.instructions);return s.jsxs(s.Fragment,{children:[D.instructions&&s.jsx("p",{className:"typography-meta text-[var(--status-info-text)] bg-[var(--status-info-background)] px-2 py-1.5 rounded",children:D.instructions}),F&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ge,{value:F,readOnly:!0,"aria-label":o("settings.providers.page.auth.oauth.deviceCodeLabel"),className:"font-mono text-center tracking-widest"}),s.jsx(V,{variant:"outline",size:"xs",className:"!font-normal shrink-0",onClick:()=>{k(F,"settings.providers.page.toast.deviceCodeCopied","settings.providers.page.toast.deviceCodeCopyFailed")},children:o("settings.providers.page.actions.copyCode")})]}),D.url&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ge,{value:D.url,readOnly:!0,"aria-label":o("settings.providers.page.auth.oauth.linkLabel"),className:"text-xs text-muted-foreground"}),s.jsxs("div",{className:"flex gap-1 shrink-0",children:[s.jsx(V,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Gs(D.url)},children:o("settings.providers.page.actions.open")}),s.jsx(V,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{k(D.url,"settings.providers.page.toast.oauthLinkCopied","settings.providers.page.toast.oauthLinkCopyFailed")},children:o("settings.providers.page.actions.copy")})]})]})]})};return s.jsx("div",{className:Ne("space-y-4",i),children:e.map(D=>{const F=C===D.id;return s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"typography-ui-label text-foreground",children:D.label}),s.jsx(V,{variant:"outline",size:"xs",className:"!font-normal shrink-0",onClick:()=>w(D),disabled:v,children:o("settings.providers.page.actions.connect")})]}),F&&d.phase==="prompting"&&s.jsxs("div",{className:"space-y-3",children:[Yr(d.fields,g).map(M),d.error&&s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:d.error}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(V,{size:"xs",className:"!font-normal",onClick:()=>A(D),children:o("settings.providers.page.actions.continue")}),s.jsx(V,{variant:"ghost",size:"xs",className:"!font-normal",onClick:T,children:o("settings.providers.page.actions.cancel")})]})]}),F&&d.phase==="connecting"&&s.jsxs("p",{className:"typography-meta text-muted-foreground flex items-center gap-2",children:[s.jsx($,{name:"loader",className:"h-3.5 w-3.5 animate-spin"}),o("settings.providers.page.auth.oauth.starting")]}),F&&d.phase==="waiting"&&s.jsxs("div",{className:"space-y-3",children:[E(d.attempt),s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("p",{className:"typography-meta text-muted-foreground flex items-center gap-2",children:[s.jsx($,{name:"loader",className:"h-3.5 w-3.5 animate-spin"}),o("settings.providers.page.auth.oauth.waiting")]}),s.jsx(V,{variant:"ghost",size:"xs",className:"!font-normal shrink-0",onClick:T,children:o("settings.providers.page.actions.cancel")})]}),s.jsx("p",{className:"typography-meta text-muted-foreground",children:o("settings.providers.page.auth.oauth.waitingHint")})]}),F&&d.phase==="awaitingCode"&&s.jsxs("div",{className:"space-y-3",children:[E(d.attempt),s.jsx("p",{className:"typography-meta text-muted-foreground",children:o("settings.providers.page.auth.oauth.codeHint")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ge,{value:h,onChange:L=>f(L.target.value),placeholder:o("settings.providers.page.auth.pasteAuthorizationCodePlaceholder"),className:"font-mono text-xs",disabled:d.submitting}),s.jsx(V,{size:"xs",className:"!font-normal shrink-0",onClick:()=>{x()},disabled:d.submitting||h.trim().length===0,children:d.submitting?o("settings.providers.page.actions.saving"):o("settings.providers.page.actions.complete")}),s.jsx(V,{variant:"ghost",size:"xs",className:"!font-normal shrink-0",onClick:T,disabled:d.submitting,children:o("settings.providers.page.actions.cancel")})]})]}),F&&d.phase==="failed"&&s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:d.message}),s.jsx(V,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>w(D),children:o("settings.providers.page.actions.tryAgain")})]})]},D.id)})})},kf=(t,e)=>t.find(a=>a.id.startsWith("mcp_")&&a.metadata?.source==="mcp"&&a.name===e),wf=t=>(t?.methods??[]).filter(e=>e.type==="oauth"),Nf=({serverName:t,directory:e,onConnected:a})=>{const[n,i]=l.useState(null);l.useEffect(()=>{let r=!1;i(null);const d=e?Ts.getScopedSdkClient(e):Ts.getSdkClient();return(async()=>{try{const{data:g}=await d.integration.list();r||i(kf(g,t)??null)}catch(g){console.error("Failed to load MCP integrations:",g)}})(),()=>{r=!0}},[e,t]);const o=wf(n??void 0);return!n||o.length===0?null:s.jsx(kr,{integrationId:n.id,methods:o,directory:e,onConnected:a},n.id)},ao={oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",oauthCallbackPort:""},Sf=t=>t===!1?{...ao,oauthEnabled:!1}:t?{oauthEnabled:!0,oauthClientId:t.client_id??"",oauthClientSecret:t.client_secret??"",oauthScope:t.scope??"",oauthRedirectUri:t.redirect_uri??"",oauthCallbackPort:t.callback_port===void 0?"":String(t.callback_port)}:ao,Zr="grid grid-cols-1 gap-3 @xl:grid-cols-2 @3xl:grid-cols-3",wr=Ne("group flex min-h-[132px] flex-col rounded-xl border p-4 text-left transition-colors duration-150","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]"),Cf={success:"bg-[var(--status-success)]/15 text-[var(--status-success)]",warning:"bg-[var(--status-warning)]/15 text-[var(--status-warning)]",error:"bg-[var(--status-error)]/15 text-[var(--status-error)]",info:"bg-[var(--status-info)]/15 text-[var(--status-info)]",neutral:"bg-[var(--surface-muted)] text-muted-foreground"},In=t=>{const e=Be.c(5),{tone:a,children:n}=t,i=Cf[a];let o;e[0]!==i?(o=Ne("max-w-40 shrink-0 truncate rounded-full px-2 py-0.5 text-[10px] font-medium",i),e[0]=i,e[1]=o):o=e[1];let r;return e[2]!==n||e[3]!==o?(r=s.jsx("span",{className:o,children:n}),e[2]=n,e[3]=o,e[4]=r):r=e[4],r},io=t=>{const e=Be.c(2),{children:a}=t;let n;return e[0]!==a?(n=s.jsx("span",{className:"shrink-0 rounded-full border border-[var(--interactive-border)] px-2 py-px text-[10px] font-medium",children:a}),e[0]=a,e[1]=n):n=e[1],n},Cd=t=>{const e=Be.c(5),{action:a}=t;let n;e[0]!==a.icon?(n=a.icon?s.jsx($,{name:a.icon,className:"size-4"}):null,e[0]=a.icon,e[1]=n):n=e[1];let i;return e[2]!==a.label||e[3]!==n?(i=s.jsxs(s.Fragment,{children:[n,a.label]}),e[2]=a.label,e[3]=n,e[4]=i):i=e[4],i},ji=t=>{const e=Be.c(57),{icon:a,title:n,subtitle:i,badges:o,footer:r,muted:d,onOpen:c,actions:g,actionsLabel:m}=t,h=(g?.length??0)>0,f=d&&"opacity-60";let p;e[0]!==f?(p=Ne("flex size-10 shrink-0 items-center justify-center rounded-[10px] bg-[var(--surface-muted)]",f),e[0]=f,e[1]=p):p=e[1];let b;e[2]!==a||e[3]!==p?(b=s.jsx("span",{className:p,children:a}),e[2]=a,e[3]=p,e[4]=b):b=e[4];let C;e[5]!==o?(C=o?s.jsx("span",{className:"flex min-w-0 flex-wrap justify-end gap-1",children:o}):null,e[5]=o,e[6]=C):C=e[6];let v;e[7]!==b||e[8]!==C?(v=s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[b,C]}),e[7]=b,e[8]=C,e[9]=v):v=e[9];const k=d&&"opacity-60";let u;e[10]!==k?(u=Ne("mt-3 min-w-0",k),e[10]=k,e[11]=u):u=e[11];let y;e[12]!==n?(y=s.jsx("div",{className:"truncate text-sm font-semibold text-foreground",title:n,children:n}),e[12]=n,e[13]=y):y=e[13];let S;e[14]!==i?(S=i?s.jsx("div",{className:"mt-0.5 truncate font-mono typography-micro text-muted-foreground",title:i,children:i}):null,e[14]=i,e[15]=S):S=e[15];let N;e[16]!==u||e[17]!==y||e[18]!==S?(N=s.jsxs("div",{className:u,children:[y,S]}),e[16]=u,e[17]=y,e[18]=S,e[19]=N):N=e[19];const w=h&&"pr-8";let A;e[20]!==w?(A=Ne("mt-auto flex min-w-0 items-center gap-2 pt-3 typography-micro text-muted-foreground",w),e[20]=w,e[21]=A):A=e[21];let x;e[22]!==h||e[23]!==c?(x=c&&!h?s.jsx($,{name:"arrow-right-s",className:"ml-auto size-4 shrink-0 opacity-0 transition-opacity duration-150 group-hover:opacity-70 group-focus-visible:opacity-70","aria-hidden":!0}):null,e[22]=h,e[23]=c,e[24]=x):x=e[24];let T;e[25]!==r||e[26]!==A||e[27]!==x?(T=s.jsxs("div",{className:A,children:[r,x]}),e[25]=r,e[26]=A,e[27]=x,e[28]=T):T=e[28];let M;e[29]!==N||e[30]!==T||e[31]!==v?(M=s.jsxs(s.Fragment,{children:[v,N,T]}),e[29]=N,e[30]=T,e[31]=v,e[32]=M):M=e[32];const E=M;let D;e[33]!==E||e[34]!==c?(D=c?s.jsx("button",{type:"button",onClick:c,className:Ne(wr,"h-full w-full border-[var(--interactive-border)] bg-[var(--surface-elevated)] hover:border-[var(--interactive-border-hover)] hover:bg-[var(--interactive-hover)]/50"),children:E}):s.jsx("div",{className:Ne(wr,"h-full border-[var(--interactive-border)] bg-[var(--surface-elevated)]"),children:E}),e[33]=E,e[34]=c,e[35]=D):D=e[35];const F=D;if(!h||!g)return F;let L;e[36]===Symbol.for("react.memo_cache_sentinel")?(L=s.jsx("div",{className:"group relative"}),e[36]=L):L=e[36];let P;e[37]===Symbol.for("react.memo_cache_sentinel")?(P=s.jsx($,{name:"more-2",className:"size-4"}),e[37]=P):P=e[37];let j;e[38]!==m?(j=s.jsx(Wn,{asChild:!0,children:s.jsx(V,{variant:"ghost",size:"icon",className:"absolute bottom-3 right-3 h-7 w-7 text-muted-foreground opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100 md:focus-visible:opacity-100 data-[state=open]:opacity-100","aria-label":m,title:m,children:P})}),e[38]=m,e[39]=j):j=e[39];let O;e[40]!==g?(O=g.map(If),e[40]=g,e[41]=O):O=e[41];let K;e[42]!==O?(K=s.jsx(Gn,{align:"end",className:"w-fit min-w-32",children:O}),e[42]=O,e[43]=K):K=e[43];let H;e[44]!==j||e[45]!==K?(H=s.jsxs(Jn,{children:[j,K]}),e[44]=j,e[45]=K,e[46]=H):H=e[46];let q;e[47]!==F||e[48]!==H?(q=s.jsxs(ti,{render:L,children:[F,H]}),e[47]=F,e[48]=H,e[49]=q):q=e[49];let Z;e[50]!==g?(Z=g.map(Pf),e[50]=g,e[51]=Z):Z=e[51];let ae;e[52]!==Z?(ae=s.jsx(Xa,{className:"w-fit min-w-32",children:Z}),e[52]=Z,e[53]=ae):ae=e[53];let B;return e[54]!==q||e[55]!==ae?(B=s.jsxs(si,{children:[q,ae]}),e[54]=q,e[55]=ae,e[56]=B):B=e[56],B},Xr=t=>{const e=Be.c(11),{label:a,hint:n,onClick:i,settingsItem:o}=t;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=Ne(wr,"items-center justify-center gap-2 border-dashed border-[var(--interactive-border)] text-muted-foreground hover:bg-[var(--interactive-hover)]/50 hover:text-foreground"),e[0]=r):r=e[0];let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx("span",{className:"flex size-10 items-center justify-center rounded-[10px] bg-[var(--surface-muted)]",children:s.jsx($,{name:"add",className:"size-5"})}),e[1]=d):d=e[1];let c;e[2]!==a?(c=s.jsx("span",{className:"typography-ui-label font-medium",children:a}),e[2]=a,e[3]=c):c=e[3];let g;e[4]!==n?(g=n?s.jsx("span",{className:"typography-micro",children:n}):null,e[4]=n,e[5]=g):g=e[5];let m;return e[6]!==i||e[7]!==o||e[8]!==c||e[9]!==g?(m=s.jsxs("button",{type:"button",onClick:i,"data-settings-item":o,className:r,children:[d,c,g]}),e[6]=i,e[7]=o,e[8]=c,e[9]=g,e[10]=m):m=e[10],m},el=t=>{const e=Be.c(7),{value:a,onChange:n,placeholder:i}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx($,{name:"search",className:"pointer-events-none absolute left-2.5 top-1/2 size-4 -translate-y-1/2 text-muted-foreground","aria-hidden":!0}),e[0]=o):o=e[0];let r;e[1]!==n?(r=c=>n(c.target.value),e[1]=n,e[2]=r):r=e[2];let d;return e[3]!==i||e[4]!==r||e[5]!==a?(d=s.jsxs("div",{className:"relative mb-4 max-w-[24rem]",children:[o,s.jsx(Ge,{value:a,onChange:r,placeholder:i,"aria-label":i,className:"h-9 pl-8"})]}),e[3]=i,e[4]=r,e[5]=a,e[6]=d):d=e[6],d},tl=t=>{const e=Be.c(4),{label:a,onClick:n}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx($,{name:"arrow-left-s",className:"size-4"}),e[0]=i):i=e[0];let o;return e[1]!==a||e[2]!==n?(o=s.jsx(V,{variant:"ghost",size:"icon",className:"-ml-2 h-7 w-7 shrink-0",onClick:n,"aria-label":a,title:a,children:i}),e[1]=a,e[2]=n,e[3]=o):o=e[3],o},Nr=t=>{const e=Be.c(2),{name:a}=t;let n;return e[0]!==a?(n=s.jsx($,{name:a,className:"size-5 text-muted-foreground"}),e[0]=a,e[1]=n):n=e[1],n};function If(t){return s.jsx(xn,{variant:t.destructive?"destructive":"default",onClick:t.onSelect,children:s.jsx(Cd,{action:t})},t.label)}function Pf(t){return s.jsx(ei,{className:Ne(t.destructive&&"text-destructive focus:text-destructive"),onClick:t.onSelect,children:s.jsx(Cd,{action:t})},t.label)}const Af=t=>{const e="new-mcp-server";let a=e,n=1;for(;t.some(i=>i.name===a);)a=`${e}-${n}`,n+=1;return a},Tf=t=>{const e=Be.c(9),{status:a,enabled:n}=t,{t:i}=qe();if(!n){let c;e[0]!==i?(c=i("settings.mcp.grid.status.disabled"),e[0]=i,e[1]=c):c=e[1];let g;return e[2]!==c?(g=s.jsx(In,{tone:"neutral",children:c}),e[2]=c,e[3]=g):g=e[3],g}let o;e[4]!==a||e[5]!==i?(o=a==="connected"?{tone:"success",label:i("settings.mcp.page.status.label.connected")}:a==="failed"?{tone:"error",label:i("settings.mcp.page.status.label.failed")}:a==="needs_auth"?{tone:"warning",label:i("settings.mcp.page.status.label.needsAuth")}:a==="pending"?{tone:"neutral",label:i("settings.mcp.grid.status.pending")}:null,e[4]=a,e[5]=i,e[6]=o):o=e[6];const r=o;let d;return e[7]!==r?(d=r?s.jsx(In,{tone:r.tone,children:r.label}):null,e[7]=r,e[8]=d):d=e[8],d},Ef=()=>{const t=Be.c(130),{t:e}=qe(),a=en(),{setSelectedMcp:n,setMcpDraft:i,loadMcpConfigs:o,deleteMcp:r}=Un(_s(Df)),[d,c]=l.useState(null),[g,m]=l.useState(!1);let h;t[0]!==a?(h=Me=>Rr(Me,a),t[0]=a,t[1]=h):h=t[1];const f=Un(h);let p;t[2]!==a?(p=Me=>Me.getStatusForDirectory(a),t[2]=a,t[3]=p):p=t[3];const b=pn(p),C=pn(Mf),v=pn(Rf),[k,u]=l.useState(!1),[y,S]=l.useState("");let N,w;t[4]!==o||t[5]!==a?(N=()=>{o({directory:a})},w=[o,a],t[4]=o,t[5]=a,t[6]=N,t[7]=w):(N=t[6],w=t[7]),l.useEffect(N,w);let A;t[8]!==v||t[9]!==k||t[10]!==C||t[11]!==a?(A=()=>{if(k)return;u(!0);const Me=new Promise(Of);Promise.all([C({directory:a,silent:!0}),Me]).then(()=>{const me=v(a);me&&U.error(me)}).finally(()=>u(!1))},t[8]=v,t[9]=k,t[10]=C,t[11]=a,t[12]=A):A=t[12];const x=A;let T;t[13]!==f||t[14]!==i||t[15]!==n?(T=()=>{const Me=Af(f),me={name:Me,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],...ao,oauthAuthServerMetadataUrl:"",protocol:"legacy",timeoutStartup:"",timeoutCatalog:"",timeoutExecution:"",codemode:"default",disabled:!1};i(me),n(Me)},t[13]=f,t[14]=i,t[15]=n,t[16]=T):T=t[16];const M=T;let E;t[17]!==r||t[18]!==d||t[19]!==a||t[20]!==e?(E=async()=>{if(!d)return;const Me=d;m(!0);const me=await r(Me,a);me.ok?(me.reloadFailed?U.warning(me.message||e("settings.mcp.page.toast.serverDeletedReloadFailed",{name:Me}),{description:me.warning||e("settings.mcp.page.toast.refreshListIfStale")}):U.success(me.message||e("settings.mcp.page.toast.serverDeleted",{name:Me})),c(null)):U.error(e("settings.mcp.page.toast.deleteFailed")),m(!1)},t[17]=r,t[18]=d,t[19]=a,t[20]=e,t[21]=E):E=t[21];const D=E;let F,L,P,j,O,K,H,q,Z;if(t[22]!==M||t[23]!==x||t[24]!==k||t[25]!==b||t[26]!==y||t[27]!==f||t[28]!==i||t[29]!==n||t[30]!==e){const Me=sa([...f],y,Lf);let me;t[40]!==y?(me=y.trim(),t[40]=y,t[41]=me):me=t[41];const Te=me.length>0;F=ns,t[42]!==e?(L=e("settings.page.mcp.title"),t[42]=e,t[43]=L):L=t[43],t[44]!==e?(P=e("settings.mcp.grid.description"),t[44]=e,t[45]=P):P=t[45];let Oe;t[46]===Symbol.for("react.memo_cache_sentinel")?(Oe=s.jsx(Ni,{className:"min-w-0 flex-1 @xl:w-56 @xl:flex-none"}),t[46]=Oe):Oe=t[46];let ge;t[47]!==e?(ge=e("settings.mcp.sidebar.actions.refreshStatusAria"),t[47]=e,t[48]=ge):ge=t[48];let xe;t[49]!==e?(xe=e("settings.mcp.sidebar.actions.refreshStatusTitle"),t[49]=e,t[50]=xe):xe=t[50];const ne=k&&"animate-spin";let ie;t[51]!==ne?(ie=Ne("size-4",ne),t[51]=ne,t[52]=ie):ie=t[52];let he;t[53]!==ie?(he=s.jsx($,{name:"refresh",className:ie}),t[53]=ie,t[54]=he):he=t[54],t[55]!==x||t[56]!==k||t[57]!==ge||t[58]!==xe||t[59]!==he?(j=s.jsxs("div",{className:"flex w-full items-center gap-2 @xl:w-auto",children:[Oe,s.jsx(V,{variant:"ghost",size:"icon",className:"h-9 w-9 shrink-0 text-muted-foreground",disabled:k,onClick:x,"aria-label":ge,title:xe,children:he})]}),t[55]=x,t[56]=k,t[57]=ge,t[58]=xe,t[59]=he,t[60]=j):j=t[60],t[61]!==y||t[62]!==f.length||t[63]!==e?(O=f.length>0?s.jsx(el,{value:y,onChange:S,placeholder:e("settings.mcp.grid.searchPlaceholder")}):null,t[61]=y,t[62]=f.length,t[63]=e,t[64]=O):O=t[64],K=f.length===0?s.jsx("p",{className:"py-6 typography-meta text-muted-foreground",children:e("settings.mcp.grid.empty")}):Me.length===0?s.jsx("p",{className:"py-6 typography-meta text-muted-foreground",children:e("settings.mcp.grid.noMatches",{query:y.trim()})}):null,H=Zr,t[65]!==M||t[66]!==Te||t[67]!==e?(q=Te?null:s.jsx(Xr,{label:e("settings.mcp.sidebar.actions.addServerTitle"),hint:e("settings.mcp.grid.addHint"),onClick:M,settingsItem:"mcp.create"}),t[65]=M,t[66]=Te,t[67]=e,t[68]=q):q=t[68];let Ee;t[69]!==b||t[70]!==i||t[71]!==n||t[72]!==e?(Ee=Ke=>{const Le=Ke.disabled!==!0,Se=Ke.type==="local"?Ke.command?.join(" "):Ke.url;return s.jsx(ji,{icon:s.jsx(Nr,{name:Ke.type==="local"?"server":"global"}),title:Ke.name,subtitle:Se||void 0,badges:s.jsx(Tf,{status:b[Ke.name]?.status.status,enabled:Le}),muted:!Le,footer:s.jsxs(s.Fragment,{children:[s.jsx("span",{children:Ke.type==="local"?e("settings.mcp.sidebar.serverType.localTitle"):e("settings.mcp.sidebar.serverType.remoteTitle")}),Ke.scope==="project"?s.jsx(io,{children:e("settings.mcp.grid.scope.project")}):null]}),onOpen:()=>{i(null),n(Ke.name)},actionsLabel:e("settings.mcp.grid.actionsAria",{name:Ke.name}),actions:[{label:e("settings.common.actions.delete"),icon:"delete-bin",destructive:!0,onSelect:()=>c(Ke.name)}]},Ke.name)},t[69]=b,t[70]=i,t[71]=n,t[72]=e,t[73]=Ee):Ee=t[73],Z=Me.map(Ee),t[22]=M,t[23]=x,t[24]=k,t[25]=b,t[26]=y,t[27]=f,t[28]=i,t[29]=n,t[30]=e,t[31]=F,t[32]=L,t[33]=P,t[34]=j,t[35]=O,t[36]=K,t[37]=H,t[38]=q,t[39]=Z}else F=t[31],L=t[32],P=t[33],j=t[34],O=t[35],K=t[36],H=t[37],q=t[38],Z=t[39];let ae;t[74]!==H||t[75]!==q||t[76]!==Z?(ae=s.jsxs("div",{className:H,children:[q,Z]}),t[74]=H,t[75]=q,t[76]=Z,t[77]=ae):ae=t[77];const B=d!==null;let G;t[78]!==g?(G=Me=>{!Me&&!g&&c(null)},t[78]=g,t[79]=G):G=t[79];const _=d??"";let z;t[80]!==e||t[81]!==_?(z=e("settings.mcp.page.deleteDialog.title",{name:_}),t[80]=e,t[81]=_,t[82]=z):z=t[82];let te;t[83]!==z?(te=s.jsx(Ht,{children:z}),t[83]=z,t[84]=te):te=t[84];let Q;t[85]!==e?(Q=e("settings.mcp.page.deleteDialog.descriptionPrefix"),t[85]=e,t[86]=Q):Q=t[86];let X;t[87]===Symbol.for("react.memo_cache_sentinel")?(X=s.jsx("code",{className:"text-foreground",children:"opencode.json"}),t[87]=X):X=t[87];let pe;t[88]!==e?(pe=e("settings.mcp.page.deleteDialog.descriptionSuffix"),t[88]=e,t[89]=pe):pe=t[89];let je;t[90]!==Q||t[91]!==pe?(je=s.jsxs(qt,{children:[Q," ",X,"."," ",pe]}),t[90]=Q,t[91]=pe,t[92]=je):je=t[92];let fe;t[93]!==te||t[94]!==je?(fe=s.jsxs(Vt,{children:[te,je]}),t[93]=te,t[94]=je,t[95]=fe):fe=t[95];let ke;t[96]===Symbol.for("react.memo_cache_sentinel")?(ke=()=>c(null),t[96]=ke):ke=t[96];let be;t[97]!==e?(be=e("settings.common.actions.cancel"),t[97]=e,t[98]=be):be=t[98];let De;t[99]!==g||t[100]!==be?(De=s.jsx(V,{variant:"outline",size:"sm",onClick:ke,disabled:g,children:be}),t[99]=g,t[100]=be,t[101]=De):De=t[101];let oe;t[102]!==D?(oe=()=>{D()},t[102]=D,t[103]=oe):oe=t[103];let ee;t[104]!==g||t[105]!==e?(ee=e(g?"settings.mcp.page.actions.deleting":"settings.common.actions.delete"),t[104]=g,t[105]=e,t[106]=ee):ee=t[106];let ce;t[107]!==g||t[108]!==oe||t[109]!==ee?(ce=s.jsx(V,{variant:"destructive",size:"sm",onClick:oe,disabled:g,children:ee}),t[107]=g,t[108]=oe,t[109]=ee,t[110]=ce):ce=t[110];let ue;t[111]!==De||t[112]!==ce?(ue=s.jsxs(as,{children:[De,ce]}),t[111]=De,t[112]=ce,t[113]=ue):ue=t[113];let Ie;t[114]!==fe||t[115]!==ue?(Ie=s.jsxs($t,{className:"max-w-md",children:[fe,ue]}),t[114]=fe,t[115]=ue,t[116]=Ie):Ie=t[116];let ve;t[117]!==B||t[118]!==G||t[119]!==Ie?(ve=s.jsx(_t,{open:B,onOpenChange:G,children:Ie}),t[117]=B,t[118]=G,t[119]=Ie,t[120]=ve):ve=t[120];let Re;return t[121]!==F||t[122]!==L||t[123]!==P||t[124]!==j||t[125]!==O||t[126]!==K||t[127]!==ae||t[128]!==ve?(Re=s.jsxs(F,{title:L,description:P,headerEnd:j,children:[O,K,ae,ve]}),t[121]=F,t[122]=L,t[123]=P,t[124]=j,t[125]=O,t[126]=K,t[127]=ae,t[128]=ve,t[129]=Re):Re=t[129],Re};function Df(t){return{setSelectedMcp:t.setSelectedMcp,setMcpDraft:t.setMcpDraft,loadMcpConfigs:t.loadMcpConfigs,deleteMcp:t.deleteMcp}}function Mf(t){return t.refresh}function Rf(t){return t.getErrorForDirectory}function Of(t){return setTimeout(t,500)}function Lf(t){return[t.name,t.type==="local"?t.command?.join(" ")??"":t.url??""]}const qo=t=>t===void 0?"":String(t),Go=t=>{const e=t.trim();if(!e)return null;const a=Number(e);return!Number.isFinite(a)||a<=0?null:a%1e3===0?`${a/1e3}s`:`${a}ms`},Wo={legacy:"settings.mcp.page.advanced.protocolOption.legacy",auto:"settings.mcp.page.advanced.protocolOption.auto","2026-07-28":"settings.mcp.page.advanced.protocolOption.revision20260728"},Wl={default:"settings.mcp.page.advanced.codemodeOption.default",on:"settings.mcp.page.advanced.codemodeOption.on",off:"settings.mcp.page.advanced.codemodeOption.off"},Ff=t=>{try{const e=new URL(t);return e.protocol==="http:"||e.protocol==="https:"}catch{return!1}},ci=t=>t?.status.status,Jo=t=>t?.status.status==="failed"||t?.status.status==="needs_auth"?t.status.error:void 0;function Id(t){const e=[];let a="",n=!1,i=!1;for(let o=0;o<t.length;o++){const r=t[o];if(r==="'"&&!i){n=!n;continue}if(r==='"'&&!n){i=!i;continue}if((r===" "||r===" ")&&!n&&!i){a&&(e.push(a),a="");continue}a+=r}return a&&e.push(a),e}const Kf=t=>{const e=Be.c(27),{value:a,onChange:n,preview:i,onDetectUrl:o}=t;let r;e[0]!==a?(r=()=>a.join(`
|
|
5
|
-
`),e[0]=a,e[1]=r):r=e[1];const[d,c]=l.useState(r),g=l.useRef(a);let m,h;e[2]!==a?(m=()=>{JSON.stringify(g.current)!==JSON.stringify(a)&&(g.current=a,c(a.join(`
|
|
6
|
-
`)))},h=[a],e[2]=a,e[3]=m,e[4]=h):(m=e[3],h=e[4]),l.useEffect(m,h);let f;e[5]!==n||e[6]!==o?(f=w=>{const A=w.split(`
|
|
7
|
-
`).filter(Hf);if(o&&A.length===1&&/^https?:\/\/\S+$/i.test(A[0].trim())){o(A[0].trim());return}n(A)},e[5]=n,e[6]=o,e[7]=f):f=e[7];const p=f;let b;e[8]!==n?(b=w=>{const x=w.clipboardData.getData("text").trim();if(!x||x.includes(`
|
|
8
|
-
`)||!/\s/.test(x))return;const T=w.currentTarget;if(T.selectionStart!==0||T.selectionEnd!==T.value.length)return;w.preventDefault();const M=Id(x);c(M.join(`
|
|
9
|
-
`)),n(M)},e[8]=n,e[9]=b):b=e[9];const C=b;let v;e[10]!==p?(v=w=>{c(w.target.value),p(w.target.value)},e[10]=p,e[11]=v):v=e[11];let k;e[12]!==p||e[13]!==d?(k=()=>{const w=d.split(`
|
|
10
|
-
`).map(qf).join(`
|
|
11
|
-
`);c(w),p(w)},e[12]=p,e[13]=d,e[14]=k):k=e[14];const u=Math.max(4,a.length+1);let y;e[15]!==C||e[16]!==v||e[17]!==k||e[18]!==u||e[19]!==d?(y=s.jsx(Rs,{onPaste:C,value:d,onChange:v,onBlur:k,placeholder:`npx
|
|
12
|
-
-y
|
|
13
|
-
@modelcontextprotocol/server-postgres
|
|
14
|
-
postgresql://user:pass@host/db`,rows:u,className:"font-mono typography-meta min-h-[80px]",spellCheck:!1}),e[15]=C,e[16]=v,e[17]=k,e[18]=u,e[19]=d,e[20]=y):y=e[20];let S;e[21]!==i||e[22]!==a?(S=a.length>0&&s.jsxs("details",{className:"group",children:[s.jsx("summary",{className:"typography-micro text-muted-foreground/60 cursor-pointer select-none hover:text-muted-foreground",children:i(a.length)}),s.jsx("div",{className:"mt-1 rounded-md bg-[var(--surface-elevated)] px-3 py-2 overflow-x-auto",children:s.jsx("code",{className:"typography-micro text-foreground/80 whitespace-pre",children:a.map(Gf)})})]}),e[21]=i,e[22]=a,e[23]=S):S=e[23];let N;return e[24]!==S||e[25]!==y?(N=s.jsxs("div",{className:"space-y-2","data-bwignore":"true","data-1p-ignore":"true","data-lpignore":"true",children:[y,S]}),e[24]=S,e[25]=y,e[26]=N):N=e[26],N},zf=t=>t.toUpperCase().replace(/[^A-Z0-9_]/g,"_"),Jl=({value:t,onChange:e,onCommit:a,keyTransform:n=zf,keyPlaceholder:i="API_KEY",keyInputClassName:o="w-36 shrink-0 font-mono typography-meta uppercase",pasteLabel:r="Paste .env",pasteTitle:d="Paste KEY=VALUE lines from clipboard",noPairsFoundError:c,importSuccess:g,clipboardReadFailed:m,keyLabel:h,valueLabel:f,valuePlaceholder:p,hideValueTitle:b,showValueTitle:C,addVariable:v,plainTextWarning:k,removeVariableAria:u})=>{const[y,S]=l.useState(new Set),N=()=>e([...t,{key:"",value:""}]),w=E=>{e(t.filter((D,F)=>F!==E)),a?.(),S(D=>{const F=new Set(D);return F.delete(E),F})},A=(E,D,F)=>{const L=[...t];L[E]={...L[E],[D]:F},e(L)},x=E=>{S(D=>{const F=new Set(D);return F.has(E)?F.delete(E):F.add(E),F})},T=async()=>{try{const E=await navigator.clipboard.readText(),D=[];for(const L of E.split(`
|
|
15
|
-
`)){const P=L.trim();if(!P||P.startsWith("#"))continue;const j=P.indexOf("=");if(j===-1)continue;const O=P.slice(0,j).trim();let K=P.slice(j+1).trim();(K.startsWith('"')&&K.endsWith('"')||K.startsWith("'")&&K.endsWith("'"))&&(K=K.slice(1,-1)),O&&D.push({key:O,value:K})}if(D.length===0){U.error(c);return}const F=[...t];for(const L of D){const P=F.findIndex(j=>j.key===L.key);P!==-1?F[P]=L:F.push(L)}e(F),a?.(),U.success(g(D.length))}catch{U.error(m)}},M=t.some(E=>E.value.length>0);return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"typography-micro text-muted-foreground w-32 shrink-0",children:h}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:f})]}),s.jsxs(V,{variant:"ghost",size:"xs",className:"!font-normal gap-1 text-muted-foreground",onClick:T,type:"button",title:d,children:[s.jsx($,{name:"clipboard",className:"h-3 w-3"}),r]})]}),s.jsx("div",{className:"space-y-1.5",children:t.map((E,D)=>s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ge,{value:E.key,onChange:F=>A(D,"key",n(F.target.value)),placeholder:i,className:o,"data-bwignore":"true","data-1p-ignore":"true","data-lpignore":"true",spellCheck:!1}),s.jsxs("div",{className:"relative flex-1 flex items-center",children:[s.jsx(Ge,{type:y.has(D)?"text":"password",value:E.value,onChange:F=>A(D,"value",F.target.value),placeholder:p,className:"font-mono typography-meta pr-8 w-full",autoComplete:"new-password","data-bwignore":"true","data-1p-ignore":"true","data-lpignore":"true",spellCheck:!1}),s.jsx("button",{type:"button",onClick:()=>x(D),className:"absolute right-2 text-muted-foreground/60 hover:text-muted-foreground",title:y.has(D)?b:C,children:y.has(D)?s.jsx($,{name:"eye-off",className:"h-3.5 w-3.5"}):s.jsx($,{name:"eye",className:"h-3.5 w-3.5"})})]}),s.jsx(V,{size:"sm",variant:"ghost",className:"h-7 w-7 px-0 shrink-0 text-muted-foreground hover:text-[var(--status-error)]",onClick:()=>w(D),"aria-label":u,children:s.jsx($,{name:"delete-bin",className:"h-3.5 w-3.5"})})]},D))}),s.jsxs(V,{variant:"outline",size:"xs",className:"!font-normal gap-1.5",onClick:N,type:"button",children:[s.jsx($,{name:"add",className:"h-3.5 w-3.5"}),v]}),M&&s.jsx("p",{className:"typography-micro text-muted-foreground/60",children:k})]})},Ql=t=>{const e=Be.c(14),{status:a,enabled:n,getStatusLabel:i,variant:o}=t,r=o===void 0?"compact":o;if(!n||!a)return null;let d,c;if(e[0]!==i||e[1]!==a||e[2]!==r){c=Symbol.for("react.early_return_sentinel");e:{const f={connected:{text:"text-[var(--status-success)]",bg:"bg-[var(--status-success)]/10"},failed:{text:"text-[var(--status-error)]",bg:"bg-[var(--status-error)]/10"},needs_auth:{text:"text-[var(--status-warning)]",bg:"bg-[var(--status-warning)]/10"}}[a]??{text:"text-muted-foreground",bg:""};if(r==="pill"){const p=Ne("typography-micro font-medium rounded-full px-2 py-0.5",f.text,f.bg);let b;e[5]!==i||e[6]!==a?(b=i(a),e[5]=i,e[6]=a,e[7]=b):b=e[7],c=s.jsxs("span",{className:p,children:["● ",b]});break e}d=Ne("typography-micro font-medium",f.text)}e[0]=i,e[1]=a,e[2]=r,e[3]=d,e[4]=c}else d=e[3],c=e[4];if(c!==Symbol.for("react.early_return_sentinel"))return c;let g;e[8]!==i||e[9]!==a?(g=i(a),e[8]=i,e[9]=a,e[10]=g):g=e[10];let m;return e[11]!==d||e[12]!==g?(m=s.jsxs("span",{className:d,children:["● ",g]}),e[11]=d,e[12]=g,e[13]=m):m=e[13],m},Uf=(t,e,a)=>{switch(t){case"connected":return e("settings.mcp.page.status.description.connected");case"failed":return a?.trim()||e("settings.mcp.page.status.description.failedDefault");case"needs_auth":return a?.trim()||e("settings.mcp.page.status.description.needsAuth");case"disabled":return e("settings.mcp.page.status.description.disabled");default:return e("settings.mcp.page.status.description.default")}},_f=t=>{switch(t){case"failed":return"border-[var(--status-error-border)] bg-[var(--status-error-background)]";case"needs_auth":return"border-[var(--status-warning-border)] bg-[var(--status-warning-background)]";default:return"border-[var(--interactive-border)] bg-[var(--surface-elevated)]"}},$f=t=>t==="failed"||t==="needs_auth",Bf=(t,e)=>{const a=typeof e=="string"&&e.trim()?e.trim():"__global__";return`${t??"__none__"}::${a}`},Vf=()=>{const{t}=qe(),e=l.useCallback((Y,Pe)=>t(Y,Pe),[t]),{selectedMcpName:a,mcpDraft:n,setMcpDraft:i,setSelectedMcp:o,getMcpByName:r,createMcp:d,updateMcp:c,deleteMcp:g}=Un(_s(Y=>({selectedMcpName:Y.selectedMcpName,mcpDraft:Y.mcpDraft,setMcpDraft:Y.setMcpDraft,setSelectedMcp:Y.setSelectedMcp,getMcpByName:Y.getMcpByName,createMcp:Y.createMcp,updateMcp:Y.updateMcp,deleteMcp:Y.deleteMcp}))),m=en();l.useEffect(()=>()=>{const Y=Un.getState();Y.setSelectedMcp(null),Y.setMcpDraft(null)},[]);const h=pn(Y=>Y.getStatusForDirectory(m)),f=pn(Y=>Y.getDiagnosticForDirectory(m)),p=pn(Y=>Y.refresh),b=pn(Y=>Y.connect),C=pn(Y=>Y.disconnect),v=pn(Y=>Y.testConnection),k=Un(Y=>Rr(Y,m)),u=a?r(a,m):null,y=!!(n&&n.name===a&&!u),[S,N]=l.useState(""),[w,A]=l.useState("user"),[x,T]=l.useState("local"),[M,E]=l.useState([]),[D,F]=l.useState(""),[L,P]=l.useState([]),[j,O]=l.useState([]),[K,H]=l.useState(""),[q,Z]=l.useState(""),[ae,B]=l.useState(""),[G,_]=l.useState("default"),[z,te]=l.useState("legacy"),[Q,X]=l.useState(""),[pe,je]=l.useState(ao),[fe,ke]=l.useState(!0),[be,De]=l.useState(!1),[oe,ee]=l.useState(!1),[ce,ue]=l.useState(!1),[Ie,ve]=l.useState(!1),[Re,Me]=l.useState(!1),[me,Te]=l.useState(!1),[Oe,ge]=l.useState(!1),[xe,ne]=l.useState(""),[ie,he]=l.useState(null),Ee=l.useMemo(()=>Bf(a,m),[m,a]),Ke=l.useRef(Ee),Le=l.useRef(null),Se=JSON.stringify([a,m,y]),$e=l.useRef(Se);$e.current=Se;const Ye=l.useRef(null),pt={mcpType:x,command:M,url:D,envEntries:L,headerEntries:j,timeoutStartup:K,timeoutCatalog:q,timeoutExecution:ae,codemode:G,protocol:z,oauthAuthServerMetadataUrl:x==="remote"?Q:"",enabled:fe},vt=l.useRef(pt);vt.current=pt;const wt=l.useCallback(()=>{ne(""),he(null),ge(!0)},[]),yt=l.useCallback(async()=>{try{const Y=await navigator.clipboard.readText();ne(Y),he(null)}catch{U.error(t("settings.mcp.page.toast.clipboardReadFailed"))}},[t]),st=l.useCallback(()=>{const Y=df(xe,{fallbackName:S});if(!Y.ok){he(Y.error);return}const Je=uf(Y,{name:S,scope:w,type:x,command:M,url:D,environment:L,headers:j,timeoutStartup:K,timeoutCatalog:q,timeoutExecution:ae,codemode:G,disabled:!fe,protocol:z,oauthAuthServerMetadataUrl:Q},{isNewServer:y});N(Je.name),T(Je.type),E(Je.command??[]),F(Je.url??""),P(Je.environment??[]),O(Je.headers??[]),H(Je.timeoutStartup??""),Z(Je.timeoutCatalog??""),B(Je.timeoutExecution??""),_(Je.codemode??"default"),ke(Je.disabled!==!0),te(Je.protocol??"legacy"),X(Je.oauthAuthServerMetadataUrl??""),ge(!1),ne(""),he(null),U.success(t("settings.mcp.page.toast.configImported"))},[xe,S,w,x,M,D,L,j,z,Q,K,q,ae,G,fe,y,t]);l.useEffect(()=>{if(y&&n){Ye.current=null,N(n.name),A(n.scope||"user"),T(n.type),E(n.command),F(n.url),P(n.environment),O(n.headers),H(n.timeoutStartup),Z(n.timeoutCatalog),B(n.timeoutExecution),_(n.codemode),te(n.protocol),X(n.oauthAuthServerMetadataUrl),je({oauthEnabled:n.oauthEnabled,oauthClientId:n.oauthClientId,oauthClientSecret:n.oauthClientSecret,oauthScope:n.oauthScope,oauthRedirectUri:n.oauthRedirectUri,oauthCallbackPort:n.oauthCallbackPort}),ke(!n.disabled),Te(!1),Le.current={mcpType:n.type,command:n.command,url:n.url,envEntries:n.environment,headerEntries:n.headers,timeoutStartup:n.timeoutStartup,timeoutCatalog:n.timeoutCatalog,timeoutExecution:n.timeoutExecution,codemode:n.codemode,protocol:n.protocol,oauthAuthServerMetadataUrl:n.oauthAuthServerMetadataUrl,enabled:!n.disabled};return}if(u){A(u.scope==="project"?"project":"user");const Y=pl(u.environment),Pe=u.type==="remote"?u:null,Je=pl(Pe?.headers),se=u.type,We=se==="local"?u.command??[]:[],ut=Pe?.url??"",Ce=qo(u.timeout?.startup),Ve=qo(u.timeout?.catalog),jt=qo(u.timeout?.execution),Ot=Nu(u.codemode),Yt=u.protocol??"legacy",Zt=Sf(Pe?.oauth),Ft=Pe&&Pe.oauth?Pe.oauth.auth_server_metadata_url??"":"",ms=u.disabled!==!0;je(Zt);const gs=Le.current!==null&&JSON.stringify(Le.current)!==JSON.stringify(vt.current);if(Ye.current===Se&&gs)return;Ye.current=Se,T(se),E(We),F(ut),P(Y),O(Je),H(Ce),Z(Ve),B(jt),_(Ot),te(Yt),X(Ft),ke(ms),Te(!1),Le.current={mcpType:se,command:We,url:ut,envEntries:Y,headerEntries:Je,timeoutStartup:Ce,timeoutCatalog:Ve,timeoutExecution:jt,codemode:Ot,protocol:Yt,oauthAuthServerMetadataUrl:Ft,enabled:ms}}},[u,a,m,y,n,Se]);const rt=l.useMemo(()=>{const Y=Q.trim();return!Y||Ff(Y)?null:t("settings.mcp.page.advanced.oauthMetadataUrlInvalid")},[Q,t]),de=l.useMemo(()=>{const Y=[];x==="remote"&&j.length>0&&Y.push(`${j.length} ${t("settings.mcp.page.advanced.headers")}`);const Pe=x==="local"?Go(K):null;Pe&&Y.push(t("settings.mcp.page.advanced.summary.startup",{value:Pe}));const Je=Go(q);Je&&Y.push(t("settings.mcp.page.advanced.summary.catalog",{value:Je}));const se=Go(ae);return se&&Y.push(t("settings.mcp.page.advanced.summary.execution",{value:se})),G==="on"&&Y.push(t("settings.mcp.page.advanced.summary.codemodeOn")),G==="off"&&Y.push(t("settings.mcp.page.advanced.summary.codemodeOff")),z!=="legacy"&&Y.push(t(Wo[z])),Y.join(" · ")},[G,j.length,x,z,t,q,ae,K]),Ue=l.useMemo(()=>[{id:"local",label:t("settings.mcp.page.connection.kindCommand"),icon:s.jsx($,{name:"terminal",className:"h-3.5 w-3.5"})},{id:"remote",label:t("settings.mcp.page.connection.kindLink"),icon:s.jsx($,{name:"global",className:"h-3.5 w-3.5"})}],[t]),et=l.useCallback(Y=>{T("remote"),F(Y),E([])},[]),ze=l.useCallback(Y=>{F(Y);const Pe=Y.trim();Pe&&!/^[a-z][a-z0-9+.-]*:\/\//i.test(Pe)&&/\s/.test(Pe)&&(T("local"),E(Id(Pe)),F(""))},[]),Ze=Y=>({name:Y,scope:w,type:x,command:M,url:D,environment:L,headers:j,...pe,oauthAuthServerMetadataUrl:x==="remote"?Q:"",protocol:z,timeoutStartup:K,timeoutCatalog:q,timeoutExecution:ae,codemode:G,disabled:!fe}),lt=ni(async()=>{const Y=Le.current;if(y||!Y||!a||JSON.stringify(Y)===JSON.stringify({mcpType:x,command:M,url:D,envEntries:L,headerEntries:j,timeoutStartup:K,timeoutCatalog:q,timeoutExecution:ae,codemode:G,protocol:z,oauthAuthServerMetadataUrl:x==="remote"?Q:"",enabled:fe}))return Us;if(x==="local"&&M.filter(Boolean).length===0)return xs(t("settings.mcp.page.toast.localCommandRequired"));if(x==="remote"&&!D.trim())return xs(t("settings.mcp.page.toast.remoteUrlRequired"));if(x==="remote"&&rt)return xs(rt);const Pe=await c(a,Ze(a),m);return Pe.ok?$e.current!==Se?Tn:(Le.current={mcpType:x,command:M,url:D,envEntries:L,headerEntries:j,timeoutStartup:K,timeoutCatalog:q,timeoutExecution:ae,codemode:G,protocol:z,oauthAuthServerMetadataUrl:x==="remote"?Q:"",enabled:fe},await p({directory:m,silent:!0}),Pe.reloadFailed?xs(Pe.warning||Pe.message||t("settings.mcp.page.toast.savedReloadFailed")):Tn):xs(t("settings.mcp.page.toast.saveFailed"))}),{requestSave:J}=lt,nt=async()=>{const Y=S.trim();if(!Y){U.error(t("settings.mcp.page.toast.nameRequired"));return}if(k.some(Pe=>Pe.name===Y)){U.error(t("settings.mcp.page.toast.serverNameExists"));return}if(x==="local"&&M.filter(Boolean).length===0){U.error(t("settings.mcp.page.toast.localCommandRequired"));return}if(x==="remote"&&!D.trim()){U.error(t("settings.mcp.page.toast.remoteUrlRequired"));return}if(x==="remote"&&rt){U.error(rt);return}De(!0);try{const Pe=await d(Ze(Y),m);Pe.ok?(i(null),o(Y),await p({directory:m,silent:!0}),Pe.reloadFailed?U.warning(Pe.message||t("settings.mcp.page.toast.serverCreatedReloadFailed"),{description:Pe.warning||t("settings.mcp.page.toast.retryRefreshHint")}):U.success(Pe.message||t("settings.mcp.page.toast.serverCreatedReloading"))):U.error(t("settings.mcp.page.toast.saveFailed"))}catch(Pe){U.error(Pe instanceof Error?Pe.message:t("settings.mcp.page.toast.unexpectedError"))}finally{De(!1)}},ot=()=>{i(null),o(null)},it=async()=>{if(!a)return;ue(!0);const Y=await g(a,m);Y.ok?(Y.reloadFailed?U.warning(Y.message||t("settings.mcp.page.toast.serverDeletedReloadFailed",{name:a}),{description:Y.warning||t("settings.mcp.page.toast.refreshListIfStale")}):U.success(Y.message||t("settings.mcp.page.toast.serverDeleted",{name:a})),ee(!1)):U.error(t("settings.mcp.page.toast.deleteFailed")),ue(!1)},ft=async()=>{if(a)try{await b(a,m),U.success(t("settings.mcp.page.toast.connected"))}catch(Y){U.error(Y instanceof Error?Y.message:t("settings.mcp.page.toast.connectionTestFailed"))}},xt=async()=>{if(a){ve(!0);try{if(ci(h[a])==="connected")await C(a,m),U.success(t("settings.mcp.page.toast.disconnected"));else{await b(a,m),await p({directory:m,silent:!0});const Pe=pn.getState().getStatusForDirectory(m)[a],Je=ci(Pe);Je==="connected"?U.success(t("settings.mcp.page.toast.connected")):Je==="needs_auth"?U.message(t("settings.mcp.page.toast.connectionNeedsAuthorization")):Je==="failed"?U.error(Jo(Pe)||t("settings.mcp.page.toast.connectionFailed")):U.message(t("settings.mcp.page.toast.connectionAttemptFinished"));return}await p({directory:m,silent:!0})}catch(Y){U.error(Y instanceof Error?Y.message:t("settings.mcp.page.toast.connectionFailed"))}finally{ve(!1)}}},ht=l.useCallback(()=>y?(U.error(t("settings.mcp.page.toast.createServerBeforeLiveActions")),!1):!0,[y,t]),St=l.useCallback(async(Y=!1)=>{try{await p({directory:m,silent:Y})}catch(Pe){Y||U.error(Pe instanceof Error?Pe.message:t("settings.mcp.page.toast.refreshStatusFailed"))}},[m,p,t]);l.useEffect(()=>{St(!0)},[St]),l.useEffect(()=>{Ke.current=Ee,ve(!1),Me(!1)},[Ee]);const At=l.useCallback(async()=>{if(!(!a||!ht())){if(!fe){U.error(t("settings.mcp.page.toast.enableServerBeforeTest"));return}Me(!0);try{const Y=await v(a,m),Pe=ci(Y.status);Y.warning?U.warning(Y.warning):Pe==="connected"?U.success(t("settings.mcp.page.toast.connectionTestSucceeded")):Pe==="needs_auth"?U.message(t("settings.mcp.page.toast.connectionNeedsAuthorization")):Pe==="failed"?U.error(Jo(Y.status)||Y.error||t("settings.mcp.page.toast.connectionTestFailed")):Y.error?U.error(Y.error):U.message(t("settings.mcp.page.toast.connectionTestFinished"))}catch(Y){U.error(Y instanceof Error?Y.message:t("settings.mcp.page.toast.connectionTestFailed"))}finally{Me(!1)}}},[m,fe,ht,a,t,v]);if(!a)return s.jsx(Ef,{});const _e=h[a],Xe=a?f[a]:void 0,mt=_e?ci(_e):Xe?.status,Fe=_e?Jo(_e):Xe?.error,W=ci(_e)==="connected",ye=Uf(mt,e,Fe),Ae=Y=>{switch(Y){case"connected":return t("settings.mcp.page.status.label.connected");case"failed":return t("settings.mcp.page.status.label.failed");case"needs_auth":return t("settings.mcp.page.status.label.needsAuth");default:return Y}};return s.jsxs(s.Fragment,{children:[s.jsxs(ns,{title:y?t("settings.mcp.page.header.newServer"):a,titleLeading:s.jsx(tl,{label:t("settings.mcp.page.back"),onClick:()=>{i(null),o(null)}}),titleAccessory:y?void 0:s.jsx(Ql,{status:mt,enabled:fe,getStatusLabel:Ae,variant:"pill"}),description:y?t("settings.mcp.page.header.configureNewServer"):t("settings.mcp.page.header.transport",{type:t(x==="local"?"settings.mcp.page.transport.local":"settings.mcp.page.transport.remote")}),headerEnd:y?void 0:s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(V,{variant:W?"outline":"default",size:"xs",className:"!font-normal",onClick:xt,disabled:Ie||!fe,children:t(Ie?"settings.mcp.page.actions.working":W?"settings.mcp.page.actions.disconnect":"settings.mcp.page.actions.connect")}),W&&s.jsx(V,{variant:"ghost",size:"xs",className:"!font-normal gap-1 text-muted-foreground",onClick:()=>{At()},disabled:Re||!fe,children:t(Re?"settings.mcp.page.actions.testing":"settings.mcp.page.actions.test")})]}),onBlurCapture:lt.onBlurCapture,children:[!y&&u&&s.jsx(Qr,{legacy:u.legacy===!0,path:u.path}),!y&&$f(mt)&&s.jsx(He,{divider:!1,children:s.jsx("div",{className:Ne("rounded-lg border p-3",_f(mt)),children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"min-w-0 space-y-1",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1",children:[s.jsx("span",{className:Pt,children:t("settings.mcp.page.status.runtimeStatus")}),s.jsx(Ql,{status:mt,enabled:fe,getStatusLabel:Ae})]}),s.jsx("p",{className:"typography-meta text-muted-foreground",children:ye}),s.jsx("p",{className:"typography-micro text-muted-foreground/80",children:w==="project"?t("settings.mcp.page.status.projectScopedTo",{directory:m??t("settings.mcp.page.status.activeProject")}):t("settings.mcp.page.status.userScoped")})]}),mt==="needs_auth"&&a&&s.jsx(Nf,{serverName:a,directory:m,onConnected:ft}),s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:!W&&s.jsx(V,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{At()},disabled:Re||!fe,children:t(Re?"settings.mcp.page.actions.testing":"settings.mcp.page.actions.testConnection")})})]})})}),s.jsxs(He,{title:t("settings.mcp.page.server.title"),divider:!1,settingsItem:"mcp.server",contentClassName:"space-y-0",titleAccessory:y?s.jsxs(V,{variant:"ghost",size:"xs",className:"!font-normal gap-1.5 text-muted-foreground",onClick:wt,type:"button",title:t("settings.mcp.page.server.importJsonTitle"),children:[s.jsx($,{name:"file-code",className:"h-3.5 w-3.5"}),t("settings.mcp.page.server.importJson")]}):null,children:[y&&s.jsxs(Ct,{label:t("settings.mcp.page.server.name"),controlClassName:"flex-wrap @xl:w-auto @xl:flex-1",children:[s.jsx(Ge,{value:S,onChange:Y=>N(Y.target.value.toLowerCase().replace(/[^a-z0-9_-]/g,"-")),placeholder:t("settings.mcp.page.server.namePlaceholder"),className:"h-7 w-48 min-w-0 max-w-full shrink font-mono px-2",autoFocus:!0}),s.jsxs(Dt,{value:w,onValueChange:Y=>A(Y),children:[s.jsxs(Tt,{size:Qt,className:"!h-7 min-w-0 max-w-full gap-1.5 px-2",children:[s.jsx($,{name:w==="user"?"user-3":"folder",className:"h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"truncate",children:t(w==="user"?"settings.mcp.page.scope.everywhere":"settings.mcp.page.scope.thisProject")})]}),s.jsxs(Et,{align:"end",children:[s.jsx(gt,{value:"user",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx($,{name:"user-3",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.mcp.page.scope.everywhere")})]})}),s.jsx(gt,{value:"project",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx($,{name:"folder",className:"h-3.5 w-3.5"}),s.jsx("span",{children:t("settings.mcp.page.scope.thisProject")})]})})]})]})]}),s.jsx(bt,{checked:fe,onChange:Y=>{ke(Y),J()},label:t("settings.mcp.page.server.enable"),ariaLabel:t("settings.mcp.page.server.enableAria")})]}),s.jsxs(He,{title:t("settings.mcp.page.connection.title"),description:t("settings.mcp.page.connection.description"),settingsItem:"mcp.command",contentClassName:"space-y-2",children:[s.jsx(Hr,{items:Ue,activeId:x,onSelect:Y=>{T(Y),J()},layoutMode:"fit",variant:"active-pill",activePillLowercase:!1,className:"h-10"}),x==="local"?s.jsx(Kf,{value:M,onChange:E,preview:Y=>t("settings.mcp.page.connection.previewArgs",{count:Y}),onDetectUrl:et}):s.jsx(Ge,{value:D,onChange:Y=>ze(Y.target.value),placeholder:t("settings.mcp.page.connection.serverUrlPlaceholder"),className:"font-mono typography-meta"}),s.jsx("p",{className:"typography-micro text-muted-foreground",children:t(x==="local"?"settings.mcp.page.connection.hintCommand":"settings.mcp.page.connection.hintLink")})]}),s.jsx(He,{title:t("settings.mcp.page.advanced.title"),settingsItem:"mcp.advanced",children:s.jsxs(bn,{open:me,onOpenChange:Te,children:[s.jsxs(vn,{className:"flex w-full items-center justify-between py-0.5 group",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-left",children:[s.jsx("span",{className:"typography-ui-label font-normal text-foreground",children:t("settings.mcp.page.advanced.configure")}),de&&s.jsxs("span",{className:"typography-micro text-muted-foreground",children:["(",de,")"]})]}),me?s.jsx($,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"}):s.jsx($,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"})]}),s.jsx(yn,{className:"pt-2",children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex flex-col gap-2 @xl:flex-row @xl:items-center @xl:gap-8",children:[s.jsxs("div",{className:"flex min-w-0 flex-row items-center gap-1 @xl:w-56 shrink-0",children:[s.jsx("span",{className:Pt,children:t("settings.mcp.page.advanced.protocol")}),s.jsx(Gt,{children:t("settings.mcp.page.advanced.protocolHint")})]}),s.jsxs(Dt,{value:z,onValueChange:Y=>{const Pe=pr.find(Je=>Je===Y);Pe&&(te(Pe),J())},children:[s.jsx(Tt,{size:Qt,className:"!h-7 w-full max-w-[16rem] px-2","aria-label":t("settings.mcp.page.advanced.protocol"),children:s.jsx("span",{className:"truncate",children:t(Wo[z])})}),s.jsx(Et,{children:pr.map(Y=>s.jsx(gt,{value:Y,children:t(Wo[Y])},Y))})]})]}),s.jsxs("div",{className:"space-y-2",children:[x==="local"&&s.jsxs("div",{className:"flex flex-col gap-2 @xl:flex-row @xl:items-center @xl:gap-8",children:[s.jsxs("div",{className:"flex min-w-0 flex-row items-center gap-1 @xl:w-56 shrink-0",children:[s.jsx("span",{className:Pt,children:t("settings.mcp.page.advanced.timeoutStartupMs")}),s.jsx(Gt,{children:t("settings.mcp.page.advanced.timeoutStartupHint")})]}),s.jsx(Ge,{type:"number",min:"1",step:"1",value:K,onChange:Y=>H(Y.target.value),placeholder:"5000",className:"h-7 w-32 font-mono px-2","data-bwignore":"true","data-1p-ignore":"true"})]}),s.jsxs("div",{className:"flex flex-col gap-2 @xl:flex-row @xl:items-center @xl:gap-8",children:[s.jsxs("div",{className:"flex min-w-0 flex-row items-center gap-1 @xl:w-56 shrink-0",children:[s.jsx("span",{className:Pt,children:t("settings.mcp.page.advanced.timeoutCatalogMs")}),s.jsx(Gt,{children:t("settings.mcp.page.advanced.timeoutCatalogHint")})]}),s.jsx(Ge,{type:"number",min:"1",step:"1",value:q,onChange:Y=>Z(Y.target.value),placeholder:"30000",className:"h-7 w-32 font-mono px-2","data-bwignore":"true","data-1p-ignore":"true"})]}),s.jsxs("div",{className:"flex flex-col gap-2 @xl:flex-row @xl:items-center @xl:gap-8",children:[s.jsxs("div",{className:"flex min-w-0 flex-row items-center gap-1 @xl:w-56 shrink-0",children:[s.jsx("span",{className:Pt,children:t("settings.mcp.page.advanced.timeoutExecutionMs")}),s.jsx(Gt,{children:t("settings.mcp.page.advanced.timeoutExecutionHint")})]}),s.jsx(Ge,{type:"number",min:"1",step:"1",value:ae,onChange:Y=>B(Y.target.value),placeholder:"30000",className:"h-7 w-32 font-mono px-2","data-bwignore":"true","data-1p-ignore":"true"})]})]}),s.jsxs("div",{className:"flex flex-col gap-2 @xl:flex-row @xl:items-center @xl:gap-8",children:[s.jsxs("div",{className:"flex min-w-0 flex-row items-center gap-1 @xl:w-56 shrink-0",children:[s.jsx("span",{className:Pt,children:t("settings.mcp.page.advanced.codemode")}),s.jsxs(Gt,{children:[t("settings.mcp.page.advanced.codemodeHint")," ",t("settings.mcp.page.advanced.codemodeDefaultHint")]})]}),s.jsxs(Dt,{value:G,onValueChange:Y=>{const Pe=gl.find(Je=>Je===Y);Pe&&(_(Pe),J())},children:[s.jsx(Tt,{size:Qt,className:"!h-7 w-full max-w-[16rem] px-2","aria-label":t("settings.mcp.page.advanced.codemode"),children:s.jsx("span",{className:"truncate",children:t(Wl[G])})}),s.jsx(Et,{children:gl.map(Y=>s.jsx(gt,{value:Y,children:t(Wl[Y])},Y))})]})]}),x==="remote"&&s.jsxs("div",{children:[s.jsxs(An,{as:"div",className:"mb-2",children:[t("settings.mcp.page.advanced.requestHeaders"),j.length>0&&s.jsxs("span",{className:"ml-1.5 typography-micro text-muted-foreground font-normal",children:["(",j.length,")"]})]}),s.jsx(Jl,{value:j,onChange:O,onCommit:J,keyTransform:Y=>Y.trimStart(),keyPlaceholder:t("settings.mcp.page.advanced.headerNamePlaceholder"),keyInputClassName:"w-36 shrink-0 font-mono typography-meta",pasteLabel:t("settings.mcp.page.advanced.pasteHeaders"),pasteTitle:t("settings.mcp.page.advanced.pasteHeadersTitle"),noPairsFoundError:t("settings.mcp.page.toast.noKeyValuePairsFound"),importSuccess:Y=>t("settings.mcp.page.toast.importedVariablesCount",{count:Y}),clipboardReadFailed:t("settings.mcp.page.toast.clipboardReadFailed"),keyLabel:t("settings.mcp.page.env.key"),valueLabel:t("settings.mcp.page.env.value"),valuePlaceholder:t("settings.mcp.page.env.valuePlaceholder"),hideValueTitle:t("settings.mcp.page.env.hide"),showValueTitle:t("settings.mcp.page.env.show"),addVariable:t("settings.mcp.page.env.addVariable"),plainTextWarning:t("settings.mcp.page.env.plainTextWarning"),removeVariableAria:t("settings.mcp.page.env.removeVariableAria")})]}),x==="remote"&&s.jsxs("div",{children:[s.jsx(An,{as:"div",className:"mb-2",children:t("settings.mcp.page.advanced.oauth")}),s.jsxs("div",{className:"flex flex-col gap-2 @xl:flex-row @xl:items-center @xl:gap-8",children:[s.jsxs("div",{className:"flex min-w-0 flex-row items-center gap-1 @xl:w-56 shrink-0",children:[s.jsx("span",{className:Pt,children:t("settings.mcp.page.advanced.oauthMetadataUrl")}),s.jsx(Gt,{children:t("settings.mcp.page.advanced.oauthMetadataUrlHint")})]}),s.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[s.jsx(Ge,{type:"url",value:Q,onChange:Y=>X(Y.target.value),placeholder:t("settings.mcp.page.advanced.oauthMetadataUrlPlaceholder"),"aria-label":t("settings.mcp.page.advanced.oauthMetadataUrl"),"aria-invalid":rt?!0:void 0,className:"h-7 w-full max-w-[24rem] font-mono typography-meta px-2","data-bwignore":"true","data-1p-ignore":"true"}),rt&&s.jsx("p",{className:"typography-micro text-[var(--status-error)]",children:rt})]})]})]})]})})]})}),s.jsx(He,{title:t("settings.mcp.page.env.title"),description:t("settings.mcp.page.env.description"),titleAccessory:L.length>0?s.jsxs("span",{className:"typography-micro text-muted-foreground font-normal",children:["(",L.length,")"]}):null,settingsItem:"mcp.environment",children:L.length===0?s.jsxs(V,{variant:"outline",size:"xs",className:"!font-normal gap-1.5",onClick:()=>P([{key:"",value:""}]),children:[s.jsx($,{name:"add",className:"h-3.5 w-3.5"}),t("settings.mcp.page.env.addEnvironmentVariable")]}):s.jsx(Jl,{value:L,onChange:P,onCommit:J,keyPlaceholder:t("settings.mcp.page.env.keyPlaceholder"),pasteLabel:t("settings.mcp.page.env.pasteEnv"),pasteTitle:t("settings.mcp.page.env.pasteEnvTitle"),noPairsFoundError:t("settings.mcp.page.toast.noKeyValuePairsFound"),importSuccess:Y=>t("settings.mcp.page.toast.importedVariablesCount",{count:Y}),clipboardReadFailed:t("settings.mcp.page.toast.clipboardReadFailed"),keyLabel:t("settings.mcp.page.env.key"),valueLabel:t("settings.mcp.page.env.value"),valuePlaceholder:t("settings.mcp.page.env.valuePlaceholder"),hideValueTitle:t("settings.mcp.page.env.hide"),showValueTitle:t("settings.mcp.page.env.show"),addVariable:t("settings.mcp.page.env.addVariable"),plainTextWarning:t("settings.mcp.page.env.plainTextWarning"),removeVariableAria:t("settings.mcp.page.env.removeVariableAria")})}),s.jsxs("div",{className:"flex items-center gap-2 pb-8",children:[y&&s.jsxs(s.Fragment,{children:[s.jsx(V,{onClick:()=>{nt()},disabled:be||!S.trim(),size:"xs",className:"!font-normal",children:t(be?"settings.common.actions.saving":"settings.common.actions.create")}),s.jsx(V,{variant:"ghost",onClick:ot,disabled:be,size:"xs",className:"!font-normal",children:t("settings.common.actions.cancel")})]}),!y&&s.jsx(V,{variant:"destructive",size:"xs",className:"!font-normal",onClick:()=>ee(!0),children:t("settings.common.actions.delete")})]})," "]}),s.jsx(_t,{open:Oe,onOpenChange:Y=>{Y||(ge(!1),ne(""),he(null))},children:s.jsxs($t,{className:"max-w-md",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:t("settings.mcp.page.importDialog.title")}),s.jsx(qt,{children:t("settings.mcp.page.importDialog.description")})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx(Rs,{value:xe,onChange:Y=>{ne(Y.target.value),he(null)},placeholder:`{
|
|
16
|
-
"mcpServers": {
|
|
17
|
-
"postgres": {
|
|
18
|
-
"command": "npx",
|
|
19
|
-
"args": ["-y", "@modelcontextprotocol/server-postgres"]
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}`,rows:8,className:"font-mono typography-meta",spellCheck:!1,"data-bwignore":"true","data-1p-ignore":"true"}),ie&&s.jsx("p",{className:"typography-micro text-[var(--status-error)]",children:ie}),s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:s.jsxs(V,{variant:"outline",size:"xs",className:"!font-normal gap-1",onClick:yt,type:"button",children:[s.jsx($,{name:"clipboard",className:"h-3.5 w-3.5"}),t("settings.mcp.page.importDialog.pasteFromClipboard")]})})]}),s.jsxs(as,{children:[s.jsx(V,{variant:"outline",onClick:()=>{ge(!1),ne(""),he(null)},className:"text-foreground",children:t("settings.common.actions.cancel")}),s.jsx(V,{onClick:st,disabled:!xe.trim(),size:"sm",children:t("settings.common.actions.import")})]})]})}),s.jsx(_t,{open:oe,onOpenChange:Y=>{!Y&&!ce&&ee(!1)},children:s.jsxs($t,{className:"max-w-md",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:t("settings.mcp.page.deleteDialog.title",{name:a??""})}),s.jsxs(qt,{children:[t("settings.mcp.page.deleteDialog.descriptionPrefix")," ",s.jsx("code",{className:"text-foreground",children:"opencode.json"}),"."," ",t("settings.mcp.page.deleteDialog.descriptionSuffix")]})]}),s.jsxs(as,{children:[s.jsx(V,{variant:"outline",onClick:()=>ee(!1),disabled:ce,className:"text-foreground",children:t("settings.common.actions.cancel")}),s.jsx(V,{variant:"destructive",size:"sm",onClick:it,disabled:ce,children:t(ce?"settings.mcp.page.actions.deleting":"settings.common.actions.delete")})]})]})})]})};function Hf(t){return t.trim().length>0}function qf(t){return t.trimEnd()}function Gf(t,e){return s.jsxs("span",{className:"block",children:[s.jsxs("span",{className:"text-muted-foreground select-none mr-2",children:["[",e,"]"]}),t]},e)}const Wf=/^[a-z0-9][a-z0-9-_.]*\.(js|ts|mjs|cjs)$/;function Jf(t){const e=t.trim();if(e==="")return{ok:!0,value:void 0};try{const a=JSON.parse(e);return a===null||typeof a!="object"||Array.isArray(a)?{ok:!1}:{ok:!0,value:a}}catch{return{ok:!1}}}const Qf=({open:t,onOpenChange:e,defaultScope:a="user"})=>{const{t:n}=qe(),i=zt(P=>P.createEntry),o=zt(P=>P.createFile),[r,d]=l.useState("npm"),[c,g]=l.useState(""),[m,h]=l.useState(""),[f,p]=l.useState(""),[b,C]=l.useState(""),[v,k]=l.useState(a),[u,y]=l.useState(!1),S=l.useCallback(()=>{g(""),h(""),p(""),C(""),k(a)},[a]);l.useEffect(()=>{t&&(d("npm"),S())},[t,S]);const N=P=>{P!==r&&(d(P),S())},w=l.useMemo(()=>Jf(m),[m]),A=!w.ok,x=r==="file"&&f.trim()!==""&&!Wf.test(f.trim()),T=(r==="npm"||r==="path")&&c.trim()==="",M=r==="file"&&b.trim()==="",E=r==="file"&&f.trim()==="",D=u||A||r==="npm"&&T||r==="path"&&T||r==="file"&&(E||x||M),F=async()=>{if(!D){y(!0);try{let P;r==="file"?P=await o({fileName:f.trim(),content:b,scope:v}):P=await i({spec:c.trim(),options:w.ok?w.value:void 0,scope:v}),P.ok?(U.success(P.message||n("settings.plugins.toast.created")),P.reloadFailed&&U.warning(n("settings.plugins.toast.reloadFailed")),e(!1)):U.error(P.message||n("settings.plugins.sidebar.toast.deleteFailed"))}finally{y(!1)}}},L=l.useMemo(()=>[{id:"npm",label:n("settings.plugins.dialog.add.tab.npm")},{id:"path",label:n("settings.plugins.dialog.add.tab.path")},{id:"file",label:n("settings.plugins.dialog.add.tab.file")}],[n]);return s.jsx(_t,{open:t,onOpenChange:P=>{!P&&u||e(P)},children:s.jsxs($t,{className:"max-w-xl",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:n("settings.plugins.dialog.add.title")}),s.jsx(qt,{children:n("settings.plugins.sidebar.empty.description")})]}),s.jsx(Hr,{items:L,activeId:r,onSelect:P=>N(P),layoutMode:"fit",variant:"active-pill",activePillLowercase:!1,className:"h-10"}),s.jsxs("div",{className:"flex flex-col gap-4",children:[(r==="npm"||r==="path")&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{"data-settings-item":"plugins.spec",className:"flex flex-col gap-1.5",children:[s.jsx("label",{htmlFor:"plugin-spec",className:"typography-ui-label text-foreground",children:n("settings.plugins.page.field.spec")}),s.jsx(Ge,{id:"plugin-spec",value:c,onChange:P=>g(P.target.value),placeholder:n("settings.plugins.page.field.spec.placeholder"),"aria-invalid":T?!1:void 0,disabled:u}),T&&s.jsx("p",{className:"typography-meta text-muted-foreground",children:n("settings.plugins.validation.specRequired")})]}),s.jsxs("div",{"data-settings-item":"plugins.options",className:"flex flex-col gap-1.5",children:[s.jsx("label",{htmlFor:"plugin-options",className:"typography-ui-label text-foreground",children:n("settings.plugins.page.field.options")}),s.jsx(Rs,{id:"plugin-options",value:m,onChange:P=>h(P.target.value),rows:5,className:"font-mono",hasError:A,disabled:u}),A&&s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:n("settings.plugins.page.field.options.invalidJson")})]})]}),r==="file"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{"data-settings-item":"plugins.content",className:"flex flex-col gap-1.5",children:[s.jsx("label",{htmlFor:"plugin-filename",className:"typography-ui-label text-foreground",children:n("settings.plugins.page.field.fileName")}),s.jsx(Ge,{id:"plugin-filename",value:f,onChange:P=>p(P.target.value),placeholder:"my-plugin.ts","aria-invalid":x||void 0,disabled:u}),x&&s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:n("settings.plugins.validation.fileName")})]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx("label",{htmlFor:"plugin-content",className:"typography-ui-label text-foreground",children:n("settings.plugins.page.field.content")}),s.jsx(Rs,{id:"plugin-content",value:b,onChange:P=>C(P.target.value),rows:16,className:"font-mono",disabled:u})]})]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:n("settings.plugins.page.field.scope")}),s.jsx("div",{className:"flex items-center gap-4",children:["user","project"].map(P=>{const j=v===P,O=n(P==="user"?"settings.plugins.scope.user":"settings.plugins.scope.project");return s.jsxs("button",{type:"button",onClick:()=>k(P),disabled:u,className:"flex items-center gap-2 py-1 text-left disabled:opacity-50",children:[s.jsx(Fr,{checked:j,onChange:()=>k(P),ariaLabel:O}),s.jsx("span",{className:Ne("typography-ui-label font-normal",j?"text-foreground":"text-foreground/60"),children:O})]},P)})})]})]}),s.jsxs(as,{children:[s.jsx(V,{size:"sm",variant:"ghost",onClick:()=>e(!1),disabled:u,children:n("settings.plugins.dialog.add.action.cancel")}),s.jsxs(V,{size:"sm",onClick:()=>{F()},disabled:D,children:[u?s.jsx($,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin"}):null,n("settings.plugins.dialog.add.action.submit")]})]})]})})},Yf=t=>t.startsWith("/")||/^[A-Za-z]:[\\/]/.test(t),Qa=t=>{const e=t.replace(/\\/g,"/"),a=[],[n,...i]=e.split("/");for(const r of i)if(!(r===""||r===".")){if(r===".."){a.pop();continue}a.push(r)}return`${/^[A-Za-z]:$/.test(n)?`${n.toUpperCase()}/`:"/"}${a.join("/")}`},Zf=t=>Qa(`${t.replace(/\\/g,"/")}/..`),Xf=t=>{try{const e=decodeURIComponent(new URL(t).pathname);return/^\/[A-Za-z]:\//.test(e)?e.slice(1):e}catch{return null}};function Pd(t,e){if(t.startsWith("file://")){const a=Xf(t);return a?{kind:"local",path:Qa(a)}:null}return t.startsWith("./")||t.startsWith("../")?e?{kind:"local",path:Qa(`${Zf(e)}/${t}`)}:null:Yf(t)?{kind:"local",path:Qa(t)}:{kind:"package",target:t}}function Ad(t){return t?{kind:"local",path:Qa(t)}:null}const eh=(t,e)=>{if(t.kind==="package")return e.source.kind==="package"&&e.source.target===t.target;if(e.source.kind!=="local")return!1;const a=Qa(e.source.path);return a===t.path||a.startsWith(`${t.path}/`)};function Td(t,e){return e.filter(a=>eh(t,a))}function th(t){const e=t.find(n=>n.state.kind==="failed");if(e&&e.state.kind==="failed")return{kind:"failed",error:e.state.error,ref:e.state.ref};const a=t[0];return a?{kind:"active",version:a.source.kind==="package"?a.source.version:null}:{kind:"notReported"}}function Ed(t){const e=t.flatMap(a=>a.source.kind==="package"?[a.source]:[]);return e.some(a=>a.updating)?"updating":e.some(a=>a.outdated)?"available":"none"}function Dd(t){const e=Be.c(12),a=zt(sh),n=Kr(ra());let i;e:{if(a.kind==="idle"||a.scope!==n){let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g={kind:"loading"},e[0]=g):g=e[0],i=g;break e}if(a.kind==="failed"||!t){let g;e[1]===Symbol.for("react.memo_cache_sentinel")?(g={kind:"unknown"},e[1]=g):g=e[1],i=g;break e}let o,r,d;if(e[2]!==a.plugins||e[3]!==t){const g=Td(t,a.plugins);o="known",r=th(g),d=Ed(g),e[2]=a.plugins,e[3]=t,e[4]=o,e[5]=r,e[6]=d}else o=e[4],r=e[5],d=e[6];let c;e[7]!==o||e[8]!==r||e[9]!==d||e[10]!==t?(c={kind:o,load:r,update:d,target:t},e[7]=o,e[8]=r,e[9]=d,e[10]=t,e[11]=c):c=e[11],i=c}return i}function sh(t){return t.runtime}function Md(t){const e=Be.c(4);let a;if(e[0]!==t){const o=Kr(ra());a=t?.kind==="package"?ed(o,t.target):null,e[0]=t,e[1]=a}else a=e[1];const n=a;let i;return e[2]!==n?(i=o=>n?o.packageUpdates[n]??null:null,e[2]=n,e[3]=i):i=e[3],zt(i)}const Yl=t=>{const e=Be.c(18),{target:a,spec:n}=t,{t:i}=qe(),o=Dd(a),r=Md(a);let d;e[0]!==n?(d=v=>n?v.registryInfo[n]:void 0,e[0]=n,e[1]=d):d=e[1];const c=zt(d),g=c?.kind==="npm-missing-package"||c?.kind==="npm-missing-version"||c?.kind==="npm-malformed"||c?.kind==="path-missing"||c?.kind==="path-unreadable",m=o.kind==="known"&&(o.update==="updating"||r?.kind==="running"),h=!m&&(c?.kind==="npm-ok"&&c.hasUpdate||o.kind==="known"&&o.update==="available");let f;e[2]!==g||e[3]!==i?(f=g?s.jsx(In,{tone:"error",children:i("settings.plugins.registry.banner.invalid.title")}):null,e[2]=g,e[3]=i,e[4]=f):f=e[4];let p;e[5]!==g||e[6]!==o.kind||e[7]!==o.load||e[8]!==i||e[9]!==m?(p=o.kind==="known"&&!g?m?s.jsx(In,{tone:"neutral",children:i("settings.plugins.update.running")}):o.load.kind==="failed"?s.jsx(In,{tone:"error",children:i("settings.plugins.status.failed.title")}):o.load.kind==="notReported"?s.jsx(In,{tone:"neutral",children:i("settings.plugins.status.notReported.title")}):s.jsx(In,{tone:"success",children:i("settings.plugins.status.loaded")}):null,e[5]=g,e[6]=o.kind,e[7]=o.load,e[8]=i,e[9]=m,e[10]=p):p=e[10];let b;e[11]!==i||e[12]!==h?(b=h?s.jsx(In,{tone:"info",children:i("settings.plugins.update.available.title")}):null,e[11]=i,e[12]=h,e[13]=b):b=e[13];let C;return e[14]!==f||e[15]!==p||e[16]!==b?(C=s.jsxs(s.Fragment,{children:[f,p,b]}),e[14]=f,e[15]=p,e[16]=b,e[17]=C):C=e[17],C},nh=t=>{const e=Be.c(54),{onAdd:a,onDelete:n}=t,{t:i}=qe(),{entries:o,files:r,setSelected:d,loadPlugins:c}=zt(_s(ah)),g=zt(ih),m=zt(oh),h=zt(rh),f=zt(lh),p=zt(ch),b=zt(dh),C=zt(uh),v=zt(mh),k=zt(ph),u=Kr(ra()),y=p.kind==="failed"&&p.scope===u,S=p.kind==="ready"&&p.scope===u?p.plugins:null,[N,w]=l.useState("");let A,x;e[0]!==c?(A=()=>{c()},x=[c],e[0]=c,e[1]=A,e[2]=x):(A=e[1],x=e[2]),l.useEffect(A,x);let T;e[3]!==f||e[4]!==m||e[5]!==i?(T=async()=>{U.info(i("settings.plugins.toast.refreshing"));const[ue,Ie]=await Promise.all([m({force:!0}),f()]);ue||U.error(i("settings.plugins.toast.refreshFailed")),Ie||U.error(i("settings.plugins.toast.checkFailed"))},e[3]=f,e[4]=m,e[5]=i,e[6]=T):T=e[6];const M=T;let E;if(e[7]!==o||e[8]!==r){E=new Map;for(const ue of o)E.set(ue.id,Pd(ue.spec,ue.sourcePath));for(const ue of r)E.set(ue.id,Ad(ue.absolutePath));e[7]=o,e[8]=r,e[9]=E}else E=e[9];const D=E,F=ue=>{const Ie=D.get(ue);return!S||Ie?.kind!=="package"||C[ed(u,Ie.target)]?.kind==="running"?null:Ed(Td(Ie,S))==="available"?Ie.target:null},L=ue=>{const Ie=[],ve=b[ue.spec],Re=F(ue.id);if(ve?.kind==="npm-ok"&&ve.hasUpdate&&ve.latestVersion){const Me=ve.latestVersion;Ie.push({label:i("settings.plugins.registry.banner.updateAvailable.action",{latest:Me}),icon:"arrow-up-s",onSelect:()=>{v(ue.id).then(me=>{me.ok?U.success(i("settings.plugins.toast.updatedToLatest",{version:Me})):U.error(i("settings.plugins.toast.refreshFailed"))})}})}else Re&&Ie.push({label:i("settings.plugins.update.action"),icon:"arrow-up-s",onSelect:()=>{k(Re).then(Me=>{Me?U.success(i("settings.plugins.update.toast.done",{name:ue.spec})):U.error(i("settings.plugins.update.toast.failed",{name:ue.spec}))})}});return Ie.push({label:i("settings.common.actions.delete"),icon:"delete-bin",destructive:!0,onSelect:()=>n({kind:"entry",id:ue.id,label:ue.spec})}),Ie},P=[...o.map(gh),...r.map(fh)],j=sa(P,N,hh);let O;e[10]!==N?(O=N.trim(),e[10]=N,e[11]=O):O=e[11];const K=O.length>0,H=g||h,q=ns;let Z;e[12]!==i?(Z=i("settings.page.plugins.title"),e[12]=i,e[13]=Z):Z=e[13];let ae;e[14]!==i?(ae=i("settings.plugins.grid.description"),e[14]=i,e[15]=ae):ae=e[15];let B;e[16]!==y||e[17]!==i?(B=y?s.jsxs("span",{className:"inline-flex items-center gap-1 typography-meta text-muted-foreground",children:[s.jsx($,{name:"question",className:"size-3.5"}),i("settings.plugins.status.sidebar.unavailable")]}):null,e[16]=y,e[17]=i,e[18]=B):B=e[18];let G;e[19]!==M?(G=()=>{M()},e[19]=M,e[20]=G):G=e[20];let _;e[21]!==i?(_=i("settings.plugins.sidebar.actions.refresh"),e[21]=i,e[22]=_):_=e[22];let z;e[23]!==i?(z=i("settings.plugins.sidebar.actions.refresh"),e[23]=i,e[24]=z):z=e[24];const te=H&&"animate-spin";let Q;e[25]!==te?(Q=Ne("size-4",te),e[25]=te,e[26]=Q):Q=e[26];let X;e[27]!==Q?(X=s.jsx($,{name:"refresh",className:Q}),e[27]=Q,e[28]=X):X=e[28];let pe;e[29]!==H||e[30]!==z||e[31]!==X||e[32]!==G||e[33]!==_?(pe=s.jsx(V,{variant:"ghost",size:"icon",className:"h-9 w-9 shrink-0 text-muted-foreground",onClick:G,disabled:H,"aria-label":_,title:z,children:X}),e[29]=H,e[30]=z,e[31]=X,e[32]=G,e[33]=_,e[34]=pe):pe=e[34];let je;e[35]!==pe||e[36]!==B?(je=s.jsxs("div",{className:"flex items-center gap-2",children:[B,pe]}),e[35]=pe,e[36]=B,e[37]=je):je=e[37];const fe=P.length>0?s.jsx(el,{value:N,onChange:w,placeholder:i("settings.plugins.grid.searchPlaceholder")}):null,ke=P.length===0?s.jsx("p",{className:"py-6 typography-meta text-muted-foreground",children:i("settings.plugins.grid.empty")}):j.length===0?s.jsx("p",{className:"py-6 typography-meta text-muted-foreground",children:i("settings.plugins.grid.noMatches",{query:N.trim()})}):null,be=Zr;let De;e[38]!==K||e[39]!==a||e[40]!==i?(De=K?null:s.jsx(Xr,{label:i("settings.plugins.sidebar.actions.addTitle"),hint:i("settings.plugins.grid.addHint"),onClick:a,settingsItem:"plugins.create"}),e[38]=K,e[39]=a,e[40]=i,e[41]=De):De=e[41];const oe=j.map(ue=>{if(ue.kind==="entry"){const{entry:Re}=ue;return s.jsx(ji,{icon:s.jsx(Nr,{name:Re.parsedKind==="npm"?"code-box":"folder"}),title:Re.spec,badges:s.jsx(Yl,{target:D.get(Re.id)??null,spec:Re.spec}),footer:s.jsxs(s.Fragment,{children:[s.jsx("span",{children:Re.parsedKind==="npm"?i("settings.plugins.sidebar.kind.npm"):i("settings.plugins.sidebar.kind.path")}),Re.scope==="project"?s.jsx(io,{children:i("settings.plugins.grid.scope.project")}):null]}),onOpen:()=>d(Re.id),actionsLabel:i("settings.plugins.grid.actionsAria",{name:Re.spec}),actions:L(Re)},Re.id)}const{file:Ie}=ue,ve=Ie.kind==="package";return s.jsx(ji,{icon:s.jsx(Nr,{name:ve?"folder":"file-text"}),title:Ie.fileName,badges:s.jsx(Yl,{target:D.get(Ie.id)??null}),footer:s.jsxs(s.Fragment,{children:[s.jsx("span",{children:i(ve?"settings.plugins.sidebar.kind.package":"settings.plugins.sidebar.kind.file")}),Ie.scope==="project"?s.jsx(io,{children:i("settings.plugins.grid.scope.project")}):null]}),onOpen:ve?void 0:()=>d(Ie.id),actionsLabel:i("settings.plugins.grid.actionsAria",{name:Ie.fileName}),actions:ve?void 0:[{label:i("settings.common.actions.delete"),icon:"delete-bin",destructive:!0,onSelect:()=>n({kind:"file",id:Ie.id,label:Ie.fileName})}]},Ie.id)});let ee;e[42]!==be||e[43]!==De||e[44]!==oe?(ee=s.jsxs("div",{className:be,children:[De,oe]}),e[42]=be,e[43]=De,e[44]=oe,e[45]=ee):ee=e[45];let ce;return e[46]!==q||e[47]!==je||e[48]!==fe||e[49]!==ke||e[50]!==ee||e[51]!==Z||e[52]!==ae?(ce=s.jsxs(q,{title:Z,description:ae,headerEnd:je,children:[fe,ke,ee]}),e[46]=q,e[47]=je,e[48]=fe,e[49]=ke,e[50]=ee,e[51]=Z,e[52]=ae,e[53]=ce):ce=e[53],ce};function ah(t){return{entries:t.entries,files:t.files,setSelected:t.setSelected,loadPlugins:t.loadPlugins}}function ih(t){return t.isLoadingRegistry}function oh(t){return t.loadRegistryInfo}function rh(t){return t.isCheckingUpdates}function lh(t){return t.checkUpdates}function ch(t){return t.runtime}function dh(t){return t.registryInfo}function uh(t){return t.packageUpdates}function mh(t){return t.updateToLatest}function ph(t){return t.updatePackage}function gh(t){return{kind:"entry",entry:t}}function fh(t){return{kind:"file",file:t}}function hh(t){return t.kind==="entry"?[t.entry.spec]:[t.file.fileName,t.file.absolutePath??""]}const xh=({entryId:t,spec:e})=>{const{t:a}=qe(),n=zt(h=>h.registryInfo[e]),i=zt(h=>h.updateToLatest),[o,r]=l.useState(!1);if(!n)return null;if(n.kind==="npm-ok"){if(!n.hasUpdate||!n.latestVersion)return null;const h=n.latestVersion,f=n.currentVersion??"",p=async()=>{r(!0);try{(await i(t)).ok?U.success(a("settings.plugins.toast.updatedToLatest",{version:h})):U.error(a("settings.plugins.toast.refreshFailed"))}finally{r(!1)}};return s.jsxs("div",{className:"rounded-md border border-border bg-card p-3 flex items-start gap-3",children:[s.jsx($,{name:"arrow-up",className:"h-5 w-5 text-[var(--status-success)] shrink-0 mt-0.5"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"typography-label text-[var(--status-success)]",children:a("settings.plugins.registry.banner.updateAvailable.title")}),s.jsx("p",{className:"typography-micro text-muted-foreground mt-0.5",children:a("settings.plugins.registry.banner.updateAvailable.description",{current:f,latest:h})})]}),s.jsx(V,{variant:"default",size:"sm",onClick:()=>{p()},disabled:o,children:a("settings.plugins.registry.banner.updateAvailable.action",{latest:h})})]})}if(n.kind==="path-ok")return null;if(n.kind==="npm-network")return s.jsxs("div",{className:"rounded-md border border-border bg-card p-3 flex items-start gap-3",children:[s.jsx($,{name:"cloud-off",className:"h-5 w-5 text-muted-foreground shrink-0 mt-0.5"}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx("p",{className:"typography-micro text-muted-foreground",children:a("settings.plugins.registry.badge.network.tooltip")})})]});const d=n.kind==="path-unreadable",c=d?"var(--status-warning)":"var(--status-error)",g=d?"alert":"error-warning",m=(()=>{switch(n.kind){case"npm-missing-version":return a("settings.plugins.registry.banner.invalid.missingVersion");case"npm-missing-package":return a("settings.plugins.registry.banner.invalid.missingPackage");case"npm-malformed":return a("settings.plugins.registry.banner.invalid.malformed");case"path-missing":return a("settings.plugins.registry.banner.invalid.pathMissing");case"path-unreadable":return a("settings.plugins.registry.banner.invalid.pathUnreadable")}})();return s.jsxs("div",{className:"rounded-md border border-border bg-card p-3 flex items-start gap-3",children:[s.jsx($,{name:g,className:"h-5 w-5 shrink-0 mt-0.5",style:{color:c}}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"typography-label",style:{color:c},children:a("settings.plugins.registry.banner.invalid.title")}),s.jsx("p",{className:"typography-micro text-muted-foreground mt-0.5",children:m})]})]})},Zl=t=>{const e=Be.c(68),{target:a,name:n}=t,{t:i}=qe(),o=Dd(a),r=Md(a),d=zt(bh),c=zt(vh);if(o.kind==="loading")return null;if(o.kind==="unknown"){let S;e[0]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx($,{name:"question",className:"h-5 w-5 text-muted-foreground shrink-0 mt-0.5"}),e[0]=S):S=e[0];let N;e[1]!==i?(N=i("settings.plugins.status.unknown.title"),e[1]=i,e[2]=N):N=e[2];let w;e[3]!==N?(w=s.jsx("p",{className:"typography-label text-foreground",children:N}),e[3]=N,e[4]=w):w=e[4];let A;e[5]!==i?(A=i("settings.plugins.status.unknown.description"),e[5]=i,e[6]=A):A=e[6];let x;e[7]!==A?(x=s.jsx("p",{className:"typography-micro text-muted-foreground mt-0.5",children:A}),e[7]=A,e[8]=x):x=e[8];let T;e[9]!==w||e[10]!==x?(T=s.jsxs("div",{className:"flex-1 min-w-0",children:[w,x]}),e[9]=w,e[10]=x,e[11]=T):T=e[11];let M;e[12]!==d?(M=()=>{d()},e[12]=d,e[13]=M):M=e[13];let E;e[14]!==i?(E=i("settings.plugins.status.retry"),e[14]=i,e[15]=E):E=e[15];let D;e[16]!==M||e[17]!==E?(D=s.jsx(V,{variant:"outline",size:"sm",onClick:M,children:E}),e[16]=M,e[17]=E,e[18]=D):D=e[18];let F;return e[19]!==T||e[20]!==D?(F=s.jsxs("div",{className:"rounded-md border border-border bg-card p-3 flex items-start gap-3",children:[S,T,D]}),e[19]=T,e[20]=D,e[21]=F):F=e[21],F}const{load:g,update:m}=o,h=o.target.kind==="package"?o.target.target:null,f=m==="updating"||r?.kind==="running";let p;e[22]!==n||e[23]!==h||e[24]!==i||e[25]!==c?(p=async()=>{if(!h)return;await c(h)?U.success(i("settings.plugins.update.toast.done",{name:n})):U.error(i("settings.plugins.update.toast.failed",{name:n}))},e[22]=n,e[23]=h,e[24]=i,e[25]=c,e[26]=p):p=e[26];const b=p;let C;e:{switch(g.kind){case"active":{let S;e[27]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx($,{name:"checkbox-circle",className:"h-4 w-4 text-[var(--status-success)]"}),e[27]=S):S=e[27];let N;e[28]!==g.version||e[29]!==i?(N=g.version?i("settings.plugins.status.loadedVersion",{version:g.version}):i("settings.plugins.status.loaded"),e[28]=g.version,e[29]=i,e[30]=N):N=e[30];let w;e[31]!==N?(w=s.jsxs("p",{className:"typography-meta flex items-center gap-1.5 text-muted-foreground",children:[S,N]}),e[31]=N,e[32]=w):w=e[32],C=w;break e}case"notReported":{let S;e[33]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx($,{name:"time",className:"h-5 w-5 text-muted-foreground shrink-0 mt-0.5"}),e[33]=S):S=e[33];let N;e[34]!==i?(N=i("settings.plugins.status.notReported.title"),e[34]=i,e[35]=N):N=e[35];let w;e[36]!==N?(w=s.jsx("p",{className:"typography-label text-foreground",children:N}),e[36]=N,e[37]=w):w=e[37];let A;e[38]!==i?(A=i("settings.plugins.status.notReported.description"),e[38]=i,e[39]=A):A=e[39];let x;e[40]!==A?(x=s.jsx("p",{className:"typography-micro text-muted-foreground mt-0.5",children:A}),e[40]=A,e[41]=x):x=e[41];let T;e[42]!==w||e[43]!==x?(T=s.jsxs("div",{className:"rounded-md border border-border bg-card p-3 flex items-start gap-3",children:[S,s.jsxs("div",{className:"flex-1 min-w-0",children:[w,x]})]}),e[42]=w,e[43]=x,e[44]=T):T=e[44],C=T;break e}case"failed":{let S;e[45]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx($,{name:"error-warning",className:"h-5 w-5 text-[var(--status-error)] shrink-0 mt-0.5"}),e[45]=S):S=e[45];let N;e[46]!==i?(N=i("settings.plugins.status.failed.title"),e[46]=i,e[47]=N):N=e[47];let w;e[48]!==N?(w=s.jsx("p",{className:"typography-label text-[var(--status-error)]",children:N}),e[48]=N,e[49]=w):w=e[49];let A;e[50]!==g.error?(A=s.jsx("p",{className:"typography-micro font-mono text-foreground mt-1 whitespace-pre-wrap break-words",children:g.error}),e[50]=g.error,e[51]=A):A=e[51];let x;e[52]!==g.ref||e[53]!==i?(x=g.ref?s.jsx("p",{className:"typography-micro text-muted-foreground mt-1",children:i("settings.plugins.status.failed.ref",{ref:g.ref})}):null,e[52]=g.ref,e[53]=i,e[54]=x):x=e[54];let T;e[55]!==w||e[56]!==A||e[57]!==x?(T=s.jsxs("div",{className:"rounded-md border border-border bg-card p-3 flex items-start gap-3",children:[S,s.jsxs("div",{className:"flex-1 min-w-0",children:[w,A,x]})]}),e[55]=w,e[56]=A,e[57]=x,e[58]=T):T=e[58],C=T;break e}}C=void 0}const v=C,k=h!==null&&(m!=="none"||r!==null);let u;e[59]!==b||e[60]!==f||e[61]!==r||e[62]!==k||e[63]!==i?(u=k?s.jsxs("div",{className:"rounded-md border border-border bg-card p-3 flex items-start gap-3",children:[s.jsx($,{name:"arrow-up",className:"h-5 w-5 text-[var(--status-success)] shrink-0 mt-0.5"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"typography-label text-[var(--status-success)]",children:i("settings.plugins.update.available.title")}),s.jsx("p",{className:"typography-micro text-muted-foreground mt-0.5",children:i("settings.plugins.update.available.description")}),r?.kind==="failed"?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"typography-micro text-[var(--status-error)] mt-2",children:i("settings.plugins.update.failed.title")}),s.jsx("p",{className:"typography-micro font-mono text-foreground mt-0.5 whitespace-pre-wrap break-words",children:r.error})]}):null]}),s.jsx(V,{variant:"default",size:"sm",onClick:()=>{b()},disabled:f,children:f?s.jsxs(s.Fragment,{children:[s.jsx($,{name:"loader-4",className:"size-4 animate-spin"}),i("settings.plugins.update.running")]}):i("settings.plugins.update.action")})]}):null,e[59]=b,e[60]=f,e[61]=r,e[62]=k,e[63]=i,e[64]=u):u=e[64];let y;return e[65]!==v||e[66]!==u?(y=s.jsxs("div",{className:"flex flex-col gap-3",children:[v,u]}),e[65]=v,e[66]=u,e[67]=y):y=e[67],y};function bh(t){return t.loadRuntime}function vh(t){return t.updatePackage}function oo(t){const e=t.trim();if(e.length===0)return{ok:!0,value:void 0};try{const a=JSON.parse(e);return a===null||typeof a!="object"||Array.isArray(a)?{ok:!1}:{ok:!0,value:a}}catch{return{ok:!1}}}function ro(t){return!t||Object.keys(t).length===0?"":JSON.stringify(t,null,2)}function Xl(t,e){if(t.trim()===e.trim())return!0;const a=oo(t),n=oo(e);return a.ok&&n.ok&&ro(a.value)===ro(n.value)}function yh(t){return{mode:"entry",scope:t.scope,spec:t.spec,optionsJson:ro(t.options),fileName:"",content:""}}function jh(t,e){return{mode:"file",scope:t.scope,spec:"",optionsJson:"",fileName:t.fileName,content:e}}const ec=t=>{const e=Be.c(4),{scope:a,label:n}=t;let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=Ne("typography-micro font-medium rounded-full px-2 py-0.5","bg-[var(--surface-elevated)] text-muted-foreground","border border-[var(--interactive-border)]"),e[0]=i):i=e[0];let o;return e[1]!==n||e[2]!==a?(o=s.jsx("span",{className:i,"data-scope":a,children:n}),e[1]=n,e[2]=a,e[3]=o):o=e[3],o},kh=()=>{const t=Be.c(229),{t:e}=qe(),n=hn(wh)?.trim()||ra(),i=zt(Nh),o=zt(Sh),r=i===n&&o===ln(),d=zt(Ch),c=zt(Ih),g=zt(Ph),m=zt(Ah),h=zt(Th),f=zt(Eh),p=zt(Dh),b=zt(Mh),C=zt(Rh),v=zt(Oh),k=zt(Lh),[u,y]=l.useState(!1),[S,N]=l.useState(null),[w,A]=l.useState(!1);let x;t[0]!==y?(x=()=>{const st=()=>y(!0);return window.addEventListener("openchamber:settings-open-plugin-add",st),()=>window.removeEventListener("openchamber:settings-open-plugin-add",st)},t[0]=y,t[1]=x):x=t[1];let T;t[2]===Symbol.for("react.memo_cache_sentinel")?(T=[],t[2]=T):T=t[2],l.useEffect(x,T);let M;t[3]===Symbol.for("react.memo_cache_sentinel")?(M=[],t[3]=M):M=t[3],l.useEffect(Kh,M);let E;t[4]!==c||t[5]!==d?(E=d?c.find(st=>st.id===d)??null:null,t[4]=c,t[5]=d,t[6]=E):E=t[6];const D=E;let F;t[7]!==g||t[8]!==d?(F=d?g.find(st=>st.id===d)??null:null,t[7]=g,t[8]=d,t[9]=F):F=t[9];const L=F;let P;t[10]!==D?(P=D?Pd(D.spec,D.sourcePath):null,t[10]=D,t[11]=P):P=t[11];const j=P;let O;t[12]!==L?(O=L?Ad(L.absolutePath):null,t[12]=L,t[13]=O):O=t[13];const K=O,[H,q]=l.useState(!1);let Z;t[14]===Symbol.for("react.memo_cache_sentinel")?(Z=new Map,t[14]=Z):Z=t[14];const ae=l.useRef(Z),B=l.useRef(null),G=JSON.stringify([n,d]);let _;t[15]!==r||t[16]!==n||t[17]!==G||t[18]!==b||t[19]!==D||t[20]!==L||t[21]!==h||t[22]!==q?(_=()=>{let st=!1;if(!r){B.current=null,h(null);return}const rt=(de,Ue)=>{if(zt.getState().selectedId!==de||ra()!==n)return;const et=B.current,ze=zt.getState().draft,Ze=et?.id===de&&et.directory===n&&ze!==null&&(ze.spec!==et.value.spec||!Xl(ze.optionsJson,et.value.optionsJson)||ze.content!==et.value.content);B.current={id:de,directory:n,value:Ue},Ze||h(Ue)};return D?(rt(D.id,yh(D)),()=>{st=!0}):L?(q(B.current?.id!==L.id||B.current.directory!==n),(async()=>{const de=await b(L.id);if(st||ra()!==n)return;q(!1);const Ue=de?.content??"";ae.current.set(G,Ue),rt(L.id,jh(L,Ue))})(),()=>{st=!0}):(B.current=null,h(null),()=>{st=!0})},t[15]=r,t[16]=n,t[17]=G,t[18]=b,t[19]=D,t[20]=L,t[21]=h,t[22]=q,t[23]=_):_=t[23];let z;t[24]!==r||t[25]!==n||t[26]!==G||t[27]!==b||t[28]!==D||t[29]!==L||t[30]!==h?(z=[D,L,b,h,r,n,G],t[24]=r,t[25]=n,t[26]=G,t[27]=b,t[28]=D,t[29]=L,t[30]=h,t[31]=z):z=t[31],l.useEffect(_,z);let te;t[32]!==r||t[33]!==n||t[34]!==m||t[35]!==G||t[36]!==D||t[37]!==L||t[38]!==e||t[39]!==f||t[40]!==p?(te=async()=>{if(!m||!r||ra()!==n)return Us;if(D&&m.mode==="entry"){const st=m.spec.trim();if(st===D.spec&&Xl(m.optionsJson,ro(D.options)))return Us;if(!st)return xs(e("settings.plugins.validation.specRequired"));const de=oo(m.optionsJson);if(!de.ok)return xs(e("settings.plugins.page.field.options.invalidJson"));const Ue=await f(D.id,{spec:st,options:de.value});return Ue.ok?Ue.reloadFailed?xs(Ue.warning||Ue.message||e("settings.plugins.toast.reloadFailed")):Tn:xs(Ue.message||e("settings.plugins.toast.reloadFailed"))}if(L&&m.mode==="file"){const st=ae.current.get(G)??"";if(m.content===st)return Us;const rt=await p(L.id,{content:m.content});return rt.ok?(ae.current.set(G,m.content),rt.reloadFailed?xs(rt.warning||rt.message||e("settings.plugins.toast.reloadFailed")):Tn):xs(rt.message||e("settings.plugins.toast.reloadFailed"))}return Us},t[32]=r,t[33]=n,t[34]=m,t[35]=G,t[36]=D,t[37]=L,t[38]=e,t[39]=f,t[40]=p,t[41]=te):te=t[41];const X=ni(te);let pe;t[42]!==v||t[43]!==k||t[44]!==S||t[45]!==N||t[46]!==A||t[47]!==e?(pe=async()=>{if(!S)return;A(!0);const st=S.kind==="entry"?await v(S.id):await k(S.id);st.ok?U.success(st.message||e("settings.plugins.sidebar.toast.deleted",{name:S.label})):U.error(e("settings.plugins.sidebar.toast.deleteFailed")),N(null),A(!1)},t[42]=v,t[43]=k,t[44]=S,t[45]=N,t[46]=A,t[47]=e,t[48]=pe):pe=t[48];const je=pe;let fe;t[49]!==u||t[50]!==y?(fe=s.jsx(Qf,{open:u,onOpenChange:y}),t[49]=u,t[50]=y,t[51]=fe):fe=t[51];const ke=S!==null;let be;t[52]!==w||t[53]!==N?(be=st=>{!st&&!w&&N(null)},t[52]=w,t[53]=N,t[54]=be):be=t[54];let De;t[55]!==e?(De=e("settings.plugins.sidebar.deleteDialog.title"),t[55]=e,t[56]=De):De=t[56];let oe;t[57]!==De?(oe=s.jsx(Ht,{children:De}),t[57]=De,t[58]=oe):oe=t[58];const ee=S?.label??"";let ce;t[59]!==e||t[60]!==ee?(ce=e("settings.plugins.sidebar.deleteDialog.description",{name:ee}),t[59]=e,t[60]=ee,t[61]=ce):ce=t[61];let ue;t[62]!==ce?(ue=s.jsx(qt,{children:ce}),t[62]=ce,t[63]=ue):ue=t[63];let Ie;t[64]!==oe||t[65]!==ue?(Ie=s.jsxs(Vt,{children:[oe,ue]}),t[64]=oe,t[65]=ue,t[66]=Ie):Ie=t[66];let ve;t[67]!==N?(ve=()=>N(null),t[67]=N,t[68]=ve):ve=t[68];let Re;t[69]!==e?(Re=e("settings.common.actions.cancel"),t[69]=e,t[70]=Re):Re=t[70];let Me;t[71]!==w||t[72]!==ve||t[73]!==Re?(Me=s.jsx(V,{size:"sm",variant:"ghost",onClick:ve,disabled:w,children:Re}),t[71]=w,t[72]=ve,t[73]=Re,t[74]=Me):Me=t[74];let me;t[75]!==je?(me=()=>{je()},t[75]=je,t[76]=me):me=t[76];let Te;t[77]!==w||t[78]!==e?(Te=e(w?"settings.plugins.sidebar.actions.deleting":"settings.common.actions.delete"),t[77]=w,t[78]=e,t[79]=Te):Te=t[79];let Oe;t[80]!==w||t[81]!==me||t[82]!==Te?(Oe=s.jsx(V,{size:"sm",variant:"destructive",onClick:me,disabled:w,children:Te}),t[80]=w,t[81]=me,t[82]=Te,t[83]=Oe):Oe=t[83];let ge;t[84]!==Me||t[85]!==Oe?(ge=s.jsxs(as,{children:[Me,Oe]}),t[84]=Me,t[85]=Oe,t[86]=ge):ge=t[86];let xe;t[87]!==Ie||t[88]!==ge?(xe=s.jsxs($t,{className:"max-w-md",children:[Ie,ge]}),t[87]=Ie,t[88]=ge,t[89]=xe):xe=t[89];let ne;t[90]!==ke||t[91]!==be||t[92]!==xe?(ne=s.jsx(_t,{open:ke,onOpenChange:be,children:xe}),t[90]=ke,t[91]=be,t[92]=xe,t[93]=ne):ne=t[93];let ie;t[94]!==fe||t[95]!==ne?(ie=s.jsxs(s.Fragment,{children:[fe,ne]}),t[94]=fe,t[95]=ne,t[96]=ie):ie=t[96];const he=ie;if(!d){let st;t[97]!==y?(st=()=>y(!0),t[97]=y,t[98]=st):st=t[98];let rt;t[99]!==N||t[100]!==st?(rt=s.jsx(nh,{onAdd:st,onDelete:N}),t[99]=N,t[100]=st,t[101]=rt):rt=t[101];let de;return t[102]!==he||t[103]!==rt?(de=s.jsxs(s.Fragment,{children:[rt,he]}),t[102]=he,t[103]=rt,t[104]=de):de=t[104],de}let Ee;t[105]!==e?(Ee=e("settings.plugins.page.back"),t[105]=e,t[106]=Ee):Ee=t[106];let Ke;t[107]!==C?(Ke=()=>C(null),t[107]=C,t[108]=Ke):Ke=t[108];let Le;t[109]!==Ee||t[110]!==Ke?(Le=s.jsx(tl,{label:Ee,onClick:Ke}),t[109]=Ee,t[110]=Ke,t[111]=Le):Le=t[111];const Se=Le;let $e;t[112]!==D||t[113]!==L||t[114]!==N?($e=()=>{D?N({kind:"entry",id:D.id,label:D.spec}):L&&N({kind:"file",id:L.id,label:L.fileName})},t[112]=D,t[113]=L,t[114]=N,t[115]=$e):$e=t[115];let Ye;t[116]===Symbol.for("react.memo_cache_sentinel")?(Ye=s.jsx($,{name:"delete-bin",className:"size-3.5"}),t[116]=Ye):Ye=t[116];let pt;t[117]!==e?(pt=e("settings.common.actions.delete"),t[117]=e,t[118]=pt):pt=t[118];let vt;t[119]!==$e||t[120]!==pt?(vt=s.jsxs(V,{variant:"ghost",size:"xs",className:"!font-normal text-[var(--status-error)] hover:text-[var(--status-error)]",onClick:$e,children:[Ye,pt]}),t[119]=$e,t[120]=pt,t[121]=vt):vt=t[121];const wt=vt;if(D&&m&&m.mode==="entry"){let st;t[122]!==m.optionsJson?(st=oo(m.optionsJson),t[122]=m.optionsJson,t[123]=st):st=t[123];const de=st.ok;let Ue;t[124]!==e?(Ue=e("settings.plugins.page.header.entry"),t[124]=e,t[125]=Ue):Ue=t[125];let et;t[126]!==D.scope||t[127]!==e?(et=D.scope==="project"?e("settings.plugins.sidebar.group.projectEntries"):e("settings.plugins.sidebar.group.userEntries"),t[126]=D.scope,t[127]=e,t[128]=et):et=t[128];let ze;t[129]!==D.scope||t[130]!==et?(ze=s.jsx(ec,{scope:D.scope,label:et}),t[129]=D.scope,t[130]=et,t[131]=ze):ze=t[131];const Ze=X.onBlurCapture;let tt;t[132]!==D.spec||t[133]!==j?(tt=s.jsx(Zl,{target:j,name:D.spec}),t[132]=D.spec,t[133]=j,t[134]=tt):tt=t[134];let lt;t[135]!==D.id||t[136]!==D.spec?(lt=s.jsx(xh,{entryId:D.id,spec:D.spec}),t[135]=D.id,t[136]=D.spec,t[137]=lt):lt=t[137];let J;t[138]!==tt||t[139]!==lt?(J=s.jsx(He,{divider:!1,children:s.jsxs("div",{className:"flex flex-col gap-3",children:[tt,lt]})}),t[138]=tt,t[139]=lt,t[140]=J):J=t[140];let nt;t[141]!==e?(nt=e("settings.plugins.page.field.spec"),t[141]=e,t[142]=nt):nt=t[142];const ot=m.spec;let it;t[143]!==m||t[144]!==h?(it=Pe=>h({...m,spec:Pe.target.value}),t[143]=m,t[144]=h,t[145]=it):it=t[145];let ft;t[146]!==e?(ft=e("settings.plugins.page.field.spec.placeholder"),t[146]=e,t[147]=ft):ft=t[147];let xt;t[148]!==m.spec||t[149]!==it||t[150]!==ft?(xt=s.jsx(Ge,{value:ot,onChange:it,placeholder:ft,className:"font-mono typography-meta",spellCheck:!1}),t[148]=m.spec,t[149]=it,t[150]=ft,t[151]=xt):xt=t[151];let ht;t[152]!==nt||t[153]!==xt?(ht=s.jsx(He,{title:nt,settingsItem:"plugins.spec",children:xt}),t[152]=nt,t[153]=xt,t[154]=ht):ht=t[154];let St;t[155]!==e?(St=e("settings.plugins.page.field.options"),t[155]=e,t[156]=St):St=t[156];const At=m.optionsJson;let _e;t[157]!==m||t[158]!==h?(_e=Pe=>h({...m,optionsJson:Pe.target.value}),t[157]=m,t[158]=h,t[159]=_e):_e=t[159];const Xe=!de&&"border-[var(--status-error-border)]";let mt;t[160]!==Xe?(mt=Ne("font-mono typography-meta min-h-[200px]",Xe),t[160]=Xe,t[161]=mt):mt=t[161];let Fe;t[162]!==m.optionsJson||t[163]!==_e||t[164]!==mt?(Fe=s.jsx(Rs,{value:At,onChange:_e,rows:10,className:mt,spellCheck:!1,placeholder:"{ }"}),t[162]=m.optionsJson,t[163]=_e,t[164]=mt,t[165]=Fe):Fe=t[165];let W;t[166]!==de||t[167]!==e?(W=!de&&s.jsx("p",{className:"typography-micro text-[var(--status-error)]",children:e("settings.plugins.page.field.options.invalidJson")}),t[166]=de,t[167]=e,t[168]=W):W=t[168];let ye;t[169]!==St||t[170]!==Fe||t[171]!==W?(ye=s.jsxs(He,{title:St,settingsItem:"plugins.options",children:[Fe,W]}),t[169]=St,t[170]=Fe,t[171]=W,t[172]=ye):ye=t[172];let Ae;t[173]!==X.onBlurCapture||t[174]!==Se||t[175]!==wt||t[176]!==Ue||t[177]!==ze||t[178]!==J||t[179]!==ht||t[180]!==ye?(Ae=s.jsxs(ns,{title:Ue,titleLeading:Se,headerEnd:wt,titleAccessory:ze,onBlurCapture:Ze,children:[J,ht,ye]}),t[173]=X.onBlurCapture,t[174]=Se,t[175]=wt,t[176]=Ue,t[177]=ze,t[178]=J,t[179]=ht,t[180]=ye,t[181]=Ae):Ae=t[181];let Y;return t[182]!==he||t[183]!==Ae?(Y=s.jsxs(s.Fragment,{children:[Ae,he]}),t[182]=he,t[183]=Ae,t[184]=Y):Y=t[184],Y}if(L&&m&&m.mode==="file"){let st;t[185]!==e?(st=e("settings.plugins.page.header.file"),t[185]=e,t[186]=st):st=t[186];let rt;t[187]!==L.scope||t[188]!==e?(rt=L.scope==="project"?e("settings.plugins.sidebar.group.projectFiles"):e("settings.plugins.sidebar.group.userFiles"),t[187]=L.scope,t[188]=e,t[189]=rt):rt=t[189];let de;t[190]!==L.scope||t[191]!==rt?(de=s.jsx(ec,{scope:L.scope,label:rt}),t[190]=L.scope,t[191]=rt,t[192]=de):de=t[192];let Ue;t[193]===Symbol.for("react.memo_cache_sentinel")?(Ue=Ne("typography-micro font-mono rounded-full px-2 py-0.5","bg-[var(--surface-elevated)] text-foreground","border border-[var(--interactive-border)]"),t[193]=Ue):Ue=t[193];let et;t[194]!==L.fileName?(et=s.jsx("span",{className:Ue,children:L.fileName}),t[194]=L.fileName,t[195]=et):et=t[195];let ze;t[196]!==de||t[197]!==et?(ze=s.jsxs(s.Fragment,{children:[de,et]}),t[196]=de,t[197]=et,t[198]=ze):ze=t[198];const Ze=X.onBlurCapture;let tt;t[199]!==L.fileName||t[200]!==K?(tt=s.jsx(He,{divider:!1,children:s.jsx(Zl,{target:K,name:L.fileName})}),t[199]=L.fileName,t[200]=K,t[201]=tt):tt=t[201];let lt;t[202]!==e?(lt=e("settings.plugins.page.field.content"),t[202]=e,t[203]=lt):lt=t[203];let J;t[204]!==m||t[205]!==h?(J=ht=>h({...m,content:ht.target.value}),t[204]=m,t[205]=h,t[206]=J):J=t[206];let nt;t[207]!==X?(nt=ht=>{ht.key==="Enter"&&(ht.metaKey||ht.ctrlKey)&&(ht.preventDefault(),X.requestSave())},t[207]=X,t[208]=nt):nt=t[208];let ot;t[209]!==m.content||t[210]!==H||t[211]!==J||t[212]!==nt?(ot=s.jsx(Rs,{value:m.content,onChange:J,onKeyDown:nt,rows:16,className:"font-mono typography-meta min-h-[320px]",spellCheck:!1,disabled:H}),t[209]=m.content,t[210]=H,t[211]=J,t[212]=nt,t[213]=ot):ot=t[213];let it;t[214]!==lt||t[215]!==ot?(it=s.jsx(He,{title:lt,settingsItem:"plugins.content",children:ot}),t[214]=lt,t[215]=ot,t[216]=it):it=t[216];let ft;t[217]!==X.onBlurCapture||t[218]!==Se||t[219]!==wt||t[220]!==st||t[221]!==ze||t[222]!==tt||t[223]!==it?(ft=s.jsxs(ns,{title:st,titleLeading:Se,headerEnd:wt,titleAccessory:ze,onBlurCapture:Ze,children:[tt,it]}),t[217]=X.onBlurCapture,t[218]=Se,t[219]=wt,t[220]=st,t[221]=ze,t[222]=tt,t[223]=it,t[224]=ft):ft=t[224];let xt;return t[225]!==he||t[226]!==ft?(xt=s.jsxs(s.Fragment,{children:[ft,he]}),t[225]=he,t[226]=ft,t[227]=xt):xt=t[227],xt}let yt;return t[228]===Symbol.for("react.memo_cache_sentinel")?(yt=s.jsx("div",{className:"flex h-full items-center justify-center",children:s.jsx("div",{className:"text-center text-muted-foreground",children:s.jsx($,{name:"loader-4",className:"mx-auto mb-3 h-6 w-6 animate-spin opacity-50"})})}),t[228]=yt):yt=t[228],yt};function wh(t){return t.getActiveProject()?.path}function Nh(t){return t.loadedDirectory}function Sh(t){return t.loadedRuntimeKey}function Ch(t){return t.selectedId}function Ih(t){return t.entries}function Ph(t){return t.files}function Ah(t){return t.draft}function Th(t){return t.setDraft}function Eh(t){return t.updateEntry}function Dh(t){return t.updateFile}function Mh(t){return t.readFile}function Rh(t){return t.setSelected}function Oh(t){return t.deleteEntry}function Lh(t){return t.deleteFile}function Fh(){zt.getState().setSelected(null)}function Kh(){return Fh}const zh="<built-in>",bi=t=>t?.path===zh,Sr=t=>!!t&&!bi(t)&&t.renamable===!0,Uh=t=>{const e=Be.c(166),{onItemSelect:a}=t,{t:n}=qe(),[i,o]=l.useState(""),[r,d]=l.useState(null),[c,g]=l.useState(""),[m,h]=l.useState(null),[f,p]=l.useState(!1),[b,C]=l.useState(null),{selectedSkillName:v,setSelectedSkill:k,setSkillDraft:u,deleteSkill:y,renameSkill:S,getSkillDetail:N}=rn(_s(_h)),w=en();let A;e[0]!==w?(A=Fe=>Or(Fe,w),e[0]=w,e[1]=A):A=e[1];const x=rn(A),T=rn($h);let M,E;e[2]!==T||e[3]!==w?(M=()=>{T(w)},E=[T,w],e[2]=T,e[3]=w,e[4]=M,e[5]=E):(M=e[4],E=e[5]),l.useEffect(M,E);let D;e[6]!==a||e[7]!==k||e[8]!==u||e[9]!==x?(D=()=>{let Fe="new-skill",W=1;for(;x.some(ye=>ye.name===Fe);)Fe=`new-skill-${W}`,W++;u({name:Fe,scope:"user",source:"opencode",description:""}),k(Fe),a?.()},e[6]=a,e[7]=k,e[8]=u,e[9]=x,e[10]=D):D=e[10];const F=D;let L;e[11]===Symbol.for("react.memo_cache_sentinel")?(L=async Fe=>{bi(Fe)||h(Fe)},e[11]=L):L=e[11];const P=L;let j;e[12]!==m||e[13]!==y||e[14]!==w||e[15]!==n?(j=async()=>{if(!m)return;if(bi(m)){h(null);return}p(!0),await y(m.name,w)?(U.success(n("settings.skills.sidebar.toast.skillDeleted",{name:m.name})),h(null)):U.error(n("settings.skills.sidebar.toast.deleteSkillFailed")),p(!1)},e[12]=m,e[13]=y,e[14]=w,e[15]=n,e[16]=j):j=e[16];const O=j;let K;e[17]!==N||e[18]!==k||e[19]!==u||e[20]!==w||e[21]!==x||e[22]!==n?(K=async Fe=>{if(bi(Fe))return;const W=Fe.name;let ye=1,Ae=`${W}-copy`;for(;x.some(Pe=>Pe.name===Ae);)ye++,Ae=`${W}-copy-${ye}`;const Y=await N(Fe.name,w);if(!Y){U.error(n("settings.skills.sidebar.toast.duplicateLoadFailed"));return}u({name:Ae,scope:Fe.scope||"user",source:Fe.source||"opencode",description:(Y.sources.md.fields.includes("description"),""),instructions:""}),k(Ae)},e[17]=N,e[18]=k,e[19]=u,e[20]=w,e[21]=x,e[22]=n,e[23]=K):K=e[23];const H=K;let q;e[24]===Symbol.for("react.memo_cache_sentinel")?(q=Fe=>{Sr(Fe)&&(g(Fe.name),d(Fe))},e[24]=q):q=e[24];const Z=q;let ae;e[25]!==r||e[26]!==c||e[27]!==S||e[28]!==k||e[29]!==w||e[30]!==x||e[31]!==n?(ae=async()=>{if(!r)return;if(!Sr(r)){d(null);return}const Fe=c.trim().replace(/\s+/g,"-").toLowerCase();if(!Fe){U.error(n("settings.skills.page.toast.skillNameRequired"));return}if(Fe===r.name){d(null);return}if(x.some(ye=>ye.name===Fe)){U.error(n("settings.skills.page.toast.skillExists"));return}await S(r.name,Fe,w)?(U.success(n("settings.skills.sidebar.toast.skillRenamed",{name:Fe})),k(Fe)):U.error(n("settings.skills.sidebar.toast.renameFailed")),d(null)},e[25]=r,e[26]=c,e[27]=S,e[28]=k,e[29]=w,e[30]=x,e[31]=n,e[32]=ae):ae=e[32];const B=ae;let G,_,z;if(e[33]!==i||e[34]!==x){let Fe;e[38]!==i?(Fe=W=>go([W.name,W.description],i),e[38]=i,e[39]=Fe):Fe=e[39],_=x.filter(Fe),G=_.filter(Bh),z=_.filter(Vh),e[33]=i,e[34]=x,e[35]=G,e[36]=_,e[37]=z}else G=e[35],_=e[36],z=e[37];const te=z;let Q;e[40]===Symbol.for("react.memo_cache_sentinel")?(Q=function(W){const ye={},Ae=[];for(const Pe of W)Pe.group?(ye[Pe.group]||(ye[Pe.group]=[]),ye[Pe.group].push(Pe)):Ae.push(Pe);const Y=Object.keys(ye).sort(Hh).map(Pe=>({name:Pe,skills:[...ye[Pe]].sort(qh)}));return Ae.sort(Gh),{sortedGroups:Y,ungrouped:Ae}},e[40]=Q):Q=e[40];const X=Q;let pe;e[41]!==G?(pe=X(G),e[41]=G,e[42]=pe):pe=e[42];const je=pe;let fe;e[43]!==te?(fe=X(te),e[43]=te,e[44]=fe):fe=e[44];const ke=fe;let be;e[45]===Symbol.for("react.memo_cache_sentinel")?(be=Ne("flex h-full flex-col","bg-background"),e[45]=be):be=e[45];let De;e[46]!==n?(De=n("settings.skills.sidebar.title"),e[46]=n,e[47]=De):De=e[47];let oe;e[48]!==De?(oe=s.jsx("h2",{className:`${va} mb-3`,children:De}),e[48]=De,e[49]=oe):oe=e[49];let ee;e[50]===Symbol.for("react.memo_cache_sentinel")?(ee=s.jsx(Ni,{className:"mb-3"}),e[50]=ee):ee=e[50];let ce;e[51]!==x.length||e[52]!==n?(ce=n("settings.skills.sidebar.total",{count:x.length}),e[51]=x.length,e[52]=n,e[53]=ce):ce=e[53];let ue;e[54]!==ce?(ue=s.jsx("span",{className:"typography-meta text-muted-foreground",children:ce}),e[54]=ce,e[55]=ue):ue=e[55];let Ie;e[56]===Symbol.for("react.memo_cache_sentinel")?(Ie=s.jsx($,{name:"add",className:"h-3.5 w-3.5"}),e[56]=Ie):Ie=e[56];let ve;e[57]!==F?(ve=s.jsx(V,{size:"sm","data-settings-item":"skills.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:F,children:Ie}),e[57]=F,e[58]=ve):ve=e[58];let Re;e[59]!==ue||e[60]!==ve?(Re=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[ue,ve]}),e[59]=ue,e[60]=ve,e[61]=Re):Re=e[61];let Me;e[62]!==i||e[63]!==x.length?(Me=x.length>0?s.jsx(Wr,{value:i,onChange:o}):null,e[62]=i,e[63]=x.length,e[64]=Me):Me=e[64];let me;e[65]!==oe||e[66]!==Re||e[67]!==Me?(me=s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[oe,ee,Re,Me]}),e[65]=oe,e[66]=Re,e[67]=Me,e[68]=me):me=e[68];let Te;e[69]!==je||e[70]!==ke||e[71]!==H||e[72]!==a||e[73]!==b||e[74]!==G||e[75]!==i||e[76]!==v||e[77]!==k||e[78]!==_||e[79]!==x.length||e[80]!==n||e[81]!==te?(Te=s.jsx(Ds,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:x.length===0?s.jsxs("div",{className:"py-12 px-4 text-center text-muted-foreground",children:[s.jsx($,{name:"book-open",className:"mx-auto mb-3 h-10 w-10 opacity-50"}),s.jsx("p",{className:"typography-ui-label font-medium",children:n("settings.skills.sidebar.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:n("settings.skills.sidebar.empty.description")})]}):_.length===0?s.jsx(Jr,{query:i}):s.jsxs(s.Fragment,{children:[G.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:n("settings.skills.sidebar.section.project")}),je.sortedGroups.map(Fe=>{const{name:W,skills:ye}=Fe;return s.jsx(yr,{label:W,count:ye.length,storageKey:"project-skills",children:ye.map(Ae=>s.jsx(Vi,{skill:Ae,isSelected:v===Ae.name,onSelect:()=>{k(Ae.name),a?.()},onRename:()=>Z(Ae),onDelete:()=>P(Ae),onDuplicate:()=>H(Ae),isMenuOpen:b===Ae.name,onMenuOpenChange:Y=>C(Y?Ae.name:null)},Ae.name))},W)}),je.ungrouped.map(Fe=>s.jsx(Vi,{skill:Fe,isSelected:v===Fe.name,onSelect:()=>{k(Fe.name),a?.()},onRename:()=>Z(Fe),onDelete:()=>P(Fe),onDuplicate:()=>H(Fe),isMenuOpen:b===Fe.name,onMenuOpenChange:W=>C(W?Fe.name:null)},Fe.name))]}),te.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-2 pb-1.5 pt-3 text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:n("settings.skills.sidebar.section.user")}),ke.sortedGroups.map(Fe=>{const{name:W,skills:ye}=Fe;return s.jsx(yr,{label:W,count:ye.length,storageKey:"user-skills",children:ye.map(Ae=>s.jsx(Vi,{skill:Ae,isSelected:v===Ae.name,onSelect:()=>{k(Ae.name),a?.()},onRename:()=>Z(Ae),onDelete:()=>P(Ae),onDuplicate:()=>H(Ae),isMenuOpen:b===Ae.name,onMenuOpenChange:Y=>C(Y?Ae.name:null)},Ae.name))},W)}),ke.ungrouped.map(Fe=>s.jsx(Vi,{skill:Fe,isSelected:v===Fe.name,onSelect:()=>{k(Fe.name),a?.()},onRename:()=>Z(Fe),onDelete:()=>P(Fe),onDuplicate:()=>H(Fe),isMenuOpen:b===Fe.name,onMenuOpenChange:W=>C(W?Fe.name:null)},Fe.name))]})]})}),e[69]=je,e[70]=ke,e[71]=H,e[72]=a,e[73]=b,e[74]=G,e[75]=i,e[76]=v,e[77]=k,e[78]=_,e[79]=x.length,e[80]=n,e[81]=te,e[82]=Te):Te=e[82];const Oe=m!==null;let ge;e[83]!==f?(ge=Fe=>{!Fe&&!f&&h(null)},e[83]=f,e[84]=ge):ge=e[84];let xe;e[85]!==n?(xe=n("settings.skills.sidebar.deleteDialog.title"),e[85]=n,e[86]=xe):xe=e[86];let ne;e[87]!==xe?(ne=s.jsx(Ht,{children:xe}),e[87]=xe,e[88]=ne):ne=e[88];const ie=m?.name??"";let he;e[89]!==n||e[90]!==ie?(he=n("settings.skills.sidebar.deleteDialog.description",{name:ie}),e[89]=n,e[90]=ie,e[91]=he):he=e[91];let Ee;e[92]!==he?(Ee=s.jsx(qt,{children:he}),e[92]=he,e[93]=Ee):Ee=e[93];let Ke;e[94]!==ne||e[95]!==Ee?(Ke=s.jsxs(Vt,{children:[ne,Ee]}),e[94]=ne,e[95]=Ee,e[96]=Ke):Ke=e[96];let Le;e[97]===Symbol.for("react.memo_cache_sentinel")?(Le=()=>h(null),e[97]=Le):Le=e[97];let Se;e[98]!==n?(Se=n("settings.common.actions.cancel"),e[98]=n,e[99]=Se):Se=e[99];let $e;e[100]!==f||e[101]!==Se?($e=s.jsx(V,{size:"sm",className:"text-foreground hover:bg-interactive-hover hover:text-foreground",variant:"ghost",onClick:Le,disabled:f,children:Se}),e[100]=f,e[101]=Se,e[102]=$e):$e=e[102];let Ye;e[103]!==n?(Ye=n("settings.common.actions.delete"),e[103]=n,e[104]=Ye):Ye=e[104];let pt;e[105]!==O||e[106]!==f||e[107]!==Ye?(pt=s.jsx(V,{size:"sm",onClick:O,disabled:f,children:Ye}),e[105]=O,e[106]=f,e[107]=Ye,e[108]=pt):pt=e[108];let vt;e[109]!==$e||e[110]!==pt?(vt=s.jsxs(as,{children:[$e,pt]}),e[109]=$e,e[110]=pt,e[111]=vt):vt=e[111];let wt;e[112]!==Ke||e[113]!==vt?(wt=s.jsxs($t,{className:"max-w-md",children:[Ke,vt]}),e[112]=Ke,e[113]=vt,e[114]=wt):wt=e[114];let yt;e[115]!==Oe||e[116]!==ge||e[117]!==wt?(yt=s.jsx(_t,{open:Oe,onOpenChange:ge,children:wt}),e[115]=Oe,e[116]=ge,e[117]=wt,e[118]=yt):yt=e[118];const st=r!==null;let rt;e[119]===Symbol.for("react.memo_cache_sentinel")?(rt=Fe=>!Fe&&d(null),e[119]=rt):rt=e[119];let de;e[120]!==n?(de=n("settings.skills.sidebar.renameDialog.title"),e[120]=n,e[121]=de):de=e[121];let Ue;e[122]!==de?(Ue=s.jsx(Ht,{children:de}),e[122]=de,e[123]=Ue):Ue=e[123];const et=r?.name??"";let ze;e[124]!==n||e[125]!==et?(ze=n("settings.skills.sidebar.renameDialog.description",{name:et}),e[124]=n,e[125]=et,e[126]=ze):ze=e[126];let Ze;e[127]!==ze?(Ze=s.jsx(qt,{children:ze}),e[127]=ze,e[128]=Ze):Ze=e[128];let tt;e[129]!==Ue||e[130]!==Ze?(tt=s.jsxs(Vt,{children:[Ue,Ze]}),e[129]=Ue,e[130]=Ze,e[131]=tt):tt=e[131];let lt;e[132]===Symbol.for("react.memo_cache_sentinel")?(lt=Fe=>g(Fe.target.value),e[132]=lt):lt=e[132];let J;e[133]!==n?(J=n("settings.skills.sidebar.renameDialog.placeholder"),e[133]=n,e[134]=J):J=e[134];let nt;e[135]!==B?(nt=Fe=>{Fe.key==="Enter"&&B()},e[135]=B,e[136]=nt):nt=e[136];let ot;e[137]!==c||e[138]!==J||e[139]!==nt?(ot=s.jsx(Ge,{value:c,onChange:lt,placeholder:J,className:"text-foreground placeholder:text-muted-foreground",onKeyDown:nt}),e[137]=c,e[138]=J,e[139]=nt,e[140]=ot):ot=e[140];let it;e[141]===Symbol.for("react.memo_cache_sentinel")?(it=()=>d(null),e[141]=it):it=e[141];let ft;e[142]!==n?(ft=n("settings.common.actions.cancel"),e[142]=n,e[143]=ft):ft=e[143];let xt;e[144]!==ft?(xt=s.jsx(V,{size:"sm",className:"text-foreground hover:bg-interactive-hover hover:text-foreground",variant:"ghost",onClick:it,children:ft}),e[144]=ft,e[145]=xt):xt=e[145];let ht;e[146]!==n?(ht=n("settings.common.actions.rename"),e[146]=n,e[147]=ht):ht=e[147];let St;e[148]!==B||e[149]!==ht?(St=s.jsx(V,{size:"sm",onClick:B,children:ht}),e[148]=B,e[149]=ht,e[150]=St):St=e[150];let At;e[151]!==xt||e[152]!==St?(At=s.jsxs(as,{children:[xt,St]}),e[151]=xt,e[152]=St,e[153]=At):At=e[153];let _e;e[154]!==tt||e[155]!==ot||e[156]!==At?(_e=s.jsxs($t,{children:[tt,ot,At]}),e[154]=tt,e[155]=ot,e[156]=At,e[157]=_e):_e=e[157];let Xe;e[158]!==st||e[159]!==_e?(Xe=s.jsx(_t,{open:st,onOpenChange:rt,children:_e}),e[158]=st,e[159]=_e,e[160]=Xe):Xe=e[160];let mt;return e[161]!==me||e[162]!==Te||e[163]!==yt||e[164]!==Xe?(mt=s.jsxs("div",{className:be,children:[me,Te,yt,Xe]}),e[161]=me,e[162]=Te,e[163]=yt,e[164]=Xe,e[165]=mt):mt=e[165],mt},Vi=t=>{const e=Be.c(41),{skill:a,isSelected:n,onSelect:i,onDelete:o,onRename:r,onDuplicate:d,isMenuOpen:c,onMenuOpenChange:g}=t,{t:m}=qe();let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=Mr(),e[0]=h):h=e[0];const f=h;let p;e[1]!==a?(p=bi(a),e[1]=a,e[2]=p):p=e[2];const b=p;let C;e[3]!==a?(C=Sr(a),e[3]=a,e[4]=C):C=e[4];const v=C,[k,u]=l.useState(!1);let y;e[5]!==v||e[6]!==o||e[7]!==d||e[8]!==r||e[9]!==m?(y=O=>s.jsxs(s.Fragment,{children:[v?s.jsxs(O,{onClick:K=>{K.stopPropagation(),r()},children:[s.jsx($,{name:"edit",className:"h-4 w-4 mr-px"}),m("settings.common.actions.rename")]}):null,s.jsxs(O,{onClick:K=>{K.stopPropagation(),d()},children:[s.jsx($,{name:"file-copy",className:"h-4 w-4 mr-px"}),m("settings.common.actions.duplicate")]}),s.jsxs(O,{onClick:K=>{K.stopPropagation(),o()},className:"text-destructive focus:text-destructive",children:[s.jsx($,{name:"delete-bin",className:"h-4 w-4 mr-px"}),m("settings.common.actions.delete")]})]}),e[5]=v,e[6]=o,e[7]=d,e[8]=r,e[9]=m,e[10]=y):y=e[10];const S=y,N=!b&&k,w=n?"bg-interactive-selection":"hover:bg-interactive-hover";let A;e[11]!==w?(A=Ne("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",w),e[11]=w,e[12]=A):A=e[12];let x;e[13]!==b?(x=!f&&!b?O=>{O.preventDefault(),u(!0)}:void 0,e[13]=b,e[14]=x):x=e[14];let T;e[15]!==A||e[16]!==x?(T=s.jsx("div",{className:A,onContextMenu:x}),e[15]=A,e[16]=x,e[17]=T):T=e[17];let M;e[18]!==a.name?(M=s.jsx("div",{className:"flex items-center gap-1.5",children:s.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:a.name})}),e[18]=a.name,e[19]=M):M=e[19];let E;e[20]!==i||e[21]!==M?(E=s.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-ring",tabIndex:0,children:M}),e[20]=i,e[21]=M,e[22]=E):E=e[22];let D;e[23]!==b||e[24]!==c||e[25]!==g||e[26]!==S?(D=b?null:s.jsxs(Jn,{open:c,onOpenChange:O=>{O&&u(!1),g(O)},children:[s.jsx(Wn,{asChild:!0,children:s.jsx(V,{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:s.jsx($,{name:"more-2",className:"h-3.5 w-3.5"})})}),s.jsx(Gn,{align:"end",className:"w-fit min-w-20",children:S(xn)})]}),e[23]=b,e[24]=c,e[25]=g,e[26]=S,e[27]=D):D=e[27];let F;e[28]!==E||e[29]!==D?(F=s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[E,D]}),e[28]=E,e[29]=D,e[30]=F):F=e[30];let L;e[31]!==F||e[32]!==T?(L=s.jsx(ti,{render:T,children:F}),e[31]=F,e[32]=T,e[33]=L):L=e[33];let P;e[34]!==b||e[35]!==S?(P=b?null:s.jsx(Xa,{className:"w-fit min-w-20",children:S(ei)}),e[34]=b,e[35]=S,e[36]=P):P=e[36];let j;return e[37]!==L||e[38]!==P||e[39]!==N?(j=s.jsxs(si,{open:N,onOpenChange:u,children:[L,P]}),e[37]=L,e[38]=P,e[39]=N,e[40]=j):j=e[40],j};function _h(t){return{selectedSkillName:t.selectedSkillName,setSelectedSkill:t.setSelectedSkill,setSkillDraft:t.setSkillDraft,deleteSkill:t.deleteSkill,renameSkill:t.renameSkill,getSkillDetail:t.getSkillDetail}}function $h(t){return t.loadSkills}function Bh(t){return t.scope==="project"}function Vh(t){return t.scope==="user"}function Hh(t,e){return t.localeCompare(e)}function qh(t,e){return t.name.localeCompare(e.name)}function Gh(t,e){return t.name.localeCompare(e.name)}const Wh=()=>`custom:${Date.now()}-${Math.random().toString(16).slice(2)}`,Jh=t=>{const e=t.trim(),a=e.startsWith("https://")?"https":e.startsWith("git@")?"ssh":"shorthand";if(a==="ssh")return`${e.split(":")[1].replace(/\.git$/i,"")}`;if(a==="https")return e.split("/").slice(3).filter(Boolean).join("/").replace(/\.git$/i,"");const n=e.match(/^([^/\s]+)\/([^/\s]+)(?:\/.+)?$/);return n?`${n[1]}/${n[2].replace(/\.git$/i,"")}`:e},Qh=({open:t,onOpenChange:e})=>{const{t:a}=qe(),n=zn(P=>P.scanRepo),i=zn(P=>P.loadCatalog),o=zn(P=>P.loadSource),r=zn(P=>P.setSelectedSource),d=zn(P=>P.isScanning),c=ua(P=>P.defaultGitIdentityId),g=ua(P=>P.loadDefaultGitIdentityId),[m,h]=l.useState(""),[f,p]=l.useState(""),[b,C]=l.useState(""),[v,k]=l.useState(null),[u,y]=l.useState(null),[S,N]=l.useState(!1),[w,A]=l.useState([]),[x,T]=l.useState(null),M=l.useRef(0),E=l.useCallback(P=>{M.current+=1,N(!1),y(null),P?.clearIdentity&&(A([]),T(null))},[]);l.useEffect(()=>{t&&(M.current+=1,h(""),p(""),C(""),y(null),N(!1),A([]),T(null),g(),k(null),(async()=>{const P=await En();k(P?P.skillCatalogs??[]:null)})())},[t,g]);const D=l.useMemo(()=>{const P=f.trim(),j=b.trim();return(v??[]).some(O=>{const K=(O.source||"").trim(),H=(O.subpath||"").trim();return K===P&&H===j})},[v,f,b]),F=async()=>{const P=f.trim();if(!P){U.error(a("settings.skills.catalog.add.toast.repositoryRequired"));return}m.trim()||h(Jh(P)),N(!1),y(null);const j=M.current+1;M.current=j;const O=await n({source:P,subpath:b.trim()||void 0,gitIdentityId:x||void 0});if(M.current!==j)return;if(!O.ok){if(O.error?.kind==="authRequired"){if(ps()){U.error(a("settings.skills.catalog.shared.toast.privateRepoNotSupportedVsCode"));return}const H=O.error.identities||[];if(A(H),!x&&H.length>0){const q=c&&c!=="global"&&H.some(Z=>Z.id===c)?c:H[0].id;T(q)}U.error(a("settings.skills.catalog.add.toast.authenticationRequiredScan"));return}U.error(O.error?.message||a("settings.skills.catalog.add.toast.scanFailed"));return}const K=O.items?.length||0;if(y(K),K===0){U.error(a("settings.skills.catalog.add.toast.noSkillsFound")),N(!1);return}A([]),N(!0),U.success(a("settings.skills.catalog.shared.toast.foundSkills",{count:K}))},L=async()=>{const P=m.trim(),j=f.trim(),O=b.trim();if(!P){U.error(a("settings.skills.catalog.add.toast.catalogNameRequired"));return}if(!j){U.error(a("settings.skills.catalog.add.toast.repositoryRequired"));return}if(!S){U.error(a("settings.skills.catalog.add.toast.scanBeforeAdd"));return}if(D){U.error(a("settings.skills.catalog.add.toast.catalogAlreadyExists"));return}const K={id:Wh(),label:P,source:j,...O?{subpath:O}:{},...x?{gitIdentityId:x}:{}};if(v===null){U.error(a("settings.skills.catalog.add.toast.saveFailed"));return}const H=[...v,K];try{if(!(await kt({skillCatalogs:H})).ok)throw new Error(a("settings.skills.catalog.add.toast.saveFailed"));k(H),U.success(a("settings.skills.catalog.add.toast.catalogAdded")),await i({refresh:!0}),await o(K.id,{refresh:!0}),r(K.id),e(!1)}catch(q){U.error(q instanceof Error?q.message:a("settings.skills.catalog.add.toast.saveFailed"))}};return s.jsx(_t,{open:t,onOpenChange:e,children:s.jsxs($t,{className:"max-w-xl",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:a("settings.skills.catalog.add.title")}),s.jsxs(qt,{children:[a("settings.skills.catalog.add.descriptionPrefix")," ",s.jsx("code",{className:"font-mono",children:"SKILL.md"}),a("settings.skills.catalog.add.descriptionSuffix")]})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"typography-ui-label text-foreground",children:a("settings.skills.catalog.add.field.catalogName")}),s.jsx(Ge,{value:m,onChange:P=>h(P.target.value),placeholder:a("settings.skills.catalog.add.field.catalogNamePlaceholder")})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("label",{className:"typography-ui-label text-foreground",children:a("settings.skills.catalog.add.field.repository")}),s.jsx(Gt,{children:a("settings.skills.catalog.add.field.repositoryHint")})]}),s.jsx(Ge,{value:f,onChange:P=>{p(P.target.value),E({clearIdentity:!0})},placeholder:a("settings.skills.catalog.shared.field.repositoryPlaceholder")})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsx("label",{className:"typography-ui-label text-foreground",children:a("settings.skills.catalog.add.field.optionalSubpath")}),s.jsx(Ge,{value:b,onChange:P=>{C(P.target.value),E({clearIdentity:!0})},placeholder:a("settings.skills.catalog.shared.field.subpathPlaceholder")})]}),w.length>0&&!ps()?s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center",children:[s.jsx("span",{className:"typography-ui-label text-[var(--status-warning)]",children:a("settings.skills.catalog.shared.auth.title")}),s.jsx("span",{className:"typography-meta text-muted-foreground ml-2",children:a("settings.skills.catalog.shared.auth.description")}),s.jsx(Gt,{className:"ml-1",children:a("settings.skills.catalog.shared.auth.footerHint")})]}),s.jsxs(Dt,{value:x||"",onValueChange:P=>{T(P),E()},children:[s.jsx(Tt,{className:"w-fit",children:s.jsx("span",{children:w.find(P=>P.id===x)?.name||a("settings.skills.catalog.shared.auth.chooseIdentity")})}),s.jsx(Et,{align:"start",children:w.map(P=>s.jsx(gt,{value:P.id,children:P.name},P.id))})]})]}):null,u!==null?s.jsx("div",{className:"typography-meta text-muted-foreground",children:a("settings.skills.catalog.add.scanResult",{count:u})}):null,D?s.jsx("div",{className:"typography-meta text-muted-foreground",children:a("settings.skills.catalog.add.duplicateMessage")}):null]}),s.jsxs(as,{children:[s.jsx(V,{size:"sm",variant:"ghost",onClick:()=>e(!1),children:a("settings.common.actions.cancel")}),s.jsxs(V,{size:"sm",className:"gap-2",variant:"ghost",onClick:()=>{F()},disabled:d||!f.trim(),children:[s.jsx($,{name:"git-repository",className:"h-4 w-4"}),a(d?"settings.skills.catalog.shared.actions.scanning":"settings.skills.catalog.shared.actions.scan")]}),s.jsx(V,{size:"sm",onClick:()=>{L()},disabled:!S||D||v===null||!m.trim()||!f.trim(),children:a("settings.skills.catalog.add.actions.addCatalog")})]})]})})},Yh=t=>{const e=Be.c(85),{open:a,onOpenChange:n,conflicts:i,onConfirm:o}=t,{t:r}=qe();let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={},e[0]=d):d=e[0];const[c,g]=l.useState(d);let m,h;e[1]!==i||e[2]!==a?(m=()=>{if(!a)return;const Q={};for(const X of i)Q[X.skillName]="skip";g(Q)},h=[a,i],e[1]=i,e[2]=a,e[3]=m,e[4]=h):(m=e[3],h=e[4]),l.useEffect(m,h);let f;e[5]!==i?(f=Q=>{const X={};for(const pe of i)X[pe.skillName]=Q;g(X)},e[5]=i,e[6]=f):f=e[6];const p=f;let b;e[7]!==i||e[8]!==c?(b=i.length>0&&i.every(Q=>c[Q.skillName]),e[7]=i,e[8]=c,e[9]=b):b=e[9];const C=b;let v;e[10]!==r?(v=r("settings.skills.catalog.conflicts.title"),e[10]=r,e[11]=v):v=e[11];let k;e[12]!==v?(k=s.jsx(Ht,{children:v}),e[12]=v,e[13]=k):k=e[13];let u;e[14]!==r?(u=r("settings.skills.catalog.conflicts.description"),e[14]=r,e[15]=u):u=e[15];let y;e[16]!==u?(y=s.jsx(qt,{children:u}),e[16]=u,e[17]=y):y=e[17];let S;e[18]!==k||e[19]!==y?(S=s.jsxs(Vt,{children:[k,y]}),e[18]=k,e[19]=y,e[20]=S):S=e[20];let N;e[21]!==i.length||e[22]!==r?(N=r("settings.skills.catalog.conflicts.count",{count:i.length}),e[21]=i.length,e[22]=r,e[23]=N):N=e[23];let w;e[24]!==N?(w=s.jsx("span",{className:"typography-meta text-muted-foreground",children:N}),e[24]=N,e[25]=w):w=e[25];let A;e[26]!==p?(A=()=>p("skip"),e[26]=p,e[27]=A):A=e[27];let x;e[28]!==r?(x=r("settings.skills.catalog.conflicts.actions.skipAll"),e[28]=r,e[29]=x):x=e[29];let T;e[30]!==A||e[31]!==x?(T=s.jsx(V,{variant:"outline",size:"xs",className:"!font-normal",onClick:A,children:x}),e[30]=A,e[31]=x,e[32]=T):T=e[32];let M;e[33]!==p?(M=()=>p("overwrite"),e[33]=p,e[34]=M):M=e[34];let E;e[35]!==r?(E=r("settings.skills.catalog.conflicts.actions.overwriteAll"),e[35]=r,e[36]=E):E=e[36];let D;e[37]!==M||e[38]!==E?(D=s.jsx(V,{variant:"outline",size:"xs",className:"!font-normal",onClick:M,children:E}),e[37]=M,e[38]=E,e[39]=D):D=e[39];let F;e[40]!==T||e[41]!==D?(F=s.jsxs("div",{className:"flex items-center gap-2",children:[T,D]}),e[40]=T,e[41]=D,e[42]=F):F=e[42];let L;e[43]!==w||e[44]!==F?(L=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[w,F]}),e[43]=w,e[44]=F,e[45]=L):L=e[45];let P;if(e[46]!==i||e[47]!==c||e[48]!==r){let Q;e[50]!==c||e[51]!==r?(Q=X=>s.jsxs("div",{className:"flex items-center justify-between gap-3 py-1.5",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"typography-ui-label truncate",children:X.skillName}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:r("settings.skills.catalog.conflicts.installedIn",{scope:X.scope==="project"?r("settings.skills.catalog.conflicts.scope.project"):r("settings.skills.catalog.conflicts.scope.user"),source:X.source==="agents"?r("settings.skills.catalog.conflicts.source.agents"):r("settings.skills.catalog.conflicts.source.opencode")})})]}),s.jsxs(Dt,{value:c[X.skillName]||"skip",onValueChange:pe=>g(je=>({...je,[X.skillName]:pe})),children:[s.jsx(Tt,{className:"w-fit",children:s.jsx("span",{className:"capitalize",children:(c[X.skillName]||"skip")==="overwrite"?r("settings.skills.catalog.conflicts.decision.overwrite"):r("settings.skills.catalog.conflicts.decision.skip")})}),s.jsxs(Et,{align:"end",children:[s.jsx(gt,{value:"skip",className:"pr-2 [&>span:first-child]:hidden",children:r("settings.skills.catalog.conflicts.decision.skip")}),s.jsx(gt,{value:"overwrite",className:"pr-2 [&>span:first-child]:hidden",children:r("settings.skills.catalog.conflicts.decision.overwrite")})]})]})]},X.skillName),e[50]=c,e[51]=r,e[52]=Q):Q=e[52],P=i.map(Q),e[46]=i,e[47]=c,e[48]=r,e[49]=P}else P=e[49];let j;e[53]!==P?(j=s.jsx("div",{className:"space-y-2",children:P}),e[53]=P,e[54]=j):j=e[54];let O;e[55]!==L||e[56]!==j?(O=s.jsxs("div",{className:"space-y-3",children:[L,j]}),e[55]=L,e[56]=j,e[57]=O):O=e[57];let K;e[58]!==n?(K=()=>n(!1),e[58]=n,e[59]=K):K=e[59];let H;e[60]!==r?(H=r("settings.common.actions.cancel"),e[60]=r,e[61]=H):H=e[61];let q;e[62]!==K||e[63]!==H?(q=s.jsx(V,{size:"sm",variant:"ghost",onClick:K,children:H}),e[62]=K,e[63]=H,e[64]=q):q=e[64];let Z;e[65]!==c||e[66]!==o?(Z=()=>o(c),e[65]=c,e[66]=o,e[67]=Z):Z=e[67];const ae=!C;let B;e[68]!==r?(B=r("settings.skills.catalog.conflicts.actions.continue"),e[68]=r,e[69]=B):B=e[69];let G;e[70]!==Z||e[71]!==ae||e[72]!==B?(G=s.jsx(V,{size:"sm",onClick:Z,disabled:ae,children:B}),e[70]=Z,e[71]=ae,e[72]=B,e[73]=G):G=e[73];let _;e[74]!==q||e[75]!==G?(_=s.jsxs(as,{children:[q,G]}),e[74]=q,e[75]=G,e[76]=_):_=e[76];let z;e[77]!==S||e[78]!==O||e[79]!==_?(z=s.jsxs($t,{className:"max-w-2xl",children:[S,O,_]}),e[77]=S,e[78]=O,e[79]=_,e[80]=z):z=e[80];let te;return e[81]!==n||e[82]!==a||e[83]!==z?(te=s.jsx(_t,{open:a,onOpenChange:n,children:z}),e[81]=n,e[82]=a,e[83]=z,e[84]=te):te=e[84],te},sl=[{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 vi(t,e){return t==="project"&&e==="claude"?"project-claude":t==="project"&&e==="agents"?"project-agents":e==="claude"?"user-claude":t==="project"?"project-opencode":e==="agents"?"user-agents":"user-opencode"}function Rd(t){if(t==="user-claude")return{scope:"user",source:"claude"};if(t==="project-claude")return{scope:"project",source:"claude"};const e=sl.find(a=>a.value===t);return e?{scope:e.scope,source:e.source}:{scope:"user",source:"opencode"}}const Zh=t=>{const e=Be.c(124),{open:a,onOpenChange:n,item:i}=t,{t:o}=qe(),r=zn(Xh),d=zn(ex),[c,g]=l.useState("user"),[m,h]=l.useState("opencode"),f=hn(tx),p=hn(sx),[b,C]=l.useState(null),[v,k]=l.useState(!1);let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=[],e[0]=u):u=e[0];const[y,S]=l.useState(u),[N,w]=l.useState(null);let A,x;e[1]!==p||e[2]!==a?(A=()=>{a&&(g("user"),h("opencode"),C(p),k(!1),S([]),w(null))},x=[a,p],e[1]=p,e[2]=a,e[3]=A,e[4]=x):(A=e[3],x=e[4]),l.useEffect(A,x);let T;e[5]!==o?(T=Se=>{switch(Se){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")}},e[5]=o,e[6]=T):T=e[6];const M=T;let E;e[7]!==o?(E=Se=>{switch(Se){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")}},e[7]=o,e[8]=E):E=e[8];const D=E;let F;e:{if(f.length===0){F=null;break e}if(b&&f.some(Se=>Se.id===b)){F=b;break e}if(p&&f.some(Se=>Se.id===p)){F=p;break e}F=f[0]?.id??null}const L=F;let P;e:{if(c!=="project"){P=null;break e}const Se=L;if(!Se){P=null;break e}let $e;if(e[9]!==Se||e[10]!==f){let pt;e[12]!==Se?(pt=vt=>vt.id===Se,e[12]=Se,e[13]=pt):pt=e[13],$e=f.find(pt),e[9]=Se,e[10]=f,e[11]=$e}else $e=e[11];P=$e?.path??null}const j=P;let O;e[14]!==r||e[15]!==i?.gitIdentityId||e[16]!==n||e[17]!==o?(O=async Se=>{const $e=await r({source:Se.source,subpath:Se.subpath,gitIdentityId:i?.gitIdentityId,scope:Se.scope,targetSource:Se.targetSource,selections:[{skillDir:Se.skillDir}],conflictPolicy:"prompt",conflictDecisions:Se.conflictDecisions},{directory:Se.directoryOverride??null});if($e.ok){U.success(o("settings.skills.catalog.installSkill.toast.installed")),n(!1);return}if($e.error?.kind==="conflicts"){w({source:Se.source,subpath:Se.subpath,scope:Se.scope,targetSource:Se.targetSource,skillDir:Se.skillDir,directoryOverride:Se.directoryOverride??null}),S($e.error.conflicts),k(!0);return}if($e.error?.kind==="authRequired"){U.error($e.error.message||o("settings.skills.catalog.installSkill.toast.authRequired"));return}U.error($e.error?.message||o("settings.skills.catalog.installSkill.toast.installFailed"))},e[14]=r,e[15]=i?.gitIdentityId,e[16]=n,e[17]=o,e[18]=O):O=e[18];const K=O;if(!i)return null;let H;e[19]!==o?(H=o("settings.skills.catalog.installSkill.title"),e[19]=o,e[20]=H):H=e[20];let q;e[21]!==H?(q=s.jsx(Ht,{children:H}),e[21]=H,e[22]=q):q=e[22];let Z;e[23]!==o?(Z=o("settings.skills.catalog.installSkill.descriptionPrefix"),e[23]=o,e[24]=Z):Z=e[24];let ae;e[25]!==i.skillName?(ae=s.jsx("span",{className:"font-semibold text-foreground",children:i.skillName}),e[25]=i.skillName,e[26]=ae):ae=e[26];let B;e[27]!==o?(B=o("settings.skills.catalog.installSkill.descriptionSuffix"),e[27]=o,e[28]=B):B=e[28];let G;e[29]!==Z||e[30]!==ae||e[31]!==B?(G=s.jsxs(qt,{children:[Z," ",ae," ",B]}),e[29]=Z,e[30]=ae,e[31]=B,e[32]=G):G=e[32];let _;e[33]!==q||e[34]!==G?(_=s.jsxs(Vt,{children:[q,G]}),e[33]=q,e[34]=G,e[35]=_):_=e[35];let z;e[36]!==o?(z=o("settings.skills.catalog.installSkill.field.destination"),e[36]=o,e[37]=z):z=e[37];let te;e[38]!==z?(te=s.jsx("span",{className:"typography-ui-label text-foreground",children:z}),e[38]=z,e[39]=te):te=e[39];let Q;e[40]!==c||e[41]!==m?(Q=vi(c,m),e[40]=c,e[41]=m,e[42]=Q):Q=e[42];let X;e[43]===Symbol.for("react.memo_cache_sentinel")?(X=Se=>{const $e=Rd(Se);g($e.scope),h($e.source==="agents"?"agents":"opencode")},e[43]=X):X=e[43];let pe;e[44]!==c?(pe=c==="user"?s.jsx($,{name:"user-3",className:"h-3.5 w-3.5"}):s.jsx($,{name:"folder",className:"h-3.5 w-3.5"}),e[44]=c,e[45]=pe):pe=e[45];let je;e[46]!==m?(je=m==="agents"?s.jsx($,{name:"robot-2",className:"h-3.5 w-3.5"}):null,e[46]=m,e[47]=je):je=e[47];let fe;e[48]!==M||e[49]!==c||e[50]!==m?(fe=M(vi(c,m)),e[48]=M,e[49]=c,e[50]=m,e[51]=fe):fe=e[51];let ke;e[52]!==fe?(ke=s.jsx("span",{children:fe}),e[52]=fe,e[53]=ke):ke=e[53];let be;e[54]!==pe||e[55]!==je||e[56]!==ke?(be=s.jsxs(Tt,{className:"w-fit gap-1.5",children:[pe,je,ke]}),e[54]=pe,e[55]=je,e[56]=ke,e[57]=be):be=e[57];let De;e[58]!==D||e[59]!==M?(De=sl.map(Se=>s.jsx(gt,{value:Se.value,className:"pr-2 [&>span:first-child]:hidden",children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[Se.scope==="user"?s.jsx($,{name:"user-3",className:"h-3.5 w-3.5"}):s.jsx($,{name:"folder",className:"h-3.5 w-3.5"}),Se.source==="agents"?s.jsx($,{name:"robot-2",className:"h-3.5 w-3.5"}):null,s.jsx("span",{children:M(Se.value)})]}),s.jsx("span",{className:"typography-micro text-muted-foreground ml-5",children:D(Se.value)})]})},Se.value)),e[58]=D,e[59]=M,e[60]=De):De=e[60];let oe;e[61]!==De?(oe=s.jsx(Et,{align:"start",children:De}),e[61]=De,e[62]=oe):oe=e[62];let ee;e[63]!==Q||e[64]!==be||e[65]!==oe?(ee=s.jsxs(Dt,{value:Q,onValueChange:X,children:[be,oe]}),e[63]=Q,e[64]=be,e[65]=oe,e[66]=ee):ee=e[66];let ce;e[67]!==te||e[68]!==ee?(ce=s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[te,ee]}),e[67]=te,e[68]=ee,e[69]=ce):ce=e[69];let ue;e[70]!==f||e[71]!==L||e[72]!==c||e[73]!==o?(ue=c==="project"&&s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:o("settings.skills.catalog.installSkill.field.project")}),f.length===0?s.jsx("span",{className:"typography-meta text-muted-foreground",children:o("settings.skills.catalog.installSkill.field.noProjects")}):s.jsxs(Dt,{value:L??"",onValueChange:Se=>C(Se),disabled:f.length===1,children:[s.jsx(Tt,{className:"w-fit",children:s.jsx(Jt,{placeholder:o("settings.skills.catalog.installSkill.field.chooseProjectPlaceholder")})}),s.jsx(Et,{align:"start",children:f.map(nx)})]})]}),e[70]=f,e[71]=L,e[72]=c,e[73]=o,e[74]=ue):ue=e[74];let Ie;e[75]!==i.warnings?(Ie=i.warnings?.length?s.jsx("div",{className:"typography-micro text-[var(--status-warning)] bg-[var(--status-warning)]/10 px-2 py-1.5 rounded",children:i.warnings.join(" · ")}):null,e[75]=i.warnings,e[76]=Ie):Ie=e[76];let ve;e[77]!==ce||e[78]!==ue||e[79]!==Ie?(ve=s.jsxs("div",{className:"mt-2 space-y-3",children:[ce,ue,Ie]}),e[77]=ce,e[78]=ue,e[79]=Ie,e[80]=ve):ve=e[80];let Re;e[81]!==n?(Re=()=>n(!1),e[81]=n,e[82]=Re):Re=e[82];let Me;e[83]!==o?(Me=o("settings.common.actions.cancel"),e[83]=o,e[84]=Me):Me=e[84];let me;e[85]!==Re||e[86]!==Me?(me=s.jsx(V,{size:"sm",variant:"ghost",onClick:Re,children:Me}),e[85]=Re,e[86]=Me,e[87]=me):me=e[87];const Te=d||!i.installable||c==="project"&&!j;let Oe;e[88]!==j||e[89]!==K||e[90]!==i.repoSource||e[91]!==i.repoSubpath||e[92]!==i.skillDir||e[93]!==c||e[94]!==m?(Oe=()=>{K({source:i.repoSource,subpath:i.repoSubpath,scope:c,targetSource:m,skillDir:i.skillDir,directoryOverride:j})},e[88]=j,e[89]=K,e[90]=i.repoSource,e[91]=i.repoSubpath,e[92]=i.skillDir,e[93]=c,e[94]=m,e[95]=Oe):Oe=e[95];let ge;e[96]!==d||e[97]!==o?(ge=o(d?"settings.skills.catalog.installSkill.actions.installing":"settings.skills.catalog.installSkill.actions.install"),e[96]=d,e[97]=o,e[98]=ge):ge=e[98];let xe;e[99]!==Te||e[100]!==Oe||e[101]!==ge?(xe=s.jsx(V,{size:"sm",disabled:Te,onClick:Oe,children:ge}),e[99]=Te,e[100]=Oe,e[101]=ge,e[102]=xe):xe=e[102];let ne;e[103]!==me||e[104]!==xe?(ne=s.jsxs(as,{children:[me,xe]}),e[103]=me,e[104]=xe,e[105]=ne):ne=e[105];let ie;e[106]!==_||e[107]!==ve||e[108]!==ne?(ie=s.jsxs($t,{className:"max-w-md",children:[_,ve,ne]}),e[106]=_,e[107]=ve,e[108]=ne,e[109]=ie):ie=e[109];let he;e[110]!==n||e[111]!==a||e[112]!==ie?(he=s.jsx(_t,{open:a,onOpenChange:n,children:ie}),e[110]=n,e[111]=a,e[112]=ie,e[113]=he):he=e[113];let Ee;e[114]!==N||e[115]!==K?(Ee=Se=>{N&&(K({source:N.source,subpath:N.subpath,scope:N.scope,targetSource:N.targetSource,skillDir:N.skillDir,conflictDecisions:Se,directoryOverride:N.directoryOverride??null}),k(!1))},e[114]=N,e[115]=K,e[116]=Ee):Ee=e[116];let Ke;e[117]!==y||e[118]!==v||e[119]!==Ee?(Ke=s.jsx(Yh,{open:v,onOpenChange:k,conflicts:y,onConfirm:Ee}),e[117]=y,e[118]=v,e[119]=Ee,e[120]=Ke):Ke=e[120];let Le;return e[121]!==he||e[122]!==Ke?(Le=s.jsxs(s.Fragment,{children:[he,Ke]}),e[121]=he,e[122]=Ke,e[123]=Le):Le=e[123],Le};function Xh(t){return t.installSkills}function ex(t){return t.isInstalling}function tx(t){return t.projects}function sx(t){return t.activeProjectId}function nx(t){return s.jsx(gt,{value:t.id,children:t.label||t.path},t.id)}const ax=/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/,ix=t=>{const e=t.trim();return ax.test(e)?`https://github.com/${e}`:null},ox=t=>{const e=ix(t.repoSource);if(!e)return null;const a=[t.repoSubpath,t.skillDir].filter(Boolean).join("/");return a?`${e}/tree/HEAD/${a}`:e};let Hi=null;const rx=t=>{const e=zr();return(!Hi||Hi.locale!==e)&&(Hi={locale:e,formatter:new Intl.NumberFormat(e,{notation:"compact"})}),Hi.formatter.format(t)},lx=t=>{const e=Date.parse(t);if(Number.isNaN(e))return null;const a=Date.now()-e;if(a<6e4)return{key:"common.relative.justNow",count:0};const n=Math.floor(a/6e4);if(n<60)return{key:"common.relative.minutesAgoShort",count:n};const i=Math.floor(n/60);if(i<24)return{key:"common.relative.hoursAgoShort",count:i};const o=Math.floor(i/24);if(o<7)return{key:"common.relative.daysAgoShort",count:o};const r=Math.floor(o/7);return r<52?{key:"common.relative.weeksAgoShort",count:r}:{key:"common.relative.yearsAgoShort",count:Math.floor(o/365)}},cx=t=>{const e=Be.c(50),{source:a,isActive:n,isLoading:i,skillsCount:o,onSelect:r,t:d}=t,c=a.stars??null;let g,m,h,f,p,b,C,v,k,u;if(e[0]!==n||e[1]!==i||e[2]!==r||e[3]!==o||e[4]!==a.label||e[5]!==a.repoUpdatedAt||e[6]!==a.source||e[7]!==c||e[8]!==d){const w=a.repoUpdatedAt?lx(a.repoUpdatedAt):null;v="button",k=r,u=n;const A=n?"border-border bg-interactive-selection text-interactive-selection-foreground":"border-border hover:border-interactive-border-hover";e[19]!==A?(m=Ne("oc-surface-elevated w-full min-h-24 text-left rounded-lg border bg-surface-elevated p-3.5 flex gap-3 items-start transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",A),e[19]=A,e[20]=m):m=e[20],p="min-w-0 flex-1 block";let x;e[21]!==a.label?(x=s.jsx("span",{className:"typography-ui-label font-medium text-foreground truncate",children:a.label}),e[21]=a.label,e[22]=x):x=e[22];let T;e[23]!==i||e[24]!==o||e[25]!==d?(T=i?s.jsx($,{name:"refresh",className:"h-3 w-3 animate-spin text-muted-foreground shrink-0"}):o!==null&&s.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:d("settings.skills.catalog.page.source.skillsCount",{count:o})}),e[23]=i,e[24]=o,e[25]=d,e[26]=T):T=e[26],e[27]!==x||e[28]!==T?(b=s.jsxs("span",{className:"flex items-center gap-2",children:[x,T]}),e[27]=x,e[28]=T,e[29]=b):b=e[29],e[30]!==a.source?(C=s.jsx("span",{className:"typography-micro font-mono text-muted-foreground block mt-0.5 truncate",children:a.source}),e[30]=a.source,e[31]=C):C=e[31],g="flex items-center gap-3 mt-1",e[32]!==c||e[33]!==d?(h=c!==null&&s.jsxs("span",{className:"typography-micro text-muted-foreground flex items-center gap-1",title:d("settings.skills.catalog.page.source.stars",{count:c}),children:[s.jsx($,{name:"star",className:"h-3 w-3"}),rx(c)]}),e[32]=c,e[33]=d,e[34]=h):h=e[34],f=w&&s.jsx("span",{className:"typography-micro text-muted-foreground",children:w.key==="common.relative.justNow"?d(w.key):d("settings.skills.catalog.page.source.updated",{time:d(w.key,{count:w.count})})}),e[0]=n,e[1]=i,e[2]=r,e[3]=o,e[4]=a.label,e[5]=a.repoUpdatedAt,e[6]=a.source,e[7]=c,e[8]=d,e[9]=g,e[10]=m,e[11]=h,e[12]=f,e[13]=p,e[14]=b,e[15]=C,e[16]=v,e[17]=k,e[18]=u}else g=e[9],m=e[10],h=e[11],f=e[12],p=e[13],b=e[14],C=e[15],v=e[16],k=e[17],u=e[18];let y;e[35]!==g||e[36]!==h||e[37]!==f?(y=s.jsxs("span",{className:g,children:[h,f]}),e[35]=g,e[36]=h,e[37]=f,e[38]=y):y=e[38];let S;e[39]!==y||e[40]!==p||e[41]!==b||e[42]!==C?(S=s.jsxs("span",{className:p,children:[b,C,y]}),e[39]=y,e[40]=p,e[41]=b,e[42]=C,e[43]=S):S=e[43];let N;return e[44]!==m||e[45]!==S||e[46]!==v||e[47]!==k||e[48]!==u?(N=s.jsx("button",{type:v,onClick:k,"aria-pressed":u,className:m,children:S}),e[44]=m,e[45]=S,e[46]=v,e[47]=k,e[48]=u,e[49]=N):N=e[49],N},dx=({mode:t,onModeChange:e,showModeTabs:a=!0})=>{const{t:n}=qe(),{sources:i,itemsBySource:o,selectedSourceId:r,setSelectedSource:d,loadCatalog:c,loadSource:g,isLoadingCatalog:m,isLoadingSource:h,loadedSourceIds:f,lastCatalogError:p}=zn(_s(K=>({sources:K.sources,itemsBySource:K.itemsBySource,selectedSourceId:K.selectedSourceId,setSelectedSource:K.setSelectedSource,loadCatalog:K.loadCatalog,loadSource:K.loadSource,isLoadingCatalog:K.isLoadingCatalog,isLoadingSource:K.isLoadingSource,loadedSourceIds:K.loadedSourceIds,lastCatalogError:K.lastCatalogError}))),[b,C]=l.useState(""),[v,k]=l.useState(!1),[u,y]=l.useState(!1),[S,N]=l.useState(null),[w,A]=l.useState(!1),[x,T]=l.useState(!1),M=l.useRef(null);l.useEffect(()=>{c()},[c]),l.useEffect(()=>{const K=i.filter(Z=>!f[Z.id]);if(K.length===0)return;let H=!1;return(async()=>{for(const Z of K){if(H)return;await g(Z.id)}})(),()=>{H=!0}},[i,f,g]),l.useEffect(()=>{!r||f[r]||g(r)},[r,f,g]),l.useEffect(()=>{const K=H=>{(H.metaKey||H.ctrlKey)&&H.key.toLowerCase()==="k"&&(H.preventDefault(),M.current?.focus())};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[]);const E=b.trim().length>0,D=l.useMemo(()=>E?sa(i.flatMap(K=>o[K.id]||[]),b,K=>[K.skillName,K.frontmatterName,K.description]):r?o[r]||[]:[],[i,o,r,b,E]),F=l.useMemo(()=>i.find(K=>K.id===r)||null,[i,r]),L=!!(r&&r.startsWith("custom:")),P=async()=>{if(!(!r||!L)){A(!0);try{const K=await En();if(!K)return;const q=(K.skillCatalogs??[]).filter(Z=>Z.id!==r);await kt({skillCatalogs:q}),await c({refresh:!0}),T(!1)}finally{A(!1)}}},j=E?n("settings.skills.catalog.page.list.searchTitle"):F?.label??"",O=!E&&r!==null&&!f[r]&&(h||m);return s.jsxs(s.Fragment,{children:[s.jsxs(ns,{title:n("settings.skills.catalog.page.title"),showSaveStatus:!1,children:[a&&s.jsx("div",{className:"mb-4",children:s.jsx("div",{className:"h-10",children:s.jsx(Hr,{items:[{id:"manual",label:n("settings.skills.catalog.page.mode.manual")},{id:"external",label:n("settings.skills.catalog.page.mode.external")}],activeId:t,onSelect:K=>e(K),layoutMode:"fit",variant:"animated",animateActivePill:!1,className:"h-full"})})}),s.jsx("p",{className:"typography-meta text-muted-foreground mb-4",children:n("settings.skills.catalog.page.subtitle")}),s.jsx("div",{"data-settings-item":"skills.catalog.search",className:"mb-5",children:s.jsxs("div",{className:"relative max-w-md",children:[s.jsx($,{name:"search",className:"absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),s.jsx(Ge,{ref:M,value:b,onChange:K=>C(K.target.value),placeholder:n("settings.skills.catalog.page.searchAllPlaceholder"),className:Ne("h-8 pl-8 w-full",b&&"pr-8")}),b&&s.jsx("button",{type:"button",onClick:()=>{C(""),M.current?.focus()},className:"absolute right-2 top-1/2 -translate-y-1/2 flex items-center justify-center h-4 w-4 rounded text-muted-foreground hover:text-foreground transition-colors",title:n("settings.skills.catalog.page.search.clear"),children:s.jsx($,{name:"close",className:"h-3 w-3"})})]})}),s.jsx(He,{title:n("settings.skills.catalog.page.section.sources"),divider:!1,settingsItem:"skills.catalog.source",contentClassName:"space-y-0",children:s.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 py-1.5",children:[i.map(K=>s.jsx(cx,{source:K,isActive:K.id===r,isLoading:h&&!f[K.id],skillsCount:f[K.id]?(o[K.id]||[]).length:null,onSelect:()=>d(K.id),t:n},K.id)),s.jsxs("button",{type:"button","data-settings-item":"skills.catalog.add-catalog",onClick:()=>k(!0),className:"min-h-24 text-left rounded-lg border border-dashed border-[var(--interactive-border)] hover:border-[var(--interactive-border-hover)] hover:bg-[var(--surface-muted)] p-3.5 flex gap-3 items-start transition-colors",children:[s.jsx("span",{className:"flex items-center justify-center rounded-md bg-transparent text-muted-foreground w-8 h-8 shrink-0",children:s.jsx($,{name:"add",className:"h-4 w-4"})}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"typography-ui-label text-muted-foreground block",children:n("settings.skills.catalog.page.source.addOwnTitle")}),s.jsx("span",{className:"typography-micro text-muted-foreground/70 block mt-0.5",children:n("settings.skills.catalog.page.source.addOwnDescription")})]})]})]})}),p&&s.jsx(He,{children:s.jsxs("div",{className:"rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-4 py-3",children:[s.jsx("div",{className:"typography-ui-label font-medium text-[var(--status-error)]",children:n("settings.skills.catalog.page.error.catalogTitle")}),s.jsx("div",{className:"typography-meta text-[var(--status-error)]/80 mt-1",children:p.message})]})}),s.jsxs(He,{children:[s.jsxs("div",{className:"flex items-center justify-between gap-2 pb-2",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("span",{className:"typography-micro font-medium uppercase tracking-wide text-muted-foreground truncate",children:j}),s.jsx("span",{className:"typography-micro text-muted-foreground/70 shrink-0",children:n("settings.skills.catalog.page.foundCount",{count:D.length})})]}),s.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[s.jsx(V,{variant:"ghost",size:"xs",className:"!font-normal h-6 w-6 px-0",onClick:()=>{r&&!E?g(r,{refresh:!0}):c({refresh:!0})},disabled:m||h,title:n("settings.skills.catalog.page.actions.refreshTitle"),children:s.jsx($,{name:"refresh",className:Ne("h-3.5 w-3.5",(m||h)&&"animate-spin")})}),L&&!E&&s.jsx(V,{variant:"ghost",size:"xs",className:"!font-normal h-6 w-6 px-0 text-[var(--status-error)] hover:text-[var(--status-error)]",onClick:()=>T(!0),disabled:w,title:n("settings.skills.catalog.page.actions.removeCatalogTitle"),children:s.jsx($,{name:"delete-bin",className:"h-3.5 w-3.5"})})]})]}),O||h&&D.length===0?s.jsxs("div",{className:"py-8 text-center text-muted-foreground",children:[s.jsx($,{name:"refresh",className:"mx-auto mb-3 h-5 w-5 animate-spin opacity-50"}),s.jsx("p",{className:"typography-meta",children:n("settings.skills.catalog.page.loading.skills")})]}):D.length===0?s.jsxs("div",{className:"py-8 text-center text-muted-foreground",children:[s.jsx("p",{className:"typography-body",children:n("settings.skills.catalog.page.empty.noSkillsTitle")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:n("settings.skills.catalog.page.empty.noSkillsDescription")})]}):s.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:D.map(K=>{const H=K.installed?.isInstalled,q=K.installed?.scope,Z=ox(K);return s.jsx("div",{className:"py-2",children:s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"typography-ui-label font-medium text-foreground truncate",children:K.skillName}),H&&s.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:n("settings.skills.catalog.page.badge.installed",{scope:q||n("settings.skills.catalog.page.badge.unknown")})}),!K.installable&&s.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:n("settings.skills.catalog.page.badge.notInstallable")})]}),K.description?s.jsx("div",{className:"typography-meta text-muted-foreground mt-0.5 line-clamp-2",children:K.description}):s.jsx("div",{className:"typography-meta text-muted-foreground/50 mt-0.5 italic",children:n("settings.skills.catalog.shared.noDescription")}),s.jsxs("div",{className:"typography-micro text-muted-foreground/80 mt-1 flex items-center gap-2 min-w-0",children:[Z?s.jsxs("a",{href:Z,target:"_blank",rel:"noreferrer",className:"font-mono hover:underline truncate inline-flex items-center gap-1",title:n("settings.skills.catalog.page.skill.viewOnGithub"),children:[s.jsx($,{name:"github",className:"h-3 w-3 shrink-0"}),K.repoSource]}):s.jsx("span",{className:"font-mono truncate",children:K.repoSource}),K.skillDir&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"opacity-40",children:"·"}),s.jsx("span",{className:"truncate",children:K.skillDir})]})]}),K.warnings?.length?s.jsx("div",{className:"typography-micro text-[var(--status-warning)] mt-1.5 bg-[var(--status-warning)]/10 px-2 py-1 rounded w-fit",children:K.warnings.join(" · ")}):null]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[Z&&s.jsx(V,{variant:"ghost",size:"xs",className:"!font-normal h-6 w-6 px-0",onClick:()=>window.open(Z,"_blank","noreferrer"),title:n("settings.skills.catalog.page.skill.viewOnGithub"),children:s.jsx($,{name:"external-link",className:"h-3.5 w-3.5"})}),H?s.jsx("span",{className:"text-[var(--status-success)] flex items-center justify-center w-7 h-7",title:n("settings.skills.catalog.page.badge.installed",{scope:q||""}),children:s.jsx($,{name:"check",className:"h-4 w-4"})}):s.jsx(V,{variant:"outline",size:"xs",className:"!font-normal",disabled:!K.installable,onClick:()=>{N(K),y(!0)},children:n("settings.skills.catalog.shared.actions.install")})]})]})},`${K.sourceId}:${K.skillDir}`)})})]})]}),s.jsx(Qh,{open:v,onOpenChange:k}),s.jsx(Zh,{open:u,onOpenChange:y,item:S}),s.jsx(_t,{open:x,onOpenChange:K=>{w||T(K)},children:s.jsxs($t,{className:"max-w-md",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:n("settings.skills.catalog.page.removeDialog.title")}),s.jsx(qt,{children:n("settings.skills.catalog.page.removeDialog.description")})]}),s.jsxs(as,{children:[s.jsx(V,{size:"sm",variant:"ghost",onClick:()=>T(!1),disabled:w,children:n("settings.common.actions.cancel")}),s.jsx(V,{size:"sm",variant:"destructive",onClick:()=>{P()},disabled:w,children:n("settings.skills.catalog.page.actions.removeCatalog")})]})]})})]})},ux=()=>{const t=Be.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(dx,{mode:"external",onModeChange:xx,showModeTabs:!1}),t[0]=e):e=t[0],e},mx="SKILL.md",px="h-[clamp(320px,58dvh,680px)] min-h-[260px] max-h-[calc(100dvh-220px)]",Zi=(t,e)=>{const a=kp({description:t}).trimEnd(),n=e.trimStart();return`---
|
|
23
|
-
${a}
|
|
24
|
-
---${n?`
|
|
25
|
-
|
|
26
|
-
${n}`:`
|
|
27
|
-
`}`},gx=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),Od=t=>{const e=t.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)([\s\S]*)$/);if(!e)return{description:null,instructions:t};let a=null;try{const n=wp(e[1]);if(gx(n)){const i=n.description;typeof i=="string"&&(a=i)}}catch{a=null}return{description:a,instructions:e[2].replace(/^\r?\n/,"")}},fx=(t,e)=>{const a=Od(t);return Zi(e,a.instructions)},hx=()=>{const{t}=qe(),{currentTheme:e}=ba(),{selectedSkillName:a,getSkillByName:n,getSkillDetail:i,createSkill:o,updateSkill:r,skillDraft:d,setSkillDraft:c,setSelectedSkill:g}=rn(_s(de=>({selectedSkillName:de.selectedSkillName,getSkillByName:de.getSkillByName,getSkillDetail:de.getSkillDetail,createSkill:de.createSkill,updateSkill:de.updateSkill,skillDraft:de.skillDraft,setSkillDraft:de.setSkillDraft,setSelectedSkill:de.setSelectedSkill}))),m=en(),h=rn(de=>Or(de,m)),f=a?n(a,m):null,p=!!(d&&d.name===a&&!f),b=!!(a&&!f&&!d),C=f?.path==="<built-in>";l.useEffect(()=>{b&&g(null)},[b,g]);const[v,k]=l.useState(""),[u,y]=l.useState("user"),[S,N]=l.useState("opencode"),[w,A]=l.useState(""),[x,T]=l.useState(""),[M,E]=l.useState(()=>Zi("","")),[D,F]=l.useState("edit"),[L,P]=l.useState([]),[j,O]=l.useState([]),[K,H]=l.useState(!1),[q,Z]=l.useState(!1),[ae,B]=l.useState(""),[G,_]=l.useState(""),[z,te]=l.useState(!1),[Q,X]=l.useState(""),[pe,je]=l.useState(""),[fe,ke]=l.useState(null),[be,De]=l.useState(!1),[oe,ee]=l.useState(""),[ce,ue]=l.useState(null),[Ie,ve]=l.useState(!1),Re=fe?pe!==oe:Q.trim()!=="",Me=l.useCallback(de=>{switch(de){case"project-opencode":return t("settings.skills.location.option.projectOpencode.label");case"user-claude":return t("settings.skills.location.option.userClaude.label");case"project-claude":return t("settings.skills.location.option.projectClaude.label");case"user-agents":return t("settings.skills.location.option.userAgents.label");case"project-agents":return t("settings.skills.location.option.projectAgents.label");default:return t("settings.skills.location.option.userOpencode.label")}},[t]),me=l.useCallback(de=>{switch(de){case"project-opencode":return t("settings.skills.location.option.projectOpencode.description");case"user-claude":return t("settings.skills.location.option.userClaude.description");case"project-claude":return t("settings.skills.location.option.projectClaude.description");case"user-agents":return t("settings.skills.location.option.userAgents.description");case"project-agents":return t("settings.skills.location.option.projectAgents.description");default:return t("settings.skills.location.option.userOpencode.description")}},[t]),Te=JSON.stringify([m,a,f?.path,p]),Oe=l.useRef(null),ge=l.useRef({key:Te,markdown:M});ge.current={key:Te,markdown:M};const xe=l.useRef("");l.useEffect(()=>{let de=!1;const Ue=(ze,Ze)=>{if(ge.current.key!==Te)return;const tt=Zi(ze,Ze),lt=Oe.current===Te&&ge.current.markdown!==xe.current;Oe.current=Te,xe.current=tt,lt||(A(ze),T(Ze),E(tt))};return(async()=>{if(p&&d){Z(!1);const ze=d.description||"",Ze=d.instructions||"";k(d.name||""),y(d.scope||"user"),N(d.source==="agents"?"agents":"opencode"),Ue(ze,Ze),B(""),_(""),P([]),O(d.pendingFiles||[])}else if(a&&f){Z(Oe.current!==Te);try{const ze=await i(a,m);if(!de&&ge.current.key===Te&&ze){const Ze=ze.sources.md,tt=Ze.description||"",lt=Ze.instructions||"";Ue(tt,lt),B(tt),_(lt),P(Ze.supportingFiles||[])}}catch(ze){console.error("Failed to load skill details:",ze)}finally{de||Z(!1)}}})(),()=>{de=!0}},[f,p,a,m,h,d,i,Te]);const ne=re(de=>de.editorFontSize),ie=l.useMemo(()=>{const de=[Ol(e,{fontSize:ne})],Ue=fl(mx);return Ue&&de.push(Ue),de.push(Fl.lineWrapping),de},[e,ne]),he=l.useMemo(()=>{const de=Q.trim()||"supporting-file.md",Ue=Su(de),et=!!Ue&&Ue!=="markdown",ze=[Ol(e,et?{syntaxColors:!1,fontSize:ne}:{fontSize:ne})],Ze=fl(de);return Ze&&ze.push(Ze),et&&Ue&&ze.push(Np({language:Ue,themeName:e.metadata.id,theme:Cp(e)})),ze.push(Fl.lineWrapping),ze},[e,Q,ne]),Ee=l.useCallback(de=>{A(de),E(Ue=>fx(Ue,de))},[]),Ke=l.useCallback(de=>{E(de);const Ue=Od(de);A(Ue.description??""),T(Ue.instructions)},[]),Le=de=>de?!/^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]$/.test(de)||de.length>64?t("settings.skills.page.toast.invalidSkillName"):null:t("settings.skills.page.toast.skillNameRequired"),Se=l.useCallback(async()=>{const de=a?.trim();return p||C||!de||w===ae&&x===G?Us:w.trim()?await r(de,{name:de,description:w.trim(),instructions:x.trim()||void 0,targetPath:f?.path},m)?(ge.current.key===Te&&(xe.current=Zi(w,x),B(w),_(x)),Tn):xs(t("settings.skills.page.toast.updateSkillFailed")):xs(t("settings.skills.page.toast.descriptionRequired"))},[w,x,p,C,ae,G,f?.path,a,m,Te,t,r]),$e=ni(Se),Ye=async()=>{const de=v.trim().replace(/\s+/g,"-").toLowerCase(),Ue=Le(de);if(Ue){U.error(Ue);return}if(!w.trim()){U.error(t("settings.skills.page.toast.descriptionRequired"));return}if(h.some(et=>et.name===de)){U.error(t("settings.skills.page.toast.skillExists"));return}H(!0);try{const et={name:de,description:w.trim(),instructions:x.trim()||void 0,scope:u,source:S,supportingFiles:j.length>0?j:void 0};await o(et,m)?(c(null),O([]),g(de),U.success(t("settings.skills.page.toast.skillCreated"))):U.error(t("settings.skills.page.toast.createSkillFailed"))}catch(et){console.error("Error creating skill:",et),U.error(t("settings.skills.page.toast.saveUnexpectedError"))}finally{H(!1)}},pt=()=>{c(null),g(null)},vt=()=>{ke(null),X(""),je(""),ee(""),te(!0)},wt=async de=>{if(ke(de),X(de),p){const et=j.find(ze=>ze.path===de)?.content||"";je(et),ee(et),te(!0);return}if(a){De(!0),te(!0);try{const{readSupportingFile:Ue}=rn.getState(),et=await Ue(a,de,m);je(et||""),ee(et||"")}catch{U.error(t("settings.skills.page.toast.loadFileContentFailed")),je(""),ee("")}finally{De(!1)}}},yt=async()=>{if(!Q.trim()){U.error(t("settings.skills.page.toast.fileNameRequired"));return}const de=Q.trim(),Ue=fe!==null;if(p){if(Ue)O(Ze=>Ze.map(tt=>tt.path===fe?{path:de,content:pe}:tt)),U.success(t("settings.skills.page.toast.fileUpdated",{path:de}));else{if(j.some(Ze=>Ze.path===de)){U.error(t("settings.skills.page.toast.fileExists"));return}O(Ze=>[...Ze,{path:de,content:pe}]),U.success(t("settings.skills.page.toast.fileAdded",{path:de}))}te(!1),ke(null);return}if(!a){U.error(t("settings.skills.page.toast.noSkillSelected"));return}const{writeSupportingFile:et}=rn.getState();if(await et(a,de,pe,m)){U.success(Ue?t("settings.skills.page.toast.fileUpdated",{path:de}):t("settings.skills.page.toast.fileCreated",{path:de})),te(!1),ke(null);const Ze=await i(a,m);Ze&&P(Ze.sources.md.supportingFiles||[])}else U.error(t(Ue?"settings.skills.page.toast.updateFileFailed":"settings.skills.page.toast.createFileFailed"))},st=de=>{if(p){O(Ue=>Ue.filter(et=>et.path!==de)),U.success(t("settings.skills.page.toast.fileRemoved",{path:de}));return}a&&ue(de)},rt=async()=>{if(!ce||!a)return;ve(!0);const{deleteSupportingFile:de}=rn.getState();if(await de(a,ce,m)){U.success(t("settings.skills.page.toast.fileDeleted",{path:ce}));const et=await i(a,m);et&&P(et.sources.md.supportingFiles||[]),ue(null)}else U.error(t("settings.skills.page.toast.deleteFileFailed"));ve(!1)};return!a&&!d||b?s.jsx("div",{className:"flex h-full items-center justify-center px-4",children:s.jsxs("div",{className:"text-center text-muted-foreground",children:[s.jsx($,{name:"book-open",className:"mx-auto mb-3 h-10 w-10 sm:h-12 sm:w-12 opacity-50"}),s.jsx("p",{className:"typography-body",children:t("settings.skills.page.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:t("settings.skills.page.empty.description")})]})}):q?s.jsx("div",{className:"flex h-full items-center justify-center px-4",children:s.jsx("div",{className:"text-center text-muted-foreground",children:s.jsx("p",{className:"typography-body",children:t("settings.skills.page.loading.details")})})}):s.jsxs(s.Fragment,{children:[s.jsxs(ns,{title:p?t("settings.skills.page.title.newSkill"):a,description:f?t("settings.skills.page.subtitle.skillLocation",{location:Me(vi(f.scope,f.source))}):t("settings.skills.page.subtitle.newSkill"),onBlurCapture:$e.onBlurCapture,children:[s.jsxs(He,{title:t("settings.skills.page.section.basicInformation"),divider:!1,settingsItem:"skills.basic-information",contentClassName:"space-y-0",children:[p&&s.jsxs(Ct,{label:t("settings.skills.page.field.skillNameLocation"),info:t("settings.skills.page.field.skillNameHint"),children:[s.jsx(Ge,{value:v,onChange:de=>k(de.target.value.toLowerCase().replace(/\s+/g,"-")),placeholder:t("settings.skills.page.field.skillNamePlaceholder"),className:"h-7 w-40 px-2"}),s.jsxs(Dt,{value:vi(u,S),onValueChange:de=>{const Ue=Rd(de);y(Ue.scope),N(Ue.source==="agents"?"agents":"opencode")},children:[s.jsxs(Tt,{size:Qt,className:"w-fit gap-1.5",children:[u==="user"?s.jsx($,{name:"user-3",className:"h-3.5 w-3.5"}):s.jsx($,{name:"folder",className:"h-3.5 w-3.5"}),S==="agents"?s.jsx($,{name:"robot-2",className:"h-3.5 w-3.5"}):null,s.jsx("span",{children:Me(vi(u,S))})]}),s.jsx(Et,{align:"start",children:sl.map(de=>s.jsx(gt,{value:de.value,children:s.jsxs("div",{className:"flex flex-col gap-0.5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[de.scope==="user"?s.jsx($,{name:"user-3",className:"h-3.5 w-3.5"}):s.jsx($,{name:"folder",className:"h-3.5 w-3.5"}),de.source==="agents"?s.jsx($,{name:"robot-2",className:"h-3.5 w-3.5"}):null,s.jsx("span",{children:Me(de.value)})]}),s.jsx("span",{className:"typography-micro text-muted-foreground ml-6",children:me(de.value)})]})},de.value))})]})]}),s.jsx(Kt,{label:s.jsxs(s.Fragment,{children:[t("settings.common.field.description")," ",s.jsx("span",{className:"text-[var(--status-error)]",children:"*"})]}),info:t("settings.skills.page.field.descriptionHint"),controlClassName:"w-full max-w-none",children:s.jsx(Rs,{value:w,onChange:de=>Ee(de.target.value),placeholder:t("settings.skills.page.field.descriptionPlaceholder"),rows:2,className:"w-full resize-none min-h-[60px] max-h-32 bg-transparent",disabled:C})})]}),s.jsx(He,{title:t("settings.skills.page.section.instructions"),headerAction:s.jsx(Sp,{currentMode:D==="preview"?"preview":"edit",onToggle:()=>F(de=>de==="preview"?"edit":"preview")}),settingsItem:"skills.instructions",children:s.jsx("div",{className:Ne("overflow-hidden rounded-md border border-[var(--surface-subtle)] bg-background",px),onKeyDown:de=>{de.key==="Enter"&&(de.metaKey||de.ctrlKey)&&(de.preventDefault(),$e.requestSave())},children:D==="preview"?s.jsx(Ds,{outerClassName:"h-full",className:"h-full",children:s.jsx("div",{className:"min-h-full px-4 py-3",children:s.jsx(Cu,{content:M,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})}):s.jsx(Ll,{value:M,onChange:Ke,readOnly:C,extensions:ie,className:"h-full",enableSearch:!0})})}),s.jsx(He,{title:t("settings.skills.page.section.supportingFiles"),headerAction:s.jsxs(V,{variant:"outline",size:"xs",className:"!font-normal gap-1",onClick:vt,disabled:C,children:[s.jsx($,{name:"add",className:"h-3.5 w-3.5"})," ",t("settings.skills.page.actions.addFile")]}),settingsItem:"skills.supporting-files",children:(()=>{const de=p?j:L;return de.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground py-1.5",children:t("settings.skills.page.supportingFiles.empty")}):s.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:de.map(Ue=>s.jsxs("div",{className:"flex items-center gap-2 py-1.5 cursor-pointer group",onClick:()=>wt(Ue.path),children:[s.jsx($,{name:"file",className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:Ue.path}),p&&s.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:t("settings.skills.page.badge.pending")}),!C&&s.jsx(V,{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:et=>{et.stopPropagation(),st(Ue.path)},children:s.jsx($,{name:"delete-bin",className:"h-3 w-3"})})]},Ue.path))})})()}),p&&s.jsx(He,{children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(V,{onClick:()=>{Ye()},disabled:K||!v.trim()||!w.trim(),size:"xs",className:"!font-normal",children:t(K?"settings.common.actions.saving":"settings.skills.page.actions.createSkill")}),s.jsx(V,{variant:"ghost",onClick:pt,disabled:K,size:"xs",className:"!font-normal",children:t("settings.common.actions.cancel")})]})})]}),s.jsx(_t,{open:ce!==null,onOpenChange:de=>{!de&&!Ie&&ue(null)},children:s.jsxs($t,{className:"max-w-md",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:t("settings.skills.page.deleteFileDialog.title")}),s.jsx(qt,{children:t("settings.skills.page.deleteFileDialog.description",{path:ce??""})})]}),s.jsxs(as,{children:[s.jsx(V,{size:"sm",variant:"ghost",onClick:()=>ue(null),disabled:Ie,children:t("settings.common.actions.cancel")}),s.jsx(V,{size:"sm",variant:"destructive",onClick:rt,disabled:Ie,children:t("settings.common.actions.delete")})]})]})}),s.jsx(_t,{open:z,onOpenChange:de=>{if(de){te(!0);return}if(fe!==null&&pe!==oe){yt();return}te(!1),ke(null)},children:s.jsxs($t,{className:"max-w-3xl max-h-[85vh] flex flex-col",children:[s.jsxs(Vt,{className:"flex-shrink-0",children:[s.jsx(Ht,{children:t(fe?"settings.skills.page.fileDialog.titleEdit":"settings.skills.page.fileDialog.titleAdd")}),s.jsx(qt,{children:t(fe?"settings.skills.page.fileDialog.descriptionEdit":"settings.skills.page.fileDialog.descriptionAdd")})]}),be?s.jsx("div",{className:"flex-1 flex items-center justify-center py-8",children:s.jsx("span",{className:"typography-meta text-muted-foreground",children:t("settings.skills.page.loading.fileContent")})}):s.jsxs("div",{className:"space-y-4 flex-1 min-h-0 flex flex-col pt-2",children:[s.jsxs("div",{className:"space-y-2 flex-shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("label",{className:Pt,children:t("settings.skills.page.fileDialog.field.filePath")}),!fe&&s.jsx(Gt,{children:t("settings.skills.page.fileDialog.field.filePathHint")})]}),s.jsx(Ge,{value:Q,onChange:de=>X(de.target.value),placeholder:t("settings.skills.page.fileDialog.field.filePathPlaceholder"),className:"text-foreground placeholder:text-muted-foreground focus-visible:ring-ring",disabled:fe!==null})]}),s.jsxs("div",{className:"space-y-2 flex-1 min-h-0 flex flex-col",children:[s.jsx("label",{className:`${Pt} flex-shrink-0`,children:t("settings.skills.page.fileDialog.field.content")}),s.jsx("div",{className:"h-[45vh] min-h-[250px] max-h-[55vh] overflow-hidden rounded-md border border-[var(--surface-subtle)] bg-background",children:s.jsx(Ll,{value:pe,onChange:je,extensions:he,className:"h-full",enableSearch:!0})})]})]}),s.jsx(as,{className:"mt-4",children:fe?s.jsx(V,{size:"sm",onClick:()=>{yt()},disabled:be,children:t("settings.common.actions.close")}):s.jsxs(s.Fragment,{children:[s.jsx(V,{size:"sm",variant:"ghost",onClick:()=>{te(!1),ke(null)},children:t("settings.common.actions.cancel")}),s.jsx(V,{size:"sm",onClick:()=>{yt()},disabled:be||!Re,children:t("settings.skills.page.actions.createFile")})]})})]})})]})},tc=t=>{const e=Be.c(2),{view:a}=t,n=a===void 0?"installed":a;let i;return e[0]!==n?(i=n==="catalog"?s.jsx(ux,{}):s.jsx(hx,{}),e[0]=n,e[1]=i):i=e[1],i};function xx(){}const bx=t=>{const e=Be.c(26),{header:a,footer:n,children:i,className:o,variant:r}=t,d=r===void 0?"sidebar":r,c=ps(),g=l.useRef(null),[m,h]=l.useState(!1),[f,p]=l.useState(!1),b=d==="background"||c?"bg-background":"bg-sidebar",C=b==="bg-background"?"var(--surface-background)":"var(--surface-muted)";let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{const D=g.current;if(!D){h(!1),p(!1);return}if(!(D.scrollHeight>D.clientHeight+1)){h(!1),p(!1);return}h(D.scrollTop>1),p(D.scrollTop+D.clientHeight<D.scrollHeight-1)},e[0]=v):v=e[0];const k=v;let u;e[1]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{k()},e[1]=u):u=e[1];let y;e[2]!==i?(y=[i,k],e[2]=i,e[3]=y):y=e[3],l.useEffect(u,y);let S,N;e[4]===Symbol.for("react.memo_cache_sentinel")?(S=()=>{const D=g.current;if(!D)return;const F=()=>k();return D.addEventListener("scroll",F,{passive:!0}),()=>D.removeEventListener("scroll",F)},N=[k],e[4]=S,e[5]=N):(S=e[4],N=e[5]),l.useEffect(S,N);let w;e[6]!==b||e[7]!==o?(w=Ne("flex h-full flex-col",b,o),e[6]=b,e[7]=o,e[8]=w):w=e[8];let A;e[9]!==i?(A=s.jsx(Ds,{ref:g,outerClassName:"flex-1 min-h-0",className:"space-y-0.5 px-3 py-2 overflow-x-hidden",children:i}),e[9]=i,e[10]=A):A=e[10];let x;e[11]!==C||e[12]!==m?(x=m&&s.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-4",style:{background:`linear-gradient(to bottom, ${C} 0%, transparent 100%)`}}),e[11]=C,e[12]=m,e[13]=x):x=e[13];let T;e[14]!==C||e[15]!==f?(T=f&&s.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-6",style:{background:`linear-gradient(to top, ${C} 0%, transparent 100%)`}}),e[14]=C,e[15]=f,e[16]=T):T=e[16];let M;e[17]!==T||e[18]!==A||e[19]!==x?(M=s.jsxs("div",{className:"relative flex flex-1 min-h-0 flex-col",children:[A,x,T]}),e[17]=T,e[18]=A,e[19]=x,e[20]=M):M=e[20];let E;return e[21]!==n||e[22]!==a||e[23]!==M||e[24]!==w?(E=s.jsxs("div",{className:w,children:[a,M,n]}),e[21]=n,e[22]=a,e[23]=M,e[24]=w,e[25]=E):E=e[25],E},vx=t=>{const e=Be.c(23),{title:a,metadata:n,selected:i,onSelect:o,icon:r,actions:d,className:c}=t,g=i===void 0?!1:i,m=d&&d.length>0,h=g?"bg-interactive-selection":"hover:bg-interactive-hover";let f;e[0]!==c||e[1]!==h?(f=Ne("group relative flex items-center rounded-md px-1.5 py-0.5 transition-all duration-200",h,c),e[0]=c,e[1]=h,e[2]=f):f=e[2];let p;e[3]!==a?(p=s.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:a}),e[3]=a,e[4]=p):p=e[4];let b;e[5]!==r||e[6]!==p?(b=s.jsxs("div",{className:"flex items-center gap-1.5",children:[r,p]}),e[5]=r,e[6]=p,e[7]=b):b=e[7];let C;e[8]!==n?(C=n&&s.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:n}),e[8]=n,e[9]=C):C=e[9];let v;e[10]!==o||e[11]!==b||e[12]!==C?(v=s.jsxs("button",{onClick:o,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-ring",tabIndex:0,children:[b,C]}),e[10]=o,e[11]=b,e[12]=C,e[13]=v):v=e[13];let k;e[14]!==d||e[15]!==m?(k=m&&s.jsxs(Jn,{children:[s.jsx(Wn,{asChild:!0,children:s.jsx(V,{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:s.jsx($,{name:"more-2",className:"h-3.5 w-3.5"})})}),s.jsx(Gn,{align:"end",className:"w-fit min-w-20",children:d.map(yx)})]}),e[14]=d,e[15]=m,e[16]=k):k=e[16];let u;e[17]!==v||e[18]!==k?(u=s.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[v,k]}),e[17]=v,e[18]=k,e[19]=u):u=e[19];let y;return e[20]!==f||e[21]!==u?(y=s.jsx("div",{className:f,children:u}),e[20]=f,e[21]=u,e[22]=y):y=e[22],y};function yx(t){const e=t.icon;return s.jsxs(xn,{onClick:a=>{a.stopPropagation(),t.onClick()},className:Ne(t.destructive&&"text-destructive focus:text-destructive"),children:[e&&s.jsx($,{name:e,className:"h-4 w-4 mr-px"}),t.label]},t.label)}const jx=t=>{const e=Be.c(38),{onItemSelect:a}=t,{t:n}=qe(),i=hn(kx),o=re(wx),r=re(Nx),{currentTheme:d}=ba();let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=ps(),e[0]=c):c=e[0];const g=c,m=Sx;let h,f;e[1]!==i||e[2]!==o||e[3]!==r?(h=()=>{if(i.length===0){o!==null&&r(null);return}o&&i.some(A=>A.id===o)||r(i[0].id)},f=[i,o,r],e[1]=i,e[2]=o,e[3]=r,e[4]=h,e[5]=f):(h=e[4],f=e[5]),l.useEffect(h,f);let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=Ne("border-b px-3","pt-4 pb-3"),e[6]=p):p=e[6];let b;e[7]!==n?(b=n("settings.page.projects.title"),e[7]=n,e[8]=b):b=e[8];let C;e[9]!==b?(C=s.jsx("h2",{className:`${va} mb-3`,children:b}),e[9]=b,e[10]=C):C=e[10];let v;e[11]!==i.length||e[12]!==n?(v=n("settings.projects.sidebar.total",{count:i.length}),e[11]=i.length,e[12]=n,e[13]=v):v=e[13];let k;e[14]!==v?(k=s.jsx("span",{className:"typography-meta text-muted-foreground",children:v}),e[14]=v,e[15]=k):k=e[15];let u;e[16]!==n?(u=!g&&s.jsx(V,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 -my-1 text-muted-foreground",onClick:m,"aria-label":n("settings.projects.sidebar.actions.addProject"),children:s.jsx($,{name:"add",className:"size-4"})}),e[16]=n,e[17]=u):u=e[17];let y;e[18]!==k||e[19]!==u?(y=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[k,u]}),e[18]=k,e[19]=u,e[20]=y):y=e[20];let S;e[21]!==y||e[22]!==C?(S=s.jsxs("div",{className:p,children:[C,y]}),e[21]=y,e[22]=C,e[23]=S):S=e[23];let N;if(e[24]!==d||e[25]!==a||e[26]!==i||e[27]!==o||e[28]!==r){let A;e[30]!==d||e[31]!==a||e[32]!==o||e[33]!==r?(A=x=>{const T=x.id===o,M=x.icon?Pu[x.icon]:null,E=x.color?Au[x.color]??null:null,D=M?s.jsx($,{name:M,className:Ne("h-4 w-4",T?"text-foreground":"text-muted-foreground/70"),style:E?{color:E}:void 0}):s.jsx($,{name:"folder",className:Ne("h-4 w-4",T?"text-foreground":"text-muted-foreground/70"),style:E?{color:E}:void 0}),F=x.iconImage?s.jsx("span",{className:"inline-flex h-4 w-4 items-center justify-center overflow-hidden rounded-[2px]",style:x.iconBackground?{backgroundColor:x.iconBackground}:void 0,children:s.jsx(Tu,{project:x,options:{themeVariant:d.metadata.variant,iconColor:d.colors.surface.foreground},className:"h-full w-full object-contain",fallback:D})}):D;return s.jsx(vx,{title:x.label||x.path,icon:F,selected:T,onSelect:()=>{r(x.id),a?.()}},x.id)},e[30]=d,e[31]=a,e[32]=o,e[33]=r,e[34]=A):A=e[34],N=i.map(A),e[24]=d,e[25]=a,e[26]=i,e[27]=o,e[28]=r,e[29]=N}else N=e[29];let w;return e[35]!==S||e[36]!==N?(w=s.jsx(bx,{variant:"background",header:S,children:N}),e[35]=S,e[36]=N,e[37]=w):w=e[37],w};function kx(t){return t.projects}function wx(t){return t.settingsProjectsSelectedId}function Nx(t){return t.setSettingsProjectsSelectedId}function Sx(){Iu.requestDirectoryDialog()}const Cx=()=>{const t=Be.c(30),{t:e}=qe(),a=hn(Ix),n=hn(Px),i=re(Ax),o=re(Tx);let r;e:{if(!i){r=null;break e}let v;t[0]!==a||t[1]!==i?(v=a.find(k=>k.id===i)??null,t[0]=a,t[1]=i,t[2]=v):v=t[2],r=v}const d=r;let c,g;t[3]!==a||t[4]!==i||t[5]!==o?(c=()=>{if(a.length===0){o(null);return}i&&a.some(v=>v.id===i)||o(a[0].id)},g=[a,i,o],t[3]=a,t[4]=i,t[5]=o,t[6]=c,t[7]=g):(c=t[6],g=t[7]),l.useEffect(c,g);let m;t[8]!==d||t[9]!==n?(m=async v=>{d&&n(d.id,{label:v.label,icon:v.icon,color:v.color,iconBackground:v.iconBackground,defaultAgent:v.defaultAgent??null,defaultModel:v.defaultModel??null,defaultVariant:v.defaultVariant??null})},t[8]=d,t[9]=n,t[10]=m):m=t[10];const h=m;if(!d){let v;t[11]!==e?(v=e("settings.page.projects.title"),t[11]=e,t[12]=v):v=t[12];let k;t[13]!==e?(k=e("settings.projects.page.empty.noProjects"),t[13]=e,t[14]=k):k=t[14];let u;t[15]!==k?(u=s.jsx("p",{className:"typography-meta text-muted-foreground",children:k}),t[15]=k,t[16]=u):u=t[16];let y;return t[17]!==v||t[18]!==u?(y=s.jsx(ns,{title:v,showSaveStatus:!0,children:u}),t[17]=v,t[18]=u,t[19]=y):y=t[19],y}let f;t[20]!==d.label||t[21]!==e?(f=d.label??e("settings.projects.page.title.default"),t[20]=d.label,t[21]=e,t[22]=f):f=t[22];const p=f;let b;t[23]!==h||t[24]!==d?(b=s.jsx(pp,{project:d,onIdentitySave:h}),t[23]=h,t[24]=d,t[25]=b):b=t[25];let C;return t[26]!==p||t[27]!==d.path||t[28]!==b?(C=s.jsx(ns,{title:p,description:d.path,showSaveStatus:!0,outerClassName:"bg-background",children:b}),t[26]=p,t[27]=d.path,t[28]=b,t[29]=C):C=t[29],C};function Ix(t){return t.projects}function Px(t){return t.updateProjectMeta}function Ax(t){return t.settingsProjectsSelectedId}function Tx(t){return t.setSettingsProjectsSelectedId}const Ex=Os({clientToken:Rt().trim().min(1)}),Dx=Os({error:jp("Invalid or expired pairing session")}),Mx=async t=>{const e=await t.json().catch(()=>null);if(!t.ok)return t.status===400&&Dx.safeParse(e).success?{kind:"rejected"}:{kind:"http-error",status:t.status};const a=Ex.safeParse(e);return a.success?{kind:"success",token:a.data.clientToken}:{kind:"invalid-response"}};function Rx(t){const e=Be.c(42),{t:a}=qe(),[n,i]=at.useState(null),o=at.useRef(null),r=at.useRef(null);let d,c;e[0]!==t?(d=()=>(r.current=t,i(null),()=>{r.current=null;const P=o.current;o.current=null,P?.(null)}),c=[t],e[0]=t,e[1]=d,e[2]=c):(d=e[1],c=e[2]),at.useEffect(d,c);let g;e[3]!==t?(g=(P,j)=>{const O=j===void 0?"settings.common.actions.saveChanges":j;return!t||r.current!==t||o.current?Promise.resolve(null):new Promise(K=>{o.current=K,i({messageKey:P,actionKey:O})})},e[3]=t,e[4]=g):g=e[4];const m=g;let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=P=>{const j=o.current;o.current=null,i(null),j?.(P)},e[5]=h):h=e[5];const f=h,p=n!==null;let b;e[6]===Symbol.for("react.memo_cache_sentinel")?(b=P=>{P||f(!1)},e[6]=b):b=e[6];let C;e[7]!==a?(C=a("settings.remoteInstances.page.title"),e[7]=a,e[8]=C):C=e[8];let v;e[9]!==C?(v=s.jsx(Ht,{children:C}),e[9]=C,e[10]=v):v=e[10];let k;e[11]!==n||e[12]!==a?(k=n?a(n.messageKey):null,e[11]=n,e[12]=a,e[13]=k):k=e[13];let u;e[14]!==k?(u=s.jsx(qt,{children:k}),e[14]=k,e[15]=u):u=e[15];let y;e[16]!==v||e[17]!==u?(y=s.jsxs(Vt,{children:[v,u]}),e[16]=v,e[17]=u,e[18]=y):y=e[18];let S;e[19]===Symbol.for("react.memo_cache_sentinel")?(S=()=>f(!1),e[19]=S):S=e[19];let N;e[20]!==a?(N=a("settings.common.actions.cancel"),e[20]=a,e[21]=N):N=e[21];let w;e[22]!==N?(w=s.jsx(V,{variant:"outline",autoFocus:!0,onClick:S,children:N}),e[22]=N,e[23]=w):w=e[23];let A;e[24]===Symbol.for("react.memo_cache_sentinel")?(A=()=>f(!0),e[24]=A):A=e[24];let x;e[25]!==n||e[26]!==a?(x=n?a(n.actionKey):null,e[25]=n,e[26]=a,e[27]=x):x=e[27];let T;e[28]!==x?(T=s.jsx(V,{onClick:A,children:x}),e[28]=x,e[29]=T):T=e[29];let M;e[30]!==w||e[31]!==T?(M=s.jsxs(as,{children:[w,T]}),e[30]=w,e[31]=T,e[32]=M):M=e[32];let E;e[33]!==y||e[34]!==M?(E=s.jsxs($t,{children:[y,M]}),e[33]=y,e[34]=M,e[35]=E):E=e[35];let D;e[36]!==E||e[37]!==p?(D=s.jsx(_t,{open:p,onOpenChange:b,children:E}),e[36]=E,e[37]=p,e[38]=D):D=e[38];const F=D;let L;return e[39]!==m||e[40]!==F?(L={confirm:m,dialog:F},e[39]=m,e[40]=F,e[41]=L):L=e[41],L}const Xi=()=>Math.floor(2e4+Math.random()*3e4),Ox=t=>{const e=(t instanceof Error?t.message:String(t)).toLowerCase();return e.includes("address already in use")||e.includes("eaddrinuse")||e.includes("port already in use")},Lx=()=>{if(typeof navigator>"u")return;const t=(navigator.userAgent||"").toLowerCase();if(t.includes("mac"))return"macos";if(t.includes("win"))return"windows";if(t.includes("linux"))return"linux"},sc=t=>{switch((t||"").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}},nc=t=>{switch(t){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.installingOpenChamber";case"updating":return"settings.remoteInstances.page.phase.updatingOpenChamber";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"}},Fx=new Set(["config_resolved","auth_check","master_connecting","remote_probe","installing","updating","server_detecting","server_starting","forwarding"]),nl=t=>!!(t&&Fx.has(t)),ac=t=>t==="ready"?"ready":t==="error"?"error":t==="degraded"||nl(t)?"connecting":"idle",ic=t=>{switch(t){case"ready":return"settings.remoteInstances.page.state.ready";case"connecting":return"settings.remoteInstances.page.state.connecting";case"error":return"settings.remoteInstances.page.state.problem";default:return"settings.remoteInstances.page.state.notConnected"}},Kx=t=>{const e=(t||"").toLowerCase();return e?e.includes("ui authentication")||e.includes("ui password")?"uiPassword":e.includes("already in use")||e.includes("eaddrinuse")?"localPort":e.includes("neither bun nor npm")?"noRuntime":e.includes("opencode cli is not installed")?"noOpencode":e.includes("requires a ui password")?"uiPassword":e.includes("preferred remote openchamber port")?"externalPort":null:null},oc={noRuntime:"settings.remoteInstances.page.error.hint.noRuntime",noOpencode:"settings.remoteInstances.page.error.hint.noOpencode"},zx=t=>t==="noRuntime"?oc.noRuntime:t==="noOpencode"?oc.noOpencode:null,rc=t=>t==="ready"?"bg-[var(--status-success)] animate-pulse":t==="error"?"bg-[var(--status-error)] animate-pulse":t==="degraded"||nl(t)?"bg-[var(--status-warning)] animate-pulse":"bg-muted-foreground/40",Ux=t=>t.type==="dynamic"?`${t.localHost||"127.0.0.1"}:${t.localPort||0}`:t.type==="remote"?`${t.remoteHost||"127.0.0.1"}:${t.remotePort||0} -> ${t.localHost||"127.0.0.1"}:${t.localPort||0}`:`${t.localHost||"127.0.0.1"}:${t.localPort||0} -> ${t.remoteHost||"127.0.0.1"}:${t.remotePort||0}`,_x=()=>({id:`forward-${Date.now()}-${Math.random().toString(16).slice(2)}`,enabled:!0,type:"local",localHost:"127.0.0.1",localPort:Xi(),remoteHost:"127.0.0.1",remotePort:80}),$x=t=>t.trim().replace(/\*/g,"host").replace(/\?/g,"x")||"user@host",on=t=>{const e=Be.c(7),{label:a,hint:n}=t;let i;e[0]!==a?(i=s.jsx("span",{children:a}),e[0]=a,e[1]=i):i=e[1];let o;e[2]!==n?(o=s.jsx(Gt,{contentClassName:"max-w-xs",children:n}),e[2]=n,e[3]=o):o=e[3];let r;return e[4]!==i||e[5]!==o?(r=s.jsxs("span",{className:`inline-flex items-center gap-1 ${Pt}`,children:[i,o]}),e[4]=i,e[5]=o,e[6]=r):r=e[6],r},Bx=t=>{switch(t){case"remote":return"settings.remoteInstances.page.forwardTypeDescription.remote";case"dynamic":return"settings.remoteInstances.page.forwardTypeDescription.dynamic";default:return"settings.remoteInstances.page.forwardTypeDescription.local"}},lc=(t,e)=>{const a=(t||"").trim();return`${!a||a==="127.0.0.1"||a==="::1"?"localhost":a}:${e||0}`},Vx=t=>{const e=(t||"").trim();return!e||e==="0.0.0.0"||e==="::"?"127.0.0.1":e},Hx=t=>{const e=t.match(/^\[(\d{10,})\]\s*(?:\[([A-Z]+)\]\s*)?(.*)$/);if(!e)return t;const a=Number(e[1]),n=Number.isFinite(a)?new Date(a).toISOString():e[1],i=(e[2]||"INFO").toUpperCase(),o=e[3]||"";return`[${n}] [${i}] ${o}`},Cr=(t="",e="")=>({id:typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`header-${Date.now()}-${Math.random().toString(16).slice(2)}`,name:t,value:e}),qx=t=>t.trim().toLowerCase()==="authorization",Qo=t=>{const e={};for(const a of t){const n=a.name.trim(),i=a.value.trim();n&&i&&!qx(n)&&(e[n]=i)}return Object.keys(e).length>0?e:void 0},Gx=t=>Object.entries(t||{}).map(([e,a])=>Cr(e,a)),Ld=()=>{if(typeof window>"u")return null;const e=ki()||window.location.href;try{const a=Number(new URL(e).port||window.location.port);return Number.isFinite(a)&&a>0?a:null}catch{const a=Number(window.location.port);return Number.isFinite(a)&&a>0?a:null}},cc=t=>{try{const e=new URL(t).hostname.toLowerCase();return e==="localhost"||e==="127.0.0.1"||e==="::1"||e==="[::1]"}catch{return!1}},Wx=async()=>{const t=Ba(ki())||window.location.origin;if(!us()||!wi()||(await En())?.desktopLanAccessActive!==!0)return t;const a=await hd(),n=Ld();return!a||!n?t:`http://${a}:${n}`},qi=t=>{const e=t.trim();if(e)try{window.location.assign(e)}catch{window.location.href=e}},Jx=t=>{const e=t.sshCommand.trim(),a=t.nickname?.trim(),n=t.portForwards.map(i=>({...i,localHost:i.localHost?.trim()||"127.0.0.1",localPort:typeof i.localPort=="number"?Math.max(1,Math.min(65535,Math.round(i.localPort))):void 0,remoteHost:i.remoteHost?.trim(),remotePort:typeof i.remotePort=="number"?Math.max(1,Math.min(65535,Math.round(i.remotePort))):void 0}));return{...t,sshCommand:e,...a?{nickname:a}:{nickname:void 0},connectionTimeoutSec:Math.max(5,Math.min(240,Math.round(t.connectionTimeoutSec||60))),localForward:{...t.localForward,bindHost:t.localForward.bindHost==="localhost"||t.localForward.bindHost==="0.0.0.0"?t.localForward.bindHost:"127.0.0.1",preferredLocalPort:typeof t.localForward.preferredLocalPort=="number"?Math.max(1,Math.min(65535,Math.round(t.localForward.preferredLocalPort))):void 0},remoteOpenchamber:{...t.remoteOpenchamber,preferredPort:typeof t.remoteOpenchamber.preferredPort=="number"?Math.max(1,Math.min(65535,Math.round(t.remoteOpenchamber.preferredPort))):void 0},portForwards:n}},Qx=()=>{const{t}=qe(),e=re(R=>R.timeFormatPreference),{clientAuth:a}=Ur(),n=us(),i=As(R=>R.instances),o=As(R=>R.statusesById),r=As(R=>R.importCandidates),d=As(R=>R.isLoading),c=As(R=>R.isImportsLoading),g=As(R=>R.isSaving),m=As(R=>R.error),h=As(R=>R.load),f=As(R=>R.loadImports),p=As(R=>R.refreshStatuses),b=As(R=>R.upsertInstance),C=As(R=>R.createFromCommand),v=As(R=>R.removeInstance),k=As(R=>R.connect),u=As(R=>R.disconnect),y=As(R=>R.retry),S=re(R=>R.settingsRemoteInstancesSelectedId),N=re(R=>R.setSettingsRemoteInstancesSelectedId),{confirm:w,dialog:A}=Rx(S),x=l.useMemo(()=>S&&i.find(R=>R.id===S)||null,[i,S]),[T,M]=l.useState(null),[E,D]=l.useState(!1),[F,L]=l.useState(!1),[P,j]=l.useState(null),[O,K]=l.useState([]),[H,q]=l.useState(null),[Z,ae]=l.useState(""),[B,G]=l.useState(!1),[_,z]=l.useState({}),[te,Q]=l.useState(!1),[X,pe]=l.useState(!1),[je,fe]=l.useState(()=>Date.now()),[ke,be]=l.useState([]),[De,oe]=l.useState({}),[ee,ce]=l.useState("local"),[ue,Ie]=l.useState(!1),[ve,Re]=l.useState(!1),[Me,me]=l.useState(""),[Te,Oe]=l.useState(""),[ge,xe]=l.useState(""),[ne,ie]=l.useState([]),[he,Ee]=l.useState(""),[Ke,Le]=l.useState(null),[Se,$e]=l.useState(!1),[Ye,pt]=l.useState(!1),[vt,wt]=l.useState(!1),[yt,st]=l.useState(null),[rt,de]=l.useState(""),[Ue,et]=l.useState(""),[ze,Ze]=l.useState(""),[tt,lt]=l.useState([]),[J,nt]=l.useState([]),[ot,it]=l.useState([]),[ft,xt]=l.useState(!1),[ht,St]=l.useState(""),[At,_e]=l.useState(null),[Xe,mt]=l.useState(null),[Fe,W]=l.useState(null),[ye,Ae]=l.useState(null),[Y,Pe]=l.useState(!1),[Je,se]=l.useState(!1),[We,ut]=l.useState("configure"),[Ce,Ve]=l.useState(!1),[jt,Ot]=l.useState("relay"),[Yt,Zt]=l.useState(!0),[Ft,ms]=l.useState(null),gs=l.useMemo(()=>J.filter(R=>!!R.revokedAt).length,[J]),[tn,$s]=l.useState(!1),[Bs,cn]=l.useState("saved"),[sn,nn]=l.useState(""),[Vs,Dn]=l.useState(""),[Lt,Xt]=l.useState(""),[Wt,Mt]=l.useState(!1);l.useEffect(()=>{h(),f()},[h,f]);const ls=l.useCallback(async()=>{Ie(!0),Le(null);try{const R=await Nl();be(R.hosts||[]),ce(R.defaultHostId||"local")}catch(R){Le(R instanceof Error?R.message:String(R))}finally{Ie(!1)}},[]);l.useEffect(()=>{ls()},[ls]);const is=l.useCallback(async(R,le=ee)=>{Re(!0),Le(null);try{return await Sl({hosts:R,defaultHostId:le,initialHostChoiceCompleted:!0}),be(R),ce(le),!0}catch(Qe){return Le(Qe instanceof Error?Qe.message:String(Qe)),!1}finally{Re(!1)}},[ee]),vo=l.useCallback(async()=>{const R=Cl(Te);if(!R){Le(t("desktopHostSwitcher.error.invalidUrl"));return}const le=R.persistedUrl,dt={id:typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`host-${Date.now()}-${Math.random().toString(16).slice(2)}`,label:Me.trim()||oi(le),url:le,apiUrl:le,...ge.trim()?{clientToken:ge.trim()}:{},...Qo(ne)?{requestHeaders:Qo(ne)}:{}};await is([dt,...ke],ee)&&(me(""),Oe(""),xe(""),ie([]),$e(!1),R.redeemUrl&&qi(R.redeemUrl))},[ee,ne,ke,Me,ge,Te,is,t]),yo=l.useCallback(async()=>{Le(null);const R=Dm(he);if(!R){Le(t("settings.remoteInstances.direct.error.invalidConnectLink"));return}const le=await Mm().catch(()=>""),Qe=JSON.stringify({pairingId:R.pairingId,secret:R.secret,clientLabel:R.label||"OpenChamber Desktop",clientKind:"desktop",deviceName:"OpenChamber Desktop",devicePlatform:Lx(),...le?{dedupeKey:`desktop:${le}`}:{}}),dt={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:Qe};let Ut=null;const ks=async ss=>{const Ps=await Mx(ss);switch(Ps.kind){case"success":return Ps.token;case"rejected":Ut=t("desktopHostSwitcher.error.pairingRejected");break;case"http-error":Ut??=t("desktopHostSwitcher.error.pairingFailed",{status:Ps.status});break;case"invalid-response":Ut??=t("desktopHostSwitcher.error.pairingInvalidResponse");break}return null},an=[...R.candidates].sort((ss,Ps)=>(ss.type==="relay"?1:0)-(Ps.type==="relay"?1:0));let bs=null;for(const ss of an){if(ss.type==="relay"){const Ra=Rm({relayUrl:ss.relayUrl,serverId:ss.serverId,hostEncPubJwk:ss.hostEncPubJwk,...ss.grant?{grant:ss.grant}:{}});try{const Oa=await Ra.fetch("/api/client-auth/pairing/redeem",{...dt,signal:AbortSignal.timeout(15e3)}),La=await ks(Oa);if(La){bs={kind:"relay",relay:{relayUrl:ss.relayUrl,serverId:ss.serverId,hostEncPubJwk:ss.hostEncPubJwk},token:La};break}}catch{}finally{Ra.close()}continue}const Ps=Ba(ss.url);if(Ps)try{const Ra=await fetch(`${Ps}/api/client-auth/pairing/redeem`,{...dt,signal:AbortSignal.timeout(15e3)}),Oa=await ks(Ra);if(Oa){bs={kind:"direct",url:Ps,token:Oa};break}}catch{}}if(!bs){Le(Ut||t("mobile.connect.error.unreachable"));return}const Hs=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`host-${Date.now()}-${Math.random().toString(16).slice(2)}`,Rn=R.candidates.find(ss=>ss.type==="relay"),wn=bs.kind==="relay"?bs.relay:Rn?{relayUrl:Rn.relayUrl,serverId:Rn.serverId,hostEncPubJwk:Rn.hostEncPubJwk}:void 0,Da=R.candidates.filter(ss=>ss.type!=="relay").map(ss=>Ba(ss.url)).find(ss=>!!ss),Ma=bs.kind==="direct"?bs.url:Da,{token:Bt}=bs,ts=Ma||(wn?Om(wn.serverId):null);if(!ts){Le(t("settings.remoteInstances.direct.error.invalidConnectLink"));return}const Nn={url:ts,apiUrl:Ma||void 0,clientToken:Bt,...wn?{relay:wn}:{}},mn=ke.find(ss=>wn?ss.relay?.serverId===wn.serverId:!ss.relay&&Ba(ss.apiUrl||ss.url)===ts);if(mn){const ss=ke.map(Ps=>Ps.id===mn.id?{...Ps,label:R.label||Ps.label,...Nn}:Ps);if(!await is(ss,ee))return}else if(!await is([{id:Hs(),label:R.label||oi(ts),...Nn},...ke],ee))return;Ee(""),Le(null),pt(!1)},[he,ee,ke,is,t]),jo=l.useCallback(async R=>{const le=ke.filter(dt=>dt.id!==R);await is(le,ee===R?"local":ee)&&yt===R&&st(null)},[ee,yt,ke,is]),ko=l.useCallback(R=>{st(R.id),de(R.label),et(R.apiUrl||R.url),Ze(R.clientToken||""),lt(Gx(R.requestHeaders)),Le(null)},[]),Ci=l.useCallback(async()=>{if(!yt)return;const R=Cl(Ue);if(!R){Le(t("desktopHostSwitcher.error.invalidUrl"));return}const le=R.persistedUrl,Qe=ke.map(dt=>dt.id===yt?{...dt,label:rt.trim()||oi(le),url:le,apiUrl:le,clientToken:ze.trim()||void 0,requestHeaders:Qo(tt)}:dt);await is(Qe,ee)&&(st(null),R.redeemUrl&&qi(R.redeemUrl))},[ee,tt,rt,ze,Ue,yt,ke,is,t]),wo=l.useCallback(async()=>{const R=Vs.trim();if(!R){U.error(t("settings.remoteInstances.page.toast.sshCommandRequired"));return}const le=`ssh-${Date.now()}-${Math.random().toString(16).slice(2)}`;try{await C(le,R,Lt.trim()||t("settings.remoteInstances.sidebar.newSshInstanceName")),N(le),$s(!1),Dn(""),Xt(""),U.success(t("settings.remoteInstances.page.toast.instanceCreated"))}catch(Qe){U.error(t("settings.remoteInstances.sidebar.toast.createFailed"),{description:Qe instanceof Error?Qe.message:String(Qe)})}},[C,N,Vs,Lt,t]),Ii=l.useCallback(()=>{nn(""),cn(r.length>0?"saved":"manual"),$s(!0)},[r.length]),No=l.useCallback(async R=>{await is(ke,R)},[ke,is]);l.useEffect(()=>{if(!n||ke.length===0)return;let R=!1;return Promise.all(ke.map(async le=>{const Qe=()=>_m(le.relay,{clientToken:le.clientToken||null,requestHeaders:le.requestHeaders||null}).catch(()=>({status:"unreachable",latencyMs:0}));if(le.relay&&!le.apiUrl)return[le.id,await Qe()];const dt=Ba(Lm(le));if(!dt)return[le.id,le.relay?await Qe():{status:"unreachable",latencyMs:0}];const Ut=await Fm(dt,{clientToken:le.clientToken||null,requestHeaders:le.requestHeaders||null}).catch(()=>({status:"unreachable",latencyMs:0}));if(Ut.status==="unreachable"&&le.relay){const ks=await Qe();if(ks.status==="ok")return[le.id,ks]}return[le.id,Ut]})).then(le=>{R||oe(Object.fromEntries(le))}),()=>{R=!0}},[ke,n]);const Ws=l.useCallback(async R=>{if(a){R?.silent||xt(!0),R?.silent||_e(null);try{const[le,Qe]=await Promise.all([a.listClients(),a.listPendingPairings().catch(()=>null)]);nt(le),Qe&&it(Qe)}catch(le){R?.silent||_e(le instanceof Error?le.message:String(le))}finally{R?.silent||xt(!1)}}},[a]),ai=l.useRef(!1);l.useEffect(()=>{if(!(!Je||We!=="result"||!Fe)){if(ot.some(R=>R.id===Fe)){ai.current=!0;return}ai.current&&(W(null),se(!1),J.some(R=>R.pairingId===Fe)&&U.success(t("settings.remoteInstances.clientAuth.addDevice.connectedToast")))}},[Je,We,Fe,ot,J,t]);const Pi=l.useCallback(async R=>{if(a)try{await a.cancelPairing(R),it(le=>le.filter(Qe=>Qe.id!==R)),await Ws({silent:!0})}catch(le){_e(le instanceof Error?le.message:String(le))}},[a,Ws]);l.useEffect(()=>{if(!a)return;Ws();const R=window.setInterval(()=>{typeof document<"u"&&document.visibilityState!=="visible"||Ws({silent:!0})},5e3);return()=>window.clearInterval(R)},[a,Ws]);const Ai=l.useCallback(async()=>{if(a?.getPairingTransports)try{const dt=await a.getPairingTransports();return{localUrl:dt.local,lanUrl:dt.lan,relayAvailable:dt.relayAvailable}}catch{}const R=Ld(),le=R?`http://127.0.0.1:${R}`:cc(window.location.origin)?window.location.origin:null;let Qe=null;try{const dt=Ba(await Wx());Qe=dt&&!cc(dt)?dt:null}catch{}return{localUrl:le,lanUrl:Qe,relayAvailable:!0}},[a]),So=l.useCallback(async()=>{_e(null),mt(null),Ae(null),Pe(!1),W(null),ut("configure"),Zt(!0),se(!0);const R=await Ai();ms(R),Ot(R.relayAvailable?"relay":R.lanUrl?"lan":"local")},[Ai]),Co=l.useCallback(async()=>{if(!(!a?.createPairingSession||!Ft)){_e(null),Ve(!0);try{const R=ht.trim()||void 0;let le,Qe,dt=!0;jt==="local"?(le=Ft.localUrl??void 0,Qe=!1):jt==="lan"?(le=Ft.lanUrl??void 0,Qe=Yt):Yt&&Ft.lanUrl?(le=Ft.lanUrl,Qe=!0):(dt=!1,Qe=!0);const{pairing:Ut,server:ks}=await a.createPairingSession({label:R,allowedClientKinds:["mobile","desktop"],serverUrl:le,includeRelay:Qe,includeDirect:dt}),an=Km({pairingId:Ut.id,secret:Ut.secret,label:ks.label,fingerprint:Ut.fingerprint??void 0,expiresAt:Ut.expiresAt,candidates:ks.candidates}),bs=zm(an);mt(bs),Ae(await jd.toDataURL(bs,{width:1024,margin:2,errorCorrectionLevel:"L"})),Pe(!1),ai.current=!1,W(Ut.id),ut("result"),await Ws({silent:!0})}catch(R){_e(R instanceof Error?R.message:String(R))}finally{Ve(!1)}}},[a,Ft,jt,Yt,ht,Ws]),Ti=l.useCallback(()=>{Xe&&qa(Xe).then(R=>{R.ok&&(Pe(!0),window.setTimeout(()=>Pe(!1),2e3))})},[Xe]),Io=l.useCallback(async R=>{if(!a)return;const le=R.clientKind==="desktop-local";_e(null);try{if(await a.revokeClient(R.id),le&&us()){const Qe=await Nl();await Sl({hosts:Qe.hosts,defaultHostId:Qe.defaultHostId,initialHostChoiceCompleted:Qe.initialHostChoiceCompleted,localClientToken:null}),nt(dt=>dt.map(Ut=>Ut.id===R.id?{...Ut,revokedAt:new Date().toISOString()}:Ut)),Um({apiBaseUrl:ki(),clientToken:null,runtimeKey:"local"});return}await Ws()}catch(Qe){_e(Qe instanceof Error?Qe.message:String(Qe))}},[a,Ws]),Po=l.useCallback(async()=>{if(a){_e(null);try{await a.purgeRevokedClients(),await Ws()}catch(R){_e(R instanceof Error?R.message:String(R))}}},[a,Ws]);l.useEffect(()=>{M(x)},[x]),l.useEffect(()=>{Mt(!1)},[S]),l.useEffect(()=>{if(!S)return;const R=window.setInterval(()=>{typeof document<"u"&&document.visibilityState!=="visible"||p()},2e3);return()=>{window.clearInterval(R)}},[p,S]),l.useEffect(()=>{let R=null,le=Date.now();const Qe=()=>{const Ut=Date.now();Ut-le>=1e3&&(fe(Ut),le=Ut),R=requestAnimationFrame(Qe)};(typeof document>"u"||document.visibilityState==="visible")&&(R=requestAnimationFrame(Qe));const dt=()=>{document.visibilityState==="visible"&&R===null?R=requestAnimationFrame(Qe):document.visibilityState!=="visible"&&R!==null&&(cancelAnimationFrame(R),R=null)};return document.addEventListener("visibilitychange",dt),()=>{document.removeEventListener("visibilitychange",dt),R!==null&&cancelAnimationFrame(R)}},[]);const Ns=S?o[S]:null,dn=Ns?.phase,ka=dn==="ready",Mn=dn==="degraded",Qn=nl(dn),un=ka||(Qn||Mn),Ao=Ns?Math.max(0,je-Ns.updatedAtMs):0,wa=Mn&&Ao>12e3,Na=ac(dn),na=Na==="error"?Kx(Ns?.detail):null,ii=zx(na),To=l.useMemo(()=>!T||!x?!1:JSON.stringify(T)!==JSON.stringify(x),[T,x]),fs=l.useCallback(R=>{M(le=>le&&R(le))},[]),Eo=l.useCallback(async()=>{if(!T)return;const R=Jx(T);if(!R.sshCommand.trim()){U.error(t("settings.remoteInstances.page.toast.sshCommandRequired"));return}if(R.remoteOpenchamber.mode==="external"&&!R.remoteOpenchamber.preferredPort){U.error(t("settings.remoteInstances.page.validation.externalPortRequired")),Mt(!0);return}if(R.remoteOpenchamber.mode==="managed"&&R.remoteOpenchamber.bindHost==="0.0.0.0"&&!R.auth.openchamberPassword?.value?.trim()){U.error(t("settings.remoteInstances.page.validation.remoteLanNeedsPassword")),Mt(!0),window.setTimeout(()=>Ia.current?.focus(),0);return}if(!(R.localForward.bindHost==="0.0.0.0"&&!await w("settings.remoteInstances.page.confirm.bindAllInterfaces"))){if(R.auth.sshPassword?.enabled&&R.auth.sshPassword.value?.trim()&&R.auth.sshPassword.store!=="settings"){const le=await w("settings.remoteInstances.page.confirm.storeSshPasswordPlaintext");if(le===null)return;R.auth.sshPassword.store=le?"settings":"never",le||(R.auth.sshPassword.value=void 0)}if(R.auth.openchamberPassword?.enabled&&R.auth.openchamberPassword.value?.trim()&&R.auth.openchamberPassword.store!=="settings"){const le=await w("settings.remoteInstances.page.confirm.storeUiPasswordPlaintext");if(le===null)return;R.auth.openchamberPassword.store=le?"settings":"never",le||(R.auth.openchamberPassword.value=void 0)}try{await b(R),U.success(t("settings.remoteInstances.page.toast.instanceSaved"))}catch(le){U.error(t("settings.remoteInstances.page.toast.saveFailed"),{description:le instanceof Error?le.message:String(le)})}}},[w,T,t,b]),Sa=l.useCallback(async(R,le)=>{const Qe=`ssh-${Date.now()}-${Math.random().toString(16).slice(2)}`;try{return await C(Qe,`ssh ${le}`,R),N(Qe),U.success(t("settings.remoteInstances.page.toast.instanceCreated")),!0}catch(dt){return U.error(t("settings.remoteInstances.sidebar.toast.createFailed"),{description:dt instanceof Error?dt.message:String(dt)}),!1}},[C,N,t]),Ca=l.useCallback(()=>{B||(q(null),ae(""))},[B]),Do=l.useCallback((R,le)=>{if($s(!1),le){q(R),ae($x(R));return}Sa(R,R)},[Sa]),Ei=l.useMemo(()=>sa(r,sn,R=>[R.host,R.sshCommand]),[r,sn]),Mo=l.useCallback(R=>{const le=(R||"").trim();if(!le){U.error(t("settings.remoteInstances.page.toast.instanceUrlUnavailable"));return}qi(le)},[t]),Yn=l.useCallback(async()=>{const R=H,le=Z.trim();if(R){if(!le){U.error(t("settings.remoteInstances.page.toast.destinationRequired"));return}G(!0);try{await Sa(R,le)&&(q(null),ae(""))}finally{G(!1)}}},[Sa,Z,H,t]),jn=l.useCallback(async()=>{if(x)try{await k(x.id);return}catch(R){if(!Ox(R)||!await w("settings.remoteInstances.sidebar.confirm.localPortInUseRetry","settings.remoteInstances.sidebar.actions.retry"))throw R;const Qe={...x,localForward:{...x.localForward,preferredLocalPort:Xi()}};await b(Qe),await k(Qe.id),U.success(t("settings.remoteInstances.sidebar.toast.retriedWithRandomPort"))}},[w,k,x,t,b]),Ia=l.useRef(null),Di=l.useRef(null),Pa=l.useCallback(async R=>{if(x){if(R==="localPort"){const le={...x,localForward:{...x.localForward,preferredLocalPort:Xi()}};try{await b(le),await k(le.id),U.success(t("settings.remoteInstances.sidebar.toast.retriedWithRandomPort"))}catch(Qe){U.error(t("settings.remoteInstances.page.toast.connectFailed"),{description:Qe instanceof Error?Qe.message:String(Qe)})}return}Mt(!0),window.setTimeout(()=>{if(R==="uiPassword"){Ia.current?.focus();return}Di.current?.scrollIntoView({block:"center"})},0)}},[k,x,t,b]),Aa=l.useCallback(async R=>(await Eu(R,600)).map(Qe=>Hx(Qe)),[]),Ro=l.useCallback(async()=>{if(T){D(!0),L(!0),j(null);try{const R=await Aa(T.id);K(R)}catch(R){K([]),j(R instanceof Error?R.message:String(R))}finally{L(!1)}}},[T,Aa]);l.useEffect(()=>{if(!E||!T)return;let R=!1;const le=async()=>{try{const dt=await Aa(T.id);R||(K(dt),j(null))}catch(dt){R||j(dt instanceof Error?dt.message:String(dt))}};le();const Qe=window.setInterval(()=>{typeof document<"u"&&document.visibilityState!=="visible"||le()},1e3);return()=>{R=!0,window.clearInterval(Qe)}},[T,E,Aa]);const we=l.useMemo(()=>O.join(`
|
|
28
|
-
`),[O]),Is=l.useCallback(()=>{if(!we.trim()){U.error(t("settings.remoteInstances.page.toast.noLogsToCopy"));return}qa(we).then(R=>{R.ok&&U.success(t("settings.remoteInstances.page.toast.logsCopied"))})},[we,t]),Ta=l.useCallback(async()=>{if(T)try{await Du(T.id),K([]),U.success(t("settings.remoteInstances.page.toast.logsCleared"))}catch(R){U.error(t("settings.remoteInstances.page.toast.clearLogsFailed"),{description:R instanceof Error?R.message:String(R)})}},[T,t]),Mi=l.useCallback(async()=>{if(!Ns?.localUrl){U.error(t("settings.remoteInstances.page.toast.instanceUrlUnavailable"));return}const R=Ns.localUrl.trim();if(!R){U.error(t("settings.remoteInstances.page.toast.instanceUrlUnavailable"));return}qi(R)},[Ns?.localUrl,t]),Ri=l.useCallback(()=>{if(!T)return;if(!un&&T.remoteOpenchamber.mode==="external"&&!T.remoteOpenchamber.preferredPort){U.error(t("settings.remoteInstances.page.validation.externalPortRequired")),Mt(!0);return}if(!un&&T.remoteOpenchamber.mode==="managed"&&T.remoteOpenchamber.bindHost==="0.0.0.0"&&!T.auth.openchamberPassword?.value?.trim()){U.error(t("settings.remoteInstances.page.validation.remoteLanNeedsPassword")),Mt(!0),window.setTimeout(()=>Ia.current?.focus(),0);return}Q(!0),(un?u(T.id):jn()).catch(le=>{const Qe=un?ka?"settings.remoteInstances.page.toast.disconnectFailed":"settings.remoteInstances.page.toast.cancelConnectionFailed":"settings.remoteInstances.page.toast.connectFailed";U.error(t(Qe),{description:le instanceof Error?le.message:String(le)})}).finally(()=>{Q(!1)})},[un,jn,u,T,ka,t]),Oi=l.useCallback(()=>{if(!T||Qn)return;pe(!0),(Mn?u(T.id).then(()=>jn()):y(T.id)).catch(le=>{U.error(t("settings.remoteInstances.page.toast.retryFailed"),{description:le instanceof Error?le.message:String(le)})}).finally(()=>{pe(!1)})},[jn,u,T,Qn,Mn,y,t]),Li=t(Qn?"settings.remoteInstances.page.actions.connecting":Mn?wa?"settings.remoteInstances.page.actions.reconnectNow":"settings.remoteInstances.page.actions.reconnecting":"settings.remoteInstances.sidebar.actions.retry"),Fi=!te&&!X&&(dn==="error"||dn==="idle"||!dn||Mn&&wa)&&!Qn,Oo=t(ka?"settings.remoteInstances.sidebar.actions.disconnect":un?"settings.remoteInstances.page.actions.cancel":"settings.remoteInstances.sidebar.actions.connect");if(!T)return s.jsxs(ns,{title:t("settings.page.remoteInstances.title"),children:[a?s.jsxs(He,{title:t("settings.remoteInstances.clientAuth.title"),info:t("settings.remoteInstances.clientAuth.description"),divider:!1,settingsItem:"remote-instances.client-auth",contentClassName:"space-y-3",children:[s.jsx("div",{children:s.jsxs(V,{type:"button",size:"xs",className:"!font-normal",onClick:()=>{So()},children:[s.jsx($,{name:"add",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.clientAuth.actions.addDevice")]})}),s.jsxs("div",{className:"space-y-2.5",children:[gs>0?s.jsx("div",{className:"flex justify-end",children:s.jsx(V,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{Po()},children:t("settings.remoteInstances.clientAuth.actions.clearRevoked")})}):null,ft&&J.length===0&&ot.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.clientAuth.state.loading")}):J.length===0&&ot.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.clientAuth.state.empty")}):s.jsxs(s.Fragment,{children:[ot.map(R=>s.jsxs("div",{className:"flex items-center justify-between gap-3 py-1.5",children:[s.jsxs("div",{className:"min-w-0 space-y-0.5",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{className:"h-2 w-2 shrink-0 rounded-full bg-[var(--status-warning)] animate-pulse"}),s.jsx("p",{className:"typography-ui-label text-foreground truncate",children:R.label||t("settings.remoteInstances.clientAuth.field.labelPlaceholder")}),R.usesRelay?s.jsx("span",{className:"typography-micro text-muted-foreground bg-muted px-1 rounded shrink-0 leading-none pb-px border border-border/50",children:t("settings.remoteInstances.clientAuth.state.viaRelay")}):null]}),s.jsx("p",{className:"typography-micro text-muted-foreground truncate",children:t("settings.remoteInstances.clientAuth.state.pending")})]}),s.jsx(V,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{Pi(R.id)},children:t("settings.common.actions.cancel")})]},`pending-${R.id}`)),J.map(R=>{const le=R.clientKind==="desktop-local",Qe=R.lastUsedAt?Date.parse(R.lastUsedAt):Number.NaN,dt=!R.revokedAt&&(le||Number.isFinite(Qe)&&Date.now()-Qe<9e4),Ut=R.revokedAt?t("settings.remoteInstances.clientAuth.state.revoked"):dt?R.lastTransport==="relay"&&!le?t("settings.remoteInstances.clientAuth.state.connectedRelay"):t("settings.remoteInstances.clientAuth.state.connectedDirect"):Number.isFinite(Qe)?t("settings.remoteInstances.clientAuth.lastUsed",{date:Mu(Qe,e,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}):t("settings.remoteInstances.clientAuth.neverUsed");return s.jsxs("div",{className:"flex items-center justify-between gap-3 py-1.5",children:[s.jsx("div",{className:"min-w-0",children:s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5",children:[s.jsx("span",{className:Ne("h-2 w-2 shrink-0 rounded-full",R.revokedAt?"bg-muted-foreground/20":dt?"bg-[var(--status-success)]":"bg-muted-foreground/30")}),s.jsx("p",{className:"typography-ui-label text-foreground truncate",children:R.label}),sc(R.devicePlatform)?s.jsx("span",{className:"typography-micro text-muted-foreground bg-muted px-1 rounded shrink-0 leading-none pb-px border border-border/50",children:sc(R.devicePlatform)}):null,le?s.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:t("settings.remoteInstances.clientAuth.state.thisDevice")}):null,s.jsx("span",{className:Ne("typography-micro truncate",dt&&!R.revokedAt?"text-[var(--status-success)]":"text-muted-foreground"),children:Ut})]})}),s.jsx(V,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{Io(R)},disabled:!!R.revokedAt,children:t("settings.remoteInstances.clientAuth.actions.revoke")})]},R.id)})]})]}),At?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:At}):null]}):null,n?s.jsxs(He,{title:t("settings.remoteInstances.direct.title"),info:t("settings.remoteInstances.direct.description"),settingsItem:"remote-instances.direct-hosts",contentClassName:"space-y-4",headerAction:s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsx(V,{type:"button",size:"xs",className:"!font-normal",onClick:()=>{Le(null),pt(!0)},disabled:ve,children:t("settings.remoteInstances.direct.import.action")}),s.jsxs(V,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Le(null),$e(!0)},disabled:ve,children:[s.jsx($,{name:"add",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.direct.actions.add")]})]}),children:[s.jsx("div",{className:"space-y-2.5",children:ue?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.direct.state.loading")}):ke.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.direct.state.empty")}):ke.map(R=>{const le=De[R.id],Qe=le?le.status==="ok"?"desktopHostSwitcher.status.connected":le.status==="auth"?"desktopHostSwitcher.status.authRequired":le.status==="update-recommended"?"desktopHostSwitcher.status.updateRecommended":le.status==="incompatible"?"desktopHostSwitcher.status.incompatible":le.status==="wrong-service"?"desktopHostSwitcher.status.wrongService":"desktopHostSwitcher.status.unreachable":"desktopHostSwitcher.status.checking",dt=le?.status==="ok";return s.jsx("div",{className:"py-1.5",children:s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0 space-y-0.5",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{className:Ne("h-2 w-2 shrink-0 rounded-full",le?dt?"bg-[var(--status-success)]":"bg-[var(--status-error)]":"bg-muted-foreground/30 animate-pulse")}),s.jsx("p",{className:"typography-ui-label text-foreground truncate",children:oi(R.label)}),ee===R.id?s.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:t("desktopHostSwitcher.header.default")}):null,s.jsxs("span",{className:Ne("typography-micro shrink-0",dt?"text-[var(--status-success)]":"text-muted-foreground"),children:[t(Qe),dt&&typeof le?.latencyMs=="number"?t("desktopHostSwitcher.status.ping",{ms:Math.max(0,Math.round(le.latencyMs))}):""]})]}),s.jsx("p",{className:Ne("typography-micro text-muted-foreground truncate",R.apiUrl&&"font-mono"),children:R.relay&&!R.apiUrl?t("mobile.connect.relay.badge"):oi(R.apiUrl||R.url)})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s.jsx(V,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{No(R.id)},disabled:ve||ee===R.id,"aria-label":t("desktopHostSwitcher.actions.setAsDefaultAria"),children:ee===R.id?s.jsx($,{name:"star-fill",className:"h-3.5 w-3.5"}):s.jsx($,{name:"star",className:"h-3.5 w-3.5"})}),R.relay&&!R.apiUrl?null:s.jsxs(V,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>ko(R),disabled:ve,children:[s.jsx($,{name:"pencil",className:"h-3.5 w-3.5"}),t("desktopHostSwitcher.actions.edit")]}),s.jsxs(V,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{jo(R.id)},disabled:ve,children:[s.jsx($,{name:"delete-bin",className:"h-3.5 w-3.5"}),t("settings.common.actions.delete")]})]})]})},R.id)})}),Ke&&!Ye&&!Se&&!yt?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:Ke}):null]}):null,n?s.jsx(_t,{open:Se,onOpenChange:$e,children:s.jsxs($t,{className:"sm:max-w-lg",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:t("settings.remoteInstances.direct.actions.add")}),s.jsx(qt,{children:t("settings.remoteInstances.direct.addDialog.description")})]}),s.jsxs("form",{className:"space-y-3",onSubmit:R=>{R.preventDefault(),vo()},children:[s.jsx(Ge,{className:"h-8",value:Me,onChange:R=>me(R.target.value),placeholder:t("settings.remoteInstances.direct.field.labelPlaceholder"),disabled:ve}),s.jsx(Ge,{className:"h-8",value:Te,onChange:R=>Oe(R.target.value),placeholder:t("settings.remoteInstances.direct.field.urlPlaceholder"),disabled:ve,autoFocus:!0}),s.jsxs("div",{className:"space-y-1",children:[s.jsx(Ge,{className:"h-8",value:ge,onChange:R=>xe(R.target.value),placeholder:t("settings.remoteInstances.direct.field.tokenPlaceholder"),type:"password",disabled:ve}),s.jsx("p",{className:"px-1 typography-micro text-muted-foreground",children:t("settings.remoteInstances.direct.note")})]}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(An,{children:t("settings.remoteInstances.direct.headers.title")}),s.jsx(Gt,{children:t("settings.remoteInstances.direct.headers.description")})]}),ne.map(R=>s.jsxs("div",{className:"flex w-full gap-2",children:[s.jsx(Ge,{className:"h-8 font-mono text-xs",value:R.name,onChange:le=>ie(Qe=>Qe.map(dt=>dt.id===R.id?{...dt,name:le.target.value}:dt)),placeholder:t("settings.remoteInstances.direct.headers.field.namePlaceholder"),disabled:ve}),s.jsx(Ge,{className:"h-8 font-mono text-xs",value:R.value,onChange:le=>ie(Qe=>Qe.map(dt=>dt.id===R.id?{...dt,value:le.target.value}:dt)),placeholder:t("settings.remoteInstances.direct.headers.field.valuePlaceholder"),type:"password",disabled:ve}),s.jsx("button",{type:"button",onClick:()=>ie(le=>le.filter(Qe=>Qe.id!==R.id)),className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-[var(--status-error-background)] hover:text-[var(--status-error)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":t("settings.remoteInstances.direct.headers.removeAria"),disabled:ve,children:s.jsx($,{name:"close",className:"h-4 w-4"})})]},R.id)),s.jsxs(V,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>ie(R=>[...R,Cr()]),disabled:ve,children:[s.jsx($,{name:"add",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.direct.headers.actions.add")]})]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(V,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>$e(!1),disabled:ve,children:t("settings.common.actions.cancel")}),s.jsx(V,{type:"submit",size:"xs",className:"!font-normal",disabled:ve||!Te.trim(),children:t("settings.remoteInstances.direct.actions.add")})]}),Ke?s.jsx("p",{role:"alert",className:"typography-meta text-[var(--status-error)]",children:Ke}):null]})]})}):null,n?s.jsx(_t,{open:!!yt,onOpenChange:R=>{R||st(null)},children:s.jsxs($t,{className:"sm:max-w-lg",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:t("desktopHostSwitcher.actions.edit")}),s.jsx(qt,{children:t("settings.remoteInstances.direct.description")})]}),s.jsxs("form",{className:"space-y-3",onSubmit:R=>{R.preventDefault(),Ci()},children:[s.jsx(Ge,{className:"h-8",value:rt,onChange:R=>de(R.target.value),placeholder:t("settings.remoteInstances.direct.field.labelPlaceholder"),disabled:ve}),s.jsx(Ge,{className:"h-8",value:Ue,onChange:R=>et(R.target.value),placeholder:t("settings.remoteInstances.direct.field.urlPlaceholder"),disabled:ve,autoFocus:!0}),s.jsx(Ge,{className:"h-8",value:ze,onChange:R=>Ze(R.target.value),placeholder:t("settings.remoteInstances.direct.field.tokenPlaceholder"),type:"password",disabled:ve}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(An,{children:t("settings.remoteInstances.direct.headers.title")}),s.jsx(Gt,{children:t("settings.remoteInstances.direct.headers.description")})]}),tt.map(R=>s.jsxs("div",{className:"flex w-full gap-2",children:[s.jsx(Ge,{className:"h-8 font-mono text-xs",value:R.name,onChange:le=>lt(Qe=>Qe.map(dt=>dt.id===R.id?{...dt,name:le.target.value}:dt)),placeholder:t("settings.remoteInstances.direct.headers.field.namePlaceholder"),disabled:ve}),s.jsx(Ge,{className:"h-8 font-mono text-xs",value:R.value,onChange:le=>lt(Qe=>Qe.map(dt=>dt.id===R.id?{...dt,value:le.target.value}:dt)),placeholder:t("settings.remoteInstances.direct.headers.field.valuePlaceholder"),type:"password",disabled:ve}),s.jsx("button",{type:"button",onClick:()=>lt(le=>le.filter(Qe=>Qe.id!==R.id)),className:"flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-[var(--status-error-background)] hover:text-[var(--status-error)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":t("settings.remoteInstances.direct.headers.removeAria"),disabled:ve,children:s.jsx($,{name:"close",className:"h-4 w-4"})})]},R.id)),s.jsxs(V,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>lt(R=>[...R,Cr()]),disabled:ve,children:[s.jsx($,{name:"add",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.direct.headers.actions.add")]})]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(V,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>st(null),disabled:ve,children:t("settings.common.actions.cancel")}),s.jsx(V,{type:"submit",size:"xs",className:"!font-normal",disabled:ve,children:t("settings.common.actions.saveChanges")})]}),Ke?s.jsx("p",{role:"alert",className:"typography-meta text-[var(--status-error)]",children:Ke}):null]})]})}):null,n?s.jsx(_t,{open:Ye,onOpenChange:R=>{vt||pt(R)},children:s.jsxs($t,{className:"sm:max-w-lg",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:t("settings.remoteInstances.direct.import.action")}),s.jsx(qt,{children:t("settings.remoteInstances.direct.import.description")})]}),s.jsxs("form",{className:"space-y-3","aria-busy":vt,onSubmit:async R=>{if(R.preventDefault(),!(vt||ve)){wt(!0);try{await yo()}catch{Le(t("mobile.connect.error.unreachable"))}finally{wt(!1)}}},children:[s.jsx(Ge,{className:"h-8",value:he,onChange:R=>{Ee(R.target.value),Le(null)},placeholder:t("settings.remoteInstances.direct.import.placeholder"),disabled:ve||vt,"aria-describedby":Ke?"direct-import-error":void 0,autoFocus:!0}),Ke?s.jsx("p",{id:"direct-import-error",role:"alert",className:"typography-meta text-[var(--status-error)]",children:Ke}):null,s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(V,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>pt(!1),disabled:ve||vt,children:t("settings.common.actions.cancel")}),s.jsx(V,{type:"submit",size:"xs",className:"!font-normal",disabled:ve||vt||!he.trim(),children:t("settings.remoteInstances.direct.import.action")})]})]})]})}):null,s.jsx(_t,{open:Je,onOpenChange:se,children:s.jsxs($t,{className:We==="result"?"sm:max-w-lg":"sm:max-w-md",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:t(We==="result"?"settings.remoteInstances.clientAuth.qrDialogTitle":"settings.remoteInstances.clientAuth.actions.addDevice")}),s.jsx(qt,{children:t(We==="result"?"settings.remoteInstances.clientAuth.qrScanHint":"settings.remoteInstances.clientAuth.addDevice.subtitle")})]}),We==="configure"?s.jsxs("form",{className:"space-y-4",onSubmit:R=>{R.preventDefault(),Co()},children:[s.jsx(Ge,{className:"h-8",value:ht,onChange:R=>St(R.target.value),placeholder:t("settings.remoteInstances.clientAuth.field.labelPlaceholder"),autoFocus:!0}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("p",{className:"typography-ui-label text-foreground",children:t("settings.remoteInstances.clientAuth.addDevice.transportLabel")}),s.jsx("div",{role:"radiogroup","aria-label":t("settings.remoteInstances.clientAuth.addDevice.transportLabel"),className:"space-y-1.5",children:[{key:"relay",label:t("settings.remoteInstances.clientAuth.addDevice.transport.relay"),hint:t("settings.remoteInstances.clientAuth.addDevice.transport.relayHint"),available:!!Ft?.relayAvailable},{key:"lan",label:t("settings.remoteInstances.clientAuth.addDevice.transport.lan"),hint:t("settings.remoteInstances.clientAuth.addDevice.transport.lanHint"),available:!!Ft?.lanUrl},{key:"local",label:t("settings.remoteInstances.clientAuth.addDevice.transport.local"),hint:t("settings.remoteInstances.clientAuth.addDevice.transport.localHint"),available:!!Ft?.localUrl}].map(R=>{const le=jt===R.key;return s.jsxs("div",{className:Ne("flex items-start gap-2 py-0.5",R.available?"cursor-pointer":"opacity-45"),onClick:()=>{R.available&&Ot(R.key)},role:"presentation",children:[s.jsx(Fr,{checked:le,disabled:!R.available,onChange:()=>Ot(R.key),ariaLabel:R.label,className:"mt-0.5"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:Ne("typography-ui-label font-normal",le?"text-foreground":"text-foreground/70"),children:R.label}),s.jsx("p",{className:"typography-meta text-muted-foreground",children:R.hint})]})]},R.key)})}),jt==="lan"?s.jsxs("label",{className:"flex w-fit cursor-pointer items-center gap-2 pt-1",children:[s.jsx(gr,{checked:Yt,onChange:Zt,ariaLabel:t("settings.remoteInstances.clientAuth.addDevice.fallback.relay")}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.clientAuth.addDevice.fallback.relay")})]}):null,jt==="relay"&&Ft?.lanUrl?s.jsxs("label",{className:"flex w-fit cursor-pointer items-center gap-2 pt-1",children:[s.jsx(gr,{checked:Yt,onChange:Zt,ariaLabel:t("settings.remoteInstances.clientAuth.addDevice.fallback.preferLocal")}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.clientAuth.addDevice.fallback.preferLocal")})]}):null]}),At?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:At}):null,s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(V,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>se(!1),disabled:Ce,children:t("settings.common.actions.cancel")}),s.jsx(V,{type:"submit",size:"xs",className:"!font-normal",disabled:Ce||!Ft,children:t("settings.remoteInstances.clientAuth.addDevice.create")})]})]}):s.jsxs("div",{className:"space-y-3",children:[ye?s.jsx("div",{className:"flex justify-center",children:s.jsx("img",{src:ye,alt:t("settings.remoteInstances.clientAuth.qrAlt"),className:"w-full max-w-[420px] rounded-md bg-white p-4"})}):null,Xe?s.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-[var(--interactive-border)] p-2",children:[s.jsx("code",{className:"min-w-0 flex-1 truncate typography-code text-muted-foreground",children:Xe}),s.jsxs(V,{type:"button",variant:"outline",size:"xs",className:"!font-normal shrink-0",onClick:Ti,children:[s.jsx($,{name:Y?"check":"file-copy",className:Ne("h-3.5 w-3.5",Y&&"text-[var(--status-success)]")}),t(Y?"settings.remoteInstances.clientAuth.actions.copied":"settings.common.actions.copyAll")]})]}):null,s.jsx("div",{className:"flex justify-end",children:s.jsx(V,{type:"button",size:"xs",className:"!font-normal",onClick:()=>se(!1),children:t("settings.remoteInstances.clientAuth.addDevice.done")})})]})]})}),n?s.jsx(He,{title:t("settings.remoteInstances.sidebar.title"),description:t("settings.remoteInstances.sidebar.total",{count:i.length}),headerAction:s.jsxs(V,{type:"button",size:"xs",className:"!font-normal",onClick:Ii,children:[s.jsx($,{name:"add",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.sidebar.actions.addSshInstance")]}),contentClassName:"space-y-2.5",children:d?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.page.state.loadingInstances")}):i.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:r.length===1?t("settings.remoteInstances.page.empty.noInstancesWithOneImport"):r.length>1?t("settings.remoteInstances.page.empty.noInstancesWithImports",{count:r.length}):t("settings.remoteInstances.page.empty.noInstances")}):i.map(R=>{const le=o[R.id],Qe=R.nickname?.trim()||R.sshParsed?.destination||R.id,dt=le?.phase,Ut=dt==="ready",ks=ac(dt),an=ks==="error"?le?.detail:void 0;return s.jsxs("div",{className:"space-y-1.5 py-1.5",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0 space-y-0.5",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{className:`h-2 w-2 rounded-full ${rc(dt)}`}),s.jsx("p",{className:"typography-ui-label text-foreground truncate",children:Qe})]}),s.jsxs("p",{className:"typography-micro text-muted-foreground truncate",children:[t(ic(ks)),ks==="connecting"?` · ${t(nc(dt))}`:"",Ut&&le?.localUrl?` · ${le.localUrl}`:""]})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[Ut?s.jsxs(V,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>Mo(le?.localUrl),children:[s.jsx($,{name:"external-link",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.page.actions.open")]}):null,s.jsxs(V,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{(Ut?u(R.id):k(R.id)).catch(Hs=>U.error(t(Ut?"settings.remoteInstances.sidebar.toast.disconnectFailed":"settings.remoteInstances.sidebar.toast.connectFailed"),{description:Hs instanceof Error?Hs.message:String(Hs)}))},children:[Ut?s.jsx($,{name:"stop",className:"h-3.5 w-3.5"}):s.jsx($,{name:"plug-2",className:"h-3.5 w-3.5"}),t(Ut?"settings.remoteInstances.sidebar.actions.disconnect":"settings.remoteInstances.sidebar.actions.connect")]}),s.jsxs(V,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>N(R.id),children:[s.jsx($,{name:"pencil",className:"h-3.5 w-3.5"}),t("desktopHostSwitcher.actions.edit")]}),s.jsxs(V,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{window.confirm(t("settings.remoteInstances.page.confirm.removeInstance"))&&v(R.id).catch(Hs=>U.error(t("settings.remoteInstances.page.toast.removeInstanceFailed"),{description:Hs instanceof Error?Hs.message:String(Hs)}))},children:[s.jsx($,{name:"delete-bin",className:"h-3.5 w-3.5"}),t("settings.common.actions.delete")]})]})]}),an?s.jsx("p",{className:"typography-micro text-[var(--status-error)] break-words",children:an}):null]},R.id)})}):null,n?s.jsx(_t,{open:tn,onOpenChange:$s,children:s.jsxs($t,{className:"sm:max-w-lg",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:t("settings.remoteInstances.sidebar.actions.addSshInstance")}),s.jsx(qt,{children:t("settings.remoteInstances.page.addDialog.description")})]}),s.jsx(Xs,{value:Bs,onChange:cn,"aria-label":t("settings.remoteInstances.page.addDialog.sourceLabel"),options:[{value:"saved",label:t("settings.remoteInstances.page.addDialog.tab.saved")},{value:"manual",label:t("settings.remoteInstances.page.addDialog.tab.manual")}]}),Bs==="saved"?s.jsxs("div",{className:"space-y-2",children:[s.jsx(Ge,{className:"h-8",value:sn,onChange:R=>nn(R.target.value),placeholder:t("settings.remoteInstances.page.addDialog.searchPlaceholder"),autoFocus:!0}),c?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.page.import.loading")}):r.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.page.addDialog.emptySaved")}):Ei.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.page.addDialog.searchEmpty")}):s.jsx("div",{className:"max-h-[45vh] overflow-auto",children:Ei.map(R=>s.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--surface-subtle)] py-2.5 last:border-b-0",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"typography-ui-label font-medium text-foreground truncate",children:[R.host,R.pattern?` ${t("settings.remoteInstances.page.import.patternSuffix")}`:""]}),s.jsx("div",{className:"typography-meta text-muted-foreground truncate",children:R.sshCommand})]}),s.jsx(V,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Do(R.host,R.pattern)},children:t("settings.remoteInstances.page.addDialog.use")})]},`${R.source}:${R.host}`))})]}):s.jsxs("form",{className:"space-y-3",onSubmit:R=>{R.preventDefault(),wo()},children:[s.jsx(Ge,{className:"h-8",value:Lt,onChange:R=>Xt(R.target.value),placeholder:t("settings.remoteInstances.page.field.nicknamePlaceholder"),disabled:g}),s.jsx(Ge,{className:"h-8",value:Vs,onChange:R=>Dn(R.target.value),placeholder:t("settings.remoteInstances.page.field.sshCommandPlaceholder"),disabled:g,autoFocus:!0}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(V,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>$s(!1),disabled:g,children:t("settings.common.actions.cancel")}),s.jsx(V,{type:"submit",size:"xs",className:"!font-normal",disabled:g||!Vs.trim(),children:t("settings.common.actions.create")})]})]})]})}):null,s.jsx(_t,{open:!!H,onOpenChange:R=>{R||Ca()},children:s.jsxs($t,{className:"sm:max-w-md",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:t("settings.remoteInstances.page.patternDialog.title")}),s.jsx(qt,{children:H?t("settings.remoteInstances.page.patternDialog.descriptionWithHost",{host:H}):t("settings.remoteInstances.page.patternDialog.description")})]}),s.jsxs("form",{className:"space-y-3",onSubmit:R=>{R.preventDefault(),Yn()},children:[s.jsx(Ge,{value:Z,onChange:R=>ae(R.target.value),placeholder:t("settings.remoteInstances.page.patternDialog.destinationPlaceholder"),autoFocus:!0}),s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsx(V,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:Ca,disabled:B,children:t("settings.common.actions.cancel")}),s.jsx(V,{type:"submit",size:"xs",className:"!font-normal",disabled:B,children:t("settings.remoteInstances.page.actions.create")})]})]})]})})]});const kn=T.remoteOpenchamber.mode==="managed",Zn=kn&&T.remoteOpenchamber.bindHost==="0.0.0.0",Ea=Zn&&!T.auth.openchamberPassword?.value?.trim(),Lo=T.nickname?.trim()||T.sshParsed?.destination||T.id;return s.jsx(_t,{open:!!T,onOpenChange:R=>{R||N(null)},children:s.jsxs($t,{className:"sm:max-w-4xl max-h-[90vh] overflow-auto",children:[s.jsxs("div",{className:"mb-6 px-1",children:[s.jsx("h1",{className:`${mr} truncate`,children:Lo}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2 typography-meta text-muted-foreground",children:[s.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${rc(dn)}`}),s.jsx("span",{className:"text-foreground",children:t(ic(Na))}),Na==="connecting"?s.jsx("span",{children:t(nc(dn))}):null,Ns?.localUrl?s.jsx("span",{className:"font-mono text-foreground/80",children:Ns.localUrl}):null,wa?s.jsx("span",{children:t("settings.remoteInstances.page.status.reconnectStale")}):null]})]}),s.jsxs(He,{title:t("settings.remoteInstances.page.section.actions"),info:t("settings.remoteInstances.page.section.actionsDescription"),divider:!1,contentClassName:"space-y-3",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(V,{type:"button",variant:un?"outline":"default",size:"xs",className:"!font-normal",onClick:Ri,disabled:te||X,children:[un?s.jsx($,{name:"stop",className:"h-3.5 w-3.5"}):s.jsx($,{name:"plug-2",className:"h-3.5 w-3.5"}),Oo]}),s.jsxs(V,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:Oi,disabled:!Fi,children:[s.jsx($,{name:"refresh",className:`h-3.5 w-3.5 ${Qn||Mn&&!wa?"animate-spin":""}`}),Li]}),s.jsxs(V,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Ro()},children:[s.jsx($,{name:"terminal-window",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.page.actions.logs")]}),s.jsxs(V,{type:"button",variant:"outline",size:"xs",className:"!font-normal text-[var(--status-error)] border-[var(--status-error)]/30 hover:text-[var(--status-error)]",onClick:()=>{window.confirm(t("settings.remoteInstances.page.confirm.removeInstance"))&&v(T.id).then(()=>{N(null),U.success(t("settings.remoteInstances.page.toast.instanceRemoved"))}).catch(le=>{U.error(t("settings.remoteInstances.page.toast.removeInstanceFailed"),{description:le instanceof Error?le.message:String(le)})})},children:[s.jsx($,{name:"delete-bin",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.sidebar.actions.remove")]})]}),Na==="error"&&Ns?.detail?s.jsxs("div",{className:"space-y-2 rounded-md border border-[var(--status-error)]/30 bg-[var(--status-error-background)] p-3",children:[s.jsx("p",{className:"typography-meta text-[var(--status-error)] break-words",children:Ns.detail}),ii?s.jsx("p",{className:"typography-micro text-muted-foreground",children:t(ii)}):null,na&&!ii?s.jsx(V,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Pa(na)},children:t(na==="uiPassword"?"settings.remoteInstances.page.error.action.setUiPassword":na==="localPort"?"settings.remoteInstances.page.error.action.pickRandomPort":"settings.remoteInstances.page.error.action.setRemotePort")}):null]}):null,Ns?.localUrl?s.jsxs("div",{className:"flex flex-wrap items-center gap-2 typography-meta text-muted-foreground",children:[s.jsx("span",{children:t("settings.remoteInstances.page.status.currentLocalUrl")}),s.jsx("span",{className:"font-mono text-foreground/90",children:Ns.localUrl})]}):null]}),s.jsxs(He,{title:t("settings.remoteInstances.page.section.instance"),info:t("settings.remoteInstances.page.section.instanceDescription"),contentClassName:"space-y-3",children:[s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("span",{className:"typography-ui-label text-foreground w-56 shrink-0",children:t("settings.remoteInstances.page.field.sshCommand")}),s.jsx(Ge,{className:"h-7 md:max-w-xl",value:T.sshCommand,onChange:R=>fs(le=>({...le,sshCommand:R.target.value})),placeholder:t("settings.remoteInstances.page.field.sshCommandPlaceholder")})]}),s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("span",{className:"typography-ui-label text-foreground w-56 shrink-0",children:t("settings.remoteInstances.page.field.nickname")}),s.jsx(Ge,{className:"h-7 md:max-w-sm",value:T.nickname||"",onChange:R=>fs(le=>({...le,nickname:R.target.value})),placeholder:t("settings.remoteInstances.page.field.nicknamePlaceholder")})]}),s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(on,{label:t("settings.remoteInstances.page.field.mode"),hint:t("settings.remoteInstances.page.field.modeHint")})}),s.jsxs(Dt,{value:T.remoteOpenchamber.mode,onValueChange:R=>fs(le=>({...le,remoteOpenchamber:{...le.remoteOpenchamber,mode:R==="external"?"external":"managed"}})),children:[s.jsx(Tt,{size:Qt,className:"w-fit min-w-[140px]",children:s.jsx(Jt,{placeholder:t("settings.remoteInstances.page.field.modePlaceholder")})}),s.jsxs(Et,{children:[s.jsx(gt,{value:"managed",children:t("settings.remoteInstances.page.field.modeManaged")}),s.jsx(gt,{value:"external",children:t("settings.remoteInstances.page.field.modeExternal")})]})]})]})]}),s.jsxs(bn,{open:Wt,onOpenChange:Mt,children:[s.jsxs(vn,{className:"mt-6 w-auto justify-start gap-1.5",children:[s.jsx("span",{className:td,children:t("settings.remoteInstances.page.section.advanced")}),s.jsx($,{name:Wt?"arrow-up-s":"arrow-down-s",className:"h-4 w-4 text-muted-foreground"})]}),s.jsxs(yn,{children:[s.jsx("p",{className:"px-2 pb-2 typography-micro text-muted-foreground",children:t("settings.remoteInstances.page.section.advancedHint")}),s.jsxs("div",{className:"flex flex-col gap-1.5 px-2 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("span",{className:"typography-ui-label text-foreground w-56 shrink-0",children:t("settings.remoteInstances.page.field.connectionTimeoutSeconds")}),s.jsx(js,{containerClassName:"w-fit",min:5,max:240,step:1,className:Ne(ws,"tabular-nums"),value:T.connectionTimeoutSec,onValueChange:R=>{fs(le=>({...le,connectionTimeoutSec:Number.isFinite(R)?R:le.connectionTimeoutSec}))}})]}),s.jsxs(He,{title:t("settings.remoteInstances.page.section.remoteServer"),info:t("settings.remoteInstances.page.section.remoteServerDescription"),contentClassName:"space-y-3",children:[s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",ref:Di,children:s.jsx(on,{label:t("settings.remoteInstances.page.field.preferredRemotePort"),hint:t("settings.remoteInstances.page.field.preferredRemotePortHint")})}),s.jsx(js,{containerClassName:"w-fit",min:1,max:65535,step:1,className:Ne(ws,"tabular-nums"),value:T.remoteOpenchamber.preferredPort,onValueChange:R=>{fs(le=>({...le,remoteOpenchamber:{...le.remoteOpenchamber,preferredPort:Number.isFinite(R)&&R>0?R:void 0}}))},onClear:()=>{fs(R=>({...R,remoteOpenchamber:{...R.remoteOpenchamber,preferredPort:void 0}}))},emptyLabel:t("settings.remoteInstances.page.field.auto")})]}),kn?s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(on,{label:t("settings.remoteInstances.page.field.installMethod"),hint:t("settings.remoteInstances.page.field.installMethodHint")})}),s.jsxs(Dt,{value:T.remoteOpenchamber.installMethod,onValueChange:R=>fs(le=>({...le,remoteOpenchamber:{...le.remoteOpenchamber,installMethod:R==="npm"||R==="bun"?R:"auto"}})),children:[s.jsx(Tt,{size:Qt,className:"w-fit min-w-[140px]",children:s.jsx(Jt,{placeholder:t("settings.remoteInstances.page.field.selectInstallMethodPlaceholder")})}),s.jsxs(Et,{children:[s.jsx(gt,{value:"auto",children:t("settings.remoteInstances.page.field.installMethodAuto")}),s.jsx(gt,{value:"bun",children:"bun"}),s.jsx(gt,{value:"npm",children:"npm"})]})]})]}):null,kn?s.jsxs("div",{className:"py-1.5",children:[s.jsxs("div",{className:"flex flex-col gap-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(on,{label:t("settings.remoteInstances.page.field.remoteLanAccess"),hint:t("settings.remoteInstances.page.field.remoteLanAccessHint")})}),s.jsx(ga,{checked:Zn,onCheckedChange:R=>fs(le=>({...le,remoteOpenchamber:{...le.remoteOpenchamber,bindHost:R?"0.0.0.0":"127.0.0.1"}})),"aria-label":t("settings.remoteInstances.page.field.remoteLanAccess")})]}),Zn?s.jsx("p",{className:"mt-2 typography-micro text-[var(--status-warning)] md:pl-[16rem]",children:t("settings.remoteInstances.page.field.remoteLanAccessWarning")}):null]}):null,kn?s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(on,{label:t("settings.remoteInstances.page.field.keepServerRunning"),hint:t("settings.remoteInstances.page.field.keepServerRunningHint")})}),s.jsx("div",{className:"flex w-full items-center gap-2 md:max-w-xs",children:s.jsx(ga,{checked:T.remoteOpenchamber.keepRunning,onCheckedChange:R=>fs(le=>({...le,remoteOpenchamber:{...le.remoteOpenchamber,keepRunning:R}}))})})]}):null]}),s.jsxs(He,{title:t("settings.remoteInstances.page.section.mainTunnel"),info:t("settings.remoteInstances.page.section.mainTunnelDescription"),contentClassName:"space-y-3",children:[s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(on,{label:t("settings.remoteInstances.page.field.bindHost"),hint:t("settings.remoteInstances.page.field.bindHostHint")})}),s.jsxs(Dt,{value:T.localForward.bindHost,onValueChange:R=>{R==="0.0.0.0"&&!window.confirm(t("settings.remoteInstances.page.confirm.bindAllInterfaces"))||fs(le=>({...le,localForward:{...le.localForward,bindHost:R==="localhost"||R==="0.0.0.0"?R:"127.0.0.1"}}))},children:[s.jsx(Tt,{size:Qt,className:"w-fit min-w-[240px]",children:s.jsx(Jt,{placeholder:t("settings.remoteInstances.page.field.selectBindHostPlaceholder")})}),s.jsxs(Et,{children:[s.jsx(gt,{value:"127.0.0.1",children:t("settings.remoteInstances.page.field.bindHostOption.loopback")}),s.jsx(gt,{value:"localhost",children:t("settings.remoteInstances.page.field.bindHostOption.localhost")}),s.jsx(gt,{value:"0.0.0.0",children:t("settings.remoteInstances.page.field.bindHostOption.lan")})]})]})]}),s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(on,{label:t("settings.remoteInstances.page.field.preferredLocalPort"),hint:t("settings.remoteInstances.page.field.preferredLocalPortHint")})}),s.jsxs("div",{className:"flex w-full items-center gap-2 md:max-w-sm",children:[s.jsx(js,{containerClassName:"w-fit",min:1,max:65535,step:1,className:Ne(ws,"tabular-nums"),value:T.localForward.preferredLocalPort,onValueChange:R=>{fs(le=>({...le,localForward:{...le.localForward,preferredLocalPort:Number.isFinite(R)&&R>0?R:void 0}}))},onClear:()=>{fs(R=>({...R,localForward:{...R.localForward,preferredLocalPort:void 0}}))},emptyLabel:t("settings.remoteInstances.page.field.auto")}),s.jsx(V,{type:"button",variant:"outline",size:"xs",className:"!font-normal h-7 w-7 px-0",title:t("settings.remoteInstances.page.actions.pickRandomPort"),onClick:()=>fs(R=>({...R,localForward:{...R.localForward,preferredLocalPort:Xi()}})),children:s.jsx($,{name:"shuffle",className:"h-3.5 w-3.5"})})]})]}),s.jsxs("div",{className:"space-y-1 pt-1",children:[s.jsx("p",{className:"typography-micro text-muted-foreground",children:t("settings.remoteInstances.page.tunnelPreview.caption")}),s.jsx("p",{className:"typography-micro font-mono text-foreground/80 break-all",children:`${T.localForward.bindHost}:${T.localForward.preferredLocalPort||"auto"} → ${T.sshParsed?.destination||T.nickname||"remote"}:${T.remoteOpenchamber.preferredPort||"auto"}`})]})]}),s.jsxs(He,{title:t("settings.remoteInstances.page.section.authentication"),info:t("settings.remoteInstances.page.section.authenticationDescription"),contentClassName:"space-y-3",children:[s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(on,{label:t("settings.remoteInstances.page.field.sshPasswordOptional"),hint:t("settings.remoteInstances.page.field.sshPasswordHint")})}),s.jsx(Ge,{className:"h-7 md:max-w-sm",type:"password",value:T.auth.sshPassword?.value||"",onChange:R=>fs(le=>({...le,auth:{...le.auth,sshPassword:{enabled:R.target.value.trim().length>0,value:R.target.value,store:le.auth.sshPassword?.store||"never"}}})),placeholder:t("settings.remoteInstances.page.field.sshPasswordPlaceholder")})]}),s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(on,{label:t(Zn?"settings.remoteInstances.page.field.uiPasswordRequired":"settings.remoteInstances.page.field.uiPasswordOptional"),hint:t(kn?"settings.remoteInstances.page.field.uiPasswordHintManaged":"settings.remoteInstances.page.field.uiPasswordHintExternal")})}),s.jsx(Ge,{className:Ne("h-7 md:max-w-sm",Ea&&"border-[var(--status-error)]"),type:"password",ref:Ia,"aria-invalid":Ea,value:T.auth.openchamberPassword?.value||"",onChange:R=>fs(le=>({...le,auth:{...le.auth,openchamberPassword:{enabled:R.target.value.trim().length>0,value:R.target.value,store:le.auth.openchamberPassword?.store||"never"}}})),placeholder:t("settings.remoteInstances.page.field.uiPasswordPlaceholder")})]}),Ea?s.jsx("p",{className:"typography-micro text-[var(--status-error)] md:pl-[16rem]",children:t("settings.remoteInstances.page.field.uiPasswordMissingForLan")}):null]}),s.jsxs(He,{title:t("settings.remoteInstances.page.section.portForwards"),info:t("settings.remoteInstances.page.section.portForwardsDescription"),contentClassName:"space-y-2",children:[T.portForwards.length===0?s.jsx("p",{className:"typography-micro text-muted-foreground/80",children:t("settings.remoteInstances.page.empty.noExtraForwards")}):null,T.portForwards.map((R,le)=>{const Qe=Bt=>{fs(ts=>({...ts,portForwards:ts.portForwards.map((Nn,mn)=>mn===le?Bt(Nn):Nn)}))},dt=R.type==="remote"?"Local target":"Local listen",Ut=R.type==="remote"?"Local host and port on your machine that receives traffic from remote -R listener.":"Local host and port where this forward listens on your machine.",ks=R.type==="remote"?"Remote listen":"Remote target",an=R.type==="remote"?"Remote host and port where SSH creates the -R listener.":"Remote host and port that receives traffic from local -L listener.",bs=lc(R.localHost||"localhost",R.localPort),Hs=lc(R.remoteHost||"localhost",R.remotePort),Rn=R.type==="local"&&typeof R.localPort=="number"&&R.localPort>0,wn=Rn?`http://${Vx(R.localHost)}:${R.localPort}`:"",Da=!!_[R.id],Ma=R.type==="local"?t("settings.remoteInstances.page.forwardType.local"):R.type==="remote"?t("settings.remoteInstances.page.forwardType.remote"):t("settings.remoteInstances.page.forwardType.dynamic");return s.jsxs(bn,{open:Da,onOpenChange:Bt=>{z(ts=>({...ts,[R.id]:Bt}))},className:`${le>0?"border-t border-[var(--surface-subtle)]":""} py-2`,children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"min-w-0 flex items-center gap-2",children:s.jsxs(vn,{className:"flex items-center gap-2 group",children:[s.jsx($,{name:"arrow-down-s",className:`h-4 w-4 text-muted-foreground transition-transform ${Da?"rotate-180":""}`}),s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:Ux(R)}),s.jsx("span",{className:"typography-micro text-muted-foreground/70 shrink-0",children:Ma})]})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ga,{checked:R.enabled,onCheckedChange:Bt=>Qe(ts=>({...ts,enabled:Bt})),"aria-label":t("settings.remoteInstances.page.actions.enableForwardAria")}),s.jsx(V,{type:"button",variant:"ghost",size:"xs",className:"!font-normal h-6 w-6 px-0 text-[var(--status-error)] hover:text-[var(--status-error)]",onClick:()=>fs(Bt=>({...Bt,portForwards:Bt.portForwards.filter(ts=>ts.id!==R.id)})),children:s.jsx($,{name:"delete-bin",className:"h-3.5 w-3.5"})})]})]}),s.jsx(yn,{className:"pt-2",children:s.jsxs("div",{className:"space-y-0 pb-2",children:[s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(on,{label:t("settings.remoteInstances.page.field.forwardType"),hint:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{children:t("settings.remoteInstances.page.field.forwardTypeHint")}),s.jsx("p",{children:t(Bx(R.type))})]})})}),s.jsxs(Dt,{value:R.type,onValueChange:Bt=>Qe(ts=>({...ts,type:Bt==="dynamic"||Bt==="remote"?Bt:"local"})),children:[s.jsx(Tt,{size:Qt,className:"w-fit min-w-[140px]",children:s.jsx(Jt,{placeholder:t("settings.remoteInstances.page.field.typePlaceholder")})}),s.jsxs(Et,{children:[s.jsx(gt,{value:"local",children:t("settings.remoteInstances.page.forwardType.local")}),s.jsx(gt,{value:"remote",children:t("settings.remoteInstances.page.forwardType.remote")}),s.jsx(gt,{value:"dynamic",children:t("settings.remoteInstances.page.forwardType.dynamic")})]})]})]}),s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(on,{label:dt,hint:Ut})}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Ge,{className:"h-7 w-32",value:R.localHost||"127.0.0.1",onChange:Bt=>Qe(ts=>({...ts,localHost:Bt.target.value})),placeholder:t("settings.remoteInstances.page.field.localHostPlaceholder")}),s.jsx("span",{className:"text-muted-foreground",children:":"}),s.jsx(js,{containerClassName:"w-fit",min:1,max:65535,step:1,className:Ne(ws,"tabular-nums"),value:R.localPort,onValueChange:Bt=>{Qe(ts=>({...ts,localPort:Number.isFinite(Bt)&&Bt>0?Bt:void 0}))},onClear:()=>{Qe(Bt=>({...Bt,localPort:void 0}))},emptyLabel:t("settings.remoteInstances.page.field.auto")})]})]}),R.type!=="dynamic"?s.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[s.jsx("div",{className:"w-56 shrink-0",children:s.jsx(on,{label:ks,hint:an})}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(Ge,{className:"h-7 w-32",value:R.remoteHost||"",onChange:Bt=>Qe(ts=>({...ts,remoteHost:Bt.target.value})),placeholder:t("settings.remoteInstances.page.field.remoteHostPlaceholder")}),s.jsx("span",{className:"text-muted-foreground",children:":"}),s.jsx(js,{containerClassName:"w-fit",min:1,max:65535,step:1,className:Ne(ws,"tabular-nums"),value:R.remotePort,onValueChange:Bt=>{Qe(ts=>({...ts,remotePort:Number.isFinite(Bt)&&Bt>0?Bt:void 0}))},onClear:()=>{Qe(Bt=>({...Bt,remotePort:void 0}))},emptyLabel:t("settings.remoteInstances.page.field.auto")})]})]}):null,s.jsxs("div",{className:"mt-2 flex flex-wrap items-center justify-between gap-2 rounded-md bg-[var(--surface-subtle)] p-2",children:[s.jsx("div",{className:"flex flex-wrap items-center gap-1 typography-micro text-muted-foreground/80",children:R.type==="dynamic"?s.jsxs(s.Fragment,{children:[s.jsx($,{name:"computer",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-mono text-foreground",children:bs}),s.jsx("span",{children:t("settings.remoteInstances.page.preview.localSocks5")})]}):R.type==="remote"?s.jsxs(s.Fragment,{children:[s.jsx($,{name:"server",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-mono text-foreground",children:Hs}),s.jsx("span",{children:t("settings.remoteInstances.page.preview.remote")}),s.jsx($,{name:"arrow-right",className:"h-3.5 w-3.5"}),s.jsx($,{name:"computer",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-mono text-foreground",children:bs}),s.jsx("span",{children:t("settings.remoteInstances.page.preview.local")})]}):s.jsxs(s.Fragment,{children:[s.jsx($,{name:"computer",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-mono text-foreground",children:bs}),s.jsx("span",{children:t("settings.remoteInstances.page.preview.local")}),s.jsx($,{name:"arrow-right",className:"h-3.5 w-3.5"}),s.jsx($,{name:"server",className:"h-3.5 w-3.5"}),s.jsx("span",{className:"font-mono text-foreground",children:Hs}),s.jsx("span",{children:t("settings.remoteInstances.page.preview.remote")})]})}),Rn?s.jsxs(V,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Gs(wn).then(Bt=>{Bt||U.error(t("settings.remoteInstances.page.toast.openLocalEndpointFailed"))})},children:[s.jsx($,{name:"external-link",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.page.actions.openLocal")]}):null]})]})})]},R.id)}),s.jsxs(V,{type:"button",variant:"outline",size:"xs",className:"!font-normal mt-1",onClick:()=>{const R=_x();fs(le=>({...le,portForwards:[...le.portForwards,R]})),z(le=>({...le,[R.id]:!0}))},children:[s.jsx($,{name:"add",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.page.actions.addForward")]})]})]})]}),s.jsx("div",{className:"mt-8 border-t border-[var(--interactive-border)] pt-3",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(V,{type:"button",size:"xs",className:"!font-normal",onClick:()=>{Eo()},disabled:!To||g,children:t("settings.common.actions.saveChanges")}),Ns?.localUrl?s.jsxs(s.Fragment,{children:[s.jsxs(V,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{qa(Ns.localUrl||"").then(R=>{R.ok&&U.success(t("settings.remoteInstances.page.toast.localUrlCopied"))})},children:[s.jsx($,{name:"file-copy",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.page.actions.copyLocalUrl")]}),s.jsxs(V,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Mi()},children:[s.jsx($,{name:"external-link",className:"h-3.5 w-3.5"}),t("settings.remoteInstances.page.actions.open")]})]}):null,m?s.jsx("div",{className:"ml-auto typography-meta text-[var(--status-error)]",children:m}):null]})}),A,s.jsx(_t,{open:E,onOpenChange:D,children:s.jsxs($t,{className:"sm:max-w-2xl",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:t("settings.remoteInstances.page.logsDialog.title")}),s.jsx(qt,{children:T?.nickname?.trim()||T?.sshParsed?.destination||T?.id||t("settings.remoteInstances.page.logsDialog.selectedInstanceFallback")})]}),s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsxs(V,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:Is,disabled:F||!we.trim(),children:[s.jsx($,{name:"file-copy",className:"h-3.5 w-3.5"}),t("settings.common.actions.copyAll")]}),s.jsxs(V,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Ta()},disabled:F,children:[s.jsx($,{name:"delete-bin",className:"h-3.5 w-3.5"}),t("settings.common.actions.clear")]})]}),F?s.jsx("div",{className:"typography-meta text-muted-foreground",children:t("settings.remoteInstances.page.logsDialog.loading")}):P?s.jsx("div",{className:"typography-meta text-[var(--status-error)]",children:P}):s.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:O.length>0?O.join(`
|
|
29
|
-
`):t("settings.remoteInstances.page.logsDialog.empty")})]})}),s.jsx(_t,{open:!!H,onOpenChange:R=>{R||Ca()},children:s.jsxs($t,{className:"sm:max-w-md",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:t("settings.remoteInstances.page.patternDialog.title")}),s.jsx(qt,{children:H?t("settings.remoteInstances.page.patternDialog.descriptionWithHost",{host:H}):t("settings.remoteInstances.page.patternDialog.description")})]}),s.jsxs("form",{className:"space-y-3",onSubmit:R=>{R.preventDefault(),Yn()},children:[s.jsx(Ge,{value:Z,onChange:R=>ae(R.target.value),placeholder:t("settings.remoteInstances.page.patternDialog.destinationPlaceholder"),autoFocus:!0}),s.jsxs("div",{className:"flex items-center justify-end gap-2",children:[s.jsx(V,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:Ca,disabled:B,children:t("settings.common.actions.cancel")}),s.jsx(V,{type:"submit",size:"xs",className:"!font-normal",disabled:B,children:t("settings.common.actions.create")})]})]})]})})]})})},Yx=t=>t,Zx=(t,e,a)=>t&&!e&&!a,Xx=Rt(),Ir=t=>Xx.safeParse(t?.settings?.apiKey).data??null,Kn=(t,e)=>t.find(a=>a.id===e),fi=t=>t==="opencode-go"?"opencode":t,eo=(t,e)=>{const a=Kn(t,e)?.connections,n=fi(e);if(n===e)return a;const i=Kn(t,n)?.connections;if(!(!a&&!i))return[...a??[],...i??[]]},dc=t=>(t?.methods??[]).filter(e=>e.type==="oauth"),eb=t=>(t?.methods??[]).find(e=>e.type==="key"),uc=t=>t===void 0||eb(t)!==void 0,mc=t=>(t?.connections??[]).filter(e=>e.type==="credential"),pc=t=>(t.connections?.length??0)>0?!0:typeof t.optionsApiKey=="string"&&t.optionsApiKey.trim().length>0,tb=t=>{if(t.integrations===null)return null;const e=eo(t.integrations,t.providerId),a=(e??[]).filter(n=>n.type==="credential").length;return a>1?{kind:"accounts",count:a}:a===1||(t.optionsApiKey?.trim().length??0)>0?{kind:"connected"}:(e??[]).some(n=>n.type==="env")?{kind:"environment"}:e===void 0?null:{kind:"signInNeeded"}},sb=t=>t.modelCount>0&&(!t.integrationsLoaded||t.hasCredentials||!!t.isEditableCustomProvider),nb=t=>!t.hasCredentials&&!t.userDismissed&&!t.isEditableCustomProvider,al=t=>{const e=Be.c(12),{t:a}=qe();if(t==="zen-promo"){let n;return e[0]!==a?(n=a("settings.classification.source.zenPromo.name"),e[0]=a,e[1]=n):n=e[1],n}if(t==="zen-key"){let n;return e[2]!==a?(n=a("settings.classification.source.zenKey.name"),e[2]=a,e[3]=n):n=e[3],n}if(t==="openrouter"){let n;return e[4]!==a?(n=a("settings.classification.source.openrouter.name"),e[4]=a,e[5]=n):n=e[5],n}if(t==="vercel"){let n;return e[6]!==a?(n=a("settings.classification.source.vercel.name"),e[6]=a,e[7]=n):n=e[7],n}if(t==="typesafe"){let n;return e[8]!==a?(n=a("settings.classification.source.typesafe.name"),e[8]=a,e[9]=n):n=e[9],n}if(t==="custom"){let n;return e[10]!==a?(n=a("settings.classification.source.custom.name"),e[10]=a,e[11]=n):n=e[11],n}return null},lo=()=>{const t=re.getState();t.setSettingsProvidersClassificationRequested(!0),t.requestSettingsJump("providers","providers.classification")},Vn=t=>{const e=Be.c(3),{onClick:a,children:n}=t;let i;return e[0]!==n||e[1]!==a?(i=s.jsx("button",{type:"button",onClick:a,className:"cursor-pointer text-[var(--primary-text)] underline-offset-4 hover:underline focus-visible:underline focus-visible:outline-none",children:n}),e[0]=n,e[1]=a,e[2]=i):i=e[2],i},xo=()=>{const t=Be.c(16),{t:e}=qe(),a=es(ab),n=es(ib),i=es(ob),o=al(i),r=ya();if(!a)return null;if(r&&!n){let h;t[0]!==e?(h=e("settings.jevAccess.enterprise"),t[0]=e,t[1]=h):h=t[1];let f;return t[2]!==h?(f=s.jsx("p",{className:ds,children:h}),t[2]=h,t[3]=f):f=t[3],f}let d;t[4]!==n||t[5]!==o||t[6]!==e?(d=n&&o?e("settings.jevAccess.via",{provider:o}):e("settings.jevAccess.missing"),t[4]=n,t[5]=o,t[6]=e,t[7]=d):d=t[7];let c;t[8]!==n||t[9]!==e?(c=e(n?"settings.jevAccess.manage":"settings.jevAccess.setUp"),t[8]=n,t[9]=e,t[10]=c):c=t[10];let g;t[11]!==c?(g=s.jsx(Vn,{onClick:lo,children:c}),t[11]=c,t[12]=g):g=t[12];let m;return t[13]!==d||t[14]!==g?(m=s.jsxs("p",{className:ds,children:[d," ",g]}),t[13]=d,t[14]=g,t[15]=m):m=t[15],m};function ab(t){return t.available}function ib(t){return t.jevAvailable}function ob(t){return t.classifier?.effective??null}const rb="https://opencode.ai/v2/docs/policies/",lb=t=>{const e=Be.c(3),[a,n]=l.useState(null);let i,o;return e[0]!==t?(i=()=>{let r=!1;return n(null),Ts.configDeniesAnyProvider(t).then(d=>{r||n(d)}).catch(d=>{console.warn("[providers] could not read OpenCode provider policies:",d instanceof Error?d.message:String(d)),r||n(null)}),()=>{r=!0}},o=[t],e[0]=t,e[1]=i,e[2]=o):(i=e[1],o=e[2]),l.useEffect(i,o),a},cb=t=>{const e=Be.c(44),{directory:a,integrations:n}=t,{t:i}=qe(),o=lb(a),r=hr(gb),d=hr(fb),c=n===null?null:(Kn(n,"opencode")?.connections?.length??0)>0,g=o!==!1||c===null?null:c?"console":"open",m=g==="open";let h;e[0]!==i?(h=i("settings.providers.enterprisePolicyLink"),e[0]=i,e[1]=h):h=e[1];let f;e[2]!==h?(f=s.jsx(Vn,{onClick:hb,children:h}),e[2]=h,e[3]=f):f=e[3];const p=f,b=m?"border-[var(--status-warning)]/30 bg-[var(--status-warning)]/5":"border-[var(--status-info-border)] bg-[var(--status-info-background)]/30";let C;e[4]!==b?(C=Ne("mb-4 flex items-start gap-2 rounded-lg border p-3",b),e[4]=b,e[5]=C):C=e[5];const v=m?"error-warning":"information",k=m?"text-[var(--status-warning)]":"text-[var(--status-info)]";let u;e[6]!==k?(u=Ne("mt-0.5 size-4 shrink-0",k),e[6]=k,e[7]=u):u=e[7];let y;e[8]!==v||e[9]!==u?(y=s.jsx($,{name:v,className:u}),e[8]=v,e[9]=u,e[10]=y):y=e[10];let S;e[11]!==i?(S=i("settings.providers.enterpriseTitle"),e[11]=i,e[12]=S):S=e[12];let N;e[13]!==S?(N=s.jsx("p",{className:fr,children:S}),e[13]=S,e[14]=N):N=e[14];let w;e[15]!==r||e[16]!==i?(w=r?s.jsx("p",{className:"typography-meta text-foreground",children:i("settings.providers.enterpriseManagedBy",{organization:r})}):null,e[15]=r,e[16]=i,e[17]=w):w=e[17];let A;e[18]!==d||e[19]!==i?(A=d?s.jsx("p",{className:"typography-meta text-foreground",children:i("settings.providers.enterprisePolicyUnreadable")}):null,e[18]=d,e[19]=i,e[20]=A):A=e[20];let x;e[21]!==i?(x=i("settings.providers.enterpriseMode"),e[21]=i,e[22]=x):x=e[22];let T;e[23]!==x?(T=s.jsx("p",{className:"typography-meta text-muted-foreground",children:x}),e[23]=x,e[24]=T):T=e[24];let M;e[25]!==g||e[26]!==p||e[27]!==i?(M=g==="open"?s.jsxs("p",{className:"typography-meta text-foreground",children:[i("settings.providers.enterprisePolicyMissing")," ",p]}):null,e[25]=g,e[26]=p,e[27]=i,e[28]=M):M=e[28];let E;e[29]!==g||e[30]!==p||e[31]!==i?(E=g==="console"?s.jsxs("p",{className:"typography-meta text-muted-foreground",children:[i("settings.providers.enterprisePolicyConsole")," ",p]}):null,e[29]=g,e[30]=p,e[31]=i,e[32]=E):E=e[32];let D;e[33]!==N||e[34]!==w||e[35]!==A||e[36]!==T||e[37]!==M||e[38]!==E?(D=s.jsxs("div",{className:"min-w-0 space-y-1.5",children:[N,w,A,T,M,E]}),e[33]=N,e[34]=w,e[35]=A,e[36]=T,e[37]=M,e[38]=E,e[39]=D):D=e[39];let F;return e[40]!==D||e[41]!==C||e[42]!==y?(F=s.jsxs("div",{className:C,children:[y,D]}),e[40]=D,e[41]=C,e[42]=y,e[43]=F):F=e[43],F},db=t=>{const e=Be.c(19),{onOpen:a}=t,{t:n}=qe(),i=es(xb),o=es(bb),r=es(vb);if(!i)return null;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=s.jsx($n,{providerId:"typesafe",className:"size-5"}),e[0]=d):d=e[0];let c;e[1]!==n?(c=n("settings.classification.page.title"),e[1]=n,e[2]=c):c=e[2];const g=o?"success":r?"neutral":"warning";let m;e[3]!==o||e[4]!==r||e[5]!==n?(m=n(o?"settings.classification.card.ready":r?"settings.classification.card.off":"settings.classification.card.notSetUp"),e[3]=o,e[4]=r,e[5]=n,e[6]=m):m=e[6];let h;e[7]!==g||e[8]!==m?(h=s.jsx(In,{tone:g,children:m}),e[7]=g,e[8]=m,e[9]=h):h=e[9];let f;e[10]!==n?(f=n("settings.classification.card.usedFor"),e[10]=n,e[11]=f):f=e[11];let p;e[12]!==f?(p=s.jsx("span",{className:"min-w-0 truncate",children:f}),e[12]=f,e[13]=p):p=e[13];let b;return e[14]!==a||e[15]!==c||e[16]!==h||e[17]!==p?(b=s.jsx(ji,{icon:d,title:c,subtitle:"jev",badges:h,footer:p,onOpen:a}),e[14]=a,e[15]=c,e[16]=h,e[17]=p,e[18]=b):b=e[18],b},ub=(t,e)=>{const[a,n]=l.useState(()=>new Set);return l.useEffect(()=>{let i=!1;const o=e?`?directory=${encodeURIComponent(e)}`:"";return Promise.all(t.map(async r=>{try{const d=await It(`/api/provider/${encodeURIComponent(r.id)}/source${o}`,{method:"GET",headers:{Accept:"application/json"}});if(!d.ok)return null;const c=await d.json().catch(()=>null);return(c?.sources??c?.data?.sources)?.project?.exists===!0?r.id:null}catch{return null}})).then(r=>{i||n(new Set(r.filter(d=>d!==null)))}),()=>{i=!0}},[e,t]),a},mb=t=>{const e=Be.c(7),{status:a}=t,{t:n}=qe();let i;e[0]!==a.count||e[1]!==a.kind||e[2]!==n?(i=a.kind==="accounts"?n("settings.providers.card.status.accounts",{count:a.count}):a.kind==="connected"?n("settings.providers.card.status.connected"):a.kind==="environment"?n("settings.providers.card.status.environment"):n("settings.providers.card.status.signInNeeded"),e[0]=a.count,e[1]=a.kind,e[2]=n,e[3]=i):i=e[3];const o=i,r=a.kind==="signInNeeded"?"warning":a.kind==="environment"?"neutral":"success";let d;return e[4]!==o||e[5]!==r?(d=s.jsx(In,{tone:r,children:o}),e[4]=o,e[5]=r,e[6]=d):d=e[6],d},pb=t=>{const e=Be.c(42),{providers:a,integrations:n,directory:i,onSelect:o,onConnect:r,onOpenClassification:d}=t,{t:c}=qe(),[g,m]=l.useState(""),h=ub(a,i),f=sa([...a],g,yb);let p;e[0]!==g?(p=g.trim(),e[0]=g,e[1]=p):p=e[1];const b=p.length>0,C=ya(),v=ns;let k;e[2]!==c?(k=c("settings.page.providers.title"),e[2]=c,e[3]=k):k=e[3];let u;e[4]!==c?(u=c("settings.providers.grid.description"),e[4]=c,e[5]=u):u=e[5];let y;e[6]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(Ni,{className:"w-full min-w-0 @xl:w-56"}),e[6]=y):y=e[6];let S;e[7]!==i||e[8]!==n||e[9]!==C?(S=C?s.jsx(cb,{directory:i,integrations:n}):null,e[7]=i,e[8]=n,e[9]=C,e[10]=S):S=e[10];let N;e[11]!==a.length||e[12]!==g||e[13]!==c?(N=a.length>0?s.jsx(el,{value:g,onChange:m,placeholder:c("settings.providers.grid.searchPlaceholder")}):null,e[11]=a.length,e[12]=g,e[13]=c,e[14]=N):N=e[14];const w=a.length===0?s.jsx("p",{className:"py-6 typography-meta text-muted-foreground",children:c("settings.providers.grid.empty")}):f.length===0?s.jsx("p",{className:"py-6 typography-meta text-muted-foreground",children:c("settings.providers.grid.noMatches",{query:g.trim()})}):null,A=Zr;let x;e[15]!==b||e[16]!==C||e[17]!==r||e[18]!==c?(x=b||C?null:s.jsx(Xr,{label:c("settings.providers.grid.connect"),hint:c("settings.providers.grid.connectHint"),onClick:r}),e[15]=b,e[16]=C,e[17]=r,e[18]=c,e[19]=x):x=e[19];let T;e[20]!==b||e[21]!==d?(T=b?null:s.jsx(db,{onOpen:d}),e[20]=b,e[21]=d,e[22]=T):T=e[22];let M;e[23]!==n||e[24]!==o||e[25]!==h||e[26]!==c?(M=L=>{const P=tb({integrations:n,providerId:L.id,optionsApiKey:Ir(L)});return s.jsx(ji,{icon:s.jsx($n,{providerId:L.id,className:"size-5"}),title:L.name||L.id,subtitle:L.id,badges:P?s.jsx(mb,{status:P}):null,footer:s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"inline-flex items-center gap-1","aria-label":c("settings.providers.card.models",{count:L.models.length}),children:[s.jsx($,{name:"stack",className:"size-3.5 opacity-70","aria-hidden":!0}),s.jsx("span",{className:"tabular-nums",children:L.models.length})]}),h.has(L.id)?s.jsx(io,{children:c("settings.providers.card.source.project")}):null]}),onOpen:()=>o(L.id)},L.id)},e[23]=n,e[24]=o,e[25]=h,e[26]=c,e[27]=M):M=e[27];const E=f.map(M);let D;e[28]!==T||e[29]!==E||e[30]!==A||e[31]!==x?(D=s.jsxs("div",{className:A,children:[x,T,E]}),e[28]=T,e[29]=E,e[30]=A,e[31]=x,e[32]=D):D=e[32];let F;return e[33]!==v||e[34]!==D||e[35]!==k||e[36]!==u||e[37]!==y||e[38]!==S||e[39]!==N||e[40]!==w?(F=s.jsxs(v,{title:k,description:u,headerEnd:y,children:[S,N,w,D]}),e[33]=v,e[34]=D,e[35]=k,e[36]=u,e[37]=y,e[38]=S,e[39]=N,e[40]=w,e[41]=F):F=e[41],F};function gb(t){return t.organization}function fb(t){return t.policyError!==null}function hb(){Gs(rb)}function xb(t){return t.available}function bb(t){return t.jevAvailable}function vb(t){return t.classifier?.selected==="off"}function yb(t){return[t.name||t.id,t.id]}const Yo="flex w-full min-w-0 items-center gap-2",Zo="h-8 rounded-md px-3 min-w-0 flex-1",jb=()=>{const{t}=qe(),e=es(u=>u.customEndpoint),a=es(u=>u.setCustomEndpoint),n=es(u=>u.clearCustomEndpoint),[i,o]=l.useState(e?.url??""),[r,d]=l.useState(e?.model??""),[c,g]=l.useState(""),[m,h]=l.useState(!1),[f,p]=l.useState(null);l.useEffect(()=>{o(e?.url??""),d(e?.model??"")},[e?.url,e?.model]);const b=async u=>{h(!0),p(null);try{await u(),g("")}catch(y){p(y instanceof Error?y.message:String(y))}finally{h(!1)}},C=i.trim().length>0&&r.trim().length>0,v=()=>{if(!C)return;const u={url:i.trim(),model:r.trim()},y=c.trim();y&&(u.key=y),b(()=>a(u))},k=u=>{u.key==="Enter"&&v()};return e?.pinned?s.jsx(He,{title:t("settings.classification.custom.title"),info:t("settings.classification.custom.info"),children:s.jsx("p",{className:Pn,children:t("settings.classification.custom.pinned",{url:e.url,model:e.model})})}):s.jsx(He,{title:t("settings.classification.custom.title"),info:t("settings.classification.custom.info"),children:s.jsxs("div",{className:Ms,children:[s.jsx(Ct,{label:t("settings.classification.custom.url.label"),info:t("settings.classification.custom.url.info"),children:s.jsx("div",{className:Yo,children:s.jsx(Ge,{type:"url",autoComplete:"off",spellCheck:!1,value:i,onChange:u=>o(u.target.value),onKeyDown:k,placeholder:"https://example.com/v1","aria-label":t("settings.classification.custom.url.label"),className:Zo,disabled:m})})}),s.jsx(Ct,{label:t("settings.classification.custom.model.label"),children:s.jsx("div",{className:Yo,children:s.jsx(Ge,{autoComplete:"off",spellCheck:!1,value:r,onChange:u=>d(u.target.value),onKeyDown:k,placeholder:"jev-latest","aria-label":t("settings.classification.custom.model.label"),className:Zo,disabled:m})})}),s.jsx(Ct,{label:t("settings.classification.custom.key.label"),info:t("settings.classification.custom.key.info"),children:s.jsx("div",{className:Yo,children:s.jsx(Ge,{type:"password",autoComplete:"off",value:c,onChange:u=>g(u.target.value),onKeyDown:k,placeholder:e?.keyPresent?t("settings.classification.custom.key.replacePlaceholder"):t("settings.classification.custom.key.placeholder"),"aria-label":t("settings.classification.custom.key.label"),className:Zo,disabled:m})})}),s.jsxs(Ct,{label:null,children:[s.jsx(V,{size:"sm",variant:"outline",onClick:v,disabled:m||!C,children:t("settings.classification.custom.save")}),e?s.jsx(V,{size:"sm",variant:"ghost",onClick:()=>{b(n)},disabled:m,children:t("settings.classification.custom.remove")}):null]}),f?s.jsx("p",{className:Pn,children:f}):null]})})},kb="https://docs.openchamber.dev/classification-providers/",Xo=t=>{const e=Be.c(6),{text:a,linkLabel:n,onOpen:i}=t;let o;e[0]!==n||e[1]!==i?(o=s.jsx("span",{onClick:Nb,onKeyDown:Sb,children:s.jsx(Vn,{onClick:i,children:n})}),e[0]=n,e[1]=i,e[2]=o):o=e[2];let r;return e[3]!==o||e[4]!==a?(r=s.jsxs(s.Fragment,{children:[a," ",o]}),e[3]=o,e[4]=a,e[5]=r):r=e[5],r},wb=({titleLeading:t,onOpenProvider:e})=>{const{t:a}=qe(),n=es(P=>P.available),i=es(P=>P.loaded),o=es(P=>P.loadError),r=es(P=>P.classifier),d=es(P=>P.tokenPresent),c=es(P=>P.customEndpoint),g=es(P=>P.enterpriseMode),m=es(P=>P.load),h=es(P=>P.setClassifierSource),f=es(P=>P.setToken),p=es(P=>P.clearToken),b=al(r?.effective??null),[C,v]=l.useState(""),[k,u]=l.useState(!1),[y,S]=l.useState(null);l.useEffect(()=>{m()},[m]);const N=P=>r?.sources.find(j=>j.id===P)?.usable===!0,w=async P=>{os("saving");try{await h(P),os("saved")}catch{os("error")}},A=async()=>{const P=C.trim();if(P){u(!0),S(null);try{await f(P),v("")}catch(j){S(j instanceof Error?j.message:String(j))}finally{u(!1)}}},x=async()=>{u(!0),S(null);try{await p()}catch(P){S(P instanceof Error?P.message:String(P))}finally{u(!1)}},T=g?c?.pinned?a("settings.classification.status.enterprisePinned"):a("settings.classification.status.enterprise"):!r||r.selected==="off"?null:r.effective===null?a("settings.classification.status.none"):r.effective!==r.selected&&b?a("settings.classification.status.fallback",{provider:b}):null,M=N("zen-promo"),E=N("zen-key"),D=N("openrouter"),F=N("vercel"),L=N("custom");return s.jsxs(ns,{title:a("settings.classification.page.title"),titleLeading:t,description:s.jsxs("p",{className:Pn,children:[a("settings.classification.page.description")," ",s.jsx(Vn,{onClick:()=>{Gs(kb)},children:a("settings.classification.page.docsLink")})]}),showSaveStatus:!0,children:[o?s.jsx("p",{className:Pn,children:a("settings.routing.loadError",{error:o})}):null,i?!n||!r?s.jsx("p",{className:Pn,children:a("settings.classification.unavailable")}):s.jsxs(s.Fragment,{children:[s.jsx(He,{title:s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx($n,{providerId:"typesafe",className:"size-4 shrink-0"}),a("settings.classification.jev.title")]}),info:a("settings.classification.jev.info"),divider:!1,settingsItem:"providers.classification",children:s.jsxs("div",{className:Ms,children:[T?s.jsx("p",{className:ds,children:T}):null,s.jsxs(Js,{"aria-label":a("settings.classification.jev.title"),children:[s.jsx(rs,{selected:r.selected==="off",onSelect:()=>{w("off")},label:a("settings.classification.source.off.name"),description:a("settings.classification.source.off.description")}),g?null:s.jsxs(s.Fragment,{children:[M||r.selected==="zen-promo"?s.jsx(rs,{selected:r.selected==="zen-promo",onSelect:()=>{w("zen-promo")},disabled:!M,label:a("settings.classification.source.zenPromo.name"),description:a(M?"settings.classification.source.zenPromo.description":"settings.classification.source.zenPromo.ended")}):null,s.jsx(rs,{selected:r.selected==="zen-key",onSelect:()=>{w("zen-key")},disabled:!E,label:a("settings.classification.source.zenKey.name"),description:E?a("settings.classification.source.zenKey.description"):s.jsx(Xo,{text:a("settings.classification.source.zenKey.missing"),linkLabel:a("settings.classification.source.openProvider",{provider:"OpenCode Zen"}),onOpen:()=>e("opencode")})}),s.jsx(rs,{selected:r.selected==="openrouter",onSelect:()=>{w("openrouter")},disabled:!D,label:a("settings.classification.source.openrouter.name"),description:D?a("settings.classification.source.openrouter.description"):s.jsx(Xo,{text:a("settings.classification.source.openrouter.missing"),linkLabel:a("settings.classification.source.openProvider",{provider:"OpenRouter"}),onOpen:()=>e("openrouter")})}),s.jsx(rs,{selected:r.selected==="vercel",onSelect:()=>{w("vercel")},disabled:!F,label:a("settings.classification.source.vercel.name"),description:F?a("settings.classification.source.vercel.description"):s.jsx(Xo,{text:a("settings.classification.source.vercel.missing"),linkLabel:a("settings.classification.source.openProvider",{provider:"Vercel AI Gateway"}),onOpen:()=>e("vercel")})}),s.jsx(rs,{selected:r.selected==="typesafe",onSelect:()=>{w("typesafe")},disabled:!d,label:a("settings.classification.source.typesafe.name"),description:a(d?"settings.classification.source.typesafe.description":"settings.classification.source.typesafe.missing")})]}),!g||c?.pinned?s.jsx(rs,{selected:r.selected==="custom",onSelect:()=>{w("custom")},disabled:!L,label:a("settings.classification.source.custom.name"),description:c&&L?a("settings.classification.source.custom.description",{url:c.url}):a("settings.classification.source.custom.missing")}):null]}),g?null:s.jsx(Ct,{label:a("settings.routing.token.label"),info:a("settings.routing.token.info"),children:s.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[s.jsx(Ge,{type:"password",autoComplete:"off",value:C,onChange:P=>v(P.target.value),onKeyDown:P=>{P.key==="Enter"&&A()},placeholder:a(d?"settings.routing.token.replacePlaceholder":"settings.routing.token.placeholder"),"aria-label":a("settings.routing.token.label"),className:"h-8 rounded-md px-3 min-w-0 flex-1",disabled:k}),s.jsx(V,{size:"sm",variant:"outline",onClick:()=>{A()},disabled:k||C.trim().length===0,children:a("settings.routing.token.save")}),d?s.jsx(V,{size:"sm",variant:"ghost",onClick:()=>{x()},disabled:k,children:a("settings.routing.token.remove")}):null]})}),y?s.jsx("p",{className:Pn,children:y}):null]})}),!g||c?.pinned?s.jsx(jb,{}):null]}):null]})};function Nb(t){return t.stopPropagation()}function Sb(t){return t.stopPropagation()}const gc=t=>{const e=Be.c(2),{icon:a}=t;let n;return e[0]!==a?(n=s.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-[var(--surface-muted)] text-muted-foreground",children:s.jsx($,{name:a,className:"size-4"})}),e[0]=a,e[1]=n):n=e[1],n},Cb=t=>{const e=Be.c(32),{initial:a,onSave:n,onCancel:i}=t,{t:o}=qe(),[r,d]=l.useState(a);let c;e[0]!==r?(c=r.trim(),e[0]=r,e[1]=c):c=e[1];const g=c;let m;e[2]!==a||e[3]!==i||e[4]!==n||e[5]!==g?(m=()=>{if(g.length===0||g===a){i();return}n(g)},e[2]=a,e[3]=i,e[4]=n,e[5]=g,e[6]=m):m=e[6];const h=m;let f;e[7]!==h?(f=w=>{w.preventDefault(),h()},e[7]=h,e[8]=f):f=e[8];let p;e[9]===Symbol.for("react.memo_cache_sentinel")?(p=w=>d(w.target.value),e[9]=p):p=e[9];let b;e[10]!==i?(b=w=>{w.key==="Escape"&&(w.preventDefault(),w.stopPropagation(),i())},e[10]=i,e[11]=b):b=e[11];let C;e[12]!==o?(C=o("settings.providers.accounts.nameAria"),e[12]=o,e[13]=C):C=e[13];let v;e[14]!==b||e[15]!==C||e[16]!==r?(v=s.jsx(Ge,{autoFocus:!0,value:r,onChange:p,onKeyDown:b,"aria-label":C,className:"h-8 max-w-[18rem]"}),e[14]=b,e[15]=C,e[16]=r,e[17]=v):v=e[17];let k;e[18]!==o?(k=o("settings.providers.accounts.save"),e[18]=o,e[19]=k):k=e[19];let u;e[20]!==k?(u=s.jsx(V,{type:"submit",size:"xs",children:k}),e[20]=k,e[21]=u):u=e[21];let y;e[22]!==o?(y=o("settings.providers.page.actions.cancel"),e[22]=o,e[23]=y):y=e[23];let S;e[24]!==i||e[25]!==y?(S=s.jsx(V,{type:"button",variant:"ghost",size:"xs",onClick:i,children:y}),e[24]=i,e[25]=y,e[26]=S):S=e[26];let N;return e[27]!==S||e[28]!==f||e[29]!==v||e[30]!==u?(N=s.jsxs("form",{className:"flex min-w-0 flex-1 items-center gap-2",onSubmit:f,children:[v,u,S]}),e[27]=S,e[28]=f,e[29]=v,e[30]=u,e[31]=N):N=e[31],N},Ib=t=>{const e=Be.c(32),{connections:a,activeId:n,unusedIds:i,busyId:o,onActivate:r,onRename:d,onRemove:c}=t,{t:g}=qe(),[m,h]=l.useState(null);let f;if(e[0]!==a||e[1]!==i){let y;e[3]!==i?(y=S=>S.type==="credential"&&!i.has(S.id),e[3]=i,e[4]=y):y=e[4],f=a.filter(y),e[0]=a,e[1]=i,e[2]=f}else f=e[2];const b=f.length>1;let C;e[5]!==a?(C=a.filter(Pb),e[5]=a,e[6]=C):C=e[6];const v=C.length>1;let k;if(e[7]!==n||e[8]!==o||e[9]!==b||e[10]!==a||e[11]!==r||e[12]!==c||e[13]!==d||e[14]!==m||e[15]!==v||e[16]!==g||e[17]!==i){let y;e[19]!==n||e[20]!==o||e[21]!==b||e[22]!==r||e[23]!==c||e[24]!==d||e[25]!==m||e[26]!==v||e[27]!==g||e[28]!==i?(y=S=>{if(S.type==="env")return s.jsxs("div",{className:"flex min-w-0 items-center gap-3 py-2.5",children:[s.jsx(gc,{icon:"terminal-box"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate font-mono typography-ui-label text-foreground",children:S.name}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:g("settings.providers.accounts.environment")})]})]},`env:${S.name}`);const N=S.id===n,w=i.has(S.id),A=o!==null,x=S.method==="oauth"?g(w?"settings.providers.accounts.method.oauthUnused":"settings.providers.accounts.method.oauth"):g(w?"settings.providers.accounts.method.keyUnused":"settings.providers.accounts.method.key");return s.jsxs("div",{className:Ne("flex min-w-0 items-center gap-3 py-2.5",w&&"opacity-60"),children:[s.jsx(gc,{icon:S.method==="oauth"?"user-3":"key"}),m===S.id?s.jsx(Cb,{initial:S.label,onCancel:()=>h(null),onSave:T=>{h(null),d(S,T)}}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:S.label}),v&&N?s.jsx("span",{className:"shrink-0 rounded-full bg-[var(--interactive-selection)] px-2 py-px text-[10px] font-medium text-[var(--interactive-selection-foreground)]",children:g("settings.providers.accounts.active")}):null]}),s.jsx("div",{className:"typography-micro text-muted-foreground",children:x})]}),b&&!N&&!w?s.jsxs(V,{variant:"outline",size:"xs",disabled:A,onClick:()=>r(S),"aria-label":g("settings.providers.accounts.useAria",{account:S.label}),children:[o===S.id?s.jsx($,{name:"loader-4",className:"size-3.5 animate-spin"}):null,g("settings.providers.accounts.use")]}):null,s.jsxs(Jn,{children:[s.jsx(Wn,{asChild:!0,children:s.jsx(V,{variant:"ghost",size:"icon",disabled:A,className:Ne(hs,"shrink-0"),"aria-label":g("settings.providers.accounts.menuAria",{account:S.label}),children:s.jsx($,{name:"more-2",className:"size-4"})})}),s.jsxs(Gn,{align:"end",children:[s.jsxs(xn,{onSelect:()=>h(S.id),children:[s.jsx($,{name:"pencil",className:"size-4"}),g("settings.providers.accounts.rename")]}),s.jsxs(xn,{variant:"destructive",onSelect:()=>c(S),children:[s.jsx($,{name:"delete-bin",className:"size-4"}),g("settings.providers.accounts.remove")]})]})]})]})]},S.id)},e[19]=n,e[20]=o,e[21]=b,e[22]=r,e[23]=c,e[24]=d,e[25]=m,e[26]=v,e[27]=g,e[28]=i,e[29]=y):y=e[29],k=a.map(y),e[7]=n,e[8]=o,e[9]=b,e[10]=a,e[11]=r,e[12]=c,e[13]=d,e[14]=m,e[15]=v,e[16]=g,e[17]=i,e[18]=k}else k=e[18];let u;return e[30]!==k?(u=s.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:k}),e[30]=k,e[31]=u):u=e[31],u};function Pb(t){return t.type==="credential"}const il={"openai-chat":"aisdk:@ai-sdk/openai-compatible","openai-responses":"aisdk:@ai-sdk/openai","anthropic-messages":"aisdk:@ai-sdk/anthropic"},oa="__custom_provider__",Ab=/^[a-z0-9][a-z0-9-_]*$/,Fd=/^https?:\/\//,Tb=/^\{env:([^}]+)\}$/,co=t=>{if(!t)return;if(typeof t.package=="string"&&t.package)return t.package;const e=t.api?.npm;return typeof e=="string"&&e?`aisdk:${e}`:void 0},Kd=t=>t.settings&&typeof t.settings=="object"?t.settings:t.options&&typeof t.options=="object"?t.options:{};let Eb=0;const uo=()=>`row-${Eb++}`,ol=()=>({row:uo(),id:"",name:"",variants:""});function Db(t,e){switch(t){case"openai-chat":return{settings:{reasoningEffort:e}};case"openai-responses":return{settings:{reasoningEffort:e,reasoningSummary:"auto",include:["reasoning.encrypted_content"]}};case"anthropic-messages":return{settings:{thinking:{type:"adaptive",display:"summarized"},effort:e}}}}function Mb(t){const e=t.split(/[,\s]+/).map(a=>a.trim()).filter(Boolean);return e.filter((a,n)=>e.indexOf(a)===n)}function Rb(t){return Object.fromEntries((t??[]).map(({id:e,...a})=>[e,a]))}const rl=()=>({row:uo(),key:"",value:""}),Ob=()=>({providerID:"",name:"",protocol:"openai-chat",baseURL:"",apiKey:"",models:[ol()],headers:[rl()]}),zd={"@opencode/ai/providers/openai-compatible":"openai-chat","@opencode/ai/providers/openai":"openai-responses","@opencode/ai/providers/anthropic":"anthropic-messages"};function Lb(t){const e=t?zd[t]:void 0;if(e)return e;switch(t){case"aisdk:@ai-sdk/openai":case"@ai-sdk/openai":return"openai-responses";case"aisdk:@ai-sdk/anthropic":case"@ai-sdk/anthropic":return"anthropic-messages";default:return"openai-chat"}}function Fb(t){const e=t.trim();if(!e)return{};const n=e.match(Tb)?.[1]?.trim();return n?{env:n}:{key:e}}function Kb(t){const e=Kd(t),a=typeof e.baseURL=="string"?e.baseURL.trim():"";if(a&&Fd.test(a))return!0;const n=new Set([...Object.values(il),...Object.keys(zd)]);return n.has(co(t)??"")?!0:(Array.isArray(t.models)?t.models:t.models&&typeof t.models=="object"?Object.values(t.models):[]).some(o=>!o||typeof o!="object"?!1:n.has(co(o)??""))}function fc(t,e){return e?!!(e.user?.exists||e.project?.exists||e.custom?.exists)&&Kb(t):!1}function hc(t){return t?.custom?.exists?"custom":t?.project?.exists?"project":"user"}function xc(t){const e=Kd(t),a=typeof e.baseURL=="string"?e.baseURL:"",n=t.headers&&typeof t.headers=="object"?t.headers:e.headers&&typeof e.headers=="object"&&!Array.isArray(e.headers)?e.headers:{},i=Object.entries(n).filter(g=>typeof g[0]=="string"&&typeof g[1]=="string").map(([g,m])=>({row:uo(),key:g,value:m})),o=Array.isArray(t.models)?t.models:t.models&&typeof t.models=="object"?Object.entries(t.models).map(([g,m])=>{const h=m&&typeof m=="object"?m:{};return{id:g,modelID:typeof h.modelID=="string"?h.modelID:g,name:typeof h.name=="string"?h.name:g,package:typeof h.package=="string"?h.package:void 0,variants:Ud.safeParse(h.variants).data}}):[],r=o.length>0?o.map(g=>{const m=typeof g?.modelID=="string"&&g.modelID?g.modelID:typeof g?.id=="string"?g.id:"",h=Rb(g?.variants);return{row:uo(),id:m,name:typeof g?.name=="string"?g.name:m,variants:Object.keys(h).join(", "),savedVariants:h}}):[ol()],d=Array.isArray(t.env)?t.env.find(g=>typeof g=="string"&&g.trim().length>0)?.trim():void 0,c=o.map(g=>co(g)).find(g=>!!g);return{providerID:t.id,name:typeof t.name=="string"&&t.name.trim()?t.name:t.id,protocol:Lb(co(t)??c),baseURL:a,apiKey:d?`{env:${d}}`:"",models:r,headers:i.length>0?i:[rl()]}}const Ud=ja(Os({id:Rt(),settings:Bn(Rt(),br()).optional(),headers:Bn(Rt(),Rt()).optional(),body:Bn(Rt(),br()).optional()})),zb=Os({name:Rt().optional(),package:Rt().optional(),env:ja(Rt()).optional(),settings:Bn(Rt(),br()).optional(),headers:Bn(Rt(),Rt()).optional(),models:Bn(Rt(),Os({modelID:Rt().optional(),name:Rt().optional(),package:Rt().optional(),variants:Ud.optional()})).optional()});function Ub(t,e){const a=Array.isArray(t.models)?t.models.map(o=>({...o,variants:void 0})):t.models,n=xc({...t,models:a});if(!e)return{...n,models:n.models.map(o=>({...o,savedVariants:void 0}))};const i=xc({...e,id:t.id});return{providerID:t.id,name:e.name?.trim()?i.name:n.name,protocol:e.package?i.protocol:n.protocol,baseURL:i.baseURL||n.baseURL,apiKey:i.apiKey,models:e.models&&Object.keys(e.models).length>0?i.models:n.models.map(o=>({...o,savedVariants:void 0})),headers:i.headers}}function _b(t){const e=t.form.providerID.trim(),a=t.form.name.trim(),n=t.form.baseURL.trim(),{env:i,key:o}=Fb(t.form.apiKey),r=t.disabledProviders??[],d=t.editingProviderID?.trim(),c=e?Ab.test(e)?void 0:t.t("settings.providers.page.custom.error.providerID.format"):t.t("settings.providers.page.custom.error.providerID.required"),g=a?void 0:t.t("settings.providers.page.custom.error.name.required"),m=n?Fd.test(n)?void 0:t.t("settings.providers.page.custom.error.baseURL.format"):t.t("settings.providers.page.custom.error.baseURL.required"),f=!!(i||o||d&&t.allowExistingAuth&&d===e)?void 0:t.t("settings.providers.page.custom.error.apiKey.required"),p=r.includes(e),C=c||!!(d&&d===e)?void 0:t.existingProviderIDs.has(e)&&!p?t.t("settings.providers.page.custom.error.providerID.exists"):void 0,v=new Set,k=t.form.models.map(M=>{const E=M.id.trim(),D=E?v.has(E)?t.t("settings.providers.page.custom.error.duplicate"):void v.add(E):t.t("settings.providers.page.custom.error.required"),F=M.name.trim()?void 0:t.t("settings.providers.page.custom.error.required");return{id:D,name:F}}),u=k.every(M=>!M.id&&!M.name),y=Object.fromEntries(t.form.models.map(M=>{const E=M.id.trim(),D={modelID:E,name:M.name.trim()},F=Mb(M.variants);return(F.length>0||M.savedVariants!==void 0)&&(D.variants=F.map(L=>({id:L,...M.savedVariants?.[L]??Db(t.form.protocol,L)}))),[E,D]})),S=new Set,N=t.form.headers.map(M=>{const E=M.key.trim(),D=M.value.trim();if(!E&&!D)return{};const F=E?S.has(E.toLowerCase())?t.t("settings.providers.page.custom.error.duplicate"):void S.add(E.toLowerCase()):t.t("settings.providers.page.custom.error.required"),L=D?void 0:t.t("settings.providers.page.custom.error.required");return{key:F,value:L}}),w=N.every(M=>!M.key&&!M.value),A=Object.fromEntries(t.form.headers.map(M=>({key:M.key.trim(),value:M.value.trim()})).filter(M=>M.key&&M.value).map(M=>[M.key,M.value])),x={providerID:c??C,name:g,baseURL:m,apiKey:f};return!c&&!C&&!g&&!m&&!f&&u&&w?{err:x,models:k,headers:N,result:{providerID:e,name:a,apiKey:o,...!i&&!o?{keepsStoredCredential:!0}:{},config:$b({protocol:t.form.protocol,name:a,env:i,baseURL:n,headers:A,models:y})}}:{err:x,models:k,headers:N}}function $b(t){const e={package:il[t.protocol],name:t.name,settings:{baseURL:t.baseURL},models:t.models};return t.env&&(e.env=[t.env]),Object.keys(t.headers).length>0&&(e.headers=t.headers),e}function Bb(t){return t.apiKey?{integrationID:t.providerID,key:t.apiKey}:null}function Vb(t,e){return{providerID:t.providerID,config:t.config,scope:e?.scope??"user",hasCredential:!!(t.apiKey||t.keepsStoredCredential)}}const Hb=[250,500,1e3,2e3];async function qb(t,e=a=>new Promise(n=>setTimeout(n,a))){for(let a=0;;a+=1)try{await t();return}catch(n){const i=Hb[a];if(!(n instanceof Error&&/not found/i.test(n.message))||i===void 0)throw n;await e(i)}}const bc=t=>{const e=Be.c(234),{existingProviderIDs:a,disabledProviders:n,busy:i,mode:o,initialValues:r,allowExistingAuth:d,authFailureHint:c,onSubmit:g,onCancel:m,onDisconnect:h}=t;let f;e[0]!==n?(f=n===void 0?[]:n,e[0]=n,e[1]=f):f=e[1];const p=f,b=i===void 0?!1:i,C=o===void 0?"create":o,v=d===void 0?!1:d,k=c===void 0?null:c,{t:u}=qe(),y=C==="edit";let S;e[2]!==r?(S=()=>r??Ob(),e[2]=r,e[3]=S):S=e[3];const[N,w]=l.useState(S);let A;e[4]===Symbol.for("react.memo_cache_sentinel")?(A={},e[4]=A):A=e[4];const[x,T]=l.useState(A);let M;e[5]===Symbol.for("react.memo_cache_sentinel")?(M=[],e[5]=M):M=e[5];const[E,D]=l.useState(M);let F;e[6]===Symbol.for("react.memo_cache_sentinel")?(F=[],e[6]=F):F=e[6];const[L,P]=l.useState(F),j=l.useRef(null);let O,K;e[7]!==r||e[8]!==y?(O=()=>{r&&(y&&j.current===r.providerID||(j.current=y?r.providerID:null,w(r),T({}),D([]),P([])))},K=[r,y],e[7]=r,e[8]=y,e[9]=O,e[10]=K):(O=e[9],K=e[10]),l.useEffect(O,K);let H;e[11]===Symbol.for("react.memo_cache_sentinel")?(H=(Lt,Xt)=>{w(Wt=>({...Wt,[Lt]:Xt})),T(Wt=>({...Wt,[Lt]:void 0}))},e[11]=H):H=e[11];const q=H;let Z;e[12]===Symbol.for("react.memo_cache_sentinel")?(Z=(Lt,Xt,Wt)=>{w(Mt=>({...Mt,models:Mt.models.map((ls,is)=>is===Lt?{...ls,[Xt]:Wt}:ls)})),D(Mt=>{const ls=[...Mt];return ls[Lt]={...ls[Lt]??{},[Xt]:void 0},ls})},e[12]=Z):Z=e[12];const ae=Z;let B;e[13]===Symbol.for("react.memo_cache_sentinel")?(B=(Lt,Xt,Wt)=>{w(Mt=>({...Mt,headers:Mt.headers.map((ls,is)=>is===Lt?{...ls,[Xt]:Wt}:ls)})),P(Mt=>{const ls=[...Mt];return ls[Lt]={...ls[Lt]??{},[Xt]:void 0},ls})},e[13]=B):B=e[13];const G=B;let _;e[14]!==v||e[15]!==b||e[16]!==p||e[17]!==a||e[18]!==N||e[19]!==y||e[20]!==g||e[21]!==u?(_=async Lt=>{if(Lt.preventDefault(),b)return;const Xt=_b({form:N,t:((Wt,Mt)=>u(Wt,Mt)),existingProviderIDs:a,disabledProviders:p,editingProviderID:y?N.providerID:void 0,allowExistingAuth:y&&v});T(Xt.err),D(Xt.models),P(Xt.headers),Xt.result&&await g(Xt.result)},e[14]=v,e[15]=b,e[16]=p,e[17]=a,e[18]=N,e[19]=y,e[20]=g,e[21]=u,e[22]=_):_=e[22];const z=_;let te;e[23]!==y||e[24]!==u?(te=u(y?"settings.providers.page.custom.editTitle":"settings.providers.page.custom.title"),e[23]=y,e[24]=u,e[25]=te):te=e[25];let Q;e[26]!==u?(Q=u("settings.providers.page.custom.description"),e[26]=u,e[27]=Q):Q=e[27];let X;e[28]!==Q?(X=s.jsx("p",{className:ds,children:Q}),e[28]=Q,e[29]=X):X=e[29];let pe;e[30]!==k?(pe=k?s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",role:"status",children:k}):null,e[30]=k,e[31]=pe):pe=e[31];let je;e[32]!==u?(je=u("settings.providers.page.custom.field.providerID.label"),e[32]=u,e[33]=je):je=e[33];let fe;e[34]!==u?(fe=u("settings.providers.page.custom.field.providerID.info"),e[34]=u,e[35]=fe):fe=e[35];const ke=N.providerID;let be;e[36]===Symbol.for("react.memo_cache_sentinel")?(be=Lt=>q("providerID",Lt.target.value),e[36]=be):be=e[36];let De;e[37]!==u?(De=u("settings.providers.page.custom.field.providerID.placeholder"),e[37]=u,e[38]=De):De=e[38];const oe=!y,ee=y||b,ce=!!x.providerID;let ue;e[39]!==u?(ue=u("settings.providers.page.custom.field.providerID.label"),e[39]=u,e[40]=ue):ue=e[40];let Ie;e[41]!==N.providerID||e[42]!==De||e[43]!==oe||e[44]!==ee||e[45]!==ce||e[46]!==ue?(Ie=s.jsx(Ge,{value:ke,onChange:be,placeholder:De,className:"h-8 rounded-md px-3 font-mono text-xs",autoFocus:oe,disabled:ee,"aria-invalid":ce,"aria-label":ue}),e[41]=N.providerID,e[42]=De,e[43]=oe,e[44]=ee,e[45]=ce,e[46]=ue,e[47]=Ie):Ie=e[47];let ve;e[48]!==x.providerID?(ve=x.providerID?s.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:x.providerID}):null,e[48]=x.providerID,e[49]=ve):ve=e[49];let Re;e[50]!==je||e[51]!==fe||e[52]!==Ie||e[53]!==ve?(Re=s.jsxs(Kt,{label:je,info:fe,children:[Ie,ve]}),e[50]=je,e[51]=fe,e[52]=Ie,e[53]=ve,e[54]=Re):Re=e[54];let Me;e[55]!==u?(Me=u("settings.providers.page.custom.field.protocol.label"),e[55]=u,e[56]=Me):Me=e[56];let me;e[57]!==u?(me=u("settings.providers.page.custom.field.protocol.info"),e[57]=u,e[58]=me):me=e[58];const Te=N.protocol;let Oe;e[59]===Symbol.for("react.memo_cache_sentinel")?(Oe=Lt=>{Lt in il&&w(Xt=>({...Xt,protocol:Lt,models:Xt.models.map(Gb)}))},e[59]=Oe):Oe=e[59];let ge;e[60]!==u?(ge=u("settings.providers.page.custom.field.protocol.label"),e[60]=u,e[61]=ge):ge=e[61];let xe;e[62]===Symbol.for("react.memo_cache_sentinel")?(xe=s.jsx(Jt,{}),e[62]=xe):xe=e[62];let ne;e[63]!==ge?(ne=s.jsx(Tt,{"aria-label":ge,className:"w-full",children:xe}),e[63]=ge,e[64]=ne):ne=e[64];let ie;e[65]!==u?(ie=u("settings.providers.page.custom.field.protocol.openaiChat"),e[65]=u,e[66]=ie):ie=e[66];let he;e[67]!==ie?(he=s.jsx(gt,{value:"openai-chat",children:ie}),e[67]=ie,e[68]=he):he=e[68];let Ee;e[69]!==u?(Ee=u("settings.providers.page.custom.field.protocol.openaiResponses"),e[69]=u,e[70]=Ee):Ee=e[70];let Ke;e[71]!==Ee?(Ke=s.jsx(gt,{value:"openai-responses",children:Ee}),e[71]=Ee,e[72]=Ke):Ke=e[72];let Le;e[73]!==u?(Le=u("settings.providers.page.custom.field.protocol.anthropicMessages"),e[73]=u,e[74]=Le):Le=e[74];let Se;e[75]!==Le?(Se=s.jsx(gt,{value:"anthropic-messages",children:Le}),e[75]=Le,e[76]=Se):Se=e[76];let $e;e[77]!==he||e[78]!==Ke||e[79]!==Se?($e=s.jsxs(Et,{children:[he,Ke,Se]}),e[77]=he,e[78]=Ke,e[79]=Se,e[80]=$e):$e=e[80];let Ye;e[81]!==b||e[82]!==N.protocol||e[83]!==ne||e[84]!==$e?(Ye=s.jsxs(Dt,{value:Te,onValueChange:Oe,disabled:b,children:[ne,$e]}),e[81]=b,e[82]=N.protocol,e[83]=ne,e[84]=$e,e[85]=Ye):Ye=e[85];let pt;e[86]!==Me||e[87]!==me||e[88]!==Ye?(pt=s.jsx(Kt,{label:Me,info:me,children:Ye}),e[86]=Me,e[87]=me,e[88]=Ye,e[89]=pt):pt=e[89];let vt;e[90]!==u?(vt=u("settings.providers.page.custom.field.name.label"),e[90]=u,e[91]=vt):vt=e[91];let wt;e[92]!==u?(wt=u("settings.providers.page.custom.field.name.info"),e[92]=u,e[93]=wt):wt=e[93];const yt=N.name;let st;e[94]===Symbol.for("react.memo_cache_sentinel")?(st=Lt=>q("name",Lt.target.value),e[94]=st):st=e[94];let rt;e[95]!==u?(rt=u("settings.providers.page.custom.field.name.placeholder"),e[95]=u,e[96]=rt):rt=e[96];const de=!!x.name;let Ue;e[97]!==u?(Ue=u("settings.providers.page.custom.field.name.label"),e[97]=u,e[98]=Ue):Ue=e[98];let et;e[99]!==N.name||e[100]!==rt||e[101]!==de||e[102]!==Ue?(et=s.jsx(Ge,{value:yt,onChange:st,placeholder:rt,className:"h-8 rounded-md px-3","aria-invalid":de,"aria-label":Ue}),e[99]=N.name,e[100]=rt,e[101]=de,e[102]=Ue,e[103]=et):et=e[103];let ze;e[104]!==x.name?(ze=x.name?s.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:x.name}):null,e[104]=x.name,e[105]=ze):ze=e[105];let Ze;e[106]!==vt||e[107]!==wt||e[108]!==et||e[109]!==ze?(Ze=s.jsxs(Kt,{label:vt,info:wt,children:[et,ze]}),e[106]=vt,e[107]=wt,e[108]=et,e[109]=ze,e[110]=Ze):Ze=e[110];let tt;e[111]!==u?(tt=u("settings.providers.page.custom.field.baseURL.label"),e[111]=u,e[112]=tt):tt=e[112];let lt;e[113]!==u?(lt=u("settings.providers.page.custom.field.baseURL.info"),e[113]=u,e[114]=lt):lt=e[114];const J=N.baseURL;let nt;e[115]===Symbol.for("react.memo_cache_sentinel")?(nt=Lt=>q("baseURL",Lt.target.value),e[115]=nt):nt=e[115];let ot;e[116]!==u?(ot=u("settings.providers.page.custom.field.baseURL.placeholder"),e[116]=u,e[117]=ot):ot=e[117];const it=!!x.baseURL;let ft;e[118]!==u?(ft=u("settings.providers.page.custom.field.baseURL.label"),e[118]=u,e[119]=ft):ft=e[119];let xt;e[120]!==N.baseURL||e[121]!==ot||e[122]!==it||e[123]!==ft?(xt=s.jsx(Ge,{value:J,onChange:nt,placeholder:ot,className:"h-8 rounded-md px-3 font-mono text-xs","aria-invalid":it,"aria-label":ft}),e[120]=N.baseURL,e[121]=ot,e[122]=it,e[123]=ft,e[124]=xt):xt=e[124];let ht;e[125]!==x.baseURL?(ht=x.baseURL?s.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:x.baseURL}):null,e[125]=x.baseURL,e[126]=ht):ht=e[126];let St;e[127]!==tt||e[128]!==lt||e[129]!==xt||e[130]!==ht?(St=s.jsxs(Kt,{label:tt,info:lt,children:[xt,ht]}),e[127]=tt,e[128]=lt,e[129]=xt,e[130]=ht,e[131]=St):St=e[131];let At;e[132]!==u?(At=u("settings.providers.page.custom.field.apiKey.label"),e[132]=u,e[133]=At):At=e[133];let _e;e[134]!==v||e[135]!==y||e[136]!==u?(_e=u(y&&v?"settings.providers.page.custom.field.apiKey.editInfo":"settings.providers.page.custom.field.apiKey.info"),e[134]=v,e[135]=y,e[136]=u,e[137]=_e):_e=e[137];const Xe=N.apiKey;let mt;e[138]===Symbol.for("react.memo_cache_sentinel")?(mt=Lt=>q("apiKey",Lt.target.value),e[138]=mt):mt=e[138];let Fe;e[139]!==v||e[140]!==y||e[141]!==u?(Fe=u(y&&v?"settings.providers.page.custom.field.apiKey.editPlaceholder":"settings.providers.page.custom.field.apiKey.placeholder"),e[139]=v,e[140]=y,e[141]=u,e[142]=Fe):Fe=e[142];const W=!!x.apiKey;let ye;e[143]!==u?(ye=u("settings.providers.page.custom.field.apiKey.label"),e[143]=u,e[144]=ye):ye=e[144];let Ae;e[145]!==N.apiKey||e[146]!==Fe||e[147]!==W||e[148]!==ye?(Ae=s.jsx(Ge,{type:"password",value:Xe,onChange:mt,placeholder:Fe,className:"h-8 rounded-md px-3 font-mono text-xs","aria-invalid":W,"aria-label":ye}),e[145]=N.apiKey,e[146]=Fe,e[147]=W,e[148]=ye,e[149]=Ae):Ae=e[149];let Y;e[150]!==x.apiKey?(Y=x.apiKey?s.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:x.apiKey}):null,e[150]=x.apiKey,e[151]=Y):Y=e[151];let Pe;e[152]!==At||e[153]!==_e||e[154]!==Ae||e[155]!==Y?(Pe=s.jsxs(Kt,{label:At,info:_e,children:[Ae,Y]}),e[152]=At,e[153]=_e,e[154]=Ae,e[155]=Y,e[156]=Pe):Pe=e[156];let Je;e[157]!==te||e[158]!==X||e[159]!==pe||e[160]!==Re||e[161]!==pt||e[162]!==Ze||e[163]!==St||e[164]!==Pe?(Je=s.jsxs(He,{title:te,divider:!1,settingsItem:"providers.custom",contentClassName:Ms,children:[X,pe,Re,pt,Ze,St,Pe]}),e[157]=te,e[158]=X,e[159]=pe,e[160]=Re,e[161]=pt,e[162]=Ze,e[163]=St,e[164]=Pe,e[165]=Je):Je=e[165];let se;e[166]!==u?(se=u("settings.providers.page.custom.models.title"),e[166]=u,e[167]=se):se=e[167];let We;if(e[168]!==N.models||e[169]!==E||e[170]!==u){let Lt;e[172]!==N.models.length||e[173]!==E||e[174]!==u?(Lt=(Xt,Wt)=>s.jsx("div",{className:`${Es} space-y-2`,children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:Pt,children:u("settings.providers.page.custom.models.idLabel")}),s.jsx(Ge,{value:Xt.id,onChange:Mt=>ae(Wt,"id",Mt.target.value),placeholder:u("settings.providers.page.custom.models.idPlaceholder"),className:"mt-1 h-8 rounded-md px-3 font-mono text-xs","aria-label":u("settings.providers.page.custom.models.idLabel")}),E[Wt]?.id?s.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:E[Wt]?.id}):null]}),s.jsxs("div",{children:[s.jsx("label",{className:Pt,children:u("settings.providers.page.custom.models.nameLabel")}),s.jsx(Ge,{value:Xt.name,onChange:Mt=>ae(Wt,"name",Mt.target.value),placeholder:u("settings.providers.page.custom.models.namePlaceholder"),className:"mt-1 h-8 rounded-md px-3","aria-label":u("settings.providers.page.custom.models.nameLabel")}),E[Wt]?.name?s.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:E[Wt]?.name}):null]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("label",{className:Pt,children:u("settings.providers.page.custom.models.variantsLabel")}),s.jsx(Gt,{children:u("settings.providers.page.custom.models.variantsInfo")})]}),s.jsx(Ge,{value:Xt.variants,onChange:Mt=>ae(Wt,"variants",Mt.target.value),placeholder:u("settings.providers.page.custom.models.variantsPlaceholder"),className:"mt-1 h-8 rounded-md px-3 font-mono text-xs","aria-label":u("settings.providers.page.custom.models.variantsLabel")})]})]}),s.jsx(V,{type:"button",variant:"ghost",size:"icon",className:hs,disabled:N.models.length<=1,onClick:()=>{N.models.length<=1||(w(Mt=>({...Mt,models:Mt.models.filter((ls,is)=>is!==Wt)})),D(Mt=>Mt.filter((ls,is)=>is!==Wt)))},"aria-label":u("settings.providers.page.custom.models.remove"),children:s.jsx($,{name:"delete-bin",className:"size-4"})})]})},Xt.row),e[172]=N.models.length,e[173]=E,e[174]=u,e[175]=Lt):Lt=e[175],We=N.models.map(Lt),e[168]=N.models,e[169]=E,e[170]=u,e[171]=We}else We=e[171];let ut;e[176]===Symbol.for("react.memo_cache_sentinel")?(ut=()=>{w(Wb),D(Jb)},e[176]=ut):ut=e[176];let Ce;e[177]!==u?(Ce=u("settings.providers.page.custom.models.add"),e[177]=u,e[178]=Ce):Ce=e[178];let Ve;e[179]!==Ce?(Ve=s.jsx(V,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:ut,children:Ce}),e[179]=Ce,e[180]=Ve):Ve=e[180];let jt;e[181]!==se||e[182]!==We||e[183]!==Ve?(jt=s.jsxs(He,{title:se,contentClassName:Ms,children:[We,Ve]}),e[181]=se,e[182]=We,e[183]=Ve,e[184]=jt):jt=e[184];let Ot;e[185]!==u?(Ot=u("settings.providers.page.custom.headers.title"),e[185]=u,e[186]=Ot):Ot=e[186];let Yt;e[187]!==u?(Yt=u("settings.providers.page.custom.headers.description"),e[187]=u,e[188]=Yt):Yt=e[188];let Zt;e[189]!==Yt?(Zt=s.jsx("p",{className:ds,children:Yt}),e[189]=Yt,e[190]=Zt):Zt=e[190];let Ft;if(e[191]!==N.headers||e[192]!==L||e[193]!==u){let Lt;e[195]!==N.headers.length||e[196]!==L||e[197]!==u?(Lt=(Xt,Wt)=>s.jsx("div",{className:`${Es} space-y-2`,children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:Pt,children:u("settings.providers.page.custom.headers.keyLabel")}),s.jsx(Ge,{value:Xt.key,onChange:Mt=>G(Wt,"key",Mt.target.value),placeholder:u("settings.providers.page.custom.headers.keyPlaceholder"),className:"mt-1 h-8 rounded-md px-3 font-mono text-xs","aria-label":u("settings.providers.page.custom.headers.keyLabel")}),L[Wt]?.key?s.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:L[Wt]?.key}):null]}),s.jsxs("div",{children:[s.jsx("label",{className:Pt,children:u("settings.providers.page.custom.headers.valueLabel")}),s.jsx(Ge,{value:Xt.value,onChange:Mt=>G(Wt,"value",Mt.target.value),placeholder:u("settings.providers.page.custom.headers.valuePlaceholder"),className:"mt-1 h-8 rounded-md px-3 font-mono text-xs","aria-label":u("settings.providers.page.custom.headers.valueLabel")}),L[Wt]?.value?s.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:L[Wt]?.value}):null]})]}),s.jsx(V,{type:"button",variant:"ghost",size:"icon",className:hs,disabled:N.headers.length<=1,onClick:()=>{N.headers.length<=1||(w(Mt=>({...Mt,headers:Mt.headers.filter((ls,is)=>is!==Wt)})),P(Mt=>Mt.filter((ls,is)=>is!==Wt)))},"aria-label":u("settings.providers.page.custom.headers.remove"),children:s.jsx($,{name:"delete-bin",className:"size-4"})})]})},Xt.row),e[195]=N.headers.length,e[196]=L,e[197]=u,e[198]=Lt):Lt=e[198],Ft=N.headers.map(Lt),e[191]=N.headers,e[192]=L,e[193]=u,e[194]=Ft}else Ft=e[194];let ms;e[199]===Symbol.for("react.memo_cache_sentinel")?(ms=()=>{w(Qb),P(Yb)},e[199]=ms):ms=e[199];let gs;e[200]!==u?(gs=u("settings.providers.page.custom.headers.add"),e[200]=u,e[201]=gs):gs=e[201];let tn;e[202]!==gs?(tn=s.jsx(V,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:ms,children:gs}),e[202]=gs,e[203]=tn):tn=e[203];let $s;e[204]!==Ot||e[205]!==Zt||e[206]!==Ft||e[207]!==tn?($s=s.jsxs(He,{title:Ot,contentClassName:Ms,children:[Zt,Ft,tn]}),e[204]=Ot,e[205]=Zt,e[206]=Ft,e[207]=tn,e[208]=$s):$s=e[208];let Bs;e[209]!==b||e[210]!==m||e[211]!==u?(Bs=m?s.jsx(V,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:m,disabled:b,children:u("settings.providers.page.custom.actions.back")}):null,e[209]=b,e[210]=m,e[211]=u,e[212]=Bs):Bs=e[212];let cn;e[213]!==b||e[214]!==h||e[215]!==u?(cn=h?s.jsx(V,{type:"button",variant:"destructive",size:"xs",className:"!font-normal",onClick:()=>{h()},disabled:b,children:u("settings.providers.page.actions.disconnect")}):null,e[213]=b,e[214]=h,e[215]=u,e[216]=cn):cn=e[216];let sn;e[217]!==b||e[218]!==y||e[219]!==u?(sn=u(b?"settings.providers.page.actions.saving":y?"settings.providers.page.custom.actions.update":"settings.providers.page.custom.actions.save"),e[217]=b,e[218]=y,e[219]=u,e[220]=sn):sn=e[220];let nn;e[221]!==b||e[222]!==sn?(nn=s.jsx(V,{type:"submit",size:"xs",className:"!font-normal",disabled:b,children:sn}),e[221]=b,e[222]=sn,e[223]=nn):nn=e[223];let Vs;e[224]!==Bs||e[225]!==cn||e[226]!==nn?(Vs=s.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-4",children:[Bs,cn,nn]}),e[224]=Bs,e[225]=cn,e[226]=nn,e[227]=Vs):Vs=e[227];let Dn;return e[228]!==z||e[229]!==Je||e[230]!==jt||e[231]!==$s||e[232]!==Vs?(Dn=s.jsxs("form",{onSubmit:z,className:"space-y-0",children:[Je,jt,$s,Vs]}),e[228]=z,e[229]=Je,e[230]=jt,e[231]=$s,e[232]=Vs,e[233]=Dn):Dn=e[233],Dn};function Gb(t){return t.savedVariants?{...t,savedVariants:{}}:t}function Wb(t){return{...t,models:[...t.models,ol()]}}function Jb(t){return[...t,{}]}function Qb(t){return{...t,headers:[...t.headers,rl()]}}function Yb(t){return[...t,{}]}const Zb=t=>new Intl.NumberFormat(zr(),{notation:"compact",compactDisplay:"short",maximumFractionDigits:1,minimumFractionDigits:0}).format(t),vc=t=>{if(typeof t!="number"||Number.isNaN(t))return null;if(t===0)return"0";const e=Zb(t);return e.endsWith(".0")?e.slice(0,-2):e},On="__add_provider__",_a="__classification__",_d=t=>typeof t=="object"&&t!==null,Xb=t=>{if(typeof t=="string")return{id:t};if(!_d(t))return null;const e=typeof t.id=="string"&&t.id||typeof t.providerID=="string"&&t.providerID||typeof t.slug=="string"&&t.slug||typeof t.name=="string"&&t.name;if(!e)return null;const a=typeof t.name=="string"?t.name:void 0;return{id:e,name:a}},ev=t=>{let e=[];Array.isArray(t)?e=t:_d(t)&&(Array.isArray(t.all)?e=t.all:Array.isArray(t.providers)&&(e=t.providers));const a=e.map(i=>Xb(i)).filter(i=>!!i),n=new Set;return a.filter(i=>n.has(i.id)?!1:(n.add(i.id),!0))},tv=()=>{const{t}=qe(),{isMobile:e}=qn(),a=en(),n=ct(se=>sd(se,a)),i=re(se=>se.settingsProvidersConnectRequested),o=re(se=>se.setSettingsProvidersConnectRequested),r=re(se=>se.settingsProvidersClassificationRequested),d=re(se=>se.setSettingsProvidersClassificationRequested),c=re(se=>se.settingsProvidersOpenRequested),g=re(se=>se.setSettingsProvidersOpenRequested),[m,h]=l.useState(()=>i?On:r?_a:c??"");l.useEffect(()=>{i&&(h(On),o(!1))},[i,o]),l.useEffect(()=>{r&&(h(_a),d(!1))},[r,d]),l.useEffect(()=>{c&&(h(c),g(null))},[c,g]);const f=ct(se=>se.getModelMetadata),p=re(se=>se.hiddenModels),b=re(se=>se.toggleHiddenModel),C=re(se=>se.hideAllModels),v=re(se=>se.showAllModels),k=ct(se=>se.loadProviders);l.useEffect(()=>{a&&k({directory:a,source:"settings:providers"})},[k,a]);const[u,y]=l.useState(null),[S,N]=l.useState(!1),[w,A]=l.useState({}),[x,T]=l.useState(null),[M,E]=l.useState(null),[D,F]=l.useState(""),[L,P]=l.useState([]),[j,O]=l.useState(!1),[K,H]=l.useState(null),[q,Z]=l.useState(""),[ae,B]=l.useState(""),[G,_]=l.useState(!1),[z,te]=l.useState({}),[Q,X]=l.useState({}),[pe,je]=l.useState(0),[fe,ke]=l.useState(0),[be,De]=l.useState(!1),oe=ya(),[ee,ce]=l.useState(null),[ue,Ie]=l.useState(null),[ve,Re]=l.useState(null),[Me,me]=l.useState(null),[Te,Oe]=l.useState(null),[ge,xe]=l.useState(null),ne=m===On,ie=ne&&q===oa,he=!!(ue&&m&&ue===m&&!ne);l.useEffect(()=>{let se=!0;return(async()=>{N(!0);try{const{data:ut}=await Ts.getSdkClient().integration.list();if(!se)return;y(ut)}catch(ut){if(!se)return;console.error("Failed to load provider integrations:",ut),U.error(t("settings.providers.page.toast.authMethodsLoadFailed"))}finally{se&&N(!1)}})(),()=>{se=!1}},[fe,t]),l.useEffect(()=>{if(!Yx(ne))return;let se=!0;return(async()=>{O(!0),H(null);try{const[{data:ut},Ce]=await Promise.all([Ts.getSdkClient().integration.list(),Ru(Ts.getDirectory()??null).catch(()=>null)]);if(!se)return;const Ve=new Set((Ce??[]).map(jt=>jt.id));P(ev(ut.filter(jt=>!jt.id.startsWith("mcp_")&&!Ve.has(jt.id)&&jt.connections.length===0)))}catch(ut){if(!se)return;console.error("Failed to load available providers:",ut),H(t("settings.providers.page.state.unableToLoadProviderList"))}finally{se&&O(!1)}})(),()=>{se=!1}},[ne,t]);const Ee=l.useMemo(()=>new Set(n.map(se=>se.id)),[n]),Ke=l.useMemo(()=>L.filter(se=>!Ee.has(se.id)).sort((se,We)=>{const ut=(se.name||se.id).toLowerCase(),Ce=(We.name||We.id).toLowerCase();return ut.localeCompare(Ce)}),[L,Ee]);l.useEffect(()=>{m!==On||j||L.length===0||q&&q!==oa&&!Ke.some(se=>se.id===q)&&Z("")},[m,q,Ke,j,L.length]),l.useEffect(()=>{if(m===On){De(!0),ce(null),Ie(null),Re(null),me(null),Oe(null);return}De(!1),ce(null),ue&&ue!==m&&(Ie(null),Re(null),me(null),Oe(null))},[m,ue]),l.useEffect(()=>{if(!m||m===On||m===_a)return;const se=z[m];if(!se||u===null)return;const We=n.find(Ve=>Ve.id===m),ut=pc({connections:eo(u,m),optionsApiKey:Ir(We)}),Ce=!!(We&&fc(We,se));nb({hasCredentials:ut,userDismissed:ee===m,isEditableCustomProvider:Ce})&&De(!0)},[m,z,n,u,ee]),l.useEffect(()=>{if(!m||m===On||m===_a)return;let se=!1;return(async()=>{try{const ut=a?`?directory=${encodeURIComponent(a)}`:"",Ce=await It(`/api/provider/${encodeURIComponent(m)}/source${ut}`,{method:"GET",headers:{Accept:"application/json"}}),Ve=await Ce.json().catch(()=>null);if(!Ce.ok)throw new Error(Ve?.error||t("settings.providers.page.toast.providerSourcesLoadFailed"));const jt=Ve?.sources??Ve?.data?.sources;!se&&jt&&(te(Ot=>({...Ot,[m]:jt})),X(Ot=>({...Ot,[m]:zb.safeParse(Ve?.config??Ve?.data?.config).data??null})))}catch(ut){se||console.error("Failed to load provider sources:",ut)}})(),()=>{se=!0}},[m,pe,a,t]);const Le=l.useCallback(()=>{je(se=>se+1)},[]),Se=l.useCallback(()=>{ke(se=>se+1)},[]),$e=l.useCallback(se=>{y(We=>(We??[]).map(ut=>ut.id===se&&ut.connections.length===0?{...ut,connections:[{type:"credential",id:`pending:${se}`,label:se,method:"key"}]}:ut)),ce(null),De(!1),h(se),Le(),Se()},[Se,Le,h]),Ye=n.find(se=>se.id===m),pt=m?z[m]:void 0,vt=async se=>{const We=w[se]?.trim()??"";if(!We){U.error(t("settings.providers.page.toast.apiKeyRequired"));return}const ut=`api:${se}`;T(ut);try{await Ts.getSdkClient().integration.connect.key({integrationID:se,key:We}),U.success(t("settings.providers.page.toast.apiKeySaved")),A(Ce=>({...Ce,[se]:""})),$e(se)}catch(Ce){console.error("Failed to save API key:",Ce),U.error(t("settings.providers.page.toast.apiKeySaveFailed"))}finally{T(null)}},wt=async se=>{const We=`custom:${se.providerID}`;T(We),xe(se.providerID),Oe(null);try{const ut=Bb(se),Ce=Vb(se,{scope:ue?Me??hc(z[ue]):"user"}),Ve=await It(`/api/provider${a?`?directory=${encodeURIComponent(a)}`:""}`,{method:"PUT",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(Ce)}),jt=await Ve.json().catch(()=>null);if(!Ve.ok)throw new Error(jt?.error||t("settings.providers.page.toast.customProviderSaveFailed"));if(ut)try{await qb(()=>Ts.getSdkClient().integration.connect.key(ut))}catch(Ot){throw Oe(t("settings.providers.page.custom.authFailure.keyAfterConfig")),Ot}U.success(t("settings.providers.page.toast.customProviderSaved",{provider:se.name})),Z(""),Ie(null),Re(null),me(null),Oe(null),xe(null),$e(se.providerID)}catch(ut){console.error("Failed to save custom provider:",ut),U.error(ut instanceof Error&&ut.message?ut.message:t("settings.providers.page.toast.customProviderSaveFailed"))}finally{T(null)}},yt=se=>{De(!1),$e(se)},st=async se=>{const We=`disconnect:${se}`;T(We);try{const ut=mc(Kn(u??[],se)),Ce=Ts.getSdkClient();for(const Ve of ut)await Ce.credential.remove({credentialID:Ve.id});U.success(t("settings.providers.page.toast.providerDisconnected")),ce(null),Le(),Se()}catch(ut){console.error("Failed to disconnect provider:",ut),U.error(t("settings.providers.page.toast.providerDisconnectFailed"))}finally{T(null)}},rt=async se=>{se&&(await st(se),Ie(null),Re(null),me(null),Oe(null),xe(null),Z(""))},de=async(se,We,ut)=>{E(se.id);try{await We(),ut.success&&U.success(ut.success)}catch(Ce){console.error("Provider account action failed:",Ce),U.error(ut.failure)}finally{E(null),Se()}},Ue=se=>de(se,async()=>{await Ts.getSdkClient().credential.activate({credentialID:se.id})},{success:t("settings.providers.accounts.toast.switched",{account:se.label}),failure:t("settings.providers.accounts.toast.switchFailed")}),et=(se,We)=>de(se,async()=>{await Ts.getSdkClient().credential.update({credentialID:se.id,label:We})},{failure:t("settings.providers.accounts.toast.renameFailed")}),ze=se=>de(se,async()=>{await Ts.getSdkClient().credential.remove({credentialID:se.id}),Le()},{success:t("settings.providers.accounts.toast.removed"),failure:t("settings.providers.accounts.toast.removeFailed")}),Ze=()=>h(""),tt=s.jsx(tl,{label:t("settings.providers.page.back"),onClick:Ze}),lt=se=>{if(n.some(We=>We.id===se)){h(se);return}Z(se),h(On)};if(m===_a)return s.jsx(wb,{titleLeading:tt,onOpenProvider:lt});if(ne&&!oe)return s.jsxs(ns,{title:t("settings.providers.page.connect.title"),titleLeading:tt,showSaveStatus:!1,children:[s.jsx(He,{title:t("settings.providers.page.connect.selectProviderTitle"),divider:!1,settingsItem:"providers.connect",children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1.5",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:t("settings.providers.page.connect.providerField")}),j?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.providers.page.state.loading")}):K?s.jsx("p",{className:"typography-meta text-muted-foreground",children:K}):s.jsxs(Jn,{open:G,onOpenChange:se=>{_(se),se||B("")},children:[s.jsx(Wn,{asChild:!0,children:s.jsxs("button",{type:"button",className:Zs,children:[s.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[q&&q!==oa?s.jsx($n,{providerId:q,className:"h-3.5 w-3.5 flex-shrink-0"}):null,s.jsx("span",{className:Ne("truncate typography-ui-label font-normal",q?"text-foreground":"text-muted-foreground"),children:q===oa?t("settings.providers.page.custom.optionLabel"):q?Ke.find(se=>se.id===q)?.name||q:t("settings.providers.page.connect.selectProviderPlaceholder")})]}),s.jsx($,{name:"arrow-down-s",className:"h-4 w-4 flex-shrink-0 text-muted-foreground/50"})]})}),s.jsxs(Gn,{align:"start",className:"w-[280px] p-0",onCloseAutoFocus:se=>se.preventDefault(),children:[s.jsxs("div",{className:"flex items-center gap-2 border-b border-[var(--surface-subtle)] px-3 py-2",onKeyDown:se=>se.stopPropagation(),children:[s.jsx($,{name:"search",className:"h-4 w-4 text-muted-foreground"}),s.jsx("input",{type:"text",value:ae,onChange:se=>B(se.target.value),onKeyDown:se=>se.stopPropagation(),placeholder:t("settings.providers.page.connect.searchProvidersPlaceholder"),className:"flex-1 bg-transparent typography-meta outline-none placeholder:text-muted-foreground",autoFocus:!0})]}),s.jsx(Ds,{outerClassName:"max-h-[240px]",className:"p-1",children:(()=>{const se=t("settings.providers.page.custom.optionLabel"),We=go([se,"other","custom"],ae),ut=sa(Ke,ae,Ce=>[Ce.name||Ce.id,Ce.id]);return ut.length===0&&!We?s.jsx("p",{className:"py-4 text-center typography-meta text-muted-foreground",children:t("settings.providers.page.connect.noProvidersFound")}):s.jsxs(s.Fragment,{children:[ut.map(Ce=>s.jsxs(xn,{onSelect:()=>{Z(Ce.id),_(!1),B("")},className:"flex items-center justify-between",children:[s.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[s.jsx($n,{providerId:Ce.id,className:"h-4 w-4 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:Ce.name||Ce.id})]}),q===Ce.id&&s.jsx($,{name:"check",className:"h-4 w-4 text-[var(--primary-base)]"})]},Ce.id)),We?s.jsxs(xn,{onSelect:()=>{Z(oa),_(!1),B("")},className:"flex items-center justify-between",children:[s.jsxs("span",{className:"flex items-center gap-2 min-w-0",children:[s.jsx($,{name:"add",className:"h-4 w-4 flex-shrink-0"}),s.jsx("span",{className:"truncate",children:se})]}),q===oa&&s.jsx($,{name:"check",className:"h-4 w-4 text-[var(--primary-base)]"})]},oa):null]})})()})]})]})]})}),ie?s.jsx(bc,{mode:"create",existingProviderIDs:Ee,busy:x?.startsWith("custom:")??!1,authFailureHint:Te,onCancel:()=>{Z(""),Oe(null),xe(null)},onDisconnect:Te&&ge?()=>{rt(ge)}:void 0,onSubmit:wt}):q?s.jsx(He,{title:t("settings.providers.page.auth.title"),settingsItem:"providers.auth",contentClassName:"space-y-4",children:S?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.providers.page.auth.loadingMethods")}):s.jsx(s.Fragment,{children:(()=>{const se=Kn(u??[],q),We=dc(Kn(u??[],fi(q))),ut=uc(se);return s.jsxs(s.Fragment,{children:[ut?s.jsxs("div",{className:"py-1.5",children:[s.jsxs("label",{className:"typography-ui-label text-foreground flex items-center gap-1.5",children:[t("settings.providers.page.auth.apiKeyLabel"),s.jsx(Gt,{children:t("settings.providers.page.auth.apiKeyTooltip")})]}),s.jsxs("div",{className:"flex flex-col @xl:flex-row @xl:items-center gap-2 mt-1.5",children:[s.jsx(Ge,{type:"password",value:w[q]??"",onChange:Ce=>A(Ve=>({...Ve,[q]:Ce.target.value})),placeholder:t("settings.providers.page.auth.apiKeyPlaceholder"),className:"flex-1 font-mono text-xs"}),s.jsx(V,{size:"xs",className:"!font-normal shrink-0",onClick:()=>vt(q),disabled:x===`api:${q}`,children:x===`api:${q}`?t("settings.providers.page.actions.saving"):t("settings.providers.page.actions.saveKey")})]})]}):null,We.length>0?s.jsx(kr,{integrationId:fi(q),methods:We,onConnected:()=>yt(q),className:Ne(ut&&"border-t border-[var(--surface-subtle)] pt-2")},q):null]})})()})}):null]});if(!Ye)return s.jsx(pb,{providers:n,integrations:u,directory:a,onSelect:h,onConnect:()=>h(On),onOpenClassification:()=>h(_a)});const J=Array.isArray(Ye.models)?Ye.models:[],nt=Kn(u??[],Ye.id),ot=dc(Kn(u??[],fi(Ye.id))),it=uc(nt),ft=u!==null,xt=!!pt,ht=xt&&fc(Ye,pt),St=pc({connections:eo(u??[],Ye.id),optionsApiKey:Ir(Ye)}),At=Zx(ft,St,ht),_e=sb({modelCount:J.length,integrationsLoaded:ft,hasCredentials:St,isEditableCustomProvider:ht}),Xe=eo(u??[],Ye.id)??[],mt=Ye.integrationID??Ye.id,Fe=mc(Kn(u??[],mt)),W=Fe[0]?.id??null,ye=new Set(Xe.flatMap(se=>se.type==="credential"&&!Fe.some(We=>We.id===se.id)?[se.id]:[])),Ae=[pt?.user.exists?t("settings.providers.page.connectionDetails.source.userConfig"):null,pt?.project.exists?t("settings.providers.page.connectionDetails.source.projectConfig"):null,pt?.custom?.exists?t("settings.providers.page.connectionDetails.source.customConfig"):null].filter(se=>se!==null),Y=s.jsxs("span",{className:"flex items-center gap-2",children:[tt,s.jsx($n,{providerId:Ye.id,className:"h-5 w-5 shrink-0"})]}),Pe=s.jsxs("span",{className:"typography-settings-description text-muted-foreground",children:[s.jsx("span",{className:"font-mono",children:Ye.id}),Ae.length>0?s.jsxs(s.Fragment,{children:[" · ",t("settings.providers.page.configuredIn",{sources:Ae.join(", ")})]}):null]}),Je=sa(J,D,se=>[typeof se?.name=="string"?se.name:"",typeof se?.id=="string"?se.id:""]);return he&&ht&&ve?s.jsx(ns,{title:Ye.name||Ye.id,titleLeading:Y,description:Pe,showSaveStatus:!1,children:s.jsx(bc,{mode:"edit",existingProviderIDs:Ee,initialValues:ve,allowExistingAuth:St||!xt,busy:x?.startsWith("custom:")??!1,authFailureHint:Te,onCancel:()=>{Ie(null),Re(null),me(null),Oe(null),xe(null)},onDisconnect:()=>{rt(Ye.id)},onSubmit:wt})}):s.jsxs(ns,{title:Ye.name||Ye.id,titleLeading:Y,description:Pe,showSaveStatus:!1,children:[s.jsxs(He,{title:t("settings.providers.accounts.title"),info:t("settings.providers.accounts.info"),divider:!1,headerAction:s.jsxs("div",{className:"flex items-center gap-1",children:[ht&&!oe?s.jsx(V,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Oe(null),Re(Ub(Ye,Q[Ye.id]??null)),me(hc(pt)),Ie(Ye.id)},children:t("settings.providers.page.actions.edit")}):null,oe?null:s.jsx(V,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{const se=!be;De(se),ce(se?null:Ye.id)},children:be?t("settings.providers.page.actions.cancel"):s.jsxs(s.Fragment,{children:[s.jsx($,{name:"add",className:"size-3.5"}),Xe.length>0?t("settings.providers.accounts.add"):t("settings.providers.page.actions.connect")]})})]}),settingsItem:"providers.auth",contentClassName:"space-y-4",children:[Xe.length>0?s.jsx(Ib,{connections:Xe,activeId:W,unusedIds:ye,busyId:M,onActivate:se=>{Ue(se)},onRename:(se,We)=>{et(se,We)},onRemove:se=>{ze(se)}}):!be&&At?s.jsxs("div",{className:"flex items-center gap-1.5 py-1.5",children:[s.jsx($,{name:"alert",className:"w-4 h-4 text-[var(--status-warning)] shrink-0"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:t("settings.providers.page.auth.incomplete")}),it?s.jsx(Gt,{children:t("settings.providers.page.auth.incompleteHint")}):null]}):null,oe?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.providers.enterpriseMode")}):null,!be||oe?null:S?s.jsx("div",{className:"py-1.5 typography-meta text-muted-foreground",children:t("settings.providers.page.auth.loadingMethods")}):s.jsxs("div",{className:Ne("space-y-4",Xe.length>0&&"rounded-xl border border-[var(--interactive-border)] p-4"),children:[it?s.jsxs("div",{className:"py-1.5",children:[s.jsxs("label",{className:"typography-ui-label text-foreground flex items-center gap-1.5",children:[t("settings.providers.page.auth.apiKeyLabel"),s.jsx(Gt,{children:t("settings.providers.page.auth.apiKeyTooltip")})]}),s.jsxs("div",{className:"flex flex-col @xl:flex-row @xl:items-center gap-2 mt-1.5",children:[s.jsx(Ge,{type:"password",value:w[Ye.id]??"",onChange:se=>A(We=>({...We,[Ye.id]:se.target.value})),placeholder:t("settings.providers.page.auth.apiKeyPlaceholder"),className:"flex-1 font-mono text-xs"}),s.jsx(V,{size:"xs",className:"!font-normal shrink-0",onClick:()=>vt(Ye.id),disabled:x===`api:${Ye.id}`,children:x===`api:${Ye.id}`?t("settings.providers.page.actions.saving"):t("settings.providers.page.actions.saveKey")})]})]}):null,ot.length>0&&s.jsx(kr,{integrationId:fi(Ye.id),methods:ot,onConnected:()=>yt(Ye.id),className:Ne(it&&"border-t border-[var(--surface-subtle)] pt-2")},Ye.id)]})]}),_e?s.jsxs(He,{title:t("settings.providers.page.models.title"),titleAccessory:s.jsxs("span",{className:"typography-micro text-muted-foreground font-normal",children:["(",J.length,")"]}),headerAction:s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(V,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{const se=J.map(We=>typeof We?.id=="string"?We.id:"").filter(We=>We.length>0);C(Ye.id,se)},children:t("settings.providers.page.actions.hideAll")}),s.jsx(V,{variant:"outline",size:"xs",className:"!font-normal",onClick:()=>v(Ye.id),children:t("settings.providers.page.actions.showAll")})]}),settingsItem:"providers.models",children:[s.jsxs("div",{className:"relative mb-2",children:[s.jsx($,{name:"search",className:"absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground"}),s.jsx(Ge,{value:D,onChange:se=>F(se.target.value),placeholder:t("settings.providers.page.models.filterPlaceholder"),className:"h-7 pl-8 w-full"})]}),Je.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground py-4 text-center",children:t("settings.providers.page.models.noModelsMatchFilter")}):s.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:Je.map(se=>{const We=typeof se?.id=="string"?se.id:"",ut=typeof se?.name=="string"?se.name:We,Ce=We?f(Ye.id,We):void 0,Ve=p.some(Ft=>Ft.providerID===Ye.id&&Ft.modelID===We),jt=vc(Ce?.limit?.context),Ot=vc(Ce?.limit?.output),Yt=[jt?`${jt} ${t("settings.providers.page.models.tokenBadge.context")}`:null,Ot?`${Ot} ${t("settings.providers.page.models.tokenBadge.output")}`:null].filter(Boolean).join(" · "),Zt=[];return Ce?.tool_call&&Zt.push({key:"tools",icon:"tools",label:t("settings.providers.page.models.capability.toolCalling")}),Ce?.reasoning&&Zt.push({key:"reasoning",icon:"brain-ai-3",label:t("settings.providers.page.models.capability.reasoning")}),Ce?.attachment&&Zt.push({key:"image",icon:"file-image",label:t("settings.providers.page.models.capability.imageInput")}),s.jsx("div",{className:"py-1.5",children:s.jsxs("div",{className:Ne("flex items-center gap-3",Ve&&"opacity-50"),children:[s.jsx("span",{className:"typography-meta font-medium text-foreground truncate flex-1 min-w-0",children:ut}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e?Yt||Zt.length>0?s.jsx(Gt,{className:"h-6 w-6",children:s.jsxs("div",{className:"space-y-1.5",children:[Yt?s.jsx("div",{className:"font-medium",children:Yt}):null,Zt.map(({key:Ft,icon:ms,label:gs})=>s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx($,{name:ms,className:"h-3.5 w-3.5"}),gs]},Ft))]})}):null:s.jsxs(s.Fragment,{children:[Yt?s.jsx("span",{className:"typography-micro text-muted-foreground flex-shrink-0 bg-[var(--surface-muted)] px-1.5 py-0.5 rounded",children:Yt}):null,Zt.length>0&&s.jsx("div",{className:"flex items-center gap-1 flex-shrink-0",children:Zt.map(({key:Ft,icon:ms,label:gs})=>s.jsx("span",{className:"flex h-5 w-5 rounded items-center justify-center text-muted-foreground bg-[var(--surface-muted)]",title:gs,"aria-label":gs,children:s.jsx($,{name:ms,className:"h-3 w-3"})},Ft))})]}),s.jsx("button",{type:"button",onClick:()=>b(Ye.id,We),className:"flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-[var(--interactive-hover)]/50",title:t(Ve?"settings.providers.page.models.actions.showModelInSelectors":"settings.providers.page.models.actions.hideModelFromSelectors"),"aria-label":t(Ve?"settings.providers.page.models.actions.showModel":"settings.providers.page.models.actions.hideModel"),children:Ve?s.jsx($,{name:"eye-off",className:"h-3.5 w-3.5"}):s.jsx($,{name:"eye",className:"h-3.5 w-3.5"})})]})]})},We)})})]}):null]})},sv=t=>{const e=t?.windows??{},a=Object.values(e).map(n=>n.usedPercent).filter(n=>typeof n=="number");return a.length===0?null:Math.max(...a)},nv=t=>{const e=Be.c(75),{onItemSelect:a}=t,{t:n}=qe(),i=cs(av),o=cs(iv),r=cs(ov),d=cs(rv),c=cs(lv),g=cs(cv),m=cs(dv),h=cs(uv);let f,p;e[0]!==h?(f=()=>{h()},p=[h],e[0]=h,e[1]=f,e[2]=p):(f=e[1],p=e[2]),l.useEffect(f,p);const b=mv;let C;e[3]!==m?(C=X=>{X!=="usage"&&X!=="remaining"||(m(X),b({usageDisplayMode:X}))},e[3]=m,e[4]=C):C=e[4];const v=C;let k;e[5]===Symbol.for("react.memo_cache_sentinel")?(k=Ne("flex h-full flex-col","bg-background"),e[5]=k):k=e[5];let u;e[6]!==n?(u=n("settings.usage.sidebar.title"),e[6]=n,e[7]=u):u=e[7];let y;e[8]!==u?(y=s.jsx("h2",{className:`${va} mb-3`,children:u}),e[8]=u,e[9]=y):y=e[9];let S;e[10]!==n?(S=n("settings.usage.sidebar.total",{count:so.length}),e[10]=n,e[11]=S):S=e[11];let N;e[12]!==S?(N=s.jsx("span",{className:"typography-meta text-muted-foreground",children:S}),e[12]=S,e[13]=N):N=e[13];let w;e[14]!==d?(w=()=>d(),e[14]=d,e[15]=w):w=e[15];let A;e[16]!==n?(A=n("settings.usage.sidebar.actions.refreshAria"),e[16]=n,e[17]=A):A=e[17];let x;e[18]!==n?(x=n("settings.usage.sidebar.actions.refreshTitle"),e[18]=n,e[19]=x):x=e[19];const T=c&&"animate-spin";let M;e[20]!==T?(M=Ne("h-3.5 w-3.5",T),e[20]=T,e[21]=M):M=e[21];let E;e[22]!==M?(E=s.jsx($,{name:"refresh",className:M}),e[22]=M,e[23]=E):E=e[23];let D;e[24]!==c||e[25]!==A||e[26]!==x||e[27]!==E||e[28]!==w?(D=s.jsx("div",{className:"flex items-center gap-2",children:s.jsx(V,{size:"sm",variant:"ghost",className:"h-7 w-7 px-0 text-muted-foreground",onClick:w,"aria-label":A,title:x,disabled:c,children:E})}),e[24]=c,e[25]=A,e[26]=x,e[27]=E,e[28]=w,e[29]=D):D=e[29];let F;e[30]!==D||e[31]!==N?(F=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[N,D]}),e[30]=D,e[31]=N,e[32]=F):F=e[32];let L;e[33]!==n?(L=n("settings.usage.sidebar.field.display"),e[33]=n,e[34]=L):L=e[34];let P;e[35]!==L?(P=s.jsx("span",{className:"typography-micro text-muted-foreground",children:L}),e[35]=L,e[36]=P):P=e[36];let j;e[37]!==n?(j=n("settings.usage.sidebar.field.displayModePlaceholder"),e[37]=n,e[38]=j):j=e[38];let O;e[39]!==j?(O=s.jsx(Tt,{className:"w-fit",children:s.jsx(Jt,{placeholder:j})}),e[39]=j,e[40]=O):O=e[40];let K;e[41]!==n?(K=n("settings.usage.sidebar.field.displayModeUsage"),e[41]=n,e[42]=K):K=e[42];let H;e[43]!==K?(H=s.jsx(gt,{value:"usage",children:K}),e[43]=K,e[44]=H):H=e[44];let q;e[45]!==n?(q=n("settings.usage.sidebar.field.displayModeRemaining"),e[45]=n,e[46]=q):q=e[46];let Z;e[47]!==q?(Z=s.jsx(gt,{value:"remaining",children:q}),e[47]=q,e[48]=Z):Z=e[48];let ae;e[49]!==H||e[50]!==Z?(ae=s.jsxs(Et,{children:[H,Z]}),e[49]=H,e[50]=Z,e[51]=ae):ae=e[51];let B;e[52]!==v||e[53]!==O||e[54]!==ae||e[55]!==g?(B=s.jsxs(Dt,{value:g,onValueChange:v,children:[O,ae]}),e[52]=v,e[53]=O,e[54]=ae,e[55]=g,e[56]=B):B=e[56];let G;e[57]!==P||e[58]!==B?(G=s.jsxs("div",{className:"mt-2 flex items-center justify-between gap-2",children:[P,B]}),e[57]=P,e[58]=B,e[59]=G):G=e[59];let _;e[60]!==F||e[61]!==G||e[62]!==y?(_=s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[y,F,G]}),e[60]=F,e[61]=G,e[62]=y,e[63]=_):_=e[63];let z;e[64]!==a||e[65]!==i||e[66]!==o||e[67]!==r||e[68]!==n?(z=so.map(X=>{const pe=i.find(oe=>oe.providerId===X.id),je=sv(pe?.usage),fe=nd(je),ke=X.id===o,be=pe?.configured,De=be?fe==="critical"?{backgroundColor:"var(--status-error)"}:fe==="warn"?{backgroundColor:"var(--status-warning)"}:{backgroundColor:"var(--status-success)"}:{backgroundColor:"var(--surface-muted-foreground)",opacity:.4};return s.jsx("div",{className:Ne("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200",ke?"bg-interactive-selection":"hover:bg-interactive-hover"),children:s.jsxs("button",{type:"button",onClick:()=>{r(X.id),a?.()},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-ring",children:[s.jsx("span",{className:"h-2.5 w-2.5 rounded-full flex-shrink-0",style:De}),s.jsx($n,{providerId:X.id,className:"h-4 w-4 flex-shrink-0"}),s.jsx("span",{className:"typography-ui-label font-normal truncate flex-1 min-w-0 text-foreground",children:X.name}),be===!1&&s.jsx("span",{className:"typography-micro text-muted-foreground/60 flex-shrink-0",children:n("settings.usage.sidebar.status.notSet")})]})},X.id)}),e[64]=a,e[65]=i,e[66]=o,e[67]=r,e[68]=n,e[69]=z):z=e[69];let te;e[70]!==z?(te=s.jsx(Ds,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2 overflow-x-hidden",children:z}),e[70]=z,e[71]=te):te=e[71];let Q;return e[72]!==_||e[73]!==te?(Q=s.jsxs("div",{className:k,children:[_,te]}),e[72]=_,e[73]=te,e[74]=Q):Q=e[74],Q};function av(t){return t.results}function iv(t){return t.selectedProviderId}function ov(t){return t.setSelectedProvider}function rv(t){return t.fetchAllQuotas}function lv(t){return t.isLoading}function cv(t){return t.displayMode}function dv(t){return t.setDisplayMode}function uv(t){return t.loadSettings}async function mv(t){try{await kt(t)}catch(e){console.warn("Failed to save usage settings:",e)}}const pv=t=>{const e=Be.c(17),{percent:a,tonePercent:n,className:i}=t;let o;e[0]!==a?(o=Ou(a)??0,e[0]=a,e[1]=o):o=e[1];const r=o,d=n??a;let c;e[2]!==d?(c=nd(d),e[2]=d,e[3]=c):c=e[3];const g=c;let m;e[4]!==g?(m=g==="critical"?{backgroundColor:"var(--status-error)"}:g==="warn"?{backgroundColor:"var(--status-warning)"}:{backgroundColor:"var(--status-success)"},e[4]=g,e[5]=m):m=e[5];const h=m;let f;e[6]!==i?(f=Ne("relative h-2.5 rounded-full bg-[var(--interactive-border)] overflow-hidden",i),e[6]=i,e[7]=f):f=e[7];const p=`${r}%`;let b;e[8]!==h||e[9]!==p?(b={...h,width:p},e[8]=h,e[9]=p,e[10]=b):b=e[10];let C;e[11]!==r||e[12]!==b?(C=s.jsx("div",{className:"h-full transition-all duration-300",style:b,role:"progressbar","aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100}),e[11]=r,e[12]=b,e[13]=C):C=e[13];let v;return e[14]!==f||e[15]!==C?(v=s.jsx("div",{className:f,children:C}),e[14]=f,e[15]=C,e[16]=v):v=e[16],v},er=t=>{const e=Be.c(37),{title:a,window:n,subtitle:i,showToggle:o,toggleEnabled:r,onToggle:d}=t,c=o===void 0?!1:o,g=r===void 0?!1:r,m=cs(gv),h=re(fv),f=m==="remaining"?n.remainingPercent:n.usedPercent,p=f!==null,b=m==="remaining"?"remaining":"used";let C;e[0]!==f||e[1]!==n.valueLabel?(C=Lu(n.valueLabel,f),e[0]=f,e[1]=n.valueLabel,e[2]=C):C=e[2];const v=C,k=n.resetAfterFormatted??n.resetAtFormatted;let u;e[3]!==k||e[4]!==h||e[5]!==n.resetAt?(u=Fu(n.resetAt,k,h),e[3]=k,e[4]=h,e[5]=n.resetAt,e[6]=u):u=e[6];const y=u,S=y?`Resets ${y}`:"";let N;e[7]!==a?(N=Ku(a),e[7]=a,e[8]=N):N=e[8];const w=N;let A;e[9]!==d||e[10]!==c||e[11]!==g?(A=c&&s.jsx(gr,{checked:g,onChange:O=>d?.(O),ariaLabel:"Show in dropdown"}),e[9]=d,e[10]=c,e[11]=g,e[12]=A):A=e[12];let x;e[13]!==w?(x=s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:w}),e[13]=w,e[14]=x):x=e[14];let T;e[15]!==i?(T=i&&s.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:i}),e[15]=i,e[16]=T):T=e[16];let M;e[17]!==x||e[18]!==T?(M=s.jsxs("div",{className:"min-w-0 flex flex-col",children:[x,T]}),e[17]=x,e[18]=T,e[19]=M):M=e[19];let E;e[20]!==M||e[21]!==A?(E=s.jsxs("div",{className:"min-w-0 flex-1 flex items-center gap-2",children:[A,M]}),e[20]=M,e[21]=A,e[22]=E):E=e[22];const D=v==="-"?"":v;let F;e[23]!==D?(F=s.jsx("div",{className:"typography-ui-label text-foreground tabular-nums flex items-center justify-end",children:D}),e[23]=D,e[24]=F):F=e[24];let L;e[25]!==E||e[26]!==F?(L=s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[E,F]}),e[25]=E,e[26]=F,e[27]=L):L=e[27];let P;e[28]!==b||e[29]!==f||e[30]!==p||e[31]!==S||e[32]!==n.usedPercent?(P=p?s.jsxs("div",{className:"mt-2.5",children:[s.jsx(pv,{percent:f,tonePercent:n.usedPercent,className:"h-1.5"}),s.jsxs("div",{className:"mt-1 flex items-center justify-between",children:[s.jsx("span",{className:"typography-micro text-muted-foreground",children:S}),s.jsx("span",{className:"typography-micro text-muted-foreground",children:b})]})]}):S?s.jsx("div",{className:"mt-1 typography-micro text-muted-foreground",children:S}):null,e[28]=b,e[29]=f,e[30]=p,e[31]=S,e[32]=n.usedPercent,e[33]=P):P=e[33];let j;return e[34]!==L||e[35]!==P?(j=s.jsxs("div",{className:"py-3",children:[L,P]}),e[34]=L,e[35]=P,e[36]=j):j=e[36],j};function gv(t){return t.displayMode}function fv(t){return t.timeFormatPreference}const hv=`ssh exe.dev "ssh-key generate-api-key --label=openchamber --exp=30d --cmds='billing credits usage'"`,xv=({providerId:t,providerName:e})=>{const{t:a}=qe(),[n,i]=l.useState(null),[o,r]=l.useState({}),[d,c]=l.useState(!1),g=`/api/quota/credentials/${t}`;l.useEffect(()=>{It(g).then(async f=>{if(!f.ok)throw new Error;const p=await f.json();i(p),r({})}).catch(()=>i({configured:!1}))},[g]);const m=async(f,p,b)=>{c(!0);try{const C=await It(f,{method:p,headers:b?{"Content-Type":"application/json"}:void 0,body:b?JSON.stringify(b):void 0}),v=await C.json().catch(()=>null);if(!C.ok)throw new Error(v?.error);v?.configured!==void 0&&i(v),r({}),U.success(a("settings.providers.page.quotaCredentials.saved",{provider:e}))}catch(C){U.error(C instanceof Error&&C.message?C.message:a("settings.providers.page.openCodeGo.saveFailed"))}finally{c(!1)}},h=(f,p,b)=>s.jsxs("label",{className:"block typography-ui-label text-foreground",children:[p,s.jsx(Ge,{className:"mt-1 h-7 font-mono text-xs",type:"password",autoComplete:"off",value:o[f]??"",onChange:C=>r(v=>({...v,[f]:C.target.value})),placeholder:n?.secretMasked??b})]});return s.jsxs("div",{"data-settings-item":`usage.${t}-credentials`,className:"mb-8",children:[s.jsx("div",{className:"mb-1 px-1",children:s.jsx("h3",{className:"typography-ui-header font-medium text-foreground",children:e})}),s.jsxs("section",{className:"space-y-3 px-2 pb-2 pt-0",children:[t==="exe-dev"&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("p",{className:"typography-meta text-muted-foreground",children:a("settings.providers.page.quotaCredentials.exeDevTokenInstructions")}),s.jsx("code",{className:"typography-code block whitespace-pre-wrap break-all rounded bg-muted/50 px-2 py-1.5 text-xs text-foreground",children:hv})]}),t==="ollama-cloud"&&h("cookie",a("settings.providers.page.openCodeGo.authCookie"),"aid=...; __Secure-session=..."),t==="exe-dev"&&h("usageToken",a("settings.providers.page.quotaCredentials.usageToken"),a("settings.providers.page.quotaCredentials.tokenPlaceholder")),t==="cursor"&&h("accessToken",a("settings.providers.page.quotaCredentials.accessToken"),a("settings.providers.page.quotaCredentials.tokenPlaceholder")),t==="cursor"&&h("refreshToken",a("settings.providers.page.quotaCredentials.refreshToken"),a("settings.providers.page.quotaCredentials.tokenPlaceholder")),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.jsx(V,{size:"xs",disabled:d,onClick:()=>m(g,"PUT",o),children:n?.configured?a("settings.providers.page.openCodeGo.replace"):a("settings.providers.page.openCodeGo.save")}),n?.configured&&s.jsx(V,{variant:"outline",size:"xs",disabled:d,onClick:()=>m(`${g}/validate`,"POST"),children:a("settings.providers.page.openCodeGo.validate")}),t==="cursor"&&s.jsx(V,{variant:"outline",size:"xs",disabled:d,onClick:()=>m(`${g}/import`,"POST"),children:a("settings.providers.page.actions.connect")}),n?.configured&&s.jsx(V,{variant:"destructive",size:"xs",disabled:d,onClick:()=>m(g,"DELETE"),children:a("settings.providers.page.openCodeGo.delete")})]})]})]})},yc=(t,e)=>{if(!t)return"-";try{return ad(t,e,{fallback:"-"})}catch{return"-"}},bv=()=>{const{t}=qe(),e=re(j=>j.timeFormatPreference),a=cs(j=>j.results),n=cs(j=>j.selectedProviderId),i=cs(j=>j.setSelectedProvider),o=cs(j=>j.loadSettings),r=cs(j=>j.fetchAllQuotas),d=cs(j=>j.isLoading),c=cs(j=>j.lastUpdated),g=cs(j=>j.refreshErrors),m=cs(j=>j.dropdownProviderIds),h=cs(j=>j.setDropdownProviderIds),f=cs(j=>j.selectedModels),p=cs(j=>j.toggleModelSelected),b=cs(j=>j.applyDefaultSelections);zu(),l.useEffect(()=>{o(),r()},[o,r]),l.useEffect(()=>{if(n||a.length===0)return;const j=a.find(O=>O.configured)?.providerId;i(j??so[0]?.id??null)},[a,n,i]);const C=a.find(j=>j.providerId===n)??null,k=so.find(j=>j.id===n)?.name??n??t("settings.usage.sidebar.title"),u=C?.usage,y=n?g[n]:void 0,S=y?u?t("header.services.usageRefreshFailedStale",{error:y}):y:C?.configured&&!C.ok?C.error:null,N=n?m.includes(n):!1,w=n==="exe-dev"||n==="ollama-cloud"||n==="cursor",A=l.useCallback(j=>{if(!n)return;const O=j?Array.from(new Set([...m,n])):m.filter(K=>K!==n);h(O),kt({usageDropdownProviders:O})},[m,n,h]),x=l.useMemo(()=>u?.models?Object.entries(u.models).map(([j,O])=>({name:j,windows:O})).filter(j=>Object.keys(j.windows.windows).length>0):[],[u?.models]);l.useEffect(()=>{n&&x.length>0&&b(n,x.map(j=>j.name))},[n,x,b]);const T=l.useMemo(()=>!n||x.length===0?new Map:Uu(x,j=>j.name,n),[x,n]),M=l.useMemo(()=>{if(!n)return[];const j=$u(n);return _u(j)},[n]),[E,D]=l.useState(()=>({})),F=l.useCallback(j=>{D(O=>({...O,[j]:!O[j]}))},[]),L=l.useCallback(j=>{if(!n)return;p(n,j);const O=f[n]??[],H=O.includes(j)?O.filter(Z=>Z!==j):[...O,j],q={...f,[n]:H};kt({usageSelectedModels:q})},[n,f,p]),P=n?f[n]??[]:[];return n?s.jsxs(ns,{title:t("settings.usage.page.header.providerUsage",{provider:k}),titleLeading:s.jsx($n,{providerId:n,className:"h-5 w-5 shrink-0"}),description:d?s.jsx("span",{className:"animate-pulse typography-settings-description text-muted-foreground",children:t("settings.usage.page.header.refreshing")}):C?.planLabel?t("settings.usage.page.header.lastUpdatedWithPlan",{plan:C.planLabel,time:yc(c,e)}):t("settings.usage.page.header.lastUpdated",{time:yc(c,e)}),showSaveStatus:!0,children:[s.jsx(He,{divider:!1,settingsItem:"usage.work-status-panel",children:s.jsx(bt,{checked:N,onChange:A,label:t("settings.usage.page.options.showInWorkStatus"),ariaLabel:t("settings.usage.page.options.showInWorkStatusAria"),info:t("settings.usage.page.options.showInWorkStatusTooltip")})}),!C&&s.jsx("p",{className:"typography-ui-label text-foreground pb-8",children:t("settings.usage.page.state.noData")}),S&&s.jsxs("div",{className:"mb-8 rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-4 py-3",children:[s.jsx("p",{className:"typography-ui-label font-medium text-[var(--status-error)]",children:t("settings.usage.page.state.refreshFailedTitle")}),s.jsx("p",{className:"typography-meta text-[var(--status-error)]/80 mt-1",children:S})]}),C&&!C.configured&&!w&&s.jsxs("div",{className:"mb-8 rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] px-4 py-3",children:[s.jsx("p",{className:"typography-ui-label font-medium text-[var(--status-warning)]",children:t("settings.usage.page.state.providerNotConfiguredTitle")}),s.jsx("p",{className:"typography-meta text-[var(--status-warning)]/80 mt-1",children:t("settings.usage.page.state.providerNotConfiguredDescription")})]}),(n==="exe-dev"||n==="ollama-cloud"||n==="cursor")&&s.jsx(xv,{providerId:n,providerName:k}),u?.windows&&Object.keys(u.windows).length>0&&s.jsx(He,{settingsItem:"usage.model-quotas",children:s.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:Object.entries(u.windows).map(([j,O])=>s.jsx(er,{title:j,window:O},j))})}),x.length>0&&s.jsxs(He,{title:t("settings.usage.page.section.modelQuotas"),contentClassName:"space-y-3",children:[M.map(j=>{const O=T.get(j.id)??[];if(O.length===0)return null;const K=E[j.id]??!1;return s.jsx("section",{className:"p-2",children:s.jsxs(bn,{open:!K,onOpenChange:()=>F(j.id),children:[s.jsxs(vn,{className:"flex w-full items-center justify-between py-0.5 group",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-left",children:[s.jsx("span",{className:"typography-ui-label font-normal text-foreground",children:j.label}),s.jsxs("span",{className:"typography-micro text-muted-foreground",children:["(",O.length,")"]})]}),K?s.jsx($,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"}):s.jsx($,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"})]}),s.jsx(yn,{children:s.jsx("div",{className:"divide-y divide-[var(--surface-subtle)] mt-1",children:O.map(H=>{const q=Object.entries(H.windows.windows);if(q.length===0)return null;const[Z,ae]=q[0],B=P.includes(H.name);return s.jsx(er,{title:Z,subtitle:hl(H.name),window:ae,showToggle:!0,toggleEnabled:B,onToggle:()=>L(H.name)},H.name)})})})]})},j.id)}),(()=>{const j=T.get(null)??[];if(j.length===0)return null;const O=E.other??!1;return s.jsx("section",{className:"p-2",children:s.jsxs(bn,{open:!O,onOpenChange:()=>F("other"),children:[s.jsxs(vn,{className:"flex w-full items-center justify-between py-0.5 group",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-left",children:[s.jsx("span",{className:"typography-ui-label font-normal text-foreground",children:t("settings.usage.page.section.otherModels")}),s.jsxs("span",{className:"typography-micro text-muted-foreground",children:["(",j.length,")"]})]}),O?s.jsx($,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"}):s.jsx($,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground group-hover:text-foreground transition-colors"})]}),s.jsx(yn,{children:s.jsx("div",{className:"divide-y divide-[var(--surface-subtle)] mt-1",children:j.map(K=>{const H=Object.entries(K.windows.windows);if(H.length===0)return null;const[q,Z]=H[0],ae=P.includes(K.name);return s.jsx(er,{title:q,subtitle:hl(K.name),window:Z,showToggle:!0,toggleEnabled:ae,onToggle:()=>L(K.name)},K.name)})})})]})})})()]}),C?.configured&&u&&Object.keys(u.windows??{}).length===0&&x.length===0&&s.jsxs("div",{className:"pb-8",children:[s.jsx("p",{className:"typography-ui-label text-foreground",children:t("settings.usage.page.state.noQuotaWindowsTitle")}),s.jsx("p",{className:"typography-meta text-muted-foreground mt-1",children:t("settings.usage.page.state.noQuotaWindowsDescription")})]})]}):s.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:s.jsx("p",{className:"typography-body",children:t("settings.usage.page.empty.selectProvider")})})},vv="git.commit.generate",Pr=yp(t=>({selectedPromptId:vv,setSelectedPromptId:e=>{t(a=>a.selectedPromptId===e?a:{selectedPromptId:e})}})),yv=t=>{const e=Be.c(24),{onItemSelect:a}=t,{t:n}=qe(),i=Pr(jv),o=Pr(kv);let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={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"}]},e[0]=r):r=e[0];let d;e[1]===Symbol.for("react.memo_cache_sentinel")?(d={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"}]},e[1]=d):d=e[1];let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c={groupKey:"settings.magicPrompts.sidebar.group.linear",items:[{id:"linear.issue.review",titleKey:"settings.magicPrompts.sidebar.item.linearIssueReview"}]},e[2]=c):c=e[2];let g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g={groupKey:"settings.magicPrompts.sidebar.group.planning",items:[{id:"plan.todo",titleKey:"settings.magicPrompts.sidebar.item.planTodo"},{id:"plan.improve",titleKey:"settings.magicPrompts.sidebar.item.planImprove"},{id:"plan.implement",titleKey:"settings.magicPrompts.sidebar.item.planImplement"}]},e[3]=g):g=e[3];let m;e[4]===Symbol.for("react.memo_cache_sentinel")?(m=[r,d,c,g,{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.plan",titleKey:"settings.magicPrompts.sidebar.item.sessionFeaturePlan"},{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"}]}],e[4]=m):m=e[4];const h=m;let f;e[5]!==n?(f=n("settings.magicPrompts.sidebar.title"),e[5]=n,e[6]=f):f=e[6];let p;e[7]!==f?(p=s.jsx("h2",{className:va,children:f}),e[7]=f,e[8]=p):p=e[8];let b;e[9]!==n?(b=n("settings.magicPrompts.sidebar.description"),e[9]=n,e[10]=b):b=e[10];let C;e[11]!==b?(C=s.jsx("p",{className:"typography-meta mt-1 text-muted-foreground",children:b}),e[11]=b,e[12]=C):C=e[12];let v;e[13]!==p||e[14]!==C?(v=s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[p,C]}),e[13]=p,e[14]=C,e[15]=v):v=e[15];let k;e[16]!==a||e[17]!==i||e[18]!==o||e[19]!==n?(k=s.jsx(Ds,{outerClassName:"flex-1 min-h-0",className:"space-y-3 px-3 py-2 overflow-x-hidden",children:h.map(y=>s.jsxs("div",{className:"space-y-1",children:[s.jsx("div",{className:"typography-micro px-1 text-muted-foreground",children:n(y.groupKey)}),y.items.map(S=>{const N=i===S.id;return s.jsx("button",{type:"button",onClick:()=>{o(S.id),a?.()},className:Ne("flex w-full items-center rounded-md px-2 py-1.5 text-left transition-colors",N?"bg-interactive-selection text-foreground":"text-foreground hover:bg-interactive-hover"),children:s.jsx("span",{className:"typography-ui-label truncate font-normal",children:n(S.titleKey)})},S.id)})]},y.groupKey))}),e[16]=a,e[17]=i,e[18]=o,e[19]=n,e[20]=k):k=e[20];let u;return e[21]!==v||e[22]!==k?(u=s.jsxs("div",{className:"flex h-full flex-col bg-background",children:[v,k]}),e[21]=v,e[22]=k,e[23]=u):u=e[23],u};function jv(t){return t.selectedPromptId}function kv(t){return t.setSelectedPromptId}const jc={"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"}]},"linear.issue.review":{titleKey:"settings.magicPrompts.page.group.linearIssueReview.title",descriptionKey:"settings.magicPrompts.page.group.linearIssueReview.description",blocks:[{id:"linear.issue.review.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"linear.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"}]},"plan.improve":{titleKey:"settings.magicPrompts.page.group.planImprove.title",descriptionKey:"settings.magicPrompts.page.group.planImprove.description",blocks:[{id:"plan.improve.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"plan.improve.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"plan.todo":{titleKey:"settings.magicPrompts.page.group.planTodo.title",descriptionKey:"settings.magicPrompts.page.group.planTodo.description",blocks:[{id:"plan.todo.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"plan.todo.instructions",titleKey:"settings.magicPrompts.page.block.instructions"}]},"plan.implement":{titleKey:"settings.magicPrompts.page.group.planImplement.title",descriptionKey:"settings.magicPrompts.page.group.planImplement.description",blocks:[{id:"plan.implement.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"plan.implement.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.plan":{titleKey:"settings.magicPrompts.page.group.sessionFeaturePlan.title",descriptionKey:"settings.magicPrompts.page.group.sessionFeaturePlan.description",blocks:[{id:"session.plan.visible",titleKey:"settings.magicPrompts.page.block.visiblePrompt"},{id:"session.plan.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"},{id:"session.fusion.codeInstructions",titleKey:"settings.magicPrompts.page.block.codeFusionInstructions"}]}},kc=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),tr=t=>t.endsWith(".visible"),wv=()=>{const{t}=qe(),e=l.useCallback(w=>t(w),[t]),a=Pr(w=>w.selectedPromptId),[n,i]=l.useState(!0),[o,r]=l.useState({}),[d,c]=l.useState({}),[g,m]=l.useState({}),[h,f]=l.useState({}),[p,b]=l.useState(!1);l.useEffect(()=>{let w=!0;return(async()=>{i(!0);try{const x=await qu();if(!w)return;r(x)}catch(x){console.warn("Failed to load magic prompts:",x),U.error(t("settings.magicPrompts.page.toast.loadFailed"))}finally{w&&i(!1)}})(),()=>{w=!1}},[t]);const C=jc[a]??jc["git.commit.generate"],v=l.useCallback(w=>kc(o,w)?o[w]:zo(w),[o]),k=l.useCallback(w=>d[w]??v(w),[d,v]),u=l.useCallback((w,A)=>{c(x=>x[w]===A?x:{...x,[w]:A})},[]),y=l.useCallback(async w=>{const A=k(w);if(tr(w)&&A.trim().length===0){U.error(t("settings.magicPrompts.page.toast.visiblePromptRequired"));return}m(x=>({...x,[w]:!0}));try{const x=A===zo(w)?await xl(w):await Bu(w,A);r(x.overrides),U.success(t("settings.magicPrompts.page.toast.saved"))}catch(x){const T=x instanceof Error?x.message:String(x);U.error(t("settings.magicPrompts.page.toast.saveFailed"),{description:T})}finally{m(x=>({...x,[w]:!1}))}},[k,t]),S=l.useCallback(async w=>{f(A=>({...A,[w]:!0}));try{const A=await xl(w);r(A.overrides),c(x=>({...x,[w]:zo(w)})),U.success(t("settings.magicPrompts.page.toast.resetSuccess"))}catch(A){const x=A instanceof Error?A.message:String(A);U.error(t("settings.magicPrompts.page.toast.resetFailed"),{description:x})}finally{f(A=>({...A,[w]:!1}))}},[t]),N=l.useCallback(async()=>{b(!0);try{const w=await Vu();r(w.overrides),c({}),U.success(t("settings.magicPrompts.page.toast.resetAllSuccess"))}catch(w){const A=w instanceof Error?w.message:String(w);U.error(t("settings.magicPrompts.page.toast.resetAllFailed"),{description:A})}finally{b(!1)}},[t]);return n?s.jsxs("div",{className:"py-6 px-6 flex items-center gap-2 text-muted-foreground",children:[s.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-current animate-busy-pulse","aria-label":t("settings.magicPrompts.page.loading.aria")}),s.jsx("span",{className:"typography-ui",children:t("settings.magicPrompts.page.loading.text")})]}):s.jsx(ns,{title:e(C.titleKey),titleAccessory:s.jsx(Gt,{contentClassName:"max-w-xs",children:e(C.descriptionKey)}),headerEnd:s.jsx(V,{"data-settings-item":"magic-prompts.reset-overrides",variant:"outline",size:"sm",onClick:()=>{N()},disabled:p||Object.keys(o).length===0,children:t(p?"settings.magicPrompts.page.actions.resetting":"settings.magicPrompts.page.actions.resetAllOverrides")}),showSaveStatus:!1,children:C.blocks.map((w,A)=>{const x=Hu(w.id),T=v(w.id),M=k(w.id),E=kc(o,w.id),D=M!==T,F=tr(w.id)&&M.trim().length===0,L=g[w.id]===!0,P=h[w.id]===!0;return s.jsxs(He,{title:e(w.titleKey),info:x.description,description:x.placeholders&&x.placeholders.length>0?`${t("settings.magicPrompts.page.placeholdersLabel")} ${x.placeholders.map(j=>`{{${j.key}}}`).join(", ")}`:void 0,divider:A>0,settingsItem:tr(w.id)?"magic-prompts.visible-prompt":"magic-prompts.instructions",contentClassName:"space-y-3",children:[s.jsx(Rs,{value:M,onChange:j=>u(w.id,j.target.value),className:"min-h-[220px] font-mono text-sm"}),F&&s.jsx("div",{className:"typography-micro text-[var(--status-error)]",children:t("settings.magicPrompts.page.validation.visiblePromptRequired")}),s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"typography-micro text-muted-foreground",children:t(D?"settings.magicPrompts.page.status.unsavedChanges":E?"settings.magicPrompts.page.status.usingSavedOverride":"settings.magicPrompts.page.status.usingBuiltinDefault")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(V,{variant:"outline",size:"sm",onClick:()=>{S(w.id)},disabled:!E||L||P,children:t(P?"settings.magicPrompts.page.actions.resetting":"settings.magicPrompts.page.actions.resetToDefault")}),s.jsx(V,{size:"sm",onClick:()=>{y(w.id)},disabled:!D||L||P||F,children:t(L?"settings.common.actions.saving":"settings.magicPrompts.page.actions.save")})]})]})]},w.id)})})},Nv=t=>{const e=Be.c(89),{onItemSelect:a}=t,{t:n}=qe(),[i,o]=l.useState(null),[r,d]=l.useState(null),[c,g]=l.useState(null),{selectedSnippetName:m,snippets:h,setSelectedSnippet:f,setSnippetDraft:p,deleteSnippet:b,loadSnippets:C}=no(_s(Sv));let v,k;e[0]!==C?(v=()=>{C()},k=[C],e[0]=C,e[1]=v,e[2]=k):(v=e[1],k=e[2]),l.useEffect(v,k);let u;e[3]!==a||e[4]!==f||e[5]!==p||e[6]!==h?(u=async()=>{const ee=new Set(h.map(Cv));let ce="new-snippet",ue=1;for(;ee.has(ce);)ce=`new-snippet-${ue++}`;p({name:ce,scope:"global"}),f(ce),a?.()},e[3]=a,e[4]=f,e[5]=p,e[6]=h,e[7]=u):u=e[7];const y=u;let S;e[8]!==i||e[9]!==b||e[10]!==n?(S=async()=>{if(!i)return;await b(i.name)?(U.success(n("settings.snippets.sidebar.toast.deleted")),o(null)):U.error(n("settings.snippets.sidebar.toast.deleteFailed"))},e[8]=i,e[9]=b,e[10]=n,e[11]=S):S=e[11];const N=S;let w;e[12]!==h?(w=[...h].sort(Iv),e[12]=h,e[13]=w):w=e[13];const A=w;let x;e[14]===Symbol.for("react.memo_cache_sentinel")?(x=Ne("flex h-full flex-col","bg-background"),e[14]=x):x=e[14];let T;e[15]!==n?(T=n("settings.snippets.sidebar.title"),e[15]=n,e[16]=T):T=e[16];let M;e[17]!==T?(M=s.jsx("h2",{className:`${va} mb-3`,children:T}),e[17]=T,e[18]=M):M=e[18];let E;e[19]!==h.length||e[20]!==n?(E=n("settings.snippets.sidebar.total",{count:h.length}),e[19]=h.length,e[20]=n,e[21]=E):E=e[21];let D;e[22]!==E?(D=s.jsx("span",{className:"typography-meta text-muted-foreground",children:E}),e[22]=E,e[23]=D):D=e[23];let F;e[24]!==n?(F=n("settings.snippets.sidebar.actions.create"),e[24]=n,e[25]=F):F=e[25];let L;e[26]===Symbol.for("react.memo_cache_sentinel")?(L=s.jsx($,{name:"add",className:"h-3.5 w-3.5"}),e[26]=L):L=e[26];let P;e[27]!==y||e[28]!==F?(P=s.jsx(V,{size:"sm","data-settings-item":"snippets.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:y,"aria-label":F,children:L}),e[27]=y,e[28]=F,e[29]=P):P=e[29];let j;e[30]!==D||e[31]!==P?(j=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[D,P]}),e[30]=D,e[31]=P,e[32]=j):j=e[32];let O;e[33]!==j||e[34]!==M?(O=s.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[M,j]}),e[33]=j,e[34]=M,e[35]=O):O=e[35];let K;if(e[36]!==a||e[37]!==r||e[38]!==c||e[39]!==m||e[40]!==f||e[41]!==A||e[42]!==n){let ee;e[44]!==a||e[45]!==r||e[46]!==c||e[47]!==m||e[48]!==f||e[49]!==n?(ee=ce=>s.jsxs(si,{open:c===ce.name,onOpenChange:ue=>g(ue?ce.name:null),children:[s.jsxs(ti,{render:s.jsx("div",{className:Ne("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",m===ce.name?"bg-interactive-selection":"hover:bg-interactive-hover"),onContextMenu:ue=>{ue.preventDefault(),g(ce.name)}}),children:[s.jsxs("button",{onClick:()=>{f(ce.name),a?.()},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-ring",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"typography-ui-label font-normal truncate text-foreground",children:["#",ce.name]}),s.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:n(`snippets.source.${ce.source}`)})]}),s.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:ce.description||ce.content.replace(/\s+/g," ").substring(0,80)})]}),s.jsxs(Jn,{open:r===ce.name,onOpenChange:ue=>{ue&&g(null),d(ue?ce.name:null)},children:[s.jsx(Wn,{asChild:!0,children:s.jsx(V,{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","aria-label":n("settings.snippets.sidebar.actions.more",{name:ce.name}),children:s.jsx($,{name:"more-2",className:"h-3.5 w-3.5"})})}),s.jsx(Gn,{align:"end",className:"w-fit min-w-20",children:s.jsxs(xn,{onClick:ue=>{ue.stopPropagation(),o(ce)},className:"text-destructive focus:text-destructive",children:[s.jsx($,{name:"delete-bin",className:"h-4 w-4 mr-px"}),n("settings.common.actions.delete")]})})]})]}),s.jsx(Xa,{className:"w-fit min-w-20",children:s.jsxs(ei,{onClick:ue=>{ue.stopPropagation(),o(ce)},className:"text-destructive focus:text-destructive",children:[s.jsx($,{name:"delete-bin",className:"h-4 w-4 mr-px"}),n("settings.common.actions.delete")]})})]},`${ce.source}:${ce.filePath}`),e[44]=a,e[45]=r,e[46]=c,e[47]=m,e[48]=f,e[49]=n,e[50]=ee):ee=e[50],K=A.map(ee),e[36]=a,e[37]=r,e[38]=c,e[39]=m,e[40]=f,e[41]=A,e[42]=n,e[43]=K}else K=e[43];let H;e[51]!==K?(H=s.jsx(Ds,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2",children:K}),e[51]=K,e[52]=H):H=e[52];const q=i!==null;let Z;e[53]===Symbol.for("react.memo_cache_sentinel")?(Z=ee=>{ee||o(null)},e[53]=Z):Z=e[53];let ae;e[54]!==n?(ae=n("settings.snippets.sidebar.dialog.deleteTitle"),e[54]=n,e[55]=ae):ae=e[55];let B;e[56]!==ae?(B=s.jsx(Ht,{children:ae}),e[56]=ae,e[57]=B):B=e[57];const G=i?.name??"";let _;e[58]!==n||e[59]!==G?(_=n("settings.snippets.sidebar.dialog.deleteDescription",{name:G}),e[58]=n,e[59]=G,e[60]=_):_=e[60];let z;e[61]!==_?(z=s.jsx(qt,{children:_}),e[61]=_,e[62]=z):z=e[62];let te;e[63]!==B||e[64]!==z?(te=s.jsxs(Vt,{children:[B,z]}),e[63]=B,e[64]=z,e[65]=te):te=e[65];let Q;e[66]===Symbol.for("react.memo_cache_sentinel")?(Q=()=>o(null),e[66]=Q):Q=e[66];let X;e[67]!==n?(X=n("settings.common.actions.cancel"),e[67]=n,e[68]=X):X=e[68];let pe;e[69]!==X?(pe=s.jsx(V,{size:"sm",variant:"ghost",onClick:Q,children:X}),e[69]=X,e[70]=pe):pe=e[70];let je;e[71]!==n?(je=n("settings.common.actions.delete"),e[71]=n,e[72]=je):je=e[72];let fe;e[73]!==N||e[74]!==je?(fe=s.jsx(V,{size:"sm",onClick:N,children:je}),e[73]=N,e[74]=je,e[75]=fe):fe=e[75];let ke;e[76]!==pe||e[77]!==fe?(ke=s.jsxs(as,{children:[pe,fe]}),e[76]=pe,e[77]=fe,e[78]=ke):ke=e[78];let be;e[79]!==te||e[80]!==ke?(be=s.jsxs($t,{className:"max-w-md",children:[te,ke]}),e[79]=te,e[80]=ke,e[81]=be):be=e[81];let De;e[82]!==q||e[83]!==be?(De=s.jsx(_t,{open:q,onOpenChange:Z,children:be}),e[82]=q,e[83]=be,e[84]=De):De=e[84];let oe;return e[85]!==O||e[86]!==H||e[87]!==De?(oe=s.jsxs("div",{className:x,children:[O,H,De]}),e[85]=O,e[86]=H,e[87]=De,e[88]=oe):oe=e[88],oe};function Sv(t){return{selectedSnippetName:t.selectedSnippetName,snippets:t.snippets,setSelectedSnippet:t.setSelectedSnippet,setSnippetDraft:t.setSnippetDraft,deleteSnippet:t.deleteSnippet,loadSnippets:t.loadSnippets}}function Cv(t){return t.name}function Iv(t,e){return t.name.localeCompare(e.name)}const Pv=()=>{const{t}=qe(),{selectedSnippetName:e,snippets:a,snippetDraft:n,setSnippetDraft:i,updateSnippet:o,createSnippet:r}=no(_s(x=>({selectedSnippetName:x.selectedSnippetName,snippets:x.snippets,snippetDraft:x.snippetDraft,setSnippetDraft:x.setSnippetDraft,updateSnippet:x.updateSnippet,createSnippet:x.createSnippet}))),d=l.useMemo(()=>e?a.find(x=>x.name===e||x.aliases.includes(e))??null:null,[e,a]),c=!!(n&&n.name===e&&!d),[g,m]=l.useState(""),[h,f]=l.useState("global"),[p,b]=l.useState(""),[C,v]=l.useState(""),[k,u]=l.useState(""),[y,S]=l.useState(!1),N=l.useRef(null);l.useEffect(()=>{if(c&&n){const x={draftName:n.name||"",draftScope:n.scope||"global",description:n.description||"",aliases:(n.aliases||[]).join(", "),content:n.content||""};m(x.draftName),f(x.draftScope),b(x.description),v(x.aliases),u(x.content),N.current=x}else if(d){const x={draftName:"",draftScope:"global",description:d.description??"",aliases:d.aliases.join(", "),content:d.content};b(x.description),v(x.aliases),u(x.content),N.current=x}},[d,c,e,n]);const w=l.useMemo(()=>{const x=N.current;return x?c&&g!==x.draftName||c&&h!==x.draftScope?!0:p!==x.description||C!==x.aliases||k!==x.content:!1},[C,k,p,g,h,c]),A=async()=>{const x=c?g.trim().replace(/\s+/g,"-"):e?.trim();if(!x){U.error(t("settings.snippets.page.toast.nameRequired"));return}if(!k.trim()){U.error(t("settings.snippets.page.toast.contentRequired"));return}const T=C.split(",").map(M=>M.trim()).filter(Boolean);S(!0);try{if(!(c?await r(x,k,{aliases:T,description:p,scope:h}):await o(x,{content:k,aliases:T,description:p}))){U.error(t("settings.snippets.page.toast.saveFailed"));return}U.success(t("settings.snippets.page.toast.saved")),c&&i(null)}finally{S(!1)}};return e?s.jsxs(ns,{title:c?t("settings.snippets.page.title.new"):`#${e}`,description:d?d.filePath:void 0,showSaveStatus:!1,children:[s.jsxs(He,{divider:!1,contentClassName:"space-y-0",children:[c?s.jsxs(Ct,{label:"#",children:[s.jsx(Ge,{value:g,onChange:x=>m(x.target.value),placeholder:t("settings.snippets.page.field.namePlaceholder"),className:"h-7 w-44 px-2"}),s.jsxs(Dt,{value:h,onValueChange:x=>f(x),children:[s.jsx(Tt,{size:Qt,className:"w-fit min-w-[100px]",children:s.jsx(Jt,{})}),s.jsxs(Et,{align:"end",children:[s.jsx(gt,{value:"global",children:t("settings.common.scope.global")}),s.jsx(gt,{value:"project",children:t("settings.common.scope.project")})]})]})]}):null,s.jsx(Kt,{label:t("settings.common.field.description"),children:s.jsx(Ge,{value:p,onChange:x=>b(x.target.value),placeholder:t("settings.snippets.page.field.descriptionPlaceholder"),className:"h-7 w-full max-w-sm px-2"})}),s.jsx(Kt,{label:t("settings.snippets.page.field.aliases"),children:s.jsx(Ge,{value:C,onChange:x=>v(x.target.value),placeholder:t("settings.snippets.page.field.aliasesPlaceholder"),className:"h-7 w-full max-w-sm px-2"})})]}),s.jsxs(He,{settingsItem:"snippets.content",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:t("settings.snippets.page.field.content")}),s.jsx(Gt,{children:t("settings.snippets.page.hint")})]}),s.jsx(Rs,{value:k,onChange:x=>u(x.target.value),placeholder:t("settings.snippets.page.field.contentPlaceholder"),rows:12,className:"mt-1.5 w-full font-mono typography-meta min-h-[160px] max-h-[60vh] bg-transparent"}),s.jsx("div",{className:"pt-3",children:s.jsx(V,{onClick:A,disabled:y||!w,size:"xs",className:"!font-normal",children:t(y?"settings.common.actions.saving":"settings.common.actions.saveChanges")})})]})]}):s.jsx("div",{className:"flex h-full items-center justify-center",children:s.jsxs("div",{className:"text-center text-muted-foreground",children:[s.jsx($,{name:"file-text",className:"mx-auto mb-3 h-12 w-12 opacity-50"}),s.jsx("p",{className:"typography-body",children:t("settings.snippets.page.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:t("settings.snippets.page.empty.description")})]})})},$d=()=>{const{t}=qe(),e=ct(h=>h.settingsGitmojiEnabled),a=ct(h=>h.setSettingsGitmojiEnabled),n=$m(),i=re(h=>h.gitChangesViewMode),o=re(h=>h.setGitChangesViewMode),[r,d]=l.useState(!0),c=l.useMemo(()=>[{id:"flat",label:t("settings.openchamber.git.option.flatList")},{id:"tree",label:t("settings.openchamber.git.option.treeView")}],[t]);l.useEffect(()=>{(async()=>{try{const f=await En();f&&(f.gitmojiEnabled!==void 0&&a(f.gitmojiEnabled),f.gitChangesViewMode!==void 0&&o(f.gitChangesViewMode))}catch(f){console.warn("Failed to load git settings:",f)}finally{d(!1)}})()},[o,a]);const g=l.useCallback(async h=>{a(h);try{await kt({gitmojiEnabled:h})}catch(f){console.warn("Failed to save gitmoji setting:",f)}},[a]),m=l.useCallback(h=>{h!==i&&(o(h),kt({gitChangesViewMode:h}))},[i,o]);return r?null:s.jsx(He,{title:t("settings.openchamber.git.title"),children:s.jsxs("div",{className:ys,children:[s.jsx(Ss,{settingsItem:"git.changes-view",title:t("settings.openchamber.git.changesViewTitle"),children:s.jsx(Js,{"aria-label":t("settings.openchamber.git.changesViewAria"),children:c.map(h=>s.jsx(rs,{selected:i===h.id,onSelect:()=>{m(h.id)},label:h.label,ariaLabel:t("settings.openchamber.git.optionAria",{option:h.label})},h.id))})}),s.jsx(bt,{settingsItem:"git.gitmoji",checked:e,onChange:h=>{g(h)},label:t("settings.openchamber.git.enableGitmoji"),ariaLabel:t("settings.openchamber.git.enableGitmojiAria")}),s.jsx(bt,{settingsItem:"git.gitignored-files",checked:n,onChange:Bm,label:t("settings.openchamber.git.showGitignored"),ariaLabel:t("settings.openchamber.git.showGitignoredAria")})]})})},wc=[{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)"}],Av=[{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"}],Tv=({open:t,onOpenChange:e,profileId:a,importData:n})=>{const{t:i}=qe(),o=ua(z=>z.getProfileById),r=ua(z=>z.createProfile),d=ua(z=>z.updateProfile),c=ua(z=>z.deleteProfile),g=l.useMemo(()=>a&&a!=="new"&&!n?o(a):null,[a,o,n]),m=a==="new"||n!=null,h=a==="global",[f,p]=l.useState(""),[b,C]=l.useState(""),[v,k]=l.useState(""),[u,y]=l.useState("ssh"),[S,N]=l.useState(""),[w,A]=l.useState(!1),[x,T]=l.useState(""),[M,E]=l.useState(""),[D,F]=l.useState("keyword"),[L,P]=l.useState("branch"),[j,O]=l.useState(!1),[K,H]=l.useState(!1),[q,Z]=l.useState(!1);l.useEffect(()=>{if(t){if(n){const z=n.host.split("/"),te=z.length>=3?z[z.length-1]:n.host;p(te),C(n.username),k(""),y("token"),N(""),A(!1),T(""),E(n.host),F("string"),P("code")}else if(m)p(""),C(""),k(""),y("ssh"),N(""),A(!1),T(""),E(""),F("keyword"),P("branch");else if(g)p(g.name),C(g.userName),k(g.userEmail),y(g.authType||"ssh"),N(g.sshKey||""),A(g.signCommits===!0),T(g.signingKey||""),E(g.host||""),F(g.color||"keyword"),P(g.icon||"branch");else if(h){const z=o("global");z&&(p(z.name),C(z.userName),k(z.userEmail),y(z.authType||"ssh"),N(z.sshKey||""),A(!1),T(""),E(z.host||""),F(z.color||"keyword"),P(z.icon||"branch"))}}},[t,a,g,m,n,h,o]);const ae=async()=>{if(!b.trim()||!v.trim()){U.error(i("settings.gitIdentities.editor.toast.userNameEmailRequired"));return}if(u==="token"&&!M.trim()){U.error(i("settings.gitIdentities.editor.toast.hostRequiredForToken"));return}if(w&&!x.trim()){U.error(i("settings.gitIdentities.editor.toast.signingKeyRequired"));return}O(!0);try{const z={name:f.trim()||b.trim(),userName:b.trim(),userEmail:v.trim(),authType:u,sshKey:u==="ssh"&&S.trim()||null,signCommits:w,signingKey:x.trim()||null,host:u==="token"&&M.trim()||null,color:D,icon:L};let te;if(m)te=await r(z);else if(a)te=await d(a,z);else return;te?(U.success(i(m?"settings.gitIdentities.editor.toast.profileCreated":"settings.gitIdentities.editor.toast.profileUpdated")),e(!1)):U.error(i(m?"settings.gitIdentities.editor.toast.createProfileFailed":"settings.gitIdentities.editor.toast.updateProfileFailed"))}catch(z){console.error("Error saving profile:",z),U.error(i("settings.gitIdentities.editor.toast.saveUnexpectedError"))}finally{O(!1)}},B=async()=>{if(!(!a||m)){Z(!0);try{await c(a)?(U.success(i("settings.gitIdentities.editor.toast.profileDeleted")),H(!1),e(!1)):U.error(i("settings.gitIdentities.editor.toast.deleteProfileFailed"))}catch(z){console.error("Error deleting profile:",z),U.error(i("settings.gitIdentities.editor.toast.deleteUnexpectedError"))}finally{Z(!1)}}},G=l.useMemo(()=>wc.find(te=>te.key===D)?.cssVar||"var(--syntax-keyword)",[D]),_=n?i("settings.gitIdentities.editor.title.importCredential"):m?i("settings.gitIdentities.editor.title.newIdentity"):h?i("settings.gitIdentities.editor.title.globalIdentity"):g?.name||i("settings.gitIdentities.editor.title.editIdentity");return s.jsxs(s.Fragment,{children:[s.jsx(_t,{open:t,onOpenChange:e,children:s.jsxs($t,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:_}),s.jsx(qt,{children:i(h?"settings.gitIdentities.editor.description.globalReadOnly":m?"settings.gitIdentities.editor.description.newProfile":"settings.gitIdentities.editor.description.editProfile")})]}),s.jsxs("div",{className:"space-y-5 py-2",children:[!h&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:`${Pt} block mb-1.5`,children:i("settings.gitIdentities.editor.field.profileName")}),s.jsx(Ge,{value:f,onChange:z=>p(z.target.value),placeholder:i("settings.gitIdentities.editor.field.profileNamePlaceholder"),className:"h-8"})]}),s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.gitIdentities.editor.field.color")}),s.jsx("div",{className:"flex gap-1.5",children:wc.map(z=>s.jsx("button",{type:"button",onClick:()=>F(z.key),className:Ne("w-6 h-6 rounded-md border-2 transition-all cursor-pointer",D===z.key?"border-foreground scale-110":"border-transparent hover:border-border"),style:{backgroundColor:z.cssVar},title:z.label},z.key))})]}),s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.gitIdentities.editor.field.icon")}),s.jsx("div",{className:"flex gap-1.5",children:Av.map(z=>{const te=z.Icon;return s.jsx("button",{type:"button",onClick:()=>P(z.key),className:Ne("w-7 h-7 rounded-md border-2 transition-all flex items-center justify-center cursor-pointer",L===z.key?"border-[var(--interactive-border)] bg-[var(--surface-muted)]":"border-transparent hover:border-[var(--interactive-border)] hover:bg-[var(--surface-muted)]/50"),title:z.label,children:s.jsx($,{name:te,className:"w-3.5 h-3.5",style:{color:L===z.key?G:"var(--surface-muted-foreground)"}})},z.key)})})]})]}),!h&&s.jsx("div",{className:"border-t border-border/40"}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[s.jsx("label",{className:Pt,children:i("settings.gitIdentities.editor.field.userName")}),!h&&s.jsx("span",{className:"text-[var(--status-error)] text-xs",children:"*"}),s.jsx(Gt,{contentClassName:"max-w-xs",children:i("settings.gitIdentities.editor.field.userNameTooltip")})]}),s.jsx(Ge,{value:b,onChange:z=>C(z.target.value),placeholder:i("settings.gitIdentities.editor.field.userNamePlaceholder"),required:!h,readOnly:h,disabled:h,className:"h-8"})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[s.jsx("label",{className:Pt,children:i("settings.gitIdentities.editor.field.emailAddress")}),!h&&s.jsx("span",{className:"text-[var(--status-error)] text-xs",children:"*"}),s.jsx(Gt,{contentClassName:"max-w-xs",children:i("settings.gitIdentities.editor.field.emailAddressTooltip")})]}),s.jsx(Ge,{type:"email",value:v,onChange:z=>k(z.target.value),placeholder:i("settings.gitIdentities.editor.field.emailAddressPlaceholder"),required:!h,readOnly:h,disabled:h,className:"h-8"})]})]}),!h&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"border-t border-border/40"}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:i("settings.gitIdentities.editor.field.authMethod")}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs(V,{size:"sm",type:"button",variant:"chip","aria-pressed":u==="ssh",onClick:()=>y("ssh"),children:[s.jsx($,{name:"lock-2",className:"w-3.5 h-3.5 mr-1"})," SSH"]}),s.jsxs(V,{size:"sm",type:"button",variant:"chip","aria-pressed":u==="token",onClick:()=>y("token"),children:[s.jsx($,{name:"key",className:"w-3.5 h-3.5 mr-1"})," ",i("settings.gitIdentities.editor.field.authToken")]})]})]}),u==="ssh"&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[s.jsx("label",{className:Pt,children:i("settings.gitIdentities.editor.field.sshKeyPath")}),s.jsx(Gt,{contentClassName:"max-w-xs",children:i("settings.gitIdentities.editor.field.sshKeyPathTooltip")})]}),s.jsx(Ge,{value:S,onChange:z=>N(z.target.value),placeholder:i("settings.gitIdentities.editor.field.sshKeyPathPlaceholder"),className:"h-8 font-mono text-xs"})]}),s.jsxs("div",{className:"border-t border-border/40 pt-3 space-y-3",children:[s.jsx(bt,{checked:w,onChange:A,label:i("settings.gitIdentities.editor.field.signCommits"),info:i("settings.gitIdentities.editor.section.commitSigning"),ariaLabel:i("settings.gitIdentities.editor.field.signCommits")}),s.jsxs("div",{children:[s.jsx("div",{className:"flex items-center gap-1.5 mb-1.5",children:s.jsx("label",{className:Pt,children:i("settings.gitIdentities.editor.field.signingKey")})}),s.jsx(Ge,{value:x,onChange:z=>T(z.target.value),placeholder:i("settings.gitIdentities.editor.field.signingKeyPlaceholder"),disabled:!w,className:"h-8 font-mono text-xs"})]})]}),u==="token"&&s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[s.jsx("label",{className:Pt,children:i("settings.gitIdentities.editor.field.host")}),s.jsx("span",{className:"text-[var(--status-error)] text-xs",children:"*"}),s.jsx(Gt,{contentClassName:"max-w-xs",children:i("settings.gitIdentities.editor.field.hostTooltip")})]}),s.jsx(Ge,{value:M,onChange:z=>E(z.target.value),placeholder:i("settings.gitIdentities.editor.field.hostPlaceholder"),required:!0,className:"h-8 font-mono text-xs"})]})]})]})]}),s.jsxs(as,{className:"gap-2",children:[!h&&!m&&s.jsxs(V,{variant:"outline",size:"sm",onClick:()=>H(!0),className:"text-[var(--status-error)] hover:text-[var(--status-error)] border-[var(--status-error)]/30 hover:bg-[var(--status-error)]/10 mr-auto",children:[s.jsx($,{name:"delete-bin",className:"w-3.5 h-3.5 mr-1"})," ",i("settings.common.actions.delete")]}),s.jsx(V,{variant:"ghost",size:"sm",onClick:()=>e(!1),className:"text-foreground hover:bg-interactive-hover hover:text-foreground",children:i(h?"settings.gitIdentities.editor.actions.close":"settings.common.actions.cancel")}),!h&&s.jsx(V,{size:"sm",onClick:ae,disabled:j,children:i(j?"settings.common.actions.saving":m?"settings.gitIdentities.editor.actions.create":"settings.gitIdentities.editor.actions.save")})]})]})}),s.jsx(_t,{open:K,onOpenChange:z=>{q||H(z)},children:s.jsxs($t,{className:"max-w-md",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:i("settings.gitIdentities.page.deleteDialog.title")}),s.jsx(qt,{children:i("settings.gitIdentities.page.deleteDialog.description",{name:g?.name||f})})]}),s.jsxs(as,{children:[s.jsx(V,{variant:"ghost",onClick:()=>H(!1),disabled:q,children:i("settings.common.actions.cancel")}),s.jsx(V,{size:"sm",variant:"destructive",onClick:()=>{B()},disabled:q,children:i("settings.common.actions.delete")})]})]})})]})},Ev={branch:"git-branch",briefcase:"briefcase",house:"home",graduation:"graduation-cap",code:"code",heart:"heart"},Dv={keyword:"var(--syntax-keyword)",error:"var(--status-error)",string:"var(--syntax-string)",function:"var(--syntax-function)",type:"var(--syntax-type)"},Mv=()=>{const t=Be.c(112),{t:e}=qe(),{profiles:a,globalIdentity:n,defaultGitIdentityId:i,deleteProfile:o,loadProfiles:r,loadGlobalIdentity:d,loadDiscoveredCredentials:c,loadDefaultGitIdentityId:g,setDefaultGitIdentityId:m,getUnimportedCredentials:h}=ua(_s(Ov)),[f,p]=l.useState(!1),[b,C]=l.useState(null),[v,k]=l.useState(null),[u,y]=l.useState(null),[S,N]=l.useState(!1);let w,A;t[0]!==g||t[1]!==c||t[2]!==d||t[3]!==r?(w=()=>{r(),d(),c(),g()},A=[r,d,c,g],t[0]=g,t[1]=c,t[2]=d,t[3]=r,t[4]=w,t[5]=A):(w=t[4],A=t[5]),l.useEffect(w,A);let x,T,M,E,D,F,L,P,j,O,K,H,q,Z;if(t[6]!==i||t[7]!==u||t[8]!==o||t[9]!==h||t[10]!==n||t[11]!==a||t[12]!==m||t[13]!==e){const Te=h();let Oe;t[28]===Symbol.for("react.memo_cache_sentinel")?(Oe=(Le,Se)=>{C(Le),k(Se??null),p(!0)},t[28]=Oe):Oe=t[28];const ge=Oe;let xe;t[29]!==i||t[30]!==m||t[31]!==e?(xe=async Le=>{const Se=i===Le?null:Le;if(!await m(Se)){U.error(e("settings.gitIdentities.page.toast.updateDefaultFailed"));return}U.success(e(Se?"settings.gitIdentities.page.toast.defaultUpdated":"settings.gitIdentities.page.toast.defaultUnset"))},t[29]=i,t[30]=m,t[31]=e,t[32]=xe):xe=t[32];const ne=xe;let ie;t[33]!==u||t[34]!==o||t[35]!==e?(ie=async()=>{if(!u)return;N(!0),await o(u.id)?(U.success(e("settings.gitIdentities.page.toast.profileDeleted",{name:u.name})),y(null)):U.error(e("settings.gitIdentities.page.toast.deleteProfileFailed")),N(!1)},t[33]=u,t[34]=o,t[35]=e,t[36]=ie):ie=t[36],M=ie,T=ns,t[37]!==e?(D=e("settings.page.git.title"),t[37]=e,t[38]=D):D=t[38],F=!0,x=He,t[39]!==e?(H=e("settings.gitIdentities.page.section.title"),t[39]=e,t[40]=H):H=t[40],q=!1;let he,Ee;t[41]===Symbol.for("react.memo_cache_sentinel")?(he=()=>ge("new"),Ee=s.jsx($,{name:"add",className:"w-3.5 h-3.5 mr-1"}),t[41]=he,t[42]=Ee):(he=t[41],Ee=t[42]);let Ke;t[43]!==e?(Ke=e("settings.common.badge.new"),t[43]=e,t[44]=Ke):Ke=t[44],t[45]!==Ke?(Z=s.jsxs(V,{size:"sm",variant:"outline",onClick:he,children:[Ee," ",Ke]}),t[45]=Ke,t[46]=Z):Z=t[46],E="git.identities",L="rounded-lg bg-[var(--surface-elevated)]/70 overflow-hidden flex flex-col",P=n&&s.jsx(Nc,{profile:n,isDefault:i==="global",onEdit:()=>ge("global"),onToggleDefault:()=>ne("global"),isReadOnly:!0,hasBorder:a.length>0||Te.length>0}),j=a.map((Le,Se)=>s.jsx(Nc,{profile:Le,isDefault:i===Le.id,onEdit:()=>ge(Le.id),onToggleDefault:()=>ne(Le.id),onDelete:()=>y(Le),hasBorder:Se<a.length-1||Te.length>0},Le.id)),O=!n&&a.length===0&&Te.length===0&&s.jsxs("div",{className:"py-8 px-4 text-center text-muted-foreground",children:[s.jsx($,{name:"shield-keyhole",className:"mx-auto mb-2 h-8 w-8 opacity-40"}),s.jsx("p",{className:"typography-ui-label",children:e("settings.gitIdentities.page.empty.title")}),s.jsx("p",{className:"typography-meta mt-1 opacity-75",children:e("settings.gitIdentities.page.empty.description")})]}),K=Te.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-4 py-2 border-t border-[var(--surface-subtle)]",children:s.jsx("span",{className:"typography-micro text-muted-foreground",children:e("settings.gitIdentities.page.discoveredCredentials.title")})}),Te.map((Le,Se)=>s.jsx(Rv,{credential:Le,onImport:()=>ge("new",{host:Le.host,username:Le.username}),hasBorder:Se<Te.length-1},`${Le.host}-${Le.username}`))]}),t[6]=i,t[7]=u,t[8]=o,t[9]=h,t[10]=n,t[11]=a,t[12]=m,t[13]=e,t[14]=x,t[15]=T,t[16]=M,t[17]=E,t[18]=D,t[19]=F,t[20]=L,t[21]=P,t[22]=j,t[23]=O,t[24]=K,t[25]=H,t[26]=q,t[27]=Z}else x=t[14],T=t[15],M=t[16],E=t[17],D=t[18],F=t[19],L=t[20],P=t[21],j=t[22],O=t[23],K=t[24],H=t[25],q=t[26],Z=t[27];let ae;t[47]!==L||t[48]!==P||t[49]!==j||t[50]!==O||t[51]!==K?(ae=s.jsxs("div",{className:L,children:[P,j,O,K]}),t[47]=L,t[48]=P,t[49]=j,t[50]=O,t[51]=K,t[52]=ae):ae=t[52];let B;t[53]!==x||t[54]!==E||t[55]!==ae||t[56]!==H||t[57]!==q||t[58]!==Z?(B=s.jsx(x,{title:H,divider:q,headerAction:Z,settingsItem:E,children:ae}),t[53]=x,t[54]=E,t[55]=ae,t[56]=H,t[57]=q,t[58]=Z,t[59]=B):B=t[59];let G;t[60]===Symbol.for("react.memo_cache_sentinel")?(G=s.jsx($d,{}),t[60]=G):G=t[60];let _;t[61]!==T||t[62]!==D||t[63]!==F||t[64]!==B?(_=s.jsxs(T,{title:D,showSaveStatus:F,children:[B,G]}),t[61]=T,t[62]=D,t[63]=F,t[64]=B,t[65]=_):_=t[65];let z;t[66]!==v||t[67]!==f||t[68]!==b?(z=s.jsx(Tv,{open:f,onOpenChange:p,profileId:b,importData:v}),t[66]=v,t[67]=f,t[68]=b,t[69]=z):z=t[69];const te=u!==null;let Q;t[70]!==S?(Q=Te=>{S||Te||y(null)},t[70]=S,t[71]=Q):Q=t[71];let X;t[72]!==e?(X=e("settings.gitIdentities.page.deleteDialog.title"),t[72]=e,t[73]=X):X=t[73];let pe;t[74]!==X?(pe=s.jsx(Ht,{children:X}),t[74]=X,t[75]=pe):pe=t[75];const je=u?.name??"";let fe;t[76]!==e||t[77]!==je?(fe=e("settings.gitIdentities.page.deleteDialog.description",{name:je}),t[76]=e,t[77]=je,t[78]=fe):fe=t[78];let ke;t[79]!==fe?(ke=s.jsx(qt,{children:fe}),t[79]=fe,t[80]=ke):ke=t[80];let be;t[81]!==pe||t[82]!==ke?(be=s.jsxs(Vt,{children:[pe,ke]}),t[81]=pe,t[82]=ke,t[83]=be):be=t[83];let De;t[84]===Symbol.for("react.memo_cache_sentinel")?(De=()=>y(null),t[84]=De):De=t[84];let oe;t[85]!==e?(oe=e("settings.common.actions.cancel"),t[85]=e,t[86]=oe):oe=t[86];let ee;t[87]!==S||t[88]!==oe?(ee=s.jsx(V,{variant:"ghost",onClick:De,disabled:S,children:oe}),t[87]=S,t[88]=oe,t[89]=ee):ee=t[89];let ce;t[90]!==M?(ce=()=>{M()},t[90]=M,t[91]=ce):ce=t[91];let ue;t[92]!==e?(ue=e("settings.common.actions.delete"),t[92]=e,t[93]=ue):ue=t[93];let Ie;t[94]!==S||t[95]!==ce||t[96]!==ue?(Ie=s.jsx(V,{size:"sm",variant:"destructive",onClick:ce,disabled:S,children:ue}),t[94]=S,t[95]=ce,t[96]=ue,t[97]=Ie):Ie=t[97];let ve;t[98]!==ee||t[99]!==Ie?(ve=s.jsxs(as,{children:[ee,Ie]}),t[98]=ee,t[99]=Ie,t[100]=ve):ve=t[100];let Re;t[101]!==be||t[102]!==ve?(Re=s.jsxs($t,{className:"max-w-md",children:[be,ve]}),t[101]=be,t[102]=ve,t[103]=Re):Re=t[103];let Me;t[104]!==te||t[105]!==Q||t[106]!==Re?(Me=s.jsx(_t,{open:te,onOpenChange:Q,children:Re}),t[104]=te,t[105]=Q,t[106]=Re,t[107]=Me):Me=t[107];let me;return t[108]!==_||t[109]!==z||t[110]!==Me?(me=s.jsxs(s.Fragment,{children:[_,z,Me]}),t[108]=_,t[109]=z,t[110]=Me,t[111]=me):me=t[111],me},Nc=t=>{const e=Be.c(56),{profile:a,isDefault:n,onEdit:i,onToggleDefault:o,onDelete:r,isReadOnly:d,hasBorder:c}=t,{t:g}=qe(),[m,h]=l.useState(!1),f=Ev[a.icon||"branch"]||"git-branch",p=Dv[a.color||""],b=a.authType||"ssh";let C;e[0]!==i?(C=B=>{B.currentTarget===B.target&&(B.key!=="Enter"&&B.key!==" "||(B.preventDefault(),i()))},e[0]=i,e[1]=C):C=e[1];const v=C;let k;e[2]!==n||e[3]!==d||e[4]!==r||e[5]!==o||e[6]!==g?(k=B=>s.jsxs(s.Fragment,{children:[s.jsx(B,{onClick:G=>{G.stopPropagation(),o()},children:g(n?"settings.gitIdentities.page.actions.unsetDefault":"settings.gitIdentities.page.actions.setAsDefault")}),!d&&r&&s.jsxs(B,{onClick:G=>{G.stopPropagation(),r()},className:"text-destructive focus:text-destructive",children:[s.jsx($,{name:"delete-bin",className:"h-4 w-4 mr-px"}),g("settings.common.actions.delete")]})]}),e[2]=n,e[3]=d,e[4]=r,e[5]=o,e[6]=g,e[7]=k):k=e[7];const u=k,y=c&&"border-b border-[var(--surface-subtle)]";let S;e[8]!==y?(S=Ne("group flex items-center justify-between gap-3 px-4 py-2.5 transition-colors hover:bg-[var(--interactive-hover)]/30 cursor-pointer",y),e[8]=y,e[9]=S):S=e[9];let N;e[10]===Symbol.for("react.memo_cache_sentinel")?(N=B=>{B.preventDefault(),h(!0)},e[10]=N):N=e[10];let w;e[11]!==v||e[12]!==i||e[13]!==S?(w=s.jsx("div",{className:S,onClick:i,role:"button",tabIndex:0,onKeyDown:v,onContextMenu:N}),e[11]=v,e[12]=i,e[13]=S,e[14]=w):w=e[14];let A;e[15]!==p?(A={color:p},e[15]=p,e[16]=A):A=e[16];let x;e[17]!==f||e[18]!==A?(x=s.jsx($,{name:f,className:"w-4 h-4 shrink-0",style:A}),e[17]=f,e[18]=A,e[19]=x):x=e[19];let T;e[20]!==a.name?(T=s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:a.name}),e[20]=a.name,e[21]=T):T=e[21];let M;e[22]!==b?(M=s.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:b}),e[22]=b,e[23]=M):M=e[23];let E;e[24]!==n||e[25]!==g?(E=n&&s.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:g("settings.gitIdentities.page.badge.default")}),e[24]=n,e[25]=g,e[26]=E):E=e[26];let D;e[27]!==d||e[28]!==g?(D=d&&s.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:g("settings.agents.sidebar.badge.system")}),e[27]=d,e[28]=g,e[29]=D):D=e[29];let F;e[30]!==M||e[31]!==E||e[32]!==D||e[33]!==T?(F=s.jsxs("div",{className:"flex items-center gap-1.5",children:[T,M,E,D]}),e[30]=M,e[31]=E,e[32]=D,e[33]=T,e[34]=F):F=e[34];const L=b==="token"&&a.host?a.host:a.userEmail;let P;e[35]!==L?(P=s.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:L}),e[35]=L,e[36]=P):P=e[36];let j;e[37]!==F||e[38]!==P?(j=s.jsxs("div",{className:"min-w-0",children:[F,P]}),e[37]=F,e[38]=P,e[39]=j):j=e[39];let O;e[40]!==j||e[41]!==x?(O=s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[x,j]}),e[40]=j,e[41]=x,e[42]=O):O=e[42];let K;e[43]===Symbol.for("react.memo_cache_sentinel")?(K=s.jsx(Wn,{asChild:!0,children:s.jsx(V,{size:"icon",variant:"ghost",className:"h-6 w-6 shrink-0 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100",onClick:Lv,children:s.jsx($,{name:"more-2",className:"h-3.5 w-3.5"})})}),e[43]=K):K=e[43];let H;e[44]!==u?(H=s.jsxs(Jn,{children:[K,s.jsx(Gn,{align:"end",className:"w-fit min-w-28",children:u(xn)})]}),e[44]=u,e[45]=H):H=e[45];let q;e[46]!==O||e[47]!==H||e[48]!==w?(q=s.jsxs(ti,{render:w,children:[O,H]}),e[46]=O,e[47]=H,e[48]=w,e[49]=q):q=e[49];let Z;e[50]!==u?(Z=s.jsx(Xa,{className:"w-fit min-w-28",children:u(ei)}),e[50]=u,e[51]=Z):Z=e[51];let ae;return e[52]!==m||e[53]!==q||e[54]!==Z?(ae=s.jsxs(si,{open:m,onOpenChange:h,children:[q,Z]}),e[52]=m,e[53]=q,e[54]=Z,e[55]=ae):ae=e[55],ae},Rv=t=>{const e=Be.c(21),{credential:a,onImport:n,hasBorder:i}=t,{t:o}=qe();let r;e[0]!==a.host?(r=a.host.split("/"),e[0]=a.host,e[1]=r):r=e[1];const d=r,c=d.length>=3?d[d.length-1]:a.host,g=a.host.includes("/"),m=i&&"border-b border-[var(--surface-subtle)]";let h;e[2]!==m?(h=Ne("flex items-center justify-between gap-3 px-4 py-2.5 transition-colors hover:bg-[var(--interactive-hover)]/30",m),e[2]=m,e[3]=h):h=e[3];let f;e[4]!==c?(f=s.jsx("span",{className:"typography-ui-label text-foreground truncate block",children:c}),e[4]=c,e[5]=f):f=e[5];const p=g?a.host:a.username;let b;e[6]!==p?(b=s.jsx("span",{className:"typography-micro text-muted-foreground/60 truncate block leading-tight",children:p}),e[6]=p,e[7]=b):b=e[7];let C;e[8]!==f||e[9]!==b?(C=s.jsxs("div",{className:"min-w-0",children:[f,b]}),e[8]=f,e[9]=b,e[10]=C):C=e[10];let v;e[11]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsx($,{name:"download",className:"h-3 w-3"}),e[11]=v):v=e[11];let k;e[12]!==o?(k=o("settings.gitIdentities.page.actions.import"),e[12]=o,e[13]=k):k=e[13];let u;e[14]!==n||e[15]!==k?(u=s.jsxs(V,{size:"sm",variant:"ghost",onClick:n,className:"gap-1 shrink-0",children:[v,k]}),e[14]=n,e[15]=k,e[16]=u):u=e[16];let y;return e[17]!==u||e[18]!==h||e[19]!==C?(y=s.jsxs("div",{className:h,children:[C,u]}),e[17]=u,e[18]=h,e[19]=C,e[20]=y):y=e[20],y};function Ov(t){return{profiles:t.profiles,globalIdentity:t.globalIdentity,defaultGitIdentityId:t.defaultGitIdentityId,deleteProfile:t.deleteProfile,loadProfiles:t.loadProfiles,loadGlobalIdentity:t.loadGlobalIdentity,loadDiscoveredCredentials:t.loadDiscoveredCredentials,loadDefaultGitIdentityId:t.loadDefaultGitIdentityId,setDefaultGitIdentityId:t.setDefaultGitIdentityId,getUnimportedCredentials:t.getUnimportedCredentials}}function Lv(t){return t.stopPropagation()}const Bd=({guest:t})=>{const{t:e}=qe(),a=t.integration,n=Bo(Q=>Q.byId[t.id]),i=Bo(Q=>Q.setStatus),o=l.useMemo(()=>id(t.id,t.icon,xd().authenticatedAsset),[t.id,t.icon]),r=Bo(Q=>Q.refresh),[d,c]=l.useState(!1),[g,m]=l.useState(!1),[h,f]=l.useState(!1),[p,b]=l.useState(""),[C,v]=l.useState(""),[k,u]=l.useState(""),[y,S]=l.useState(""),[N,w]=l.useState({}),[A,x]=l.useState(!1),T=l.useRef(null),[M]=l.useState(ln),E=l.useRef(!0),D=()=>E.current&&ln()===M,F=l.useCallback(()=>{T.current!=null&&(window.clearInterval(T.current),T.current=null),f(!1)},[]);if(l.useEffect(()=>(E.current=!0,r(t.id),()=>{E.current=!1,F()}),[t.id,r,F]),l.useEffect(()=>{n&&w(n.settings)},[n]),!a)return null;const L=a.auth,P=L==="token"&&a.token?.scheme==="basic",j=!!n?.connection.connected,O=n?.connection.account.trim()||"",K=h?e("settings.integrations.guests.status.waiting"):j?O||e("settings.integrations.guests.status.connected"):e("settings.integrations.guests.status.notConnected"),H=h?"bg-[var(--status-warning)]/15 text-[var(--status-warning)]":j?"bg-[var(--status-success)]/15 text-[var(--status-success)]":"bg-[var(--surface-muted)] text-muted-foreground",q=h||d,Z=a.name,ae=async()=>{if(!D())return!1;const Q=p.trim();if(!Q)return n?.hasClient?!0:(U.error(e("settings.integrations.guests.toast.clientRequired")),!1);os("saving");const X=await Rp(t.id,Q,C.trim()||void 0);return D()?X?(i(t.id,X),v(""),os("saved"),!0):(os("error"),U.error(e("settings.integrations.guests.toast.saveFailed",{name:Z})),!1):!1},B=async(Q=N)=>{if(!D())return!1;const X=n?.settings??{};if((a.settings??[]).every(ke=>(Q[ke.id]??"").trim()===(X[ke.id]??"")))return!0;os("saving");const fe=await Ip(t.id,Q);return D()?fe?(i(t.id,fe),os("saved"),!0):(os("error"),U.error(e("settings.integrations.guests.toast.saveFailed",{name:Z})),!1):!1},G=async()=>{if(!D())return!1;const Q=k.trim();if(!Q)return j?!0:(U.error(e("settings.integrations.guests.toast.tokenRequired")),!1);const X=y.trim();if(P&&!X)return U.error(e("settings.integrations.guests.toast.usernameRequired")),!1;os("saving");const pe=await Mp(t.id,Q,P?X:void 0);return D()?pe?(i(t.id,pe),u(""),S(""),os("saved"),!0):(os("error"),U.error(e("settings.integrations.guests.toast.tokenInvalid")),!1):!1},_=async()=>{if(!D())return;F(),m(!0);const Q=n?.connection??{connected:!1,account:""};try{if(L==="token"){if(await G()){if((a.settings??[]).length>0&&!await B()||!D())return;U.success(e("settings.integrations.guests.toast.connected",{name:Z}))}return}if(L==="oauth"&&!n?.hasClient&&!await ae())return;const X=await Ap(t.id);if(!D())return;if(!X){U.error(e("settings.integrations.guests.toast.startFailed",{name:Z}));return}f(!0),c(!0),Gs(X);const pe=Date.now()+Tp;T.current=window.setInterval(()=>{(async()=>{if(!D()){F();return}if(Date.now()>pe){F(),U.error(e("settings.integrations.guests.toast.authorizationFailed",{name:Z}));return}const je=await r(t.id);D()&&je&&Ep(Q,je.connection)&&(F(),U.success(e("settings.integrations.guests.toast.connected",{name:Z})),us()&&bd())})()},Dp)}catch(X){if(!D())return;console.error("Failed to start guest connect:",X),U.error(e("settings.integrations.guests.toast.startFailed",{name:Z})),F()}finally{D()&&m(!1)}},z=async()=>{if(D()){m(!0);try{F();const Q=await Pp(t.id);if(!D())return;if(!Q){U.error(e("settings.integrations.guests.toast.disconnectFailed",{name:Z}));return}i(t.id,Q),U.success(e("settings.integrations.guests.toast.disconnected",{name:Z}))}catch(Q){if(!D())return;console.error("Failed to disconnect guest:",Q),U.error(e("settings.integrations.guests.toast.disconnectFailed",{name:Z}))}finally{D()&&m(!1)}}},te=async()=>{const Q=n?.redirectUri??"";!Q||!(await qa(Q)).ok||(x(!0),window.setTimeout(()=>x(!1),1500))};return s.jsx(bn,{open:q,onOpenChange:Q=>{if(h){c(!0);return}c(Q)},children:s.jsxs("div",{className:"overflow-hidden rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)]",children:[s.jsxs(vn,{className:"flex w-full min-w-0 items-center gap-3 px-4 py-3 text-left hover:bg-[var(--interactive-hover)]/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]",children:[s.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-[10px] bg-[var(--surface-muted)]",children:s.jsx(od,{icon:rd(t.icon),iconSrc:o,className:"size-5 text-foreground"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:Z}),s.jsx("p",{className:"mt-0.5 line-clamp-1 text-xs leading-snug text-muted-foreground",children:a.description})]}),s.jsx("span",{"aria-live":"polite",className:Ne("max-w-36 shrink-0 truncate rounded-full px-2 py-0.5 text-[10px] font-medium",H),children:K}),s.jsx($,{name:"arrow-down-s",className:Ne("size-4 shrink-0 text-muted-foreground transition-transform duration-150 ease-out motion-reduce:transition-none",q&&"rotate-180")})]}),s.jsx(yn,{className:"border-t border-[var(--interactive-border)] px-4 py-4",children:s.jsxs("div",{className:"space-y-3",children:[L==="oauth"?s.jsxs(s.Fragment,{children:[s.jsx(Kt,{label:e("settings.integrations.guests.field.clientId"),controlClassName:"w-full max-w-none",children:s.jsx(Ge,{value:p,onChange:Q=>b(Q.target.value),autoComplete:"off",spellCheck:!1,className:"h-8 min-w-0 flex-1 rounded-md px-3",disabled:g})}),s.jsx(Kt,{label:e("settings.integrations.guests.field.clientSecret"),controlClassName:"w-full max-w-none",children:s.jsx(Ge,{type:"password",value:C,onChange:Q=>v(Q.target.value),autoComplete:"off",spellCheck:!1,className:"h-8 min-w-0 flex-1 rounded-md px-3",disabled:g})})]}):null,P?s.jsx(Kt,{label:a.token?.usernameLabel??e("settings.integrations.guests.field.username"),controlClassName:"w-full max-w-none",children:s.jsx(Ge,{value:y,onChange:Q=>S(Q.target.value),autoComplete:"off",spellCheck:!1,className:"h-8 min-w-0 flex-1 rounded-md px-3",disabled:g})}):null,L==="token"?s.jsx(Kt,{label:e("settings.integrations.guests.field.token"),info:e("settings.integrations.guests.field.token.info"),controlClassName:"w-full max-w-none",children:s.jsx(Ge,{type:"password",value:k,onChange:Q=>u(Q.target.value),autoComplete:"off",spellCheck:!1,className:"h-8 min-w-0 flex-1 rounded-md px-3",disabled:g})}):null,(a.settings??[]).map(Q=>s.jsx(Kt,{label:Q.label,controlClassName:"w-full max-w-none",children:s.jsx(Ge,{value:N[Q.id]??"",onChange:X=>{w(pe=>({...pe,[Q.id]:X.target.value}))},onBlur:()=>{B()},autoComplete:"off",spellCheck:!1,className:"h-8 min-w-0 flex-1 rounded-md px-3",disabled:g})},Q.id)),L==="oauth"?s.jsxs(Kt,{label:e("settings.integrations.guests.field.redirectUri"),info:e("settings.integrations.guests.field.redirectUri.info"),controlClassName:"w-full max-w-none",children:[s.jsx(Ge,{value:n?.redirectUri??"",readOnly:!0,className:"h-8 min-w-0 flex-1 rounded-md px-3"}),s.jsx(V,{type:"button",size:"sm",variant:"outline",disabled:!n?.redirectUri,onClick:()=>{te()},children:e(A?"settings.integrations.guests.actions.copied":"settings.integrations.guests.actions.copyRedirect")})]}):null,s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:j?s.jsx(V,{type:"button",size:"sm",variant:"destructive",disabled:g,onClick:()=>{z()},children:e("settings.integrations.guests.actions.disconnect")}):s.jsxs(V,{type:"button",size:"sm",disabled:g||h,onClick:()=>{_()},children:[g?s.jsx($,{name:"loader-4",className:"size-3.5 animate-spin"}):null,e("settings.integrations.guests.actions.connect")]})})]})})]})})},Fv=t=>{const e=Be.c(27),{divider:a}=t,n=a===void 0?!0:a,{t:i}=qe(),o=Ks(Kv),r=Ks(zv);let d;if(e[0]===Symbol.for("react.memo_cache_sentinel")?(d=[],e[0]=d):d=e[0],l.useEffect(Uv,d),ps()||vd())return null;let c,g,m,h,f,p,b,C;if(e[1]!==n||e[2]!==o||e[3]!==r||e[4]!==i){C=Symbol.for("react.early_return_sentinel");e:{const k=o.filter(_v);if(k.length===0){C=null;break e}c=He,e[13]!==i?(g=i("settings.integrations.guests.title"),e[13]=i,e[14]=g):g=e[14],e[15]!==i?(m=i("settings.integrations.guests.info"),e[15]=i,e[16]=m):m=e[16],h=n,f="integrations.guests",p="space-y-3";let u;e[17]!==r?(u=y=>s.jsx(Bd,{guest:y},`${r}:${y.id}`),e[17]=r,e[18]=u):u=e[18],b=k.map(u)}e[1]=n,e[2]=o,e[3]=r,e[4]=i,e[5]=c,e[6]=g,e[7]=m,e[8]=h,e[9]=f,e[10]=p,e[11]=b,e[12]=C}else c=e[5],g=e[6],m=e[7],h=e[8],f=e[9],p=e[10],b=e[11],C=e[12];if(C!==Symbol.for("react.early_return_sentinel"))return C;let v;return e[19]!==c||e[20]!==g||e[21]!==m||e[22]!==h||e[23]!==f||e[24]!==p||e[25]!==b?(v=s.jsx(c,{title:g,info:m,divider:h,settingsItem:f,contentClassName:p,children:b}),e[19]=c,e[20]=g,e[21]=m,e[22]=h,e[23]=f,e[24]=p,e[25]=b,e[26]=v):v=e[26],v};function Kv(t){return t.guests}function zv(t){return t.runtimeKey}function Uv(){gn()}function _v(t){return t.source!=="bundled"&&t.integration&&_r(t)}const $v=({embedded:t=!1})=>{const{t:e}=qe(),{isMobile:a}=qn(),n=Wa()?.github,i=ta(P=>P.status),o=ta(P=>P.isLoading),r=ta(P=>P.hasChecked),d=ta(P=>P.refreshStatus),c=ta(P=>P.setStatus),g=l.useCallback(async P=>{await Gs(P)},[]),[m,h]=l.useState(!1),[f,p]=l.useState(null),[b,C]=l.useState(null),v=l.useRef(null),k=l.useCallback(()=>{v.current!=null&&(window.clearInterval(v.current),v.current=null),C(null)},[]);l.useEffect(()=>((async()=>{try{r||await d(n)}catch(P){console.warn("Failed to load GitHub auth status:",P)}})(),()=>{k()}),[r,d,n,k]);const u=l.useCallback(async()=>{h(!0);try{const P=n?await n.authStart():await(async()=>{const O=await It("/api/github/auth/start",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({})}),K=await O.json().catch(()=>null);if(!O.ok||!K||!("deviceCode"in K))throw new Error(K?.error||O.statusText);return K})();p(P),C(Math.max(1,P.interval)*1e3);const j=P.verificationUriComplete||P.verificationUri;g(j)}catch(P){console.error("Failed to start GitHub connect:",P),U.error(e("settings.github.page.toast.startConnectFailed"))}finally{h(!1)}},[g,n,e]),y=l.useCallback(async P=>{if(n)return n.authComplete(P);const j=await It("/api/github/auth/complete",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({deviceCode:P})}),O=await j.json().catch(()=>null);if(!j.ok||!O)throw new Error(O?.error||j.statusText);return O},[n]);l.useEffect(()=>{if(!(!f?.deviceCode||!b)&&v.current==null)return v.current=window.setInterval(()=>{(async()=>{try{const P=await y(f.deviceCode);if(P.connected){U.success(e("settings.github.page.toast.connected")),p(null),k(),await d(n,{force:!0});return}P.status==="slow_down"&&C(j=>j?j+5e3:5e3),(P.status==="expired_token"||P.status==="access_denied")&&(U.error(P.error||e("settings.github.page.toast.authorizationFailed")),p(null),k())}catch(P){console.warn("GitHub polling failed:",P)}})()},b),()=>{v.current!=null&&(window.clearInterval(v.current),v.current=null)}},[f,b,y,d,n,k,e]);const S=l.useCallback(async P=>{h(!0);try{if(n)await n.authSetGhCliDisabled(P);else{const j=await It("/api/github/auth/gh-cli",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({disabled:P})}),O=await j.json().catch(()=>null);if(!j.ok)throw new Error(O?.error||j.statusText)}U.success(e(P?"settings.github.page.toast.ghCliDisabled":"settings.github.page.toast.ghCliEnabled")),await d(n,{force:!0})}catch(j){console.error("Failed to update gh CLI setting:",j),U.error(e("settings.github.page.toast.ghCliUpdateFailed"))}finally{h(!1)}},[d,n,e]),N=l.useCallback(async()=>{h(!0);try{if(k(),p(null),n)await n.authDisconnect();else{const P=await It("/api/github/auth",{method:"DELETE",headers:{Accept:"application/json"}});if(!P.ok)throw new Error(P.statusText)}U.success(e("settings.github.page.toast.disconnected")),await d(n,{force:!0})}catch(P){console.error("Failed to disconnect GitHub:",P),U.error(e("settings.github.page.toast.disconnectFailed"))}finally{h(!1)}},[d,n,k,e]),w=l.useCallback(async P=>{if(P){h(!0);try{const j=n?await n.authActivate(P):await(async()=>{const O=await It("/api/github/auth/activate",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({accountId:P})}),K=await O.json().catch(()=>null);if(!O.ok||!K)throw new Error(K?.error||O.statusText);return K})();c(j),U.success(e("settings.github.page.toast.accountSwitched"))}catch(j){console.error("Failed to switch GitHub account:",j),U.error(e("settings.github.page.toast.accountSwitchFailed"))}finally{h(!1)}}},[n,c,e]);if(o&&!r)return null;const A=!!i?.connected,x=i?.user,M=(i?.accounts??[]).filter(P=>!P.current),E=i?.ghCli??null,D=E?.active?e("settings.github.page.accountSource.cli"):e("settings.github.page.accountSource.oauth"),F=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 overflow-hidden flex flex-col",children:[A?s.jsxs("div",{className:Ne("px-4 py-3",a?"flex flex-col gap-3":"flex items-center justify-between gap-4"),children:[s.jsxs("div",{className:Ne("flex min-w-0 items-center gap-4",a?"w-full":void 0),children:[x?.avatarUrl?s.jsx("img",{src:x.avatarUrl,alt:x.login?e("settings.github.page.avatarAlt.withLogin",{login:x.login}):e("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"}):s.jsx("div",{className:"h-10 w-10 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)]"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"typography-ui-label text-foreground",children:x?.name?.trim()||x?.login||"GitHub"}),s.jsxs("div",{className:Ne("flex items-center gap-2 typography-meta text-muted-foreground mt-0.5",a?"flex-wrap":"truncate"),children:[s.jsx($,{name:"github-fill",className:"h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"font-mono",children:x?.login||e("settings.github.page.label.unknownUser")}),x?.email&&s.jsx("span",{className:"opacity-50",children:"•"}),x?.email&&s.jsx("span",{children:x.email}),s.jsx("span",{className:"opacity-50",children:"•"}),s.jsx("span",{children:D})]}),i?.scope&&s.jsx("div",{className:"typography-micro text-muted-foreground/70 mt-0.5",children:e("settings.github.page.label.scopes",{value:i.scope})}),E?.active&&s.jsx("div",{className:"typography-micro text-muted-foreground/70 mt-0.5",children:e("settings.github.page.ghCli.activeDescription")})]})]}),E?.active?s.jsx(V,{size:"sm",variant:"outline",onClick:()=>S(!0),disabled:m,className:Ne(a?"w-full":void 0),children:e("settings.github.page.ghCli.actions.disable")}):s.jsx(V,{size:"sm",variant:"outline",onClick:N,disabled:m,className:Ne("text-[var(--status-error)] hover:text-[var(--status-error)]",a?"w-full":void 0),children:e("settings.github.page.actions.disconnect")})]}):s.jsxs("div",{className:"flex items-center justify-between gap-4 px-4 py-4",children:[s.jsx("div",{className:"flex min-w-0 flex-col",children:s.jsx("span",{className:"typography-ui-label text-foreground",children:e("settings.github.page.status.notConnected")})}),s.jsx(V,{size:"sm",variant:"default",onClick:u,disabled:m,children:e("settings.github.page.actions.connect")})]}),M.length>0&&s.jsxs("div",{className:"mt-2 border-t border-[var(--surface-subtle)] pt-2 px-2 pb-1",children:[s.jsx("div",{className:"typography-micro text-muted-foreground mb-2 px-1",children:e("settings.github.page.label.otherAccounts")}),s.jsx("div",{className:"space-y-1",children:M.map(P=>{const j=P.user,O=P.source==="gh-cli"?e("settings.github.page.accountSource.cli"):e("settings.github.page.accountSource.oauth");return s.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-[var(--surface-subtle)] bg-[var(--surface-muted)] px-3 py-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[j?.avatarUrl?s.jsx("img",{src:j.avatarUrl,alt:j.login?e("settings.github.page.avatarAlt.withLogin",{login:j.login}):e("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"}):s.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:s.jsx($,{name:"github-fill",className:"h-3 w-3 text-muted-foreground"})}),s.jsxs("div",{className:"min-w-0 flex flex-col",children:[s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:j?.name?.trim()||j?.login||"GitHub"}),j?.login&&s.jsxs("span",{className:"typography-micro text-muted-foreground truncate",children:[s.jsx("span",{className:"font-mono",children:j.login}),s.jsx("span",{className:"mx-1 opacity-50",children:"·"}),s.jsx("span",{children:O})]})]})]}),s.jsx(V,{size:"sm",variant:"ghost",onClick:()=>w(P.id),disabled:m,children:e("settings.github.page.actions.switchTo")})]},P.id)})})]})]}),A&&s.jsx("div",{className:"mt-2 px-2 pb-2",children:s.jsx(V,{size:"sm",variant:"outline",onClick:u,disabled:m,className:Ne(a?"w-full":void 0),children:e("settings.github.page.actions.addAccount")})}),f&&s.jsxs("div",{className:"mt-4 rounded-lg bg-[var(--surface-elevated)]/70 p-4 border border-[var(--interactive-border)]",children:[s.jsxs("div",{className:"space-y-1",children:[s.jsx(An,{children:e("settings.github.page.flow.title")}),s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.github.page.flow.description")})]}),s.jsxs("div",{className:"flex items-center justify-between gap-3 mt-4",children:[s.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:f.userCode}),s.jsx(V,{size:"sm",asChild:!0,children:s.jsx("a",{href:f.verificationUriComplete||f.verificationUri,target:"_blank",rel:"noopener noreferrer",children:e("settings.github.page.actions.openGithub")})})]}),s.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[s.jsx("span",{className:"typography-micro text-muted-foreground animate-pulse",children:e("settings.github.page.flow.waiting")}),s.jsx(V,{size:"sm",variant:"ghost",disabled:m,onClick:()=>{k(),p(null)},children:e("settings.common.actions.cancel")})]})]})]}),L=E?.available&&!E?.active&&(!E.user||E.disabled)?s.jsx(s.Fragment,{children:s.jsx("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 overflow-hidden",children:s.jsxs("div",{className:Ne("px-4 py-3",a?"flex flex-col gap-3":"flex items-center justify-between gap-4"),children:[s.jsxs("div",{className:Ne("flex min-w-0 items-center gap-4",a?"w-full":void 0),children:[E.user?.avatarUrl?s.jsx("img",{src:E.user.avatarUrl,alt:E.user.login?e("settings.github.page.avatarAlt.withLogin",{login:E.user.login}):e("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"}):s.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:s.jsx($,{name:"github-fill",className:"h-4 w-4 text-muted-foreground"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[!E.disabled&&E.user&&s.jsx("div",{className:"typography-ui-label text-foreground truncate",children:E.user.name?.trim()||E.user.login||"GitHub"}),!E.disabled&&E.user?.login&&s.jsxs("div",{className:Ne("flex items-center gap-2 typography-meta text-muted-foreground mt-0.5",a?"flex-wrap":"truncate"),children:[s.jsx($,{name:"github-fill",className:"h-3.5 w-3.5 shrink-0"}),s.jsx("span",{className:"font-mono",children:E.user.login}),E.user.email&&s.jsx("span",{className:"opacity-50",children:"•"}),E.user.email&&s.jsx("span",{children:E.user.email})]}),s.jsx("div",{className:Ne("typography-meta text-muted-foreground",E.disabled?"opacity-60":void 0),children:E.disabled?e("settings.github.page.ghCli.disabledDescription"):e("settings.github.page.ghCli.fallbackDescription")})]})]}),s.jsx(V,{size:"sm",variant:"outline",onClick:()=>S(!E.disabled),disabled:m,className:Ne(a?"w-full":void 0),children:E.disabled?e("settings.github.page.ghCli.actions.enable"):e("settings.github.page.ghCli.actions.disable")})]})})}):null;return t?s.jsxs("div",{className:"space-y-4",children:[F,L?s.jsxs("div",{className:"space-y-2",children:[s.jsx(An,{children:e("settings.github.page.ghCli.title")}),L]}):null]}):s.jsxs(s.Fragment,{children:[s.jsx(He,{title:e("settings.github.page.oauth.title"),divider:!1,settingsItem:"git.github-account",info:e("settings.github.page.tooltip.connectAccount"),children:F}),L?s.jsx(He,{title:e("settings.github.page.ghCli.title"),children:L}):null]})},Bv=()=>{const t=Be.c(37),{t:e}=qe(),a=ta(Vv),n=ta(Hv),i=ta(qv),[o,r]=l.useState(!1),d=a?.connected===!0;let c;t[0]!==d||t[1]!==i||t[2]!==n||t[3]!==a?.user?.login||t[4]!==e?(c=n&&!i?e("common.loading"):d?a?.user?.login?.trim()||e("settings.github.page.status.active"):e("settings.integrations.github.status.notConnected"),t[0]=d,t[1]=i,t[2]=n,t[3]=a?.user?.login,t[4]=e,t[5]=c):c=t[5];const g=c,m=d?"bg-[var(--status-success)]/15 text-[var(--status-success)]":"bg-[var(--surface-muted)] text-muted-foreground";let h;t[6]===Symbol.for("react.memo_cache_sentinel")?(h=s.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-[10px] bg-[var(--surface-muted)]",children:s.jsx($,{name:"github-fill",className:"size-5 text-foreground"})}),t[6]=h):h=t[6];let f;t[7]!==e?(f=e("settings.integrations.github.title"),t[7]=e,t[8]=f):f=t[8];let p;t[9]!==f?(p=s.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:f}),t[9]=f,t[10]=p):p=t[10];let b;t[11]!==e?(b=e("settings.integrations.github.description"),t[11]=e,t[12]=b):b=t[12];let C;t[13]!==b?(C=s.jsx("p",{className:"mt-0.5 line-clamp-1 text-xs leading-snug text-muted-foreground",children:b}),t[13]=b,t[14]=C):C=t[14];let v;t[15]!==p||t[16]!==C?(v=s.jsxs("div",{className:"min-w-0 flex-1",children:[p,C]}),t[15]=p,t[16]=C,t[17]=v):v=t[17];let k;t[18]!==m?(k=Ne("max-w-36 shrink-0 truncate rounded-full px-2 py-0.5 text-[10px] font-medium",m),t[18]=m,t[19]=k):k=t[19];let u;t[20]!==g||t[21]!==k?(u=s.jsx("span",{"aria-live":"polite",className:k,children:g}),t[20]=g,t[21]=k,t[22]=u):u=t[22];const y=o&&"rotate-180";let S;t[23]!==y?(S=Ne("size-4 shrink-0 text-muted-foreground transition-transform duration-150 ease-out motion-reduce:transition-none",y),t[23]=y,t[24]=S):S=t[24];let N;t[25]!==S?(N=s.jsx($,{name:"arrow-down-s",className:S}),t[25]=S,t[26]=N):N=t[26];let w;t[27]!==N||t[28]!==v||t[29]!==u?(w=s.jsxs(vn,{className:"flex w-full min-w-0 items-center gap-3 px-4 py-3 text-left hover:bg-[var(--interactive-hover)]/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]",children:[h,v,u,N]}),t[27]=N,t[28]=v,t[29]=u,t[30]=w):w=t[30];let A;t[31]===Symbol.for("react.memo_cache_sentinel")?(A=s.jsx(yn,{className:"border-t border-[var(--interactive-border)] px-4 py-4",children:s.jsx($v,{embedded:!0})}),t[31]=A):A=t[31];let x;t[32]!==w?(x=s.jsxs("div",{"data-settings-item":"integrations.github",className:"overflow-hidden rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)]",children:[w,A]}),t[32]=w,t[33]=x):x=t[33];let T;return t[34]!==o||t[35]!==x?(T=s.jsx(bn,{open:o,onOpenChange:r,children:x}),t[34]=o,t[35]=x,t[36]=T):T=t[36],T};function Vv(t){return t.status}function Hv(t){return t.isLoading}function qv(t){return t.hasChecked}const Gi="__none__",Wi="__inherit__";function Gv({linear:t,connected:e,organizationId:a}){const{t:n}=qe(),i=hn(v=>v.projects),[o,r]=l.useState(null),[d,c]=l.useState(!1),[g,m]=l.useState(!1),h=l.useCallback(async()=>{if(!e){r(null),c(!1);return}try{const v=await t.mappingGet();if(v.connected===!1){r(null),c(!1);return}r(v),c(!1)}catch(v){console.error("Failed to load Linear mapping:",v),c(!0)}},[e,t]);l.useEffect(()=>{h()},[h,a]);const f=l.useCallback(async v=>{const k={};for(const u of v.teams??[])u.projectPath&&(k[u.id]=u.projectPath);m(!0),os("saving");try{const u=await t.mappingSet({defaultProjectPath:v.defaultProjectPath??null,teamProjectPaths:k});if(u.connected===!1){r(null),os("error");return}r(u),c(!1),os("saved")}catch(u){console.error("Failed to save Linear mapping:",u),os("error")}finally{m(!1)}},[t]);if(!e)return null;if(d&&!o)return s.jsx("p",{className:"text-xs text-muted-foreground",children:n("settings.integrations.linear.mapping.loadFailed")});if(!o)return null;const p=v=>i.find(u=>u.path===v)?.label?.trim()||v,b=v=>!v||v===Gi?n("settings.integrations.linear.mapping.defaultProject.placeholder"):p(v),C=v=>!v||v===Wi?n("settings.integrations.linear.mapping.teams.useDefault"):p(v);return s.jsxs("div",{className:Ms,children:[i.length===0?s.jsx("p",{className:"text-xs text-muted-foreground",children:n("settings.integrations.linear.mapping.emptyProjects")}):null,s.jsx(Ct,{label:n("settings.integrations.linear.mapping.defaultProject"),info:n("settings.integrations.linear.mapping.defaultProject.info"),settingsItem:"integrations.linear.mapping",children:s.jsxs(Dt,{value:o.defaultProjectPath||Gi,disabled:g||i.length===0,onValueChange:v=>{f({...o,defaultProjectPath:v===Gi?null:v})},children:[s.jsx(Tt,{size:Qt,className:fn,"aria-label":n("settings.integrations.linear.mapping.defaultProject.aria"),children:s.jsx(Jt,{placeholder:n("settings.integrations.linear.mapping.defaultProject.placeholder"),children:b})}),s.jsxs(Et,{children:[s.jsx(gt,{value:Gi,children:n("settings.integrations.linear.mapping.defaultProject.placeholder")}),o.defaultProjectPath&&!i.some(v=>v.path===o.defaultProjectPath)?s.jsx(gt,{value:o.defaultProjectPath,children:o.defaultProjectPath}):null,i.map(v=>s.jsx(gt,{value:v.path,children:p(v.path)},v.id))]})]})}),s.jsx(Ss,{title:n("settings.integrations.linear.mapping.teams"),info:n("settings.integrations.linear.mapping.teams.info"),children:(o.teams??[]).length===0?s.jsx("p",{className:"text-xs text-muted-foreground",children:n("settings.integrations.linear.mapping.emptyTeams")}):s.jsx("div",{className:Ms,children:(o.teams??[]).map(v=>s.jsx(Ct,{label:`${v.key} · ${v.name}`,children:s.jsxs(Dt,{value:v.projectPath||Wi,disabled:g||i.length===0,onValueChange:k=>{f({...o,teams:(o.teams??[]).map(u=>u.id===v.id?{...u,projectPath:k===Wi?null:k}:u)})},children:[s.jsx(Tt,{size:Qt,className:fn,"aria-label":n("settings.integrations.linear.mapping.teams.aria",{team:v.key}),children:s.jsx(Jt,{placeholder:n("settings.integrations.linear.mapping.teams.useDefault"),children:C})}),s.jsxs(Et,{children:[s.jsx(gt,{value:Wi,children:n("settings.integrations.linear.mapping.teams.useDefault")}),v.projectPath&&!i.some(k=>k.path===v.projectPath)?s.jsx(gt,{value:v.projectPath,children:v.projectPath}):null,i.map(k=>s.jsx(gt,{value:k.path,children:p(k.path)},k.id))]})]})},v.id))})})]})}function Wv({linear:t,connected:e}){const{t:a}=qe(),[n,i]=l.useState(null),[o,r]=l.useState(!1),[d,c]=l.useState(!1);l.useEffect(()=>{if(!e){i(null),r(!1);return}let m=!1;return t.preferencesGet().then(h=>{m||(i(h.sessionComments),r(!1))}).catch(()=>{m||r(!0)}),()=>{m=!0}},[e,t]);const g=l.useCallback(async m=>{const h=n;i(m),c(!0);try{const f=await t.preferencesSet({sessionComments:m});i(f.sessionComments),os("saved")}catch{i(h),os("error")}finally{c(!1)}},[n,t]);return e?o?s.jsx("p",{className:"text-xs text-muted-foreground",children:a("settings.integrations.linear.sessionComments.loadFailed")}):s.jsx("div",{className:Ms,children:s.jsx(Ct,{label:a("settings.integrations.linear.sessionComments.label"),info:a("settings.integrations.linear.sessionComments.info"),settingsItem:"integrations.linear.session-comments",children:s.jsx(ga,{checked:n===!0,disabled:n===null||d,onCheckedChange:m=>{g(m)},"aria-label":a("settings.integrations.linear.sessionComments.aria")})})}):null}const Jv=3*6e4,Qv=1500;function Sc(t){const e=t?.workspaces??[],a=e.find(n=>n.current);return{connected:!!t?.connected,ids:e.map(n=>n.id).slice().sort().join(","),currentId:a?.id||t?.organization?.id||"",currentAuthorizedAt:a?.authorizedAt??0}}function Yv(t,e){return e.connected?t.connected?e.ids!==t.ids||e.currentId!==t.currentId||e.currentAuthorizedAt!==t.currentAuthorizedAt:!0:!1}const Zv=()=>{const{t}=qe(),e=Wa()?.linear,a=Fa(E=>E.status),n=Fa(E=>E.isLoading),i=Fa(E=>E.hasChecked),o=Fa(E=>E.refreshStatus),r=Fa(E=>E.setStatus),[d,c]=l.useState(!1),[g,m]=l.useState(!1),[h,f]=l.useState(!1),p=l.useRef(null),b=l.useCallback(()=>{p.current!=null&&(window.clearInterval(p.current),p.current=null),m(!1)},[]);l.useEffect(()=>{if(e)return i||o(e),()=>{b()}},[i,o,e,b]);const C=l.useCallback(async()=>{if(!e)return;b(),c(!0);const E=Sc(Fa.getState().status);try{const D=await e.authStart(us()?"desktop":"web");m(!0),f(!0),Gs(D.authorizationUrl);const F=Date.now()+Jv;p.current=window.setInterval(()=>{(async()=>{if(Date.now()>F){b(),U.error(t("settings.integrations.linear.toast.authorizationFailed"));return}const L=await o(e,{force:!0});Yv(E,Sc(L))&&(b(),U.success(t("settings.integrations.linear.toast.connected")),bd())})()},Qv)}catch(D){console.error("Failed to start Linear connect:",D),U.error(t("settings.integrations.linear.toast.startConnectFailed")),b()}finally{c(!1)}},[o,e,b,t]),v=l.useCallback(async E=>{if(!(!e||!E)){c(!0);try{const D=await e.authActivate(E);r(D),U.success(t("settings.integrations.linear.toast.workspaceSwitched"))}catch(D){console.error("Failed to switch Linear workspace:",D),U.error(t("settings.integrations.linear.toast.workspaceSwitchFailed"))}finally{c(!1)}}},[e,r,t]),k=l.useCallback(async()=>{if(e){c(!0);try{b(),await e.authDisconnect(),U.success(t("settings.integrations.linear.toast.disconnected")),await o(e,{force:!0})}catch(E){console.error("Failed to disconnect Linear:",E),U.error(t("settings.integrations.linear.toast.disconnectFailed"))}finally{c(!1)}}},[o,e,b,t]);if(!e)return null;const u=!!a?.connected,y=a?.user,S=a?.organization,w=(a?.workspaces??[]).filter(E=>!E.current),A=y?.displayName?.trim()||y?.name?.trim()||t("settings.integrations.linear.label.unknownUser"),x=g?t("settings.integrations.linear.status.waiting"):n&&!i?t("common.loading"):u?S?.name?.trim()||t("settings.integrations.linear.status.connected"):t("settings.integrations.linear.status.notConnected"),T=g?"bg-[var(--status-warning)]/15 text-[var(--status-warning)]":u?"bg-[var(--status-success)]/15 text-[var(--status-success)]":"bg-[var(--surface-muted)] text-muted-foreground",M=g||h;return s.jsx(bn,{open:M,onOpenChange:E=>{if(g){f(!0);return}f(E)},children:s.jsxs("div",{"data-settings-item":"integrations.linear",className:"overflow-hidden rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)]",children:[s.jsxs(vn,{className:"flex w-full min-w-0 items-center gap-3 px-4 py-3 text-left hover:bg-[var(--interactive-hover)]/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]",children:[s.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-[10px] bg-[var(--surface-muted)]",children:s.jsx($,{name:"linear",className:"size-5 text-foreground"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:t("settings.integrations.linear.title")}),s.jsx("p",{className:"mt-0.5 line-clamp-1 text-xs leading-snug text-muted-foreground",children:t("settings.integrations.linear.description")})]}),s.jsx("span",{"aria-live":"polite",className:Ne("max-w-36 shrink-0 truncate rounded-full px-2 py-0.5 text-[10px] font-medium",T),children:x}),s.jsx($,{name:"arrow-down-s",className:Ne("size-4 shrink-0 text-muted-foreground transition-transform duration-150 ease-out motion-reduce:transition-none",M&&"rotate-180")})]}),s.jsx(yn,{className:"border-t border-[var(--interactive-border)] px-4 py-4",children:s.jsxs("div",{className:"space-y-3",children:[u?s.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[y?.avatarUrl?s.jsx("img",{src:y.avatarUrl,alt:t("settings.integrations.linear.avatarAlt.withName",{name:A}),className:"size-10 shrink-0 rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)] object-cover",loading:"lazy",referrerPolicy:"no-referrer"}):s.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-full border border-[var(--interactive-border)] bg-[var(--surface-muted)]",children:s.jsx($,{name:"linear",className:"size-4 text-muted-foreground"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:A}),s.jsx("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:[S?.name,y?.email].filter(Boolean).join(" · ")})]})]}):g?s.jsx("p",{className:"text-xs text-muted-foreground",children:t("settings.integrations.linear.flow.description")}):null,u?s.jsxs(s.Fragment,{children:[s.jsx(Gv,{linear:e,connected:u,organizationId:S?.id??null}),s.jsx(Wv,{linear:e,connected:u}),w.length>0?s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"typography-micro text-muted-foreground",children:t("settings.integrations.linear.label.otherWorkspaces")}),s.jsx("div",{className:"space-y-1",children:w.map(E=>{const D=E.user,F=E.name?.trim()||t("settings.integrations.linear.status.connected");return s.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-[var(--surface-subtle)] bg-[var(--surface-muted)] px-3 py-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"truncate text-sm font-medium text-foreground",children:F}),D?.email?s.jsx("p",{className:"truncate text-xs text-muted-foreground",children:D.email}):null]}),s.jsx(V,{type:"button",size:"sm",variant:"ghost",onClick:()=>{v(E.id)},disabled:d,children:t("settings.integrations.linear.actions.switchTo")})]},E.id)})})]}):null,s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx(V,{type:"button",size:"sm",variant:"outline",onClick:()=>{C()},disabled:d||g,"data-settings-item":"integrations.linear.add-workspace",children:t("settings.integrations.linear.actions.addWorkspace")}),s.jsx(V,{type:"button",size:"sm",variant:"destructive",onClick:()=>{k()},disabled:d,children:t("settings.integrations.linear.actions.disconnect")})]})]}):g?s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:"typography-micro text-muted-foreground animate-pulse",children:t("settings.integrations.linear.flow.waiting")}),s.jsx(V,{type:"button",size:"sm",variant:"ghost",disabled:d,onClick:b,children:t("settings.common.actions.cancel")})]}):s.jsxs(V,{type:"button",size:"sm",variant:"default",onClick:()=>{C()},disabled:d||n&&!i,children:[d?s.jsx($,{name:"loader-4",className:"size-3.5 animate-spin"}):null,t("settings.integrations.linear.actions.connect")]})]})})]})})},sr=[{id:"opencode-claude",packageName:"@openchamber/opencode-claude",providerId:"claude-code",nameKey:"settings.integrations.thirdParty.opencodeClaude.name",descriptionKey:"settings.integrations.thirdParty.opencodeClaude.description",homepage:"https://github.com/openchamber/opencode-claude"}],Xv=(t,e)=>t===e||t.startsWith(`${e}@`);function nr(t,e,a){const n=t.filter(c=>Xv(c.spec,e)),i=n.filter(c=>c.scope==="user"),o=n.filter(c=>c.scope==="project"),r=i.length===1?i[0]:null,d=a[r?.spec??e]??a[e]??null;return{userEntry:r,userEntryIsAmbiguous:i.length>1,projectEntries:o,registry:d}}function Ar(t,e){return e?.kind!=="npm-ok"||e.name!==t||!e.latestVersion?null:`${t}@${e.latestVersion}`}function Cc(t,e){if(t.userEntryIsAmbiguous)return"manage";if(!t.userEntry)return"install";const a=Ar(e,t.registry);return a&&a!==t.userEntry.spec?"update":"setup"}function ey(t,e={}){const a=t.registry?.kind==="npm-ok"?t.registry.latestVersion:null;return t.userEntryIsAmbiguous?{status:"ambiguous",latestVersion:a}:e.restartRequired?{status:"restart-required",latestVersion:a}:e.providerUnavailable?{status:"provider-unavailable",latestVersion:a}:e.registryUnavailable?{status:"registry-unavailable",latestVersion:a}:t.userEntry?t.registry?.kind==="npm-ok"&&t.registry.currentVersion===t.registry.latestVersion?{status:"installed-version",latestVersion:a}:t.registry?.kind==="npm-ok"&&t.registry.currentVersion===null?{status:"unpinned",latestVersion:a}:t.registry?.kind==="npm-ok"&&a?{status:"update-available",latestVersion:a}:{status:"installed",latestVersion:a}:{status:"not-installed",latestVersion:a}}const ty={success:"bg-[var(--status-success)]/15 text-[var(--status-success)]",warning:"bg-[var(--status-warning)]/15 text-[var(--status-warning)]",neutral:"bg-[var(--surface-muted)] text-muted-foreground"},Vd=t=>{const e=Be.c(33),{settingsItem:a,logo:n,name:i,description:o,status:r,statusTone:d,open:c,onOpenChange:g,children:m}=t;let h;e[0]!==n?(h=s.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-[10px] bg-[var(--surface-muted)]",children:n}),e[0]=n,e[1]=h):h=e[1];let f;e[2]!==i?(f=s.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:i}),e[2]=i,e[3]=f):f=e[3];let p;e[4]!==o?(p=s.jsx("p",{className:"mt-0.5 line-clamp-1 text-xs leading-snug text-muted-foreground",children:o}),e[4]=o,e[5]=p):p=e[5];let b;e[6]!==f||e[7]!==p?(b=s.jsxs("div",{className:"min-w-0 flex-1",children:[f,p]}),e[6]=f,e[7]=p,e[8]=b):b=e[8];const C=ty[d];let v;e[9]!==C?(v=Ne("max-w-36 shrink-0 truncate rounded-full px-2 py-0.5 text-[10px] font-medium",C),e[9]=C,e[10]=v):v=e[10];let k;e[11]!==r||e[12]!==v?(k=s.jsx("span",{"aria-live":"polite",className:v,children:r}),e[11]=r,e[12]=v,e[13]=k):k=e[13];const u=c&&"rotate-180";let y;e[14]!==u?(y=Ne("size-4 shrink-0 text-muted-foreground transition-transform duration-150 ease-out motion-reduce:transition-none",u),e[14]=u,e[15]=y):y=e[15];let S;e[16]!==y?(S=s.jsx($,{name:"arrow-down-s",className:y}),e[16]=y,e[17]=S):S=e[17];let N;e[18]!==h||e[19]!==S||e[20]!==b||e[21]!==k?(N=s.jsxs(vn,{className:"flex w-full min-w-0 items-center gap-3 px-4 py-3 text-left hover:bg-[var(--interactive-hover)]/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]",children:[h,b,k,S]}),e[18]=h,e[19]=S,e[20]=b,e[21]=k,e[22]=N):N=e[22];let w;e[23]!==m?(w=s.jsx(yn,{className:"border-t border-[var(--interactive-border)] px-4 py-4",children:m}),e[23]=m,e[24]=w):w=e[24];let A;e[25]!==a||e[26]!==N||e[27]!==w?(A=s.jsxs("div",{"data-settings-item":a,className:"overflow-hidden rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)]",children:[N,w]}),e[25]=a,e[26]=N,e[27]=w,e[28]=A):A=e[28];let x;return e[29]!==g||e[30]!==c||e[31]!==A?(x=s.jsx(bn,{open:c,onOpenChange:g,children:A}),e[29]=g,e[30]=c,e[31]=A,e[32]=x):x=e[32],x},sy=t=>t.requiresManualRestart===!0||t.reloadFailed===!0,ny=({divider:t=!0})=>{const{t:e}=qe(),a=en(),n=l.useCallback(()=>{re.getState().requestSettingsJump("plugins")},[]),i=l.useCallback(async j=>{if(await ct.getState().loadProviders({directory:a,source:"settings:third-party-provider-setup"}),!sd(ct.getState(),a).some(H=>H.id===j))return!1;const K=re.getState();return K.setSettingsProvidersOpenRequested(j),K.requestSettingsJump("providers"),!0},[a]),{entries:o,registryInfo:r,loadPlugins:d,loadRegistryInfo:c,createEntry:g,updateEntry:m,deleteEntry:h}=zt(_s(j=>({entries:j.entries,registryInfo:j.registryInfo,loadPlugins:j.loadPlugins,loadRegistryInfo:j.loadRegistryInfo,createEntry:j.createEntry,updateEntry:j.updateEntry,deleteEntry:j.deleteEntry}))),[f,p]=l.useState(!1),[b,C]=l.useState(null),[v,k]=l.useState(()=>new Set),[u,y]=l.useState(()=>new Set),[S,N]=l.useState(null),[w,A]=l.useState(()=>new Set),x=l.useCallback(async()=>{if(!await d({force:!0})){p(!0);return}const O=zt.getState().entries,K=new Set(sr.map(q=>q.packageName));for(const q of O)sr.some(Z=>q.spec===Z.packageName||q.spec.startsWith(`${Z.packageName}@`))&&K.add(q.spec);const H=await c({specs:[...K],force:!0});p(!H)},[d,c]);l.useEffect(()=>{x()},[x]);const T=l.useCallback((j,O)=>{k(K=>{const H=new Set(K);return O?H.add(j):H.delete(j),H})},[]),M=l.useCallback((j,O)=>{y(K=>{const H=new Set(K);return O?H.add(j):H.delete(j),H})},[]),E=l.useCallback(async(j,O,K)=>{C({pluginId:j.id,action:O});try{const H=await K();if(!H.ok){U.error(e("settings.integrations.thirdParty.toast.actionFailed"));return}M(j.id,!1);const q=sy(H);T(j.id,q);const Z=q?{description:e("settings.integrations.thirdParty.toast.restartRequired")}:void 0;O==="install"?U.success(e("settings.integrations.thirdParty.toast.installed",{name:e(j.nameKey)}),Z):O==="update"?U.success(e("settings.integrations.thirdParty.toast.updated",{name:e(j.nameKey)}),Z):U.success(e("settings.integrations.thirdParty.toast.removed",{name:e(j.nameKey)}),Z),await x()}finally{C(null)}},[x,M,T,e]),D=l.useCallback(async j=>{const O=nr(o,j.packageName,r),K=Cc(O,j.packageName);if(K==="manage"){n();return}if(K==="setup"){C({pluginId:j.id,action:K});try{const q=await i(j.providerId);M(j.id,!q),q?T(j.id,!1):U.error(e("settings.integrations.thirdParty.toast.providerUnavailable"))}finally{C(null)}return}const H=Ar(j.packageName,O.registry);if(!H){p(!0);return}if(K==="install"){await E(j,"install",()=>g({spec:H,scope:"user"}));return}O.userEntry&&await E(j,"update",()=>m(O.userEntry.id,{spec:H}))},[g,o,n,i,r,E,M,T,e,m]),F=l.useCallback(async()=>{const j=S;if(!j)return;const O=nr(o,j.packageName,r);if(!O.userEntry||O.userEntryIsAmbiguous){N(null),n();return}N(null),await E(j,"remove",()=>h(O.userEntry.id))},[h,o,n,r,S,E]),L=l.useCallback((j,O)=>{A(K=>{const H=new Set(K);return O?H.add(j):H.delete(j),H})},[]),P=j=>{const O=nr(o,j.packageName,r),K=Cc(O,j.packageName),H=Ar(j.packageName,O.registry),q=b?.pluginId===j.id,Z=v.has(j.id),ae=u.has(j.id),B=f||O.registry?.kind==="npm-network",G=q||Z&&K!=="setup"||(K==="install"||K==="update")&&(B||!H),_=ey(O,{registryUnavailable:B,restartRequired:Z,providerUnavailable:ae});let z;switch(_.status){case"installed-version":z=_.latestVersion?e("settings.integrations.thirdParty.status.installedVersion",{version:_.latestVersion}):e("settings.integrations.thirdParty.status.installed");break;case"update-available":z=_.latestVersion?e("settings.integrations.thirdParty.status.updateAvailable",{version:_.latestVersion}):e("settings.integrations.thirdParty.status.unpinned");break;case"not-installed":z=e("settings.integrations.thirdParty.status.notInstalled");break;case"installed":z=e("settings.integrations.thirdParty.status.installed");break;case"unpinned":z=e("settings.integrations.thirdParty.status.unpinned");break;case"ambiguous":z=e("settings.integrations.thirdParty.status.ambiguous");break;case"restart-required":z=e("settings.integrations.thirdParty.status.restartRequired");break;case"registry-unavailable":z=e("settings.integrations.thirdParty.status.registryUnavailable");break;case"provider-unavailable":z=e("settings.integrations.thirdParty.status.providerUnavailable");break}const te=_.status==="installed-version"?"success":_.status==="update-available"||_.status==="ambiguous"||_.status==="restart-required"||_.status==="registry-unavailable"||_.status==="provider-unavailable"?"warning":"neutral",Q={install:e("settings.integrations.thirdParty.actions.install"),update:e("settings.integrations.thirdParty.actions.update"),setup:e("settings.integrations.thirdParty.actions.setup"),manage:e("settings.integrations.thirdParty.actions.managePlugins")}[K],X=w.has(j.id);return s.jsx(Vd,{settingsItem:`integrations.third-party.${j.id}`,logo:s.jsx($n,{providerId:j.providerId,alt:"",className:"size-5"}),name:e(j.nameKey),description:e(j.descriptionKey),status:z,statusTone:te,open:X,onOpenChange:pe=>L(j.id,pe),children:s.jsxs("div",{className:"space-y-3",children:[O.projectEntries.length>0?s.jsx("p",{className:"text-xs text-muted-foreground",children:e("settings.integrations.thirdParty.status.projectInstalled")}):null,s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(V,{type:"button",size:"sm",variant:K==="manage"?"outline":"default",onClick:()=>{D(j)},disabled:G,children:[q?s.jsx($,{name:"loader-4",className:"size-3.5 animate-spin"}):K==="setup"?s.jsx($,{name:"plug-2",className:"size-3.5"}):null,Q]}),s.jsxs(V,{type:"button",size:"sm",variant:"secondary",onClick:()=>{Gs(j.homepage)},children:[s.jsx($,{name:"external-link",className:"size-3.5"}),e("settings.integrations.thirdParty.actions.docs")]}),O.userEntry&&!O.userEntryIsAmbiguous?s.jsxs(V,{type:"button",size:"sm",variant:"destructive",onClick:()=>N(j),disabled:q,children:[s.jsx($,{name:"delete-bin",className:"size-3.5"}),e("settings.integrations.thirdParty.actions.remove")]}):null]})]})},j.id)};return s.jsxs(s.Fragment,{children:[s.jsx(He,{title:e("settings.integrations.thirdParty.title"),info:e("settings.integrations.thirdParty.info"),divider:t,settingsItem:"integrations.third-party",contentClassName:"space-y-3",children:sr.map(P)}),s.jsx(_t,{open:S!==null,onOpenChange:j=>!j&&N(null),children:s.jsxs($t,{className:"max-w-md",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:e("settings.integrations.thirdParty.dialog.remove.title")}),s.jsx(qt,{children:e("settings.integrations.thirdParty.dialog.remove.description",{name:S?e(S.nameKey):""})})]}),s.jsxs(as,{children:[s.jsx(V,{type:"button",size:"sm",variant:"ghost",onClick:()=>N(null),children:e("settings.common.actions.cancel")}),s.jsx(V,{type:"button",size:"sm",variant:"destructive",onClick:()=>{F()},children:e("settings.integrations.thirdParty.actions.remove")})]})]})})]})},Hd=t=>t==="invalid-path"?"settings.extensions.toast.invalidPath":t==="invalid-url"?"settings.extensions.toast.invalidUrl":t==="not-found"?"settings.extensions.toast.notFound":t==="invalid-manifest"?"settings.extensions.toast.invalidManifest":t==="reserved-id"?"settings.extensions.toast.reservedId":t==="id-taken"?"settings.extensions.toast.idTaken":t==="already-installed"?"settings.extensions.toast.alreadyInstalled":t==="missing-build"?"settings.extensions.toast.missingBuild":t==="host-too-old"?"settings.extensions.toast.hostTooOld":t==="clone-failed"?"settings.extensions.toast.cloneFailed":t==="extract-failed"?"settings.extensions.toast.extractFailed":t==="too-large"?"settings.extensions.toast.zipTooLarge":t==="enterprise-mode"?"settings.extensions.toast.enterpriseMode":"settings.extensions.toast.failed",qd=t=>t==="not-git"?"settings.extensions.toast.notGit":t==="enterprise-mode"?"settings.extensions.toast.enterpriseUpdate":t==="clone-failed"?"settings.extensions.toast.cloneFailed":t==="invalid-manifest"?"settings.extensions.toast.invalidManifest":t==="missing-build"?"settings.extensions.toast.missingBuild":t==="swap-failed"?"settings.extensions.toast.swapFailed":t==="not-found"?"settings.extensions.toast.notFound":"settings.extensions.toast.updateFailed",ay=Os({error:Gr(["invalid-path","invalid-url","not-found","invalid-manifest","id-taken","already-installed","missing-build","host-too-old","bundled","reserved-id","clone-failed","extract-failed","too-large","enterprise-mode"]),required:Rt().trim().min(1).max(64).optional(),id:Rt().trim().min(1).max(128).optional()}),iy=t=>{const e=t.trim();if(!e)return{ok:!1,code:"invalid-path"};if(e.slice(0,8).toLowerCase()==="https://")return{ok:!0,request:{url:e}};if(e.slice(0,6).toLowerCase()==="ssh://"||/^(?:[A-Za-z0-9_][A-Za-z0-9_.-]*@)?[A-Za-z0-9][A-Za-z0-9.-]*\.[A-Za-z0-9.-]+:[^\s]+$/.test(e))return{ok:!0,request:{url:e}};const a=/^[a-zA-Z]:[\\/]/.test(e);return/^[a-z][a-z0-9+.-]*:/i.test(e)&&!a?{ok:!1,code:"invalid-url"}:e.startsWith("/")||a||e.startsWith("\\\\")?{ok:!0,request:{path:e}}:{ok:!1,code:"invalid-path"}},Gd=async t=>{try{const e=ay.safeParse(JSON.parse(await t.text()));return e.success?e.data.error==="host-too-old"&&e.data.required&&e.data.id?{code:"host-too-old",required:e.data.required,id:e.data.id}:e.data.error==="host-too-old"&&e.data.required?{code:"host-too-old",required:e.data.required}:e.data.id?{code:e.data.error,id:e.data.id}:{code:e.data.error}:{code:"failed"}}catch{return{code:"failed"}}},Wd=async(t,e)=>{if(!t.ok)return{ok:!1,...await Gd(t),diagnostic:{method:"POST",path:e,kind:"http",status:t.status}};const a=await t.text().catch(()=>null),n=a===null?null:ld(a);return n?{ok:!0,guest:n,replaced:t.status===200}:{ok:!1,code:"failed",diagnostic:{method:"POST",path:e,kind:"invalid-response",status:t.status}}},Jd=async(t,e={})=>{const a=iy(t);if(!a.ok)return a;const n={...a.request};e.replace&&(n.replace=!0),"url"in n&&e.gitIdentityId&&(n.gitIdentityId=e.gitIdentityId);try{const i=await It("/api/guests",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(n)});return await Wd(i,"/api/guests")}catch{return{ok:!1,code:"failed",diagnostic:{method:"POST",path:"/api/guests",kind:"network"}}}},oy=async(t,e={})=>{try{const a=await It("/api/guests/upload",{method:"POST",query:{replace:e.replace?"true":void 0,name:t.name||void 0},headers:{"Content-Type":"application/octet-stream",Accept:"application/json"},body:t});return await Wd(a,"/api/guests/upload")}catch{return{ok:!1,code:"failed",diagnostic:{method:"POST",path:"/api/guests/upload",kind:"network"}}}},Qd=async t=>{try{const e=await It(`/api/guests/${t}`,{method:"DELETE"});return e.status===204?{ok:!0}:{ok:!1,code:(await Gd(e)).code}}catch{return{ok:!1,code:"failed"}}},Yd=async(t,e)=>{try{return(await It(`/api/guests/${t}/enabled`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:e})})).ok}catch{return!1}},ry=async(t,e)=>{try{return(await It(`/api/guests/${t}/capabilities`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({granted:e})})).ok}catch{return!1}},ly=Os({updates:Bn(Rt().min(1),Gu)}),cy=Os({error:Gr(["not-git","clone-failed","invalid-manifest","missing-build","host-too-old","swap-failed","not-found","enterprise-mode"]),required:Rt().trim().min(1).max(64).optional()}),Ic=async t=>{try{const e=await It("/api/guests/updates/check",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({force:t})});if(!e.ok)return{ok:!1};const a=ly.safeParse(JSON.parse(await e.text()));return a.success?{ok:!0,updates:a.data.updates}:{ok:!1}}catch{return{ok:!1}}},dy=async t=>{try{const e=cy.safeParse(JSON.parse(await t.text()));return e.success?e.data.required?{code:e.data.error,required:e.data.required}:{code:e.data.error}:{code:"failed"}}catch{return{code:"failed"}}},Zd=async t=>{try{const e=await It(`/api/guests/${t}/update`,{method:"POST",headers:{Accept:"application/json"}});if(!e.ok){const n=await dy(e);return n.required?{ok:!1,code:n.code,required:n.required}:{ok:!1,code:n.code}}const a=ld(await e.text());return a?{ok:!0,guest:a}:{ok:!1,code:"failed"}}catch{return{ok:!1,code:"failed"}}},uy={guestId:"excalidraw",gitUrl:"https://github.com/openchamber/openchamber-excalidraw",homepage:"https://github.com/openchamber/openchamber-excalidraw",nameKey:"settings.integrations.extensionCatalog.excalidraw.name",descriptionKey:"settings.integrations.extensionCatalog.excalidraw.description",logoFileName:"drawing.excalidraw"},my=[uy],py=(t,e)=>{const a=t.find(n=>n.id===e.guestId);return a?a.enterpriseBlocked?.length?{kind:"blocked",guest:a}:Za(a)?{kind:"needs-approval",guest:a}:a.enabled===!1?{kind:"paused",guest:a}:a.update?{kind:"update-available",guest:a,version:a.update.version}:{kind:"installed",guest:a}:{kind:"not-installed"}},gy=({divider:t=!0})=>{const{t:e}=qe(),a=Ks(u=>u.guests),n=Ks(u=>u.status),[i,o]=l.useState(null),[r,d]=l.useState(()=>new Set),[c,g]=l.useState(null);l.useEffect(()=>{gn()},[]);const m=l.useCallback(()=>{re.getState().requestSettingsJump("extensions")},[]),h=l.useCallback(async(u,y,S)=>{const N=ln();o({guestId:u.guestId,action:y});try{await S(),ln()===N&&await gn()}finally{o(null)}},[]),f=u=>h(u,"install",async()=>{const y=await Jd(u.gitUrl);if(!y.ok){U.error(y.code==="host-too-old"&&y.required?e("settings.extensions.toast.hostTooOld",{version:y.required}):e(Hd(y.code)));return}U.success(e("settings.integrations.thirdParty.toast.installed",{name:e(u.nameKey)})),Za(y.guest)&&m()}),p=u=>h(u,"update",async()=>{const y=await Zd(u.guestId);if(!y.ok){U.error(y.code==="host-too-old"&&y.required?e("settings.extensions.toast.hostTooOld",{version:y.required}):e(qd(y.code)));return}xi(u.guestId),U.success(e("settings.integrations.thirdParty.toast.updated",{name:e(u.nameKey)})),Za(y.guest)&&m()}),b=u=>h(u,"enable",async()=>{if(!await Yd(u.guestId,!0)){U.error(e("settings.integrations.extensionCatalog.toast.enableFailed",{name:e(u.nameKey)}));return}U.success(e("settings.integrations.extensionCatalog.toast.enabled",{name:e(u.nameKey)}))}),C=async()=>{const u=c;u&&(g(null),await h(u,"remove",async()=>{if(!(await Qd(u.guestId)).ok){U.error(e("settings.integrations.thirdParty.toast.actionFailed"));return}xi(u.guestId),U.success(e("settings.integrations.thirdParty.toast.removed",{name:e(u.nameKey)}))}))},v=u=>{switch(u.kind){case"not-installed":return{status:e("settings.integrations.thirdParty.status.notInstalled"),tone:"neutral"};case"blocked":return{status:e("settings.extensions.status.enterpriseBlocked"),tone:"warning"};case"needs-approval":return{status:e("settings.integrations.extensionCatalog.status.needsApproval"),tone:"warning"};case"paused":return{status:e("settings.integrations.extensionCatalog.status.paused"),tone:"neutral"};case"update-available":return{status:e("settings.integrations.thirdParty.status.updateAvailable",{version:u.version}),tone:"warning"};case"installed":return{status:u.guest.version?e("settings.integrations.thirdParty.status.installedVersion",{version:u.guest.version}):e("settings.integrations.thirdParty.status.installed"),tone:"success"}}},k=u=>{const y=py(a,u),S=n==="idle"||n==="loading",{status:N,tone:w}=S?{status:e("common.loading"),tone:"neutral"}:v(y),A=i?.guestId===u.guestId||S,x=r.has(u.guestId),T=s.jsx($,{name:"loader-4",className:"size-3.5 animate-spin"}),M=y.kind==="not-installed"?{label:e("settings.integrations.thirdParty.actions.install"),onClick:()=>{f(u)},variant:"default"}:y.kind==="update-available"?{label:e("settings.integrations.thirdParty.actions.update"),onClick:()=>{p(u)},variant:"default"}:y.kind==="paused"?{label:e("settings.integrations.extensionCatalog.actions.enable"),onClick:()=>{b(u)},variant:"default"}:y.kind==="needs-approval"||y.kind==="blocked"?{label:e("settings.integrations.extensionCatalog.actions.manage"),onClick:m,variant:"outline"}:null;return s.jsx(Vd,{settingsItem:`integrations.extensions.${u.guestId}`,logo:s.jsx(Wu,{filePath:u.logoFileName,className:"size-5"}),name:e(u.nameKey),description:e(u.descriptionKey),status:N,statusTone:w,open:x,onOpenChange:E=>d(D=>{const F=new Set(D);return E?F.add(u.guestId):F.delete(u.guestId),F}),children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[M?s.jsxs(V,{type:"button",size:"sm",variant:M.variant,onClick:M.onClick,disabled:A,children:[A?T:null,M.label]}):null,s.jsxs(V,{type:"button",size:"sm",variant:"secondary",onClick:()=>{Gs(u.homepage)},children:[s.jsx($,{name:"external-link",className:"size-3.5"}),e("settings.integrations.thirdParty.actions.docs")]}),y.kind!=="not-installed"?s.jsxs(V,{type:"button",size:"sm",variant:"destructive",onClick:()=>g(u),disabled:A,children:[s.jsx($,{name:"delete-bin",className:"size-3.5"}),e("settings.integrations.thirdParty.actions.remove")]}):null]})},u.guestId)};return n==="unsupported"?null:s.jsxs(s.Fragment,{children:[s.jsx(He,{title:e("settings.integrations.extensionCatalog.title"),info:e("settings.integrations.extensionCatalog.info"),divider:t,settingsItem:"integrations.extensions",contentClassName:"space-y-3",children:my.map(k)}),s.jsx(_t,{open:c!==null,onOpenChange:u=>!u&&g(null),children:s.jsxs($t,{className:"max-w-md",children:[s.jsxs(Vt,{children:[s.jsx(Ht,{children:e("settings.integrations.extensionCatalog.dialog.remove.title")}),s.jsx(qt,{children:e("settings.integrations.extensionCatalog.dialog.remove.description",{name:c?e(c.nameKey):""})})]}),s.jsxs(as,{children:[s.jsx(V,{type:"button",size:"sm",variant:"ghost",onClick:()=>g(null),children:e("settings.common.actions.cancel")}),s.jsx(V,{type:"button",size:"sm",variant:"destructive",onClick:()=>{C()},children:e("settings.integrations.thirdParty.actions.remove")})]})]})})]})},fy=()=>{const t=Be.c(25),{t:e}=qe();let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=ps(),t[0]=a):a=t[0];const n=!a,i=!!Wa()?.linear,o=Ks(hy),r=Ks(xy);let d,c,g,m,h,f;if(t[1]!==o||t[2]!==r||t[3]!==e){const k=!ps()&&!vd()?o.filter(by):[];c=n||i||k.length>0,d=ns,t[10]!==e?(g=e("settings.page.integrations.title"),t[10]=e,t[11]=g):g=t[11],t[12]!==e?(m=e("settings.page.integrations.description"),t[12]=e,t[13]=m):m=t[13],h=!0,f=c?s.jsxs(He,{title:e("settings.integrations.firstParty.title"),info:e("settings.integrations.firstParty.info"),divider:!1,settingsItem:"integrations.first-party",contentClassName:"space-y-3",children:[n?s.jsx(Bv,{}):null,i?s.jsx(Zv,{}):null,k.map(u=>s.jsx(Bd,{guest:u},`${r}:${u.id}`))]}):null,t[1]=o,t[2]=r,t[3]=e,t[4]=d,t[5]=c,t[6]=g,t[7]=m,t[8]=h,t[9]=f}else d=t[4],c=t[5],g=t[6],m=t[7],h=t[8],f=t[9];let p;t[14]!==c?(p=s.jsx(ny,{divider:c}),t[14]=c,t[15]=p):p=t[15];let b,C;t[16]===Symbol.for("react.memo_cache_sentinel")?(b=s.jsx(gy,{}),C=s.jsx(Fv,{}),t[16]=b,t[17]=C):(b=t[16],C=t[17]);let v;return t[18]!==d||t[19]!==g||t[20]!==m||t[21]!==h||t[22]!==f||t[23]!==p?(v=s.jsxs(d,{title:g,description:m,showSaveStatus:h,children:[f,p,b,C]}),t[18]=d,t[19]=g,t[20]=m,t[21]=h,t[22]=f,t[23]=p,t[24]=v):v=t[24],v};function hy(t){return t.guests}function xy(t){return t.runtimeKey}function by(t){return t.source==="bundled"&&t.integration&&_r(t)}const $a="__default__",vy=500,yy=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"").slice(0,64),jy=(t,e)=>{const a=Be.c(9),n=ct(Ny);let i;e:{if(!t||!e){let c;a[0]===Symbol.for("react.memo_cache_sentinel")?(c=[],a[0]=c):c=a[0],i=c;break e}let o;if(a[1]!==e||a[2]!==t||a[3]!==n){let c;a[5]!==t?(c=m=>m.id===t,a[5]=t,a[6]=c):c=a[6],o=n.find(c)?.models.find(m=>m.id===e),a[1]=e,a[2]=t,a[3]=n,a[4]=o}else o=a[4];const r=o;let d;a[7]!==r?(d=r?.variants?Object.keys(r.variants):[],a[7]=r,a[8]=d):d=a[8],i=d}return i},Xd=t=>{const e=Be.c(33),{providerID:a,modelID:n,value:i,onChange:o,ariaLabel:r,className:d}=t,{t:c}=qe(),g=jy(a,n);let m;e[0]!==c?(m=T=>T===$a?c("settings.routing.thinking.default"):T.charAt(0).toUpperCase()+T.slice(1),e[0]=c,e[1]=m):m=e[1];const h=m,f=i??$a;let p;e[2]!==o?(p=T=>o(T===$a?null:T),e[2]=o,e[3]=p):p=e[3];const b=g.length===0;let C;e[4]!==d?(C=Ne(fn,d),e[4]=d,e[5]=C):C=e[5];const v=i??$a;let k;e[6]!==h||e[7]!==v?(k=h(v),e[6]=h,e[7]=v,e[8]=k):k=e[8];let u;e[9]!==k?(u=s.jsx(Jt,{children:k}),e[9]=k,e[10]=u):u=e[10];let y;e[11]!==r||e[12]!==C||e[13]!==u?(y=s.jsx(Tt,{size:Qt,className:C,"aria-label":r,children:u}),e[11]=r,e[12]=C,e[13]=u,e[14]=y):y=e[14];let S;e[15]!==h?(S=h($a),e[15]=h,e[16]=S):S=e[16];let N;e[17]!==S?(N=s.jsx(gt,{value:$a,children:S}),e[17]=S,e[18]=N):N=e[18];let w;if(e[19]!==h||e[20]!==g){let T;e[22]!==h?(T=M=>s.jsx(gt,{value:M,children:h(M)},M),e[22]=h,e[23]=T):T=e[23],w=g.map(T),e[19]=h,e[20]=g,e[21]=w}else w=e[21];let A;e[24]!==N||e[25]!==w?(A=s.jsxs(Et,{children:[N,w]}),e[24]=N,e[25]=w,e[26]=A):A=e[26];let x;return e[27]!==A||e[28]!==f||e[29]!==p||e[30]!==b||e[31]!==y?(x=s.jsxs(Dt,{value:f,onValueChange:p,disabled:b,children:[y,A]}),e[27]=A,e[28]=f,e[29]=p,e[30]=b,e[31]=y,e[32]=x):x=e[32],x},ky=t=>{const e=Be.c(49),{category:a,expanded:n,onToggle:i,onChange:o,onReset:r,onRemove:d}=t,{t:c}=qe();let g;e[0]!==a.model||e[1]!==a.variant||e[2]!==c?(g=a.model?`${a.model.modelID}${a.variant?` / ${a.variant}`:""}`:c("settings.routing.model.useFallback"),e[0]=a.model,e[1]=a.variant,e[2]=c,e[3]=g):g=e[3];const m=g;let h;e[4]!==a.agent||e[5]!==m?(h=[m,a.agent].filter(Boolean),e[4]=a.agent,e[5]=m,e[6]=h):h=e[6];const f=h.join(" · "),p=!a.enabled&&"opacity-60";let b;e[7]!==p?(b=Ne("py-1",p),e[7]=p,e[8]=b):b=e[8];const C=n?"arrow-down-s":"arrow-right-s";let v;e[9]!==C?(v=s.jsx($,{name:C,className:"size-4 flex-shrink-0 text-muted-foreground"}),e[9]=C,e[10]=v):v=e[10];const k=a.name||a.id;let u;e[11]!==k?(u=s.jsx("span",{className:"typography-ui-label font-medium text-foreground truncate",children:k}),e[11]=k,e[12]=u):u=e[12];let y;e[13]!==f?(y=s.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:f}),e[13]=f,e[14]=y):y=e[14];let S;e[15]!==n||e[16]!==i||e[17]!==v||e[18]!==u||e[19]!==y?(S=s.jsxs("button",{type:"button",onClick:i,"aria-expanded":n,className:"flex min-w-0 flex-1 items-center gap-2 rounded-md px-1 py-1.5 text-left hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",children:[v,u,y]}),e[15]=n,e[16]=i,e[17]=v,e[18]=u,e[19]=y,e[20]=S):S=e[20];const N=a.enabled;let w;e[21]!==o?(w=D=>o({enabled:D}),e[21]=o,e[22]=w):w=e[22];let A;e[23]!==a.name||e[24]!==c?(A=c("settings.routing.category.enabledAria",{name:a.name}),e[23]=a.name,e[24]=c,e[25]=A):A=e[25];let x;e[26]!==a.enabled||e[27]!==w||e[28]!==A?(x=s.jsx(ga,{checked:N,onCheckedChange:w,"aria-label":A}),e[26]=a.enabled,e[27]=w,e[28]=A,e[29]=x):x=e[29];let T;e[30]!==S||e[31]!==x?(T=s.jsxs("div",{className:"flex items-center gap-2",children:[S,x]}),e[30]=S,e[31]=x,e[32]=T):T=e[32];let M;e[33]!==a.agent||e[34]!==a.description||e[35]!==a.model?.modelID||e[36]!==a.model?.providerID||e[37]!==a.name||e[38]!==a.variant||e[39]!==n||e[40]!==o||e[41]!==d||e[42]!==r||e[43]!==c?(M=n?s.jsxs("div",{className:"space-y-4 px-1 pb-4 pt-2",children:[s.jsxs(Fn,{children:[s.jsx(Kt,{label:c("settings.routing.category.name"),controlClassName:"max-w-none",children:s.jsx(Ge,{value:a.name,onChange:D=>o({name:D.target.value}),"aria-label":c("settings.routing.category.name"),className:"h-8 w-full rounded-md px-3",maxLength:60})}),s.jsx(Kt,{label:c("settings.routing.category.agent"),info:c("settings.routing.category.agentInfo"),controlClassName:"max-w-none",children:s.jsx(Lr,{agentName:a.agent??"",onChange:D=>o({agent:D||null}),filter:Sy,className:Ne(Zs,"w-full")})}),s.jsx(Kt,{label:c("settings.routing.category.model"),info:c("settings.routing.category.modelInfo"),controlClassName:"max-w-none",children:s.jsx(pa,{providerId:a.model?.providerID??"",modelId:a.model?.modelID??"",onChange:(D,F)=>o({model:{providerID:D,modelID:F},variant:null}),className:Ne(Zs,"w-full"),placeholder:c("settings.routing.model.useFallback")})}),s.jsx(Kt,{label:c("settings.routing.category.thinking"),controlClassName:"max-w-none",children:s.jsx(Xd,{providerID:a.model?.providerID,modelID:a.model?.modelID,value:a.variant,onChange:D=>o({variant:D}),ariaLabel:c("settings.routing.category.thinking"),className:"w-full"})})]}),s.jsx(Kt,{label:c("settings.routing.category.description"),info:c("settings.routing.category.descriptionInfo"),controlClassName:"max-w-none",children:s.jsx(Rs,{value:a.description,onChange:D=>o({description:D.target.value}),"aria-label":c("settings.routing.category.description"),rows:5,maxLength:2e3,className:"w-full"})}),s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[r?s.jsx(V,{size:"sm",variant:"outline",onClick:r,children:c("settings.routing.category.reset")}):null,s.jsx(V,{size:"sm",variant:"ghost",onClick:d,children:c("settings.routing.category.remove")})]})]}):null,e[33]=a.agent,e[34]=a.description,e[35]=a.model?.modelID,e[36]=a.model?.providerID,e[37]=a.name,e[38]=a.variant,e[39]=n,e[40]=o,e[41]=d,e[42]=r,e[43]=c,e[44]=M):M=e[44];let E;return e[45]!==T||e[46]!==M||e[47]!==b?(E=s.jsxs("div",{className:b,children:[T,M]}),e[45]=T,e[46]=M,e[47]=b,e[48]=E):E=e[48],E},wy=()=>{const{t}=qe(),e=es(j=>j.available),a=es(j=>j.autoReady),n=es(j=>j.config),i=es(j=>j.builtins),o=es(j=>j.loaded),r=es(j=>j.loadError),d=es(j=>j.load),c=es(j=>j.saveConfig),[g,m]=l.useState(n),[h,f]=l.useState(""),[p,b]=l.useState(null),C=l.useRef(null),v=l.useRef(null),k=l.useRef(Promise.resolve()),u=l.useRef(0);l.useEffect(()=>{d()},[d]),l.useEffect(()=>{!C.current&&u.current===0&&m(n)},[n]);const y=l.useCallback(()=>{const j=C.current;if(!j||(C.current=null,j.runtimeKey!==ln()))return k.current;u.current+=1,os("saving");const O=k.current.then(async()=>{try{if(j.runtimeKey!==ln()){os("saved");return}await c(j.config),os("saved")}catch{os("error")}finally{u.current-=1}});return k.current=O,O},[c]);l.useEffect(()=>()=>{v.current&&clearTimeout(v.current),y()},[y]);const S=ct(j=>j.settingsDefaultModel),N=ct(j=>j.settingsDefaultVariant),w=l.useRef(!1);l.useEffect(()=>{if(w.current||!o||!n||n.fallback)return;const j=_n(S);!j||yd(j.providerId,j.modelId)||(w.current=!0,A(O=>O.fallback?O:{...O,fallback:{model:{providerID:j.providerId,modelID:j.modelId},variant:N??null}}))},[o,n,S,N]);const A=l.useCallback(j=>{m(O=>{if(!O)return O;const K=j(O);return C.current={config:K,runtimeKey:ln()},v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{v.current=null,y()},vy),K})},[y]),x=l.useCallback((j,O)=>{A(K=>({...K,categories:K.categories.map(H=>H.id===j?{...H,...O}:H)}))},[A]),T=()=>{const j=h.trim();if(!j||!g)return;const O=yy(j)||`category-${Date.now()}`;let K=O,H=2;for(;g.categories.some(q=>q.id===K);)K=`${O}-${H++}`;A(q=>({...q,categories:[...q.categories,{id:K,builtin:!1,enabled:!0,name:j,description:"",model:null,variant:null,agent:null}]})),f(""),b(K)},M=j=>{const O=i.find(K=>K.id===j);O&&x(j,{name:O.name,description:O.description,model:null,variant:null,agent:null,enabled:!0})},E=j=>{const O=i.find(K=>K.id===j);O&&A(K=>({...K,categories:[...K.categories,{id:j,builtin:!0,enabled:!0,name:O.name,description:O.description,model:null,variant:null,agent:null}]}))},D=j=>{A(O=>({...O,categories:O.categories.filter(K=>K.id!==j)}))},F=g?.categories.filter(j=>j.enabled).length??0,L=i.filter(j=>!g?.categories.some(O=>O.id===j.id)),P=g?.enabled?g.fallback?F<2?t("settings.routing.status.tooFewCategories"):t(a?"settings.routing.status.ready":"settings.routing.status.notReady"):t("settings.routing.status.noFallback"):t("settings.routing.status.disabled");return s.jsxs(ns,{title:t("settings.page.routing.title"),description:t("settings.page.routing.description"),showSaveStatus:!0,children:[r?s.jsx("p",{className:Pn,children:t("settings.routing.loadError",{error:r})}):null,!o||!g?null:e?s.jsxs(s.Fragment,{children:[s.jsx(He,{title:t("settings.routing.auto.title"),divider:!1,children:s.jsxs("div",{className:Ms,children:[s.jsx(xo,{}),s.jsx("div",{className:ys,children:s.jsx(bt,{settingsItem:"routing.enabled",checked:g.enabled,onChange:j=>A(O=>({...O,enabled:j})),label:t("settings.routing.auto.enable"),ariaLabel:t("settings.routing.auto.enable"),info:t("settings.routing.auto.enableInfo")})}),s.jsx("p",{className:ds,children:P}),s.jsx(Ct,{settingsItem:"routing.fallback-model",label:t("settings.routing.auto.fallbackModel"),info:t("settings.routing.auto.fallbackModelInfo"),children:s.jsx(pa,{providerId:g.fallback?.model.providerID??"",modelId:g.fallback?.model.modelID??"",onChange:(j,O)=>A(K=>({...K,fallback:{model:{providerID:j,modelID:O},variant:null}})),className:Zs,placeholder:t("settings.routing.model.placeholder")})}),s.jsx(Ct,{settingsItem:"routing.fallback-thinking",label:t("settings.routing.auto.fallbackThinking"),info:t("settings.routing.auto.fallbackThinkingInfo"),children:s.jsx(Xd,{providerID:g.fallback?.model.providerID,modelID:g.fallback?.model.modelID,value:g.fallback?.variant??null,onChange:j=>A(O=>O.fallback?{...O,fallback:{...O.fallback,variant:j}}:O),ariaLabel:t("settings.routing.auto.fallbackThinking")})})]})}),s.jsx(He,{title:t("settings.routing.categories.title"),children:s.jsxs("div",{className:Ms,children:[s.jsx("p",{className:ds,children:t("settings.routing.categories.description")}),s.jsx("div",{className:"divide-y divide-border/40 border-y border-border/40",children:g.categories.map(j=>s.jsx(ky,{category:j,expanded:p===j.id,onToggle:()=>b(O=>O===j.id?null:j.id),onChange:O=>x(j.id,O),onReset:j.builtin?()=>M(j.id):null,onRemove:()=>D(j.id)},j.id))}),L.length>0?s.jsx("div",{className:"flex flex-wrap items-center gap-2",children:L.map(j=>s.jsx(V,{size:"sm",variant:"outline",onClick:()=>E(j.id),children:t("settings.routing.category.restore",{name:j.name})},j.id))}):null,s.jsx(Ct,{label:t("settings.routing.categories.addLabel"),settingsItem:"routing.add-category",children:s.jsxs("div",{className:"flex w-full min-w-0 items-center gap-2",children:[s.jsx(Ge,{value:h,onChange:j=>f(j.target.value),onKeyDown:j=>{j.key==="Enter"&&T()},placeholder:t("settings.routing.categories.addPlaceholder"),"aria-label":t("settings.routing.categories.addLabel"),className:"h-8 rounded-md px-3 min-w-0 flex-1",maxLength:60}),s.jsx(V,{size:"sm",variant:"outline",onClick:T,disabled:h.trim().length===0,children:t("settings.routing.categories.add")})]})})]})})]}):s.jsx("p",{className:Pn,children:t("settings.routing.unavailable")})]})};function Ny(t){return t.providers}function Sy(t){return cd(t.mode)}const Cy={prompt:{icon:"chat-1",titleKey:"settings.extensions.capability.prompt",detailKey:"settings.extensions.capability.prompt.detail"},sessions:{icon:"git-branch",titleKey:"settings.extensions.capability.sessions",detailKey:"settings.extensions.capability.sessions.detail"},files:{icon:"file-text",titleKey:"settings.extensions.capability.files",detailKey:"settings.extensions.capability.files.detail"},model:{icon:"sparkling",titleKey:"settings.extensions.capability.model",detailKey:"settings.extensions.capability.model.detail"},conversation:{icon:"chat-history",titleKey:"settings.extensions.capability.conversation",detailKey:"settings.extensions.capability.conversation.detail"},filesystem:{icon:"hard-drive-2",titleKey:"settings.extensions.capability.filesystem",detailKey:"settings.extensions.capability.filesystem.detail"},service:{icon:"terminal",titleKey:"settings.extensions.capability.service",detailKey:"settings.extensions.capability.service.detail"},network:{icon:"plug",titleKey:"settings.extensions.capability.network",detailKey:"settings.extensions.capability.network.detail"},origins:{icon:"global",titleKey:"settings.extensions.capability.origins",detailKey:"settings.extensions.capability.origins.detail"}},Iy=t=>{const e=Be.c(77),{guest:a,busy:n,onApprove:i,onDecline:o,onDismiss:r}=t,{t:d}=qe();let c;e[0]!==a?.capabilities.requested?(c=a?.capabilities.requested??[],e[0]=a?.capabilities.requested,e[1]=c):c=e[1];const g=c;let m;e[2]!==a?.filesystem?(m=a?.filesystem??[],e[2]=a?.filesystem,e[3]=m):m=e[3];const h=m;let f;e[4]!==a?.origins?(f=a?.origins??[],e[4]=a?.origins,e[5]=f):f=e[5];const p=f;let b;e[6]!==a?.service?.permissions?.exec?(b=a?.service?.permissions?.exec??[],e[6]=a?.service?.permissions?.exec,e[7]=b):b=e[7];const C=b;let v;e[8]!==a?.service?.permissions?.sockets?(v=a?.service?.permissions?.sockets??[],e[8]=a?.service?.permissions?.sockets,e[9]=v):v=e[9];const k=v,u=a?.service;let y;e[10]!==u?(y=dd(u,"browser"),e[10]=u,e[11]=y):y=e[11];const S=y,N=a?.integration?.apiOrigin??null,w=a!==null;let A;e[12]!==n||e[13]!==r?(A=te=>{!te&&!n&&r()},e[12]=n,e[13]=r,e[14]=A):A=e[14];const x=a?.name??"";let T;e[15]!==d||e[16]!==x?(T=d("settings.extensions.dialog.approveTitle",{name:x}),e[15]=d,e[16]=x,e[17]=T):T=e[17];let M;e[18]!==T?(M=s.jsx(Ht,{children:T}),e[18]=T,e[19]=M):M=e[19];const E=a?.name??"",D=a?.version?`v${a.version}`:"";let F;e[20]!==d||e[21]!==E||e[22]!==D?(F=d("settings.extensions.dialog.approveDescription",{name:E,version:D}),e[20]=d,e[21]=E,e[22]=D,e[23]=F):F=e[23];let L;e[24]!==F?(L=s.jsx(qt,{children:F}),e[24]=F,e[25]=L):L=e[25];let P;e[26]!==M||e[27]!==L?(P=s.jsxs(Vt,{children:[M,L]}),e[26]=M,e[27]=L,e[28]=P):P=e[28];let j;if(e[29]!==N||e[30]!==h||e[31]!==p||e[32]!==S||e[33]!==g||e[34]!==C||e[35]!==k||e[36]!==d){let te;e[38]!==N||e[39]!==h||e[40]!==p||e[41]!==S||e[42]!==C||e[43]!==k||e[44]!==d?(te=Q=>{const X=Cy[Q];return s.jsxs("li",{className:"flex items-start gap-3",children:[s.jsx("div",{className:"mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-md bg-[var(--surface-muted)]",children:s.jsx($,{name:X.icon,className:"size-4 text-foreground"})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-foreground",children:d(X.titleKey)}),s.jsx("p",{className:"typography-meta text-muted-foreground",children:d(X.detailKey)}),Q==="filesystem"&&h.length>0?s.jsx("ul",{className:"mt-1 space-y-0.5",children:h.map(Py)}):null,Q==="origins"&&p.length>0?s.jsx("ul",{className:"mt-1 space-y-0.5",children:p.map(Ay)}):null,Q==="network"&&N?s.jsxs("p",{className:"typography-meta mt-1 text-foreground",children:[d("settings.extensions.capability.service.sockets")," ",s.jsx("span",{className:"break-all font-mono",children:N})]}):null,Q==="service"&&C.length>0?s.jsxs("p",{className:"typography-meta mt-1 text-foreground",children:[d("settings.extensions.capability.service.runs")," ",s.jsx("span",{className:"break-all font-mono",children:C.join(", ")})]}):null,Q==="service"&&k.length>0?s.jsxs("p",{className:"typography-meta mt-0.5 text-foreground",children:[d("settings.extensions.capability.service.sockets")," ",s.jsx("span",{className:"break-all font-mono",children:k.join(", ")})]}):null,Q==="service"&&S?s.jsx("p",{className:"typography-meta mt-0.5 text-foreground",children:d("settings.extensions.capability.service.providesBrowser")}):null]})]},Q)},e[38]=N,e[39]=h,e[40]=p,e[41]=S,e[42]=C,e[43]=k,e[44]=d,e[45]=te):te=e[45],j=g.map(te),e[29]=N,e[30]=h,e[31]=p,e[32]=S,e[33]=g,e[34]=C,e[35]=k,e[36]=d,e[37]=j}else j=e[37];let O;e[46]!==j?(O=s.jsx("ul",{className:"space-y-3",children:j}),e[46]=j,e[47]=O):O=e[47];let K;e[48]!==a||e[49]!==o?(K=()=>a&&o(a),e[48]=a,e[49]=o,e[50]=K):K=e[50];let H;e[51]!==d?(H=d("settings.extensions.dialog.decline"),e[51]=d,e[52]=H):H=e[52];let q;e[53]!==n||e[54]!==K||e[55]!==H?(q=s.jsx(V,{size:"sm",variant:"ghost",disabled:n,onClick:K,children:H}),e[53]=n,e[54]=K,e[55]=H,e[56]=q):q=e[56];let Z;e[57]!==a||e[58]!==i?(Z=()=>a&&i(a),e[57]=a,e[58]=i,e[59]=Z):Z=e[59];let ae;e[60]!==d?(ae=d("settings.extensions.dialog.approve"),e[60]=d,e[61]=ae):ae=e[61];let B;e[62]!==n||e[63]!==Z||e[64]!==ae?(B=s.jsx(V,{size:"sm",disabled:n,onClick:Z,children:ae}),e[62]=n,e[63]=Z,e[64]=ae,e[65]=B):B=e[65];let G;e[66]!==q||e[67]!==B?(G=s.jsxs(as,{children:[q,B]}),e[66]=q,e[67]=B,e[68]=G):G=e[68];let _;e[69]!==P||e[70]!==O||e[71]!==G?(_=s.jsxs($t,{className:"max-w-md",children:[P,O,G]}),e[69]=P,e[70]=O,e[71]=G,e[72]=_):_=e[72];let z;return e[73]!==_||e[74]!==w||e[75]!==A?(z=s.jsx(_t,{open:w,onOpenChange:A,children:_}),e[73]=_,e[74]=w,e[75]=A,e[76]=z):z=e[76],z};function Py(t){return s.jsx("li",{className:"typography-meta break-all font-mono text-foreground",children:t},t)}function Ay(t){return s.jsx("li",{className:"typography-meta break-all font-mono text-foreground",children:t},t)}const Ty=t=>{if(t.source!=="git"||!t.origin?.url)return null;const e=t.origin.url.trim(),a=/^(?:[A-Za-z0-9_][A-Za-z0-9_.-]*@)?([A-Za-z0-9][A-Za-z0-9.-]*\.[A-Za-z0-9.-]+):([^\s]+)$/.exec(e);try{const n=new URL(a?`ssh://${a[1]}/${a[2]}`:e);if(n.protocol!=="https:"&&n.protocol!=="ssh:")return null;const i=n.protocol==="ssh:"?new URL(`https://${n.hostname}${n.pathname}`):n;return i.username="",i.password="",i.search="",i.hash="",i.pathname=i.pathname.replace(/\/+$/,"").replace(/\.git$/i,""),i.pathname==="/"?null:i.href}catch{return null}},ar=(t,e)=>{const a=`${t.method} ${t.path}`;return t.kind==="network"?`${a}: ${e("settings.extensions.request.noResponse")}`:t.kind==="invalid-response"?`${a}: ${e("settings.extensions.request.invalidResponse",{status:t.status})}`:`${a}: HTTP ${t.status}`},Pc=t=>t.name.toLowerCase().endsWith(".zip"),Ey=t=>t==="path"?"settings.extensions.source.path":t==="zip"?"settings.extensions.source.zip":t==="git"?"settings.extensions.source.git":"settings.extensions.source.bundled",Dy=t=>{const e=(t.service?.socketBindings??[]).map(i=>i.resolved?`${i.id}=${i.resolved}`:`${i.id}?`),a=(t.service?.permissions?.sockets??[]).filter(i=>!(t.service?.socketBindings??[]).some(o=>o.id===i));return[...e,...a,...t.service?.permissions?.exec??[]].join(", ")},My=t=>{const e=Be.c(27),{guest:a,binding:n,busy:i,onSaved:o}=t,{t:r}=qe(),[d,c]=l.useState(n.override??n.resolved??""),[g,m]=l.useState(!1),[h,f]=l.useState(!n.resolved);let p;e[0]!==n.override||e[1]!==n.resolved?(p=()=>{c(n.override??n.resolved??""),n.resolved||f(!0)},e[0]=n.override,e[1]=n.resolved,e[2]=p):p=e[2];let b;e[3]!==n.id||e[4]!==n.override||e[5]!==n.resolved?(b=[n.id,n.override,n.resolved],e[3]=n.id,e[4]=n.override,e[5]=n.resolved,e[6]=b):b=e[6],l.useEffect(p,b);let C;e[7]!==n.id||e[8]!==a.id||e[9]!==a.name||e[10]!==o||e[11]!==r?(C=async S=>{m(!0);const N=await Op(a.id,n.id,S);if(m(!1),!N){U.error(r("settings.extensions.toast.socketSaveFailed"));return}U.success(r("settings.extensions.toast.socketSaved",{name:a.name})),f(!1),await o()},e[7]=n.id,e[8]=a.id,e[9]=a.name,e[10]=o,e[11]=r,e[12]=C):C=e[12];const v=C;let k;e[13]!==n.override||e[14]!==n.resolved?(k=()=>{c(n.override??n.resolved??""),n.resolved&&f(!1)},e[13]=n.override,e[14]=n.resolved,e[15]=k):k=e[15];const u=k;let y;return e[16]!==n.id||e[17]!==n.override||e[18]!==n.resolved||e[19]!==i||e[20]!==u||e[21]!==h||e[22]!==v||e[23]!==g||e[24]!==r||e[25]!==d?(y=s.jsx("div",{className:"space-y-1",children:h?s.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[s.jsx(Ge,{value:d,onChange:S=>c(S.target.value),placeholder:r("settings.extensions.service.socket.path",{id:n.id}),"aria-label":r("settings.extensions.service.socket.path.aria",{id:n.id}),className:"h-8 min-w-0 flex-1 rounded-md px-3",disabled:i||g,autoFocus:!0}),s.jsx(V,{type:"button",variant:"ghost",size:"xs",disabled:i||g,"aria-label":r("settings.extensions.service.socket.save.aria",{id:n.id}),onClick:()=>{v(d.trim()||null)},children:r("settings.extensions.service.socket.save")}),n.override?s.jsx(V,{type:"button",variant:"ghost",size:"xs",disabled:i||g,"aria-label":r("settings.extensions.service.socket.clear.aria",{id:n.id}),onClick:()=>{v(null)},children:r("settings.extensions.service.socket.clear")}):null,n.resolved?s.jsx(V,{type:"button",variant:"ghost",size:"xs",disabled:i||g,"aria-label":r("settings.extensions.service.socket.cancel.aria",{id:n.id}),onClick:u,children:r("settings.extensions.service.socket.cancel")}):null]}):s.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[s.jsx("div",{className:"typography-meta min-w-0 flex-1 truncate text-muted-foreground",children:n.resolved?r("settings.extensions.service.socket.resolved",{path:n.resolved}):r("settings.extensions.service.socket.unresolved")}),s.jsx(V,{type:"button",variant:"ghost",size:"icon",className:hs,disabled:i||g,"aria-label":r("settings.extensions.service.socket.edit.aria",{id:n.id}),onClick:()=>f(!0),children:s.jsx($,{name:"pencil",className:"h-3.5 w-3.5"})})]})}),e[16]=n.id,e[17]=n.override,e[18]=n.resolved,e[19]=i,e[20]=u,e[21]=h,e[22]=v,e[23]=g,e[24]=r,e[25]=d,e[26]=y):y=e[26],y},Ry=t=>{const e=Be.c(151),{guest:a,busy:n,onReview:i,onRemove:o,onSetEnabled:r,onUpdate:d}=t,{t:c}=qe(),[g,m]=l.useState(!1),h=a.enabled!==!1,f=(a.enterpriseBlocked?.length??0)>0;let p;e[0]!==f||e[1]!==a?(p=!f&&Za(a),e[0]=f,e[1]=a,e[2]=p):p=e[2];const b=p;let C,v,k,u,y,S,N,w,A,x,T,M,E,D,F;if(e[3]!==h||e[4]!==f||e[5]!==a||e[6]!==b||e[7]!==g||e[8]!==c){const z=Dy(a);k=!!(a.source&&a.source!=="bundled");const te=a.source==="bundled";let Q;e[24]!==a?(Q=Ty(a),e[24]=a,e[25]=Q):Q=e[25],u=Q,F=a.source==="git"?a.update:void 0;let X;e[26]!==a.icon||e[27]!==a.id?(X=id(a.id,a.icon,xd().authenticatedAsset),e[26]=a.icon,e[27]=a.id,e[28]=X):X=e[28];const pe=X;let je;e[29]!==te||e[30]!==a.source||e[31]!==c?(je=te?null:c(Ey(a.source)),e[29]=te,e[30]=a.source,e[31]=c,e[32]=je):je=e[32];const fe=a.version?`v${a.version}`:null;let ke;e[33]!==a.entry||e[34]!==c?(ke=a.entry?null:c("settings.extensions.source.noPanel"),e[33]=a.entry,e[34]=c,e[35]=ke):ke=e[35];let be;e[36]!==je||e[37]!==fe||e[38]!==ke?(be=[je,fe,ke].filter(Boolean),e[36]=je,e[37]=fe,e[38]=ke,e[39]=be):be=e[39];const De=be.join(" · "),oe=a.path||a.id;let ee;e[40]!==h||e[41]!==f||e[42]!==b||e[43]!==c?(ee=c(f?"settings.extensions.status.enterpriseBlocked":b?"settings.extensions.status.needsApproval":h?"settings.extensions.status.enabled":"settings.extensions.status.disabled"),e[40]=h,e[41]=f,e[42]=b,e[43]=c,e[44]=ee):ee=e[44];const ce=ee,ue=f||b?"bg-[var(--status-warning)]/15 text-[var(--status-warning)]":h?"bg-[var(--status-success)]/15 text-[var(--status-success)]":"bg-[var(--surface-muted)] text-muted-foreground";v=bn,y=g,S=m,E="overflow-hidden rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)]";let Ie;e[45]!==a.icon?(Ie=rd(a.icon),e[45]=a.icon,e[46]=Ie):Ie=e[46];let ve;e[47]!==pe||e[48]!==Ie?(ve=s.jsx("div",{className:"flex size-10 shrink-0 items-center justify-center rounded-[10px] bg-[var(--surface-muted)]",children:s.jsx(od,{icon:Ie,iconSrc:pe,className:"size-5 text-foreground"})}),e[47]=pe,e[48]=Ie,e[49]=ve):ve=e[49];let Re;e[50]!==a.name?(Re=s.jsx("div",{className:"truncate text-sm font-semibold text-foreground",children:a.name}),e[50]=a.name,e[51]=Re):Re=e[51];let Me;e[52]!==De?(Me=s.jsx("p",{className:"mt-0.5 truncate text-xs leading-snug text-muted-foreground",children:De}),e[52]=De,e[53]=Me):Me=e[53];let me;e[54]!==Re||e[55]!==Me?(me=s.jsxs("div",{className:"min-w-0 flex-1",children:[Re,Me]}),e[54]=Re,e[55]=Me,e[56]=me):me=e[56];let Te;e[57]!==te||e[58]!==c?(Te=te?s.jsx("span",{className:"shrink-0 rounded-full border border-[var(--interactive-border)] px-2 py-0.5 text-[10px] font-medium text-muted-foreground",children:c("settings.extensions.source.bundled")}):null,e[57]=te,e[58]=c,e[59]=Te):Te=e[59];let Oe;e[60]!==c||e[61]!==F?(Oe=F?s.jsx("span",{className:"max-w-40 shrink-0 truncate rounded-full bg-[var(--status-info)]/15 px-2 py-0.5 text-[10px] font-medium text-[var(--status-info)]",children:c("settings.extensions.update.badge",{version:F.version})}):null,e[60]=c,e[61]=F,e[62]=Oe):Oe=e[62];let ge;e[63]!==ue?(ge=Ne("max-w-36 shrink-0 truncate rounded-full px-2 py-0.5 text-[10px] font-medium",ue),e[63]=ue,e[64]=ge):ge=e[64];let xe;e[65]!==ce||e[66]!==ge?(xe=s.jsx("span",{"aria-live":"polite",className:ge,children:ce}),e[65]=ce,e[66]=ge,e[67]=xe):xe=e[67];const ne=g&&"rotate-180";let ie;e[68]!==ne?(ie=Ne("size-4 shrink-0 text-muted-foreground transition-transform duration-150 ease-out motion-reduce:transition-none",ne),e[68]=ne,e[69]=ie):ie=e[69];let he;e[70]!==ie?(he=s.jsx($,{name:"arrow-down-s",className:ie}),e[70]=ie,e[71]=he):he=e[71],e[72]!==ve||e[73]!==me||e[74]!==Te||e[75]!==Oe||e[76]!==xe||e[77]!==he?(D=s.jsxs(vn,{className:"flex w-full min-w-0 items-center gap-3 px-4 py-3 text-left hover:bg-[var(--interactive-hover)]/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]",children:[ve,me,Te,Oe,xe,he]}),e[72]=ve,e[73]=me,e[74]=Te,e[75]=Oe,e[76]=xe,e[77]=he,e[78]=D):D=e[78],C=yn,M="border-t border-[var(--interactive-border)] px-4 py-4",N="space-y-3",e[79]!==oe?(w=s.jsx("p",{className:"typography-meta truncate font-mono text-muted-foreground",title:oe,children:oe}),e[79]=oe,e[80]=w):w=e[80],e[81]!==f||e[82]!==c?(A=f?s.jsx("p",{className:"typography-meta text-foreground",children:c("settings.extensions.enterpriseBlocked")}):null,e[81]=f,e[82]=c,e[83]=A):A=e[83],e[84]!==te||e[85]!==c?(x=te?s.jsx("p",{className:"typography-meta text-muted-foreground",children:c("settings.extensions.builtIn.info")}):null,e[84]=te,e[85]=c,e[86]=x):x=e[86],T=z?s.jsx("p",{className:"typography-meta truncate text-muted-foreground",children:c("settings.extensions.service.permissions",{list:z})}):null,e[3]=h,e[4]=f,e[5]=a,e[6]=b,e[7]=g,e[8]=c,e[9]=C,e[10]=v,e[11]=k,e[12]=u,e[13]=y,e[14]=S,e[15]=N,e[16]=w,e[17]=A,e[18]=x,e[19]=T,e[20]=M,e[21]=E,e[22]=D,e[23]=F}else C=e[9],v=e[10],k=e[11],u=e[12],y=e[13],S=e[14],N=e[15],w=e[16],A=e[17],x=e[18],T=e[19],M=e[20],E=e[21],D=e[22],F=e[23];let L;e[87]!==a.service||e[88]!==c?(L=a.service?s.jsx("p",{className:"typography-meta text-muted-foreground",children:c("settings.extensions.service.warning")}):null,e[87]=a.service,e[88]=c,e[89]=L):L=e[89];let P;e[90]!==n||e[91]!==h||e[92]!==a?(P=h?(a.service?.socketBindings??[]).map(z=>s.jsx(My,{guest:a,binding:z,busy:n,onSaved:gn},z.id)):null,e[90]=n,e[91]=h,e[92]=a,e[93]=P):P=e[93];let j;e[94]!==n||e[95]!==a||e[96]!==d||e[97]!==c||e[98]!==F?(j=F?s.jsx(V,{type:"button",size:"sm",disabled:n,"aria-label":c("settings.extensions.update.action.aria",{name:a.name,version:F.version}),onClick:()=>{d(a)},children:c("settings.extensions.update.action")}):null,e[94]=n,e[95]=a,e[96]=d,e[97]=c,e[98]=F,e[99]=j):j=e[99];let O;e[100]!==n||e[101]!==a||e[102]!==b||e[103]!==i||e[104]!==c?(O=b?s.jsx(V,{type:"button",size:"sm",disabled:n,"aria-label":c("settings.extensions.review.aria",{name:a.name}),onClick:()=>i(a),children:c("settings.extensions.review")}):null,e[100]=n,e[101]=a,e[102]=b,e[103]=i,e[104]=c,e[105]=O):O=e[105];let K;e[106]!==n||e[107]!==h||e[108]!==a.id||e[109]!==a.name||e[110]!==r||e[111]!==c?(K=h?s.jsx(V,{type:"button",size:"sm",variant:"outline",disabled:n,"aria-label":c("settings.extensions.actions.disable.aria",{name:a.name}),onClick:()=>{r(a.id,a.name,!1)},children:c("settings.extensions.actions.disable")}):s.jsx(V,{type:"button",size:"sm",disabled:n,"aria-label":c("settings.extensions.actions.enable.aria",{name:a.name}),onClick:()=>{r(a.id,a.name,!0)},children:c("settings.extensions.actions.enable")}),e[106]=n,e[107]=h,e[108]=a.id,e[109]=a.name,e[110]=r,e[111]=c,e[112]=K):K=e[112];let H;e[113]!==n||e[114]!==k||e[115]!==a.id||e[116]!==a.name||e[117]!==o||e[118]!==c?(H=k?s.jsx(V,{type:"button",size:"sm",variant:"destructive",disabled:n,"aria-label":c("settings.extensions.remove.aria",{name:a.name}),onClick:()=>{o(a.id,a.name)},children:c("settings.extensions.remove")}):null,e[113]=n,e[114]=k,e[115]=a.id,e[116]=a.name,e[117]=o,e[118]=c,e[119]=H):H=e[119];let q;e[120]!==u||e[121]!==c?(q=u?s.jsxs(V,{type:"button",size:"sm",variant:"outline",className:"ml-auto",onClick:()=>{Gs(u)},children:[s.jsx($,{name:"external-link",className:"size-4"}),c("settings.extensions.actions.openSource")]}):null,e[120]=u,e[121]=c,e[122]=q):q=e[122];let Z;e[123]!==j||e[124]!==O||e[125]!==K||e[126]!==H||e[127]!==q?(Z=s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[j,O,K,H,q]}),e[123]=j,e[124]=O,e[125]=K,e[126]=H,e[127]=q,e[128]=Z):Z=e[128];let ae;e[129]!==L||e[130]!==P||e[131]!==Z||e[132]!==N||e[133]!==w||e[134]!==A||e[135]!==x||e[136]!==T?(ae=s.jsxs("div",{className:N,children:[w,A,x,T,L,P,Z]}),e[129]=L,e[130]=P,e[131]=Z,e[132]=N,e[133]=w,e[134]=A,e[135]=x,e[136]=T,e[137]=ae):ae=e[137];let B;e[138]!==C||e[139]!==ae||e[140]!==M?(B=s.jsx(C,{className:M,children:ae}),e[138]=C,e[139]=ae,e[140]=M,e[141]=B):B=e[141];let G;e[142]!==B||e[143]!==E||e[144]!==D?(G=s.jsxs("div",{className:E,children:[D,B]}),e[142]=B,e[143]=E,e[144]=D,e[145]=G):G=e[145];let _;return e[146]!==v||e[147]!==y||e[148]!==S||e[149]!==G?(_=s.jsx(v,{open:y,onOpenChange:S,children:G}),e[146]=v,e[147]=y,e[148]=S,e[149]=G,e[150]=_):_=e[150],_},Oy=()=>{const t=Be.c(175),{t:e}=qe(),a=Ks(Ly),n=Ks(Fy),i=Ks(Ky),o=Ks(zy),[r,d]=l.useState(null),[c,g]=l.useState(!1),[m,h]=l.useState("global"),f=n==="unsupported",[p,b]=l.useState(""),C=ya(),[v,k]=l.useState(!1),[u,y]=l.useState(!1),S=l.useRef(!1),[N,w]=l.useState(null),[A,x]=l.useState(null),[T,M]=l.useState(!1),E=l.useRef(0),D=l.useRef(null);let F;t[0]===Symbol.for("react.memo_cache_sentinel")?(F=Vm(),t[0]=F):F=t[0];const L=F;let P;t[1]===Symbol.for("react.memo_cache_sentinel")?(P=[],t[1]=P):P=t[1],l.useEffect(Uy,P);let j,O;t[2]!==o||t[3]!==f?(j=()=>{let Ce=!1;if(d(null),g(!1),h("global"),w(null),x(null),S.current=!1,!f)return Promise.all([Ju(),Qu()]).then(Ve=>{const[jt,Ot]=Ve;Ce||d({runtimeKey:o,profiles:jt,global:Ot})}).catch(()=>{Ce||g(!0)}),()=>{Ce=!0}},O=[o,f],t[2]=o,t[3]=f,t[4]=j,t[5]=O):(j=t[4],O=t[5]),l.useEffect(j,O);const K=r?.runtimeKey===o?r:null;let H;t[6]!==e?(H=e("settings.gitIdentities.editor.title.globalIdentity"),t[6]=e,t[7]=H):H=t[7];const q=K?.global?.userName??"",Z=K?.global?.userEmail??"";let ae;t[8]!==H||t[9]!==q||t[10]!==Z?(ae={id:"global",name:H,userName:q,userEmail:Z,icon:"fingerprint",color:"info"},t[8]=H,t[9]=q,t[10]=Z,t[11]=ae):ae=t[11];let B;t[12]!==K?.profiles||t[13]!==ae?(B=[ae,...K?.profiles.filter(_y)??[]],t[12]=K?.profiles,t[13]=ae,t[14]=B):B=t[14];const G=B;let _;t[15]!==G||t[16]!==m?(_=G.find(Ce=>Ce.id===m)??G[0],t[15]=G,t[16]=m,t[17]=_):_=t[17];const z=_;let te,Q;t[18]!==n?(te=()=>{if(n!=="ready"||S.current)return;S.current=!0;const Ce=Ks.getState().runtimeKey;Ic(!1).then(Ve=>{Ve.ok&&Ks.getState().applyUpdates(Ve.updates,Ce)})},Q=[n],t[18]=n,t[19]=te,t[20]=Q):(te=t[19],Q=t[20]),l.useEffect(te,Q);let X;t[21]!==e?(X=async()=>{y(!0);const Ce=Ks.getState().runtimeKey,Ve=await Ic(!0);if(y(!1),!Ve.ok){U.error(e("settings.extensions.toast.checkFailed"));return}Ks.getState().applyUpdates(Ve.updates,Ce),Object.keys(Ve.updates).length===0&&U.success(e("settings.extensions.toast.upToDate"))},t[21]=e,t[22]=X):X=t[22];const pe=X;let je;t[23]!==e?(je=async Ce=>{k(!0);const Ve=await Zd(Ce.id);if(k(!1),!Ve.ok){U.error(Ve.code==="host-too-old"&&Ve.required?e("settings.extensions.toast.hostTooOld",{version:Ve.required}):e(qd(Ve.code)));return}xi(Ce.id),U.success(e("settings.extensions.toast.updated",{name:Ve.guest.name,version:Ve.guest.version??""})),await gn(),Za(Ve.guest)&&x(Ve.guest)},t[23]=e,t[24]=je):je=t[24];const fe=je;let ke;if(t[25]!==a||t[26]!==e){const Ce=async(Ve,jt,Ot)=>{const Yt=Ot===void 0?{}:Ot;if(!Ve.ok){if(Yt.allowConflictDialog!==!1&&(Ve.code==="id-taken"||Ve.code==="already-installed")){const Zt=Ve.id?a.find(Ft=>Ft.id===Ve.id):void 0;return w({source:jt,name:Zt?.name??Ve.id??(jt.kind==="file"?jt.file.name:jt.input)}),!1}return Ve.code==="host-too-old"?U.error(Ve.required?e("settings.extensions.toast.hostTooOld",{version:Ve.required}):e("settings.extensions.toast.failed"),{description:Ve.diagnostic?ar(Ve.diagnostic,e):void 0}):U.error(e(Hd(Ve.code)),{description:Ve.diagnostic?ar(Ve.diagnostic,e):void 0}),!1}return b(""),w(null),U.success(Ve.replaced?e("settings.extensions.toast.reinstalled",{name:Ve.guest.name}):e("settings.extensions.toast.added",{name:Ve.guest.name})),await gn(),Za(Ve.guest)&&x(Ve.guest),!0};ke=async(Ve,jt)=>{const Ot=jt===void 0?{}:jt,Yt=ln();Ve.kind==="input"&&b(Ve.input),k(!0);const Zt=Ve.kind==="file"?await oy(Ve.file,Ot):await Jd(Ve.input,{...Ot,gitIdentityId:Ve.gitIdentityId});k(!1),ln()===Yt&&await Ce(Zt,Ve,{allowConflictDialog:!Ot.replace})},t[25]=a,t[26]=e,t[27]=ke}else ke=t[27];const be=ke;let De;t[28]!==p||t[29]!==be||t[30]!==z||t[31]!==e?(De=async()=>{const Ce=p.trim();if(!Ce){U.error(e("settings.extensions.toast.invalidPath"));return}await be({kind:"input",input:Ce,gitIdentityId:z.id})},t[28]=p,t[29]=be,t[30]=z,t[31]=e,t[32]=De):De=t[32];const oe=De;let ee;t[33]!==be?(ee=async()=>{if(!L)return;const Ce=await Hm("");Ce.success&&Ce.path&&await be({kind:"input",input:Ce.path})},t[33]=be,t[34]=ee):ee=t[34];const ce=ee;let ue;t[35]!==be?(ue=async()=>{if(!L){D.current?.click();return}const Ce=await Vr({filters:[{name:"ZIP Archive",extensions:["zip"]}]});Ce.success&&Ce.path&&await be({kind:"input",input:Ce.path})},t[35]=be,t[36]=ue):ue=t[36];const Ie=ue;let ve;t[37]!==be||t[38]!==e?(ve=async Ce=>{const Ve=Ce.target.files?.[0]??null;if(Ce.target.value="",!!Ve){if(!Pc(Ve)){U.error(e("settings.extensions.toast.invalidPath"));return}await be({kind:"file",file:Ve})}},t[37]=be,t[38]=e,t[39]=ve):ve=t[39];const Re=ve;let Me;t[40]!==v?(Me=Ce=>{v||(Ce.preventDefault(),E.current=E.current+1,M(!0))},t[40]=v,t[41]=Me):Me=t[41];const me=Me;let Te;t[42]!==v?(Te=Ce=>{v||(Ce.preventDefault(),Ce.dataTransfer.dropEffect="copy")},t[42]=v,t[43]=Te):Te=t[43];const Oe=Te;let ge;t[44]===Symbol.for("react.memo_cache_sentinel")?(ge=()=>{E.current=Math.max(0,E.current-1),E.current===0&&M(!1)},t[44]=ge):ge=t[44];const xe=ge;let ne;t[45]!==v||t[46]!==be||t[47]!==e?(ne=async Ce=>{if(Ce.preventDefault(),E.current=0,M(!1),v)return;const Ve=Ce.dataTransfer.items[0],jt=Ve?.getAsFile()??null,Yt=(Ve?.webkitGetAsEntry()??null)?.isDirectory===!0,Zt=jt!==null&&!Yt&&Pc(jt),Ft=jt&&L?qm(jt):null;if(Ft&&(Yt||Zt)){await be({kind:"input",input:Ft});return}if(Yt){U.error(e(L?"settings.extensions.toast.invalidPath":"settings.extensions.toast.folderNeedsZip"));return}if(!jt||!Zt){U.error(e("settings.extensions.toast.invalidPath"));return}await be({kind:"file",file:jt})},t[45]=v,t[46]=be,t[47]=e,t[48]=ne):ne=t[48];const ie=ne;let he;t[49]!==N||t[50]!==be?(he=async()=>{N&&await be(N.source,{replace:!0})},t[49]=N,t[50]=be,t[51]=he):he=t[51];const Ee=he;let Ke;t[52]!==e?(Ke=async(Ce,Ve)=>{k(!0);const jt=await Qd(Ce);if(k(!1),!jt.ok){U.error(e("settings.extensions.toast.removeFailed"));return}xi(Ce),U.success(e("settings.extensions.toast.removed",{name:Ve})),await gn()},t[52]=e,t[53]=Ke):Ke=t[53];const Le=Ke;let Se;t[54]!==e?(Se=async Ce=>{k(!0);const Ve=await ry(Ce.id,Ce.capabilities.requested);if(k(!1),!Ve){U.error(e("settings.extensions.toast.approveFailed"));return}x(null),U.success(e("settings.extensions.toast.approved",{name:Ce.name})),await gn()},t[54]=e,t[55]=Se):Se=t[55];const $e=Se;let Ye;t[56]!==Le?(Ye=async Ce=>{x(null),await Le(Ce.id,Ce.name)},t[56]=Le,t[57]=Ye):Ye=t[57];const pt=Ye;let vt;t[58]!==e?(vt=async(Ce,Ve,jt)=>{k(!0);const Ot=await Yd(Ce,jt);if(k(!1),!Ot){U.error(e("settings.extensions.toast.enabledFailed"));return}jt||xi(Ce),U.success(jt?e("settings.extensions.toast.enabled",{name:Ve}):e("settings.extensions.toast.disabled",{name:Ve})),await gn()},t[58]=e,t[59]=vt):vt=t[59];const wt=vt;let yt;t[60]!==e?(yt=e("settings.page.extensions.title"),t[60]=e,t[61]=yt):yt=t[61];let st;t[62]!==e?(st=e("settings.page.extensions.description"),t[62]=e,t[63]=st):st=t[63];let rt;t[64]!==oe||t[65]!==ce||t[66]!==Ie||t[67]!==v||t[68]!==T||t[69]!==C||t[70]!==G||t[71]!==r||t[72]!==c||t[73]!==p||t[74]!==me||t[75]!==Oe||t[76]!==ie||t[77]!==Re||t[78]!==z||t[79]!==e||t[80]!==f?(rt=f?null:s.jsxs(He,{title:e("settings.extensions.add.action"),info:C?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"block",children:e("settings.extensions.add.enterpriseRule")}),s.jsx("span",{className:"mt-2 block",children:e("settings.extensions.add.info")})]}):e("settings.extensions.add.info"),children:[s.jsx(Kt,{label:e("settings.extensions.add.label"),info:e(L?"settings.extensions.add.drop":"settings.extensions.add.drop.zipOnly"),settingsItem:"extensions.add",controlClassName:"w-full max-w-none",children:s.jsxs("div",{className:Ne("relative -m-1 flex min-w-0 flex-1 items-center gap-2 rounded-md border border-dashed border-transparent p-1 transition-colors",T&&"border-primary bg-primary/5"),onDragEnter:me,onDragOver:Oe,onDragLeave:xe,onDrop:Ce=>{ie(Ce)},children:[T?s.jsx("span",{className:"pointer-events-none absolute inset-0 z-10 flex items-center justify-center rounded-md bg-background/80 typography-ui-label text-primary",children:e("settings.extensions.add.drop.active")}):null,s.jsxs("div",{className:"relative flex min-w-0 flex-1 items-center",children:[s.jsx(Ge,{value:p,onChange:Ce=>b(Ce.target.value),onKeyDown:Ce=>{Ce.key==="Enter"&&(Ce.preventDefault(),oe())},placeholder:e("settings.extensions.add.placeholder"),"aria-label":e("settings.extensions.add.label"),className:Ne("h-8 min-w-0 flex-1 rounded-md pl-3",L?"pr-14":"pr-8"),disabled:v}),s.jsx("input",{ref:D,type:"file",accept:".zip,application/zip",className:"sr-only",tabIndex:-1,"aria-hidden":"true",onChange:Ce=>{Re(Ce)}}),s.jsxs("div",{className:"absolute right-1 top-1/2 flex -translate-y-1/2 items-center gap-0.5",children:[L?s.jsx(V,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-foreground",title:e("settings.extensions.add.browseFolder"),"aria-label":e("settings.extensions.add.browseFolder.aria"),disabled:v,onClick:()=>{ce()},children:s.jsx($,{name:"folder",className:"h-4 w-4"})}):null,s.jsx(V,{type:"button",variant:"ghost",size:"icon",className:"h-6 w-6 text-muted-foreground hover:text-foreground",title:e("settings.extensions.add.browseZip"),"aria-label":e("settings.extensions.add.browseZip.aria"),disabled:v,onClick:()=>{Ie()},children:s.jsx($,{name:"archive",className:"h-4 w-4"})})]})]}),s.jsx("div",{className:"shrink-0","data-settings-item":"extensions.gitIdentity",children:s.jsx(gp,{activeProfile:z,identities:G,onSelect:Ce=>h(Ce.id),isApplying:v||!r&&!c,iconOnly:!0})}),s.jsxs(V,{type:"button",size:"sm",disabled:v,"aria-label":e("settings.extensions.add.aria"),onClick:()=>{oe()},children:[s.jsx($,{name:"add",className:"h-4 w-4"}),e("settings.extensions.add.action")]})]})}),c?s.jsx("p",{className:"typography-meta text-destructive",children:e("settings.extensions.identity.loadFailed")}):null]}),t[64]=oe,t[65]=ce,t[66]=Ie,t[67]=v,t[68]=T,t[69]=C,t[70]=G,t[71]=r,t[72]=c,t[73]=p,t[74]=me,t[75]=Oe,t[76]=ie,t[77]=Re,t[78]=z,t[79]=e,t[80]=f,t[81]=rt):rt=t[81];let de;t[82]!==e?(de=e("settings.extensions.section.installed"),t[82]=e,t[83]=de):de=t[83];let Ue;t[84]!==v||t[85]!==pe||t[86]!==u||t[87]!==n||t[88]!==e||t[89]!==f?(Ue=f?null:s.jsxs(V,{type:"button",variant:"ghost",size:"sm","data-settings-item":"extensions.updates.check",disabled:v||u||n!=="ready","aria-label":e("settings.extensions.updates.check.aria"),onClick:()=>{pe()},children:[s.jsx($,{name:"refresh",className:Ne("h-4 w-4",u&&"animate-spin")}),e("settings.extensions.updates.check")]}),t[84]=v,t[85]=pe,t[86]=u,t[87]=n,t[88]=e,t[89]=f,t[90]=Ue):Ue=t[90];let et;t[91]!==i||t[92]!==n||t[93]!==e?(et=n==="error"||i?s.jsxs("p",{className:"typography-meta whitespace-pre-line text-destructive",children:[e("settings.extensions.toast.loadFailed"),i?`
|
|
30
|
-
${ar(i,e)}`:""]}):null,t[91]=i,t[92]=n,t[93]=e,t[94]=et):et=t[94];let ze;t[95]!==e||t[96]!==f?(ze=f?s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.extensions.unsupported")}):null,t[95]=e,t[96]=f,t[97]=ze):ze=t[97];let Ze;t[98]!==a.length||t[99]!==n||t[100]!==e?(Ze=n==="ready"&&a.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.extensions.empty")}):null,t[98]=a.length,t[99]=n,t[100]=e,t[101]=Ze):Ze=t[101];let tt;if(t[102]!==v||t[103]!==a||t[104]!==Le||t[105]!==wt||t[106]!==fe){let Ce;t[108]!==v||t[109]!==Le||t[110]!==wt||t[111]!==fe?(Ce=Ve=>s.jsx(Ry,{guest:Ve,busy:v,onReview:x,onRemove:Le,onSetEnabled:wt,onUpdate:fe},Ve.id),t[108]=v,t[109]=Le,t[110]=wt,t[111]=fe,t[112]=Ce):Ce=t[112],tt=a.map(Ce),t[102]=v,t[103]=a,t[104]=Le,t[105]=wt,t[106]=fe,t[107]=tt}else tt=t[107];let lt;t[113]!==de||t[114]!==Ue||t[115]!==et||t[116]!==ze||t[117]!==Ze||t[118]!==tt?(lt=s.jsxs(He,{title:de,contentClassName:"space-y-3",headerAction:Ue,children:[et,ze,Ze,tt]}),t[113]=de,t[114]=Ue,t[115]=et,t[116]=ze,t[117]=Ze,t[118]=tt,t[119]=lt):lt=t[119];let J;t[120]!==$e?(J=Ce=>{$e(Ce)},t[120]=$e,t[121]=J):J=t[121];let nt;t[122]!==pt?(nt=Ce=>{pt(Ce)},t[122]=pt,t[123]=nt):nt=t[123];let ot;t[124]===Symbol.for("react.memo_cache_sentinel")?(ot=()=>x(null),t[124]=ot):ot=t[124];let it;t[125]!==A||t[126]!==v||t[127]!==J||t[128]!==nt?(it=s.jsx(Iy,{guest:A,busy:v,onApprove:J,onDecline:nt,onDismiss:ot}),t[125]=A,t[126]=v,t[127]=J,t[128]=nt,t[129]=it):it=t[129];const ft=N!==null;let xt;t[130]!==v?(xt=Ce=>{!Ce&&!v&&w(null)},t[130]=v,t[131]=xt):xt=t[131];let ht;t[132]!==e?(ht=e("settings.extensions.dialog.reinstallTitle"),t[132]=e,t[133]=ht):ht=t[133];let St;t[134]!==ht?(St=s.jsx(Ht,{children:ht}),t[134]=ht,t[135]=St):St=t[135];const At=N?.name??"";let _e;t[136]!==e||t[137]!==At?(_e=e("settings.extensions.dialog.reinstallDescription",{name:At}),t[136]=e,t[137]=At,t[138]=_e):_e=t[138];let Xe;t[139]!==_e?(Xe=s.jsx(qt,{children:_e}),t[139]=_e,t[140]=Xe):Xe=t[140];let mt;t[141]!==St||t[142]!==Xe?(mt=s.jsxs(Vt,{children:[St,Xe]}),t[141]=St,t[142]=Xe,t[143]=mt):mt=t[143];let Fe;t[144]===Symbol.for("react.memo_cache_sentinel")?(Fe=()=>w(null),t[144]=Fe):Fe=t[144];let W;t[145]!==e?(W=e("settings.common.actions.cancel"),t[145]=e,t[146]=W):W=t[146];let ye;t[147]!==v||t[148]!==W?(ye=s.jsx(V,{size:"sm",variant:"ghost",disabled:v,onClick:Fe,children:W}),t[147]=v,t[148]=W,t[149]=ye):ye=t[149];let Ae;t[150]!==Ee?(Ae=()=>{Ee()},t[150]=Ee,t[151]=Ae):Ae=t[151];let Y;t[152]!==e?(Y=e("settings.extensions.dialog.reinstall"),t[152]=e,t[153]=Y):Y=t[153];let Pe;t[154]!==v||t[155]!==Ae||t[156]!==Y?(Pe=s.jsx(V,{size:"sm",disabled:v,onClick:Ae,children:Y}),t[154]=v,t[155]=Ae,t[156]=Y,t[157]=Pe):Pe=t[157];let Je;t[158]!==ye||t[159]!==Pe?(Je=s.jsxs(as,{children:[ye,Pe]}),t[158]=ye,t[159]=Pe,t[160]=Je):Je=t[160];let se;t[161]!==mt||t[162]!==Je?(se=s.jsxs($t,{className:"max-w-md",children:[mt,Je]}),t[161]=mt,t[162]=Je,t[163]=se):se=t[163];let We;t[164]!==ft||t[165]!==xt||t[166]!==se?(We=s.jsx(_t,{open:ft,onOpenChange:xt,children:se}),t[164]=ft,t[165]=xt,t[166]=se,t[167]=We):We=t[167];let ut;return t[168]!==yt||t[169]!==st||t[170]!==rt||t[171]!==lt||t[172]!==it||t[173]!==We?(ut=s.jsxs(ns,{title:yt,description:st,children:[rt,lt,it,We]}),t[168]=yt,t[169]=st,t[170]=rt,t[171]=lt,t[172]=it,t[173]=We,t[174]=ut):ut=t[174],ut};function Ly(t){return t.guests}function Fy(t){return t.status}function Ky(t){return t.failure}function zy(t){return t.runtimeKey}function Uy(){gn()}function _y(t){return t.id!=="global"}const qs=ca,$y=t=>{const e=t.kind==="dark"||t.kind==="high-contrast",a=Yu(e),n=(ue,Ie)=>t.colors[ue]??Ie,i=ue=>ue!=="transparent"&&(Qs(ue,"#000000")!==1||Qs(ue,"#ffffff")!==1),o=(ue,Ie)=>{const ve=n(ue,Ie);return i(ve)?ve:Ie},r=n("chat.list.background",n("editor.background",a.colors.surface.background)),d=n("interactive-session.foreground",n("foreground",n("editor.foreground",a.colors.surface.foreground))),g=[["editorWidget.background","editorWidget.foreground"],["dropdown.background","dropdown.foreground"],["input.background","input.foreground"]].find(([ue])=>t.colors[ue]),m=g?n(g[0],a.colors.surface.elevated):a.colors.surface.elevated,h=la(d,m,r),f=g?n(g[1],h):h,p=n("sideBar.background",n("panel.background",a.colors.surface.muted)),b=n("descriptionForeground",n("input.placeholderForeground",a.colors.surface.mutedForeground)),C=n("textBlockQuote.background",p),v=a.colors.surface.overlay,k=n("button.background",n("textLink.foreground",a.colors.primary.base)),u=n("button.hoverBackground",k),y=t.colors["button.background"]?n("button.foreground",zs(k,r)):zs(k,r),S=qs(k,.5),w=[t.kind==="high-contrast"?n("contrastBorder",""):"",n("widget.border",""),n("input.border",""),n("panel.border",""),n("sideBar.border",""),n("editorWidget.border",""),n("contrastBorder","")].find(ue=>ue&&i(ue))||qs(d,e?.25:.2),A=n("toolbar.hoverBackground",n("list.hoverBackground",a.colors.interactive.hover)),x=n("toolbar.activeBackground",A),M=[["list.activeSelectionBackground","list.activeSelectionForeground"],["menu.selectionBackground","menu.selectionForeground"],["editor.selectionBackground","editor.selectionForeground"]].filter(([ue])=>t.colors[ue]),E=M.find(([ue])=>[r,p,m].every(Ie=>{const ve=Qs(n(ue,""),Ie,r);return ve===null||ve>1.01}))??M[0],D=E?n(E[0],a.colors.interactive.selection):a.colors.interactive.selection,F=E?n(E[1],d):d,L=n("focusBorder",n("inputOption.activeBorder",k)),P=L,j=n("editorCursor.foreground",a.colors.interactive.cursor),O=n("editorError.foreground",n("testing.iconFailed",a.colors.status.error)),K=o("editorError.background",qs(O,e?.16:.12)),H=n("problemsWarningIcon.foreground",n("notificationsWarningIcon.foreground",n("editorWarning.foreground",a.colors.status.warning))),q=o("editorWarning.background",qs(H,e?.16:.12)),Z=n("testing.iconPassed",n("gitDecoration.addedResourceForeground",a.colors.status.success)),ae=qs(Z,e?.16:.12),B=n("problemsInfoIcon.foreground",n("editorInfo.foreground",a.colors.status.info)),G=o("editorInfo.background",qs(B,e?.16:.12)),_=n("editorLineNumber.foreground",b),z=n("textPreformat.foreground",n("terminal.ansiGreen",a.colors.syntax.base.string)),te=n("terminal.ansiBlue",k),Q=n("terminal.ansiYellow",a.colors.syntax.base.number),X=n("terminal.ansiCyan",a.colors.syntax.base.function),pe=n("terminal.ansiMagenta",d),je=n("terminal.ansiYellow",a.colors.syntax.base.type),fe=n("chat.requestBorder",w),ke=n("diffEditor.insertedLineBackground",n("diffEditor.insertedTextBackground",ae)),be=n("diffEditor.removedLineBackground",n("diffEditor.removedTextBackground",K)),De=n("chat.linesAddedForeground",n("gitDecoration.addedResourceForeground",Z)),oe=n("chat.linesRemovedForeground",n("gitDecoration.deletedResourceForeground",O)),ee=n("gitDecoration.modifiedResourceForeground",B),ce=n("chat.requestBubbleBackground",n("chat.requestBackground",m));return{...a,metadata:{...a.metadata,id:"vscode-auto",name:"VS Code Theme",description:"Mirrors your current VS Code color theme",author:"VS Code",version:"1.0.0",variant:e?"dark":"light",tags:["vscode","auto"]},colors:{...a.colors,primary:{base:k,hover:u,active:u,foreground:y,muted:S},surface:{background:r,foreground:d,muted:p,mutedForeground:b,elevated:m,elevatedForeground:f,overlay:v,subtle:C},interactive:{border:w,borderHover:n("toolbar.hoverOutline",w),borderFocus:L,selection:D,selectionForeground:F,focus:L,focusRing:P,cursor:j,hover:A,active:x},status:{error:O,errorForeground:zs(O,r),errorBackground:K,errorBorder:qs(O,e?.45:.35),warning:H,warningForeground:zs(H,r),warningBackground:q,warningBorder:qs(H,e?.45:.35),success:Z,successForeground:zs(Z,r),successBackground:ae,successBorder:qs(Z,e?.45:.35),info:B,infoForeground:zs(B,r),infoBackground:G,infoBorder:qs(B,e?.45:.35)},syntax:{tokens:{},highlights:{diffAdded:De,diffAddedBackground:ke,diffRemoved:oe,diffRemovedBackground:be,diffModified:ee,diffModifiedBackground:qs(ee,e?.16:.12),lineNumber:n("editorLineNumber.foreground",b),lineNumberActive:n("editorLineNumber.activeForeground",d)},base:{background:n("editor.background",r),foreground:n("editor.foreground",d),comment:_,keyword:te,string:z,number:Q,function:X,variable:pe,type:je,operator:k}},tools:{border:fe,icon:n("icon.foreground",b),title:d,description:qs(b,.8),edit:{added:De,addedBackground:ke,removed:oe,removedBackground:be,modified:ee,modifiedBackground:qs(ee,e?.16:.12),lineNumber:_}},chat:{background:r,userMessage:d,userMessageBackground:ce,assistantMessage:d,assistantMessageBackground:r,timestamp:b,divider:w,typing:n("chat.thinkingShimmer",b),avatarBackground:n("chat.avatarBackground",r),avatarForeground:n("chat.avatarForeground",d),slashCommandBackground:n("chat.slashCommandBackground",k),slashCommandForeground:n("chat.slashCommandForeground",y),inputWorkingBorderColor1:n("chat.inputWorkingBorderColor1",k),inputWorkingBorderColor2:n("chat.inputWorkingBorderColor2",u),inputWorkingBorderColor3:n("chat.inputWorkingBorderColor3",S)},markdown:{link:n("textLink.foreground",k),linkHover:n("textLink.activeForeground",u),inlineCode:n("textPreformat.foreground",z),inlineCodeBackground:n("textPreformat.background",n("editor.background",r)),blockquote:d,blockquoteBackground:n("textBlockQuote.background","transparent"),blockquoteBorder:n("textBlockQuote.border",w),listMarker:qs(k,.6)}}}},ir=.075;function By(t,e,a){const{surface:n,primary:i,status:o,interactive:r}=t.colors,d=n.background,c=t.metadata.variant==="dark",g=zs(n.muted,d),m=[d,n.muted,n.elevated,Cs(r.selection,n.muted,1,d)].filter(k=>zs(k,d)===g),h=k=>m.reduce((u,y)=>la(u,y,d),k),f=k=>[d,n.muted].every(u=>(Qs(k,u,d)??0)>=3),p=[e["button.background"],e["textLink.foreground"],e["activityBarBadge.background"],e["list.highlightForeground"],e.focusBorder,e["inputOption.activeBorder"],a.function,a.keyword].filter(k=>k!==void 0),b=h(p.find(f)??i.base);b!==i.base&&(i.base=b,i.foreground=zs(b,d),i.hover=Cs(n.foreground,b,.08,d),i.active=Cs(n.foreground,b,.16,d),i.muted=ca(b,.5),!e.focusBorder&&!e["inputOption.activeBorder"]&&(r.focus=b,r.focusRing=b,r.borderFocus=b),t.colors.markdown&&(e["textLink.foreground"]||(t.colors.markdown.link=b),e["textLink.activeForeground"]||(t.colors.markdown.linkHover=i.hover),t.colors.markdown.listMarker=ca(b,.6))),m.some(k=>(Qs(r.focusRing,k,d)??0)<1.1)&&(r.focus=i.base,r.focusRing=i.base,r.borderFocus=i.base);const C=(k,u,y)=>m.every(S=>(bl(k,u,S,d)??0)>=y);let v=h(o.info);if(!C(v,i.base,ir)){const k=S=>C(S,i.base,ir)&&[o.error,o.warning,o.success].every(N=>C(S,N,.1));let y=[e["notificationsInfoIcon.foreground"],e["editorInfo.foreground"],e["terminal.ansiCyan"],e["terminal.ansiBlue"],e["terminal.ansiMagenta"],e["textLink.foreground"],a.function,a.type].filter(S=>S!==void 0).map(h).find(k);if(!y){const S=Cs(v,d,1,d),w=[S,h(Cs(S,d,.5,d))].flatMap(A=>[.12,.18].flatMap(x=>[0,60,-60,90,-90,120,-120,180].map(T=>h(Zu(A,T,x)))));if(y=w.find(k),!y){const A=x=>Math.min(...[o.error,o.warning,o.success].map(T=>bl(x,T,n.muted,d)??0));y=w.filter(x=>C(x,i.base,ir)).sort((x,T)=>A(T)-A(x))[0]}}y&&(v=y)}if(v!==o.info&&(o.info=v,o.infoForeground=zs(v,d),o.infoBackground=ca(v,c?.16:.12),o.infoBorder=ca(v,c?.45:.35)),t.colors.chat){const k=t.colors.chat.userMessageBackground??n.elevated;if((Qs(k,d,d)??1)<1.1){const u=Cs(k,d,1,d);let S=(Qs(u,"#000000")??1)<(Qs(d,"#000000")??1)?"#000000":"#ffffff",N=u;((Qs(S,d,d)??1)<1.1||(Qs(u,d,d)??1)<1.01)&&(N=d,S=n.foreground);let w=0,A=1;for(let T=0;T<16;T++){const M=(w+A)/2,E=Cs(S,N,M,d);(Qs(E,d,d)??1)>=1.1?A=M:w=M}const x=Cs(S,N,A,d);(Qs(n.foreground,x,d)??0)>=4.5&&(t.colors.chat.userMessageBackground=x)}}}const mo=Rt().regex(/^#(?:[\da-f]{3}|[\da-f]{4}|[\da-f]{6}|[\da-f]{8})$/i),ll=Os({foreground:mo.optional()}),eu=Os({scope:vr([Rt(),ja(Rt())]).optional(),settings:ll}),Vy=Os({name:Rt().trim().min(1).max(160).optional(),author:Rt().max(160).optional(),description:Rt().max(1024).optional(),type:Gr(["light","dark","hc","hc-black","hc-light"]).optional(),include:Rt().optional(),colors:Bn(Rt(),mo.nullable()).default({}),tokenColors:vr([ja(eu),Rt()]).optional(),semanticHighlighting:qr().optional(),semanticTokenColors:Bn(Rt(),vr([mo,ll])).optional()});function Hy(t){return t.flatMap(e=>(Array.isArray(e.scope)?e.scope:[e.scope??""]).flatMap(n=>n.split(",").map(i=>({scope:i.trim(),color:e.settings.foreground}))))}function qy(t,e){for(const a of e){let n,i=-1;for(const o of t)!o.color||!o.scope||(a===o.scope||a.startsWith(`${o.scope}.`))&&o.scope.length>=i&&(n=o.color,i=o.scope.length);if(n)return n}}function Gy(t,e){for(const a of e.length?[...e,"*"]:e){const n=t[a];if(n===void 0)continue;const i=mo.safeParse(n);if(i.success)return i.data;const o=ll.safeParse(n);if(o.success&&o.data.foreground)return o.data.foreground}}function Wy(t){return/^[a-z0-9]+(?:[-_][a-z0-9]+)+$/.test(t)?t.split(/[-_]/).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "):t}function Jy(t,e,a,n){const i=zs(a,a);if(e.some(c=>zs(c,a)!==i))return t;let o=t;for(const c of e)o=la(o,c,a);let r=0,d=1;for(let c=0;c<16;c++){const g=(r+d)/2,m=ca(o,g);e.every(h=>(Qs(m,h,a)??0)>=n)?d=g:r=g}return ca(o,d)}function tu(t,e){if(new TextEncoder().encode(t).byteLength>ud)throw new da("size");let a;try{a=Vy.parse(JSON.parse(Lp(t.replace(/^\uFEFF/,""),{trailingCommas:!0})))}catch{throw new da("invalid")}const n=ja(eu).safeParse(a.tokenColors??[]);if(a.include||!n.success)throw new da("include");const i={};for(const[T,M]of Object.entries(a.colors))M!==null&&(i[T]=M);const o={...i},r=i["editor.background"];if(!r)throw new da("background");const d=a.type?["dark","hc","hc-black"].includes(a.type):zs(r,"#ffffff")==="#ffffff",c=d?"dark":"light",g=Cs(r,d?"#000000":"#ffffff",1),m=Hy(n.data),h=n.data.filter(T=>!T.scope&&T.settings.foreground).at(-1)?.settings.foreground,f=i["editor.foreground"]??h??i.foreground??zs(g,g),p=i["chat.list.background"]??g,b=i["interactive-session.foreground"]??i.foreground??f;i["editor.background"]=g,i["editor.foreground"]=f,i.foreground??=b,i["sideBar.background"]??=i["panel.background"]??Cs(b,p,.03,p),!i["editorWidget.background"]&&!i["dropdown.background"]&&!i["input.background"]&&(i["editorWidget.background"]=Cs(b,p,.04,p),i["editorWidget.foreground"]=la(b,i["editorWidget.background"],p)),i.descriptionForeground??=la(Cs(b,p,.6,p),p),i["widget.border"]??=i["input.border"]??i["panel.border"]??Cs(b,p,.15,p),i["toolbar.hoverBackground"]??=i["list.hoverBackground"]??Cs(b,p,.08,p),i["toolbar.activeBackground"]??=Cs(b,p,.12,p),!i["list.activeSelectionBackground"]&&!i["editor.selectionBackground"]&&(i["list.activeSelectionBackground"]=Cs(b,p,.16,p),i["list.activeSelectionForeground"]=la(b,i["list.activeSelectionBackground"],p)),i["button.background"]||(i["button.background"]=i["textLink.foreground"]??i.focusBorder??b,i["button.foreground"]=zs(i["button.background"],p)),i.focusBorder??=i["button.background"],i["editorCursor.foreground"]??=f;const C=a.type?.startsWith("hc")??!1;C&&i.contrastBorder&&(i["widget.border"]=i.contrastBorder);const k=$y({kind:d&&C?"high-contrast":c,colors:i});if(C)k.colors.interactive.focusRing=i.focusBorder;else{const{surface:T,interactive:M}=k.colors,E=Jy(M.border,[T.background,T.muted,T.elevated],T.background,d?1.15:1.2);M.border=E,i["toolbar.hoverOutline"]||(M.borderHover=E),k.colors.tools&&!i["chat.requestBorder"]&&(k.colors.tools.border=E),k.colors.chat&&(k.colors.chat.divider=E),k.colors.markdown&&!i["textBlockQuote.border"]&&(k.colors.markdown.blockquoteBorder=E)}const u=a.semanticHighlighting===!1?{}:a.semanticTokenColors??{},y=(T,M,E)=>Gy(u,T)??qy(m,M)??E,S={background:g,foreground:f,comment:y(["comment"],["comment","comment.line","comment.block"],la(Cs(f,g,.6,g),g)),keyword:y(["keyword"],["keyword","storage","keyword.control","storage.type"],f),string:y(["string"],["string","string.quoted","string.template"],f),number:y(["number"],["constant.numeric"],f),function:y(["function"],["entity.name.function","support.function"],f),variable:y(["variable"],["variable.other.readwrite","variable"],f),type:y(["type"],["entity.name.type","support.type","support.class"],f),operator:y(["operator"],["keyword.operator"],f)},N=y(["class"],["entity.name.type.class","entity.name.class"],S.type),w=y(["property"],["variable.other.property","support.type.property-name"],S.variable),A={base:S,tokens:{className:N,interface:y(["interface"],["entity.name.type.interface"],S.type),enum:y(["enum"],["entity.name.type.enum"],N),method:y(["method"],["entity.name.function.method"],S.function),variableProperty:w,parameter:y(["parameter"],["variable.parameter"],S.variable),constant:y(["variable.readonly","*.readonly","enumMember"],["variable.other.constant","constant.other"],S.number),boolean:y([],["constant.language.boolean","constant.language"],S.number),punctuation:y([],["punctuation","punctuation.separator"],S.operator),stringEscape:y([],["constant.character.escape"],S.string),commentDoc:y([],["comment.block.documentation","comment.documentation"],S.comment),keywordImport:y([],["keyword.control.import","keyword.import"],S.keyword),tag:y([],["entity.name.tag"],S.keyword),tagAttribute:y([],["entity.other.attribute-name"],w)},highlights:k.colors.syntax.highlights},x=Wy(a.name??(e.replace(/\.(jsonc?|code-theme)$/i,"").replace(/[-_]color[-_]theme$/i,"").trim().slice(0,160)||"VS Code"));return By(k,o,S),Xu({metadata:{id:`vscode-import-${c}`,name:x,variant:c,author:a.author,description:a.description??"",version:"1.0.0",tags:["imported","vscode"]},colors:{...k.colors,syntax:A,pr:{open:k.colors.status.success,draft:k.colors.surface.mutedForeground,blocked:k.colors.status.warning,merged:N,closed:k.colors.status.error}}})}const Qy=Os({namespace:Rt(),name:Rt(),version:Rt(),label:Rt(),icon:Rt().url().refine(t=>{const e=new URL(t);return e.protocol==="https:"&&["open-vsx.org","openvsx.eclipsecontent.org"].includes(e.hostname)}).nullable()});async function Yy(t,e){const a=await It("/api/config/themes/catalog/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:t}),signal:e});if(!a.ok)throw new Error("catalog");return Os({items:ja(Qy).max(24)}).parse(await a.json()).items}async function Zy(t,e){const a=await It("/api/config/themes/catalog/package",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:e});if(!a.ok)throw new Error("catalog");const{items:n}=Os({items:ja(Os({path:Rt(),name:Rt(),text:Rt(),error:qr()})).max(40)}).parse(await a.json());return n.map((i,o)=>{const r=`${o}:${i.path}`;try{if(i.error)throw new Error("invalid");const d=tu(i.text,i.path);return d.metadata.name=i.name,d.metadata.author=t.namespace,{status:"ready",key:r,name:i.name,definition:d,theme:em(d)}}catch{return{status:"invalid",key:r,name:i.name}}})}function Xy(t){const e=Be.c(3),{extension:a}=t,[n,i]=l.useState(!1);let o;return e[0]!==a.icon||e[1]!==n?(o=a.icon&&!n?s.jsx("img",{src:a.icon,alt:"",referrerPolicy:"no-referrer",loading:"lazy",className:"size-9 shrink-0 rounded object-contain",onError:()=>i(!0)}):s.jsx($,{name:"palette",className:"size-9 shrink-0 text-muted-foreground"}),e[0]=a.icon,e[1]=n,e[2]=o):o=e[2],o}function e1(t){const e=Be.c(93),{pickFile:a,fileBusy:n,onClose:i}=t,{t:o}=qe(),r=re(n1),{isMobile:d}=qn(),c=r||d,{importTheme:g}=ba(),[m,h]=l.useState("");let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f={step:"search",status:"idle",results:[]},e[0]=f):f=e[0];const[p,b]=l.useState(f);let C;e[1]===Symbol.for("react.memo_cache_sentinel")?(C=new Set,e[1]=C):C=e[1];const[v,k]=l.useState(C);let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=new Set,e[2]=u):u=e[2];const[y,S]=l.useState(u),[N,w]=l.useState(!1),[A,x]=l.useState(null),T=l.useRef(null);let M,E;e[3]===Symbol.for("react.memo_cache_sentinel")?(M=()=>{const z=new AbortController;T.current=z;const te=ho(()=>z.abort());return()=>{te(),z.abort()}},E=[],e[3]=M,e[4]=E):(M=e[3],E=e[4]),l.useEffect(M,E);let D,F;e[5]!==m||e[6]!==p.step?(D=()=>{if(p.step!=="search")return;const z=new AbortController,te=m.trim(),Q=setTimeout(async()=>{if(!te){b({step:"search",status:"idle",results:[]});return}b({step:"search",status:"loading",results:[]});try{const X=await Yy(te,z.signal);z.signal.aborted||b({step:"search",status:"ready",results:X})}catch{z.signal.aborted||b({step:"search",status:"error",results:[]})}},350);return()=>{clearTimeout(Q),z.abort()}},F=[m,p.step],e[5]=m,e[6]=p.step,e[7]=D,e[8]=F):(D=e[7],F=e[8]),l.useEffect(D,F);let L,P;if(e[9]!==n||e[10]!==g||e[11]!==c||e[12]!==a||e[13]!==m||e[14]!==A||e[15]!==y||e[16]!==N||e[17]!==v||e[18]!==p.extension||e[19]!==p.results||e[20]!==p.status||e[21]!==p.step||e[22]!==p.variants||e[23]!==o){const z=async ee=>{const ce=T.current?.signal;if(ce){b({step:"package",status:"loading",extension:ee}),S(new Set),x(null),k(new Set);try{const ue=await Zy(ee,ce);ce.aborted||b({step:"variants",extension:ee,variants:ue})}catch{ce.aborted||b({step:"package",status:"error",extension:ee})}}};let te;e[26]!==g||e[27]!==y||e[28]!==N||e[29]!==v||e[30]!==p.step||e[31]!==p.variants||e[32]!==o?(te=async()=>{if(p.step!=="variants"||N)return;const ee=T.current?.signal;if(!ee)return;w(!0),x(null);let ce=!1;for(const ue of p.variants){if(ee.aborted)break;if(!(ue.status!=="ready"||!v.has(ue.key)||y.has(ue.key)))try{if(await g(ue.definition,{activate:!1}),ee.aborted)break;S(Ie=>new Set(Ie).add(ue.key)),k(Ie=>{const ve=new Set(Ie);return ve.delete(ue.key),ve})}catch{ce=!0}}ee.aborted||(w(!1),x(ce?"partial":null),ce?Ja.error(o("settings.themeImport.partialError")):Ja.success(o("settings.themeImport.complete")))},e[26]=g,e[27]=y,e[28]=N,e[29]=v,e[30]=p.step,e[31]=p.variants,e[32]=o,e[33]=te):te=e[33];const Q=te;let X,pe;e[34]!==y||e[35]!==v||e[36]!==p.step||e[37]!==p.variants?(X=p.step==="variants"?p.variants.filter(ee=>ee.status==="ready"&&!y.has(ee.key)):[],pe=X.length>0&&X.every(ee=>v.has(ee.key)),e[34]=y,e[35]=v,e[36]=p.step,e[37]=p.variants,e[38]=X,e[39]=pe):(X=e[38],pe=e[39]);const je=pe;let fe;e[40]!==n||e[41]!==Q||e[42]!==N||e[43]!==v||e[44]!==p.step||e[45]!==o?(fe=p.step==="variants"&&s.jsx(V,{disabled:!v.size||N||n,onClick:()=>{Q()},children:o(N?"settings.themeImport.busy":"settings.themeImport.importSelected")}),e[40]=n,e[41]=Q,e[42]=N,e[43]=v,e[44]=p.step,e[45]=o,e[46]=fe):fe=e[46];const ke=N||n;let be;e[47]!==o?(be=o("settings.themeImport.chooseFile"),e[47]=o,e[48]=be):be=e[48];let De;e[49]!==a||e[50]!==ke||e[51]!==be?(De=s.jsx(V,{variant:"outline",className:"self-start",disabled:ke,onClick:a,children:be}),e[49]=a,e[50]=ke,e[51]=be,e[52]=De):De=e[52];let oe;e[53]!==fe||e[54]!==De?(oe=s.jsxs(s.Fragment,{children:[fe,De]}),e[53]=fe,e[54]=De,e[55]=oe):oe=e[55],L=oe,P=s.jsx(s.Fragment,{children:p.step==="search"?s.jsxs(s.Fragment,{children:[s.jsx(Ge,{autoFocus:!0,"aria-label":o("settings.themeImport.search"),placeholder:o("settings.themeImport.search"),value:m,maxLength:160,onChange:ee=>h(ee.target.value)}),s.jsxs("div",{className:c?"space-y-1":"max-h-[45dvh] overflow-y-auto space-y-1","aria-live":"polite",children:[p.status==="loading"&&s.jsx("p",{className:"text-muted-foreground",children:o("common.loading")}),p.status==="error"&&s.jsx("p",{role:"alert",className:"text-[var(--status-error-text)]",children:o("settings.themeImport.catalogError")}),p.status==="ready"&&!p.results.length&&s.jsx("p",{className:"text-muted-foreground",children:o("settings.themeImport.empty")}),p.results.map(ee=>s.jsxs(V,{variant:"ghost",className:"h-auto w-full justify-start py-2 text-left",onClick:()=>{z(ee)},children:[s.jsx(Xy,{extension:ee}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block truncate",children:ee.label}),s.jsx("span",{className:"block truncate typography-meta text-muted-foreground",children:ee.namespace})]})]},`${ee.namespace}.${ee.name}`))]})]}):s.jsxs(s.Fragment,{children:[s.jsxs(V,{variant:"ghost",size:"sm",className:"justify-start",disabled:N||p.step==="package"&&p.status==="loading",onClick:()=>b({step:"search",status:"idle",results:[]}),children:[s.jsx($,{name:"arrow-left",className:"size-4"}),o("settings.themeImport.back")]}),s.jsx("p",{className:"typography-ui-label",children:p.extension.label}),A==="partial"&&s.jsx("p",{role:"alert",className:"text-[var(--status-error-text)]",children:o("settings.themeImport.partialError")}),p.step==="package"?p.status==="loading"?s.jsx("p",{role:"status",children:o("common.loading")}):s.jsx("p",{role:"alert",className:"text-[var(--status-error-text)]",children:o("settings.themeImport.catalogError")}):s.jsxs(s.Fragment,{children:[p.variants.length>1&&s.jsx(V,{variant:"ghost",size:"sm",className:"self-start",disabled:N||n||!X.length,onClick:()=>k(je?new Set:new Set(X.map(s1))),children:o(je?"settings.themeImport.deselectAll":"settings.themeImport.selectAll")}),s.jsx("div",{className:c?"space-y-2":"max-h-[45dvh] overflow-y-auto space-y-2",children:p.variants.map(ee=>s.jsxs("div",{className:"flex items-center gap-3",children:[ee.status==="ready"&&s.jsxs("div",{"aria-hidden":"true",className:"flex w-20 shrink-0 items-center gap-2 rounded px-2 py-3",style:{backgroundColor:ee.theme.colors.surface.background,color:ee.theme.colors.surface.foreground},children:[s.jsx("span",{children:"Aa"}),s.jsx("span",{className:"space-y-1",children:[ee.theme.colors.syntax.base.keyword,ee.theme.colors.syntax.base.string,ee.theme.colors.syntax.base.function].map(t1)})]}),s.jsxs("div",{className:"min-w-0 flex-1",children:[y.has(ee.key)?s.jsxs("div",{className:"flex items-center gap-2 py-1",children:[s.jsx($,{name:"check",className:"size-4 shrink-0 text-[var(--status-success-text)]"}),s.jsx("span",{className:"typography-ui-label",children:ee.name})]}):s.jsx(bt,{checked:v.has(ee.key),disabled:ee.status!=="ready"||N||n,label:ee.name,onChange:ce=>k(ue=>{const Ie=new Set(ue);return ce?Ie.add(ee.key):Ie.delete(ee.key),Ie})}),s.jsx("p",{className:y.has(ee.key)?"typography-meta font-medium text-[var(--status-success-text)]":"typography-meta text-muted-foreground",children:ee.status!=="ready"?o("settings.themeImport.error.invalid"):y.has(ee.key)?o("settings.themeImport.installed"):o(ee.theme.metadata.variant==="dark"?"settings.openchamber.visual.option.themeMode.dark":"settings.openchamber.visual.option.themeMode.light")})]})]},ee.key))})]})]})}),e[9]=n,e[10]=g,e[11]=c,e[12]=a,e[13]=m,e[14]=A,e[15]=y,e[16]=N,e[17]=v,e[18]=p.extension,e[19]=p.results,e[20]=p.status,e[21]=p.step,e[22]=p.variants,e[23]=o,e[24]=L,e[25]=P}else L=e[24],P=e[25];const j=P;if(c){let z;e[56]!==o?(z=o("settings.themeImport.catalogTitle"),e[56]=o,e[57]=z):z=e[57];let te;e[58]!==L?(te=s.jsx("div",{className:"flex flex-col gap-2",children:L}),e[58]=L,e[59]=te):te=e[59];let Q;e[60]!==o?(Q=o("settings.themeImport.catalogHint"),e[60]=o,e[61]=Q):Q=e[61];let X;e[62]!==Q?(X=s.jsx("p",{className:"typography-meta text-muted-foreground",children:Q}),e[62]=Q,e[63]=X):X=e[63];let pe;e[64]!==j||e[65]!==X?(pe=s.jsxs("div",{className:"flex flex-col gap-4 px-1",children:[X,j]}),e[64]=j,e[65]=X,e[66]=pe):pe=e[66];let je;return e[67]!==i||e[68]!==te||e[69]!==pe||e[70]!==z?(je=s.jsx(md,{open:!0,title:z,onClose:i,footer:te,children:pe}),e[67]=i,e[68]=te,e[69]=pe,e[70]=z,e[71]=je):je=e[71],je}let O;e[72]!==i?(O=z=>{z||i()},e[72]=i,e[73]=O):O=e[73];let K;e[74]===Symbol.for("react.memo_cache_sentinel")?(K={forceRender:!0},e[74]=K):K=e[74];let H;e[75]!==o?(H=o("settings.themeImport.catalogTitle"),e[75]=o,e[76]=H):H=e[76];let q;e[77]!==H?(q=s.jsx(Ht,{children:H}),e[77]=H,e[78]=q):q=e[78];let Z;e[79]!==o?(Z=o("settings.themeImport.catalogHint"),e[79]=o,e[80]=Z):Z=e[80];let ae;e[81]!==Z?(ae=s.jsx(qt,{children:Z}),e[81]=Z,e[82]=ae):ae=e[82];let B;e[83]!==q||e[84]!==ae?(B=s.jsxs(Vt,{children:[q,ae]}),e[83]=q,e[84]=ae,e[85]=B):B=e[85];let G;e[86]!==L||e[87]!==j||e[88]!==B?(G=s.jsxs($t,{className:"max-w-lg",backdropProps:K,children:[B,j,L]}),e[86]=L,e[87]=j,e[88]=B,e[89]=G):G=e[89];let _;return e[90]!==G||e[91]!==O?(_=s.jsx(_t,{open:!0,onOpenChange:O,children:G}),e[90]=G,e[91]=O,e[92]=_):_=e[92],_}function t1(t,e){return s.jsx("span",{className:"block h-1 w-5 rounded",style:{backgroundColor:t}},e)}function s1(t){return t.key}function n1(t){return t.isMobile}function a1(){const{t}=qe(),{importTheme:e,customThemesLoading:a}=ba(),n=Ur(),[i,o]=l.useState(!1),r=l.useCallback(()=>o(!1),[]),d=l.useRef(null),c=l.useRef(0),g=l.useRef(null),[m,h]=l.useState(!1);l.useEffect(()=>ho(()=>{c.current+=1,o(!1)}),[]);const f=async(C,v)=>{h(!0);try{if(C.size>ud)throw new da("size");const k=await C.text();if(v.key!==ln()||v.generation!==c.current)throw new da("connection");const u=await e(tu(k,C.name));Ja.success(t("settings.themeImport.success",{name:u.metadata.name})),o(!1)}catch(k){const u=k instanceof da?k.code:"invalid";Ja.error(t(`settings.themeImport.error.${u}`))}finally{h(!1)}},p=async()=>{if(m)return;const C={key:ln(),generation:c.current};if(g.current=C,!n.themeFiles){d.current?.click();return}h(!0);try{const v=await n.themeFiles.pick();if(v?.status==="picked"){if(v.file){const k=v.file;await f({name:k.name,size:k.size,text:async()=>k.text},C)}return}d.current?.click()}catch{Ja.error(t("settings.themeImport.error.invalid"))}finally{h(!1)}},b=async C=>{const v=C.target.files?.[0];C.target.value="",v&&!m&&g.current&&await f(v,g.current)};return s.jsxs("div",{className:"flex items-center gap-2","data-settings-item":"appearance.import-theme",children:[s.jsxs(V,{variant:"outline",size:"sm",disabled:m||a,onClick:()=>o(!0),children:[s.jsx($,{name:m?"loader":"add",className:m?"size-3.5 animate-spin":"size-3.5"}),t(m?"settings.themeImport.busy":"settings.themeImport.action")]}),s.jsx(Gt,{children:t("settings.themeImport.catalogHint")}),s.jsx("input",{ref:d,type:"file",accept:".json,.jsonc",className:"hidden","aria-label":t("settings.themeImport.action"),onChange:b}),i&&s.jsx(e1,{pickFile:()=>{p()},fileBusy:m,onClose:r})]})}const Ac=(t,e,a)=>{const n=t?.querySelector("[cmdk-list]"),i=t?.querySelector(`[cmdk-item][data-value="${CSS.escape(e)}"]`);if(!n||!i)return;const o=n.getBoundingClientRect(),r=n.offsetHeight>0?o.height/n.offsetHeight:1;if(r<=0)return;const d=i.getBoundingClientRect(),c=(d.top-o.top)/r+n.scrollTop,g=d.height/r;a?.onlyIfHidden&&c>=n.scrollTop&&c+g<=n.scrollTop+n.clientHeight||(n.scrollTop=Math.max(0,c-(n.clientHeight-g)/2))};function Tc({options:t,value:e,onValueChange:a,placeholder:n,ariaLabel:i}){const{t:o}=qe(),{deleteImportedTheme:r,customThemeIds:d}=ba(),{isMobile:c}=qn(),[g,m]=l.useState(!1),[h,f]=l.useState(""),[p,b]=l.useState(void 0),[C,v]=l.useState(null),k=l.useRef(null),u=l.useRef(null),[y,S]=l.useState(null),[N,w]=l.useState(null),A=l.useCallback(j=>{const O=j instanceof HTMLElement?j:null,K=O?.closest('[data-slot="dialog-content"], [role="dialog"]');S(K instanceof HTMLElement?K:null),w(O?.closest("main")??null)},[]);l.useEffect(()=>{if(g)return tm.suspend()},[g]);const x=l.useRef(e);x.current=e;const T=l.useCallback(j=>{j&&Ac(j,x.current)},[]),M=t.find(j=>j.id===e),E=l.useMemo(()=>g?sa(t,h,j=>[j.label]):t,[g,t,h]),D=j=>{a(j),m(!1)},F=async j=>{if(!C){v(j.id);try{await r(j.id),k.current?.focus()}catch{Ja.error(o("settings.themeImport.deleteError"))}finally{v(null)}}},L=j=>{if(!d.includes(j.id))return null;const O=C===j.id;return s.jsx(V,{variant:"ghost",size:"icon",className:"size-6 shrink-0",disabled:O,"aria-label":o("settings.themeImport.delete",{name:j.label}),onPointerDown:K=>K.stopPropagation(),onClick:K=>{K.stopPropagation(),F(j)},children:s.jsx($,{name:O?"loader":"delete-bin",className:O?"size-4 animate-spin":"size-4"})})},P=s.jsx("div",{role:"status",className:"px-3 py-6 text-center typography-ui-label text-muted-foreground",children:o("settings.openchamber.visual.field.noThemesFound")});return c?s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button","aria-label":i,"aria-haspopup":"dialog",className:Ne(Zs,!M&&"text-muted-foreground"),onClick:()=>{f(""),m(!0)},children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:M?.label??n}),s.jsx($,{name:"arrow-down-s",className:"size-4 opacity-50"})]}),s.jsx(md,{open:g,title:i,onClose:()=>m(!1),children:s.jsxs("div",{className:"flex flex-col gap-2 px-3 pb-4 pt-1",children:[s.jsx(Ge,{value:h,onChange:j=>f(j.target.value),placeholder:o("settings.openchamber.visual.field.searchThemes"),"aria-label":o("settings.openchamber.visual.field.searchThemes"),className:"h-9"}),s.jsx("div",{className:"flex flex-col",role:"listbox","aria-label":i,children:E.length===0?P:E.map(j=>s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsxs("button",{type:"button",role:"option","aria-selected":j.id===e,className:"flex min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-lg px-2 py-2.5 text-left typography-ui-label hover:bg-[var(--interactive-hover)]",onClick:()=>D(j.id),children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:j.label}),j.id===e?s.jsx($,{name:"check",className:"size-4 shrink-0 text-muted-foreground"}):null]}),L(j)]},j.id))})]})})]}):s.jsxs(Fp,{open:g,onOpenChange:j=>{f(""),b(j?e:void 0),m(j)},onOpenChangeComplete:j=>{if(!j){u.current?.focus();return}k.current?.focus(),Ac(k.current?.closest('[data-slot="command"]'),e,{onlyIfHidden:!0})},children:[s.jsxs(Kp,{ref:u,"aria-label":i,"aria-haspopup":"dialog",className:Ne(Zs,!M&&"text-muted-foreground"),onPointerDownCapture:j=>A(j.currentTarget),onFocusCapture:j=>A(j.currentTarget),children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:M?.label??n}),s.jsx($,{name:"arrow-down-s",className:"size-4 opacity-50"})]}),s.jsx(zp,{container:y??void 0,children:s.jsx(Up,{side:"bottom",align:"start",sideOffset:4,collisionAvoidance:{side:"none"},collisionBoundary:N??void 0,className:"z-[120]",children:s.jsx(_p,{role:"dialog","aria-label":i,className:Ne(lm,"flex w-[var(--anchor-width)] min-w-[16rem] max-w-[calc(100vw-2rem)] flex-col p-0"),initialFocus:!1,finalFocus:!1,children:s.jsxs(sm,{ref:T,className:"min-h-0 flex-1",shouldFilter:!1,value:p,onValueChange:b,children:[s.jsx(nm,{ref:k,"aria-label":o("settings.openchamber.visual.field.searchThemes"),placeholder:o("settings.openchamber.visual.field.searchThemes"),value:h,onValueChange:f,onKeyDown:j=>{if(am(j)){j.stopPropagation();return}im(j,O=>{j.currentTarget.dispatchEvent(new KeyboardEvent("keydown",{key:O,bubbles:!0,cancelable:!0}))})}}),s.jsx(om,{label:i,className:"max-h-[20rem] p-1",children:E.length===0?P:E.map(j=>s.jsxs(rm,{value:j.id,onSelect:D,"aria-current":j.id===e?!0:void 0,className:"max-w-full typography-ui-label",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate",children:j.label}),j.id===e?s.jsx($,{name:"check",className:"size-4 shrink-0 text-muted-foreground"}):null,L(j)]},j.id))})]})})})})]})}const i1=()=>{re.getState().requestSettingsJump("sessions","sessions.small-model")},o1=t=>{const e=Be.c(33),{disabled:a}=t,n=a===void 0?!1:a,{t:i}=qe(),o=re(r1),r=re(l1),d=es($r),c=!ya(),g=d?o:"small-model";let m;e[0]!==i?(m=i("settings.openchamber.visual.goal.checkerLabel"),e[0]=i,e[1]=m):m=e[1];let h;e[2]!==i?(h=i("settings.openchamber.visual.goal.checkerInfo"),e[2]=i,e[3]=h):h=e[3];let f;e[4]!==i?(f=i("settings.openchamber.visual.goal.checkerLabel"),e[4]=i,e[5]=f):f=e[5];const p=n||!d;let b;e[6]!==p?(b={value:"classifier",label:"Jev",disabled:p},e[6]=p,e[7]=b):b=e[7];let C;e[8]!==i?(C=i("settings.openchamber.visual.goal.checker.smallModel"),e[8]=i,e[9]=C):C=e[9];let v;e[10]!==n||e[11]!==C?(v={value:"small-model",label:C,disabled:n},e[10]=n,e[11]=C,e[12]=v):v=e[12];let k;e[13]!==b||e[14]!==v?(k=[b,v],e[13]=b,e[14]=v,e[15]=k):k=e[15];let u;e[16]!==r||e[17]!==g||e[18]!==f||e[19]!==k?(u=s.jsx(Xs,{"aria-label":f,value:g,onChange:r,options:k}),e[16]=r,e[17]=g,e[18]=f,e[19]=k,e[20]=u):u=e[20];let y;e[21]!==u||e[22]!==m||e[23]!==h?(y=s.jsx(Ct,{settingsItem:"chat.session-goal-checker",label:m,info:h,children:u}),e[21]=u,e[22]=m,e[23]=h,e[24]=y):y=e[24];let S;e[25]!==c||e[26]!==d||e[27]!==g||e[28]!==i?(S=g==="classifier"?s.jsx(xo,{}):s.jsxs("p",{className:ds,children:[i(d?"settings.openchamber.visual.goal.checker.viaSmallModel":"settings.openchamber.visual.goal.checker.jevMissing")," ",s.jsx(Vn,{onClick:i1,children:i("settings.openchamber.visual.goal.checker.smallModelLink")}),d||!c?null:s.jsxs(s.Fragment,{children:[" · ",s.jsx(Vn,{onClick:lo,children:i("settings.jevAccess.setUp")})]})]}),e[25]=c,e[26]=d,e[27]=g,e[28]=i,e[29]=S):S=e[29];let N;return e[30]!==y||e[31]!==S?(N=s.jsxs("div",{className:"space-y-1",children:[y,S]}),e[30]=y,e[31]=S,e[32]=N):N=e[32],N};function r1(t){return t.sessionGoalChecker}function l1(t){return t.setSessionGoalChecker}const c1=[{value:"system",labelKey:"settings.openchamber.visual.option.themeMode.system",descriptionKey:"settings.openchamber.visual.option.themeMode.system.description"},{value:"light",labelKey:"settings.openchamber.visual.option.themeMode.light",descriptionKey:"settings.openchamber.visual.option.themeMode.light.description"},{value:"dark",labelKey:"settings.openchamber.visual.option.themeMode.dark",descriptionKey:"settings.openchamber.visual.option.themeMode.dark.description"}],d1=[{id:"dynamic",labelKey:"settings.openchamber.visual.option.diffLayout.dynamic.label",descriptionKey:"settings.openchamber.visual.option.diffLayout.dynamic.description"},{id:"inline",labelKey:"settings.openchamber.visual.option.diffLayout.inline.label",descriptionKey:"settings.openchamber.visual.option.diffLayout.inline.description"},{id:"side-by-side",labelKey:"settings.openchamber.visual.option.diffLayout.sideBySide.label",descriptionKey:"settings.openchamber.visual.option.diffLayout.sideBySide.description"}],u1=[{id:"svg",labelKey:"settings.openchamber.visual.option.mermaidRendering.svg.label",descriptionKey:"settings.openchamber.visual.option.mermaidRendering.svg.description"},{id:"ascii",labelKey:"settings.openchamber.visual.option.mermaidRendering.ascii.label",descriptionKey:"settings.openchamber.visual.option.mermaidRendering.ascii.description"}],di="OpenChamber - AI Coding Assistant",Ec=[{id:"system",labelKey:"settings.openchamber.visual.option.pwaOrientation.system.label",descriptionKey:"settings.openchamber.visual.option.pwaOrientation.system.description"},{id:"portrait",labelKey:"settings.openchamber.visual.option.pwaOrientation.portrait.label",descriptionKey:"settings.openchamber.visual.option.pwaOrientation.portrait.description"},{id:"landscape",labelKey:"settings.openchamber.visual.option.pwaOrientation.landscape.label",descriptionKey:"settings.openchamber.visual.option.pwaOrientation.landscape.description"}],Dc=[{id:"native",labelKey:"settings.openchamber.visual.option.mobileKeyboardMode.native.label",descriptionKey:"settings.openchamber.visual.option.mobileKeyboardMode.native.description"},{id:"resize-content",labelKey:"settings.openchamber.visual.option.mobileKeyboardMode.resizeContent.label",descriptionKey:"settings.openchamber.visual.option.mobileKeyboardMode.resizeContent.description"}],or=t=>t==="portrait"||t==="landscape"?t:"system",m1=[{id:"markdown",labelKey:"settings.openchamber.visual.option.userMessageRendering.markdown.label",descriptionKey:"settings.openchamber.visual.option.userMessageRendering.markdown.description"},{id:"plain",labelKey:"settings.openchamber.visual.option.userMessageRendering.plain.label",descriptionKey:"settings.openchamber.visual.option.userMessageRendering.plain.description"}],p1=[{id:"sorted",labelKey:"settings.openchamber.visual.option.chatRenderMode.sorted.label",descriptionKey:"settings.openchamber.visual.option.chatRenderMode.sorted.description"},{id:"live",labelKey:"settings.openchamber.visual.option.chatRenderMode.live.label",descriptionKey:"settings.openchamber.visual.option.chatRenderMode.live.description"}],Mc=[{id:"auto",labelKey:"settings.openchamber.visual.option.messageTransport.auto.label",descriptionKey:"settings.openchamber.visual.option.messageTransport.auto.description"},{id:"ws",labelKey:"settings.openchamber.visual.option.messageTransport.ws.label",descriptionKey:"settings.openchamber.visual.option.messageTransport.ws.description"},{id:"sse",labelKey:"settings.openchamber.visual.option.messageTransport.sse.label",descriptionKey:"settings.openchamber.visual.option.messageTransport.sse.description"}],g1=[{id:"collapsed",labelKey:"settings.openchamber.visual.option.activityRenderMode.collapsed.label",descriptionKey:"settings.openchamber.visual.option.activityRenderMode.collapsed.description"},{id:"summary",labelKey:"settings.openchamber.visual.option.activityRenderMode.summary.label",descriptionKey:"settings.openchamber.visual.option.activityRenderMode.summary.description"}],Rc=[{id:"auto",labelKey:"settings.openchamber.visual.option.timeFormat.auto.label",descriptionKey:"settings.openchamber.visual.option.timeFormat.auto.description"},{id:"24h",labelKey:"settings.openchamber.visual.option.timeFormat.24h.label",descriptionKey:"settings.openchamber.visual.option.timeFormat.24h.description"},{id:"12h",labelKey:"settings.openchamber.visual.option.timeFormat.12h.label",descriptionKey:"settings.openchamber.visual.option.timeFormat.12h.description"}],Oc=[{id:"auto",labelKey:"settings.openchamber.visual.option.weekStart.auto.label",descriptionKey:"settings.openchamber.visual.option.weekStart.auto.description"},{id:"monday",labelKey:"settings.openchamber.visual.option.weekStart.monday.label"},{id:"sunday",labelKey:"settings.openchamber.visual.option.weekStart.sunday.label"}],f1=[{id:"steer",labelKey:"settings.openchamber.visual.option.followUpBehavior.steer.label"},{id:"queue",labelKey:"settings.openchamber.visual.option.followUpBehavior.queue.label"}],h1=[{id:"ask",labelKey:"settings.openchamber.visual.option.largeTextPaste.ask.label"},{id:"attach",labelKey:"settings.openchamber.visual.option.largeTextPaste.attach.label"},{id:"inline",labelKey:"settings.openchamber.visual.option.largeTextPaste.inline.label"}],x1=[{id:"global",labelKey:"settings.openchamber.visual.option.inputHistoryScope.global.label"},{id:"session",labelKey:"settings.openchamber.visual.option.inputHistoryScope.session.label"}],b1=t=>t==="markdown"?"markdown":"plain",v1=[{id:"left",labelKey:"settings.openchamber.desktopNetwork.option.windowControlsLeft"},{id:"right",labelKey:"settings.openchamber.desktopNetwork.option.windowControlsRight"}],y1=[{id:"classic",labelKey:"settings.openchamber.desktopNetwork.option.windowControlsClassic"},{id:"traffic-lights",labelKey:"settings.openchamber.desktopNetwork.option.windowControlsTrafficLights"}],bo=({visibleSettings:t})=>{const{locale:e,locales:a,setLocale:n,label:i,t:o}=qe(),r=l.useCallback(I=>o(I),[o]),{isMobile:d}=qn(),{terminal:c}=Ur(),{browserTab:g}=fp(),m=Gm(),h=re(I=>I.showReasoningTraces),f=re(I=>I.sessionRecapEnabled),p=re(I=>I.sessionSuggestionEnabled),b=re(I=>I.setSessionRecapEnabled),C=re(I=>I.setSessionSuggestionEnabled),v=re(I=>I.sessionGoalEnabled),k=re(I=>I.setSessionGoalEnabled),u=re(I=>I.sessionGoalDefaultBudgetEnabled),y=re(I=>I.setSessionGoalDefaultBudgetEnabled),S=re(I=>I.sessionGoalDefaultBudget),N=re(I=>I.setSessionGoalDefaultBudget),w=re(I=>I.setShowReasoningTraces),A=re(I=>I.streamingAutoFollowEnabled),x=re(I=>I.setStreamingAutoFollowEnabled),T=re(I=>I.collapsibleThinkingBlocks),M=re(I=>I.setCollapsibleThinkingBlocks),E=Il(I=>I.animatedActivityIndicators),D=Il(I=>I.setAnimatedActivityIndicators),F=re(I=>I.mermaidRenderingMode),L=re(I=>I.setMermaidRenderingMode),P=re(I=>I.userMessageRenderingMode),j=re(I=>I.setUserMessageRenderingMode),O=re(I=>I.collapsibleUserMessages),K=re(I=>I.setCollapsibleUserMessages),H=re(I=>I.stickyUserHeader),q=re(I=>I.promptNavigatorEnabled),Z=re(I=>I.setStickyUserHeader),ae=re(I=>I.setPromptNavigatorEnabled),B=re(I=>I.autoSaveEnabled),G=re(I=>I.setAutoSaveEnabled),_=re(I=>I.wideChatLayoutEnabled),z=re(I=>I.setWideChatLayoutEnabled),te=re(I=>I.codeBlockLineWrap),Q=re(I=>I.setCodeBlockLineWrap),X=re(I=>I.chatRenderMode),pe=re(I=>I.setChatRenderMode),je=re(I=>I.activityRenderMode),fe=re(I=>I.setActivityRenderMode),ke=re(I=>I.fontSize),be=re(I=>I.setFontSize),De=re(I=>I.terminalFontSize),oe=re(I=>I.setTerminalFontSize),ee=re(I=>I.terminalShell),ce=re(I=>I.setTerminalShell),ue=re(I=>I.terminalLoginShells),Ie=re(I=>I.setTerminalLoginShells),ve=re(I=>I.editorFontSize),Re=re(I=>I.setEditorFontSize),Me=re(I=>I.uiFont),me=re(I=>I.setUiFont),Te=re(I=>I.monoFont),Oe=re(I=>I.setMonoFont),ge=re(I=>I.padding),xe=re(I=>I.setPadding),ne=re(I=>I.inputBarOffset),ie=re(I=>I.setInputBarOffset),he=re(I=>I.mobileKeyboardMode),Ee=re(I=>I.setMobileKeyboardMode),Ke=re(I=>I.diffLayoutPreference),Le=re(I=>I.setDiffLayoutPreference),Se=re(I=>I.showTerminalQuickKeysOnDesktop),$e=re(I=>I.sessionTabsEnabled),Ye=re(I=>I.setSessionTabsEnabled),pt=re(I=>I.setShowTerminalQuickKeysOnDesktop),vt=re(I=>I.fileEditorKeymap),wt=re(I=>I.setFileEditorKeymap),yt=Pl(I=>I.followUpBehavior),st=Pl(I=>I.setFollowUpBehavior),rt=zi(I=>I.scope),de=zi(I=>I.entryLimit),Ue=zi(I=>I.applyScope),et=zi(I=>I.applyEntryLimit),ze=re(I=>I.persistChatDraft),Ze=re(I=>I.setPersistChatDraft),tt=re(I=>I.inputSpellcheckEnabled),lt=re(I=>I.setInputSpellcheckEnabled),J=re(I=>I.largeTextPasteBehavior),nt=re(I=>I.setLargeTextPasteBehavior),ot=re(I=>I.enterToSend),it=re(I=>I.setEnterToSend),ft=re(I=>I.enterToSendConfigured),xt=re(I=>I.setEnterToSendConfigured),ht=ft?ot:!d,St=re(I=>I.showToolFileIcons),At=re(I=>I.setShowToolFileIcons),_e=re(I=>I.showTurnChangedFiles),Xe=re(I=>I.setShowTurnChangedFiles),mt=re(I=>I.showExpandedBashTools),Fe=re(I=>I.setShowExpandedBashTools),W=re(I=>I.showExpandedEditTools),ye=re(I=>I.setShowExpandedEditTools),Ae=re(I=>I.timeFormatPreference),Y=re(I=>I.setTimeFormatPreference),Pe=re(I=>I.weekStartPreference),Je=re(I=>I.setWeekStartPreference),se=re(I=>I.showSplitAssistantMessageActions),We=re(I=>I.setShowSplitAssistantMessageActions),ut=re(I=>I.allowPromptingSubagentSessions),Ce=re(I=>I.setAllowPromptingSubagentSessions),Ve=re(I=>I.draftStartersVisible),jt=re(I=>I.setDraftStartersVisible),Ot=ct(I=>I.settingsMessageStreamTransport),Yt=ct(I=>I.setSettingsMessageStreamTransport),Zt=Ot,Ft=ct(I=>I.settingsDefaultFileViewerPreview),ms=ct(I=>I.setSettingsDefaultFileViewerPreview),gs=re(I=>I.isSettingsDialogOpen),{themeMode:tn,setThemeMode:$s,availableThemes:Bs,customThemesLoading:cn,reloadCustomThemes:sn,lightThemeId:nn,darkThemeId:Vs,setLightThemePreference:Dn,setDarkThemePreference:Lt}=ba(),[Xt,Wt]=l.useState(!1),Mt=l.useMemo(()=>us()&&typeof window<"u"&&window.__OPENCHAMBER_PLATFORM__==="darwin",[]),ls=re(I=>I.dockBadgeEnabled),is=re(I=>I.setDockBadgeEnabled),vo=re(I=>I.alwaysShowScrollbars===!0),yo=re(I=>I.setAlwaysShowScrollbars),jo=Wm(),ko=re(I=>I.desktopWindowControlsPosition),Ci=re(I=>I.setDesktopWindowControlsPosition),wo=re(I=>I.desktopWindowControlsStyle),Ii=re(I=>I.setDesktopWindowControlsStyle),[No,Ws]=l.useState(0),ai=re(I=>I.reportUsage),Pi=re(I=>I.setReportUsage),Ai=l.useCallback(I=>{Pi(I),kt({reportUsage:I})},[Pi]),So=l.useCallback(I=>{Ci(I),kt({desktopWindowControlsPosition:I})},[Ci]),Co=l.useCallback(I=>{Ii(I),kt({desktopWindowControlsStyle:I})},[Ii]),Ti=(gs||d||ps())&&(t?t.includes("chatRenderMode"):!0);l.useEffect(()=>{if(!Ti)return;let I=null,Nt=Date.now();const vs=()=>{const Sn=Date.now();Sn-Nt>=420&&(Ws(aa=>(aa+1)%24),Nt=Sn),I=requestAnimationFrame(vs)};(typeof document>"u"||document.visibilityState==="visible")&&(I=requestAnimationFrame(vs));const Ls=()=>{document.visibilityState==="visible"&&I===null?I=requestAnimationFrame(vs):document.visibilityState!=="visible"&&I!==null&&(cancelAnimationFrame(I),I=null)};return document.addEventListener("visibilitychange",Ls),()=>{document.removeEventListener("visibilitychange",Ls),I!==null&&cancelAnimationFrame(I)}},[Ti]);const Io=l.useCallback(I=>{j(I),kt({userMessageRenderingMode:I})},[j]),Po=l.useCallback(I=>{Z(I),kt({stickyUserHeader:I})},[Z]),Ns=l.useCallback(I=>{ae(I),kt({promptNavigatorEnabled:I})},[ae]),dn=l.useCallback(I=>{jt(I),kt({draftStartersVisible:I})},[jt]),ka=l.useCallback(I=>{K(I),kt({collapsibleUserMessages:I})},[K]),Mn=l.useCallback(I=>{z(I),kt({wideChatLayoutEnabled:I})},[z]),Qn=l.useCallback(I=>{We(I),kt({showSplitAssistantMessageActions:I})},[We]),ul=l.useCallback(I=>{lt(I),kt({inputSpellcheckEnabled:I})},[lt]),un=l.useCallback(I=>{it(I),xt(!0),kt({enterToSend:I,enterToSendConfigured:!0})},[it,xt]),Ao=l.useCallback(I=>{pe(I),kt({chatRenderMode:I})},[pe]),wa=l.useCallback(I=>{Yt(I),kt({messageStreamTransport:I})},[Yt]),Na=l.useCallback(I=>{Ue(I),kt({inputHistoryScope:I})},[Ue]),na=l.useCallback(I=>{const Nt=Math.round(I);Jm(Nt)&&(et(Nt),kt({inputHistoryLimit:Nt}))},[et]),ii=l.useCallback(I=>{fe(I),kt({activityRenderMode:I})},[fe]),To=l.useCallback(I=>{L(I),kt({mermaidRenderingMode:I})},[L]),fs=l.useCallback(I=>{At(I),kt({showToolFileIcons:I})},[At]),Eo=l.useCallback(I=>{Xe(I),kt({showTurnChangedFiles:I})},[Xe]),Sa=l.useCallback(I=>{ms(I),kt({defaultFileViewerPreview:I}),window.dispatchEvent(new CustomEvent("openchamber:file-viewer-preview-mode-changed",{detail:{enabled:I}}))},[ms]),Ca=l.useCallback(I=>{Fe(I),kt({showExpandedBashTools:I})},[Fe]),Do=l.useCallback(I=>{ye(I),kt({showExpandedEditTools:I})},[ye]),Ei=l.useCallback(I=>{Y(I),kt({timeFormatPreference:I})},[Y]),Mo=l.useCallback(I=>{Je(I),kt({weekStartPreference:I})},[Je]),Yn=l.useMemo(()=>Bs.filter(I=>I.metadata.variant==="light").sort((I,Nt)=>I.metadata.name.localeCompare(Nt.metadata.name)),[Bs]),jn=l.useMemo(()=>Bs.filter(I=>I.metadata.variant==="dark").sort((I,Nt)=>I.metadata.name.localeCompare(Nt.metadata.name)),[Bs]),Ia=l.useMemo(()=>Yn.find(I=>I.metadata.id===nn)??Yn[0],[Yn,nn]),Di=l.useMemo(()=>jn.find(I=>I.metadata.id===Vs)??jn[0],[jn,Vs]),Pa=l.useCallback((I,Nt)=>{const vs=Nt==="dark"?" Dark":" Light";return I.endsWith(vs)?I.slice(0,-vs.length):I},[]),Aa=l.useMemo(()=>Yn.map(I=>({id:I.metadata.id,label:Pa(I.metadata.name,"light")})),[Yn,Pa]),Ro=l.useMemo(()=>jn.map(I=>({id:I.metadata.id,label:Pa(I.metadata.name,"dark")})),[jn,Pa]),we=I=>I==="enterToSend"&&d?!1:t?t.includes(I):!0,Is=ps(),Ta=we("theme")&&!Is,Mi=we("windowControlsPosition")&&jo,Ri=we("theme")||we("timeFormat")||we("weekStart"),Oi=Is?Ri:we("theme")||Mi||we("pwaInstallName")||we("pwaOrientation")||we("timeFormat")||we("weekStart"),Li=we("fontSize")||we("terminalFontSize")||we("editorFontSize")||we("spacing")||we("scrollbars")&&!Ta||we("inputBarOffset")&&d,Fi=we("terminalQuickKeys")&&!d||(we("terminalShell")||we("terminalLoginShell"))&&!Is||we("fileEditorKeymap")||we("autoSaveEnabled")||we("sessionTabs")&&!Is&&!d,Oo=we("mermaidRendering")||we("sessionGoal")&&!Is||we("userMessageRendering")||we("chatRenderMode")||we("messageTransport")||we("activityRenderMode")||we("collapsibleUserMessages")||we("stickyUserHeader")||we("promptNavigatorEnabled")||we("wideChatLayout")||we("codeBlockLineWrap")||we("splitAssistantMessageActions")||we("subagentReadOnlyBanner")||we("diffLayout")||we("dotfiles")||we("fileViewerPreview")||we("reasoning")||we("followUpBehavior")||we("inputHistoryScope")||we("inputHistoryLimit")||we("persistDraft")||we("largeTextPaste")||we("showToolFileIcons")||we("expandedTools")||!d&&we("inputSpellcheck")||we("enterToSend"),kn=we("chatRenderMode")||we("activityRenderMode"),Zn=we("messageTransport"),Ea=we("userMessageRendering")||we("mermaidRendering")||we("diffLayout")&&!Is||we("followUpBehavior")||we("inputHistoryScope")||we("inputHistoryLimit"),Lo=we("sessionAssist")||we("sessionGoal")&&!Is||we("subagentReadOnlyBanner")||we("collapsibleUserMessages")||we("stickyUserHeader")||we("promptNavigatorEnabled")||we("wideChatLayout")||we("codeBlockLineWrap")||we("splitAssistantMessageActions")||we("dotfiles")||we("fileViewerPreview")||we("persistDraft")||we("largeTextPaste")||we("showToolFileIcons")||we("showTurnChangedFiles")||!d&&we("inputSpellcheck")||we("enterToSend")||we("reasoning")||we("expandedTools"),R=Oi||Li||Fi,le=we("pwaInstallName")&&fa()&&g&&!us()&&!Is,Qe=we("pwaOrientation")&&fa()&&!us()&&!Is,dt=we("mobileKeyboardMode")&&fa()&&!us()&&!Is&&Qm(),Ut=(we("terminalShell")||we("terminalLoginShell"))&&!Is,[ks,an]=l.useState([]),[bs,Hs]=l.useState(0);l.useEffect(()=>ho(()=>{an([]),Hs(I=>I+1)}),[]),l.useEffect(()=>{let I=!1;if(!(!Ut||!c.listShells))return c.listShells().then(Nt=>{I||an(Nt)}).catch(()=>{I||an([])}),()=>{I=!0}},[Ut,c,bs]);const Rn=l.useMemo(()=>{const I=ks.filter(Nt=>Nt.id!=="auto");return ee==="auto"||I.some(Nt=>Nt.id===ee)?I:[{id:ee,name:ee,supportsLogin:!1},...I]},[ks,ee]),wn=ks.find(I=>I.id===ee)?.supportsLogin===!0,Da=ue.includes(ee),Ma=I=>{Ie(I?[...ue.filter(Nt=>Nt!==ee),ee]:ue.filter(Nt=>Nt!==ee))},[Bt,ts]=l.useState(""),[Nn,mn]=l.useState("system"),ss=l.useMemo(()=>{const I=Rc.find(Nt=>Nt.id===Ae);return r(I?.labelKey??"settings.openchamber.visual.option.timeFormat.auto.label")},[Ae,r]),Ps=l.useMemo(()=>{const I=Oc.find(Nt=>Nt.id===Pe);return r(I?.labelKey??"settings.openchamber.visual.option.weekStart.auto.label")},[Pe,r]),Ra=l.useMemo(()=>{const I=Ec.find(Nt=>Nt.id===Nn);return I?r(I.labelKey):void 0},[Nn,r]),Oa=l.useMemo(()=>{const I=Dc.find(Nt=>Nt.id===he);return I?r(I.labelKey):void 0},[he,r]),La=l.useCallback(async I=>{if(typeof window>"u")return;const Nt=window,Ls=I.trim().replace(/\s+/g," ").slice(0,64);if(await kt({pwaAppName:Ls}),typeof Nt.__OPENCHAMBER_SET_PWA_INSTALL_NAME__=="function"){const Sn=Nt.__OPENCHAMBER_SET_PWA_INSTALL_NAME__(Ls);ts(Sn);return}ts(Ls||di),Nt.__OPENCHAMBER_UPDATE_PWA_MANIFEST__?.()},[]),ml=l.useCallback(async I=>{if(typeof window>"u")return;const Nt=window,vs=or(I);if(await kt({pwaOrientation:vs}),typeof Nt.__OPENCHAMBER_SET_PWA_ORIENTATION__=="function"){const Ls=Nt.__OPENCHAMBER_SET_PWA_ORIENTATION__(vs);mn(Ls);return}mn(vs),Nt.__OPENCHAMBER_UPDATE_PWA_MANIFEST__?.()},[]);l.useEffect(()=>{if(typeof window>"u"||!le&&!Qe&&!dt)return;let I=!1;return(async()=>{try{const vs=await En();if(!vs){I||ts(di);return}const Sn=(vs.pwaAppName??"").trim().replace(/\s+/g," ").slice(0,64),aa=or(vs.pwaOrientation),Ki=Ml(vs.mobileKeyboardMode);I||(le&&ts(Sn||di),Qe&&mn(aa),dt&&Ee(Ki))}catch{I||(le&&ts(di),Qe&&mn("system"),dt&&Ee("native"))}})(),()=>{I=!0}},[Ee,dt,le,Qe]);const Fo=we("scrollbars")?s.jsx(bt,{checked:vo,onChange:yo,label:o("settings.openchamber.visual.field.alwaysShowScrollbars"),info:o("settings.openchamber.visual.field.alwaysShowScrollbarsHint"),settingsItem:"appearance.scrollbars"}):null;return s.jsxs("div",{className:"space-y-0",children:[Oi&&s.jsxs("div",{className:"space-y-0",children:[Ta&&s.jsxs(He,{title:o("settings.openchamber.visual.section.colorModeAndTheme"),divider:!1,children:[s.jsxs(Fn,{children:[s.jsx("div",{className:Ms,children:s.jsx(Js,{"aria-label":o("settings.openchamber.visual.section.colorMode"),children:c1.map(I=>s.jsx(rs,{selected:tn===I.value,onSelect:()=>$s(I.value),label:r(I.labelKey),ariaLabel:r(I.labelKey)},I.value))})}),s.jsxs("div",{className:Ms,children:[s.jsx(Kt,{label:o("settings.openchamber.visual.field.lightTheme"),settingsItem:"appearance.light-theme",children:s.jsx(Tc,{options:Aa,value:Ia?.metadata.id??"",onValueChange:Dn,placeholder:o("settings.openchamber.visual.field.selectThemePlaceholder"),ariaLabel:o("settings.openchamber.visual.field.selectLightThemeAria")})}),s.jsx(Kt,{label:o("settings.openchamber.visual.field.darkTheme"),settingsItem:"appearance.dark-theme",children:s.jsx(Tc,{options:Ro,value:Di?.metadata.id??"",onValueChange:Lt,placeholder:o("settings.openchamber.visual.field.selectThemePlaceholder"),ariaLabel:o("settings.openchamber.visual.field.selectDarkThemeAria")})}),s.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[s.jsxs("button",{type:"button",disabled:cn||Xt,onClick:()=>{const I=Date.now();Wt(!0),sn().finally(()=>{const Nt=Date.now()-I;if(Nt<500){window.setTimeout(()=>{Wt(!1)},500-Nt);return}Wt(!1)})},className:"typography-settings-link inline-flex items-center gap-1.5 disabled:cursor-not-allowed disabled:opacity-50 disabled:no-underline",children:[s.jsx($,{name:"restart",className:Ne("h-3.5 w-3.5",Xt&&"animate-spin")}),o(Xt?"settings.openchamber.visual.actions.reloadingThemes":"settings.openchamber.visual.actions.reloadThemes")]}),s.jsx(Gt,{children:o("settings.openchamber.visual.field.themeImportInfoTooltip")})]}),s.jsx(a1,{})]})]}),Mt&&s.jsx(ha,{settingsItem:"appearance.dock-badge",children:s.jsx(bt,{checked:ls,onChange:is,label:o("settings.openchamber.visual.field.dockBadge"),info:o("settings.openchamber.visual.field.dockBadgeHint"),ariaLabel:o("settings.openchamber.visual.field.dockBadge")})}),Fo&&s.jsx(ha,{children:Fo})]}),Mi&&s.jsx(He,{title:o("settings.openchamber.desktopNetwork.field.windowControls"),info:o("settings.openchamber.desktopNetwork.field.windowControlsPositionDescription"),divider:Ta,children:s.jsxs(Fn,{children:[s.jsx(Kt,{label:o("settings.openchamber.desktopNetwork.field.windowControlsPosition"),settingsItem:"sessions.desktop-window-controls-position",children:s.jsx(Xs,{value:ko,options:v1.map(I=>({value:I.id,label:r(I.labelKey)})),onChange:So,"aria-label":o("settings.openchamber.desktopNetwork.field.windowControlsPositionAria")})}),s.jsx(Kt,{label:o("settings.openchamber.desktopNetwork.field.windowControlsStyle"),settingsItem:"sessions.desktop-window-controls-style",children:s.jsx(Xs,{value:wo,options:y1.map(I=>({value:I.id,label:r(I.labelKey)})),onChange:Co,"aria-label":o("settings.openchamber.desktopNetwork.field.windowControlsStyleAria")})})]})}),Ri&&s.jsx(He,{title:o("settings.openchamber.visual.section.localization"),children:s.jsxs(Fn,{children:[s.jsx(Kt,{label:o("settings.appearance.language.label"),info:o("settings.appearance.language.description"),settingsItem:"appearance.language",children:s.jsxs(Dt,{value:e,onValueChange:I=>n(I),children:[s.jsx(Tt,{"aria-label":o("settings.appearance.language.select"),size:Qt,className:Ka,children:s.jsx(Jt,{children:i(e)})}),s.jsx(Et,{children:a.map(I=>s.jsx(gt,{value:I,children:i(I)},I))})]})}),(we("timeFormat")||we("weekStart"))&&s.jsxs("div",{className:Ms,children:[we("timeFormat")&&s.jsx(Kt,{label:o("settings.openchamber.visual.field.timeFormat"),settingsItem:"appearance.time-format",children:s.jsxs(Dt,{value:Ae,onValueChange:I=>Ei(I),children:[s.jsx(Tt,{"aria-label":o("settings.openchamber.visual.field.selectTimeFormatAria"),size:Qt,className:Ka,children:s.jsx(Jt,{children:ss})}),s.jsx(Et,{children:Rc.map(I=>s.jsx(gt,{value:I.id,children:r(I.labelKey)},I.id))})]})}),we("weekStart")&&s.jsx(Kt,{label:o("settings.openchamber.visual.field.weekStartsOn"),settingsItem:"appearance.week-start",children:s.jsxs(Dt,{value:Pe,onValueChange:I=>Mo(I),children:[s.jsx(Tt,{"aria-label":o("settings.openchamber.visual.field.selectWeekStartAria"),size:Qt,className:Ka,children:s.jsx(Jt,{children:Ps})}),s.jsx(Et,{children:Oc.map(I=>s.jsx(gt,{value:I.id,children:r(I.labelKey)},I.id))})]})})]})]})}),(le||Qe||dt)&&s.jsxs(He,{title:o("settings.openchamber.visual.section.appInstall"),contentClassName:Ms,children:[le&&s.jsxs(Ct,{label:o("settings.openchamber.visual.field.installAppName"),info:o("settings.openchamber.visual.field.installAppNameHint"),settingsItem:"appearance.pwa-install-name",alignEnd:!1,controlClassName:Es,children:[s.jsx(Ge,{value:Bt,onChange:I=>{ts(I.target.value)},onBlur:()=>{La(Bt)},onKeyDown:I=>{I.key==="Enter"&&(I.preventDefault(),La(Bt))},className:"min-w-0 flex-1",maxLength:64,"aria-label":o("settings.openchamber.visual.field.pwaInstallAppNameAria")}),s.jsx(V,{size:"sm",type:"button",variant:"ghost",onClick:()=>{ts(di),La("")},className:hs,"aria-label":o("settings.openchamber.visual.actions.resetInstallAppNameAria"),title:o("settings.common.actions.reset"),children:s.jsx($,{name:"restart",className:"h-3.5 w-3.5"})})]}),Qe&&s.jsxs(Ct,{label:o("settings.openchamber.visual.field.installOrientation"),description:o("settings.openchamber.visual.field.installOrientationHint"),settingsItem:"appearance.pwa-orientation",alignEnd:!1,controlClassName:Es,children:[s.jsxs(Dt,{value:Nn,onValueChange:I=>{const Nt=or(I);mn(Nt),ml(Nt)},children:[s.jsx(Tt,{"aria-label":o("settings.openchamber.visual.field.pwaInstallOrientationAria"),size:Qt,className:vl,children:s.jsx(Jt,{placeholder:o("settings.openchamber.visual.field.selectOrientationPlaceholder"),children:Ra})}),s.jsx(Et,{children:Ec.map(I=>s.jsx(gt,{value:I.id,children:r(I.labelKey)},I.id))})]}),s.jsx(V,{size:"sm",type:"button",variant:"ghost",onClick:()=>{mn("system"),ml("system")},disabled:Nn==="system",className:hs,"aria-label":o("settings.openchamber.visual.actions.resetInstallOrientationAria"),title:o("settings.common.actions.reset"),children:s.jsx($,{name:"restart",className:"h-3.5 w-3.5"})})]}),dt&&s.jsxs(Ct,{label:o("settings.openchamber.visual.field.mobileKeyboardMode"),info:o("settings.openchamber.visual.field.mobileKeyboardModeHint"),settingsItem:"appearance.mobile-keyboard-mode",alignEnd:!1,controlClassName:Es,children:[s.jsxs(Dt,{value:he,onValueChange:I=>{const Nt=Ml(I);Ee(Nt),kt({mobileKeyboardMode:Nt})},children:[s.jsx(Tt,{"aria-label":o("settings.openchamber.visual.field.mobileKeyboardModeAria"),size:Qt,className:vl,children:s.jsx(Jt,{placeholder:o("settings.openchamber.visual.field.selectMobileKeyboardModePlaceholder"),children:Oa})}),s.jsx(Et,{children:Dc.map(I=>s.jsx(gt,{value:I.id,children:r(I.labelKey)},I.id))})]}),s.jsx(V,{size:"sm",type:"button",variant:"ghost",onClick:()=>{Ee("native"),kt({mobileKeyboardMode:"native"})},disabled:he==="native",className:hs,"aria-label":o("settings.openchamber.visual.actions.resetMobileKeyboardModeAria"),title:o("settings.common.actions.reset"),children:s.jsx($,{name:"restart",className:"h-3.5 w-3.5"})})]})]})]}),Li&&s.jsxs(He,{title:o("settings.openchamber.visual.section.densityAndType"),contentClassName:Ms,children:[we("fontSize")&&!d||we("terminalFontSize")?s.jsxs(Fn,{children:[we("fontSize")&&!d&&s.jsxs(Kt,{label:o("settings.openchamber.visual.field.interfaceFont"),settingsItem:"appearance.interface-font-size",controlClassName:"w-full",children:[s.jsxs(Dt,{value:Me,onValueChange:I=>me(I),children:[s.jsx(Tt,{"aria-label":o("settings.openchamber.visual.field.selectInterfaceFontAria"),size:Qt,className:Ka,children:s.jsx(Jt,{children:Al.find(I=>I.id===Me)?.label})}),s.jsx(Et,{children:Al.map(I=>s.jsx(gt,{value:I.id,children:s.jsx("span",{style:{fontFamily:I.stack},children:I.label})},I.id))})]}),s.jsx(V,{size:"sm",type:"button",variant:"ghost",onClick:()=>me(Tl),disabled:Me===Tl,className:hs,"aria-label":o("settings.openchamber.visual.actions.resetInterfaceFontAria"),title:o("settings.common.actions.reset"),children:s.jsx($,{name:"restart",className:"h-3.5 w-3.5"})})]}),we("terminalFontSize")&&s.jsxs(Kt,{label:o("settings.openchamber.visual.field.codeFont"),controlClassName:"w-full",children:[s.jsxs(Dt,{value:Te,onValueChange:I=>Oe(I),children:[s.jsx(Tt,{"aria-label":o("settings.openchamber.visual.field.selectCodeFontAria"),size:Qt,className:Ka,children:s.jsx(Jt,{children:El.find(I=>I.id===Te)?.label})}),s.jsx(Et,{children:El.map(I=>s.jsx(gt,{value:I.id,children:s.jsx("span",{style:{fontFamily:I.stack},children:I.label})},I.id))})]}),s.jsx(V,{size:"sm",type:"button",variant:"ghost",onClick:()=>Oe(Dl),disabled:Te===Dl,className:hs,"aria-label":o("settings.openchamber.visual.actions.resetCodeFontAria"),title:o("settings.common.actions.reset"),children:s.jsx($,{name:"restart",className:"h-3.5 w-3.5"})})]})]}):null,we("fontSize")&&!d||we("terminalFontSize")||we("editorFontSize")?s.jsxs(Fn,{children:[we("fontSize")&&!d&&s.jsx(Kt,{label:o("settings.openchamber.visual.field.interfaceFontSize"),controlClassName:"w-full",children:s.jsxs("div",{className:za,children:[s.jsx(js,{value:ke,onValueChange:be,min:50,max:200,step:5,className:ws,"aria-label":o("settings.openchamber.visual.field.fontSizePercentageAria")}),s.jsx("span",{className:Ua,children:"%"}),s.jsx(V,{size:"sm",type:"button",variant:"ghost",onClick:()=>be(100),disabled:ke===100,className:hs,"aria-label":o("settings.openchamber.visual.actions.resetFontSizeAria"),title:o("settings.common.actions.reset"),children:s.jsx($,{name:"restart",className:"h-3.5 w-3.5"})})]})}),we("terminalFontSize")&&s.jsx(Kt,{label:o("settings.openchamber.visual.field.terminalFontSize"),settingsItem:"appearance.terminal-font-size",controlClassName:"w-full",children:s.jsxs("div",{className:za,children:[s.jsx(js,{value:De,onValueChange:oe,min:9,max:52,step:1,className:ws}),s.jsx("span",{className:Ua,children:"px"}),s.jsx(V,{size:"sm",type:"button",variant:"ghost",onClick:()=>oe(13),disabled:De===13,className:hs,"aria-label":o("settings.openchamber.visual.actions.resetTerminalFontSizeAria"),title:o("settings.common.actions.reset"),children:s.jsx($,{name:"restart",className:"h-3.5 w-3.5"})})]})}),we("editorFontSize")&&s.jsx(Kt,{label:o("settings.openchamber.visual.field.editorFontSize"),settingsItem:"appearance.editor-font-size",controlClassName:"w-full",children:s.jsxs("div",{className:za,children:[s.jsx(js,{value:ve,onValueChange:Re,min:9,max:32,step:1,className:ws}),s.jsx("span",{className:Ua,children:"px"}),s.jsx(V,{size:"sm",type:"button",variant:"ghost",onClick:()=>Re(13),disabled:ve===13,className:hs,"aria-label":o("settings.openchamber.visual.actions.resetEditorFontSizeAria"),title:o("settings.common.actions.reset"),children:s.jsx($,{name:"restart",className:"h-3.5 w-3.5"})})]})})]}):null,we("spacing")||we("inputBarOffset")&&d?s.jsxs(Fn,{children:[we("spacing")&&s.jsx(Kt,{label:o("settings.openchamber.visual.field.spacingDensity"),settingsItem:"appearance.spacing-density",controlClassName:"w-full",children:s.jsxs("div",{className:za,children:[s.jsx(js,{value:ge,onValueChange:xe,min:50,max:200,step:5,className:ws}),s.jsx("span",{className:Ua,children:"%"}),s.jsx(V,{size:"sm",type:"button",variant:"ghost",onClick:()=>xe(100),disabled:ge===100,className:hs,"aria-label":o("settings.openchamber.visual.actions.resetSpacingAria"),title:o("settings.common.actions.reset"),children:s.jsx($,{name:"restart",className:"h-3.5 w-3.5"})})]})}),we("inputBarOffset")&&d&&s.jsx(Kt,{label:o("settings.openchamber.visual.field.inputBarOffset"),info:o("settings.openchamber.visual.field.inputBarOffsetTooltip"),settingsItem:"appearance.input-bar-offset",controlClassName:"w-full",children:s.jsxs("div",{className:za,children:[s.jsx(js,{value:ne,onValueChange:ie,min:0,max:100,step:5,className:ws}),s.jsx("span",{className:Ua,children:"px"}),s.jsx(V,{size:"sm",type:"button",variant:"ghost",onClick:()=>ie(0),disabled:ne===0,className:hs,"aria-label":o("settings.openchamber.visual.actions.resetInputBarOffsetAria"),title:o("settings.common.actions.reset"),children:s.jsx($,{name:"restart",className:"h-3.5 w-3.5"})})]})})]}):null,!Ta&&Fo]}),we("animatedActivityIndicators")&&s.jsx(He,{title:o("settings.openchamber.visual.section.sessionActivity"),settingsItem:"appearance.session-activity",contentClassName:ys,children:s.jsx(bt,{checked:E,onChange:D,label:o("settings.openchamber.visual.field.animatedActivityIndicators"),ariaLabel:o("settings.openchamber.visual.field.animatedActivityIndicatorsAria"),info:o("settings.openchamber.visual.field.animatedActivityIndicatorsInfo"),settingsItem:"appearance.animated-activity-indicators"})}),Fi&&s.jsxs(He,{title:o("settings.openchamber.visual.section.navigation"),contentClassName:"space-y-4",children:[we("fileEditorKeymap")&&s.jsx(Ss,{title:o("settings.openchamber.visual.field.fileEditorKeymap"),settingsItem:"appearance.file-editor-keymap",children:s.jsx(Js,{"aria-label":o("settings.openchamber.visual.field.fileEditorKeymap"),children:["default","vim"].map(I=>s.jsx(rs,{selected:vt===I,onSelect:()=>wt(I),label:o(`settings.openchamber.visual.option.fileEditorKeymap.${I}`),ariaLabel:o(`settings.openchamber.visual.option.fileEditorKeymap.${I}`)},I))})}),s.jsxs("div",{className:ys,children:[we("autoSaveEnabled")&&s.jsx(bt,{checked:B,onChange:G,label:o("settings.openchamber.visual.field.autoSaveEnabled"),ariaLabel:o("settings.openchamber.visual.field.autoSaveEnabledAria"),info:o("settings.openchamber.visual.field.autoSaveEnabledInfo"),settingsItem:"appearance.auto-save-enabled"}),Ut&&s.jsx(Kt,{label:o("settings.openchamber.visual.field.terminalShell"),info:o("settings.openchamber.visual.field.terminalShellHint"),settingsItem:"appearance.terminal-shell",className:"pt-2",children:s.jsxs(Dt,{value:ee,onValueChange:I=>{Ym(I)&&ce(I)},children:[s.jsx(Tt,{"aria-label":o("settings.openchamber.visual.field.terminalShellAria"),size:Qt,className:Ka,children:s.jsx(Jt,{})}),s.jsxs(Et,{children:[s.jsx(gt,{value:"auto",children:o("settings.openchamber.visual.option.terminalShell.auto")}),Rn.map(I=>s.jsx(gt,{value:I.id,children:I.name},I.id))]})]})}),Ut&&wn&&s.jsx(bt,{checked:Da,onChange:Ma,label:o("settings.openchamber.visual.field.terminalLoginShell"),ariaLabel:o("settings.openchamber.visual.field.terminalLoginShell"),settingsItem:"appearance.terminal-login-shell"}),we("terminalQuickKeys")&&!d&&s.jsx(bt,{checked:Se,onChange:pt,label:o("settings.openchamber.visual.field.terminalQuickKeys"),ariaLabel:o("settings.openchamber.visual.field.terminalQuickKeysAria"),settingsItem:"appearance.terminal-quick-keys",info:o("settings.openchamber.visual.field.terminalQuickKeysTooltip",{control:xa("ctrl"),alt:xa("alt")})})]}),we("sessionTabs")&&!Is&&!d&&s.jsx(Ss,{title:o("settings.openchamber.visual.field.sessionTabsGroup"),settingsItem:"appearance.session-tabs",children:s.jsx(bt,{checked:$e,onChange:Ye,label:o("settings.openchamber.visual.field.sessionTabs"),ariaLabel:o("settings.openchamber.visual.field.sessionTabsAria"),info:o("settings.openchamber.visual.field.sessionTabsInfo")})})]}),Oo&&s.jsxs(s.Fragment,{children:[kn&&s.jsxs(He,{title:o("settings.openchamber.visual.section.chatDisplay"),divider:R,contentClassName:"space-y-6",children:[we("chatRenderMode")&&s.jsx(Ss,{title:o("settings.openchamber.visual.section.chatRenderMode"),settingsItem:"chat.render-mode",children:s.jsx("div",{role:"radiogroup","aria-label":o("settings.openchamber.visual.section.chatRenderModeAria"),className:"grid w-full max-w-[26rem] grid-cols-1 gap-3 @xl:grid-cols-2",children:p1.map(I=>{const Nt=X===I.id,vs=No%12;return s.jsxs("button",{type:"button",onClick:()=>Ao(I.id),"aria-pressed":Nt,className:Ne("flex flex-col items-start gap-1 rounded-lg border p-3 text-left transition-colors",Nt?"border-border bg-interactive-selection text-interactive-selection-foreground":"border-border hover:border-border/80 hover:bg-interactive-hover"),children:[s.jsx("span",{className:Ne("typography-ui-label",Nt?"text-inherit":"text-muted-foreground"),children:r(I.labelKey)}),s.jsx("div",{className:"mt-2 w-full rounded-md border border-border/60 bg-muted/30 p-2",children:I.id==="live"?s.jsx("div",{className:"space-y-1.5",children:[0,1,2].map(Ls=>{const Sn=Ls*3+1,aa=vs-Sn+1,Ki=aa<=0?0:aa===1?42:aa===2?68:92,fu=Ki>0;return s.jsxs("div",{className:Ne("flex items-center gap-1.5 transition-all duration-300 motion-reduce:transition-none",fu?"translate-y-0 opacity-100":"translate-y-1 opacity-0"),children:[s.jsx("span",{className:"h-2 w-2 shrink-0 rounded-full bg-muted-foreground/55"}),s.jsx("span",{className:"h-1.5 rounded bg-muted-foreground/30 transition-all duration-300 motion-reduce:transition-none",style:{width:`${Ki}%`}})]},Ls)})}):s.jsx("div",{className:"space-y-1.5",children:[0,1,2].map(Ls=>{const Sn=vs>=(Ls+1)*3;return s.jsxs("div",{className:Ne("flex items-center gap-1.5 transition-all duration-300 motion-reduce:transition-none",Sn?"translate-y-0 opacity-100":"translate-y-1 opacity-0"),children:[s.jsx("span",{className:"h-2 w-2 shrink-0 rounded-full bg-muted-foreground/55"}),s.jsx("span",{className:"h-1.5 rounded bg-muted-foreground/30",style:{width:"92%"}})]},Ls)})})})]},I.id)})})}),we("activityRenderMode")&&s.jsx(Ss,{title:o("settings.openchamber.visual.section.activityDefault"),settingsItem:"chat.activity-default",children:s.jsx(Js,{"aria-label":o("settings.openchamber.visual.section.activityDefaultAria"),children:g1.map(I=>s.jsx(rs,{selected:je===I.id,onSelect:()=>ii(I.id),label:r(I.labelKey),ariaLabel:o("settings.openchamber.visual.field.activityDefaultModeAria",{option:r(I.labelKey)})},I.id))})})]}),Zn&&s.jsxs(He,{title:o("settings.openchamber.visual.section.messageStreamTransport"),divider:kn||R,settingsItem:"chat.message-transport",contentClassName:"space-y-2",children:[s.jsx(Xs,{value:Zt,options:Mc.map(I=>({value:I.id,label:r(I.labelKey)})),onChange:wa,"aria-label":o("settings.openchamber.visual.section.messageStreamTransport")}),(()=>{const I=Mc.find(Nt=>Nt.id===Zt);return I?.descriptionKey?s.jsx("span",{className:"typography-meta text-muted-foreground",children:r(I.descriptionKey)}):null})()]}),Ea&&s.jsx(He,{title:o("settings.openchamber.visual.section.chatMessageOptions"),divider:kn||Zn||R,children:s.jsxs(Fn,{className:"lg:gap-y-6",children:[we("userMessageRendering")&&s.jsx(Ss,{title:o("settings.openchamber.visual.section.userMessageRendering"),children:s.jsx(Js,{"aria-label":o("settings.openchamber.visual.section.userMessageRenderingAria"),children:m1.map(I=>s.jsx(rs,{selected:b1(P)===I.id,onSelect:()=>Io(I.id),label:r(I.labelKey),ariaLabel:o("settings.openchamber.visual.field.userMessageRenderingAria",{option:r(I.labelKey)})},I.id))})}),we("mermaidRendering")&&s.jsx(Ss,{title:o("settings.openchamber.visual.section.mermaidRendering"),children:s.jsx(Js,{"aria-label":o("settings.openchamber.visual.section.mermaidRenderingAria"),children:u1.map(I=>s.jsx(rs,{selected:F===I.id,onSelect:()=>To(I.id),label:r(I.labelKey),ariaLabel:o("settings.openchamber.visual.field.mermaidRenderingAria",{option:r(I.labelKey)})},I.id))})}),we("diffLayout")&&!Is&&s.jsx(Ss,{title:o("settings.openchamber.visual.section.diffLayout"),children:s.jsx(Js,{"aria-label":o("settings.openchamber.visual.section.diffLayoutAria"),children:d1.map(I=>s.jsx(rs,{selected:Ke===I.id,onSelect:()=>Le(I.id),label:r(I.labelKey),ariaLabel:o("settings.openchamber.visual.field.diffLayoutAria",{option:r(I.labelKey)})},I.id))})}),we("followUpBehavior")&&s.jsx(Ss,{title:o("settings.openchamber.visual.section.followUpBehavior"),settingsItem:"chat.follow-up-behavior",children:s.jsx(Js,{"aria-label":o("settings.openchamber.visual.section.followUpBehaviorAria"),children:f1.map(I=>s.jsx(rs,{selected:yt===I.id,onSelect:()=>st(I.id),label:r(I.labelKey),ariaLabel:o("settings.openchamber.visual.field.followUpBehaviorAria",{option:r(I.labelKey)})},I.id))})}),we("inputHistoryScope")&&s.jsx(Ss,{title:o("settings.openchamber.visual.field.inputHistoryScope"),info:o("settings.openchamber.visual.field.inputHistoryScopeDescription"),settingsItem:"chat.input-history-scope",children:s.jsx(Js,{"aria-label":o("settings.openchamber.visual.section.inputHistoryScopeAria"),children:x1.map(I=>s.jsx(rs,{selected:rt===I.id,onSelect:()=>Na(I.id),label:r(I.labelKey),ariaLabel:r(I.labelKey)},I.id))})}),we("inputHistoryLimit")&&s.jsx(Ss,{title:o("settings.openchamber.visual.field.inputHistoryLimit"),description:o("settings.openchamber.visual.field.inputHistoryLimitDescription"),contentClassName:Es,settingsItem:"chat.input-history-limit",children:s.jsxs("div",{className:za,children:[s.jsx(js,{value:de,onValueChange:na,min:Xm,max:Zm,step:1,className:ws,deferExternalValueWhileFocused:!0,"aria-label":o("settings.openchamber.visual.field.inputHistoryLimitAria")}),s.jsx("span",{className:Ua,children:o("settings.openchamber.visual.field.inputHistoryLimitUnit")})]})})]})}),Lo&&s.jsxs(s.Fragment,{children:[we("expandedTools")&&s.jsxs(He,{title:o("settings.openchamber.visual.section.showToolsOpenedByDefault"),divider:kn||Zn||Ea||R,contentClassName:ys,children:[s.jsx(bt,{checked:mt,onChange:Ca,label:o("settings.openchamber.visual.field.bash"),ariaLabel:o("settings.openchamber.visual.field.showExpandedBashToolsAria")}),s.jsx(bt,{checked:W,onChange:Do,label:o("settings.openchamber.visual.field.editTools"),ariaLabel:o("settings.openchamber.visual.field.showExpandedEditToolsAria")})]}),s.jsxs(He,{title:o("settings.openchamber.visual.section.sessionAssistance"),settingsItem:"chat.session-assistance",contentClassName:ys,children:[s.jsx(bt,{checked:Ve,onChange:dn,label:o("settings.openchamber.visual.field.draftStartersVisible"),ariaLabel:o("settings.openchamber.visual.field.draftStartersVisibleAria"),settingsItem:"chat.draft-starters-visible"}),we("sessionAssist")&&s.jsxs(s.Fragment,{children:[s.jsx(bt,{checked:f,onChange:b,label:o("settings.openchamber.visual.field.sessionRecap"),ariaLabel:o("settings.openchamber.visual.field.sessionRecapAria"),settingsItem:"chat.session-recap"}),s.jsx(bt,{checked:p,onChange:C,label:o("settings.openchamber.visual.field.sessionSuggestion"),ariaLabel:o("settings.openchamber.visual.field.sessionSuggestionAria"),settingsItem:"chat.session-suggestion"})]}),we("subagentReadOnlyBanner")&&s.jsx(bt,{checked:ut,onChange:Ce,label:o("settings.openchamber.visual.field.allowPromptingSubagentSessions"),ariaLabel:o("settings.openchamber.visual.field.allowPromptingSubagentSessionsAria"),settingsItem:"chat.subagent-read-only-banner"})]}),we("sessionGoal")&&!Is&&s.jsxs(He,{title:o("settings.openchamber.visual.goal.sectionTitle"),info:o("settings.openchamber.visual.goal.description"),contentClassName:ys,children:[s.jsx(bt,{checked:v,onChange:k,label:o("settings.openchamber.visual.field.sessionGoal"),ariaLabel:o("settings.openchamber.visual.field.sessionGoalAria"),settingsItem:"chat.session-goal"}),s.jsx(o1,{disabled:!v}),s.jsxs("div",{"data-settings-item":"chat.session-goal-budget",className:"flex items-center gap-2",children:[s.jsx(bt,{checked:u,onChange:y,disabled:!v,label:o("settings.openchamber.visual.goal.budgetLabel"),ariaLabel:o("settings.openchamber.visual.goal.budgetAria")}),v&&u?s.jsx(js,{value:S,onValueChange:I=>{typeof I=="number"&&Number.isFinite(I)&&I>0&&N(Math.floor(I))},min:1e3,max:1e8,step:5e4}):null]})]}),we("reasoning")&&s.jsxs(He,{title:o("settings.openchamber.visual.section.reasoning"),settingsItem:"chat.reasoning",contentClassName:ys,children:[s.jsx(bt,{checked:h,onChange:w,label:o("settings.openchamber.visual.field.showReasoningTraces"),ariaLabel:o("settings.openchamber.visual.field.showReasoningTracesAria"),settingsItem:"chat.reasoning-traces"}),h&&s.jsx(bt,{checked:T,onChange:M,label:o("settings.openchamber.visual.field.collapsibleThinkingBlocks"),ariaLabel:o("settings.openchamber.visual.field.collapsibleThinkingBlocksAria")})]}),s.jsx(He,{title:o("settings.openchamber.visual.section.streaming"),settingsItem:"chat.streaming",contentClassName:ys,children:s.jsx(bt,{checked:A,onChange:x,label:o("settings.openchamber.visual.field.streamingAutoFollow"),ariaLabel:o("settings.openchamber.visual.field.streamingAutoFollowAria"),info:o("settings.openchamber.visual.field.streamingAutoFollowInfo"),settingsItem:"chat.streaming-auto-follow"})}),(we("collapsibleUserMessages")||we("stickyUserHeader")||we("promptNavigatorEnabled")||we("wideChatLayout")||we("splitAssistantMessageActions")||we("codeBlockLineWrap"))&&s.jsxs(He,{title:o("settings.openchamber.visual.section.messageAppearance"),settingsItem:"chat.message-appearance",contentClassName:ys,children:[we("collapsibleUserMessages")&&s.jsx(bt,{checked:O,onChange:ka,label:o("settings.openchamber.visual.field.collapsibleUserMessages"),ariaLabel:o("settings.openchamber.visual.field.collapsibleUserMessagesAria"),settingsItem:"chat.collapsible-user-messages"}),we("stickyUserHeader")&&s.jsx(bt,{checked:H,onChange:Po,label:o("settings.openchamber.visual.field.stickyUserHeader"),ariaLabel:o("settings.openchamber.visual.field.stickyUserHeaderAria"),settingsItem:"chat.sticky-user-header"}),we("promptNavigatorEnabled")&&s.jsx(bt,{checked:q,onChange:Ns,label:o("settings.openchamber.visual.field.promptNavigatorEnabled"),ariaLabel:o("settings.openchamber.visual.field.promptNavigatorEnabledAria"),settingsItem:"chat.prompt-navigator"}),we("wideChatLayout")&&s.jsx(bt,{checked:_,onChange:Mn,label:o("settings.openchamber.visual.field.wideChatLayout"),ariaLabel:o("settings.openchamber.visual.field.wideChatLayoutAria"),settingsItem:"chat.wide-layout"}),we("splitAssistantMessageActions")&&s.jsx(bt,{checked:se,onChange:Qn,label:o("settings.openchamber.visual.field.showSplitAssistantMessageActions"),ariaLabel:o("settings.openchamber.visual.field.showSplitAssistantMessageActionsAria"),settingsItem:"chat.inline-assistant-actions",info:o("settings.openchamber.visual.field.showSplitAssistantMessageActionsTooltip")}),we("codeBlockLineWrap")&&s.jsx(bt,{checked:te,onChange:Q,label:o("settings.openchamber.visual.field.codeBlockLineWrap"),ariaLabel:o("settings.openchamber.visual.field.codeBlockLineWrapAria"),settingsItem:"chat.code-block-line-wrap"})]}),(we("showToolFileIcons")||we("showTurnChangedFiles")||we("dotfiles")&&!ps()||we("fileViewerPreview"))&&s.jsxs(He,{title:o("settings.openchamber.visual.section.toolsAndFiles"),settingsItem:"chat.tools-and-files",contentClassName:ys,children:[we("showToolFileIcons")&&s.jsx(bt,{checked:St,onChange:fs,label:o("settings.openchamber.visual.field.showToolFileIcons"),ariaLabel:o("settings.openchamber.visual.field.showToolFileIconsAria"),settingsItem:"chat.tool-file-icons"}),we("showTurnChangedFiles")&&s.jsx(bt,{checked:_e,onChange:Eo,label:o("settings.openchamber.visual.field.showTurnChangedFiles"),ariaLabel:o("settings.openchamber.visual.field.showTurnChangedFilesAria"),settingsItem:"chat.changed-files"}),we("dotfiles")&&!ps()&&s.jsx(bt,{checked:m,onChange:ep,label:o("settings.openchamber.visual.field.showDotfiles"),ariaLabel:o("settings.openchamber.visual.field.showDotfilesAria"),settingsItem:"chat.dotfiles"}),we("fileViewerPreview")&&s.jsx(bt,{checked:Ft,onChange:Sa,label:o("settings.openchamber.defaults.field.openFilesPreview"),ariaLabel:o("settings.openchamber.defaults.field.openFilesPreviewAria")})]}),(we("persistDraft")||we("largeTextPaste")||!d&&we("inputSpellcheck")||we("enterToSend"))&&s.jsxs(He,{title:o("settings.openchamber.visual.section.composer"),settingsItem:"chat.composer",contentClassName:"space-y-6",children:[(we("persistDraft")||!d&&we("inputSpellcheck"))&&s.jsxs("div",{className:ys,children:[we("persistDraft")&&s.jsx(bt,{checked:ze,onChange:Ze,label:o("settings.openchamber.visual.field.persistDraftMessages"),ariaLabel:o("settings.openchamber.visual.field.persistDraftMessagesAria"),settingsItem:"chat.persist-drafts"}),!d&&we("inputSpellcheck")&&s.jsx(bt,{checked:tt,onChange:ul,label:o("settings.openchamber.visual.field.enableSpellcheckInTextInputs"),ariaLabel:o("settings.openchamber.visual.field.enableSpellcheckInTextInputsAria"),settingsItem:"chat.spellcheck"})]}),we("largeTextPaste")&&s.jsx(Ss,{title:o("settings.openchamber.visual.field.largeTextPaste"),info:o("settings.openchamber.visual.field.largeTextPasteHint"),settingsItem:"chat.large-text-paste",children:s.jsx(Js,{"aria-label":o("settings.openchamber.visual.field.largeTextPasteAria"),children:h1.map(I=>s.jsx(rs,{selected:J===I.id,onSelect:()=>nt(I.id),label:r(I.labelKey),ariaLabel:o("settings.openchamber.visual.field.largeTextPasteOptionAria",{option:r(I.labelKey)})},I.id))})}),we("enterToSend")&&s.jsx(Ss,{title:o("settings.openchamber.visual.field.enterToSend"),info:o("settings.openchamber.visual.field.enterToSendHint"),settingsItem:"chat.enter-to-send",children:s.jsxs(Js,{"aria-label":o("settings.openchamber.visual.field.enterToSend"),children:[s.jsx(rs,{selected:ht,onSelect:()=>un(!0),label:o("settings.openchamber.visual.option.enterToSend.enter.label"),ariaLabel:o("settings.openchamber.visual.option.enterToSend.enter.label")}),s.jsx(rs,{selected:!ht,onSelect:()=>un(!1),label:o("settings.openchamber.visual.option.enterToSend.modifier.label"),ariaLabel:o("settings.openchamber.visual.option.enterToSend.modifier.label")})]})})]})]})]}),we("reportUsage")&&s.jsx(He,{title:o("settings.openchamber.visual.section.privacy"),children:s.jsx(bt,{checked:ai,onChange:Ai,label:o("settings.openchamber.visual.field.sendAnonymousUsageReports"),info:o("settings.openchamber.visual.field.sendAnonymousUsageReportsHint"),ariaLabel:o("settings.openchamber.visual.field.sendAnonymousUsageReportsAria"),settingsItem:"appearance.usage-reports"})})]})},j1=1,k1=365,Lc=30,w1=[{value:"archive",labelKey:"settings.openchamber.sessionRetention.action.archive"},{value:"delete",labelKey:"settings.openchamber.sessionRetention.action.delete"}],su=()=>{const t=Be.c(105),{t:e}=qe(),a=re(N1),n=re(S1),i=re(C1),o=re(I1),r=re(P1),d=re(A1),c=re(T1);let g;t[0]===Symbol.for("react.memo_cache_sentinel")?(g={autoRun:!1},t[0]=g):g=t[0];const{candidates:m,isRunning:h,runCleanup:f,action:p,status:b}=cm(g),C=m.length;let v;t[1]!==f||t[2]!==e?(v=async()=>{const ce=await f({force:!0}).catch(()=>(U.error(e("sessions.sidebar.group.empty.loadFailed")),null));if(!(!ce||ce.skippedReason&&ce.skippedReason!=="no-candidates")){if(ce.completedIds.length===0&&ce.failedIds.length===0){U.message(ce.action==="archive"?e("settings.openchamber.sessionRetention.toast.noneEligibleArchive"):e("settings.openchamber.sessionRetention.toast.noneEligibleDelete"));return}ce.completedIds.length>0&&U.success(ce.action==="archive"?e("settings.openchamber.sessionRetention.toast.archivedCount",{count:ce.completedIds.length}):e("settings.openchamber.sessionRetention.toast.deletedCount",{count:ce.completedIds.length})),ce.failedIds.length>0&&U.error(ce.action==="archive"?e("settings.openchamber.sessionRetention.toast.failedArchiveCount",{count:ce.failedIds.length}):e("settings.openchamber.sessionRetention.toast.failedDeleteCount",{count:ce.failedIds.length}))}},t[1]=f,t[2]=e,t[3]=v):v=t[3];const k=v;let u;t[4]!==e?(u=e("settings.openchamber.sessionRetention.title"),t[4]=e,t[5]=u):u=t[5];const y=i?"settings.openchamber.sessionRetention.archivedTooltip":"settings.openchamber.sessionRetention.tooltip";let S;t[6]!==e||t[7]!==y?(S=e(y),t[6]=e,t[7]=y,t[8]=S):S=t[8];let N;t[9]!==e?(N=e("settings.openchamber.sessionRetention.field.enableAutoCleanup"),t[9]=e,t[10]=N):N=t[10];let w;t[11]!==e?(w=e("settings.openchamber.sessionRetention.field.enableAutoCleanupAria"),t[11]=e,t[12]=w):w=t[12];let A;t[13]!==a||t[14]!==o||t[15]!==N||t[16]!==w?(A=s.jsx(bt,{settingsItem:"sessions.auto-cleanup",checked:a,onChange:o,label:N,ariaLabel:w}),t[13]=a,t[14]=o,t[15]=N,t[16]=w,t[17]=A):A=t[17];let x;t[18]!==e?(x=e("settings.openchamber.sessionRetention.field.onlyArchived"),t[18]=e,t[19]=x):x=t[19];let T;t[20]!==e?(T=e("settings.openchamber.sessionRetention.field.onlyArchived"),t[20]=e,t[21]=T):T=t[21];let M;t[22]!==e?(M=e("settings.openchamber.sessionRetention.field.onlyArchivedDescription"),t[22]=e,t[23]=M):M=t[23];let E;t[24]!==h||t[25]!==i||t[26]!==c||t[27]!==M||t[28]!==x||t[29]!==T?(E=s.jsx(bt,{settingsItem:"sessions.retention-only-archived",checked:i,onChange:c,disabled:h,label:x,ariaLabel:T,info:M}),t[24]=h,t[25]=i,t[26]=c,t[27]=M,t[28]=x,t[29]=T,t[30]=E):E=t[30];let D;t[31]!==e?(D=e("settings.openchamber.sessionRetention.field.retentionPeriod"),t[31]=e,t[32]=D):D=t[32];let F;t[33]!==e?(F=e("settings.openchamber.sessionRetention.field.retentionPeriodAria"),t[33]=e,t[34]=F):F=t[34];let L;t[35]===Symbol.for("react.memo_cache_sentinel")?(L=Ne(ws,"tabular-nums"),t[35]=L):L=t[35];let P;t[36]!==n||t[37]!==r||t[38]!==F?(P=s.jsx(js,{value:n,onValueChange:r,min:j1,max:k1,step:1,"aria-label":F,className:L}),t[36]=n,t[37]=r,t[38]=F,t[39]=P):P=t[39];let j;t[40]!==e?(j=e("settings.openchamber.sessionRetention.field.days"),t[40]=e,t[41]=j):j=t[41];let O;t[42]!==j?(O=s.jsx("span",{className:"typography-ui-label text-muted-foreground",children:j}),t[42]=j,t[43]=O):O=t[43];let K;t[44]!==r?(K=()=>r(Lc),t[44]=r,t[45]=K):K=t[45];const H=n===Lc;let q;t[46]!==e?(q=e("settings.openchamber.sessionRetention.actions.resetRetentionAria"),t[46]=e,t[47]=q):q=t[47];let Z;t[48]!==e?(Z=e("settings.common.actions.reset"),t[48]=e,t[49]=Z):Z=t[49];let ae;t[50]===Symbol.for("react.memo_cache_sentinel")?(ae=s.jsx($,{name:"restart",className:"h-3.5 w-3.5"}),t[50]=ae):ae=t[50];let B;t[51]!==K||t[52]!==H||t[53]!==q||t[54]!==Z?(B=s.jsx(V,{size:"sm",type:"button",variant:"ghost",onClick:K,disabled:H,className:hs,"aria-label":q,title:Z,children:ae}),t[51]=K,t[52]=H,t[53]=q,t[54]=Z,t[55]=B):B=t[55];let G;t[56]!==D||t[57]!==P||t[58]!==O||t[59]!==B?(G=s.jsxs(Ct,{settingsItem:"sessions.retention-period",label:D,children:[P,O,B]}),t[56]=D,t[57]=P,t[58]=O,t[59]=B,t[60]=G):G=t[60];let _;t[61]!==e?(_=e("settings.openchamber.sessionRetention.field.whenSessionsExpire"),t[61]=e,t[62]=_):_=t[62];let z;t[63]!==i||t[64]!==e?(z=w1.map(ce=>({value:ce.value,label:e(ce.labelKey),disabled:i&&ce.value==="archive"})),t[63]=i,t[64]=e,t[65]=z):z=t[65];let te;t[66]!==p||t[67]!==d||t[68]!==z?(te=s.jsx(Xs,{value:p,onChange:d,options:z}),t[66]=p,t[67]=d,t[68]=z,t[69]=te):te=t[69];let Q;t[70]!==_||t[71]!==te?(Q=s.jsx(Ct,{settingsItem:"sessions.retention-action",label:_,children:te}),t[70]=_,t[71]=te,t[72]=Q):Q=t[72];let X;t[73]!==E||t[74]!==G||t[75]!==Q?(X=s.jsxs(ha,{className:"space-y-0",children:[E,G,Q]}),t[73]=E,t[74]=G,t[75]=Q,t[76]=X):X=t[76];let pe;t[77]!==e?(pe=e("settings.openchamber.sessionRetention.manualCleanup.title"),t[77]=e,t[78]=pe):pe=t[78];let je;t[79]!==h||t[80]!==e?(je=e(h?"settings.openchamber.sessionRetention.actions.cleaningUp":"settings.openchamber.sessionRetention.actions.runCleanupNow"),t[79]=h,t[80]=e,t[81]=je):je=t[81];let fe;t[82]!==k||t[83]!==h||t[84]!==je?(fe=s.jsx(V,{type:"button",variant:"outline",size:"xs",onClick:k,disabled:h,className:"!font-normal",children:je}),t[82]=k,t[83]=h,t[84]=je,t[85]=fe):fe=t[85];let ke;t[86]!==pe||t[87]!==fe?(ke=s.jsx(Ct,{label:pe,children:fe}),t[86]=pe,t[87]=fe,t[88]=ke):ke=t[88];let be;t[89]!==p||t[90]!==C||t[91]!==b||t[92]!==e?(be=b==="error"?e("sessions.sidebar.group.empty.loadFailed"):b!=="ready"?e("sessions.sidebar.group.empty.loadingSessions"):p==="archive"?e("settings.openchamber.sessionRetention.manualCleanup.eligibleArchiveNow",{count:C}):e("settings.openchamber.sessionRetention.manualCleanup.eligibleDeleteNow",{count:C}),t[89]=p,t[90]=C,t[91]=b,t[92]=e,t[93]=be):be=t[93];let De;t[94]!==be?(De=s.jsx("p",{className:"typography-meta text-muted-foreground",children:be}),t[94]=be,t[95]=De):De=t[95];let oe;t[96]!==ke||t[97]!==De?(oe=s.jsxs("div",{className:"mt-1 py-1.5 space-y-1",children:[ke,De]}),t[96]=ke,t[97]=De,t[98]=oe):oe=t[98];let ee;return t[99]!==u||t[100]!==X||t[101]!==oe||t[102]!==S||t[103]!==A?(ee=s.jsxs(He,{title:u,info:S,children:[A,X,oe]}),t[99]=u,t[100]=X,t[101]=oe,t[102]=S,t[103]=A,t[104]=ee):ee=t[104],ee};function N1(t){return t.autoDeleteEnabled}function S1(t){return t.autoDeleteAfterDays}function C1(t){return t.sessionRetentionOnlyArchived}function I1(t){return t.setAutoDeleteEnabled}function P1(t){return t.setAutoDeleteAfterDays}function A1(t){return t.setSessionRetentionAction}function T1(t){return t.setSessionRetentionOnlyArchived}const nu=()=>{const t=Be.c(25),{t:e}=qe();let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=ps(),t[0]=a):a=t[0];const n=a,i=re(E1),o=re(D1),r=re(M1),d=re(R1),c=es($r);let g;t[1]!==e?(g=e("settings.openchamber.sessionWork.title"),t[1]=e,t[2]=g):g=t[2];let m;t[3]!==e?(m=e("settings.openchamber.sessionWork.info"),t[3]=e,t[4]=m):m=t[4];let h;t[5]!==e?(h=e("settings.openchamber.sessionWork.field.enabled"),t[5]=e,t[6]=h):h=t[6];let f;t[7]!==e?(f=e("settings.openchamber.sessionWork.field.enabled"),t[7]=e,t[8]=f):f=t[8];let p;t[9]!==i||t[10]!==r||t[11]!==h||t[12]!==f?(p=s.jsx(bt,{settingsItem:"sessions.work-enabled",checked:i,onChange:r,label:h,ariaLabel:f}),t[9]=i,t[10]=r,t[11]=h,t[12]=f,t[13]=p):p=t[13];let b;t[14]!==o||t[15]!==i||t[16]!==c||t[17]!==d||t[18]!==e?(b=n?null:s.jsxs(ha,{className:"space-y-0",children:[s.jsx(bt,{settingsItem:"sessions.work-auto-open",checked:i&&c&&o,onChange:d,disabled:!i||!c,label:e("settings.openchamber.sessionWork.field.autoOpen"),ariaLabel:e("settings.openchamber.sessionWork.field.autoOpen"),info:e("settings.openchamber.sessionWork.field.autoOpenInfo")}),s.jsx(xo,{})]}),t[14]=o,t[15]=i,t[16]=c,t[17]=d,t[18]=e,t[19]=b):b=t[19];let C;return t[20]!==g||t[21]!==m||t[22]!==p||t[23]!==b?(C=s.jsxs(He,{title:g,info:m,settingsItem:"sessions.work",children:[p,b]}),t[20]=g,t[21]=m,t[22]=p,t[23]=b,t[24]=C):C=t[24],C};function E1(t){return t.sessionWorkEnabled}function D1(t){return t.sessionWorkAutoOpen}function M1(t){return t.setSessionWorkEnabled}function R1(t){return t.setSessionWorkAutoOpen}const Fc=(t,e,a)=>!t||!Number.isFinite(t)?e:new Intl.DateTimeFormat(zr(),{dateStyle:"medium",timeStyle:"short",hour12:a==="auto"?void 0:a==="12h"}).format(t),au=()=>{const{t}=qe(),e=re(A=>A.timeFormatPreference),[a,n]=l.useState(!1),[i,o]=l.useState(!0),[r,d]=l.useState(!1),[c,g]=l.useState(null),[m,h]=l.useState(!1),[f,p]=l.useState([]),[b,C]=l.useState(dm),[v,k]=l.useState(""),u=l.useMemo(()=>um(),[]),y=l.useCallback(async()=>{o(!0),k("");try{const A=await mm();p(A)}catch(A){const x=A instanceof Error?A.message:t("settings.openchamber.passkeys.toast.loadFailed");k(x)}finally{o(!1)}},[t]);l.useEffect(()=>{let A=!1;return(async()=>{try{if(!u.supported){A||(n(!1),o(!1));return}A||n(!0)}catch{A||n(!1)}if(!A){const x=await Uo();if(C(x),!x.enabled){p([]),o(!1);return}await y()}})(),()=>{A=!0,yl()}},[y,u.supported]);const S=l.useCallback(async()=>{if(!b.enabled){const A=t("settings.openchamber.passkeys.toast.enableUiPasswordFirst");k(A),U.message(A);return}if(!a){k(u.reason),U.message(u.reason);return}if(r){yl(),d(!1);return}k(""),d(!0);try{await pm(),C(await Uo()),await y(),U.success(t("settings.openchamber.passkeys.toast.added"))}catch(A){if(gm(A)){U.message(t("settings.openchamber.passkeys.toast.setupCanceled"));return}const x=A instanceof Error?A.message:t("settings.openchamber.passkeys.toast.addFailed");k(x),U.error(x)}finally{d(!1)}},[r,y,b.enabled,u.reason,a,t]),N=l.useCallback(async A=>{g(A),k("");try{await fm(A),C(await Uo()),await y(),U.success(t("settings.openchamber.passkeys.toast.removed"))}catch(x){const T=x instanceof Error?x.message:t("settings.openchamber.passkeys.toast.removeFailed");k(T),U.error(T)}finally{g(null)}},[y,t]),w=l.useCallback(async()=>{h(!0),k("");try{await hm(),window.location.reload()}catch(A){const x=A instanceof Error?A.message:t("settings.openchamber.passkeys.toast.clearAuthFailed");k(x),U.error(x),h(!1)}},[t]);return s.jsxs(He,{title:t("settings.openchamber.passkeys.title"),children:[s.jsxs("div",{className:"space-y-2",children:[s.jsxs(Ct,{label:t("settings.openchamber.passkeys.field.currentDevice"),children:[s.jsx(V,{type:"button",variant:r?"secondary":"outline",size:"xs",onClick:()=>{S()},disabled:i||m,className:"!font-normal",children:t(r?"settings.openchamber.passkeys.actions.cancelSetup":"settings.openchamber.passkeys.actions.add")}),s.jsx(V,{type:"button",variant:"ghost",size:"xs",onClick:()=>{w()},disabled:i||r||m,className:"!font-normal text-muted-foreground hover:text-foreground",children:t(m?"settings.openchamber.passkeys.actions.signingOut":"settings.openchamber.passkeys.actions.signOutEverywhere")})]}),!b.enabled&&s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.openchamber.passkeys.state.uiPasswordRequired")}),b.enabled&&!a&&s.jsx("p",{className:"typography-meta text-muted-foreground",children:u.reason}),i?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.openchamber.passkeys.state.loading")}):f.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.openchamber.passkeys.state.noneSaved")}):s.jsx("div",{className:"space-y-1 pt-1",children:f.map(A=>s.jsxs(Ct,{label:s.jsx("span",{title:A.label,children:A.label}),alignEnd:!1,controlClassName:"justify-between sm:flex-1",children:[s.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:A.lastUsedAt?t("settings.openchamber.passkeys.item.lastUsed",{time:Fc(A.lastUsedAt,t("settings.openchamber.passkeys.time.neverUsed"),e)}):t("settings.openchamber.passkeys.item.added",{time:Fc(A.createdAt,t("settings.openchamber.passkeys.time.neverUsed"),e)})}),s.jsx(V,{type:"button",variant:"ghost",size:"xs",onClick:()=>{N(A.id)},disabled:c===A.id,className:"!font-normal text-muted-foreground hover:text-foreground",children:c===A.id?t("settings.openchamber.passkeys.actions.removing"):t("settings.common.actions.delete")})]},A.id))})]}),v&&s.jsx("div",{className:"mt-1 py-1.5",children:s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:v})})]})},iu=()=>{const t=Be.c(14),{t:e}=qe(),a=jl(O1),n=jl(L1);let i;t[0]!==e?(i=e("settings.openchamber.appLinks.title"),t[0]=e,t[1]=i):i=t[1];let o;t[2]!==e?(o=e("settings.openchamber.appLinks.info"),t[2]=e,t[3]=o):o=t[3];let r;t[4]!==n||t[5]!==e||t[6]!==a?(r=a.length===0?s.jsx("p",{className:"typography-meta text-muted-foreground",children:e("settings.openchamber.appLinks.empty")}):a.map(g=>s.jsxs("div",{className:"flex items-center justify-between gap-2 py-0.5",children:[s.jsx("span",{className:"min-w-0 truncate font-mono text-[13px]",children:`${g}://`}),s.jsx(V,{type:"button",variant:"ghost",size:"xs",onClick:()=>n(g),className:"!font-normal text-muted-foreground hover:text-foreground","aria-label":e("settings.openchamber.appLinks.removeAria",{scheme:`${g}://`}),children:e("settings.common.actions.delete")})]},g)),t[4]=n,t[5]=e,t[6]=a,t[7]=r):r=t[7];let d;t[8]!==r?(d=s.jsx("div",{className:"space-y-1","data-settings-item":"general.app-links",children:r}),t[8]=r,t[9]=d):d=t[9];let c;return t[10]!==i||t[11]!==o||t[12]!==d?(c=s.jsx(He,{title:i,description:o,children:d}),t[10]=i,t[11]=o,t[12]=d,t[13]=c):c=t[13],c};function O1(t){return t.trustedSchemes}function L1(t){return t.removeTrustedScheme}const F1=()=>{const{t}=qe(),[e,a]=l.useState(null),n=l.useRef(0);l.useEffect(()=>{let o=!1;return Ts.getConfig(null).then(r=>{!o&&n.current===0&&a(!!r.warming)},r=>console.warn("[session-warming] failed to read config",r)),()=>{o=!0}},[]);const i=l.useCallback(async o=>{const r=e,d=++n.current;a(o),os("saving");try{const c=await It("/api/config/warming",{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({enabled:o})});if(!c.ok)throw new Error(`HTTP ${c.status}`);os("saved"),Ts.clearConfigCache()}catch(c){console.warn("[session-warming] failed to save",c),os("error"),d===n.current&&a(r)}},[e]);return s.jsx(bt,{settingsItem:"sessions.warming",checked:e??!1,disabled:e===null,onChange:o=>{i(o)},label:t("settings.openchamber.defaults.field.sessionWarming"),info:t("settings.openchamber.defaults.field.sessionWarmingInfo")})},K1={ask:{icon:"shield-user",color:void 0},safety:{icon:"shield-star",color:"var(--status-success)"},auto:{icon:"shield-check",color:"var(--status-info)"}},z1=t=>{const e=Be.c(42),{agentName:a}=t,{t:n}=qe(),i=re(U1),o=re(_1),r=es($r),d=al(es($1));let c;e[0]!==i||e[1]!==r?(c=xm(i,r),e[0]=i,e[1]=r,e[2]=c):c=e[2];const g=c;let m;e[3]!==o?(m=E=>{o(E),kt({permissionDefaultMode:E})},e[3]=o,e[4]=m):m=e[4];const h=m;let f;e[5]!==a?(f=()=>{const E=a??ct.getState().currentAgentName;E&&Hn.getState().setSelectedAgent(E),re.getState().requestSettingsJump("agents","agents.permissions")},e[5]=a,e[6]=f):f=e[6];const p=f;let b;e[7]!==p||e[8]!==d||e[9]!==r||e[10]!==n?(b=E=>E==="safety"&&!r?s.jsxs(s.Fragment,{children:[n("settings.sessions.permissions.explain.safetyUnavailable")," ",s.jsx(Vn,{onClick:lo,children:n("settings.jevAccess.setUp")})]}):E==="safety"?s.jsxs(s.Fragment,{children:[d?n("settings.sessions.permissions.explain.safetyVia",{provider:d}):n("settings.sessions.permissions.explain.safety")," ",s.jsx(Vn,{onClick:lo,children:n("settings.jevAccess.manage")})]}):s.jsxs(s.Fragment,{children:[n(E==="auto"?"settings.sessions.permissions.explain.auto":"settings.sessions.permissions.explain.ask")," ",s.jsx(Vn,{onClick:p,children:n("settings.sessions.permissions.agentPermissionsLink")})]}),e[7]=p,e[8]=d,e[9]=r,e[10]=n,e[11]=b):b=e[11];const C=b;let v;e[12]!==C||e[13]!==r?(v=(E,D)=>{const{icon:F,color:L}=K1[E];return{value:E,label:s.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[s.jsx($,{name:F,className:"size-3.5",style:L?{color:L}:void 0}),D]}),tooltip:C(E),disabled:E==="safety"&&!r}},e[12]=C,e[13]=r,e[14]=v):v=e[14];const k=v;let u;e[15]!==n?(u=n("settings.sessions.permissions.defaultMode"),e[15]=n,e[16]=u):u=e[16];let y;e[17]!==n?(y=n("settings.sessions.permissions.defaultModeInfo"),e[17]=n,e[18]=y):y=e[18];let S;e[19]!==n?(S=n("settings.sessions.permissions.defaultMode"),e[19]=n,e[20]=S):S=e[20];let N;e[21]!==k||e[22]!==n?(N=[k("ask",n("settings.sessions.permissions.mode.ask")),k("safety",n("settings.sessions.permissions.mode.safety")),k("auto",n("settings.sessions.permissions.mode.auto"))],e[21]=k,e[22]=n,e[23]=N):N=e[23];let w;e[24]!==h||e[25]!==g||e[26]!==S||e[27]!==N?(w=s.jsx(Xs,{"aria-label":S,value:g,onChange:h,options:N}),e[24]=h,e[25]=g,e[26]=S,e[27]=N,e[28]=w):w=e[28];let A;e[29]!==w||e[30]!==u||e[31]!==y?(A=s.jsx(Ct,{settingsItem:"sessions.permission-default",label:u,info:y,children:w}),e[29]=w,e[30]=u,e[31]=y,e[32]=A):A=e[32];let x;e[33]!==C||e[34]!==g?(x=s.jsx("p",{className:ds,children:C(g)}),e[33]=C,e[34]=g,e[35]=x):x=e[35];let T;e[36]!==r?(T=r?null:s.jsx(xo,{}),e[36]=r,e[37]=T):T=e[37];let M;return e[38]!==A||e[39]!==x||e[40]!==T?(M=s.jsxs("div",{className:"space-y-1",children:[A,x,T]}),e[38]=A,e[39]=x,e[40]=T,e[41]=M):M=e[41],M};function U1(t){return t.permissionDefaultMode}function _1(t){return t.setPermissionDefaultMode}function $1(t){return t.classifier?.effective??null}const rr=t=>{const e=_n(t);return e||{providerId:"",modelId:""}},ou=()=>{const{t}=qe(),e=ct(oe=>oe.setProvider),a=ct(oe=>oe.setModel),n=ct(oe=>oe.setAgent),i=ct(oe=>oe.setCurrentVariant),o=ct(oe=>oe.setCurrentVariantOverride),r=ct(oe=>oe.setSettingsDefaultModel),d=ct(oe=>oe.setSettingsDefaultVariant),c=ct(oe=>oe.setSettingsDefaultAgent),g=ct(oe=>oe.selectionSource==="manual"),m=bm(oe=>oe.currentSessionId),h=kl(oe=>oe.getSessionModelSelection),f=kl(oe=>oe.getSessionAgentSelection),p=ct(oe=>oe.agentSelectionSource==="manual"),C=!!(ct(oe=>{if(oe.agentSelectionSource!=="manual")return!1;const ee=oe.agents.find(ce=>ce.name===oe.currentAgentName);return!!(ee?.model?.providerID&&ee.model.id)})||g&&m&&h(m)),v=!!(p&&m&&f(m)),k=l.useMemo(()=>ps(),[]),u=re(oe=>oe.showDeletionDialog),y=re(oe=>oe.setShowDeletionDialog),S=ct(oe=>oe.providers),N=ct(oe=>oe.modelsMetadata),[w,A]=l.useState(),[x,T]=l.useState(),[M,E]=l.useState(),[D,F]=l.useState(!0),[L,P]=l.useState(),[j,O]=l.useState([]),[K,H]=l.useState(),[q,Z]=l.useState(!0),ae=l.useMemo(()=>rr(w),[w]);l.useEffect(()=>{(async()=>{try{const ee=await En();if(ee){const ce=ee.defaultModel?.trim()||void 0,ue=ee.defaultVariant?.trim()||void 0,Ie=ee.defaultAgent?.trim()||void 0;ce!==void 0&&A(ce),ue!==void 0&&T(ue),Ie!==void 0&&E(Ie),ee.smallModelUseDefault!==void 0&&F(ee.smallModelUseDefault);const ve=ee.smallModelOverride?.trim();ve&&P(ve);const Re=ee.walkthroughModelOverride?.trim();Re&&H(Re)}}catch(ee){console.warn("Failed to load defaults settings:",ee)}finally{Z(!1)}})()},[]);const B=l.useCallback(async(oe,ee)=>{const ce=oe&&ee?`${oe}/${ee}`:void 0;A(ce),T(void 0),d(void 0),r(ce),C||(i(void 0),oe&&ee&&(S.find(Ie=>Ie.id===oe)||yd(oe,ee))&&(e(oe),a(ee)));try{await kt({defaultModel:ce??"",defaultVariant:""})}catch(ue){console.warn("Failed to save default model:",ue)}},[C,S,i,a,e,r,d]),G="__default__",_=l.useCallback(oe=>oe===G?t("settings.openchamber.defaults.option.default"):oe.charAt(0).toUpperCase()+oe.slice(1),[t]),z=l.useCallback(async oe=>{const ee=oe===G?void 0:oe||void 0;T(ee),d(ee),C||o(ee??null,ee);try{await kt({defaultVariant:ee??""})}catch(ce){console.warn("Failed to save default variant:",ce)}},[C,o,d]),te=l.useCallback(async oe=>{const ee=oe||void 0;E(ee),c(ee),oe&&!v&&n(oe);try{await kt({defaultAgent:ee??""})}catch(ce){console.warn("Failed to save default agent:",ce)}},[v,n,c]),Q=l.useCallback(async oe=>{F(oe);try{await kt({smallModelUseDefault:oe})}catch(ee){console.warn("Failed to save small model preference:",ee)}},[]),X=l.useCallback(async(oe,ee)=>{const ce=oe&&ee?`${oe}/${ee}`:void 0;P(ce);try{await kt({smallModelOverride:ce??""})}catch(ue){console.warn("Failed to save small model override:",ue)}},[]),pe=l.useCallback(async(oe,ee)=>{const ce=oe&&ee?`${oe}/${ee}`:void 0;H(ce);try{await kt({walkthroughModelOverride:ce??""})}catch(ue){console.warn("Failed to save walkthrough model override:",ue)}},[]),je=l.useCallback((oe,ee)=>N.get(`${oe}/${ee}`)?.structured_output!==!1,[N]),fe=l.useMemo(()=>rr(L),[L]),ke=l.useMemo(()=>rr(K),[K]);l.useEffect(()=>{let oe=!1;return(async()=>{try{const ee=await It("/api/small-model",{method:"GET",headers:{Accept:"application/json"}});if(!ee.ok)return;const ce=await ee.json().catch(()=>null);!oe&&Array.isArray(ce?.authenticatedProviders)&&O(ce.authenticatedProviders.filter(ue=>typeof ue=="string"))}catch{}})(),()=>{oe=!0}},[]);const be=l.useMemo(()=>{if(!ae.providerId||!ae.modelId)return[];const ee=S.find(ce=>ce.id===ae.providerId)?.models.find(ce=>ce.id===ae.modelId);return vm(ee?.variants)},[ae.modelId,ae.providerId,S]),De=be.length>0;return q?null:s.jsx(s.Fragment,{children:s.jsx(He,{title:t("settings.openchamber.defaults.title"),divider:!1,children:s.jsxs("div",{className:"space-y-0",children:[s.jsxs("div",{className:"mt-0 mb-4 typography-meta text-muted-foreground",children:[t("settings.openchamber.defaults.summaryPrefix")," ",ae.providerId?s.jsxs("span",{className:"text-foreground",children:[ae.providerId,"/",ae.modelId,De?` (${x??t("settings.openchamber.defaults.option.defaultLowercase")})`:""]}):s.jsx("span",{className:"text-foreground",children:t("settings.openchamber.defaults.summaryOpenCodeDefault")}),M&&s.jsxs(s.Fragment,{children:[" / ",s.jsx("span",{className:"text-foreground",children:M})]})]}),s.jsxs("div",{className:Ms,children:[s.jsx(Ct,{settingsItem:"sessions.default-model",label:t("settings.openchamber.defaults.field.defaultModel"),children:s.jsx(pa,{providerId:ae.providerId,modelId:ae.modelId,onChange:B,className:Zs,offerAuto:!0})}),s.jsx(Ct,{settingsItem:"sessions.default-thinking",label:t("settings.openchamber.defaults.field.defaultThinking"),children:s.jsxs(Dt,{value:x??G,onValueChange:z,disabled:!De,children:[s.jsx(Tt,{size:Qt,className:fn,children:s.jsx(Jt,{placeholder:t("settings.openchamber.defaults.field.thinkingPlaceholder"),children:_(x??G)})}),s.jsxs(Et,{children:[s.jsx(gt,{value:G,children:t("settings.openchamber.defaults.option.default")}),be.map(oe=>s.jsx(gt,{value:oe,children:_(oe)},oe))]})]})}),s.jsx(Ct,{settingsItem:"sessions.default-agent",label:t("settings.openchamber.defaults.field.defaultAgent"),children:s.jsx(Lr,{agentName:M||"",onChange:te,filter:oe=>cd(oe.mode),className:Zs})}),k?null:s.jsx(z1,{agentName:M})]}),s.jsxs(ha,{className:ys,children:[s.jsx(bt,{settingsItem:"sessions.deletion-dialog",checked:u,onChange:y,label:t("settings.openchamber.defaults.field.showDeletionDialog"),ariaLabel:t("settings.openchamber.defaults.field.showDeletionDialogAria")}),s.jsx(F1,{})]}),s.jsxs("div",{className:"space-y-3 pt-6",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(An,{children:t("settings.openchamber.defaults.smallModel.title")}),s.jsx(Gt,{children:t("settings.openchamber.defaults.smallModel.description")})]}),s.jsx(bt,{settingsItem:"sessions.small-model",checked:D,onChange:oe=>{Q(oe)},label:t("settings.openchamber.defaults.smallModel.useDefault"),ariaLabel:t("settings.openchamber.defaults.smallModel.useDefaultAria")}),D?null:s.jsx(Ct,{label:t("settings.openchamber.defaults.smallModel.overrideModel"),children:s.jsx(pa,{providerId:fe.providerId,modelId:fe.modelId,onChange:X,allowedProviderIds:j,className:Zs})}),s.jsxs(ha,{className:ys,children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(An,{children:t("settings.openchamber.defaults.walkthroughModel.title")}),s.jsx(Gt,{children:t("settings.openchamber.defaults.walkthroughModel.description")})]}),s.jsx(Ct,{settingsItem:"sessions.walkthrough-model",label:t("settings.openchamber.defaults.walkthroughModel.overrideModel"),children:s.jsx(pa,{providerId:ke.providerId,modelId:ke.modelId,onChange:pe,allowedProviderIds:j,isModelAllowed:je,placeholder:t("settings.openchamber.defaults.walkthroughModel.usesSmallModel"),className:Zs})})]})]})]})})})},Kc={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"}},B1={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"},V1=()=>{const{t}=qe(),e=l.useMemo(()=>us(),[]),a=l.useMemo(()=>ps(),[]),n=l.useMemo(()=>typeof window>"u"?!1:window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol==="capacitor:",[]),i=!e&&!a&&!n,o=re(B=>B.nativeNotificationsEnabled),r=re(B=>B.setNativeNotificationsEnabled),d=re(B=>B.notificationMode),c=re(B=>B.setNotificationMode),g=re(B=>B.notifyOnSubtasks),m=re(B=>B.setNotifyOnSubtasks),h=re(B=>B.notifyOnCompletion),f=re(B=>B.setNotifyOnCompletion),p=re(B=>B.notifyOnError),b=re(B=>B.setNotifyOnError),C=re(B=>B.notifyOnQuestion),v=re(B=>B.setNotifyOnQuestion),k=re(B=>B.notificationTemplates),u=re(B=>B.setNotificationTemplates),[y,S]=l.useState("default"),[N,w]=l.useState(!1),[A,x]=l.useState(!1),[T,M]=l.useState(!1);l.useEffect(()=>{if(!i){w(!1),x(!1);return}typeof Notification<"u"&&S(Notification.permission);const B=typeof window<"u"&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window;w(B),(async()=>{if(!B){x(!1);return}try{const _=await navigator.serviceWorker.getRegistration();if(!_){x(!1);return}const z=await _.pushManager.getSubscription();x(!!z)}catch{x(!1)}})()},[i]);const E=async B=>{if(e){r(B);return}if(!i){r(B);return}if(B&&typeof Notification<"u"&&Notification.permission==="default")try{const G=await Notification.requestPermission();S(G),G==="granted"?r(!0):U.error(t("settings.notifications.page.toast.permissionDenied.title"),{description:t("settings.notifications.page.toast.permissionDenied.description")})}catch(G){console.error("Failed to request notification permission:",G),U.error(t("settings.notifications.page.toast.requestPermissionFailed"))}else r(!!(B&&y==="granted"))},D=e||a||n||i&&typeof Notification<"u"&&Notification.permission==="granted",F=(B,G,_)=>{u(z=>({...z,[B]:{...z[B],[G]:_}}))},L=B=>{const G="=".repeat((4-B.length%4)%4),_=(B+G).replace(/-/g,"+").replace(/_/g,"/"),z=atob(_),te=new Uint8Array(z.length);for(let Q=0;Q<z.length;Q+=1)te[Q]=z.charCodeAt(Q);return te},P=async(B,G,_)=>{let z=null;const te=new Promise((Q,X)=>{z=setTimeout(()=>{X(new Error(_))},G)});try{return await Promise.race([B,te])}finally{z&&clearTimeout(z)}},j=async B=>{if(B.active)return;const G=B.installing||B.waiting;G&&G.state!=="activated"&&await P(new Promise(_=>{const z=()=>{G.state==="activated"&&(G.removeEventListener("statechange",z),_())};G.addEventListener("statechange",z),z()}),15e3,"Service worker activation timed out")},O=async()=>{if(typeof navigator.serviceWorker.register!="function")throw new Error("navigator.serviceWorker.register unavailable");const B=[{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:"/"}}];let G=null;for(const _ of B)try{const z=_.opts?navigator.serviceWorker.register("/sw.js",_.opts):navigator.serviceWorker.register("/sw.js");return await P(z,1e4,`Service worker registration timed out (${_.label})`)}catch(z){G=z}throw G instanceof Error?G:new Error("Service worker registration failed")},K=async()=>{if(!("serviceWorker"in navigator))throw new Error("Service worker not supported");const B=await navigator.serviceWorker.getRegistration();if(B)return B;const G=await O();try{await G.update()}catch{}return await j(G),G},H=B=>{const G=B,_=[`type=${typeof B}`,`toString=${String(B)}`,`name=${String(G?.name??"")}`,`message=${String(G?.message??"")}`];let z="";try{z=JSON.stringify(B)}catch{}return{summary:_.filter(Boolean).join(" | "),json:z,stack:typeof G?.stack=="string"?G.stack:""}},q=async()=>{const B=Wa();if(!B?.notifications){U.error(t("settings.notifications.page.toast.notificationsApiUnavailable"));return}try{await B.notifications.notifyAgentCompletion({title:t("settings.notifications.page.testNotification.title"),body:t("settings.notifications.page.testNotification.body"),tag:"openchamber-test"})?U.success(t("settings.notifications.page.toast.testNotificationSent")):U.error(t("settings.notifications.page.toast.testNotificationFailed"))}catch(G){console.error("Test notification failed:",G),U.error(t("settings.notifications.page.toast.testNotificationFailed"))}},Z=async()=>{if(!N){U.error(t("settings.notifications.page.toast.pushUnsupported"));return}const B=Wa();if(!B?.push){U.error(t("settings.notifications.page.toast.pushApiUnavailable"));return}M(!0);try{if(typeof Notification<"u"&&Notification.permission==="default"){const je=await Notification.requestPermission();if(S(je),je!=="granted"){U.error(t("settings.notifications.page.toast.permissionDenied.title"),{description:t("settings.notifications.page.toast.permissionDenied.enableInBrowser")});return}}if(typeof Notification<"u"&&Notification.permission!=="granted"){U.error(t("settings.notifications.page.toast.permissionDenied.title"),{description:t("settings.notifications.page.toast.permissionDenied.enableInBrowser")});return}const G=await B.push.getVapidPublicKey();if(!G?.publicKey){U.error(t("settings.notifications.page.toast.pushKeyLoadFailed"));return}const _=await K();await j(_);const z=await _.pushManager.getSubscription();if(!("pushManager"in _)||!_.pushManager)throw new Error("PushManager unavailable (requires installed PWA + iOS 16.4+)");const Q=(z??await P(_.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:L(G.publicKey)}),15e3,"Push subscription timed out")).toJSON(),X=Q.keys;if(!Q.endpoint||!X?.p256dh||!X.auth)throw new Error("Push subscription missing keys");if(!(await P(B.push.subscribe({endpoint:Q.endpoint,keys:{p256dh:X.p256dh,auth:X.auth},origin:typeof window<"u"?window.location.origin:void 0,platform:tp()}),15e3,"Push subscribe request timed out"))?.ok){U.error(t("settings.notifications.page.toast.enableBackgroundFailed"));return}x(!0),U.success(t("settings.notifications.page.toast.backgroundEnabled"))}catch(G){console.error("[Push] Enable failed:",G);const _=H(G);U.error(t("settings.notifications.page.toast.enableBackgroundFailed"),{description:_.summary})}finally{M(!1)}},ae=async()=>{if(!N){x(!1);return}const B=Wa();if(!B?.push){U.error(t("settings.notifications.page.toast.pushApiUnavailable"));return}M(!0);try{const _=await(await K()).pushManager.getSubscription();if(!_){x(!1);return}const z=_.endpoint;await _.unsubscribe(),await B.push.unsubscribe({endpoint:z}),x(!1),U.success(t("settings.notifications.page.toast.backgroundDisabled"))}finally{M(!1)}};return s.jsxs(s.Fragment,{children:[s.jsxs(He,{settingsItem:"notifications.delivery",title:t("settings.notifications.page.delivery.title"),divider:!1,children:[s.jsxs("div",{className:ys,children:[s.jsx(bt,{checked:o&&D,onChange:B=>{E(B)},label:t("settings.notifications.page.delivery.enableLabel"),info:i?t("settings.notifications.page.delivery.browserPermissionHint"):a?t("settings.notifications.page.delivery.vscodeHint"):void 0,ariaLabel:t("settings.notifications.page.delivery.enableAria")}),o&&D&&!n&&s.jsxs(s.Fragment,{children:[s.jsx(bt,{checked:d==="always",onChange:B=>c(B?"always":"hidden-only"),label:t("settings.notifications.page.delivery.focusedLabel"),ariaLabel:t("settings.notifications.page.delivery.focusedAria")}),s.jsx("div",{className:"py-2",children:s.jsx(V,{type:"button",variant:"outline",size:"sm",onClick:()=>{q()},children:t("settings.notifications.page.delivery.testAction")})})]})]}),i&&s.jsxs("div",{className:"mt-1",children:[y==="denied"&&s.jsx("p",{className:"typography-meta text-[var(--status-error)] mt-1",children:t("settings.notifications.page.delivery.permissionDenied")}),y==="granted"&&!o&&s.jsx("p",{className:"typography-meta text-muted-foreground/70 mt-1",children:t("settings.notifications.page.delivery.permissionGrantedButDisabled")})]})]}),o&&D&&s.jsxs(s.Fragment,{children:[s.jsx(He,{settingsItem:"notifications.events",title:t("settings.notifications.page.events.title"),children:s.jsxs("div",{className:ys,children:[s.jsx(bt,{checked:h,onChange:f,label:t("settings.notifications.page.events.completionLabel"),ariaLabel:t("settings.notifications.page.events.completionAria")}),s.jsx(bt,{checked:g,onChange:m,label:t("settings.notifications.page.events.subtaskLabel"),ariaLabel:t("settings.notifications.page.events.subtaskAria")}),s.jsx(bt,{checked:p,onChange:b,label:t("settings.notifications.page.events.errorLabel"),ariaLabel:t("settings.notifications.page.events.errorAria")}),s.jsx(bt,{checked:C,onChange:v,label:t("settings.notifications.page.events.questionLabel"),ariaLabel:t("settings.notifications.page.events.questionAria")})]})}),!n&&s.jsx(He,{title:t("settings.notifications.page.template.title"),description:s.jsxs(s.Fragment,{children:[t("settings.notifications.page.template.variablesLabel")," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{project_name}"})," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{worktree}"})," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{branch}"})," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{session_name}"})," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{agent_name}"})," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{model_name}"})," ",s.jsx("code",{className:"text-[var(--syntax-variable)]",children:"{last_message}"})]}),children:s.jsx(Fn,{className:"gap-2 md:grid-cols-2 md:gap-3 lg:gap-3",children:["completion","subtask","error","question"].map(B=>s.jsxs("section",{className:"p-2",children:[s.jsx(An,{className:"capitalize",children:t(B1[B])}),s.jsxs("div",{className:"mt-1.5 space-y-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"typography-micro text-muted-foreground block mb-1",children:t("settings.notifications.page.template.field.title")}),s.jsx(Ge,{value:k[B].title,onChange:G=>F(B,"title",G.target.value),className:"h-7",placeholder:t(Kc[B].titleKey)})]}),s.jsxs("div",{children:[s.jsx("label",{className:"typography-micro text-muted-foreground block mb-1",children:t("settings.notifications.page.template.field.message")}),s.jsx(Ge,{value:k[B].message,onChange:G=>F(B,"message",G.target.value),className:"h-7",placeholder:t(Kc[B].messageKey)})]})]})]},B))})})]}),i&&s.jsx(He,{settingsItem:"notifications.push",title:t("settings.notifications.page.push.title"),children:s.jsx(bt,{checked:N?A:!1,disabled:!N||T,onChange:B=>{B?Z():ae()},label:t("settings.notifications.page.push.enableLabel"),description:N?void 0:t("settings.notifications.page.push.unsupportedHint"),info:N?t("settings.notifications.page.push.supportedHint"):void 0,ariaLabel:t("settings.notifications.page.push.enableAria"),labelAccessory:T?s.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-current text-muted-foreground animate-busy-pulse","aria-label":t("settings.notifications.page.push.loadingAria")}):null})})]})},Fs=t=>{if(!t)return;t.pause();const{src:e}=t;e.startsWith("blob:")&&URL.revokeObjectURL(e),t.removeAttribute("src"),t.load()},Ln="oc-surface-elevated w-full h-7 rounded-lg border border-input bg-surface-elevated px-2 typography-ui-label text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring focus:border-interactive-border-focus",H1=[{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"}],zc=t=>{const e=Be.c(8),{value:a,label:n}=t,i=`${n}: ${a}/5`,o=`${a/5*100}%`;let r;e[0]!==o?(r=s.jsx("span",{className:"h-1.5 w-12 flex-shrink-0 overflow-hidden rounded-full bg-[var(--interactive-border)]","aria-hidden":"true",children:s.jsx("span",{className:"block h-full rounded-full bg-[var(--primary-base)]",style:{width:o}})}),e[0]=o,e[1]=r):r=e[1];let d;e[2]!==n?(d=s.jsx("span",{className:"typography-ui-compact text-muted-foreground",children:n}),e[2]=n,e[3]=d):d=e[3];let c;return e[4]!==i||e[5]!==r||e[6]!==d?(c=s.jsxs("span",{className:"flex items-center gap-1.5",title:i,children:[r,d]}),e[4]=i,e[5]=r,e[6]=d,e[7]=c):c=e[7],c},q1=({selectedModelId:t,onSelect:e})=>{const{t:a}=qe(),n=at.useCallback(f=>a(f),[a]),[i,o]=at.useState(new Map),[r,d]=at.useState(null),c=at.useCallback(async()=>{try{const f=await It("/api/dictation/status",{query:{provider:"local"}});if(!f.ok)return;const p=await f.json();Array.isArray(p?.models)&&o(new Map(p.models.map(b=>[b.id,b])))}catch{}},[]);at.useEffect(()=>{c()},[c]);const g=Array.from(i.values()).some(f=>f.downloading);at.useEffect(()=>{if(!g)return;const f=setInterval(()=>{c()},2e3);return()=>clearInterval(f)},[g,c]);const m=async f=>{d(f);try{await It(`/api/dictation/models/${encodeURIComponent(f)}/download`,{method:"POST"}),await c()}catch{}finally{d(null)}},h=async f=>{d(f);try{await It(`/api/dictation/models/${encodeURIComponent(f)}`,{method:"DELETE"}),await c()}catch{}finally{d(null)}};return s.jsx("div",{role:"radiogroup","aria-label":a("settings.voice.page.field.model"),className:"mt-1.5 grid w-full grid-cols-1 gap-3 @xl:grid-cols-2",children:H1.map(f=>{const p=t===f.id,b=i.get(f.id)??null;return s.jsx("div",{className:Ne("rounded-lg border border-[var(--interactive-border)] p-3",p&&"border-border bg-interactive-selection text-interactive-selection-foreground"),children:s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex min-w-0 flex-1 cursor-pointer items-start gap-2",role:"button",tabIndex:0,onClick:()=>e(f.id),onKeyDown:C=>{(C.key===" "||C.key==="Enter")&&(C.preventDefault(),e(f.id))},children:[s.jsx("div",{className:"pt-0.5",children:s.jsx(Fr,{checked:p,onChange:()=>e(f.id),ariaLabel:n(f.labelKey)})}),s.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:Ne("typography-ui-label font-normal",p?"text-foreground":"text-foreground/50"),children:n(f.labelKey)}),f.badgeKey?s.jsx("span",{className:"rounded border border-[var(--status-success-border)] bg-[var(--status-success-background)] px-1 text-[9px] font-medium uppercase leading-[14px] tracking-wide text-[var(--status-success)]",children:n(f.badgeKey)}):null]}),s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(zc,{value:f.accuracy,label:a("settings.voice.page.stt.meta.accuracy")}),s.jsx(zc,{value:f.speed,label:a("settings.voice.page.stt.meta.speed")}),s.jsx("span",{className:"typography-ui-compact tabular-nums text-muted-foreground",children:f.size})]}),b?.downloadError?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:b.downloadError}):null]})]}),s.jsx("div",{className:"flex shrink-0 items-center gap-1",children:b?.installed?s.jsxs(s.Fragment,{children:[s.jsx(V,{variant:"ghost",size:"xs",className:"h-6 w-6 p-0 text-muted-foreground hover:text-[var(--status-error)]",disabled:r===f.id,onClick:()=>{h(f.id)},title:a("settings.voice.page.stt.modelDelete"),"aria-label":a("settings.voice.page.stt.modelDelete"),children:s.jsx($,{name:"delete-bin",className:"h-4 w-4"})}),s.jsx($,{name:"checkbox-circle",className:"h-4 w-4 flex-shrink-0 text-[var(--status-success)]","aria-label":a("settings.voice.page.stt.modelInstalled")})]}):b?.downloading?s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx($,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin text-muted-foreground"}),s.jsx("span",{className:"typography-ui-compact tabular-nums text-muted-foreground",children:typeof b.downloadProgress=="number"?`${b.downloadProgress}%`:""})]}):s.jsx(V,{variant:"ghost",size:"xs",className:"h-6 w-6 p-0",disabled:r===f.id,onClick:()=>{m(f.id)},title:a("settings.voice.page.stt.modelDownload"),"aria-label":a("settings.voice.page.stt.modelDownload"),children:s.jsx($,{name:"download",className:"h-4 w-4"})})})]})},f.id)})})},G1=[{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)"}],Tr="kokoro-en-v0_19",W1="kokoro-multi-lang-v1_1",J1=[{id:0,label:"Maple (af)"},{id:1,label:"Sol (af)"},{id:2,label:"Vale (bf)"},{id:3,label:"Xiaoxiao (zf)"},{id:58,label:"Yunxi (zm)"}],ui=(t,e)=>`${t}:${e}`,Q1=()=>{const[t,e]=at.useState([]),[a,n]=at.useState(null),i=at.useCallback(async()=>{try{const d=await It("/api/dictation/status",{query:{provider:"local"}});if(!d.ok)return;const c=await d.json();Array.isArray(c?.ttsModels)&&e(c.ttsModels)}catch{}},[]);at.useEffect(()=>{i()},[i]);const o=t.some(d=>d.downloading);at.useEffect(()=>{if(!o)return;const d=setInterval(()=>{i()},2e3);return()=>clearInterval(d)},[o,i]);const r=at.useCallback(async(d,c)=>{n(d);try{const g=c==="POST"?`/api/dictation/models/${d}/download`:`/api/dictation/models/${d}`;await It(g,{method:c}),await i()}catch{}finally{n(null)}},[i]);return{models:t,requestingId:a,request:r,refresh:i}},Y1=t=>{const e=G1.map(a=>({modelId:Tr,speakerId:a.id,label:a.label}));for(const a of t)if(!(a.id===Tr||!a.installed)){if(a.id===W1){for(const n of J1)e.push({modelId:a.id,speakerId:n.id,label:`${n.label} · Kokoro zh/en`});continue}e.push({modelId:a.id,speakerId:0,label:a.description??a.id})}return e},Z1=t=>{const e=Be.c(14),{models:a,requestingId:n,request:i}=t,{t:o}=qe();let r,d,c;if(e[0]!==a||e[1]!==i||e[2]!==n||e[3]!==o){c=Symbol.for("react.early_return_sentinel");e:{const m=a.filter(tj);if(m.length===0){c=null;break e}r="flex flex-col";let h;e[7]!==i||e[8]!==n||e[9]!==o?(h=f=>s.jsxs("div",{className:"flex items-center gap-2 py-1.5",children:[s.jsx("span",{className:"typography-ui-label text-foreground",children:f.description??f.id}),f.installed?s.jsxs(s.Fragment,{children:[s.jsx($,{name:"checkbox-circle",className:"h-4 w-4 text-[var(--status-success)]","aria-label":o("settings.voice.page.stt.modelInstalled")}),s.jsx(V,{variant:"ghost",size:"xs",className:"h-6 w-6 p-0 text-muted-foreground hover:text-[var(--status-error)]",disabled:n!==null,onClick:()=>{i(f.id,"DELETE")},title:o("settings.voice.page.stt.modelDelete"),"aria-label":o("settings.voice.page.stt.modelDelete"),children:s.jsx($,{name:"delete-bin",className:"h-4 w-4"})})]}):f.downloading?s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx($,{name:"loader-4",className:"h-3.5 w-3.5 animate-spin text-muted-foreground"}),s.jsx("span",{className:"typography-ui-compact tabular-nums text-muted-foreground",children:typeof f.downloadProgress=="number"?`${f.downloadProgress}%`:""})]}):s.jsx(V,{variant:"ghost",size:"xs",className:"h-6 w-6 p-0",disabled:n!==null,onClick:()=>{i(f.id,"POST")},title:o("settings.voice.page.stt.modelDownload"),"aria-label":o("settings.voice.page.stt.modelDownload"),children:s.jsx($,{name:"download",className:"h-4 w-4"})}),f.downloadError?s.jsx("span",{className:"typography-meta text-[var(--status-error)]",children:f.downloadError}):null]},f.id),e[7]=i,e[8]=n,e[9]=o,e[10]=h):h=e[10],d=m.map(h)}e[0]=a,e[1]=i,e[2]=n,e[3]=o,e[4]=r,e[5]=d,e[6]=c}else r=e[4],d=e[5],c=e[6];if(c!==Symbol.for("react.early_return_sentinel"))return c;let g;return e[11]!==r||e[12]!==d?(g=s.jsx("div",{className:r,children:d}),e[11]=r,e[12]=d,e[13]=g):g=e[13],g},X1=[{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"}],ej=()=>{const{t}=qe(),{isMobile:e}=qn(),a=ct(J=>J.voiceProvider),n=ct(J=>J.setVoiceProvider),i=ct(J=>J.speechRate),o=ct(J=>J.setSpeechRate),r=ct(J=>J.speechPitch),d=ct(J=>J.setSpeechPitch),c=ct(J=>J.speechVolume),g=ct(J=>J.setSpeechVolume),m=ct(J=>J.sayVoice),h=ct(J=>J.setSayVoice),f=ct(J=>J.localTtsVoiceId),p=ct(J=>J.localTtsModelId),b=ct(J=>J.setLocalTtsModelId),C=Q1(),v=at.useMemo(()=>Y1(C.models),[C.models]),k=ct(J=>J.ttsFollowTextLanguage),u=ct(J=>J.setTtsFollowTextLanguage),y=ct(J=>J.setLocalTtsVoiceId),{speak:S,stop:N,isPlaying:w,error:A}=ym(),x=at.useCallback(()=>{if(w){N();return}const J=v.find(nt=>nt.modelId===p&&nt.speakerId===f)?.label??String(f);S(t("settings.voice.page.preview.voiceLine",{voiceName:J}),{model:p,speakerId:f,speed:ct.getState().speechRate})},[w,p,f,v,S,N,t]),T=ct(J=>J.browserVoice),M=ct(J=>J.setBrowserVoice),E=ct(J=>J.openaiVoice),D=ct(J=>J.setOpenaiVoice),F=ct(J=>J.openaiApiKey),L=ct(J=>J.setOpenaiApiKey),P=ct(J=>J.openaiCompatibleUrl),j=ct(J=>J.setOpenaiCompatibleUrl),O=ct(J=>J.openaiCompatibleApiKey),K=ct(J=>J.setOpenaiCompatibleApiKey),H=ct(J=>J.openaiCompatibleVoice),q=ct(J=>J.setOpenaiCompatibleVoice),Z=ct(J=>J.openaiCompatibleTtsModel),ae=ct(J=>J.setOpenaiCompatibleTtsModel),B=ct(J=>J.showMessageTTSButtons),G=ct(J=>J.ttsInputMode),_=ct(J=>J.setTtsInputMode),z=ct(J=>J.sttProvider),te=ct(J=>J.setSttProvider),Q=ct(J=>J.sttServerUrl),X=ct(J=>J.setSttServerUrl),pe=ct(J=>J.sttApiKey),je=ct(J=>J.setSttApiKey),fe=ct(J=>J.sttModel),ke=ct(J=>J.setSttModel),be=ct(J=>J.sttLocalModel),De=ct(J=>J.setSttLocalModel),oe=ct(J=>J.sttLanguage),ee=ct(J=>J.setSttLanguage),ce=ct(J=>J.setShowMessageTTSButtons),ue=ct(J=>J.dictationEnabled),Ie=ct(J=>J.setDictationEnabled),[ve,Re]=at.useState(!1),[Me,me]=at.useState([]),[Te,Oe]=at.useState(!1),[ge,xe]=at.useState(null),[ne,ie]=at.useState(!1),[he,Ee]=at.useState(!1),[Ke,Le]=at.useState(!1),[Se,$e]=at.useState(null),[Ye,pt]=at.useState(!1),[vt,wt]=at.useState(null),[yt,st]=at.useState([]),[rt,de]=at.useState(!1);at.useEffect(()=>((async()=>{const nt=await _o.waitForVoices();st(nt)})(),"speechSynthesis"in window&&(window.speechSynthesis.onvoiceschanged=()=>{st(window.speechSynthesis.getVoices())}),()=>{"speechSynthesis"in window&&(window.speechSynthesis.onvoiceschanged=null)}),[]);const Ue=at.useMemo(()=>yt.filter(J=>J.lang).sort((J,nt)=>{const ot=J.lang.startsWith("en"),it=nt.lang.startsWith("en");if(ot&&!it)return-1;if(!ot&&it)return 1;const ft=J.lang.localeCompare(nt.lang);return ft!==0?ft:J.name.localeCompare(nt.name)}),[yt]),et=at.useCallback(()=>{if(rt){_o.cancelSpeech(),de(!1);return}const J=yt.find(ft=>ft.name===T),nt=J?.name??t("settings.voice.page.preview.browserVoiceFallback"),ot=t("settings.voice.page.preview.voiceLine",{voiceName:nt});de(!0);const it=new SpeechSynthesisUtterance(ot);it.rate=i,it.pitch=r,it.volume=c,J&&(it.voice=J,it.lang=J.lang),it.onend=()=>de(!1),it.onerror=()=>de(!1),window.speechSynthesis.cancel(),window.speechSynthesis.speak(it)},[T,yt,i,r,c,rt,t]);at.useEffect(()=>()=>{rt&&_o.cancelSpeech()},[rt]),at.useEffect(()=>{if(!B||a!=="openai"&&a!=="openai-compatible"){ie(F.trim().length>0);return}(async()=>{try{const ot=await(await It("/api/tts/status")).json(),it=ot.available,ft=F.trim().length>0,xt=ot.enterpriseMode===!0;Ee(xt),ie(!xt&&(it||ft))}catch{ie(F.trim().length>0)}})()},[F,B,a]),at.useEffect(()=>{if(!B){Re(!1),me([]);return}It("/api/tts/say/status").then(J=>J.json()).then(J=>{if(Re(J.available),J.voices){const nt=J.voices.filter((ot,it,ft)=>ft.findIndex(xt=>xt.name===ot.name)===it).sort((ot,it)=>ot.name.localeCompare(it.name));me(nt)}}).catch(()=>{Re(!1)})},[B]);const ze=at.useCallback(async()=>{if(ge){Fs(ge),xe(null),Oe(!1);return}Oe(!0);let J=null;try{const nt=await It("/api/tts/say/speak",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:t("settings.voice.page.preview.voiceLine",{voiceName:m}),voice:m,rate:Math.round(100+(i-.5)*200)})});if(!nt.ok)throw new Error("Preview failed");const ot=await nt.blob(),it=URL.createObjectURL(ot);J=new Audio(it),J.onended=()=>{Fs(J),xe(null),Oe(!1)},J.onerror=()=>{Fs(J),xe(null),Oe(!1)},xe(J),await J.play()}catch{Fs(J),xe(null),Oe(!1)}},[m,i,ge,t]);at.useEffect(()=>()=>{Fs(ge)},[ge]);const Ze=at.useCallback(async()=>{if(Se){Fs(Se),$e(null),Le(!1);return}Le(!0);let J=null;try{const nt=await It("/api/tts/speak",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:t("settings.voice.page.preview.voiceLine",{voiceName:E}),voice:E,speed:i,apiKey:F||void 0})});if(!nt.ok){const ft=await nt.json().catch(()=>({error:"Unknown error"}));throw new Error(ft.error||`HTTP ${nt.status}`)}const ot=await nt.blob(),it=URL.createObjectURL(ot);J=new Audio(it),J.onended=()=>{Fs(J),$e(null),Le(!1)},J.onerror=()=>{Fs(J),$e(null),Le(!1)},$e(J),await J.play()}catch{Fs(J),$e(null),Le(!1)}},[E,i,Se,F,t]);at.useEffect(()=>()=>{Fs(Se)},[Se]);const tt=at.useCallback(async()=>{if(vt){Fs(vt),wt(null),pt(!1);return}if(!P.trim())return;pt(!0);let J=null;try{const nt=await It("/api/tts/speak",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:t("settings.voice.page.preview.customServerLine"),voice:H,model:Z||void 0,speed:i,baseURL:P,apiKey:O||void 0})});if(!nt.ok){const ft=await nt.json().catch(()=>({error:"Unknown error"}));throw new Error(ft.error||`HTTP ${nt.status}`)}const ot=await nt.blob(),it=URL.createObjectURL(ot);J=new Audio(it),J.onended=()=>{Fs(J),wt(null),pt(!1)},J.onerror=()=>{Fs(J),wt(null),pt(!1)},wt(J),await J.play()}catch{Fs(J),wt(null),pt(!1)}},[P,H,Z,O,i,vt,t]);at.useEffect(()=>()=>{Fs(vt)},[vt]);const lt="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 s.jsxs(s.Fragment,{children:[s.jsxs(He,{settingsItem:"voice.playback",title:t("settings.voice.page.section.playbackAndSummary"),divider:!1,contentClassName:"space-y-4",children:[s.jsx(bt,{checked:B,onChange:ce,label:t("settings.voice.page.field.messageReadAloudButton"),ariaLabel:t("settings.voice.page.field.messageReadAloudButtonAria")}),B&&s.jsxs(s.Fragment,{children:[s.jsx(Ss,{title:t("settings.voice.page.field.provider"),info:s.jsxs("ul",{className:"space-y-1",children:[s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.browser")})," ",t("settings.voice.page.tooltip.browser")]}),s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.local")})," ",t("settings.voice.page.tooltip.localTts")]}),s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.openai")})," ",t("settings.voice.page.tooltip.openai")]}),s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.custom")})," ",t("settings.voice.page.tooltip.custom")]}),s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.say")})," ",t("settings.voice.page.tooltip.say")]})]}),children:s.jsx(Xs,{value:a,onChange:n,"aria-label":t("settings.voice.page.field.provider"),className:"w-full gap-1.5 sm:gap-2",options:[{value:"browser",label:t("settings.voice.page.provider.browser")},{value:"local",label:t("settings.voice.page.provider.local")},{value:"openai",label:t("settings.voice.page.provider.openai")},{value:"openai-compatible",label:t("settings.voice.page.provider.custom")},...ve?[{value:"say",label:s.jsxs(s.Fragment,{children:[s.jsx($,{name:"apple",className:"mr-0.5 h-3.5 w-3.5"}),t("settings.voice.page.provider.say")]})}]:[]]})}),he&&(a==="openai"||a==="openai-compatible")&&s.jsx("p",{className:ds,children:t("settings.voice.page.enterpriseMode")}),a==="openai"&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("span",{className:Ne(Pt,!ne&&"text-[var(--status-error)]"),children:t("settings.voice.page.field.apiKey")}),s.jsx("span",{className:Ne(ds,!ne&&"text-[var(--status-error)]/80"),children:t(ne&&!F?"settings.voice.page.field.apiKeyHintUsingConfig":ne?"settings.voice.page.field.apiKeyHintProvide":"settings.voice.page.field.apiKeyHintRequired")}),s.jsxs("div",{className:Ne("relative",Es),children:[s.jsx("input",{type:"password",value:F,onChange:J=>L(J.target.value),placeholder:"sk-...",className:Ln}),F&&s.jsx("button",{type:"button",onClick:()=>L(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:s.jsx($,{name:"close",className:"w-3.5 h-3.5"})})]})]}),a==="openai-compatible"&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:Ne(Pt,!P.trim()&&"text-[var(--status-error)]"),children:t("settings.voice.page.field.serverUrl")}),s.jsx(Gt,{children:t("settings.voice.page.field.serverUrlHint")})]}),s.jsxs("div",{className:Ne("relative",Es),children:[s.jsx("input",{type:"text",value:P,onChange:J=>j(J.target.value),placeholder:"http://localhost:8880/v1",className:Ln}),P&&s.jsx("button",{type:"button",onClick:()=>j(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:s.jsx($,{name:"close",className:"w-3.5 h-3.5"})})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("span",{className:Pt,children:"API Key"}),s.jsx("span",{className:ds,children:"Optional"}),s.jsxs("div",{className:Ne("relative",Es),children:[s.jsx("input",{type:"password",value:O,onChange:J=>K(J.target.value),placeholder:"sk-...",className:Ln}),O&&s.jsx("button",{type:"button",onClick:()=>K(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:s.jsx($,{name:"close",className:"w-3.5 h-3.5"})})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("span",{className:Pt,children:t("settings.voice.page.field.model")}),s.jsx("div",{className:Ne("relative",Es),children:s.jsx("input",{type:"text",value:Z,onChange:J=>ae(J.target.value),placeholder:"speaches-ai/Kokoro-82M-v1.0-ONNX",className:Ln})})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:Pt,children:t("settings.voice.page.field.voice")}),s.jsx(Gt,{children:t("settings.voice.page.field.voiceIdentifierHint")})]}),s.jsxs("div",{className:Ne("flex items-center gap-2",Es),children:[s.jsx("div",{className:"relative min-w-0 flex-1",children:s.jsx("input",{type:"text",value:H,onChange:J=>q(J.target.value),placeholder:"af_sky",className:Ln})}),s.jsx(V,{size:"xs",variant:"ghost",onClick:tt,title:t("settings.voice.page.actions.preview"),disabled:!P.trim(),children:Ye?s.jsx($,{name:"stop",className:"w-3.5 h-3.5"}):s.jsx($,{name:"play",className:"w-3.5 h-3.5"})})]})]})]}),a==="local"&&s.jsx(Z1,{...C}),(a==="local"||a==="say")&&s.jsx(bt,{checked:k,onChange:u,label:t("settings.voice.page.field.followTextLanguage"),ariaLabel:t("settings.voice.page.field.followTextLanguageAria"),info:t("settings.voice.page.field.followTextLanguageInfo")}),s.jsxs(Ct,{label:t("settings.voice.page.field.voice"),children:[a==="local"&&s.jsxs(s.Fragment,{children:[s.jsxs(Dt,{value:ui(p,f),onValueChange:J=>{const nt=v.find(ot=>ui(ot.modelId,ot.speakerId)===J);nt&&(b(nt.modelId),y(nt.speakerId))},children:[s.jsx(Tt,{size:Qt,className:fn,children:s.jsx(Jt,{placeholder:t("settings.voice.page.field.selectVoicePlaceholder"),children:J=>v.find(nt=>ui(nt.modelId,nt.speakerId)===J)?.label??J})}),s.jsx(Et,{children:v.map(J=>s.jsx(gt,{value:ui(J.modelId,J.speakerId),children:J.label},ui(J.modelId,J.speakerId)))})]}),s.jsx(V,{size:"xs",variant:"ghost",onClick:x,title:t("settings.voice.page.actions.preview"),children:w?s.jsx($,{name:"stop",className:"w-3.5 h-3.5"}):s.jsx($,{name:"play",className:"w-3.5 h-3.5"})}),A?s.jsx("span",{className:"typography-meta text-[var(--status-error)]",children:A}):null]}),a==="openai"&&ne&&s.jsxs(s.Fragment,{children:[s.jsxs(Dt,{value:E,onValueChange:D,children:[s.jsx(Tt,{size:Qt,className:fn,children:s.jsx(Jt,{placeholder:t("settings.voice.page.field.selectVoicePlaceholder")})}),s.jsx(Et,{children:X1.map(J=>s.jsx(gt,{value:J.value,children:J.label},J.value))})]}),s.jsx(V,{size:"xs",variant:"ghost",onClick:Ze,title:t("settings.voice.page.actions.preview"),children:Ke?s.jsx($,{name:"stop",className:"w-3.5 h-3.5"}):s.jsx($,{name:"play",className:"w-3.5 h-3.5"})})]}),a==="openai-compatible"&&s.jsx("span",{className:ds,children:t("settings.voice.page.field.configuredAbove")}),a==="say"&&ve&&Me.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs(Dt,{value:m,onValueChange:h,children:[s.jsx(Tt,{size:Qt,className:fn,children:s.jsx(Jt,{placeholder:t("settings.voice.page.field.selectVoicePlaceholder")})}),s.jsx(Et,{children:Me.map(J=>s.jsx(gt,{value:J.name,children:J.name},J.name))})]}),s.jsx(V,{size:"xs",variant:"ghost",onClick:ze,title:t("settings.voice.page.actions.preview"),children:Te?s.jsx($,{name:"stop",className:"w-3.5 h-3.5"}):s.jsx($,{name:"play",className:"w-3.5 h-3.5"})})]}),a==="browser"&&Ue.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs(Dt,{value:T||"$auto",onValueChange:J=>M(J==="$auto"?"":J),children:[s.jsx(Tt,{size:Qt,className:fn,children:s.jsx(Jt,{placeholder:t("settings.voice.page.field.auto")})}),s.jsxs(Et,{children:[s.jsx(gt,{value:"$auto",children:t("settings.voice.page.field.auto")}),Ue.map(J=>s.jsxs(gt,{value:J.name,children:[J.name," (",J.lang,")"]},J.name))]})]}),s.jsx(V,{size:"xs",variant:"ghost",onClick:et,title:t("settings.voice.page.actions.preview"),children:rt?s.jsx($,{name:"stop",className:"w-3.5 h-3.5"}):s.jsx($,{name:"play",className:"w-3.5 h-3.5"})})]})]}),s.jsxs(Ct,{label:t("settings.voice.page.field.speechRate"),children:[!e&&s.jsx("input",{type:"range",min:.5,max:2,step:.1,value:i,onChange:J=>o(Number(J.target.value)),className:lt}),s.jsx(js,{value:i,onValueChange:o,min:.5,max:2,step:.1,className:Ne(ws,"tabular-nums")})]}),s.jsxs(Ct,{label:t("settings.voice.page.field.speechPitch"),children:[!e&&s.jsx("input",{type:"range",min:.5,max:2,step:.1,value:r,onChange:J=>d(Number(J.target.value)),className:lt}),s.jsx(js,{value:r,onValueChange:d,min:.5,max:2,step:.1,className:Ne(ws,"tabular-nums")})]}),s.jsxs(Ct,{label:t("settings.voice.page.field.speechVolume"),children:[!e&&s.jsx("input",{type:"range",min:0,max:1,step:.1,value:c,onChange:J=>g(Number(J.target.value)),className:lt}),e?s.jsx(js,{value:Math.round(c*100),onValueChange:J=>g(J/100),min:0,max:100,step:10,className:Ne(ws,"tabular-nums")}):s.jsxs("span",{className:"typography-ui-label text-foreground tabular-nums min-w-[3rem] text-right",children:[Math.round(c*100),"%"]})]}),s.jsx(Ss,{title:t("settings.voice.page.field.ttsInputMode"),children:s.jsx(Xs,{value:G,onChange:_,"aria-label":t("settings.voice.page.field.ttsInputMode"),className:"w-full gap-1.5 sm:gap-2",options:[{value:"sanitized",label:t("settings.voice.page.field.ttsInputModeSanitized")},{value:"raw",label:t("settings.voice.page.field.ttsInputModeRaw")},{value:"summarized",label:t("settings.voice.page.field.ttsInputModeSummarized")}]})})]})]}),s.jsxs(He,{settingsItem:"voice.speech-recognition",title:t("settings.voice.page.section.speechRecognition"),contentClassName:"space-y-4",children:[s.jsx(bt,{checked:ue,onChange:Ie,label:t("settings.voice.page.field.enableVoiceInput"),ariaLabel:t("settings.voice.page.field.enableVoiceInputAria")}),ue&&s.jsxs(s.Fragment,{children:[s.jsx(Ss,{title:t("settings.voice.page.field.provider"),info:s.jsxs("ul",{className:"space-y-1",children:[s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.local")})," ",t("settings.voice.page.tooltip.sttLocal")]}),s.jsxs("li",{children:[s.jsx("strong",{children:t("settings.voice.page.provider.server")})," ",t("settings.voice.page.tooltip.sttServer")]})]}),children:s.jsx(Xs,{value:z,onChange:te,"aria-label":t("settings.voice.page.field.provider"),className:"w-full gap-1.5 sm:gap-2",options:[{value:"local",label:t("settings.voice.page.provider.local")},{value:"openai-compatible",label:t("settings.voice.page.provider.server")}]})}),z==="local"&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("span",{className:Pt,children:t("settings.voice.page.field.model")}),s.jsx(q1,{selectedModelId:be,onSelect:De})]}),z==="openai-compatible"&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:Ne(Pt,!Q.trim()&&"text-[var(--status-error)]"),children:t("settings.voice.page.field.serverUrl")}),s.jsx(Gt,{children:t("settings.voice.page.field.sttServerUrlHint")})]}),s.jsxs("div",{className:Ne("relative",Es),children:[s.jsx("input",{type:"text",value:Q,onChange:J=>X(J.target.value),placeholder:"http://localhost:8001/v1",className:Ln}),Q&&s.jsx("button",{type:"button",onClick:()=>X(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:s.jsx($,{name:"close",className:"w-3.5 h-3.5"})})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("span",{className:Pt,children:"API Key"}),s.jsx("span",{className:ds,children:"Optional"}),s.jsxs("div",{className:Ne("relative",Es),children:[s.jsx("input",{type:"password",value:pe,onChange:J=>je(J.target.value),placeholder:"sk-...",className:Ln}),pe&&s.jsx("button",{type:"button",onClick:()=>je(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:s.jsx($,{name:"close",className:"w-3.5 h-3.5"})})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("span",{className:Pt,children:t("settings.voice.page.field.model")}),s.jsx("div",{className:Ne("relative",Es),children:s.jsx("input",{type:"text",value:fe,onChange:J=>ke(J.target.value),placeholder:"deepdml/faster-whisper-large-v3-turbo-ct2",className:Ln})})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("span",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:Pt,children:t("settings.voice.page.field.language")}),s.jsx(Gt,{children:t("settings.voice.page.field.sttLanguageHint")})]}),s.jsx("div",{className:"relative max-w-[8rem]",children:s.jsx("input",{type:"text",value:oe,onChange:J=>ee(J.target.value),placeholder:"auto",className:Ln})})]})]})]})]})]})};function tj(t){return t.id===Tr||t.installed||t.downloading}const Ji=[{value:"1800000",label:"30m",ms:1800*1e3},{value:"180000",label:"3m",ms:180*1e3},{value:"7200000",label:"2h",ms:7200*1e3},{value:"28800000",label:"8h",ms:480*60*1e3},{value:"86400000",label:"24h",ms:1440*60*1e3}],Qi=[{value:"3600000",label:"1h",ms:3600*1e3},{value:"28800000",label:"8h",ms:480*60*1e3},{value:"43200000",label:"12h",ms:720*60*1e3},{value:"86400000",label:"24h",ms:1440*60*1e3},{value:"604800000",label:"1w",ms:10080*60*1e3},{value:"2592000000",label:"30d",ms:720*60*60*1e3}],sj="https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/get-started/create-remote-tunnel/",nj="https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/do-more-with-tunnels/local-management/configuration-file/",lr=[{value:"quick",labelKey:"settings.openchamber.tunnel.option.mode.quick.label",tooltipKey:"settings.openchamber.tunnel.option.mode.quick.tooltip"},{value:"managed-remote",labelKey:"settings.openchamber.tunnel.option.mode.managedRemote.label",tooltipKey:"settings.openchamber.tunnel.option.mode.managedRemote.tooltip"},{value:"managed-local",labelKey:"settings.openchamber.tunnel.option.mode.managedLocal.label",tooltipKey:"settings.openchamber.tunnel.option.mode.managedLocal.tooltip"}],aj=[".yml",".yaml",".json"],ij="settings.openchamber.tunnel.error.invalidConfigExtension",mi=t=>{const e=t.trim().toLowerCase();return aj.some(a=>e.endsWith(a))},oj=t=>t==="ngrok"?"ngrok":"cloudflared",ru=()=>{if(typeof window<"u"&&typeof window.__OPENCHAMBER_PLATFORM__=="string"){const e=window.__OPENCHAMBER_PLATFORM__;if(e==="win32"||e==="darwin"||e==="linux")return e}const t=typeof navigator<"u"?`${navigator.platform||""} ${navigator.userAgent||""}`.toLowerCase():"";return t.includes("win")?"win32":t.includes("mac")?"darwin":"linux"},rj=(t,e=ru())=>t==="ngrok"?e==="win32"?"winget install ngrok -s msstore":e==="darwin"?"brew install ngrok":"https://ngrok.com/download":e==="win32"?"winget install --id Cloudflare.cloudflared":e==="darwin"?"brew install cloudflared":"https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/downloads/",cr=(t,e)=>{const a=typeof e?.provider=="string"&&e.provider.trim().length>0?e.provider.trim().toLowerCase():t,n=typeof e?.dependency=="string"&&e.dependency.trim().length>0?e.dependency.trim():oj(a),i=typeof e?.platform=="string"&&e.platform.trim().length>0?e.platform.trim():ru(),o=typeof e?.installCommand=="string"&&e.installCommand.trim().length>0?e.installCommand.trim():rj(a,i);return{provider:a,dependency:n,installCommand:o}},lu=t=>t==="cloudflare"?"Cloudflare":t==="ngrok"?"Ngrok":t,Uc=t=>{const e=Be.c(11),{provider:a}=t;let n;e[0]!==a?(n=lu(a),e[0]=a,e[1]=n):n=e[1];const i=n,d=a==="cloudflare"||a==="ngrok"?"text-[var(--status-warning)]":"text-muted-foreground";let c;e[2]!==d?(c=Ne("size-4 shrink-0",d),e[2]=d,e[3]=c):c=e[3];let g;e[4]!==c?(g=s.jsx($,{name:"cloud",className:c}),e[4]=c,e[5]=g):g=e[5];let m;e[6]!==i?(m=s.jsx("span",{children:i}),e[6]=i,e[7]=m):m=e[7];let h;return e[8]!==g||e[9]!==m?(h=s.jsxs("span",{className:"flex items-center gap-2",children:[g,m]}),e[8]=g,e[9]=m,e[10]=h):h=e[10],h},ea=t=>t==="quick"?"quick":t==="managed-remote"?"managed-remote":t==="managed-local"?"managed-local":"quick",Er=(t,e,a)=>t.find(i=>i.ms===e)?.value||a,_c=(t,e,a)=>{const n=Er(t,e,a);return t.find(i=>i.value===n)?.label||n},$c=t=>{const e=Math.max(0,t),a=Math.floor(e/1e3),n=Math.floor(a/3600),i=Math.floor(a%3600/60),o=a%60;return n>0?`${n}h ${i}m`:i>0?`${i}m ${o}s`:`${o}s`},lj=(t,e)=>ad(t,e,{hour:"2-digit",precision:"second"}),to=t=>{const e=t.trim();if(!e)return"";try{return(e.includes("://")?new URL(e):new URL(`https://${e}`)).hostname.trim().toLowerCase()}catch{return e.toLowerCase()}},cj=t=>{if(!Array.isArray(t))return[];const e=new Set,a=new Set,n=[];for(const i of t){if(!i||typeof i!="object")continue;const o=i,r=typeof o.id=="string"?o.id.trim():"",d=typeof o.name=="string"?o.name.trim():"",c=to(typeof o.hostname=="string"?o.hostname:"");!r||!d||!c||e.has(r)||a.has(c)||(e.add(r),a.add(c),n.push({id:r,name:d,hostname:c}))}return n},dj=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2,10)}`,uj=()=>{const{t}=qe(),e=re(W=>W.timeFormatPreference),a=l.useCallback(W=>t(W),[t]),[n,i]=l.useState("checking"),[o,r]=l.useState(!1),[d,c]=l.useState(null),[g,m]=l.useState(null),[h,f]=l.useState(null),[p,b]=l.useState(null),[C,v]=l.useState(null),[k,u]=l.useState(!1),[y,S]=l.useState(!1),[N,w]=l.useState(!1),[A,x]=l.useState("cloudflare"),[T,M]=l.useState(()=>cr("cloudflare")),[E,D]=l.useState([]),[F,L]=l.useState("quick"),[P,j]=l.useState(null),[O,K]=l.useState([]),[H,q]=l.useState({}),[Z,ae]=l.useState(""),[B,G]=l.useState({}),[_,z]=l.useState(new Set),[te,Q]=l.useState(!1),[X,pe]=l.useState(""),[je,fe]=l.useState(""),[ke,be]=l.useState(""),[De,oe]=l.useState(1800*1e3),[ee,ce]=l.useState(480*60*1e3),[ue,Ie]=l.useState(""),[ve,Re]=l.useState([]),[Me,me]=l.useState(()=>Date.now()),[Te,Oe]=l.useState(null),ge=t(ij),xe=l.useRef(null),ne=l.useMemo(()=>P?!mi(P):!1,[P]),ie=l.useMemo(()=>O.find(W=>W.id===Z)||O[0]||null,[O,Z]),he=l.useMemo(()=>ve.map(W=>{const ye=W.expiresAt<=Me,Ae=W.status==="active"&&!ye,Y=Ae?$c(W.expiresAt-Me):W.inactiveReason==="expired"||ye?"expired":"inactive",Pe=Y==="expired"?t("settings.openchamber.tunnel.state.expired"):W.inactiveReason==="tunnel-revoked"?t("settings.openchamber.tunnel.state.revoked"):t("settings.openchamber.tunnel.state.inactive"),Je=ea(W.mode);return{...W,isActive:Ae,mode:Je,remainingTextForSession:Y,inactiveLabel:Pe}}),[Me,ve,t]),Ee=l.useMemo(()=>d?.connectUrl?d.bootstrapExpiresAt===null?!0:d.bootstrapExpiresAt>Me:!1,[Me,d?.bootstrapExpiresAt,d?.connectUrl]),Ke=l.useMemo(()=>!d||n!=="active"&&n!=="stopping"?!1:g===F,[g,n,d,F]),Le=l.useMemo(()=>!d||n!=="active"||!g?!1:g!==F,[g,n,d,F]),Se=l.useMemo(()=>{if(typeof Te=="number"&&Number.isFinite(Te)&&Te>0)return Te;if(typeof window>"u")return null;const ye=ki()||window.location.href;let Ae=0;try{Ae=Number(new URL(ye).port)}catch{Ae=Number(window.location.port)}return Number.isFinite(Ae)&&Ae>0?Ae:null},[Te]),$e=l.useMemo(()=>E.find(W=>W.provider===A)??null,[E,A]),Ye=l.useMemo(()=>{const W=new Set($e?.modes?.map(ye=>ye.key).filter(ye=>ye==="quick"||ye==="managed-remote"||ye==="managed-local"));return W.size===0?lr:lr.filter(ye=>W.has(ye.value))},[$e]),pt=l.useMemo(()=>Ye.some(W=>W.value==="managed-remote"||W.value==="managed-local"),[Ye]),vt=l.useMemo(()=>T.provider===A?T:cr(A),[T,A]),wt=l.useCallback(async W=>{await Gs(W)},[]),yt=l.useCallback((W,ye)=>(M(cr(ye,W)),W.available===!0),[]),st=l.useCallback(async(W,ye)=>{try{const Ae=await It("/api/openchamber/tunnel/check",{query:{provider:W},...ye?{signal:ye}:{}});if(!Ae.ok)return null;const Y=await Ae.json();if(ye?.aborted)return null;const Pe=yt(Y,W);return i(Je=>Je==="checking"||Je==="starting"||Je==="active"||Je==="stopping"?Je:Pe?"idle":"not-available"),Pe}catch{return null}},[yt]),rt=l.useCallback(async W=>{try{const[ye,Ae,Y,Pe]=await Promise.all([It("/api/openchamber/tunnel/check",{signal:W}),It("/api/openchamber/tunnel/status",{signal:W}),En(),It("/api/openchamber/tunnel/providers",{signal:W})]),Je=await ye.json(),se=await Ae.json(),We=Y??{},ut=Pe.ok?await Pe.json():{},Ce=se.ttlConfig?.bootstrapTtlMs??(We.tunnelBootstrapTtlMs===void 0?1800*1e3:We.tunnelBootstrapTtlMs),Ve=typeof se.ttlConfig?.sessionTtlMs=="number"?se.ttlConfig.sessionTtlMs:We.tunnelSessionTtlMs??480*60*1e3,jt=ea(se.mode??We.tunnelMode),Ot=We.tunnelProvider??"cloudflare",Yt=We.managedLocalTunnelConfigPath??null,Zt=yt(Je,Ot),Ft=cj(se?.managedRemoteTunnelPresets),ms=typeof se.managedRemoteTunnelHostname=="string"?se.managedRemoteTunnelHostname:"",gs=Ft.length>0?Ft:ms?[{id:`legacy-${to(ms)}`,name:ms,hostname:to(ms)}]:[],tn=gs[0]?.id||"";if(r(se.enterpriseMode===!0),oe(Ce),ce(Ve),x(Ot),D(Array.isArray(ut?.providers)?ut.providers:[]),L(jt),j(Yt),K(gs),ae(tn),Re(Array.isArray(se.activeSessions)?se.activeSessions:[]),m(se.activeTunnelMode?ea(se.activeTunnelMode):se.active&&se.mode?ea(se.mode):null),z(new Set(Array.isArray(se.managedRemoteTunnelTokenPresetIds)?se.managedRemoteTunnelTokenPresetIds:[])),Oe(typeof se.localPort=="number"?se.localPort:null),se.active&&se.url){c({url:se.url,connectUrl:null,bootstrapExpiresAt:typeof se.bootstrapExpiresAt=="number"?se.bootstrapExpiresAt:null}),i("active");return}i(Zt?"idle":"not-available")}catch{W.aborted||(i("error"),b(t("settings.openchamber.tunnel.toast.checkAvailabilityFailed")))}},[yt,t]);l.useEffect(()=>{const W=new AbortController;return rt(W.signal),()=>W.abort()},[rt]),l.useEffect(()=>{if(!d?.connectUrl){f(null);return}let W=!1;return jd.toDataURL(d.connectUrl,{width:256,margin:2,color:{dark:"#000000",light:"#ffffff"}}).then(ye=>{W||f(ye)}).catch(()=>{W||f(null)}),()=>{W=!0}},[d?.connectUrl]),l.useEffect(()=>{if(!d?.bootstrapExpiresAt){Ie(t("settings.openchamber.tunnel.state.noExpiry"));return}let W=null,ye=Date.now();const Ae=()=>{const Je=d.bootstrapExpiresAt?d.bootstrapExpiresAt-Date.now():0;Je<=0?Ie(t("settings.openchamber.tunnel.state.expired")):Ie($c(Je))},Y=()=>{const Je=Date.now();Je-ye>=1e3&&(Ae(),ye=Je),W=requestAnimationFrame(Y)};Ae(),(typeof document>"u"||document.visibilityState==="visible")&&(W=requestAnimationFrame(Y));const Pe=()=>{document.visibilityState==="visible"&&W===null?W=requestAnimationFrame(Y):document.visibilityState!=="visible"&&W!==null&&(cancelAnimationFrame(W),W=null)};return document.addEventListener("visibilitychange",Pe),()=>{document.removeEventListener("visibilitychange",Pe),W!==null&&cancelAnimationFrame(W)}},[t,d?.bootstrapExpiresAt]),l.useEffect(()=>{let W=null,ye=Date.now();const Ae=()=>{const Pe=Date.now();Pe-ye>=1e3&&(me(Pe),ye=Pe),W=requestAnimationFrame(Ae)};(typeof document>"u"||document.visibilityState==="visible")&&(W=requestAnimationFrame(Ae));const Y=()=>{document.visibilityState==="visible"&&W===null?W=requestAnimationFrame(Ae):document.visibilityState!=="visible"&&W!==null&&(cancelAnimationFrame(W),W=null)};return document.addEventListener("visibilitychange",Y),()=>{document.removeEventListener("visibilitychange",Y),W!==null&&cancelAnimationFrame(W)}},[]),l.useEffect(()=>{if(n==="starting"||n==="stopping"||n==="checking")return;let W=!1;const ye=async()=>{try{const Y=await It("/api/openchamber/tunnel/status");if(!Y.ok||W)return;const Pe=await Y.json();if(W)return;Re(Array.isArray(Pe.activeSessions)?Pe.activeSessions:[]),z(new Set(Array.isArray(Pe.managedRemoteTunnelTokenPresetIds)?Pe.managedRemoteTunnelTokenPresetIds:[])),Oe(typeof Pe.localPort=="number"?Pe.localPort:null)}catch{}},Ae=window.setInterval(()=>{typeof document<"u"&&document.visibilityState!=="visible"||ye()},5e3);return()=>{W=!0,window.clearInterval(Ae)}},[n]);const de=l.useCallback(async W=>{w(!0);try{await kt(W),Object.prototype.hasOwnProperty.call(W,"tunnelMode")&&W.tunnelMode&&L(W.tunnelMode),Object.prototype.hasOwnProperty.call(W,"tunnelProvider")&&typeof W.tunnelProvider=="string"&&x(W.tunnelProvider),Object.prototype.hasOwnProperty.call(W,"managedLocalTunnelConfigPath")&&j(W.managedLocalTunnelConfigPath??null),Object.prototype.hasOwnProperty.call(W,"managedRemoteTunnelPresets")&&W.managedRemoteTunnelPresets&&K(W.managedRemoteTunnelPresets)}catch{U.error(t("settings.openchamber.tunnel.toast.saveSettingsFailed"))}finally{w(!1)}},[t]),Ue=l.useCallback(async(W,ye)=>{S(!0);try{await kt({tunnelBootstrapTtlMs:W,tunnelSessionTtlMs:ye})}catch{U.error(t("settings.openchamber.tunnel.toast.saveTtlFailed"))}finally{S(!1)}},[t]),et=l.useCallback(async W=>{const ye=W.token.trim();if(ye)try{const Ae={...B,[W.presetId]:ye};await kt({managedRemoteTunnelPresetTokens:Ae}),z(Y=>{const Pe=new Set(Y);return Pe.add(W.presetId),Pe})}catch{U.error(t("settings.openchamber.tunnel.toast.saveTokenFailed"))}},[B,t]),ze=l.useCallback(async W=>{v(null),b(null);const ye=E.find(Y=>Y.provider===W),Ae=ye?.modes?.some(Y=>Y.key===F)?F:ea(ye?.modes?.[0]?.key);await de({tunnelProvider:W,tunnelMode:Ae}),st(W)},[E,st,de,F]),Ze=l.useCallback(async()=>{const W=await Vr({filters:[{name:"Config",extensions:["yml","yaml","json"]}]});if(W.success&&typeof W.path=="string"&&W.path.trim().length>0){const ye=W.path.trim();if(!mi(ye)){U.error(ge);return}j(ye),await de({managedLocalTunnelConfigPath:ye});return}xe.current?.click()},[ge,de]),tt=l.useCallback(W=>{const ye=W.trim();j(ye.length>0?ye:null)},[]),lt=l.useCallback(async()=>{if(P&&!mi(P)){U.error(ge);return}await de({managedLocalTunnelConfigPath:P})},[ge,P,de]),J=l.useCallback(async()=>{j(null),await de({managedLocalTunnelConfigPath:null})},[de]),nt=l.useCallback(async W=>{const ye=W.target.files?.[0];if(!ye)return;const Ae=ye.name.trim();if(Ae.length!==0){if(!mi(Ae)){U.error(ge);return}j(Ae),await de({managedLocalTunnelConfigPath:Ae}),W.target.value=""}},[ge,de]),ot=l.useCallback(async()=>{if(b(null),v(null),F==="managed-local"&&P&&!mi(P)){b(ge),U.error(ge);return}i("starting");try{let W="",ye="";if(F==="managed-remote"){if(!ie){i("idle"),v(t("settings.openchamber.tunnel.toast.selectOrAddManagedRemoteFirst")),U.error(t("settings.openchamber.tunnel.toast.selectOrAddManagedRemoteFirst"));return}W=ie.hostname,ye=(B[ie.id]||"").trim(),await de({tunnelMode:"managed-remote",managedRemoteTunnelPresets:O})}const Ae=await It("/api/openchamber/tunnel/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:A,mode:F,...F==="managed-remote"&&ie?{managedRemoteTunnelPresetId:ie.id,managedRemoteTunnelPresetName:ie.name}:{},...F==="managed-remote"&&W?{managedRemoteTunnelHostname:W}:{},...F==="managed-remote"&&ye?{managedRemoteTunnelToken:ye}:{},...F==="managed-local"&&P?{configPath:P}:{}})}),Y=await Ae.json();if(!Ae.ok||!Y.ok){if(F==="managed-remote"&&typeof Y.error=="string"&&Y.error.includes("Managed remote tunnel token is required")){i("idle"),v(t("settings.openchamber.tunnel.toast.managedRemoteTokenRequiredBeforeStarting")),U.error(t("settings.openchamber.tunnel.toast.addManagedRemoteTokenBeforeStarting"));return}i("error"),b(Y.error||t("settings.openchamber.tunnel.toast.startFailed")),U.error(Y.error||t("settings.openchamber.tunnel.toast.startFailed"));return}const Pe=typeof Y.url=="string"?Y.url:"";if(!Pe){i("error"),b(t("settings.openchamber.tunnel.toast.startedButNoPublicUrl")),U.error(t("settings.openchamber.tunnel.toast.startedButNoPublicUrl"));return}if(c({url:Pe,connectUrl:typeof Y.connectUrl=="string"?Y.connectUrl:null,bootstrapExpiresAt:typeof Y.bootstrapExpiresAt=="number"?Y.bootstrapExpiresAt:null}),m(Y.activeTunnelMode?ea(Y.activeTunnelMode):Y.mode?ea(Y.mode):F),Re(Array.isArray(Y.activeSessions)?Y.activeSessions:[]),Array.isArray(Y.managedRemoteTunnelTokenPresetIds)&&z(new Set(Y.managedRemoteTunnelTokenPresetIds)),typeof Y.localPort=="number"&&Oe(Y.localPort),typeof Y.mode=="string"&&L(ea(Y.mode)),i("active"),Y.replacedTunnel){const Je=typeof Y.revokedBootstrapCount=="number"?Y.revokedBootstrapCount:0,se=typeof Y.invalidatedSessionCount=="number"?Y.invalidatedSessionCount:0;Je===1&&se===1?U.warning(t("settings.openchamber.tunnel.toast.replacedTunnelSingleSingle")):Je===1?U.warning(t("settings.openchamber.tunnel.toast.replacedTunnelSingleManySessions",{invalidatedSessionCount:se})):se===1?U.warning(t("settings.openchamber.tunnel.toast.replacedTunnelManyLinksSingleSession",{revokedBootstrapCount:Je})):U.warning(t("settings.openchamber.tunnel.toast.replacedTunnelManyMany",{revokedBootstrapCount:Je,invalidatedSessionCount:se}))}else U.success(t("settings.openchamber.tunnel.toast.linkReady"))}catch{i("error"),b(t("settings.openchamber.tunnel.toast.startFailed")),U.error(t("settings.openchamber.tunnel.toast.startFailed"))}},[ge,O,de,ie,B,t,A,F,P]),it=l.useCallback(async()=>{i("stopping");try{await It("/api/openchamber/tunnel/stop",{method:"POST"});const W=await It("/api/openchamber/tunnel/status");if(W.ok){const ye=await W.json();Re(Array.isArray(ye.activeSessions)?ye.activeSessions:[]),z(new Set(Array.isArray(ye.managedRemoteTunnelTokenPresetIds)?ye.managedRemoteTunnelTokenPresetIds:[])),Oe(typeof ye.localPort=="number"?ye.localPort:null)}c(null),m(null),f(null),i("idle"),U.success(t("settings.openchamber.tunnel.toast.stopped"))}catch{i("error"),b(t("settings.openchamber.tunnel.toast.stopFailed")),U.error(t("settings.openchamber.tunnel.toast.stopFailed"))}},[t]),ft=l.useCallback(async()=>{if(d?.connectUrl)try{await navigator.clipboard.writeText(d.connectUrl),u(!0),U.success(t("settings.openchamber.tunnel.toast.connectLinkCopied")),setTimeout(()=>u(!1),2e3)}catch{U.error(t("settings.openchamber.tunnel.toast.copyUrlFailed"))}},[t,d?.connectUrl]),xt=l.useCallback(async W=>{const ye=Ji.find(Ae=>Ae.value===W);ye&&(oe(ye.ms),await Ue(ye.ms,ee))},[Ue,ee]),ht=l.useCallback(async W=>{const ye=Qi.find(Ae=>Ae.value===W);!ye||ye.ms===null||(ce(ye.ms),await Ue(De,ye.ms))},[De,Ue]),St=l.useCallback(async W=>{v(null),b(null),n!=="active"&&n!=="stopping"&&n!=="starting"&&i("idle"),await de({tunnelMode:W,managedRemoteTunnelPresets:O})},[O,de,n]),At=l.useCallback(async(W,ye)=>{try{await kt({managedRemoteTunnelPresets:ye})}catch{U.error(t("settings.openchamber.tunnel.toast.saveSelectedManagedRemoteFailed"))}},[t]),_e=l.useCallback(W=>{const ye=O.find(Ae=>Ae.id===W);ye&&(ae(ye.id),v(null),At(ye,O))},[O,At]),Xe=l.useCallback(async()=>{const W=X.trim(),ye=to(je),Ae=ke.trim();if(!W){U.error(t("settings.openchamber.tunnel.toast.tunnelNameRequired"));return}if(!ye){U.error(t("settings.openchamber.tunnel.toast.managedRemoteHostnameRequired"));return}if(!Ae){U.error(t("settings.openchamber.tunnel.toast.managedRemoteTokenRequired"));return}if(O.some(Je=>Je.hostname===ye)){U.error(t("settings.openchamber.tunnel.toast.hostnameAlreadyExists"));return}const Y={id:dj(),name:W,hostname:ye},Pe=[...O,Y];K(Pe),ae(Y.id),q(Je=>({...Je,[Y.id]:!0})),G(Je=>({...Je,[Y.id]:Ae})),v(null),Q(!1),pe(""),fe(""),be(""),await de({tunnelMode:"managed-remote",managedRemoteTunnelPresets:Pe,managedRemoteTunnelPresetTokens:{...B,[Y.id]:Ae}}),await et({presetId:Y.id,presetName:Y.name,hostname:Y.hostname,token:Ae}),U.success(t("settings.openchamber.tunnel.toast.managedRemoteSaved"))},[O,je,X,ke,et,de,B,t]),mt=l.useCallback(async W=>{const ye=O.find(se=>se.id===W);if(!ye)return;const Ae=O.filter(se=>se.id!==ye.id),Y=Ae[0]?.id||"",Pe=Z===ye.id?Y:Z,Je=Object.fromEntries(Object.entries(B).filter(([se,We])=>se!==ye.id&&We.trim().length>0));K(Ae),ae(Pe),q(se=>{const We={...se};return delete We[ye.id],We}),G(se=>{const We={...se};return delete We[ye.id],We}),z(se=>{const We=new Set(se);return We.delete(ye.id),We}),v(null),await de({managedRemoteTunnelPresets:Ae,managedRemoteTunnelPresetTokens:Je}),U.success(t("settings.openchamber.tunnel.toast.managedRemoteRemoved"))},[O,de,Z,B,t]),Fe="gap-2 border-[var(--primary-base)] bg-[var(--primary-base)] text-[var(--primary-foreground)] hover:bg-[var(--primary-hover)] hover:text-[var(--primary-foreground)]";return n==="checking"?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current animate-busy-pulse","aria-label":t("settings.openchamber.tunnel.state.loading")})}):o?s.jsx(He,{title:t("settings.openchamber.tunnel.title"),divider:!1,children:s.jsx("p",{className:Pn,children:t("settings.openchamber.tunnel.enterpriseMode")})}):s.jsx(He,{title:t("settings.openchamber.tunnel.title"),info:s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{children:t("settings.openchamber.tunnel.description")}),s.jsx("p",{children:t("settings.openchamber.tunnel.note.serverSideEnforced")}),s.jsx("p",{children:t("settings.openchamber.tunnel.note.connectLinksOneTime")})]}),divider:!1,children:s.jsxs("div",{className:"space-y-6",children:[he.length>0&&s.jsx("section",{className:"space-y-2 px-2 pb-2 pt-0",children:s.jsxs("div",{className:"rounded-lg border border-[var(--status-info-border)] bg-[var(--status-info-background)]/30 p-3",children:[s.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[s.jsx($,{name:"information",className:"size-4 text-[var(--status-info)]"}),s.jsx("p",{className:fr,children:t("settings.openchamber.tunnel.section.redeemedAccessLinks")})]}),s.jsx("div",{className:"space-y-1",children:he.map(W=>{const ye=W.mode==="quick",Ae=W.mode==="managed-remote",Y=ye?"border-[var(--status-warning-border)] bg-[var(--status-warning-background)] text-[var(--status-warning)]":Ae?"border-[var(--status-info-border)] bg-[var(--status-info-background)] text-[var(--status-info)]":"border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)]",Pe=W.isActive?ye?"text-[var(--status-warning)]":Ae?"text-[var(--status-info)]":"text-[var(--status-success)]":"text-muted-foreground/50",Je=t(ye?"settings.openchamber.tunnel.badge.quick":Ae?"settings.openchamber.tunnel.badge.remote":"settings.openchamber.tunnel.badge.local");return s.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 rounded border border-[var(--surface-subtle)] bg-[var(--surface-elevated)] px-2 py-1.5",children:[s.jsx($,{name:"checkbox-blank-circle-fill",className:Ne("size-2.5 shrink-0",Pe)}),s.jsx("span",{className:Ne("typography-micro rounded border px-1.5 py-0.5 uppercase",Y),children:Je}),s.jsx("span",{className:"typography-meta text-muted-foreground/80",children:t("settings.openchamber.tunnel.session.redeemedAt",{time:lj(W.createdAt,e)})}),s.jsx("span",{className:"typography-meta text-foreground",children:W.isActive?t("settings.openchamber.tunnel.session.expiresIn",{remaining:W.remainingTextForSession}):W.inactiveLabel===t("settings.openchamber.tunnel.state.inactive")?t("settings.openchamber.tunnel.state.inactive"):t("settings.openchamber.tunnel.session.inactiveWithReason",{reason:W.inactiveLabel})})]},W.sessionId)})})]})}),n==="not-available"&&s.jsx("section",{className:"space-y-2 px-2 pb-2 pt-0",children:s.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-[var(--status-warning)]/30 bg-[var(--status-warning)]/5 p-3",children:[s.jsx($,{name:"error-warning",className:"mt-0.5 size-4 shrink-0 text-[var(--status-warning)]"}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("p",{className:fr,children:t("settings.openchamber.tunnel.notAvailable.dependencyNotFound",{dependency:vt.dependency})}),s.jsx("p",{className:"typography-meta text-muted-foreground/70",children:t("settings.openchamber.tunnel.notAvailable.installHint")}),s.jsx("code",{className:"typography-code block rounded bg-muted/50 px-2 py-1 text-xs text-foreground",children:vt.installCommand})]})]})}),s.jsxs("section",{className:"space-y-4 px-2 pb-2 pt-0",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{"data-settings-item":"tunnel.provider",className:"space-y-1.5",children:[s.jsx("p",{className:Pt,children:t("settings.openchamber.tunnel.field.provider")}),s.jsxs(Dt,{value:A,onValueChange:W=>{ze(W)},disabled:N||n==="starting"||n==="stopping",children:[s.jsx(Tt,{size:Qt,className:"max-w-[16rem]",children:s.jsx(Jt,{placeholder:t("settings.openchamber.tunnel.field.providerPlaceholder"),children:lu(A)})}),s.jsxs(Et,{children:[E.length>0?E.map(W=>s.jsx(gt,{value:W.provider,children:s.jsx(Uc,{provider:W.provider})},W.provider)):s.jsx(gt,{value:"cloudflare",children:s.jsx(Uc,{provider:"cloudflare"})}),s.jsx(gt,{value:"__more-soon",disabled:!0,children:t("settings.openchamber.tunnel.option.moreProvidersSoon")})]})]})]}),s.jsxs("div",{"data-settings-item":"tunnel.type",className:"space-y-1.5",children:[s.jsx("p",{className:Pt,children:t("settings.openchamber.tunnel.field.tunnelType")}),s.jsx("div",{className:"flex flex-wrap items-center gap-1",children:Ye.map(W=>s.jsxs(pd,{children:[s.jsx(gd,{asChild:!0,children:s.jsx(V,{variant:"chip",size:"xs","aria-pressed":F===W.value,className:"!font-normal",onClick:()=>{St(W.value)},disabled:N||n==="starting"||n==="stopping",children:a(W.labelKey)})}),s.jsx(jm,{sideOffset:8,className:"max-w-xs",children:a(W.tooltipKey)})]},W.value))})]})]}),s.jsxs("div",{"data-settings-item":"tunnel.ttl",className:"mt-2 grid grid-cols-1 gap-2 py-1.5 md:grid-cols-[14rem_auto] md:gap-x-8 md:gap-y-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{className:Ne(Pt,"shrink-0"),children:t("settings.openchamber.tunnel.field.connectLinkTtl")}),s.jsxs(Dt,{value:Er(Ji,De,"1800000"),onValueChange:W=>{xt(W)},disabled:y||N||n==="starting"||n==="stopping",children:[s.jsx(Tt,{size:Qt,className:"max-w-[11rem] min-w-0",children:s.jsx(Jt,{className:"truncate",children:_c(Ji,De,"1800000")})}),s.jsx(Et,{children:Ji.map(W=>s.jsx(gt,{value:W.value,children:W.label},W.value))})]})]}),s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx("span",{className:Ne(Pt,"shrink-0"),children:t("settings.openchamber.tunnel.field.tunnelSessionTtl")}),s.jsxs(Dt,{value:Er(Qi,ee,"28800000"),onValueChange:W=>{ht(W)},disabled:y||N||n==="starting"||n==="stopping",children:[s.jsx(Tt,{size:Qt,className:"max-w-[11rem] min-w-0",children:s.jsx(Jt,{className:"truncate",children:_c(Qi,ee,"28800000")})}),s.jsx(Et,{children:Qi.map(W=>s.jsx(gt,{value:W.value,children:W.label},W.value))})]})]})]}),F==="quick"&&s.jsx("div",{className:"rounded-lg border border-[var(--status-warning)]/35 bg-[var(--status-warning)]/10 p-3",children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx($,{name:"error-warning",className:"mt-0.5 size-4 shrink-0 text-[var(--status-warning)]"}),s.jsxs("div",{children:[s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:t("settings.openchamber.tunnel.option.mode.quick.tooltip")}),pt&&s.jsx("p",{className:"typography-meta mt-1 text-[var(--status-warning)]",children:t("settings.openchamber.tunnel.warning.quickModeReliability")})]})]})}),F==="managed-remote"&&s.jsxs("div",{"data-settings-item":"tunnel.managed-remote",className:"space-y-2 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-3",children:[typeof Se=="number"&&s.jsx("div",{className:"rounded-md border border-[var(--status-info-border)] bg-[var(--status-info-background)]/35 px-2 py-1.5",children:s.jsxs("p",{className:"typography-meta text-[var(--status-info)]",children:[t("settings.openchamber.tunnel.note.cloudflareConnectorTarget")," ",s.jsxs("code",{children:["http://localhost:",Se]})]})}),s.jsxs("div",{className:"mb-1 flex items-center justify-between gap-3",children:[s.jsx(An,{children:t("settings.openchamber.tunnel.section.savedManagedRemoteTunnels")}),s.jsxs(V,{variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>Q(W=>!W),disabled:n==="starting"||n==="stopping"||N,children:[s.jsx($,{name:"add",className:"h-3.5 w-3.5"}),t("settings.common.actions.create")]})]}),O.length>0?s.jsx("div",{className:"overflow-hidden rounded-md border border-[var(--surface-subtle)]",children:O.map((W,ye)=>{const Ae=B[W.id]||"",Y=_.has(W.id),Pe=H[W.id]??!1;return s.jsx("div",{className:Ne(ye<O.length-1&&"border-b border-[var(--surface-subtle)]"),children:s.jsxs(bn,{open:Pe,onOpenChange:Je=>{q(se=>({...se,[W.id]:Je})),Je&&_e(W.id)},className:"py-1.5",children:[s.jsxs("div",{className:"flex items-start gap-2 px-3",children:[s.jsxs(vn,{type:"button",className:"group flex-1 justify-start gap-2 rounded-md px-0 py-1 pr-1 text-left hover:bg-[var(--interactive-hover)]",disabled:n==="starting"||n==="stopping"||N,children:[Pe?s.jsx($,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"}):s.jsx($,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground"}),s.jsx("span",{className:"typography-ui-label min-w-0 flex-1 truncate text-foreground",children:W.name})]}),s.jsx(V,{variant:"ghost",size:"xs",className:"h-7 w-7 p-0 text-muted-foreground hover:text-[var(--status-error)]","aria-label":t("settings.openchamber.tunnel.actions.removePresetAria",{name:W.name}),onClick:()=>{mt(W.id)},disabled:n==="starting"||n==="stopping"||N,children:s.jsx($,{name:"delete-bin",className:"h-3.5 w-3.5"})})]}),s.jsx(yn,{className:"pt-1.5",children:s.jsxs("div",{className:"space-y-1 px-3 pb-2",children:[s.jsxs("p",{className:"typography-meta text-muted-foreground/70",children:[t("settings.openchamber.tunnel.field.hostnameLabel")," ",s.jsx("code",{children:W.hostname})]}),s.jsx(Ge,{type:"password",value:Ae,onChange:Je=>{const se=Je.target.value;v(null),G(We=>({...We,[W.id]:se}))},onBlur:Je=>{const se=Je.currentTarget.value.trim();se&&et({presetId:W.id,presetName:W.name,hostname:W.hostname,token:se})},placeholder:t(Y?"settings.openchamber.tunnel.field.savedTokenAvailablePlaceholder":"settings.openchamber.tunnel.field.pasteTokenPlaceholder"),className:"h-7",disabled:n==="starting"||n==="stopping"}),s.jsx("div",{className:"flex items-center justify-end",children:s.jsx(V,{variant:"ghost",size:"xs",className:"!font-normal",disabled:n==="starting"||n==="stopping"||Ae.trim().length===0,onClick:()=>{et({presetId:W.id,presetName:W.name,hostname:W.hostname,token:Ae})},children:t("settings.openchamber.tunnel.actions.saveToken")})})]})})]})},W.id)})}):s.jsx("p",{className:"typography-meta text-muted-foreground/70",children:t("settings.openchamber.tunnel.empty.noManagedRemoteTunnels")}),te&&s.jsxs("div",{className:"space-y-2 rounded-md border border-[var(--surface-subtle)] p-2",children:[s.jsx(Ge,{value:X,onChange:W=>pe(W.target.value),placeholder:t("settings.openchamber.tunnel.field.newPresetNamePlaceholder"),className:"h-7",disabled:N||n==="starting"||n==="stopping"}),s.jsx(Ge,{value:je,onChange:W=>fe(W.target.value),placeholder:t("settings.openchamber.tunnel.field.newPresetHostnamePlaceholder"),className:"h-7",disabled:N||n==="starting"||n==="stopping"}),s.jsx(Ge,{type:"password",value:ke,onChange:W=>be(W.target.value),placeholder:t("settings.openchamber.tunnel.field.newPresetTokenPlaceholder"),className:"h-7",disabled:N||n==="starting"||n==="stopping"}),typeof Se=="number"&&s.jsxs("p",{className:"typography-meta text-muted-foreground/70",children:[t("settings.openchamber.tunnel.note.cloudflareConnectorTargetUse")," ",s.jsxs("code",{children:["http://localhost:",Se]}),"."]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(V,{variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{Xe()},disabled:N||n==="starting"||n==="stopping",children:t("settings.common.actions.saveChanges")}),s.jsx(V,{variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{Q(!1),pe(""),fe(""),be("")},disabled:N||n==="starting"||n==="stopping",children:t("settings.common.actions.cancel")})]})]}),s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("p",{className:"typography-meta text-muted-foreground/80",children:t("settings.openchamber.tunnel.note.tokensSavedPerTunnel")}),s.jsx(Gt,{children:t("settings.openchamber.tunnel.tooltip.tokensSavedPath")})]}),!ie&&C&&s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:C})]}),F==="managed-local"&&s.jsx("div",{"data-settings-item":"tunnel.managed-local-config",className:"space-y-2 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-3",children:s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("p",{className:Pt,children:t("settings.openchamber.tunnel.field.configurationFile")}),s.jsx("input",{ref:xe,type:"file",accept:".yml,.yaml,.json",className:"hidden",onChange:W=>{nt(W)}}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ge,{value:P||"",onChange:W=>{tt(W.target.value)},onBlur:()=>{lt()},placeholder:t("settings.openchamber.tunnel.field.configurationFilePlaceholder"),className:"h-7",disabled:n==="starting"||n==="stopping"||N}),s.jsx(V,{variant:"outline",size:"xs",className:"h-7 w-7 p-0","aria-label":t("settings.openchamber.tunnel.actions.browseConfigFileAria"),onClick:()=>{Ze()},disabled:n==="starting"||n==="stopping"||N,children:s.jsx($,{name:"folder",className:"size-3.5"})}),P&&s.jsx(V,{variant:"ghost",size:"xs",className:"h-7 w-7 p-0","aria-label":t("settings.openchamber.tunnel.actions.clearConfigFileAria"),onClick:()=>{J()},disabled:n==="starting"||n==="stopping"||N,children:s.jsx($,{name:"close",className:"size-3.5"})})]}),s.jsx("p",{className:"typography-meta text-muted-foreground/70",children:t(P?"settings.openchamber.tunnel.note.customConfigUsed":"settings.openchamber.tunnel.note.defaultConfigUsed")}),ne&&s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:ge})]})}),!Ke&&s.jsxs("div",{"data-settings-item":"tunnel.start",className:"space-y-6",children:[s.jsx("div",{className:"rounded-lg border border-[var(--status-info-border)] bg-[var(--status-info-background)] p-3",children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx($,{name:"information",className:"mt-0.5 size-4 shrink-0 text-[var(--status-info)]"}),s.jsxs("div",{className:"space-y-1",children:[F==="managed-remote"&&s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"typography-meta text-[var(--status-info)]",children:t("settings.openchamber.tunnel.note.managedRemoteRequiresDomain")}),s.jsxs("button",{type:"button",className:"typography-meta inline-flex items-center gap-1 text-[var(--status-info)] underline underline-offset-2 hover:opacity-90",onClick:()=>{wt(sj)},children:[t("settings.openchamber.tunnel.actions.openManagedRemoteDocs"),s.jsx($,{name:"external-link",className:"size-3.5"})]})]}),F==="managed-local"&&s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"typography-meta text-[var(--status-info)]",children:t("settings.openchamber.tunnel.note.managedLocalUsesConfig")}),s.jsxs("button",{type:"button",className:"typography-meta inline-flex items-center gap-1 text-[var(--status-info)] underline underline-offset-2 hover:opacity-90",onClick:()=>{wt(nj)},children:[t("settings.openchamber.tunnel.actions.openManagedLocalDocs"),s.jsx($,{name:"external-link",className:"size-3.5"})]})]}),s.jsx("p",{className:"typography-meta text-[var(--status-info)]",children:t("settings.openchamber.tunnel.note.startModeAndGenerateLink",{mode:a(lr.find(W=>W.value===F)?.labelKey??"settings.openchamber.tunnel.option.mode.quick.label")})})]})]})}),F==="managed-remote"&&s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("p",{className:Pt,children:t("settings.openchamber.tunnel.field.managedRemoteTunnelToConnect")}),s.jsxs(Dt,{value:Z||(O[0]?.id??""),onValueChange:W=>{_e(W)},disabled:N||n==="starting"||n==="stopping"||O.length<=1,children:[s.jsx(Tt,{size:Qt,children:s.jsx(Jt,{placeholder:t("settings.openchamber.tunnel.field.selectSavedTunnelPlaceholder"),children:ie?.name})}),s.jsx(Et,{fitContent:!0,children:O.map(W=>s.jsx(gt,{value:W.id,children:W.name},W.id))})]})]}),Le&&s.jsx("div",{className:"rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] p-3",children:s.jsxs("div",{className:"flex items-start gap-2",children:[s.jsx($,{name:"error-warning",className:"mt-0.5 size-4 shrink-0 text-[var(--status-warning)]"}),s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:t("settings.openchamber.tunnel.warning.replacesActiveTunnel")})]})}),s.jsx(V,{size:"sm",variant:"outline",onClick:ot,disabled:n==="starting"||N||F==="managed-remote"&&!ie||F==="managed-local"&&ne,className:Ne(Fe,n==="starting"&&"opacity-70"),children:n==="starting"?s.jsxs(s.Fragment,{children:[s.jsx($,{name:"loader-4",className:"size-3.5 animate-spin"})," ",t("settings.openchamber.tunnel.actions.startingTunnel")]}):t("settings.openchamber.tunnel.actions.startTunnel")})]})]}),Ke&&d&&s.jsxs("section",{"data-settings-item":"tunnel.start",className:"space-y-4 px-2 pb-2 pt-0",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"size-2 shrink-0 rounded-full bg-[var(--status-success)]"}),s.jsx("p",{className:"typography-meta font-medium text-foreground",children:t("settings.openchamber.tunnel.state.tunnelReady")})]}),s.jsxs("div",{children:[s.jsx("p",{className:"typography-meta mb-1 text-muted-foreground/70",children:t("settings.openchamber.tunnel.field.publicUrlHint")}),s.jsx("code",{className:"typography-code block truncate rounded bg-muted/50 px-2 py-1 text-xs text-foreground",children:d.url})]}),Ee&&d.connectUrl&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("p",{className:"typography-meta mb-1 text-muted-foreground/70",children:t("settings.openchamber.tunnel.field.connectLink")}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("code",{className:"typography-code flex-1 truncate rounded bg-muted/50 px-2 py-1 text-xs text-foreground",children:d.connectUrl}),s.jsxs(V,{size:"sm",variant:"ghost",onClick:ft,className:"shrink-0 gap-1.5",children:[k?s.jsx($,{name:"check",className:"size-3.5 text-[var(--status-success)]"}):s.jsx($,{name:"file-copy",className:"size-3.5"}),t(k?"settings.openchamber.tunnel.actions.copied":"settings.common.actions.copyAll")]})]}),s.jsxs("p",{className:"typography-meta mt-1 text-muted-foreground/70",children:[t("settings.openchamber.tunnel.field.expires"),": ",d.bootstrapExpiresAt?ue:t("settings.openchamber.tunnel.state.never")]})]}),s.jsxs("div",{className:"flex flex-col items-center gap-2 rounded-lg border border-border/50 bg-[var(--surface-elevated)] p-4",children:[h?s.jsx("img",{src:h,alt:t("settings.openchamber.tunnel.field.connectQrAlt"),className:"size-48"}):s.jsx("div",{className:"size-48 rounded bg-muted/30"}),s.jsx("p",{className:"typography-meta text-muted-foreground",children:t("settings.openchamber.tunnel.note.scanQrToConnect")})]})]})]}),s.jsx("div",{className:"pt-1",children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s.jsxs(V,{size:"sm",variant:"outline",onClick:ot,disabled:n==="stopping"||N||F==="managed-local"&&ne,className:Fe,children:[s.jsx($,{name:"restart",className:"size-3.5"}),t("settings.openchamber.tunnel.actions.newConnectLink")]}),s.jsx(V,{size:"sm",variant:"ghost",onClick:it,disabled:n==="stopping"||N,className:"gap-2 text-[var(--status-error)]",children:n==="stopping"?s.jsxs(s.Fragment,{children:[s.jsx($,{name:"loader-4",className:"size-3.5 animate-spin"})," ",t("settings.openchamber.tunnel.actions.stopping")]}):t("settings.openchamber.tunnel.actions.stopTunnel")})]})})]}),n==="error"&&p&&s.jsxs("section",{className:"space-y-3 px-2 pb-2 pt-0",children:[s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:p}),s.jsx(V,{size:"sm",variant:"ghost",onClick:ot,children:t("settings.openchamber.tunnel.actions.retry")})]})]})})},cu=()=>{const{t}=qe(),[e,a]=at.useState(""),[n,i]=at.useState(!0),[o,r]=at.useState(!1),d=re(p=>p.showOpenCodeUpdateNotifications),c=re(p=>p.setShowOpenCodeUpdateNotifications);at.useEffect(()=>{let p=!1;return(async()=>{try{const b=await En();if(p||!b)return;a(b.opencodeBinary??"")}catch{}finally{p||i(!1)}})(),()=>{p=!0}},[]);const g=at.useCallback(async()=>{if(!(typeof window>"u")&&us())try{const p=await Vr();p.success&&p.path&&p.path.trim().length>0&&a(p.path.trim())}catch{}},[]),m=at.useCallback(async()=>{r(!0);try{const p=e.trim(),b=p.length>=2&&(p.startsWith('"')&&p.endsWith('"')||p.startsWith("'")&&p.endsWith("'"))?p.slice(1,-1).trim():p;await kt({opencodeBinary:b}),await Jc({message:t("settings.openchamber.opencodeCli.actions.restartingOpenCode"),mode:"projects",scopes:["all"]})}catch(p){if(p?.requiresManualRestart){U.warning(t("settings.openchamber.opencodeCli.restart.manualRequired"));return}U.error(t("settings.openchamber.opencodeCli.restart.failed"))}finally{r(!1)}},[t,e]),h=at.useCallback(async()=>{r(!0);try{await hp(t)}finally{r(!1)}},[t]),f=at.useCallback(p=>{c(p),kt({showOpenCodeUpdateNotifications:p})},[c]);return s.jsx(He,{title:t("settings.openchamber.opencodeCli.title"),children:s.jsxs("div",{className:"space-y-0.5",children:[s.jsxs(Ct,{settingsItem:"sessions.opencode-binary",label:t("settings.openchamber.opencodeCli.field.binaryPath"),info:s.jsxs(s.Fragment,{children:[t("settings.openchamber.opencodeCli.tipPrefix")," ",s.jsx("span",{className:"font-mono",children:"OPENCODE_BINARY"})," ",t("settings.openchamber.opencodeCli.tipMiddle")," ",s.jsx("span",{className:"font-mono",children:"~/.config/openchamber/settings.json"}),"."]}),alignEnd:!1,controlClassName:"@xl:w-[20rem]",children:[s.jsx(Ge,{value:e,onChange:p=>a(p.target.value),placeholder:t("settings.openchamber.opencodeCli.field.binaryPathPlaceholder"),disabled:n||o,className:"h-8 min-w-0 flex-1 font-mono text-xs"}),s.jsx(V,{type:"button",variant:"outline",size:"xs",onClick:g,disabled:n||o||!us(),className:hs,"aria-label":t("settings.openchamber.opencodeCli.actions.browseAria"),title:t("settings.openchamber.opencodeCli.actions.browse"),children:s.jsx($,{name:"folder",className:"h-4 w-4"})})]}),s.jsxs(ha,{className:ys,children:[s.jsx(bt,{settingsItem:"sessions.opencode-update-notifications",checked:d,onChange:f,label:t("settings.openchamber.opencodeCli.field.showUpdateNotifications"),ariaLabel:t("settings.openchamber.opencodeCli.field.showUpdateNotificationsAria")}),s.jsxs("div",{className:"flex flex-wrap justify-start gap-2 py-1.5","data-settings-item":"sessions.opencode-restart",children:[s.jsx(V,{type:"button",size:"xs",onClick:m,disabled:n||o,className:"shrink-0 !font-normal",children:t(o?"settings.openchamber.opencodeCli.actions.restartingOpenCode":"settings.openchamber.opencodeCli.actions.saveAndReload")}),s.jsx(V,{type:"button",variant:"outline",size:"xs",onClick:h,disabled:n||o,className:"shrink-0 !font-normal",children:t("settings.openchamber.opencodeCli.actions.restart")})]})]})]})})},po=!1,dr="builtin",mj=t=>t.filter(e=>_r(e)&&dd(e.service,"browser")),pj="pl-[3.75rem]",Yi=t=>{const e=Be.c(31),{icon:a,title:n,summary:i,info:o,ariaLabel:r,checked:d,onChange:c,settingsItem:g}=t,m=!d&&"opacity-50";let h;e[0]!==m?(h=Ne("flex size-8 shrink-0 items-center justify-center rounded-lg bg-[var(--surface-muted)] text-foreground transition-opacity",m),e[0]=m,e[1]=h):h=e[1];let f;e[2]!==a?(f=s.jsx($,{name:a,className:"size-4"}),e[2]=a,e[3]=f):f=e[3];let p;e[4]!==h||e[5]!==f?(p=s.jsx("span",{className:h,children:f}),e[4]=h,e[5]=f,e[6]=p):p=e[6];const b=!d&&"opacity-60";let C;e[7]!==b?(C=Ne("min-w-0 flex-1 transition-opacity",b),e[7]=b,e[8]=C):C=e[8];let v;e[9]!==n?(v=s.jsx("span",{className:"truncate typography-ui-label font-medium text-foreground",children:n}),e[9]=n,e[10]=v):v=e[10];let k;e[11]!==o?(k=s.jsx(Gt,{children:o}),e[11]=o,e[12]=k):k=e[12];let u;e[13]!==v||e[14]!==k?(u=s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[v,k]}),e[13]=v,e[14]=k,e[15]=u):u=e[15];let y;e[16]!==i?(y=s.jsx("p",{className:"typography-meta text-muted-foreground",children:i}),e[16]=i,e[17]=y):y=e[17];let S;e[18]!==y||e[19]!==C||e[20]!==u?(S=s.jsxs("div",{className:C,children:[u,y]}),e[18]=y,e[19]=C,e[20]=u,e[21]=S):S=e[21];let N;e[22]!==r||e[23]!==d||e[24]!==c?(N=s.jsx(ga,{checked:d,onCheckedChange:c,"aria-label":r}),e[22]=r,e[23]=d,e[24]=c,e[25]=N):N=e[25];let w;return e[26]!==g||e[27]!==S||e[28]!==N||e[29]!==p?(w=s.jsxs("div",{"data-settings-item":g,className:"flex items-center gap-3 px-4 py-3",children:[p,S,N]}),e[26]=g,e[27]=S,e[28]=N,e[29]=p,e[30]=w):w=e[30],w},du=()=>{const t=Be.c(130),{t:e}=qe(),a=re(gj),n=re(fj),i=re(hj),o=re(xj),r=re(bj),d=re(vj),c=Ks(yj),g=re(jj),m=re(kj),h=re(wj),f=re(Nj),p=re(Sj),b=re(Cj),C=re(Ij);let v;t[0]!==n?(v=$e=>{n($e),kt({agentControlToolEnabled:$e})},t[0]=n,t[1]=v):v=t[1];const k=v;let u;t[2]!==o?(u=$e=>{o($e),kt({agentWebToolEnabled:$e})},t[2]=o,t[3]=u):u=t[3];const y=u;let S;t[4]!==p?(S=$e=>{p($e),kt({agentNotifyToolEnabled:$e})},t[4]=p,t[5]=S):S=t[5];const N=S;let w;t[6]!==C?(w=$e=>{C($e),kt({agentToolsCodeMode:$e})},t[6]=C,t[7]=w):w=t[7];const A=w;let x;t[8]===Symbol.for("react.memo_cache_sentinel")?(x=[],t[8]=x):x=t[8],at.useEffect(Pj,x);let T;t[9]!==c?(T=mj(c),t[9]=c,t[10]=T):T=t[10];const M=T;let E;t[11]!==r||t[12]!==M?(E=M.some($e=>$e.id===r)?r:dr,t[11]=r,t[12]=M,t[13]=E):E=t[13];const D=E;let F;t[14]!==d?(F=$e=>{d($e),kt({browserProvider:$e})},t[14]=d,t[15]=F):F=t[15];const L=F;let P;t[16]!==h?(P=$e=>{h($e),kt({agentMemoryToolEnabled:$e}).finally(()=>{$e&&km.getState().refresh()})},t[16]=h,t[17]=P):P=t[17];const j=P;let O;t[18]!==e?(O=e("settings.openchamber.tools.title"),t[18]=e,t[19]=O):O=t[19];let K;t[20]!==e?(K=e("settings.openchamber.tools.field.agentControlTool"),t[20]=e,t[21]=K):K=t[21];let H;t[22]!==e?(H=e("settings.openchamber.tools.field.agentControlToolSummary"),t[22]=e,t[23]=H):H=t[23];let q;t[24]!==e?(q=e("settings.openchamber.tools.field.agentControlToolInfo"),t[24]=e,t[25]=q):q=t[25];let Z;t[26]!==e?(Z=e("settings.openchamber.tools.field.agentControlToolAria"),t[26]=e,t[27]=Z):Z=t[27];let ae;t[28]!==a||t[29]!==k||t[30]!==K||t[31]!==H||t[32]!==q||t[33]!==Z?(ae=s.jsx(Yi,{icon:"node-tree",settingsItem:"sessions.agent-control-tool",checked:a,onChange:k,title:K,summary:H,info:q,ariaLabel:Z}),t[28]=a,t[29]=k,t[30]=K,t[31]=H,t[32]=q,t[33]=Z,t[34]=ae):ae=t[34];let B;t[35]!==e?(B=e("settings.openchamber.tools.field.agentWebTool"),t[35]=e,t[36]=B):B=t[36];let G;t[37]!==e?(G=e("settings.openchamber.tools.field.agentWebToolSummary"),t[37]=e,t[38]=G):G=t[38];let _;t[39]!==e?(_=e("settings.openchamber.tools.field.agentWebToolInfo"),t[39]=e,t[40]=_):_=t[40];let z;t[41]!==e?(z=e("settings.openchamber.tools.field.agentWebToolAria"),t[41]=e,t[42]=z):z=t[42];let te;t[43]!==i||t[44]!==y||t[45]!==B||t[46]!==G||t[47]!==_||t[48]!==z?(te=s.jsx(Yi,{icon:"global",settingsItem:"sessions.agent-web-tool",checked:i,onChange:y,title:B,summary:G,info:_,ariaLabel:z}),t[43]=i,t[44]=y,t[45]=B,t[46]=G,t[47]=_,t[48]=z,t[49]=te):te=t[49];let Q;t[50]===Symbol.for("react.memo_cache_sentinel")?(Q=Ne("flex min-w-0 items-center gap-2 pb-3 pr-4",pj),t[50]=Q):Q=t[50];let X;t[51]!==e?(X=e("settings.openchamber.tools.browserProvider.label"),t[51]=e,t[52]=X):X=t[52];let pe;t[53]!==X?(pe=s.jsx("span",{className:"truncate typography-meta text-muted-foreground",children:X}),t[53]=X,t[54]=pe):pe=t[54];let je;t[55]!==e?(je=e("settings.openchamber.tools.browserProvider.info"),t[55]=e,t[56]=je):je=t[56];let fe;t[57]!==je?(fe=s.jsx(Gt,{children:je}),t[57]=je,t[58]=fe):fe=t[58];const ke=!i||M.length===0;let be;t[59]!==e?(be=e("settings.openchamber.tools.browserProvider.aria"),t[59]=e,t[60]=be):be=t[60];let De;t[61]!==M||t[62]!==e?(De=s.jsx(Jt,{children:$e=>$e===dr?e("settings.openchamber.tools.browserProvider.option.builtin"):M.find(Ye=>Ye.id===$e)?.name??null}),t[61]=M,t[62]=e,t[63]=De):De=t[63];let oe;t[64]!==be||t[65]!==De?(oe=s.jsx(Tt,{size:Qt,className:"ml-auto w-auto min-w-0 max-w-[14rem]","aria-label":be,children:De}),t[64]=be,t[65]=De,t[66]=oe):oe=t[66];let ee;t[67]!==e?(ee=e("settings.openchamber.tools.browserProvider.option.builtin"),t[67]=e,t[68]=ee):ee=t[68];let ce;t[69]!==ee?(ce=s.jsx(gt,{value:dr,children:ee}),t[69]=ee,t[70]=ce):ce=t[70];let ue;t[71]!==M?(ue=M.map(Aj),t[71]=M,t[72]=ue):ue=t[72];let Ie;t[73]!==ce||t[74]!==ue?(Ie=s.jsxs(Et,{children:[ce,ue]}),t[73]=ce,t[74]=ue,t[75]=Ie):Ie=t[75];let ve;t[76]!==L||t[77]!==D||t[78]!==ke||t[79]!==oe||t[80]!==Ie?(ve=s.jsxs(Dt,{value:D,onValueChange:L,disabled:ke,children:[oe,Ie]}),t[76]=L,t[77]=D,t[78]=ke,t[79]=oe,t[80]=Ie,t[81]=ve):ve=t[81];let Re;t[82]!==pe||t[83]!==fe||t[84]!==ve?(Re=s.jsxs("div",{"data-settings-item":"sessions.browser-provider",className:Q,children:[pe,fe,ve]}),t[82]=pe,t[83]=fe,t[84]=ve,t[85]=Re):Re=t[85];let Me;t[86]!==te||t[87]!==Re?(Me=s.jsxs("div",{children:[te,Re]}),t[86]=te,t[87]=Re,t[88]=Me):Me=t[88];let me;t[89]!==e?(me=e("settings.openchamber.tools.field.agentNotifyTool"),t[89]=e,t[90]=me):me=t[90];let Te;t[91]!==e?(Te=e("settings.openchamber.tools.field.agentNotifyToolSummary"),t[91]=e,t[92]=Te):Te=t[92];let Oe;t[93]!==e?(Oe=e("settings.openchamber.tools.field.agentNotifyToolInfo"),t[93]=e,t[94]=Oe):Oe=t[94];let ge;t[95]!==e?(ge=e("settings.openchamber.tools.field.agentNotifyToolAria"),t[95]=e,t[96]=ge):ge=t[96];let xe;t[97]!==f||t[98]!==N||t[99]!==me||t[100]!==Te||t[101]!==Oe||t[102]!==ge?(xe=s.jsx(Yi,{icon:"notification-3",settingsItem:"sessions.agent-notify-tool",checked:f,onChange:N,title:me,summary:Te,info:Oe,ariaLabel:ge}),t[97]=f,t[98]=N,t[99]=me,t[100]=Te,t[101]=Oe,t[102]=ge,t[103]=xe):xe=t[103];let ne;t[104]!==m||t[105]!==g||t[106]!==j||t[107]!==e?(ne=m?s.jsx(Yi,{icon:"brain",settingsItem:"sessions.agent-memory-tool",checked:g,onChange:j,title:e("settings.openchamber.tools.field.agentMemoryTool"),summary:e("settings.openchamber.tools.field.agentMemoryToolSummary"),info:e("settings.openchamber.tools.field.agentMemoryToolInfo"),ariaLabel:e("settings.openchamber.tools.field.agentMemoryToolAria")}):null,t[104]=m,t[105]=g,t[106]=j,t[107]=e,t[108]=ne):ne=t[108];let ie;t[109]!==ae||t[110]!==Me||t[111]!==xe||t[112]!==ne?(ie=s.jsxs("div",{className:"max-w-[44rem] divide-y divide-[var(--interactive-border)] rounded-xl border border-[var(--interactive-border)] bg-[var(--surface-elevated)]",children:[ae,Me,xe,ne]}),t[109]=ae,t[110]=Me,t[111]=xe,t[112]=ne,t[113]=ie):ie=t[113];let he;t[114]!==e?(he=e("settings.openchamber.tools.field.agentToolsCodeMode"),t[114]=e,t[115]=he):he=t[115];let Ee;t[116]!==e?(Ee=e("settings.openchamber.tools.field.agentToolsCodeModeAria"),t[116]=e,t[117]=Ee):Ee=t[117];let Ke;t[118]!==e?(Ke=e("settings.openchamber.tools.field.agentToolsCodeModeInfo"),t[118]=e,t[119]=Ke):Ke=t[119];let Le;t[120]!==b||t[121]!==A||t[122]!==he||t[123]!==Ee||t[124]!==Ke?(Le=s.jsx(bt,{className:"mt-4",settingsItem:"sessions.agent-tools-code-mode",checked:b,onChange:A,label:he,ariaLabel:Ee,info:Ke}),t[120]=b,t[121]=A,t[122]=he,t[123]=Ee,t[124]=Ke,t[125]=Le):Le=t[125];let Se;return t[126]!==ie||t[127]!==Le||t[128]!==O?(Se=s.jsxs(He,{title:O,children:[ie,Le]}),t[126]=ie,t[127]=Le,t[128]=O,t[129]=Se):Se=t[129],Se};function gj(t){return t.agentControlToolEnabled}function fj(t){return t.setAgentControlToolEnabled}function hj(t){return t.agentWebToolEnabled}function xj(t){return t.setAgentWebToolEnabled}function bj(t){return t.browserProvider}function vj(t){return t.setBrowserProvider}function yj(t){return t.guests}function jj(t){return t.agentMemoryToolEnabled}function kj(t){return t.agentMemoryFeatureAvailable}function wj(t){return t.setAgentMemoryToolEnabled}function Nj(t){return t.agentNotifyToolEnabled}function Sj(t){return t.setAgentNotifyToolEnabled}function Cj(t){return t.agentToolsCodeMode}function Ij(t){return t.setAgentToolsCodeMode}function Pj(){gn()}function Aj(t){return s.jsx(gt,{value:t.id,children:t.name},t.id)}const uu=()=>{const{t}=qe(),e=us()&&wi(),a=e&&typeof window<"u"&&window.__OPENCHAMBER_PLATFORM__==="darwin",[n,i]=at.useState(!1),[o,r]=at.useState(!1),[d,c]=at.useState(!1),[g,m]=at.useState(""),[h,f]=at.useState(!1),[p,b]=at.useState(!1),[C,v]=at.useState(null),[k,u]=at.useState(!0),[y,S]=at.useState(!1),[N,w]=at.useState(!1),[A,x]=at.useState(!1),[T,M]=at.useState(!1),[E,D]=at.useState(!1),[F,L]=at.useState(!1),[P,j]=at.useState(!1),[O,K]=at.useState(!0),[H,q]=at.useState(!0),[Z,ae]=at.useState(!1),[B,G]=at.useState(!1),[_,z]=at.useState(!1),[te,Q]=at.useState(null),[X,pe]=at.useState(null);at.useEffect(()=>{if(!e){u(!1);return}let ge=!1;return(async()=>{try{const xe=await En();if(!xe)throw new Error(t("settings.openchamber.desktopNetwork.error.loadFailed"));if(ge)return;const ne=xe.desktopLanAccessEnabled===!0;i(ne),r(ne),c(xe.hasDesktopUiPassword===!0),m(""),f(!1),b(xe.desktopLanAccessActive===!0),v(xe.desktopLanAccessBlockedReason??null);const ie=xe.desktopMacMenuBarEnabled!==!1;K(ie),q(ie),Q(null)}catch(xe){ge||Q(xe instanceof Error?xe.message:t("settings.openchamber.desktopNetwork.error.loadFailed"))}finally{ge||u(!1)}})(),()=>{ge=!0}},[e,t]),at.useEffect(()=>{if(!e){w(!1);return}let ge=!1;return(async()=>{const xe=await sp();ge||(w(xe?.supported===!0),x(xe?.enabled===!0))})(),()=>{ge=!0}},[e]),at.useEffect(()=>{if(!e){D(!1);return}let ge=!1;return(async()=>{const xe=await np();ge||(D(xe?.supported===!0),L(xe?.enabled===!0))})(),()=>{ge=!0}},[e]),at.useEffect(()=>{if(!e){ae(!1);return}let ge=!1;return(async()=>{const xe=await ap();ge||(ae(xe?.supported===!0),G(xe?.enabled===!0))})(),()=>{ge=!0}},[e]),at.useEffect(()=>{if(!e||!o){pe(null);return}let ge=!1;return(async()=>{const xe=await hd();ge||pe(xe)})(),()=>{ge=!0}},[o,e]);const je=g.trim(),fe=je.length>0||h,ke=o!==n||fe||H!==O,be=at.useMemo(()=>{if(typeof window>"u")return null;const xe=ki()||window.location.href;let ne=0;try{ne=Number(new URL(xe).port)}catch{ne=Number(window.location.port)}return Number.isFinite(ne)&&ne>0?ne:null},[]),De=o&&p&&X&&be?`http://${X}:${be}`:null,oe=je.length>0||d&&!h,ee=o&&!oe,ce=n&&!p&&C==="missing-password",ue=hr(ge=>ge.networkAccessBlocked)||C==="enterprise-mode",Ie=k||y||!ke||ee,ve=at.useCallback(ge=>{m(ge),ge.trim()&&f(!1)},[]),Re=at.useCallback(()=>{m(""),f(!0),r(!1)},[]),Me=at.useCallback(async()=>{if(!N||T)return;const ge=!A;x(ge),M(!0),Q(null);try{const xe=await ip(ge);if(!xe?.supported)throw new Error(t("settings.openchamber.desktopNetwork.error.launchAtLoginUnsupported"));x(xe.enabled)}catch(xe){x(!ge),Q(xe instanceof Error?xe.message:t("settings.openchamber.desktopNetwork.error.launchAtLoginSaveFailed"))}finally{M(!1)}},[T,A,N,t]),me=at.useCallback(async()=>{if(!E||P)return;const ge=!F;L(ge),j(!0),Q(null);try{const xe=await op(ge);if(!xe)throw new Error(t("settings.openchamber.desktopNetwork.error.minimizeToTraySaveFailed"));if(!xe.supported)throw new Error(t("settings.openchamber.desktopNetwork.error.minimizeToTrayUnsupported"));L(xe.enabled)}catch(xe){L(!ge),Q(xe instanceof Error?xe.message:t("settings.openchamber.desktopNetwork.error.minimizeToTraySaveFailed"))}finally{j(!1)}},[P,F,E,t]),Te=at.useCallback(async()=>{if(!Z||_)return;const ge=!B;G(ge),z(!0),Q(null);try{const xe=await rp(ge);if(!xe?.supported)throw new Error(t("settings.openchamber.desktopNetwork.error.keepAwakeUnsupported"));G(xe.enabled)}catch(xe){G(!ge),Q(xe instanceof Error?xe.message:t("settings.openchamber.desktopNetwork.error.keepAwakeSaveFailed"))}finally{z(!1)}},[_,B,Z,t]),Oe=at.useCallback(async()=>{if(ke){S(!0),Q(null);try{if(!(await kt({desktopLanAccessEnabled:o,...je?{desktopUiPassword:je}:h?{desktopUiPassword:""}:{},desktopMacMenuBarEnabled:H})).ok)throw new Error(t("settings.openchamber.desktopNetwork.error.saveFailed"));if(i(o),je?c(!0):h&&c(!1),m(""),f(!1),K(H),!await lp())throw new Error(t("settings.openchamber.desktopNetwork.error.savedRestartFailed"))}catch(ge){Q(ge instanceof Error?ge.message:t("settings.openchamber.desktopNetwork.error.saveFailed")),S(!1)}}},[H,o,ke,je,h,t]);return e?s.jsx(He,{title:t("settings.openchamber.desktopNetwork.title"),children:s.jsxs("div",{className:"space-y-3",children:[N||a||E||Z?s.jsxs("div",{className:ys,children:[N?s.jsx(bt,{settingsItem:"sessions.desktop-launch-at-login",checked:A,onChange:ge=>{ge!==A&&Me()},disabled:T,label:t("settings.openchamber.desktopNetwork.field.launchAtLogin"),info:t("settings.openchamber.desktopNetwork.field.launchAtLoginDescription"),ariaLabel:t("settings.openchamber.desktopNetwork.field.launchAtLoginAria")}):null,a?s.jsx(bt,{settingsItem:"sessions.desktop-mac-menu-bar",checked:H,onChange:q,disabled:k||y,label:t("settings.openchamber.desktopNetwork.field.macMenuBar"),info:t("settings.openchamber.desktopNetwork.field.macMenuBarDescription"),ariaLabel:t("settings.openchamber.desktopNetwork.field.macMenuBarAria")}):null,E?s.jsx(bt,{settingsItem:"sessions.desktop-minimize-to-tray",checked:F,onChange:ge=>{ge!==F&&me()},disabled:P,label:t("settings.openchamber.desktopNetwork.field.minimizeToTray"),info:t("settings.openchamber.desktopNetwork.field.minimizeToTrayDescription"),ariaLabel:t("settings.openchamber.desktopNetwork.field.minimizeToTrayAria")}):null,Z?s.jsx(bt,{settingsItem:"sessions.desktop-keep-awake",checked:B,onChange:ge=>{ge!==B&&Te()},disabled:_,label:t("settings.openchamber.desktopNetwork.field.keepAwake"),info:t("settings.openchamber.desktopNetwork.field.keepAwakeDescription"),ariaLabel:t("settings.openchamber.desktopNetwork.field.keepAwakeAria")}):null]}):null,s.jsxs(Kt,{settingsItem:"sessions.desktop-ui-password",label:s.jsx("label",{htmlFor:"desktop-ui-password",children:t("settings.openchamber.desktopPassword.field.password")}),info:t("settings.openchamber.desktopPassword.field.passwordDescription"),children:[s.jsx(Ge,{id:"desktop-ui-password",type:"password",className:"h-8 min-w-0 flex-1",value:g,onChange:ge=>ve(ge.target.value),placeholder:t(d&&!h?"settings.openchamber.desktopPassword.field.passwordSetPlaceholder":"settings.openchamber.desktopPassword.field.passwordPlaceholder"),disabled:k||y,required:o&&!oe,"aria-invalid":ee}),d&&!h?s.jsx(V,{type:"button",variant:"ghost",size:"xs",onClick:Re,disabled:k||y,className:"shrink-0 !font-normal",children:t("settings.openchamber.desktopPassword.actions.removePassword")}):null]}),s.jsx("div",{className:ys,children:s.jsx(bt,{settingsItem:"sessions.desktop-lan-access",checked:o&&!ue,onChange:r,disabled:k||y||ue,label:t("settings.openchamber.desktopNetwork.field.allowLanAccess"),info:t("settings.openchamber.desktopNetwork.field.allowLanAccessDescription"),description:ue?s.jsx("span",{className:"block",children:t("settings.openchamber.desktopNetwork.field.enterpriseBlocked")}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"block text-[var(--status-warning)]/85",children:t("settings.openchamber.desktopNetwork.field.warning")}),ee||ce?s.jsx("span",{className:"block text-[var(--status-warning)]/85",children:t("settings.openchamber.desktopNetwork.field.passwordRequiredWarning")}):null]}),ariaLabel:t("settings.openchamber.desktopNetwork.field.allowLanAccessAria")})}),te?s.jsx("div",{className:"typography-micro text-[var(--status-error)]",children:te}):null,De&&!ue?s.jsxs("div",{className:"typography-micro text-muted-foreground/80",children:[t(ke&&!n?"settings.openchamber.desktopNetwork.hint.openAfterRestart":"settings.openchamber.desktopNetwork.hint.openNow"),s.jsx("span",{className:"font-mono text-foreground",children:De})]}):null,s.jsx("div",{className:"flex justify-start py-1.5",children:s.jsx(V,{type:"button",size:"xs",onClick:Oe,disabled:Ie,className:"shrink-0 !font-normal",children:t(y?"settings.common.actions.saving":"settings.openchamber.desktopNetwork.actions.saveAndRestart")})})]})}):null},mu=new Set(["shift","control","alt","meta"]),cl=3,Tj=3e3;function dl(t,e=!1){const a=new Set;return t.altKey&&a.add("alt"),t.ctrlKey&&a.add("control"),t.metaKey&&a.add("meta"),t.shiftKey&&a.add("shift"),e&&a.add(t.key.toLowerCase()),a.size}function Ej(t){return t.action.customizable}function Bc(t){if(dl(t)>cl)return null;const e=[];return(t.metaKey||t.ctrlKey)&&e.push("mod"),t.shiftKey&&e.push("shift"),t.altKey&&e.push("alt"),e.length>0?fo(e.join("+")):null}function Dj(t){if(mu.has(t.key.toLowerCase())||dl(t,!0)>cl)return null;const e=Sm(Cm(t));if(!e)return null;const a=[];return(t.metaKey||t.ctrlKey)&&a.push("mod"),t.shiftKey&&a.push("shift"),t.altKey&&a.push("alt"),a.push(e),fo(a.join("+"))}function Mj(t){const e=t.key.toLowerCase();if(!mu.has(e)||dl(t,!0)>cl)return null;const a=[];return(t.metaKey||t.ctrlKey||e==="meta"||e==="control")&&a.push("mod"),(t.shiftKey||e==="shift")&&a.push("shift"),(t.altKey||e==="alt")&&a.push("alt"),a.length>0?fo(a.join("+")):null}function Vc(t){return t.chords.length>0?{...t,livePreview:null,settled:!0}:t}function Rj(t,e,a){if(e.repeat||e.isComposing)return t;if(a==="keyup")return{...t,livePreview:Bc(e)};if(e.key==="Backspace")return{chords:t.chords.slice(0,-1),livePreview:null,settled:!1};const n=Dj(e);if(n){if(t.settled)return{chords:[n],livePreview:null,settled:!1};const i=t.chords.length<2?[...t.chords,n]:t.chords;return{chords:i,livePreview:null,settled:i.length===2}}return{...t,livePreview:Bc(e)}}const Oj=t=>{const e=Be.c(117),{action:a,overrides:n,onSave:i,onOpenChange:o}=t,{t:r}=qe();let d;e[0]!==r?(d=be=>r(be.settingsLabelKey),e[0]=r,e[1]=d):d=e[1];const c=d;let g;e[2]!==c?(g=be=>be.action.customizable?c(be.action):xa(be.action.defaultBinding),e[2]=c,e[3]=g):g=e[3];const m=g;let h;e[4]===Symbol.for("react.memo_cache_sentinel")?(h={chords:[],livePreview:null,settled:!1},e[4]=h):h=e[4];const[f,p]=l.useState(h),b=l.useRef(null);let C,v;e[5]!==a?(C=()=>{a&&(p({chords:[],livePreview:null,settled:!1}),b.current?.focus())},v=[a],e[5]=a,e[6]=C,e[7]=v):(C=e[6],v=e[7]),l.useEffect(C,v);const k=f.chords.length===1&&!f.settled;let u,y;e[8]!==k?(u=()=>{if(!k)return;const be=window.setTimeout(()=>p(Vc),Tj);return()=>window.clearTimeout(be)},y=[k],e[8]=k,e[9]=u,e[10]=y):(u=e[9],y=e[10]),l.useEffect(u,y);let S;e[11]!==f.chords?(S=fo(f.chords.join(" ")),e[11]=f.chords,e[12]=S):S=e[12];const N=S;let w;e[13]!==a||e[14]!==N||e[15]!==n?(w=a&&N?wm(a.id,N,n):[],e[13]=a,e[14]=N,e[15]=n,e[16]=w):w=e[16];const A=w;let x;e[17]!==A?(x=A.find(Lj),e[17]=A,e[18]=x):x=e[18];const T=x;let M,E,D,F,L,P,j,O,K,H,q,Z,ae,B,G;if(e[19]!==a||e[20]!==c||e[21]!==N||e[22]!==m||e[23]!==A||e[24]!==o||e[25]!==i||e[26]!==T||e[27]!==f||e[28]!==r){const be=A.filter(Ej);L=be.find(Fj);const De=be.find(Kj),oe=A.find(zj);let ee;e[44]!==o?(ee=()=>o(!1),e[44]=o,e[45]=ee):ee=e[45],D=ee,F=()=>{f.settled||p(Vc),!(!a||!N||T||L)&&(i(a.id,N,De?.action.id),D())};let ce;e[46]!==a||e[47]!==f?(ce=(he,Ee)=>{he.preventDefault(),he.stopPropagation();const Ke=!!(a&&"prefixStyle"in a&&a.prefixStyle);if(Ee==="keyup"&&Ke&&f.chords.length===0){const Se=Mj(he);if(Se){p({chords:[Se],livePreview:null,settled:!0});return}}const Le=Rj(f,{altKey:he.altKey,code:he.nativeEvent.code,ctrlKey:he.ctrlKey,isComposing:he.nativeEvent.isComposing,key:he.key,metaKey:he.metaKey,repeat:he.repeat,shiftKey:he.shiftKey},Ee);p(Ke&&Le.chords.length>1?f:Le)},e[46]=a,e[47]=f,e[48]=ce):ce=e[48];const ue=ce;E=_t,B=a!==null,G=Uj,M=$t,P="max-w-md",j=b,O=!1;let Ie;e[49]!==a||e[50]!==c||e[51]!==r?(Ie=a?r("settings.openchamber.keyboardShortcuts.dialog.title",{action:c(a)}):"",e[49]=a,e[50]=c,e[51]=r,e[52]=Ie):Ie=e[52];let ve;e[53]!==Ie?(ve=s.jsx(Ht,{children:Ie}),e[53]=Ie,e[54]=ve):ve=e[54];let Re;e[55]!==r?(Re=r("settings.openchamber.keyboardShortcuts.dialog.instructions"),e[55]=r,e[56]=Re):Re=e[56];let Me;e[57]!==Re?(Me=s.jsx(qt,{children:Re}),e[57]=Re,e[58]=Me):Me=e[58],e[59]!==ve||e[60]!==Me?(K=s.jsxs(Vt,{children:[ve,Me]}),e[59]=ve,e[60]=Me,e[61]=K):K=e[61];let me,Te;e[62]!==ue?(me=he=>ue(he,"keydown"),Te=he=>ue(he,"keyup"),e[62]=ue,e[63]=me,e[64]=Te):(me=e[63],Te=e[64]);let Oe;e[65]===Symbol.for("react.memo_cache_sentinel")?(Oe=()=>p(_j),e[65]=Oe):Oe=e[65];let ge;e[66]!==f.chords?(ge=f.chords.map($j),e[66]=f.chords,e[67]=ge):ge=e[67];let xe;e[68]!==f.livePreview?(xe=f.livePreview?s.jsx("kbd",{className:"rounded-md border border-dashed border-border bg-muted px-3 py-2 typography-ui-label font-mono text-muted-foreground",children:xa(f.livePreview)}):null,e[68]=f.livePreview,e[69]=xe):xe=e[69];let ne;e[70]!==f.chords.length||e[71]!==f.livePreview||e[72]!==r?(ne=f.chords.length===0&&!f.livePreview?s.jsx("span",{className:"typography-ui-label text-muted-foreground",children:r("settings.openchamber.keyboardShortcuts.dialog.recording")}):null,e[70]=f.chords.length,e[71]=f.livePreview,e[72]=r,e[73]=ne):ne=e[73];let ie;e[74]!==ge||e[75]!==xe||e[76]!==ne?(ie=s.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-2",children:[ge,xe,ne]}),e[74]=ge,e[75]=xe,e[76]=ne,e[77]=ie):ie=e[77],e[78]!==me||e[79]!==Te||e[80]!==ie?(H=s.jsx("div",{className:"flex min-h-28 items-center justify-center rounded-lg border border-border bg-[var(--surface-elevated)] px-4 py-5 text-center outline-none focus-visible:ring-2 focus-visible:ring-ring",tabIndex:0,ref:b,onKeyDown:me,onKeyUp:Te,onBlur:Oe,children:ie}),e[78]=me,e[79]=Te,e[80]=ie,e[81]=H):H=e[81],q=f.settled&&T?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:r("settings.openchamber.keyboardShortcuts.error.internalConflict")}):f.settled&&L?s.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:r("settings.openchamber.keyboardShortcuts.error.prefixConflict",{action:c(L.action)})}):null,Z=f.settled&&De&&!T&&!L?s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:r("settings.openchamber.keyboardShortcuts.error.exactConflict",{action:c(De.action)})}):null,ae=f.settled&&oe&&!T&&!L?s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:r("settings.openchamber.keyboardShortcuts.warning.contextualPrefix",{action:m(oe)})}):null,e[19]=a,e[20]=c,e[21]=N,e[22]=m,e[23]=A,e[24]=o,e[25]=i,e[26]=T,e[27]=f,e[28]=r,e[29]=M,e[30]=E,e[31]=D,e[32]=F,e[33]=L,e[34]=P,e[35]=j,e[36]=O,e[37]=K,e[38]=H,e[39]=q,e[40]=Z,e[41]=ae,e[42]=B,e[43]=G}else M=e[29],E=e[30],D=e[31],F=e[32],L=e[33],P=e[34],j=e[35],O=e[36],K=e[37],H=e[38],q=e[39],Z=e[40],ae=e[41],B=e[42],G=e[43];let _;e[82]!==N||e[83]!==f.settled||e[84]!==r?(_=f.settled&&N&&Nm(N)?s.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:r("settings.openchamber.keyboardShortcuts.warning.riskyBrowserShortcut")}):null,e[82]=N,e[83]=f.settled,e[84]=r,e[85]=_):_=e[85];let z;e[86]!==r?(z=r("settings.common.actions.cancel"),e[86]=r,e[87]=z):z=e[87];let te;e[88]!==D||e[89]!==z?(te=s.jsx(V,{type:"button",variant:"ghost",size:"sm",onClick:D,children:z}),e[88]=D,e[89]=z,e[90]=te):te=e[90];const Q=!N||f.settled&&(!!T||!!L);let X;e[91]!==r?(X=r("settings.openchamber.keyboardShortcuts.actions.confirm"),e[91]=r,e[92]=X):X=e[92];let pe;e[93]!==F||e[94]!==Q||e[95]!==X?(pe=s.jsx(V,{type:"button",size:"sm",disabled:Q,onClick:F,children:X}),e[93]=F,e[94]=Q,e[95]=X,e[96]=pe):pe=e[96];let je;e[97]!==te||e[98]!==pe?(je=s.jsxs(as,{children:[te,pe]}),e[97]=te,e[98]=pe,e[99]=je):je=e[99];let fe;e[100]!==M||e[101]!==P||e[102]!==j||e[103]!==O||e[104]!==K||e[105]!==H||e[106]!==q||e[107]!==Z||e[108]!==ae||e[109]!==_||e[110]!==je?(fe=s.jsxs(M,{className:P,initialFocus:j,showCloseButton:O,children:[K,H,q,Z,ae,_,je]}),e[100]=M,e[101]=P,e[102]=j,e[103]=O,e[104]=K,e[105]=H,e[106]=q,e[107]=Z,e[108]=ae,e[109]=_,e[110]=je,e[111]=fe):fe=e[111];let ke;return e[112]!==E||e[113]!==B||e[114]!==G||e[115]!==fe?(ke=s.jsx(E,{open:B,onOpenChange:G,children:fe}),e[112]=E,e[113]=B,e[114]=G,e[115]=fe,e[116]=ke):ke=e[116],ke};function Lj(t){return!t.action.customizable&&t.kind!=="contextual-prefix"}function Fj(t){return t.kind==="prefix"}function Kj(t){return t.kind==="exact"}function zj(t){return t.kind==="contextual-prefix"}function Uj(t,e){t||e.cancel()}function _j(t){return{...t,livePreview:null}}function $j(t,e){return s.jsx("kbd",{className:"rounded-md border border-border bg-muted px-3 py-2 typography-ui-label font-mono text-foreground",children:xa(t)},`${t}-${e}`)}const Bj=["session","models","panels","navigation","application"],Vj=()=>{const t=Be.c(24),{t:e}=qe(),a=re(Hj),n=re(qj),i=re(Gj),o=re(Wj),[r,d]=l.useState(null);let c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c=Im(),t[0]=c):c=t[0];const g=c,m=Jj;let h;t[1]!==n||t[2]!==a?(h=(N,w,A)=>{const x={...a,[N]:w};A&&(x[A]=$o),n(N,w),A&&n(A,$o),m(x)},t[1]=n,t[2]=a,t[3]=h):h=t[3];const f=h;let p;t[4]!==i||t[5]!==a?(p=N=>{const w={...a};delete w[N],i(N),m(w)},t[4]=i,t[5]=a,t[6]=p):p=t[6];const b=p;let C;t[7]!==a||t[8]!==e?(C=N=>{const w="prefixStyle"in N&&N.prefixStyle,A=w?Pm(N.id,a):fd(N.id,a),x=xa(A,e("settings.openchamber.keyboardShortcuts.unassigned"));if(!w||!A||A===$o)return x;const T=N.id==="switch_session_tab"?e("settings.openchamber.keyboardShortcuts.action.switch_session_tab.suffix"):e("settings.openchamber.keyboardShortcuts.action.switch_context_surface.suffix");return`${x}${T}`},t[7]=a,t[8]=e,t[9]=C):C=t[9];const v=C;let k;t[10]!==o||t[11]!==b||t[12]!==v||t[13]!==a||t[14]!==e?(k=Bj.map((N,w)=>{const A=g.filter(x=>x.category===N);return A.length===0?null:s.jsx(He,{settingsItem:w===0?"shortcuts.keyboard-shortcuts":void 0,title:e(`settings.openchamber.keyboardShortcuts.category.${N}`),divider:w!==0,info:w===0?e("settings.openchamber.keyboardShortcuts.tooltip"):void 0,headerAction:w===0?s.jsx(V,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{o(),m({})},children:e("settings.openchamber.keyboardShortcuts.actions.resetAll")}):void 0,children:s.jsx("div",{className:"space-y-2",children:A.map(x=>s.jsxs(Ct,{label:e(x.settingsLabelKey),children:[s.jsx("kbd",{className:"min-w-32 rounded-md border border-border bg-muted px-2 py-1 text-center typography-meta font-mono text-foreground",children:v(x)}),s.jsx(V,{type:"button",variant:"secondary",size:"xs",className:"!font-normal",onClick:()=>d(x),children:e("settings.openchamber.keyboardShortcuts.actions.edit")}),x.id in a?s.jsx(V,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>b(x.id),children:e("settings.common.actions.reset")}):null]},x.id))})},N)}),t[10]=o,t[11]=b,t[12]=v,t[13]=a,t[14]=e,t[15]=k):k=t[15];let u;t[16]===Symbol.for("react.memo_cache_sentinel")?(u=N=>{N||d(null)},t[16]=u):u=t[16];let y;t[17]!==r||t[18]!==f||t[19]!==a?(y=s.jsx(Oj,{action:r,overrides:a,onSave:f,onOpenChange:u}),t[17]=r,t[18]=f,t[19]=a,t[20]=y):y=t[20];let S;return t[21]!==k||t[22]!==y?(S=s.jsxs(s.Fragment,{children:[k,y]}),t[21]=k,t[22]=y,t[23]=S):S=t[23],S};function Hj(t){return t.shortcutOverrides}function qj(t){return t.setShortcutOverride}function Gj(t){return t.clearShortcutOverride}function Wj(t){return t.resetAllShortcutOverrides}function Jj(t){kt({shortcutOverrides:t})}const pu=()=>{const t=Be.c(2),[e,a]=l.useState(0);let n,i;return t[0]===Symbol.for("react.memo_cache_sentinel")?(n=()=>ho(()=>a(ok)),i=[],t[0]=n,t[1]=i):(n=t[0],i=t[1]),l.useEffect(n,i),e},Qj=t=>{const e=Be.c(85),{section:a}=t,{t:n}=qe(),{isMobile:i}=qn(),o=pu();let r;e[0]!==i?(r=i&&fa(),e[0]=i,e[1]=r):r=e[1];const d=r;let c;e[2]===Symbol.for("react.memo_cache_sentinel")?(c=ps(),e[2]=c):c=e[2];const g=c;let m;e[3]===Symbol.for("react.memo_cache_sentinel")?(m=us()&&wi(),e[3]=m):m=e[3];const h=m;if(!a){let ae;e[4]===Symbol.for("react.memo_cache_sentinel")?(ae=s.jsx(bo,{}),e[4]=ae):ae=e[4];let B;e[5]!==o?(B=s.jsx(ou,{},o),e[5]=o,e[6]=B):B=e[6];let G,_,z,te,Q,X,pe,je;e[7]===Symbol.for("react.memo_cache_sentinel")?(Q=s.jsx(nu,{}),X=h&&s.jsx(uu,{}),pe=!g&&s.jsx(cu,{}),je=!g&&s.jsx(du,{}),G=!g&&po,_=s.jsx(su,{}),z=s.jsx(iu,{}),te=fa()&&!us()&&!g&&!Br()&&s.jsx(au,{}),e[7]=G,e[8]=_,e[9]=z,e[10]=te,e[11]=Q,e[12]=X,e[13]=pe,e[14]=je):(G=e[7],_=e[8],z=e[9],te=e[10],Q=e[11],X=e[12],pe=e[13],je=e[14]);let fe;e[15]!==d?(fe=d&&s.jsx(kd,{}),e[15]=d,e[16]=fe):fe=e[16];let ke;return e[17]!==fe||e[18]!==B?(ke=s.jsxs(ns,{showSaveStatus:!0,className:"openchamber-page-body space-y-3 sm:space-y-6",children:[ae,B,Q,X,pe,je,G,_,z,te,fe]}),e[17]=fe,e[18]=B,e[19]=ke):ke=e[19],ke}let f;e[20]!==o||e[21]!==a?(f=()=>{switch(a){case"general":return s.jsx(Zj,{});case"visual":return s.jsx(Xj,{});case"chat":return s.jsx(ek,{});case"sessions":return s.jsx(tk,{runtimeEndpointEpoch:o});case"shortcuts":return s.jsx(Yj,{});case"git":return s.jsx(sk,{});case"notifications":return s.jsx(nk,{});case"voice":return s.jsx(ak,{});case"tunnel":return s.jsx(ik,{});default:return null}},e[20]=o,e[21]=a,e[22]=f):f=e[22];const p=f;let b;e[23]!==n?(b=n("settings.page.general.title"),e[23]=n,e[24]=b):b=e[24];let C;e[25]!==n?(C=n("settings.page.appearance.title"),e[25]=n,e[26]=C):C=e[26];let v;e[27]!==n?(v=n("settings.page.chat.title"),e[27]=n,e[28]=v):v=e[28];let k;e[29]!==n?(k=n("settings.page.sessions.title"),e[29]=n,e[30]=k):k=e[30];let u;e[31]!==n?(u=n("settings.page.shortcuts.title"),e[31]=n,e[32]=u):u=e[32];let y;e[33]!==n?(y=n("settings.page.git.title"),e[33]=n,e[34]=y):y=e[34];let S;e[35]!==n?(S=n("settings.page.git.title"),e[35]=n,e[36]=S):S=e[36];let N;e[37]!==n?(N=n("settings.page.notifications.title"),e[37]=n,e[38]=N):N=e[38];let w;e[39]!==n?(w=n("settings.page.voice.title"),e[39]=n,e[40]=w):w=e[40];let A;e[41]!==n?(A=n("settings.page.tunnel.title"),e[41]=n,e[42]=A):A=e[42];let x;e[43]!==y||e[44]!==S||e[45]!==N||e[46]!==w||e[47]!==A||e[48]!==b||e[49]!==C||e[50]!==v||e[51]!==k||e[52]!==u?(x={general:b,visual:C,chat:v,sessions:k,shortcuts:u,git:y,github:S,notifications:N,voice:w,tunnel:A},e[43]=y,e[44]=S,e[45]=N,e[46]=w,e[47]=A,e[48]=b,e[49]=C,e[50]=v,e[51]=k,e[52]=u,e[53]=x):x=e[53];const T=x[a];let M;e[54]!==n?(M=n("settings.page.general.description"),e[54]=n,e[55]=M):M=e[55];let E;e[56]!==n?(E=n("settings.page.appearance.description"),e[56]=n,e[57]=E):E=e[57];let D;e[58]!==n?(D=n("settings.page.chat.description"),e[58]=n,e[59]=D):D=e[59];let F;e[60]!==n?(F=n("settings.page.sessions.description"),e[60]=n,e[61]=F):F=e[61];let L;e[62]!==n?(L=n("settings.page.shortcuts.description"),e[62]=n,e[63]=L):L=e[63];let P;e[64]!==n?(P=n("settings.page.notifications.description"),e[64]=n,e[65]=P):P=e[65];let j;e[66]!==n?(j=n("settings.page.voice.description"),e[66]=n,e[67]=j):j=e[67];let O;e[68]!==n?(O=n("settings.page.tunnel.description"),e[68]=n,e[69]=O):O=e[69];let K;e[70]!==M||e[71]!==E||e[72]!==D||e[73]!==F||e[74]!==L||e[75]!==P||e[76]!==j||e[77]!==O?(K={general:M,visual:E,chat:D,sessions:F,shortcuts:L,git:void 0,github:void 0,notifications:P,voice:j,tunnel:O},e[70]=M,e[71]=E,e[72]=D,e[73]=F,e[74]=L,e[75]=P,e[76]=j,e[77]=O,e[78]=K):K=e[78];const H=K[a];let q;e[79]!==p?(q=p(),e[79]=p,e[80]=q):q=e[80];let Z;return e[81]!==H||e[82]!==T||e[83]!==q?(Z=s.jsx(ns,{title:T,description:H,showSaveStatus:!0,className:"openchamber-page-body",children:q}),e[81]=H,e[82]=T,e[83]=q,e[84]=Z):Z=e[84],Z},Yj=()=>{const t=Be.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(Vj,{}),t[0]=e):e=t[0],e},Zj=()=>{const t=Be.c(11);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=ps(),t[0]=e):e=t[0];const a=e;pu();let n;t[1]===Symbol.for("react.memo_cache_sentinel")?(n=us()&&wi(),t[1]=n):n=t[1];const i=n;let o;t[2]===Symbol.for("react.memo_cache_sentinel")?(o=fa()&&!us()&&!a&&!Br(),t[2]=o):o=t[2];const r=o;let d,c,g,m,h,f;t[3]===Symbol.for("react.memo_cache_sentinel")?(d=i&&s.jsx(uu,{}),c=r&&s.jsx(au,{}),g=s.jsx(iu,{}),m=!a&&s.jsx(cu,{}),h=!a&&s.jsx(du,{}),f=!a&&po,t[3]=d,t[4]=c,t[5]=g,t[6]=m,t[7]=h,t[8]=f):(d=t[3],c=t[4],g=t[5],m=t[6],h=t[7],f=t[8]);let p;t[9]===Symbol.for("react.memo_cache_sentinel")?(p=a?[]:["sessionTabs"],t[9]=p):p=t[9];let b;return t[10]===Symbol.for("react.memo_cache_sentinel")?(b=s.jsxs(s.Fragment,{children:[d,c,g,m,h,f,s.jsx(bo,{visibleSettings:["fileEditorKeymap",...p,"autoSaveEnabled",...a?[]:["terminalQuickKeys"],...a?[]:["terminalShell"],...a?[]:["terminalLoginShell"],"messageTransport","reportUsage"]})]}),t[10]=b):b=t[10],b},Xj=()=>{const t=Be.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=ps(),t[0]=e):e=t[0];const a=e;let n;return t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx(bo,{visibleSettings:["theme","windowControlsPosition","pwaInstallName","pwaOrientation","mobileKeyboardMode","timeFormat",...a?[]:["weekStart"],"fontSize","terminalFontSize","editorFontSize","spacing","scrollbars","inputBarOffset","animatedActivityIndicators"]}),t[1]=n):n=t[1],n},ek=()=>{const t=Be.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(bo,{visibleSettings:["sessionGoal","sessionAssist","chatRenderMode","activityRenderMode","userMessageRendering","mermaidRendering","reasoning","showToolFileIcons","showTurnChangedFiles","expandedTools","collapsibleUserMessages","stickyUserHeader","promptNavigatorEnabled","wideChatLayout","codeBlockLineWrap","splitAssistantMessageActions","subagentReadOnlyBanner","diffLayout","inputHistoryScope","inputHistoryLimit","dotfiles","fileViewerPreview","followUpBehavior","persistDraft","inputSpellcheck","largeTextPaste","enterToSend"]}),t[0]=e):e=t[0],e},tk=t=>{const e=Be.c(6),{runtimeEndpointEpoch:a}=t;let n;e[0]!==a?(n=s.jsx(ou,{},a),e[0]=a,e[1]=n):n=e[1];let i,o;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=s.jsx(nu,{}),o=s.jsx(su,{}),e[2]=i,e[3]=o):(i=e[2],o=e[3]);let r;return e[4]!==n?(r=s.jsxs(s.Fragment,{children:[n,i,o]}),e[4]=n,e[5]=r):r=e[5],r},sk=()=>{const t=Be.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx($d,{}),t[0]=e):e=t[0],e},nk=()=>{const t=Be.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(V1,{}),t[0]=e):e=t[0],e},ak=()=>{const t=Be.c(1);if(ps())return null;let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(ej,{}),t[0]=e):e=t[0],e},ik=()=>{const t=Be.c(1);if(ps())return null;let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(uj,{}),t[0]=e):e=t[0],e};function ok(t){return t+1}const rk=[{id:"chat.activity-default",page:"chat",titleKey:"settings.openchamber.visual.section.activityDefault",keywords:["activity","collapsed","expanded","live","tools","history"]},{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.openchamber.visual.field.timeFormat",keywords:["clock","12h","24h"]},{id:"appearance.week-start",page:"appearance",titleKey:"settings.openchamber.visual.field.weekStartsOn",keywords:["calendar","monday","sunday"]},{id:"appearance.light-theme",page:"appearance",titleKey:"settings.openchamber.visual.field.lightTheme",keywords:["theme","color","light mode"],isAvailable:t=>!t.isVSCode},{id:"appearance.dark-theme",page:"appearance",titleKey:"settings.openchamber.visual.field.darkTheme",keywords:["theme","color","dark mode"],isAvailable:t=>!t.isVSCode},{id:"appearance.import-theme",page:"appearance",titleKey:"settings.themeImport.action",descriptionKey:"settings.themeImport.catalogHint",keywords:["theme","import","vscode","open vsx","openvsx","json","jsonc","syntax","palette"],isAvailable:t=>!t.isVSCode},{id:"appearance.dock-badge",page:"appearance",titleKey:"settings.openchamber.visual.field.dockBadge",descriptionKey:"settings.openchamber.visual.field.dockBadgeHint",keywords:["dock","badge","unread","unseen","counter","count","notification","macos"],isAvailable:t=>t.isMac},{id:"appearance.scrollbars",page:"appearance",titleKey:"settings.openchamber.visual.field.alwaysShowScrollbars",descriptionKey:"settings.openchamber.visual.field.alwaysShowScrollbarsHint",keywords:["scrollbar","scrollbars","scroll","mouse","wheel","accessibility","always visible"]},{id:"appearance.pwa-install-name",page:"appearance",titleKey:"settings.openchamber.visual.field.installAppName",descriptionKey:"settings.openchamber.visual.field.installAppNameHint",keywords:["pwa","installed app"],isAvailable:t=>t.isWeb&&!t.isDesktop&&!t.isVSCode},{id:"appearance.pwa-orientation",page:"appearance",titleKey:"settings.openchamber.visual.field.installOrientation",descriptionKey:"settings.openchamber.visual.field.installOrientationHint",keywords:["pwa","portrait","landscape"],isAvailable:t=>t.isWeb&&!t.isDesktop&&!t.isVSCode},{id:"appearance.mobile-keyboard-mode",page:"appearance",titleKey:"settings.openchamber.visual.field.mobileKeyboardMode",descriptionKey:"settings.openchamber.visual.field.mobileKeyboardModeHint",keywords:["mobile","keyboard","resize"],isAvailable:t=>t.isMobile&&t.isWeb&&!t.isDesktop&&!t.isVSCode},{id:"appearance.animated-activity-indicators",page:"appearance",titleKey:"settings.openchamber.visual.field.animatedActivityIndicators",descriptionKey:"settings.openchamber.visual.field.animatedActivityIndicatorsInfo",keywords:["spinner","animation","session","activity","motion","running","indicator"]},{id:"appearance.interface-font-size",page:"appearance",titleKey:"settings.openchamber.visual.field.interfaceFontSize",keywords:["font","text size","ui scale"],isAvailable:t=>!t.isMobile},{id:"appearance.terminal-font-size",page:"appearance",titleKey:"settings.openchamber.visual.field.terminalFontSize",keywords:["terminal","font","text size"]},{id:"appearance.terminal-shell",page:"general",titleKey:"settings.openchamber.visual.field.terminalShell",descriptionKey:"settings.openchamber.visual.field.terminalShellHint",keywords:["terminal","shell","bash","zsh","fish","pwsh","powershell"],isAvailable:t=>!t.isVSCode},{id:"appearance.editor-font-size",page:"appearance",titleKey:"settings.openchamber.visual.field.editorFontSize",keywords:["editor","font","text size","code"]},{id:"appearance.spacing-density",page:"appearance",titleKey:"settings.openchamber.visual.field.spacingDensity",keywords:["density","compact","comfortable","spacing"]},{id:"appearance.input-bar-offset",page:"appearance",titleKey:"settings.openchamber.visual.field.inputBarOffset",descriptionKey:"settings.openchamber.visual.field.inputBarOffsetTooltip",keywords:["input","home bar","offset"],isAvailable:t=>t.isMobile},{id:"appearance.auto-save-enabled",page:"general",titleKey:"settings.openchamber.visual.field.autoSaveEnabled",descriptionKey:"settings.openchamber.visual.field.autoSaveEnabledInfo",keywords:["editor","autosave","auto-save","files","save"]},{id:"appearance.file-editor-keymap",page:"general",titleKey:"settings.openchamber.visual.field.fileEditorKeymap",keywords:["editor","vim","keymap"]},{id:"appearance.session-tabs",page:"general",titleKey:"settings.openchamber.visual.field.sessionTabsGroup",descriptionKey:"settings.openchamber.visual.field.sessionTabsInfo",keywords:["session","tabs","header","working set"],isAvailable:t=>!t.isMobile&&!t.isVSCode},{id:"appearance.terminal-quick-keys",page:"general",titleKey:"settings.openchamber.visual.field.terminalQuickKeys",descriptionKey:"settings.openchamber.visual.field.terminalQuickKeysTooltip",keywords:["terminal","keyboard","esc","ctrl","arrows"],isAvailable:t=>!t.isMobile&&!t.isVSCode},{id:"appearance.usage-reports",page:"general",titleKey:"settings.openchamber.visual.field.sendAnonymousUsageReports",descriptionKey:"settings.openchamber.visual.field.sendAnonymousUsageReportsHint",keywords:["telemetry","analytics"]},{id:"general.app-links",page:"general",titleKey:"settings.openchamber.appLinks.title",descriptionKey:"settings.openchamber.appLinks.info",keywords:["security","app link","deep link","scheme","protocol","obsidian","notion"]},{id:"chat.render-mode",page:"chat",titleKey:"settings.openchamber.visual.section.chatRenderMode",keywords:["messages","conversation","rendering"]},{id:"chat.message-transport",page:"general",titleKey:"settings.openchamber.visual.section.messageStreamTransport",keywords:["streaming","sse","websocket"]},{id:"chat.session-recap",page:"chat",titleKey:"settings.openchamber.visual.field.sessionRecap",keywords:["recap","assist","small model","summary"]},{id:"chat.session-assistance",page:"chat",titleKey:"settings.openchamber.visual.section.sessionAssistance",keywords:["recap","suggestion","subagent"]},{id:"chat.session-suggestion",page:"chat",titleKey:"settings.openchamber.visual.field.sessionSuggestion",keywords:["suggestion","assist","small model","follow up"]},{id:"chat.session-goal",page:"chat",titleKey:"settings.openchamber.visual.field.sessionGoal",keywords:["goal","objective","auto continue"],isAvailable:t=>!t.isVSCode},{id:"chat.session-goal-checker",page:"chat",titleKey:"settings.openchamber.visual.goal.checkerLabel",keywords:["goal","progress","check","jev","classification","small model"],isAvailable:t=>!t.isVSCode},{id:"chat.session-goal-budget",page:"chat",titleKey:"settings.openchamber.visual.goal.budgetLabel",keywords:["goal","budget","tokens","limit"],isAvailable:t=>!t.isVSCode},{id:"chat.reasoning-traces",page:"chat",titleKey:"settings.openchamber.visual.field.showReasoningTraces",keywords:["thinking","reasoning"]},{id:"chat.reasoning",page:"chat",titleKey:"settings.openchamber.visual.section.reasoning",keywords:["thinking","traces"]},{id:"chat.streaming",page:"chat",titleKey:"settings.openchamber.visual.section.streaming",keywords:["stream","scroll"]},{id:"chat.streaming-auto-follow",page:"chat",titleKey:"settings.openchamber.visual.field.streamingAutoFollow",descriptionKey:"settings.openchamber.visual.field.streamingAutoFollowInfo",keywords:["autoscroll","auto-scroll","follow","stick to bottom","streaming"]},{id:"chat.sticky-user-header",page:"chat",titleKey:"settings.openchamber.visual.field.stickyUserHeader",keywords:["messages","header"]},{id:"chat.prompt-navigator",page:"chat",titleKey:"settings.openchamber.visual.field.promptNavigatorEnabled",keywords:["prompt","navigator","navigation","timeline","scroll"]},{id:"chat.collapsible-user-messages",page:"chat",titleKey:"settings.openchamber.visual.field.collapsibleUserMessages",keywords:["collapse","expand","clamp","long messages","user messages"]},{id:"chat.wide-layout",page:"chat",titleKey:"settings.openchamber.visual.field.wideChatLayout",keywords:["layout","wide","messages"]},{id:"chat.message-appearance",page:"chat",titleKey:"settings.openchamber.visual.section.messageAppearance",keywords:["layout","messages","appearance"]},{id:"chat.code-block-line-wrap",page:"chat",titleKey:"settings.openchamber.visual.field.codeBlockLineWrap",keywords:["code","wrap","line wrap","markdown"]},{id:"chat.inline-assistant-actions",page:"chat",titleKey:"settings.openchamber.visual.field.showSplitAssistantMessageActions",descriptionKey:"settings.openchamber.visual.field.showSplitAssistantMessageActionsTooltip",keywords:["copy","save image","read aloud"]},{id:"chat.draft-starters-visible",page:"chat",titleKey:"settings.openchamber.visual.field.draftStartersVisible",keywords:["starter","starters","new session","welcome","suggestions"]},{id:"chat.subagent-read-only-banner",page:"chat",titleKey:"settings.openchamber.visual.field.allowPromptingSubagentSessions",keywords:["subagent","read only","prompt","banner"]},{id:"chat.tool-file-icons",page:"chat",titleKey:"settings.openchamber.visual.field.showToolFileIcons",keywords:["tools","files","icons"]},{id:"chat.tools-and-files",page:"chat",titleKey:"settings.openchamber.visual.section.toolsAndFiles",keywords:["tools","files","dotfiles"]},{id:"chat.changed-files",page:"chat",titleKey:"settings.openchamber.visual.field.showTurnChangedFiles",keywords:["changed files","turns"]},{id:"chat.dotfiles",page:"chat",titleKey:"settings.openchamber.visual.field.showDotfiles",keywords:["hidden files"],isAvailable:t=>!t.isVSCode},{id:"chat.follow-up-behavior",page:"chat",titleKey:"settings.openchamber.visual.section.followUpBehavior",descriptionKey:"settings.openchamber.visual.field.followUpBehaviorDescription",keywords:["follow up","queue","steer","send immediately"]},{id:"chat.input-history-scope",page:"chat",titleKey:"settings.openchamber.visual.field.inputHistoryScope",descriptionKey:"settings.openchamber.visual.field.inputHistoryScopeDescription",keywords:["input history","composer history","global","session","reuse"]},{id:"chat.input-history-limit",page:"chat",titleKey:"settings.openchamber.visual.field.inputHistoryLimit",descriptionKey:"settings.openchamber.visual.field.inputHistoryLimitDescription",keywords:["history limit","prompt recall","remember prompts","composer history","submitted prompts","trim history"]},{id:"chat.persist-drafts",page:"chat",titleKey:"settings.openchamber.visual.field.persistDraftMessages",keywords:["draft","message"]},{id:"chat.composer",page:"chat",titleKey:"settings.openchamber.visual.section.composer",keywords:["input","draft","spellcheck","paste"]},{id:"chat.spellcheck",page:"chat",titleKey:"settings.openchamber.visual.field.enableSpellcheckInTextInputs",keywords:["spelling","input"],isAvailable:t=>!t.isMobile},{id:"chat.large-text-paste",page:"chat",titleKey:"settings.openchamber.visual.field.largeTextPaste",descriptionKey:"settings.openchamber.visual.field.largeTextPasteHint",keywords:["paste","clipboard","attachment","large","text","file"]},{id:"chat.enter-to-send",page:"chat",titleKey:"settings.openchamber.visual.field.enterToSend",descriptionKey:"settings.openchamber.visual.field.enterToSendHint",keywords:["enter","shift enter","ctrl enter","cmd enter","mod enter","send","newline"],isAvailable:t=>!t.isMobile},{id:"sessions.default-model",page:"sessions",titleKey:"settings.openchamber.defaults.field.defaultModel",keywords:["model","provider","new sessions"]},{id:"sessions.default-thinking",page:"sessions",titleKey:"settings.openchamber.defaults.field.defaultThinking",keywords:["thinking","reasoning","variant"]},{id:"sessions.default-agent",page:"sessions",titleKey:"settings.openchamber.defaults.field.defaultAgent",keywords:["agent","new sessions"]},{id:"sessions.deletion-dialog",page:"sessions",titleKey:"settings.openchamber.defaults.field.showDeletionDialog",keywords:["delete","confirmation"]},{id:"sessions.warming",page:"sessions",titleKey:"settings.openchamber.defaults.field.sessionWarming",descriptionKey:"settings.openchamber.defaults.field.sessionWarmingInfo",keywords:["warming","warm","cache","prompt cache","keep-alive","idle"]},{id:"sessions.permission-default",page:"sessions",titleKey:"settings.sessions.permissions.defaultMode",descriptionKey:"settings.sessions.permissions.defaultModeInfo",keywords:["permissions","auto-accept","accept","safety net","ask","shield","approval","new session"],isAvailable:t=>!t.isVSCode},{id:"sessions.work",page:"sessions",titleKey:"settings.openchamber.sessionWork.title",descriptionKey:"settings.openchamber.sessionWork.info",keywords:["in work","in progress","track","done","inbox","sidebar","jev"]},{id:"sessions.work-enabled",page:"sessions",titleKey:"settings.openchamber.sessionWork.field.enabled",keywords:["in work","in progress","track","done","sidebar"]},{id:"sessions.work-auto-open",page:"sessions",titleKey:"settings.openchamber.sessionWork.field.autoOpen",descriptionKey:"settings.openchamber.sessionWork.field.autoOpenInfo",keywords:["in work","automatic","jev","classification","track"],isAvailable:t=>!t.isVSCode},{id:"sessions.small-model",page:"sessions",titleKey:"settings.openchamber.defaults.smallModel.title",descriptionKey:"settings.openchamber.defaults.smallModel.description",keywords:["small model","utility","summary","recap","cheap","override"]},{id:"sessions.walkthrough-model",page:"sessions",titleKey:"settings.openchamber.defaults.walkthroughModel.title",descriptionKey:"settings.openchamber.defaults.walkthroughModel.description",keywords:["walkthrough","diff","review","changes","structured output","model","override"]},{id:"sessions.auto-cleanup",page:"sessions",titleKey:"settings.openchamber.sessionRetention.field.enableAutoCleanup",descriptionKey:"settings.openchamber.sessionRetention.tooltip",keywords:["retention","archive","delete"]},{id:"sessions.retention-only-archived",page:"sessions",titleKey:"settings.openchamber.sessionRetention.field.onlyArchived",descriptionKey:"settings.openchamber.sessionRetention.field.onlyArchivedDescription",keywords:["archive","archived","only","delete","cleanup","retention"]},{id:"sessions.retention-period",page:"sessions",titleKey:"settings.openchamber.sessionRetention.field.retentionPeriod",keywords:["days","cleanup","retention"]},{id:"sessions.retention-action",page:"sessions",titleKey:"settings.openchamber.sessionRetention.field.whenSessionsExpire",keywords:["archive","delete","expire"]},{id:"sessions.desktop-launch-at-login",page:"general",titleKey:"settings.openchamber.desktopNetwork.field.launchAtLogin",descriptionKey:"settings.openchamber.desktopNetwork.field.launchAtLoginDescription",keywords:["desktop","startup","login","launch","background","autostart"],isAvailable:t=>t.isDesktopLocalOrigin},{id:"sessions.desktop-window-controls-position",page:"appearance",titleKey:"settings.openchamber.desktopNetwork.field.windowControlsPosition",descriptionKey:"settings.openchamber.desktopNetwork.field.windowControlsPositionDescription",keywords:["desktop","window","controls","minimize","maximize","close","titlebar","linux","windows"],isAvailable:t=>t.isDesktop&&(t.isWindows||!t.isMac)},{id:"sessions.desktop-window-controls-style",page:"appearance",titleKey:"settings.openchamber.desktopNetwork.field.windowControlsStyle",keywords:["desktop","window","controls","style","traffic","lights","classic","macos","titlebar"],isAvailable:t=>t.isDesktop&&(t.isWindows||!t.isMac)},{id:"sessions.desktop-mac-menu-bar",page:"general",titleKey:"settings.openchamber.desktopNetwork.field.macMenuBar",descriptionKey:"settings.openchamber.desktopNetwork.field.macMenuBarDescription",keywords:["desktop","menu bar","tray","status item","macos","background"],isAvailable:t=>t.isDesktopLocalOrigin&&t.isMac},{id:"sessions.desktop-minimize-to-tray",page:"general",titleKey:"settings.openchamber.desktopNetwork.field.minimizeToTray",descriptionKey:"settings.openchamber.desktopNetwork.field.minimizeToTrayDescription",keywords:["desktop","tray","system tray","minimize","close","background","windows","linux"],isAvailable:t=>t.isDesktopLocalOrigin&&(t.isWindows||t.isLinux)},{id:"sessions.desktop-keep-awake",page:"general",titleKey:"settings.openchamber.desktopNetwork.field.keepAwake",descriptionKey:"settings.openchamber.desktopNetwork.field.keepAwakeDescription",keywords:["desktop","sleep","awake","server","mobile","phone"],isAvailable:t=>t.isDesktopLocalOrigin},{id:"sessions.desktop-ui-password",page:"general",titleKey:"settings.openchamber.desktopPassword.field.password",descriptionKey:"settings.openchamber.desktopPassword.field.passwordDescription",keywords:["desktop","password","auth","login"],isAvailable:t=>t.isDesktopLocalOrigin},{id:"sessions.desktop-lan-access",page:"general",titleKey:"settings.openchamber.desktopNetwork.field.allowLanAccess",descriptionKey:"settings.openchamber.desktopNetwork.field.allowLanAccessDescription",keywords:["desktop","lan","network","phone","tablet"],isAvailable:t=>t.isDesktopLocalOrigin},{id:"sessions.opencode-binary",page:"general",titleKey:"settings.openchamber.opencodeCli.field.binaryPath",keywords:["opencode","cli","binary","path"],isAvailable:t=>!t.isVSCode},{id:"sessions.opencode-restart",page:"general",titleKey:"settings.openchamber.opencodeCli.actions.restart",keywords:["opencode","restart","reload","plugin"],isAvailable:t=>!t.isVSCode},{id:"sessions.opencode-update-notifications",page:"general",titleKey:"settings.openchamber.opencodeCli.field.showUpdateNotifications",keywords:["opencode","cli","updates"],isAvailable:t=>!t.isVSCode},{id:"sessions.agent-control-tool",page:"general",titleKey:"settings.openchamber.tools.field.agentControlTool",descriptionKey:"settings.openchamber.tools.field.agentControlToolInfo",keywords:["agent","tool","orchestration","openchamber","sessions","schedule","control"],isAvailable:t=>!t.isVSCode},{id:"sessions.agent-web-tool",page:"general",titleKey:"settings.openchamber.tools.field.agentWebTool",descriptionKey:"settings.openchamber.tools.field.agentWebToolInfo",keywords:["agent","tool","web","browser","page","preview","openchamber"],isAvailable:t=>!t.isVSCode},{id:"sessions.browser-provider",page:"general",titleKey:"settings.openchamber.tools.browserProvider.label",descriptionKey:"settings.openchamber.tools.browserProvider.info",keywords:["agent","browser","provider","extension","chrome","server","headless"],isAvailable:t=>!t.isVSCode},{id:"sessions.agent-notify-tool",page:"general",titleKey:"settings.openchamber.tools.field.agentNotifyTool",descriptionKey:"settings.openchamber.tools.field.agentNotifyToolInfo",keywords:["agent","tool","notify","notification","alert","ping","openchamber"],isAvailable:t=>!t.isVSCode},{id:"general.isolated-spaces",page:"general",titleKey:"settings.openchamber.spaces.field.enabled",descriptionKey:"settings.openchamber.spaces.field.enabledInfo",keywords:["isolated","space","spaces","container","docker","sandbox","agent"],isAvailable:t=>!t.isVSCode&&po},{id:"general.isolated-spaces-idle-stop",page:"general",titleKey:"settings.openchamber.spaces.idleStop.enabled",descriptionKey:"settings.openchamber.spaces.idleStop.enabledInfo",keywords:["idle","stop","space","spaces","container","hours","timeout","sleep"],isAvailable:t=>!t.isVSCode&&po&&re.getState().isolatedSpacesEnabled},{id:"sessions.agent-memory-tool",page:"general",titleKey:"settings.openchamber.tools.field.agentMemoryTool",descriptionKey:"settings.openchamber.tools.field.agentMemoryToolInfo",keywords:["agent","tool","memory","remember","recall","preferences","openchamber"],isAvailable:t=>!t.isVSCode&&re.getState().agentMemoryFeatureAvailable},{id:"sessions.agent-tools-code-mode",page:"general",titleKey:"settings.openchamber.tools.field.agentToolsCodeMode",descriptionKey:"settings.openchamber.tools.field.agentToolsCodeModeInfo",keywords:["agent","tool","code mode","codemode","execute","openchamber"],isAvailable:t=>!t.isVSCode},{id:"routing.enabled",page:"routing",titleKey:"settings.routing.auto.enable",descriptionKey:"settings.routing.auto.enableInfo",keywords:["auto","routing","model","jev","automatic"],isAvailable:t=>!t.isVSCode&&t.routingAvailable&&!t.jevBlockedByEnterprise},{id:"routing.fallback-model",page:"routing",titleKey:"settings.routing.auto.fallbackModel",descriptionKey:"settings.routing.auto.fallbackModelInfo",keywords:["fallback","default","model","routing"],isAvailable:t=>!t.isVSCode&&t.routingAvailable&&!t.jevBlockedByEnterprise},{id:"routing.add-category",page:"routing",titleKey:"settings.routing.categories.title",descriptionKey:"settings.routing.categories.description",keywords:["category","categories","task type","routing"],isAvailable:t=>!t.isVSCode&&t.routingAvailable&&!t.jevBlockedByEnterprise},{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.openchamber.git.changesViewTitle",keywords:["changes","flat list","tree view"]},{id:"git.gitmoji",page:"git",titleKey:"settings.openchamber.git.enableGitmoji",keywords:["commit","emoji"]},{id:"git.gitignored-files",page:"git",titleKey:"settings.openchamber.git.showGitignored",keywords:["ignored","files","gitignore"]},{id:"usage.work-status-panel",page:"usage",titleKey:"settings.usage.page.options.showInWorkStatus",descriptionKey:"settings.usage.page.options.showInWorkStatusTooltip",keywords:["quota","work","status","panel"]},{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.default-agent",page:"projects",titleKey:"settings.projects.page.field.projectAgent",keywords:["agent","default","new chat","project metadata"]},{id:"projects.default-model",page:"projects",titleKey:"settings.projects.page.field.projectModel",keywords:["model","default","new chat","project metadata"]},{id:"projects.default-thinking",page:"projects",titleKey:"settings.projects.page.field.projectThinking",keywords:["thinking","variant","reasoning","effort","model","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.openchamber.worktrees.setup.waitForCommands",keywords:["worktree","setup commands","bootstrap","wait"]},{id:"projects.worktree.setup.replace",page:"projects",titleKey:"settings.projects.shared.replaceMode",keywords:["worktree","setup commands","shared","team","only mine"]},{id:"projects.shared",page:"projects",titleKey:"settings.projects.shared.title",descriptionKey:"settings.projects.shared.description",keywords:["shared","team","repository",".openchamber","project.json","trust"]},{id:"projects.shared.plansDir",page:"projects",titleKey:"settings.projects.shared.plansDir",descriptionKey:"settings.projects.shared.plansDirInfo",keywords:["plans","folder","shared","team","docs"]},{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:t=>!t.isVSCode},{id:"remote-instances.direct-hosts",page:"remote-instances",titleKey:"settings.remoteInstances.direct.title",descriptionKey:"settings.remoteInstances.direct.description",keywords:["server url","connection token","import link","host switcher","additional headers","request headers","cloudflare access","service token"],isAvailable:t=>t.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:"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.model",page:"agents",titleKey:"settings.agents.page.field.overrideModel",keywords:["model","provider"]},{id:"agents.variant",page:"agents",titleKey:"settings.agents.page.field.variant",descriptionKey:"settings.agents.page.field.variantTooltip",keywords:["thinking","reasoning","variant","depth"]},{id:"agents.temperature",page:"agents",titleKey:"settings.agents.page.field.temperature",descriptionKey:"settings.agents.page.field.temperatureTooltip",keywords:["randomness","creative"]},{id:"agents.top-p",page:"agents",titleKey:"settings.agents.page.field.topP",descriptionKey:"settings.agents.page.field.topPTooltip",keywords:["sampling","nucleus"]},{id:"agents.system-prompt",page:"agents",titleKey:"settings.agents.page.section.systemPrompt",keywords:["prompt","instructions"]},{id:"agents.steps",page:"agents",titleKey:"settings.agents.page.field.steps",descriptionKey:"settings.agents.page.field.stepsTooltip",keywords:["steps","loop","tool calls"]},{id:"agents.permissions",page:"agents",titleKey:"settings.agents.page.section.toolPermissions",keywords:["tools","permissions","rules","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.variant",page:"commands",titleKey:"settings.agents.page.field.variant",keywords:["variant","reasoning","thinking"]},{id:"commands.subagent",page:"commands",titleKey:"settings.commands.page.field.subagent",descriptionKey:"settings.commands.page.field.subagentTooltip",keywords:["subagent","background","child session"]},{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","code mode","codemode"]},{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:"snippets.create",page:"snippets",titleKey:"settings.snippets.sidebar.actions.create",keywords:["add","new snippet"]},{id:"snippets.content",page:"snippets",titleKey:"settings.snippets.page.field.content",keywords:["markdown","prompt","template"]},{id:"providers.connect",page:"providers",titleKey:"settings.providers.page.connect.title",keywords:["add provider","connect provider","credentials"]},{id:"providers.classification",page:"providers",titleKey:"settings.classification.page.title",descriptionKey:"settings.classification.page.description",keywords:["jev","typesafe","zen","api key","token","safety net","auto","routing","classification","promotion","off","disable","privacy","custom endpoint","base url","openai-compatible","system one","self-hosted","proxy"],isAvailable:t=>!t.isVSCode&&t.routingAvailable},{id:"providers.custom",page:"providers",titleKey:"settings.providers.page.custom.title",descriptionKey:"settings.providers.page.custom.description",keywords:["other","custom","openai-compatible","base url","api key"]},{id:"providers.auth",page:"providers",titleKey:"settings.providers.accounts.title",keywords:["api key","oauth","credentials","accounts","switch account","disconnect"]},{id:"providers.models",page:"providers",titleKey:"settings.providers.page.models.title",keywords:["models","hide","show"]},{id:"web-search.provider",page:"web-search",titleKey:"settings.webSearch.section.provider",descriptionKey:"settings.webSearch.section.providerInfo",keywords:["web search","websearch","internet","default provider","disable","off","random"]},{id:"web-search.keys",page:"web-search",titleKey:"settings.webSearch.section.keys",keywords:["api key","exa","tavily","firecrawl","parallel","tinyfish","credentials"]},{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:t=>!t.isVSCode},{id:"magic-prompts.instructions",page:"magic-prompts",titleKey:"settings.magicPrompts.page.block.instructions",keywords:["hidden prompt","instructions","template"],isAvailable:t=>!t.isVSCode},{id:"magic-prompts.reset-overrides",page:"magic-prompts",titleKey:"settings.magicPrompts.page.actions.resetAllOverrides",keywords:["reset","default prompts","overrides"],isAvailable:t=>!t.isVSCode},{id:"shortcuts.keyboard-shortcuts",page:"shortcuts",titleKey:"settings.openchamber.keyboardShortcuts.title",descriptionKey:"settings.openchamber.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"]},{id:"voice.speech-recognition",page:"voice",titleKey:"settings.voice.page.section.speechRecognition",keywords:["stt","dictation","voice input","transcribe","whisper","parakeet","microphone"]},{id:"tunnel.provider",page:"tunnel",titleKey:"settings.openchamber.tunnel.field.provider",descriptionKey:"settings.openchamber.tunnel.description",keywords:["remote access","cloudflare","ngrok"],isAvailable:t=>!t.isVSCode&&!t.enterpriseMode},{id:"tunnel.type",page:"tunnel",titleKey:"settings.openchamber.tunnel.field.tunnelType",keywords:["quick","managed remote","managed local"],isAvailable:t=>!t.isVSCode&&!t.enterpriseMode},{id:"tunnel.ttl",page:"tunnel",titleKey:"settings.openchamber.tunnel.field.connectLinkTtl",descriptionKey:"settings.openchamber.tunnel.field.tunnelSessionTtl",keywords:["expiry","expiration","session ttl","connect link ttl"],isAvailable:t=>!t.isVSCode&&!t.enterpriseMode},{id:"tunnel.managed-remote",page:"tunnel",titleKey:"settings.openchamber.tunnel.section.savedManagedRemoteTunnels",keywords:["cloudflare","hostname","token","managed remote"],isAvailable:t=>!t.isVSCode&&!t.enterpriseMode},{id:"tunnel.managed-local-config",page:"tunnel",titleKey:"settings.openchamber.tunnel.field.configurationFile",descriptionKey:"settings.openchamber.tunnel.note.managedLocalUsesConfig",keywords:["cloudflared","config","yaml","json","managed local"],isAvailable:t=>!t.isVSCode&&!t.enterpriseMode},{id:"tunnel.start",page:"tunnel",titleKey:"settings.openchamber.tunnel.actions.startTunnel",descriptionKey:"settings.openchamber.tunnel.note.connectLinksOneTime",keywords:["connect link","qr code","public url","remote access"],isAvailable:t=>!t.isVSCode&&!t.enterpriseMode},{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:t=>t.isWeb&&!t.isDesktop&&!t.isVSCode},{id:"integrations.first-party",page:"integrations",titleKey:"settings.integrations.firstParty.title",descriptionKey:"settings.integrations.firstParty.info",keywords:["built-in","first-party","native","github","linear"],isAvailable:t=>!t.isVSCode},{id:"integrations.github",page:"integrations",titleKey:"settings.integrations.github.title",descriptionKey:"settings.integrations.github.description",keywords:["github","account","oauth","gh","cli","prs","pull request","issues","connect"],isAvailable:t=>!t.isVSCode},{id:"integrations.linear",page:"integrations",titleKey:"settings.integrations.linear.title",descriptionKey:"settings.integrations.linear.description",keywords:["linear","issues","oauth","connect","workspace"],isAvailable:t=>!t.isVSCode},{id:"integrations.linear.add-workspace",page:"integrations",titleKey:"settings.integrations.linear.actions.addWorkspace",descriptionKey:"settings.integrations.linear.description",keywords:["linear","workspace","add","connect","oauth"],isAvailable:t=>!t.isVSCode},{id:"integrations.linear.mapping",page:"integrations",titleKey:"settings.integrations.linear.mapping.defaultProject",descriptionKey:"settings.integrations.linear.mapping.defaultProject.info",keywords:["linear","project","team","map","workspace","directory"],isAvailable:t=>!t.isVSCode},{id:"integrations.third-party",page:"integrations",titleKey:"settings.integrations.thirdParty.title",descriptionKey:"settings.integrations.thirdParty.info",keywords:["plugin","provider","install","update","remove","subscription"],isAvailable:t=>!t.isVSCode},{id:"integrations.third-party.opencode-claude",page:"integrations",titleKey:"settings.integrations.thirdParty.opencodeClaude.name",descriptionKey:"settings.integrations.thirdParty.opencodeClaude.description",keywords:["claude","anthropic","claude code","pro","max","agent sdk","@openchamber/opencode-claude"],isAvailable:t=>!t.isVSCode},{id:"integrations.extensions",page:"integrations",titleKey:"settings.integrations.extensionCatalog.title",descriptionKey:"settings.integrations.extensionCatalog.info",keywords:["extension","install","update","remove","openchamber"],isAvailable:t=>!t.isVSCode&&!t.isMobile},{id:"integrations.extensions.excalidraw",page:"integrations",titleKey:"settings.integrations.extensionCatalog.excalidraw.name",descriptionKey:"settings.integrations.extensionCatalog.excalidraw.description",keywords:["excalidraw","drawing","diagram","canvas","whiteboard","obsidian","sketch"],isAvailable:t=>!t.isVSCode&&!t.isMobile},{id:"integrations.guests",page:"integrations",titleKey:"settings.integrations.guests.title",descriptionKey:"settings.integrations.guests.info",keywords:["guest","extension","oauth","clickup","gitlab","panel","connect"],isAvailable:t=>!t.isVSCode},{id:"extensions.add",page:"extensions",titleKey:"settings.extensions.add.label",descriptionKey:"settings.extensions.add.info",keywords:["folder","path","zip","git","url","install","guest","panel"],isAvailable:t=>!t.isVSCode&&!t.isMobile},{id:"extensions.gitIdentity",page:"extensions",titleKey:"settings.extensions.identity.title",descriptionKey:"settings.extensions.add.info",keywords:["ssh","key","identity","git","private","clone","extension"],isAvailable:t=>!t.isVSCode&&!t.isMobile},{id:"extensions.updates.check",page:"extensions",titleKey:"settings.extensions.updates.check",keywords:["update","upgrade","version","git","extension","guest","refresh"],isAvailable:t=>!t.isVSCode&&!t.isMobile}];function Hc(t){return t.trim().toLocaleLowerCase()}function lk({query:t,runtimeCtx:e,visiblePageSlugs:a,t:n,getPageTitle:i}){const o=Hc(t);if(!o)return[];const r=a?new Set(a):null,d=o.split(/\s+/).filter(Boolean);return rk.flatMap(c=>{if(r&&!r.has(c.page))return[];const g=Va(c.page);if(!g||g.isAvailable&&!g.isAvailable(e)||c.isAvailable&&!c.isAvailable(e))return[];const m=n(c.titleKey),h=c.descriptionKey?n(c.descriptionKey):null,f=Hc([m,h,i(c.page),...c.keywords??[]].filter(Boolean).join(" "));return d.every(p=>f.includes(p))?[{...c,title:m,description:h,pageTitle:i(c.page)}]:[]})}const qc=256,Gc=280,gu="__openchamberSettingsDetail",ck=30,dk=["general","appearance","chat","notifications","sessions","routing","shortcuts","voice","integrations","extensions","usage","about","projects","remote-instances","tunnel","git","providers","web-search","agents","behavior","commands","mcp","plugins","magic-prompts","snippets","skills.installed","skills.catalog"],uk=["general","projects","opencode","content"];function mk(t,e,a,n,i){const o=ps(),r=!t&&fa();return{isVSCode:o,isWeb:r,isDesktop:t,isMobile:e,routingAvailable:a,enterpriseMode:n,jevBlockedByEnterprise:i}}function Wc(t,e){return t.isAvailable?t.isAvailable(e):!0}function Dr(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function pi(t,e){const a=new Set(e);let n=t,i=1;for(;a.has(n);)n=`${t}-${i}`,i+=1;return n}function ur(t){if(!Dr(t))return null;const e=t[gu];if(!Dr(e))return null;const a=e.page,n=e.stage;return typeof a!="string"||n!=="page-content"?null:{page:xr(a),stage:n}}function pk(){return typeof window>"u"||!Dr(window.history.state)?{}:window.history.state}const Tk=({onClose:t,forceMobile:e,isWindowed:a,visiblePageSlugs:n,initialMobileStage:i="nav",registerBackHandler:o})=>{const{t:r}=qe(),d=qn(),c=e??d.isMobile,g=re(ne=>ne.settingsPage),m=re(ne=>ne.isSettingsDialogOpen),h=re(ne=>ne.setSettingsPage),f=re(ne=>ne.shortcutOverrides.open_settings),p=xr(g),[b,C]=l.useState(i),v=l.useRef(i==="nav"?p:null);l.useEffect(()=>{!c&&p==="home"&&h("general")},[c,h,p]);const[k,u]=l.useState(""),[y,S]=l.useState(null),[N,w]=l.useState(0),A=l.useRef(null),x=l.useRef(!1),T=l.useRef([]),M=l.useRef(0),E=l.useRef(!1),D=l.useMemo(()=>us(),[]),F=l.useMemo(()=>us()&&wi(),[]),L=l.useMemo(()=>us()&&typeof window<"u"&&window.__OPENCHAMBER_PLATFORM__==="darwin",[]),P=l.useMemo(()=>us()&&typeof window<"u"&&window.__OPENCHAMBER_PLATFORM__==="win32",[]),j=l.useMemo(()=>us()&&typeof window<"u"&&window.__OPENCHAMBER_PLATFORM__==="linux",[]),O=re(ne=>ne.routingFeatureAvailable),K=ya(),H=xp(),q=l.useMemo(()=>mk(D,c,O,K,H),[D,c,O,K,H]),Z=l.useMemo(()=>{const ne=n?new Set(n):null;return bp.filter(ie=>ie.slug!=="home").filter(ie=>!ne||ne.has(ie.slug)).filter(ie=>Wc(ie,q)).filter(ie=>!(q.isVSCode&&ie.slug==="projects")).filter(ie=>!(c&&ie.slug==="shortcuts"))},[q,c,n]),ae=l.useMemo(()=>{const ne=new Map(dk.map((ie,he)=>[ie,he]));return Z.slice().sort((ie,he)=>(ne.get(ie.slug)??999)-(ne.get(he.slug)??999))},[Z]),B=hn(ne=>ne.activeProjectId),G=en();l.useEffect(()=>{if(!(!m&&!q.isVSCode&&!a)){if(p==="agents"){Hn.getState().loadAgents(G);return}if(p==="commands"){Ya.getState().loadCommands(G);return}if(p==="mcp"){Un.getState().loadMcpConfigs({directory:G});return}if(p==="plugins"){zt.getState().loadPlugins();return}(p==="skills.installed"||p==="skills.catalog")&&(rn.getState().loadSkills(G),zn.getState().loadCatalog()),p==="snippets"&&no.getState().loadSnippets()}},[B,m,a,q.isVSCode,G,p]);const _=l.useCallback(ne=>{if(h(ne),v.current=ne,!c)return;const ie=Va(ne);if(!ie||ie.slug==="home"){C("nav");return}C(ie.kind==="split"?"page-sidebar":"page-content")},[c,h]),z=l.useMemo(()=>Va(p),[p]),te=l.useMemo(()=>({general:"general",appearance:"visual",chat:"chat",shortcuts:"shortcuts",sessions:"sessions",notifications:"notifications",voice:"voice",tunnel:"tunnel"}),[]),Q=l.useCallback(ne=>{switch(ne){case"general":return r("settings.page.general.title");case"projects":return r("settings.page.projects.title");case"remote-instances":return r("settings.page.remoteInstances.title");case"providers":return r("settings.page.providers.title");case"web-search":return r("settings.page.webSearch.title");case"usage":return r("settings.page.usage.title");case"agents":return r("settings.page.agents.title");case"behavior":return r("settings.page.behavior.title");case"commands":return r("settings.page.commands.title");case"mcp":return r("settings.page.mcp.title");case"plugins":return r("settings.page.plugins.title");case"skills.installed":return r("settings.page.skills.title");case"skills.catalog":return r("settings.page.skillsCatalog.title");case"git":return r("settings.page.git.title");case"integrations":return r("settings.page.integrations.title");case"extensions":return r("settings.page.extensions.title");case"appearance":return r("settings.page.appearance.title");case"chat":return r("settings.page.chat.title");case"shortcuts":return r("settings.page.shortcuts.title");case"sessions":return r("settings.page.sessions.title");case"routing":return r("settings.page.routing.title");case"magic-prompts":return r("settings.page.magicPrompts.title");case"snippets":return r("settings.page.snippets.title");case"notifications":return r("settings.page.notifications.title");case"voice":return r("settings.page.voice.title");case"tunnel":return r("settings.page.tunnel.title");case"about":return r("settings.page.about.title");default:return r("settings.view.home.title")}},[r]),X=l.useMemo(()=>lk({query:k,runtimeCtx:{...q,isDesktopLocalOrigin:F,isMac:L,isWindows:P,isLinux:j},visiblePageSlugs:n,t:r,getPageTitle:Q}),[Q,F,L,P,j,q,k,r,n]),pe=l.useCallback(ne=>{if(ne.id.startsWith("agents.")){const ie=Hn.getState(),he=pi("new-agent",ie.agents.map(Ee=>Ee.name));return ie.setAgentDraft({name:he,scope:"user"}),ie.setSelectedAgent(he),ne.id==="agents.create"?"agents.name":ne.id}if(ne.id.startsWith("commands.")){const ie=Ya.getState(),he=pi("new-command",ie.commands.map(Ee=>Ee.name));return ie.setCommandDraft({name:he,scope:"user"}),ie.setSelectedCommand(he),ne.id==="commands.create"?"commands.name":ne.id}if(ne.id.startsWith("mcp.")){const ie=Un.getState(),he=pi("new-mcp-server",ie.mcpServers.map(Ee=>Ee.name));return ie.setMcpDraft({name:he,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",oauthCallbackPort:"",oauthAuthServerMetadataUrl:"",protocol:"legacy",timeoutStartup:"",timeoutCatalog:"",timeoutExecution:"",codemode:"default",disabled:!1}),ie.setSelectedMcp(he),ne.id==="mcp.create"?"mcp.server":ne.id}if(ne.id.startsWith("snippets.")){const ie=no.getState(),he=pi("new-snippet",ie.snippets.map(Ee=>Ee.name));return ie.setSnippetDraft({name:he,scope:"global"}),ie.setSelectedSnippet(he),ne.id==="snippets.create"?"snippets.content":ne.id}if(ne.id.startsWith("skills.")){const ie=rn.getState(),he=pi("new-skill",ie.skills.map(Ee=>Ee.name));return ie.setSkillDraft({name:he,scope:"user",source:"opencode",description:"",instructions:""}),ie.setSelectedSkill(he),ne.id==="skills.create"?"skills.basic-information":ne.id}return ne.id==="providers.connect"&&re.getState().setSettingsProvidersConnectRequested(!0),ne.id==="providers.classification"&&re.getState().setSettingsProvidersClassificationRequested(!0),ne.id==="plugins.create"?"plugins.spec":ne.id},[]),je=l.useMemo(()=>{const ne=[],ie=new Map;for(const he of X){let Ee=ie.get(he.page);Ee||(Ee={page:he.page,pageTitle:he.pageTitle,results:[]},ie.set(he.page,Ee),ne.push(Ee)),Ee.results.push(he)}return ne},[X]);l.useEffect(()=>{w(0),M.current=0,E.current=!1},[k]),l.useEffect(()=>{M.current=N},[N]),l.useEffect(()=>{T.current[N]?.scrollIntoView({block:"nearest"})},[N]),l.useEffect(()=>{N>=X.length&&w(Math.max(0,X.length-1)),T.current.length=X.length},[N,X.length]);const fe=l.useCallback(ne=>{const ie=pe(ne);S(ie),_(ne.page),c&&C("page-content"),ne.id==="plugins.create"&&typeof window<"u"&&window.setTimeout(()=>{window.dispatchEvent(new CustomEvent("openchamber:settings-open-plugin-add"))},50)},[c,_,pe]),ke=l.useCallback(ne=>{if(k.trim()){if(ne.key==="Escape"){ne.preventDefault(),u("");return}if(X.length!==0){if(ne.key==="ArrowDown"){ne.preventDefault(),E.current=!0,w(ie=>(ie+1)%X.length);return}if(ne.key==="ArrowUp"){ne.preventDefault(),E.current=!0,w(ie=>(ie-1+X.length)%X.length);return}if(ne.key==="Enter"){ne.preventDefault();const ie=(M.current%X.length+X.length)%X.length,he=X[ie]??X[0];he&&fe(he)}}}},[fe,k,X]),be=re(ne=>ne.settingsJumpRequest);l.useEffect(()=>{be&&(re.getState().clearSettingsJumpRequest(),S(be.itemId),_(xr(be.page)),c&&C("page-content"))},[c,_,be]),l.useEffect(()=>{const ne=y;if(!ne)return;let ie=!1,he=0,Ee=0;const Ke=()=>{if(ie)return;const Le=typeof CSS<"u"&&CSS.escape?CSS.escape(ne):ne.replace(/[^a-zA-Z0-9_-]/g,"\\$&"),Se=A.current?.querySelector(`[data-settings-item="${Le}"]`);if(!Se){he+=1,he<ck&&(Ee=window.requestAnimationFrame(Ke));return}S(null),Se.scrollIntoView({block:"center",behavior:"smooth"}),Se.setAttribute("data-settings-search-highlight","true"),window.setTimeout(()=>{Se.removeAttribute("data-settings-search-highlight")},1600)};return Ee=window.requestAnimationFrame(Ke),()=>{ie=!0,window.cancelAnimationFrame(Ee)}},[y,p]);const De=l.useCallback(()=>s.jsx("div",{className:"flex h-full items-center justify-center px-6",children:s.jsxs("div",{className:"max-w-md text-center",children:[s.jsx("div",{className:td,children:r("settings.view.unavailable.title")}),s.jsx("p",{className:"typography-ui text-muted-foreground mt-1",children:r("settings.view.unavailable.description")})]})}),[r]),oe=l.useCallback((ne,ie)=>{switch(ne){case"projects":return s.jsx(jx,{onItemSelect:ie.onItemSelect});case"agents":return s.jsx(rg,{onItemSelect:ie.onItemSelect});case"commands":return s.jsx(Qg,{onItemSelect:ie.onItemSelect});case"skills.installed":return s.jsx(Uh,{onItemSelect:ie.onItemSelect});case"usage":return s.jsx(nv,{onItemSelect:ie.onItemSelect});case"magic-prompts":return s.jsx(yv,{onItemSelect:ie.onItemSelect});case"snippets":return s.jsx(Nv,{onItemSelect:ie.onItemSelect});default:return null}},[]),ee=l.useCallback(ne=>{const ie=Va(ne);if(ie&&!Wc(ie,q))return De();switch(ne){case"projects":return s.jsx(Cx,{});case"remote-instances":return s.jsx(Qx,{});case"agents":return s.jsx(Dg,{});case"behavior":return s.jsx(Kg,{});case"commands":return s.jsx(nf,{});case"mcp":return s.jsx(Vf,{});case"plugins":return s.jsx(kh,{});case"skills.installed":return s.jsx(tc,{view:"installed"});case"skills.catalog":return s.jsx(tc,{view:"catalog"});case"providers":return s.jsx(tv,{});case"web-search":return s.jsx(Bg,{});case"usage":return s.jsx(bv,{});case"about":return s.jsx(ns,{title:r("settings.page.about.title"),showSaveStatus:!1,children:s.jsx(kd,{})});case"magic-prompts":return s.jsx(wv,{});case"snippets":return s.jsx(Pv,{});case"git":return s.jsx(Mv,{});case"integrations":return s.jsx(fy,{});case"routing":return s.jsx(wy,{});case"extensions":return s.jsx(Oy,{});case"general":case"appearance":case"chat":case"shortcuts":case"sessions":case"notifications":case"voice":case"tunnel":{const he=te[ne]??"visual";return s.jsx(Qj,{section:he})}default:return null}},[te,De,q,r]);l.useEffect(()=>{if(!c||b!=="nav"||p==="home"||v.current===p)return;const ne=Va(p);!ne||ne.slug==="home"||(v.current=p,C(ne.kind==="split"?"page-sidebar":"page-content"))},[c,b,p]);const ce=c&&b!=="nav",ue=c&&b==="page-content"&&z?.kind==="split",Ie=r(ue?"settings.view.actions.back":ce?"settings.view.actions.backToSettings":"settings.view.actions.closeSettings"),ve=fd("open_settings",f===void 0?void 0:{open_settings:f}),Re=ve?r("settings.view.actions.closeSettingsWithShortcut",{shortcut:xa(ve)}):r("settings.view.actions.closeSettings"),Me=l.useCallback(ne=>{if(typeof window>"u"||q.isVSCode)return;const ie=ur(window.history.state);ie?.page===ne&&ie.stage==="page-content"||window.history.pushState({...pk(),[gu]:{page:ne,stage:"page-content"}},"",window.location.href)},[q.isVSCode]),me=l.useCallback(()=>{x.current=!0,C("page-content"),Me(p)},[Me,p]);l.useEffect(()=>{if(!c||b!=="page-content"||!x.current)return;x.current=!1;const ne=window.requestAnimationFrame(()=>{A.current?.querySelector("[data-settings-page-heading]")?.focus({preventScroll:!0})});return()=>{window.cancelAnimationFrame(ne)}},[c,b,p]);const Te=l.useCallback(()=>{if(ue){if((typeof window<"u"?ur(window.history.state):null)?.page===p&&!q.isVSCode){window.history.back();return}C("page-sidebar");return}C("nav")},[ue,q.isVSCode,p]);l.useEffect(()=>{if(o)return o(()=>!c||b==="nav"?!1:(Te(),!0)),()=>o(null)},[Te,c,b,o]),l.useEffect(()=>{if(!c||q.isVSCode)return;const ne=ie=>{if(Va(p)?.kind!=="split")return;if(ur(ie.state)?.page===p){C("page-content");return}C(Ee=>Ee==="page-content"?"page-sidebar":Ee)};return window.addEventListener("popstate",ne),()=>{window.removeEventListener("popstate",ne)}},[c,q.isVSCode,p]);const Oe=()=>{const ne=k.trim().length>0;return s.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[s.jsx("div",{className:"px-4 pt-3",children:s.jsxs("div",{className:"oc-surface-elevated flex h-10 items-center gap-1.5 rounded-md border border-border bg-surface-elevated/70 px-2 text-muted-foreground focus-within:ring-2 focus-within:ring-ring sm:h-8",children:[s.jsx($,{name:"search",className:"h-4 w-4 shrink-0"}),s.jsx("input",{value:k,onChange:ie=>u(ie.target.value),onKeyDown:ke,placeholder:r("settings.view.search.placeholder"),"aria-label":r("settings.view.search.aria"),className:"typography-ui min-w-0 flex-1 bg-transparent text-foreground outline-none placeholder:text-muted-foreground/70"}),ne&&s.jsx("button",{type:"button",onClick:()=>u(""),"aria-label":r("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:s.jsx($,{name:"close",className:"h-3.5 w-3.5"})})]})}),s.jsx(Ds,{outerClassName:"flex-1 min-h-0",disableHorizontal:!0,children:s.jsx("div",{className:"flex flex-col gap-0.5 px-4 pt-4 pb-2",children:ne?X.length>0?(()=>{let ie=0;return je.map(he=>s.jsxs("div",{className:"space-y-0.5",children:[s.jsx("div",{className:"px-2 pb-0.5 pt-2 typography-micro font-medium text-muted-foreground/70",children:he.pageTitle}),he.results.map(Ee=>{const Ke=ie;ie+=1;const Le=Ke===N,Se=!!Ee.description;return s.jsxs("button",{type:"button",ref:$e=>{T.current[Ke]=$e},onMouseMove:()=>{E.current=!1,w(Ke)},onClick:()=>fe(Ee),className:Ne("flex w-full flex-col rounded-md px-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",Se?"min-h-11 py-1.5":"py-2",Le?"bg-interactive-selection":"hover:bg-interactive-hover"),children:[s.jsx("span",{className:"typography-ui-label text-foreground truncate",children:Ee.title}),Se&&s.jsx("span",{className:"typography-micro text-muted-foreground/70 line-clamp-2",children:Ee.description})]},Ee.id)})]},he.page))})():s.jsx("div",{className:"px-2 py-6 text-center typography-ui text-muted-foreground",children:r("settings.view.search.noResults")}):(()=>{const ie=new Map;for(const Ee of ae){const Ke=Ee.group,Le=ie.get(Ke);Le?Le.push(Ee):ie.set(Ke,[Ee])}return uk.map(Ee=>({group:Ee,pages:ie.get(Ee)??[]})).filter(Ee=>Ee.pages.length>0).map(({group:Ee,pages:Ke},Le)=>s.jsxs("div",{className:"space-y-0.5",children:[s.jsx("div",{className:Ne("px-3 pb-1 typography-micro font-semibold uppercase tracking-wide text-muted-foreground sm:px-2 sm:pb-0.5",Le===0?"pt-1":"pt-4 sm:pt-3"),children:r(`settings.view.nav.group.${Ee}`)}),Ke.map(Se=>{const $e=p===Se.slug&&!(c&&b==="nav"),Ye=vp(Se.slug);return!Ye&&Se.slug!=="mcp"?null:s.jsx(pd,{children:s.jsx(gd,{asChild:!0,children:s.jsxs("button",{type:"button",onClick:()=>_(Se.slug),"aria-current":$e?"page":void 0,className:Ne("flex h-11 w-full items-center gap-2.5 rounded-md px-3 overflow-hidden sm:h-8 sm:gap-2 sm:px-2",$e?"bg-interactive-selection text-foreground":"text-foreground hover:bg-interactive-hover"),children:[Se.slug==="mcp"?s.jsx(Am,{className:"h-[18px] w-[18px] shrink-0 sm:h-4 sm:w-4"}):s.jsx($,{name:Ye,className:"h-[18px] w-[18px] shrink-0 sm:h-4 sm:w-4"}),s.jsxs("span",{className:"flex items-center gap-1.5 whitespace-nowrap overflow-hidden transition-opacity duration-150 opacity-100",children:[s.jsx("span",{className:"typography-ui-label font-normal truncate",children:Q(Se.slug)}),Se.slug==="tunnel"&&s.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-[var(--status-warning)] bg-[var(--status-warning)]/10",children:r("settings.view.badge.beta")})]})]})})},Se.slug)})]},Ee))})()})})]})},ge=()=>{if(b==="nav")return s.jsx("div",{className:"flex-1 min-h-0 overflow-hidden bg-background",children:s.jsx("div",{className:"flex h-full min-h-0 flex-col",children:s.jsx(Xn,{children:Oe()})})});if(!z)return s.jsx("div",{className:"flex-1 bg-background"});if(b==="page-sidebar"){if(z.kind!=="split"){const ie=ee(p);return s.jsx(Ds,{outerClassName:"flex-1 min-h-0",className:"bg-background",disableHorizontal:!0,children:s.jsx(Xn,{children:ie})})}return s.jsx(Ds,{outerClassName:"flex-1 min-h-0",className:"bg-background",disableHorizontal:!0,children:s.jsx(Xn,{children:oe(p,{onItemSelect:me})})})}const ne=ee(p);return s.jsx(Ds,{outerClassName:"flex-1 min-h-0",className:"bg-background",disableHorizontal:!0,children:s.jsx(Xn,{children:ne})})},xe=()=>!z||p==="home"?null:z.kind==="split"?s.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[s.jsx("div",{className:Ne("border-r",q.isVSCode?"bg-background":"bg-sidebar"),style:{width:Gc,minWidth:Gc,borderColor:"var(--interactive-border)"},children:s.jsx(Xn,{children:oe(p,{})})}),s.jsx(Ds,{outerClassName:"flex-1 min-h-0",className:"bg-background",disableHorizontal:!0,children:s.jsx(Xn,{children:ee(p)})})]}):s.jsx(Ds,{outerClassName:"h-full min-h-0",className:"bg-background",disableHorizontal:!0,children:s.jsx(Xn,{children:ee(p)})});return s.jsxs("div",{ref:A,"data-settings-view":"true",className:Ne("relative flex h-full min-h-0 flex-col overflow-hidden bg-background"),children:[c?s.jsxs("div",{className:Ne("flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",b!=="nav"&&"border-b","bg-background"),style:b!=="nav"?{borderColor:"var(--interactive-border)"}:void 0,children:[ce?s.jsx("button",{type:"button",onClick:Te,"aria-label":Ie,className:"inline-flex h-9 w-9 flex-shrink-0 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-ring",children:s.jsx($,{name:"arrow-left-s",className:"h-5 w-5"})}):null,s.jsx("div",{className:"min-w-0 flex-1 px-2 typography-ui-label font-medium text-foreground truncate",children:b==="nav"?r("settings.view.home.title"):z?Q(z.slug):r("settings.view.home.title")}),t&&s.jsx("button",{type:"button",onClick:t,"aria-label":r("settings.view.actions.closeSettings"),title:Re,className:"inline-flex h-9 w-9 flex-shrink-0 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-ring",children:s.jsx($,{name:"close",className:"h-5 w-5"})})]}):s.jsxs(s.Fragment,{children:[ce&&s.jsx("div",{className:Ne("absolute left-3 z-50",a?"top-2":"top-3"),children:s.jsx("button",{type:"button",onClick:Te,"aria-label":r("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-ring",children:s.jsx($,{name:"arrow-left-s",className:"h-5 w-5"})})}),t&&s.jsx("div",{className:Ne("absolute right-0.5 z-50",a?"top-0.5":"top-1"),children:s.jsx("button",{type:"button",onClick:t,"aria-label":r("settings.view.actions.closeSettings"),title:Re,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-ring",children:s.jsx($,{name:"close",className:"h-5 w-5"})})})]}),s.jsx("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:c?ge():s.jsxs(s.Fragment,{children:[s.jsx("div",{className:Ne("relative flex h-full min-h-0 flex-col overflow-hidden border-r",D?"bg-sidebar":q.isVSCode?"bg-background":"bg-sidebar"),style:{width:`${qc}px`,minWidth:`${qc}px`,borderColor:"var(--interactive-border)"},children:s.jsx(Xn,{children:Oe()})}),s.jsx("div",{className:"flex-1 overflow-hidden bg-background",children:xe()})]})})]})};export{kd as A,Tk as S};
|