@aiworker/web 1.23.2 → 1.23.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{CodeMirrorCommentWidgets-COGJG0Iv.js → CodeMirrorCommentWidgets-pFeKzADY.js} +1 -1
- package/dist/assets/{DiffView-BviYY3zL.js → DiffView-BYwAHIlW.js} +3 -3
- package/dist/assets/{DirtyBranchSwitchDialog-C26DvfVJ.js → DirtyBranchSwitchDialog-BeyJczAi.js} +1 -1
- package/dist/assets/{FilesView-D0ZU_nCt.js → FilesView-lrP5OlzK.js} +6 -6
- package/dist/assets/{GitView-CYgiDRH-.js → GitView-CCUK73JL.js} +4 -4
- package/dist/assets/{JsonTreeView-GsV9UScz.js → JsonTreeView-CqUi8Ytj.js} +1 -1
- package/dist/assets/{LinearIssuesView-shqUS8nl.js → LinearIssuesView-C0WwIDQN.js} +1 -1
- package/dist/assets/{MarkdownImageGallery-CQSTFp6m.js → MarkdownImageGallery-0NXPad4K.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-DJWP3A8X.js → MarkdownRendererImpl-q-rUxBkU.js} +4 -4
- package/dist/assets/{OnboardingScreen-CTuu4lgo.js → OnboardingScreen-Cy6xZ-IQ.js} +1 -1
- package/dist/assets/{PatchDiff-Dp53v2pl.js → PatchDiff-DuYWs-7m.js} +1 -1
- package/dist/assets/{PierreDiffViewer-B5l0djPS.js → PierreDiffViewer-C51SEtjJ.js} +1 -1
- package/dist/assets/{PlanView-CLUWkGiG.js → PlanView-k63mHfFF.js} +1 -1
- package/dist/assets/SettingsView-DNJXHPYC.js +28 -0
- package/dist/assets/{SettingsWindow-DbgEnZ6T.js → SettingsWindow-DFMJqIkx.js} +1 -1
- package/dist/assets/{ToolOutputDialog-Du-RZj-a.js → ToolOutputDialog-B4kBDjLK.js} +4 -4
- package/dist/assets/{ToolPartDiffPreview-HBLSokoe.js → ToolPartDiffPreview-DhVBmwis.js} +2 -2
- package/dist/assets/{VirtualizedFileDiff-Bzp3hClU.js → VirtualizedFileDiff-C-MFNoKo.js} +1 -1
- package/dist/assets/{WalkthroughView-CpgA4s9w.js → WalkthroughView-hmnM70S9.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-CI1PC_z2.js → computeVirtualFileMetrics-Bv64vrxY.js} +1 -1
- package/dist/assets/{de-BX8b4hDD.js → de-i-51iOMQ.js} +2 -2
- package/dist/assets/{es-e98cS-yM.js → es-CNkqJISC.js} +3 -3
- package/dist/assets/{fr-BOiqxJAs.js → fr-a9t4bHWo.js} +3 -3
- package/dist/assets/index-BvwlOZOg.js +40 -0
- package/dist/assets/{index-Cmn74sw-.js → index-C-KjDH6t.js} +1 -1
- package/dist/assets/index-n5p3SnES.css +1 -0
- package/dist/assets/{isDiffPlainText-DVralkU-.js → isDiffPlainText-B0pMS3gs.js} +1 -1
- package/dist/assets/{isFilePlainText-CgTREsRX.js → isFilePlainText-IXDeiXmH.js} +1 -1
- package/dist/assets/{ja-aoO55hGu.js → ja-C2HQKC-_.js} +3 -3
- package/dist/assets/{ko-BGzFLogk.js → ko-CvVt6P_Q.js} +3 -3
- package/dist/assets/main-6ZT1mvpO.js +930 -0
- package/dist/assets/{main-BgfXQ-4g.js → main-BeWvA5d9.js} +2 -2
- package/dist/assets/markdownCore-DTW1POUM.js +5 -0
- package/dist/assets/{miniChat-DHKXp-_I.js → miniChat-DzMGD1Hv.js} +2 -2
- package/dist/assets/{mobile-lXQ08VnX.js → mobile-CrDSF4dQ.js} +2 -2
- package/dist/assets/{patchFileDiff-i1lTtNbn.js → patchFileDiff-DHG-znZQ.js} +3 -3
- package/dist/assets/{pl-B5x19laq.js → pl-CQi2SXLP.js} +3 -3
- package/dist/assets/{pt-BR-C3oU51Il.js → pt-BR-FdnmJOe8.js} +3 -3
- package/dist/assets/{renderElectronMiniChatApp-CuO4ue6B.js → renderElectronMiniChatApp-BuaS0XYk.js} +2 -2
- package/dist/assets/renderMobileApp-hxXJf_Db.js +25 -0
- package/dist/assets/runtimeEndpointReset-DB4KI-ED.js +41 -0
- package/dist/assets/{scheduledTasksApi-BEuUF_cj.js → scheduledTasksApi-DZaxQ19y.js} +1 -1
- package/dist/assets/{shikiHighlight-ctlcPvvx.js → shikiHighlight-B1goMnV6.js} +1 -1
- package/dist/assets/{tr-C0QQa7et.js → tr-BwD9HLzh.js} +2 -2
- package/dist/assets/{uk-CqLSe9wT.js → uk-BWNCwGJO.js} +3 -3
- package/dist/assets/{useAppFontEffects-B6OfEypo.js → useAppFontEffects-cYK1WODe.js} +130 -130
- package/dist/assets/useGitComparison-DIetwQtj.js +1 -0
- package/dist/assets/{useInlineCommentController-CgbrpEWu.js → useInlineCommentController-DscFZWyI.js} +2 -2
- package/dist/assets/{useRootScrollLock-Me41OjBT.js → useRootScrollLock-CE3HJBOu.js} +1 -1
- package/dist/assets/{vendor-codemirror-language-data-SJuFp0a0.js → vendor-codemirror-language-data-CsvoASYk.js} +2 -2
- package/dist/assets/{vendor-remixicon-react-Dil0zKKT.js → vendor-remixicon-react-BDmGmFCA.js} +1 -1
- package/dist/assets/{web-components-D8GS8Ork.js → web-components-HM6S8xyb.js} +1 -1
- package/dist/assets/{zh-CN-iJEie4d6.js → zh-CN-CH6L_7cX.js} +3 -3
- package/dist/assets/{zh-TW-CyslEwlK.js → zh-TW--py9VFnc.js} +3 -3
- package/dist/index.html +3 -3
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +2 -2
- package/server/lib/opencode/DOCUMENTATION.md +14 -0
- package/server/lib/opencode/openchamber-routes.js +72 -14
- package/server/lib/opencode/openchamber-routes.test.js +71 -3
- package/server/lib/opencode/settings-helpers.js +5 -0
- package/server/lib/opencode/settings-helpers.test.js +13 -1
- package/server/lib/opencode/settings-registry.json +3 -0
- package/dist/assets/SettingsView-CojPQVHx.js +0 -28
- package/dist/assets/index-BD8ILbxF.js +0 -40
- package/dist/assets/index-zhgg-SDz.css +0 -1
- package/dist/assets/main-DGYUWmIt.js +0 -930
- package/dist/assets/markdownCore-BesaNs_G.js +0 -5
- package/dist/assets/renderMobileApp-B3zFlHy4.js +0 -25
- package/dist/assets/runtimeEndpointReset-BLzrtrmj.js +0 -41
- package/dist/assets/useGitComparison-BXZXEAW6.js +0 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FilesView-lrP5OlzK.js","assets/vendor-react-BUCujlKS.js","assets/vendor-scheduler-7OC5HNn7.js","assets/index-BvwlOZOg.js","assets/vendor-zod-B6551dwG.js","assets/vendor-vite-runtime-DD1OZmLC.js","assets/vendor-zustand-BAGL70zf.js","assets/vendor-opencode-sdk-BJ73u-bH.js","assets/index-n5p3SnES.css","assets/useAppFontEffects-cYK1WODe.js","assets/vendor-simplewebauthn-browser-VDA66rT_.js","assets/vendor-base-ui-BY_5qla_.js","assets/vendor-floating-ui-utils-D6FqdtJt.js","assets/vendor-floating-ui-react-dom-DxYCWdHj.js","assets/vendor-floating-ui-dom-BTvzWks8.js","assets/vendor-floating-ui-core-PuGzNPnN.js","assets/vendor-use-sync-external-store-D6wYuSt-.js","assets/vendor-class-variance-authority-5VPnzWs2.js","assets/vendor-clsx-B-dksMZM.js","assets/vendor-dnd-kit-core-BZknOX2w.js","assets/vendor-dnd-kit-utilities-B_MdXhJC.js","assets/vendor-dnd-kit-accessibility-BHxJPORy.js","assets/vendor-dnd-kit-sortable-CsEagZ81.js","assets/vendor-framer-motion-livSKyyV.js","assets/vendor-motion-dom-D_o3BTI3.js","assets/vendor-motion-utils-BGh8QBgx.js","assets/vendor-tanstack-react-virtual-g05Cx3z9.js","assets/vendor-tanstack-virtual-core-Dubg10g5.js","assets/contextPanelEmbeddedChat-BdA6bdky.js","assets/vendor-sonner-DFyL3AvE.js","assets/vendor-cmdk-DgLInKvT.js","assets/vendor-radix-ui-react-dialog-B94Bt2qq.js","assets/vendor-radix-ui-primitive-Dc_FVRD7.js","assets/vendor-radix-ui-react-compose-refs-DcAh5WdT.js","assets/vendor-radix-ui-react-context-Czxm7Z62.js","assets/vendor-radix-ui-react-id-f5BLKEVw.js","assets/vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js","assets/vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js","assets/vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js","assets/vendor-radix-ui-react-primitive-DhVoX9SD.js","assets/vendor-radix-ui-react-slot-BQgQOasS.js","assets/vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js","assets/vendor-radix-ui-react-use-escape-keydown-oph88g-F.js","assets/vendor-radix-ui-react-focus-scope-CiaxW4dD.js","assets/vendor-radix-ui-react-portal-BMJYHWck.js","assets/vendor-radix-ui-react-presence-CNxf-uq4.js","assets/vendor-radix-ui-react-focus-guards-B6qJXYua.js","assets/vendor-react-remove-scroll-DO7dCTnK.js","assets/vendor-tslib-De9GV7Vy.js","assets/vendor-react-remove-scroll-bar-BcFYyj3E.js","assets/vendor-react-style-singleton-q6EMHnwf.js","assets/vendor-get-nonce-C-Z93AgS.js","assets/vendor-use-sidecar-zDC0RhA3.js","assets/vendor-use-callback-ref-D3RC8gqK.js","assets/vendor-aria-hidden-DvXkyWUv.js","assets/vendor-codemirror-language-BgPj_McA.js","assets/vendor-lezer-common-B3-cUCR_.js","assets/vendor-codemirror-state-C9awkmn-.js","assets/vendor-marijn-find-cluster-break-DXwl3gUT.js","assets/vendor-codemirror-view-CiLROUVV.js","assets/vendor-style-mod-NZ5MEPvj.js","assets/vendor-w3c-keyname-Vcq4gwWv.js","assets/vendor-crelt-C8TCjufn.js","assets/vendor-lezer-highlight-CDMHUZ74.js","assets/vendor-codemirror-lang-javascript-Cc2ZYbgX.js","assets/vendor-lezer-javascript-D7Tj24ot.js","assets/vendor-lezer-lr-bhwg1HMg.js","assets/vendor-codemirror-autocomplete-DzPz9Wgq.js","assets/vendor-codemirror-lang-json-CMBS2tG9.js","assets/vendor-lezer-json-Iaex0UN-.js","assets/vendor-codemirror-lang-css-O0cZX78y.js","assets/vendor-lezer-css-C5xB6jxd.js","assets/vendor-codemirror-lang-html-CfgK872x.js","assets/vendor-lezer-html-C0I1p52t.js","assets/vendor-codemirror-lang-markdown-BPGOH9ye.js","assets/vendor-lezer-markdown-C6g-d6P3.js","assets/vendor-codemirror-language-data-CsvoASYk.js","assets/vendor-codemirror-lang-python-HahnQaAS.js","assets/vendor-lezer-python-CvuFxeZl.js","assets/vendor-codemirror-commands-B7H_j0iU.js","assets/vendor-legendapp-list-BuBPBC3R.js","assets/vendor-tailwind-merge-CPcsbTWB.js","assets/vendor-fuse.js-Dw8P0qyA.js","assets/runtimeEndpointReset-DB4KI-ED.js","assets/shikiHighlight-B1goMnV6.js","assets/vendor-codemirror-search-BmS-GmcX.js","assets/vendor-replit-codemirror-vim-B2DJlAhT.js","assets/vendor-replit-codemirror-vim-core-FHzKdNUS.js","assets/JsonTreeView-CqUi8Ytj.js","assets/web-components-HM6S8xyb.js","assets/computeVirtualFileMetrics-Bv64vrxY.js","assets/vendor-shiki-Bbf2GEcE.js","assets/vendor-shikijs-core-CGM_jqPK.js","assets/vendor-shikijs-types-CPSbSeK6.js","assets/vendor-shikijs-vscode-textmate-BgLrS_2D.js","assets/vendor-hast-util-to-html-BKBhbTDb.js","assets/vendor-html-void-elements-CkdplsNl.js","assets/vendor-property-information-rJCbAzvX.js","assets/vendor-zwitch-C2o2j-tx.js","assets/vendor-stringify-entities-CsH1VEn9.js","assets/vendor-character-entities-legacy-BpoLgcEt.js","assets/vendor-character-entities-html4-D7taRCQ7.js","assets/vendor-ccount-c2V3InAJ.js","assets/vendor-comma-separated-tokens-D8TqSuIK.js","assets/vendor-space-separated-tokens-DD3iYX1K.js","assets/vendor-hast-util-whitespace-D4Wp6AEg.js","assets/vendor-shikijs-engine-oniguruma-DPWuIF1G.js","assets/themeResolver-BmJyTmjJ.js","assets/vendor-pierre-theming-C6Z4M5_u.js","assets/vendor-shikijs-engine-javascript-Cme4830A.js","assets/vendor-oniguruma-to-es-DLBnFDCE.js","assets/vendor-oniguruma-parser-C0D4_9rT.js","assets/vendor-regex-BBWcyTkg.js","assets/vendor-regex-utilities-2BQyy0xI.js","assets/vendor-regex-recursion-JU4mF-dD.js","assets/vendor-shikijs-transformers-CZWsLLKm.js","assets/Virtualizer-CZlLSacm.js","assets/isFilePlainText-IXDeiXmH.js","assets/appThemeRegistry-BK0dHKa6.js","assets/registerCustomTheme-BBXUCRnG.js","assets/Virtualizer-D_a8gKmg.js","assets/scheduledTasksApi-DZaxQ19y.js","assets/vendor-react-drawio-Ct3Q0DsD.js","assets/useInlineCommentController-DscFZWyI.js","assets/CodeMirrorCommentWidgets-pFeKzADY.js","assets/vendor-capacitor-app-BrDJj9I_.js","assets/vendor-capacitor-core-B4EWRrHz.js","assets/vendor-capacitor-push-notifications-KNe1zSBF.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{f as le,r as an,j as t,R as c,c as Ot,h as Oo}from"./vendor-react-BUCujlKS.js";import{u as dt,a as Ut,b as $r,d as qn,i as Oe,e as ut,s as It,f as ms,h as pn,j as Bo,k as Fr,l as Lo,p as $o,m as Fo,n as jt,o as Wo,q as Jn,t as Uo,v as Vo,x as Yn,y as Xn,z as Qn,A as Go,B as Zn,M as Cs,C as Ko,D as Ho}from"./index-BvwlOZOg.js";import{u as hn,a as qo,b as Ve,c as Wr,d as Ur,r as gn,e as Jo,f as fe,t as ue,o as Yo,I as X,B as he,g as Xo,O as yt,h as Y,P as Qo,i as Zo,j as ei,k as ti,l as He,m as si,n as xt,p as ni,q as er,s as ri,v as bn,w as oi,x as ii,y as Se,z as ai,A as Vr,C as Gr,D as Kr,E as li,F as xn,G as ci,H as Hr,J as Ge,K as qr,L as ui,M as di,N as fi,Q as Jr,R as Yr,S as Xr,T as Qr,U as Zr,V as eo,W as mi,X as pi,Y as yn,Z as hi,_ as gi,$ as ts,a0 as Qs,a1 as bi,a2 as to,a3 as xi,a4 as $s,a5 as so,a6 as no,a7 as rs,a8 as Mt,a9 as yi,aa as vi,ab as wi,ac as ji,ad as ki,ae as vn,af as Si,ag as Ni,ah as Ci,ai as Ei,aj as Ri,ak as Pi,al as Ai,am as Ti,an as tr,ao as Ii,ap as Di,aq as _i,ar as Mi,as as zi,at as Es,au as Oi,av as Bi,aw as ro,ax as qe,ay as Li,az as $i,aA as Fi,aB as Wi,aC as Ui,aD as Vi,aE as Gi,aF as oo,aG as Ki,aH as Hi,aI as qi,aJ as Ji,aK as Yi,aL as Xi,aM as Qi,aN as Zi,aO as ea,aP as ta,aQ as sa,aR as na,aS as ra,aT as oa,aU as ia,aV as aa,aW as la,aX as ca,aY as ua,aZ as da,a_ as fa,a$ as ma,b0 as pa,b1 as ha,b2 as ga,b3 as ba,b4 as xa,b5 as ya,b6 as va,b7 as wa,b8 as ja,b9 as ka,ba as Sa,bb as Na}from"./useAppFontEffects-cYK1WODe.js";import{u as Dt,S as io,s as Ca,p as Ea,a as Ra,D as Pa,N as Aa,b as Ta,r as Ia,c as Da,g as _a,h as Ma,d as za,B as Oa,e as Ba,f as La,i as $a,j as Fa,T as Wa,P as Ua,k as Va,l as Ga,m as Ka,n as Ha,O as qa,C as Ja,o as Ya,q as Xa,t as Qa}from"./runtimeEndpointReset-DB4KI-ED.js";import{_ as Bt}from"./vendor-vite-runtime-DD1OZmLC.js";import{S as Za,A as el}from"./SettingsView-DNJXHPYC.js";import{PlanView as tl}from"./PlanView-k63mHfFF.js";import{p as sl}from"./vendor-aparajita-capacitor-secure-storage-5IShChL0.js";import{Capacitor as nl}from"./vendor-capacitor-core-B4EWRrHz.js";import{k as ln,s as ao,M as wn,a as _s,J as cn,p as rl,_ as sr,d as ol,f as jn,V as il,K as nr,P as al,b as ll,c as cl,Q as ul,r as dl,U as fl,Z as ml}from"./vendor-remixicon-react-BDmGmFCA.js";import{f as kn,h as Lt,i as Sn,P as Nn,D as Cn,j as En}from"./vendor-dnd-kit-core-BZknOX2w.js";import{s as Rn,S as Pn,v as An,u as Tn}from"./vendor-dnd-kit-sortable-CsEagZ81.js";import{C as In}from"./vendor-dnd-kit-utilities-B_MdXhJC.js";import{c as Dn,p as lo}from"./vendor-zustand-BAGL70zf.js";import{toast as rr}from"./vendor-sonner-DFyL3AvE.js";import{C as pl,a as hl,D as gl}from"./DirtyBranchSwitchDialog-BeyJczAi.js";import{u as bl,a as xl,b as yl,c as vl,i as wl,f as jl,B as kl,C as Sl,P as or}from"./patchFileDiff-DHG-znZQ.js";import{u as Nl,a as Cl,i as El,b as Rl}from"./useGitComparison-DIetwQtj.js";import{P as Pl}from"./PierreDiffViewer-C51SEtjJ.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-zod-B6551dwG.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-BY_5qla_.js";import"./vendor-floating-ui-utils-D6FqdtJt.js";import"./vendor-floating-ui-react-dom-DxYCWdHj.js";import"./vendor-floating-ui-dom-BTvzWks8.js";import"./vendor-floating-ui-core-PuGzNPnN.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-framer-motion-livSKyyV.js";import"./vendor-motion-dom-D_o3BTI3.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./contextPanelEmbeddedChat-BdA6bdky.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-CsvoASYk.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-BuBPBC3R.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-yaml-3778uTud.js";import"./shikiHighlight-B1goMnV6.js";import"./vendor-codemirror-search-BmS-GmcX.js";import"./vendor-replit-codemirror-vim-B2DJlAhT.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./appThemeRegistry-BK0dHKa6.js";import"./registerCustomTheme-BBXUCRnG.js";import"./themeResolver-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-qrcode-DTJ12-WC.js";import"./vendor-dijkstrajs-COg3n3zL.js";import"./useInlineCommentController-DscFZWyI.js";import"./CodeMirrorCommentWidgets-pFeKzADY.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./VirtualizedFileDiff-C-MFNoKo.js";import"./web-components-HM6S8xyb.js";import"./computeVirtualFileMetrics-Bv64vrxY.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./isDiffPlainText-B0pMS3gs.js";import"./vendor-diff-C3JhlQdm.js";import"./Virtualizer-D_a8gKmg.js";let co=null,ir=!1;const Al=new Promise(n=>{co=n});function Tl(){ir||(ir=!0,co?.())}const Il=6,Dl=n=>n.parentID??null,ar=n=>{const e=n.replace(/\/+$/,"");return e.slice(e.lastIndexOf("/")+1)||e},_l=n=>n.replace(/\\/g,"/").replace(/\/+$/,""),Ml=(n,e)=>{if(!n)return"";let s=null,o=-1;for(const r of e){const i=_l(r.path);(n===i||n.startsWith(`${i}/`))&&i.length>o&&(s=r,o=i.length)}return s?s.label?.trim()||ar(s.path):ar(n)},zl=()=>{const n=hn.getState().activeSessions,e=qo.getState().index.session.unseenCount,s=dt.getState().notifyOnSubtasks,o=Ve.getState().projects,r=Wr.getState().ids,i=Ur.getState().rankById;let a=0;const u=[];for(const d of n){const l=Dl(d)!==null,g=(e[d.id]??0)>0&&(!l||s);g&&(a+=1),l||u.push({session:d,unread:g,project:Ml(gn(d),o)})}u.sort((d,l)=>Jo(d.session,l.session,r,i));const f=u.slice(0,Il).map(({session:d,unread:l,project:p})=>({id:d.id,title:d.title??"",unread:l,project:p}));return{runtimeKey:Ut(),attentionCount:a,recentSessions:f}},Ol="__AIWORKER_WIDGET_SNAPSHOT__",Bl=()=>{typeof window>"u"||(window[Ol]=()=>{try{return JSON.stringify(zl())}catch{return null}})},Zs="mobile-app-update-available",lr="mobile-app-update-toast-dismissed-version",Ll=()=>{const n=le.c(8),{t:e}=fe(),s=Dt($l),o=Dt(Fl),r=Dt(Wl),i=Dt(Ul);let a;n[0]===Symbol.for("react.memo_cache_sentinel")?(a=new Set,n[0]=a):a=n[0];const u=an.useRef(a);let f,d;return n[1]!==s||n[2]!==i||n[3]!==o||n[4]!==e||n[5]!==r?(f=()=>{if($r()!=="android"||o!=="mobile"||!s||!r||!i){ue.dismiss(Zs);return}qn().getItem(lr)!==r&&(u.current.has(r)||(u.current.add(r),ue.info(e("mobileUpdate.toast.available.title"),{id:Zs,description:e("mobileUpdate.toast.available.description",{version:r}),duration:1/0,icon:t.jsx(X,{name:"download",className:"h-4 w-4 text-muted-foreground"}),action:{label:e("mobileUpdate.toast.actions.download"),onClick:()=>{Yo(i)}},cancel:{label:e("mobileUpdate.toast.actions.dismiss"),onClick:()=>{qn().setItem(lr,r),ue.dismiss(Zs)}}})))},d=[s,i,o,e,r],n[1]=s,n[2]=i,n[3]=o,n[4]=e,n[5]=r,n[6]=f,n[7]=d):(f=n[6],d=n[7]),an.useEffect(f,d),null};function $l(n){return n.available}function Fl(n){return n.runtimeType}function Wl(n){return n.info?.version}function Ul(n){return n.info?.downloadUrl}const cr=300,Vl="aiworker.mobile.connectLog.v1",_t=[];if(typeof window<"u")try{window.localStorage.removeItem(Vl)}catch{}const _n=(n,e)=>{_t.push({at:Date.now(),step:n,detail:e}),_t.length>cr&&_t.splice(0,_t.length-cr)};typeof window<"u"&&_n("app:launch","{}");const Gl=()=>[..._t],Kl=n=>{const e=new Date(n),s=(o,r=2)=>String(o).padStart(r,"0");return`${s(e.getHours())}:${s(e.getMinutes())}:${s(e.getSeconds())}.${s(e.getMilliseconds(),3)}`},uo=n=>`${Kl(n.at)} ${n.step}${n.detail&&n.detail!=="{}"?` ${n.detail}`:""}`,Hl=()=>_t.map(uo).join(`
|
|
3
|
+
`),fo=(n,e)=>{const s=le.c(10),o=700,r=c.useRef(null),i=c.useRef(null),a=c.useRef(!1);let u;s[0]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{r.current!==null&&window.clearTimeout(r.current),r.current=null,i.current=null},s[0]=u):u=s[0];const f=u;let d,l;s[1]===Symbol.for("react.memo_cache_sentinel")?(d=()=>f,l=[f],s[1]=d,s[2]=l):(d=s[1],l=s[2]),c.useEffect(d,l);let p;s[3]!==o||s[4]!==n?(p=S=>{a.current=!1,i.current={x:S.clientX,y:S.clientY},r.current!==null&&window.clearTimeout(r.current),r.current=window.setTimeout(()=>{r.current=null,a.current=!0,n()},o)},s[3]=o,s[4]=n,s[5]=p):p=s[5];const g=p;let h;s[6]===Symbol.for("react.memo_cache_sentinel")?(h=S=>{const E=i.current;E&&(Math.abs(S.clientX-E.x)>10||Math.abs(S.clientY-E.y)>10)&&f()},s[6]=h):h=s[6];const y=h;let j;s[7]===Symbol.for("react.memo_cache_sentinel")?(j=S=>{a.current&&(a.current=!1,S.preventDefault(),S.stopPropagation())},s[7]=j):j=s[7];const v=j;let T;return s[8]!==g?(T={onPointerDown:g,onPointerMove:y,onPointerUp:f,onPointerCancel:f,onClickCapture:v},s[8]=g,s[9]=T):T=s[9],T},Ms="aiworker.mobile.connections.v1",ql="aiworker.mobile.",ur="aiworker.mobile.deviceId",Jl=()=>{try{const n=window.localStorage.getItem(ur);if(n&&n.trim())return n.trim();const e=crypto.randomUUID();return window.localStorage.setItem(ur,e),e}catch{return crypto.randomUUID()}},dr=()=>`mobile:${Jl()}`,fr=()=>{try{const n=nl.getPlatform();return n==="ios"||n==="android"?n:void 0}catch{return}},mo=12,po=8e3,Yl=2500,Xl=3e3,zs=2500,Ql=()=>{let n=0;return{begin:()=>(n+=1,n),cancel:()=>{n+=1},isCurrent:e=>e===n}},Vt=n=>{const e=n.trim();if(!e)return"";const s=/^https?:\/\//i.test(e)?e:`http://${e}`,o=new URL(s);return o.hash="",o.search="",o.pathname=o.pathname.replace(/\/+$/,""),o.toString().replace(/\/+$/,"")},Ts=n=>{try{return new URL(n).host}catch{return n}},$t=n=>{try{return Vt(n)}catch{return n.trim().replace(/\/+$/g,"")}},ho=(n,e)=>$t(n)===$t(e),go=n=>`relay:${n.serverId}@${n.relayUrl.trim()}`,Zl=n=>`relay://${n.serverId}`,Fs=n=>n.candidates.filter(e=>e.kind==="direct"),kt=n=>{const e=n.candidates.find(s=>s.kind==="relay");return e&&e.kind==="relay"?e.relay:null},ft=n=>{const e=Fs(n)[0];if(e)return e.url;const s=kt(n);return s?Zl(s):""},De=n=>{const e=kt(n);if(e)return go(e);const s=Fs(n)[0];return s?$t(s.url):""},Os=(n,e)=>{const s=n.find(i=>i.kind==="relay"),o=s&&s.kind==="relay"?s.relay.serverId:null,r=new Set(n.filter(i=>i.kind==="direct").map(i=>$t(i.url)));return e.some(i=>i.kind==="relay"?o!==null&&i.relay.serverId===o:r.has($t(i.url)))},Mn=n=>{const e=(()=>{try{return Vt(n)}catch{return""}})();return e?[{kind:"direct",url:e}]:[]},mr=n=>{if(n.candidates&&n.candidates.length>0)return n.candidates;const e=[];return typeof n.url=="string"&&n.url.trim()&&!/^relay:\/\//i.test(n.url.trim())&&e.push(...Mn(n.url)),n.relay&&e.push({kind:"relay",relay:n.relay}),e},zn=n=>{if(!n||typeof n!="object"||Array.isArray(n))return null;const e=n;if(typeof e.relayUrl!="string"||!e.relayUrl.trim()||typeof e.serverId!="string"||!e.serverId.trim())return null;const s=e.hostEncPubJwk;if(!s||typeof s!="object"||Array.isArray(s))return null;const o=s;return o.kty!=="EC"||o.crv!=="P-256"||typeof o.x!="string"||!o.x||typeof o.y!="string"||!o.y?null:{relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:{kty:"EC",crv:"P-256",x:o.x,y:o.y}}},bo=n=>{try{return JSON.stringify(n)}catch{return String(n)}},be=(n,e={})=>{const s=bo(e);console.info("[mobile-connect]",n,s),_n(n,s)},ss=(n,e={})=>{be(n,e)},Ft=(n,e={})=>{const s=bo(e);console.info("[mobile-storage]",n,s),_n(n,s)},ec=n=>{if(typeof n!="string")return n;try{return JSON.parse(n)}catch{return n}},tc=n=>{if(typeof n!="string")return n??void 0;try{return JSON.parse(n)}catch{return n}},sc=async(n,e)=>{if(!Oe())return null;try{const{CapacitorHttp:s}=await Bt(async()=>{const{CapacitorHttp:i}=await import("./vendor-capacitor-core-B4EWRrHz.js");return{CapacitorHttp:i}},[]),o=Lo(n,new Headers(e?.headers)),r=await s.request({url:n,method:e?.method||"GET",headers:Object.fromEntries(o.entries()),data:tc(e?.body)});return{ok:r.status>=200&&r.status<300,status:r.status,source:"native-http",json:async()=>ec(r.data)}}catch(s){return be("native-http:failed",{url:n,error:s instanceof Error?s.message:String(s)}),null}},nc=async(n,e)=>{const s=await fetch(n,e).catch(o=>(be("browser-fetch:failed",{url:n,error:o instanceof Error?o.message:String(o)}),null));return s?{ok:s.ok,status:s.status,source:"browser-fetch",json:()=>s.json()}:null},pt=async(n,e,s)=>{let o;const r=new Promise(i=>{o=window.setTimeout(()=>{s?.(),i(null)},n)});try{return await Promise.race([e,r])}catch{return null}finally{o!==void 0&&window.clearTimeout(o)}},St=async(n,e,s)=>{const o=s?.totalTimeoutMs??po,r=Date.now(),i=await pt(Math.min(Yl,o),sc(n,e));if(i)return i;const a=new AbortController,u=Math.max(500,o-(Date.now()-r));return pt(u,nc(n,{...e,signal:a.signal}),()=>a.abort())},Ws=async n=>{if(!n)return null;const e=await n.json().catch(()=>null);if(!e||typeof e!="object")return null;const s=e;return{authenticated:typeof s.authenticated=="boolean"?s.authenticated:void 0,disabled:typeof s.disabled=="boolean"?s.disabled:void 0,scope:typeof s.scope=="string"?s.scope:void 0}},Wt=15e3,rc=async(n,e,s,o=Wt,r)=>{const i=Fr({relayUrl:n.relayUrl,serverId:n.serverId,hostEncPubJwk:n.hostEncPubJwk}),a=u=>u==="ok"&&r?.keepTunnel?{outcome:u,tunnel:i}:(i.close(),{outcome:u});try{const u=e?{Authorization:`Bearer ${e}`}:void 0,f=await pt(o,i.fetch("/auth/session",{headers:u}).catch(()=>null));if(be("relay:session",{ok:f?.ok===!0,status:f?.status??null,hasToken:!!e}),!f)return a("unreachable");if(f.status===401)return a(e?"auth-failed":"needs-login");if(!f.ok&&f.status!==404)return a("auth-failed");const d=await Ws(f);return d&&d.disabled!==!0&&d.authenticated===!1?a(e?"auth-failed":"needs-login"):a("ok")}catch(u){throw i.close(),u}},oc=(n,e,s,o,r)=>{const i=typeof window<"u"?window.location.origin:"",a={relayUrl:n.relayUrl,serverId:n.serverId,hostEncPubJwk:n.hostEncPubJwk,...s?{grant:s}:{}};r&&Bo(a,r),It({apiBaseUrl:i,clientToken:e,runtimeKey:o??go(n),relay:a})},ic=n=>{if(!n||typeof n!="object")return null;const e=n;if(e.kind==="direct")return typeof e.url=="string"&&e.url.trim()?{kind:"direct",url:e.url}:null;if(e.kind==="relay"){const s=zn(e.relay);return s?{kind:"relay",relay:s}:null}return null},ac=n=>{if(n.mode==="relay"){const e=zn(n.relay);return e?[{kind:"relay",relay:e}]:[]}return typeof n.url=="string"?Mn(n.url):[]},Ct=()=>{if(typeof window>"u")return[];let n;try{n=JSON.parse(window.localStorage.getItem(Ms)||"[]")}catch{return[]}if(!Array.isArray(n))return[];const e=Oe();return n.flatMap(s=>{if(!s||typeof s!="object")return[];const o=s;if(typeof o.id!="string")return[];const r=Array.isArray(o.candidates)?o.candidates.map(ic).filter(f=>!!f):ac(o);if(r.length===0)return[];const i=typeof o.clientToken=="string"&&o.clientToken.trim()?o.clientToken:void 0,a=typeof o.label=="string"&&o.label.trim()?o.label:Ts(ft({candidates:r})),u={id:o.id,label:a,candidates:r,lastUsedAt:typeof o.lastUsedAt=="number"?o.lastUsedAt:0};return e?[{...u,hasToken:!!o.hasToken||!!i}]:[{...u,clientToken:i,hasToken:!!i}]}).sort((s,o)=>o.lastUsedAt-s.lastUsedAt)},un=n=>n.kind==="relay"?{kind:"relay",relay:{relayUrl:n.relay.relayUrl,serverId:n.relay.serverId,hostEncPubJwk:n.relay.hostEncPubJwk}}:{kind:"direct",url:n.url},On=n=>{if(typeof window>"u")return;const e=Oe(),s=n.slice(0,mo).map(o=>{const r={id:o.id,label:o.label,candidates:o.candidates.map(un),lastUsedAt:o.lastUsedAt};return e?{...r,hasToken:!!(o.hasToken||o.clientToken)}:{...r,clientToken:o.clientToken}});try{window.localStorage.setItem(Ms,JSON.stringify(s))}catch(o){console.warn("[mobile-storage] failed to persist connection metadata",o)}},xo=(n,e)=>{const s=n.find(i=>e.id&&i.id===e.id||Os(i.candidates,e.candidates)),o=Oe(),r={id:e.id||s?.id||crypto.randomUUID(),label:e.label,candidates:e.candidates,lastUsedAt:Date.now(),...o?{hasToken:e.hasToken??(!!e.clientToken||s?.hasToken||!1)}:{clientToken:e.clientToken??s?.clientToken,hasToken:!!(e.clientToken??s?.clientToken)}};return[r,...n.filter(i=>i.id!==r.id&&!Os(i.candidates,e.candidates))].slice(0,mo)},Bn=sl,lc=0,Ln=n=>`${ql}token.${encodeURIComponent(n)}`,cc=async(n,e)=>{let s;const o=new Promise(r=>{s=window.setTimeout(()=>r(e),Xl)});try{return await Promise.race([n.catch(()=>e),o])}finally{s!==void 0&&window.clearTimeout(s)}},$n=async(n,e,s)=>Oe()?cc(e().catch(o=>(console.warn(`[mobile-storage] ${n} failed`,o),s)),s):s,ps=async n=>{Ft("secure:read-start",{key:n});const e=await $n("secure:read",async()=>(await Bn.internalGetItem({prefixedKey:Ln(n),sync:!1})).data,null),s=typeof e=="string"&&e.trim()?e:void 0;return Ft("secure:read",{key:n,hasToken:!!s}),s},vt=async(n,e)=>{Ft("secure:write-start",{key:n});const s=await $n("secure:write",async()=>(await Bn.internalSetItem({prefixedKey:Ln(n),data:e,sync:!1,access:lc}),!0),!1);return Ft("secure:write",{key:n,ok:s}),s},uc=async n=>{await $n("secure:delete",async()=>(await Bn.internalRemoveItem({prefixedKey:Ln(n),sync:!1}),!0),!1)},dc=async(n,e)=>{let s=0,o=0;return{records:await Promise.all(n.map(async i=>{if(!i||typeof i!="object")return i;const a=i,u=typeof a.url=="string"?a.url:null,f=typeof a.clientToken=="string"?a.clientToken.trim():"";if(!u||!f)return i;if(!await e(u,f))return o+=1,i;s+=1;const{clientToken:d,...l}=a;return{...l,hasToken:!0}})),migrated:s,failed:o}},yo=async()=>{if(typeof window>"u"||!Oe())return;let n;try{n=JSON.parse(window.localStorage.getItem(Ms)||"[]")}catch{return}if(!Array.isArray(n))return;const e=n.filter(o=>!!o&&typeof o=="object"&&typeof o.url=="string"&&typeof o.clientToken=="string"&&!!o.clientToken.trim());if(e.length===0)return;Ft("secure:migrate-start",{count:e.length});const s=await dc(n,async(o,r)=>{const i=$t(o);return await vt(i,r)?await ps(i)===r:!1});if(s.migrated>0)try{window.localStorage.setItem(Ms,JSON.stringify(s.records))}catch(o){console.warn("[mobile-storage] failed to finalize secure token migration",o);return}Ft("secure:migrate-done",{migrated:s.migrated,failed:s.failed})},fc=async()=>(await yo(),Ct()),Bs=async n=>{const e=xo(Ct(),n);return On(e),Oe()&&n.clientToken&&await vt(De({candidates:n.candidates}),n.clientToken),e},mc=async n=>{const e=Ct(),s=e.find(r=>r.id===n)??null,o=e.filter(r=>r.id!==n);return On(o),s&&Oe()&&await uc(De(s)),o},pc=1500,Ls=async(n,e,s)=>{const o=s?.fast?{totalTimeoutMs:zs}:void 0,r=kt({candidates:n})?.serverId??null,i=n.find(d=>d.kind==="relay")??null,a=n.filter(d=>d.kind==="direct"),u=async()=>{for(const d of a){const l=Vt(d.url)||d.url,p=e?{Authorization:`Bearer ${e}`}:void 0,g=await St(`${l}/health`,{method:"GET"},o);if(be("probe:direct:health",{url:l,ok:g?.ok===!0,status:g?.status??null,source:g?.source??null}),!g?.ok)continue;if(r){const v=await g.json().catch(()=>null),T=v&&typeof v=="object"?v.serverId:null;if(typeof T=="string"&&T&&T!==r){be("probe:server-id-mismatch",{url:l});continue}}const h=await St(`${l}/auth/session`,{method:"GET",credentials:e?"omit":"include",headers:p},o);if(be("probe:direct:session",{url:l,ok:h?.ok===!0,status:h?.status??null,source:h?.source??null,hasToken:!!e}),h?.status===401)return{status:"needs-login"};if(!h||!h.ok&&h.status!==404)continue;const y=await Ws(h);if(y&&y.disabled!==!0&&y.authenticated===!1)return{status:"needs-login"};const j=y?.disabled===!0;return!e&&Oe()&&!j&&y?.scope!=="client"?{status:"needs-login"}:{status:"ok",transport:{kind:"direct",url:l}}}return{status:"unreachable"}},f=async()=>{if(!i)return{status:"unreachable"};const{outcome:d,tunnel:l}=await rc(i.relay,e,void 0,s?.fast?zs:po,{keepTunnel:!0});return d==="ok"?{status:"ok",transport:{kind:"relay",relay:i.relay,tunnel:l}}:d==="needs-login"||d==="auth-failed"?{status:"needs-login"}:{status:"unreachable"}};return i?a.length===0?f():new Promise(d=>{let l=!1,p=!1,g,h=null,y=null;const j=S=>{S?.status==="ok"&&S.transport.kind==="relay"&&S.transport.tunnel?.close()},v=S=>{l||(l=!0,d(S))},T=()=>{p||l||(g!==void 0&&(window.clearTimeout(g),g=void 0),f().then(S=>{if(y=S,l||p){j(S);return}if(S.status==="ok"||S.status==="needs-login"){v(S);return}h&&v(h)}))};u().then(S=>{if(h=S,!l){if(S.status==="ok"||S.status==="needs-login"){p=!0,g!==void 0&&window.clearTimeout(g),j(y),v(S);return}if(y){v(y);return}T()}}),g=window.setTimeout(T,pc)}):u()},wt=(n,e,s)=>{n.kind==="relay"?oc(n.relay,e,s?.grant,s?.runtimeKey,n.tunnel):It({apiBaseUrl:n.url,clientToken:e,runtimeKey:s?.runtimeKey}),wo()},os=()=>{const n=Ct()[0];return n?.label?.trim()?n.label:null},ns=async n=>{const e=n?.fast!==!1;await yo();const s=Ct()[0];if(be("auto-connect:start",{hasCandidate:!!s,fast:e}),!s)return{status:"no-candidate"};let o;if(Oe()){if(s.hasToken&&(o=await ps(De(s)),!o))return{status:"no-candidate"}}else if(o=s.clientToken,!o&&s.hasToken)return{status:"no-candidate"};const r=await Ls(s.candidates,o,{fast:e});return be("auto-connect:probe",{status:r.status,candidates:s.candidates.map(i=>i.kind)}),r.status==="needs-login"?{status:"needs-login",label:s.label}:r.status!=="ok"?{status:"unreachable",label:s.label}:n?.skipIfConnected&&ut()?(r.transport.kind==="relay"&&r.transport.tunnel?.close(),be("auto-connect:superseded",{}),{status:"no-candidate"}):(await Bs({id:s.id,label:s.label,candidates:s.candidates}),wt(r.transport,o??null,{runtimeKey:De(s)}),{status:"connected"})},hc=async(n,e)=>{let s="";try{s=Vt(n.url)}catch{return!1}if(!s)return!1;const o=n.clientToken?.trim()||void 0,r=o?{Authorization:`Bearer ${o}`}:void 0,i=e?.fast?{totalTimeoutMs:zs}:void 0;if(!(await St(`${s}/health`,{method:"GET",headers:r},i))?.ok)return!1;const u=await St(`${s}/auth/session`,{method:"GET",credentials:o?"omit":"include",headers:r},i);if(!u||!u.ok&&u.status!==404)return!1;const f=await Ws(u);return!(f&&f.disabled!==!0&&f.authenticated===!1)},gc=n=>[...n].sort((e,s)=>{const o=(e.priority??100)-(s.priority??100);if(o!==0)return o;const r=i=>i.type==="relay"?2:i.url.startsWith("https://")?0:1;return r(e)-r(s)}).flatMap(e=>{if(e.type==="relay"){const s=zn({relayUrl:e.relayUrl,serverId:e.serverId,hostEncPubJwk:e.hostEncPubJwk});return s?[{kind:"relay",relay:s}]:[]}return Mn(e.url)}),pr=async n=>{const e=kt({candidates:n})?.serverId??null;for(const s of n){if(s.kind==="relay"){const i=Fr(s.relay),a=await pt(Wt,i.fetch("/health").catch(()=>null));if(be("establish:relay:health",{ok:a?.ok===!0,status:a?.status??null}),a?.ok)return{kind:"relay",relay:s.relay,tunnel:i};i.close();continue}const o=Vt(s.url)||s.url,r=await St(`${o}/health`,{method:"GET"});if(be("establish:direct:health",{ok:r?.ok===!0,status:r?.status??null}),!!r?.ok){if(e){const i=await r.json().catch(()=>null),a=i&&typeof i=="object"?i.serverId:null;if(typeof a=="string"&&a&&a!==e){be("establish:server-id-mismatch",{url:o});continue}}return{kind:"direct",url:o}}}return null},bc=async(n,e)=>{if(!ms())return hc(n,e);const s=await pt(e?.fast?zs:Wt,pn("/auth/session").then(r=>r).catch(()=>null));if(!s)return!0;if(s.status===401)return!1;if(!s.ok&&s.status!==404)return!0;const o=await Ws(s);return!(o&&o.disabled!==!0&&o.authenticated===!1)},xc=n=>n.kind==="relay"?ms():!ms()&&ho(n.url,ut()),vo=()=>{const n=Ut();return n?Ct().find(e=>De(e)===n)??null:null},hr=n=>{const e=Ut();return!!e&&De(n)===e},Is=async n=>{const e=n?.fast!==!1,s=vo();if(!s)return be("reprobe:no-connection",{runtimeKey:!!Ut()}),"no-connection";let o;if(Oe()?o=s.hasToken?await ps(De(s)):void 0:o=s.clientToken,!o&&s.hasToken)return be("reprobe:no-token",{hasToken:!0}),"unreachable";be("reprobe:start",{candidates:s.candidates.map(d=>d.kind),fast:e,hasToken:!!o});const r=s.candidates.findIndex(d=>xc(d.kind==="relay"?{kind:"relay",relay:d.relay}:{kind:"direct",url:d.url})),i=r>=0?s.candidates.slice(0,r):s.candidates,a=await Ls(i,o,{fast:e});if(be("reprobe:better",{status:a.status,probed:i.length}),a.status==="ok")return await Bs({id:s.id,label:s.label,candidates:s.candidates}),wt(a.transport,o??null,{runtimeKey:De(s)}),"switched";if(a.status==="needs-login")return"needs-login";if(r>=0){const d=await bc({url:ut(),clientToken:o},{fast:e});if(be("reprobe:current",{stillValid:d}),d)return wo(),"unchanged"}const u=r>=0?s.candidates.slice(r+1):[],f=await Ls(u,o,{fast:e});return be("reprobe:fallback",{status:f.status,probed:u.length}),f.status==="ok"?(await Bs({id:s.id,label:s.label,candidates:s.candidates}),wt(f.transport,o??null,{runtimeKey:De(s)}),"switched"):f.status==="needs-login"?"needs-login":"unreachable"},yc=5e3;let en=!1;const vc=async()=>{if(en)return"skipped";const n=vo();if(!n)return be("candidates:refresh-skip",{reason:"no-active-connection"}),"skipped";const e=kt(n);if(!e)return be("candidates:refresh-skip",{reason:"no-relay-candidate"}),"skipped";en=!0;try{const s=await pt(Wt,pn("/api/client-auth/connection/candidates").then(d=>d).catch(()=>null));if(!s?.ok)return be("candidates:refresh-skip",{reason:"fetch-failed",status:s?.status??null}),"skipped";const o=await s.json().catch(()=>null);if(!o||o.serverId!==e.serverId)return be("candidates:refresh-skip",{reason:"server-id-mismatch"}),"skipped";const r=Array.isArray(o.candidates)?o.candidates:[],i=[];for(const d of r){if(!d||typeof d!="object")continue;const l=d;if(!(l.type!=="lan"||typeof l.url!="string"))try{const p=Vt(l.url);p&&!i.includes(p)&&i.push(p)}catch{}}if(i.length===0)return be("candidates:refresh-skip",{reason:"no-lan-reported"}),"skipped";const a=Fs(n).filter(d=>d.url.startsWith("https://")),u=[...i.map(d=>({kind:"direct",url:d})),...a,{kind:"relay",relay:e}];return JSON.stringify(n.candidates.map(un))===JSON.stringify(u.map(un))?"unchanged":(be("candidates:refreshed",{lanCount:i.length}),await Bs({id:n.id,label:n.label,candidates:u}),"updated")}finally{en=!1}},wo=()=>{typeof window>"u"||window.setTimeout(()=>{(async()=>{const n=await vc().catch(()=>"skipped");be("candidates:refresh-result",{result:n}),n==="updated"&&ms()&&await Is().catch(()=>null)})()},yc)},jo=n=>{const{t:e}=fe(),[s,o]=c.useState(()=>Ct()),[r,i]=c.useState(null),[a,u]=c.useState(null),[f,d]=c.useState(null),l=c.useRef(s),p=c.useRef(null),g=c.useRef(Ql()),h=c.useCallback(k=>{l.current=k,o(k)},[]),y=c.useCallback(k=>{p.current=k,i(k)},[]),j=c.useCallback(k=>{p.current===k&&(p.current=null,i(null))},[]);c.useEffect(()=>{let k=!1;return fc().then(R=>{k||h(R)}),()=>{k=!0}},[h]);const v=c.useCallback(k=>{const R=xo(l.current,k);return h(R),On(R),R},[h]),T=c.useCallback(async k=>{u(null),y("connect");try{const R=mr(k);if(R.length===0){u(e("mobile.connect.error.urlRequired"));return}const b=k.id?l.current.find(K=>K.id===k.id):l.current.find(K=>Os(K.candidates,R)),O=k.label?.trim()||b?.label||Ts(ft({candidates:R})),z=k.relayGrant;let C=k.clientToken?.trim()||void 0;const x=!!C;C||(Oe()?b?.hasToken&&(C=await ps(De({candidates:R}))):C=b?.clientToken),be("connect:start",{candidates:R.map(K=>K.kind),hasToken:!!C});const _=await Ls(R,C);if(be("connect:probe",{status:_.status}),_.status==="unreachable"){u(e("mobile.connect.error.unreachable"));return}if(_.status==="needs-login"){v({id:b?.id,label:O,candidates:R}),d({id:b?.id??crypto.randomUUID(),label:O,candidates:R,relay:kt({candidates:R})??void 0,relayGrant:z});return}C&&x&&Oe()&&await vt(De({candidates:R}),C),v({id:b?.id,label:O,candidates:R,clientToken:C}),wt(_.transport,C??null,{runtimeKey:De({candidates:R}),grant:z}),n()}catch(R){console.warn("[mobile-connect] connect threw",R),u(e("mobile.connect.error.invalidUrl"))}finally{j("connect")}},[y,j,n,v,e]),S=c.useCallback(async k=>{if(p.current==="pairing")return;u(null),y("pairing");const R=gc(k.candidates);let b=null,O=!1;try{if(b=await pr(R),!b){u(e("mobile.connect.error.unreachable"));return}const z=JSON.stringify({pairingId:k.pairingId,secret:k.secret,clientLabel:"AiWorker Mobile",clientKind:"mobile",deviceName:"AiWorker Mobile",devicePlatform:fr(),dedupeKey:dr()}),C={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:z},x=b.kind==="relay"?await pt(Wt,b.tunnel.fetch("/api/client-auth/pairing/redeem",C).catch(()=>null)):await St(`${b.url}/api/client-auth/pairing/redeem`,C);if(!x?.ok){u(e("mobile.connect.error.authRequired"));return}const _=await x.json().catch(()=>null),K=typeof _?.clientToken=="string"?_.clientToken.trim():"";if(!K){u(e("mobile.connect.error.authRequired"));return}const N=typeof _?.server?.label=="string"?_.server.label:"",V=k.label||N||Ts(ft({candidates:R}));if(Oe()&&!await vt(De({candidates:R}),K)){u(e("mobile.connect.error.authRequired"));return}v({label:V,candidates:R,clientToken:K}),wt(b.kind==="relay"?{kind:"relay",relay:b.relay,tunnel:b.tunnel}:{kind:"direct",url:b.url},K,{runtimeKey:De({candidates:R})}),O=b.kind==="relay",n()}catch(z){console.warn("[mobile-connect] pairing threw",z),u(e("mobile.connect.error.authRequired"))}finally{!O&&b?.kind==="relay"&&b.tunnel.close(),j("pairing")}},[y,j,n,v,e]),E=c.useCallback(async k=>{if(!f||!k.trim()||p.current==="password")return;u(null),y("password");const R=g.current.begin(),b=()=>g.current.isCurrent(R),{id:O,label:z,candidates:C}=f;let x=null,_=!1;try{if(x=await pr(C),!b())return;if(!x){u(e("mobile.connect.error.unreachable"));return}const K={method:"POST",credentials:"include",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({password:k,trustDevice:!0,issueClientToken:!0,clientLabel:"AiWorker Mobile",clientKind:"mobile",devicePlatform:fr(),dedupeKey:dr()})};be("password:start",{transport:x.kind});const N=x.kind==="relay"?await pt(Wt,x.tunnel.fetch("/auth/session",K).catch(()=>null)):await St(`${x.url}/auth/session`,K);if(!b())return;if(be("password:done",{ok:N?.ok===!0,status:N?.status??null}),!N?.ok){u(e("mobile.connect.error.passwordFailed"));return}const V=await N.json().catch(()=>null);if(!b())return;const F=typeof V?.clientToken=="string"?V.clientToken.trim():"";if(be("password:token",{issued:!!F}),!F){if(x.kind==="direct"&&!Oe()){v({id:O,label:z,candidates:C}),d(null),wt({kind:"direct",url:x.url},null,{runtimeKey:De({candidates:C})}),n();return}u(e("mobile.connect.error.authRequired"));return}if(Oe()&&(!b()||(await vt(De({candidates:C}),F),!b()))||!b()||(v({id:O,label:z,candidates:C,clientToken:F}),d(null),wt(x.kind==="relay"?{kind:"relay",relay:x.relay,tunnel:x.tunnel}:{kind:"direct",url:x.url},F,{runtimeKey:De({candidates:C})}),_=x.kind==="relay",!b()))return;n()}catch(K){if(!b())return;console.warn("[mobile-connect] password threw",K),u(e("mobile.connect.error.passwordFailed"))}finally{!_&&x?.kind==="relay"&&x.tunnel.close(),b()&&j("password")}},[y,j,n,f,v,e]),D=c.useCallback(()=>{g.current.cancel(),j("password"),d(null),u(null)},[j]),w=c.useCallback(async k=>{u(null);let R=mr(k);const b=k.id?l.current.find(x=>x.id===k.id)??null:null;if(b){const x=R.filter(N=>N.kind==="direct"),_=Fs(b).filter(N=>N.url.startsWith("https://")&&!x.some(V=>ho(V.url,N.url))),K=kt(b);R=[...x,..._,...K?[{kind:"relay",relay:K}]:[]]}if(R.length===0)return u(e("mobile.connect.error.urlRequired")),null;const O=k.clientToken?.trim()||void 0,z=k.label?.trim()||Ts(ft({candidates:R}));if(Oe()){const x=De({candidates:R});if(O)await vt(x,O);else if(b?.hasToken){const _=De(b);if(_&&x&&_!==x){const K=await ps(_);K&&await vt(x,K)}}}return v({id:k.id,label:z,candidates:R,clientToken:O}).find(x=>Os(x.candidates,R))??null},[v,e]),A=c.useCallback(async k=>{const R=l.current.find(O=>O.id===k)??null,b=await mc(k);return h(b),R},[h]);return{connections:s,isBusy:r!==null,isPasswordBusy:r==="password",error:a,pendingConnection:f,connect:T,redeemPairingConnection:S,submitPassword:E,cancelPassword:D,saveConnection:w,removeConnection:A,setError:u}},ko=n=>{const e=le.c(31),{onClose:s}=n,{t:o}=fe(),[r,i]=c.useState(!1);let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=Gl(),e[0]=a):a=e[0];const u=a;let f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{Xo(Hl()).then(k=>{k.ok&&(i(!0),window.setTimeout(()=>i(!1),2e3))})},e[1]=f):f=e[1];const d=f;let l;e[2]!==o?(l=o("mobile.connectionDebug.title"),e[2]=o,e[3]=l):l=e[3];let p;e[4]!==l?(p=t.jsx("h2",{className:"min-w-0 truncate typography-ui-label text-foreground",children:l}),e[4]=l,e[5]=p):p=e[5];const g=r?"check":"file-copy";let h;e[6]!==g?(h=t.jsx(X,{name:g,className:"size-4"}),e[6]=g,e[7]=h):h=e[7];let y;e[8]!==r||e[9]!==o?(y=o(r?"mobile.connectionDebug.copied":"mobile.connectionDebug.copy"),e[8]=r,e[9]=o,e[10]=y):y=e[10];let j;e[11]!==h||e[12]!==y?(j=t.jsxs(he,{type:"button",variant:"outline",size:"sm",onClick:d,disabled:u.length===0,children:[h,y]}),e[11]=h,e[12]=y,e[13]=j):j=e[13];let v;e[14]!==o?(v=o("mobile.connectionDebug.close"),e[14]=o,e[15]=v):v=e[15];let T;e[16]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx(X,{name:"close",className:"size-[18px]"}),e[16]=T):T=e[16];let S;e[17]!==s||e[18]!==v?(S=t.jsx(he,{type:"button",variant:"ghost",size:"icon","aria-label":v,onClick:s,children:T}),e[17]=s,e[18]=v,e[19]=S):S=e[19];let E;e[20]!==S||e[21]!==j?(E=t.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[j,S]}),e[20]=S,e[21]=j,e[22]=E):E=e[22];let D;e[23]!==E||e[24]!==p?(D=t.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border/70 px-4 py-2.5",children:[p,E]}),e[23]=E,e[24]=p,e[25]=D):D=e[25];let w;e[26]!==o?(w=t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overflow-x-hidden px-4 py-3",children:u.length===0?t.jsx("p",{className:"typography-small text-muted-foreground",children:o("mobile.connectionDebug.empty")}):t.jsx("pre",{className:"whitespace-pre-wrap break-words typography-code text-muted-foreground",children:u.map(uo).join(`
|
|
4
|
+
`)})}),e[26]=o,e[27]=w):w=e[27];let A;return e[28]!==D||e[29]!==w?(A=t.jsxs("div",{className:"fixed inset-0 z-[70] flex flex-col bg-background pb-[var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px))] pt-[var(--safe-area-inset-top,env(safe-area-inset-top,0px))] text-foreground",children:[D,w]}),e[28]=D,e[29]=w,e[30]=A):A=e[30],A},So=()=>{if(typeof window>"u")return null;const e=window.Capacitor?.Plugins?.BarcodeScanner;return e&&(typeof e.scan=="function"||typeof e.startScan=="function")?e:null},wc=()=>window.Capacitor?.getPlatform?.()==="android",No=n=>{const e=n.trim();if(!e)return null;if(/^aiworker:\/\//i.test(e)){const s=$o(e);return s?{pairing:s}:null}return/^https?:\/\//i.test(e)?{url:e}:null},Co=(n,e)=>{const s=No(n);if(!s&&e?.pairingStringFallback){const o=Fo(n);if(o)return{status:"pairing",pairing:o}}return s?"pairing"in s?{status:"pairing",...s}:{status:"ok",...s}:{status:"invalid"}},jc=async(n,e)=>{if(!n.startScan||!n.stopScan||!n.addListener)return{status:"unsupported"};if(e?.aborted)return{status:"cancelled"};let s,o,r=!1,i=()=>{};const a=new Promise(d=>{i=d}),u=d=>{r||(r=!0,i(d))},f=()=>u({status:"cancelled"});e?.addEventListener("abort",f,{once:!0});try{return(await Promise.allSettled([Promise.resolve(n.addListener("barcodesScanned",({barcodes:l})=>{const p=l?.[0],g=(p?.rawValue??p?.displayValue??"").trim();g&&u(Co(g,{pairingStringFallback:!0}))})).then(l=>{s=l}),Promise.resolve(n.addListener("scanError",()=>u({status:"failed"}))).then(l=>{o=l})])).some(({status:l})=>l==="rejected")?u({status:"failed"}):r||n.startScan({formats:["QR_CODE"]}).catch(()=>u({status:"failed"})),await a}finally{e?.removeEventListener("abort",f),await Promise.allSettled([Promise.resolve(s?.remove()),Promise.resolve(o?.remove()),n.stopScan()])}},dn=()=>So()!==null,Eo=async n=>{const e=So();if(!e)return{status:"unsupported"};try{if(e.requestPermissions){const a=(await e.requestPermissions())?.camera;if(a&&a!=="granted"&&a!=="limited")return{status:"permission-denied"}}if(n?.signal?.aborted)return{status:"cancelled"};if(wc())return jc(e,n?.signal);if(!e.scan)return{status:"unsupported"};const o=(await e.scan({formats:["QR_CODE"]}))?.barcodes?.[0],r=(o?.rawValue??o?.displayValue??"").trim();return r?Co(r):{status:"cancelled"}}catch{return{status:"failed"}}},zt={autoComplete:"off",autoCorrect:"off",spellCheck:!1},is="h-12 w-full rounded-[16px] border border-border/70 bg-surface-elevated px-4 text-[16px] text-foreground outline-none transition-colors placeholder:text-muted-foreground focus:border-primary focus:ring-2 focus:ring-primary/20",Ro=n=>{const e=le.c(22),{onCancel:s}=n,{t:o}=fe(),r=c.useRef(null);let i,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{const T={value:document.documentElement.style.getPropertyValue("background-color"),priority:document.documentElement.style.getPropertyPriority("background-color")},S={value:document.body.style.getPropertyValue("background-color"),priority:document.body.style.getPropertyPriority("background-color")};document.documentElement.style.setProperty("background-color","rgba(0, 0, 0, 0)","important"),document.body.style.setProperty("background-color","rgba(0, 0, 0, 0)","important");const E=new Map,D=A=>{!(A instanceof HTMLElement)||A===r.current||E.has(A)||(E.set(A,{opacity:A.style.opacity,pointerEvents:A.style.pointerEvents}),A.style.setProperty("opacity","0"),A.style.setProperty("pointer-events","none"))};Array.from(document.body.children).forEach(D);const w=new MutationObserver(A=>{A.forEach(k=>k.addedNodes.forEach(D))});return w.observe(document.body,{childList:!0}),()=>{w.disconnect(),E.forEach(kc),T.value?document.documentElement.style.setProperty("background-color",T.value,T.priority):document.documentElement.style.removeProperty("background-color"),S.value?document.body.style.setProperty("background-color",S.value,S.priority):document.body.style.removeProperty("background-color")}},a=[],e[0]=i,e[1]=a):(i=e[0],a=e[1]),c.useLayoutEffect(i,a);let u,f;e[2]!==s?(u=()=>{const T=()=>{document.visibilityState==="hidden"&&s()};return document.addEventListener("visibilitychange",T),()=>document.removeEventListener("visibilitychange",T)},f=[s],e[2]=s,e[3]=u,e[4]=f):(u=e[3],f=e[4]),c.useEffect(u,f);let d;e[5]!==o?(d=o("mobile.connect.scanQr"),e[5]=o,e[6]=d):d=e[6];let l;e[7]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx("div",{className:"aspect-square w-full max-w-72 rounded-[28px] border-2 border-foreground/90 shadow-[0_0_0_9999px_color-mix(in_srgb,var(--surface-background)_18%,transparent)]","aria-hidden":!0}),e[7]=l):l=e[7];let p;e[8]!==o?(p=o("mobile.connect.welcome.scanHint"),e[8]=o,e[9]=p):p=e[9];let g;e[10]!==p?(g=t.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-6",children:[l,t.jsx("p",{className:"max-w-sm rounded-[16px] border border-border/60 bg-background px-4 py-3 text-center typography-body text-foreground shadow-sm",children:p})]}),e[10]=p,e[11]=g):g=e[11];let h;e[12]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(X,{name:"close",className:"size-[18px]"}),e[12]=h):h=e[12];let y;e[13]!==o?(y=o("mobile.instances.cancelEdit"),e[13]=o,e[14]=y):y=e[14];let j;e[15]!==s||e[16]!==y?(j=t.jsxs(he,{type:"button",variant:"outline",size:"lg",className:"mx-auto min-h-12 w-full max-w-sm bg-background",onClick:s,children:[h,y]}),e[15]=s,e[16]=y,e[17]=j):j=e[17];let v;return e[18]!==j||e[19]!==d||e[20]!==g?(v=Ot.createPortal(t.jsxs("div",{ref:r,role:"dialog","aria-modal":"true","aria-label":d,className:"fixed inset-0 z-[1000] flex flex-col bg-transparent px-6 pb-[calc(var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px))+24px)] pt-[calc(var(--safe-area-inset-top,env(safe-area-inset-top,0px))+24px)] text-foreground",children:[g,j]}),document.body),e[18]=j,e[19]=d,e[20]=g,e[21]=v):v=e[21],v},Po=()=>{const n=le.c(6),{t:e}=fe();let s;n[0]===Symbol.for("react.memo_cache_sentinel")?(s=t.jsx(yt,{width:96,height:96,isAnimated:!0}),n[0]=s):s=n[0];let o;n[1]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx(X,{name:"loader-4",className:"size-[18px] animate-spin"}),n[1]=o):o=n[1];let r;n[2]!==e?(r=e("mobile.connect.connecting"),n[2]=e,n[3]=r):r=n[3];let i;return n[4]!==r?(i=Ot.createPortal(t.jsxs("div",{role:"status",className:"fixed inset-0 z-[1000] flex flex-col items-center justify-center gap-5 bg-background px-6 text-foreground",children:[s,t.jsxs("div",{className:"flex items-center gap-2 typography-ui-label text-muted-foreground",children:[o,t.jsx("span",{children:r})]})]}),document.body),n[4]=r,n[5]=i):i=n[5],i};function kc(n,e){e.style.opacity=n.opacity,e.style.pointerEvents=n.pointerEvents}const Sc=({onConnected:n,notice:e=null})=>{const{t:s}=fe(),o=jo(n),{connections:r,isBusy:i,isPasswordBusy:a,error:u,pendingConnection:f}=o,[d,l]=c.useState(""),[p,g]=c.useState(""),[h,y]=c.useState(""),[j,v]=c.useState(!1),[T,S]=c.useState(!1),E=c.useRef(null),D=c.useMemo(()=>dn(),[]),[w,A]=c.useState(()=>!dn()),[k,R]=c.useState(null),[b,O]=c.useState(""),[z,C]=c.useState(!1),x=fo(c.useCallback(()=>C(!0),[])),_=c.useCallback(I=>{I.preventDefault(),o.connect({url:d,clientToken:h,label:p})},[h,o,p,d]),K=c.useCallback(I=>{if(/^aiworker:\/\//i.test(I.trim())){const B=No(I);if(B){if("pairing"in B){o.redeemPairingConnection(B.pairing);return}l(B.url),B.label&&g(B.label),B.clientToken&&y(B.clientToken);return}}l(I)},[o]),N=c.useCallback(async()=>{if(E.current||i)return;o.setError(null),v(!0);const I=new AbortController;E.current=I;try{const B=await Eo({signal:I.signal});switch(E.current===I&&(E.current=null,v(!1)),B.status){case"ok":S(!0),l(B.url),B.label&&g(B.label),B.clientToken&&y(B.clientToken),await o.connect({url:B.url,clientToken:B.clientToken,label:B.label});break;case"pairing":S(!0),await o.redeemPairingConnection(B.pairing);break;case"permission-denied":o.setError(s("mobile.connect.scan.permissionDenied"));break;case"invalid":o.setError(s("mobile.connect.scan.invalid"));break;case"unsupported":o.setError(s("mobile.connect.scan.unsupported"));break;case"failed":o.setError(s("mobile.connect.scan.failed"));break;default:break}}finally{S(!1),E.current===I&&(E.current=null,v(!1))}},[o,i,s]);c.useEffect(()=>()=>E.current?.abort(),[]);const V=c.useCallback(I=>{I.preventDefault(),o.submitPassword(b)},[o,b]),F=c.useCallback(()=>{O(""),o.cancelPassword()},[o]);return t.jsxs(t.Fragment,{children:[j?t.jsx(Ro,{onCancel:()=>E.current?.abort()}):null,T?t.jsx(Po,{}):null,z?t.jsx(ko,{onClose:()=>C(!1)}):null,t.jsx("main",{className:"oc-keyboard-fill-screen flex min-h-dvh flex-col overflow-y-auto bg-background px-6 pb-[calc(var(--safe-area-inset-bottom,env(safe-area-inset-bottom,0px))+28px)] pt-[calc(var(--safe-area-inset-top,env(safe-area-inset-top,0px))+28px)] text-foreground",children:t.jsxs("div",{className:"m-auto flex w-full max-w-[360px] shrink-0 flex-col items-center gap-9 py-8",children:[t.jsxs("div",{className:"flex flex-col items-center gap-5 text-center",children:[t.jsx("span",{...x,className:"select-none",style:{touchAction:"manipulation"},children:t.jsx(yt,{width:72,height:72,className:"size-[72px]"})}),t.jsx("h1",{className:"typography-h2 text-foreground",children:s("mobile.connect.welcome.title")})]}),e?t.jsxs("div",{role:"status",className:"flex w-full items-center gap-3 rounded-[18px] border border-[color-mix(in_srgb,var(--status-warning)_35%,transparent)] bg-[color-mix(in_srgb,var(--status-warning)_10%,transparent)] px-3.5 py-3",children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-[color-mix(in_srgb,var(--status-warning)_16%,transparent)] text-[var(--status-warning)]",children:t.jsx(X,{name:e.kind==="auth-expired"?"lock":"cloud-off",className:"size-[18px]"})}),t.jsx("p",{className:"min-w-0 flex-1 typography-small text-foreground",children:e.kind==="auth-expired"?s("mobile.connect.notice.authExpired",{label:e.label}):s("mobile.connect.notice.unreachable",{label:e.label})})]}):null,f?t.jsxs("form",{className:"flex w-full flex-col gap-3",onSubmit:V,children:[t.jsxs("div",{className:"flex items-center gap-3 rounded-[18px] border border-border/70 bg-surface-elevated px-3.5 py-3",children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:t.jsx(X,{name:"lock",className:"size-[18px]"})}),t.jsxs("div",{className:"min-w-0 text-left",children:[t.jsx("p",{className:"truncate typography-ui-label text-foreground",children:f.label}),t.jsx("p",{className:"truncate typography-small text-muted-foreground",children:f.candidates.some(I=>I.kind==="direct")?ft(f):s("mobile.connect.relay.badge")})]})]}),t.jsx("input",{...zt,value:b,onChange:I=>O(I.target.value),placeholder:s("mobile.connect.password.placeholder"),"aria-label":s("mobile.connect.password.label"),type:"password",autoFocus:!0,className:is}),u?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:u}):null,t.jsx(he,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",disabled:a||!b.trim(),children:s(a?"mobile.connect.connecting":"mobile.connect.unlockButton")}),t.jsx(he,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:F,children:s("mobile.connect.cancelPassword")})]}):t.jsxs("div",{className:"flex w-full flex-col gap-6",children:[D?t.jsxs("div",{className:"flex w-full flex-col gap-2",children:[t.jsxs(he,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{N()},disabled:j||i,children:[t.jsx(X,{name:"scan-2",className:Y("size-[18px]",j&&"animate-pulse")}),s(i?"mobile.connect.connecting":"mobile.connect.scanQr")]}),t.jsx("p",{className:"px-2 text-center typography-small text-muted-foreground",children:s("mobile.connect.welcome.scanHint")})]}):null,u&&!w?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:u}):null,r.length>0?t.jsxs("section",{className:"flex w-full flex-col gap-2.5",children:[t.jsx("h2",{className:"text-center typography-micro uppercase tracking-[0.14em] text-muted-foreground",children:s("mobile.connect.saved.title")}),t.jsx("div",{className:"overflow-hidden rounded-[18px] border border-border/70 bg-surface-elevated",children:r.map(I=>{const B=k===I.id;return t.jsxs("button",{type:"button",disabled:i,className:"flex min-h-14 w-full items-center gap-3 border-b border-border/70 px-3.5 py-2.5 text-left last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary disabled:opacity-70",onClick:()=>{R(I.id),o.connect({id:I.id,candidates:I.candidates,clientToken:I.clientToken,label:I.label}).finally(()=>R(null))},children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:t.jsx(X,{name:"server",className:"size-[18px]"})}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate typography-ui-label text-foreground",children:I.label}),t.jsx("span",{className:Y("block truncate typography-small",B?"text-foreground":"text-muted-foreground"),children:B?s("mobile.connect.connecting"):I.candidates.some(Q=>Q.kind==="direct")?ft(I):s("mobile.connect.relay.badge")})]}),B?t.jsx(X,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):t.jsx(X,{name:"arrow-right-s",className:"size-5 text-muted-foreground"})]},I.id)})})]}):null,t.jsxs("div",{className:"flex w-full flex-col",children:[D?t.jsxs("button",{type:"button",onClick:()=>A(I=>!I),"aria-expanded":w,className:"mx-auto flex items-center gap-1 rounded-full px-2 py-1 typography-small text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:[t.jsx("span",{children:s("mobile.connect.manual.toggle")}),t.jsx(X,{name:"arrow-down-s",className:Y("size-4 transition-transform duration-200",w&&"rotate-180")})]}):null,t.jsx("div",{className:"grid transition-[grid-template-rows] duration-200 ease-out",style:{gridTemplateRows:w?"1fr":"0fr"},children:t.jsx("div",{className:"min-h-0 overflow-hidden",children:t.jsxs("form",{className:"flex w-full flex-col gap-3 pt-3",onSubmit:_,children:[t.jsx("input",{...zt,value:d,onChange:I=>K(I.target.value),placeholder:s("mobile.connect.url.placeholder"),"aria-label":s("mobile.connect.url.label"),type:"url",inputMode:"url",autoCapitalize:"none",tabIndex:w?void 0:-1,className:Y(is,"text-center")}),t.jsx("input",{value:p,onChange:I=>g(I.target.value),placeholder:s("mobile.instances.label.placeholder"),"aria-label":s("mobile.instances.label.label"),autoComplete:"off",autoCapitalize:"words",autoCorrect:"off",spellCheck:!1,tabIndex:w?void 0:-1,className:Y(is,"text-center")}),t.jsx("input",{...zt,value:h,onChange:I=>y(I.target.value),placeholder:s("mobile.connect.token.placeholder"),"aria-label":s("mobile.connect.token.label"),tabIndex:w?void 0:-1,autoCapitalize:"none",className:Y(is,"text-center")}),t.jsx("p",{className:"px-1 text-center typography-micro text-muted-foreground",children:s("mobile.connect.token.hint")}),u?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:u}):null,t.jsx(he,{type:"submit",variant:D?"outline":"default",size:"lg",className:"h-12 w-full",disabled:i||j||!d.trim(),children:s(i?"mobile.connect.connecting":"mobile.connect.connectButton")})]})})})]})]})]})})]})},Nc=n=>{const e=n.usedPercent;return typeof e!="number"||!Number.isFinite(e)?"text-foreground":e>=80?"text-[var(--status-error)]":e>=50?"text-[var(--status-warning)]":"text-foreground"},Cc=n=>{const e=le.c(12),{groups:s,displayMode:o,timeFormatPreference:r,className:i}=n;let a;e[0]!==i?(a=Y("space-y-1.5",i),e[0]=i,e[1]=a):a=e[1];let u;if(e[2]!==o||e[3]!==s||e[4]!==r){let d;e[6]!==o||e[7]!==r?(d=l=>t.jsxs("div",{className:"min-w-0 rounded-xl bg-[var(--surface-muted)] p-2.5",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(Qo,{providerId:l.providerId,className:"size-4 shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground",children:l.providerName}),l.planLabel?t.jsx("span",{className:"shrink-0 typography-micro capitalize text-muted-foreground",children:l.planLabel}):null,l.status&&l.rows.length===0?t.jsx("span",{className:"shrink-0 truncate typography-micro text-muted-foreground",children:l.status}):null]}),l.rows.length>0?t.jsx("div",{className:"mt-1.5 space-y-1",children:l.rows.map(p=>{const g=o==="remaining"?p.window.remainingPercent:p.window.usedPercent,h=Zo(p.window.valueLabel,g),y=ei(p.window.resetAt,p.window.resetAfterFormatted??p.window.resetAtFormatted,r);return t.jsxs("div",{className:"flex min-w-0 items-baseline justify-between gap-3",children:[t.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[t.jsx("span",{className:"shrink-0 truncate typography-ui-label text-muted-foreground",children:p.subtitle?`${p.subtitle} · ${p.label}`:p.label}),y?t.jsx("span",{className:"min-w-0 truncate typography-micro text-muted-foreground/70",children:y}):null]}),t.jsx("span",{className:Y("shrink-0 typography-ui-label font-semibold tabular-nums",Nc(p.window)),children:h==="-"?"":h})]},p.key)})}):null,l.status&&l.rows.length>0?t.jsx("div",{className:"mt-1.5 typography-micro text-muted-foreground",children:l.status}):null]},l.providerId),e[6]=o,e[7]=r,e[8]=d):d=e[8],u=s.map(d),e[2]=o,e[3]=s,e[4]=r,e[5]=u}else u=e[5];let f;return e[9]!==a||e[10]!==u?(f=t.jsx("div",{className:a,children:u}),e[9]=a,e[10]=u,e[11]=f):f=e[11],f},gr=380,Ec=(n,e)=>{if(!n||typeof n!="object")return;const s=n[e];return typeof s=="number"&&Number.isFinite(s)?s:void 0},Rt=n=>typeof n=="number"&&Number.isFinite(n)?n:0,br=n=>n>=1e6?`${(n/1e6).toFixed(1)}M`:n>=1e3?`${(n/1e3).toFixed(1)}K`:String(n),Ao=n=>{const e=le.c(19),{percentage:s}=n;let o,r,i,a,u,f,d;if(e[0]!==s){i=oi(s)??0;const y=ii(s);r=y==="critical"?"var(--status-error)":y==="warn"?"var(--status-warning)":"var(--status-success)",o=2*Math.PI*7.5,a="0 0 18 18",u="size-[18px] -rotate-90",f="progressbar",d=Math.round(i),e[0]=s,e[1]=o,e[2]=r,e[3]=i,e[4]=a,e[5]=u,e[6]=f,e[7]=d}else o=e[1],r=e[2],i=e[3],a=e[4],u=e[5],f=e[6],d=e[7];let l;e[8]===Symbol.for("react.memo_cache_sentinel")?(l=t.jsx("circle",{cx:9,cy:9,r:7.5,fill:"none",stroke:"var(--interactive-border)",strokeWidth:3}),e[8]=l):l=e[8];const p=o*(1-i/100);let g;e[9]!==o||e[10]!==r||e[11]!==p?(g=t.jsx("circle",{cx:9,cy:9,r:7.5,fill:"none",stroke:r,strokeWidth:3,strokeLinecap:"round",strokeDasharray:o,strokeDashoffset:p,className:"transition-[stroke-dashoffset,stroke] duration-300"}),e[9]=o,e[10]=r,e[11]=p,e[12]=g):g=e[12];let h;return e[13]!==a||e[14]!==u||e[15]!==f||e[16]!==d||e[17]!==g?(h=t.jsxs("svg",{viewBox:a,className:u,role:f,"aria-valuenow":d,"aria-valuemin":0,"aria-valuemax":100,children:[l,g]}),e[13]=a,e[14]=u,e[15]=f,e[16]=d,e[17]=g,e[18]=h):h=e[18],h},Rc=n=>{const e=le.c(13),{icon:s,iconNode:o,label:r,children:i}=n;let a;e[0]!==s||e[1]!==o?(a=o??(s?t.jsx(X,{name:s,className:"size-[18px]"}):null),e[0]=s,e[1]=o,e[2]=a):a=e[2];let u;e[3]!==a?(u=t.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:a}),e[3]=a,e[4]=u):u=e[4];let f;e[5]!==r?(f=t.jsx("span",{className:"shrink-0 typography-ui-label text-muted-foreground",children:r}),e[5]=r,e[6]=f):f=e[6];let d;e[7]!==i?(d=t.jsx("span",{className:"min-w-0 flex-1 truncate text-right typography-ui-label font-medium text-foreground",children:i}),e[7]=i,e[8]=d):d=e[8];let l;return e[9]!==u||e[10]!==f||e[11]!==d?(l=t.jsxs("div",{className:"flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5",children:[u,f,d]}),e[9]=u,e[10]=f,e[11]=d,e[12]=l):l=e[12],l},Pc=n=>{const e=le.c(49),{open:s,onClose:o,anchorRef:r,contextDisplay:i,usageGroups:a,usageDisplayMode:u,isUsageLoading:f,timeFormatPreference:d}=n,{t:l}=fe(),p=c.useRef(null),[g,h]=c.useState(s),[y,j]=c.useState(!1),{enabled:v}=bn(),T=c.useRef(null),[S,E]=c.useState(null);let D,w;e[0]!==r||e[1]!==v||e[2]!==s||e[3]!==g?(D=()=>{if(!s||!v||!g)return;const J=()=>{const re=r.current?.getBoundingClientRect(),se=T.current?.getBoundingClientRect();if(!re||!se){E(null);return}const ae=re.left-se.left,de=Math.min(Math.max(ae,8),Math.max(8,se.width-gr-8));E(de)};J();const G=T.current;if(typeof ResizeObserver>"u"||!G)return;const te=new ResizeObserver(J);return te.observe(G),()=>te.disconnect()},w=[r,v,s,g],e[0]=r,e[1]=v,e[2]=s,e[3]=g,e[4]=D,e[5]=w):(D=e[4],w=e[5]),c.useLayoutEffect(D,w);const A=v&&S!==null;let k,R;e[6]!==s||e[7]!==g?(k=()=>{if(s){h(!0),j(!1);return}if(!g)return;j(!0);const J=window.setTimeout(()=>{h(!1),j(!1)},140);return()=>window.clearTimeout(J)},R=[s,g],e[6]=s,e[7]=g,e[8]=k,e[9]=R):(k=e[8],R=e[9]),c.useEffect(k,R);let b,O;e[10]!==o||e[11]!==s?(b=()=>{if(!s)return;const J=G=>{G.key==="Escape"&&o()};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)},O=[o,s],e[10]=o,e[11]=s,e[12]=b,e[13]=O):(b=e[12],O=e[13]),c.useEffect(b,O);let z,C;if(e[14]!==r||e[15]!==o||e[16]!==s?(z=()=>{if(!s)return;const J=G=>{const te=G.target;if(!(te instanceof Node)){o();return}p.current?.contains(te)||r.current?.contains(te)||o()};return document.addEventListener("pointerdown",J,!0),document.addEventListener("wheel",J,!0),()=>{document.removeEventListener("pointerdown",J,!0),document.removeEventListener("wheel",J,!0)}},C=[r,o,s],e[14]=r,e[15]=o,e[16]=s,e[17]=z,e[18]=C):(z=e[17],C=e[18]),c.useEffect(z,C),!g)return null;let x;e[19]!==l?(x=l("mobile.header.openMetadataAria"),e[19]=l,e[20]=x):x=e[20];const _=A?"absolute origin-top-left":"mx-3 mt-2",K=y?"pointer-events-none":"pointer-events-auto";let N;e[21]!==_||e[22]!==K?(N=Y("overflow-y-auto overscroll-contain rounded-[20px] border border-border/70 bg-[var(--surface-elevated)] p-2 shadow-[0_12px_32px_rgb(0_0_0_/_0.2)] will-change-transform",_,K),e[21]=_,e[22]=K,e[23]=N):N=e[23];const V=`${y?"session-metadata-out":"session-metadata-in"} ${y?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`;let F;e[24]!==S||e[25]!==A?(F=A?{top:8,left:S??8,width:`min(${gr}px, calc(100% - 16px))`}:null,e[24]=S,e[25]=A,e[26]=F):F=e[26];let I;e[27]!==V||e[28]!==F?(I={animation:V,maxHeight:"min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))",...F},e[27]=V,e[28]=F,e[29]=I):I=e[29];let B;e[30]!==i||e[31]!==l?(B=i?t.jsx(Rc,{iconNode:t.jsx(Ao,{percentage:i.percentage}),label:l("mobile.header.metadata.context"),children:t.jsxs("span",{className:"inline-flex items-baseline gap-1.5 tabular-nums",children:[t.jsxs("span",{className:Y("font-semibold",i.colorClass),children:[i.percentage.toFixed(1),"%"]}),t.jsx("span",{className:"text-muted-foreground",children:i.tokens})]})}):null,e[30]=i,e[31]=l,e[32]=B):B=e[32];let Q;e[33]!==f||e[34]!==d||e[35]!==u||e[36]!==a?(Q=t.jsx(Ac,{groups:a,displayMode:u,isLoading:f,timeFormatPreference:d}),e[33]=f,e[34]=d,e[35]=u,e[36]=a,e[37]=Q):Q=e[37];let Z;e[38]!==B||e[39]!==Q?(Z=t.jsxs("div",{className:"space-y-1",children:[B,Q]}),e[38]=B,e[39]=Q,e[40]=Z):Z=e[40];let ne;e[41]!==N||e[42]!==I||e[43]!==Z||e[44]!==x?(ne=t.jsx("div",{ref:p,role:"dialog","aria-label":x,className:N,style:I,children:Z}),e[41]=N,e[42]=I,e[43]=Z,e[44]=x,e[45]=ne):ne=e[45];let M;e[46]===Symbol.for("react.memo_cache_sentinel")?(M=t.jsx("style",{children:`
|
|
5
|
+
@keyframes session-metadata-in {
|
|
6
|
+
from { opacity: 0; transform: translateY(-8px) scale(0.985); }
|
|
7
|
+
to { opacity: 1; transform: translateY(0) scale(1); }
|
|
8
|
+
}
|
|
9
|
+
@keyframes session-metadata-out {
|
|
10
|
+
from { opacity: 1; transform: translateY(0) scale(1); }
|
|
11
|
+
to { opacity: 0; transform: translateY(-6px) scale(0.985); }
|
|
12
|
+
}
|
|
13
|
+
`}),e[46]=M):M=e[46];let W;return e[47]!==ne?(W=t.jsxs("div",{ref:T,className:"fixed inset-x-0 bottom-0 top-[calc(var(--oc-safe-area-top,0px)+var(--oc-header-height,56px))] z-20 pointer-events-none",children:[ne,M]}),e[47]=ne,e[48]=W):W=e[48],W},Ac=n=>{const e=le.c(30),{groups:s,displayMode:o,isLoading:r,timeFormatPreference:i}=n,{t:a}=fe();let u;e[0]!==o||e[1]!==a?(u=a(o==="remaining"?"header.services.remaining":"header.services.used"),e[0]=o,e[1]=a,e[2]=u):u=e[2];const f=u;if(s.length===0){if(!r)return null;let S;e[3]===Symbol.for("react.memo_cache_sentinel")?(S=t.jsx(X,{name:"loader-4",className:"size-4 animate-spin","aria-hidden":!0}),e[3]=S):S=e[3];let E;e[4]!==a?(E=a("common.loading"),e[4]=a,e[5]=E):E=e[5];let D;return e[6]!==E?(D=t.jsxs("div",{className:"flex items-center justify-center gap-2 px-2.5 py-6 text-muted-foreground",children:[S,t.jsx("span",{className:"typography-ui-label",children:E})]}),e[6]=E,e[7]=D):D=e[7],D}let d;e[8]===Symbol.for("react.memo_cache_sentinel")?(d=t.jsx("span",{className:"flex size-5 shrink-0 items-center justify-center text-muted-foreground",children:t.jsx(X,{name:"timer",className:"size-[18px]"})}),e[8]=d):d=e[8];let l;e[9]!==a?(l=a("mobile.header.metadata.usage"),e[9]=a,e[10]=l):l=e[10];let p;e[11]!==l?(p=t.jsx("span",{className:"shrink-0 typography-ui-label text-muted-foreground",children:l}),e[11]=l,e[12]=p):p=e[12];let g;e[13]!==r?(g=r?t.jsx(X,{name:"refresh",className:"size-3.5 animate-spin"}):null,e[13]=r,e[14]=g):g=e[14];let h;e[15]!==f?(h=t.jsx("span",{className:"truncate",children:f}),e[15]=f,e[16]=h):h=e[16];let y;e[17]!==g||e[18]!==h?(y=t.jsxs("span",{className:"inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground",children:[g,h]}),e[17]=g,e[18]=h,e[19]=y):y=e[19];let j;e[20]!==p||e[21]!==y?(j=t.jsxs("div",{className:"flex min-w-0 items-center gap-3 px-2.5 pb-1.5",children:[d,p,y]}),e[20]=p,e[21]=y,e[22]=j):j=e[22];let v;e[23]!==o||e[24]!==s||e[25]!==i?(v=t.jsx(Cc,{groups:s,displayMode:o,timeFormatPreference:i}),e[23]=o,e[24]=s,e[25]=i,e[26]=v):v=e[26];let T;return e[27]!==j||e[28]!==v?(T=t.jsxs("div",{className:"pt-2.5",children:[j,v]}),e[27]=j,e[28]=v,e[29]=T):T=e[29],T},Tc=c.memo(function({open:e,onOpenChange:s,currentSessionId:o,effectiveDirectory:r,isNewSessionDraftOpen:i}){const{t:a}=fe(),u=c.useRef(null),f=ti(o??"",r||void 0),d=He(I=>I.providers),l=He(I=>I.currentProviderId),p=He(I=>I.currentModelId),g=He(I=>I.getModelMetadata);He(I=>I.modelsMetadata.size);const h=si(c.useCallback(I=>o?I.sessionModelSelections.get(o)??null:null,[o])),y=xt(I=>I.results),j=xt(I=>I.refreshErrors),v=c.useRef(!1),T=xt(I=>I.loadSettings),S=xt(I=>I.fetchAllQuotas),E=xt(I=>I.isLoading),D=xt(I=>I.displayMode),w=xt(I=>I.dropdownProviderIds),A=dt(I=>I.timeFormatPreference);ni(),c.useEffect(()=>{T()},[T]),c.useEffect(()=>{er(w)},[w]),c.useEffect(()=>{if(!e){v.current=!1;return}v.current||E||!w.some(B=>!y.some(Q=>Q.providerId===B)||j[B])||(v.current=!0,S())},[w,S,E,e,y,j]);const R=c.useMemo(()=>{for(let I=f.length-1;I>=0;I-=1){const B=f[I];if(B.role!=="user")continue;const Q=typeof B.model?.providerID=="string"&&B.model.providerID.trim().length>0?B.model.providerID:void 0,Z=typeof B.model?.modelID=="string"&&B.model.modelID.trim().length>0?B.model.modelID:void 0;if(Q&&Z)return{providerID:Q,modelID:Z}}return null},[f])??(h?{providerID:h.providerId,modelID:h.modelId}:null)??(l&&p?{providerID:l,modelID:p}:null),O=(R?d.find(I=>I.id===R.providerID):void 0)?.models.find(I=>I.id===R?.modelID),z=R?g(R.providerID,R.modelID):void 0,C=Ec(O?.limit,"context")??z?.limit?.context??0,x=c.useMemo(()=>{for(let I=f.length-1;I>=0;I-=1){const B=f[I];if(B.role!=="assistant"||!B.tokens)continue;const Q=Rt(B.tokens.total);if(Q>0)return Q;const Z=Rt(B.tokens.input)+Rt(B.tokens.output)+Rt(B.tokens.reasoning)+Rt(B.tokens.cache?.read)+Rt(B.tokens.cache?.write);if(Z>0)return Z}return 0},[f]),_=!i&&x>0&&C>0?Math.min(x/C*100,999):null,K=_!==null?`${br(x)}/${br(C)}`:null,N=_===null?"":_>=90?"text-[var(--status-error)]":_>=75?"text-[var(--status-warning)]":"text-[var(--status-success)]",V=_!==null&&K?{percentage:_,tokens:K,colorClass:N}:null,F=ri();return c.useEffect(()=>{!e||F.length===0||er(F.map(I=>I.providerId))},[e,F]),t.jsxs(t.Fragment,{children:[t.jsx("button",{ref:u,type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":a("mobile.header.openMetadataAria"),"aria-expanded":e,onClick:()=>s(I=>!I),style:{touchAction:"manipulation"},children:t.jsx(Ao,{percentage:V?.percentage??0})}),t.jsx(Pc,{open:e,onClose:()=>s(!1),anchorRef:u,contextDisplay:V,usageGroups:F,usageDisplayMode:D,isUsageLoading:E,timeFormatPreference:A})]})}),Ic=10,xr=380,Dc=(n,e)=>n.title?.trim()||e,_c=n=>{const e=le.c(32),{session:s,meta:o,active:r,onSelect:i}=n,{t:a}=fe(),u=Vr(s.id),f=Gr(s.id),d=u?.type??"idle",l=d==="busy"||d==="retry",p=!l&&f>0&&!r,g=Kr(s.id,l),h=(l||p)&&g,y=s.time?.updated??s.time?.created??0;let j;e[0]!==y?(j=li(y),e[0]=y,e[1]=j):j=e[1];const v=j,T=r&&"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]";let S;e[2]!==T?(S=Y("flex w-full items-center gap-3 rounded-xl px-2.5 py-2 text-left transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary",T),e[2]=T,e[3]=S):S=e[3];let E;e[4]===Symbol.for("react.memo_cache_sentinel")?(E={touchAction:"manipulation"},e[4]=E):E=e[4];const D=r?"text-primary":"text-foreground";let w;e[5]!==D?(w=Y("block truncate typography-ui-label",D),e[5]=D,e[6]=w):w=e[6];let A;e[7]!==s||e[8]!==a?(A=Dc(s,a("sessions.sidebar.session.untitled")),e[7]=s,e[8]=a,e[9]=A):A=e[9];let k;e[10]!==w||e[11]!==A?(k=t.jsx("span",{className:w,children:A}),e[10]=w,e[11]=A,e[12]=k):k=e[12];let R;e[13]!==o?(R=o?t.jsx("span",{className:"block truncate typography-micro text-muted-foreground",children:o}):null,e[13]=o,e[14]=R):R=e[14];let b;e[15]!==R||e[16]!==k?(b=t.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[k,R]}),e[15]=R,e[16]=k,e[17]=b):b=e[17];let O;e[18]!==l||e[19]!==p?(O=l||p?t.jsx("span",{className:Y("size-1.5 shrink-0 rounded-full",l?"bg-primary":"bg-[var(--status-info)]"),"aria-hidden":!0}):null,e[18]=l,e[19]=p,e[20]=O):O=e[20];let z;e[21]!==l||e[22]!==s.id||e[23]!==h||e[24]!==v?(z=h?t.jsx(io,{sessionId:s.id,running:l,className:"typography-micro"}):v?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:v}):null,e[21]=l,e[22]=s.id,e[23]=h,e[24]=v,e[25]=z):z=e[25];let C;return e[26]!==i||e[27]!==b||e[28]!==O||e[29]!==z||e[30]!==S?(C=t.jsxs("button",{type:"button",className:S,onClick:i,style:E,children:[b,O,z]}),e[26]=i,e[27]=b,e[28]=O,e[29]=z,e[30]=S,e[31]=C):C=e[31],C},Mc=n=>{const e=le.c(50),{open:s,onClose:o,anchorRef:r}=n,{t:i}=fe(),a=c.useRef(null),[u,f]=c.useState(s),[d,l]=c.useState(!1),{enabled:p}=bn(),g=c.useRef(null),[h,y]=c.useState(null);let j,v;e[0]!==r||e[1]!==p||e[2]!==s||e[3]!==u?(j=()=>{if(!s||!p||!u)return;const G=()=>{const se=r.current?.getBoundingClientRect(),ae=g.current?.getBoundingClientRect();if(!se||!ae){y(null);return}const de=se.left-ae.left;y(Math.min(Math.max(de,8),Math.max(8,ae.width-xr-8)))};G();const te=g.current;if(typeof ResizeObserver>"u"||!te)return;const re=new ResizeObserver(G);return re.observe(te),()=>re.disconnect()},v=[r,p,s,u],e[0]=r,e[1]=p,e[2]=s,e[3]=u,e[4]=j,e[5]=v):(j=e[4],v=e[5]),c.useLayoutEffect(j,v);const T=p&&h!==null,S=Se(zc),E=Se(Oc),D=Ve(Bc);let w;e[6]===Symbol.for("react.memo_cache_sentinel")?(w={maxParents:Ic},e[6]=w):w=e[6];const A=ai(s||u,w);let k,R;e[7]!==s||e[8]!==u?(k=()=>{if(s){xn(),f(!0),l(!1);return}if(!u)return;l(!0);const G=window.setTimeout(()=>{f(!1),l(!1)},140);return()=>window.clearTimeout(G)},R=[s,u],e[7]=s,e[8]=u,e[9]=k,e[10]=R):(k=e[9],R=e[10]),c.useEffect(k,R);let b,O;e[11]!==o||e[12]!==s?(b=()=>{if(!s)return;const G=te=>{te.key==="Escape"&&o()};return document.addEventListener("keydown",G),()=>document.removeEventListener("keydown",G)},O=[o,s],e[11]=o,e[12]=s,e[13]=b,e[14]=O):(b=e[13],O=e[14]),c.useEffect(b,O);let z,C;e[15]!==r||e[16]!==o||e[17]!==s?(z=()=>{if(!s)return;const G=te=>{const re=te.target;if(!(re instanceof Node)){o();return}a.current?.contains(re)||r.current?.contains(re)||o()};return document.addEventListener("pointerdown",G,!0),()=>document.removeEventListener("pointerdown",G,!0)},C=[r,o,s],e[15]=r,e[16]=o,e[17]=s,e[18]=z,e[19]=C):(z=e[18],C=e[19]),c.useEffect(z,C);let x;e[20]!==o||e[21]!==E?(x=G=>{E(G.id,gn(G)),o()},e[20]=o,e[21]=E,e[22]=x):x=e[22];const _=x;if(!u)return null;let K;e[23]!==i?(K=i("sessions.switcher.openAria"),e[23]=i,e[24]=K):K=e[24];const N=T?"absolute origin-top-left":"mx-3 mt-2",V=d?"pointer-events-none":"pointer-events-auto";let F;e[25]!==N||e[26]!==V?(F=Y("flex flex-col overflow-hidden rounded-[20px] border border-border/70 bg-[var(--surface-elevated)] p-2 shadow-[0_12px_32px_rgb(0_0_0_/_0.2)] will-change-transform",N,V),e[25]=N,e[26]=V,e[27]=F):F=e[27];const I=`${d?"session-switcher-out":"session-switcher-in"} ${d?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`;let B;e[28]!==h||e[29]!==T?(B=T?{top:8,left:h??8,width:`min(${xr}px, calc(100% - 16px))`}:null,e[28]=h,e[29]=T,e[30]=B):B=e[30];let Q;e[31]!==I||e[32]!==B?(Q={animation:I,maxHeight:"min(72dvh, calc(100dvh - var(--oc-safe-area-top, 0px) - var(--oc-header-height, 56px) - 1rem))",...B},e[31]=I,e[32]=B,e[33]=Q):Q=e[33];let Z;e[34]!==S||e[35]!==_||e[36]!==A||e[37]!==D||e[38]!==i?(Z=A.length===0?t.jsx("p",{className:"px-3 py-6 text-center typography-small text-muted-foreground",children:i("sessions.switcher.empty")}):A.map(G=>{const te=G.node.session,re=[G.secondaryMeta?.projectLabel,G.secondaryMeta?.branchLabel].filter(Boolean).join(" · ");return t.jsx(_c,{session:te,meta:re,active:te.id===S,onSelect:()=>{G.projectId&&D(G.projectId),_(te)}},te.id)}),e[34]=S,e[35]=_,e[36]=A,e[37]=D,e[38]=i,e[39]=Z):Z=e[39];let ne;e[40]!==Z?(ne=t.jsx("div",{className:"oc-hide-scrollbar min-h-0 flex-1 space-y-0.5 overflow-y-auto overscroll-contain",children:Z}),e[40]=Z,e[41]=ne):ne=e[41];let M;e[42]!==K||e[43]!==F||e[44]!==Q||e[45]!==ne?(M=t.jsx("div",{ref:a,role:"dialog","aria-label":K,className:F,style:Q,children:ne}),e[42]=K,e[43]=F,e[44]=Q,e[45]=ne,e[46]=M):M=e[46];let W;e[47]===Symbol.for("react.memo_cache_sentinel")?(W=t.jsx("style",{children:`
|
|
14
|
+
@keyframes session-switcher-in {
|
|
15
|
+
from { opacity: 0; transform: translateY(-8px) scale(0.985); }
|
|
16
|
+
to { opacity: 1; transform: translateY(0) scale(1); }
|
|
17
|
+
}
|
|
18
|
+
@keyframes session-switcher-out {
|
|
19
|
+
from { opacity: 1; transform: translateY(0) scale(1); }
|
|
20
|
+
to { opacity: 0; transform: translateY(-6px) scale(0.985); }
|
|
21
|
+
}
|
|
22
|
+
`}),e[47]=W):W=e[47];let J;return e[48]!==M?(J=t.jsxs("div",{ref:g,className:"fixed inset-x-0 bottom-0 top-[calc(var(--oc-safe-area-top,0px)+var(--oc-header-height,56px))] z-20 pointer-events-none",children:[M,W]}),e[48]=M,e[49]=J):J=e[49],J};function zc(n){return n.currentSessionId}function Oc(n){return n.setCurrentSession}function Bc(n){return n.setActiveProjectIdOnly}const Lc=n=>{const e=le.c(78),{onOpenSessions:s,onOpenWorkspace:o,compactTitle:r}=n,i=r===void 0?!1:r,{t:a}=fe(),[u,f]=c.useState(!1),[d,l]=c.useState(!1),p=c.useRef(null),g=jt($c),h=Se(Fc);let y;e[0]!==h?(y=ce=>h?ce.getDirectoryForSession(h):null,e[0]=h,e[1]=y):y=e[1];const v=Se(y)||g,T=ci(h,v||void 0),S=Se(Wc),E=Hr(v||null);let D;e[2]!==v||e[3]!==E?(D=ce=>{if(!v||E!==!0)return!1;const Re=ce.directories.get(v)?.status;return!!(Re&&!Re.isClean)},e[2]=v,e[3]=E,e[4]=D):D=e[4];const w=Ge(D);let A;e[5]!==T?.title?(A=T?.title?.trim(),e[5]=T?.title,e[6]=A):A=e[6];const k=A;let R;e[7]!==h||e[8]!==k||e[9]!==a?(R=k||a(h?"mobile.sessions.untitled":"sessions.switcher.draftTitle"),e[7]=h,e[8]=k,e[9]=a,e[10]=R):R=e[10];const b=R;let O;e[11]===Symbol.for("react.memo_cache_sentinel")?(O=()=>{f(!1),l(!1)},e[11]=O):O=e[11];let z;e[12]!==h||e[13]!==v?(z=[h,v],e[12]=h,e[13]=v,e[14]=z):z=e[14],c.useEffect(O,z);let C;e[15]!==s?(C=()=>{f(!1),l(!1),s()},e[15]=s,e[16]=C):C=e[16];const x=C;let _;e[17]===Symbol.for("react.memo_cache_sentinel")?(_=ce=>{f(Re=>{const Ye=typeof ce=="function"?ce(Re):ce;return Ye&&l(!1),Ye})},e[17]=_):_=e[17];const K=_;let N;e[18]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{l(ce=>{const Re=!ce;return Re&&f(!1),Re})},e[18]=N):N=e[18];const V=N;let F;e[19]===Symbol.for("react.memo_cache_sentinel")?(F={paddingTop:"var(--oc-safe-area-top, 0px)"},e[19]=F):F=e[19];let I;e[20]!==a?(I=a("mobile.sessions.openSheetAria"),e[20]=a,e[21]=I):I=e[21];let B,Q;e[22]===Symbol.for("react.memo_cache_sentinel")?(B={touchAction:"manipulation"},Q=t.jsx(X,{name:"list-unordered",className:"size-5"}),e[22]=B,e[23]=Q):(B=e[22],Q=e[23]);let Z;e[24]!==x||e[25]!==I?(Z=t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":I,onClick:x,style:B,children:Q}),e[24]=x,e[25]=I,e[26]=Z):Z=e[26];const ne=i?"shrink":"flex-1";let M;e[27]!==ne?(M=Y("flex min-w-0 items-center rounded-lg px-2 py-1.5 text-left transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",ne),e[27]=ne,e[28]=M):M=e[28];let W;e[29]!==a?(W=a("sessions.switcher.openAria"),e[29]=a,e[30]=W):W=e[30];let J;e[31]===Symbol.for("react.memo_cache_sentinel")?(J={touchAction:"manipulation"},e[31]=J):J=e[31];let G;e[32]!==b?(G=t.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",children:b}),e[32]=b,e[33]=G):G=e[33];const te=d&&"rotate-180";let re;e[34]!==te?(re=Y("size-4 shrink-0 text-muted-foreground transition-transform duration-150",te),e[34]=te,e[35]=re):re=e[35];let se;e[36]!==re?(se=t.jsx(X,{name:"arrow-down-s",className:re}),e[36]=re,e[37]=se):se=e[37];let ae;e[38]!==G||e[39]!==se?(ae=t.jsxs("span",{className:"flex min-w-0 items-center gap-1",children:[G,se]}),e[38]=G,e[39]=se,e[40]=ae):ae=e[40];let de;e[41]!==d||e[42]!==M||e[43]!==W||e[44]!==ae?(de=t.jsx("button",{ref:p,type:"button",className:M,"aria-label":W,"aria-haspopup":"dialog","aria-expanded":d,onClick:V,style:J,children:ae}),e[41]=d,e[42]=M,e[43]=W,e[44]=ae,e[45]=de):de=e[45];let U;e[46]!==i?(U=i?t.jsx("div",{className:"min-w-0 flex-1"}):null,e[46]=i,e[47]=U):U=e[47];let ie;e[48]!==h||e[49]!==v||e[50]!==S||e[51]!==u?(ie=t.jsx(Tc,{open:u,onOpenChange:K,currentSessionId:h,effectiveDirectory:v,isNewSessionDraftOpen:S}),e[48]=h,e[49]=v,e[50]=S,e[51]=u,e[52]=ie):ie=e[52];let xe;e[53]!==w||e[54]!==a?(xe=a(w?"mobile.header.openWorkspaceWithChangesAria":"mobile.header.openWorkspaceAria"),e[53]=w,e[54]=a,e[55]=xe):xe=e[55];let je;e[56]!==o?(je=()=>{f(!1),l(!1),o()},e[56]=o,e[57]=je):je=e[57];let q,ve;e[58]===Symbol.for("react.memo_cache_sentinel")?(q={touchAction:"manipulation"},ve=t.jsx(X,{name:"pencil-ruler-2",className:"size-5"}),e[58]=q,e[59]=ve):(q=e[58],ve=e[59]);let Ne;e[60]!==w?(Ne=w?t.jsx("span",{className:"absolute right-1.5 top-1.5 size-2.5 rounded-full border-2 border-[var(--background)] bg-[var(--status-warning)]","aria-hidden":!0}):null,e[60]=w,e[61]=Ne):Ne=e[61];let _e;e[62]!==xe||e[63]!==je||e[64]!==Ne?(_e=t.jsxs("button",{type:"button",className:"relative flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":xe,onClick:je,style:q,children:[ve,Ne]}),e[62]=xe,e[63]=je,e[64]=Ne,e[65]=_e):_e=e[65];let Me;e[66]!==Z||e[67]!==de||e[68]!==U||e[69]!==ie||e[70]!==_e?(Me=t.jsx("header",{className:"oc-mobile-header relative z-30 flex shrink-0 items-center gap-1 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80",style:F,children:t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] w-full items-center gap-1 px-2",children:[Z,de,U,ie,_e]})}),e[66]=Z,e[67]=de,e[68]=U,e[69]=ie,e[70]=_e,e[71]=Me):Me=e[71];let Je;e[72]===Symbol.for("react.memo_cache_sentinel")?(Je=()=>l(!1),e[72]=Je):Je=e[72];let Ce;e[73]!==d?(Ce=t.jsx(Mc,{open:d,onClose:Je,anchorRef:p}),e[73]=d,e[74]=Ce):Ce=e[74];let Ie;return e[75]!==Me||e[76]!==Ce?(Ie=t.jsxs(t.Fragment,{children:[Me,Ce]}),e[75]=Me,e[76]=Ce,e[77]=Ie):Ie=e[77],Ie};function $c(n){return n.currentDirectory}function Fc(n){return n.currentSessionId}function Wc(n){return!!n.newSessionDraft?.open}const Uc=({onActiveConnectionDeleted:n,onConnect:e})=>{const{t:s}=fe(),o=jo(e),{connections:r,isBusy:i,isPasswordBusy:a,error:u,pendingConnection:f,connect:d,submitPassword:l,cancelPassword:p,saveConnection:g,removeConnection:h,setError:y}=o,[j,v]=c.useState(null),T=j?r.find(U=>U.id===j)??null:null,[S,E]=c.useState(null),[D,w]=c.useState(""),[A,k]=c.useState(""),[R,b]=c.useState(""),[O,z]=c.useState(""),[C,x]=c.useState(!1),[_,K]=c.useState(!1),N=c.useRef(null),V=c.useMemo(()=>dn(),[]),[F,I]=c.useState(!1),[B,Q]=c.useState(null),[Z,ne]=c.useState(!1),M=fo(c.useCallback(()=>ne(!0),[])),W=c.useCallback(()=>{v(null),w(""),k(""),b(""),y(null),I(!1)},[y]),J=c.useCallback(U=>{U.preventDefault(),g({id:j??void 0,url:D,label:A,clientToken:R}).then(ie=>{ie&&W()})},[R,j,A,W,g,D]),G=c.useCallback(async()=>{if(N.current)return;y(null),x(!0);const U=new AbortController;N.current=U;try{const ie=await Eo({signal:U.signal});switch(N.current===U&&(N.current=null,x(!1)),ie.status){case"ok":w(ie.url),ie.label&&k(ie.label),ie.clientToken&&b(ie.clientToken),I(!0);break;case"pairing":K(!0),await o.redeemPairingConnection(ie.pairing);break;case"permission-denied":y(s("mobile.connect.scan.permissionDenied"));break;case"invalid":y(s("mobile.connect.scan.invalid"));break;case"unsupported":y(s("mobile.connect.scan.unsupported"));break;case"failed":y(s("mobile.connect.scan.failed"));break;default:break}}finally{K(!1),N.current===U&&(N.current=null,x(!1))}},[o,y,s]);c.useEffect(()=>()=>N.current?.abort(),[]);const te=c.useCallback(U=>{U.preventDefault(),l(O)},[O,l]),re=c.useCallback(()=>{z(""),p()},[p]),se=c.useCallback(U=>{E(ie=>ie===U?null:U)},[]),ae=c.useCallback(U=>{E(null),j===U&&W();const ie=r.length===1;h(U).then(xe=>{xe&&(ie||hr(xe))&&n()})},[r.length,j,n,h,W]),de=is;return f?t.jsx("div",{className:"flex h-full flex-col overflow-hidden",children:t.jsx("form",{className:"flex-1 overflow-y-auto px-5 py-4",onSubmit:te,children:t.jsxs("div",{className:"flex flex-col gap-3",children:[t.jsxs("div",{className:"flex items-center gap-3 rounded-[18px] border border-border/70 bg-surface-elevated px-3.5 py-3",children:[t.jsx("span",{className:"flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:t.jsx(X,{name:"lock",className:"size-[18px]"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("p",{className:"truncate typography-ui-label text-foreground",children:f.label}),t.jsx("p",{className:"truncate typography-small text-muted-foreground",children:f.candidates.some(U=>U.kind==="direct")?ft(f):s("mobile.connect.relay.badge")})]})]}),t.jsx("input",{...zt,value:O,onChange:U=>z(U.target.value),placeholder:s("mobile.connect.password.placeholder"),"aria-label":s("mobile.connect.password.label"),type:"password",autoFocus:!0,className:de}),u?t.jsx("p",{className:"px-1 typography-small text-[var(--status-error)]",children:u}):null,t.jsx(he,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",disabled:a||!O.trim(),children:s(a?"mobile.connect.connecting":"mobile.connect.unlockButton")}),t.jsx(he,{type:"button",variant:"ghost",size:"sm",className:"w-full",onClick:re,children:s("mobile.connect.cancelPassword")})]})})}):t.jsxs(t.Fragment,{children:[C?t.jsx(Ro,{onCancel:()=>N.current?.abort()}):null,_?t.jsx(Po,{}):null,Z?t.jsx(ko,{onClose:()=>ne(!1)}):null,t.jsx("div",{className:"flex h-full flex-col overflow-hidden",children:t.jsx("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:t.jsxs("div",{className:"space-y-6",children:[r.length>0?t.jsx("div",{...M,className:"overflow-hidden rounded-[18px] border border-border/70 bg-surface-elevated",children:r.map(U=>{const ie=S===U.id,xe=hr(U),je=B===U.id,q=je?s("mobile.connect.connecting"):xe?ms()?s("mobile.instances.status.connectedRelay"):s("mobile.instances.status.connectedDirect"):U.candidates.some(ve=>ve.kind==="direct")?ft(U):s("mobile.connect.relay.badge");return t.jsxs("div",{className:Y("flex items-center border-b border-border/70 transition-colors last:border-b-0",ie&&"bg-[color-mix(in_srgb,var(--destructive)_8%,transparent)]"),children:[t.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-center gap-3 px-3.5 py-3 text-left transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary disabled:opacity-60",onClick:()=>{xe||(Q(U.id),d({id:U.id,candidates:U.candidates,clientToken:U.clientToken,label:U.label}).finally(()=>Q(null)))},disabled:i&&!je||ie,children:[t.jsxs("span",{className:"relative flex size-9 shrink-0 items-center justify-center rounded-[12px] bg-interactive-hover text-foreground",children:[t.jsx(X,{name:"server",className:"size-[18px]"}),xe?t.jsx("span",{className:"absolute -right-0.5 -top-0.5 size-2.5 rounded-full border-2 border-[var(--surface-elevated)] bg-[var(--status-success)]","aria-hidden":!0}):null]}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate typography-ui-label text-foreground",children:U.label}),t.jsx("span",{className:Y("block truncate typography-small",xe&&!je?"text-[var(--status-success)]":"text-muted-foreground"),children:q})]}),je?t.jsx(X,{name:"loader-4",className:"size-5 shrink-0 animate-spin text-muted-foreground"}):null]}),t.jsxs("div",{className:"flex items-center gap-0.5 pr-2",children:[ie?t.jsxs("button",{type:"button","aria-label":s("mobile.instances.confirmDeleteAria",{label:U.label}),className:"flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-destructive px-3 text-destructive-foreground transition-opacity active:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive",onClick:()=>ae(U.id),style:{touchAction:"manipulation"},children:[t.jsx(X,{name:"delete-bin",className:"size-[18px]"}),t.jsx("span",{className:"typography-ui-label",children:s("mobile.instances.delete")})]}):U.candidates.some(ve=>ve.kind==="direct")?t.jsx("button",{type:"button","aria-label":s("mobile.instances.edit"),className:"flex size-9 items-center justify-center rounded-full text-muted-foreground transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:()=>{v(U.id),w(ft(U)),k(U.label),b(U.clientToken||""),y(null)},style:{touchAction:"manipulation"},children:t.jsx(X,{name:"edit",className:"size-[18px]"})}):null,t.jsx("button",{type:"button","aria-label":ie?s("mobile.instances.cancelDeleteAria",{label:U.label}):s("mobile.instances.deleteAria",{label:U.label}),className:"flex size-9 items-center justify-center rounded-full text-muted-foreground transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:()=>se(U.id),style:{touchAction:"manipulation"},children:t.jsx(X,{name:ie?"close":"delete-bin",className:"size-[18px]"})})]})]},U.id)})}):t.jsx("p",{...M,className:"rounded-[18px] border border-dashed border-border/70 px-4 py-6 text-center typography-small text-muted-foreground",children:s("mobile.connect.saved.empty")}),!F&&!T?t.jsxs("div",{className:"space-y-2",children:[V?t.jsxs(he,{type:"button",size:"lg",className:"h-12 w-full",onClick:()=>{G()},disabled:C,children:[t.jsx(X,{name:"scan-2",className:Y("size-[18px]",C&&"animate-pulse")}),s("mobile.connect.scanQr")]}):null,t.jsxs(he,{type:"button",variant:V?"ghost":"outline",size:"lg",className:"h-12 w-full",onClick:()=>{y(null),I(!0)},children:[t.jsx(X,{name:"add",className:"size-[18px]"}),s("mobile.instances.addManual")]}),u?t.jsx("p",{className:"px-1 text-center typography-small text-[var(--status-error)]",children:u}):null]}):t.jsxs("form",{className:"space-y-3",onSubmit:J,children:[t.jsxs("div",{className:"flex h-8 items-center justify-between gap-3 px-1",children:[t.jsx("h3",{className:"typography-ui-label text-foreground",children:s(T?"mobile.instances.editTitle":"mobile.instances.addTitle")}),t.jsx(he,{type:"button",variant:"ghost",size:"xs",onClick:W,children:s("mobile.instances.cancelEdit")})]}),t.jsxs("label",{className:"block space-y-1.5",children:[t.jsx("span",{className:"block px-1 typography-ui-label text-foreground",children:s("mobile.connect.url.label")}),t.jsx("input",{...zt,value:D,onChange:U=>w(U.target.value),placeholder:s("mobile.connect.url.placeholder"),type:"url",inputMode:"url",autoCapitalize:"none",className:de})]}),t.jsxs("label",{className:"block space-y-1.5",children:[t.jsx("span",{className:"block px-1 typography-ui-label text-foreground",children:s("mobile.instances.label.label")}),t.jsx("input",{value:A,onChange:U=>k(U.target.value),placeholder:s("mobile.instances.label.placeholder"),autoComplete:"off",autoCapitalize:"words",autoCorrect:"off",spellCheck:!1,className:de})]}),t.jsxs("label",{className:"block space-y-1.5",children:[t.jsx("span",{className:"block px-1 typography-ui-label text-foreground",children:s("mobile.connect.token.label")}),t.jsx("input",{...zt,value:R,onChange:U=>b(U.target.value),placeholder:s("mobile.connect.token.placeholder"),autoCapitalize:"none",className:de}),t.jsx("p",{className:"px-1 typography-micro text-muted-foreground",children:s("mobile.connect.token.hint")})]}),u?t.jsx("p",{className:"px-1 typography-small text-[var(--status-error)]",children:u}):null,t.jsx(he,{type:"submit",size:"lg",className:"mt-1 h-12 w-full",children:s(T?"mobile.instances.saveEdit":"mobile.instances.saveNew")})]})]})})})]})},Te=n=>Wo(n)??"",tn=n=>{const e=Te(n);if(!e)return"";const s=e.split("/").filter(Boolean);return s[s.length-1]?.replace(/[-_]/g," ")||e},yr=Dn(n=>({expandedParents:{},toggleParent:e=>n(s=>{const o={...s.expandedParents};return o[e]?delete o[e]:o[e]=!0,{expandedParents:o}})})),Rs=Dn()(lo(n=>({projectExpanded:{},worktreeExpanded:{},setProjectExpanded:(e,s)=>n(o=>({projectExpanded:{...o.projectExpanded,[e]:s}})),setWorktreeExpanded:(e,s)=>n(o=>({worktreeExpanded:{...o.worktreeExpanded,[e]:s}}))}),{name:"mobile-session-tree"})),fn=Dn()(lo(n=>({orderByProject:{},setWorktreeOrder:(e,s)=>n(o=>({orderByProject:{...o.orderByProject,[e]:s}}))}),{name:"mobile-worktree-order"})),vr=n=>n.replace(/\\/g,"/").replace(/\/+$/,""),Vc=(n,e)=>{if(!n||n.length===0)return e;const s=new Map(n.map((r,i)=>[vr(r),i])),o=r=>s.get(vr(r.path))??Number.MAX_SAFE_INTEGER;return e.map((r,i)=>({worktree:r,index:i})).sort((r,i)=>{const a=o(r.worktree)-o(i.worktree);return a!==0?a:r.index-i.index}).map(r=>r.worktree)},as=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/,""),Gc=n=>{const e=n;return as(e.directory??e.project?.worktree??null)},To=({open:n,project:e,worktree:s,onClose:o,onDeleted:r})=>{const{t:i}=fe(),a=qr(),u=hn(b=>b.activeSessions),f=Se(b=>b.archiveSessions),d=jt(b=>b.currentDirectory),[l,p]=c.useState(!1),[g,h]=c.useState(!1),[y,j]=c.useState(!1),[v,T]=c.useState(!1),S=as(s?.path),E=typeof s?.branch=="string"&&s.branch.trim().length>0,D=c.useMemo(()=>{if(!S)return[];const b=new Map;for(const O of[...u,...a])Gc(O)===S&&b.set(O.id,O);return Array.from(b.values())},[u,a,S]);c.useEffect(()=>{if(!n){p(!1),h(!1),j(!1),T(!1);return}if(!s?.path)return;let b=!1;return ui(s.path).then(O=>{b||j(!!O?.isDirty)}).catch(()=>{b||j(!!s.status?.isDirty)}),()=>{b=!0}},[n,s?.path,s?.status?.isDirty]);const w=c.useCallback((b,O)=>{const z=di(b),C=ue.loading(i("sessions.sidebar.sessionDialogs.worktree.removingTitle",{name:z}));(async()=>{try{if(O.length>0){const{failedIds:x}=await f(O);if(x.length>0){ue.error(x.length===1?i("sessions.sidebar.bulkActions.failedArchiveSingle",{count:x.length}):i("sessions.sidebar.bulkActions.failedArchivePlural",{count:x.length}),{id:C,description:i("sessions.sidebar.dialogs.deleteResult.tryAgain")});return}}await fi(e,b,{deleteRemoteBranch:E&&g,deleteLocalBranch:E&&l}),as(d)===S&&as(e.path)&&jt.getState().setDirectory(as(e.path),{showOverlay:!1}),ue.success(i("sessions.sidebar.sessionDialogs.worktree.removedTitle",{name:z}),{id:C,description:i(E&&g?"sessions.sidebar.sessionDialogs.worktree.removedWithRemote":"sessions.sidebar.sessionDialogs.worktree.removed")}),r?.()}catch(x){ue.error(i("sessions.sidebar.sessionDialogs.worktree.errorRemoveTitle",{name:z}),{id:C,description:x instanceof Error?x.message:i("sessions.sidebar.dialogs.deleteResult.tryAgain")})}})()},[f,d,l,g,E,r,e,i,S]),A=()=>{!s||v||(T(!0),w(s,D.map(b=>b.id)),o())};if(!s)return null;const k=s.branch||s.label||s.path,R=(b,O,z,C)=>t.jsxs("button",{type:"button",role:"switch","aria-checked":b,disabled:C,onClick:()=>O(!b),className:Y("flex w-full items-center justify-between gap-3 rounded-xl border border-border/70 px-3.5 py-3 text-left transition-colors","hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",C&&"pointer-events-none opacity-40"),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label text-foreground",children:z}),t.jsx("span",{className:Y("relative h-6 w-10 shrink-0 rounded-full transition-colors",b?"bg-primary":"bg-muted-foreground/30"),children:t.jsx("span",{className:Y("absolute top-0.5 size-5 rounded-full bg-white transition-transform",b?"translate-x-[1.125rem]":"translate-x-0.5")})})]});return t.jsx(Jr,{open:n,onClose:o,title:i("mobile.projectEdit.deleteWorktreeTitle"),footer:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(he,{variant:"ghost",className:"flex-1",onClick:o,disabled:v,children:i("projectEditDialog.actions.cancel")}),t.jsx(he,{variant:"destructive",className:"flex-1",onClick:()=>{A()},disabled:v,children:i("mobile.projectEdit.deleteWorktreeConfirmButton")})]}),children:t.jsxs("div",{className:"flex flex-col gap-4 px-1 py-1",children:[t.jsx("p",{className:"typography-ui-body text-foreground",children:i("mobile.projectEdit.deleteWorktreeConfirm",{name:k})}),y?t.jsx("p",{className:"rounded-xl border border-[var(--warning)]/40 bg-[color-mix(in_srgb,var(--warning)_10%,transparent)] px-3.5 py-3 typography-meta text-foreground",children:i("mobile.projectEdit.deleteWorktreeDirty")}):null,D.length>0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:i("mobile.projectEdit.deleteWorktreeArchiveNote",{count:D.length})}):null,E?t.jsxs("div",{className:"flex flex-col gap-2",children:[R(l,p,i("mobile.projectEdit.deleteLocalBranch"),v),R(g,h,i("mobile.projectEdit.deleteRemoteBranch"),v)]}):null]})})},wr="mobile-surface-root",sn=16,Ps=200,Kc=()=>{if(typeof document>"u")return null;let n=document.getElementById(wr);return n||(n=document.createElement("div"),n.id=wr,document.body.appendChild(n)),n},ls=({open:n,onClose:e,title:s,subtitle:o,trailing:r,disableEscapeDismiss:i=!1,headerless:a=!1,noHeaderBorder:u=!1,ariaLabel:f,variant:d="fullscreen",dialogAlign:l="chat",children:p})=>{const{t:g}=fe(),h=c.useRef(null),[y,j]=c.useState(!1),[v,T]=c.useState(!1),S=c.useRef(null),E=c.useRef(null),D=c.useRef(e);if(c.useEffect(()=>{D.current=e},[e]),typeof document<"u"&&!h.current&&(h.current=Kc()),c.useEffect(()=>{if(!n){j(!1);return}const k=window.setTimeout(()=>j(!0),sn);return()=>window.clearTimeout(k)},[n]),c.useEffect(()=>{if(!n){T(!1);return}const k=window.setTimeout(()=>T(!0),sn+Ps+80);return()=>window.clearTimeout(k)},[n]),c.useEffect(()=>{if(!n)return;const k=document.body.style.overflow;E.current=document.activeElement instanceof HTMLElement?document.activeElement:null,document.body.style.overflow="hidden";const R=()=>{const z=S.current;if(!z)return;(z.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')??z).focus({preventScroll:!0})},b=window.setTimeout(R,sn),O=z=>{if(z.key==="Escape"&&!i){D.current();return}if(z.key!=="Tab")return;const C=S.current;if(!C)return;const x=Array.from(C.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])')).filter(V=>!V.hasAttribute("disabled")&&V.getAttribute("aria-hidden")!=="true");if(x.length===0){z.preventDefault(),C.focus({preventScroll:!0});return}const _=x[0],K=x[x.length-1],N=document.activeElement;z.shiftKey&&N===_?(z.preventDefault(),K.focus({preventScroll:!0})):!z.shiftKey&&N===K&&(z.preventDefault(),_.focus({preventScroll:!0}))};return document.addEventListener("keydown",O),()=>{window.clearTimeout(b),document.body.style.overflow=k,document.removeEventListener("keydown",O),E.current?.focus?.({preventScroll:!0}),E.current=null}},[i,n]),!n||!h.current)return null;const w=d==="dialog",A=t.jsxs("section",{ref:S,role:"dialog","aria-modal":"true","aria-label":f,tabIndex:-1,className:Y("flex flex-col bg-background text-foreground",w?"h-[min(88dvh,860px)] w-full max-w-[720px] overflow-hidden rounded-2xl border border-border/70 shadow-[0_24px_64px_rgb(0_0_0_/_0.32)]":"oc-keyboard-inset-surface oc-bottom-safe-surface fixed inset-0 z-50"),style:w?{opacity:y?1:0,transform:y?"none":"scale(0.97)",transition:`opacity ${Ps}ms ease-out, transform ${Ps}ms cubic-bezier(0.32, 0.72, 0, 1)`}:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:y?"none":"translateX(100%)",transition:`transform ${Ps}ms cubic-bezier(0.32, 0.72, 0, 1)`},onTransitionEnd:k=>{y&&k.target===k.currentTarget&&k.propertyName==="transform"&&T(!0)},children:[a?null:t.jsxs("header",{className:Y("flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",!u&&"border-b border-border/70"),children:[t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":g("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(X,{name:"close",className:"size-5"})}),t.jsxs("div",{className:"min-w-0 flex-1 px-1",children:[s?typeof s=="string"?t.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:s}):s:null,o?typeof o=="string"?t.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:o}):o:null]}),r?t.jsx("div",{className:"flex shrink-0 items-center gap-1.5",children:r}):null]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:v?t.jsx("div",{className:"h-full",style:{animation:"oc-surface-content-in 200ms ease-out"},children:p}):null}),t.jsx("style",{children:"@keyframes oc-surface-content-in { from { opacity: 0 } to { opacity: 1 } }"})]});return w?Ot.createPortal(t.jsx("div",{className:"oc-keyboard-inset-surface oc-bottom-safe-surface fixed inset-0 z-50 flex items-center justify-center p-4 transition-opacity duration-200 ease-out",style:{background:"rgb(0 0 0 / 0.45)",opacity:y?1:0,paddingLeft:l==="chat"?"max(1rem, var(--oc-chat-inset-left, 0px))":"1rem",paddingRight:l==="chat"?"max(1rem, var(--oc-chat-inset-right, 0px))":"1rem",paddingTop:"max(1rem, var(--oc-safe-area-top, 0px))"},onClick:e,children:t.jsx("div",{className:"flex w-full max-w-[720px] justify-center",onClick:k=>k.stopPropagation(),children:A})}),h.current):Ot.createPortal(A,h.current)},Hc=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/,""),qc=n=>{const e=le.c(36),{worktree:s,onDelete:o}=n,{t:r}=fe();let i;e[0]!==s.path?(i={id:s.path},e[0]=s.path,e[1]=i):i=e[1];const{attributes:a,listeners:u,setNodeRef:f,transform:d,transition:l,isDragging:p}=Tn(i);let g;e[2]!==d?(g=In.Transform.toString(d),e[2]=d,e[3]=g):g=e[3];const h=p?10:1;let y;e[4]!==g||e[5]!==h||e[6]!==l?(y={transform:g,transition:l,zIndex:h},e[4]=g,e[5]=h,e[6]=l,e[7]=y):y=e[7];const j=y,v=s.branch||s.label||s.path,T=p&&"shadow-lg shadow-black/20";let S;e[8]!==T?(S=Y("flex items-center gap-1 rounded-2xl border border-border/70 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",T),e[8]=T,e[9]=S):S=e[9];let E;e[10]!==v||e[11]!==r?(E=r("mobile.projectEdit.dragWorktreeAria",{label:v}),e[10]=v,e[11]=r,e[12]=E):E=e[12];let D;e[13]===Symbol.for("react.memo_cache_sentinel")?(D=t.jsx(wn,{className:"size-4"}),e[13]=D):D=e[13];let w;e[14]!==a||e[15]!==u||e[16]!==E?(w=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 cursor-grab touch-none items-center justify-center rounded-xl text-muted-foreground/70 transition-colors hover:text-foreground active:cursor-grabbing","aria-label":E,...a,...u,children:D}),e[14]=a,e[15]=u,e[16]=E,e[17]=w):w=e[17];let A;e[18]===Symbol.for("react.memo_cache_sentinel")?(A=t.jsx(X,{name:"node-tree",className:"size-4 shrink-0 text-muted-foreground"}),e[18]=A):A=e[18];let k;e[19]!==v?(k=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:v}),e[19]=v,e[20]=k):k=e[20];let R;e[21]!==v||e[22]!==r?(R=r("mobile.projectEdit.deleteWorktreeAria",{label:v}),e[21]=v,e[22]=r,e[23]=R):R=e[23];let b,O;e[24]===Symbol.for("react.memo_cache_sentinel")?(b={touchAction:"manipulation"},O=t.jsx(_s,{className:"size-4"}),e[24]=b,e[25]=O):(b=e[24],O=e[25]);let z;e[26]!==o||e[27]!==R?(z=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 items-center justify-center rounded-xl text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-destructive","aria-label":R,onClick:o,style:b,children:O}),e[26]=o,e[27]=R,e[28]=z):z=e[28];let C;return e[29]!==f||e[30]!==j||e[31]!==k||e[32]!==z||e[33]!==S||e[34]!==w?(C=t.jsxs("div",{ref:f,style:j,className:S,children:[w,A,k,z]}),e[29]=f,e[30]=j,e[31]=k,e[32]=z,e[33]=S,e[34]=w,e[35]=C):C=e[35],C},Jc=({open:n,project:e,onClose:s,onWorktreesChanged:o})=>{const{t:r}=fe(),{currentTheme:i}=Yr(),a=Ve(N=>N.updateProjectMeta),u=Ve(N=>N.discoverProjectIcon),f=Ve(N=>N.removeProjectIcon),d=fn(N=>N.setWorktreeOrder),l=Ve(N=>e?N.projects.find(V=>V.id===e.id)?.iconImage??null:null),[p,g]=c.useState(""),[h,y]=c.useState(null),[j,v]=c.useState(null),[T,S]=c.useState(!1),[E,D]=c.useState([]),[w,A]=c.useState(null),k=e?.id??null;c.useEffect(()=>{!n||!e||(g(e.label),y(e.icon??null),v(e.color??null),D(e.worktrees))},[n,k]),c.useEffect(()=>{!n||!e||D(N=>{const V=e.worktrees.map(B=>B.path),F=N.map(B=>B.path);return V.length===F.length&&V.every(B=>F.includes(B))?N:e.worktrees})},[e?.worktrees]);const R=kn(Lt(Nn,{activationConstraint:{distance:8}}),Lt(Sn,{coordinateGetter:Rn})),b=()=>{if(!e)return;const N=p.trim();a(e.id,{label:N||e.label,icon:h,color:j}),s()},O=()=>{!e||T||(S(!0),u(e.id).then(N=>{if(!N.ok){ue.error(N.error||r("projectEditDialog.toast.failedToDiscoverIcon"));return}if(N.skipped){ue.success(r("projectEditDialog.toast.customIconAlreadySet"));return}ue.success(r("projectEditDialog.toast.iconDiscovered"))}).finally(()=>S(!1)))},z=()=>{e&&f(e.id).then(N=>{if(!N.ok){ue.error(N.error||r("projectEditDialog.toast.failedToRemoveIcon"));return}ue.success(r("projectEditDialog.toast.iconRemoved"))})},C=N=>{const{active:V,over:F}=N;if(!F||V.id===F.id||!e)return;const I=E.findIndex(ne=>ne.path===V.id),B=E.findIndex(ne=>ne.path===F.id);if(I<0||B<0)return;const Q=[...E],[Z]=Q.splice(I,1);Q.splice(B,0,Z),D(Q),d(e.id,Q.map(ne=>Hc(ne.path)))},x=j?Xr[j]??null:null,_=h?Qr[h]:null,K=!!l;return t.jsxs(t.Fragment,{children:[t.jsx(ls,{open:n,onClose:s,title:r("projectEditDialog.title"),ariaLabel:r("projectEditDialog.title"),noHeaderBorder:!0,trailing:t.jsxs(he,{type:"button",variant:"default",size:"sm","aria-label":r("projectEditDialog.actions.save"),onClick:b,disabled:!p.trim(),style:{touchAction:"manipulation"},children:[t.jsx(ao,{className:"size-4"}),r("projectEditDialog.actions.save")]}),children:e?t.jsxs("div",{className:"h-full space-y-6 overflow-y-auto px-4 pb-8 pt-2",children:[t.jsx("div",{className:"flex justify-center pt-2",children:t.jsx("span",{className:"flex size-16 items-center justify-center overflow-hidden rounded-2xl bg-[var(--surface-muted)] text-muted-foreground",style:e.iconBackground?{backgroundColor:e.iconBackground}:void 0,children:K?t.jsx(Zr,{project:{id:e.id,iconImage:l},options:{themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},className:"size-full object-contain",fallback:t.jsx(ln,{className:"size-7"})}):_?t.jsx(X,{name:_,className:"size-7",style:x?{color:x}:void 0}):t.jsx(ln,{className:"size-7",style:x?{color:x}:void 0})})}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:r("projectEditDialog.field.name")}),t.jsx(eo,{value:p,onChange:N=>g(N.target.value),placeholder:r("projectEditDialog.field.namePlaceholder"),className:"h-11"}),t.jsx("p",{className:"truncate typography-meta text-muted-foreground",title:e.path,children:e.path})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:r("projectEditDialog.field.color")}),t.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[t.jsx("button",{type:"button",onClick:()=>v(null),"aria-label":r("projectEditDialog.option.none"),className:Y("flex size-9 items-center justify-center rounded-xl border-2 transition-all",j===null?"border-foreground":"border-border/70 hover:border-border/70"),style:{touchAction:"manipulation"},children:t.jsx("span",{className:"h-0.5 w-4 rotate-45 rounded-full bg-muted-foreground/40"})}),mi.map(N=>t.jsx("button",{type:"button",onClick:()=>v(N.key),"aria-label":N.label,title:N.label,className:Y("size-9 rounded-xl border-2 transition-all",j===N.key?"border-foreground":"border-transparent hover:border-border/70"),style:{backgroundColor:N.cssVar,touchAction:"manipulation"}},N.key))]})]}),t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:r("projectEditDialog.field.icon")}),t.jsxs("div",{className:"flex flex-wrap gap-2.5",children:[t.jsx("button",{type:"button",onClick:()=>y(null),"aria-label":r("projectEditDialog.option.none"),className:Y("flex size-9 items-center justify-center rounded-xl border-2 transition-all",h===null?"border-foreground bg-[var(--surface-elevated)]":"border-border/70 hover:border-border/70"),style:{touchAction:"manipulation"},children:t.jsx("span",{className:"h-0.5 w-4 rotate-45 rounded-full bg-muted-foreground/40"})}),pi.map(N=>t.jsx("button",{type:"button",onClick:()=>y(N.key),"aria-label":N.label,title:N.label,className:Y("flex size-9 items-center justify-center rounded-xl border-2 transition-all",h===N.key?"border-foreground bg-[var(--surface-elevated)]":"border-border/70 hover:border-border/70"),style:{touchAction:"manipulation"},children:t.jsx(X,{name:N.Icon,className:"size-4",style:x?{color:x}:void 0})},N.key))]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-1",children:[t.jsx(he,{size:"sm",variant:"outline",onClick:O,disabled:T,children:r(T?"projectEditDialog.actions.discovering":"projectEditDialog.actions.discoverFavicon")}),K?t.jsx(he,{size:"sm",variant:"outline",onClick:z,children:r("projectEditDialog.actions.removeProjectIcon")}):null]})]}),e.isGitRepo?t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx("label",{className:"typography-ui-label font-medium text-foreground",children:r("mobile.projectEdit.worktreesTitle")}),E.length===0?t.jsx("p",{className:"typography-meta text-muted-foreground",children:r("mobile.projectEdit.worktreesEmpty")}):t.jsxs(t.Fragment,{children:[t.jsx("p",{className:"typography-meta text-muted-foreground",children:r("mobile.projectEdit.reorderHint")}),t.jsx(Cn,{sensors:R,collisionDetection:En,onDragEnd:C,children:t.jsx(Pn,{items:E.map(N=>N.path),strategy:An,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:E.map(N=>t.jsx(qc,{worktree:N,onDelete:()=>A(N)},N.path))})})})]})]}):null]}):null}),e?t.jsx(To,{open:!!w,project:{id:e.id,path:e.path},worktree:w,onClose:()=>A(null),onDeleted:()=>{D(N=>N.filter(V=>V.path!==w?.path)),o?.()}}):null]})},Yc=32,Xc=80,Qc=64,Zc=.7,Fn=(n,e)=>{const s=c.useRef(e);s.current=e;const o=e.enabled??!0;c.useEffect(()=>{if(!o)return;const r=n.current;if(!r)return;const a=window.Capacitor?.getPlatform?.()==="android"?Xc:Yc;let u=!1,f=!1,d=0,l=0;const p=h=>{if(h.touches.length!==1){u=!1;return}const y=h.touches[0],j=r.clientWidth,v=y.clientX<=a,T=y.clientX>=j-a;u=v||T,f=v,d=y.clientX,l=y.clientY},g=h=>{if(!u)return;u=!1;const y=h.changedTouches[0];if(!y)return;const j=y.clientX-d,v=y.clientY-l;Math.abs(j)<Qc||Math.abs(v)>Math.abs(j)*Zc||f&&j<=0||!f&&j>=0||(f?s.current.onLeftEdgeSwipe?.():s.current.onRightEdgeSwipe?.())};return r.addEventListener("touchstart",p,{passive:!0}),r.addEventListener("touchend",g,{passive:!0}),()=>{r.removeEventListener("touchstart",p),r.removeEventListener("touchend",g)}},[o,n])},eu=new Set,tu=[["manual","sessions.sidebar.header.projectSort.manual"],["a-z","sessions.sidebar.header.projectSort.aToZ"],["z-a","sessions.sidebar.header.projectSort.zToA"],["date-added","sessions.sidebar.header.projectSort.dateAdded"],["recent","sessions.sidebar.header.projectSort.recent"]],nn=7,As=40,su=16,Pt=n=>n.parentID??null,cs=n=>{const e=n;return Te(e.directory??e.project?.worktree??null)},nu=n=>{const e=n.time?.updated??n.time?.created,s=typeof e=="number"?e:Number(e);return Number.isFinite(s)&&s>0?s:0},ru=n=>{if(n<=0)return"";const e=Date.now()-n;if(e<6e4)return"now";const s=Math.floor(e/6e4);if(s<60)return`${s}m`;const o=Math.floor(s/60);if(o<24)return`${o}h`;const r=Math.floor(o/24);return r<7?`${r}d`:new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric"}).format(new Date(n))},ou=(n,e)=>{const s=Te(n),o=Te(e),r=o.endsWith("/")?o:`${o}/`;return!!(s&&o&&(s===o||s.startsWith(r)))},Ds=(n,e)=>n.worktrees.find(s=>Te(s.path)===e)??null,Io=(n,e)=>e===n.path||!!Ds(n,e),rn=(n,e)=>{const s=Te(e);return s?n.find(o=>Io(o,s))??null:null},on=(n,e,s)=>to([n.title,n.id,cs(n),e],s),mn=n=>{const e=le.c(17),{project:s,size:o}=n,r=o===void 0?"md":o,{currentTheme:i}=Yr(),a=s.icon?Qr[s.icon]:null,u=s.color?Xr[s.color]??null:null,f=r==="sm"?"size-6 rounded-md":"size-8 rounded-lg",d=r==="sm"?"size-3.5":"size-4";let l;e[0]!==a||e[1]!==u||e[2]!==d?(l=a?t.jsx(X,{name:a,className:d,style:u?{color:u}:void 0}):t.jsx(ln,{className:d,style:u?{color:u}:void 0}),e[0]=a,e[1]=u,e[2]=d,e[3]=l):l=e[3];const p=l;let g;e[4]!==f?(g=Y("flex shrink-0 items-center justify-center overflow-hidden bg-[var(--surface-muted)] text-muted-foreground",f),e[4]=f,e[5]=g):g=e[5];let h;e[6]!==s.iconBackground?(h=s.iconBackground?{backgroundColor:s.iconBackground}:void 0,e[6]=s.iconBackground,e[7]=h):h=e[7];let y;e[8]!==i||e[9]!==p||e[10]!==s.iconImage||e[11]!==s.id?(y=s.iconImage?t.jsx(Zr,{project:{id:s.id,iconImage:s.iconImage??null},options:{themeVariant:i.metadata.variant,iconColor:i.colors.surface.foreground},className:"size-full object-contain",fallback:p}):p,e[8]=i,e[9]=p,e[10]=s.iconImage,e[11]=s.id,e[12]=y):y=e[12];let j;return e[13]!==g||e[14]!==h||e[15]!==y?(j=t.jsx("span",{className:g,style:h,children:y}),e[13]=g,e[14]=h,e[15]=y,e[16]=j):j=e[16],j},iu=n=>{const e=le.c(2),{ariaLabel:s}=n;let o;return e[0]!==s?(o=t.jsx("span",{className:"inline-block size-1.5 shrink-0 rounded-full bg-primary","aria-label":s}),e[0]=s,e[1]=o):o=e[1],o},jr=n=>{const e=le.c(12),{onClick:s,className:o}=n,{t:r}=fe();let i;e[0]!==r?(i=r("sessions.sidebar.project.actions.newWorktree"),e[0]=r,e[1]=i):i=e[1];const a=i;let u;e[2]!==o?(u=Y("flex size-9 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",o),e[2]=o,e[3]=u):u=e[3];let f;e[4]!==s?(f=g=>{g.stopPropagation(),s()},e[4]=s,e[5]=f):f=e[5];let d,l;e[6]===Symbol.for("react.memo_cache_sentinel")?(d={touchAction:"manipulation"},l=t.jsx(X,{name:"node-tree",className:"size-4"}),e[6]=d,e[7]=l):(d=e[6],l=e[7]);let p;return e[8]!==a||e[9]!==u||e[10]!==f?(p=t.jsx("button",{type:"button",className:u,"aria-label":a,title:a,onClick:f,style:d,children:l}),e[8]=a,e[9]=u,e[10]=f,e[11]=p):p=e[11],p},kr=n=>{const e=le.c(10),{label:s,onClick:o,className:r}=n;let i;e[0]!==r?(i=Y("flex size-9 shrink-0 items-center justify-center rounded-full text-[var(--surface-mutedForeground)] transition-colors hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",r),e[0]=r,e[1]=i):i=e[1];let a;e[2]!==o?(a=l=>{l.stopPropagation(),o()},e[2]=o,e[3]=a):a=e[3];let u,f;e[4]===Symbol.for("react.memo_cache_sentinel")?(u={touchAction:"manipulation"},f=t.jsx(X,{name:"add",className:"size-4"}),e[4]=u,e[5]=f):(u=e[4],f=e[5]);let d;return e[6]!==s||e[7]!==i||e[8]!==a?(d=t.jsx("button",{type:"button",className:i,"aria-label":s,title:s,onClick:a,style:u,children:f}),e[6]=s,e[7]=i,e[8]=a,e[9]=d):d=e[9],d},At=192,Do=180,Sr=n=>{const e=le.c(25),{actionsWidth:s,actions:o,revealed:r,onRevealedChange:i,children:a}=n,u=c.useRef(null),f=c.useRef(null),d=c.useRef(!1),l=c.useRef(0),p=c.useRef(r);let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=(C,x)=>{const _=u.current;_&&(_.style.transition=x?`transform ${Do}ms ease-out`:"none",_.style.transform=C===0?"none":`translateX(${C}px)`,l.current=C)},e[0]=g):g=e[0];const h=g;let y,j;e[1]!==s||e[2]!==r?(y=()=>{p.current=r,h(r?s:0,!0)},j=[s,h,r],e[1]=s,e[2]=r,e[3]=y,e[4]=j):(y=e[3],j=e[4]),c.useEffect(y,j);let v;e[5]===Symbol.for("react.memo_cache_sentinel")?(v=C=>{if(C.touches.length!==1)return;const x=C.touches[0];f.current={x:x.clientX,y:x.clientY},d.current=!1},e[5]=v):v=e[5];const T=v;let S;e[6]!==s?(S=C=>{if(!f.current)return;const x=C.touches[0],_=x.clientX-f.current.x,K=x.clientY-f.current.y;if(!d.current){if(Math.abs(_)<8||Math.abs(_)<=Math.abs(K))return;d.current=!0}const N=p.current?s:0;h(Math.max(0,Math.min(s,N+_)),!1)},e[6]=s,e[7]=S):S=e[7];const E=S;let D;e[8]!==s||e[9]!==i?(D=()=>{if(f.current=null,!d.current)return;d.current=!1;const C=l.current>s/2;h(C?s:0,!0),C!==p.current&&i(C)},e[8]=s,e[9]=i,e[10]=D):D=e[10];const w=D;let A;e[11]===Symbol.for("react.memo_cache_sentinel")?(A={touchAction:"pan-y"},e[11]=A):A=e[11];let k;e[12]!==s?(k={width:s},e[12]=s,e[13]=k):k=e[13];const R=!r;let b;e[14]!==o||e[15]!==k||e[16]!==R?(b=t.jsx("div",{className:"absolute inset-y-0 left-0 flex items-stretch",style:k,"aria-hidden":R,children:o}),e[14]=o,e[15]=k,e[16]=R,e[17]=b):b=e[17];let O;e[18]!==a?(O=t.jsx("div",{ref:u,className:"relative flex w-full items-center bg-background",children:a}),e[18]=a,e[19]=O):O=e[19];let z;return e[20]!==w||e[21]!==E||e[22]!==b||e[23]!==O?(z=t.jsxs("div",{className:"relative overflow-hidden",onTouchStart:T,onTouchMove:E,onTouchEnd:w,onTouchCancel:w,style:A,children:[b,O]}),e[20]=w,e[21]=E,e[22]=b,e[23]=O,e[24]=z):z=e[24],z},au=n=>{const e=le.c(41),{initialTitle:s,indent:o,onSubmit:r,onCancel:i}=n,{t:a}=fe(),[u,f]=c.useState(s),d=hu;let l;e[0]!==s||e[1]!==i||e[2]!==r||e[3]!==u?(l=()=>{const x=u.trim();if(!x||x===s.trim()){i();return}r(x)},e[0]=s,e[1]=i,e[2]=r,e[3]=u,e[4]=l):l=e[4];const p=l;let g;e[5]!==o?(g={paddingLeft:o},e[5]=o,e[6]=g):g=e[6];let h;e[7]!==p?(h=x=>{x.preventDefault(),p()},e[7]=p,e[8]=h):h=e[8];let y;e[9]===Symbol.for("react.memo_cache_sentinel")?(y=x=>f(x.target.value),e[9]=y):y=e[9];let j;e[10]!==i?(j=x=>Ma(x,i),e[10]=i,e[11]=j):j=e[11];let v;e[12]!==a?(v=a("sessions.sidebar.session.rename.save"),e[12]=a,e[13]=v):v=e[13];let T;e[14]!==a?(T=a("sessions.sidebar.session.menu.rename"),e[14]=a,e[15]=T):T=e[15];let S;e[16]===Symbol.for("react.memo_cache_sentinel")?(S={minHeight:0},e[16]=S):S=e[16];let E;e[17]!==j||e[18]!==v||e[19]!==T||e[20]!==u?(E=t.jsx("input",{ref:d,value:u,onChange:y,onKeyDown:j,"aria-label":v,placeholder:T,className:"min-w-0 flex-1 bg-transparent text-[16px] typography-ui-label text-foreground outline-none placeholder:text-muted-foreground",style:S,enterKeyHint:"done"}),e[17]=j,e[18]=v,e[19]=T,e[20]=u,e[21]=E):E=e[21];let D;e[22]!==a?(D=a("sessions.sidebar.session.rename.save"),e[22]=a,e[23]=D):D=e[23];let w,A;e[24]===Symbol.for("react.memo_cache_sentinel")?(w={touchAction:"manipulation",minHeight:0,minWidth:0},A=t.jsx(X,{name:"check",className:"size-4"}),e[24]=w,e[25]=A):(w=e[24],A=e[25]);let k;e[26]!==D?(k=t.jsx("button",{type:"submit","aria-label":D,className:"flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",style:w,children:A}),e[26]=D,e[27]=k):k=e[27];let R;e[28]!==a?(R=a("sessions.sidebar.session.rename.cancel"),e[28]=a,e[29]=R):R=e[29];let b,O;e[30]===Symbol.for("react.memo_cache_sentinel")?(b={touchAction:"manipulation",minHeight:0,minWidth:0},O=t.jsx(X,{name:"close",className:"size-4"}),e[30]=b,e[31]=O):(b=e[30],O=e[31]);let z;e[32]!==i||e[33]!==R?(z=t.jsx("button",{type:"button",onClick:i,"aria-label":R,className:"flex size-8 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",style:b,children:O}),e[32]=i,e[33]=R,e[34]=z):z=e[34];let C;return e[35]!==k||e[36]!==z||e[37]!==g||e[38]!==h||e[39]!==E?(C=t.jsxs("form",{className:"flex h-9 min-w-0 flex-1 items-center gap-2 pr-2",style:g,onSubmit:h,children:[E,k,z]}),e[35]=k,e[36]=z,e[37]=g,e[38]=h,e[39]=E,e[40]=C):C=e[40],C},Nr=n=>{const e=le.c(52),{session:s,active:o,indent:r,contextLabel:i,hasChildren:a,expanded:u,onToggleChildren:f,onSelect:d,revealed:l,onRevealedChange:p,confirmingDelete:g,onArchive:h,onRequestDelete:y,onConfirmDelete:j,renaming:v,onRequestRename:T,onSubmitRename:S,onCancelRename:E}=n,D=a===void 0?!1:a,w=u===void 0?!1:u,A=l===void 0?!1:l,k=g===void 0?!1:g,R=v===void 0?!1:v,{t:b}=fe();let O;e[0]!==s?(O=ru(nu(s)),e[0]=s,e[1]=O):O=e[1];const z=O,C=s.title?.trim()||b("mobile.sessions.untitled"),x=!!(p&&h),_=Ta(s.id,s.directory,x&&A),K=Vr(s.id),N=Gr(s.id),V=K?.type??"idle",F=V==="busy"||V==="retry",I=!F&&N>0&&!o,B=Kr(s.id,F),Q=(F||I)&&B,Z=c.useRef(null),ne=c.useRef(null),M=c.useRef(!1),W=c.useRef(0),J=c.useRef(A);let G;e[2]===Symbol.for("react.memo_cache_sentinel")?(G=(Pe,Xe)=>{const Ee=Z.current;Ee&&(Ee.style.transition=Xe?`transform ${Do}ms ease-out`:"none",Ee.style.transform=Pe===0?"none":`translateX(${Pe}px)`,W.current=Pe)},e[2]=G):G=e[2];const te=G;let re,se;e[3]!==A?(re=()=>{J.current=A,te(A?At:0,!0)},se=[te,A],e[3]=A,e[4]=re,e[5]=se):(re=e[4],se=e[5]),c.useEffect(re,se);let ae;e[6]!==x?(ae=Pe=>{if(!x||Pe.touches.length!==1)return;const Xe=Pe.touches[0];ne.current={x:Xe.clientX,y:Xe.clientY},M.current=!1},e[6]=x,e[7]=ae):ae=e[7];const de=ae;let U;e[8]!==x?(U=Pe=>{if(!x||!ne.current)return;const Xe=Pe.touches[0],Ee=Xe.clientX-ne.current.x,$e=Xe.clientY-ne.current.y;if(!M.current){if(Math.abs(Ee)<8||Math.abs(Ee)<=Math.abs($e))return;M.current=!0}const Fe=J.current?At:0,Qe=Math.max(0,Math.min(At,Fe+Ee));te(Qe,!1)},e[8]=x,e[9]=U):U=e[9];const ie=U;let xe;e[10]!==p?(xe=()=>{if(ne.current=null,!M.current)return;M.current=!1;const Pe=W.current>At/2;te(Pe?At:0,!0),Pe!==J.current&&p?.(Pe)},e[10]=p,e[11]=xe):xe=e[11];const je=xe,q=o||void 0,ve="relative overflow-hidden";let Ne;e[12]!==x?(Ne=x?{touchAction:"pan-y"}:void 0,e[12]=x,e[13]=Ne):Ne=e[13];const _e=x?t.jsxs("div",{className:"absolute inset-y-0 left-0 flex items-stretch",style:{width:At},"aria-hidden":!A,children:[t.jsx("button",{type:"button",tabIndex:A?0:-1,className:Y("flex flex-1 items-center justify-center transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-destructive",k?"rounded-lg bg-destructive text-destructive-foreground":"text-[var(--status-error)] active:opacity-80"),"aria-label":k?b("mobile.sessions.confirmDeleteSessionAria",{title:C}):b("mobile.sessions.deleteSessionAria",{title:C}),onClick:k?j:y,style:{touchAction:"manipulation"},children:t.jsx(_s,{className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:A?0:-1,className:"flex flex-1 items-center justify-center text-muted-foreground transition-colors active:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary","aria-label":b("mobile.sessions.archiveSessionAria",{title:C}),onClick:h,style:{touchAction:"manipulation"},children:t.jsx(ol,{className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:A?0:-1,className:"flex flex-1 items-center justify-center text-muted-foreground transition-colors active:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary","aria-label":b("mobile.sessions.renameSessionAria",{title:C}),onClick:T,style:{touchAction:"manipulation"},children:t.jsx(cn,{className:"size-[18px]"})}),t.jsx(he,{variant:"ghost",size:"icon",tabIndex:A?0:-1,className:"flex-1 self-center text-muted-foreground",disabled:_.disabled,"aria-label":b("sessions.aiRename.action"),"aria-description":_.hint,title:_.hint,onClick:()=>{_.run(),p?.(!1)},style:{touchAction:"manipulation"},children:t.jsx(X,{name:_.pending?"loader-4":"ai-generate-2",className:_.pending?"size-[18px] animate-spin":"size-[18px]"})})]}):null,Me=x&&"bg-background",Je=o&&(x?"bg-[color-mix(in_srgb,var(--primary)_10%,var(--background))]":"bg-[color-mix(in_srgb,var(--primary)_10%,transparent)]");let Ce;e[14]!==Me||e[15]!==Je?(Ce=Y("relative flex items-center gap-1 transition-colors",Me,Je),e[14]=Me,e[15]=Je,e[16]=Ce):Ce=e[16];let Ie;e[17]!==_.pending||e[18]!==w||e[19]!==D||e[20]!==r||e[21]!==F||e[22]!==f||e[23]!==I||e[24]!==b?(Ie=_.pending||F||I||D&&f?t.jsx("button",{type:"button",className:"absolute z-10 flex w-6 items-center justify-center rounded-md text-muted-foreground/70 transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",style:{left:Math.max(r-32,2),top:0,bottom:0,touchAction:"manipulation"},"aria-label":_.pending?b("sessions.aiRename.generating"):b(w?"sessions.sidebar.session.subsessions.collapse":"sessions.sidebar.session.subsessions.expand"),disabled:!D||!f,onClick:Pe=>{Pe.stopPropagation(),f?.()},children:_.pending?t.jsx(X,{name:"loader-4",className:"size-3 animate-spin text-primary","aria-label":b("sessions.aiRename.generating")}):F||I?t.jsx("span",{className:Y("size-1.5 rounded-full",F?"bg-primary":"bg-[var(--status-info)]"),"aria-hidden":!0}):t.jsx(jn,{className:Y("size-[18px] transition-transform duration-150",w?"rotate-0":"-rotate-90")})}):null,e[17]=_.pending,e[18]=w,e[19]=D,e[20]=r,e[21]=F,e[22]=f,e[23]=I,e[24]=b,e[25]=Ie):Ie=e[25];let ce;e[26]!==o||e[27]!==i||e[28]!==r||e[29]!==F||e[30]!==E||e[31]!==p||e[32]!==d||e[33]!==S||e[34]!==R||e[35]!==s.id||e[36]!==Q||e[37]!==z||e[38]!==C?(ce=R&&S&&E?t.jsx(au,{initialTitle:C,indent:r,onSubmit:S,onCancel:E}):t.jsx("button",{type:"button",className:Y("flex min-w-0 flex-1 items-center gap-2.5 pr-3.5 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",i?"min-h-10 py-1":"h-9"),style:{paddingLeft:r,touchAction:"manipulation"},onClick:()=>{if(J.current){p?.(!1);return}d()},children:t.jsxs("span",{className:"flex min-w-0 flex-1 flex-col",children:[t.jsxs("span",{className:"flex items-center gap-2.5",children:[t.jsx("span",{className:Y("block min-w-0 flex-1 truncate typography-ui-label",o?"text-primary":"text-foreground"),children:C}),Q?t.jsx(io,{sessionId:s.id,running:F,className:"typography-micro"}):z?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:z}):null]}),i?t.jsx("span",{className:"block truncate typography-micro text-muted-foreground",children:i}):null]})}),e[26]=o,e[27]=i,e[28]=r,e[29]=F,e[30]=E,e[31]=p,e[32]=d,e[33]=S,e[34]=R,e[35]=s.id,e[36]=Q,e[37]=z,e[38]=C,e[39]=ce):ce=e[39];let Re;e[40]!==Ce||e[41]!==Ie||e[42]!==ce?(Re=t.jsxs("div",{ref:Z,className:Ce,children:[Ie,ce]}),e[40]=Ce,e[41]=Ie,e[42]=ce,e[43]=Re):Re=e[43];let Ye;return e[44]!==je||e[45]!==ie||e[46]!==de||e[47]!==q||e[48]!==Ne||e[49]!==_e||e[50]!==Re?(Ye=t.jsxs("div",{"data-active-session":q,className:ve,onTouchStart:de,onTouchMove:ie,onTouchEnd:je,onTouchCancel:je,style:Ne,children:[_e,Re]}),e[44]=je,e[45]=ie,e[46]=de,e[47]=q,e[48]=Ne,e[49]=_e,e[50]=Re,e[51]=Ye):Ye=e[51],Ye},lu=n=>{const e=le.c(11),{indent:s,onClick:o}=n,{t:r}=fe();let i;e[0]!==s?(i={paddingLeft:s,touchAction:"manipulation"},e[0]=s,e[1]=i):i=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx(jn,{className:"size-4"}),e[2]=a):a=e[2];let u;e[3]!==r?(u=r("sessions.sidebar.group.showMore"),e[3]=r,e[4]=u):u=e[4];let f;e[5]!==u?(f=t.jsx("span",{className:"typography-micro",children:u}),e[5]=u,e[6]=f):f=e[6];let d;return e[7]!==o||e[8]!==i||e[9]!==f?(d=t.jsxs("button",{type:"button",className:"flex min-h-9 w-full items-center gap-2 py-1 pr-3 text-left text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",style:i,onClick:o,children:[a,f]}),e[7]=o,e[8]=i,e[9]=f,e[10]=d):d=e[10],d},cu=n=>{const e=le.c(11),{indent:s,onClick:o}=n,{t:r}=fe();let i;e[0]!==s?(i={paddingLeft:s,touchAction:"manipulation"},e[0]=s,e[1]=i):i=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=t.jsx(il,{className:"size-4"}),e[2]=a):a=e[2];let u;e[3]!==r?(u=r("sessions.sidebar.group.showFewer"),e[3]=r,e[4]=u):u=e[4];let f;e[5]!==u?(f=t.jsx("span",{className:"typography-micro",children:u}),e[5]=u,e[6]=f):f=e[6];let d;return e[7]!==o||e[8]!==i||e[9]!==f?(d=t.jsxs("button",{type:"button",className:"flex min-h-9 w-full items-center gap-2 py-1 pr-3 text-left text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",style:i,onClick:o,children:[a,f]}),e[7]=o,e[8]=i,e[9]=f,e[10]=d):d=e[10],d},uu=n=>{const e=le.c(29),{worktree:s}=n,{t:o}=fe();let r;e[0]!==s.path?(r=Te(s.path),e[0]=s.path,e[1]=r):r=e[1];const i=r;let a;e[2]!==i?(a={id:i},e[2]=i,e[3]=a):a=e[3];const{attributes:u,listeners:f,setNodeRef:d,transform:l,transition:p,isDragging:g}=Tn(a),h=s.branch||s.label||s.path;let y;e[4]!==l?(y=In.Transform.toString(l),e[4]=l,e[5]=y):y=e[5];const j=g?10:1;let v;e[6]!==y||e[7]!==j||e[8]!==p?(v={transform:y,transition:p,zIndex:j},e[6]=y,e[7]=j,e[8]=p,e[9]=v):v=e[9];const T=g&&"shadow-lg shadow-black/20";let S;e[10]!==T?(S=Y("flex items-center gap-1 rounded-xl bg-background px-1 py-1",T),e[10]=T,e[11]=S):S=e[11];let E;e[12]!==h||e[13]!==o?(E=o("mobile.sessions.dragHandleAria",{label:h}),e[12]=h,e[13]=o,e[14]=E):E=e[14];let D;e[15]===Symbol.for("react.memo_cache_sentinel")?(D=t.jsx(wn,{className:"size-4"}),e[15]=D):D=e[15];let w;e[16]!==u||e[17]!==f||e[18]!==E?(w=t.jsx("button",{type:"button",className:"flex size-8 shrink-0 cursor-grab touch-none items-center justify-center rounded-lg text-muted-foreground/70 transition-colors hover:text-foreground active:cursor-grabbing","aria-label":E,...u,...f,children:D}),e[16]=u,e[17]=f,e[18]=E,e[19]=w):w=e[19];let A;e[20]===Symbol.for("react.memo_cache_sentinel")?(A=t.jsx(X,{name:"git-branch",className:"size-4 shrink-0 text-muted-foreground"}),e[20]=A):A=e[20];let k;e[21]!==h?(k=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-bold text-muted-foreground",children:h}),e[21]=h,e[22]=k):k=e[22];let R;return e[23]!==d||e[24]!==w||e[25]!==k||e[26]!==v||e[27]!==S?(R=t.jsxs("div",{ref:d,style:v,className:S,children:[w,A,k]}),e[23]=d,e[24]=w,e[25]=k,e[26]=v,e[27]=S,e[28]=R):R=e[28],R},du=n=>{const e=le.c(61),{project:s,totalSessions:o,expanded:r,onToggleExpanded:i,onReorderWorktrees:a}=n,{t:u}=fe();let f;e[0]!==s.id?(f={id:s.id},e[0]=s.id,e[1]=f):f=e[1];const{attributes:d,listeners:l,setNodeRef:p,transform:g,transition:h,isDragging:y}=Tn(f);let j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j={activationConstraint:{distance:8}},e[2]=j):j=e[2];let v;e[3]===Symbol.for("react.memo_cache_sentinel")?(v={coordinateGetter:Rn},e[3]=v):v=e[3];const T=kn(Lt(Nn,j),Lt(Sn,v)),S=s.worktrees.length>0;let E;e[4]!==a||e[5]!==s.worktrees?(E=M=>{const{active:W,over:J}=M;if(!J||W.id===J.id)return;const G=s.worktrees.map(gu),te=G.indexOf(String(W.id)),re=G.indexOf(String(J.id));if(te<0||re<0)return;const se=[...G],[ae]=se.splice(te,1);se.splice(re,0,ae),a(se)},e[4]=a,e[5]=s.worktrees,e[6]=E):E=e[6];const D=E;let w;e[7]!==g?(w=In.Transform.toString(g),e[7]=g,e[8]=w):w=e[8];const A=y?10:1;let k;e[9]!==w||e[10]!==A||e[11]!==h?(k={transform:w,transition:h,zIndex:A},e[9]=w,e[10]=A,e[11]=h,e[12]=k):k=e[12];const R=y&&"shadow-lg shadow-black/20";let b;e[13]!==R?(b=Y("rounded-2xl border border-border/70 bg-[var(--surface-elevated)] px-1.5 py-1.5 transition-colors",R),e[13]=R,e[14]=b):b=e[14];let O;e[15]!==s.label||e[16]!==u?(O=u("mobile.sessions.dragHandleAria",{label:s.label}),e[15]=s.label,e[16]=u,e[17]=O):O=e[17];let z;e[18]===Symbol.for("react.memo_cache_sentinel")?(z=t.jsx(wn,{className:"size-4"}),e[18]=z):z=e[18];let C;e[19]!==d||e[20]!==l||e[21]!==O?(C=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 cursor-grab touch-none items-center justify-center rounded-xl text-muted-foreground/70 transition-colors hover:text-foreground active:cursor-grabbing","aria-label":O,...d,...l,children:z}),e[19]=d,e[20]=l,e[21]=O,e[22]=C):C=e[22];let x;e[23]!==r||e[24]!==s.label||e[25]!==u?(x=r?u("sessions.sidebar.group.collapseAria",{label:s.label}):u("sessions.sidebar.group.expandAria",{label:s.label}),e[23]=r,e[24]=s.label,e[25]=u,e[26]=x):x=e[26];const _=!S;let K;e[27]===Symbol.for("react.memo_cache_sentinel")?(K={touchAction:"manipulation"},e[27]=K):K=e[27];let N;e[28]!==s?(N=t.jsx(mn,{project:s}),e[28]=s,e[29]=N):N=e[29];let V;e[30]!==s.label?(V=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:s.label}),e[30]=s.label,e[31]=V):V=e[31];let F;e[32]!==o?(F=t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:o}),e[32]=o,e[33]=F):F=e[33];let I;e[34]!==r||e[35]!==S?(I=S?t.jsx(jn,{className:Y("size-4 shrink-0 text-muted-foreground transition-transform",r&&"rotate-180")}):null,e[34]=r,e[35]=S,e[36]=I):I=e[36];let B;e[37]!==r||e[38]!==i||e[39]!==x||e[40]!==_||e[41]!==N||e[42]!==V||e[43]!==F||e[44]!==I?(B=t.jsxs("button",{type:"button",className:"flex min-h-9 min-w-0 flex-1 items-center gap-2 rounded-xl px-1 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary",onClick:i,"aria-expanded":r,"aria-label":x,disabled:_,style:K,children:[N,V,F,I]}),e[37]=r,e[38]=i,e[39]=x,e[40]=_,e[41]=N,e[42]=V,e[43]=F,e[44]=I,e[45]=B):B=e[45];let Q;e[46]!==C||e[47]!==B?(Q=t.jsxs("div",{className:"flex items-center gap-1",children:[C,B]}),e[46]=C,e[47]=B,e[48]=Q):Q=e[48];let Z;e[49]!==r||e[50]!==D||e[51]!==S||e[52]!==s.worktrees||e[53]!==T?(Z=r&&S?t.jsx(Cn,{sensors:T,collisionDetection:En,onDragEnd:D,children:t.jsx(Pn,{items:s.worktrees.map(bu),strategy:An,children:t.jsx("div",{className:"mt-1 flex flex-col gap-0.5 pl-3",children:s.worktrees.map(xu)})})}):null,e[49]=r,e[50]=D,e[51]=S,e[52]=s.worktrees,e[53]=T,e[54]=Z):Z=e[54];let ne;return e[55]!==p||e[56]!==Q||e[57]!==Z||e[58]!==k||e[59]!==b?(ne=t.jsxs("div",{ref:p,style:k,className:b,children:[Q,Z]}),e[55]=p,e[56]=Q,e[57]=Z,e[58]=k,e[59]=b,e[60]=ne):ne=e[60],ne},Cr=({open:n,onOpenChange:e,variant:s="drawer",footer:o})=>{const{t:r}=fe(),{git:i}=yn(),a=qr(),u=hn(m=>m.activeSessions),f=Wr(c.useCallback(m=>n||s==="sidebar"?m.ids:eu,[n,s])),d=Ur(c.useCallback(m=>n||s==="sidebar"?m.rankById:hi,[n,s])),l=Ve(m=>m.projects),p=Ve(m=>m.activeProjectId),g=jt(m=>m.currentDirectory),h=Se(m=>m.currentSessionId),y=Se(m=>m.setCurrentSession),j=Se(m=>m.archiveSession),v=Se(m=>m.archiveSessions),T=Se(m=>m.deleteSession),S=Se(m=>m.deleteSessions),E=Se(m=>m.updateSessionTitle),D=Se(m=>m.openNewSessionDraft),w=Ve(m=>m.setActiveProject),A=Ve(m=>m.setActiveProjectIdOnly),k=Ve(m=>m.reorderProjects),R=Ve(m=>m.manualProjectOrder),b=Jn(m=>m.projectSortOrder),O=Jn(m=>m.setProjectSortOrder),z=Ve(m=>m.removeProject),C=Rs(m=>m.projectExpanded),x=Rs(m=>m.worktreeExpanded),_=Rs(m=>m.setProjectExpanded),K=Rs(m=>m.setWorktreeExpanded),N=fn(m=>m.orderByProject),V=fn(m=>m.setWorktreeOrder),F=yr(m=>m.expandedParents),I=yr(m=>m.toggleParent),[B,Q]=c.useState(""),[Z,ne]=c.useState(null),[M,W]=c.useState(null),[J,G]=c.useState(null),[te,re]=c.useState(null),[se,ae]=c.useState(null),[de,U]=c.useState(null),[ie,xe]=c.useState(null),[je,q]=c.useState(0),[ve,Ne]=c.useState(!1),[_e,Me]=c.useState(!1),[Je,Ce]=c.useState(!1),[Ie,ce]=c.useState(null),[Re,Ye]=c.useState(()=>new Map(Se.getState().availableWorktreesByProject)),[Pe,Xe]=c.useState(()=>{const m=new Set;for(const[$,H]of Se.getState().availableWorktreesByProject)H.length>0&&m.add($);return m}),[Ee,$e]=c.useState(!1),[Fe,Qe]=c.useState(new Set),[at,et]=c.useState(new Map);c.useEffect(()=>{if(!n){Q(""),$e(!1),Qe(new Set),et(new Map),ne(null),W(null),G(null),re(null),ae(null),U(null);return}xn(a)},[n]),c.useEffect(()=>{Ee||Qe(new Set)},[Ee]),c.useEffect(()=>{if(!n||l.length===0)return;let m=!1;return(async()=>{const H=await Promise.all(l.map(async pe=>{const me=Te(pe.path);if(!me)return null;const Le=await i.checkIsGitRepository(me).catch(()=>!1),Ze=Le?await so({id:pe.id,path:me}).catch(()=>[]):[];return[me,Ze,Le]}));if(m)return;const oe=new Map,ge=new Set;for(const pe of H)pe&&(oe.set(pe[0],pe[1]),pe[2]&&ge.add(pe[0]));Ye(no(l,oe)),Xe(ge)})(),()=>{m=!0}},[i,n,l,je]);const Ae=c.useMemo(()=>Ca(l.map(m=>({id:m.id,label:m.label?.trim()||tn(m.path),path:Te(m.path),icon:m.icon,color:m.color,iconImage:m.iconImage,iconBackground:m.iconBackground,isGitRepo:Pe.has(Te(m.path)),worktrees:Vc(N[m.id],Re.get(Te(m.path))??[]),addedAt:m.addedAt,lastOpenedAt:m.lastOpenedAt})),b,R),[Pe,R,b,l,N,Re]),lt=c.useMemo(()=>{const m=new Map(a.map(oe=>[oe.id,oe])),$=u.map(oe=>{const ge=m.get(oe.id);return ge?gi(ge,oe):oe}),H=new Set($.map(oe=>oe.id));for(const oe of a)H.has(oe.id)||$.push(oe);return $.filter(oe=>!oe.time?.archived)},[u,a]),we=c.useMemo(()=>{const m=new Map;for(const $ of lt){const H=Pt($);if(!H)continue;const oe=m.get(H)??[];oe.push($),m.set(H,oe)}return m},[lt]),{projectSessions:Gt,chatSessions:ct}=c.useMemo(()=>Ea(lt,!1),[lt]),nt=c.useMemo(()=>({key:ts,label:"",path:"",worktree:null,sessions:Qs(ct,f,d)}),[ct,f,d]),Us=`${ts}::${ts}`,Vs=c.useMemo(()=>ct.filter(m=>!Pt(m)).length,[ct]),ze=B.trim().toLowerCase(),hs=c.useRef(null);c.useEffect(()=>{if(!n)return;const m=window.requestAnimationFrame(()=>{const $=hs.current;if(!$)return;($.querySelector('[data-active-session="true"]')??$.querySelector('[data-active-project="true"]'))?.scrollIntoView({block:"center"})});return()=>window.cancelAnimationFrame(m)},[n]);const rt=c.useMemo(()=>{const m=Ae.map(H=>({project:H,buckets:[],totalSessions:0,isActive:H.id===p})),$=(H,oe,ge)=>{const pe=Te(oe)||H.project.path,me=pe||"__root__";let Le=H.buckets.find(Ze=>Ze.key===me);return Le||(Le={key:me,label:ge?.branch||tn(pe),path:pe,worktree:ge,sessions:[]},H.buckets.push(Le)),Le};for(const H of m){$(H,H.project.path,null);for(const oe of H.project.worktrees)$(H,oe.path,oe)}for(const H of Gt){const oe=cs(H);if(!oe)continue;const ge=Te(oe),pe=m.find(Ze=>Io(Ze.project,ge));if(!pe)continue;const me=Ds(pe.project,ge);(me?$(pe,me.path,me):$(pe,pe.project.path,null)).sessions.push(H)}for(const H of m)for(const oe of H.buckets){oe.sessions=Qs(oe.sessions,f,d);for(const ge of oe.sessions)Pt(ge)||(H.totalSessions+=1)}return m},[p,f,Gt,Ae,d]),Ue=Te(g),tt=m=>m.isActive?Ue===m.project.path?m.project.path:m.project.worktrees.find(H=>ou(Ue,H.path))?.path??m.project.path:null,Kt=m=>C[m.project.id]??!0,mt=(m,$)=>x[`${m.project.id}::${$.key}`]??!0,gs=m=>{et($=>{if(!$.has(m))return $;const H=new Map($);return H.delete(m),H})},Gs=m=>{et($=>{let H=!1;const oe=new Map($),ge=`${m}::`;for(const pe of oe.keys())pe.startsWith(ge)&&(oe.delete(pe),H=!0);return H?oe:$})},Be=(m,$)=>{et(H=>{const oe=new Map(H);return oe.set(m,$+nn),oe})},Ht=(m,$,H)=>{const oe=new Set($.sessions.map(ke=>ke.id)),ge=new Map;for(const ke of $.sessions){const it=Pt(ke);if(it&&oe.has(it)){const Zt=ge.get(it)??[];Zt.push(ke),ge.set(it,Zt)}}const pe=$.sessions.filter(ke=>{const it=Pt(ke);return!it||!oe.has(it)}),me=at.get(m)??nn,Le=pe.slice(0,me),Ze=pe.length-Le.length,Ys=pe.length>nn&&Ze===0,Kn=(ke,it)=>{const Zt=ge.get(ke.id)??[],Xs=Zt.length>0,Hn=!!F[ke.id];return t.jsxs(c.Fragment,{children:[t.jsx(Nr,{session:ke,active:h===ke.id,indent:it,hasChildren:Xs,expanded:Hn,onToggleChildren:Xs?()=>I(ke.id):void 0,onSelect:()=>xs(ke),revealed:M===ke.id,onRevealedChange:es=>Ks(ke.id,es),confirmingDelete:J===ke.id,onArchive:()=>{ht(ke)},onRequestDelete:()=>G(ke.id),onConfirmDelete:()=>{Jt(ke)},renaming:te===ke.id,onRequestRename:()=>Yt(ke.id),onSubmitRename:es=>{ys(ke.id,es)},onCancelRename:()=>re(null)}),Xs&&Hn?Zt.map(es=>Kn(es,it+su)):null]},ke.id)};return t.jsxs("div",{children:[Le.map(ke=>Kn(ke,H)),Ze>0?t.jsx(lu,{indent:H,onClick:()=>Be(m,Le.length)}):null,Ys?t.jsx(cu,{indent:H,onClick:()=>gs(m)}):null]})},bs=(m,$)=>{_(m,!$),Gs(m)},Et=(m,$,H)=>{K(`${m}::${$}`,!H),gs(`${m}::${$}`)},xs=m=>{const $=cs(m)||null,H=rn(Ae,$??"");if(H){A(H.id),_(H.id,!0);const oe=Ds(H,Te($??""));oe&&K(`${H.id}::${Te(oe.path)}`,!0)}y(m.id,$),e(!1)},Ks=(m,$)=>{W($?m:null),G(null),ae(null),U(null)},ot=(m,$)=>{ae($?m:null),U(null),W(null),G(null)},qt=(m,$)=>(W(null),G(null),Ia(m,$,Da($.id,_a(we,$.id),m==="delete"),{archiveSession:j,archiveSessions:v,deleteSession:T,deleteSessions:S},r)),ht=m=>qt("archive",m),Jt=m=>qt("delete",m),Yt=m=>{W(null),G(null),re(m)},ys=async(m,$)=>{re(null);try{await E(m,$)}catch{ue.error(r("mobile.sessions.renameError"))}},Hs=()=>{D(),e(!1)},vs=m=>{ce(m),A(m),Ce(!0)},ws=kn(Lt(Nn,{activationConstraint:{distance:8}}),Lt(Sn,{coordinateGetter:Rn})),qs=m=>{O(m),Uo({sidebarProjectSortOrder:m}),m!=="manual"&&$e(!1)},Xt=m=>{const{active:$,over:H}=m;if(!H||$.id===H.id)return;const oe=Ae.findIndex(pe=>pe.id===$.id),ge=Ae.findIndex(pe=>pe.id===H.id);oe<0||ge<0||k(oe,ge)},js=m=>{Qe($=>{const H=new Set($);return H.has(m)?H.delete(m):H.add(m),H})},ks=c.useCallback(m=>{const $=cs(m);if(bi($))return r("mobile.sessions.section.chats");const H=rn(Ae,$);if(!H)return tn($)||$;const oe=Ds(H,Te($));return oe?.branch?`${H.label} · ${oe.branch}`:H.label},[Ae,r]),Js=m=>{w(m.id),e(!1)},P=m=>{A(m.id),D({selectedProjectId:m.id,directoryOverride:m.path}),e(!1)},ee=c.useMemo(()=>ze?rt.filter(m=>to([m.project.label,m.project.path],ze)?!0:m.buckets.some($=>$.sessions.some(H=>on(H,m.project.label,ze)))):rt,[ze,rt]),ye=c.useMemo(()=>ze?Qs(lt.filter(m=>{if(Pt(m))return!1;const $=cs(m),H=rn(Ae,$);return on(m,H?.label??"",ze)}),f,d):[],[ze,f,Ae,d,lt]),We=c.useMemo(()=>ze?xi(Ae,ze,m=>[m.label,m.path]):[],[ze,Ae]),gt=ze&&ye.length===0&&We.length===0,bt=!ze&&Ae.length>1&&b==="manual",Qt=!Ee&&!ze&&Ae.length>1?t.jsx(he,{type:"button",variant:"chip",size:"sm","aria-label":r("sessions.sidebar.header.actions.sortProjects"),title:r("sessions.sidebar.header.actions.sortProjects"),onClick:()=>Ne(!0),style:{touchAction:"manipulation"},children:t.jsx(X,{name:"equalizer-2",className:"size-4"})}):null,Ss=bt?t.jsx(he,{type:"button",variant:"chip",size:"sm","aria-label":r(Ee?"mobile.sessions.doneEditing":"mobile.sessions.editOrder"),"aria-pressed":Ee,onClick:()=>$e(m=>!m),style:{touchAction:"manipulation"},children:Ee?t.jsx(ao,{className:"size-4"}):t.jsx(cn,{className:"size-4"})}):null,Un=!Ee&&Ae.length>0?t.jsxs(he,{type:"button",variant:"default",size:"sm","aria-label":r("mobile.sessions.newChat"),onClick:Hs,style:{touchAction:"manipulation"},children:[t.jsx(rl,{className:"size-4"}),r("mobile.sessions.newChat")]}):null,Vn=Ee?null:t.jsx(he,{type:"button",variant:"chip",size:"sm","aria-label":r("sessions.sidebar.header.actions.addProject"),title:r("sessions.sidebar.header.actions.addProject"),onClick:()=>Me(!0),style:{touchAction:"manipulation"},children:t.jsx(sr,{className:"size-4"})}),Ns=Un||Vn||Qt||Ss?t.jsxs(t.Fragment,{children:[Vn,Qt,Ss,Un]}):null,Gn=t.jsxs("div",{ref:hs,className:"flex min-h-0 flex-1 flex-col",children:[t.jsxs($s,{className:"min-h-0 flex-1 overflow-y-auto pb-4",children:[t.jsx("div",{className:Y("px-4 pb-2 pt-1",Ee&&"hidden"),children:t.jsx(Ra,{value:B,onSearch:Q,active:n||s==="sidebar",mobile:!0,placeholder:r("mobile.sessions.search.placeholder"),clearLabel:r("mobile.sessions.clearSearchAria")})}),Ae.length===0&&ct.length===0?t.jsx(Pr,{title:r("mobile.sessions.empty.noProjectsTitle"),description:r("mobile.sessions.empty.noProjectsDescription"),action:t.jsxs("button",{type:"button",className:"flex items-center justify-center gap-2 rounded-2xl bg-primary px-5 py-3 typography-ui-label text-primary-foreground transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:()=>Me(!0),children:[t.jsx(sr,{className:"size-4"}),r("sessions.sidebar.header.actions.addProject")]})}):gt?t.jsx(Pr,{title:r("mobile.sessions.empty.searchTitle"),description:r("mobile.sessions.empty.searchDescription")}):ze&&!Ee?t.jsxs("div",{className:"flex flex-col gap-3 px-3 pt-2",children:[ye.length>0?t.jsxs("section",{children:[t.jsxs("div",{className:"flex items-center justify-between px-1 pb-1.5",children:[t.jsx("span",{className:"typography-micro font-semibold uppercase tracking-wider text-muted-foreground",children:r("mobile.sessions.search.section.sessions")}),t.jsx("span",{className:"typography-micro text-muted-foreground tabular-nums",children:ye.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:ye.map((m,$)=>t.jsx("div",{className:Y($>0&&"border-t border-border/70"),children:t.jsx(Nr,{session:m,active:h===m.id,indent:12,contextLabel:ks(m),onSelect:()=>xs(m)})},m.id))})]}):null,We.length>0?t.jsxs("section",{children:[t.jsxs("div",{className:"flex items-center justify-between px-1 pb-1.5",children:[t.jsx("span",{className:"typography-micro font-semibold uppercase tracking-wider text-muted-foreground",children:r("mobile.sessions.search.section.projects")}),t.jsx("span",{className:"typography-micro text-muted-foreground tabular-nums",children:We.length})]}),t.jsx("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:We.map((m,$)=>t.jsxs("div",{className:Y("flex items-center",$>0&&"border-t border-border/70"),children:[t.jsxs("button",{type:"button",className:"flex min-h-12 min-w-0 flex-1 items-center gap-3 px-3 py-1.5 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",onClick:()=>Js(m),style:{touchAction:"manipulation"},children:[t.jsx(mn,{project:m}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:m.label})]}),m.isGitRepo?t.jsx(jr,{onClick:()=>vs(m.id)}):null,t.jsx(kr,{className:"mr-2",label:r("mobile.sessions.newSessionInProjectAria",{label:m.label}),onClick:()=>P(m)})]},m.id))})]}):null]}):Ee?t.jsxs("div",{className:"flex flex-col gap-2 px-3 py-2",children:[t.jsx("p",{className:"px-1 typography-micro text-muted-foreground",children:r("mobile.sessions.editOrderHint")}),t.jsx(Cn,{sensors:ws,collisionDetection:En,onDragEnd:Xt,children:t.jsx(Pn,{items:Ae.map(m=>m.id),strategy:An,children:t.jsx("div",{className:"flex flex-col gap-1.5",children:Ae.map(m=>{const $=rt.find(H=>H.project.id===m.id);return t.jsx(du,{project:m,totalSessions:$?.totalSessions??0,expanded:Fe.has(m.id),onToggleExpanded:()=>js(m.id),onReorderWorktrees:H=>V(m.id,H)},m.id)})})})})]}):t.jsxs("div",{className:"flex flex-col",children:[(()=>{const m=C[ts]??!0,$=r("mobile.sessions.section.chats");return t.jsxs("section",{children:[t.jsx("div",{className:"flex min-h-12 w-full items-center",children:t.jsxs("button",{type:"button",className:"flex min-h-12 min-w-0 flex-1 items-center gap-2 px-3 py-1.5 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",onClick:()=>{if(se){ot(se,!1);return}bs(ts,m)},"aria-expanded":m,"aria-label":m?r("sessions.sidebar.group.collapseAria",{label:$}):r("sessions.sidebar.group.expandAria",{label:$}),style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-[var(--surface-muted)] text-muted-foreground",children:t.jsx(X,{name:"chat-4",className:"size-4"})}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",children:$}),t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:Vs})]})}),m?t.jsx("div",{className:"pb-2",children:nt.sessions.length>0?Ht(Us,nt,As):t.jsx("p",{className:"px-3 pb-1 typography-micro text-muted-foreground",style:{paddingLeft:As},children:r("sessions.sidebar.activity.chatsEmpty")})}):null]})})(),ee.map(m=>{const $=Kt(m),H=ze?m.buckets.filter(ge=>ge.sessions.some(pe=>on(pe,m.project.label,ze))):m.buckets,oe=tt(m);return t.jsxs("section",{className:"border-t border-border/70",children:[t.jsx(Sr,{actionsWidth:96,revealed:se===`project:${m.project.id}`,onRevealedChange:ge=>ot(`project:${m.project.id}`,ge),actions:t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",tabIndex:se===`project:${m.project.id}`?0:-1,className:Y("flex flex-1 items-center justify-center transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-destructive",de===m.project.id?"rounded-lg bg-destructive text-destructive-foreground":"text-[var(--status-error)] active:opacity-80"),"aria-label":de===m.project.id?r("mobile.sessions.confirmRemoveProjectAria",{label:m.project.label}):r("mobile.sessions.removeProjectAria",{label:m.project.label}),onClick:()=>{if(de===m.project.id){ae(null),U(null),z(m.project.id),ue.success(r("mobile.sessions.toast.projectRemoved",{label:m.project.label}));return}U(m.project.id)},style:{touchAction:"manipulation"},children:t.jsx(_s,{className:"size-[18px]"})}),t.jsx("button",{type:"button",tabIndex:se===`project:${m.project.id}`?0:-1,className:"flex flex-1 items-center justify-center text-muted-foreground transition-colors active:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary","aria-label":r("mobile.sessions.editProjectAria",{label:m.project.label}),onClick:()=>{ae(null),ne(m.project.id)},style:{touchAction:"manipulation"},children:t.jsx(cn,{className:"size-[18px]"})})]}),children:t.jsxs("div",{"data-active-project":m.isActive||void 0,className:"flex min-h-12 w-full items-center",children:[t.jsxs("button",{type:"button",className:"flex min-h-12 min-w-0 flex-1 items-center gap-2 px-3 py-1.5 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",onClick:()=>{if(se){ot(se,!1);return}bs(m.project.id,$)},"aria-expanded":$,"aria-label":$?r("sessions.sidebar.group.collapseAria",{label:m.project.label}):r("sessions.sidebar.group.expandAria",{label:m.project.label}),style:{touchAction:"manipulation"},children:[t.jsx(mn,{project:m.project}),t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label font-semibold text-foreground",children:m.project.label})]}),m.project.isGitRepo?t.jsx(jr,{onClick:()=>vs(m.project.id)}):null,t.jsx(kr,{className:"mr-2",label:r("mobile.sessions.newSessionInProjectAria",{label:m.project.label}),onClick:()=>P(m.project)})]})}),$?t.jsx("div",{className:"pb-2",children:(()=>{const ge=H.find(me=>me.worktree===null),pe=H.filter(me=>me.worktree!==null);return t.jsxs(t.Fragment,{children:[ge&&ge.sessions.length>0?Ht(`${m.project.id}::${ge.key}`,ge,As):null,pe.map(me=>{const Le=mt(m,me),Ze=oe===me.path;return t.jsxs("div",{children:[t.jsx(Sr,{actionsWidth:48,revealed:se===`wt:${me.key}`,onRevealedChange:Ys=>ot(`wt:${me.key}`,Ys),actions:t.jsx("button",{type:"button",tabIndex:se===`wt:${me.key}`?0:-1,className:"flex flex-1 items-center justify-center text-[var(--status-error)] transition-colors active:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-destructive","aria-label":r("mobile.projectEdit.deleteWorktreeAria",{label:me.label}),onClick:()=>{ae(null),me.worktree&&xe({project:m.project,worktree:me.worktree})},style:{touchAction:"manipulation"},children:t.jsx(_s,{className:"size-[18px]"})}),children:t.jsxs("button",{type:"button",className:"flex min-h-10 w-full items-center gap-2 px-3 py-1 text-left transition-colors hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",onClick:()=>{if(se){ot(se,!1);return}Et(m.project.id,me.key,Le)},"aria-expanded":Le,"aria-label":Le?r("sessions.sidebar.group.collapseAria",{label:me.label}):r("sessions.sidebar.group.expandAria",{label:me.label}),style:{touchAction:"manipulation"},children:[t.jsx(X,{name:"git-branch",className:Y("size-4 shrink-0",Ze?"text-primary":"text-muted-foreground")}),t.jsx("span",{className:Y("block min-w-0 flex-1 truncate typography-ui-label font-bold",Ze?"text-foreground":"text-muted-foreground"),children:me.label}),Ze?t.jsx(iu,{ariaLabel:r("mobile.sessions.activeWorktreeAria")}):null,t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground tabular-nums",children:me.sessions.length})]})}),Le?Ht(`${m.project.id}::${me.key}`,me,As):null]},me.key)})]})})()}):null]},m.project.id)})]})]}),o?t.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-t border-border/70 px-2 pt-1.5",style:{paddingBottom:"calc(0.375rem + var(--oc-safe-area-bottom, 0px))"},children:[o.instanceLabel&&o.onOpenInstances?t.jsxs(he,{type:"button",variant:"info",size:"lg",className:"min-w-0 shrink justify-start",onClick:o.onOpenInstances,"aria-label":r("mobile.menu.instances"),style:{touchAction:"manipulation"},children:[t.jsx(X,{name:"server",className:"size-[18px]"}),t.jsx("span",{className:"block min-w-0 truncate",children:o.instanceLabel})]}):t.jsx("div",{className:"min-w-0 flex-1"}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[o.onOpenUpdate?t.jsxs(he,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:o.onOpenUpdate,"aria-label":r("mobile.menu.update"),title:r("mobile.menu.update"),style:{touchAction:"manipulation"},children:[t.jsx(X,{name:"download",className:"size-5"}),t.jsx("span",{className:"absolute right-2 top-2 inline-flex size-2 rounded-full bg-primary","aria-hidden":!0})]}):null,t.jsx(he,{type:"button",variant:"default",size:"lg",className:"w-10 px-0",onClick:o.onOpenSettings,"aria-label":r("mobile.menu.settings"),title:r("mobile.menu.settings"),style:{touchAction:"manipulation"},children:t.jsx(X,{name:"settings-3",className:"size-5"})})]})]}):null,t.jsx(Pa,{open:_e,onOpenChange:Me}),t.jsx(Aa,{open:Je,onOpenChange:m=>{Ce(m),m||ce(null)},onWorktreeCreated:(m,$)=>{$?.sessionId?y($.sessionId,m):D({selectedProjectId:Ie,directoryOverride:m,preserveDirectoryOverride:!0}),e(!1)}}),t.jsx(Jc,{open:Z!==null,project:Ae.find(m=>m.id===Z)??null,onClose:()=>ne(null),onWorktreesChanged:()=>q(m=>m+1)}),t.jsx(Jr,{open:ve,onClose:()=>Ne(!1),title:r("sessions.sidebar.header.actions.sortProjects"),children:t.jsx("div",{className:"flex flex-col",children:tu.map(([m,$])=>t.jsxs("button",{type:"button",className:Y("flex min-h-11 w-full items-center justify-between rounded-lg px-3 text-left transition-colors active:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary",b===m?"text-primary":"text-foreground"),onClick:()=>{qs(m),Ne(!1)},style:{touchAction:"manipulation"},children:[t.jsx("span",{className:"typography-ui-label",children:r($)}),b===m?t.jsx(X,{name:"check",className:"size-4"}):null]},m))})}),ie?t.jsx(To,{open:!0,project:{id:ie.project.id,path:ie.project.path},worktree:ie.worktree,onClose:()=>xe(null),onDeleted:()=>q(m=>m+1)}):null]});return s==="sidebar"?n?t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center justify-between gap-2 border-b border-border/70 px-4",children:[t.jsx("h2",{className:"truncate typography-ui-label font-semibold text-foreground",children:r("mobile.sessions.sheet.title")}),Ns?t.jsx("div",{className:"flex shrink-0 items-center gap-2",children:Ns}):null]}),Gn]}):null:t.jsxs(pu,{open:n,onClose:()=>e(!1),onSwipeClose:()=>{if(M||se){W(null),ae(null),G(null),U(null);return}e(!1)},ariaLabel:r("mobile.sessions.sheet.title"),children:[t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",children:[t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":r("mobile.surface.closeAria"),onClick:()=>e(!1),style:{touchAction:"manipulation"},children:t.jsx(X,{name:"close",className:"size-5"})}),t.jsx("h2",{className:"min-w-0 flex-1 truncate px-1 typography-ui-label font-semibold text-foreground",children:r("mobile.sessions.sheet.title")}),Ns?t.jsx("div",{className:"flex shrink-0 items-center gap-2",children:Ns}):null]}),Gn]})},Er="mobile-surface-root",fu=16,Rr=320,mu="cubic-bezier(0.22, 1, 0.36, 1)",pu=({open:n,onClose:e,onSwipeClose:s,ariaLabel:o,children:r})=>{const i=c.useRef(null),a=c.useRef(null),[u,f]=c.useState(!1),[d,l]=c.useState(n),p=c.useRef(e);c.useEffect(()=>{p.current=e},[e]);const g=c.useRef(s);if(c.useEffect(()=>{g.current=s},[s]),Fn(a,{enabled:n,onRightEdgeSwipe:()=>(g.current??p.current)()}),typeof document<"u"&&!i.current){let h=document.getElementById(Er);h||(h=document.createElement("div"),h.id=Er,document.body.appendChild(h)),i.current=h}return c.useEffect(()=>{if(n){l(!0);const y=window.setTimeout(()=>f(!0),fu);return()=>window.clearTimeout(y)}f(!1);const h=window.setTimeout(()=>l(!1),Rr+40);return()=>window.clearTimeout(h)},[n]),c.useEffect(()=>{if(!n)return;const h=document.body.style.overflow;document.body.style.overflow="hidden";const y=j=>{j.key==="Escape"&&p.current()};return document.addEventListener("keydown",y),()=>{document.body.style.overflow=h,document.removeEventListener("keydown",y)}},[n]),i.current?Ot.createPortal(t.jsx("section",{ref:a,role:"dialog","aria-modal":"true","aria-label":o,"aria-hidden":!n,className:"oc-keyboard-inset-surface fixed inset-0 z-50 flex flex-col bg-background text-foreground",style:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:u?"none":"translateX(-100%)",transition:`transform ${Rr}ms ${mu}`,visibility:d?"visible":"hidden",pointerEvents:n?"auto":"none"},children:t.jsx("div",{className:"flex h-full min-h-0 flex-col",children:r})}),i.current):null},Pr=n=>{const e=le.c(10),{title:s,description:o,action:r}=n;let i;e[0]!==s?(i=t.jsx("p",{className:"typography-ui-label text-foreground",children:s}),e[0]=s,e[1]=i):i=e[1];let a;e[2]!==o?(a=o?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o}):null,e[2]=o,e[3]=a):a=e[3];let u;e[4]!==r?(u=r?t.jsx("div",{className:"pt-2",children:r}):null,e[4]=r,e[5]=u):u=e[5];let f;return e[6]!==i||e[7]!==a||e[8]!==u?(f=t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[i,a,u]}),e[6]=i,e[7]=a,e[8]=u,e[9]=f):f=e[9],f};function hu(n){n&&(n.focus(),n.select())}function gu(n){return Te(n.path)}function bu(n){return Te(n.path)}function xu(n){return t.jsx(uu,{worktree:n},Te(n.path))}const yu=(n,e)=>{if(!n)return e("mcpDropdown.status.unknown");switch(n.status){case"connected":return e("mcpDropdown.status.connected");case"failed":return e("mcpDropdown.status.failed",{error:n.error||e("mcpDropdown.status.unknownError")});case"needs_auth":return e("mcpDropdown.status.needsAuth");case"needs_client_registration":return e("mcpDropdown.status.needsRegistration",{error:n.error||""});default:return n.status}},vu=n=>{switch(n?.status){case"connected":return"success";case"failed":return"error";case"needs_auth":case"needs_client_registration":return"warning";default:return"default"}},wu=({active:n,className:e,headerAction:s,listClassName:o,hideHeader:r=!1,mobileListDensity:i=!1})=>{const{t:a}=fe(),f=jt(w=>w.currentDirectory)??null,d=rs(w=>w.getStatusForDirectory(f)),l=rs(w=>w.refresh),p=rs(w=>w.connect),g=rs(w=>w.disconnect),h=Mt(w=>w.mcpServers),y=Mt(w=>w.loadMcpConfigs),[j,v]=c.useState(!1),[T,S]=c.useState(null);c.useEffect(()=>{l({directory:f,silent:!0})},[l,f]),c.useEffect(()=>{y({force:!0})},[y]),c.useEffect(()=>{n&&Promise.all([l({directory:f,silent:!0}),y({force:!0})])},[n,l,f,y]);const E=c.useMemo(()=>{const w=new Set(Object.keys(d));for(const A of h)A?.name&&w.add(A.name);return Array.from(w).sort((A,k)=>A.localeCompare(k))},[h,d]),D=c.useCallback(w=>{if(w?.preventDefault(),j)return;v(!0);const A=new Promise(k=>setTimeout(k,500));Promise.all([l({directory:f}),A]).finally(()=>{v(!1)})},[j,l,f]);return t.jsxs("div",{className:Y("w-full",e),children:[r?null:t.jsx("div",{className:"border-b border-[var(--interactive-border)]",children:t.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-2.5",children:[t.jsxs("div",{className:"min-w-0 flex items-baseline gap-2",children:[t.jsx("div",{className:"typography-ui-header font-semibold text-foreground",children:a("mcpDropdown.title")}),f&&t.jsx("div",{className:"truncate typography-micro text-muted-foreground",children:f.split("/").pop()||f})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s,t.jsx("button",{type:"button",className:"inline-flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",disabled:j,onClick:D,"aria-label":a("mcpDropdown.actions.refreshAria"),children:t.jsx(X,{name:"refresh",className:Y("h-4 w-4",j&&"animate-spin")})})]})]})}),t.jsx("div",{className:Y("max-h-64 overflow-y-auto",i?"space-y-1 py-3":"px-3 py-2.5",o),children:t.jsxs("div",{className:Y(!i&&E.length>0&&"rounded-xl bg-[var(--surface-muted)] p-1.5"),children:[E.map(w=>{const A=d[w],k=vu(A),R=A?.status==="connected",b=T===w,O=yu(A,a);return t.jsxs("div",{className:Y("flex items-center justify-between rounded-lg hover:bg-interactive-hover/50",i?"gap-3 px-4 py-3":"gap-2 px-2.5 py-2"),children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsxs(yi,{children:[t.jsx(vi,{asChild:!0,children:t.jsx("span",{className:Y("rounded-full flex-shrink-0",i?"h-2.5 w-2.5":"h-2 w-2",k==="success"&&"bg-status-success",k==="error"&&"bg-status-error",k==="warning"&&"bg-status-warning",k==="default"&&"bg-muted-foreground/40"),"aria-label":O})}),t.jsx(wi,{side:"left",children:t.jsx("p",{children:O})})]}),t.jsx("span",{className:Y("truncate",i?"text-[17px] leading-6 font-medium":"typography-ui-label"),children:w})]})}),t.jsx(ji,{checked:R,disabled:b,className:"data-[checked]:bg-status-info",onCheckedChange:async z=>{S(w);try{if(!z){await g(w,f);return}const C=d?.[w]?.status;if(C==="needs_auth"||C==="needs_client_registration"){const{opened:x}=await ki({name:w,directory:f});x||rr.error(a("mcpDropdown.toast.authorizeOpenFailed"));return}await p(w,f)}catch(C){rr.error(C instanceof Error?C.message:a("mcpDropdown.toast.authorizeFailed"))}finally{S(null)}}})]},w)}),E.length===0&&t.jsx("div",{className:"px-4 py-5 typography-ui-label text-muted-foreground text-center",children:a("mcpDropdown.empty.configureInConfig")})]})})]})},Ar={status:"loading"},Tt={type:"list"},ju=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/g,""),ku=n=>{const e=n.index?.trim();return!!(e&&e!=="?")},Su=n=>{const e=n.working_dir?.trim(),s=n.index?.trim();return!!(e||s==="?")},Tr=(n,e)=>e?`${n}\0staged`:n,Nu=n=>{const e=le.c(8),s=vn()??null;let o;e[0]!==s?(o=ju(s),e[0]=s,e[1]=o):o=e[1];const r=o,i=n.visible??!0;let a;e[2]!==i?(a={enabled:i},e[2]=i,e[3]=a):a=e[3];const u=Si(r||null,a);let f;return e[4]!==n||e[5]!==u||e[6]!==r?(f=t.jsx(Cu,{...n,rootDirectory:r,repository:u}),e[4]=n,e[5]=u,e[6]=r,e[7]=f):f=e[7],f},Cu=({rootDirectory:n,repository:e,onClose:s,initialDiff:o,visible:r=!0})=>{const{t:i}=fe(),{git:a}=yn(),{rootIsGitRepo:u,gitDirectory:f,nestedRepos:d}=e,l=f??n,p=Ni(l||null),g=Ci(l||null),h=Hr(l||null),y=Ei(l||null),j=Ge(P=>P.setActiveDirectory),v=Ge(P=>P.ensureAll),T=Ge(P=>P.ensureNestedRepos),S=Ge(P=>P.selectNestedRepo),E=Ge(P=>P.fetchStatus),D=Ge(P=>P.fetchBranches),w=Ge(P=>P.prefetchDiffs),A=Ge(P=>P.getDiff),k=Ge(P=>P.setDiff),R=Ge(P=>P.runtimeKey),b=JSON.stringify([R,l]),O=c.useRef(b);O.current=b;const[z,C]=c.useState(()=>({ownerKey:b,mode:"working",route:o?.path?{type:"diff",path:o.path,staged:o.staged}:Tt})),x=z.ownerKey===b?z.mode:"working",_=z.ownerKey===b?z.route:Tt,[K,N]=c.useState(!1),V=c.useCallback(P=>{C({ownerKey:b,mode:P,route:Tt}),N(!1)},[b]),F=c.useCallback(P=>{C(L=>({ownerKey:b,mode:L.ownerKey===b?L.mode:"working",route:P}))},[b]);c.useEffect(()=>{C(P=>P.ownerKey===b?P:{ownerKey:b,mode:"working",route:Tt}),N(!1)},[b]),c.useEffect(()=>{r||N(!1)},[r]),c.useEffect(()=>{o?.path&&C({ownerKey:O.current,mode:"working",route:{type:"diff",path:o.path,staged:o.staged}})},[o]);const[I,B]=c.useState(null),[Q,Z]=c.useState(null),[ne,M]=c.useState(""),[W,J]=c.useState(new Set),[G,te]=c.useState(!1),[re,se]=c.useState(!1),[ae,de]=c.useState([]),[U,ie]=c.useState([]),[xe,je]=c.useState([]),[q,ve]=c.useState(null),[Ne,_e]=c.useState(null),[Me,Je]=c.useState(0),[Ce,Ie]=c.useState(null),ce=p?.current??null,Re=p?.tracking?.trim().split("/")[0],Ye=(Re&&g?.defaultBranches?.[Re])??g?.defaultBranches?.origin??null,Pe=Rl(ce,Ye),Xe=h===!1||El(ce,Ye,p!==null,g!==null),Ee=bl(P=>P.setOverride),$e=xl(l||null,ce,r&&x==="branch"&&Pe),Fe=yl(l||null,ce,r&&x==="commit"&&h===!0),Qe=Fe.selectedCommit?.hash??null,at=vl(l||null,ce,r&&x==="pr"&&h===!0),et=at.selectedSource,Ae=c.useMemo(()=>x==="pr"?et:x==="branch"&&ce&&$e.base?{kind:"branch",baseRef:$e.base,headRef:ce}:x==="commit"&&Qe?{kind:"commit",hash:Qe}:null,[$e.base,ce,x,Qe,et]),lt=x==="branch"?$e.revision:"",we=Nl(l||null,Ae,r&&h===!0,lt),{fetchDiff:Gt}=we,ct=c.useMemo(()=>we.files?[...we.files].sort((P,L)=>P.path.localeCompare(L.path)):null,[we.files]),nt=_.type==="comparison"&&_.sourceKey===we.key?_.path:null,[Us,Vs]=c.useState(0),ze=c.useCallback(async P=>{try{const{diff:L}=await Gt(P),ee={original:"",modified:"",isBinary:wl(L)};return ee.isBinary||(ee.fileDiff=jl(P,L)),{status:"ready",diff:ee}}catch(L){return{status:"error",message:L instanceof Error?L.message:i("diffView.state.failedToLoadDiff")}}},[Gt,i]),hs=Cl(we.files?x==="pr"?JSON.stringify([we.key,we.revision]):we.key:null,r&&nt?nt:"",r?ze:null,Ar,JSON.stringify([lt,x==="pr"?we.revision:0,Us])),rt=nt?hs.get(nt)??Ar:null;c.useEffect(()=>{x==="branch"&&Xe&&V("working")},[Xe,V,x]),c.useEffect(()=>{C(P=>P.ownerKey===b&&P.route.type==="comparison"&&P.route.sourceKey!==we.key?{...P,route:Tt}:P)},[we.key,b]);const Ue=c.useMemo(()=>{const P=p?.files??[],L=new Map;for(const ee of P)L.set(ee.path,ee);return Array.from(L.values()).sort((ee,ye)=>ee.path.localeCompare(ye.path))},[p?.files]),tt=c.useMemo(()=>Ue.filter(ku),[Ue]),Kt=c.useMemo(()=>Ue.filter(Su),[Ue]),mt=c.useMemo(()=>{if(xe.length>0)return xe;const P=p?.tracking?.includes("/")?p.tracking.split("/")[0]:null;return P||q?[{name:P||"origin",fetchUrl:q??"",pushUrl:q??""}]:[]},[q,xe,p?.tracking]),gs=Ge(c.useCallback(P=>!l||_.type!=="diff"?null:P.directories.get(l)?.diffCache.get(Tr(_.path,_.staged))??null,[l,_])),Gs=c.useMemo(()=>_.type!=="diff"?null:Ue.find(P=>P.path===_.path)??null,[Ue,_]),Be=c.useCallback(async(P=!0)=>{if(l)try{await Promise.all([E(l,a),D(l,a)])}catch(L){P&&ue.error(L instanceof Error?L.message:i("gitView.toast.refreshRepositoryFailed"))}},[l,D,E,a,i]),Ht=c.useMemo(()=>(g?.all??[]).filter(P=>!P.startsWith("remotes/")).sort(),[g]),bs=c.useMemo(()=>(g?.all??[]).filter(P=>P.startsWith("remotes/")).map(P=>P.replace(/^remotes\//,"")).sort(),[g]),Et=c.useCallback(async P=>{if(!l)return;const L=P.replace(/^remotes\//,"");try{const ee=await a.checkoutBranch(l,L);ue.success(i("gitView.toast.checkedOut",{name:ee.branch||L})),await Be()}catch(ee){ue.error(ee instanceof Error?ee.message:i("gitView.toast.checkoutFailed",{name:L}))}},[l,a,Be,i]),xs=c.useCallback(P=>{const L=P.replace(/^remotes\//,"");if((p?.files?.length??0)>0){Ie(L);return}Et(L)},[Et,p?.files]),Ks=c.useCallback(async(P,L)=>{if(l)try{await a.createBranch(l,P,ce??"HEAD"),await a.checkoutBranch(l,P),L&&await a.gitPush(l,{remote:L.name,branch:P,options:["--set-upstream"]}),await Be()}catch(ee){throw ue.error(ee instanceof Error?ee.message:i("gitView.toast.createBranchFailed")),ee}},[ce,l,a,Be,i]),ot=c.useCallback(async()=>{if(!l){je([]),ve(null);return}try{const[P,L]=await Promise.all([a.getRemotes(l).catch(()=>[]),a.getRemoteUrl?a.getRemoteUrl(l).catch(()=>null):Promise.resolve(null)]);je(P),ve(L)}catch{je([]),ve(null)}},[l,a]);c.useEffect(()=>{!l||!r||(j(l),v(l,a))},[l,v,a,j,r]),c.useEffect(()=>{r&&ot()},[ot,r]),c.useEffect(()=>{if(!r||x!=="working"||!l||Ue.length===0)return;const P=Array.from(new Set([...tt.map(ee=>ee.path),...U,...Ue.slice(0,20).map(ee=>ee.path)])).filter(Boolean);if(P.length===0)return;const L=window.setTimeout(()=>{w(l,a,P,{maxFiles:40})},120);return()=>window.clearTimeout(L)},[Ue,l,a,x,w,tt,U,r]),c.useEffect(()=>{if(!r)return;if(_.type!=="diff"){_e(null);return}const P=Tr(_.path,_.staged);if(!l||A(l,P)){_e(null);return}let L=!1;const ee=Ut();return _e(null),a.getGitFileDiff(l,{path:_.path,staged:_.staged||void 0}).then(ye=>{L||k(l,P,{original:ye.original??"",modified:ye.modified??"",isBinary:ye.isBinary},ee)}).catch(ye=>{L||_e(ye instanceof Error?ye.message:String(ye))}),()=>{L=!0}},[l,Me,A,a,_,k,r]);const qt=async(P,L)=>{if(l){B(P);try{const ee=ye=>{const We=`${ye.name}/`,gt=p?.tracking?.startsWith(We)?p.tracking.slice(We.length):void 0;return{remote:ye.name,branch:gt,rebase:!0}};if(P==="fetch"){if(!L)throw new Error(i("mobile.changes.noRemote"));await a.gitFetch(l,{remote:L.name}),ue.success(i("gitView.toast.fetchedFromRemote",{name:L.name}))}else if(P==="sync"){if(!L)throw new Error(i("mobile.changes.noRemote"));await a.gitFetch(l,{remote:L.name});const ye=await a.getGitStatus(l);if((ye.behind??0)>0){if((ye.files?.length??0)>0){ue.error(i("gitView.toast.commitOrStashBeforeSync"));return}await a.gitPull(l,ee(L))}((await a.getGitStatus(l)).ahead??0)>0&&await a.gitPush(l),ue.success(i("gitView.toast.alreadyUpToDate"))}await Be(!1),await ot()}catch(ee){ue.error(ee instanceof Error?ee.message:i("gitView.toast.syncActionFailed",{action:i("gitView.sync.syncChanges")}))}finally{B(null)}}},ht=c.useCallback(async(P,L)=>{if(!(!l||P.length===0))try{L==="stage"?P.length>1?await Ri(l,P):await Pi(l,P[0]):P.length>1?await Ai(l,P):await Ti(l,P[0]),await Be(!1)}catch(ee){ue.error(ee instanceof Error?ee.message:i(L==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.unstageFileFailed"))}},[l,Be,i]),Jt=c.useCallback((P,L=!1)=>{F({type:"diff",path:P,staged:L})},[F]),Yt=c.useCallback(async P=>{if(l){J(L=>new Set(L).add(P));try{await a.revertGitFile(l,P),ue.success(i("gitView.toast.revertedFile",{path:P})),await Be(!1)}catch(L){ue.error(L instanceof Error?L.message:i("gitView.toast.revertFailed"))}finally{J(L=>{const ee=new Set(L);return ee.delete(P),ee})}}},[l,a,Be,i]),ys=c.useCallback(async P=>{if(!l||P.length===0||G)return;const L=Array.from(new Set(P));te(!0),J(new Set(L));try{await Promise.all(L.map(ee=>a.revertGitFile(l,ee))),await Be(!1),ue.success(L.length===1?i("gitView.toast.revertedFilesSingle",{count:L.length}):i("gitView.toast.revertedFilesPlural",{count:L.length}))}catch(ee){ue.error(ee instanceof Error?ee.message:i("gitView.toast.revertFailed"))}finally{J(new Set),te(!1)}},[l,a,G,Be,i]),Hs=c.useCallback(P=>{const L=P.map(ee=>ee.trim()).filter(Boolean);if(L.length===0){de([]);return}M(ee=>`${ee.trim()}${ee.trim()?`
|
|
23
|
+
|
|
24
|
+
`:""}${L.join(`
|
|
25
|
+
`)}`.trim()),de([])},[]),vs=c.useCallback(async()=>{if(!l)return;const P=tt.map(L=>L.path).sort();if(P.length===0){ue.error(i("gitView.toast.selectFileToDescribe"));return}se(!0);try{const{message:L}=await tr(l,P);M(L.subject?.trim()??""),de(Array.isArray(L.highlights)?L.highlights:[])}catch(L){ue.error(L instanceof Error?L.message:i("gitView.toast.generateCommitMessageFailed"))}finally{se(!1)}},[l,tt,i]),ws=async(P={})=>{if(!l)return;if(!ne.trim()){ue.error(i("gitView.toast.enterCommitMessage"));return}const L=tt.map(ee=>ee.path).sort();if(L.length===0){ue.error(i("gitView.toast.selectFileToCommit"));return}Z(P.pushAfter?"commitAndPush":"commit");try{if(await a.createGitCommit(l,ne.trim(),{files:L}),ue.success(i("gitView.toast.commitCreated")),M(""),de([]),P.pushAfter){const ee=p?.tracking?.split("/")[0],ye=mt.find(Ss=>Ss.name===ee)??mt[0];if(!ye)throw new Error(i("mobile.changes.noRemote"));B("sync");const We=`${ye.name}/`,gt=p?.tracking?.startsWith(We)?p.tracking.slice(We.length):void 0;await a.gitFetch(l,{remote:ye.name}),((await a.getGitStatus(l)).behind??0)>0&&await a.gitPull(l,{remote:ye.name,branch:gt,rebase:!0}),((await a.getGitStatus(l)).ahead??0)>0&&await a.gitPush(l),await Be(!1),await ot()}else await Be(!1)}catch(ee){ue.error(ee instanceof Error?ee.message:i("gitView.toast.createCommitFailed"))}finally{Z(null),P.pushAfter&&B(null)}},qs=c.useMemo(()=>{const P=[];return tt.length>0&&P.push({id:"staged",title:i("gitView.changes.stagedTitle"),entries:tt,actionSymbol:"-",actionAllLabel:i("gitView.changes.unstageAllAria"),getActionLabel:L=>i("gitView.changes.unstageFileAria",{path:L}),onActionFile:L=>{ht([L],"unstage")},onActionAll:L=>{ht(L,"unstage")},onViewDiff:L=>Jt(L,!0),onRevertFile:Yt,showRevertActions:!1,accent:!0}),Kt.length>0&&P.push({id:"unstaged",title:i("gitView.changes.title"),entries:Kt,actionSymbol:"+",actionAllLabel:i("gitView.changes.stageAllAria"),getActionLabel:L=>i("gitView.changes.stageFileAria",{path:L}),onActionFile:L=>{ht([L],"stage")},onActionAll:L=>{ht(L,"stage")},onViewDiff:L=>Jt(L,!1),onRevertFile:Yt}),P},[Yt,Jt,ht,tt,i,Kt]),Xt=P=>t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[s?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":i("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(X,{name:"close",className:"size-5"})}):null,t.jsxs("div",{className:"min-w-0 flex-1 px-1",children:[t.jsx("h2",{className:"typography-ui-label text-foreground",children:i("mobile.nav.changes")}),t.jsx("p",{className:"truncate typography-micro text-muted-foreground",children:p?.current||l||""})]}),u===!1&&Array.isArray(d)&&d.length>0?t.jsx(La,{repositories:d,selectedRepository:f??null,onSelectRepository:L=>{n&&S(n,L)},repositoryRoot:n??void 0}):null]}),t.jsx("div",{className:"min-h-0 flex-1",children:P})]});if(!l)return Xt(t.jsx(st,{message:i("gitView.empty.selectSessionOrDirectory")}));if(u===!1&&h!==!0)return Xt(t.jsx($a,{rootIsGitRepo:u,resolvedIsGitRepo:h,nestedRepos:d,onRetryDiscovery:()=>{n&&T(n,{force:!0})}}));if(y&&h===null)return Xt(t.jsx(st,{loading:!0,message:i("gitView.loading.checkingRepository")}));if(_.type==="diff")return t.jsx(Ir,{path:_.path,diff:gs,fileExists:!!Gs,error:Ne,onBack:()=>F({type:"list"}),onRetry:()=>Je(P=>P+1)});const js=i(x==="pr"?"session.githubIntegration.tabs.pullRequests":x==="branch"?"diffView.scope.branch":x==="commit"?"commitComparison.mode":"mobile.nav.changes"),ks=x==="branch"&&$e.base?za($e.base):x==="commit"?Qe?.slice(0,8):x==="pr"&&et?`#${et.number}`:null;if(nt&&rt)return t.jsx(Ir,{path:nt,subtitle:[js,ks].filter(Boolean).join(" · "),diff:rt.status==="ready"?rt.diff:null,fileExists:!we.files||we.files.some(P=>P.path===nt),error:we.error??(rt.status==="error"?rt.message:null),onBack:()=>F(Tt),onRetry:()=>{we.error&&we.refresh(),Vs(P=>P+1)}});const Js=()=>x==="pr"&&!et?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx(st,{loading:at.loading,message:at.error??(at.loading?i("session.githubPrPicker.loading.pullRequests"):i("pullRequestComparison.select"))}),!at.loading&&t.jsx(or,{mobile:!0,comparison:at})]}):x==="branch"&&!$e.base?t.jsx(st,{loading:!$e.resolved,message:$e.resolved?i("gitView.pr.toast.baseBranchRequired"):i("diffView.branch.resolvingBase")}):x==="commit"&&!Qe?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[Fe.loading&&t.jsx(X,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}),t.jsx("p",{className:"typography-ui-label text-muted-foreground",children:Fe.loading?i("diffView.state.loadingChanges"):Fe.error??i("commitComparison.noCommits")}),Fe.error&&t.jsx(he,{variant:"outline",size:"lg",onClick:()=>{Fe.refresh()},children:i("diffView.actions.retry")})]}):we.error?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 px-6 text-center",children:[t.jsx("p",{className:"typography-ui-label font-semibold",children:i("diffView.state.failedToLoadDiff")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:we.error}),t.jsx(he,{variant:"outline",size:"lg",onClick:()=>{we.refresh()},children:i("diffView.actions.retry")})]}):ct?ct.length===0?t.jsx(st,{icon:x==="branch",message:x==="pr"?i("walkthrough.blocked.emptyDiff.description"):x==="commit"?i("commitComparison.emptyDiff"):i("diffView.branch.empty",{base:ks??""})}):t.jsx(Eu,{files:ct,onSelect:P=>{we.key&&F({type:"comparison",path:P,sourceKey:we.key})}}):t.jsx(st,{loading:!0,message:i("diffView.state.loadingChanges")});return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex shrink-0 flex-wrap items-center gap-2 border-b border-border/60 px-3 py-2",children:[s?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":i("mobile.surface.closeAria"),onClick:s,style:{touchAction:"manipulation"},children:t.jsx(X,{name:"close",className:"size-5"})}):null,t.jsxs(Ii,{open:K,onOpenChange:N,children:[t.jsx(Di,{asChild:!0,children:t.jsxs(he,{variant:"outline",className:_i({size:"default"}),"data-mobile-comparison-trigger":!0,"aria-label":i("diffView.scope.selectorAria"),children:[t.jsx("span",{children:js}),t.jsx(X,{name:"arrow-down-s",className:"size-4"})]})}),t.jsx(Mi,{align:"start",children:t.jsxs(zi,{value:x,onValueChange:P=>{(P==="working"||P==="branch"||P==="commit"||P==="pr")&&V(P)},children:[t.jsx(Es,{value:"working",className:"min-h-8 items-center",children:i("mobile.nav.changes")}),Pe&&t.jsx(Es,{value:"branch",className:"min-h-8 items-center",children:i("diffView.scope.branch")}),t.jsx(Es,{value:"commit",className:"min-h-8 items-center",children:i("commitComparison.mode")}),t.jsx(Es,{value:"pr",className:"min-h-8 items-center",children:i("session.githubIntegration.tabs.pullRequests")})]})})]}),r&&x==="branch"&&t.jsx(kl,{mobile:!0,branches:g?.all??[],currentBranch:ce,base:$e.base,onSelect:P=>{ce&&Ee(l,ce,P)}},JSON.stringify([b,ce])),r&&x==="commit"&&t.jsx(Sl,{mobile:!0,commits:Fe.commits,selectedHash:Qe,loading:Fe.loading,error:Fe.error,onSelect:Fe.select,onRefresh:()=>{Fe.refresh()}},JSON.stringify([b,ce])),r&&x==="pr"&&t.jsxs(t.Fragment,{children:[t.jsx(or,{mobile:!0,comparison:at},JSON.stringify([b,ce])),et&&t.jsx(he,{variant:"ghost",size:"sm",disabled:we.loading,"aria-label":i("session.githubIssuePicker.actions.refresh"),onClick:()=>{we.refresh()},children:t.jsx(X,{name:"refresh",className:"size-4"})})]})]}),x==="working"&&t.jsxs("div",{className:"flex shrink-0 items-center gap-2 px-3 py-2",children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx(Oa,{currentBranch:p?.current,localBranches:Ht,remoteBranches:bs,branchInfo:g?.branches,currentBranchAhead:p?.ahead,onCheckout:P=>{xs(P)},onCreate:Ks,remotes:mt,disabled:y,directory:l,switchBlockedNotice:(p?.files?.length??0)>0?i("gitView.branch.switchBlockedNotice"):null})}),t.jsx(Ba,{syncAction:I,remotes:mt,onFetch:P=>{qt("fetch",P)},onSync:P=>{qt("sync",P)},disabled:Q!==null||y,aheadCount:p?.ahead??0,behindCount:p?.behind??0,trackingRemoteName:p?.tracking?.split("/")[0],hasUncommittedChanges:Ue.length>0})]}),x!=="working"?t.jsx("div",{className:"min-h-0 flex-1",children:Js()}):Ue.length>0?t.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden px-4 pt-4",children:t.jsx(pl,{groups:qs,diffStats:p?.diffStats,revertingPaths:W,onRevertAll:ys,isRevertingAll:G,headerBackgroundClassName:"bg-transparent",onVisiblePathsChange:ie})}),t.jsx("div",{className:"shrink-0 border-t border-border/70 px-4 pb-4 pt-3",children:t.jsx(hl,{stagedCount:tt.length,commitMessage:ne,onCommitMessageChange:M,generatedHighlights:ae,onInsertHighlights:Hs,onGenerateMessage:vs,isGeneratingMessage:re,onCommit:()=>{ws({pushAfter:!1})},onCommitAndPush:()=>{ws({pushAfter:!0})},commitAction:Q,gitmojiEnabled:!1,onOpenGitmojiPicker:()=>{}})})]}):t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(st,{icon:!0,message:i("gitView.empty.cleanTitle"),description:i("mobile.changes.cleanDescription")})}),t.jsx(gl,{open:Ce!==null,onOpenChange:P=>{P||Ie(null)},targetBranch:Ce??"",changedFileCount:p?.files?.length??0,onCommitAndSwitch:async(P,L)=>{const ee=Ce;if(!ee||!l)return;const ye=p?.current??null;await a.createGitCommit(l,P,{addAll:!0});let We=null;if(L){const gt=p?.tracking?.split("/")[0],bt=mt.find(Qt=>Qt.name===gt)??mt[0];try{if(!bt)throw new Error(i("mobile.changes.noRemote"));await a.gitPush(l,p?.tracking?{remote:bt.name}:{remote:bt.name,branch:ye??void 0,options:["--set-upstream"]}),We=bt.name}catch{ue.error(i("gitView.dirtySwitch.pushFailed")),await Be(),Ie(null);return}}ue.success(ye?We?i("gitView.toast.pushedToUpstream",{name:We}):i("gitView.dirtySwitch.committedNotPushed",{branch:ye}):i("gitView.toast.commitCreated")),await Be(),Ie(null),await Et(ee)},onGenerateMessage:async()=>{if(!l)return"";const P=(p?.files??[]).map(ee=>ee.path).sort(),{message:L}=await tr(l,P);return L.subject?.trim()??""},onRevertAndSwitch:async()=>{const P=Ce;if(!P||!l)return;await ys((p?.files??[]).map(ee=>ee.path));const L=await a.getGitStatus(l);if(!L.isClean&&(L.files?.length??0)>0){ue.error(i("gitView.dirtySwitch.revertIncomplete"));return}Ie(null),await Et(P)}})]})},st=n=>{const e=le.c(13),{message:s,description:o,loading:r,icon:i}=n,a=r===void 0?!1:r,u=i===void 0?!1:i;let f;e[0]!==a?(f=a?t.jsx(X,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):null,e[0]=a,e[1]=f):f=e[1];let d;e[2]!==u?(d=u?t.jsx(X,{name:"git-branch",className:"size-6 text-muted-foreground"}):null,e[2]=u,e[3]=d):d=e[3];let l;e[4]!==s?(l=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:s}),e[4]=s,e[5]=l):l=e[5];let p;e[6]!==o?(p=o?t.jsx("p",{className:"typography-meta text-muted-foreground",children:o}):null,e[6]=o,e[7]=p):p=e[7];let g;return e[8]!==f||e[9]!==d||e[10]!==l||e[11]!==p?(g=t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[f,d,l,p]})}),e[8]=f,e[9]=d,e[10]=l,e[11]=p,e[12]=g):g=e[12],g},Ir=n=>{const e=le.c(29),{path:s,subtitle:o,diff:r,fileExists:i,error:a,onBack:u,onRetry:f}=n,{t:d}=fe();let l;e[0]!==s?(l=Oi(s)||"text",e[0]=s,e[1]=l):l=e[1];const p=l;let g;e[2]!==d?(g=d("header.actions.backAria"),e[2]=d,e[3]=g):g=e[3];let h;e[4]===Symbol.for("react.memo_cache_sentinel")?(h=t.jsx(X,{name:"arrow-left",className:"size-5"}),e[4]=h):h=e[4];let y;e[5]!==u||e[6]!==g?(y=t.jsx("button",{type:"button",className:"flex size-9 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":g,onClick:u,children:h}),e[5]=u,e[6]=g,e[7]=y):y=e[7];let j;e[8]!==s?(j=t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:s}),e[8]=s,e[9]=j):j=e[9];let v;e[10]!==o?(v=o&&t.jsx("p",{className:"truncate typography-meta text-muted-foreground",children:o}),e[10]=o,e[11]=v):v=e[11];let T;e[12]!==j||e[13]!==v?(T=t.jsxs("div",{className:"min-w-0 flex-1 px-2",children:[j,v]}),e[12]=j,e[13]=v,e[14]=T):T=e[14];let S;e[15]!==y||e[16]!==T?(S=t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-3 border-b border-border/70 px-3 text-foreground",children:[y,T]}),e[15]=y,e[16]=T,e[17]=S):S=e[17];let E;e[18]!==r||e[19]!==a||e[20]!==i||e[21]!==p||e[22]!==f||e[23]!==s||e[24]!==d?(E=t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:i?a?t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-3",children:[t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:d("mobile.changes.diffDetail.loadFailed")}),t.jsx("p",{className:"typography-meta text-muted-foreground",children:a}),t.jsx(he,{type:"button",size:"sm",variant:"outline",onClick:f,children:d("diffView.actions.retry")})]})}):r?r.isBinary?t.jsx(st,{icon:!0,message:d("diffView.binary.unavailable")}):Bi(s)&&!r.fileDiff?t.jsx(st,{icon:!0,message:d("mobile.changes.diffDetail.imageUnavailable")}):t.jsx($s,{className:"h-full overflow-y-auto overflow-x-hidden p-3","data-diff-virtual-root":!0,"data-diff-virtual-content":!0,children:t.jsx(Pl,{original:r.original,modified:r.modified,fileDiff:r.fileDiff,language:p,fileName:s,renderSideBySide:!1,wrapLines:!0,layout:"inline"})}):t.jsx(st,{loading:!0,message:d("diffView.state.loadingDiff")}):t.jsx(st,{icon:!0,message:d("mobile.changes.diffDetail.missingTitle"),description:d("mobile.changes.diffDetail.missingDescription")})}),e[18]=r,e[19]=a,e[20]=i,e[21]=p,e[22]=f,e[23]=s,e[24]=d,e[25]=E):E=e[25];let D;return e[26]!==S||e[27]!==E?(D=t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[S,E]}),e[26]=S,e[27]=E,e[28]=D):D=e[28],D},Eu=n=>{const e=le.c(12),{files:s,onSelect:o}=n,{t:r}=fe();let i;e[0]!==r?(i=r("gitView.changes.changedFilesAria"),e[0]=r,e[1]=i):i=e[1];let a;if(e[2]!==s||e[3]!==o||e[4]!==r){let f;e[6]!==o||e[7]!==r?(f=d=>{const l=d.status==="A"?r("diffView.change.new"):d.status==="D"?r("diffView.change.deleted"):d.status==="R"?r("diffView.change.renamed"):d.status==="C"?r("diffView.change.copied"):r("diffView.change.modified"),p=d.status==="A"?"var(--status-success)":d.status==="D"?"var(--status-error)":d.status==="R"||d.status==="C"?"var(--status-info)":"var(--status-warning)";return t.jsx("li",{children:t.jsxs(he,{variant:"ghost",size:"lg",className:"w-full justify-start gap-2.5 text-left normal-case",onClick:()=>o(d.path),children:[t.jsx("span",{className:"w-4 shrink-0 text-center typography-meta font-semibold uppercase",style:{color:p},"aria-label":l,children:d.status}),t.jsx(ro,{filePath:d.path,className:"size-4 shrink-0"}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label",title:d.path,children:d.path}),(d.insertions>0||d.deletions>0)&&t.jsxs("span",{className:"shrink-0 typography-meta text-muted-foreground",children:["+",d.insertions," -",d.deletions]}),t.jsx(X,{name:"arrow-right-s",className:"size-4 shrink-0 text-muted-foreground"})]})},d.path)},e[6]=o,e[7]=r,e[8]=f):f=e[8],a=s.map(f),e[2]=s,e[3]=o,e[4]=r,e[5]=a}else a=e[5];let u;return e[9]!==i||e[10]!==a?(u=t.jsx($s,{className:"h-full overflow-y-auto overflow-x-hidden px-3 py-2",children:t.jsx("ul",{"aria-label":i,className:"flex flex-col gap-1",children:a})}),e[9]=i,e[10]=a,e[11]=u):u=e[11],u},Ru=c.lazy(()=>Bt(()=>import("./FilesView-lrP5OlzK.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124])).then(n=>({default:n.FilesView}))),Nt=n=>(n||"").replace(/\\/g,"/").replace(/\/+$/g,""),ds=n=>{const e=Nt(n);return!e||e==="/"?e||"/":e.split("/").filter(Boolean).at(-1)??e},Pu=n=>{const e=Nt(n);if(!e||e==="/")return null;const s=e.lastIndexOf("/");return s<=0?e.startsWith("/")?"/":null:e.slice(0,s)},Au=(n,e)=>{const s=Nt(n),o=Nt(e);return!o||s===o?ds(s):s.startsWith(`${o}/`)?s.slice(o.length+1):s},Tu=n=>{if(typeof n!="number"||!Number.isFinite(n)||n<0)return"";if(n<1024)return`${n} B`;const e=["KB","MB","GB"];let s=n/1024;for(const o of e){if(s<1024||o===e[e.length-1])return`${s.toFixed(s>=10?0:1)} ${o}`;s/=1024}return""},Iu=({onClose:n})=>{const{t:e}=fe(),{files:s}=yn(),o=Vo(N=>N.setSelectedPath),r=Nt(vn()??null),[i,a]=c.useState(()=>({type:"browser",directory:r})),[u,f]=c.useState([]),[d,l]=c.useState(!1),[p,g]=c.useState(null),[h,y]=c.useState(""),[j,v]=c.useState([]),[T,S]=c.useState(!1),E=c.useRef(0);c.useEffect(()=>{r&&a(N=>N.type==="browser"&&N.directory?N:{type:"browser",directory:r})},[r]);const D=i.type==="browser"?i.directory:i.returnDirectory,w=c.useCallback(async N=>{if(!N)return;const V=E.current+1;E.current=V,l(!0),g(null);try{const F=await s.listDirectory(N);if(E.current!==V)return;f(F.entries.slice().sort((I,B)=>I.isDirectory!==B.isDirectory?I.isDirectory?-1:1:I.name.localeCompare(B.name)))}catch(F){if(E.current!==V)return;f([]),g(F instanceof Error?F.message:e("mobile.files.error.listFailed"))}finally{E.current===V&&l(!1)}},[s,e]);c.useEffect(()=>{i.type==="browser"&&w(i.directory)},[w,i]),c.useEffect(()=>{if(i.type!=="browser")return;const N=h.trim();if(!N){v([]),S(!1);return}let V=!1;const F=window.setTimeout(()=>{S(!0),s.search({directory:i.directory,query:N,maxResults:40}).then(I=>{V||v(I)}).catch(()=>{V||v([])}).finally(()=>{V||S(!1)})},250);return()=>{V=!0,window.clearTimeout(F)}},[s,h,i]);const A=N=>{y(""),a({type:"browser",directory:N})},k=N=>{o(r,N),a({type:"file",path:N,returnDirectory:D||r})},R=dt(N=>N.pendingFileFocusPath),b=dt(N=>N.pendingFileNavigation);if(c.useEffect(()=>{const N=Nt(b?.path??R??"");!N||!r||N!==r&&!N.startsWith(`${r}/`)||(o(r,N),a({type:"file",path:N,returnDirectory:r}),R&&dt.getState().setPendingFileFocusPath(null))},[R,b,r,o]),!r)return t.jsx(fs,{message:e("mobile.files.empty.noDirectory")});if(i.type==="file")return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 border-b border-border/70 px-3 text-foreground",children:[t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-lg text-muted-foreground hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":e("header.actions.backAria"),onClick:()=>a({type:"browser",directory:i.returnDirectory}),style:{touchAction:"manipulation"},children:t.jsx(nr,{className:"size-5"})}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("h2",{className:"truncate typography-ui-header text-foreground",children:ds(i.path)})})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:t.jsx(qe,{children:t.jsx(c.Suspense,{fallback:t.jsx(fs,{loading:!0,message:e("filesView.state.loading")}),children:t.jsx(Ru,{mode:"editor-only"})})})})]});const O=i.directory===r?e("mobile.files.rootDirectory"):ds(i.directory),z=h.trim()?j:[],C=Pu(i.directory),x=i.directory!==r&&C!==null&&(C===r||C.startsWith(`${r}/`)),_=x&&!h.trim(),K=x?C:null;return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsxs("header",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3 text-foreground",children:[n?t.jsx("button",{type:"button",className:"-ml-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":e("mobile.surface.closeAria"),onClick:n,style:{touchAction:"manipulation"},children:t.jsx(al,{className:"size-5"})}):null,_&&K?t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":e("mobile.files.backToParentAria",{name:ds(K)}),onClick:()=>A(K),style:{touchAction:"manipulation"},children:t.jsx(nr,{className:"size-5"})}):null,t.jsx("div",{className:"min-w-0 flex-1 px-1",children:t.jsx("h2",{className:"truncate typography-ui-label text-foreground",children:O})}),t.jsx("button",{type:"button",className:"flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":e("mobile.files.refreshAria"),onClick:()=>{w(i.directory)},style:{touchAction:"manipulation"},children:t.jsx(ll,{className:Y("size-5",d&&"animate-spin")})})]}),t.jsx("div",{className:"shrink-0 px-4 pb-2 pt-1",children:t.jsxs("div",{className:"relative",children:[t.jsx(cl,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground"}),t.jsx(eo,{value:h,onChange:N=>y(N.target.value),placeholder:e("mobile.files.search.placeholder"),className:"h-11 pl-9"})]})}),t.jsx($s,{className:"min-h-0 flex-1 overflow-y-auto px-4 pb-3",children:p?t.jsx(fs,{message:p}):h.trim()?t.jsx(Du,{results:z,isSearching:T,onOpenFile:k}):t.jsxs("div",{className:"overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",children:[u.length===0&&!d?t.jsx("div",{className:"px-4 py-8 text-center typography-body text-muted-foreground",children:e("mobile.files.empty.directory")}):null,u.map(N=>t.jsx(_o,{name:N.name,path:N.path,directory:N.isDirectory,meta:N.isDirectory?void 0:Tu(N.size),onClick:()=>N.isDirectory?A(N.path):k(N.path)},N.path))]})})]})},_o=n=>{const e=le.c(16),{name:s,path:o,directory:r,meta:i,onClick:a}=n;let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u={touchAction:"manipulation"},e[0]=u):u=e[0];let f;e[1]!==r||e[2]!==o?(f=r?t.jsx(ul,{className:"size-5 shrink-0 text-primary/80"}):t.jsx(ro,{filePath:o,className:"size-5 shrink-0"}),e[1]=r,e[2]=o,e[3]=f):f=e[3];let d;e[4]!==s?(d=t.jsx("span",{className:"block min-w-0 flex-1 truncate typography-ui-label text-foreground",children:s}),e[4]=s,e[5]=d):d=e[5];let l;e[6]!==i?(l=i?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:i}):null,e[6]=i,e[7]=l):l=e[7];let p;e[8]!==r?(p=r?t.jsx(dl,{className:"size-4 shrink-0 text-muted-foreground/60"}):null,e[8]=r,e[9]=p):p=e[9];let g;return e[10]!==a||e[11]!==f||e[12]!==d||e[13]!==l||e[14]!==p?(g=t.jsxs("button",{type:"button",className:"flex min-h-14 w-full items-center gap-3 border-b border-border/70 px-3 py-2.5 text-left transition-colors last:border-b-0 hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset",onClick:a,style:u,children:[f,d,l,p]}),e[10]=a,e[11]=f,e[12]=d,e[13]=l,e[14]=p,e[15]=g):g=e[15],g},Du=n=>{const e=le.c(10),{results:s,isSearching:o,onOpenFile:r}=n,{t:i}=fe(),a=Nt(vn()??null);if(o){let l;e[0]!==i?(l=i("common.loading"),e[0]=i,e[1]=l):l=e[1];let p;return e[2]!==l?(p=t.jsx(fs,{loading:!0,message:l}),e[2]=l,e[3]=p):p=e[3],p}if(s.length===0){let l;e[4]!==i?(l=i("mobile.files.search.empty"),e[4]=i,e[5]=l):l=e[5];let p;return e[6]!==l?(p=t.jsx(fs,{message:l}),e[6]=l,e[7]=p):p=e[7],p}const u="overflow-hidden rounded-2xl border border-border/70 bg-[var(--surface-elevated)]",f=s.map(l=>t.jsx(_o,{name:ds(l.path),path:l.path,directory:!1,meta:Au(l.path,a),onClick:()=>r(l.path)},l.path));let d;return e[8]!==f?(d=t.jsx("div",{className:u,children:f}),e[8]=f,e[9]=d):d=e[9],d},fs=n=>{const e=le.c(7),{message:s,loading:o}=n,r=o===void 0?!1:o;let i;e[0]!==r?(i=r?t.jsx(fl,{className:"size-5 animate-spin text-muted-foreground"}):t.jsx(ml,{className:"size-6 text-muted-foreground"}),e[0]=r,e[1]=i):i=e[1];let a;e[2]!==s?(a=t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:s}),e[2]=s,e[3]=a):a=e[3];let u;return e[4]!==i||e[5]!==a?(u=t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[i,a]})}),e[4]=i,e[5]=a,e[6]=u):u=e[6],u},Dr="mobile-surface-root",_u=16,_r=320,Mu="cubic-bezier(0.22, 1, 0.36, 1)",zu=n=>{const e=le.c(36),{onOpenMcpSettings:s}=n,{t:o}=fe(),[r,i]=c.useState(!1),a=jt(Ou),u=rs(Bu),f=Mt(Lu);let d;e[0]!==a||e[1]!==r||e[2]!==f||e[3]!==u?(d=()=>{if(r)return;i(!0);const O=new Promise($u);Promise.all([u({directory:a||null,silent:!0}),f({force:!0}),O]).finally(()=>i(!1))},e[0]=a,e[1]=r,e[2]=f,e[3]=u,e[4]=d):d=e[4];const l=d;let p;e[5]!==o?(p=o("settings.mcp.sidebar.actions.addServerTitle"),e[5]=o,e[6]=p):p=e[6];let g;e[7]!==o?(g=o("settings.mcp.sidebar.actions.addServerTitle"),e[7]=o,e[8]=g):g=e[8];let h,y;e[9]===Symbol.for("react.memo_cache_sentinel")?(h={touchAction:"manipulation"},y=t.jsx(X,{name:"add",className:"size-5"}),e[9]=h,e[10]=y):(h=e[9],y=e[10]);let j;e[11]!==s||e[12]!==p||e[13]!==g?(j=t.jsx("button",{type:"button",className:"flex size-10 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:s,"aria-label":p,title:g,style:h,children:y}),e[11]=s,e[12]=p,e[13]=g,e[14]=j):j=e[14];let v;e[15]!==o?(v=o("mcpDropdown.actions.refreshAria"),e[15]=o,e[16]=v):v=e[16];let T;e[17]!==o?(T=o("mcpDropdown.actions.refreshAria"),e[17]=o,e[18]=T):T=e[18];let S;e[19]===Symbol.for("react.memo_cache_sentinel")?(S={touchAction:"manipulation"},e[19]=S):S=e[19];const E=r&&"animate-spin";let D;e[20]!==E?(D=Y("size-5",E),e[20]=E,e[21]=D):D=e[21];let w;e[22]!==D?(w=t.jsx(X,{name:"refresh",className:D}),e[22]=D,e[23]=w):w=e[23];let A;e[24]!==r||e[25]!==l||e[26]!==w||e[27]!==v||e[28]!==T?(A=t.jsx("button",{type:"button",className:"flex size-10 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground disabled:opacity-60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",onClick:l,disabled:r,"aria-label":v,title:T,style:S,children:w}),e[24]=r,e[25]=l,e[26]=w,e[27]=v,e[28]=T,e[29]=A):A=e[29];let k;e[30]!==A||e[31]!==j?(k=t.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-1 px-2 pt-1",children:[j,A]}),e[30]=A,e[31]=j,e[32]=k):k=e[32];let R;e[33]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(wu,{active:!0,className:"h-full",listClassName:"max-h-none",hideHeader:!0,mobileListDensity:!0})}),e[33]=R):R=e[33];let b;return e[34]!==k?(b=t.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[k,R]}),e[34]=k,e[35]=b):b=e[35],b},Mr=({open:n,onClose:e,tab:s,onTabChange:o,pendingChangesDiff:r,onOpenPlan:i,onOpenMcpSettings:a,variant:u="drawer"})=>{const{t:f}=fe(),d=c.useRef(null),l=c.useRef(null),[p,g]=c.useState(!1),[h,y]=c.useState(n),j=c.useRef(e);c.useEffect(()=>{j.current=e},[e]);const v=c.useRef(s);c.useEffect(()=>{v.current=s},[s]),Fn(l,{enabled:u==="drawer"&&n,onLeftEdgeSwipe:()=>j.current()});const[T,S]=c.useState(()=>new Set);if(c.useEffect(()=>{n&&S(w=>{if(w.has(s))return w;const A=new Set(w);return A.add(s),A})},[n,s]),typeof document<"u"&&!d.current){let w=document.getElementById(Dr);w||(w=document.createElement("div"),w.id=Dr,document.body.appendChild(w)),d.current=w}if(c.useEffect(()=>{if(n){y(!0);const A=window.setTimeout(()=>g(!0),_u);return()=>window.clearTimeout(A)}g(!1);const w=window.setTimeout(()=>y(!1),_r+40);return()=>window.clearTimeout(w)},[n]),c.useEffect(()=>{if(!n)return;const w=document.body.style.overflow;u==="drawer"&&(document.body.style.overflow="hidden");const A=k=>{k.key!=="Escape"||v.current==="terminal"||$i(k.target)||j.current()};return document.addEventListener("keydown",A),()=>{u==="drawer"&&(document.body.style.overflow=w),document.removeEventListener("keydown",A)}},[n,u]),u==="drawer"&&!d.current)return null;const E=[{id:"changes",label:f("mobile.menu.changes"),icon:t.jsx(X,{name:"git-branch",className:"h-3.5 w-3.5"})},{id:"files",label:f("mobile.menu.files"),icon:t.jsx(X,{name:"file-text",className:"h-3.5 w-3.5"})},{id:"terminal",label:f("mobile.menu.terminal"),icon:t.jsx(X,{name:"terminal",className:"h-3.5 w-3.5"})},{id:"notes",label:f("contextRail.surface.notes"),icon:t.jsx(X,{name:"sticky-note",className:"h-3.5 w-3.5"})},{id:"mcp",label:f("mobile.menu.mcp"),icon:t.jsx(Li,{className:"h-3.5 w-3.5"})}],D=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-[var(--oc-header-height,56px)] shrink-0 items-center gap-2 px-3",children:[t.jsx("div",{className:"flex h-9 min-w-0 flex-1 items-center",children:h?t.jsx(Fa,{items:E,activeId:s,onSelect:w=>o(w),layoutMode:"fit",variant:"active-pill",nonCompositedIndicator:!0,inactiveTabsIconOnly:!0,className:"h-full"}):null}),t.jsx("button",{type:"button",className:"-mr-1 flex size-10 shrink-0 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":f("mobile.surface.closeAria"),onClick:e,style:{touchAction:"manipulation"},children:t.jsx(X,{name:"close",className:"size-5"})})]}),t.jsxs("div",{className:"min-h-0 flex-1 overflow-hidden",children:[T.has("changes")?t.jsx("div",{className:Y("h-full",s!=="changes"&&"hidden"),children:t.jsx(qe,{children:t.jsx(Nu,{visible:n&&s==="changes",initialDiff:r})})},r?`changes:${r.path}:${r.staged}`:"changes"):null,T.has("files")?t.jsx("div",{className:Y("h-full",s!=="files"&&"hidden"),children:t.jsx(qe,{children:t.jsx(Iu,{})})}):null,T.has("terminal")?t.jsx("div",{className:Y("h-full",s!=="terminal"&&"hidden"),children:t.jsx(qe,{children:t.jsx(Wa,{visible:n&&s==="terminal"})})}):null,T.has("notes")?t.jsx("div",{className:Y("h-full",s!=="notes"&&"hidden"),children:t.jsx(qe,{children:t.jsx(Ua,{onActionComplete:e,onOpenPlan:i})})}):null,T.has("mcp")?t.jsx("div",{className:Y("h-full",s!=="mcp"&&"hidden"),children:t.jsx(qe,{children:t.jsx(zu,{onOpenMcpSettings:a})})}):null]})]});return u==="panel"?t.jsx("div",{className:"flex h-full min-h-0 flex-col bg-background text-foreground",children:D}):Ot.createPortal(t.jsx("section",{ref:l,role:"dialog","aria-modal":"true","aria-label":f("mobile.header.openWorkspaceAria"),"aria-hidden":!n,className:"oc-keyboard-inset-surface oc-bottom-safe-surface fixed inset-0 z-50 flex flex-col bg-background text-foreground",style:{paddingTop:"var(--oc-safe-area-top, 0px)",transform:p?"none":"translateX(100%)",transition:`transform ${_r}ms ${Mu}`,visibility:h?"visible":"hidden",pointerEvents:n?"auto":"none"},children:D}),d.current)};function Ou(n){return n.currentDirectory}function Bu(n){return n.refresh}function Lu(n){return n.loadMcpConfigs}function $u(n){return window.setTimeout(n,500)}function Fu(n){const e=le.c(4),s=2500,{uiFont:o}=Fi(),[r,i]=c.useState(!1);let a,u;return e[0]!==s||e[1]!==o?(a=()=>{let f=!1;const d=()=>{f||i(!0)},l=()=>{requestAnimationFrame(()=>requestAnimationFrame(d))},p=Promise.all([Wi(o).catch(Ku),document.fonts?.ready?.then(Gu).catch(Vu)??Promise.resolve(),Al.catch(Uu)]).then(Wu),g=new Promise(h=>{window.setTimeout(h,s)});return Promise.race([p,g]).then(l),()=>{f=!0}},u=[o,s],e[0]=s,e[1]=o,e[2]=a,e[3]=u):(a=e[2],u=e[3]),c.useEffect(a,u),r}function Wu(){}function Uu(){}function Vu(){}function Gu(){}function Ku(){}const Hu="aiworker",qu=n=>n.replace(/^\/+|\/+$/g,""),Ju=n=>{const e=qu(n.pathname).split("/").filter(Boolean);return n.host?[n.host,...e]:e};function Yu(n){if(typeof n!="string"||n.length===0)return null;let e;try{e=new URL(n)}catch{return null}if(e.protocol!==`${Hu}:`)return null;const s=Ju(e),o=(s[0]??"").toLowerCase(),r=s.slice(1),i=e.searchParams;switch(o){case"session":{const a=r[0]||i.get("id")||"";return a?{type:"session",sessionId:a,directory:i.get("dir")??void 0}:null}case"new":case"new-session":return{type:"new-session",directory:i.get("dir")??void 0,projectId:i.get("project")??void 0,agent:i.get("agent")??void 0,model:i.get("model")??void 0};case"sessions":{const a=i.get("filter");return{type:"sessions",filter:a==="attention"||a==="recent"||a==="all"?a:void 0}}case"status":return{type:"status"};case"settings":return{type:"settings",section:r[0]||i.get("section")||void 0};case"changes":return{type:"changes",path:r.join("/")||i.get("path")||void 0,staged:i.get("staged")==="true"};case"view":{const a=(r[0]||"").toLowerCase();return a==="changes"?{type:"changes"}:a==="files"||a==="mcp"||a==="instances"||a==="update"?{type:"view",target:a}:null}default:return null}}let Ke={},Mo=!1,us=null;const Xu=n=>{switch(n.type){case"session":return Se.getState().setCurrentSession(n.sessionId,n.directory??null),!0;case"new-session":{const e=Se.getState();return e.openNewSessionDraft(),(n.directory||n.projectId)&&e.setNewSessionDraftTarget({directoryOverride:n.directory??null,projectId:n.projectId??null,selectedProjectId:n.projectId??null}),!0}case"sessions":return Ke.openSessions?(Ke.openSessions(n.filter),!0):!1;case"status":return Ke.openSessions?(Ke.openSessions(),!0):!1;case"view":return Ke.openView?(Ke.openView(n.target),!0):!1;case"changes":return Ke.openChanges?(Ke.openChanges({path:n.path,staged:n.staged}),!0):!1;case"settings":return Ke.openSettings?(Ke.openSettings(n.section),!0):!1}},Wn=()=>{if(!Mo||!us)return;const n=us;us=null,Xu(n)||(us=n)},zo=n=>{us=n,Wn()},zr=n=>{const e=Yu(n);e&&zo(e)},Qu=n=>{Mo=n,Wn()},Zu=n=>{const e=le.c(3);let s,o;e[0]!==n?(s=()=>(Ke=n,Wn(),()=>{Ke===n&&(Ke={})}),o=[n],e[0]=n,e[1]=s,e[2]=o):(s=e[1],o=e[2]),c.useEffect(s,o)},ed=n=>{const{ready:e}=n;c.useEffect(()=>{Qu(e)},[e]),c.useEffect(()=>{if(!Oe())return;let s=!1;const o=[];return Bt(()=>import("./vendor-capacitor-app-BrDJj9I_.js"),__vite__mapDeps([125,5,126])).then(async({App:r})=>{if(s)return;const i=await r.addListener("appUrlOpen",a=>{zr(a?.url)});if(s){i.remove();return}o.push(()=>{i.remove()})}).catch(()=>{}),Bt(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([127,126])).then(async({PushNotifications:r})=>{if(s)return;const i=await r.addListener("pushNotificationActionPerformed",a=>{const u=a?.notification?.data,f=typeof u?.url=="string"?u.url:typeof u?.deeplink=="string"?u.deeplink:void 0;if(f){zr(f);return}const d=typeof u?.sessionId=="string"?u.sessionId:void 0;d&&zo({type:"session",sessionId:d})});if(s){i.remove();return}o.push(()=>{i.remove()})}).catch(()=>{}),()=>{s=!0,o.forEach(r=>r())}},[])},td=()=>{if(typeof window>"u")return;const n=window.__AIWORKER_APNS_ENV__;if(n==="development")return"sandbox";if(n==="production")return"production"},sd=()=>{if(typeof window>"u")return!1;const e=window.Capacitor?.getPlatform?.();return e==="ios"||e==="android"},nd=n=>{const{enabled:e}=n,s=dt(r=>r.nativeNotificationsEnabled),o=c.useRef(null);c.useEffect(()=>{if(!e||!s||!sd())return;let r=!1;const i=[];return Bt(()=>import("./vendor-capacitor-push-notifications-KNe1zSBF.js"),__vite__mapDeps([127,126])).then(async({PushNotifications:a})=>{if(r)return;let u=await a.checkPermissions().catch(()=>null);if(u?.receive!=="granted"&&(u=await a.requestPermissions().catch(()=>null)),u?.receive!=="granted")return;const f=await a.addListener("registration",l=>{o.current=l.value,Yn()?.push?.registerApnsToken?.({token:l.value,platform:$r(),environment:td()})}),d=await a.addListener("registrationError",l=>{console.warn("[Push] APNs registration error:",l)});if(await a.register().catch(()=>{}),r){f.remove(),d.remove();return}i.push(()=>{f.remove()},()=>{d.remove()})}).catch(()=>{}),()=>{r=!0,i.forEach(a=>a())}},[e,s]),c.useEffect(()=>{if(s)return;const r=o.current;if(!r)return;o.current=null,Yn()?.push?.unregisterApnsToken?.({token:r})},[s])},Or=n=>{const e=le.c(12),{side:s,isResizing:o,ariaLabel:r,handleProps:i}=n,a=s==="left"?"right-0":"left-0";let u;e[0]!==a?(u=Y("absolute inset-y-0 z-50 w-6 cursor-col-resize touch-none",a),e[0]=a,e[1]=u):u=e[1];const f=s==="left"?"right-0":"left-0",d=o&&"bg-[var(--interactive-border)]";let l;e[2]!==f||e[3]!==d?(l=Y("absolute inset-y-0 w-[3px] transition-colors",f,d),e[2]=f,e[3]=d,e[4]=l):l=e[4];let p;e[5]!==l?(p=t.jsx("div",{className:l}),e[5]=l,e[6]=p):p=e[6];let g;return e[7]!==r||e[8]!==i||e[9]!==u||e[10]!==p?(g=t.jsx("div",{className:u,role:"separator","aria-orientation":"vertical","aria-label":r,...i,children:p}),e[7]=r,e[8]=i,e[9]=u,e[10]=p,e[11]=g):g=e[11],g},rd=320,od=380,Br=280,id=560,ad=900;function Lr(n,e,s,o){const r=le.c(23),i=o===void 0?id:o,a=c.useRef(null);let u;r[0]!==s||r[1]!==i||r[2]!==e?(u=()=>{if(typeof window>"u")return s;const x=Number.parseInt(window.localStorage.getItem(e)??"",10);return Number.isFinite(x)?Math.min(i,Math.max(Br,x)):s},r[0]=s,r[1]=i,r[2]=e,r[3]=u):u=r[3];const[f,d]=c.useState(u),[l,p]=c.useState(!1),g=c.useRef(0),h=c.useRef(f),y=c.useRef(null),j=c.useRef(null);let v;r[4]!==i?(v=x=>Math.min(i,Math.max(Br,Math.round(x))),r[4]=i,r[5]=v):v=r[5];const T=v;let S;r[6]===Symbol.for("react.memo_cache_sentinel")?(S=x=>{const _=a.current;_&&(_.style.width=`${x}px`,_.style.minWidth=`${x}px`,_.style.maxWidth=`${x}px`,_.style.setProperty("--oc-ipad-sidebar-width",`${x}px`))},r[6]=S):S=r[6];const E=S;let D;r[7]!==f?(D=x=>{try{x.currentTarget.setPointerCapture(x.pointerId)}catch{}j.current=x.pointerId,g.current=x.clientX,h.current=f,y.current=f,p(!0),x.preventDefault()},r[7]=f,r[8]=D):D=r[8];const w=D;let A;r[9]!==T||r[10]!==n?(A=x=>{if(j.current!==x.pointerId)return;const _=x.clientX-g.current,K=T(h.current+(n==="left"?_:-_));y.current!==K&&(y.current=K,E(K))},r[9]=T,r[10]=n,r[11]=A):A=r[11];const k=A;let R;r[12]!==T||r[13]!==e?(R=x=>{if(j.current!==x.pointerId)return;try{x.currentTarget.releasePointerCapture(x.pointerId)}catch{}const _=T(y.current??h.current);j.current=null,y.current=null,p(!1),d(_);try{window.localStorage.setItem(e,String(_))}catch{}},r[12]=T,r[13]=e,r[14]=R):R=r[14];const b=R;let O;r[15]!==w||r[16]!==b||r[17]!==k?(O={onPointerDown:w,onPointerMove:k,onPointerUp:b,onPointerCancel:b},r[15]=w,r[16]=b,r[17]=k,r[18]=O):O=r[18];const z=O;let C;return r[19]!==z||r[20]!==l||r[21]!==f?(C={asideRef:a,width:f,isResizing:l,handleProps:z},r[19]=z,r[20]=l,r[21]=f,r[22]=C):C=r[22],C}const ld=["general","appearance","chat","notifications","sessions","git","magic-prompts","snippets","behavior","agents","commands","mcp","plugins","skills.installed","skills.catalog","providers","usage","voice","integrations","about"],cd=1e3,ud=({onActiveConnectionDeleted:n})=>{const{t:e}=fe();Ya();const[s,o]=c.useState(!1),[r,i]=c.useState(null),[a,u]=c.useState(!1),[f,d]=c.useState("changes"),[l,p]=c.useState(null),[g,h]=c.useState("nav"),[y,j]=c.useState(null),v=dt(q=>q.setSettingsPage),T=dt(q=>q.wideChatLayoutEnabled),S=Dt(q=>q.available),E=Dt(q=>q.runtimeType),D=c.useMemo(()=>oo(),[]),w=Mt(q=>q.mcpServers),A=Mt(q=>q.setMcpDraft),k=Mt(q=>q.setSelectedMcp),R=c.useCallback(()=>{i(null),p(null)},[]),b=c.useCallback(q=>{i(q)},[]),O=c.useCallback(()=>{u(!1)},[]),z=c.useCallback(q=>{h(q),b("settings")},[b]),{enabled:C,roomyForPanels:x}=bn(),K=ua()==="portrait",N=da(),[V,F]=c.useState(()=>fa().roomyForPanels),I=c.useCallback(()=>{F(q=>!q)},[]);c.useEffect(()=>{C||F(!1)},[C]);const B=c.useCallback(()=>{j(null),d("files"),u(!0)},[]),Q=c.useCallback((q=null)=>{j(q),d("changes"),u(!0)},[]),Z=Lr("left","aiworker.ipad.leftSidebarWidth",rd),ne=Lr("right","aiworker.ipad.rightSidebarWidth",od,ad),M=x,W=M&&a?ne.width:0,J=C&&V?Z.width:0;c.useEffect(()=>{if(typeof document>"u")return;const q=document.documentElement;return q.style.setProperty("--oc-chat-inset-left",`${J}px`),q.style.setProperty("--oc-chat-inset-right",`${W}px`),()=>{q.style.removeProperty("--oc-chat-inset-left"),q.style.removeProperty("--oc-chat-inset-right")}},[J,W]),c.useEffect(()=>{if(typeof document>"u")return;const q=document.documentElement;return q.classList.toggle("wide-chat-layout",T),()=>q.classList.remove("wide-chat-layout")},[T]),c.useEffect(()=>{if(typeof document>"u")return;const q=C&&(K||N),ve=document.documentElement;return ve.classList.toggle("oc-keep-draft-starters",q),()=>ve.classList.remove("oc-keep-draft-starters")},[N,C,K]);const G=c.useMemo(()=>({openChanges:({diffPath:q,staged:ve}={})=>{Q(q?{path:q,staged:ve===!0}:null)},openFiles:()=>B(),openSettings:()=>z("nav")}),[Q,B,z]),te=c.useMemo(()=>({openSessions:()=>{C?F(!0):o(!0)},openView:q=>{if(q==="files"){B();return}if(q==="mcp"){d("mcp"),u(!0);return}b(q)},openChanges:({path:q,staged:ve}={})=>{Q(q?{path:q,staged:ve===!0}:null)},openSettings:q=>{q&&v(q),z(q?"page-content":"nav")}}),[C,Q,B,z,b,v]);Zu(te);const re=c.useRef(null);Fn(re,{onLeftEdgeSwipe:()=>{C?F(!0):o(!0)},onRightEdgeSwipe:()=>u(!0)});const se=c.useRef(null),ae=c.useCallback(q=>{se.current=q},[]),de=c.useCallback(()=>l?(p(null),!0):r==="settings"&&se.current?.()?!0:r?(R(),!0):a?(O(),!0):s?(o(!1),!0):!1,[r,R,O,l,s,a]);ma(de);const U=!D&&S&&(E==="desktop"||E==="web"),ie=C?"dialog":"fullscreen",xe=c.useMemo(()=>({instanceLabel:D?os():null,onOpenInstances:D?()=>b("instances"):void 0,onOpenSettings:()=>z("nav"),onOpenUpdate:U?()=>b("update"):void 0}),[z,b,D,U]),je=c.useCallback(()=>{const q="new-mcp-server";let ve=q,Ne=1;for(;w.some(Me=>Me.name===ve);)ve=`${q}-${Ne}`,Ne+=1;A({name:ve,scope:"user",type:"local",command:[],url:"",environment:[],headers:[],oauthEnabled:!0,oauthClientId:"",oauthClientSecret:"",oauthScope:"",oauthRedirectUri:"",timeout:"",enabled:!0}),k(ve),v("mcp"),z("page-content")},[w,z,A,k,v]);return t.jsx(pa,{actions:G,children:t.jsxs("div",{className:"oc-mobile-app-shell main-content-safe-area flex h-[100dvh] flex-row bg-background text-foreground","data-page-scroll-lock":"true",children:[C?t.jsxs("aside",{ref:Z.asideRef,className:Y("relative flex h-full shrink-0 flex-col overflow-hidden border-r border-border/70 bg-background will-change-[width] motion-reduce:transition-none",!V&&"border-r-0"),style:{width:V?Z.width:0,minWidth:V?Z.width:0,maxWidth:V?Z.width:0,"--oc-ipad-sidebar-width":`${Z.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)",transitionProperty:Z.isResizing?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!V,"data-page-scroll-lock":"true",children:[t.jsx("div",{className:Y("flex h-full shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",Z.isResizing&&"pointer-events-none",!V&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(qe,{children:t.jsx(Cr,{open:!0,variant:"sidebar",onOpenChange:q=>{!q&&!x&&F(!1)},footer:xe})})}),V?t.jsx(Or,{side:"left",isResizing:Z.isResizing,ariaLabel:e("sidebar.resize.leftPanelAria"),handleProps:Z.handleProps}):null]}):null,t.jsxs("div",{className:"flex h-full min-w-0 flex-1 flex-col","data-page-scroll-lock":"true",children:[t.jsx(Lc,{onOpenSessions:()=>C?I():o(!0),onOpenWorkspace:()=>u(!0),compactTitle:C}),t.jsx("main",{ref:re,className:"relative min-h-0 flex-1 overflow-hidden","data-page-scroll-lock":"true",children:t.jsx("div",{className:"h-full w-full",children:t.jsx(qe,{children:t.jsx(Xa,{})})})})]}),C?null:t.jsx(Cr,{open:s,onOpenChange:o,footer:xe}),C?t.jsxs("aside",{ref:ne.asideRef,className:Y("relative flex h-full shrink-0 flex-col overflow-hidden border-l border-border/70 bg-background will-change-[width] motion-reduce:transition-none",!W&&"border-l-0"),style:{width:W,minWidth:W,maxWidth:W,"--oc-ipad-sidebar-width":`${ne.width}px`,overflowX:"clip",paddingTop:"var(--oc-safe-area-top, 0px)",transitionProperty:ne.isResizing?"none":"width, min-width, max-width",transitionDuration:"200ms",transitionTimingFunction:"cubic-bezier(0.22, 1, 0.36, 1)"},"aria-hidden":!W,"data-page-scroll-lock":"true",children:[t.jsx("div",{className:Y("flex h-full min-h-0 shrink-0 flex-col transition-opacity duration-200 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none",ne.isResizing&&"pointer-events-none",!W&&"pointer-events-none select-none opacity-0"),style:{width:"var(--oc-ipad-sidebar-width)",overflowX:"hidden"},children:t.jsx(qe,{children:t.jsx(Mr,{open:a,onClose:O,tab:f,onTabChange:d,pendingChangesDiff:y,onOpenPlan:p,onOpenMcpSettings:je,variant:M?"panel":"drawer"})})}),W?t.jsx(Or,{side:"right",isResizing:ne.isResizing,ariaLabel:e("sidebar.resize.rightPanelAria"),handleProps:ne.handleProps}):null]}):t.jsx(Mr,{open:a,onClose:O,tab:f,onTabChange:d,pendingChangesDiff:y,onOpenPlan:p,onOpenMcpSettings:je}),l?t.jsx(ls,{open:!0,variant:ie,onClose:()=>p(null),ariaLabel:l.title,title:l.title,children:t.jsx(qe,{children:t.jsx(tl,{savedProjectPlan:{projectRef:l.projectRef,planId:l.id},onNavigatedToChat:()=>{R(),O()}})})}):null,r==="instances"&&D?t.jsx(ls,{open:!0,variant:ie,dialogAlign:"app",onClose:R,ariaLabel:e("mobile.menu.instances"),title:e("mobile.menu.instances"),children:t.jsx(Uc,{onConnect:R,onActiveConnectionDeleted:n})}):null,r==="settings"?t.jsx(ls,{open:!0,variant:ie,dialogAlign:"app",onClose:R,ariaLabel:e("mobile.menu.settings"),headerless:!0,children:t.jsx(qe,{children:t.jsx(Za,{forceMobile:!0,isWindowed:!0,initialMobileStage:g,registerBackHandler:ae,visiblePageSlugs:ld.filter(q=>!(D&&q==="about")),onClose:R})})}):null,r==="update"?t.jsx(ls,{open:!0,variant:ie,dialogAlign:"app",onClose:R,ariaLabel:e("mobile.menu.update"),title:e("mobile.menu.update"),children:t.jsx(qe,{children:t.jsx("div",{className:"h-full overflow-auto px-5 py-4",children:t.jsx(el,{initialUpdateDialogOpen:!0})})})}):null]})})};function dd({apis:n}){const{t:e}=fe(),s=He(M=>M.initializeApp),o=He(M=>M.isInitialized),r=He(M=>M.isConnected),i=He(M=>M.connectionPhase),a=He(M=>M.providers.length),u=He(M=>M.agents.length),f=He(M=>M.loadProviders),d=He(M=>M.loadAgents),l=jt(M=>M.currentDirectory),p=Se(M=>M.error),g=Se(M=>M.clearError),h=dt(M=>M.setIsMobile),y=Ui(M=>M.refreshStatus),j=Vi(M=>M.refreshStatus),v=Gi(M=>M.setPlanModeEnabled),T=Ve(M=>M.projects),[S,E]=c.useState(0),[D,w]=c.useState(0),[A,k]=c.useState(!1),[R,b]=c.useState("pending"),[O,z]=c.useState(null),C=c.useMemo(()=>os(),[]),[,x]=c.useReducer(M=>M+1,0),_=c.useMemo(()=>oo(),[]),K=c.useRef(0),N=c.useRef(0),V=c.useCallback(()=>{const M=ut(),W=N.current+1;if(N.current=W,!M){ss("resume:auto-connect",{}),ns();return}ss("resume:reprobe",{});const J=()=>{s(),y(n.github,{force:!0}),j(n.linear,{force:!0}),a===0&&f({source:"mobileApp:nativeResume"}),u===0&&d({source:"mobileApp:nativeResume"})},G=re=>{ss("resume:disconnect",{reason:re}),It({apiBaseUrl:"",clientToken:null,runtimeKey:Cs}),E(se=>se+1)};Is().then(re=>{if(N.current===W){if(re==="no-connection"){G("no-connection");return}if(re==="needs-login"){z({kind:"auth-expired",label:os()??""}),G("needs-login");return}if(re==="unreachable"){const se=[4e3,1e4],ae=de=>{window.setTimeout(()=>{if(N.current!==W)return;const U=de===se.length-1;Is({fast:!U}).then(ie=>{if(N.current===W&&ie!=="switched"){if(ie==="unchanged"){J();return}if(ie==="needs-login"){z({kind:"auth-expired",label:os()??""}),G("retry-needs-login");return}if(!U){ae(de+1);return}G(`retry-${ie}`)}})},se[de])};ae(0);return}re!=="switched"&&J()}});const te=Date.now();te-K.current>=cd&&(K.current=te,window.dispatchEvent(new Event("aiworker:system-resume")))},[u,n.github,n.linear,s,d,f,a,y,j]);Ki(),Hi(V),c.useEffect(()=>{if(!_)return;let M;const W=()=>{window.clearTimeout(M),M=window.setTimeout(()=>V(),1500)};return window.addEventListener("online",W),()=>{window.removeEventListener("online",W),window.clearTimeout(M)}},[_,V]),c.useEffect(()=>{if(_)return Xn.subscribe((M,W)=>{M.state==="expired"&&W.state!=="expired"&&(V(),Xn.getState().markAuthenticated())})},[_,V]),c.useEffect(()=>(Qn(n),()=>Qn(null)),[n]),c.useEffect(()=>Go(M=>{if(ss("endpoint:changed",{runtimeKey:M.runtimeKey||"none",previousRuntimeKey:M.previousRuntimeKey||"none",connected:!!M.apiBaseUrl}),!!M.runtimeKey&&M.runtimeKey===M.previousRuntimeKey){Va(),x();return}Ga(M),w(J=>J+1),E(J=>J+1)}),[]),c.useEffect(()=>{if(!_||r||ut()){b("done");return}let M=!1;return b("attempting"),(async()=>{const W=await ns().catch(()=>({status:"no-candidate"}));M||(W.status==="unreachable"?z({kind:"unreachable",label:W.label}):W.status==="needs-login"&&z({kind:"auth-expired",label:W.label}),b("done"),W.status==="unreachable"&&ns({fast:!1,skipIfConnected:!0}).catch(()=>null))})(),()=>{M=!0}},[]),c.useEffect(()=>{if(!_||!ut())return;let M=!1;const W=J=>{ss("cold-launch:drop",{kind:J?.kind??"unknown"}),J&&z(J),It({apiBaseUrl:"",clientToken:null,runtimeKey:Cs}),E(G=>G+1)};return Is().then(async J=>{if(M||J==="switched"||J==="unchanged")return;const G=os();if(J==="needs-login"){W({kind:"auth-expired",label:G??""});return}if(J==="unreachable"){W(G?{kind:"unreachable",label:G}:null),ns({fast:!1,skipIfConnected:!0}).catch(()=>null);return}const te=await ns().catch(()=>({status:"no-candidate"}));M||te.status==="connected"||(te.status==="needs-login"?W({kind:"auth-expired",label:te.label}):te.status==="unreachable"?W({kind:"unreachable",label:te.label}):W(null))}),()=>{M=!0}},[]),c.useEffect(()=>{h(!0)},[h]),c.useEffect(()=>{_&&!ut()||s()},[S,s,_]),c.useEffect(()=>{r&&(a===0&&f({source:"mobileApp:recovery"}),u===0&&d({source:"mobileApp:recovery"}))},[u,r,d,f,a]);const F=c.useRef(!1),[I,B]=c.useState(_);c.useEffect(()=>{if(!_||!r||F.current)return;if(Se.getState().currentSessionId){F.current=!0,B(!1);return}const M=Ut(),W=qi(M);if(!W){F.current=!0,B(!1);return}let J=!1;const G=window.setTimeout(()=>B(!1),6e3);return(async()=>{const te=await xn().catch(()=>null);if(J)return;if(!te){B(!1);return}F.current=!0;const re=te.activeSessions.find(ae=>ae.id===W.sessionId);if(!re){Ji(M),B(!1);return}const se=Se.getState();se.currentSessionId||se.setCurrentSession(re.id,gn(re)??W.directory??void 0),B(!1)})(),()=>{J=!0,window.clearTimeout(G)}},[S,r,_]),c.useEffect(()=>{r&&Zn.setDirectory(l)},[l,r]),c.useEffect(()=>{r&&(y(n.github,{force:!0}),j(n.linear,{force:!0}))},[n.github,n.linear,r,y,j]),c.useEffect(()=>{if(!r||T.length===0)return;let M=!1;return(async()=>{const J=new Map(Se.getState().availableWorktreesByProject);if(await Promise.all(T.map(async re=>{const se=re.path.replace(/\\/g,"/").replace(/\/+$/,"");if(se)try{if(!(Ge.getState().directories.get(se)?.isGitRepo??await Bt(()=>import("./useAppFontEffects-cYK1WODe.js").then(ie=>ie.iF),__vite__mapDeps([9,1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82])).then(ie=>ie.checkIsGitRepository(se))))return;const U=await so({id:re.id,path:se});if(M)return;J.set(se,U)}catch{}})),M)return;const G=no(T,J),te=Se.getState().availableWorktreesByProject;la(G,te)||Se.setState({availableWorktrees:[...G.values()].flat(),availableWorktreesByProject:G})})(),()=>{M=!0}},[r,T]),c.useEffect(()=>{if(!r)return;let M=!1;const W=Yi(J=>{J.type==="worktree-changed"&&ca(T,J.directories,()=>M)});return()=>{M=!0,W()}},[r,T]),c.useEffect(()=>{let M=!1;return(async()=>{const J=await pn("/health",{method:"GET"}).catch(()=>null);if(!J||!J.ok||M)return;const G=await J.json().catch(()=>null);if(!G||M)return;const te=G.planModeExperimentalEnabled;v(te===!0||te===1||te==="1"||te==="true")})(),()=>{M=!0}},[v]),c.useEffect(()=>{if(!p)return;const M=window.setTimeout(()=>g(),5e3);return()=>window.clearTimeout(M)},[g,p]),c.useEffect(()=>{if(!(!r&&(_?!!ut():!0))){k(!1);return}const W=window.setTimeout(()=>{k(!0)},_?4e3:8e3);return()=>window.clearTimeout(W)},[r,_,S,D]),Xi(),Qi({enabled:!0}),Ka(),Zi(),Ha(),nd({enabled:_&&r}),ed({ready:_&&r&&o});const Q=Fu(),Z=!r&&i==="reconnecting";if(!Q)return t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background text-foreground",children:t.jsx(yt,{width:120,height:120,isAnimated:!0})});const ne=!!ut();return _&&(!ne||!r&&!Z)?ne?t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-4",children:[t.jsx(yt,{width:120,height:120,isAnimated:!A}),A?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx("h1",{className:"typography-h3 text-foreground",children:e("sessionAuth.error.networkTitle")}),t.jsx("p",{className:"typography-body text-muted-foreground",children:e("mobile.connect.recovery.description")})]}),t.jsx(he,{type:"button",variant:"outline",onClick:()=>{It({apiBaseUrl:"",clientToken:null,runtimeKey:Cs}),E(M=>M+1)},children:e("mobile.connect.cancelPassword")})]}):null]})}):R!=="done"?t.jsxs("main",{className:"relative flex min-h-dvh items-center justify-center bg-background text-foreground",children:[t.jsx(yt,{width:120,height:120,isAnimated:!0}),C?t.jsxs("div",{className:"absolute inset-x-0 top-[calc(50%+84px)] flex flex-col items-center gap-0.5 px-6 text-center",children:[t.jsx("p",{className:"typography-small text-muted-foreground",children:e("mobile.connect.splash.connectingTo")}),t.jsxs("p",{className:"typography-small text-foreground",children:[C,t.jsx(ea,{})]})]}):null]}):t.jsx(t.Fragment,{children:t.jsx(Sc,{onConnected:()=>E(M=>M+1),notice:O})}):!r&&!Z?A?t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background px-6 text-center text-foreground",children:t.jsxs("div",{className:"max-w-sm space-y-3",children:[t.jsx("h1",{className:"typography-h3 text-foreground",children:e("sessionAuth.error.networkTitle")}),t.jsx("p",{className:"typography-body text-muted-foreground",children:e("sessionAuth.error.networkDescription")})]})}):t.jsx("main",{className:"flex min-h-dvh items-center justify-center bg-background text-foreground",children:t.jsx(yt,{width:120,height:120,isAnimated:!0})}):t.jsx(qe,{children:t.jsx(ta,{sdk:Zn.getSdkClient(),directory:l||"",children:t.jsx(sa,{apis:n,children:t.jsx(na,{delayDuration:300,skipDelayDuration:150,children:t.jsxs("div",{className:"h-full bg-background text-foreground",children:[_&&I?t.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background",children:t.jsx(yt,{width:120,height:120,isAnimated:!0})}):null,t.jsx(ra,{embeddedBackgroundWorkEnabled:o}),t.jsx(qa,{}),t.jsx(Ll,{}),t.jsx(ud,{onActiveConnectionDeleted:()=>{It({apiBaseUrl:"",clientToken:null,runtimeKey:Cs}),E(M=>M+1)}}),t.jsx(oa,{}),t.jsx(ia,{}),t.jsx(aa,{position:"top-center",offset:"calc(var(--oc-safe-area-top, 0px) + 16px)"}),o?t.jsx(Ja,{}):null]})})})},D)})}const fd=()=>{wa(),Ko().then(()=>{Promise.all([Ho(),ja()]).catch(n=>{console.error("[mobile-main] settings init failed:",n)}),ka(),Sa(),Na()}).catch(n=>{console.error("[mobile-main] appearance init failed:",n)}).finally(()=>{Tl()})};function Lm(n){window.__AIWORKER_SURFACE__="mobile",ha(),fd(),Bl(),ga();const e=document.getElementById("root");if(!e)throw new Error("Root element not found");const o=window.Capacitor?.isNativePlatform?.()===!0||window.location.protocol==="capacitor:",r=o?{...n,notifications:{notifyAgentCompletion:async()=>!1,canNotify:()=>!1}}:n,i=t.jsx(dd,{apis:r});Oo.createRoot(e).render(t.jsx(an.StrictMode,{children:t.jsx(ba,{children:t.jsx(xa,{children:t.jsx(ya,{children:t.jsx(Qa,{children:o?i:t.jsx(va,{children:i})})})})})}))}export{Lm as renderMobileApp};
|