@pi-chamber/web 0.1.8
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/README.md +43 -0
- package/bin/cli-entry.js +55 -0
- package/bin/cli-output.js +140 -0
- package/bin/cli-output.test.js +36 -0
- package/bin/cli.js +383 -0
- package/bin/cli.test.js +1065 -0
- package/bin/lib/DOCUMENTATION.md +31 -0
- package/bin/lib/cli-api-target.js +74 -0
- package/bin/lib/cli-args.js +846 -0
- package/bin/lib/cli-errors.js +18 -0
- package/bin/lib/cli-http.js +252 -0
- package/bin/lib/cli-lifecycle.js +421 -0
- package/bin/lib/cli-log-files.js +93 -0
- package/bin/lib/cli-network.js +186 -0
- package/bin/lib/cli-paths.js +128 -0
- package/bin/lib/cli-ports.js +51 -0
- package/bin/lib/cli-process.js +342 -0
- package/bin/lib/cli-startup.js +371 -0
- package/bin/lib/cli-tunnel-capabilities.js +9 -0
- package/bin/lib/cli-tunnel-profiles.js +366 -0
- package/bin/lib/cli-tunnel-utils.js +300 -0
- package/bin/lib/commands-connect-url.js +329 -0
- package/bin/lib/commands-lifecycle.js +396 -0
- package/bin/lib/commands-logs.js +110 -0
- package/bin/lib/commands-serve.js +419 -0
- package/bin/lib/commands-startup.js +64 -0
- package/bin/lib/commands-status.js +114 -0
- package/bin/lib/commands-tunnel.js +1761 -0
- package/bin/lib/commands-update.js +184 -0
- package/bin/lib/commands-update.test.js +98 -0
- package/dist/apple-touch-icon-120x120.png +0 -0
- package/dist/apple-touch-icon-152x152.png +0 -0
- package/dist/apple-touch-icon-167x167.png +0 -0
- package/dist/apple-touch-icon-180x180.png +0 -0
- package/dist/apple-touch-icon.png +0 -0
- package/dist/apple-touch-icon.svg +13 -0
- package/dist/assets/CommitSection-DGGArAb2.js +1 -0
- package/dist/assets/DiagramEditor-ig5nYV6t.js +1 -0
- package/dist/assets/DiagramView-8Qr6pwwI.js +1 -0
- package/dist/assets/DiffView-BHS4m_K7.js +18 -0
- package/dist/assets/FilesView-DmZcdwl-.js +14 -0
- package/dist/assets/GitView-gfHxmc66.js +6 -0
- package/dist/assets/JsonTreeView-DbFqka3P.js +1 -0
- package/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/dist/assets/MarkdownRendererImpl-B07lHhBl.js +12 -0
- package/dist/assets/PatchDiff-DD9pAs47.js +1 -0
- package/dist/assets/PierreDiffViewer-Bo0_BCT7.js +136 -0
- package/dist/assets/SessionSwitcherDropdown-t7WZX24f.js +1 -0
- package/dist/assets/SettingsView-CtsS4oDI.js +3 -0
- package/dist/assets/SettingsWindow-DIRGn3eQ.js +1 -0
- package/dist/assets/TerminalView-BV3KOtdA.css +1 -0
- package/dist/assets/TerminalView-DUwO1CCY.js +46 -0
- package/dist/assets/ToolOutputDialog-iZG2ey4T.js +15 -0
- package/dist/assets/ToolPartDiffPreview-FTexlZSz.js +8 -0
- package/dist/assets/VirtualizedFileDiff-DD5IznIe.js +10 -0
- package/dist/assets/Virtualizer-BxW2CJGB.js +1 -0
- package/dist/assets/abap-BdImnpbu.js +1 -0
- package/dist/assets/abap-Dg923wIy.js +1 -0
- package/dist/assets/actionscript-3-8WTK4YD2.js +1 -0
- package/dist/assets/actionscript-3-CoDkCxhg.js +1 -0
- package/dist/assets/ada-CTi7YQtL.js +1 -0
- package/dist/assets/ada-bCR0ucgS.js +1 -0
- package/dist/assets/andromeeda-C4gqWexZ.js +1 -0
- package/dist/assets/andromeeda-CT0vplkN.js +1 -0
- package/dist/assets/angular-html-CU67Zn6k.js +1 -0
- package/dist/assets/angular-html-D2R1pe45.js +1 -0
- package/dist/assets/angular-ts-BDmYQnhm.js +1 -0
- package/dist/assets/angular-ts-BwZT4LLn.js +1 -0
- package/dist/assets/apache-PcO-DBxQ.js +1 -0
- package/dist/assets/apache-Pmp26Uib.js +1 -0
- package/dist/assets/apex-CnCu5_gb.js +1 -0
- package/dist/assets/apex-D8_7TLub.js +1 -0
- package/dist/assets/apl-B4CMkyY2.js +1 -0
- package/dist/assets/apl-DkfyvC6M.js +1 -0
- package/dist/assets/apl-dKokRX4l.js +1 -0
- package/dist/assets/appThemeRegistry-BK0dHKa6.js +1 -0
- package/dist/assets/applescript-Co6uUVPk.js +1 -0
- package/dist/assets/applescript-Ds_W2jPS.js +1 -0
- package/dist/assets/ara-BRHolxvo.js +1 -0
- package/dist/assets/ara-C1--7J61.js +1 -0
- package/dist/assets/asciiarmor-Df11BRmG.js +1 -0
- package/dist/assets/asciidoc-Ve4PFQV2.js +1 -0
- package/dist/assets/asciidoc-nTfEFGxb.js +1 -0
- package/dist/assets/asm-CTFRnVOM.js +1 -0
- package/dist/assets/asm-D_Q5rh1f.js +1 -0
- package/dist/assets/asn1-EdZsLKOL.js +1 -0
- package/dist/assets/asterisk-B-8jnY81.js +1 -0
- package/dist/assets/astro-CbQHKStN.js +1 -0
- package/dist/assets/astro-DtPAdMss.js +1 -0
- package/dist/assets/aurora-x-C0VKFdlO.js +1 -0
- package/dist/assets/aurora-x-D-2ljcwZ.js +1 -0
- package/dist/assets/awk-CrWgQKhV.js +1 -0
- package/dist/assets/awk-DMzUqQB5.js +1 -0
- package/dist/assets/ayu-dark-DYE7WIF3.js +1 -0
- package/dist/assets/ayu-dark-wZ6ORhBL.js +1 -0
- package/dist/assets/ayu-light-BA47KaF1.js +1 -0
- package/dist/assets/ayu-light-xXLJ_Ch1.js +1 -0
- package/dist/assets/ayu-mirage-32ctXXKs.js +1 -0
- package/dist/assets/ayu-mirage-CQckA_sP.js +1 -0
- package/dist/assets/ballerina-BFfxhgS-.js +1 -0
- package/dist/assets/ballerina-a0yOSyc5.js +1 -0
- package/dist/assets/bat-B0cHNp6s.js +1 -0
- package/dist/assets/bat-BkioyH1T.js +1 -0
- package/dist/assets/beancount-dPJi_gci.js +1 -0
- package/dist/assets/beancount-k_qm7-4y.js +1 -0
- package/dist/assets/berry-CVKoklHx.js +1 -0
- package/dist/assets/berry-uYugtg8r.js +1 -0
- package/dist/assets/bibtex-CHM0blh-.js +1 -0
- package/dist/assets/bibtex-DRcCXNgM.js +1 -0
- package/dist/assets/bicep-Bmn6On1c.js +1 -0
- package/dist/assets/bicep-jWz-hQ8I.js +1 -0
- package/dist/assets/bird2-DPOp833l.js +1 -0
- package/dist/assets/bird2-DaGXIRGu.js +1 -0
- package/dist/assets/blade-D4QpJJKB.js +1 -0
- package/dist/assets/blade-QlWdzBxO.js +1 -0
- package/dist/assets/brainfuck-C4LP7Hcl.js +1 -0
- package/dist/assets/bsl-BO_Y6i37.js +1 -0
- package/dist/assets/bsl-jNujDQK2.js +1 -0
- package/dist/assets/c-BG-tZi7o.js +1 -0
- package/dist/assets/c-BIGW1oBm.js +1 -0
- package/dist/assets/c3-Fcb8_HKm.js +1 -0
- package/dist/assets/c3-eo99z4R2.js +1 -0
- package/dist/assets/cadence-BuaeHeSu.js +1 -0
- package/dist/assets/cadence-Bv_4Rxtq.js +1 -0
- package/dist/assets/cairo-BYiDgOF2.js +1 -0
- package/dist/assets/cairo-KRGpt6FW.js +1 -0
- package/dist/assets/catppuccin-frappe-CfssSZMA.js +1 -0
- package/dist/assets/catppuccin-frappe-DFWUc33u.js +1 -0
- package/dist/assets/catppuccin-latte-C9dUb6Cb.js +1 -0
- package/dist/assets/catppuccin-latte-DoBaWTGn.js +1 -0
- package/dist/assets/catppuccin-macchiato-BkAuvdZC.js +1 -0
- package/dist/assets/catppuccin-macchiato-DQyhUUbL.js +1 -0
- package/dist/assets/catppuccin-mocha-D87Tk5Gz.js +1 -0
- package/dist/assets/catppuccin-mocha-D9fcC0iT.js +1 -0
- package/dist/assets/clarity-CC_0IFDj.js +1 -0
- package/dist/assets/clarity-D53aC0YG.js +1 -0
- package/dist/assets/clike-B9uivgTg.js +1 -0
- package/dist/assets/clojure-BMjYHr_A.js +1 -0
- package/dist/assets/clojure-KnfDkB_V.js +1 -0
- package/dist/assets/clojure-P80f7IUj.js +1 -0
- package/dist/assets/cmake-BQqOBYOt.js +1 -0
- package/dist/assets/cmake-D1j8_8rp.js +1 -0
- package/dist/assets/cmake-bh2MLnkv.js +1 -0
- package/dist/assets/cobol-CWcv1MsR.js +1 -0
- package/dist/assets/cobol-dIXRVV9Y.js +1 -0
- package/dist/assets/cobol-nwyudZeR.js +1 -0
- package/dist/assets/codeowners-Bp6g37R7.js +1 -0
- package/dist/assets/codeowners-CtwIM3TN.js +1 -0
- package/dist/assets/codeql-D164juXQ.js +1 -0
- package/dist/assets/codeql-DsOJ9woJ.js +1 -0
- package/dist/assets/coffee-Bk-z6oI_.js +1 -0
- package/dist/assets/coffee-Ch7k5sss.js +1 -0
- package/dist/assets/coffeescript-S37ZYGWr.js +1 -0
- package/dist/assets/collapsible-ODWWxk4f.js +1 -0
- package/dist/assets/common-lisp-Cg-RD9OK.js +1 -0
- package/dist/assets/common-lisp-DXc9XcIM.js +1 -0
- package/dist/assets/commonlisp-DBKNyK5s.js +1 -0
- package/dist/assets/computeVirtualFileMetrics-DdXkLFAD.js +3 -0
- package/dist/assets/contextFileOpenGuard-uC4OerzL.js +1 -0
- package/dist/assets/coq-BBL5-mG4.js +1 -0
- package/dist/assets/coq-DkFqJrB1.js +1 -0
- package/dist/assets/cpp-C0lzDePx.js +1 -0
- package/dist/assets/cpp-CofmeUqb.js +1 -0
- package/dist/assets/crystal-Bhade0k2.js +1 -0
- package/dist/assets/crystal-SjHAIU92.js +1 -0
- package/dist/assets/crystal-tKQVLTB8.js +1 -0
- package/dist/assets/csharp-B7nLXyi8.js +1 -0
- package/dist/assets/csharp-COcwbKMJ.js +1 -0
- package/dist/assets/css-BnMrqG3P.js +1 -0
- package/dist/assets/css-DPfMkruS.js +1 -0
- package/dist/assets/css-PZBBrkI0.js +1 -0
- package/dist/assets/csv-D5aBhKLr.js +1 -0
- package/dist/assets/csv-fuZLfV_i.js +1 -0
- package/dist/assets/cue-D82EKSYY.js +1 -0
- package/dist/assets/cue-WCin6O4e.js +1 -0
- package/dist/assets/cypher-COkxafJQ.js +1 -0
- package/dist/assets/cypher-C_CwsFkJ.js +1 -0
- package/dist/assets/cypher-DYQk2G82.js +1 -0
- package/dist/assets/d-85-TOEBH.js +1 -0
- package/dist/assets/d-DVc-yF-l.js +1 -0
- package/dist/assets/d-pRatUO7H.js +1 -0
- package/dist/assets/dark-plus-C3mMm8J8.js +1 -0
- package/dist/assets/dark-plus-DLU5INA3.js +1 -0
- package/dist/assets/dart-CF10PKvl.js +1 -0
- package/dist/assets/dart-YLd5yyRs.js +1 -0
- package/dist/assets/dax-CEL-wOlO.js +1 -0
- package/dist/assets/dax-oldcCaJg.js +1 -0
- package/dist/assets/desktop-BmXAJ9_W.js +1 -0
- package/dist/assets/desktop-DZfyBMgF.js +1 -0
- package/dist/assets/diff-D97Zzqfu.js +1 -0
- package/dist/assets/diff-DbItnlRl.js +1 -0
- package/dist/assets/diff-jW5kmiru.js +1 -0
- package/dist/assets/docker-BcOcwvcX.js +1 -0
- package/dist/assets/docker-DG9neUKd.js +1 -0
- package/dist/assets/dockerfile-BKs6k2Af.js +1 -0
- package/dist/assets/document-attachments-BslE4Ns7.js +30 -0
- package/dist/assets/dotenv-Bea-FkXq.js +1 -0
- package/dist/assets/dotenv-Da5cRb03.js +1 -0
- package/dist/assets/dracula-BzJJZx-M.js +1 -0
- package/dist/assets/dracula-XcYHBZy6.js +1 -0
- package/dist/assets/dracula-soft-BPeX9gxW.js +1 -0
- package/dist/assets/dracula-soft-BXkSAIEj.js +1 -0
- package/dist/assets/dream-maker-BtqSS_iP.js +1 -0
- package/dist/assets/dream-maker-DAHQwpwp.js +1 -0
- package/dist/assets/dtd-DF_7sFjM.js +1 -0
- package/dist/assets/dylan-DwRh75JA.js +1 -0
- package/dist/assets/ebnf-CDyGwa7X.js +1 -0
- package/dist/assets/ecl-Cabwm37j.js +1 -0
- package/dist/assets/edge-BkV0erSs.js +1 -0
- package/dist/assets/edge-zt3dU95k.js +1 -0
- package/dist/assets/eiffel-CnydiIhH.js +1 -0
- package/dist/assets/elixir-CDX3lj18.js +1 -0
- package/dist/assets/elixir-JolcG37e.js +1 -0
- package/dist/assets/elm-BjIDgKzz.js +1 -0
- package/dist/assets/elm-DbKCFpqz.js +1 -0
- package/dist/assets/elm-vLlmbW-K.js +1 -0
- package/dist/assets/emacs-lisp-C9XAeP06.js +1 -0
- package/dist/assets/emacs-lisp-DMBh55R4.js +1 -0
- package/dist/assets/erb-B12qg9BL.js +1 -0
- package/dist/assets/erb-rsjdL4fB.js +1 -0
- package/dist/assets/erlang-BNw1qcRV.js +1 -0
- package/dist/assets/erlang-DNeY46SW.js +1 -0
- package/dist/assets/erlang-DsQrWhSR.js +1 -0
- package/dist/assets/everforest-dark-BgDCqdQA.js +1 -0
- package/dist/assets/everforest-dark-WOub3wle.js +1 -0
- package/dist/assets/everforest-light-C8M2exoo.js +1 -0
- package/dist/assets/everforest-light-DCUg8VH8.js +1 -0
- package/dist/assets/factor-kuTfRLto.js +1 -0
- package/dist/assets/fcl-Kvtd6kyn.js +1 -0
- package/dist/assets/fennel-BYunw83y.js +1 -0
- package/dist/assets/fennel-DBMsxtrh.js +1 -0
- package/dist/assets/fish-BvzEVeQv.js +1 -0
- package/dist/assets/fish-BxskpYPN.js +1 -0
- package/dist/assets/fluent-Bwo2XpEt.js +1 -0
- package/dist/assets/fluent-C4IJs8-o.js +1 -0
- package/dist/assets/forth-Ffai-XNe.js +1 -0
- package/dist/assets/fortran-DYz_wnZ1.js +1 -0
- package/dist/assets/fortran-fixed-form-CkoXwp7k.js +1 -0
- package/dist/assets/fortran-fixed-form-DFFnVrrY.js +1 -0
- package/dist/assets/fortran-free-form-BxgE0vQu.js +1 -0
- package/dist/assets/fortran-free-form-DB5N_DgY.js +1 -0
- package/dist/assets/fsharp-CXgrBDvD.js +1 -0
- package/dist/assets/fsharp-DRAF1jsN.js +1 -0
- package/dist/assets/gas-Bneqetm1.js +1 -0
- package/dist/assets/gdresource-BD-1uzY7.js +1 -0
- package/dist/assets/gdresource-BOOCDP_w.js +1 -0
- package/dist/assets/gdscript-C3mT4Uym.js +1 -0
- package/dist/assets/gdscript-C5YyOfLZ.js +1 -0
- package/dist/assets/gdshader-DkwncUOv.js +1 -0
- package/dist/assets/gdshader-G7X6ysY3.js +1 -0
- package/dist/assets/genie-D0YGMca9.js +1 -0
- package/dist/assets/genie-DSsjfZMX.js +1 -0
- package/dist/assets/gherkin-Cl2Fw-_0.js +1 -0
- package/dist/assets/gherkin-DyxjwDmM.js +1 -0
- package/dist/assets/gherkin-heZmZLOM.js +1 -0
- package/dist/assets/git-commit-CJPsQObV.js +1 -0
- package/dist/assets/git-commit-F4YmCXRG.js +1 -0
- package/dist/assets/git-rebase-DeZqv4fp.js +1 -0
- package/dist/assets/git-rebase-r7XF79zn.js +1 -0
- package/dist/assets/github-dark-BQV5ugrc.js +1 -0
- package/dist/assets/github-dark-DHJKELXO.js +1 -0
- package/dist/assets/github-dark-default-Cuk6v7N8.js +1 -0
- package/dist/assets/github-dark-default-DLWDM7FH.js +1 -0
- package/dist/assets/github-dark-dimmed-D1FmiR_p.js +1 -0
- package/dist/assets/github-dark-dimmed-DH5Ifo-i.js +1 -0
- package/dist/assets/github-dark-high-contrast-BilLoi0o.js +1 -0
- package/dist/assets/github-dark-high-contrast-E3gJ1_iC.js +1 -0
- package/dist/assets/github-light-DAi9KRSo.js +1 -0
- package/dist/assets/github-light-Rcb2q3L5.js +1 -0
- package/dist/assets/github-light-default-CQ75esMw.js +1 -0
- package/dist/assets/github-light-default-D7oLnXFd.js +1 -0
- package/dist/assets/github-light-high-contrast-BfjtVDDH.js +1 -0
- package/dist/assets/github-light-high-contrast-CRF1wyLy.js +1 -0
- package/dist/assets/gleam-BeBqoPwE.js +1 -0
- package/dist/assets/gleam-BspZqrRM.js +1 -0
- package/dist/assets/glimmer-js-BuyKUjfV.js +1 -0
- package/dist/assets/glimmer-js-Rg0-pVw9.js +1 -0
- package/dist/assets/glimmer-ts-D9iniPFN.js +1 -0
- package/dist/assets/glimmer-ts-U6CK756n.js +1 -0
- package/dist/assets/glsl-BOG9l2nV.js +1 -0
- package/dist/assets/glsl-DplSGwfg.js +1 -0
- package/dist/assets/gn-Dxr0sSUf.js +1 -0
- package/dist/assets/gn-n2N0HUVH.js +1 -0
- package/dist/assets/gnuplot-CtW3R_Hz.js +1 -0
- package/dist/assets/gnuplot-DdkO51Og.js +1 -0
- package/dist/assets/go-BBr2UQCn.js +1 -0
- package/dist/assets/go-CxLEBnE3.js +1 -0
- package/dist/assets/graphql-B6XHM4uj.js +1 -0
- package/dist/assets/graphql-ChdNCCLP.js +1 -0
- package/dist/assets/groovy-D9Dt4D0W.js +1 -0
- package/dist/assets/groovy-DFxE31Qs.js +1 -0
- package/dist/assets/groovy-gcz8RCvz.js +1 -0
- package/dist/assets/gruvbox-dark-hard-C37G1gbc.js +1 -0
- package/dist/assets/gruvbox-dark-hard-CFHQjOhq.js +1 -0
- package/dist/assets/gruvbox-dark-medium-C3G9m3TV.js +1 -0
- package/dist/assets/gruvbox-dark-medium-GsRaNv29.js +1 -0
- package/dist/assets/gruvbox-dark-soft-CVdnzihN.js +1 -0
- package/dist/assets/gruvbox-dark-soft-eZmcmZ9I.js +1 -0
- package/dist/assets/gruvbox-light-hard-BYj-vz_3.js +1 -0
- package/dist/assets/gruvbox-light-hard-CH1njM8p.js +1 -0
- package/dist/assets/gruvbox-light-medium-BdQlDiiF.js +1 -0
- package/dist/assets/gruvbox-light-medium-DRw_LuNl.js +1 -0
- package/dist/assets/gruvbox-light-soft-BGNwjiRh.js +1 -0
- package/dist/assets/gruvbox-light-soft-hJgmCMqR.js +1 -0
- package/dist/assets/hack-CaT9iCJl.js +1 -0
- package/dist/assets/hack-Cxa-FaZ4.js +1 -0
- package/dist/assets/haml-2e0EI6Is.js +1 -0
- package/dist/assets/haml-B8DHNrY2.js +1 -0
- package/dist/assets/handlebars-BL8al0AC.js +1 -0
- package/dist/assets/handlebars-CojHdNmS.js +1 -0
- package/dist/assets/haskell-BfdhR_WN.js +1 -0
- package/dist/assets/haskell-Cw1EW3IL.js +1 -0
- package/dist/assets/haskell-Df6bDoY_.js +1 -0
- package/dist/assets/haxe-CzTSHFRz.js +1 -0
- package/dist/assets/haxe-DVIybFAS.js +1 -0
- package/dist/assets/haxe-H-WmDvRZ.js +1 -0
- package/dist/assets/hcl-B6OePqme.js +1 -0
- package/dist/assets/hcl-BWvSN4gD.js +1 -0
- package/dist/assets/hjson-D2jn7IRw.js +1 -0
- package/dist/assets/hjson-D5-asLiD.js +1 -0
- package/dist/assets/hlsl-D3lLCCz7.js +1 -0
- package/dist/assets/hlsl-MKeth5V9.js +1 -0
- package/dist/assets/horizon-BUw7H-hv.js +1 -0
- package/dist/assets/horizon-bright-Cn-bp-IR.js +1 -0
- package/dist/assets/horizon-bright-CoQRYDvy.js +1 -0
- package/dist/assets/horizon-cslQss18.js +1 -0
- package/dist/assets/houston-DnULxvSX.js +1 -0
- package/dist/assets/houston-RHIKkNfR.js +1 -0
- package/dist/assets/html-DOf0XnR2.js +1 -0
- package/dist/assets/html-GMplVEZG.js +1 -0
- package/dist/assets/html-derivative-BFtXZ54Q.js +1 -0
- package/dist/assets/html-derivative-DfCZ6Hio.js +1 -0
- package/dist/assets/http-CG3jvXcS.js +1 -0
- package/dist/assets/http-DBlCnlav.js +1 -0
- package/dist/assets/http-jrhK8wxY.js +1 -0
- package/dist/assets/hurl-CxQrh4RI.js +1 -0
- package/dist/assets/hurl-irOxFIW8.js +1 -0
- package/dist/assets/hxml-Bvhsp5Yf.js +1 -0
- package/dist/assets/hxml-CkS3Eie7.js +1 -0
- package/dist/assets/hy-DFXneXwc.js +1 -0
- package/dist/assets/hy-DI6mCUnw.js +1 -0
- package/dist/assets/idl-BEugSyMb.js +1 -0
- package/dist/assets/imba-D-Pk5S0X.js +1 -0
- package/dist/assets/imba-DGztddWO.js +1 -0
- package/dist/assets/index-CRB7i1S2.js +8 -0
- package/dist/assets/index-C_Mo87uS.css +1 -0
- package/dist/assets/index-MSKFS67y.js +1 -0
- package/dist/assets/ini-BEwlwnbL.js +1 -0
- package/dist/assets/ini-Dix3pTmg.js +1 -0
- package/dist/assets/isDiffPlainText-CeCQwHA2.js +1 -0
- package/dist/assets/isFilePlainText-BcfhE9FH.js +1 -0
- package/dist/assets/java-BTDmaRNO.js +1 -0
- package/dist/assets/java-CylS5w8V.js +1 -0
- package/dist/assets/javascript-BO_2ioGC.js +1 -0
- package/dist/assets/javascript-WyGyM1wV.js +1 -0
- package/dist/assets/javascript-wDzz0qaB.js +1 -0
- package/dist/assets/jinja-4LBKfQ-Z.js +1 -0
- package/dist/assets/jinja-D0mZ3q2r.js +1 -0
- package/dist/assets/jison-B9XHrcYJ.js +1 -0
- package/dist/assets/jison-wvAkD_A8.js +1 -0
- package/dist/assets/json-B8JryHcM.js +1 -0
- package/dist/assets/json-Cp-IABpG.js +1 -0
- package/dist/assets/json5-C9tS-k6U.js +1 -0
- package/dist/assets/json5-Cdatmj9n.js +1 -0
- package/dist/assets/jsonc-CvUCa1o5.js +1 -0
- package/dist/assets/jsonc-Des-eS-w.js +1 -0
- package/dist/assets/jsonl-9I_GBd5L.js +1 -0
- package/dist/assets/jsonl-DcaNXYhu.js +1 -0
- package/dist/assets/jsonnet-DFQXde-d.js +1 -0
- package/dist/assets/jsonnet-XoenQ2oc.js +1 -0
- package/dist/assets/jssm-C2t-YnRu.js +1 -0
- package/dist/assets/jssm-CWE2S0Z5.js +1 -0
- package/dist/assets/jsx-8cLv2Six.js +1 -0
- package/dist/assets/jsx-g9-lgVsj.js +1 -0
- package/dist/assets/julia-C1oINnwa.js +1 -0
- package/dist/assets/julia-CxzCAyBv.js +1 -0
- package/dist/assets/julia-DuME0IfC.js +1 -0
- package/dist/assets/just-Bo3fV9RY.js +1 -0
- package/dist/assets/just-Cw27pwNe.js +1 -0
- package/dist/assets/kanagawa-dragon-BOvIHJVT.js +1 -0
- package/dist/assets/kanagawa-dragon-CkXjmgJE.js +1 -0
- package/dist/assets/kanagawa-lotus-Bwcd7Bvx.js +1 -0
- package/dist/assets/kanagawa-lotus-CfQXZHmo.js +1 -0
- package/dist/assets/kanagawa-wave-0SAlpf0s.js +1 -0
- package/dist/assets/kanagawa-wave-DWedfzmr.js +1 -0
- package/dist/assets/kdl-CMbyIXjQ.js +1 -0
- package/dist/assets/kdl-DV7GczEv.js +1 -0
- package/dist/assets/kimi-for-coding-eVEHug_h.svg +3 -0
- package/dist/assets/kotlin-BQy537ds.js +1 -0
- package/dist/assets/kotlin-BdnUsdx6.js +1 -0
- package/dist/assets/kusto-B_y0uMaZ.js +1 -0
- package/dist/assets/kusto-DZf3V79B.js +1 -0
- package/dist/assets/laserwave-DUszq2jm.js +1 -0
- package/dist/assets/laserwave-si7wuSrt.js +1 -0
- package/dist/assets/latex-CWtU0Tv5.js +1 -0
- package/dist/assets/latex-CZAhoKip.js +1 -0
- package/dist/assets/lean-BZvkOJ9d.js +1 -0
- package/dist/assets/lean-C4RHkN41.js +1 -0
- package/dist/assets/less-B1dDrJ26.js +1 -0
- package/dist/assets/less-XNfgnZC7.js +1 -0
- package/dist/assets/light-plus-B7mTdjB0.js +1 -0
- package/dist/assets/light-plus-g_Fi9vkG.js +1 -0
- package/dist/assets/liquid-DFlqVvG0.js +1 -0
- package/dist/assets/liquid-DYVedYrR.js +1 -0
- package/dist/assets/livescript-BwQOo05w.js +1 -0
- package/dist/assets/llmapi-detailed-Pup_107f.svg +28 -0
- package/dist/assets/llvm-BJRUtCev.js +1 -0
- package/dist/assets/llvm-DjAJT7YJ.js +1 -0
- package/dist/assets/log-2UxHyX5q.js +1 -0
- package/dist/assets/log-CcaF_xNv.js +1 -0
- package/dist/assets/logo-BtOb2qkB.js +1 -0
- package/dist/assets/logo-D9WQLoKQ.js +1 -0
- package/dist/assets/lua-8Av-h-ns.js +1 -0
- package/dist/assets/lua-BaeVxFsk.js +1 -0
- package/dist/assets/lua-BgMRiT3U.js +1 -0
- package/dist/assets/luau-BTSFCcFb.js +1 -0
- package/dist/assets/luau-C-HG3fhB.js +1 -0
- package/dist/assets/main-CPygRDd9.js +134 -0
- package/dist/assets/main-DZg4qzOe.js +2 -0
- package/dist/assets/make-CHLpvVh8.js +1 -0
- package/dist/assets/make-DXVx14cr.js +1 -0
- package/dist/assets/markdown-Cvjx9yec.js +1 -0
- package/dist/assets/markdown-DX-TNHnc.js +1 -0
- package/dist/assets/markdown-shiki.worker-DnvH1S1x.js +12 -0
- package/dist/assets/markdownCore-BULtt6Xa.js +2 -0
- package/dist/assets/marko-CnJfTvn9.js +1 -0
- package/dist/assets/marko-DiIoNBFw.js +1 -0
- package/dist/assets/material-theme-CIJ3cGaW.js +1 -0
- package/dist/assets/material-theme-D5KoaKCx.js +1 -0
- package/dist/assets/material-theme-darker-BWg3m1GB.js +1 -0
- package/dist/assets/material-theme-darker-BfHTSMKl.js +1 -0
- package/dist/assets/material-theme-lighter-B0m2ddpp.js +1 -0
- package/dist/assets/material-theme-lighter-DR8HWMN7.js +1 -0
- package/dist/assets/material-theme-ocean-CZf9pk28.js +1 -0
- package/dist/assets/material-theme-ocean-CyktbL80.js +1 -0
- package/dist/assets/material-theme-palenight-BF01YeZy.js +1 -0
- package/dist/assets/material-theme-palenight-Csfq5Kiy.js +1 -0
- package/dist/assets/mathematica-DTrFuWx2.js +1 -0
- package/dist/assets/matlab-D7o27uSR.js +1 -0
- package/dist/assets/matlab-DzreyMvm.js +1 -0
- package/dist/assets/mbox-CNhZ1qSd.js +1 -0
- package/dist/assets/mdc-BMNejdWA.js +1 -0
- package/dist/assets/mdc-D_DpLax5.js +1 -0
- package/dist/assets/mdx-C2fqO2XY.js +1 -0
- package/dist/assets/mdx-Cmh6b_Ma.js +1 -0
- package/dist/assets/mermaid-Cwy4Up_p.js +1 -0
- package/dist/assets/mermaid-mWjccvbQ.js +1 -0
- package/dist/assets/min-dark-CafNBF8u.js +1 -0
- package/dist/assets/min-dark-DhfaepVE.js +1 -0
- package/dist/assets/min-light-6xx0uMgm.js +1 -0
- package/dist/assets/min-light-CTRr51gU.js +1 -0
- package/dist/assets/miniChat-BFotDgpO.js +2 -0
- package/dist/assets/mipsasm-CKIfxQSi.js +1 -0
- package/dist/assets/mipsasm-yE_Aqo9y.js +1 -0
- package/dist/assets/mirc-CjQqDB4T.js +1 -0
- package/dist/assets/mllike-BO34x3tv.js +1 -0
- package/dist/assets/mobile-3LLzhN5Q.js +2 -0
- package/dist/assets/modelica-Dc1JOy9r.js +1 -0
- package/dist/assets/mojo-M6pJPbMk.js +1 -0
- package/dist/assets/mojo-rZm6bMo-.js +1 -0
- package/dist/assets/monokai-BodnsaDQ.js +1 -0
- package/dist/assets/monokai-D4h5O-jR.js +1 -0
- package/dist/assets/moonbit-CR8uFLGd.js +1 -0
- package/dist/assets/moonbit-_H4v1dQx.js +1 -0
- package/dist/assets/move-CyYMWVy5.js +1 -0
- package/dist/assets/move-IF9eRakj.js +1 -0
- package/dist/assets/mscgen-BA5vi2Kp.js +1 -0
- package/dist/assets/mumps-BT43cFF4.js +1 -0
- package/dist/assets/narrat-DRg8JJMk.js +1 -0
- package/dist/assets/narrat-DXUZ_ZkW.js +1 -0
- package/dist/assets/nextflow-BPolriEg.js +1 -0
- package/dist/assets/nextflow-Zz6hmt5N.js +1 -0
- package/dist/assets/nextflow-groovy-BeH2EWoN.js +1 -0
- package/dist/assets/nextflow-groovy-pQRwk_Jg.js +1 -0
- package/dist/assets/nginx-BpAMiNFr.js +1 -0
- package/dist/assets/nginx-DSXkacNc.js +1 -0
- package/dist/assets/nginx-DdIZxoE0.js +1 -0
- package/dist/assets/night-owl-C39BiMTA.js +1 -0
- package/dist/assets/night-owl-EdP2Hztp.js +1 -0
- package/dist/assets/night-owl-light-Bk-lYVyk.js +1 -0
- package/dist/assets/night-owl-light-CMTm3GFP.js +1 -0
- package/dist/assets/nim-CVrawwO9.js +1 -0
- package/dist/assets/nim-e2z2kCcq.js +1 -0
- package/dist/assets/nix-Ckjrpg0r.js +1 -0
- package/dist/assets/nix-CwoSXNpI.js +1 -0
- package/dist/assets/nord-BAu0wM6c.js +1 -0
- package/dist/assets/nord-Ddv68eIx.js +1 -0
- package/dist/assets/nsis-LdVXkNf5.js +1 -0
- package/dist/assets/ntriples-BfvgReVJ.js +1 -0
- package/dist/assets/nushell-Cz2AlsmD.js +1 -0
- package/dist/assets/nushell-DtHLcZf1.js +1 -0
- package/dist/assets/objective-c-BoaBTdtz.js +1 -0
- package/dist/assets/objective-c-DXmwc3jG.js +1 -0
- package/dist/assets/objective-cpp-CLxacb5B.js +1 -0
- package/dist/assets/objective-cpp-DstR8hNy.js +1 -0
- package/dist/assets/ocaml-C0hk2d4L.js +1 -0
- package/dist/assets/ocaml-DTbn2Hv7.js +1 -0
- package/dist/assets/octave-CWZ4xMHY.js +1 -0
- package/dist/assets/odin-BBf5iR-q.js +1 -0
- package/dist/assets/odin-Bxc4S6Xn.js +1 -0
- package/dist/assets/one-dark-pro-DVMEJ2y_.js +1 -0
- package/dist/assets/one-dark-pro-utPxbBbJ.js +1 -0
- package/dist/assets/one-light-BuCQ22aO.js +1 -0
- package/dist/assets/one-light-C3Wv6jpd.js +1 -0
- package/dist/assets/openscad-C4EeE6gA.js +1 -0
- package/dist/assets/openscad-CXHpNBsb.js +1 -0
- package/dist/assets/oz-BzwKVEFT.js +1 -0
- package/dist/assets/pascal--L3eBynH.js +1 -0
- package/dist/assets/pascal-D93ZcfNL.js +1 -0
- package/dist/assets/pascal-Sr-XLSE6.js +1 -0
- package/dist/assets/perl-C0TMdlhV.js +1 -0
- package/dist/assets/perl-C95KruZl.js +1 -0
- package/dist/assets/perl-CdXCOZ3F.js +1 -0
- package/dist/assets/permissionStore-BRcQ9Jgt.js +1 -0
- package/dist/assets/php-B4Kqya17.js +1 -0
- package/dist/assets/php-Dhbhpdrm.js +1 -0
- package/dist/assets/pig-CevX1Tat.js +1 -0
- package/dist/assets/pkl-CRusufhw.js +1 -0
- package/dist/assets/pkl-u5AG7uiY.js +1 -0
- package/dist/assets/plastic-3e1v2bzS.js +1 -0
- package/dist/assets/plastic-CXnNNlFZ.js +1 -0
- package/dist/assets/plsql-ChMvpjG-.js +1 -0
- package/dist/assets/plsql-Dbm3tV2N.js +1 -0
- package/dist/assets/po-BTJTHyun.js +1 -0
- package/dist/assets/po-LG0lFwH4.js +1 -0
- package/dist/assets/poimandres-BrOVMvuE.js +1 -0
- package/dist/assets/poimandres-CS3Unz2-.js +1 -0
- package/dist/assets/polar-C0HS_06l.js +1 -0
- package/dist/assets/polar-DjOs3GWb.js +1 -0
- package/dist/assets/postcss-CXtECtnM.js +1 -0
- package/dist/assets/postcss-GRRkWn2F.js +1 -0
- package/dist/assets/powerquery-CEu0bR-o.js +1 -0
- package/dist/assets/powerquery-DHf-dtTS.js +1 -0
- package/dist/assets/powershell-CFHJl5sT.js +1 -0
- package/dist/assets/powershell-DXrKVo3G.js +1 -0
- package/dist/assets/powershell-Dpen1YoG.js +1 -0
- package/dist/assets/prisma-Dd19v3D-.js +1 -0
- package/dist/assets/prisma-Dgf8IN_C.js +1 -0
- package/dist/assets/prolog-9JcfiY6I.js +1 -0
- package/dist/assets/prolog-CbFg5uaA.js +1 -0
- package/dist/assets/properties-C78fOPTZ.js +1 -0
- package/dist/assets/proto-C7zT0LnQ.js +1 -0
- package/dist/assets/proto-dqx_Sj2i.js +1 -0
- package/dist/assets/protobuf-ChK-085T.js +1 -0
- package/dist/assets/pug-CGlum2m_.js +1 -0
- package/dist/assets/pug-CIGw5rlb.js +1 -0
- package/dist/assets/pug-CoOVtr4u.js +1 -0
- package/dist/assets/puppet-BMWR74SV.js +1 -0
- package/dist/assets/puppet-DMA9R1ak.js +1 -0
- package/dist/assets/puppet-Di57VbSS.js +1 -0
- package/dist/assets/purescript-BgpM7rDH.js +1 -0
- package/dist/assets/purescript-CklMAg4u.js +1 -0
- package/dist/assets/python-B6Ihcp-E.js +1 -0
- package/dist/assets/python-B6aJPvgy.js +1 -0
- package/dist/assets/python-Cso5vRIg.js +1 -0
- package/dist/assets/q-pXgVlZs6.js +1 -0
- package/dist/assets/qml-3beO22l8.js +1 -0
- package/dist/assets/qml-DmGQGbca.js +1 -0
- package/dist/assets/qmldir-C8lEn-DE.js +1 -0
- package/dist/assets/qmldir-DXd9s5XC.js +1 -0
- package/dist/assets/qss-B7NnhfIi.js +1 -0
- package/dist/assets/qss-IeuSbFQv.js +1 -0
- package/dist/assets/r-1ts4xG1r.js +1 -0
- package/dist/assets/r-B6wPVr8A.js +1 -0
- package/dist/assets/r-Dspwwk_N.js +1 -0
- package/dist/assets/racket-BqYA7rlc.js +1 -0
- package/dist/assets/racket-CeDx7KO2.js +1 -0
- package/dist/assets/raku-BMJwmrCS.js +1 -0
- package/dist/assets/raku-DXvB9xmW.js +1 -0
- package/dist/assets/razor-BaMsy-R7.js +1 -0
- package/dist/assets/razor-Uh8Bk_45.js +1 -0
- package/dist/assets/red-DR6ZwibK.js +1 -0
- package/dist/assets/red-bN70gL4F.js +1 -0
- package/dist/assets/reg-C-SQnVFl.js +1 -0
- package/dist/assets/reg-Cvyu2Gnx.js +1 -0
- package/dist/assets/regexp-CDVJQ6XC.js +1 -0
- package/dist/assets/regexp-DK-WlHNu.js +1 -0
- package/dist/assets/registerCustomTheme-BBXUCRnG.js +1 -0
- package/dist/assets/rel-BlqNHz8k.js +1 -0
- package/dist/assets/rel-C3B-1QV4.js +1 -0
- package/dist/assets/renderElectronMiniChatApp-DGmmT9Wf.js +1 -0
- package/dist/assets/renderMobileApp-Dd8P9hvM.js +23 -0
- package/dist/assets/riscv-BM1_JUlF.js +1 -0
- package/dist/assets/riscv-C5dpdlr7.js +1 -0
- package/dist/assets/ron-D8l8udqQ.js +1 -0
- package/dist/assets/ron-j5NfrB3z.js +1 -0
- package/dist/assets/rose-pine-CN2F2lJl.js +1 -0
- package/dist/assets/rose-pine-dawn-0S8NEhsA.js +1 -0
- package/dist/assets/rose-pine-dawn-DHQR4-dF.js +1 -0
- package/dist/assets/rose-pine-moon-D4_iv3hh.js +1 -0
- package/dist/assets/rose-pine-moon-DzBDT4rc.js +1 -0
- package/dist/assets/rose-pine-qdsjHGoJ.js +1 -0
- package/dist/assets/rosmsg-BJDFO7_C.js +1 -0
- package/dist/assets/rosmsg-ZkSIzPhc.js +1 -0
- package/dist/assets/rpm-CTu-6PCP.js +1 -0
- package/dist/assets/rst-BrH8l1NY.js +1 -0
- package/dist/assets/rst-C371KPjr.js +1 -0
- package/dist/assets/ruby-B2Rjki9n.js +1 -0
- package/dist/assets/ruby-DusoydGj.js +1 -0
- package/dist/assets/ruby-Dw2BHqvy.js +1 -0
- package/dist/assets/runtimeSurface-Cnqjhb6Y.js +1 -0
- package/dist/assets/rust-B1yitclQ.js +1 -0
- package/dist/assets/rust-CxuBE0J8.js +1 -0
- package/dist/assets/sas-B4kiWyti.js +1 -0
- package/dist/assets/sas-DtSHuIwI.js +1 -0
- package/dist/assets/sas-cz2c8ADy.js +1 -0
- package/dist/assets/sass-Cj5Yp3dK.js +1 -0
- package/dist/assets/sass-bfEVHPJ8.js +1 -0
- package/dist/assets/scala-C151Ov-r.js +1 -0
- package/dist/assets/scala-Dtw19ca_.js +1 -0
- package/dist/assets/scheme-C41bIUwD.js +1 -0
- package/dist/assets/scheme-C98Dy4si.js +1 -0
- package/dist/assets/scheme-OJppFQF3.js +1 -0
- package/dist/assets/scss-DxBkwadj.js +1 -0
- package/dist/assets/scss-OYdSNvt2.js +1 -0
- package/dist/assets/sdbl-CvZs3G9c.js +1 -0
- package/dist/assets/sdbl-DVxCFoDh.js +1 -0
- package/dist/assets/shaderlab-CEJedz68.js +1 -0
- package/dist/assets/shaderlab-Dg9Lc6iA.js +1 -0
- package/dist/assets/shellscript-DgJyDXW6.js +1 -0
- package/dist/assets/shellscript-Yzrsuije.js +1 -0
- package/dist/assets/shellsession-BADoaaVG.js +1 -0
- package/dist/assets/shellsession-DSlzxnCM.js +1 -0
- package/dist/assets/sieve-C3Gn_uJK.js +1 -0
- package/dist/assets/simple-mode-GW_nhZxv.js +1 -0
- package/dist/assets/slack-dark-BthQWCQV.js +1 -0
- package/dist/assets/slack-dark-CWRQmTmo.js +1 -0
- package/dist/assets/slack-ochin-DO_ok7XK.js +1 -0
- package/dist/assets/slack-ochin-DqwNpetd.js +1 -0
- package/dist/assets/smalltalk-B9IHbYt7.js +1 -0
- package/dist/assets/smalltalk-BERRCDM3.js +1 -0
- package/dist/assets/smalltalk-CnHTOXQT.js +1 -0
- package/dist/assets/snazzy-light-B5llO_gK.js +1 -0
- package/dist/assets/snazzy-light-Bw305WKR.js +1 -0
- package/dist/assets/solarized-dark-DXbdFlpD.js +1 -0
- package/dist/assets/solarized-dark-G9yBjKj_.js +1 -0
- package/dist/assets/solarized-light-DeSzljQz.js +1 -0
- package/dist/assets/solarized-light-L9t79GZl.js +1 -0
- package/dist/assets/solidity-B3CjIuAd.js +1 -0
- package/dist/assets/solidity-rGO070M0.js +1 -0
- package/dist/assets/solr-DehyRSwq.js +1 -0
- package/dist/assets/soy-BSb8SaP0.js +1 -0
- package/dist/assets/soy-Brmx7dQM.js +1 -0
- package/dist/assets/sparql-BJh4JEw-.js +1 -0
- package/dist/assets/sparql-DkYu6x3z.js +1 -0
- package/dist/assets/sparql-rVzFXLq3.js +1 -0
- package/dist/assets/splunk-BtCnVYZw.js +1 -0
- package/dist/assets/splunk-h-bNAnbk.js +1 -0
- package/dist/assets/spreadsheet-BCZA_wO0.js +1 -0
- package/dist/assets/sql-BLtJtn59.js +1 -0
- package/dist/assets/sql-BbONfI8K.js +1 -0
- package/dist/assets/sql-D0XecflT.js +1 -0
- package/dist/assets/ssh-config-CywOjoXH.js +1 -0
- package/dist/assets/ssh-config-_ykCGR6B.js +1 -0
- package/dist/assets/stata-BH5u7GGu.js +1 -0
- package/dist/assets/stata-BKjsT8qe.js +1 -0
- package/dist/assets/stex-C3f8Ysf7.js +1 -0
- package/dist/assets/stylus-B533Al4x.js +1 -0
- package/dist/assets/stylus-BEDo0Tqx.js +1 -0
- package/dist/assets/stylus-CIg617SB.js +1 -0
- package/dist/assets/surrealql-2KNEnAt7.js +1 -0
- package/dist/assets/surrealql-Bq5Q-fJD.js +1 -0
- package/dist/assets/svelte-C_ipcX3V.js +1 -0
- package/dist/assets/svelte-xaxjcSSP.js +1 -0
- package/dist/assets/swift-BzpIVaGY.js +1 -0
- package/dist/assets/swift-D82vCrfD.js +1 -0
- package/dist/assets/swift-tEesUtni.js +1 -0
- package/dist/assets/synthwave-84-CbfX1IO0.js +1 -0
- package/dist/assets/synthwave-84-DRVv-_m_.js +1 -0
- package/dist/assets/system-verilog-CnnmHF94.js +1 -0
- package/dist/assets/system-verilog-Qdm_1g2q.js +1 -0
- package/dist/assets/systemd-4A_iFExJ.js +1 -0
- package/dist/assets/systemd-DKMPPZjB.js +1 -0
- package/dist/assets/talonscript-CkByrt1z.js +1 -0
- package/dist/assets/talonscript-eRuyeYHl.js +1 -0
- package/dist/assets/tasl-B9CVvjfG.js +1 -0
- package/dist/assets/tasl-QIJgUcNo.js +1 -0
- package/dist/assets/tcl-Bq9dbVAF.js +1 -0
- package/dist/assets/tcl-DVfN8rqt.js +1 -0
- package/dist/assets/tcl-dwOrl1Do.js +1 -0
- package/dist/assets/templ-BVTOctZ7.js +1 -0
- package/dist/assets/templ-P3uqSqPl.js +1 -0
- package/dist/assets/terraform-BETggiCN.js +1 -0
- package/dist/assets/terraform-CAp711iT.js +1 -0
- package/dist/assets/tex-BHxF5DMe.js +1 -0
- package/dist/assets/tex-idrVyKtj.js +1 -0
- package/dist/assets/textile-CnDTJFAw.js +1 -0
- package/dist/assets/themeResolver-BmJyTmjJ.js +1 -0
- package/dist/assets/tiddlywiki-DO-Gjzrf.js +1 -0
- package/dist/assets/tiki-DGYXhP31.js +1 -0
- package/dist/assets/tokyo-night-BvwC8l2v.js +1 -0
- package/dist/assets/tokyo-night-hegEt444.js +1 -0
- package/dist/assets/toml-Bm5Em-hy.js +1 -0
- package/dist/assets/toml-Ms459DBw.js +1 -0
- package/dist/assets/toml-vGWfd6FD.js +1 -0
- package/dist/assets/troff-wAsdV37c.js +1 -0
- package/dist/assets/ts-tags-C-gylFal.js +1 -0
- package/dist/assets/ts-tags-zn1MmPIZ.js +1 -0
- package/dist/assets/tsv-BFtm7NXx.js +1 -0
- package/dist/assets/tsv-B_m7g4N7.js +1 -0
- package/dist/assets/tsx-COt5Ahok.js +1 -0
- package/dist/assets/tsx-D6116Ycy.js +1 -0
- package/dist/assets/ttcn-CfJYG6tj.js +1 -0
- package/dist/assets/ttcn-cfg-B9xdYoR4.js +1 -0
- package/dist/assets/turtle-B1tBg_DP.js +1 -0
- package/dist/assets/turtle-BsS91CYL.js +1 -0
- package/dist/assets/turtle-DpRhbQZY.js +1 -0
- package/dist/assets/twig-DNn4PbVi.js +1 -0
- package/dist/assets/twig-DuP5mDZ4.js +1 -0
- package/dist/assets/typescript-BPQ3VLAy.js +1 -0
- package/dist/assets/typescript-BqvgUolh.js +1 -0
- package/dist/assets/typespec-BGHnOYBU.js +1 -0
- package/dist/assets/typespec-DhK7u29_.js +1 -0
- package/dist/assets/typst-DHCkPAjA.js +1 -0
- package/dist/assets/typst-Dfd71gQj.js +1 -0
- package/dist/assets/useAppFontEffects-DXASDavv.js +7043 -0
- package/dist/assets/useInlineCommentController-KJFe98HG.js +2 -0
- package/dist/assets/useOpenInAppsStore-DHAeT9zx.js +1 -0
- package/dist/assets/useWindowTitle-BcwmWC0M.js +10 -0
- package/dist/assets/v-BH76v7br.js +1 -0
- package/dist/assets/v-BcVCzyr7.js +1 -0
- package/dist/assets/vala-CsfeWuGM.js +1 -0
- package/dist/assets/vala-z59IxkFd.js +1 -0
- package/dist/assets/vb-4AxSLKIU.js +1 -0
- package/dist/assets/vb-CmGdzxic.js +1 -0
- package/dist/assets/vb-D17OF-Vu.js +1 -0
- package/dist/assets/vbscript-BuJXcnF6.js +1 -0
- package/dist/assets/velocity-D8B20fx6.js +1 -0
- package/dist/assets/vendor-aparajita-capacitor-secure-storage-5IShChL0.js +1 -0
- package/dist/assets/vendor-aria-hidden-DvXkyWUv.js +1 -0
- package/dist/assets/vendor-base-ui-DwfTg5wD.js +1 -0
- package/dist/assets/vendor-beautiful-mermaid-r4GK_usS.js +119 -0
- package/dist/assets/vendor-capacitor-app-BrDJj9I_.js +1 -0
- package/dist/assets/vendor-capacitor-core-B4EWRrHz.js +1 -0
- package/dist/assets/vendor-capacitor-keyboard-CYccoJjr.js +1 -0
- package/dist/assets/vendor-capacitor-push-notifications-KNe1zSBF.js +1 -0
- package/dist/assets/vendor-capacitor-status-bar-B-N0EOVk.js +1 -0
- package/dist/assets/vendor-ccount-c2V3InAJ.js +1 -0
- package/dist/assets/vendor-character-entities-html4-D7taRCQ7.js +1 -0
- package/dist/assets/vendor-character-entities-legacy-BpoLgcEt.js +1 -0
- package/dist/assets/vendor-class-variance-authority-5VPnzWs2.js +1 -0
- package/dist/assets/vendor-clsx-B-dksMZM.js +1 -0
- package/dist/assets/vendor-cmdk-BCEUzcHE.js +1 -0
- package/dist/assets/vendor-codemirror-autocomplete-3xMyV7a2.js +1 -0
- package/dist/assets/vendor-codemirror-commands-Bzf12ODH.js +1 -0
- package/dist/assets/vendor-codemirror-lang-angular-0K6s6cvb.js +1 -0
- package/dist/assets/vendor-codemirror-lang-cpp-B0aL03z-.js +1 -0
- package/dist/assets/vendor-codemirror-lang-css-C4jEScp7.js +1 -0
- package/dist/assets/vendor-codemirror-lang-go-CgrfVBPr.js +7 -0
- package/dist/assets/vendor-codemirror-lang-html-C1Svvdey.js +1 -0
- package/dist/assets/vendor-codemirror-lang-java-DNPz7_Bx.js +1 -0
- package/dist/assets/vendor-codemirror-lang-javascript-CrbeaEAU.js +13 -0
- package/dist/assets/vendor-codemirror-lang-jinja-DL8BR_RG.js +1 -0
- package/dist/assets/vendor-codemirror-lang-json-BTvAjwkJ.js +1 -0
- package/dist/assets/vendor-codemirror-lang-less-CPABt6NZ.js +1 -0
- package/dist/assets/vendor-codemirror-lang-liquid-BLOLOBMg.js +1 -0
- package/dist/assets/vendor-codemirror-lang-markdown-BloD9GN-.js +1 -0
- package/dist/assets/vendor-codemirror-lang-php-FIZMTuWM.js +1 -0
- package/dist/assets/vendor-codemirror-lang-python-CR2g6ukK.js +3 -0
- package/dist/assets/vendor-codemirror-lang-rust-lsPqn4k4.js +1 -0
- package/dist/assets/vendor-codemirror-lang-sass-CtECMwzH.js +1 -0
- package/dist/assets/vendor-codemirror-lang-sql-BtmZrrZH.js +2 -0
- package/dist/assets/vendor-codemirror-lang-vue-Br6DrntY.js +1 -0
- package/dist/assets/vendor-codemirror-lang-wast-DT7IlCnb.js +1 -0
- package/dist/assets/vendor-codemirror-lang-xml-wNr-LZOf.js +1 -0
- package/dist/assets/vendor-codemirror-lang-yaml-BTKFwfc2.js +1 -0
- package/dist/assets/vendor-codemirror-language-BuDklWi8.js +3 -0
- package/dist/assets/vendor-codemirror-language-data-CFVH0pe8.js +2 -0
- package/dist/assets/vendor-codemirror-search-BzyfPoRb.js +2 -0
- package/dist/assets/vendor-codemirror-state-Wdz6Qsow.js +5 -0
- package/dist/assets/vendor-codemirror-view-pXtfpqbT.js +4 -0
- package/dist/assets/vendor-comma-separated-tokens-D8TqSuIK.js +1 -0
- package/dist/assets/vendor-crelt-C8TCjufn.js +1 -0
- package/dist/assets/vendor-detect-node-es-l0sNRNKZ.js +1 -0
- package/dist/assets/vendor-diff-C3JhlQdm.js +13 -0
- package/dist/assets/vendor-dijkstrajs-COg3n3zL.js +1 -0
- package/dist/assets/vendor-dnd-kit-accessibility-Cv52zwWT.js +1 -0
- package/dist/assets/vendor-dnd-kit-core-GipZW2tY.js +5 -0
- package/dist/assets/vendor-dnd-kit-sortable-Ct2QxIHb.js +1 -0
- package/dist/assets/vendor-dnd-kit-utilities-CrOcp0Bp.js +1 -0
- package/dist/assets/vendor-dompurify-r8glNMJW.js +2 -0
- package/dist/assets/vendor-elkjs-CRCLNXjf.js +24 -0
- package/dist/assets/vendor-entities-C3BA0AJP.js +1 -0
- package/dist/assets/vendor-fflate-C7GOKjkv.js +1 -0
- package/dist/assets/vendor-floating-ui-core-CXmKXOXc.js +1 -0
- package/dist/assets/vendor-floating-ui-dom-Bkw82kL9.js +1 -0
- package/dist/assets/vendor-floating-ui-react-dom-sVFnuruh.js +1 -0
- package/dist/assets/vendor-floating-ui-utils-BzXdqYpP.js +1 -0
- package/dist/assets/vendor-framer-motion-DJASDzNt.js +1 -0
- package/dist/assets/vendor-fuse.js-Dw8P0qyA.js +1 -0
- package/dist/assets/vendor-get-nonce-C-Z93AgS.js +1 -0
- package/dist/assets/vendor-ghostty-web-CrxinGGH.js +13 -0
- package/dist/assets/vendor-hast-util-to-html-BKBhbTDb.js +9 -0
- package/dist/assets/vendor-hast-util-whitespace-D4Wp6AEg.js +1 -0
- package/dist/assets/vendor-heic2any-L8hyfc24.js +66 -0
- package/dist/assets/vendor-html-to-image-BeoRn2gJ.js +2 -0
- package/dist/assets/vendor-html-void-elements-CkdplsNl.js +1 -0
- package/dist/assets/vendor-katex-CHD9BdDO.js +257 -0
- package/dist/assets/vendor-katex-Cp579UoJ.css +1 -0
- package/dist/assets/vendor-lezer-common-B3-cUCR_.js +1 -0
- package/dist/assets/vendor-lezer-cpp-BleAU9o-.js +1 -0
- package/dist/assets/vendor-lezer-css-C5xB6jxd.js +1 -0
- package/dist/assets/vendor-lezer-go-CXK1UKk8.js +1 -0
- package/dist/assets/vendor-lezer-highlight-CDMHUZ74.js +1 -0
- package/dist/assets/vendor-lezer-html-C0I1p52t.js +1 -0
- package/dist/assets/vendor-lezer-java-D_zzj-NV.js +1 -0
- package/dist/assets/vendor-lezer-javascript-D7Tj24ot.js +1 -0
- package/dist/assets/vendor-lezer-json-Iaex0UN-.js +1 -0
- package/dist/assets/vendor-lezer-lr-bhwg1HMg.js +1 -0
- package/dist/assets/vendor-lezer-markdown-C6g-d6P3.js +6 -0
- package/dist/assets/vendor-lezer-php-_DHrbsZG.js +1 -0
- package/dist/assets/vendor-lezer-python-CvuFxeZl.js +1 -0
- package/dist/assets/vendor-lezer-rust-Lqgd5SAo.js +1 -0
- package/dist/assets/vendor-lezer-sass-Dnm2lY4t.js +1 -0
- package/dist/assets/vendor-lezer-xml-hUDuAyS5.js +1 -0
- package/dist/assets/vendor-lezer-yaml-BNIl6S_O.js +1 -0
- package/dist/assets/vendor-lru_map-B-cPXHXW.js +1 -0
- package/dist/assets/vendor-marijn-find-cluster-break-DXwl3gUT.js +1 -0
- package/dist/assets/vendor-marked-i_gIkIP3.js +59 -0
- package/dist/assets/vendor-morphdom-B7dS_VPB.js +1 -0
- package/dist/assets/vendor-motion-dom-DJLgZh4Q.js +1 -0
- package/dist/assets/vendor-motion-l0sNRNKZ.js +1 -0
- package/dist/assets/vendor-motion-utils-BGh8QBgx.js +1 -0
- package/dist/assets/vendor-oniguruma-parser-C0D4_9rT.js +33 -0
- package/dist/assets/vendor-oniguruma-to-es-DLBnFDCE.js +94 -0
- package/dist/assets/vendor-pierre-theme-Bp7SdUL6.js +1 -0
- package/dist/assets/vendor-pierre-theming-C6Z4M5_u.js +1 -0
- package/dist/assets/vendor-property-information-rJCbAzvX.js +1 -0
- package/dist/assets/vendor-qrcode-COsmt6jn.js +8 -0
- package/dist/assets/vendor-radix-ui-primitive-Dc_FVRD7.js +1 -0
- package/dist/assets/vendor-radix-ui-react-compose-refs-D1GnwnP9.js +1 -0
- package/dist/assets/vendor-radix-ui-react-context-CM4yFQ2I.js +1 -0
- package/dist/assets/vendor-radix-ui-react-dialog-jX3Dld8c.js +5 -0
- package/dist/assets/vendor-radix-ui-react-dismissable-layer-M7LsH3yL.js +1 -0
- package/dist/assets/vendor-radix-ui-react-focus-guards-D5MZ0nQs.js +1 -0
- package/dist/assets/vendor-radix-ui-react-focus-scope-C2K7lNPv.js +1 -0
- package/dist/assets/vendor-radix-ui-react-id-BcxRjnbX.js +1 -0
- package/dist/assets/vendor-radix-ui-react-portal-xlJWBfDg.js +1 -0
- package/dist/assets/vendor-radix-ui-react-presence-Btn-Dp7L.js +1 -0
- package/dist/assets/vendor-radix-ui-react-primitive-CfpW6_IT.js +1 -0
- package/dist/assets/vendor-radix-ui-react-slot-BxUc3Pvz.js +1 -0
- package/dist/assets/vendor-radix-ui-react-use-callback-ref-UKEWHtoP.js +1 -0
- package/dist/assets/vendor-radix-ui-react-use-controllable-state-C_ecoh35.js +1 -0
- package/dist/assets/vendor-radix-ui-react-use-effect-event-DkJl_Rn_.js +1 -0
- package/dist/assets/vendor-radix-ui-react-use-escape-keydown-Co13lHGj.js +1 -0
- package/dist/assets/vendor-radix-ui-react-use-layout-effect-0fyGwS2_.js +1 -0
- package/dist/assets/vendor-react-DYyjh7Q0.js +9 -0
- package/dist/assets/vendor-react-drawio-Boqanm0j.js +1 -0
- package/dist/assets/vendor-react-remove-scroll-CfeMe0DL.js +4 -0
- package/dist/assets/vendor-react-remove-scroll-bar-C9YRs2nU.js +38 -0
- package/dist/assets/vendor-react-style-singleton-B1H4bWSG.js +1 -0
- package/dist/assets/vendor-regex-BBWcyTkg.js +16 -0
- package/dist/assets/vendor-regex-recursion-JU4mF-dD.js +1 -0
- package/dist/assets/vendor-regex-utilities-2BQyy0xI.js +1 -0
- package/dist/assets/vendor-remend-BWYYytN3.js +22 -0
- package/dist/assets/vendor-remixicon-react-CzPq62YO.js +1 -0
- package/dist/assets/vendor-replit-codemirror-vim-BUqe2Slv.js +39 -0
- package/dist/assets/vendor-reselect-l0sNRNKZ.js +1 -0
- package/dist/assets/vendor-scheduler-7OC5HNn7.js +1 -0
- package/dist/assets/vendor-shiki-Bbf2GEcE.js +2 -0
- package/dist/assets/vendor-shikijs-core-CGM_jqPK.js +2 -0
- package/dist/assets/vendor-shikijs-engine-javascript-Cme4830A.js +1 -0
- package/dist/assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js +1 -0
- package/dist/assets/vendor-shikijs-transformers-CZWsLLKm.js +1 -0
- package/dist/assets/vendor-shikijs-types-CPSbSeK6.js +1 -0
- package/dist/assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js +3 -0
- package/dist/assets/vendor-simplewebauthn-browser-VDA66rT_.js +2 -0
- package/dist/assets/vendor-sonner-dWA7qvjr.js +1 -0
- package/dist/assets/vendor-space-separated-tokens-DD3iYX1K.js +1 -0
- package/dist/assets/vendor-stringify-entities-CsH1VEn9.js +1 -0
- package/dist/assets/vendor-style-mod-NZ5MEPvj.js +3 -0
- package/dist/assets/vendor-tailwind-merge-CPcsbTWB.js +1 -0
- package/dist/assets/vendor-tanstack-react-virtual-IrbCBGJ4.js +1 -0
- package/dist/assets/vendor-tanstack-virtual-core-Dubg10g5.js +1 -0
- package/dist/assets/vendor-tslib-De9GV7Vy.js +1 -0
- package/dist/assets/vendor-use-callback-ref-CJB0R85I.js +1 -0
- package/dist/assets/vendor-use-sidecar-C-AuTczP.js +1 -0
- package/dist/assets/vendor-use-sync-external-store-B7OScDIw.js +1 -0
- package/dist/assets/vendor-vite-runtime-DD1OZmLC.js +1 -0
- package/dist/assets/vendor-w3c-keyname-Vcq4gwWv.js +1 -0
- package/dist/assets/vendor-workbox-window-BIl4cyR9.js +2 -0
- package/dist/assets/vendor-zumer-snapdom-Btyu_Xi2.js +8 -0
- package/dist/assets/vendor-zustand-CnsBKjP5.js +6 -0
- package/dist/assets/vendor-zwitch-C2o2j-tx.js +1 -0
- package/dist/assets/verilog-BQ8w6xss.js +1 -0
- package/dist/assets/verilog-C6RDOZhf.js +1 -0
- package/dist/assets/verilog-LfQUkHDc.js +1 -0
- package/dist/assets/vesper--t9w6MWz.js +1 -0
- package/dist/assets/vesper-DU1UobuO.js +1 -0
- package/dist/assets/vhdl-CeAyd5Ju.js +1 -0
- package/dist/assets/vhdl-DJCsFYgn.js +1 -0
- package/dist/assets/vhdl-lSbBsy5d.js +1 -0
- package/dist/assets/viml-CJc9bBzg.js +1 -0
- package/dist/assets/viml-pbKHW3Ia.js +1 -0
- package/dist/assets/vitesse-black-B_BYPdvp.js +1 -0
- package/dist/assets/vitesse-black-Bkuqu6BP.js +1 -0
- package/dist/assets/vitesse-dark-D0r3Knsf.js +1 -0
- package/dist/assets/vitesse-dark-DOSOf2Sz.js +1 -0
- package/dist/assets/vitesse-light-CVO1_9PV.js +1 -0
- package/dist/assets/vitesse-light-gUX51GpB.js +1 -0
- package/dist/assets/vue-D2k0BAl5.js +1 -0
- package/dist/assets/vue-DN_0RTcg.js +1 -0
- package/dist/assets/vue-html-AaS7Mt5G.js +1 -0
- package/dist/assets/vue-html-zEfNEgpj.js +1 -0
- package/dist/assets/vue-vine-CQOfvN7w.js +1 -0
- package/dist/assets/vue-vine-D9eCaTqi.js +1 -0
- package/dist/assets/vyper-CDx5xZoG.js +1 -0
- package/dist/assets/vyper-DpazWNpx.js +1 -0
- package/dist/assets/wasm-CFi-k9--.js +1 -0
- package/dist/assets/wasm-CG6Dc4jp.js +1 -0
- package/dist/assets/wasm-MzD3tlZU.js +1 -0
- package/dist/assets/web-components-CNPQSzpa.js +1390 -0
- package/dist/assets/webidl-ZXfAyPTL.js +1 -0
- package/dist/assets/wenyan-BV7otONQ.js +1 -0
- package/dist/assets/wenyan-CYFFG9DK.js +1 -0
- package/dist/assets/wgsl-CxjTZs-b.js +1 -0
- package/dist/assets/wgsl-Dx-B1_4e.js +1 -0
- package/dist/assets/wikitext-BhOHFoWU.js +1 -0
- package/dist/assets/wikitext-Bx2qct8O.js +1 -0
- package/dist/assets/wit-5i3qLPDT.js +1 -0
- package/dist/assets/wit-DDW3hD69.js +1 -0
- package/dist/assets/wolfram-lXgVvXCa.js +1 -0
- package/dist/assets/wolfram-pu21K997.js +1 -0
- package/dist/assets/worker-BBk7yuNN.js +153 -0
- package/dist/assets/workerFactory-tw7cIdmV.js +1 -0
- package/dist/assets/xml-BkAJuBCc.js +1 -0
- package/dist/assets/xml-sdJ4AIDG.js +1 -0
- package/dist/assets/xquery-DzFWVndE.js +1 -0
- package/dist/assets/xsl-C6UUWSil.js +1 -0
- package/dist/assets/xsl-CtQFsRM5.js +1 -0
- package/dist/assets/yacas-BJ4BC0dw.js +1 -0
- package/dist/assets/yaml-Bopit2L3.js +1 -0
- package/dist/assets/yaml-Buea-lGh.js +1 -0
- package/dist/assets/z80-Hz9HOZM7.js +1 -0
- package/dist/assets/zenscript-BIAKq-aR.js +1 -0
- package/dist/assets/zenscript-DVFEvuxE.js +1 -0
- package/dist/assets/zig-VOosw3JB.js +1 -0
- package/dist/assets/zig-bSFrHQ7n.js +1 -0
- package/dist/favicon-16.png +0 -0
- package/dist/favicon-32.png +0 -0
- package/dist/favicon.png +0 -0
- package/dist/favicon.svg +13 -0
- package/dist/index.html +658 -0
- package/dist/logo-dark-192x192.png +0 -0
- package/dist/logo-dark-512x512.svg +13 -0
- package/dist/logo-light-192x192.png +0 -0
- package/dist/logo-light-512x512.svg +13 -0
- package/dist/mini-chat.html +121 -0
- package/dist/mobile.html +79 -0
- package/dist/pwa-192.png +0 -0
- package/dist/pwa-512.png +0 -0
- package/dist/pwa-maskable-192.png +0 -0
- package/dist/pwa-maskable-512.png +0 -0
- package/dist/site.webmanifest +21 -0
- package/dist/sw.js +1 -0
- package/package.json +115 -0
- package/public/apple-touch-icon-120x120.png +0 -0
- package/public/apple-touch-icon-152x152.png +0 -0
- package/public/apple-touch-icon-167x167.png +0 -0
- package/public/apple-touch-icon-180x180.png +0 -0
- package/public/apple-touch-icon.png +0 -0
- package/public/apple-touch-icon.svg +13 -0
- package/public/favicon-16.png +0 -0
- package/public/favicon-32.png +0 -0
- package/public/favicon.png +0 -0
- package/public/favicon.svg +13 -0
- package/public/logo-dark-192x192.png +0 -0
- package/public/logo-dark-512x512.svg +13 -0
- package/public/logo-light-192x192.png +0 -0
- package/public/logo-light-512x512.svg +13 -0
- package/public/pwa-192.png +0 -0
- package/public/pwa-512.png +0 -0
- package/public/pwa-maskable-192.png +0 -0
- package/public/pwa-maskable-512.png +0 -0
- package/public/site.webmanifest +21 -0
- package/server/index.d.ts +35 -0
- package/server/index.js +206 -0
- package/server/lib/client-auth/pairing.js +308 -0
- package/server/lib/client-auth/pairing.test.js +142 -0
- package/server/lib/client-auth/remote-clients.js +280 -0
- package/server/lib/client-auth/remote-clients.test.js +158 -0
- package/server/lib/cloudflare-tunnel.js +606 -0
- package/server/lib/fs/DOCUMENTATION.md +39 -0
- package/server/lib/fs/pick-directory.js +236 -0
- package/server/lib/fs/pick-directory.test.js +134 -0
- package/server/lib/fs/routes.js +1543 -0
- package/server/lib/fs/routes.test.js +920 -0
- package/server/lib/fs/search.js +238 -0
- package/server/lib/git/DOCUMENTATION.md +180 -0
- package/server/lib/git/credentials.js +41 -0
- package/server/lib/git/identity-storage.js +113 -0
- package/server/lib/git/index.js +6 -0
- package/server/lib/git/issue-2746-longpaths.test.js +206 -0
- package/server/lib/git/routes.js +1089 -0
- package/server/lib/git/routes.test.js +210 -0
- package/server/lib/git/service.js +4927 -0
- package/server/lib/git/service.test.js +1216 -0
- package/server/lib/inherited-env.js +74 -0
- package/server/lib/inherited-env.test.js +65 -0
- package/server/lib/ngrok-tunnel.js +343 -0
- package/server/lib/ngrok-tunnel.test.js +50 -0
- package/server/lib/package-manager.js +850 -0
- package/server/lib/package-manager.test.js +370 -0
- package/server/lib/path-realpath-cache.js +85 -0
- package/server/lib/path-realpath-cache.test.js +75 -0
- package/server/lib/pi/archive-store.js +52 -0
- package/server/lib/pi/archive-store.test.js +32 -0
- package/server/lib/pi/attachment-store.js +98 -0
- package/server/lib/pi/attachment-store.test.js +40 -0
- package/server/lib/pi/custom-themes.js +33 -0
- package/server/lib/pi/custom-themes.test.js +21 -0
- package/server/lib/pi/legacy-ui-model-defaults.js +57 -0
- package/server/lib/pi/legacy-ui-model-defaults.test.js +65 -0
- package/server/lib/pi/model-config-store.js +173 -0
- package/server/lib/pi/model-config-store.test.js +42 -0
- package/server/lib/pi/routes.js +956 -0
- package/server/lib/pi/routes.test.js +733 -0
- package/server/lib/pi/session-daemon/DOCUMENTATION.md +41 -0
- package/server/lib/pi/session-daemon/daemon-process.js +113 -0
- package/server/lib/pi/session-daemon/ipc-client.js +144 -0
- package/server/lib/pi/session-daemon/runtime-registry.js +149 -0
- package/server/lib/pi/session-daemon/runtime-registry.test.js +109 -0
- package/server/lib/pi/session-daemon/session-daemon.js +1903 -0
- package/server/lib/pi/session-daemon/session-daemon.test.js +1306 -0
- package/server/lib/pi/session-daemon/session-jsonl.js +94 -0
- package/server/lib/pi/session-daemon/session-jsonl.test.js +73 -0
- package/server/lib/pi/session-daemon/supervisor.js +458 -0
- package/server/lib/pi/session-daemon/supervisor.test.js +212 -0
- package/server/lib/pi/session-folders-store.js +74 -0
- package/server/lib/pi/session-folders-store.test.js +45 -0
- package/server/lib/pi/session-lifecycle.integration.test.js +197 -0
- package/server/lib/pi/settings-store.js +133 -0
- package/server/lib/pi/settings-store.test.js +113 -0
- package/server/lib/pi/thinking-levels.js +39 -0
- package/server/lib/pi/thinking-levels.test.js +34 -0
- package/server/lib/pi/ui-settings-store.js +68 -0
- package/server/lib/pi/ui-settings-store.test.js +40 -0
- package/server/lib/pichamber-data-dir.js +78 -0
- package/server/lib/pichamber-data-dir.test.js +105 -0
- package/server/lib/pichamber-data-root-authority.test.js +81 -0
- package/server/lib/preview/proxy-runtime.js +1604 -0
- package/server/lib/preview/proxy-runtime.test.js +528 -0
- package/server/lib/pwa-keys-contract.test.ts +62 -0
- package/server/lib/relay/DOCUMENTATION.md +106 -0
- package/server/lib/relay/cross-compat.test.js +135 -0
- package/server/lib/relay/e2ee.js +341 -0
- package/server/lib/relay/e2ee.test.js +124 -0
- package/server/lib/relay/host-client.js +389 -0
- package/server/lib/relay/host-client.test.js +292 -0
- package/server/lib/relay/identity.js +93 -0
- package/server/lib/relay/identity.test.js +78 -0
- package/server/lib/relay/service.js +9 -0
- package/server/lib/relay/signing-key.js +73 -0
- package/server/lib/relay/tunnel-codec.js +373 -0
- package/server/lib/relay/tunnel-codec.test.js +58 -0
- package/server/lib/relay/tunnel-host.js +465 -0
- package/server/lib/security/bind-host.js +40 -0
- package/server/lib/security/bind-host.test.js +36 -0
- package/server/lib/security/packaged-client-origins.js +11 -0
- package/server/lib/security/request-security.js +122 -0
- package/server/lib/security/request-security.test.js +57 -0
- package/server/lib/server/cli-entry-runtime.js +44 -0
- package/server/lib/server/cli-options.js +132 -0
- package/server/lib/server/core-routes.js +1041 -0
- package/server/lib/server/cors.js +51 -0
- package/server/lib/server/cors.test.js +37 -0
- package/server/lib/server/lan-addresses.js +41 -0
- package/server/lib/server/lan-addresses.test.js +42 -0
- package/server/lib/server/path-utils.js +27 -0
- package/server/lib/server/tunnel-auth.js +586 -0
- package/server/lib/terminal/DOCUMENTATION.md +48 -0
- package/server/lib/terminal/history.js +83 -0
- package/server/lib/terminal/history.test.js +19 -0
- package/server/lib/terminal/runtime.js +391 -0
- package/server/lib/terminal/runtime.test.js +566 -0
- package/server/lib/terminal/shells.js +100 -0
- package/server/lib/terminal/shells.test.js +73 -0
- package/server/lib/terminal/terminal-ws-protocol.js +68 -0
- package/server/lib/terminal/terminal-ws-protocol.test.js +145 -0
- package/server/lib/terminal/theme-response.js +98 -0
- package/server/lib/terminal/theme-response.test.js +70 -0
- package/server/lib/tunnels/DOCUMENTATION.md +33 -0
- package/server/lib/tunnels/executable-search.js +140 -0
- package/server/lib/tunnels/executable-search.test.js +96 -0
- package/server/lib/tunnels/install-help.js +56 -0
- package/server/lib/tunnels/install-help.test.js +31 -0
- package/server/lib/tunnels/providers/cloudflare.js +54 -0
- package/server/lib/tunnels/providers/ngrok.js +32 -0
- package/server/lib/tunnels/types.js +16 -0
- package/server/lib/ui-auth/DOCUMENTATION.md +44 -0
- package/server/lib/ui-auth/ui-auth.js +972 -0
- package/server/lib/ui-auth/ui-auth.test.js +250 -0
- package/server/lib/ui-auth/ui-passkeys.js +543 -0
- package/server/lib/workspace/host.js +91 -0
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{R as n,j as e,r as le}from"./vendor-react-DYyjh7Q0.js";import{B as j,I as C,o as Pn,aG as ba,t as E,P as gi,D as lt,C as ct,E as pt,G as ht,H as gt,J as ga,a$ as Qs,f as ne,e0 as ps,az as Tn,aA as In,aB as En,aC as An,b as La,bm as fi,K as _r,aE as en,e1 as xi,e2 as bi,b4 as vi,a1 as ie,bD as Un,bS as Re,bT as De,bU as Oe,bV as _e,bW as je,bZ as Fr,h as rt,e3 as tn,e4 as zn,e5 as yi,e6 as wi,e7 as ji,e8 as ki,e9 as Mt,aF as Si,ea as Ni,eb as Ci,ec as Pi,ed as Ti,ee as sn,ef as Bn,eg as Ii,eh as Ei,ei as Ai,ej as Mi,c0 as Li,ek as an,el as Hn,em as Pa,en as $n,bY as Ri,eo as Di,T as Ur,y as zr,z as Oi,ep as _i,eq as Fi,er as Yt,aU as Vn,es as Kn,et as nn,bf as Ui,aT as Wn,eu as Br,dF as zi,a0 as cs}from"./useAppFontEffects-DXASDavv.js";import{r as Je,ao as Ye,a as Is,u as k,t as Ve,A as Gn,a$ as qn,b2 as Qn,B as ia,bC as Bi,f as Hi,a_ as Ws,bD as $i,ai as Vi,b1 as Ki,s as Wi,d as va,b0 as Gi,v as ya,bE as Hr,I as qi,Y as ve,bF as Qi,n as ha,H as Ji,a7 as Jn,aj as Yi,bq as Xi,as as Zi,Q as hs,bG as eo,p as $r,bH as Yn,bu as Xn,bI as Zn,ad as er,bJ as to,bK as so,bp as ao,bL as tr,X as rn,aa as no,bM as ro,bN as io,bO as oo,bP as lo,bQ as co,bR as uo,bS as mo}from"./index-CRB7i1S2.js";import{u as po,z as ho,U as sr,B as ae,E as $e,G as fn,H as go,I as Mn,J as wa,K as fo,g as Qe,L as Ra,M as Ht,R as xo,N as Fe,O as Bt,Q as ar,V as Le,W as Gs,X as nt,Y as Ge,Z as xn,m as Vr,o as Kr,p as Wr,q as Gr,_ as ft,$ as Ts,a0 as Cs,a1 as Ps,a2 as me,a3 as ua,a4 as ms,a5 as Da,a6 as ma,a7 as Ns,a8 as nr,a9 as oa,aa as la,ab as Ta,ac as rr,ad as pa,ae as qr,x as bo,af as vo,y as yo}from"./TerminalView-DUwO1CCY.js";import{Q as Qr}from"./vendor-qrcode-COsmt6jn.js";import{W as wo,X as jo}from"./vendor-base-ui-DwfTg5wD.js";import{C as Jr,a as Yr,b as Xr}from"./collapsible-ODWWxk4f.js";import{u as Ln,c as Zr}from"./vendor-zustand-CnsBKjP5.js";import{c as ko,s as So,g as No,i as ei,d as Co}from"./runtimeSurface-Cnqjhb6Y.js";const qs=16384,Oa=globalThis,Po=t=>{if(Oa.Buffer)return Oa.Buffer.from(t,"utf8").toString("base64url");const s=new TextEncoder().encode(t);let i="";for(let o=0;o<s.length;o+=32768)i+=String.fromCharCode(...s.slice(o,o+32768));return btoa(i).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")},ti=t=>{try{if(Oa.Buffer)return Oa.Buffer.from(t,"base64url").toString("utf8");const s=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(Math.ceil(t.length/4)*4,"="),i=atob(s),o=new Uint8Array(i.length);for(let l=0;l<i.length;l+=1)o[l]=i.charCodeAt(l);return new TextDecoder().decode(o)}catch{return null}},To=t=>{if(typeof t!="string")return null;const s=t.trim();if(!s)return null;try{const i=new URL(s);return i.protocol!=="http:"&&i.protocol!=="https:"?null:(i.hash="",i.toString().replace(/\/+$/g,""))}catch{return null}},Io=t=>{if(typeof t!="string")return null;const s=t.trim();if(!s)return null;try{const i=new URL(s);return i.protocol!=="ws:"&&i.protocol!=="wss:"?null:(i.hash="",i.toString())}catch{return null}},ir=t=>typeof t=="string"&&t.length>0,Eo=t=>{if(!t||typeof t!="object"||Array.isArray(t))return null;const s=t;return s.kty!=="EC"||s.crv!=="P-256"||!ir(s.x)||!ir(s.y)?null:{kty:"EC",crv:"P-256",x:s.x,y:s.y}},Ao=t=>typeof t=="number"&&Number.isFinite(t)?t:void 0,Mo=t=>{if(!t||typeof t!="object")return null;const s=t,i=Ao(s.priority);if(s.type==="lan"||s.type==="tunnel"){const o=To(s.url);return o?i===void 0?{type:s.type,url:o}:{type:s.type,url:o,priority:i}:null}if(s.type==="relay"){const o=Io(s.relayUrl);if(!o)return null;const l=typeof s.serverId=="string"?s.serverId.trim():"";if(!l)return null;const h=Eo(s.hostEncPubJwk);if(!h)return null;const f=typeof s.grant=="string"&&s.grant.trim()?s.grant.trim():void 0;return{type:"relay",relayUrl:o,serverId:l,hostEncPubJwk:h,...f?{grant:f}:{},...i===void 0?{}:{priority:i}}}return null},Rn=t=>{if(!t||typeof t!="object")return null;const s=t;if(s.v!==2)return null;const i=typeof s.pairingId=="string"?s.pairingId.trim():"",o=typeof s.secret=="string"?s.secret.trim():"";if(!i||!o)return null;const l=Array.isArray(s.candidates)?s.candidates.map(Mo).filter(x=>!!x):[];if(l.length===0)return null;const h=typeof s.expiresAt=="string"&&s.expiresAt.trim()?s.expiresAt.trim():void 0;if(h){const x=Date.parse(h);if(!Number.isFinite(x)||x<=Date.now())return null}const f=typeof s.label=="string"&&s.label.trim()?s.label.trim():void 0,u=typeof s.fingerprint=="string"&&s.fingerprint.trim()?s.fingerprint.trim():void 0;return{v:2,pairingId:i,secret:o,...f?{label:f}:{},...u?{fingerprint:u}:{},...h?{expiresAt:h}:{},candidates:l}},Lo=t=>({v:2,pairingId:t.pairingId.trim(),secret:t.secret.trim(),...t.label?.trim()?{label:t.label.trim()}:{},...t.fingerprint?.trim()?{fingerprint:t.fingerprint.trim()}:{},...t.expiresAt?.trim()?{expiresAt:t.expiresAt.trim()}:{},candidates:t.candidates}),Ro=t=>{const s=Rn(t);if(!s)throw new Error("Invalid pairing connection payload");const i=new URLSearchParams;return i.set("v","2"),i.set("p",Po(JSON.stringify(s))),`pichamber://connect?${i.toString()}`},Do=t=>{const s=t.trim();if(!s||s.length>qs)return null;try{const i=new URL(s);if(i.protocol!=="pichamber:"||i.hostname!=="connect"||i.searchParams.get("v")!=="2")return null;const o=i.searchParams.get("p")||"";if(!o||o.length>qs)return null;const l=ti(o);return!l||l.length>qs?null:Rn(JSON.parse(l))}catch{return null}},_c=t=>{const s=t.trim();if(!s||s.length>qs)return null;const i=s.indexOf("?");if(i===-1||!/^pichamber:\/\/connect\/?$/i.test(s.slice(0,i)))return null;let o=null,l=null;for(const f of s.slice(i+1).split("&")){const u=f.indexOf("=");if(u===-1)continue;const x=f.slice(0,u),L=f.slice(u+1);x==="v"?o=L:x==="p"&&(l=L)}if(o!=="2"||!l||l.length>qs)return null;const h=ti(l);if(!h||h.length>qs)return null;try{return Rn(JSON.parse(h))}catch{return null}},or=()=>{const[t,s]=n.useState(null);n.useEffect(()=>{let o=!1;const l=typeof AbortController<"u"?new AbortController:void 0;return(async()=>{try{const f=await Je("/api/system/info",{signal:l?.signal,headers:{Accept:"application/json"}});if(!f.ok)return;const u=await f.json().catch(()=>null);if(!u||o)return;const x=typeof u.port=="number"&&Number.isFinite(u.port)&&u.port>0?u.port:null,L=typeof u.tunnelUrl=="string"&&u.tunnelUrl.trim().length>0?u.tunnelUrl.trim():null;s({port:x,tunnelUrl:L})}catch{}})(),()=>{o=!0,l?.abort()}},[]);const i=[];return t?.port!==null&&t?.port!==void 0&&i.push({key:"application",label:"Application",url:`http://localhost:${t.port}/`}),t?.tunnelUrl&&i.push({key:"tunnel",label:"Tunnel",url:t.tunnelUrl}),i.length===0?null:e.jsx("div",{className:"flex flex-wrap items-center gap-2",children:i.map(o=>e.jsxs(j,{type:"button",variant:"outline",size:"sm",title:o.label,className:"max-w-full gap-1.5 px-2.5",onClick:()=>{Pn(o.url)},children:[e.jsx(C,{name:"external-link",className:"size-3.5 shrink-0"}),e.jsx("span",{className:"max-w-64 truncate font-mono typography-micro",children:o.url})]},o.key))})},bn="https://github.com/RyderAsKing/PiChamber",si="https://github.com/RyderAsKing/PiChamber/discussions",vn="https://pi.dev/",Oo=800,ai=({initialUpdateDialogOpen:t=!1})=>{const[s,i]=n.useState(t),[o,l]=n.useState(!1),[h,f]=n.useState(null),u=po(Ln(g=>({info:g.info,checking:g.checking,available:g.available,error:g.error,downloading:g.downloading,downloaded:g.downloaded,progress:g.progress,runtimeType:g.runtimeType,checkForUpdates:g.checkForUpdates,downloadUpdate:g.downloadUpdate,restartToUpdate:g.restartToUpdate}))),{isMobile:x}=ba(),L=h||u.info?.currentVersion||"unknown";n.useEffect(()=>{let g=!1;return(async()=>{try{const M=await Je("/api/system/info",{method:"GET",headers:{Accept:"application/json"}});if(!M.ok)return;const G=await M.json().catch(()=>null),I=typeof G?.pichamberVersion=="string"&&G.pichamberVersion.trim().length>0?G.pichamberVersion.trim():null;g||f(I)}catch{g||f(null)}})(),()=>{g=!0}},[]);const d=n.useRef(!1);n.useEffect(()=>{if(u.checking)l(!0),d.current=!0;else if(o){const g=setTimeout(()=>{l(!1),d.current&&!u.available&&!u.error&&(E.success("You are on the latest version"),d.current=!1)},Oo);return()=>clearTimeout(g)}},[u.checking,o,u.available,u.error]);const T=u.checking||o;return x?e.jsxs("div",{className:"w-full space-y-6 pb-2",children:[e.jsxs("div",{className:"flex flex-col items-center text-center",children:[e.jsx(gi,{width:72,height:72}),e.jsx("h2",{className:`mt-4 ${ho}`,children:"PiChamber"}),e.jsx("div",{className:"mt-2 space-y-1 typography-ui text-muted-foreground",children:e.jsx("p",{children:`PiChamber version ${L}`})}),e.jsx(or,{})]}),e.jsxs("div",{className:"flex justify-center",children:[!u.available&&!u.error&&e.jsxs(j,{type:"button",variant:"outline",size:"sm",onClick:()=>u.checkForUpdates(),disabled:T,className:"h-10 w-auto justify-center gap-2 rounded-xl px-4",children:[T?e.jsx(C,{name:"loader",className:"size-4 animate-spin"}):e.jsx(C,{name:"refresh",className:"size-4"}),T?"Checking...":"Check for updates"]}),!T&&u.available&&e.jsxs(j,{type:"button",variant:"default",size:"sm",onClick:()=>i(!0),className:"h-10 w-auto justify-center gap-2 rounded-xl px-4",children:[e.jsx(C,{name:"download",className:"size-4"}),`Update to ${u.info?.version||""}`]})]}),u.error&&e.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:u.error}),e.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[e.jsxs("div",{className:"flex items-center justify-center gap-5",children:[e.jsxs("a",{href:bn,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(C,{name:"github-fill",className:"size-5"}),e.jsx("span",{children:"GitHub"})]}),e.jsxs("a",{href:si,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground",children:[e.jsx(C,{name:"discord-fill",className:"size-5"}),e.jsx("span",{children:"Discord"})]})]}),e.jsx("a",{href:vn,target:"_blank",rel:"noopener noreferrer",className:"typography-ui-label text-muted-foreground transition-colors hover:text-foreground",children:"Pi Agent at pi.dev"})]}),e.jsx(lr,{}),e.jsx("p",{className:"text-center typography-ui text-muted-foreground/60",children:"Made with care for the community"}),e.jsx(sr,{open:s,onOpenChange:i,info:u.info,downloading:u.downloading,downloaded:u.downloaded,progress:u.progress,error:u.error,onDownload:u.downloadUpdate,onRestart:u.restartToUpdate,runtimeType:u.runtimeType})]}):e.jsxs(e.Fragment,{children:[e.jsxs(ae,{divider:!1,children:[e.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 overflow-hidden flex flex-col",children:[e.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:[e.jsxs("div",{className:"flex min-w-0 flex-col",children:[e.jsx("span",{className:$e,children:"Version"}),e.jsx("span",{className:"typography-meta text-muted-foreground font-mono",children:L})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[u.checking&&e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(C,{name:"loader",className:"h-4 w-4 animate-spin"}),e.jsx("span",{className:"typography-meta",children:"Checking..."})]}),!u.checking&&u.available&&e.jsxs(j,{size:"sm",variant:"default",onClick:()=>i(!0),children:[e.jsx(C,{name:"download",className:"h-4 w-4 mr-1"}),`Update to ${u.info?.version||""}`]}),!u.checking&&!u.available&&!u.error&&e.jsx("span",{className:"typography-meta text-muted-foreground",children:"Up to date"}),e.jsx(j,{size:"sm",variant:"outline",onClick:()=>u.checkForUpdates(),disabled:u.checking,children:"Check for updates"})]})]}),u.error&&e.jsx("div",{className:"px-3 py-2 border-b border-border/40",children:e.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:u.error})}),e.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:[e.jsx("span",{className:$e,children:"Instance URLs"}),e.jsx(or,{})]}),e.jsxs("div",{className:"flex items-center gap-4 px-4 py-4",children:[e.jsxs("a",{href:bn,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-muted-foreground hover:text-foreground typography-meta transition-colors",children:[e.jsx(C,{name:"github-fill",className:"h-4 w-4"}),e.jsx("span",{children:"GitHub"})]}),e.jsxs("a",{href:vn,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-muted-foreground hover:text-foreground typography-meta transition-colors",children:[e.jsx(C,{name:"information",className:"h-4 w-4"}),e.jsx("span",{children:"Pi Agent"})]})]})]}),e.jsx(sr,{open:s,onOpenChange:i,info:u.info,downloading:u.downloading,downloaded:u.downloaded,progress:u.progress,error:u.error,onDownload:u.downloadUpdate,onRestart:u.restartToUpdate,runtimeType:u.runtimeType})]}),e.jsx(lr,{})]})},lr=()=>e.jsxs(e.Fragment,{children:[e.jsx(ae,{title:"What is PiChamber",divider:!1,children:e.jsxs("div",{className:"max-w-2xl space-y-3 typography-ui text-muted-foreground",children:[e.jsx("p",{children:"PiChamber is an open-source workspace for running and supervising Pi Coding Agent sessions from a desktop app or browser."}),e.jsx("p",{children:"It keeps the Pi session daemon on your host while giving trusted devices a focused, authenticated interface for creating sessions, following live work, and steering the agent when needed."})]})}),e.jsx(ae,{title:"Our goals",children:e.jsxs("ul",{className:"max-w-2xl list-disc space-y-2 pl-5 typography-ui text-muted-foreground",children:[e.jsx("li",{children:"Make agent-assisted development practical from anywhere you work."}),e.jsx("li",{children:"Keep users in control of sessions, tools, project context, and credentials."}),e.jsx("li",{children:"Offer a calm, responsive interface for both focused coding and supervision."}),e.jsx("li",{children:"Stay open, self-hostable, and respectful of the systems where Pi runs."})]})}),e.jsx(ae,{title:"Built around Pi",children:e.jsxs("div",{className:"max-w-2xl space-y-3 typography-ui text-muted-foreground",children:[e.jsx("p",{children:"Pi is the coding agent and session engine underneath PiChamber. It is designed for working with your tools and code directly, and PiChamber adds the multi-device workspace around that experience."}),e.jsxs("p",{children:["Learn more about Pi Coding Agent at"," ",e.jsx("a",{href:vn,target:"_blank",rel:"noopener noreferrer",className:"text-foreground underline underline-offset-4 hover:text-primary",children:"pi.dev"}),"."]})]})}),e.jsx(ae,{title:"Special thanks",children:e.jsxs("div",{className:"max-w-2xl space-y-3 typography-ui text-muted-foreground",children:[e.jsxs("p",{children:["PiChamber is a community fork of"," ",e.jsx("a",{href:"https://github.com/openchamber/openchamber",target:"_blank",rel:"noopener noreferrer",className:"text-foreground underline underline-offset-4 hover:text-primary",children:"OpenChamber"})," ","by Bohdan Triapitsyn. We are grateful for the foundation and the required MIT attribution carried forward from that project."]}),e.jsx("p",{children:"Thank you to Pierre, the Pi community, Ghostty-web, and every contributor whose work, feedback, and ideas help make this project possible."})]})}),e.jsx(ae,{title:"Links and license",children:e.jsxs("div",{className:"flex flex-wrap gap-x-5 gap-y-2 typography-ui-label",children:[e.jsx("a",{href:bn,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground transition-colors hover:text-foreground",children:"PiChamber on GitHub"}),e.jsx("a",{href:si,target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground transition-colors hover:text-foreground",children:"GitHub discussions"}),e.jsx("a",{href:"https://github.com/RyderAsKing/PiChamber/blob/main/LICENSE",target:"_blank",rel:"noopener noreferrer",className:"text-muted-foreground transition-colors hover:text-foreground",children:"MIT license"})]})})]}),fa=({onResolved:t})=>{const[s,i]=n.useState(!1),[o,l]=n.useState(!1);n.useEffect(()=>{let f=!0;return Ye.getSettings({runtimeKey:Is()}).then(u=>{f&&i(u.pi.project.requiresTrust===!0)}).catch(()=>{}),()=>{f=!1}},[]);const h=async f=>{l(!0);try{await Ye.setPiSettings({scope:"project",trust:f},{runtimeKey:Is()}),i(!1),t?.()}finally{l(!1)}};return e.jsx(lt,{open:s,onOpenChange:()=>{},children:e.jsxs(ct,{className:"max-w-md",children:[e.jsxs(pt,{children:[e.jsx(ht,{children:"Trust this project?"}),e.jsx(gt,{children:"This project contains Pi settings, skills, prompts, or extensions. Trusting it allows Pi to load those project resources."})]}),e.jsxs(ga,{children:[e.jsx(j,{variant:"ghost",size:"sm",disabled:o,onClick:()=>{h(!1)},children:"Keep untrusted"}),e.jsx(j,{size:"sm",disabled:o,onClick:()=>{h(!0)},children:"Trust project"})]})]})})},xt=({children:t,className:s,outerClassName:i,title:o,titleLeading:l,titleAccessory:h,description:f,headerEnd:u,showSaveStatus:x=!1})=>{const L=o!=null||f!=null||u!=null||x,d=typeof o=="string"||typeof o=="number",T=l!=null||h!=null;return e.jsx(Qs,{outerClassName:ne("h-full",i),className:"w-full @container",children:e.jsxs("div",{className:ne("mx-auto max-w-[840px] space-y-0 px-6 py-5 @3xl:px-10 @3xl:py-7","[&>section:first-of-type]:border-t-0 [&>section:first-of-type]:pt-0",s),children:[L&&e.jsxs("div",{className:"mb-2 flex flex-wrap items-start justify-between gap-x-4 gap-y-3 pb-6",children:[e.jsxs("div",{className:"min-w-0 flex-1 basis-64 space-y-1",children:[o!=null?d?T?e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[l,e.jsx("h1",{className:ne(fn,"min-w-0 truncate"),children:o}),e.jsx("span",{className:"shrink-0",children:h})]}):e.jsx("h1",{className:fn,children:o}):o:null,f!=null?typeof f=="string"||typeof f=="number"?e.jsx("p",{className:go,children:f}):f:null]}),e.jsx("div",{className:"flex shrink-0 flex-wrap items-center justify-end gap-3",children:u})]}),t]})})},_o=()=>{const[t,s]=n.useState(null),[i,o]=n.useState({}),[l,h]=n.useState(null),[f,u]=n.useState(!1),x=n.useCallback(async()=>{const d=await Ye.listResources({runtimeKey:Is()});s(d.agents),o(Object.fromEntries(d.agents.map(T=>[T.id,T.content??""]))),u(!1)},[]);n.useEffect(()=>{x().catch(()=>u(!0))},[x]);const L=async d=>{h(d.id);try{const T=await Ye.updateResource({resourceId:d.id,content:i[d.id]??""},{runtimeKey:Is()});s(T.agents),o(Object.fromEntries(T.agents.map(g=>[g.id,g.content??""]))),E.success("Behavior saved successfully")}catch{E.error("Failed to save behavior")}finally{h(null)}};return e.jsxs(e.Fragment,{children:[e.jsx(fa,{onResolved:()=>{x().catch(()=>u(!0))}}),e.jsxs(xt,{title:"Behavior",description:"Guide how the agent responds.",showSaveStatus:!1,children:[f?e.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:"Unavailable"}):null,(t??[]).map((d,T)=>{const g=i[d.id]??"",U=d.location==="global"?"Global AGENTS.md":`Project ${d.name}`;return e.jsxs(ae,{title:U,divider:T>0,settingsItem:d.location==="global"?"behavior.global-agents":"behavior.project-agents",contentClassName:"space-y-3",children:[e.jsx(Mn,{value:g,onChange:M=>o(G=>({...G,[d.id]:M.target.value})),rows:12,disabled:d.editable!==!0,outerClassName:"min-h-[180px] max-h-[70vh]",className:"w-full font-mono typography-meta bg-transparent"}),d.editable===!0?e.jsx(j,{size:"xs",onClick:()=>{L(d)},disabled:l!==null||g===(d.content??""),children:l===d.id?"Saving...":"Save Changes"}):null]},d.id)})]})]})},Fo=({onItemSelect:t})=>{const s=ps(h=>h.skills),i=ps(h=>h.selectedSkillName),o=ps(h=>h.setSelectedSkill),l=n.useMemo(()=>[...s].sort((h,f)=>h.name.localeCompare(f.name)),[s]);return e.jsxs("div",{className:"flex h-full flex-col bg-background",children:[e.jsxs("div",{className:"border-b px-3 pb-3 pt-4",children:[e.jsx("h2",{className:`${wa} mb-3`,children:"Skills"}),e.jsx("span",{className:"typography-meta text-muted-foreground",children:`Total ${s.length}`})]}),e.jsx(Qs,{outerClassName:"min-h-0 flex-1",className:"space-y-1 px-3 py-2",children:l.length===0?e.jsxs("div",{className:"px-4 py-12 text-center text-muted-foreground",children:[e.jsx(C,{name:"book-open",className:"mx-auto mb-3 size-10 opacity-50"}),e.jsx("p",{className:"typography-ui-label",children:"No skills configured"}),e.jsx("p",{className:"typography-meta mt-1",children:"Use the + button above to create one"})]}):l.map(h=>e.jsxs("button",{type:"button",onClick:()=>{o(h.name),t?.()},className:ne("flex w-full flex-col rounded-md px-2 py-1.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",i===h.name?"bg-interactive-selection":"hover:bg-interactive-hover"),children:[e.jsx("span",{className:"typography-ui-label truncate text-foreground",children:h.name}),h.description?e.jsx("span",{className:"typography-micro truncate text-muted-foreground",children:h.description}):null]},h.id))})]})},Uo=()=>{const t=ps(i=>i.selectedSkillName),s=ps(i=>i.skills.find(o=>o.name===t)??null);return s?e.jsxs(e.Fragment,{children:[e.jsx(fa,{onResolved:()=>{ps.getState().loadSkills()}}),e.jsx(xt,{title:s.name,description:s.description,showSaveStatus:!1,children:e.jsx(ae,{title:"Basic Information",divider:!1,settingsItem:"skills.discovery",children:e.jsx("p",{className:"typography-meta text-muted-foreground",children:s.location==="project"?"Project":"Global"})})})]}):e.jsxs(e.Fragment,{children:[e.jsx(fa,{onResolved:()=>{ps.getState().loadSkills()}}),e.jsx("div",{className:"flex h-full items-center justify-center px-4 text-center text-muted-foreground",children:e.jsxs("div",{children:[e.jsx(C,{name:"book-open",className:"mx-auto mb-3 size-10 opacity-50"}),e.jsx("p",{className:"typography-body",children:"Select a skill from the sidebar"}),e.jsx("p",{className:"typography-meta mt-1",children:"or create a new one"})]})})]})},zo=({header:t,footer:s,children:i,className:o,variant:l="sidebar"})=>{const h=n.useRef(null),[f,u]=n.useState(!1),[x,L]=n.useState(!1),d=l==="background"?"bg-background":"bg-sidebar",T=d==="bg-background"?"var(--surface-background)":"var(--surface-muted)",g=n.useCallback(()=>{const U=h.current;if(!U){u(!1),L(!1);return}if(!(U.scrollHeight>U.clientHeight+1)){u(!1),L(!1);return}u(U.scrollTop>1),L(U.scrollTop+U.clientHeight<U.scrollHeight-1)},[]);return n.useEffect(()=>{g()},[i,g]),n.useEffect(()=>{const U=h.current;if(!U)return;const M=()=>g();return U.addEventListener("scroll",M,{passive:!0}),()=>U.removeEventListener("scroll",M)},[g]),e.jsxs("div",{className:ne("flex h-full flex-col",d,o),children:[t,e.jsxs("div",{className:"relative flex flex-1 min-h-0 flex-col",children:[e.jsx(Qs,{ref:h,outerClassName:"flex-1 min-h-0",className:"space-y-1.5 px-3 py-3 overflow-x-hidden",children:i}),f&&e.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-4",style:{background:`linear-gradient(to bottom, ${T} 0%, transparent 100%)`}}),x&&e.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-6",style:{background:`linear-gradient(to top, ${T} 0%, transparent 100%)`}})]}),s]})},Bo=({title:t,metadata:s,selected:i=!1,onSelect:o,icon:l,actions:h,className:f})=>{const u=h&&h.length>0;return e.jsx("div",{className:ne("group relative flex items-center rounded-lg px-2 py-2 transition-colors duration-150",i?"bg-interactive-selection":"hover:bg-interactive-hover",f),children:e.jsxs("div",{className:"flex min-w-0 flex-1 items-center",children:[e.jsxs("button",{onClick:o,className:"flex min-w-0 flex-1 flex-col gap-0.5 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",tabIndex:0,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[l,e.jsx("span",{className:"typography-ui-label font-normal truncate text-foreground",children:t})]}),s&&e.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:s})]}),u&&e.jsxs(Tn,{children:[e.jsx(In,{asChild:!0,children:e.jsx(j,{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:e.jsx(C,{name:"more-2",className:"h-3.5 w-3.5"})})}),e.jsx(En,{align:"end",className:"w-fit min-w-20",children:h.map(x=>{const L=x.icon;return e.jsxs(An,{onClick:d=>{d.stopPropagation(),x.onClick()},className:ne(x.destructive&&"text-destructive focus:text-destructive"),children:[L&&e.jsx(C,{name:L,className:"h-4 w-4 mr-px"}),x.label]},x.label)})})]})]})})},Ho=({onItemSelect:t})=>{const s=La(h=>h.projects),i=k(h=>h.settingsProjectsSelectedId),o=k(h=>h.setSettingsProjectsSelectedId),l=n.useCallback(()=>{fi.requestDirectoryDialog()},[]);return n.useEffect(()=>{if(s.length===0){i!==null&&o(null);return}i&&s.some(h=>h.id===i)||o(s[0].id)},[s,i,o]),e.jsx(zo,{variant:"background",header:e.jsxs("div",{className:ne("border-b px-3","pt-4 pb-3"),children:[e.jsx("h2",{className:`${wa} mb-3`,children:"Projects"}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"typography-meta text-muted-foreground",children:`Total ${s.length}`}),e.jsx(j,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 -my-1 text-muted-foreground",onClick:l,"aria-label":"Add project",children:e.jsx(C,{name:"add",className:"size-4"})})]})]}),children:s.map(h=>{const f=h.id===i,u=e.jsx(C,{name:"folder",className:ne("h-4 w-4",f?"text-foreground":"text-muted-foreground/70")});return e.jsx(Bo,{title:h.label||h.path,metadata:h.label?h.path:void 0,icon:u,selected:f,onSelect:()=>{o(h.id),t?.()}},h.id)})})},$o=()=>{const t=La(u=>u.projects),s=La(u=>u.updateProjectMeta),i=k(u=>u.settingsProjectsSelectedId),o=k(u=>u.setSettingsProjectsSelectedId),l=n.useMemo(()=>i?t.find(u=>u.id===i)??null:null,[t,i]);n.useEffect(()=>{if(t.length===0){o(null);return}i&&t.some(u=>u.id===i)||o(t[0].id)},[t,i,o]);const h=n.useCallback(async u=>{l&&s(l.id,{label:u.label,defaultModel:u.defaultModel??null})},[l,s]);if(!l)return e.jsx(xt,{title:"Projects",showSaveStatus:!0,children:e.jsx("p",{className:"typography-meta text-muted-foreground",children:"No projects available."})});const f=l.label??"Project Settings";return e.jsx(xt,{title:f,description:l.path,showSaveStatus:!0,outerClassName:"bg-background",children:e.jsx(fo,{project:l,onIdentitySave:h})})};function cr(t,s,i){return Math.min(i,Math.max(s,t))}function Vo(t){if(!Number.isFinite(t))return 0;const s=String(t);if(s.includes("e-")){const[,o]=s.split("e-");return Number(o)||0}const i=s.split(".");return i.length===2?i[1].length:0}function dr(t,s){const i=Vo(s);return i<=0?t:Number(t.toFixed(i))}const kt=le.forwardRef(({value:t,onValueChange:s,min:i=-1/0,max:o=1/0,step:l=1,className:h,containerClassName:f,onBlur:u,disabled:x,fallbackValue:L,onClear:d,emptyLabel:T="—",...g},U)=>{const[M,G]=le.useState(()=>t==null?"":String(t)),{isMobile:I}=ba(),R=le.useRef(!1),$=le.useRef(null),J=le.useCallback(()=>{if(typeof document>"u"||typeof window>"u")return;$.current?.();const S=ge=>{ge.preventDefault(),ge.stopPropagation(),ge.stopImmediatePropagation?.(),$.current?.()},Y=window.setTimeout(()=>{$.current?.()},700),Z=()=>{window.clearTimeout(Y),document.removeEventListener("click",S,!0),$.current=null};$.current=Z,document.addEventListener("click",S,!0)},[]);le.useEffect(()=>()=>{$.current?.()},[]),le.useEffect(()=>{G(t==null?"":String(t))},[t]);const v=le.useMemo(()=>t!==void 0?t:L!==void 0?L:Number.isFinite(i)?i:0,[L,i,t]),w=le.useRef(v);le.useEffect(()=>{w.current=v},[v]);const m=le.useCallback(S=>{const Y=cr(S,i,o),Z=dr(Y,l);w.current=Z,s(Z)},[o,i,s,l]),F=le.useCallback(S=>{const Y=S.target.value;if(G(Y),Y.trim()===""){d?.();return}const Z=Number(Y);Number.isFinite(Z)&&m(Z)},[m,d]),y=le.useCallback(S=>{if(M.trim()===""){d||G(t==null?"":String(t)),u?.(S);return}const Y=Number(M);if(!Number.isFinite(Y))G(t==null?"":String(t));else{const Z=cr(Y,i,o),ge=dr(Z,l);ge!==t?m(Y):w.current=ge,G(String(ge))}u?.(S)},[m,M,o,i,u,d,l,t]),A=!!(x||v>=o),O=!!(x||v<=i),b=()=>{O||m(w.current-l)},B=()=>{A||m(w.current+l)},W=S=>Y=>{Y.preventDefault(),Y.stopPropagation(),R.current=!0,J(),S()},X=S=>Y=>{if(R.current){R.current=!1,Y.preventDefault(),Y.stopPropagation();return}S()};return I?e.jsxs("div",{className:ne("flex h-8 shrink-0 items-stretch overflow-x-hidden overflow-y-hidden rounded-lg border border-border bg-transparent select-none overscroll-contain","[-webkit-user-select:none] [-webkit-touch-callout:none]","disabled:pointer-events-none disabled:opacity-50",f),children:[e.jsx("button",{type:"button","aria-label":"Decrease value",disabled:O,onTouchStart:W(b),onClick:X(b),className:ne("grid h-full min-h-0 w-9 shrink-0 place-items-center overflow-x-hidden overflow-y-hidden border-r border-border p-0 leading-none touch-none","text-muted-foreground","disabled:pointer-events-none disabled:opacity-50",!O&&"active:bg-interactive-hover"),children:e.jsx(C,{name:"subtract",className:"block h-4 w-4"})}),e.jsx("div",{className:ne("flex h-full min-w-0 flex-1 items-center justify-center bg-transparent px-1.5","text-center text-[16px] leading-none text-foreground [font-variant-numeric:tabular-nums]",h),"aria-live":"polite",children:t==null?T:M}),e.jsx("button",{type:"button","aria-label":"Increase value",disabled:A,onTouchStart:W(B),onClick:X(B),className:ne("grid h-full min-h-0 w-9 shrink-0 place-items-center overflow-x-hidden overflow-y-hidden border-l border-border p-0 leading-none touch-none","text-muted-foreground","disabled:pointer-events-none disabled:opacity-50",!A&&"active:bg-interactive-hover"),children:e.jsx(C,{name:"add",className:"block h-4 w-4"})})]}):e.jsxs("div",{className:ne("flex h-8 shrink-0 items-stretch overflow-x-hidden overflow-y-hidden rounded-md border border-border bg-transparent","disabled:pointer-events-none disabled:opacity-50","transition-[background-color,border-color,box-shadow] duration-150 ease-in-out",f),children:[e.jsx("button",{type:"button","aria-label":"Decrease value",disabled:O,onClick:()=>m(w.current-l),className:ne("flex h-full w-7 shrink-0 items-center justify-center overflow-x-hidden overflow-y-hidden border-r border-border p-0 leading-none touch-manipulation","text-muted-foreground hover:bg-interactive-hover hover:text-foreground","disabled:pointer-events-none disabled:opacity-50","transition-colors duration-150 ease-in-out"),children:e.jsx(C,{name:"subtract",className:"block h-3.5 w-3.5"})}),e.jsx("input",{...g,ref:U,type:"text",inputMode:g.inputMode??"numeric",value:M,onChange:F,onBlur:y,disabled:x,spellCheck:!1,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",className:ne("h-full min-w-0 w-10 flex-1 bg-transparent px-1.5 text-center typography-ui-label leading-none text-foreground [font-variant-numeric:tabular-nums]","placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground","appearance-none outline-none [appearance:textfield] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","disabled:pointer-events-none disabled:cursor-not-allowed",h)}),e.jsx("button",{type:"button","aria-label":"Increase value",disabled:A,onClick:()=>m(w.current+l),className:ne("flex h-full w-7 shrink-0 items-center justify-center overflow-x-hidden overflow-y-hidden border-l border-border p-0 leading-none touch-manipulation","text-muted-foreground hover:bg-interactive-hover hover:text-foreground","disabled:pointer-events-none disabled:opacity-50","transition-colors duration-150 ease-in-out"),children:e.jsx(C,{name:"add",className:"block h-3.5 w-3.5"})})]})});kt.displayName="NumberInput";const yn=le.forwardRef(({className:t,...s},i)=>e.jsx(wo,{className:ne("peer inline-flex shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-none transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[checked]:bg-primary data-[unchecked]:bg-[var(--interactive-border)]",t),style:{width:"36px",height:"20px",minWidth:"36px",minHeight:"20px"},...s,ref:i,children:e.jsx(jo,{className:ne("pointer-events-none block rounded-full bg-background shadow-none ring-0 transition-transform data-[checked]:translate-x-4 data-[unchecked]:translate-x-0"),style:{width:"16px",height:"16px",minWidth:"16px",minHeight:"16px"}})}));yn.displayName="Switch";const wn=()=>Math.floor(2e4+Math.random()*3e4),Ko=t=>{const s=(t instanceof Error?t.message:String(t)).toLowerCase();return s.includes("address already in use")||s.includes("eaddrinuse")||s.includes("port already in use")},Wo=()=>{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"},ur=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}},mr=t=>{switch(t){case"config_resolved":return"Resolving configuration";case"auth_check":return"Checking authentication";case"master_connecting":return"Establishing SSH connection";case"remote_probe":return"Checking remote machine";case"installing":return"Installing PiChamber";case"updating":return"Updating PiChamber";case"server_detecting":return"Detecting server";case"server_starting":return"Starting server";case"forwarding":return"Forwarding ports";case"ready":return"Ready";case"degraded":return"Reconnecting";case"error":return"Error";default:return"Idle"}},Go=new Set(["config_resolved","auth_check","master_connecting","remote_probe","installing","updating","server_detecting","server_starting","forwarding"]),ni=t=>!!(t&&Go.has(t)),pr=t=>t==="ready"?"bg-[var(--status-success)] animate-pulse":t==="error"?"bg-[var(--status-error)] animate-pulse":t==="degraded"||ni(t)?"bg-[var(--status-warning)] animate-pulse":"bg-muted-foreground/40",qo=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}`,Qo=()=>({id:`forward-${Date.now()}-${Math.random().toString(16).slice(2)}`,enabled:!0,type:"local",localHost:"127.0.0.1",localPort:wn(),remoteHost:"127.0.0.1",remotePort:80}),Jo=t=>t.trim().replace(/\*/g,"host").replace(/\?/g,"x")||"user@host",Jt=({label:t,hint:s})=>e.jsxs("span",{className:`inline-flex items-center gap-1 ${$e}`,children:[e.jsx("span",{children:t}),e.jsx(Ht,{contentClassName:"max-w-xs",children:s})]}),Yo=t=>{switch(t){case"remote":return"Open a port on the remote machine that connects back to your computer.";case"dynamic":return"Open a local SOCKS proxy through the SSH connection.";default:return"Open a local port that connects to something on the remote machine."}},hr=(t,s)=>{const i=(t||"").trim();return`${!i||i==="127.0.0.1"||i==="::1"?"localhost":i}:${s||0}`},Xo=t=>{const s=(t||"").trim();return!s||s==="0.0.0.0"||s==="::"?"127.0.0.1":s},Zo=t=>{const s=t.match(/^\[(\d{10,})\]\s*(?:\[([A-Z]+)\]\s*)?(.*)$/);if(!s)return t;const i=Number(s[1]),o=Number.isFinite(i)?new Date(i).toISOString():s[1],l=(s[2]||"INFO").toUpperCase(),h=s[3]||"";return`[${o}] [${l}] ${h}`},jn=(t="",s="")=>({id:typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`header-${Date.now()}-${Math.random().toString(16).slice(2)}`,name:t,value:s}),el=t=>t.trim().toLowerCase()==="authorization",on=t=>{const s={};for(const i of t){const o=i.name.trim(),l=i.value.trim();o&&l&&!el(o)&&(s[o]=l)}return Object.keys(s).length>0?s:void 0},tl=t=>Object.entries(t||{}).map(([s,i])=>jn(s,i)),ri=()=>{if(typeof window>"u")return null;const s=va()||window.location.href;try{const i=Number(new URL(s).port||window.location.port);return Number.isFinite(i)&&i>0?i:null}catch{const i=Number(window.location.port);return Number.isFinite(i)&&i>0?i:null}},gr=t=>{try{const s=new URL(t).hostname.toLowerCase();return s==="localhost"||s==="127.0.0.1"||s==="::1"||s==="[::1]"}catch{return!1}},sl=async()=>{const t=Ws(va())||window.location.origin;if(!Ve()||!ya())return t;let s;try{s=await Je("/api/pi/ui-settings",{method:"GET",headers:{Accept:"application/json"}})}catch{return t}if(!s.ok||(await s.json().catch(()=>null))?.desktopLanAccessActive!==!0)return t;const o=await Hr(),l=ri();return!o||!l?t:`http://${o}:${l}`},ln=t=>{const s=t.trim();if(s)try{window.location.assign(s)}catch{window.location.href=s}},al=t=>{const s=t.sshCommand.trim(),i=t.nickname?.trim(),o=t.portForwards.map(l=>({...l,localHost:l.localHost?.trim()||"127.0.0.1",localPort:typeof l.localPort=="number"?Math.max(1,Math.min(65535,Math.round(l.localPort))):void 0,remoteHost:l.remoteHost?.trim(),remotePort:typeof l.remotePort=="number"?Math.max(1,Math.min(65535,Math.round(l.remotePort))):void 0}));return{...t,sshCommand:s,...i?{nickname:i}:{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:o}},nl=()=>{const t=k(r=>r.timeFormatPreference),{clientAuth:s}=_r(),i=Ve(),o=Qe(r=>r.instances),l=Qe(r=>r.statusesById),h=Qe(r=>r.importCandidates),f=Qe(r=>r.isLoading),u=Qe(r=>r.isImportsLoading),x=Qe(r=>r.isSaving),L=Qe(r=>r.error),d=Qe(r=>r.load),T=Qe(r=>r.loadImports),g=Qe(r=>r.refreshStatuses),U=Qe(r=>r.upsertInstance),M=Qe(r=>r.createFromCommand),G=Qe(r=>r.removeInstance),I=Qe(r=>r.connect),R=Qe(r=>r.disconnect),$=Qe(r=>r.retry),J=k(r=>r.settingsRemoteInstancesSelectedId),v=k(r=>r.setSettingsRemoteInstancesSelectedId),w=n.useMemo(()=>J&&o.find(r=>r.id===J)||null,[o,J]),[m,F]=n.useState(null),[y,A]=n.useState(!1),[O,b]=n.useState(!1),[B,W]=n.useState(null),[X,S]=n.useState([]),[Y,Z]=n.useState(null),[ge,be]=n.useState(""),[Te,D]=n.useState(!1),[V,oe]=n.useState({}),[ce,K]=n.useState(!1),[we,Ce]=n.useState(!1),[Xe,Be]=n.useState(()=>Date.now()),[ke,Ue]=n.useState([]),[Ze,it]=n.useState({}),[Ie,St]=n.useState("local"),[Nt,bt]=n.useState(!1),[fe,et]=n.useState(!1),[Ct,te]=n.useState(""),[P,H]=n.useState(""),[he,pe]=n.useState(""),[ye,qe]=n.useState([]),[He,vt]=n.useState(""),[Lt,Ke]=n.useState(null),[gs,yt]=n.useState(!1),[Es,Pt]=n.useState(!1),[wt,jt]=n.useState(null),[$t,fs]=n.useState(""),[Ee,Vt]=n.useState(""),[Tt,As]=n.useState(""),[Xt,Rt]=n.useState([]),[It,xs]=n.useState([]),[Kt,Zt]=n.useState([]),[es,Ms]=n.useState(!1),[bs,Ls]=n.useState(""),[Wt,tt]=n.useState(null),[Dt,ts]=n.useState(null),[Ot,ss]=n.useState(null),[c,_]=n.useState(null),[ee,q]=n.useState(!1),[ue,de]=n.useState(!1),[se,Pe]=n.useState("configure"),[as,Rs]=n.useState(!1),[_t,vs]=n.useState("relay"),[Ft,ys]=n.useState(!0),[st,Ds]=n.useState(null),ns=n.useMemo(()=>It.filter(r=>!!r.revokedAt).length,[It]),[Os,rs]=n.useState(!1),[_s,ja]=n.useState("ssh user@example.com"),[Js,ka]=n.useState("");n.useEffect(()=>{d(),T()},[d,T]);const Sa=n.useCallback(async()=>{bt(!0),Ke(null);try{const r=await Gn();Ue(r.hosts||[]),St(r.defaultHostId||"local")}catch(r){Ke(r instanceof Error?r.message:String(r))}finally{bt(!1)}},[]);n.useEffect(()=>{Sa()},[Sa]);const dt=n.useCallback(async(r,p=Ie)=>{et(!0),Ke(null);try{await qn({hosts:r,defaultHostId:p,initialHostChoiceCompleted:!0}),Ue(r),St(p)}catch(z){Ke(z instanceof Error?z.message:String(z))}finally{et(!1)}},[Ie]),Ua=n.useCallback(async()=>{const r=Qn(P);if(!r){Ke("Invalid URL (must be http/https)");return}const p=r.persistedUrl,Q={id:typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`host-${Date.now()}-${Math.random().toString(16).slice(2)}`,label:Ct.trim()||ia(p),url:p,apiUrl:p,...he.trim()?{clientToken:he.trim()}:{},...on(ye)?{requestHeaders:on(ye)}:{}};await dt([Q,...ke],Ie),te(""),H(""),pe(""),qe([]),yt(!1),r.redeemUrl&&ln(r.redeemUrl)},[Ie,ye,ke,Ct,he,P,dt]),za=n.useCallback(async()=>{const r=Do(He);if(!r){Ke("Invalid PiChamber connection link.");return}const p=await Bi().catch(()=>""),z=JSON.stringify({pairingId:r.pairingId,secret:r.secret,clientLabel:r.label||"PiChamber Desktop",clientKind:"desktop",deviceName:"PiChamber Desktop",devicePlatform:Wo(),...p?{dedupeKey:`desktop:${p}`}:{}}),Q={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:z},Se=async Ne=>{if(!Ne.ok)return null;const mt=await Ne.json().catch(()=>null);return(typeof mt?.clientToken=="string"?mt.clientToken.trim():"")||null},ot=[...r.candidates].sort((Ne,mt)=>(Ne.type==="relay"?1:0)-(mt.type==="relay"?1:0));let a=null;for(const Ne of ot){if(Ne.type==="relay"){const ra=Hi({relayUrl:Ne.relayUrl,serverId:Ne.serverId,hostEncPubJwk:Ne.hostEncPubJwk,...Ne.grant?{grant:Ne.grant}:{}});try{const Ca=await ra.fetch("/api/client-auth/pairing/redeem",Q),Fn=await Se(Ca);if(Fn){a={kind:"relay",relay:{relayUrl:Ne.relayUrl,serverId:Ne.serverId,hostEncPubJwk:Ne.hostEncPubJwk},token:Fn};break}}catch{}finally{ra.close()}continue}const mt=Ws(Ne.url);if(mt)try{const ra=await fetch(`${mt}/api/client-auth/pairing/redeem`,Q),Ca=await Se(ra);if(Ca){a={kind:"direct",url:mt,token:Ca};break}}catch{}}if(!a){Ke("Invalid URL (must be http/https)");return}const re=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`host-${Date.now()}-${Math.random().toString(16).slice(2)}`,We=r.candidates.find(Ne=>Ne.type==="relay"),ze=a.kind==="relay"?a.relay:We?{relayUrl:We.relayUrl,serverId:We.serverId,hostEncPubJwk:We.hostEncPubJwk}:void 0,Ks=r.candidates.filter(Ne=>Ne.type!=="relay").map(Ne=>Ws(Ne.url)).find(Ne=>!!Ne),Ss=a.kind==="direct"?a.url:Ks,{token:aa}=a,xe=Ss||(ze?$i(ze.serverId):null);if(!xe){Ke("Invalid URL (must be http/https)");return}const Me={url:xe,apiUrl:Ss||void 0,clientToken:aa,...ze?{relay:ze}:{}},na=ke.find(Ne=>ze?Ne.relay?.serverId===ze.serverId:!Ne.relay&&Ws(Ne.apiUrl||Ne.url)===xe);if(na){const Ne=ke.map(mt=>mt.id===na.id?{...mt,label:r.label||mt.label,...Me}:mt);await dt(Ne,Ie)}else await dt([{id:re(),label:r.label||ia(xe),...Me},...ke],Ie);vt(""),Ke(null),Pt(!1)},[He,Ie,ke,dt]),Ba=n.useCallback(async r=>{const p=ke.filter(Q=>Q.id!==r);await dt(p,Ie===r?"local":Ie),wt===r&&jt(null)},[Ie,wt,ke,dt]),Ha=n.useCallback(r=>{jt(r.id),fs(r.label),Vt(r.apiUrl||r.url),As(r.clientToken||""),Rt(tl(r.requestHeaders)),Ke(null)},[]),$a=n.useCallback(async()=>{if(!wt)return;const r=Qn(Ee);if(!r){Ke("Invalid URL (must be http/https)");return}const p=r.persistedUrl,z=ke.map(Q=>Q.id===wt?{...Q,label:$t.trim()||ia(p),url:p,apiUrl:p,clientToken:Tt.trim()||void 0,requestHeaders:on(Xt)}:Q);await dt(z,Ie),jt(null),r.redeemUrl&&ln(r.redeemUrl)},[Ie,Xt,$t,Tt,Ee,wt,ke,dt]),Va=n.useCallback(async()=>{const r=_s.trim();if(!r){E.error("SSH command is required");return}const p=`ssh-${Date.now()}-${Math.random().toString(16).slice(2)}`;try{await M(p,r,Js.trim()||"New SSH connection"),v(p),rs(!1),ja("ssh user@example.com"),ka(""),E.success("Instance created")}catch(z){E.error("Failed to create SSH connection",{description:z instanceof Error?z.message:String(z)})}},[M,v,_s,Js]),Ka=n.useCallback(async r=>{await dt(ke,r)},[ke,dt]);n.useEffect(()=>{if(!i||ke.length===0)return;let r=!1;return Promise.all(ke.map(async p=>{const z=()=>Gi(p.relay,{clientToken:p.clientToken||null,requestHeaders:p.requestHeaders||null}).catch(()=>({status:"unreachable",latencyMs:0}));if(p.relay&&!p.apiUrl)return[p.id,await z()];const Q=Ws(Vi(p));if(!Q)return[p.id,p.relay?await z():{status:"unreachable",latencyMs:0}];const Se=await Ki(Q,{clientToken:p.clientToken||null,requestHeaders:p.requestHeaders||null}).catch(()=>({status:"unreachable",latencyMs:0}));if(Se.status==="unreachable"&&p.relay){const ot=await z();if(ot.status==="ok")return[p.id,ot]}return[p.id,Se]})).then(p=>{r||it(Object.fromEntries(p))}),()=>{r=!0}},[ke,i]);const ut=n.useCallback(async r=>{if(s){r?.silent||Ms(!0),r?.silent||tt(null);try{const[p,z]=await Promise.all([s.listClients(),s.listPendingPairings().catch(()=>null)]);xs(p),z&&Zt(z)}catch(p){r?.silent||tt(p instanceof Error?p.message:String(p))}finally{r?.silent||Ms(!1)}}},[s]),Ys=n.useRef(!1);n.useEffect(()=>{if(!(!ue||se!=="result"||!Ot)){if(Kt.some(r=>r.id===Ot)){Ys.current=!0;return}Ys.current&&(ss(null),de(!1),It.some(r=>r.pairingId===Ot)&&E.success("Device connected."))}},[ue,se,Ot,Kt,It]);const Fs=n.useCallback(async r=>{if(s)try{await s.cancelPairing(r),Zt(p=>p.filter(z=>z.id!==r)),await ut({silent:!0})}catch(p){tt(p instanceof Error?p.message:String(p))}},[s,ut]);n.useEffect(()=>{if(!s)return;ut();const r=window.setInterval(()=>{typeof document<"u"&&document.visibilityState!=="visible"||ut({silent:!0})},5e3);return()=>window.clearInterval(r)},[s,ut]);const ws=n.useCallback(async()=>{if(s?.getPairingTransports)try{const Q=await s.getPairingTransports();return{localUrl:Q.local,lanUrl:Q.lan,relayAvailable:Q.relayAvailable}}catch{}const r=ri(),p=r?`http://127.0.0.1:${r}`:gr(window.location.origin)?window.location.origin:null;let z=null;try{const Q=Ws(await sl());z=Q&&!gr(Q)?Q:null}catch{}return{localUrl:p,lanUrl:z,relayAvailable:!0}},[s]),Xs=n.useCallback(async()=>{tt(null),ts(null),_(null),q(!1),ss(null),Pe("configure"),ys(!0),de(!0);const r=await ws();Ds(r),vs(r.relayAvailable?"relay":r.lanUrl?"lan":"local")},[ws]),Zs=n.useCallback(async()=>{if(!(!s?.createPairingSession||!st)){tt(null),Rs(!0);try{const r=bs.trim()||void 0;let p,z,Q=!0;_t==="local"?(p=st.localUrl??void 0,z=!1):_t==="lan"?(p=st.lanUrl??void 0,z=Ft):Ft&&st.lanUrl?(p=st.lanUrl,z=!0):(Q=!1,z=!0);const{pairing:Se,server:ot}=await s.createPairingSession({label:r,allowedClientKinds:["mobile","desktop"],serverUrl:p,includeRelay:z,includeDirect:Q}),a=Lo({pairingId:Se.id,secret:Se.secret,label:ot.label,fingerprint:Se.fingerprint??void 0,expiresAt:Se.expiresAt,candidates:ot.candidates}),re=Ro(a);ts(re),_(await Qr.toDataURL(re,{width:1024,margin:2,errorCorrectionLevel:"L"})),q(!1),Ys.current=!1,ss(Se.id),Pe("result"),await ut({silent:!0})}catch(r){tt(r instanceof Error?r.message:String(r))}finally{Rs(!1)}}},[s,st,_t,Ft,bs,ut]),Us=n.useCallback(()=>{Dt&&en(Dt).then(r=>{r.ok&&(q(!0),window.setTimeout(()=>q(!1),2e3))})},[Dt]),N=n.useCallback(async r=>{if(!s)return;const p=r.clientKind==="desktop-local";tt(null);try{if(await s.revokeClient(r.id),p&&Ve()){const z=await Gn();await qn({hosts:z.hosts,defaultHostId:z.defaultHostId,initialHostChoiceCompleted:z.initialHostChoiceCompleted,localClientToken:null}),xs(Q=>Q.map(Se=>Se.id===r.id?{...Se,revokedAt:new Date().toISOString()}:Se)),Wi({apiBaseUrl:va(),clientToken:null,runtimeKey:"local"});return}await ut()}catch(z){tt(z instanceof Error?z.message:String(z))}},[s,ut]),Na=n.useCallback(async()=>{if(s){tt(null);try{await s.purgeRevokedClients(),await ut()}catch(r){tt(r instanceof Error?r.message:String(r))}}},[s,ut]);n.useEffect(()=>{F(w)},[w]),n.useEffect(()=>{if(!J)return;const r=window.setInterval(()=>{typeof document<"u"&&document.visibilityState!=="visible"||g()},2e3);return()=>{window.clearInterval(r)}},[g,J]),n.useEffect(()=>{let r=null,p=Date.now();const z=()=>{const Se=Date.now();Se-p>=1e3&&(Be(Se),p=Se),r=requestAnimationFrame(z)};(typeof document>"u"||document.visibilityState==="visible")&&(r=requestAnimationFrame(z));const Q=()=>{document.visibilityState==="visible"&&r===null?r=requestAnimationFrame(z):document.visibilityState!=="visible"&&r!==null&&(cancelAnimationFrame(r),r=null)};return document.addEventListener("visibilitychange",Q),()=>{document.removeEventListener("visibilitychange",Q),r!==null&&cancelAnimationFrame(r)}},[]);const at=J?l[J]:null,Ut=at?.phase,js=Ut==="ready",zt=Ut==="degraded",Gt=ni(Ut),is=js||(Gt||zt),ea=at?Math.max(0,Xe-at.updatedAtMs):0,ks=zt&&ea>12e3,Ga=n.useMemo(()=>!m||!w?!1:JSON.stringify(m)!==JSON.stringify(w),[m,w]),Ae=n.useCallback(r=>{F(p=>p&&r(p))},[]),os=n.useCallback(async()=>{if(!m)return;const r=al(m);if(!r.sshCommand.trim()){E.error("SSH command is required");return}if(!(r.localForward.bindHost==="0.0.0.0"&&!window.confirm("Binding to 0.0.0.0 exposes forwarded ports to your local network. Continue?"))){if(r.auth.sshPassword?.enabled&&r.auth.sshPassword.value?.trim()&&r.auth.sshPassword.store!=="settings"){const p=window.confirm("Store SSH password in plaintext on disk?");r.auth.sshPassword.store=p?"settings":"never",p||(r.auth.sshPassword.value=void 0)}if(r.auth.pichamberPassword?.enabled&&r.auth.pichamberPassword.value?.trim()&&r.auth.pichamberPassword.store!=="settings"){const p=window.confirm("Store UI password in plaintext on disk?");r.auth.pichamberPassword.store=p?"settings":"never",p||(r.auth.pichamberPassword.value=void 0)}try{await U(r),E.success("Instance saved")}catch(p){E.error("Failed to save instance",{description:p instanceof Error?p.message:String(p)})}}},[m,U]),Et=n.useCallback(async(r,p)=>{const z=`ssh-${Date.now()}-${Math.random().toString(16).slice(2)}`;try{return await M(z,`ssh ${p}`,r),v(z),E.success("Instance created"),!0}catch(Q){return E.error("Failed to create SSH connection",{description:Q instanceof Error?Q.message:String(Q)}),!1}},[M,v]),At=n.useCallback(()=>{Te||(Z(null),be(""))},[Te]),zs=n.useCallback((r,p)=>{if(p){Z(r),be(Jo(r));return}Et(r,r)},[Et]),Bs=n.useCallback(async()=>{const r=Y,p=ge.trim();if(r){if(!p){E.error("Destination is required");return}D(!0);try{await Et(r,p)&&(Z(null),be(""))}finally{D(!1)}}},[Et,ge,Y]),ls=n.useCallback(async()=>{if(w)try{await I(w.id);return}catch(r){if(!Ko(r)||!window.confirm("Local port is already in use. Pick a random free local port and retry?"))throw r;const z={...w,localForward:{...w.localForward,preferredLocalPort:wn()}};await U(z),await I(z.id),E.success("Retried with a random local port")}},[I,w,U]),Hs=n.useCallback(async r=>(await xi(r,600)).map(z=>Zo(z)),[]),qa=n.useCallback(async()=>{if(m){A(!0),b(!0),W(null);try{const r=await Hs(m.id);S(r)}catch(r){S([]),W(r instanceof Error?r.message:String(r))}finally{b(!1)}}},[m,Hs]);n.useEffect(()=>{if(!y||!m)return;let r=!1;const p=async()=>{try{const Q=await Hs(m.id);r||(S(Q),W(null))}catch(Q){r||W(Q instanceof Error?Q.message:String(Q))}};p();const z=window.setInterval(()=>{typeof document<"u"&&document.visibilityState!=="visible"||p()},1e3);return()=>{r=!0,window.clearInterval(z)}},[m,y,Hs]);const $s=n.useMemo(()=>X.join(`
|
|
2
|
+
`),[X]),Qa=n.useCallback(()=>{if(!$s.trim()){E.error("No logs to copy");return}en($s).then(r=>{r.ok&&E.success("Logs copied")})},[$s]),Ja=n.useCallback(async()=>{if(m)try{await bi(m.id),S([]),E.success("Logs cleared")}catch(r){E.error("Failed to clear logs",{description:r instanceof Error?r.message:String(r)})}},[m]),Ya=n.useCallback(async()=>{if(!at?.localUrl){E.error("Instance URL is unavailable");return}const r=at.localUrl.trim();if(!r){E.error("Instance URL is unavailable");return}ln(r)},[at?.localUrl]),ta=n.useCallback(()=>{if(!m)return;K(!0),(is?R(m.id):ls()).catch(p=>{const z=is?js?"Failed to disconnect instance":"Failed to cancel connection":"Failed to connect instance";E.error(z,{description:p instanceof Error?p.message:String(p)})}).finally(()=>{K(!1)})},[is,ls,R,m,js]),Xa=n.useCallback(()=>{if(!m||Gt)return;Ce(!0),(zt?R(m.id).then(()=>ls()):$(m.id)).catch(p=>{E.error("Failed to retry connection",{description:p instanceof Error?p.message:String(p)})}).finally(()=>{Ce(!1)})},[ls,R,m,Gt,zt,$]),sa=Gt?"Connecting...":zt?ks?"Reconnect now":"Reconnecting...":"Retry",qt=!ce&&!we&&(Ut==="error"||Ut==="idle"||!Ut||zt&&ks)&&!Gt,Vs=js?"Disconnect":is?"Cancel":"Connect";if(!m)return e.jsxs(xt,{title:"Remote Instances",children:[s?e.jsxs(ae,{title:"Connect to this server",info:"Create a secure link or token so PiChamber Desktop can connect to this server.",divider:!1,settingsItem:"remote-instances.client-auth",contentClassName:"space-y-3",children:[e.jsx("div",{children:e.jsxs(j,{type:"button",size:"xs",className:"!font-normal",onClick:()=>{Xs()},children:[e.jsx(C,{name:"add",className:"h-3.5 w-3.5"}),"Add a device"]})}),e.jsxs("div",{className:"space-y-2.5",children:[ns>0?e.jsx("div",{className:"flex justify-end",children:e.jsx(j,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{Na()},children:"Clear revoked"})}):null,es&&It.length===0&&Kt.length===0?e.jsx("p",{className:"typography-meta text-muted-foreground",children:"Loading tokens..."}):It.length===0&&Kt.length===0?e.jsx("p",{className:"typography-meta text-muted-foreground",children:"No devices connected yet."}):e.jsxs(e.Fragment,{children:[Kt.map(r=>e.jsxs("div",{className:"flex items-center justify-between gap-3 py-1.5",children:[e.jsxs("div",{className:"min-w-0 space-y-0.5",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"h-2 w-2 shrink-0 rounded-full bg-[var(--status-warning)] animate-pulse"}),e.jsx("p",{className:"typography-ui-label text-foreground truncate",children:r.label||"Device name — e.g. My iPhone"}),r.usesRelay?e.jsx("span",{className:"typography-micro text-muted-foreground bg-muted px-1 rounded shrink-0 leading-none pb-px border border-border/50",children:"Relay"}):null]}),e.jsx("p",{className:"typography-micro text-muted-foreground truncate",children:"Waiting to connect…"})]}),e.jsx(j,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{Fs(r.id)},children:"Cancel"})]},`pending-${r.id}`)),It.map(r=>{const p=r.clientKind==="desktop-local",z=r.lastUsedAt?Date.parse(r.lastUsedAt):Number.NaN,Q=!r.revokedAt&&(p||Number.isFinite(z)&&Date.now()-z<9e4),Se=r.revokedAt?"Revoked":Q?r.lastTransport==="relay"&&!p?"Connected · Relay":"Connected · Local network":Number.isFinite(z)?`Last used ${vi(z,t,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}`:"Never used";return e.jsxs("div",{className:"flex items-center justify-between gap-3 py-1.5",children:[e.jsx("div",{className:"min-w-0",children:e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5",children:[e.jsx("span",{className:ne("h-2 w-2 shrink-0 rounded-full",r.revokedAt?"bg-muted-foreground/20":Q?"bg-[var(--status-success)]":"bg-muted-foreground/30")}),e.jsx("p",{className:"typography-ui-label text-foreground truncate",children:r.label}),ur(r.devicePlatform)?e.jsx("span",{className:"typography-micro text-muted-foreground bg-muted px-1 rounded shrink-0 leading-none pb-px border border-border/50",children:ur(r.devicePlatform)}):null,p?e.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:"This device"}):null,e.jsx("span",{className:ne("typography-micro truncate",Q&&!r.revokedAt?"text-[var(--status-success)]":"text-muted-foreground"),children:Se})]})}),e.jsx(j,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{N(r)},disabled:!!r.revokedAt,children:"Revoke"})]},r.id)})]})]}),Wt?e.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:Wt}):null]}):null,i?e.jsxs(ae,{title:"Other PiChamber servers",info:"Servers this app can switch to. Import a pairing link from the other server, or add one by address.",settingsItem:"remote-instances.direct-hosts",contentClassName:"space-y-4",headerAction:e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(j,{type:"button",size:"xs",className:"!font-normal",onClick:()=>Pt(!0),disabled:fe,children:"Import Link"}),e.jsxs(j,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>yt(!0),disabled:fe,children:[e.jsx(C,{name:"add",className:"h-3.5 w-3.5"}),"Add Server"]})]}),children:[e.jsx("div",{className:"space-y-2.5",children:Nt?e.jsx("p",{className:"typography-meta text-muted-foreground",children:"Loading instances..."}):ke.length===0?e.jsx("p",{className:"typography-meta text-muted-foreground",children:"No other servers added yet."}):ke.map(r=>{const p=Ze[r.id],z=p?p.status==="ok"?"Connected":p.status==="auth"?"Auth required":p.status==="update-recommended"?"Update recommended":p.status==="incompatible"?"Incompatible":p.status==="wrong-service"?"Wrong service":"Unreachable":"Checking",Q=p?.status==="ok";return e.jsx("div",{className:"py-1.5",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 space-y-0.5",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:ne("h-2 w-2 shrink-0 rounded-full",p?Q?"bg-[var(--status-success)]":"bg-[var(--status-error)]":"bg-muted-foreground/30 animate-pulse")}),e.jsx("p",{className:"typography-ui-label text-foreground truncate",children:ia(r.label)}),Ie===r.id?e.jsx("span",{className:"typography-micro text-muted-foreground shrink-0",children:"Default"}):null,e.jsxs("span",{className:ne("typography-micro shrink-0",Q?"text-[var(--status-success)]":"text-muted-foreground"),children:[z,Q&&typeof p?.latencyMs=="number"?` · ${Math.max(0,Math.round(p.latencyMs))}ms ping`:""]})]}),e.jsx("p",{className:ne("typography-micro text-muted-foreground truncate",r.apiUrl&&"font-mono"),children:r.relay&&!r.apiUrl?"via PiChamber Relay":ia(r.apiUrl||r.url)})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.jsx(j,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{Ka(r.id)},disabled:fe||Ie===r.id,"aria-label":"Set as default",children:Ie===r.id?e.jsx(C,{name:"star-fill",className:"h-3.5 w-3.5"}):e.jsx(C,{name:"star",className:"h-3.5 w-3.5"})}),r.relay&&!r.apiUrl?null:e.jsxs(j,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>Ha(r),disabled:fe,children:[e.jsx(C,{name:"pencil",className:"h-3.5 w-3.5"}),"Edit"]}),e.jsxs(j,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{Ba(r.id)},disabled:fe,children:[e.jsx(C,{name:"delete-bin",className:"h-3.5 w-3.5"}),"Delete"]})]})]})},r.id)})}),Lt?e.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:Lt}):null]}):null,i?e.jsx(lt,{open:gs,onOpenChange:yt,children:e.jsxs(ct,{className:"sm:max-w-lg",children:[e.jsxs(pt,{children:[e.jsx(ht,{children:"Add Server"}),e.jsx(gt,{children:"Add another PiChamber server by URL. Use this when the server is already running and you have a connection token."})]}),e.jsxs("form",{className:"space-y-3",onSubmit:r=>{r.preventDefault(),Ua()},children:[e.jsx(ie,{className:"h-8",value:Ct,onChange:r=>te(r.target.value),placeholder:"Label (optional)",disabled:fe}),e.jsx(ie,{className:"h-8",value:P,onChange:r=>H(r.target.value),placeholder:"https://host:port",disabled:fe,autoFocus:!0}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(ie,{className:"h-8",value:he,onChange:r=>pe(r.target.value),placeholder:"Connection token (optional for trusted local servers)",type:"password",disabled:fe}),e.jsx("p",{className:"px-1 typography-micro text-muted-foreground",children:"Connection tokens are saved on this device and used only when this app connects to that server."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Ra,{children:"Additional headers"}),e.jsx(Ht,{children:"Optional HTTP headers for desktop API requests. Authorization is reserved for the connection token."})]}),ye.map(r=>e.jsxs("div",{className:"flex w-full gap-2",children:[e.jsx(ie,{className:"h-8 font-mono text-xs",value:r.name,onChange:p=>qe(z=>z.map(Q=>Q.id===r.id?{...Q,name:p.target.value}:Q)),placeholder:"Header name",disabled:fe}),e.jsx(ie,{className:"h-8 font-mono text-xs",value:r.value,onChange:p=>qe(z=>z.map(Q=>Q.id===r.id?{...Q,value:p.target.value}:Q)),placeholder:"Header value",type:"password",disabled:fe}),e.jsx("button",{type:"button",onClick:()=>qe(p=>p.filter(z=>z.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":"Remove header",disabled:fe,children:e.jsx(C,{name:"close",className:"h-4 w-4"})})]},r.id)),e.jsxs(j,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>qe(r=>[...r,jn()]),disabled:fe,children:[e.jsx(C,{name:"add",className:"h-3.5 w-3.5"}),"Add header"]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(j,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>yt(!1),disabled:fe,children:"Cancel"}),e.jsx(j,{type:"submit",size:"xs",className:"!font-normal",disabled:fe||!P.trim(),children:"Add Server"})]})]})]})}):null,i?e.jsx(lt,{open:!!wt,onOpenChange:r=>{r||jt(null)},children:e.jsxs(ct,{className:"sm:max-w-lg",children:[e.jsxs(pt,{children:[e.jsx(ht,{children:"Edit"}),e.jsx(gt,{children:"Servers this app can switch to. Import a pairing link from the other server, or add one by address."})]}),e.jsxs("form",{className:"space-y-3",onSubmit:r=>{r.preventDefault(),$a()},children:[e.jsx(ie,{className:"h-8",value:$t,onChange:r=>fs(r.target.value),placeholder:"Label (optional)",disabled:fe}),e.jsx(ie,{className:"h-8",value:Ee,onChange:r=>Vt(r.target.value),placeholder:"https://host:port",disabled:fe,autoFocus:!0}),e.jsx(ie,{className:"h-8",value:Tt,onChange:r=>As(r.target.value),placeholder:"Connection token (optional for trusted local servers)",type:"password",disabled:fe}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Ra,{children:"Additional headers"}),e.jsx(Ht,{children:"Optional HTTP headers for desktop API requests. Authorization is reserved for the connection token."})]}),Xt.map(r=>e.jsxs("div",{className:"flex w-full gap-2",children:[e.jsx(ie,{className:"h-8 font-mono text-xs",value:r.name,onChange:p=>Rt(z=>z.map(Q=>Q.id===r.id?{...Q,name:p.target.value}:Q)),placeholder:"Header name",disabled:fe}),e.jsx(ie,{className:"h-8 font-mono text-xs",value:r.value,onChange:p=>Rt(z=>z.map(Q=>Q.id===r.id?{...Q,value:p.target.value}:Q)),placeholder:"Header value",type:"password",disabled:fe}),e.jsx("button",{type:"button",onClick:()=>Rt(p=>p.filter(z=>z.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":"Remove header",disabled:fe,children:e.jsx(C,{name:"close",className:"h-4 w-4"})})]},r.id)),e.jsxs(j,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>Rt(r=>[...r,jn()]),disabled:fe,children:[e.jsx(C,{name:"add",className:"h-3.5 w-3.5"}),"Add header"]})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(j,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>jt(null),disabled:fe,children:"Cancel"}),e.jsx(j,{type:"submit",size:"xs",className:"!font-normal",disabled:fe,children:"Save Changes"})]})]})]})}):null,i?e.jsx(lt,{open:Es,onOpenChange:Pt,children:e.jsxs(ct,{className:"sm:max-w-lg",children:[e.jsxs(pt,{children:[e.jsx(ht,{children:"Import Link"}),e.jsx(gt,{children:"Paste a connection link from another PiChamber server."})]}),e.jsxs("form",{className:"space-y-3",onSubmit:r=>{r.preventDefault(),za()},children:[e.jsx(ie,{className:"h-8",value:He,onChange:r=>vt(r.target.value),placeholder:"pichamber://connect?...",disabled:fe,autoFocus:!0}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(j,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>Pt(!1),disabled:fe,children:"Cancel"}),e.jsx(j,{type:"submit",size:"xs",className:"!font-normal",disabled:fe||!He.trim(),children:"Import Link"})]})]})]})}):null,e.jsx(lt,{open:ue,onOpenChange:de,children:e.jsxs(ct,{className:se==="result"?"sm:max-w-lg":"sm:max-w-md",children:[e.jsxs(pt,{children:[e.jsx(ht,{children:se==="result"?"Scan to connect":"Add a device"}),e.jsx(gt,{children:se==="result"?"Scan this with the PiChamber app on your other device. It is single-use and expires.":"Create a one-time QR code that connects another device to this server."})]}),se==="configure"?e.jsxs("form",{className:"space-y-4",onSubmit:r=>{r.preventDefault(),Zs()},children:[e.jsx(ie,{className:"h-8",value:bs,onChange:r=>Ls(r.target.value),placeholder:"Device name — e.g. My iPhone",autoFocus:!0}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"typography-ui-label text-foreground",children:"Where will you use this device?"}),e.jsx("div",{role:"radiogroup","aria-label":"Where will you use this device?",className:"space-y-1.5",children:[{key:"relay",label:"Anywhere",hint:"Works at home and away. Away traffic goes through PiChamber Private Relay — an end-to-end encrypted tunnel. No setup needed.",available:!!st?.relayAvailable},{key:"lan",label:"Home network only",hint:"Connects directly over your Wi-Fi. Does not work away from this network.",available:!!st?.lanUrl},{key:"local",label:"This computer only",hint:"For apps running on this same machine.",available:!!st?.localUrl}].map(r=>{const p=_t===r.key;return e.jsxs("div",{className:ne("flex items-start gap-2 py-0.5",r.available?"cursor-pointer":"opacity-45"),onClick:()=>{r.available&&vs(r.key)},role:"presentation",children:[e.jsx(xo,{checked:p,disabled:!r.available,onChange:()=>vs(r.key),ariaLabel:r.label,className:"mt-0.5"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:ne("typography-ui-label font-normal",p?"text-foreground":"text-foreground/70"),children:r.label}),e.jsx("p",{className:"typography-meta text-muted-foreground",children:r.hint})]})]},r.key)})}),_t==="lan"?e.jsxs("label",{className:"flex w-fit cursor-pointer items-center gap-2 pt-1",children:[e.jsx(Un,{checked:Ft,onChange:ys,ariaLabel:"Also allow the encrypted relay when away from home"}),e.jsx("span",{className:"typography-meta text-muted-foreground",children:"Also allow the encrypted relay when away from home"})]}):null,_t==="relay"&&st?.lanUrl?e.jsxs("label",{className:"flex w-fit cursor-pointer items-center gap-2 pt-1",children:[e.jsx(Un,{checked:Ft,onChange:ys,ariaLabel:"Prefer the direct home connection when available"}),e.jsx("span",{className:"typography-meta text-muted-foreground",children:"Prefer the direct home connection when available"})]}):null]}),Wt?e.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:Wt}):null,e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(j,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>de(!1),disabled:as,children:"Cancel"}),e.jsx(j,{type:"submit",size:"xs",className:"!font-normal",disabled:as||!st,children:"Create QR code"})]})]}):e.jsxs("div",{className:"space-y-3",children:[c?e.jsx("div",{className:"flex justify-center",children:e.jsx("img",{src:c,alt:"PiChamber connection QR code",className:"w-full max-w-[420px] rounded-md bg-white p-4"})}):null,Dt?e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-[var(--interactive-border)] p-2",children:[e.jsx("code",{className:"min-w-0 flex-1 truncate typography-code text-muted-foreground",children:Dt}),e.jsxs(j,{type:"button",variant:"outline",size:"xs",className:"!font-normal shrink-0",onClick:Us,children:[e.jsx(C,{name:ee?"check":"file-copy",className:ne("h-3.5 w-3.5",ee&&"text-[var(--status-success)]")}),ee?"Copied":"Copy all"]})]}):null,e.jsx("div",{className:"flex justify-end",children:e.jsx(j,{type:"button",size:"xs",className:"!font-normal",onClick:()=>de(!1),children:"Done"})})]})]})}),i?e.jsx(ae,{title:"Remote Instances",description:`Total ${o.length}`,headerAction:e.jsxs(j,{type:"button",size:"xs",className:"!font-normal",onClick:()=>rs(!0),children:[e.jsx(C,{name:"add",className:"h-3.5 w-3.5"}),"Add SSH connection"]}),contentClassName:"space-y-2.5",children:f?e.jsx("p",{className:"typography-meta text-muted-foreground",children:"Loading SSH hosts..."}):o.length===0?e.jsx("p",{className:"typography-meta text-muted-foreground",children:"No SSH hosts found."}):o.map(r=>{const p=l[r.id],z=r.nickname?.trim()||r.sshParsed?.destination||r.id,Q=p?.phase,Se=Q==="ready";return e.jsxs("div",{className:"flex items-center justify-between gap-3 py-1.5",children:[e.jsxs("div",{className:"min-w-0 space-y-0.5",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:`h-2 w-2 rounded-full ${pr(Q)}`}),e.jsx("p",{className:"typography-ui-label text-foreground truncate",children:z})]}),e.jsxs("p",{className:"typography-micro text-muted-foreground truncate",children:[mr(Q),p?.localUrl?` · ${p.localUrl}`:""]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[e.jsxs(j,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{(Se?R(r.id):I(r.id)).catch(a=>E.error(Se?"Failed to disconnect instance":"Failed to connect instance",{description:a instanceof Error?a.message:String(a)}))},children:[Se?e.jsx(C,{name:"stop",className:"h-3.5 w-3.5"}):e.jsx(C,{name:"plug-2",className:"h-3.5 w-3.5"}),Se?"Disconnect":"Connect"]}),e.jsxs(j,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>v(r.id),children:[e.jsx(C,{name:"pencil",className:"h-3.5 w-3.5"}),"Edit"]}),e.jsxs(j,{type:"button",variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{window.confirm("Remove this remote instance?")&&G(r.id).catch(a=>E.error("Failed to remove instance",{description:a instanceof Error?a.message:String(a)}))},children:[e.jsx(C,{name:"delete-bin",className:"h-3.5 w-3.5"}),"Delete"]})]})]},r.id)})}):null,i?e.jsx(lt,{open:Os,onOpenChange:rs,children:e.jsxs(ct,{className:"sm:max-w-lg",children:[e.jsxs(pt,{children:[e.jsx(ht,{children:"Add SSH connection"}),e.jsx(gt,{children:"Choose the SSH command and a display name for this connection."})]}),e.jsxs("form",{className:"space-y-3",onSubmit:r=>{r.preventDefault(),Va()},children:[e.jsx(ie,{className:"h-8",value:Js,onChange:r=>ka(r.target.value),placeholder:"Work laptop",disabled:x}),e.jsx(ie,{className:"h-8",value:_s,onChange:r=>ja(r.target.value),placeholder:"ssh user@host",disabled:x,autoFocus:!0}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(j,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>rs(!1),disabled:x,children:"Cancel"}),e.jsx(j,{type:"submit",size:"xs",className:"!font-normal",disabled:x||!_s.trim(),children:"Create"})]})]})]})}):null,i?e.jsx(ae,{title:"Saved SSH hosts",children:u?e.jsx("p",{className:"typography-meta text-muted-foreground",children:"Loading SSH hosts..."}):h.length===0?e.jsx("p",{className:"typography-meta text-muted-foreground",children:"No SSH hosts found."}):e.jsx("div",{children:h.map(r=>e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-[var(--surface-subtle)] py-3 last:border-b-0",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"typography-ui-label font-medium text-foreground truncate",children:[r.host,r.pattern?" (pattern)":""]}),e.jsx("div",{className:"typography-meta text-muted-foreground truncate",children:r.sshCommand})]}),e.jsx(j,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{zs(r.host,r.pattern)},children:"Import"})]},`${r.source}:${r.host}`))})}):null,e.jsx(lt,{open:!!Y,onOpenChange:r=>{r||At()},children:e.jsxs(ct,{className:"sm:max-w-md",children:[e.jsxs(pt,{children:[e.jsx(ht,{children:"Choose an SSH destination"}),e.jsx(gt,{children:Y?`${Y} requires a concrete destination.`:"Enter destination."})]}),e.jsxs("form",{className:"space-y-3",onSubmit:r=>{r.preventDefault(),Bs()},children:[e.jsx(ie,{value:ge,onChange:r=>be(r.target.value),placeholder:"user@host",autoFocus:!0}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(j,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:At,disabled:Te,children:"Cancel"}),e.jsx(j,{type:"submit",size:"xs",className:"!font-normal",disabled:Te,children:"Create"})]})]})]})})]});const Qt=m.remoteOpenchamber.mode==="managed",Za=m.nickname?.trim()||m.sshParsed?.destination||m.id;return e.jsx(lt,{open:!!m,onOpenChange:r=>{r||v(null)},children:e.jsxs(ct,{className:"sm:max-w-4xl max-h-[90vh] overflow-auto",children:[e.jsxs("div",{className:"mb-6 px-1",children:[e.jsx("h1",{className:`${fn} truncate`,children:Za}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2 typography-meta text-muted-foreground",children:[e.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${pr(Ut)}`}),e.jsx("span",{children:mr(Ut)}),at?.localUrl?e.jsx("span",{className:"font-mono text-foreground/80",children:at.localUrl}):null,ks?e.jsx("span",{children:"Reconnection looks stuck. You can retry now."}):null]})]}),e.jsxs(ae,{title:"Actions",info:"Connect, reconnect, view logs, or remove this connection.",divider:!1,contentClassName:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(j,{type:"button",variant:is?"outline":"default",size:"xs",className:"!font-normal",onClick:ta,disabled:ce||we,children:[is?e.jsx(C,{name:"stop",className:"h-3.5 w-3.5"}):e.jsx(C,{name:"plug-2",className:"h-3.5 w-3.5"}),Vs]}),e.jsxs(j,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:Xa,disabled:!qt,children:[e.jsx(C,{name:"refresh",className:`h-3.5 w-3.5 ${Gt||zt&&!ks?"animate-spin":""}`}),sa]}),e.jsxs(j,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{qa()},children:[e.jsx(C,{name:"terminal-window",className:"h-3.5 w-3.5"}),"SSH Logs"]}),e.jsxs(j,{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("Remove this remote instance?")&&G(m.id).then(()=>{v(null),E.success("Instance removed")}).catch(p=>{E.error("Failed to remove instance",{description:p instanceof Error?p.message:String(p)})})},children:[e.jsx(C,{name:"delete-bin",className:"h-3.5 w-3.5"}),"Remove"]})]}),at?.localUrl?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 typography-meta text-muted-foreground",children:[e.jsx("span",{children:"Current local URL:"}),e.jsx("span",{className:"font-mono text-foreground/90",children:at.localUrl})]}):null]}),e.jsxs(ae,{title:"Instance",info:"Choose the SSH command and a display name for this connection.",contentClassName:"space-y-3",children:[e.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[e.jsx("span",{className:"typography-ui-label text-foreground w-56 shrink-0",children:"SSH command"}),e.jsx(ie,{className:"h-7 md:max-w-xl",value:m.sshCommand,onChange:r=>Ae(p=>({...p,sshCommand:r.target.value})),placeholder:"ssh user@host"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[e.jsx("span",{className:"typography-ui-label text-foreground w-56 shrink-0",children:"Nickname"}),e.jsx(ie,{className:"h-7 md:max-w-sm",value:m.nickname||"",onChange:r=>Ae(p=>({...p,nickname:r.target.value})),placeholder:"Work laptop"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[e.jsx("span",{className:"typography-ui-label text-foreground w-56 shrink-0",children:"Connection timeout (seconds)"}),e.jsx(kt,{containerClassName:"w-fit",min:5,max:240,step:1,className:"w-16 tabular-nums",value:m.connectionTimeoutSec,onValueChange:r=>{Ae(p=>({...p,connectionTimeoutSec:Number.isFinite(r)?r:p.connectionTimeoutSec}))}})]})]}),e.jsxs(ae,{title:"PiChamber on the remote machine",info:"Choose how PiChamber should run after SSH connects.",contentClassName:"space-y-3",children:[e.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[e.jsx("div",{className:"w-56 shrink-0",children:e.jsx(Jt,{label:"Mode",hint:"Choose whether PiChamber should start the server for you, or connect to one that is already running."})}),e.jsxs(Re,{value:m.remoteOpenchamber.mode,onValueChange:r=>Ae(p=>({...p,remoteOpenchamber:{...p.remoteOpenchamber,mode:r==="external"?"external":"managed"}})),children:[e.jsx(De,{size:Fe,className:"w-fit min-w-[140px]",children:e.jsx(Oe,{placeholder:"Select mode"})}),e.jsxs(_e,{children:[e.jsx(je,{value:"managed",children:"Start it for me"}),e.jsx(je,{value:"external",children:"Already running"})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[e.jsx("div",{className:"w-56 shrink-0",children:e.jsx(Jt,{label:"Preferred remote port",hint:"Port to use on the remote machine. Leave empty to choose one automatically."})}),e.jsx(kt,{containerClassName:"w-fit",min:1,max:65535,step:1,className:"w-20 tabular-nums",value:m.remoteOpenchamber.preferredPort,onValueChange:r=>{Ae(p=>({...p,remoteOpenchamber:{...p.remoteOpenchamber,preferredPort:Number.isFinite(r)&&r>0?r:void 0}}))},onClear:()=>{Ae(r=>({...r,remoteOpenchamber:{...r.remoteOpenchamber,preferredPort:void 0}}))},emptyLabel:"Auto"})]}),Qt?e.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[e.jsx("div",{className:"w-56 shrink-0",children:e.jsx(Jt,{label:"Install method",hint:"How PiChamber should be placed on the remote machine when this app starts it for you."})}),e.jsxs(Re,{value:m.remoteOpenchamber.installMethod,onValueChange:r=>Ae(p=>({...p,remoteOpenchamber:{...p.remoteOpenchamber,installMethod:r==="npm"||r==="download_release"||r==="upload_bundle"?r:"bun"}})),children:[e.jsx(De,{size:Fe,className:"w-fit min-w-[140px]",children:e.jsx(Oe,{placeholder:"Select install method"})}),e.jsxs(_e,{children:[e.jsx(je,{value:"bun",children:"bun"}),e.jsx(je,{value:"npm",children:"npm"}),e.jsx(je,{value:"download_release",children:"Download release"}),e.jsx(je,{value:"upload_bundle",children:"Upload bundle"})]})]})]}):null,Qt?e.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[e.jsx("div",{className:"w-56 shrink-0",children:e.jsx(Jt,{label:"Keep server running",hint:"Keep PiChamber running on the remote machine after you disconnect."})}),e.jsx("div",{className:"flex w-full items-center gap-2 md:max-w-xs",children:e.jsx(yn,{checked:m.remoteOpenchamber.keepRunning,onCheckedChange:r=>Ae(p=>({...p,remoteOpenchamber:{...p.remoteOpenchamber,keepRunning:r}}))})})]}):null]}),e.jsxs(ae,{title:"Local access",info:"Choose the local address used to open this remote PiChamber server.",contentClassName:"space-y-3",children:[e.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[e.jsx("div",{className:"w-56 shrink-0",children:e.jsx(Jt,{label:"Bind host",hint:"Where the local connection should listen. Use 127.0.0.1 or localhost unless you need LAN access."})}),e.jsxs(Re,{value:m.localForward.bindHost,onValueChange:r=>{r==="0.0.0.0"&&!window.confirm("Binding to 0.0.0.0 exposes forwarded ports to your local network. Continue?")||Ae(p=>({...p,localForward:{...p.localForward,bindHost:r==="localhost"||r==="0.0.0.0"?r:"127.0.0.1"}}))},children:[e.jsx(De,{size:Fe,className:"w-fit min-w-[140px]",children:e.jsx(Oe,{placeholder:"Select bind host"})}),e.jsxs(_e,{children:[e.jsx(je,{value:"127.0.0.1",children:"127.0.0.1"}),e.jsx(je,{value:"localhost",children:"localhost"}),e.jsx(je,{value:"0.0.0.0",children:"0.0.0.0"})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[e.jsx("div",{className:"w-56 shrink-0",children:e.jsx(Jt,{label:"Preferred local port",hint:"Local port to open for this connection. Leave empty to choose one automatically."})}),e.jsxs("div",{className:"flex w-full items-center gap-2 md:max-w-sm",children:[e.jsx(kt,{containerClassName:"w-fit",min:1,max:65535,step:1,className:"w-20 tabular-nums",value:m.localForward.preferredLocalPort,onValueChange:r=>{Ae(p=>({...p,localForward:{...p.localForward,preferredLocalPort:Number.isFinite(r)&&r>0?r:void 0}}))},onClear:()=>{Ae(r=>({...r,localForward:{...r.localForward,preferredLocalPort:void 0}}))},emptyLabel:"Auto"}),e.jsx(j,{type:"button",variant:"outline",size:"xs",className:"!font-normal h-7 w-7 px-0",title:"Pick random port",onClick:()=>Ae(r=>({...r,localForward:{...r.localForward,preferredLocalPort:wn()}})),children:e.jsx(C,{name:"shuffle",className:"h-3.5 w-3.5"})})]})]})]}),e.jsxs(ae,{title:"Authentication",info:"Optional credentials for SSH and the remote PiChamber UI.",contentClassName:"space-y-3",children:[e.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[e.jsx("span",{className:"typography-ui-label text-foreground w-56 shrink-0",children:"SSH password (optional)"}),e.jsx(ie,{className:"h-7 md:max-w-sm",type:"password",value:m.auth.sshPassword?.value||"",onChange:r=>Ae(p=>({...p,auth:{...p.auth,sshPassword:{enabled:r.target.value.trim().length>0,value:r.target.value,store:p.auth.sshPassword?.store||"never"}}})),placeholder:"Enter SSH password"})]}),e.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[e.jsx("span",{className:"typography-ui-label text-foreground w-56 shrink-0",children:"UI password (optional)"}),e.jsx(ie,{className:"h-7 md:max-w-sm",type:"password",value:m.auth.pichamberPassword?.value||"",onChange:r=>Ae(p=>({...p,auth:{...p.auth,pichamberPassword:{enabled:r.target.value.trim().length>0,value:r.target.value,store:p.auth.pichamberPassword?.store||"never"}}})),placeholder:"Enter UI password"})]})]}),e.jsxs(ae,{title:"Port Forwards",info:"Optional extra ports to make available through this SSH connection.",contentClassName:"space-y-2",children:[m.portForwards.length===0?e.jsx("p",{className:"typography-micro text-muted-foreground/80",children:"No extra port forwards configured."}):null,m.portForwards.map((r,p)=>{const z=xe=>{Ae(Me=>({...Me,portForwards:Me.portForwards.map((na,Ne)=>Ne===p?xe(na):na)}))},Q=r.type==="remote"?"Local target":"Local listen",Se=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.",ot=r.type==="remote"?"Remote listen":"Remote target",a=r.type==="remote"?"Remote host and port where SSH creates the -R listener.":"Remote host and port that receives traffic from local -L listener.",re=hr(r.localHost||"localhost",r.localPort),We=hr(r.remoteHost||"localhost",r.remotePort),ze=r.type==="local"&&typeof r.localPort=="number"&&r.localPort>0,Ks=ze?`http://${Xo(r.localHost)}:${r.localPort}`:"",Ss=!!V[r.id],aa=r.type==="local"?"Local (-L)":r.type==="remote"?"Remote (-R)":"Dynamic (-D)";return e.jsxs(Jr,{open:Ss,onOpenChange:xe=>{oe(Me=>({...Me,[r.id]:xe}))},className:`${p>0?"border-t border-[var(--surface-subtle)]":""} py-2`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:"min-w-0 flex items-center gap-2",children:e.jsxs(Yr,{className:"flex items-center gap-2 group",children:[e.jsx(C,{name:"arrow-down-s",className:`h-4 w-4 text-muted-foreground transition-transform ${Ss?"rotate-180":""}`}),e.jsx("span",{className:"typography-ui-label text-foreground truncate",children:qo(r)}),e.jsx("span",{className:"typography-micro text-muted-foreground/70 shrink-0",children:aa})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(yn,{checked:r.enabled,onCheckedChange:xe=>z(Me=>({...Me,enabled:xe})),"aria-label":"Enable forward"}),e.jsx(j,{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:()=>Ae(xe=>({...xe,portForwards:xe.portForwards.filter(Me=>Me.id!==r.id)})),children:e.jsx(C,{name:"delete-bin",className:"h-3.5 w-3.5"})})]})]}),e.jsx(Xr,{className:"pt-2",children:e.jsxs("div",{className:"space-y-0 pb-2",children:[e.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[e.jsx("div",{className:"w-56 shrink-0",children:e.jsx(Jt,{label:"Forward type",hint:e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{children:"Choose what kind of port access this SSH connection should provide."}),e.jsx("p",{children:Yo(r.type)})]})})}),e.jsxs(Re,{value:r.type,onValueChange:xe=>z(Me=>({...Me,type:xe==="dynamic"||xe==="remote"?xe:"local"})),children:[e.jsx(De,{size:Fe,className:"w-fit min-w-[140px]",children:e.jsx(Oe,{placeholder:"Type"})}),e.jsxs(_e,{children:[e.jsx(je,{value:"local",children:"Local (-L)"}),e.jsx(je,{value:"remote",children:"Remote (-R)"}),e.jsx(je,{value:"dynamic",children:"Dynamic (-D)"})]})]})]}),e.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[e.jsx("div",{className:"w-56 shrink-0",children:e.jsx(Jt,{label:Q,hint:Se})}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(ie,{className:"h-7 w-32",value:r.localHost||"127.0.0.1",onChange:xe=>z(Me=>({...Me,localHost:xe.target.value})),placeholder:"127.0.0.1"}),e.jsx("span",{className:"text-muted-foreground",children:":"}),e.jsx(kt,{containerClassName:"w-fit",min:1,max:65535,step:1,className:"w-16 tabular-nums",value:r.localPort,onValueChange:xe=>{z(Me=>({...Me,localPort:Number.isFinite(xe)&&xe>0?xe:void 0}))},onClear:()=>{z(xe=>({...xe,localPort:void 0}))},emptyLabel:"Auto"})]})]}),r.type!=="dynamic"?e.jsxs("div",{className:"flex flex-col gap-1.5 py-1.5 md:flex-row md:items-center md:gap-8",children:[e.jsx("div",{className:"w-56 shrink-0",children:e.jsx(Jt,{label:ot,hint:a})}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(ie,{className:"h-7 w-32",value:r.remoteHost||"",onChange:xe=>z(Me=>({...Me,remoteHost:xe.target.value})),placeholder:"127.0.0.1"}),e.jsx("span",{className:"text-muted-foreground",children:":"}),e.jsx(kt,{containerClassName:"w-fit",min:1,max:65535,step:1,className:"w-16 tabular-nums",value:r.remotePort,onValueChange:xe=>{z(Me=>({...Me,remotePort:Number.isFinite(xe)&&xe>0?xe:void 0}))},onClear:()=>{z(xe=>({...xe,remotePort:void 0}))},emptyLabel:"Auto"})]})]}):null,e.jsxs("div",{className:"mt-2 flex flex-wrap items-center justify-between gap-2 rounded-md bg-[var(--surface-subtle)] p-2",children:[e.jsx("div",{className:"flex flex-wrap items-center gap-1 typography-micro text-muted-foreground/80",children:r.type==="dynamic"?e.jsxs(e.Fragment,{children:[e.jsx(C,{name:"computer",className:"h-3.5 w-3.5"}),e.jsx("span",{className:"font-mono text-foreground",children:re}),e.jsx("span",{children:"(local SOCKS5)"})]}):r.type==="remote"?e.jsxs(e.Fragment,{children:[e.jsx(C,{name:"server",className:"h-3.5 w-3.5"}),e.jsx("span",{className:"font-mono text-foreground",children:We}),e.jsx("span",{children:"(remote)"}),e.jsx(C,{name:"arrow-right",className:"h-3.5 w-3.5"}),e.jsx(C,{name:"computer",className:"h-3.5 w-3.5"}),e.jsx("span",{className:"font-mono text-foreground",children:re}),e.jsx("span",{children:"(local)"})]}):e.jsxs(e.Fragment,{children:[e.jsx(C,{name:"computer",className:"h-3.5 w-3.5"}),e.jsx("span",{className:"font-mono text-foreground",children:re}),e.jsx("span",{children:"(local)"}),e.jsx(C,{name:"arrow-right",className:"h-3.5 w-3.5"}),e.jsx(C,{name:"server",className:"h-3.5 w-3.5"}),e.jsx("span",{className:"font-mono text-foreground",children:We}),e.jsx("span",{children:"(remote)"})]})}),ze?e.jsxs(j,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Pn(Ks).then(xe=>{xe||E.error("Failed to open local address")})},children:[e.jsx(C,{name:"external-link",className:"h-3.5 w-3.5"}),"Open local"]}):null]})]})})]},r.id)}),e.jsxs(j,{type:"button",variant:"outline",size:"xs",className:"!font-normal mt-1",onClick:()=>{const r=Qo();Ae(p=>({...p,portForwards:[...p.portForwards,r]})),oe(p=>({...p,[r.id]:!0}))},children:[e.jsx(C,{name:"add",className:"h-3.5 w-3.5"}),"Add forward"]})]}),e.jsx("div",{className:"mt-8 border-t border-[var(--interactive-border)] pt-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(j,{type:"button",size:"xs",className:"!font-normal",onClick:()=>{os()},disabled:!Ga||x,children:"Save Changes"}),at?.localUrl?e.jsxs(e.Fragment,{children:[e.jsxs(j,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{en(at.localUrl||"").then(r=>{r.ok&&E.success("Local URL copied")})},children:[e.jsx(C,{name:"file-copy",className:"h-3.5 w-3.5"}),"Copy local URL"]}),e.jsxs(j,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Ya()},children:[e.jsx(C,{name:"external-link",className:"h-3.5 w-3.5"}),"Open"]})]}):null,L?e.jsx("div",{className:"ml-auto typography-meta text-[var(--status-error)]",children:L}):null]})}),e.jsx(lt,{open:y,onOpenChange:A,children:e.jsxs(ct,{className:"sm:max-w-2xl",children:[e.jsxs(pt,{children:[e.jsx(ht,{children:"SSH Logs"}),e.jsx(gt,{children:m?.nickname?.trim()||m?.sshParsed?.destination||m?.id||"Selected instance"})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsxs(j,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:Qa,disabled:O||!$s.trim(),children:[e.jsx(C,{name:"file-copy",className:"h-3.5 w-3.5"}),"Copy all"]}),e.jsxs(j,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{Ja()},disabled:O,children:[e.jsx(C,{name:"delete-bin",className:"h-3.5 w-3.5"}),"Clear"]})]}),O?e.jsx("div",{className:"typography-meta text-muted-foreground",children:"Loading logs..."}):B?e.jsx("div",{className:"typography-meta text-[var(--status-error)]",children:B}):e.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:X.length>0?X.join(`
|
|
3
|
+
`):"No SSH logs yet."})]})}),e.jsx(lt,{open:!!Y,onOpenChange:r=>{r||At()},children:e.jsxs(ct,{className:"sm:max-w-md",children:[e.jsxs(pt,{children:[e.jsx(ht,{children:"Choose an SSH destination"}),e.jsx(gt,{children:Y?`${Y} requires a concrete destination.`:"Enter destination."})]}),e.jsxs("form",{className:"space-y-3",onSubmit:r=>{r.preventDefault(),Bs()},children:[e.jsx(ie,{value:ge,onChange:r=>be(r.target.value),placeholder:"user@host",autoFocus:!0}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(j,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:At,disabled:Te,children:"Cancel"}),e.jsx(j,{type:"submit",size:"xs",className:"!font-normal",disabled:Te,children:"Create"})]})]})]})})]})})},kn="__pi_custom_provider__",xa=Zr(t=>({selectedProviderId:null,setSelectedProviderId:s=>t(i=>i.selectedProviderId===s?i:{selectedProviderId:s})})),rl=({onItemSelect:t})=>{const s=xa(u=>u.selectedProviderId),i=xa(u=>u.setSelectedProviderId),[o,l]=n.useState(null),[h,f]=n.useState(!1);return n.useEffect(()=>{let u=!0;const x=Is();return Ye.listProviders({runtimeKey:x}).then(({providers:L})=>{u&&(l(L),f(!1),!s&&L[0]&&i(L[0].id))}).catch(()=>{u&&(f(!0),l(null))}),()=>{u=!1}},[s,i]),e.jsxs("div",{className:"flex h-full flex-col bg-background",children:[e.jsxs("div",{className:"border-b px-3 pb-3 pt-4",children:[e.jsx("h2",{className:`${wa} mb-3`,children:"Providers"}),e.jsx("span",{className:"typography-meta text-muted-foreground",children:o?`Total ${o.length}`:"Loading..."})]}),e.jsxs(Qs,{outerClassName:"min-h-0 flex-1",className:"space-y-1 overflow-x-hidden px-3 py-2",children:[e.jsxs("button",{type:"button",onClick:()=>{i(kn),t?.()},className:ne("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",s===kn?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:[e.jsx(C,{name:"add",className:"size-4 shrink-0"}),e.jsx("span",{className:"typography-ui-label font-normal",children:"Other / Custom"})]}),h?e.jsx("p",{className:"px-2 py-3 typography-meta text-[var(--status-error)]",children:"Unavailable"}):null,o?.map(u=>{const x=s===u.id;return e.jsxs("button",{type:"button",onClick:()=>{i(u.id),t?.()},className:ne("flex w-full min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",x?"bg-interactive-selection text-interactive-selection-foreground":"hover:bg-interactive-hover"),children:[e.jsx(Fr,{providerId:u.id,className:"size-4 shrink-0"}),e.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label font-normal",children:u.label}),u.authenticated?e.jsx(C,{name:"check",className:"size-4 shrink-0 text-[var(--status-success)]"}):null,e.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:u.models.length})]},u.id)})]})]})},il="@ai-sdk/openai-compatible",ol=/^[a-z0-9][a-z0-9-_]*$/,ll=/^https?:\/\//,cl=/^\{env:([^}]+)\}$/;let dl=0;const _a=()=>`row-${dl++}`,Dn=()=>({row:_a(),id:"",name:""}),On=()=>({row:_a(),key:"",value:""}),ul=()=>({providerID:"",name:"",baseURL:"",apiKey:"",models:[Dn()],headers:[On()]});function ml(t){const s=t.trim();if(!s)return{};const o=s.match(cl)?.[1]?.trim();return o?{env:o}:{key:s}}function pl(t){const s=t.options&&typeof t.options=="object"?t.options:{},i=typeof s.baseURL=="string"?s.baseURL:"",o=s.headers&&typeof s.headers=="object"&&!Array.isArray(s.headers)?s.headers:{},l=Object.entries(o).filter(x=>typeof x[0]=="string"&&typeof x[1]=="string").map(([x,L])=>({row:_a(),key:x,value:L})),h=Array.isArray(t.models)?t.models:t.models&&typeof t.models=="object"?Object.entries(t.models).map(([x,L])=>({id:x,name:L&&typeof L=="object"&&"name"in L&&typeof L.name=="string"?L.name:x})):[],f=h.length>0?h.map(x=>({row:_a(),id:typeof x?.id=="string"?x.id:"",name:typeof x?.name=="string"?x.name:typeof x?.id=="string"?x.id:""})):[Dn()],u=Array.isArray(t.env)?t.env.find(x=>typeof x=="string"&&x.trim().length>0)?.trim():void 0;return{providerID:t.id,name:typeof t.name=="string"&&t.name.trim()?t.name:t.id,baseURL:i,apiKey:u?`{env:${u}}`:"",models:f,headers:l.length>0?l:[On()]}}function hl(t){const s=t.form.providerID.trim(),i=t.form.name.trim(),o=t.form.baseURL.trim(),{env:l,key:h}=ml(t.form.apiKey),f=t.disabledProviders??[],u=t.editingProviderID?.trim(),x=s?ol.test(s)?void 0:"Use lowercase letters, numbers, hyphens, or underscores":"Provider ID is required",L=i?void 0:"Display name is required",d=o?ll.test(o)?void 0:"Base URL must start with http:// or https://":"Base URL is required",g=!!(l||h||u&&t.allowExistingAuth&&u===s)?void 0:"API key or {env:VAR_NAME} is required",U=f.includes(s),G=x||!!(u&&u===s)?void 0:t.existingProviderIDs.has(s)&&!U?"A provider with this ID is already connected":void 0,I=new Set,R=t.form.models.map(O=>{const b=O.id.trim(),B=b?I.has(b)?"Duplicate":void I.add(b):"Required",W=O.name.trim()?void 0:"Required";return{id:B,name:W}}),$=R.every(O=>!O.id&&!O.name),J=Object.fromEntries(t.form.models.map(O=>[O.id.trim(),{name:O.name.trim()}])),v=new Set,w=t.form.headers.map(O=>{const b=O.key.trim(),B=O.value.trim();return!b&&!B?{}:{key:b?v.has(b.toLowerCase())?"Duplicate":void v.add(b.toLowerCase()):"Required",value:B?void 0:"Required"}}),m=w.every(O=>!O.key&&!O.value),F=Object.fromEntries(t.form.headers.map(O=>({key:O.key.trim(),value:O.value.trim()})).filter(O=>O.key&&O.value).map(O=>[O.key,O.value])),y={providerID:x??G,name:L,baseURL:d,apiKey:g};return!x&&!G&&!L&&!d&&!g&&$&&m?{err:y,models:R,headers:w,result:{providerID:s,name:i,apiKey:h,config:{npm:il,name:i,...l?{env:[l]}:{},options:{baseURL:o,...Object.keys(F).length>0?{headers:F}:{}},models:J}}}:{err:y,models:R,headers:w}}const gl=({existingProviderIDs:t,disabledProviders:s=[],busy:i=!1,mode:o="create",initialValues:l,allowExistingAuth:h=!1,authFailureHint:f=null,onSubmit:u,onCancel:x,onDisconnect:L})=>{const d=o==="edit",[T,g]=n.useState(()=>l??ul()),[U,M]=n.useState({}),[G,I]=n.useState([]),[R,$]=n.useState([]),J=n.useRef(null);n.useEffect(()=>{l&&(d&&J.current===l.providerID||(J.current=d?l.providerID:null,g(l),M({}),I([]),$([])))},[l,d]);const v=(y,A)=>{g(O=>({...O,[y]:A})),M(O=>({...O,[y]:void 0}))},w=(y,A,O)=>{g(b=>({...b,models:b.models.map((B,W)=>W===y?{...B,[A]:O}:B)})),I(b=>{const B=[...b];return B[y]={...B[y]??{},[A]:void 0},B})},m=(y,A,O)=>{g(b=>({...b,headers:b.headers.map((B,W)=>W===y?{...B,[A]:O}:B)})),$(b=>{const B=[...b];return B[y]={...B[y]??{},[A]:void 0},B})},F=async y=>{if(y.preventDefault(),i)return;const A=hl({form:T,existingProviderIDs:t,disabledProviders:s,editingProviderID:d?T.providerID:void 0,allowExistingAuth:d&&h});M(A.err),I(A.models),$(A.headers),A.result&&await u(A.result)};return e.jsxs("form",{onSubmit:F,className:"space-y-0",children:[e.jsxs(ae,{title:d?"Edit custom provider":"Custom provider",divider:!1,settingsItem:"providers.custom",contentClassName:Bt,children:[e.jsx("p",{className:ar,children:"Add an OpenAI-compatible provider with a base URL, credentials, and model list. Saved to Pi so it is available in chat like any other provider."}),f?e.jsx("p",{className:"typography-meta text-[var(--status-warning)]",role:"status",children:f}):null,e.jsxs(Le,{label:"Provider ID",info:"Lowercase letters, numbers, hyphens, and underscores. Used as the Pi provider id.",children:[e.jsx(ie,{value:T.providerID,onChange:y=>v("providerID",y.target.value),placeholder:"my-provider",className:"h-8 rounded-md px-3 font-mono text-xs",autoFocus:!d,disabled:d||i,"aria-invalid":!!U.providerID,"aria-label":"Provider ID"}),U.providerID?e.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:U.providerID}):null]}),e.jsxs(Le,{label:"Display name",info:"Shown in the provider and model pickers.",children:[e.jsx(ie,{value:T.name,onChange:y=>v("name",y.target.value),placeholder:"My Provider",className:"h-8 rounded-md px-3","aria-invalid":!!U.name,"aria-label":"Display name"}),U.name?e.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:U.name}):null]}),e.jsxs(Le,{label:"Base URL",info:"OpenAI-compatible API base URL. Must start with http:// or https://.",children:[e.jsx(ie,{value:T.baseURL,onChange:y=>v("baseURL",y.target.value),placeholder:"https://api.example.com/v1",className:"h-8 rounded-md px-3 font-mono text-xs","aria-invalid":!!U.baseURL,"aria-label":"Base URL"}),U.baseURL?e.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:U.baseURL}):null]}),e.jsxs(Le,{label:"API key",info:d&&h?"Leave blank to keep the existing credential, or enter a new key / {env:VAR_NAME}.":"Stored in Pi authentication, not by PiChamber. Use {env:VAR_NAME} to read a key from the environment instead.",children:[e.jsx(ie,{type:"password",value:T.apiKey,onChange:y=>v("apiKey",y.target.value),placeholder:d&&h?"Leave blank to keep existing key":"sk-... or {env:VAR_NAME}",className:"h-8 rounded-md px-3 font-mono text-xs","aria-invalid":!!U.apiKey,"aria-label":"API key"}),U.apiKey?e.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:U.apiKey}):null]})]}),e.jsxs(ae,{title:"Models",contentClassName:Bt,children:[T.models.map((y,A)=>e.jsx("div",{className:`${Gs} space-y-2`,children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:$e,children:"Model ID"}),e.jsx(ie,{value:y.id,onChange:O=>w(A,"id",O.target.value),placeholder:"gpt-4o",className:"mt-1 h-8 rounded-md px-3 font-mono text-xs","aria-label":"Model ID"}),G[A]?.id?e.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:G[A]?.id}):null]}),e.jsxs("div",{children:[e.jsx("label",{className:$e,children:"Model name"}),e.jsx(ie,{value:y.name,onChange:O=>w(A,"name",O.target.value),placeholder:"GPT-4o",className:"mt-1 h-8 rounded-md px-3","aria-label":"Model name"}),G[A]?.name?e.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:G[A]?.name}):null]})]}),e.jsx(j,{type:"button",variant:"ghost",size:"icon",className:nt,disabled:T.models.length<=1,onClick:()=>{T.models.length<=1||(g(O=>({...O,models:O.models.filter((b,B)=>B!==A)})),I(O=>O.filter((b,B)=>B!==A)))},"aria-label":"Remove model",children:e.jsx(C,{name:"delete-bin",className:"size-4"})})]})},y.row)),e.jsx(j,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{g(y=>({...y,models:[...y.models,Dn()]})),I(y=>[...y,{}])},children:"Add model"})]}),e.jsxs(ae,{title:"Headers",contentClassName:Bt,children:[e.jsx("p",{className:ar,children:"Optional request headers sent with every call."}),T.headers.map((y,A)=>e.jsx("div",{className:`${Gs} space-y-2`,children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:$e,children:"Header name"}),e.jsx(ie,{value:y.key,onChange:O=>m(A,"key",O.target.value),placeholder:"X-Custom-Header",className:"mt-1 h-8 rounded-md px-3 font-mono text-xs","aria-label":"Header name"}),R[A]?.key?e.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:R[A]?.key}):null]}),e.jsxs("div",{children:[e.jsx("label",{className:$e,children:"Header value"}),e.jsx(ie,{value:y.value,onChange:O=>m(A,"value",O.target.value),placeholder:"value",className:"mt-1 h-8 rounded-md px-3 font-mono text-xs","aria-label":"Header value"}),R[A]?.value?e.jsx("p",{className:"mt-1 typography-meta text-[var(--status-error)]",children:R[A]?.value}):null]})]}),e.jsx(j,{type:"button",variant:"ghost",size:"icon",className:nt,disabled:T.headers.length<=1,onClick:()=>{T.headers.length<=1||(g(O=>({...O,headers:O.headers.filter((b,B)=>B!==A)})),$(O=>O.filter((b,B)=>B!==A)))},"aria-label":"Remove header",children:e.jsx(C,{name:"delete-bin",className:"size-4"})})]})},y.row)),e.jsx(j,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{g(y=>({...y,headers:[...y.headers,On()]})),$(y=>[...y,{}])},children:"Add header"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-4",children:[x?e.jsx(j,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:x,disabled:i,children:"Back"}):null,L?e.jsx(j,{type:"button",variant:"destructive",size:"xs",className:"!font-normal",onClick:()=>{L()},disabled:i,children:"Disconnect"}):null,e.jsx(j,{type:"submit",size:"xs",className:"!font-normal",disabled:i,children:i?"Saving...":d?"Update provider":"Save provider"})]})]})},ds=()=>({runtimeKey:Is()}),fl=()=>{const t=xa(S=>S.selectedProviderId),s=xa(S=>S.setSelectedProviderId),i=k(S=>S.toggleHiddenModel),o=k(S=>S.isHiddenModel),l=k(S=>S.hideAllModels),h=k(S=>S.showAllModels),[f,u]=n.useState(null),[x,L]=n.useState(""),[d,T]=n.useState(""),[g,U]=n.useState(null),[M,G]=n.useState(!1),[I,R]=n.useState(null),[$,J]=n.useState(!1),[v,w]=n.useState(!1),m=n.useCallback(async()=>{const{providers:S}=await Ye.listProviders(ds());u(S),w(!1),!t&&S[0]&&s(S[0].id),rt.getState().loadProviders({source:"providersPage:refresh"})},[t,s]);n.useEffect(()=>{let S=!0;return m().catch(()=>{S&&w(!0)}),()=>{S=!1}},[m]),n.useEffect(()=>{if(!g||g.state!=="pending")return;let S=!0;const Y=window.setInterval(()=>{Ye.getProviderLogin(g.providerId,g.id,ds()).then(Z=>{S&&(U(Z.login),Z.login.state==="complete"&&m().catch(()=>w(!0)))}).catch(()=>{S&&U(Z=>Z&&{...Z,state:"failed",error:{code:"PROVIDER_AUTH_REQUIRED"}})})},1e3);return()=>{S=!1,window.clearInterval(Y)}},[g,m]);const F=f?.find(S=>S.id===t)??null,y=F?.id;n.useEffect(()=>{if(!y){R(null);return}let S=!0;return Ye.getProviderConfig(y,ds()).then(Y=>{S&&R(Y.config)}).catch(()=>{S&&R(null)}),()=>{S=!1}},[y]);const A=async S=>{J(!0);try{await Ye.setProviderModels({providerId:S.providerID,label:S.name,baseUrl:S.config.options.baseURL,api:"openai-completions",models:Object.entries(S.config.models).map(([Y,Z])=>({id:Y,providerId:S.providerID,label:Z.name})),...S.config.options.headers?{headers:S.config.options.headers}:{},...S.config.env?.[0]?{apiKeyReference:`{env:${S.config.env[0]}}`}:{}},ds()),S.apiKey&&U((await Ye.loginProvider({providerId:S.providerID,type:"api_key",apiKey:S.apiKey},ds())).login),s(S.providerID),G(!1),await m()}catch{w(!0)}finally{J(!1)}},O=async S=>{if(!(!F||$||S==="api_key"&&x.trim().length===0)){J(!0);try{const Y=await Ye.loginProvider({providerId:F.id,type:S,...S==="api_key"?{apiKey:x.trim()}:{}},ds());L(""),T(""),U(Y.login),Y.login.state==="complete"&&await m()}catch{U({id:"",providerId:F.id,state:"failed",error:{code:"PROVIDER_AUTH_REQUIRED"}})}finally{J(!1)}}},b=async()=>{if(!(!g||!g.prompt||d.length===0||$)){J(!0);try{const S=await Ye.respondProviderLogin(g.providerId,g.id,d,ds());T(""),U(S.login),S.login.state==="complete"&&await m()}catch{U(S=>S&&{...S,state:"failed",error:{code:"PROVIDER_AUTH_REQUIRED"}})}finally{J(!1)}}},B=async()=>{if(!(!F||$)){J(!0);try{await Ye.logoutProvider({providerId:F.id},ds()),U(null),await m()}catch{w(!0)}finally{J(!1)}}};if(v&&!f)return e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"Unavailable"});if(M||t===kn){const S=I?.providerId===F?.id?I:null,Y=S?pl({id:S.providerId,name:S.label,options:{baseURL:S.baseUrl},models:S.models}):void 0;return e.jsx(xt,{title:S?"Edit custom provider":"Custom provider",showSaveStatus:!1,children:e.jsx(gl,{existingProviderIDs:new Set(f?.map(Z=>Z.id)??[]),mode:S?"edit":"create",initialValues:Y,allowExistingAuth:F?.authenticated===!0,busy:$,onSubmit:Z=>{A(Z)},onCancel:()=>{G(!1),s(F?.id??f?.[0]?.id??null)}})})}if(!F)return f===null?e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"Loading..."}):e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"No providers"});const X=F.authenticated||g?.state==="complete";return e.jsxs(xt,{title:F.label,titleLeading:e.jsx(Fr,{providerId:F.id,className:"size-5 shrink-0"}),description:e.jsx("span",{className:"font-mono typography-settings-description text-muted-foreground",children:F.id}),showSaveStatus:!1,children:[v?e.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:"Unavailable"}):null,e.jsxs(ae,{title:"Authentication",divider:!1,settingsItem:"providers.auth",headerAction:X?e.jsx(j,{variant:"ghost",size:"xs",onClick:()=>{B()},disabled:$,children:$?"Disconnecting...":"Disconnect"}):null,children:[X?e.jsxs("div",{className:"flex items-center gap-1.5 py-1.5 typography-ui-label",children:[e.jsx(C,{name:"check",className:"size-4 text-[var(--status-success)]"}),"Connected"]}):e.jsxs("div",{className:"space-y-4 py-1.5",children:[e.jsx(Ge,{label:"API Key",children:e.jsxs("div",{className:"flex w-full max-w-[24rem] gap-2",children:[e.jsx(ie,{type:"password",value:x,onChange:S=>L(S.target.value),placeholder:"sk-...",autoComplete:"off"}),e.jsx(j,{size:"sm",onClick:()=>{O("api_key")},disabled:$||x.trim().length===0,children:$?"Saving...":"Save Key"})]})}),e.jsx(j,{variant:"outline",size:"sm",onClick:()=>{O("oauth")},disabled:$,children:"Reconnect"})]}),g?.state==="pending"?e.jsx(xl,{login:g,promptValue:d,onPromptValueChange:T,onSubmit:()=>{b()},busy:$}):null,g?.state==="failed"?e.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:"Authorization was declined or did not complete."}):null]}),e.jsx(ae,{title:"Available Models",settingsItem:"providers.models",info:X?"Hidden models stay out of the composer and session default pickers.":void 0,headerAction:e.jsxs("div",{className:"flex items-center gap-1",children:[X?e.jsxs(e.Fragment,{children:[e.jsx(j,{variant:"ghost",size:"xs",onClick:()=>h(F.id),children:"Show all"}),e.jsx(j,{variant:"ghost",size:"xs",onClick:()=>l(F.id,F.models.map(S=>S.id)),children:"Hide all"})]}):null,I?e.jsx(j,{variant:"ghost",size:"xs",onClick:()=>G(!0),children:"Update provider"}):null]}),children:e.jsx("div",{className:"divide-y divide-[var(--surface-subtle)]",children:F.models.map(S=>{const Y=o(F.id,S.id);return e.jsxs("div",{className:ne("flex min-w-0 items-center gap-2 py-2",Y&&"opacity-60"),children:[e.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label",children:S.label||S.id}),S.supportsThinking?e.jsx(C,{name:"brain-ai-3",className:"size-4 shrink-0 text-muted-foreground","aria-label":"Reasoning"}):null,typeof S.contextWindow=="number"?e.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:S.contextWindow}):null,X?e.jsx(j,{variant:"ghost",size:"xs",onClick:()=>i(F.id,S.id),"aria-label":Y?"Show model in pickers":"Hide model from pickers",title:Y?"Show model in pickers":"Hide model from pickers",children:e.jsx(C,{name:Y?"eye":"eye-off",className:"size-4"})}):null]},S.id)})})})]})},xl=({login:t,promptValue:s,onPromptValueChange:i,onSubmit:o,busy:l})=>e.jsxs("div",{className:"space-y-3 border-t border-[var(--surface-subtle)] pt-3",children:[t.authUrl?e.jsx("a",{className:"typography-meta text-[var(--primary-base)] underline",href:t.authUrl.url,target:"_blank",rel:"noreferrer",children:t.authUrl.instructions||"Open"}):null,t.deviceCode?e.jsxs("div",{className:"typography-meta text-muted-foreground",children:[e.jsx("span",{className:"mr-2",children:"Device code"}),e.jsx("code",{className:"text-foreground",children:t.deviceCode.userCode}),e.jsx("a",{className:"ml-2 text-[var(--primary-base)] underline",href:t.deviceCode.verificationUri,target:"_blank",rel:"noreferrer",children:"Open"})]}):null,t.prompt?e.jsxs(Ge,{label:t.prompt.message||"Copy the authorization code from your browser and paste it here.",children:[t.prompt.type==="select"&&t.prompt.options?e.jsxs(Re,{value:s,onValueChange:i,children:[e.jsx(De,{size:Fe,className:xn,children:e.jsx(Oe,{})}),e.jsx(_e,{children:t.prompt.options.map(h=>e.jsx(je,{value:h.id,children:h.label},h.id))})]}):e.jsx(ie,{type:t.prompt.type==="secret"?"password":"text",value:s,onChange:h=>i(h.target.value),placeholder:t.prompt.placeholder,autoComplete:"off"}),e.jsx(j,{size:"sm",onClick:o,disabled:l||s.length===0,children:"Continue"})]}):e.jsx("p",{className:"typography-meta text-muted-foreground",children:"Waiting for authorization…"})]}),bl="git.commit.generate",Sn=Zr(t=>({selectedPromptId:bl,setSelectedPromptId:s=>{t(i=>i.selectedPromptId===s?i:{selectedPromptId:s})}})),vl=({onItemSelect:t})=>{const s=Sn(l=>l.selectedPromptId),i=Sn(l=>l.setSelectedPromptId),o=n.useMemo(()=>[{groupLabel:"Git",items:[{id:"git.commit.generate",title:"Commit Generation"},{id:"git.pr.generate",title:"PR Generation"},{id:"git.conflict.resolve",title:"Merge/Rebase Conflict Resolution"},{id:"git.integrate.cherrypick.resolve",title:"Cherry-pick Conflict Resolution"}]},{groupLabel:"GitHub",items:[{id:"github.pr.review",title:"PR Review"},{id:"github.issue.review",title:"Issue Review"},{id:"github.pr.checks.review",title:"PR Failed Checks Review"},{id:"github.pr.comments.review",title:"PR Comments Review"},{id:"github.pr.comment.single",title:"Single PR Comment Review"}]},{groupLabel:"Planning",items:[{id:"plan.todo",title:"Todo Planning"},{id:"plan.improve",title:"Improve Plan"},{id:"plan.implement",title:"Implement Plan"}]},{groupLabel:"Session",items:[{id:"session.explore",title:"Codebase Tour"},{id:"session.summary",title:"Session Summary"},{id:"session.plan",title:"Feature Planning"},{id:"session.catchup",title:"Catch Up"},{id:"session.debug",title:"Debugging"},{id:"session.weigh",title:"Weigh Options"},{id:"session.fusion",title:"Fusion"}]}],[]);return e.jsxs("div",{className:"flex h-full flex-col bg-background",children:[e.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[e.jsx("h2",{className:wa,children:"Magic Prompts"}),e.jsx("p",{className:"typography-meta mt-1 text-muted-foreground",children:"Select a prompt template to edit."})]}),e.jsx(Qs,{outerClassName:"flex-1 min-h-0",className:"space-y-3 px-3 py-2 overflow-x-hidden",children:o.map(l=>e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"typography-micro px-1 text-muted-foreground",children:l.groupLabel}),l.items.map(h=>{const f=s===h.id;return e.jsx("button",{type:"button",onClick:()=>{i(h.id),t?.()},className:ne("flex w-full items-center rounded-md px-2 py-1.5 text-left transition-colors",f?"bg-interactive-selection text-foreground":"text-foreground hover:bg-interactive-hover"),children:e.jsx("span",{className:"typography-ui-label truncate font-normal",children:h.title})},h.id)})]},l.groupLabel))})]})},fr={"git.commit.generate":{title:"Commit Generation",description:"Prompts used for commit message generation: visible user message + hidden instructions.",blocks:[{id:"git.commit.generate.visible",title:"Visible Prompt"},{id:"git.commit.generate.instructions",title:"Instructions"}]},"git.pr.generate":{title:"PR Generation",description:"Prompts used for PR title/body generation: visible user message + hidden instructions.",blocks:[{id:"git.pr.generate.visible",title:"Visible Prompt"},{id:"git.pr.generate.instructions",title:"Instructions"}]},"github.pr.review":{title:"PR Review",description:"Prompts used for PR review flow: visible user message + hidden instruction payload.",blocks:[{id:"github.pr.review.visible",title:"Visible Prompt"},{id:"github.pr.review.instructions",title:"Instructions"}]},"github.issue.review":{title:"Issue Review",description:"Prompts used for issue review flow: visible user message + hidden instruction payload.",blocks:[{id:"github.issue.review.visible",title:"Visible Prompt"},{id:"github.issue.review.instructions",title:"Instructions"}]},"github.pr.checks.review":{title:"PR Failed Checks Review",description:"Prompts used for PR failed checks analysis.",blocks:[{id:"github.pr.checks.review.visible",title:"Visible Prompt"},{id:"github.pr.checks.review.instructions",title:"Instructions"}]},"github.pr.comments.review":{title:"PR Comments Review",description:"Prompts used for PR comments analysis.",blocks:[{id:"github.pr.comments.review.visible",title:"Visible Prompt"},{id:"github.pr.comments.review.instructions",title:"Instructions"}]},"github.pr.comment.single":{title:"Single PR Comment Review",description:"Prompts used for single PR comment analysis.",blocks:[{id:"github.pr.comment.single.visible",title:"Visible Prompt"},{id:"github.pr.comment.single.instructions",title:"Instructions"}]},"git.conflict.resolve":{title:"Merge/Rebase Conflict Resolution",description:"Prompts used when resolving merge/rebase conflicts with AI.",blocks:[{id:"git.conflict.resolve.visible",title:"Visible Prompt"},{id:"git.conflict.resolve.instructions",title:"Instructions"}]},"git.integrate.cherrypick.resolve":{title:"Cherry-pick Conflict Resolution",description:"Prompts used when resolving cherry-pick conflicts in integrate flow.",blocks:[{id:"git.integrate.cherrypick.resolve.visible",title:"Visible Prompt"},{id:"git.integrate.cherrypick.resolve.instructions",title:"Instructions"}]},"plan.improve":{title:"Improve Plan",description:"Hidden prompt used when sending a saved plan into an improve flow.",blocks:[{id:"plan.improve.visible",title:"Visible Prompt"},{id:"plan.improve.instructions",title:"Instructions"}]},"plan.todo":{title:"Todo Planning",description:"Hidden prompt used when sending a todo into a new planning session.",blocks:[{id:"plan.todo.visible",title:"Visible Prompt"},{id:"plan.todo.instructions",title:"Instructions"}]},"plan.implement":{title:"Implement Plan",description:"Hidden prompt used when sending a saved plan into an implement flow.",blocks:[{id:"plan.implement.visible",title:"Visible Prompt"},{id:"plan.implement.instructions",title:"Instructions"}]},"session.summary":{title:"Session Summary",description:"Prompts used by the /summary slash command: visible user message + hidden instructions. Non-destructive - does not compact session history.",blocks:[{id:"session.summary.visible",title:"Visible Prompt"},{id:"session.summary.instructions",title:"Instructions"}]},"session.plan":{title:"Feature Planning",description:"Prompts used by the /plan-feature slash command: visible user message + hidden instructions. Runs a guided dialogue that researches the code and asks clarifying questions in small batches before producing an implementation plan.",blocks:[{id:"session.plan.visible",title:"Visible Prompt"},{id:"session.plan.instructions",title:"Instructions"}]},"session.catchup":{title:"Catch Up",description:"Prompts used by the /catch-up slash command: visible user message + hidden instructions. Builds branch-aware context — the branch's commits, its PR, and uncommitted work together — to understand what you were doing, then gives a digestible summary and a product-focused next step.",blocks:[{id:"session.catchup.visible",title:"Visible Prompt"},{id:"session.catchup.instructions",title:"Instructions"}]},"session.debug":{title:"Debugging",description:"Prompts used by the /debug slash command: visible user message + hidden instructions. Runs a guided root-cause investigation — captures the symptom, forms hypotheses, checks them against the code, and confirms the cause before proposing a fix.",blocks:[{id:"session.debug.visible",title:"Visible Prompt"},{id:"session.debug.instructions",title:"Instructions"}]},"session.weigh":{title:"Weigh Options",description:"Prompts used by the /weigh slash command: visible user message + hidden instructions. Investigates the code, then lays out 2-3 distinct approaches with trade-offs and a recommendation — without writing a plan or code.",blocks:[{id:"session.weigh.visible",title:"Visible Prompt"},{id:"session.weigh.instructions",title:"Instructions"}]},"session.explore":{title:"Codebase Tour",description:"Prompts used by the /explore slash command: visible user message + hidden instructions. Investigates the repository and gives a structured orientation — the big picture, main modules, how they connect, and where to start — rather than a file-by-file dump.",blocks:[{id:"session.explore.visible",title:"Visible Prompt"},{id:"session.explore.instructions",title:"Instructions"}]},"session.fusion":{title:"Fusion",description:"Prompts used when combining multi-run outputs into one final answer: visible user message + hidden instructions before source results.",blocks:[{id:"session.fusion.visible",title:"Visible Prompt"},{id:"session.fusion.instructions",title:"Instructions"}]}},xr=(t,s)=>Object.prototype.hasOwnProperty.call(t,s),cn=t=>t.endsWith(".visible"),yl=()=>{const t=Sn(v=>v.selectedPromptId),[s,i]=n.useState(!0),[o,l]=n.useState({}),[h,f]=n.useState({}),[u,x]=n.useState({}),[L,d]=n.useState({}),[T,g]=n.useState(!1);n.useEffect(()=>{let v=!0;return(async()=>{i(!0);try{const m=await ki();if(!v)return;l(m)}catch(m){console.warn("Failed to load magic prompts:",m),E.error("Failed to load Magic Prompts")}finally{v&&i(!1)}})(),()=>{v=!1}},[]);const U=fr[t]??fr["git.commit.generate"],M=n.useCallback(v=>xr(o,v)?o[v]:tn(v),[o]),G=n.useCallback(v=>h[v]??M(v),[h,M]),I=n.useCallback((v,w)=>{f(m=>m[v]===w?m:{...m,[v]:w})},[]),R=n.useCallback(async v=>{const w=G(v);if(cn(v)&&w.trim().length===0){E.error("Visible prompt cannot be empty");return}x(m=>({...m,[v]:!0}));try{const m=w===tn(v)?await zn(v):await yi(v,w);l(m.overrides),E.success("Magic prompt saved")}catch(m){const F=m instanceof Error?m.message:String(m);E.error("Failed to save magic prompt",{description:F})}finally{x(m=>({...m,[v]:!1}))}},[G]),$=n.useCallback(async v=>{d(w=>({...w,[v]:!0}));try{const w=await zn(v);l(w.overrides),f(m=>({...m,[v]:tn(v)})),E.success("Prompt reset to default")}catch(w){const m=w instanceof Error?w.message:String(w);E.error("Failed to reset prompt",{description:m})}finally{d(w=>({...w,[v]:!1}))}},[]),J=n.useCallback(async()=>{g(!0);try{const v=await wi();l(v.overrides),f({}),E.success("All prompt overrides reset")}catch(v){const w=v instanceof Error?v.message:String(v);E.error("Failed to reset all prompts",{description:w})}finally{g(!1)}},[]);return s?e.jsxs("div",{className:"py-6 px-6 flex items-center gap-2 text-muted-foreground",children:[e.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-current animate-busy-pulse","aria-label":"Loading"}),e.jsx("span",{className:"typography-ui",children:"Loading Magic Prompts..."})]}):e.jsx(xt,{title:U.title,titleAccessory:e.jsx(Ht,{contentClassName:"max-w-xs",children:U.description}),headerEnd:e.jsx(j,{"data-settings-item":"magic-prompts.reset-overrides",variant:"outline",size:"sm",onClick:()=>{J()},disabled:T||Object.keys(o).length===0,children:T?"Resetting...":"Reset All Overrides"}),showSaveStatus:!1,children:U.blocks.map((v,w)=>{const m=ji(v.id),F=M(v.id),y=G(v.id),A=xr(o,v.id),O=y!==F,b=cn(v.id)&&y.trim().length===0,B=u[v.id]===!0,W=L[v.id]===!0;return e.jsxs(ae,{title:v.title,info:m.description,description:m.placeholders&&m.placeholders.length>0?`Placeholders: ${m.placeholders.map(X=>`{{${X.key}}}`).join(", ")}`:void 0,divider:w>0,settingsItem:cn(v.id)?"magic-prompts.visible-prompt":"magic-prompts.instructions",contentClassName:"space-y-3",children:[e.jsx(Mn,{value:y,onChange:X=>I(v.id,X.target.value),className:"min-h-[220px] font-mono text-sm"}),b&&e.jsx("div",{className:"typography-micro text-[var(--status-error)]",children:"Visible prompt cannot be empty."}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"typography-micro text-muted-foreground",children:O?"Unsaved changes":A?"Using saved override":"Using built-in default"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(j,{variant:"outline",size:"sm",onClick:()=>{$(v.id)},disabled:!A||B||W,children:W?"Resetting...":"Reset to Default"}),e.jsx(j,{size:"sm",onClick:()=>{R(v.id)},disabled:!O||B||W||b,children:B?"Saving...":"Save"})]})]})]},v.id)})})},wl=({onItemSelect:t})=>{const[s,i]=n.useState(null),[o,l]=n.useState(null),[h,f]=n.useState(null),{selectedSnippetName:u,snippets:x,setSelectedSnippet:L,setSnippetDraft:d,deleteSnippet:T,loadSnippets:g}=Mt(Ln(I=>({selectedSnippetName:I.selectedSnippetName,snippets:I.snippets,setSelectedSnippet:I.setSelectedSnippet,setSnippetDraft:I.setSnippetDraft,deleteSnippet:I.deleteSnippet,loadSnippets:I.loadSnippets})));n.useEffect(()=>{g()},[g]);const U=async()=>{const I=new Set(x.map(J=>J.name));let R="new-snippet",$=1;for(;I.has(R);)R=`new-snippet-${$++}`;d({name:R,scope:"global"}),L(R),t?.()},M=async()=>{if(!s)return;await T(s.name)?(E.success("Snippet deleted"),i(null)):E.error("Failed to delete snippet")},G=n.useMemo(()=>[...x].sort((I,R)=>I.name.localeCompare(R.name)),[x]);return e.jsxs("div",{className:ne("flex h-full flex-col","bg-background"),children:[e.jsxs("div",{className:"border-b px-3 pt-4 pb-3",children:[e.jsx("h2",{className:`${wa} mb-3`,children:"Snippets"}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"typography-meta text-muted-foreground",children:`Total: ${x.length}`}),e.jsx(j,{size:"sm","data-settings-item":"snippets.create",variant:"ghost",className:"h-7 w-7 px-0 -my-1 text-muted-foreground",onClick:U,"aria-label":"Create snippet",children:e.jsx(C,{name:"add",className:"h-3.5 w-3.5"})})]})]}),e.jsx(Qs,{outerClassName:"flex-1 min-h-0",className:"space-y-1 px-3 py-2",children:G.map(I=>e.jsxs(Vr,{open:h===I.name,onOpenChange:R=>f(R?I.name:null),children:[e.jsxs(Kr,{render:e.jsx("div",{className:ne("group relative flex items-center rounded-md px-1.5 py-1 transition-all duration-200 select-none",u===I.name?"bg-interactive-selection":"hover:bg-interactive-hover"),onContextMenu:R=>{R.preventDefault(),f(I.name)}}),children:[e.jsxs("button",{onClick:()=>{L(I.name),t?.()},className:"flex min-w-0 flex-1 flex-col gap-0 rounded-sm text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"typography-ui-label font-normal truncate text-foreground",children:["#",I.name]}),e.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:I.source==="global"?"global":"project"})]}),e.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:I.description||I.content.replace(/\s+/g," ").substring(0,80)})]}),I.editable===!0?e.jsxs(Tn,{open:o===I.name,onOpenChange:R=>{R&&f(null),l(R?I.name:null)},children:[e.jsx(In,{asChild:!0,children:e.jsx(j,{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":`More actions for ${I.name}`,children:e.jsx(C,{name:"more-2",className:"h-3.5 w-3.5"})})}),e.jsx(En,{align:"end",className:"w-fit min-w-20",children:e.jsxs(An,{onClick:R=>{R.stopPropagation(),i(I)},className:"text-destructive focus:text-destructive",children:[e.jsx(C,{name:"delete-bin",className:"h-4 w-4 mr-px"}),"Delete"]})})]}):null]}),I.editable===!0?e.jsx(Wr,{className:"w-fit min-w-20",children:e.jsxs(Gr,{onClick:R=>{R.stopPropagation(),i(I)},className:"text-destructive focus:text-destructive",children:[e.jsx(C,{name:"delete-bin",className:"h-4 w-4 mr-px"}),"Delete"]})}):null]},`${I.source}:${I.filePath}`))}),e.jsx(lt,{open:s!==null,onOpenChange:I=>{I||i(null)},children:e.jsxs(ct,{className:"max-w-md",children:[e.jsxs(pt,{children:[e.jsx(ht,{children:"Delete snippet?"}),e.jsx(gt,{children:`This will permanently delete #${s?.name??""}.`})]}),e.jsxs(ga,{children:[e.jsx(j,{size:"sm",variant:"ghost",onClick:()=>i(null),children:"Cancel"}),e.jsx(j,{size:"sm",onClick:M,children:"Delete"})]})]})})]})},jl=()=>{const t=Mt(v=>v.selectedSnippetName),s=Mt(v=>v.snippetDraft),i=Mt(v=>v.snippets),o=Mt(v=>v.setSnippetDraft),l=Mt(v=>v.createSnippet),h=Mt(v=>v.updateSnippet),f=i.find(v=>v.name===t)??null,u=!!(s&&!f),[x,L]=n.useState(""),[d,T]=n.useState("global"),[g,U]=n.useState(""),[M,G]=n.useState(""),[I,R]=n.useState(!1),$=n.useRef("");n.useEffect(()=>{u&&s?(L(s.name),T(s.scope),U(s.description??""),G(s.content??""),$.current=s.content??""):f&&(L(f.name),T(f.source),U(f.description??""),G(f.content),$.current=f.content)},[s,u,f]);const J=async()=>{const v=x.trim().replace(/\s+/g,"-");if(!v){E.error("Template name is required");return}if(!M.trim()){E.error("Snippet content is required");return}R(!0);const w=u?await l(v,M,{description:g,scope:d}):await h(f?.name??v,{content:M});R(!1),w?(o(null),E.success(u?"Template created":"Template updated")):E.error(u?"Failed to create template":"Failed to update template")};return t?e.jsxs(e.Fragment,{children:[e.jsx(fa,{onResolved:()=>{Mt.getState().loadSnippets()}}),e.jsxs(xt,{title:u?"New template":`/${x}`,description:u?"Create a new prompt template":g,showSaveStatus:!1,children:[u?e.jsxs(ae,{title:"Identity",divider:!1,children:[e.jsxs(Ge,{label:"Name",children:[e.jsx(ie,{value:x,onChange:v=>L(v.target.value),placeholder:"Template name",className:"h-8 w-full max-w-48"}),e.jsxs(Re,{value:d,onValueChange:v=>T(v),children:[e.jsx(De,{size:Fe,className:"w-full max-w-48",children:e.jsx(Oe,{})}),e.jsxs(_e,{children:[e.jsx(je,{value:"global",children:"Global"}),e.jsx(je,{value:"project",children:"Project"})]})]})]}),e.jsx(Le,{label:"Description",children:e.jsx(ie,{value:g,onChange:v=>U(v.target.value),className:"h-8 w-full"})})]}):null,e.jsxs(ae,{title:"Template",divider:!u,settingsItem:"snippets.content",contentClassName:"space-y-3",children:[e.jsx(Mn,{value:M,onChange:v=>G(v.target.value),placeholder:"Enter the prompt template text...",rows:14,disabled:!u&&f?.editable!==!0,className:"min-h-[220px] w-full font-mono typography-meta bg-transparent"}),u||f?.editable===!0?e.jsx(j,{size:"xs",onClick:()=>{J()},disabled:I||!u&&M===$.current,children:I?"Saving...":"Save Changes"}):null]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(fa,{onResolved:()=>{Mt.getState().loadSnippets()}}),e.jsx("div",{className:"flex h-full items-center justify-center px-4 text-center text-muted-foreground",children:e.jsxs("div",{children:[e.jsx(C,{name:"file-text",className:"mx-auto mb-3 size-10 opacity-50"}),e.jsx("p",{className:"typography-body",children:"Select a template"}),e.jsx("p",{className:"typography-meta mt-1",children:"Choose a template from the sidebar to edit it."})]})})]})},_n=()=>{const t=rt(d=>d.settingsGitmojiEnabled),s=rt(d=>d.setSettingsGitmojiEnabled),i=qi(),o=k(d=>d.gitChangesViewMode),l=k(d=>d.setGitChangesViewMode),[h,f]=n.useState(!0),u=n.useMemo(()=>[{id:"flat",label:"Flat List"},{id:"tree",label:"Tree View"}],[]);n.useEffect(()=>{(async()=>{try{let T=null;if(!T){const g=ha()?.settings;if(g)try{const M=(await g.load())?.settings;M&&(T={gitmojiEnabled:typeof M.gitmojiEnabled=="boolean"?M.gitmojiEnabled:void 0,gitChangesViewMode:M.gitChangesViewMode==="flat"||M.gitChangesViewMode==="tree"?M.gitChangesViewMode:void 0})}catch{}}if(!T){const g=await Je("/api/pi/ui-settings",{method:"GET",headers:{Accept:"application/json"}});g.ok&&(T=await g.json())}T&&(typeof T.gitmojiEnabled=="boolean"&&s(T.gitmojiEnabled),(T.gitChangesViewMode==="flat"||T.gitChangesViewMode==="tree")&&l(T.gitChangesViewMode))}catch(T){console.warn("Failed to load git settings:",T)}finally{f(!1)}})()},[l,s]);const x=n.useCallback(async d=>{s(d);try{await ve({gitmojiEnabled:d})}catch(T){console.warn("Failed to save gitmoji setting:",T)}},[s]),L=n.useCallback(d=>{d!==o&&(l(d),ve({gitChangesViewMode:d}))},[o,l]);return h?null:e.jsx(ae,{title:"Git Preferences",children:e.jsxs("div",{className:ft,children:[e.jsx(Ts,{settingsItem:"git.changes-view",title:"Changes View",children:e.jsx(Cs,{"aria-label":"Git changes view mode",children:u.map(d=>e.jsx(Ps,{selected:o===d.id,onSelect:()=>{L(d.id)},label:d.label,ariaLabel:`Git changes view mode: ${d.label}`},d.id))})}),e.jsx(me,{settingsItem:"git.gitmoji",checked:t,onChange:d=>{x(d)},label:"Enable Gitmoji Picker",ariaLabel:"Enable Gitmoji picker"}),e.jsx(me,{settingsItem:"git.gitignored-files",checked:i,onChange:Qi,label:"Display Gitignored Files",ariaLabel:"Display gitignored files"})]})})},br=[{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)"}],kl=[{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"}],Sl=({open:t,onOpenChange:s,profileId:i,importData:o})=>{const l=ua(K=>K.getProfileById),h=ua(K=>K.createProfile),f=ua(K=>K.updateProfile),u=ua(K=>K.deleteProfile),x=n.useMemo(()=>i&&i!=="new"&&!o?l(i):null,[i,l,o]),L=i==="new"||o!=null,d=i==="global",[T,g]=n.useState(""),[U,M]=n.useState(""),[G,I]=n.useState(""),[R,$]=n.useState("ssh"),[J,v]=n.useState(""),[w,m]=n.useState(!1),[F,y]=n.useState(""),[A,O]=n.useState(""),[b,B]=n.useState("keyword"),[W,X]=n.useState("branch"),[S,Y]=n.useState(!1),[Z,ge]=n.useState(!1),[be,Te]=n.useState(!1);n.useEffect(()=>{if(t){if(o){const K=o.host.split("/"),we=K.length>=3?K[K.length-1]:o.host;g(we),M(o.username),I(""),$("token"),v(""),m(!1),y(""),O(o.host),B("string"),X("code")}else if(L)g(""),M(""),I(""),$("ssh"),v(""),m(!1),y(""),O(""),B("keyword"),X("branch");else if(x)g(x.name),M(x.userName),I(x.userEmail),$(x.authType||"ssh"),v(x.sshKey||""),m(x.signCommits===!0),y(x.signingKey||""),O(x.host||""),B(x.color||"keyword"),X(x.icon||"branch");else if(d){const K=l("global");K&&(g(K.name),M(K.userName),I(K.userEmail),$(K.authType||"ssh"),v(K.sshKey||""),m(!1),y(""),O(K.host||""),B(K.color||"keyword"),X(K.icon||"branch"))}}},[t,i,x,L,o,d,l]);const D=async()=>{if(!U.trim()||!G.trim()){E.error("User name and email are required");return}if(R==="token"&&!A.trim()){E.error("Host is required for token-based authentication");return}if(w&&!F.trim()){E.error("Signing key is required when commit signing is enabled");return}Y(!0);try{const K={name:T.trim()||U.trim(),userName:U.trim(),userEmail:G.trim(),authType:R,sshKey:R==="ssh"&&J.trim()||null,signCommits:w,signingKey:F.trim()||null,host:R==="token"&&A.trim()||null,color:b,icon:W};let we;if(L)we=await h(K);else if(i)we=await f(i,K);else return;we?(E.success(L?"Profile created":"Profile updated"),s(!1)):E.error(L?"Failed to create profile":"Failed to update profile")}catch(K){console.error("Error saving profile:",K),E.error("An error occurred while saving")}finally{Y(!1)}},V=async()=>{if(!(!i||L)){Te(!0);try{await u(i)?(E.success("Profile deleted"),ge(!1),s(!1)):E.error("Failed to delete profile")}catch(K){console.error("Error deleting profile:",K),E.error("An error occurred while deleting")}finally{Te(!1)}}},oe=n.useMemo(()=>br.find(we=>we.key===b)?.cssVar||"var(--syntax-keyword)",[b]),ce=o?"Import Credential":L?"New Identity":d?"Global Identity":x?.name||"Edit Identity";return e.jsxs(e.Fragment,{children:[e.jsx(lt,{open:t,onOpenChange:s,children:e.jsxs(ct,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[e.jsxs(pt,{children:[e.jsx(ht,{children:ce}),e.jsx(gt,{children:d?"System-wide Git identity (read-only)":L?"Create a new Git identity profile":"Edit identity profile settings"})]}),e.jsxs("div",{className:"space-y-5 py-2",children:[!d&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:`${$e} block mb-1.5`,children:"Profile Name"}),e.jsx(ie,{value:T,onChange:K=>g(K.target.value),placeholder:"Work Profile, Personal, etc.",className:"h-8"})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{className:"typography-ui-label text-foreground",children:"Color"}),e.jsx("div",{className:"flex gap-1.5",children:br.map(K=>e.jsx("button",{type:"button",onClick:()=>B(K.key),className:ne("w-6 h-6 rounded-md border-2 transition-all cursor-pointer",b===K.key?"border-foreground scale-110":"border-transparent hover:border-border"),style:{backgroundColor:K.cssVar},title:K.label},K.key))})]}),e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{className:"typography-ui-label text-foreground",children:"Icon"}),e.jsx("div",{className:"flex gap-1.5",children:kl.map(K=>{const we=K.Icon;return e.jsx("button",{type:"button",onClick:()=>X(K.key),className:ne("w-7 h-7 rounded-md border-2 transition-all flex items-center justify-center cursor-pointer",W===K.key?"border-[var(--interactive-border)] bg-[var(--surface-muted)]":"border-transparent hover:border-[var(--interactive-border)] hover:bg-[var(--surface-muted)]/50"),title:K.label,children:e.jsx(C,{name:we,className:"w-3.5 h-3.5",style:{color:W===K.key?oe:"var(--surface-muted-foreground)"}})},K.key)})})]})]}),!d&&e.jsx("div",{className:"border-t border-border/40"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[e.jsx("label",{className:$e,children:"User Name"}),!d&&e.jsx("span",{className:"text-[var(--status-error)] text-xs",children:"*"}),e.jsx(Ht,{contentClassName:"max-w-xs",children:"The name that will appear in Git commit messages."})]}),e.jsx(ie,{value:U,onChange:K=>M(K.target.value),placeholder:"John Doe",required:!d,readOnly:d,disabled:d,className:"h-8"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[e.jsx("label",{className:$e,children:"Email Address"}),!d&&e.jsx("span",{className:"text-[var(--status-error)] text-xs",children:"*"}),e.jsx(Ht,{contentClassName:"max-w-xs",children:"Should match your email in GitHub/GitLab for proper attribution."})]}),e.jsx(ie,{type:"email",value:G,onChange:K=>I(K.target.value),placeholder:"john@example.com",required:!d,readOnly:d,disabled:d,className:"h-8"})]})]}),!d&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-t border-border/40"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("span",{className:"typography-ui-label text-foreground",children:"Auth Method"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs(j,{size:"sm",type:"button",variant:"chip","aria-pressed":R==="ssh",onClick:()=>$("ssh"),children:[e.jsx(C,{name:"lock-2",className:"w-3.5 h-3.5 mr-1"})," SSH"]}),e.jsxs(j,{size:"sm",type:"button",variant:"chip","aria-pressed":R==="token",onClick:()=>$("token"),children:[e.jsx(C,{name:"key",className:"w-3.5 h-3.5 mr-1"})," ","Token"]})]})]}),R==="ssh"&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[e.jsx("label",{className:$e,children:"SSH Key Path"}),e.jsx(Ht,{contentClassName:"max-w-xs",children:"Optional path to private key. e.g. ~/.ssh/id_ed25519"})]}),e.jsx(ie,{value:J,onChange:K=>v(K.target.value),placeholder:"~/.ssh/id_ed25519",className:"h-8 font-mono text-xs"})]}),e.jsxs("div",{className:"border-t border-border/40 pt-3 space-y-3",children:[e.jsx(me,{checked:w,onChange:m,label:"Sign commits with this identity",info:"Commit signing",ariaLabel:"Sign commits with this identity"}),e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-1.5 mb-1.5",children:e.jsx("label",{className:$e,children:"Signing key"})}),e.jsx(ie,{value:F,onChange:K=>y(K.target.value),placeholder:"~/.ssh/id_ed25519.pub",disabled:!w,className:"h-8 font-mono text-xs"})]})]}),R==="token"&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[e.jsx("label",{className:$e,children:"Host"}),e.jsx("span",{className:"text-[var(--status-error)] text-xs",children:"*"}),e.jsx(Ht,{contentClassName:"max-w-xs",children:"Token will be read from ~/.git-credentials for this host."})]}),e.jsx(ie,{value:A,onChange:K=>O(K.target.value),placeholder:"github.com",required:!0,className:"h-8 font-mono text-xs"})]})]})]})]}),e.jsxs(ga,{className:"gap-2",children:[!d&&!L&&e.jsxs(j,{variant:"outline",size:"sm",onClick:()=>ge(!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:[e.jsx(C,{name:"delete-bin",className:"w-3.5 h-3.5 mr-1"})," ","Delete"]}),e.jsx(j,{variant:"ghost",size:"sm",onClick:()=>s(!1),className:"text-foreground hover:bg-interactive-hover hover:text-foreground",children:d?"Close":"Cancel"}),!d&&e.jsx(j,{size:"sm",onClick:D,disabled:S,children:S?"Saving...":L?"Create":"Save"})]})]})}),e.jsx(lt,{open:Z,onOpenChange:K=>{be||ge(K)},children:e.jsxs(ct,{className:"max-w-md",children:[e.jsxs(pt,{children:[e.jsx(ht,{children:"Delete Profile"}),e.jsx(gt,{children:`Are you sure you want to delete \\"${x?.name||T}\\"?`})]}),e.jsxs(ga,{children:[e.jsx(j,{variant:"ghost",onClick:()=>ge(!1),disabled:be,children:"Cancel"}),e.jsx(j,{size:"sm",variant:"destructive",onClick:()=>{V()},disabled:be,children:"Delete"})]})]})})]})},Nl={branch:"git-branch",briefcase:"briefcase",house:"home",graduation:"graduation-cap",code:"code",heart:"heart"},Cl={keyword:"var(--syntax-keyword)",error:"var(--status-error)",string:"var(--syntax-string)",function:"var(--syntax-function)",type:"var(--syntax-type)"},Pl=()=>{const{profiles:t,globalIdentity:s,defaultGitIdentityId:i,deleteProfile:o,loadProfiles:l,loadGlobalIdentity:h,loadDiscoveredCredentials:f,loadDefaultGitIdentityId:u,setDefaultGitIdentityId:x,getUnimportedCredentials:L}=ua(Ln(y=>({profiles:y.profiles,globalIdentity:y.globalIdentity,defaultGitIdentityId:y.defaultGitIdentityId,deleteProfile:y.deleteProfile,loadProfiles:y.loadProfiles,loadGlobalIdentity:y.loadGlobalIdentity,loadDiscoveredCredentials:y.loadDiscoveredCredentials,loadDefaultGitIdentityId:y.loadDefaultGitIdentityId,setDefaultGitIdentityId:y.setDefaultGitIdentityId,getUnimportedCredentials:y.getUnimportedCredentials}))),[d,T]=n.useState(!1),[g,U]=n.useState(null),[M,G]=n.useState(null),[I,R]=n.useState(null),[$,J]=n.useState(!1);n.useEffect(()=>{l(),h(),f(),u()},[l,h,f,u]);const v=L(),w=(y,A)=>{U(y),G(A??null),T(!0)},m=async y=>{const A=i===y?null:y;if(!await x(A)){E.error("Failed to update default identity");return}E.success(A?"Default identity updated":"Default identity unset")},F=async()=>{if(!I)return;J(!0),await o(I.id)?(E.success(`Profile \\"${I.name}\\" deleted`),R(null)):E.error("Failed to delete profile"),J(!1)};return e.jsxs(e.Fragment,{children:[e.jsxs(xt,{title:"Git",showSaveStatus:!0,children:[e.jsx(ae,{title:"Identities",headerAction:e.jsxs(j,{size:"sm",variant:"outline",onClick:()=>w("new"),children:[e.jsx(C,{name:"add",className:"w-3.5 h-3.5 mr-1"})," ","New"]}),settingsItem:"git.identities",children:e.jsxs("div",{className:"rounded-lg bg-[var(--surface-elevated)]/70 overflow-hidden flex flex-col",children:[s&&e.jsx(vr,{profile:s,isDefault:i==="global",onEdit:()=>w("global"),onToggleDefault:()=>m("global"),isReadOnly:!0,hasBorder:t.length>0||v.length>0}),t.map((y,A)=>e.jsx(vr,{profile:y,isDefault:i===y.id,onEdit:()=>w(y.id),onToggleDefault:()=>m(y.id),onDelete:()=>R(y),hasBorder:A<t.length-1||v.length>0},y.id)),!s&&t.length===0&&v.length===0&&e.jsxs("div",{className:"py-8 px-4 text-center text-muted-foreground",children:[e.jsx(C,{name:"shield-keyhole",className:"mx-auto mb-2 h-8 w-8 opacity-40"}),e.jsx("p",{className:"typography-ui-label",children:"No identities configured"}),e.jsx("p",{className:"typography-meta mt-1 opacity-75",children:"Create one to manage Git author settings per project"})]}),v.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"px-4 py-2 border-t border-[var(--surface-subtle)]",children:e.jsx("span",{className:"typography-micro text-muted-foreground",children:"Found in ~/.git-credentials"})}),v.map((y,A)=>e.jsx(Tl,{credential:y,onImport:()=>w("new",{host:y.host,username:y.username}),hasBorder:A<v.length-1},`${y.host}-${y.username}`))]})]})}),e.jsx(_n,{})]}),e.jsx(Sl,{open:d,onOpenChange:T,profileId:g,importData:M}),e.jsx(lt,{open:I!==null,onOpenChange:y=>{$||y||R(null)},children:e.jsxs(ct,{className:"max-w-md",children:[e.jsxs(pt,{children:[e.jsx(ht,{children:"Delete Profile"}),e.jsx(gt,{children:`Are you sure you want to delete \\"${I?.name??""}\\"?`})]}),e.jsxs(ga,{children:[e.jsx(j,{variant:"ghost",onClick:()=>R(null),disabled:$,children:"Cancel"}),e.jsx(j,{size:"sm",variant:"destructive",onClick:()=>{F()},disabled:$,children:"Delete"})]})]})})]})},vr=({profile:t,isDefault:s,onEdit:i,onToggleDefault:o,onDelete:l,isReadOnly:h,hasBorder:f})=>{const[u,x]=n.useState(!1),L=Nl[t.icon||"branch"]||"git-branch",d=Cl[t.color||""],T=t.authType||"ssh",g=M=>{M.currentTarget===M.target&&(M.key!=="Enter"&&M.key!==" "||(M.preventDefault(),i()))},U=M=>e.jsxs(e.Fragment,{children:[e.jsx(M,{onClick:G=>{G.stopPropagation(),o()},children:s?"Unset default":"Set as default"}),!h&&l&&e.jsxs(M,{onClick:G=>{G.stopPropagation(),l()},className:"text-destructive focus:text-destructive",children:[e.jsx(C,{name:"delete-bin",className:"h-4 w-4 mr-px"}),"Delete"]})]});return e.jsxs(Vr,{open:u,onOpenChange:x,children:[e.jsxs(Kr,{render:e.jsx("div",{className:ne("group flex items-center justify-between gap-3 px-4 py-2.5 transition-colors hover:bg-[var(--interactive-hover)]/30 cursor-pointer",f&&"border-b border-[var(--surface-subtle)]"),onClick:i,role:"button",tabIndex:0,onKeyDown:g,onContextMenu:M=>{M.preventDefault(),x(!0)}}),children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(C,{name:L,className:"w-4 h-4 shrink-0",style:{color:d}}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"typography-ui-label text-foreground truncate",children:t.name}),e.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}),s&&e.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:"default"}),h&&e.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:"system"})]}),e.jsx("div",{className:"typography-micro text-muted-foreground/60 truncate leading-tight",children:T==="token"&&t.host?t.host:t.userEmail})]})]}),e.jsxs(Tn,{children:[e.jsx(In,{asChild:!0,children:e.jsx(j,{size:"icon",variant:"ghost",className:"h-6 w-6 shrink-0 opacity-100 transition-opacity md:opacity-0 md:group-hover:opacity-100",onClick:M=>M.stopPropagation(),children:e.jsx(C,{name:"more-2",className:"h-3.5 w-3.5"})})}),e.jsx(En,{align:"end",className:"w-fit min-w-28",children:U(An)})]})]}),e.jsx(Wr,{className:"w-fit min-w-28",children:U(Gr)})]})},Tl=({credential:t,onImport:s,hasBorder:i})=>{const o=t.host.split("/"),l=o.length>=3?o[o.length-1]:t.host,h=t.host.includes("/");return e.jsxs("div",{className:ne("flex items-center justify-between gap-3 px-4 py-2.5 transition-colors hover:bg-[var(--interactive-hover)]/30",i&&"border-b border-[var(--surface-subtle)]"),children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"typography-ui-label text-foreground truncate block",children:l}),e.jsx("span",{className:"typography-micro text-muted-foreground/60 truncate block leading-tight",children:h?t.host:t.username})]}),e.jsxs(j,{size:"sm",variant:"ghost",onClick:s,className:"gap-1 shrink-0",children:[e.jsx(C,{name:"download",className:"h-3 w-3"}),"Import"]})]})},Il=["standalone","minimal-ui","fullscreen","window-controls-overlay"],El=t=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(`(display-mode: ${t})`).matches,Al=()=>typeof window>"u"?"browser":typeof document<"u"&&document.referrer.startsWith("android-app://")?"twa":window.navigator.standalone?"standalone":Il.find(i=>El(i))??"browser",yr=()=>{const t=Al();return{displayMode:t,installed:t!=="browser",browserTab:t==="browser"}},Ml=()=>{const[t,s]=n.useState(()=>yr());return n.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const i=[window.matchMedia("(display-mode: standalone)"),window.matchMedia("(display-mode: minimal-ui)"),window.matchMedia("(display-mode: fullscreen)"),window.matchMedia("(display-mode: window-controls-overlay)")],o=()=>{s(yr())};o();for(const l of i)typeof l.addEventListener=="function"?l.addEventListener("change",o):typeof l.addListener=="function"&&l.addListener(o);return window.addEventListener("appinstalled",o),window.addEventListener("focus",o),()=>{for(const l of i)typeof l.removeEventListener=="function"?l.removeEventListener("change",o):typeof l.removeListener=="function"&&l.removeListener(o);window.removeEventListener("appinstalled",o),window.removeEventListener("focus",o)}},[]),t},Ll=[{value:"system",label:"System",description:"Follow system setting"},{value:"light",label:"Light",description:"Always use light appearance"},{value:"dark",label:"Dark",description:"Always use dark appearance"}],Rl=[{id:"dynamic",label:"Dynamic",description:"New inline, modified side-by-side."},{id:"inline",label:"Always inline",description:"Show as a single unified view."},{id:"side-by-side",label:"Always side-by-side",description:"Compare original and modified files."}],Dl=[{id:"svg",label:"SVG",description:"Render diagrams as scalable graphics."},{id:"ascii",label:"ASCII",description:"Render diagrams as text blocks."}],ca="PiChamber - AI Coding Assistant",wr=[{id:"system",label:"Follow system",description:"Respect the device rotation setting."},{id:"portrait",label:"Portrait lock",description:"Install the app locked to portrait."},{id:"landscape",label:"Landscape lock",description:"Install the app locked to landscape."}],jr=[{id:"native",label:"Follow browser",description:"Use the browser default for panning and viewport changes when the keyboard opens."},{id:"resize-content",label:"Resize content",description:"Ask supported browsers to shrink the app layout instead of relying only on panning."}],Ol=[{value:"default",label:"Old"},{value:"new",label:"New"}],dn=t=>t==="portrait"||t==="landscape"?t:"system",_l=[{id:"markdown",label:"Markdown",description:"Render user text with markdown formatting."},{id:"plain",label:"Plain text",description:"Render user text with preserved whitespace and links."}],kr=[{id:"auto",label:"Auto",description:"Prefer WebSocket and fall back to SSE if needed."},{id:"ws",label:"WebSocket",description:"Use WebSocket for message streaming."},{id:"sse",label:"SSE",description:"Use Server-Sent Events for message streaming."}],Sr=[{id:"auto",label:"Auto",description:"Use system locale preference."},{id:"24h",label:"24-hour",description:"Show time as 14:15."},{id:"12h",label:"12-hour",description:"Show time as 02:15 PM."}],Nr=[{id:"auto",label:"Auto",description:"Use locale week start."},{id:"monday",label:"Monday"},{id:"sunday",label:"Sunday"}],Fl=[{id:"steer",label:"Steer"},{id:"queue",label:"Queue"}],Ul=t=>t==="markdown"?"markdown":"plain",zl=[{id:"left",label:"Left"},{id:"right",label:"Right"}],Bl=[{id:"classic",label:"Classic"},{id:"traffic-lights",label:"Traffic lights"}],Fa=({visibleSettings:t})=>{const{isMobile:s}=ba(),{terminal:i}=_r(),{browserTab:o}=Ml(),l=Ji(),h=k(a=>a.showReasoningTraces),f=k(a=>a.setShowReasoningTraces),u=k(a=>a.collapsibleThinkingBlocks),x=k(a=>a.setCollapsibleThinkingBlocks),L=k(a=>a.collapseThinkingByDefault),d=k(a=>a.setCollapseThinkingByDefault),T=k(a=>a.mermaidRenderingMode),g=k(a=>a.setMermaidRenderingMode),U=k(a=>a.userMessageRenderingMode),M=k(a=>a.setUserMessageRenderingMode),G=k(a=>a.collapsibleUserMessages),I=k(a=>a.setCollapsibleUserMessages),R=k(a=>a.stickyUserHeader),$=k(a=>a.promptNavigatorEnabled),J=k(a=>a.setStickyUserHeader),v=k(a=>a.setPromptNavigatorEnabled),w=k(a=>a.expandedEditorToolbar),m=k(a=>a.setExpandedEditorToolbar),F=k(a=>a.autoSaveEnabled),y=k(a=>a.setAutoSaveEnabled),A=k(a=>a.wideChatLayoutEnabled),O=k(a=>a.setWideChatLayoutEnabled),b=k(a=>a.codeBlockLineWrap),B=k(a=>a.setCodeBlockLineWrap),W=k(a=>a.fontSize),X=k(a=>a.setFontSize),S=k(a=>a.terminalFontSize),Y=k(a=>a.setTerminalFontSize),Z=k(a=>a.terminalShell),ge=k(a=>a.setTerminalShell),be=k(a=>a.terminalLoginShells),Te=k(a=>a.setTerminalLoginShells),D=k(a=>a.editorFontSize),V=k(a=>a.setEditorFontSize),oe=k(a=>a.uiFont),ce=k(a=>a.setUiFont),K=k(a=>a.monoFont),we=k(a=>a.setMonoFont),Ce=k(a=>a.padding),Xe=k(a=>a.setPadding),Be=k(a=>a.inputBarOffset),ke=k(a=>a.setInputBarOffset),Ue=k(a=>a.mobileKeyboardMode),Ze=k(a=>a.setMobileKeyboardMode),it=k(a=>a.diffLayoutPreference),Ie=k(a=>a.setDiffLayoutPreference),St=k(a=>a.showTerminalQuickKeysOnDesktop),Nt=k(a=>a.setShowTerminalQuickKeysOnDesktop),bt=k(a=>a.fileEditorKeymap),fe=k(a=>a.setFileEditorKeymap),et=Jn(a=>a.followUpBehavior),Ct=Jn(a=>a.setFollowUpBehavior),te=k(a=>a.persistChatDraft),P=k(a=>a.setPersistChatDraft),H=k(a=>a.inputSpellcheckEnabled),he=k(a=>a.setInputSpellcheckEnabled),pe=k(a=>a.showToolFileIcons),ye=k(a=>a.setShowToolFileIcons),qe=k(a=>a.showTurnChangedFiles),He=k(a=>a.setShowTurnChangedFiles),vt=k(a=>a.showExpandedBashTools),Lt=k(a=>a.setShowExpandedBashTools),Ke=k(a=>a.showExpandedEditTools),gs=k(a=>a.setShowExpandedEditTools),yt=k(a=>a.timeFormatPreference),Es=k(a=>a.setTimeFormatPreference),Pt=k(a=>a.weekStartPreference),wt=k(a=>a.setWeekStartPreference),jt=k(a=>a.showSplitAssistantMessageActions),$t=k(a=>a.setShowSplitAssistantMessageActions),fs=k(a=>a.allowPromptingSubagentSessions),Ee=k(a=>a.setAllowPromptingSubagentSessions),Vt=k(a=>a.draftStartersVisible),Tt=k(a=>a.setDraftStartersVisible),As=rt(a=>a.settingsMessageStreamTransport),Xt=rt(a=>a.setSettingsMessageStreamTransport),Rt=As,It=rt(a=>a.settingsDefaultFileViewerPreview),xs=rt(a=>a.setSettingsDefaultFileViewerPreview),{themeMode:Kt,setThemeMode:Zt,availableThemes:es,customThemesLoading:Ms,reloadCustomThemes:bs,lightThemeId:Ls,darkThemeId:Wt,setLightThemePreference:tt,setDarkThemePreference:Dt}=Si(),[ts,Ot]=n.useState(!1),ss=n.useMemo(()=>Ve()&&typeof window<"u"&&window.__PICHAMBER_PLATFORM__==="darwin",[]),c=k(a=>a.dockBadgeEnabled),_=k(a=>a.setDockBadgeEnabled),ee=Yi(),q=k(a=>a.desktopWindowControlsPosition),ue=k(a=>a.setDesktopWindowControlsPosition),de=k(a=>a.desktopWindowControlsStyle),se=k(a=>a.setDesktopWindowControlsStyle),Pe=k(a=>a.reportUsage),as=k(a=>a.setReportUsage),Rs=n.useSyncExternalStore(Xi,Zi,()=>!1),_t=n.useCallback(a=>{as(a),ve({reportUsage:a})},[as]),vs=n.useCallback(a=>{ue(a),ve({desktopWindowControlsPosition:a})},[ue]),Ft=n.useCallback(a=>{se(a),ve({desktopWindowControlsStyle:a})},[se]),ys=n.useCallback(a=>{M(a),ve({userMessageRenderingMode:a})},[M]),st=n.useCallback(a=>{J(a),ve({stickyUserHeader:a})},[J]),Ds=n.useCallback(a=>{v(a),ve({promptNavigatorEnabled:a})},[v]),ns=n.useCallback(a=>{Tt(a),ve({draftStartersVisible:a})},[Tt]),Os=n.useCallback(a=>{m(a),ve({expandedEditorToolbar:a})},[m]),rs=n.useCallback(a=>{I(a),ve({collapsibleUserMessages:a})},[I]),_s=n.useCallback(a=>{f(a),ve({showReasoningTraces:a})},[f]),ja=n.useCallback(a=>{x(a),ve({collapsibleThinkingBlocks:a})},[x]),Js=n.useCallback(a=>{d(a),ve({collapseThinkingByDefault:a})},[d]),ka=n.useCallback(a=>{O(a),ve({wideChatLayoutEnabled:a})},[O]),Sa=n.useCallback(a=>{$t(a),ve({showSplitAssistantMessageActions:a})},[$t]),dt=n.useCallback(a=>{he(a),ve({inputSpellcheckEnabled:a})},[he]),Ua=n.useCallback(a=>{Xt(a),ve({messageStreamTransport:a})},[Xt]),za=n.useCallback(a=>{g(a),ve({mermaidRenderingMode:a})},[g]),Ba=n.useCallback(a=>{ye(a),ve({showToolFileIcons:a})},[ye]),Ha=n.useCallback(a=>{He(a),ve({showTurnChangedFiles:a})},[He]),$a=n.useCallback(a=>{xs(a),ve({defaultFileViewerPreview:a}),window.dispatchEvent(new CustomEvent("pichamber:file-viewer-preview-mode-changed",{detail:{enabled:a}}))},[xs]),Va=n.useCallback(a=>{Lt(a),ve({showExpandedBashTools:a})},[Lt]),Ka=n.useCallback(a=>{gs(a),ve({showExpandedEditTools:a})},[gs]),ut=n.useCallback(a=>{Es(a),ve({timeFormatPreference:a})},[Es]),Ys=n.useCallback(a=>{wt(a),ve({weekStartPreference:a})},[wt]),Fs=n.useMemo(()=>es.filter(a=>a.metadata.variant==="light").sort((a,re)=>a.metadata.name.localeCompare(re.metadata.name)),[es]),ws=n.useMemo(()=>es.filter(a=>a.metadata.variant==="dark").sort((a,re)=>a.metadata.name.localeCompare(re.metadata.name)),[es]),Xs=n.useMemo(()=>Fs.find(a=>a.metadata.id===Ls)??Fs[0],[Fs,Ls]),Zs=n.useMemo(()=>ws.find(a=>a.metadata.id===Wt)??ws[0],[ws,Wt]),Us=n.useCallback((a,re)=>{const We=re==="dark"?" Dark":" Light";return a.endsWith(We)?a.slice(0,-We.length):a},[]),N=a=>t?t.includes(a):!0,Na=N("theme"),at=N("windowControlsPosition")&&ee,Ut=N("theme")||N("timeFormat")||N("weekStart"),js=s&&hs()&&!Ve(),zt=N("theme")||at||js||N("pwaInstallName")||N("pwaOrientation")||N("timeFormat")||N("weekStart"),Gt=N("fontSize")||N("terminalFontSize")||N("editorFontSize")||N("spacing")||N("inputBarOffset")&&s,Wa=N("terminalQuickKeys")||N("terminalShell")||N("terminalLoginShell")||N("fileEditorKeymap")||N("autoSaveEnabled")||N("expandedEditorToolbar"),is=N("mermaidRendering")||N("userMessageRendering")||N("messageTransport")||N("collapsibleUserMessages")||N("stickyUserHeader")||N("promptNavigatorEnabled")||N("wideChatLayout")||N("codeBlockLineWrap")||N("splitAssistantMessageActions")||N("subagentReadOnlyBanner")||N("diffLayout")||N("dotfiles")||N("fileViewerPreview")||N("reasoning")||N("followUpBehavior")||N("persistDraft")||N("showToolFileIcons")||N("expandedTools")||N("inputSpellcheck"),ea=N("messageTransport"),ks=N("userMessageRendering")||N("mermaidRendering")||N("diffLayout")||N("followUpBehavior"),Ga=N("subagentReadOnlyBanner")||N("collapsibleUserMessages")||N("stickyUserHeader")||N("promptNavigatorEnabled")||N("wideChatLayout")||N("codeBlockLineWrap")||N("splitAssistantMessageActions")||N("dotfiles")||N("fileViewerPreview")||N("persistDraft")||N("showToolFileIcons")||N("showTurnChangedFiles")||N("inputSpellcheck")||N("reasoning")||N("expandedTools"),Ae=zt||Gt||Wa,os=N("pwaInstallName")&&hs()&&o&&!Ve(),Et=N("pwaOrientation")&&hs()&&!Ve(),At=N("mobileKeyboardMode")&&hs()&&!Ve()&&eo(),zs=N("terminalShell")||N("terminalLoginShell"),[Bs,ls]=n.useState([]),[Hs,qa]=n.useState(0);n.useEffect(()=>$r(()=>{ls([]),qa(a=>a+1)}),[]),n.useEffect(()=>{let a=!1;if(!(!zs||!i.listShells))return i.listShells().then(re=>{a||ls(re)}).catch(()=>{a||ls([])}),()=>{a=!0}},[zs,i,Hs]);const $s=n.useMemo(()=>{const a=Bs.filter(re=>re.id!=="auto");return Z==="auto"||a.some(re=>re.id===Z)?a:[{id:Z,name:Z,supportsLogin:!1},...a]},[Bs,Z]),Qa=Bs.find(a=>a.id===Z)?.supportsLogin===!0,Ja=be.includes(Z),Ya=a=>{Te(a?[...be.filter(re=>re!==Z),Z]:be.filter(re=>re!==Z))},[ta,Xa]=n.useState(()=>ko()),[sa,qt]=n.useState(""),[Vs,Qt]=n.useState("system"),Za=n.useMemo(()=>Sr.find(re=>re.id===yt)?.label??"Auto",[yt]),r=n.useMemo(()=>Nr.find(re=>re.id===Pt)?.label??"Auto",[Pt]),p=n.useMemo(()=>{const a=wr.find(re=>re.id===Vs);return a?a.label:void 0},[Vs]),z=n.useMemo(()=>{const a=jr.find(re=>re.id===Ue);return a?a.label:void 0},[Ue]),Q=n.useCallback(a=>{a!==ta&&(Xa(a),So(a),window.location.reload())},[ta]),Se=n.useCallback(async a=>{if(typeof window>"u")return;const re=window,ze=a.trim().replace(/\s+/g," ").slice(0,64);if(await ve({pwaAppName:ze}),typeof re.__PICHAMBER_SET_PWA_INSTALL_NAME__=="function"){const Ks=re.__PICHAMBER_SET_PWA_INSTALL_NAME__(ze);qt(Ks);return}qt(ze||ca),re.__PICHAMBER_UPDATE_PWA_MANIFEST__?.()},[]),ot=n.useCallback(async a=>{if(typeof window>"u")return;const re=window,We=dn(a);if(await ve({pwaOrientation:We}),typeof re.__PICHAMBER_SET_PWA_ORIENTATION__=="function"){const ze=re.__PICHAMBER_SET_PWA_ORIENTATION__(We);Qt(ze);return}Qt(We),re.__PICHAMBER_UPDATE_PWA_MANIFEST__?.()},[]);return n.useEffect(()=>{if(typeof window>"u"||!os&&!Et&&!At)return;let a=!1;return(async()=>{try{const We=await Je("/api/pi/ui-settings",{method:"GET",headers:{Accept:"application/json"},cache:"no-store"});if(!We.ok){a||qt(ca);return}const ze=await We.json().catch(()=>({})),Ss=(typeof ze?.pwaAppName=="string"?ze.pwaAppName:"").trim().replace(/\s+/g," ").slice(0,64),aa=dn(ze?.pwaOrientation),xe=tr(ze?.mobileKeyboardMode);a||(os&&qt(Ss||ca),Et&&Qt(aa),At&&Ze(xe))}catch{a||(os&&qt(ca),Et&&Qt("system"),At&&Ze("native"))}})(),()=>{a=!0}},[Ze,At,os,Et]),e.jsxs("div",{className:"space-y-0",children:[zt&&e.jsxs("div",{className:"space-y-0",children:[Na&&e.jsxs(ae,{title:"Color mode & Theme",divider:!1,children:[e.jsxs(ms,{children:[e.jsxs("div",{className:Bt,children:[e.jsx(Cs,{"aria-label":"Color Mode",children:Ll.map(a=>e.jsx(Ps,{selected:Kt===a.value,onSelect:()=>Zt(a.value),label:a.label,ariaLabel:a.label},a.value))}),js&&e.jsx(Da,{children:e.jsx(Le,{label:"Mobile Layout",children:e.jsx(ma,{value:ta,options:Ol.map(a=>({value:a.value,label:a.label})),onChange:Q,"aria-label":"Mobile Layout"})})})]}),e.jsxs("div",{className:Bt,children:[e.jsx(Le,{label:"Light Theme",settingsItem:"appearance.light-theme",children:e.jsxs(Re,{value:Xs?.metadata.id??"",onValueChange:tt,children:[e.jsx(De,{"aria-label":"Select light theme",size:Fe,className:Ns,children:e.jsx(Oe,{placeholder:"Select theme",children:Xs?Us(Xs.metadata.name,"light"):void 0})}),e.jsx(_e,{children:Fs.map(a=>e.jsx(je,{value:a.metadata.id,children:Us(a.metadata.name,"light")},a.metadata.id))})]})}),e.jsx(Le,{label:"Dark Theme",settingsItem:"appearance.dark-theme",children:e.jsxs(Re,{value:Zs?.metadata.id??"",onValueChange:Dt,children:[e.jsx(De,{"aria-label":"Select dark theme",size:Fe,className:Ns,children:e.jsx(Oe,{placeholder:"Select theme",children:Zs?Us(Zs.metadata.name,"dark"):void 0})}),e.jsx(_e,{children:ws.map(a=>e.jsx(je,{value:a.metadata.id,children:Us(a.metadata.name,"dark")},a.metadata.id))})]})}),e.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[e.jsxs("button",{type:"button",disabled:Ms||ts,onClick:()=>{const a=Date.now();Ot(!0),bs().finally(()=>{const re=Date.now()-a;if(re<500){window.setTimeout(()=>{Ot(!1)},500-re);return}Ot(!1)})},className:"typography-settings-link inline-flex items-center gap-1.5 disabled:cursor-not-allowed disabled:opacity-50 disabled:no-underline",children:[e.jsx(C,{name:"restart",className:ne("h-3.5 w-3.5",ts&&"animate-spin")}),ts?"Reloading themes...":"Reload themes"]}),e.jsx(Ht,{children:"Import custom themes from ~/.config/pichamber/themes/"})]})]})]}),ss&&e.jsx(Da,{settingsItem:"appearance.dock-badge",children:e.jsx(me,{checked:c,onChange:_,label:"Dock badge",info:"Show a count of chats with unseen activity on the macOS dock icon.",ariaLabel:"Dock badge"})})]}),at&&e.jsx(ae,{title:"Window controls",info:"Choose where minimize, maximize, and close buttons appear. Defaults to the right.",divider:Na,children:e.jsxs(ms,{children:[e.jsx(Le,{label:"Window controls position",settingsItem:"sessions.desktop-window-controls-position",children:e.jsx(ma,{value:q,options:zl.map(a=>({value:a.id,label:a.label})),onChange:vs,"aria-label":"Window controls position"})}),e.jsx(Le,{label:"Style",settingsItem:"sessions.desktop-window-controls-style",children:e.jsx(ma,{value:de,options:Bl.map(a=>({value:a.id,label:a.label})),onChange:Ft,"aria-label":"Window controls style"})})]})}),Ut&&e.jsx(ae,{title:"Localization",children:e.jsx(ms,{children:(N("timeFormat")||N("weekStart"))&&e.jsxs("div",{className:Bt,children:[N("timeFormat")&&e.jsx(Le,{label:"Time Format",settingsItem:"appearance.time-format",children:e.jsxs(Re,{value:yt,onValueChange:a=>ut(a),children:[e.jsx(De,{"aria-label":"Select time format",size:Fe,className:Ns,children:e.jsx(Oe,{children:Za})}),e.jsx(_e,{children:Sr.map(a=>e.jsx(je,{value:a.id,children:a.label},a.id))})]})}),N("weekStart")&&e.jsx(Le,{label:"Week Starts On",settingsItem:"appearance.week-start",children:e.jsxs(Re,{value:Pt,onValueChange:a=>Ys(a),children:[e.jsx(De,{"aria-label":"Select week start",size:Fe,className:Ns,children:e.jsx(Oe,{children:r})}),e.jsx(_e,{children:Nr.map(a=>e.jsx(je,{value:a.id,children:a.label},a.id))})]})})]})})}),(os||Et||At)&&e.jsxs(ae,{title:"App install",contentClassName:Bt,children:[os&&e.jsxs(Ge,{label:"Install App Name",info:"Used by PWA installation process.",settingsItem:"appearance.pwa-install-name",alignEnd:!1,controlClassName:Gs,children:[e.jsx(ie,{value:sa,onChange:a=>{qt(a.target.value)},onBlur:()=>{Se(sa)},onKeyDown:a=>{a.key==="Enter"&&(a.preventDefault(),Se(sa))},className:"min-w-0 flex-1",maxLength:64,"aria-label":"PWA install app name"}),e.jsx(j,{size:"sm",type:"button",variant:"ghost",onClick:()=>{qt(ca),Se("")},className:nt,"aria-label":"Reset install app name",title:"Reset",children:e.jsx(C,{name:"restart",className:"h-3.5 w-3.5"})})]}),Et&&e.jsxs(Ge,{label:"Install Orientation",description:"Used by the installed web app. Reinstall the PWA after changing this.",settingsItem:"appearance.pwa-orientation",alignEnd:!1,controlClassName:Gs,children:[e.jsxs(Re,{value:Vs,onValueChange:a=>{const re=dn(a);Qt(re),ot(re)},children:[e.jsx(De,{"aria-label":"PWA install orientation",size:Fe,className:nr,children:e.jsx(Oe,{placeholder:"Select orientation",children:p})}),e.jsx(_e,{children:wr.map(a=>e.jsx(je,{value:a.id,children:a.label},a.id))})]}),e.jsx(j,{size:"sm",type:"button",variant:"ghost",onClick:()=>{Qt("system"),ot("system")},disabled:Vs==="system",className:nt,"aria-label":"Reset install orientation",title:"Reset",children:e.jsx(C,{name:"restart",className:"h-3.5 w-3.5"})})]}),At&&e.jsxs(Ge,{label:"Mobile Keyboard Behavior",info:"Default browser behavior is safest. Resize content asks supported browsers to shrink the app when the on-screen keyboard opens.",settingsItem:"appearance.mobile-keyboard-mode",alignEnd:!1,controlClassName:Gs,children:[e.jsxs(Re,{value:Ue,onValueChange:a=>{const re=tr(a);Ze(re),ve({mobileKeyboardMode:re})},children:[e.jsx(De,{"aria-label":"Mobile keyboard behavior",size:Fe,className:nr,children:e.jsx(Oe,{placeholder:"Select keyboard behavior",children:z})}),e.jsx(_e,{children:jr.map(a=>e.jsx(je,{value:a.id,children:a.label},a.id))})]}),e.jsx(j,{size:"sm",type:"button",variant:"ghost",onClick:()=>{Ze("native"),ve({mobileKeyboardMode:"native"})},disabled:Ue==="native",className:nt,"aria-label":"Reset mobile keyboard behavior",title:"Reset",children:e.jsx(C,{name:"restart",className:"h-3.5 w-3.5"})})]})]})]}),Gt&&e.jsxs(ae,{title:"Density & type",contentClassName:Bt,children:[N("fontSize")||N("terminalFontSize")?e.jsxs(ms,{children:[N("fontSize")&&e.jsxs(Le,{label:"Interface Font",settingsItem:"appearance.interface-font-size",controlClassName:"w-full",children:[e.jsxs(Re,{value:oe,onValueChange:a=>ce(a),children:[e.jsx(De,{"aria-label":"Select interface font",size:Fe,className:Ns,children:e.jsx(Oe,{children:Yn.find(a=>a.id===oe)?.label})}),e.jsx(_e,{children:Yn.map(a=>e.jsx(je,{value:a.id,children:e.jsx("span",{style:{fontFamily:a.stack},children:a.label})},a.id))})]}),e.jsx(j,{size:"sm",type:"button",variant:"ghost",onClick:()=>ce(Xn),disabled:oe===Xn,className:nt,"aria-label":"Reset interface font",title:"Reset",children:e.jsx(C,{name:"restart",className:"h-3.5 w-3.5"})})]}),N("terminalFontSize")&&e.jsxs(Le,{label:"Code Font",controlClassName:"w-full",children:[e.jsxs(Re,{value:K,onValueChange:a=>we(a),children:[e.jsx(De,{"aria-label":"Select code font",size:Fe,className:Ns,children:e.jsx(Oe,{children:Zn.find(a=>a.id===K)?.label})}),e.jsx(_e,{children:Zn.map(a=>e.jsx(je,{value:a.id,children:e.jsx("span",{style:{fontFamily:a.stack},children:a.label})},a.id))})]}),e.jsx(j,{size:"sm",type:"button",variant:"ghost",onClick:()=>we(er),disabled:K===er,className:nt,"aria-label":"Reset code font",title:"Reset",children:e.jsx(C,{name:"restart",className:"h-3.5 w-3.5"})})]})]}):null,N("fontSize")||N("terminalFontSize")||N("editorFontSize")?e.jsxs(ms,{children:[N("fontSize")&&e.jsx(Le,{label:"Interface Font Size",settingsItem:"appearance.interface-font-size",controlClassName:"w-full",children:e.jsxs("div",{className:oa,children:[e.jsx(kt,{value:W,onValueChange:X,min:50,max:200,step:5,"aria-label":"Font size percentage"}),e.jsx("span",{className:la,children:"%"}),e.jsx(j,{size:"sm",type:"button",variant:"ghost",onClick:()=>X(100),disabled:W===100,className:nt,"aria-label":"Reset font size",title:"Reset",children:e.jsx(C,{name:"restart",className:"h-3.5 w-3.5"})})]})}),N("terminalFontSize")&&e.jsx(Le,{label:"Terminal Font Size",settingsItem:"appearance.terminal-font-size",controlClassName:"w-full",children:e.jsxs("div",{className:oa,children:[e.jsx(kt,{value:S,onValueChange:Y,min:9,max:52,step:1}),e.jsx("span",{className:la,children:"px"}),e.jsx(j,{size:"sm",type:"button",variant:"ghost",onClick:()=>Y(13),disabled:S===13,className:nt,"aria-label":"Reset terminal font size",title:"Reset",children:e.jsx(C,{name:"restart",className:"h-3.5 w-3.5"})})]})}),N("editorFontSize")&&e.jsx(Le,{label:"Editor Font Size",settingsItem:"appearance.editor-font-size",controlClassName:"w-full",children:e.jsxs("div",{className:oa,children:[e.jsx(kt,{value:D,onValueChange:V,min:9,max:32,step:1}),e.jsx("span",{className:la,children:"px"}),e.jsx(j,{size:"sm",type:"button",variant:"ghost",onClick:()=>V(13),disabled:D===13,className:nt,"aria-label":"Reset editor font size",title:"Reset",children:e.jsx(C,{name:"restart",className:"h-3.5 w-3.5"})})]})})]}):null,N("spacing")||N("inputBarOffset")&&s?e.jsxs(ms,{children:[N("spacing")&&e.jsx(Le,{label:"Spacing Density",settingsItem:"appearance.spacing-density",controlClassName:"w-full",children:e.jsxs("div",{className:oa,children:[e.jsx(kt,{value:Ce,onValueChange:Xe,min:50,max:200,step:5}),e.jsx("span",{className:la,children:"%"}),e.jsx(j,{size:"sm",type:"button",variant:"ghost",onClick:()=>Xe(100),disabled:Ce===100,className:nt,"aria-label":"Reset spacing",title:"Reset",children:e.jsx(C,{name:"restart",className:"h-3.5 w-3.5"})})]})}),N("inputBarOffset")&&s&&e.jsx(Le,{label:"Input Bar Offset",info:"Raise input bar to avoid OS-level screen obstructions like home bars.",settingsItem:"appearance.input-bar-offset",controlClassName:"w-full",children:e.jsxs("div",{className:oa,children:[e.jsx(kt,{value:Be,onValueChange:ke,min:0,max:100,step:5}),e.jsx("span",{className:la,children:"px"}),e.jsx(j,{size:"sm",type:"button",variant:"ghost",onClick:()=>ke(0),disabled:Be===0,className:nt,"aria-label":"Reset input bar offset",title:"Reset",children:e.jsx(C,{name:"restart",className:"h-3.5 w-3.5"})})]})})]}):null]}),Wa&&e.jsxs(ae,{title:"Navigation",contentClassName:"space-y-4",children:[N("fileEditorKeymap")&&e.jsx(Ts,{title:"File editor keymap",settingsItem:"appearance.file-editor-keymap",children:e.jsx(Cs,{"aria-label":"File editor keymap",children:["default","vim"].map(a=>e.jsx(Ps,{selected:bt===a,onSelect:()=>fe(a),label:a==="default"?"Default":"Vim",ariaLabel:a==="default"?"Default":"Vim"},a))})}),e.jsxs("div",{className:ft,children:[N("autoSaveEnabled")&&e.jsx(me,{checked:F,onChange:y,label:"Auto-save files",ariaLabel:"Auto-save files",info:"Automatically save file edits after you stop typing. Disable to require manual save.",settingsItem:"appearance.auto-save-enabled"}),N("expandedEditorToolbar")&&e.jsx(me,{checked:w,onChange:Os,label:"Always show editor toolbar (docked under the file tabs)",ariaLabel:"Always show editor toolbar",settingsItem:"appearance.expanded-editor-toolbar"}),N("terminalQuickKeys")&&e.jsx(me,{checked:St,onChange:Nt,label:"Terminal Quick Keys",ariaLabel:"Terminal quick keys",settingsItem:"appearance.terminal-quick-keys",info:"Show Esc, Ctrl, Arrows in terminal view"}),zs&&e.jsx(Le,{label:"Terminal Shell",info:"Restart the terminal to apply this change to the current session.",settingsItem:"appearance.terminal-shell",className:"pt-2",children:e.jsxs(Re,{value:Z,onValueChange:a=>{to(a)&&ge(a)},children:[e.jsx(De,{"aria-label":"Select terminal shell",size:Fe,className:Ns,children:e.jsx(Oe,{})}),e.jsxs(_e,{children:[e.jsx(je,{value:"auto",children:"Auto"}),$s.map(a=>e.jsx(je,{value:a.id,children:a.name},a.id))]})]})}),zs&&Qa&&e.jsx(me,{checked:Ja,onChange:Ya,label:"Start as login shell",ariaLabel:"Start as login shell",settingsItem:"appearance.terminal-login-shell"})]})]}),is&&e.jsxs(e.Fragment,{children:[ea&&e.jsxs(ae,{title:"Message Stream Transport",divider:Ae,settingsItem:"chat.message-transport",contentClassName:"space-y-2",children:[e.jsx(ma,{value:Rt,options:kr.map(a=>({value:a.id,label:a.label})),onChange:Ua,"aria-label":"Message Stream Transport"}),(()=>{const a=kr.find(re=>re.id===Rt);return a?.description?e.jsx("span",{className:"typography-meta text-muted-foreground",children:a.description}):null})()]}),ks&&e.jsx(ae,{title:"Message options",divider:ea||Ae,children:e.jsxs(ms,{className:"lg:gap-y-6",children:[N("userMessageRendering")&&e.jsx(Ts,{title:"User Message Rendering",children:e.jsx(Cs,{"aria-label":"User message rendering mode",children:_l.map(a=>e.jsx(Ps,{selected:Ul(U)===a.id,onSelect:()=>ys(a.id),label:a.label,ariaLabel:`User message rendering: ${a.label}`},a.id))})}),N("mermaidRendering")&&e.jsx(Ts,{title:"Mermaid Rendering",children:e.jsx(Cs,{"aria-label":"Mermaid rendering mode",children:Dl.map(a=>e.jsx(Ps,{selected:T===a.id,onSelect:()=>za(a.id),label:a.label,ariaLabel:`Mermaid rendering: ${a.label}`},a.id))})}),N("diffLayout")&&e.jsx(Ts,{title:"Diff Layout",children:e.jsx(Cs,{"aria-label":"Diff layout",children:Rl.map(a=>e.jsx(Ps,{selected:it===a.id,onSelect:()=>Ie(a.id),label:a.label,ariaLabel:`Diff layout: ${a.label}`},a.id))})}),N("followUpBehavior")&&e.jsx(Ts,{title:"Follow-up behavior",settingsItem:"chat.follow-up-behavior",children:e.jsx(Cs,{"aria-label":"Follow-up behavior",children:Fl.map(a=>e.jsx(Ps,{selected:et===a.id,onSelect:()=>Ct(a.id),label:a.label,ariaLabel:`Follow-up behavior: ${a.label}`},a.id))})})]})}),Ga&&e.jsxs(e.Fragment,{children:[N("expandedTools")&&e.jsxs(ae,{title:"Show tools opened by default",divider:ea||ks||Ae,contentClassName:ft,children:[e.jsx(me,{checked:vt,onChange:Va,label:"Bash",ariaLabel:"Show expanded bash tools"}),e.jsx(me,{checked:Ke,onChange:Ka,label:"Edit tools",ariaLabel:"Show expanded edit tools"})]}),e.jsxs(ae,{title:"Features",contentClassName:ft,children:[e.jsx(me,{checked:Vt,onChange:ns,label:"Show Starters on New Session Screen",ariaLabel:"Show starters on the new session screen",settingsItem:"chat.draft-starters-visible"}),N("subagentReadOnlyBanner")&&e.jsx(me,{checked:fs,onChange:Ee,label:"Allow Prompting Subagent Sessions",ariaLabel:"Allow prompting subagent sessions",settingsItem:"chat.subagent-read-only-banner"})]}),N("reasoning")&&e.jsxs(ae,{title:"Reasoning",settingsItem:"chat.reasoning",contentClassName:ft,children:[e.jsx(me,{checked:h,onChange:_s,label:"Show Reasoning Traces",ariaLabel:"Show reasoning traces",settingsItem:"chat.reasoning-traces"}),h&&e.jsx(me,{checked:u,onChange:ja,label:"Enable Collapsible Reasoning Blocks",ariaLabel:"Enable collapsible reasoning blocks",settingsItem:"chat.collapsible-reasoning"}),h&&u&&e.jsx(me,{checked:L,onChange:Js,label:"Collapsed by Default",ariaLabel:"Collapse reasoning blocks by default",info:"Thinking still opens while it streams, then folds when that block finishes. Turn this off to keep a one-line trace unless you expand it.",settingsItem:"chat.collapsed-reasoning-default"})]}),(N("collapsibleUserMessages")||N("stickyUserHeader")||N("promptNavigatorEnabled")||N("wideChatLayout")||N("splitAssistantMessageActions")||N("codeBlockLineWrap"))&&e.jsxs(ae,{title:"Message Appearance",settingsItem:"chat.message-appearance",contentClassName:ft,children:[N("collapsibleUserMessages")&&e.jsx(me,{checked:G,onChange:rs,label:"Collapse Long User Messages",ariaLabel:"Collapse long user messages",settingsItem:"chat.collapsible-user-messages"}),N("stickyUserHeader")&&e.jsx(me,{checked:R,onChange:st,label:"Sticky User Header",ariaLabel:"Sticky user header",settingsItem:"chat.sticky-user-header"}),N("promptNavigatorEnabled")&&e.jsx(me,{checked:$,onChange:Ds,label:"Prompt Navigator",ariaLabel:"Prompt navigator",settingsItem:"chat.prompt-navigator"}),N("wideChatLayout")&&e.jsx(me,{checked:A,onChange:ka,label:"Wide Chat Layout",ariaLabel:"Wide chat layout",settingsItem:"chat.wide-layout"}),N("splitAssistantMessageActions")&&e.jsx(me,{checked:jt,onChange:Sa,label:"Inline Assistant Actions",ariaLabel:"Inline assistant actions",settingsItem:"chat.inline-assistant-actions",info:"Show Copy Answer, Save as image, and Read aloud on assistant text blocks that appear before later tool calls in the same response."}),N("codeBlockLineWrap")&&e.jsx(me,{checked:b,onChange:B,label:"Wrap Code Block Lines",ariaLabel:"Wrap code block lines",settingsItem:"chat.code-block-line-wrap"})]}),(N("showToolFileIcons")||N("showTurnChangedFiles")||N("dotfiles")||N("fileViewerPreview"))&&e.jsxs(ae,{title:"Tools & Files",settingsItem:"chat.tools-and-files",contentClassName:ft,children:[N("showToolFileIcons")&&e.jsx(me,{checked:pe,onChange:Ba,label:"Show Tool File Icons",ariaLabel:"Show tool file icons",settingsItem:"chat.tool-file-icons"}),N("showTurnChangedFiles")&&e.jsx(me,{checked:qe,onChange:Ha,label:"Show Changed Files for Completed Turns",ariaLabel:"Show changed files for completed turns",settingsItem:"chat.changed-files"}),N("dotfiles")&&e.jsx(me,{checked:l,onChange:so,label:"Show Dotfiles",ariaLabel:"Show dotfiles",settingsItem:"chat.dotfiles"}),N("fileViewerPreview")&&e.jsx(me,{checked:It,onChange:$a,label:"Open previewable files in preview mode",ariaLabel:"Open previewable files in preview mode"})]}),(N("persistDraft")||N("inputSpellcheck"))&&e.jsxs(ae,{title:"Composer",settingsItem:"chat.composer",contentClassName:ft,children:[N("persistDraft")&&e.jsx(me,{checked:te,onChange:P,label:"Persist Draft Messages",ariaLabel:"Persist draft messages",settingsItem:"chat.persist-drafts"}),N("inputSpellcheck")&&e.jsx(me,{checked:H,onChange:dt,label:"Enable Spellcheck in Text Inputs",ariaLabel:"Enable spellcheck in text inputs",settingsItem:"chat.spellcheck"})]})]})]}),N("reportUsage")&&e.jsx(ae,{title:"Privacy",children:e.jsx(me,{checked:Pe,onChange:_t,label:"Send anonymous usage reports",info:"Helps us understand which app versions are actively used so we can prioritize improvements. Only app version, platform, and runtime are collected - no personal data or code.",ariaLabel:"Send anonymous usage reports",settingsItem:"appearance.usage-reports"})}),N("perfHud")&&e.jsx(ae,{title:"Diagnostics",children:e.jsx(me,{checked:Rs,onChange:ao,label:"Performance overlay",info:"Shows live frame time, long tasks, and render counters. Adds overhead. Stays on this device only, and is not a substitute for profile:idle or profile:session.",ariaLabel:"Performance overlay",settingsItem:"general.performance-overlay"})})]})},Hl=1,$l=365,Cr=30,Vl=[{value:"archive",label:"Archive"},{value:"delete",label:"Delete"}],ii=()=>{const t=k(g=>g.autoDeleteEnabled),s=k(g=>g.autoDeleteAfterDays),i=k(g=>g.sessionRetentionAction),o=k(g=>g.setAutoDeleteEnabled),l=k(g=>g.setAutoDeleteAfterDays),h=k(g=>g.setSessionRetentionAction),{candidates:f,isRunning:u,runCleanup:x,action:L}=Ni({autoRun:!1}),d=f.length,T=n.useCallback(async()=>{const g=await x({force:!0});if(g.completedIds.length===0&&g.failedIds.length===0){E.message(g.action==="archive"?"No sessions eligible for archiving":"No sessions eligible for deletion");return}g.completedIds.length>0&&E.success(g.action==="archive"?`Archived ${g.completedIds.length} session(s)`:`Deleted ${g.completedIds.length} session(s)`),g.failedIds.length>0&&E.error(g.action==="archive"?`Failed to archive ${g.failedIds.length} session(s)`:`Failed to delete ${g.failedIds.length} session(s)`)},[x]);return e.jsxs(ae,{title:"Session Retention",info:"Automatically archive or delete inactive sessions based on last activity. Keeps the 5 most recent sessions.",children:[e.jsx(me,{settingsItem:"sessions.auto-cleanup",checked:t,onChange:o,label:"Enable Auto-Cleanup",ariaLabel:"Enable auto-cleanup"}),e.jsxs(Da,{className:"space-y-0",children:[e.jsxs(Ge,{settingsItem:"sessions.retention-period",label:"Retention Period",children:[e.jsx(kt,{value:s,onValueChange:l,min:Hl,max:$l,step:1,"aria-label":"Retention period in days",className:"w-20 tabular-nums"}),e.jsx("span",{className:"typography-ui-label text-muted-foreground",children:"days"}),e.jsx(j,{size:"sm",type:"button",variant:"ghost",onClick:()=>l(Cr),disabled:s===Cr,className:nt,"aria-label":"Reset retention period",title:"Reset",children:e.jsx(C,{name:"restart",className:"h-3.5 w-3.5"})})]}),e.jsx(Ge,{settingsItem:"sessions.retention-action",label:"When sessions expire",children:e.jsx(ma,{value:i,onChange:h,options:Vl.map(g=>({value:g.value,label:g.label}))})})]}),e.jsxs("div",{className:"mt-1 py-1.5 space-y-1",children:[e.jsx(Ge,{label:"Manual Cleanup",children:e.jsx(j,{type:"button",variant:"outline",size:"xs",onClick:T,disabled:u,className:"!font-normal",children:u?"Cleaning up...":"Run cleanup now"})}),e.jsx("p",{className:"typography-meta text-muted-foreground",children:L==="archive"?`Eligible for archiving right now: ${d}`:`Eligible for deletion right now: ${d}`})]})]})},Pr=(t,s,i)=>!t||!Number.isFinite(t)?s:new Intl.DateTimeFormat("en-US",{dateStyle:"medium",timeStyle:"short",hour12:i==="auto"?void 0:i==="12h"}).format(t),oi=()=>{const t=k(m=>m.timeFormatPreference),[s,i]=n.useState(!1),[o,l]=n.useState(!0),[h,f]=n.useState(!1),[u,x]=n.useState(null),[L,d]=n.useState(!1),[T,g]=n.useState([]),[U,M]=n.useState(Ci),[G,I]=n.useState(""),R=n.useMemo(()=>Pi(),[]),$=n.useCallback(async()=>{l(!0),I("");try{const m=await Ti();g(m)}catch(m){const F=m instanceof Error?m.message:"Could not load passkeys.";I(F)}finally{l(!1)}},[]);n.useEffect(()=>{let m=!1;return(async()=>{try{if(!R.supported){m||(i(!1),l(!1));return}m||i(!0)}catch{m||i(!1)}if(!m){const F=await sn();if(M(F),!F.enabled){g([]),l(!1);return}await $()}})(),()=>{m=!0,Bn()}},[$,R.supported]);const J=n.useCallback(async()=>{if(!U.enabled){const m="Enable the UI password lock before adding passkeys.";I(m),E.message(m);return}if(!s){I(R.reason),E.message(R.reason);return}if(h){Bn(),f(!1);return}I(""),f(!0);try{await Ii(),M(await sn()),await $(),E.success("Passkey added")}catch(m){if(Ei(m)){E.message("Passkey setup canceled");return}const F=m instanceof Error?m.message:"Could not add passkey.";I(F),E.error(F)}finally{f(!1)}},[h,$,U.enabled,R.reason,s]),v=n.useCallback(async m=>{x(m),I("");try{await Ai(m),M(await sn()),await $(),E.success("Passkey removed")}catch(F){const y=F instanceof Error?F.message:"Could not remove passkey.";I(y),E.error(y)}finally{x(null)}},[$]),w=n.useCallback(async()=>{d(!0),I("");try{await Mi(),window.location.reload()}catch(m){const F=m instanceof Error?m.message:"Could not clear saved authentication.";I(F),E.error(F),d(!1)}},[]);return e.jsxs(ae,{title:"Passkeys",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Ge,{label:"Current device",children:[e.jsx(j,{type:"button",variant:h?"secondary":"outline",size:"xs",onClick:()=>{J()},disabled:o||L,className:"!font-normal",children:h?"Cancel passkey setup":"Add passkey"}),e.jsx(j,{type:"button",variant:"ghost",size:"xs",onClick:()=>{w()},disabled:o||h||L,className:"!font-normal text-muted-foreground hover:text-foreground",children:L?"Signing out…":"Sign out everywhere"})]}),!U.enabled&&e.jsx("p",{className:"typography-meta text-muted-foreground",children:"Passkeys are available only when the UI password lock is enabled."}),U.enabled&&!s&&e.jsx("p",{className:"typography-meta text-muted-foreground",children:R.reason}),o?e.jsx("p",{className:"typography-meta text-muted-foreground",children:"Loading passkeys…"}):T.length===0?e.jsx("p",{className:"typography-meta text-muted-foreground",children:"No passkeys saved for this host yet."}):e.jsx("div",{className:"space-y-1 pt-1",children:T.map(m=>e.jsxs(Ge,{label:e.jsx("span",{className:"truncate",children:m.label}),alignEnd:!1,controlClassName:"justify-between sm:flex-1",children:[e.jsx("span",{className:"typography-meta text-muted-foreground truncate",children:m.lastUsedAt?`Last used ${Pr(m.lastUsedAt,"Never used",t)}`:`Added ${Pr(m.createdAt,"Never used",t)}`}),e.jsx(j,{type:"button",variant:"ghost",size:"xs",onClick:()=>{v(m.id)},disabled:u===m.id,className:"!font-normal text-muted-foreground hover:text-foreground",children:u===m.id?"Removing…":"Delete"})]},m.id))})]}),G&&e.jsx("div",{className:"mt-1 py-1.5",children:e.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:G})})]})},Kl=t=>{if(!t)return;const s=t.providerId.trim(),i=t.modelId.trim();if(!(!s||!i))return`${s}/${i}`},Aa=t=>{const s=Li(t??void 0);return s?{providerId:s.providerId,modelId:s.modelId}:null},Wl=(t,s={})=>{if(!t)return{};const i={};if(!s.defaultModel){const o=Aa(typeof t.defaultModel=="string"?t.defaultModel:void 0);o&&(i.defaultModel=o)}if(!s.smallModel&&t.smallModelUseDefault===!1){const o=Aa(typeof t.smallModelOverride=="string"?t.smallModelOverride:void 0);o&&(i.smallModel=o)}if(!s.walkthroughModel){const o=Aa(typeof t.walkthroughModelOverride=="string"?t.walkthroughModelOverride:void 0);o&&(i.walkthroughModel=o)}return i},Gl=t=>!!(t.defaultModel||t.smallModel||t.walkthroughModel),un=()=>({runtimeKey:Is()}),mn="__pi_fallback__",Tr=(t,s)=>{const i=[...t];return s&&!i.includes(s)&&i.push(s),i},li=()=>{const t=rt(b=>b.providers),s=rt(b=>b.modelsMetadata),i=rt(b=>b.loadProviders),o=rt(b=>b.setProvider),l=rt(b=>b.setModel),h=rt(b=>b.setSettingsDefaultModel),f=rt(b=>b.setSettingsDefaultThinking),u=rt(b=>b.setSettingsDefaultThinkingByModel),x=k(b=>b.showDeletionDialog),L=k(b=>b.setShowDeletionDialog),[d,T]=n.useState(null),[g,U]=n.useState("loading"),M=n.useCallback(b=>{T(b),h(Kl(b.defaultModel)),f(b.defaultThinking),u(b.defaultThinkingByModel??{})},[h,f,u]);n.useEffect(()=>{i({source:"sessionsDefaults"})},[i]),n.useEffect(()=>{let b=!0;return(async()=>{try{const W=await Ye.getSettings(un());if(!b)return;let X=W.pichamber;if(!X.defaultModel&&!X.smallModel&&!X.walkthroughModel){const S=ha()?.settings;if(S)try{const Y=await S.load(),Z=Wl(Y?.settings,X);if(Gl(Z)){const ge=await Ye.setPiChamberDefaults(Z,un());if(!b)return;X=ge.pichamber,await ve({defaultModel:"",smallModelOverride:"",walkthroughModelOverride:""})}}catch{}}if(!b)return;M(X),U("ready")}catch{b&&U("failed")}})(),()=>{b=!1}},[M]);const G=n.useCallback(async b=>{rn("saving");try{const B=await Ye.setPiChamberDefaults(b,un());M(B.pichamber),rn("saved")}catch{rn("error")}},[M]),I=n.useCallback((b,B)=>{const W=t.find(S=>S.id===b);return(Array.isArray(W?.models)?W.models:[]).find(S=>S.id===B)},[t]),R=n.useCallback(b=>{b&&t.find(W=>W.id===b.providerId)&&(o(b.providerId),l(b.modelId)),G({defaultModel:b})},[G,t,l,o]),$=n.useCallback((b,B)=>{const W=an(b);W&&G({defaultThinkingByModel:{[W]:B}})},[G]),J=n.useCallback((b,B)=>s.get(`${b}/${B}`)?.structured_output!==!1,[s]),v=n.useCallback((b,B)=>{const W=`${b}/${B}`;return d?.defaultThinkingByModel?.[W]||an(d?.defaultModel)===W?!1:Hn(Pa(I(b,B)))},[I,d?.defaultModel,d?.defaultThinkingByModel]);if(g==="loading")return null;if(g==="failed"&&!d)return e.jsx(ae,{title:"Session Defaults",divider:!1,children:e.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:"Session defaults are unavailable."})});const w=an(d?.defaultModel),m=d?.defaultModel?I(d.defaultModel.providerId,d.defaultModel.modelId):void 0,F=Pa(m),y=!!(d?.defaultModel&&Hn(F)),A=w?d?.defaultThinkingByModel?.[w]:void 0,O=Object.keys(d?.defaultThinkingByModel??{}).filter(b=>b!==w).sort();return e.jsx(ae,{title:"Session Defaults",divider:!1,info:"New sessions use these models. Leave a picker on its fallback to keep Pi's own default.",children:e.jsxs("div",{className:Bt,children:[e.jsx(Ge,{settingsItem:"sessions.default-model",label:"Default Model",info:"The model new sessions start with. Unset keeps Pi's default.",children:e.jsx(Ta,{value:d?.defaultModel??null,noneLabel:"Default",ariaLabel:"Default model",onChange:R})}),y&&d?.defaultModel?e.jsx(Ge,{settingsItem:"sessions.default-thinking",label:"Default Thinking",info:"Thinking level for new sessions that start with the default model. Unset keeps Pi's default for that model.",children:e.jsxs(Re,{value:A??mn,onValueChange:b=>{$(d.defaultModel,b===mn?null:b)},children:[e.jsx(De,{size:Fe,className:xn,"aria-label":"Default thinking",children:e.jsx(Oe,{})}),e.jsxs(_e,{children:[e.jsx(je,{value:mn,children:"Default"}),Tr(F,A).map(b=>e.jsx(je,{value:b,children:$n[b]},b))]})]})}):null,e.jsx(Ge,{settingsItem:"sessions.small-model",label:"Small Model",info:"A cheap model for quick utility tasks like short recaps and summaries.",children:e.jsx(Ta,{value:d?.smallModel??null,noneLabel:"Use default small model",ariaLabel:"Small model",onChange:b=>{G({smallModel:b})}})}),e.jsx(Ge,{settingsItem:"sessions.walkthrough-model",label:"Changes Walkthrough Model",info:"The AI review of your changes needs structured output and room for a whole diff, which a cheap small model often cannot give. Models the catalog reports as unable to produce structured output are hidden from this picker. Leave it unset and the small model is used.",children:e.jsx(Ta,{value:d?.walkthroughModel??null,noneLabel:"Small model",ariaLabel:"Changes walkthrough model",isModelAllowed:J,onChange:b=>{G({walkthroughModel:b})}})}),e.jsx(Ts,{settingsItem:"sessions.thinking-defaults",title:"Thinking defaults",info:"Per-model thinking for new sessions and composer model changes. Models that only support Off are hidden.",children:e.jsxs("div",{className:Bt,children:[O.map(b=>{const B=Aa(b);if(!B)return null;const W=I(B.providerId,B.modelId),X=Pa(W),S=d?.defaultThinkingByModel?.[b],Y=Ri(W,B.modelId);return e.jsxs(Ge,{label:Y,controlClassName:Gs,children:[e.jsxs(Re,{value:S??X[0]??"off",onValueChange:Z=>{$(B,Z)},children:[e.jsx(De,{size:Fe,className:xn,"aria-label":`Thinking for ${Y}`,children:e.jsx(Oe,{})}),e.jsx(_e,{children:Tr(X,S).map(Z=>e.jsx(je,{value:Z,children:$n[Z]},Z))})]}),e.jsx(j,{type:"button",variant:"ghost",size:"icon",className:nt,"aria-label":`Remove thinking default for ${Y}`,onClick:()=>{$(B,null)},children:e.jsx(C,{name:"delete-bin",className:"size-4"})})]},b)}),e.jsx(Ge,{label:"Add model",info:"Pick a thinking-capable model to store a default level for it.",children:e.jsx(Ta,{value:null,noneLabel:"Add model",ariaLabel:"Add thinking default",isModelAllowed:v,onChange:b=>{if(!b)return;const B=Pa(I(b.providerId,b.modelId));$(b,Di(B,"medium"))}})})]})}),e.jsx(Da,{className:ft,children:e.jsx(me,{settingsItem:"sessions.deletion-dialog",checked:x,onChange:L,label:"Show Deletion Dialog",ariaLabel:"Show deletion dialog"})})]})})},Ir={completion:{titleKey:"{agent_name} is ready",messageKey:"{model_name} completed the task"},error:{titleKey:"Tool error",messageKey:"{last_message}"},question:{titleKey:"Input needed",messageKey:"{last_message}"},subtask:{titleKey:"{agent_name} is ready",messageKey:"{model_name} completed the task"}},ql={completion:"completion",subtask:"Subagent Completion",error:"error",question:"question"},Ql=()=>{const t=n.useMemo(()=>Ve(),[]),s=n.useMemo(()=>typeof window>"u"?!1:window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol==="capacitor:",[]),i=!t&&!s,o=k(D=>D.nativeNotificationsEnabled),l=k(D=>D.setNativeNotificationsEnabled),h=k(D=>D.notificationMode),f=k(D=>D.setNotificationMode),u=k(D=>D.notifyOnSubtasks),x=k(D=>D.setNotifyOnSubtasks),L=k(D=>D.notifyOnCompletion),d=k(D=>D.setNotifyOnCompletion),T=k(D=>D.notifyOnError),g=k(D=>D.setNotifyOnError),U=k(D=>D.notifyOnQuestion),M=k(D=>D.setNotifyOnQuestion),G=k(D=>D.notificationTemplates),I=k(D=>D.setNotificationTemplates),[R,$]=n.useState("default"),[J,v]=n.useState(!1),[w,m]=n.useState(!1),[F,y]=n.useState(!1);n.useEffect(()=>{if(!i){v(!1),m(!1);return}typeof Notification<"u"&&$(Notification.permission);const D=typeof window<"u"&&"serviceWorker"in navigator&&"PushManager"in window&&"Notification"in window;v(D),(async()=>{if(!D){m(!1);return}try{const oe=await navigator.serviceWorker.getRegistration();if(!oe){m(!1);return}const ce=await oe.pushManager.getSubscription();m(!!ce)}catch{m(!1)}})()},[i]);const A=async D=>{if(t){l(D);return}if(!i){l(D);return}if(D&&typeof Notification<"u"&&Notification.permission==="default")try{const V=await Notification.requestPermission();$(V),V==="granted"?l(!0):E.error("Notification permission denied",{description:"Please enable notifications in your browser settings."})}catch(V){console.error("Failed to request notification permission:",V),E.error("Failed to request notification permission")}else l(!!(D&&R==="granted"))},O=t||s||i&&typeof Notification<"u"&&Notification.permission==="granted",b=(D,V,oe)=>{I(ce=>({...ce,[D]:{...ce[D],[V]:oe}}))},B=D=>{const V="=".repeat((4-D.length%4)%4),oe=(D+V).replace(/-/g,"+").replace(/_/g,"/"),ce=atob(oe),K=new Uint8Array(ce.length);for(let we=0;we<ce.length;we+=1)K[we]=ce.charCodeAt(we);return K},W=async(D,V,oe)=>{let ce=null;const K=new Promise((we,Ce)=>{ce=setTimeout(()=>{Ce(new Error(oe))},V)});try{return await Promise.race([D,K])}finally{ce&&clearTimeout(ce)}},X=async D=>{if(D.active)return;const V=D.installing||D.waiting;V&&V.state!=="activated"&&await W(new Promise(oe=>{const ce=()=>{V.state==="activated"&&(V.removeEventListener("statechange",ce),oe())};V.addEventListener("statechange",ce),ce()}),15e3,"Service worker activation timed out")},S=async()=>{if(typeof navigator.serviceWorker.register!="function")throw new Error("navigator.serviceWorker.register unavailable");const D=[{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 V=null;for(const oe of D)try{const ce=oe.opts?navigator.serviceWorker.register("/sw.js",oe.opts):navigator.serviceWorker.register("/sw.js");return await W(ce,1e4,`Service worker registration timed out (${oe.label})`)}catch(ce){V=ce}throw V instanceof Error?V:new Error("Service worker registration failed")},Y=async()=>{if(!("serviceWorker"in navigator))throw new Error("Service worker not supported");const D=await navigator.serviceWorker.getRegistration();if(D)return D;const V=await S();try{await V.update()}catch{}return await X(V),V},Z=D=>{const V=D,oe=[`type=${typeof D}`,`toString=${String(D)}`,`name=${String(V?.name??"")}`,`message=${String(V?.message??"")}`];let ce="";try{ce=JSON.stringify(D)}catch{}return{summary:oe.filter(Boolean).join(" | "),json:ce,stack:typeof V?.stack=="string"?V.stack:""}},ge=async()=>{const D=ha();if(!D?.notifications){E.error("Notifications API not available");return}try{await D.notifications.notifyAgentCompletion({title:"Test Notification",body:"This is a test notification from PiChamber.",tag:"pichamber-test"})?E.success("Test notification sent successfully"):E.error("Failed to send test notification")}catch(V){console.error("Test notification failed:",V),E.error("Failed to send test notification")}},be=async()=>{if(!J){E.error("Push notifications not supported");return}const D=ha();if(!D?.push){E.error("Push API not available");return}y(!0);try{if(typeof Notification<"u"&&Notification.permission==="default"){const Be=await Notification.requestPermission();if($(Be),Be!=="granted"){E.error("Notification permission denied",{description:"Enable notifications in your browser settings."});return}}if(typeof Notification<"u"&&Notification.permission!=="granted"){E.error("Notification permission denied",{description:"Enable notifications in your browser settings."});return}const V=await D.push.getVapidPublicKey();if(!V?.publicKey){E.error("Failed to load push key");return}const oe=await Y();await X(oe);const ce=await oe.pushManager.getSubscription();if(!("pushManager"in oe)||!oe.pushManager)throw new Error("PushManager unavailable (requires installed PWA + iOS 16.4+)");const we=(ce??await W(oe.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:B(V.publicKey)}),15e3,"Push subscription timed out")).toJSON(),Ce=we.keys;if(!we.endpoint||!Ce?.p256dh||!Ce.auth)throw new Error("Push subscription missing keys");if(!(await W(D.push.subscribe({endpoint:we.endpoint,keys:{p256dh:Ce.p256dh,auth:Ce.auth},origin:typeof window<"u"?window.location.origin:void 0,platform:No()}),15e3,"Push subscribe request timed out"))?.ok){E.error("Failed to enable background notifications");return}m(!0),E.success("Background notifications enabled")}catch(V){console.error("[Push] Enable failed:",V);const oe=Z(V);E.error("Failed to enable background notifications",{description:oe.summary})}finally{y(!1)}},Te=async()=>{if(!J){m(!1);return}const D=ha();if(!D?.push){E.error("Push API not available");return}y(!0);try{const oe=await(await Y()).pushManager.getSubscription();if(!oe){m(!1);return}const ce=oe.endpoint;await oe.unsubscribe(),await D.push.unsubscribe({endpoint:ce}),m(!1),E.success("Background notifications disabled")}finally{y(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs(ae,{settingsItem:"notifications.delivery",title:"Notification Delivery",divider:!1,children:[e.jsxs("div",{className:ft,children:[e.jsx(me,{checked:o&&O,onChange:D=>{A(D)},label:"Enable Notifications",info:i?"Your browser may ask for permission the first time.":void 0,ariaLabel:"Enable notifications"}),o&&O&&!s&&e.jsxs(e.Fragment,{children:[e.jsx(me,{checked:h==="always",onChange:D=>f(D?"always":"hidden-only"),label:"Notify While App is Focused",ariaLabel:"Notify while app is focused"}),e.jsx("div",{className:"py-2",children:e.jsx(j,{type:"button",variant:"outline",size:"sm",onClick:()=>{ge()},children:"Send test notification"})})]})]}),i&&e.jsxs("div",{className:"mt-1",children:[R==="denied"&&e.jsx("p",{className:"typography-meta text-[var(--status-error)] mt-1",children:"Notification permission denied. Enable it in your browser settings."}),R==="granted"&&!o&&e.jsx("p",{className:"typography-meta text-muted-foreground/70 mt-1",children:"Permission granted, but notifications are disabled."})]})]}),o&&O&&e.jsxs(e.Fragment,{children:[e.jsx(ae,{settingsItem:"notifications.events",title:"Notification Events",children:e.jsxs("div",{className:ft,children:[e.jsx(me,{checked:L,onChange:d,label:"Agent Completion",ariaLabel:"Agent completion"}),e.jsx(me,{checked:u,onChange:x,label:"Subagent Completion",ariaLabel:"Subagent completion"}),e.jsx(me,{checked:T,onChange:g,label:"Agent Errors",ariaLabel:"Agent errors"}),e.jsx(me,{checked:U,onChange:M,label:"Agent Questions",ariaLabel:"Agent questions"})]})}),!s&&e.jsx(ae,{title:"Notification Templates",description:e.jsxs(e.Fragment,{children:["Variables:"," ",e.jsx("code",{className:"text-[var(--primary-base)]",children:"{project_name}"})," ",e.jsx("code",{className:"text-[var(--primary-base)]",children:"{worktree}"})," ",e.jsx("code",{className:"text-[var(--primary-base)]",children:"{branch}"})," ",e.jsx("code",{className:"text-[var(--primary-base)]",children:"{session_name}"})," ",e.jsx("code",{className:"text-[var(--primary-base)]",children:"{agent_name}"})," ",e.jsx("code",{className:"text-[var(--primary-base)]",children:"{model_name}"})," ",e.jsx("code",{className:"text-[var(--primary-base)]",children:"{last_message}"})]}),children:e.jsx(ms,{className:"gap-2 md:grid-cols-2 md:gap-3 lg:gap-3",children:["completion","subtask","error","question"].map(D=>e.jsxs("section",{className:"p-2",children:[e.jsx(Ra,{className:"capitalize",children:ql[D]}),e.jsxs("div",{className:"mt-1.5 space-y-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"typography-micro text-muted-foreground block mb-1",children:"Title"}),e.jsx(ie,{value:G[D].title,onChange:V=>b(D,"title",V.target.value),className:"h-7",placeholder:Ir[D].titleKey})]}),e.jsxs("div",{children:[e.jsx("label",{className:"typography-micro text-muted-foreground block mb-1",children:"Message"}),e.jsx(ie,{value:G[D].message,onChange:V=>b(D,"message",V.target.value),className:"h-7",placeholder:Ir[D].messageKey})]})]})]},D))})})]}),i&&e.jsx(ae,{settingsItem:"notifications.push",title:"Background Push Notifications",children:e.jsx(me,{checked:J?w:!1,disabled:!J||F,onChange:D=>{D?be():Te()},label:"Enable push notifications",description:J?void 0:"Push not supported. Desktop Chrome/Edge and Android support push. iOS requires an installed PWA.",info:J?"Receive alerts via your operating system background service":void 0,ariaLabel:"Enable push notifications",labelAccessory:F?e.jsx("span",{className:"inline-block h-1.5 w-1.5 rounded-full bg-current text-muted-foreground animate-busy-pulse","aria-label":"Loading"}):null})})]})},Ia=[{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}],Ea=[{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}],Jl="https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/get-started/create-remote-tunnel/",Yl="https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/do-more-with-tunnels/local-management/configuration-file/",pn=[{value:"quick",label:"Quick",tooltip:"Quick Tunnel is best effort and uptime is not guaranteed."},{value:"managed-remote",label:"Managed Remote",tooltip:"Managed Remote uses your Cloudflare account and hostname for long-lived access."},{value:"managed-local",label:"Managed Local",tooltip:"Managed Local uses your local cloudflared configuration file."}],Xl=[".yml",".yaml",".json"],Zl="Config file must use .yml, .yaml, or .json extension.",da=t=>{const s=t.trim().toLowerCase();return Xl.some(i=>s.endsWith(i))},ec=t=>t==="ngrok"?"ngrok":"cloudflared",ci=()=>{if(typeof window<"u"&&typeof window.__PICHAMBER_PLATFORM__=="string"){const s=window.__PICHAMBER_PLATFORM__;if(s==="win32"||s==="darwin"||s==="linux")return s}const t=typeof navigator<"u"?`${navigator.platform||""} ${navigator.userAgent||""}`.toLowerCase():"";return t.includes("win")?"win32":t.includes("mac")?"darwin":"linux"},tc=(t,s=ci())=>t==="ngrok"?s==="win32"?"winget install ngrok -s msstore":s==="darwin"?"brew install ngrok":"https://ngrok.com/download":s==="win32"?"winget install --id Cloudflare.cloudflared":s==="darwin"?"brew install cloudflared":"https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflared/downloads/",hn=(t,s)=>{const i=typeof s?.provider=="string"&&s.provider.trim().length>0?s.provider.trim().toLowerCase():t,o=typeof s?.dependency=="string"&&s.dependency.trim().length>0?s.dependency.trim():ec(i),l=typeof s?.platform=="string"&&s.platform.trim().length>0?s.platform.trim():ci(),h=typeof s?.installCommand=="string"&&s.installCommand.trim().length>0?s.installCommand.trim():tc(i,l);return{provider:i,dependency:o,installCommand:h}},di=t=>t==="cloudflare"?"Cloudflare":t==="ngrok"?"Ngrok":t,Er=({provider:t})=>{const s=di(t),i=t==="cloudflare",o=t==="ngrok";return e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(C,{name:"cloud",className:ne("size-4 shrink-0",i||o?"text-[var(--status-warning)]":"text-muted-foreground")}),e.jsx("span",{children:s})]})},us=t=>t==="quick"?"quick":t==="managed-remote"?"managed-remote":t==="managed-local"?"managed-local":"quick",Nn=(t,s,i)=>t.find(l=>l.ms===s)?.value||i,Ar=(t,s,i)=>{const o=Nn(t,s,i);return t.find(l=>l.value===o)?.label||o},Mr=t=>{const s=Math.max(0,t),i=Math.floor(s/1e3),o=Math.floor(i/3600),l=Math.floor(i%3600/60),h=i%60;return o>0?`${o}h ${l}m`:l>0?`${l}m ${h}s`:`${h}s`},sc=(t,s)=>_i(t,s,{hour:"2-digit",precision:"second"}),Ma=t=>{const s=t.trim();if(!s)return"";try{return(s.includes("://")?new URL(s):new URL(`https://${s}`)).hostname.trim().toLowerCase()}catch{return s.toLowerCase()}},ac=t=>{if(!Array.isArray(t))return[];const s=new Set,i=new Set,o=[];for(const l of t){if(!l||typeof l!="object")continue;const h=l,f=typeof h.id=="string"?h.id.trim():"",u=typeof h.name=="string"?h.name.trim():"",x=Ma(typeof h.hostname=="string"?h.hostname:"");!f||!u||!x||s.has(f)||i.has(x)||(s.add(f),i.add(x),o.push({id:f,name:u,hostname:x}))}return o},nc=()=>typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now()}-${Math.random().toString(36).slice(2,10)}`,rc=()=>{const t=k(c=>c.timeFormatPreference),[s,i]=n.useState("checking"),[o,l]=n.useState(null),[h,f]=n.useState(null),[u,x]=n.useState(null),[L,d]=n.useState(null),[T,g]=n.useState(null),[U,M]=n.useState(!1),[G,I]=n.useState(!1),[R,$]=n.useState(!1),[J,v]=n.useState("cloudflare"),[w,m]=n.useState(()=>hn("cloudflare")),[F,y]=n.useState([]),[A,O]=n.useState("quick"),[b,B]=n.useState(null),[W,X]=n.useState([]),[S,Y]=n.useState({}),[Z,ge]=n.useState(""),[be,Te]=n.useState({}),[D,V]=n.useState(new Set),[oe,ce]=n.useState(!1),[K,we]=n.useState(""),[Ce,Xe]=n.useState(""),[Be,ke]=n.useState(""),[Ue,Ze]=n.useState(1800*1e3),[it,Ie]=n.useState(480*60*1e3),[St,Nt]=n.useState(""),[bt,fe]=n.useState([]),[et,Ct]=n.useState(()=>Date.now()),[te,P]=n.useState(null),H=Zl,he=n.useRef(null),pe=n.useMemo(()=>b?!da(b):!1,[b]),ye=n.useMemo(()=>W.find(c=>c.id===Z)||W[0]||null,[W,Z]),qe=n.useMemo(()=>bt.map(c=>{const _=c.expiresAt<=et,ee=c.status==="active"&&!_,q=ee?Mr(c.expiresAt-et):c.inactiveReason==="expired"||_?"expired":"inactive",ue=q==="expired"?"Expired":c.inactiveReason==="tunnel-revoked"?"Revoked":"Inactive",de=us(c.mode);return{...c,isActive:ee,mode:de,remainingTextForSession:q,inactiveLabel:ue}}),[et,bt]),He=n.useMemo(()=>o?.connectUrl?o.bootstrapExpiresAt===null?!0:o.bootstrapExpiresAt>et:!1,[et,o?.bootstrapExpiresAt,o?.connectUrl]),vt=n.useMemo(()=>!o||s!=="active"&&s!=="stopping"?!1:h===A,[h,s,o,A]),Lt=n.useMemo(()=>!o||s!=="active"||!h?!1:h!==A,[h,s,o,A]),Ke=n.useMemo(()=>{if(typeof te=="number"&&Number.isFinite(te)&&te>0)return te;if(typeof window>"u")return null;const _=va()||window.location.href;let ee=0;try{ee=Number(new URL(_).port)}catch{ee=Number(window.location.port)}return Number.isFinite(ee)&&ee>0?ee:null},[te]),gs=n.useMemo(()=>F.find(c=>c.provider===J)??null,[F,J]),yt=n.useMemo(()=>{const c=new Set(gs?.modes?.map(_=>_.key).filter(_=>_==="quick"||_==="managed-remote"||_==="managed-local"));return c.size===0?pn:pn.filter(_=>c.has(_.value))},[gs]),Es=n.useMemo(()=>yt.some(c=>c.value==="managed-remote"||c.value==="managed-local"),[yt]),Pt=n.useMemo(()=>w.provider===J?w:hn(J),[w,J]),wt=n.useCallback(async c=>{await Pn(c)},[]),jt=n.useCallback((c,_)=>(m(hn(_,c)),c.available===!0),[]),$t=n.useCallback(async(c,_)=>{try{const ee=await Je("/api/pichamber/tunnel/check",{query:{provider:c},..._?{signal:_}:{}});if(!ee.ok)return null;const q=await ee.json();if(_?.aborted)return null;const ue=jt(q,c);return i(de=>de==="checking"||de==="starting"||de==="active"||de==="stopping"?de:ue?"idle":"not-available"),ue}catch{return null}},[jt]),fs=n.useCallback(async c=>{try{const[_,ee,q,ue]=await Promise.all([Je("/api/pichamber/tunnel/check",{signal:c}),Je("/api/pichamber/tunnel/status",{signal:c}),Je("/api/pi/ui-settings",{signal:c,headers:{Accept:"application/json"}}),Je("/api/pichamber/tunnel/providers",{signal:c})]),de=await _.json(),se=await ee.json(),Pe=q.ok?await q.json():{},as=ue.ok?await ue.json():{},Rs=se.ttlConfig?.bootstrapTtlMs??(Pe?.tunnelBootstrapTtlMs===null?null:typeof Pe?.tunnelBootstrapTtlMs=="number"?Pe.tunnelBootstrapTtlMs:1800*1e3),_t=typeof se.ttlConfig?.sessionTtlMs=="number"?se.ttlConfig.sessionTtlMs:typeof Pe?.tunnelSessionTtlMs=="number"?Pe.tunnelSessionTtlMs:480*60*1e3,vs=us(se.mode??Pe?.tunnelMode),Ft=typeof Pe?.tunnelProvider=="string"&&Pe.tunnelProvider.trim().length>0?Pe.tunnelProvider.trim().toLowerCase():"cloudflare",ys=typeof Pe?.managedLocalTunnelConfigPath=="string"&&Pe.managedLocalTunnelConfigPath.trim()||null,st=jt(de,Ft),Ds=ac(se?.managedRemoteTunnelPresets),ns=typeof se.managedRemoteTunnelHostname=="string"?se.managedRemoteTunnelHostname:"",Os=Ds.length>0?Ds:ns?[{id:`legacy-${Ma(ns)}`,name:ns,hostname:Ma(ns)}]:[],rs=Os[0]?.id||"";if(Ze(Rs),Ie(_t),v(Ft),y(Array.isArray(as?.providers)?as.providers:[]),O(vs),B(ys),X(Os),ge(rs),fe(Array.isArray(se.activeSessions)?se.activeSessions:[]),f(se.activeTunnelMode?us(se.activeTunnelMode):se.active&&se.mode?us(se.mode):null),V(new Set(Array.isArray(se.managedRemoteTunnelTokenPresetIds)?se.managedRemoteTunnelTokenPresetIds:[])),P(typeof se.localPort=="number"?se.localPort:null),se.active&&se.url){l({url:se.url,connectUrl:null,bootstrapExpiresAt:typeof se.bootstrapExpiresAt=="number"?se.bootstrapExpiresAt:null}),i("active");return}i(st?"idle":"not-available")}catch{c.aborted||(i("error"),d("Failed to check tunnel availability"))}},[jt]);n.useEffect(()=>{const c=new AbortController;return fs(c.signal),()=>c.abort()},[fs]),n.useEffect(()=>{if(!o?.connectUrl){x(null);return}let c=!1;return Qr.toDataURL(o.connectUrl,{width:256,margin:2,color:{dark:"#000000",light:"#ffffff"}}).then(_=>{c||x(_)}).catch(()=>{c||x(null)}),()=>{c=!0}},[o?.connectUrl]),n.useEffect(()=>{if(!o?.bootstrapExpiresAt){Nt("No expiry");return}let c=null,_=Date.now();const ee=()=>{const de=o.bootstrapExpiresAt?o.bootstrapExpiresAt-Date.now():0;de<=0?Nt("Expired"):Nt(Mr(de))},q=()=>{const de=Date.now();de-_>=1e3&&(ee(),_=de),c=requestAnimationFrame(q)};ee(),(typeof document>"u"||document.visibilityState==="visible")&&(c=requestAnimationFrame(q));const ue=()=>{document.visibilityState==="visible"&&c===null?c=requestAnimationFrame(q):document.visibilityState!=="visible"&&c!==null&&(cancelAnimationFrame(c),c=null)};return document.addEventListener("visibilitychange",ue),()=>{document.removeEventListener("visibilitychange",ue),c!==null&&cancelAnimationFrame(c)}},[o?.bootstrapExpiresAt]),n.useEffect(()=>{let c=null,_=Date.now();const ee=()=>{const ue=Date.now();ue-_>=1e3&&(Ct(ue),_=ue),c=requestAnimationFrame(ee)};(typeof document>"u"||document.visibilityState==="visible")&&(c=requestAnimationFrame(ee));const q=()=>{document.visibilityState==="visible"&&c===null?c=requestAnimationFrame(ee):document.visibilityState!=="visible"&&c!==null&&(cancelAnimationFrame(c),c=null)};return document.addEventListener("visibilitychange",q),()=>{document.removeEventListener("visibilitychange",q),c!==null&&cancelAnimationFrame(c)}},[]),n.useEffect(()=>{if(s==="starting"||s==="stopping"||s==="checking")return;let c=!1;const _=async()=>{try{const q=await Je("/api/pichamber/tunnel/status");if(!q.ok||c)return;const ue=await q.json();if(c)return;fe(Array.isArray(ue.activeSessions)?ue.activeSessions:[]),V(new Set(Array.isArray(ue.managedRemoteTunnelTokenPresetIds)?ue.managedRemoteTunnelTokenPresetIds:[])),P(typeof ue.localPort=="number"?ue.localPort:null)}catch{}},ee=window.setInterval(()=>{typeof document<"u"&&document.visibilityState!=="visible"||_()},5e3);return()=>{c=!0,window.clearInterval(ee)}},[s]);const Ee=n.useCallback(async c=>{$(!0);try{await ve(c),Object.prototype.hasOwnProperty.call(c,"tunnelMode")&&c.tunnelMode&&O(c.tunnelMode),Object.prototype.hasOwnProperty.call(c,"tunnelProvider")&&typeof c.tunnelProvider=="string"&&v(c.tunnelProvider),Object.prototype.hasOwnProperty.call(c,"managedLocalTunnelConfigPath")&&B(c.managedLocalTunnelConfigPath??null),Object.prototype.hasOwnProperty.call(c,"managedRemoteTunnelPresets")&&c.managedRemoteTunnelPresets&&X(c.managedRemoteTunnelPresets)}catch{E.error("Failed to save tunnel settings")}finally{$(!1)}},[]),Vt=n.useCallback(async(c,_)=>{I(!0);try{await ve({tunnelBootstrapTtlMs:c,tunnelSessionTtlMs:_})}catch{E.error("Failed to save tunnel TTL settings")}finally{I(!1)}},[]),Tt=n.useCallback(async c=>{const _=c.token.trim();if(_)try{const ee={...be,[c.presetId]:_};await ve({managedRemoteTunnelPresetTokens:ee}),V(q=>{const ue=new Set(q);return ue.add(c.presetId),ue})}catch{E.error("Failed to save managed remote tunnel token")}},[be]),As=n.useCallback(async c=>{g(null),d(null);const _=F.find(q=>q.provider===c),ee=_?.modes?.some(q=>q.key===A)?A:us(_?.modes?.[0]?.key);await Ee({tunnelProvider:c,tunnelMode:ee}),$t(c)},[F,$t,Ee,A]),Xt=n.useCallback(async()=>{const c=await no({filters:[{name:"Config",extensions:["yml","yaml","json"]}]});if(c.success&&typeof c.path=="string"&&c.path.trim().length>0){const _=c.path.trim();if(!da(_)){E.error(H);return}B(_),await Ee({managedLocalTunnelConfigPath:_});return}he.current?.click()},[H,Ee]),Rt=n.useCallback(c=>{const _=c.trim();B(_.length>0?_:null)},[]),It=n.useCallback(async()=>{if(b&&!da(b)){E.error(H);return}await Ee({managedLocalTunnelConfigPath:b})},[H,b,Ee]),xs=n.useCallback(async()=>{B(null),await Ee({managedLocalTunnelConfigPath:null})},[Ee]),Kt=n.useCallback(async c=>{const _=c.target.files?.[0];if(!_)return;const ee=_.name.trim();if(ee.length!==0){if(!da(ee)){E.error(H);return}B(ee),await Ee({managedLocalTunnelConfigPath:ee}),c.target.value=""}},[H,Ee]),Zt=n.useCallback(async()=>{if(d(null),g(null),A==="managed-local"&&b&&!da(b)){d(H),E.error(H);return}i("starting");try{let c="",_="";if(A==="managed-remote"){if(!ye){i("idle"),g("Select or add a managed remote tunnel first"),E.error("Select or add a managed remote tunnel first");return}c=ye.hostname,_=(be[ye.id]||"").trim(),await Ee({tunnelMode:"managed-remote",managedRemoteTunnelPresets:W})}const ee=await Je("/api/pichamber/tunnel/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:J,mode:A,...A==="managed-remote"&&ye?{managedRemoteTunnelPresetId:ye.id,managedRemoteTunnelPresetName:ye.name}:{},...A==="managed-remote"&&c?{managedRemoteTunnelHostname:c}:{},...A==="managed-remote"&&_?{managedRemoteTunnelToken:_}:{},...A==="managed-local"&&b?{configPath:b}:{}})}),q=await ee.json();if(!ee.ok||!q.ok){if(A==="managed-remote"&&typeof q.error=="string"&&q.error.includes("Managed remote tunnel token is required")){i("idle"),g("Managed remote tunnel token is required before starting"),E.error("Add a managed remote tunnel token before starting");return}i("error"),d(q.error||"Failed to start tunnel"),E.error(q.error||"Failed to start tunnel");return}const ue=typeof q.url=="string"?q.url:"";if(!ue){i("error"),d("Tunnel started but no public URL was returned"),E.error("Tunnel started but no public URL was returned");return}if(l({url:ue,connectUrl:typeof q.connectUrl=="string"?q.connectUrl:null,bootstrapExpiresAt:typeof q.bootstrapExpiresAt=="number"?q.bootstrapExpiresAt:null}),f(q.activeTunnelMode?us(q.activeTunnelMode):q.mode?us(q.mode):A),fe(Array.isArray(q.activeSessions)?q.activeSessions:[]),Array.isArray(q.managedRemoteTunnelTokenPresetIds)&&V(new Set(q.managedRemoteTunnelTokenPresetIds)),typeof q.localPort=="number"&&P(q.localPort),typeof q.mode=="string"&&O(us(q.mode)),i("active"),q.replacedTunnel){const de=typeof q.revokedBootstrapCount=="number"?q.revokedBootstrapCount:0,se=typeof q.invalidatedSessionCount=="number"?q.invalidatedSessionCount:0;de===1&&se===1?E.warning("Replaced previous tunnel: revoked 1 link, invalidated 1 session."):de===1?E.warning(`Replaced previous tunnel: revoked 1 link, invalidated ${se} sessions.`):se===1?E.warning(`Replaced previous tunnel: revoked ${de} links, invalidated 1 session.`):E.warning(`Replaced previous tunnel: revoked ${de} links, invalidated ${se} sessions.`)}else E.success("Tunnel link ready")}catch{i("error"),d("Failed to start tunnel"),E.error("Failed to start tunnel")}},[H,W,Ee,ye,be,J,A,b]),es=n.useCallback(async()=>{i("stopping");try{await Je("/api/pichamber/tunnel/stop",{method:"POST"});const c=await Je("/api/pichamber/tunnel/status");if(c.ok){const _=await c.json();fe(Array.isArray(_.activeSessions)?_.activeSessions:[]),V(new Set(Array.isArray(_.managedRemoteTunnelTokenPresetIds)?_.managedRemoteTunnelTokenPresetIds:[])),P(typeof _.localPort=="number"?_.localPort:null)}l(null),f(null),x(null),i("idle"),E.success("Tunnel stopped")}catch{i("error"),d("Failed to stop tunnel"),E.error("Failed to stop tunnel")}},[]),Ms=n.useCallback(async()=>{if(o?.connectUrl)try{await navigator.clipboard.writeText(o.connectUrl),M(!0),E.success("Connect link copied"),setTimeout(()=>M(!1),2e3)}catch{E.error("Failed to copy URL")}},[o?.connectUrl]),bs=n.useCallback(async c=>{const _=Ia.find(ee=>ee.value===c);_&&(Ze(_.ms),await Vt(_.ms,it))},[Vt,it]),Ls=n.useCallback(async c=>{const _=Ea.find(ee=>ee.value===c);!_||_.ms===null||(Ie(_.ms),await Vt(Ue,_.ms))},[Ue,Vt]),Wt=n.useCallback(async c=>{g(null),d(null),s!=="active"&&s!=="stopping"&&s!=="starting"&&i("idle"),await Ee({tunnelMode:c,managedRemoteTunnelPresets:W})},[W,Ee,s]),tt=n.useCallback(async(c,_)=>{try{await ve({managedRemoteTunnelPresets:_})}catch{E.error("Failed to save selected managed remote tunnel")}},[]),Dt=n.useCallback(c=>{const _=W.find(ee=>ee.id===c);_&&(ge(_.id),g(null),tt(_,W))},[W,tt]),ts=n.useCallback(async()=>{const c=K.trim(),_=Ma(Ce),ee=Be.trim();if(!c){E.error("Tunnel name is required");return}if(!_){E.error("Managed remote tunnel hostname is required");return}if(!ee){E.error("Managed remote tunnel token is required");return}if(W.some(de=>de.hostname===_)){E.error("This hostname already exists");return}const q={id:nc(),name:c,hostname:_},ue=[...W,q];X(ue),ge(q.id),Y(de=>({...de,[q.id]:!0})),Te(de=>({...de,[q.id]:ee})),g(null),ce(!1),we(""),Xe(""),ke(""),await Ee({tunnelMode:"managed-remote",managedRemoteTunnelPresets:ue,managedRemoteTunnelPresetTokens:{...be,[q.id]:ee}}),await Tt({presetId:q.id,presetName:q.name,hostname:q.hostname,token:ee}),E.success("Managed remote tunnel saved")},[W,Ce,K,Be,Tt,Ee,be]),Ot=n.useCallback(async c=>{const _=W.find(se=>se.id===c);if(!_)return;const ee=W.filter(se=>se.id!==_.id),q=ee[0]?.id||"",ue=Z===_.id?q:Z,de=Object.fromEntries(Object.entries(be).filter(([se,Pe])=>se!==_.id&&Pe.trim().length>0));X(ee),ge(ue),Y(se=>{const Pe={...se};return delete Pe[_.id],Pe}),Te(se=>{const Pe={...se};return delete Pe[_.id],Pe}),V(se=>{const Pe=new Set(se);return Pe.delete(_.id),Pe}),g(null),await Ee({managedRemoteTunnelPresets:ee,managedRemoteTunnelPresetTokens:de}),E.success("Managed remote tunnel removed")},[W,Ee,Z,be]),ss="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 s==="checking"?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current animate-busy-pulse","aria-label":"Loading"})}):e.jsx(ae,{title:"External Tunnel",info:e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{children:"Configure secure remote access with quick links or your own managed remote Cloudflare tunnel."}),e.jsx("p",{children:"Secure tunnel access is enforced server-side."}),e.jsx("p",{children:"Connect links are one-time and are revoked when tunnel stops or connect-link TTL expires."})]}),divider:!1,children:e.jsxs("div",{className:"space-y-6",children:[qe.length>0&&e.jsx("section",{className:"space-y-2 px-2 pb-2 pt-0",children:e.jsxs("div",{className:"rounded-lg border border-[var(--status-info-border)] bg-[var(--status-info-background)]/30 p-3",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx(C,{name:"information",className:"size-4 text-[var(--status-info)]"}),e.jsx("p",{className:rr,children:"Redeemed access links"})]}),e.jsx("div",{className:"space-y-1",children:qe.map(c=>{const _=c.mode==="quick",ee=c.mode==="managed-remote",q=_?"border-[var(--status-warning-border)] bg-[var(--status-warning-background)] text-[var(--status-warning)]":ee?"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)]",ue=c.isActive?_?"text-[var(--status-warning)]":ee?"text-[var(--status-info)]":"text-[var(--status-success)]":"text-muted-foreground/50",de=_?"QUICK":ee?"REMOTE":"LOCAL";return e.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:[e.jsx(C,{name:"checkbox-blank-circle-fill",className:ne("size-2.5 shrink-0",ue)}),e.jsx("span",{className:ne("typography-micro rounded border px-1.5 py-0.5 uppercase",q),children:de}),e.jsx("span",{className:"typography-meta text-muted-foreground/80",children:`Redeemed ${sc(c.createdAt,t)}`}),e.jsx("span",{className:"typography-meta text-foreground",children:c.isActive?`Expires in ${c.remainingTextForSession}`:c.inactiveLabel==="Inactive"?"Inactive":`Inactive (${c.inactiveLabel})`})]},c.sessionId)})})]})}),s==="not-available"&&e.jsx("section",{className:"space-y-2 px-2 pb-2 pt-0",children:e.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-[var(--status-warning)]/30 bg-[var(--status-warning)]/5 p-3",children:[e.jsx(C,{name:"error-warning",className:"mt-0.5 size-4 shrink-0 text-[var(--status-warning)]"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:rr,children:`${Pt.dependency} was not found.`}),e.jsx("p",{className:"typography-meta text-muted-foreground/70",children:"Install it to enable remote tunnel access:"}),e.jsx("code",{className:"typography-code block rounded bg-muted/50 px-2 py-1 text-xs text-foreground",children:Pt.installCommand})]})]})}),e.jsxs("section",{className:"space-y-4 px-2 pb-2 pt-0",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{"data-settings-item":"tunnel.provider",className:"space-y-1.5",children:[e.jsx("p",{className:$e,children:"Provider"}),e.jsxs(Re,{value:J,onValueChange:c=>{As(c)},disabled:R||s==="starting"||s==="stopping",children:[e.jsx(De,{size:Fe,className:"max-w-[16rem]",children:e.jsx(Oe,{placeholder:"Select provider",children:di(J)})}),e.jsxs(_e,{children:[F.length>0?F.map(c=>e.jsx(je,{value:c.provider,children:e.jsx(Er,{provider:c.provider})},c.provider)):e.jsx(je,{value:"cloudflare",children:e.jsx(Er,{provider:"cloudflare"})}),e.jsx(je,{value:"__more-soon",disabled:!0,children:"More providers coming soon"})]})]})]}),e.jsxs("div",{"data-settings-item":"tunnel.type",className:"space-y-1.5",children:[e.jsx("p",{className:$e,children:"Tunnel type"}),e.jsx("div",{className:"flex flex-wrap items-center gap-1",children:yt.map(c=>e.jsxs(Ur,{children:[e.jsx(zr,{asChild:!0,children:e.jsx(j,{variant:"chip",size:"xs","aria-pressed":A===c.value,className:"!font-normal",onClick:()=>{Wt(c.value)},disabled:R||s==="starting"||s==="stopping",children:c.label})}),e.jsx(Oi,{sideOffset:8,className:"max-w-xs",children:c.tooltip})]},c.value))})]})]}),e.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:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:ne($e,"shrink-0"),children:"Connect link TTL"}),e.jsxs(Re,{value:Nn(Ia,Ue,"1800000"),onValueChange:c=>{bs(c)},disabled:G||R||s==="starting"||s==="stopping",children:[e.jsx(De,{size:Fe,className:"max-w-[11rem] min-w-0",children:e.jsx(Oe,{className:"truncate",children:Ar(Ia,Ue,"1800000")})}),e.jsx(_e,{children:Ia.map(c=>e.jsx(je,{value:c.value,children:c.label},c.value))})]})]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:ne($e,"shrink-0"),children:"Tunnel session TTL"}),e.jsxs(Re,{value:Nn(Ea,it,"28800000"),onValueChange:c=>{Ls(c)},disabled:G||R||s==="starting"||s==="stopping",children:[e.jsx(De,{size:Fe,className:"max-w-[11rem] min-w-0",children:e.jsx(Oe,{className:"truncate",children:Ar(Ea,it,"28800000")})}),e.jsx(_e,{children:Ea.map(c=>e.jsx(je,{value:c.value,children:c.label},c.value))})]})]})]}),A==="quick"&&e.jsx("div",{className:"rounded-lg border border-[var(--status-warning)]/35 bg-[var(--status-warning)]/10 p-3",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(C,{name:"error-warning",className:"mt-0.5 size-4 shrink-0 text-[var(--status-warning)]"}),e.jsxs("div",{children:[e.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:"Quick Tunnel is best effort and uptime is not guaranteed."}),Es&&e.jsx("p",{className:"typography-meta mt-1 text-[var(--status-warning)]",children:"For more reliable long-lived access, switch to Managed Remote or Managed Local tunnel mode."})]})]})}),A==="managed-remote"&&e.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 Ke=="number"&&e.jsx("div",{className:"rounded-md border border-[var(--status-info-border)] bg-[var(--status-info-background)]/35 px-2 py-1.5",children:e.jsxs("p",{className:"typography-meta text-[var(--status-info)]",children:["Cloudflare connector target:"," ",e.jsxs("code",{children:["http://localhost:",Ke]})]})}),e.jsxs("div",{className:"mb-1 flex items-center justify-between gap-3",children:[e.jsx(Ra,{children:"Saved managed remote tunnels"}),e.jsxs(j,{variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>ce(c=>!c),disabled:s==="starting"||s==="stopping"||R,children:[e.jsx(C,{name:"add",className:"h-3.5 w-3.5"}),"Create"]})]}),W.length>0?e.jsx("div",{className:"overflow-hidden rounded-md border border-[var(--surface-subtle)]",children:W.map((c,_)=>{const ee=be[c.id]||"",q=D.has(c.id),ue=S[c.id]??!1;return e.jsx("div",{className:ne(_<W.length-1&&"border-b border-[var(--surface-subtle)]"),children:e.jsxs(Jr,{open:ue,onOpenChange:de=>{Y(se=>({...se,[c.id]:de})),de&&Dt(c.id)},className:"py-1.5",children:[e.jsxs("div",{className:"flex items-start gap-2 px-3",children:[e.jsxs(Yr,{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:s==="starting"||s==="stopping"||R,children:[ue?e.jsx(C,{name:"arrow-down-s",className:"h-4 w-4 text-muted-foreground"}):e.jsx(C,{name:"arrow-right-s",className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"typography-ui-label min-w-0 flex-1 truncate text-foreground",children:c.name})]}),e.jsx(j,{variant:"ghost",size:"xs",className:"h-7 w-7 p-0 text-muted-foreground hover:text-[var(--status-error)]","aria-label":`Remove ${c.name}`,onClick:()=>{Ot(c.id)},disabled:s==="starting"||s==="stopping"||R,children:e.jsx(C,{name:"delete-bin",className:"h-3.5 w-3.5"})})]}),e.jsx(Xr,{className:"pt-1.5",children:e.jsxs("div",{className:"space-y-1 px-3 pb-2",children:[e.jsxs("p",{className:"typography-meta text-muted-foreground/70",children:["Hostname:"," ",e.jsx("code",{children:c.hostname})]}),e.jsx(ie,{type:"password",value:ee,onChange:de=>{const se=de.target.value;g(null),Te(Pe=>({...Pe,[c.id]:se}))},onBlur:de=>{const se=de.currentTarget.value.trim();se&&Tt({presetId:c.id,presetName:c.name,hostname:c.hostname,token:se})},placeholder:q?"Saved token available (optional to replace)":"Paste token for this tunnel",className:"h-7",disabled:s==="starting"||s==="stopping"}),e.jsx("div",{className:"flex items-center justify-end",children:e.jsx(j,{variant:"ghost",size:"xs",className:"!font-normal",disabled:s==="starting"||s==="stopping"||ee.trim().length===0,onClick:()=>{Tt({presetId:c.id,presetName:c.name,hostname:c.hostname,token:ee})},children:"Save token"})})]})})]})},c.id)})}):e.jsx("p",{className:"typography-meta text-muted-foreground/70",children:"No managed remote tunnels saved yet."}),oe&&e.jsxs("div",{className:"space-y-2 rounded-md border border-[var(--surface-subtle)] p-2",children:[e.jsx(ie,{value:K,onChange:c=>we(c.target.value),placeholder:"Tunnel name (e.g. Production)",className:"h-7",disabled:R||s==="starting"||s==="stopping"}),e.jsx(ie,{value:Ce,onChange:c=>Xe(c.target.value),placeholder:"Hostname (e.g. oc.example.com)",className:"h-7",disabled:R||s==="starting"||s==="stopping"}),e.jsx(ie,{type:"password",value:Be,onChange:c=>ke(c.target.value),placeholder:"Token",className:"h-7",disabled:R||s==="starting"||s==="stopping"}),typeof Ke=="number"&&e.jsxs("p",{className:"typography-meta text-muted-foreground/70",children:["For Cloudflare connector target, use"," ",e.jsxs("code",{children:["http://localhost:",Ke]}),"."]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(j,{variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{ts()},disabled:R||s==="starting"||s==="stopping",children:"Save Changes"}),e.jsx(j,{variant:"ghost",size:"xs",className:"!font-normal",onClick:()=>{ce(!1),we(""),Xe(""),ke("")},disabled:R||s==="starting"||s==="stopping",children:"Cancel"})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("p",{className:"typography-meta text-muted-foreground/80",children:"Tokens are saved per tunnel and reused from disk."}),e.jsx(Ht,{children:"Tokens are saved in ~/.config/pichamber/cloudflare-managed-remote-tunnels.json."})]}),!ye&&T&&e.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:T})]}),A==="managed-local"&&e.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:e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:$e,children:"Configuration file"}),e.jsx("input",{ref:he,type:"file",accept:".yml,.yaml,.json",className:"hidden",onChange:c=>{Kt(c)}}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ie,{value:b||"",onChange:c=>{Rt(c.target.value)},onBlur:()=>{It()},placeholder:"Using default cloudflared config",className:"h-7",disabled:s==="starting"||s==="stopping"||R}),e.jsx(j,{variant:"outline",size:"xs",className:"h-7 w-7 p-0","aria-label":"Browse config file",onClick:()=>{Xt()},disabled:s==="starting"||s==="stopping"||R,children:e.jsx(C,{name:"folder",className:"size-3.5"})}),b&&e.jsx(j,{variant:"ghost",size:"xs",className:"h-7 w-7 p-0","aria-label":"Clear config file",onClick:()=>{xs()},disabled:s==="starting"||s==="stopping"||R,children:e.jsx(C,{name:"close",className:"size-3.5"})})]}),e.jsx("p",{className:"typography-meta text-muted-foreground/70",children:b?"Custom config file will be used when starting the tunnel.":"When empty, cloudflared uses its default config (~/.cloudflared/config.yml)."}),pe&&e.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:H})]})}),!vt&&e.jsxs("div",{"data-settings-item":"tunnel.start",className:"space-y-6",children:[e.jsx("div",{className:"rounded-lg border border-[var(--status-info-border)] bg-[var(--status-info-background)] p-3",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(C,{name:"information",className:"mt-0.5 size-4 shrink-0 text-[var(--status-info)]"}),e.jsxs("div",{className:"space-y-1",children:[A==="managed-remote"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"typography-meta text-[var(--status-info)]",children:"Managed remote tunnels require a purchased domain in your Cloudflare account."}),e.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(Jl)},children:["Check documentation on how to configure a managed remote tunnel",e.jsx(C,{name:"external-link",className:"size-3.5"})]})]}),A==="managed-local"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"typography-meta text-[var(--status-info)]",children:"Managed local tunnels use your local cloudflared configuration file."}),e.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(Yl)},children:["Check documentation on managed local tunnel configuration",e.jsx(C,{name:"external-link",className:"size-3.5"})]})]}),e.jsx("p",{className:"typography-meta text-[var(--status-info)]",children:`Start a ${pn.find(c=>c.value===A)?.label??"Quick"} tunnel and generate a one-time connect link. Do not close the app while this tunnel is in use.`})]})]})}),A==="managed-remote"&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:$e,children:"Managed remote tunnel to connect"}),e.jsxs(Re,{value:Z||(W[0]?.id??""),onValueChange:c=>{Dt(c)},disabled:R||s==="starting"||s==="stopping"||W.length<=1,children:[e.jsx(De,{size:Fe,children:e.jsx(Oe,{placeholder:"Select saved tunnel",children:ye?.name})}),e.jsx(_e,{fitContent:!0,children:W.map(c=>e.jsx(je,{value:c.id,children:c.name},c.id))})]})]}),Lt&&e.jsx("div",{className:"rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] p-3",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(C,{name:"error-warning",className:"mt-0.5 size-4 shrink-0 text-[var(--status-warning)]"}),e.jsx("p",{className:"typography-meta text-[var(--status-warning)]",children:"Starting this tunnel replaces the active tunnel and revokes existing connect links and remote sessions."})]})}),e.jsx(j,{size:"sm",variant:"outline",onClick:Zt,disabled:s==="starting"||R||A==="managed-remote"&&!ye||A==="managed-local"&&pe,className:ne(ss,s==="starting"&&"opacity-70"),children:s==="starting"?e.jsxs(e.Fragment,{children:[e.jsx(C,{name:"loader-4",className:"size-3.5 animate-spin"})," ","Starting tunnel..."]}):"Start Tunnel"})]})]}),vt&&o&&e.jsxs("section",{"data-settings-item":"tunnel.start",className:"space-y-4 px-2 pb-2 pt-0",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"size-2 shrink-0 rounded-full bg-[var(--status-success)]"}),e.jsx("p",{className:"typography-meta font-medium text-foreground",children:"Tunnel ready"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"typography-meta mb-1 text-muted-foreground/70",children:"Public URL (not accessible without a token)"}),e.jsx("code",{className:"typography-code block truncate rounded bg-muted/50 px-2 py-1 text-xs text-foreground",children:o.url})]}),He&&o.connectUrl&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("p",{className:"typography-meta mb-1 text-muted-foreground/70",children:"Connect link"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("code",{className:"typography-code flex-1 truncate rounded bg-muted/50 px-2 py-1 text-xs text-foreground",children:o.connectUrl}),e.jsxs(j,{size:"sm",variant:"ghost",onClick:Ms,className:"shrink-0 gap-1.5",children:[U?e.jsx(C,{name:"check",className:"size-3.5 text-[var(--status-success)]"}):e.jsx(C,{name:"file-copy",className:"size-3.5"}),U?"Copied":"Copy all"]})]}),e.jsxs("p",{className:"typography-meta mt-1 text-muted-foreground/70",children:["Expires",": ",o.bootstrapExpiresAt?St:"Never"]})]}),e.jsxs("div",{className:"flex flex-col items-center gap-2 rounded-lg border border-border/50 bg-[var(--surface-elevated)] p-4",children:[u?e.jsx("img",{src:u,alt:"Tunnel connect QR code",className:"size-48"}):e.jsx("div",{className:"size-48 rounded bg-muted/30"}),e.jsx("p",{className:"typography-meta text-muted-foreground",children:"Scan with your phone to connect."})]})]})]}),e.jsx("div",{className:"pt-1",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(j,{size:"sm",variant:"outline",onClick:Zt,disabled:s==="stopping"||R||A==="managed-local"&&pe,className:ss,children:[e.jsx(C,{name:"restart",className:"size-3.5"}),"New connect link"]}),e.jsx(j,{size:"sm",variant:"ghost",onClick:es,disabled:s==="stopping"||R,className:"gap-2 text-[var(--status-error)]",children:s==="stopping"?e.jsxs(e.Fragment,{children:[e.jsx(C,{name:"loader-4",className:"size-3.5 animate-spin"})," ","Stopping..."]}):"Stop Tunnel"})]})})]}),s==="error"&&L&&e.jsxs("section",{className:"space-y-3 px-2 pb-2 pt-0",children:[e.jsx("p",{className:"typography-meta text-[var(--status-error)]",children:L}),e.jsx(j,{size:"sm",variant:"ghost",onClick:Zt,children:"Retry"})]})]})})},ui=()=>{const t=Ve()&&ya(),s=t&&typeof window<"u"&&window.__PICHAMBER_PLATFORM__==="darwin",[i,o]=le.useState(!1),[l,h]=le.useState(!1),[f,u]=le.useState(""),[x,L]=le.useState(""),[d,T]=le.useState(!1),[g,U]=le.useState(!1),[M,G]=le.useState(null),[I,R]=le.useState(!0),[$,J]=le.useState(!1),[v,w]=le.useState(!1),[m,F]=le.useState(!1),[y,A]=le.useState(!1),[O,b]=le.useState(!1),[B,W]=le.useState(!1),[X,S]=le.useState(!1),[Y,Z]=le.useState(!0),[ge,be]=le.useState(!0),[Te,D]=le.useState(!1),[V,oe]=le.useState(!1),[ce,K]=le.useState(!1),[we,Ce]=le.useState(null),[Xe,Be]=le.useState(null);le.useEffect(()=>{if(!t){R(!1);return}let te=!1;return(async()=>{try{const P=await Je("/api/pi/ui-settings",{method:"GET",headers:{Accept:"application/json"}});if(!P.ok)throw new Error("Failed to load desktop settings");const H=await P.json().catch(()=>null);if(te)return;const he=H?.desktopLanAccessEnabled===!0,pe=typeof H?.desktopUiPassword=="string"?H.desktopUiPassword:"";o(he),h(he),u(pe),L(pe),U(H?.desktopLanAccessActive===!0),G(typeof H?.desktopLanAccessBlockedReason=="string"?H.desktopLanAccessBlockedReason:null);const ye=H?.desktopMacMenuBarEnabled!==!1;Z(ye),be(ye),Ce(null)}catch(P){te||Ce(P instanceof Error?P.message:"Failed to load desktop settings")}finally{te||R(!1)}})(),()=>{te=!0}},[t]),le.useEffect(()=>{if(!t){w(!1);return}let te=!1;return(async()=>{const P=await ro();te||(w(P?.supported===!0),F(P?.enabled===!0))})(),()=>{te=!0}},[t]),le.useEffect(()=>{if(!t){b(!1);return}let te=!1;return(async()=>{const P=await io();te||(b(P?.supported===!0),W(P?.enabled===!0))})(),()=>{te=!0}},[t]),le.useEffect(()=>{if(!t){D(!1);return}let te=!1;return(async()=>{const P=await oo();te||(D(P?.supported===!0),oe(P?.enabled===!0))})(),()=>{te=!0}},[t]),le.useEffect(()=>{if(!t||!l){Be(null);return}let te=!1;return(async()=>{const P=await Hr();te||Be(P)})(),()=>{te=!0}},[l,t]);const ke=l!==i||x!==f||ge!==Y,Ue=le.useMemo(()=>{if(typeof window>"u")return null;const P=va()||window.location.href;let H=0;try{H=Number(new URL(P).port)}catch{H=Number(window.location.port)}return Number.isFinite(H)&&H>0?H:null},[]),Ze=l&&g&&Xe&&Ue?`http://${Xe}:${Ue}`:null,it=l&&!x.trim(),Ie=i&&!g&&M==="missing-password",St=I||$||!ke||it,Nt=le.useCallback(te=>{L(te),te.trim()||h(!1)},[]),bt=le.useCallback(async()=>{if(!v||y)return;const te=!m;F(te),A(!0),Ce(null);try{const P=await lo(te);if(!P?.supported)throw new Error("Launch at login is not supported on this system");F(P.enabled)}catch(P){F(!te),Ce(P instanceof Error?P.message:"Failed to update launch at login setting")}finally{A(!1)}},[y,m,v]),fe=le.useCallback(async()=>{if(!O||X)return;const te=!B;W(te),S(!0),Ce(null);try{const P=await co(te);if(!P)throw new Error("Failed to update system tray setting");if(!P.supported)throw new Error("System tray background mode is not supported on this system");W(P.enabled)}catch(P){W(!te),Ce(P instanceof Error?P.message:"Failed to update system tray setting")}finally{S(!1)}},[X,B,O]),et=le.useCallback(async()=>{if(!Te||ce)return;const te=!V;oe(te),K(!0),Ce(null);try{const P=await uo(te);if(!P?.supported)throw new Error("Preventing sleep is not supported on this system");oe(P.enabled)}catch(P){oe(!te),Ce(P instanceof Error?P.message:"Failed to update keep awake setting")}finally{K(!1)}},[ce,V,Te]),Ct=le.useCallback(async()=>{if(ke){J(!0),Ce(null);try{if(!(await Je("/api/pi/ui-settings",{method:"PUT",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({desktopLanAccessEnabled:l,desktopUiPassword:x,desktopMacMenuBarEnabled:ge})})).ok)throw new Error("Failed to save desktop settings");if(o(l),u(x),Z(ge),!await mo())throw new Error("Saved, but failed to restart app")}catch(te){Ce(te instanceof Error?te.message:"Failed to save desktop settings"),J(!1)}}},[ge,x,l,ke]);return t?e.jsx(ae,{title:"Desktop Network Access",children:e.jsxs("div",{className:"space-y-3",children:[v||s||O||Te?e.jsxs("div",{className:ft,children:[v?e.jsx(me,{settingsItem:"sessions.desktop-launch-at-login",checked:m,onChange:te=>{te!==m&&bt()},disabled:y,label:"Start PiChamber when you log in",info:"Starts the app in the background without opening a window. Use the desktop status icon to open it.",ariaLabel:"Start PiChamber at login"}):null,s?e.jsx(me,{settingsItem:"sessions.desktop-mac-menu-bar",checked:ge,onChange:be,disabled:I||$,label:"Show PiChamber in the menu bar",info:"Requires an app restart. When off, PiChamber does not create the menu bar item or run its session, approval, and usage updates.",ariaLabel:"Show PiChamber in the macOS menu bar"}):null,O?e.jsx(me,{settingsItem:"sessions.desktop-minimize-to-tray",checked:B,onChange:te=>{te!==B&&fe()},disabled:X,label:"Minimize and close to the system tray",info:"Keeps PiChamber running in the system tray when the main window is minimized or closed.",ariaLabel:"Minimize and close PiChamber to the system tray"}):null,Te?e.jsx(me,{settingsItem:"sessions.desktop-keep-awake",checked:V,onChange:te=>{te!==V&&et()},disabled:ce,label:"Keep computer awake while PiChamber is running",info:"Prevents system sleep so phones can keep reaching this app. The screen can still turn off.",ariaLabel:"Keep computer awake while PiChamber is running"}):null]}):null,e.jsxs(Le,{settingsItem:"sessions.desktop-ui-password",label:e.jsx("label",{htmlFor:"desktop-ui-password",children:"Desktop UI Password"}),info:"PiChamber asks after restart, then when the login session expires: after 12 hours, or 7 days with Trust this device. Leave empty to disable login.",children:[e.jsx(ie,{id:"desktop-ui-password",type:d?"text":"password",className:"h-8 min-w-0 flex-1",value:x,onChange:te=>Nt(te.target.value),placeholder:"No password required",disabled:I||$,required:l,"aria-invalid":it}),e.jsx(j,{type:"button",variant:"ghost",size:"xs",onClick:()=>T(te=>!te),className:nt,"aria-label":d?"Hide password":"Show password","aria-pressed":d,children:e.jsx(C,{name:d?"eye-off":"eye",className:"h-4 w-4"})})]}),e.jsx("div",{className:ft,children:e.jsx(me,{settingsItem:"sessions.desktop-lan-access",checked:l,onChange:h,disabled:I||$,label:"Let other devices on your local network open this app",info:"Restarts the app so phones, tablets, and other computers on your Wi-Fi can open it. On Windows, allow PiChamber through the firewall if a phone still cannot connect.",description:e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"block text-[var(--status-warning)]/85",children:"Warning: while enabled, the app is reachable by anyone on the same local network."}),it||Ie?e.jsx("span",{className:"block text-[var(--status-warning)]/85",children:"LAN access requires a Desktop UI Password. Until one is set, the desktop app starts local-only."}):null]}),ariaLabel:"Allow LAN access to desktop sidecar"})}),we?e.jsx("div",{className:"typography-micro text-[var(--status-error)]",children:we}):null,Ze?e.jsxs("div",{className:"typography-micro text-muted-foreground/80",children:[ke&&!i?"After restart, open from another device: ":"Open from another device: ",e.jsx("span",{className:"font-mono text-foreground",children:Ze})]}):null,e.jsx("div",{className:"flex justify-start py-1.5",children:e.jsx(j,{type:"button",size:"xs",onClick:Ct,disabled:St,className:"shrink-0 !font-normal",children:$?"Saving...":"Save + Restart"})})]})}):null},mi=new Set(["shift","control","alt","meta"]),ic=t=>{if(mi.has(t.key.toLowerCase()))return null;const s=[];(t.metaKey||t.ctrlKey)&&s.push("mod"),t.shiftKey&&s.push("shift"),t.altKey&&s.push("alt");const i=Br(t.key);return i?(s.push(i),Yt(s.join("+"))):null},oc=t=>{const s=[];if((t.metaKey||t.ctrlKey)&&s.push("mod"),t.shiftKey&&s.push("shift"),t.altKey&&s.push("alt"),mi.has(t.key.toLowerCase()))return s.length>0?Yt(s.join("+")):null;const i=Br(t.key);return i?(s.push(i),s.length>0?Yt(s.join("+")):null):null},lc={add_selection_to_chat:"Add selection to chat",cycle_agent:"Cycle agent",cycle_favorite_model_backward:"Cycle favorite model backward",cycle_favorite_model_forward:"Cycle favorite model forward",cycle_services_tab:"Cycle services tab",cycle_theme:"Cycle theme",focus_input:"Focus input",new_chat:"New session",new_mini_chat:"New Mini Chat window",open_command_palette:"Open command palette",open_go_to_line:"Go to line (files editor)",open_help:"Open keyboard shortcuts",open_model_selector:"Open model selector",open_right_sidebar_files:"Open Files surface",open_right_sidebar_git:"Open Git surface",open_settings:"Open settings",open_timeline_dialog:"Open conversation timeline",switch_context_surface:"Switch context panel surface",toggle_prompt_navigator:"Toggle prompt navigator",toggle_right_sidebar:"Toggle context panel",toggle_services_menu:"Toggle services menu",toggle_sidebar:"Toggle sidebar",toggle_terminal:"Toggle terminal dock",toggle_terminal_expanded:"Toggle terminal expanded"},cc=()=>{const t=k(w=>w.shortcutOverrides),s=k(w=>w.setShortcutOverride),i=k(w=>w.clearShortcutOverride),o=k(w=>w.resetAllShortcutOverrides),l=n.useMemo(()=>Fi(),[]),h=n.useCallback((w,m)=>lc[w]??m,[]),[f,u]=n.useState(null),[x,L]=n.useState({}),[d,T]=n.useState(""),[g,U]=n.useState(""),[M,G]=n.useState(null),I=n.useCallback(w=>{ve({shortcutOverrides:w})},[]),R=n.useCallback((w,m)=>{const F=Yt(m);for(const y of l){if(y.id===w)continue;const A=Vn(y.id,t);if(Yt(A)===F)return y.id}return null},[l,t]),$=n.useCallback((w,m)=>{const F=Yt(m),y=R(w,F);if(y){G({actionId:w,combo:F,conflictActionId:y}),T("");return}const A={...t,[w]:F};s(w,F),I(A),G(null),T(""),U(Kn(F)?"This shortcut can conflict with browser defaults. It is still saved.":""),L(O=>{const b={...O};return delete b[w],b})},[R,I,s,t]),J=n.useCallback(()=>{if(!M)return;const w={...t,[M.conflictActionId]:nn,[M.actionId]:M.combo};s(M.conflictActionId,nn),s(M.actionId,M.combo),I(w),G(null),T(""),U(Kn(M.combo)?"This shortcut can conflict with browser defaults. It is still saved.":""),L(m=>{const F={...m};return delete F[M.actionId],F})},[M,I,s,t]),v=n.useCallback(w=>{const m={...t};delete m[w],i(w),I(m),L(F=>{const y={...F};return delete y[w],y}),G(null),T(""),U("")},[i,I,t]);return e.jsxs(ae,{settingsItem:"shortcuts.keyboard-shortcuts",title:"Keyboard Shortcuts",divider:!1,info:"Capture a new key combo, save it, and bindings will update immediately.",headerAction:e.jsx(j,{type:"button",variant:"outline",size:"xs",className:"!font-normal",onClick:()=>{o(),I({}),L({}),G(null),T(""),U("")},children:"Reset All"}),children:[(d||g||M)&&e.jsxs("div",{className:"mb-2 space-y-2",children:[M&&e.jsxs("div",{className:"rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] p-3 flex flex-col @xl:flex-row @xl:items-center justify-between gap-3",children:[e.jsx("span",{className:"typography-meta text-foreground",children:"This combo is already used by another shortcut. Overwrite and clear that other mapping?"}),e.jsxs("div",{className:"flex gap-2 shrink-0",children:[e.jsx(j,{type:"button",size:"xs",className:"!font-normal",onClick:J,children:"Overwrite"}),e.jsx(j,{type:"button",size:"xs",className:"!font-normal",variant:"ghost",onClick:()=>G(null),children:"Cancel"})]})]}),d&&e.jsx("div",{className:"rounded-lg border border-[var(--status-error-border)] bg-[var(--status-error-background)] p-3 typography-meta text-foreground",children:d}),g&&e.jsx("div",{className:"rounded-lg border border-[var(--status-warning-border)] bg-[var(--status-warning-background)] p-3 typography-meta text-foreground",children:g})]}),e.jsx("div",{children:l.map((w,m)=>{const F=w.id==="switch_context_surface",y=F?Ui(w.id,t):Vn(w.id,t),A=x[w.id],O=A??y,b=typeof A=="string"&&Yt(A)!==Yt(y),B=O===""||Yt(O)===nn,W=f===w.id?"Press keys...":F&&!B?`${Wn(O)} + 1…0`:Wn(O);return e.jsx("div",{className:ne("py-1.5",m>0&&"border-t border-border/40"),children:e.jsxs(Ge,{label:h(w.id,w.label),alignEnd:!1,children:[e.jsx(ie,{readOnly:!0,value:W,onFocus:()=>{u(w.id),T("")},onBlur:()=>{f===w.id&&u(null)},onKeyDown:X=>{if(X.preventDefault(),X.stopPropagation(),X.key==="Escape"){u(null);return}const S=F?oc(X):ic(X);S&&(L(Y=>({...Y,[w.id]:S})),u(null),G(null),T(""))},className:"h-7 w-40 min-w-0 typography-ui-label text-center"}),e.jsx(j,{type:"button",variant:"secondary",size:"xs",className:"!font-normal",onClick:()=>{const X=x[w.id];if(!X){T("Capture a shortcut first.");return}$(w.id,X)},disabled:!b,children:"Save Changes"}),e.jsx(j,{type:"button",size:"xs",className:"!font-normal",variant:"ghost",onClick:()=>v(w.id),children:"Reset"})]})},w.id)})})]})},pi=()=>{const[t,s]=n.useState(0);return n.useEffect(()=>$r(()=>s(i=>i+1)),[]),t},dc=({section:t})=>{const{isMobile:s}=ba();pi();const i=s&&hs(),o=Ve()&&ya();if(!t)return e.jsxs(xt,{showSaveStatus:!0,className:"pichamber-page-body space-y-3 sm:space-y-6",children:[e.jsx(Fa,{}),e.jsx(li,{}),o&&e.jsx(ui,{}),e.jsx(ii,{}),hs()&&!Ve()&&!ei()&&e.jsx(oi,{}),i&&e.jsx(ai,{})]});const l=()=>{switch(t){case"general":return e.jsx(mc,{});case"visual":return e.jsx(pc,{});case"chat":return e.jsx(hc,{});case"sessions":return e.jsx(gc,{});case"shortcuts":return e.jsx(uc,{});case"git":return e.jsx(fc,{});case"github":return e.jsx(xc,{});case"notifications":return e.jsx(bc,{});case"tunnel":return e.jsx(vc,{});default:return null}},h={general:"General",visual:"Appearance",chat:"Chat",sessions:"Sessions",shortcuts:"Shortcuts",git:"Git",github:"Git",notifications:"Notifications",tunnel:"External Tunnel"}[t],f={general:"App startup, security, connection, privacy, and diagnostics.",visual:"Customize how PiChamber looks and feels.",chat:"Configure how messages and tools are displayed.",sessions:"Set defaults and retention for sessions.",shortcuts:"Customize keyboard shortcuts.",git:void 0,github:void 0,notifications:"Choose when and how you get notified.",tunnel:"Expose this instance over a remote tunnel."}[t];return e.jsx(xt,{title:h,description:f,showSaveStatus:!0,className:"pichamber-page-body",children:l()})},uc=()=>e.jsx(cc,{}),mc=()=>{pi();const t=Ve()&&ya(),s=hs()&&!Ve()&&!ei();return e.jsxs(e.Fragment,{children:[t&&e.jsx(ui,{}),s&&e.jsx(oi,{}),e.jsx(Fa,{visibleSettings:["fileEditorKeymap","autoSaveEnabled","expandedEditorToolbar","terminalQuickKeys","terminalShell","terminalLoginShell","messageTransport","reportUsage","perfHud"]})]})},pc=()=>e.jsx(Fa,{visibleSettings:["theme","windowControlsPosition","pwaInstallName","pwaOrientation","mobileKeyboardMode","timeFormat","weekStart","fontSize","terminalFontSize","editorFontSize","spacing","inputBarOffset"]}),hc=()=>e.jsx(Fa,{visibleSettings:["userMessageRendering","mermaidRendering","reasoning","showToolFileIcons","showTurnChangedFiles","expandedTools","collapsibleUserMessages","stickyUserHeader","promptNavigatorEnabled","wideChatLayout","codeBlockLineWrap","splitAssistantMessageActions","subagentReadOnlyBanner","diffLayout","dotfiles","fileViewerPreview","followUpBehavior","persistDraft","inputSpellcheck"]}),gc=()=>e.jsxs(e.Fragment,{children:[e.jsx(li,{}),e.jsx(ii,{})]}),fc=()=>e.jsx(_n,{}),xc=()=>e.jsx(_n,{}),bc=()=>e.jsx(Ql,{}),vc=()=>e.jsx(rc,{}),yc=[{id:"appearance.time-format",page:"appearance",title:"Time Format",keywords:["clock","12h","24h"]},{id:"appearance.week-start",page:"appearance",title:"Week Starts On",keywords:["calendar","monday","sunday"]},{id:"appearance.light-theme",page:"appearance",title:"Light Theme",keywords:["theme","color","light mode"]},{id:"appearance.dark-theme",page:"appearance",title:"Dark Theme",keywords:["theme","color","dark mode"]},{id:"appearance.dock-badge",page:"appearance",title:"Dock badge",description:"Show a count of chats with unseen activity on the macOS dock icon.",keywords:["dock","badge","unread","unseen","counter","count","notification","macos"],isAvailable:t=>t.isMac},{id:"appearance.pwa-install-name",page:"appearance",title:"Install App Name",description:"Used by PWA installation process.",keywords:["pwa","installed app"],isAvailable:t=>t.isWeb&&!t.isDesktop},{id:"appearance.pwa-orientation",page:"appearance",title:"Install Orientation",description:"Used by the installed web app. Reinstall the PWA after changing this.",keywords:["pwa","portrait","landscape"],isAvailable:t=>t.isWeb&&!t.isDesktop},{id:"appearance.mobile-keyboard-mode",page:"appearance",title:"Mobile Keyboard Behavior",description:"Default browser behavior is safest. Resize content asks supported browsers to shrink the app when the on-screen keyboard opens.",keywords:["mobile","keyboard","resize"],isAvailable:t=>t.isMobile&&t.isWeb&&!t.isDesktop},{id:"appearance.interface-font-size",page:"appearance",title:"Interface Font Size",keywords:["font","text size","ui scale"]},{id:"appearance.terminal-font-size",page:"appearance",title:"Terminal Font Size",keywords:["terminal","font","text size"]},{id:"appearance.terminal-shell",page:"general",title:"Terminal Shell",description:"Restart the terminal to apply this change to the current session.",keywords:["terminal","shell","bash","zsh","fish","pwsh","powershell"]},{id:"appearance.editor-font-size",page:"appearance",title:"Editor Font Size",keywords:["editor","font","text size","code"]},{id:"appearance.spacing-density",page:"appearance",title:"Spacing Density",keywords:["density","compact","comfortable","spacing"]},{id:"appearance.input-bar-offset",page:"appearance",title:"Input Bar Offset",description:"Raise input bar to avoid OS-level screen obstructions like home bars.",keywords:["input","home bar","offset"],isAvailable:t=>t.isMobile},{id:"appearance.auto-save-enabled",page:"general",title:"Auto-save files",description:"Automatically save file edits after you stop typing. Disable to require manual save.",keywords:["editor","autosave","auto-save","files","save"]},{id:"appearance.expanded-editor-toolbar",page:"general",title:"Always show editor toolbar (docked under the file tabs)",keywords:["editor","toolbar","tabs","docked","files"]},{id:"appearance.file-editor-keymap",page:"general",title:"File editor keymap",keywords:["editor","vim","keymap"]},{id:"appearance.terminal-quick-keys",page:"general",title:"Terminal Quick Keys",description:"Show Esc, Ctrl, Arrows in terminal view",keywords:["terminal","keyboard","esc","ctrl","arrows"]},{id:"appearance.usage-reports",page:"general",title:"Send anonymous usage reports",description:"Helps us understand which app versions are actively used so we can prioritize improvements. Only app version, platform, and runtime are collected - no personal data or code.",keywords:["telemetry","analytics"]},{id:"general.performance-overlay",page:"general",title:"Performance overlay",description:"Show a live frame-time overlay for debugging jank. Adds overhead and stays on this device only.",keywords:["fps","performance","hud","diagnostics","debug","jank","frame"]},{id:"chat.message-transport",page:"general",title:"Message Stream Transport",keywords:["streaming","sse","websocket"]},{id:"chat.reasoning-traces",page:"chat",title:"Show Reasoning Traces",keywords:["thinking","reasoning"]},{id:"chat.collapsible-reasoning",page:"chat",title:"Enable Collapsible Reasoning Blocks",keywords:["thinking","reasoning","collapse","expand"]},{id:"chat.collapsed-reasoning-default",page:"chat",title:"Collapsed by Default",description:"Open thinking while it streams, then fold it. Turn off to keep a one-line trace unless you expand it.",keywords:["thinking","reasoning","collapse","default"]},{id:"chat.reasoning",page:"chat",title:"Reasoning",keywords:["thinking","traces"]},{id:"chat.sticky-user-header",page:"chat",title:"Sticky User Header",keywords:["messages","header"]},{id:"chat.prompt-navigator",page:"chat",title:"Prompt Navigator",keywords:["prompt","navigator","navigation","timeline","scroll"]},{id:"chat.collapsible-user-messages",page:"chat",title:"Collapse Long User Messages",keywords:["collapse","expand","clamp","long messages","user messages"]},{id:"chat.wide-layout",page:"chat",title:"Wide Chat Layout",keywords:["layout","wide","messages"]},{id:"chat.message-appearance",page:"chat",title:"Message Appearance",keywords:["layout","messages","appearance"]},{id:"chat.code-block-line-wrap",page:"chat",title:"Wrap Code Block Lines",keywords:["code","wrap","line wrap","markdown"]},{id:"chat.inline-assistant-actions",page:"chat",title:"Inline Assistant Actions",description:"Show Copy Answer, Save as image, and Read aloud on assistant text blocks that appear before later tool calls in the same response.",keywords:["copy","save image","read aloud"]},{id:"chat.draft-starters-visible",page:"chat",title:"Show Starters on New Session Screen",keywords:["starter","starters","new session","welcome","suggestions"]},{id:"chat.subagent-read-only-banner",page:"chat",title:"Allow Prompting Subagent Sessions",keywords:["subagent","read only","prompt","banner"]},{id:"chat.tool-file-icons",page:"chat",title:"Show Tool File Icons",keywords:["tools","files","icons"]},{id:"chat.tools-and-files",page:"chat",title:"Tools & Files",keywords:["tools","files","dotfiles"]},{id:"chat.changed-files",page:"chat",title:"Show Changed Files for Completed Turns",keywords:["changed files","turns"]},{id:"chat.dotfiles",page:"chat",title:"Show Dotfiles",keywords:["hidden files"]},{id:"chat.follow-up-behavior",page:"chat",title:"Follow-up behavior",description:"Choose what happens when you press Enter on a follow-up message while the agent is still responding.",keywords:["follow up","queue","steer","send immediately"]},{id:"chat.persist-drafts",page:"chat",title:"Persist Draft Messages",keywords:["draft","message"]},{id:"chat.composer",page:"chat",title:"Composer",keywords:["input","draft","spellcheck"]},{id:"chat.spellcheck",page:"chat",title:"Enable Spellcheck in Text Inputs",keywords:["spelling","input"]},{id:"sessions.default-model",page:"sessions",title:"Default Model",keywords:["model","provider","new sessions","picker"]},{id:"sessions.default-thinking",page:"sessions",title:"Default Thinking",keywords:["thinking","reasoning","variant","new sessions","per model"]},{id:"sessions.thinking-defaults",page:"sessions",title:"Thinking defaults",description:"Per-model thinking for new sessions and composer model changes.",keywords:["thinking","reasoning","per model","default thinking"]},{id:"sessions.deletion-dialog",page:"sessions",title:"Show Deletion Dialog",keywords:["delete","confirmation"]},{id:"sessions.small-model",page:"sessions",title:"Small Model",description:"A cheap model for quick utility tasks like short recaps and summaries.",keywords:["small model","utility","summary","recap","cheap","override","picker"]},{id:"sessions.walkthrough-model",page:"sessions",title:"Changes Walkthrough Model",description:"The AI review of your changes needs structured output and room for a whole diff, which a cheap small model often cannot give. Models the catalog reports as unable to produce structured output are hidden from this picker. Leave it unset and the small model is used.",keywords:["walkthrough","diff","review","changes","structured output","model","override","picker"]},{id:"sessions.auto-cleanup",page:"sessions",title:"Enable Auto-Cleanup",description:"Automatically archive or delete inactive sessions based on last activity. Keeps the 5 most recent sessions.",keywords:["retention","archive","delete"]},{id:"sessions.retention-period",page:"sessions",title:"Retention Period",keywords:["days","cleanup","retention"]},{id:"sessions.retention-action",page:"sessions",title:"When sessions expire",keywords:["archive","delete","expire"]},{id:"sessions.desktop-launch-at-login",page:"general",title:"Start PiChamber when you log in",description:"Starts the app in the background without opening a window. Use the desktop status icon to open it.",keywords:["desktop","startup","login","launch","background","autostart"],isAvailable:t=>t.isDesktopLocalOrigin},{id:"sessions.desktop-window-controls-position",page:"appearance",title:"Window controls position",description:"Choose where minimize, maximize, and close buttons appear. Defaults to the right.",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",title:"Style",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",title:"Show PiChamber in the menu bar",description:"Requires an app restart. When off, PiChamber does not create the menu bar item or run its session, approval, and usage updates.",keywords:["desktop","menu bar","tray","status item","macos","background"],isAvailable:t=>t.isDesktopLocalOrigin&&t.isMac},{id:"sessions.desktop-minimize-to-tray",page:"general",title:"Minimize and close to the system tray",description:"Keeps PiChamber running in the system tray when the main window is minimized or closed.",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",title:"Keep computer awake while PiChamber is running",description:"Prevents system sleep so phones can keep reaching this app. The screen can still turn off.",keywords:["desktop","sleep","awake","server","mobile","phone"],isAvailable:t=>t.isDesktopLocalOrigin},{id:"sessions.desktop-ui-password",page:"general",title:"Desktop UI Password",description:"PiChamber asks after restart, then when the login session expires: after 12 hours, or 7 days with Trust this device. Leave empty to disable login.",keywords:["desktop","password","auth","login"],isAvailable:t=>t.isDesktopLocalOrigin},{id:"sessions.desktop-lan-access",page:"general",title:"Let other devices on your local network open this app",description:"Restarts the app so phones, tablets, and other computers on your Wi-Fi can open it. On Windows, allow PiChamber through the firewall if a phone still cannot connect.",keywords:["desktop","lan","network","phone","tablet","wifi","firewall"],isAvailable:t=>t.isDesktopLocalOrigin},{id:"sessions.opencode-binary",page:"general",title:"OpenCode CLI binary path",keywords:["opencode","cli","binary","path"]},{id:"sessions.opencode-update-notifications",page:"general",title:"Show update notifications",keywords:["opencode","cli","updates"],isAvailable:t=>!t.isWindowsArm64},{id:"git.github-account",page:"git",title:"Connect GitHub",keywords:["github","account","oauth","prs","issues"]},{id:"git.identities",page:"git",title:"Identities",description:"Create one to manage Git author settings per project",keywords:["identity","profile","author","email","credentials","signing","commit signing","ssh signing","gpg"]},{id:"git.changes-view",page:"git",title:"Changes View",keywords:["changes","flat list","tree view"]},{id:"git.gitmoji",page:"git",title:"Enable Gitmoji Picker",keywords:["commit","emoji"]},{id:"git.gitignored-files",page:"git",title:"Display Gitignored Files",keywords:["ignored","files","gitignore"]},{id:"projects.name",page:"projects",title:"Name",keywords:["label","display name","project metadata","project name"]},{id:"projects.default-model",page:"projects",title:"Default model",keywords:["model","provider","new chat","session default","project metadata"]},{id:"projects.worktree",page:"projects",title:"Worktree",keywords:["worktree","branch","repository"]},{id:"projects.worktree.setup.wait",page:"projects",title:"Wait for setup commands before creating or sending a session",keywords:["worktree","setup commands","bootstrap","wait"]},{id:"remote-instances.client-auth",page:"remote-instances",title:"Connect to this server",description:"Create a secure link or token so PiChamber Desktop can connect to this server.",keywords:["pairing link","client token","connect desktop","remote access","relay","devices","connect from anywhere"]},{id:"remote-instances.direct-hosts",page:"remote-instances",title:"Other PiChamber servers",description:"Servers this app can switch to. Import a pairing link from the other server, or add one by address.",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",title:"Global AGENTS.md",description:"Global rules are combined with project rules",keywords:["agents.md","global instructions","system prompt"]},{id:"behavior.response-style",page:"behavior",title:"Response style",description:"When enabled, these instructions guide how the assistant responds in each new conversation. They are sent with your first message and do not change your global AGENTS.md rules.",keywords:["tone","concise","detailed","custom instructions"]},{id:"snippets.create",page:"snippets",title:"Create snippet",keywords:["add","new snippet"]},{id:"snippets.content",page:"snippets",title:"Content",keywords:["markdown","prompt","template"]},{id:"providers.connect",page:"providers",title:"Connect Provider",keywords:["add provider","connect provider","credentials"]},{id:"providers.custom",page:"providers",title:"Custom provider",description:"Add an OpenAI-compatible provider with a base URL, credentials, and model list. Saved to Pi so it is available in chat like any other provider.",keywords:["other","custom","openai-compatible","base url","api key"]},{id:"providers.auth",page:"providers",title:"Authentication",keywords:["api key","oauth","credentials"]},{id:"providers.connection-details",page:"providers",title:"Connection Details",keywords:["config","source","disconnect"]},{id:"providers.models",page:"providers",title:"Available Models",description:"Hide models you do not want in the composer or session default pickers.",keywords:["models","hide","show"]},{id:"skills.discovery",page:"skills.installed",title:"Skills",keywords:["skills","agent skills","project resources"]},{id:"magic-prompts.visible-prompt",page:"magic-prompts",title:"Visible Prompt",keywords:["prompt text","user message","template"]},{id:"magic-prompts.instructions",page:"magic-prompts",title:"Instructions",keywords:["hidden prompt","instructions","template"]},{id:"magic-prompts.reset-overrides",page:"magic-prompts",title:"Reset All Overrides",keywords:["reset","default prompts","overrides"]},{id:"shortcuts.keyboard-shortcuts",page:"shortcuts",title:"Keyboard Shortcuts",description:"Capture a new key combo, save it, and bindings will update immediately.",keywords:["keyboard","hotkeys","bindings"]},{id:"tunnel.provider",page:"tunnel",title:"Provider",description:"Configure secure remote access with quick links or your own managed remote Cloudflare tunnel.",keywords:["remote access","cloudflare","ngrok"]},{id:"tunnel.type",page:"tunnel",title:"Tunnel type",keywords:["quick","managed remote","managed local"]},{id:"tunnel.ttl",page:"tunnel",title:"Connect link TTL",description:"Tunnel session TTL",keywords:["expiry","expiration","session ttl","connect link ttl"]},{id:"tunnel.managed-remote",page:"tunnel",title:"Saved managed remote tunnels",keywords:["cloudflare","hostname","token","managed remote"]},{id:"tunnel.managed-local-config",page:"tunnel",title:"Configuration file",description:"Managed local tunnels use your local cloudflared configuration file.",keywords:["cloudflared","config","yaml","json","managed local"]},{id:"tunnel.start",page:"tunnel",title:"Start Tunnel",description:"Connect links are one-time and are revoked when tunnel stops or connect-link TTL expires.",keywords:["connect link","qr code","public url","remote access"]},{id:"notifications.delivery",page:"notifications",title:"Notification Delivery",keywords:["desktop notifications","system notifications"]},{id:"notifications.events",page:"notifications",title:"Notification Events",keywords:["completion","subtasks","errors","questions"]},{id:"notifications.push",page:"notifications",title:"Background Push Notifications",keywords:["background","push"],isAvailable:t=>t.isWeb&&!t.isDesktop}];function Lr(t){return t.trim().toLocaleLowerCase()}function wc({query:t,runtimeCtx:s,visiblePageSlugs:i,getPageTitle:o}){const l=Lr(t);if(!l)return[];const h=i?new Set(i):null,f=l.split(/\s+/).filter(Boolean);return yc.flatMap(u=>{if(h&&!h.has(u.page))return[];const x=pa(u.page);if(!x||x.isAvailable&&!x.isAvailable(s)||u.isAvailable&&!u.isAvailable(s))return[];const L=u.title,d=u.description??null,T=Lr([L,d,o(u.page),...u.keywords??[]].filter(Boolean).join(" "));return f.every(g=>T.includes(g))?[{...u,title:L,description:d,pageTitle:o(u.page)}]:[]})}const Rr=256,Dr=280,hi="__pichamberSettingsDetail",jc=["general","appearance","chat","notifications","sessions","shortcuts","about","projects","remote-instances","tunnel","git","providers","behavior","magic-prompts","snippets","skills.installed"],kc=["general","projects","content"];function Sc(t,s){return{isWeb:!t&&hs(),isDesktop:t,isMobile:s}}function Or(t,s){return t.isAvailable?t.isAvailable(s):!0}function Cn(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Nc(t,s){const i=new Set(s);let o=t,l=1;for(;i.has(o);)o=`${t}-${l}`,l+=1;return o}function gn(t){if(!Cn(t))return null;const s=t[hi];if(!Cn(s))return null;const i=s.page,o=s.stage;return typeof i!="string"||o!=="page-content"?null:{page:qr(i),stage:o}}function Cc(){return typeof window>"u"||!Cn(window.history.state)?{}:window.history.state}const Pc=({onClose:t,forceMobile:s,isWindowed:i,visiblePageSlugs:o,initialMobileStage:l="nav"})=>{const h=ba(),f=s??h.isMobile,u=k(P=>P.settingsPage),x=k(P=>P.isSettingsDialogOpen),L=k(P=>P.setSettingsPage),d=qr(u),[T,g]=n.useState(l),U=n.useRef(l==="nav"?d:null);n.useEffect(()=>{!f&&d==="home"&&L("general")},[f,L,d]);const[M,G]=n.useState(""),[I,R]=n.useState(null),[$,J]=n.useState(0),v=n.useRef(null),w=n.useRef([]),m=n.useRef(0),F=n.useRef(!1),y=n.useMemo(()=>Ve(),[]),A=n.useMemo(()=>Ve()&&ya(),[]),O=n.useMemo(()=>Ve()&&typeof window<"u"&&window.__PICHAMBER_PLATFORM__==="darwin",[]),b=n.useMemo(()=>Ve()&&typeof window<"u"&&window.__PICHAMBER_PLATFORM__==="win32",[]),B=n.useMemo(()=>Ve()&&typeof window<"u"&&window.__PICHAMBER_PLATFORM__==="linux",[]),W=n.useMemo(()=>Co(),[]),X=n.useMemo(()=>Sc(y,f),[y,f]),S=n.useMemo(()=>{const P=o?new Set(o):null;return bo.filter(H=>H.slug!=="home").filter(H=>!P||P.has(H.slug)).filter(H=>Or(H,X))},[X,o]),Y=n.useMemo(()=>{const P=new Map(jc.map((H,he)=>[H,he]));return S.slice().sort((H,he)=>(P.get(H.slug)??999)-(P.get(he.slug)??999))},[S]),Z=La(P=>P.activeProjectId);n.useEffect(()=>{!x&&!i||(d==="skills.installed"&&ps.getState().loadSkills(),d==="snippets"&&Mt.getState().loadSnippets())},[Z,x,i,d]);const ge=n.useCallback(P=>{if(L(P),U.current=P,!f)return;const H=pa(P);if(!H||H.slug==="home"){g("nav");return}g(H.kind==="split"?"page-sidebar":"page-content")},[f,L]),be=n.useMemo(()=>pa(d),[d]),Te=n.useMemo(()=>({general:"general",appearance:"visual",chat:"chat",shortcuts:"shortcuts",sessions:"sessions",notifications:"notifications",tunnel:"tunnel"}),[]),D=n.useCallback(P=>{switch(P){case"general":return"General";case"projects":return"Projects";case"remote-instances":return"Remote Instances";case"providers":return"Providers";case"behavior":return"Behavior";case"skills.installed":return"Skills";case"git":return"Git";case"appearance":return"Appearance";case"chat":return"Chat";case"shortcuts":return"Shortcuts";case"sessions":return"Sessions";case"magic-prompts":return"Magic Prompts";case"snippets":return"Snippets";case"notifications":return"Notifications";case"tunnel":return"External Tunnel";case"about":return"About";default:return"Settings"}},[]),V=n.useMemo(()=>wc({query:M,runtimeCtx:{...X,isDesktopLocalOrigin:A,isMac:O,isWindows:b,isLinux:B,isWindowsArm64:W},visiblePageSlugs:o,getPageTitle:D}),[D,W,A,O,b,B,X,M,o]),oe=n.useCallback(P=>{if(P.id.startsWith("snippets.")){const H=Mt.getState(),he=Nc("new-snippet",H.snippets.map(pe=>pe.name));return H.setSnippetDraft({name:he,scope:"global"}),H.setSelectedSnippet(he),P.id==="snippets.create"?"snippets.content":P.id}return P.id==="providers.connect"&&xa.getState().setSelectedProviderId(null),P.id},[]),ce=n.useMemo(()=>{const P=[],H=new Map;for(const he of V){let pe=H.get(he.page);pe||(pe={page:he.page,pageTitle:he.pageTitle,results:[]},H.set(he.page,pe),P.push(pe)),pe.results.push(he)}return P},[V]);n.useEffect(()=>{J(0),m.current=0,F.current=!1},[M]),n.useEffect(()=>{m.current=$},[$]),n.useEffect(()=>{w.current[$]?.scrollIntoView({block:"nearest"})},[$]),n.useEffect(()=>{$>=V.length&&J(Math.max(0,V.length-1)),w.current.length=V.length},[$,V.length]);const K=n.useCallback(P=>{const H=oe(P);R(H),ge(P.page),f&&g("page-content")},[f,ge,oe]),we=n.useCallback(P=>{if(M.trim()){if(P.key==="Escape"){P.preventDefault(),G("");return}if(V.length!==0){if(P.key==="ArrowDown"){P.preventDefault(),F.current=!0,J(H=>(H+1)%V.length);return}if(P.key==="ArrowUp"){P.preventDefault(),F.current=!0,J(H=>(H-1+V.length)%V.length);return}if(P.key==="Enter"){P.preventDefault();const H=(m.current%V.length+V.length)%V.length,he=V[H]??V[0];he&&K(he)}}}},[K,M,V]);n.useEffect(()=>{const P=I;if(!P)return;let H=!1;const he=window.requestAnimationFrame(()=>{if(H)return;const pe=typeof CSS<"u"&&CSS.escape?CSS.escape(P):P.replace(/[^a-zA-Z0-9_-]/g,"\\$&"),ye=v.current?.querySelector(`[data-settings-item="${pe}"]`);ye&&(R(null),ye.scrollIntoView({block:"center",behavior:"smooth"}),ye.setAttribute("data-settings-search-highlight","true"),window.setTimeout(()=>{ye.removeAttribute("data-settings-search-highlight")},1600))});return()=>{H=!0,window.cancelAnimationFrame(he)}},[I,d]);const Ce=n.useCallback(()=>e.jsx("div",{className:"flex h-full items-center justify-center px-6",children:e.jsxs("div",{className:"max-w-md text-center",children:[e.jsx("div",{className:vo,children:"Not available"}),e.jsx("p",{className:"typography-ui text-muted-foreground mt-1",children:"This settings page is not available in this runtime."})]})}),[]),Xe=n.useCallback((P,H)=>{switch(P){case"projects":return e.jsx(Ho,{onItemSelect:H.onItemSelect});case"skills.installed":return e.jsx(Fo,{onItemSelect:H.onItemSelect});case"providers":return e.jsx(rl,{onItemSelect:H.onItemSelect});case"magic-prompts":return e.jsx(vl,{onItemSelect:H.onItemSelect});case"snippets":return e.jsx(wl,{onItemSelect:H.onItemSelect});default:return null}},[]),Be=n.useCallback(P=>{const H=pa(P);if(H&&!Or(H,X))return Ce();switch(P){case"projects":return e.jsx($o,{});case"remote-instances":return e.jsx(nl,{});case"behavior":return e.jsx(_o,{});case"skills.installed":return e.jsx(Uo,{});case"providers":return e.jsx(fl,{});case"about":return e.jsx(xt,{title:"About",showSaveStatus:!1,children:e.jsx(ai,{})});case"magic-prompts":return e.jsx(yl,{});case"snippets":return e.jsx(jl,{});case"git":return e.jsx(Pl,{});case"general":case"appearance":case"chat":case"shortcuts":case"sessions":case"notifications":case"tunnel":{const he=Te[P]??"visual";return e.jsx(dc,{section:he})}default:return null}},[Te,Ce,X]);n.useEffect(()=>{if(!f||T!=="nav"||d==="home"||U.current===d)return;const P=pa(d);!P||P.slug==="home"||(U.current=d,g(P.kind==="split"?"page-sidebar":"page-content"))},[f,T,d]);const ke=f&&T!=="nav",Ue=f&&T==="page-content"&&d==="skills.installed",Ze=T==="page-content"&&be?.kind==="split"&&!Ue,it=Ue?"Back":ke?"Back to Settings":"Close settings",Ie=zi(),St=n.useCallback(P=>{if(typeof window>"u")return;const H=gn(window.history.state);H?.page===P&&H.stage==="page-content"||window.history.pushState({...Cc(),[hi]:{page:P,stage:"page-content"}},"",window.location.href)},[]),Nt=n.useCallback(()=>{g("page-content"),d==="skills.installed"&&St(d)},[St,d]),bt=n.useCallback(()=>{if(Ue){if((typeof window<"u"?gn(window.history.state):null)?.page===d){window.history.back();return}g("page-sidebar");return}g("nav")},[Ue,d]);n.useEffect(()=>{if(!f)return;const P=H=>{if(d!=="skills.installed")return;if(gn(H.state)?.page==="skills.installed"){g("page-content");return}g(pe=>pe==="page-content"?"page-sidebar":pe)};return window.addEventListener("popstate",P),()=>{window.removeEventListener("popstate",P)}},[f,d]);const fe=n.useCallback(()=>{g("page-sidebar")},[]),et=()=>{const P=M.trim().length>0;return e.jsxs("div",{className:"flex h-full flex-col overflow-hidden",children:[e.jsx("div",{className:"px-3 pt-3",children:e.jsxs("div",{className:"flex h-10 items-center gap-1.5 rounded-md border border-border bg-transparent px-2 text-muted-foreground focus-within:ring-2 focus-within:ring-primary/40 sm:h-8",children:[e.jsx(C,{name:"search",className:"h-4 w-4 shrink-0"}),e.jsx("input",{value:M,onChange:H=>G(H.target.value),onKeyDown:we,placeholder:"Search settings","aria-label":"Search settings",className:"typography-ui-label min-w-0 flex-1 bg-transparent text-foreground outline-none placeholder:text-muted-foreground/70"}),P&&e.jsx("button",{type:"button",onClick:()=>G(""),"aria-label":"Clear settings search",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:e.jsx(C,{name:"close",className:"h-3.5 w-3.5"})})]})}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto overflow-x-hidden",children:e.jsx("div",{className:"flex flex-col gap-0.5 px-3 pt-3 pb-2",children:P?V.length>0?(()=>{let H=0;return ce.map(he=>e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("div",{className:"px-2 pb-0.5 pt-2 typography-micro font-medium text-muted-foreground/70",children:he.pageTitle}),he.results.map(pe=>{const ye=H;H+=1;const qe=ye===$,He=!!pe.description;return e.jsxs("button",{type:"button",ref:vt=>{w.current[ye]=vt},onMouseMove:()=>{F.current=!1,J(ye)},onClick:()=>K(pe),className:ne("flex w-full flex-col rounded-md px-2 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",He?"min-h-11 py-1.5":"py-2",qe?"bg-interactive-selection":"hover:bg-interactive-hover"),children:[e.jsx("span",{className:"typography-ui-label text-foreground truncate",children:pe.title}),He&&e.jsx("span",{className:"typography-micro text-muted-foreground/70 line-clamp-2",children:pe.description})]},pe.id)})]},he.page))})():e.jsx("div",{className:"px-2 py-6 text-center typography-ui text-muted-foreground",children:"No matching settings"}):(()=>{const H=new Map;for(const pe of Y){const ye=pe.group,qe=H.get(ye);qe?qe.push(pe):H.set(ye,[pe])}return kc.map(pe=>({group:pe,pages:H.get(pe)??[]})).filter(pe=>pe.pages.length>0).map(({group:pe,pages:ye},qe)=>e.jsxs("div",{className:"space-y-0.5",children:[e.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",qe===0?"pt-1":"pt-4 sm:pt-3"),children:pe==="general"?"PiChamber":"Workspace"}),ye.map(He=>{const vt=d===He.slug&&!(f&&T==="nav"),Lt=yo(He.slug);return Lt?e.jsx(Ur,{children:e.jsx(zr,{asChild:!0,children:e.jsxs("button",{type:"button",onClick:()=>ge(He.slug),"aria-current":vt?"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",vt?"bg-interactive-selection text-foreground":"text-foreground hover:bg-interactive-hover"),children:[e.jsx(C,{name:Lt,className:"h-[18px] w-[18px] shrink-0 sm:h-4 sm:w-4"}),e.jsxs("span",{className:"flex items-center gap-1.5 whitespace-nowrap overflow-hidden transition-opacity duration-150 opacity-100",children:[e.jsx("span",{className:"typography-ui-label font-normal truncate",children:D(He.slug)}),He.slug==="tunnel"&&e.jsx("span",{className:"shrink-0 typography-micro px-1 rounded leading-none pb-px text-[var(--status-warning)] bg-[var(--status-warning)]/10",children:"beta"})]})]})})},He.slug):null})]},pe))})()})})]})},Ct=()=>{if(T==="nav")return e.jsx("div",{className:"flex-1 min-h-0 overflow-hidden bg-background",children:e.jsx("div",{className:"flex h-full min-h-0 flex-col",children:e.jsx(cs,{children:et()})})});if(!be)return e.jsx("div",{className:"flex-1 bg-background"});if(T==="page-sidebar"){if(be.kind!=="split"){const H=Be(d);return e.jsx("div",{className:"flex-1 min-h-0 overflow-y-scroll overflow-x-hidden bg-background",children:e.jsx(cs,{children:H})})}return e.jsx("div",{className:"flex-1 min-h-0 overflow-y-scroll overflow-x-hidden bg-background",children:e.jsx(cs,{children:Xe(d,{onItemSelect:Nt})})})}const P=Be(d);return e.jsx("div",{className:"flex-1 min-h-0 overflow-y-scroll overflow-x-hidden bg-background",children:e.jsx(cs,{children:P})})},te=()=>!be||d==="home"?null:be.kind==="split"?e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden",children:[e.jsx("div",{className:ne("border-r","bg-sidebar"),style:{width:Dr,minWidth:Dr,borderColor:"var(--interactive-border)"},children:e.jsx(cs,{children:Xe(d,{})})}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-scroll overflow-x-hidden bg-background",children:e.jsx(cs,{children:Be(d)})})]}):e.jsx("div",{className:"h-full min-h-0 overflow-y-scroll overflow-x-hidden bg-background",children:e.jsx(cs,{children:Be(d)})});return e.jsxs("div",{ref:v,"data-settings-view":"true",className:ne("relative flex h-full min-h-0 flex-col overflow-hidden bg-background"),children:[f?e.jsxs("div",{className:ne("flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",T!=="nav"&&"border-b","bg-background"),style:T!=="nav"?{borderColor:"var(--interactive-border)"}:void 0,children:[ke?e.jsx("button",{type:"button",onClick:bt,"aria-label":it,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-primary",children:e.jsx(C,{name:"arrow-left-s",className:"h-5 w-5"})}):null,e.jsx("div",{className:"min-w-0 flex-1 px-2 typography-ui-label font-medium text-foreground truncate",children:T==="nav"?"Settings":be?D(be.slug):"Settings"}),Ze&&e.jsx("button",{type:"button",onClick:fe,"aria-label":"Open section list",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-primary",children:e.jsx(C,{name:"list-unordered",className:"h-5 w-5"})}),t&&e.jsx("button",{type:"button",onClick:t,"aria-label":"Close settings",title:`Close Settings (${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-primary",children:e.jsx(C,{name:"close",className:"h-5 w-5"})})]}):e.jsx(e.Fragment,{children:ke&&e.jsx("div",{className:ne("absolute left-3 z-50",i?"top-2":"top-3"),children:e.jsx("button",{type:"button",onClick:bt,"aria-label":"Back",className:"inline-flex h-9 w-9 items-center justify-center rounded-lg p-2 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:e.jsx(C,{name:"arrow-left-s",className:"h-5 w-5"})})})}),!f&&e.jsxs("div",{className:"flex shrink-0 items-center justify-between px-5 pb-3 pt-4",children:[e.jsxs("div",{className:"flex items-center gap-2 typography-ui-header font-medium text-foreground",children:[e.jsx(C,{name:"settings-3",className:"size-4 text-muted-foreground"}),e.jsx("span",{children:"Settings"})]}),t&&e.jsx("button",{type:"button",onClick:t,"aria-label":"Close settings",title:`Close Settings (${Ie}+,)`,className:"inline-flex size-8 items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",children:e.jsx(C,{name:"close",className:"size-4"})})]}),e.jsx("div",{className:"flex flex-1 min-h-0 overflow-hidden",children:f?Ct():e.jsxs(e.Fragment,{children:[e.jsx("div",{className:ne("relative flex h-full min-h-0 flex-col overflow-hidden border-r","bg-sidebar"),style:{width:`${Rr}px`,minWidth:`${Rr}px`,borderColor:"var(--interactive-border)"},children:e.jsx(cs,{children:et()})}),e.jsx("div",{className:"flex-1 overflow-hidden bg-background",children:te()})]})})]})},Fc=Object.freeze(Object.defineProperty({__proto__:null,SettingsView:Pc},Symbol.toStringTag,{value:"Module"}));export{ai as A,Pc as S,_c as a,Fc as b,Do as p};
|