@yuriai/web 0.3.3-beta.10 → 0.3.3-beta.16

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.
Files changed (130) hide show
  1. package/dist/assets/{AgentSelector-Dp2Y_etX.js → AgentSelector-Y-O2ix4y.js} +1 -1
  2. package/dist/assets/{ArchivedSessionsDialog-DOIPVgrw.js → ArchivedSessionsDialog-BuA5qj8G.js} +1 -1
  3. package/dist/assets/{AssistantConversationSurface-HGpfVNBs.js → AssistantConversationSurface-B_cXq21H.js} +3 -3
  4. package/dist/assets/{AssistantSessionCard-DedZC42m.js → AssistantSessionCard-DM513DvH.js} +2 -2
  5. package/dist/assets/{AssistantUnreadBadge-C48KUb1r.js → AssistantUnreadBadge-p9mkpbMC.js} +1 -1
  6. package/dist/assets/{AssistantView-CuoRAEno.js → AssistantView-C-KTy7x0.js} +1 -1
  7. package/dist/assets/{AssistantWorkingAvatar-JgG_07hF.js → AssistantWorkingAvatar-CoxhuMvM.js} +1 -1
  8. package/dist/assets/{AssistantsSettingsPage-t0ADcz1K.js → AssistantsSettingsPage-Dq6tz9a4.js} +1 -1
  9. package/dist/assets/{BinaryFileFallback-X1gV-nAy.js → BinaryFileFallback-Ce8Tb2eT.js} +1 -1
  10. package/dist/assets/{BtwPanel-CHS7r31i.js → BtwPanel-m2z9ve0r.js} +1 -1
  11. package/dist/assets/{BusyDots-BsUVp2eN.js → BusyDots-CtT00apU.js} +1 -1
  12. package/dist/assets/{ChatContainer-Ct4VAS3b.js → ChatContainer-B_51a5IM.js} +8 -8
  13. package/dist/assets/{ChatView-Cqnu4UDM.js → ChatView-XPKYQSRT.js} +1 -1
  14. package/dist/assets/{DiagramView-B-etEyWo.js → DiagramView-DdcQkKrt.js} +1 -1
  15. package/dist/assets/{DiffView-DDHHqjgv.js → DiffView-DOkOTpyw.js} +1 -1
  16. package/dist/assets/{ErrorBoundary-BtjED190.js → ErrorBoundary-CH2h3eG1.js} +1 -1
  17. package/dist/assets/{FadeInOnReveal-BYHr1gqj.js → FadeInOnReveal-B3uT04YJ.js} +1 -1
  18. package/dist/assets/{GuiPluginMount-Crvczrt6.js → GuiPluginMount-CwwJFGus.js} +1 -1
  19. package/dist/assets/{GuiPluginPage-2WzEPF43.js → GuiPluginPage-3ckHzsip.js} +1 -1
  20. package/dist/assets/{GuiPluginSurface-KHF2wT87.js → GuiPluginSurface-DaaXNIx_.js} +1 -1
  21. package/dist/assets/{GuiPluginWindow-zPmRKQyC.js → GuiPluginWindow-BkAFJyFd.js} +1 -1
  22. package/dist/assets/{ImageLoadingPlaceholder-CygGz74v.js → ImageLoadingPlaceholder-DgM_EFHn.js} +1 -1
  23. package/dist/assets/{LoadingImage-Dln_32pX.js → LoadingImage-Df22Rkor.js} +1 -1
  24. package/dist/assets/{MarkdownRenderer-D719PKVi.js → MarkdownRenderer-WoxwVIoR.js} +2 -2
  25. package/dist/assets/{MarkdownRendererImpl-DI1Ea45X.js → MarkdownRendererImpl--jZL9vQc.js} +1 -1
  26. package/dist/assets/{MarkstreamRendererImpl-D9FCjddm.js → MarkstreamRendererImpl-BJpcybrS.js} +1 -1
  27. package/dist/assets/{MobileAssistantSettingsPage-CQ0NYrWK.js → MobileAssistantSettingsPage-DXiu2yok.js} +1 -1
  28. package/dist/assets/{MobileAssistantTab-DLUKZcit.js → MobileAssistantTab-CMIQansR.js} +1 -1
  29. package/dist/assets/{MobileBtwPage-pxZXYPD5.js → MobileBtwPage-tdS0tYPj.js} +1 -1
  30. package/dist/assets/{MobileChangesSurface-DX--axmh.js → MobileChangesSurface-BU4qFaHP.js} +1 -1
  31. package/dist/assets/{MobileChatScreen-DWBAhlAd.js → MobileChatScreen-DecNa9lW.js} +1 -1
  32. package/dist/assets/{MobileFilesSurface-BBSHFiPy.js → MobileFilesSurface-D2YLR9XN.js} +2 -2
  33. package/dist/assets/{MobileHtmlNetworkBoundary-CZKls5Dm.js → MobileHtmlNetworkBoundary-D1U1-KQS.js} +2 -2
  34. package/dist/assets/{MobileSettingsTab-B3O2HKYI.js → MobileSettingsTab-CsbMGpja.js} +1 -1
  35. package/dist/assets/{MobileShareBridge-CW-Ga05E.js → MobileShareBridge-BAavK3r-.js} +1 -1
  36. package/dist/assets/{ModelSelector-BGR6sZJR.js → ModelSelector-DGFW9Dr_.js} +1 -1
  37. package/dist/assets/{MultiRunWindow-ChKq36k9.js → MultiRunWindow-B6DftPF5.js} +1 -1
  38. package/dist/assets/{OnboardingScreen-BK78UY6r.js → OnboardingScreen-De2wu_BS.js} +1 -1
  39. package/dist/assets/{PierreDiffViewer-Dx9xKT6Q.js → PierreDiffViewer-CglLIEfr.js} +1 -1
  40. package/dist/assets/{RemoteAssistantSessionCard-ClcMxJDi.js → RemoteAssistantSessionCard-VfMaU9MY.js} +1 -1
  41. package/dist/assets/{RemoteDesktopPanel-C2--FcGJ.js → RemoteDesktopPanel-DBXYIcvY.js} +1 -1
  42. package/dist/assets/{ScheduledTasksDialog-YbrfN9nF.js → ScheduledTasksDialog-DHbl98gj.js} +1 -1
  43. package/dist/assets/{SettingsGroup-D-7VEpNl.js → SettingsGroup-CvaPYznp.js} +1 -1
  44. package/dist/assets/{SettingsView-BAcjCVpS.js → SettingsView-CvH-qF2z.js} +1 -1
  45. package/dist/assets/{SettingsWindow-DMsvU8gG.js → SettingsWindow-5Asj_0Ab.js} +1 -1
  46. package/dist/assets/{SetupTourDialog-C23oYP0n.js → SetupTourDialog-D5j5AMCy.js} +1 -1
  47. package/dist/assets/{SyncActions-BcIQyp1F.js → SyncActions-CrOoREWF.js} +1 -1
  48. package/dist/assets/{TerminalView-BhdW5u6z.js → TerminalView-ClTlg6zO.js} +1 -1
  49. package/dist/assets/{TextSelectionMenu-pKMQsjmM.js → TextSelectionMenu-CNB9OqIt.js} +1 -1
  50. package/dist/assets/{ToolOutputDialog-DHMoC89c.js → ToolOutputDialog-Bbvt55F0.js} +1 -1
  51. package/dist/assets/{YuriLogo-Dpy8xIT7.js → YuriLogo-Cp6vWDWp.js} +1 -1
  52. package/dist/assets/{assistantMessagePreview-BoElXQcc.js → assistantMessagePreview-DLBvPQtq.js} +1 -1
  53. package/dist/assets/{assistantQueries-CU5EOlP5.js → assistantQueries-NdPqu6rx.js} +1 -1
  54. package/dist/assets/{auto-read-context-C63nte5m.js → auto-read-context-CIdRIbjK.js} +1 -1
  55. package/dist/assets/{capgoAdapter-DA9oqtUT.js → capgoAdapter-C5kwQhZH.js} +1 -1
  56. package/dist/assets/{chatUpwardIntent-vaEvclo6.js → chatUpwardIntent-BmpMGV0w.js} +1 -1
  57. package/dist/assets/{connection-hint-_XZ_PuIx.js → connection-hint-B-kOWome.js} +1 -1
  58. package/dist/assets/{dialog-DGIsM7rW.js → dialog-BeFBA6ja.js} +1 -1
  59. package/dist/assets/{es-Bl9cq4cA.js → es-DqYZgeC6.js} +1 -1
  60. package/dist/assets/{fr-Cr4jYr7F.js → fr-BHaun7Zq.js} +1 -1
  61. package/dist/assets/{gitApi-B2woehMM.js → gitApi-BI8gTJru.js} +1 -1
  62. package/dist/assets/{i18n-D5tJwyKg.js → i18n-DXc6czdR.js} +1 -1
  63. package/dist/assets/{insertionBoundaries-uc4ZzuFG.js → insertionBoundaries-BdPIw7sm.js} +1 -1
  64. package/dist/assets/{ja-Cm3BxxJJ.js → ja-BGNugvrx.js} +1 -1
  65. package/dist/assets/{ko-DvHdDOxf.js → ko-CGbNBfDe.js} +1 -1
  66. package/dist/assets/main-LnwLNNJu.js +169 -0
  67. package/dist/assets/{main-DNlHTrMN.js → main-gYmGdwmH.js} +2 -2
  68. package/dist/assets/{mcpQueries-XUc_D3YM.js → mcpQueries-BKAVhjr3.js} +1 -1
  69. package/dist/assets/{miniChat-CaNWXhjj.js → miniChat-C8uubxw9.js} +2 -2
  70. package/dist/assets/{mobile-BzAiDSbd.js → mobile-OBzNXeEM.js} +2 -2
  71. package/dist/assets/{mobileBackNavigation-DRAXoPY-.js → mobileBackNavigation-8JySoaRF.js} +1 -1
  72. package/dist/assets/{mobileConnections-BGOTglit.js → mobileConnections-7wP-T5bc.js} +2 -2
  73. package/dist/assets/{multirun-BK3mZXUk.js → multirun-B8wxvV3F.js} +1 -1
  74. package/dist/assets/{native-config-D_WRbNJv.js → native-config-rSn3LLz4.js} +1 -1
  75. package/dist/assets/{nativeComposerCover-wtrZ94Ug.js → nativeComposerCover-04c_IwGr.js} +1 -1
  76. package/dist/assets/{navigation-CTmsDjzG.js → navigation--cBMQO70.js} +1 -1
  77. package/dist/assets/{openRemoteProjectSession-BAdOlqax.js → openRemoteProjectSession-Driv6jop.js} +1 -1
  78. package/dist/assets/{pl-DpyRu1OO.js → pl-k8-4URiE.js} +1 -1
  79. package/dist/assets/{pluginPresentation-BiUzFwhI.js → pluginPresentation-CuCmjxYR.js} +1 -1
  80. package/dist/assets/{pt-BR-B3XbDM_D.js → pt-BR-DdwCzXBH.js} +1 -1
  81. package/dist/assets/{pwa-C483VkHZ.js → pwa-CmLnRiAE.js} +1 -1
  82. package/dist/assets/{queue-abort-optimistic-kruSA-oL.js → queue-abort-optimistic-dagyHxI5.js} +1 -1
  83. package/dist/assets/{quota-BbYx47Ix.js → quota-CqWNkFzw.js} +1 -1
  84. package/dist/assets/{reference-history-Dz7Csknf.js → reference-history-BqEmyaH0.js} +1 -1
  85. package/dist/assets/{remoteSessionReference-69X1dr9g.js → remoteSessionReference-wm-7vGPU.js} +1 -1
  86. package/dist/assets/{renderElectronMiniChatApp-D07-P4oV.js → renderElectronMiniChatApp-CCqwX73F.js} +2 -2
  87. package/dist/assets/renderMobileApp-DpdAzswD.js +17 -0
  88. package/dist/assets/{runtimeConfig-BwlqVwx2.js → runtimeConfig-pUJV4QRV.js} +1 -1
  89. package/dist/assets/{runtimeEndpointReset-B4l_KxK4.js → runtimeEndpointReset-BeP-eS0q.js} +3 -3
  90. package/dist/assets/{select-BYAkkuwW.js → select-vZCgcnYG.js} +1 -1
  91. package/dist/assets/{sessionLookup-CCHKrhTS.js → sessionLookup-9xT7pc4Q.js} +1 -1
  92. package/dist/assets/{sessionOwnership-B13jZE-0.js → sessionOwnership-xOCCIVwh.js} +1 -1
  93. package/dist/assets/{sortable-tabs-strip-CojmWPov.js → sortable-tabs-strip-DmtfYPz0.js} +1 -1
  94. package/dist/assets/{speechSettingsQueries-Byveu-YH.js → speechSettingsQueries-BalG6g1E.js} +1 -1
  95. package/dist/assets/src-QTj33Z0x.css +2 -0
  96. package/dist/assets/{store-DdM0dMHL.js → store-C1ifDY0C.js} +3 -3
  97. package/dist/assets/{textarea-BxFr_r0x.js → textarea-ZiXxEOHK.js} +1 -1
  98. package/dist/assets/{timeFormat-DtibJGYE.js → timeFormat-dCsf2MQv.js} +1 -1
  99. package/dist/assets/{types-ay6wuGvG.js → types-s46TxX4o.js} +1 -1
  100. package/dist/assets/{ui-BtnozFKV.js → ui-DyxdnQlj.js} +12 -12
  101. package/dist/assets/{uk-DQnRpX74.js → uk-DU-7fAP4.js} +1 -1
  102. package/dist/assets/{useAppFontEffects-BBpdXOXU.js → useAppFontEffects-xFDWXJMz.js} +2 -2
  103. package/dist/assets/{useDesktopWindowControlsLayout-E4gCLcJk.js → useDesktopWindowControlsLayout-Cf_gfhz_.js} +1 -1
  104. package/dist/assets/{useDictation-BlXyawcK.js → useDictation-CZzAlsW0.js} +1 -1
  105. package/dist/assets/{useEffectiveDirectory-Iz3O6JPo.js → useEffectiveDirectory-CjnAEiMV.js} +1 -1
  106. package/dist/assets/{useGitStore-juwpiPLM.js → useGitStore-B6LCPegX.js} +1 -1
  107. package/dist/assets/{useMcpConfigStore-DwzqwuD0.js → useMcpConfigStore-BdSg-516.js} +1 -1
  108. package/dist/assets/useMobileSwipeActions-XoxrtaUo.js +1 -0
  109. package/dist/assets/{useMobileTranscriptSyncHint-D0M5GIEa.js → useMobileTranscriptSyncHint-BXi8O9sk.js} +1 -1
  110. package/dist/assets/{useModelLists-CDgh3Fk-.js → useModelLists-DmyYnnr4.js} +1 -1
  111. package/dist/assets/{useOpenCodeReadiness-CLJ8g7hd.js → useOpenCodeReadiness-Db_8COSR.js} +1 -1
  112. package/dist/assets/{usePluginsStore-r8p_sKQN.js → usePluginsStore-COtfsDZ3.js} +1 -1
  113. package/dist/assets/{useProjectGitActions-c-fTxVgn.js → useProjectGitActions-BUoCPOxJ.js} +1 -1
  114. package/dist/assets/{useProjectGitStore-B2LnlGli.js → useProjectGitStore-xVrTE-C9.js} +1 -1
  115. package/dist/assets/{useProjectRuntimeAPIs-DnAquACf.js → useProjectRuntimeAPIs-BejNbqXr.js} +1 -1
  116. package/dist/assets/{useQuotaStore-2zTsa_Q9.js → useQuotaStore-CSn2pk3T.js} +1 -1
  117. package/dist/assets/{useSessionBtwStore-BemezL7O.js → useSessionBtwStore-CD65yTSZ.js} +1 -1
  118. package/dist/assets/{useStreamingTextThrottle-DGAjmaMZ.js → useStreamingTextThrottle-C9SaKeil.js} +1 -1
  119. package/dist/assets/{worktreeManager-CfSTt6sD.js → worktreeManager-Bv12AnI9.js} +1 -1
  120. package/dist/assets/{worktreeSourceBranchPreference-C_8tzVJi.js → worktreeSourceBranchPreference-Bj0LPDqn.js} +1 -1
  121. package/dist/assets/{zh-CN-8YyNQnhE.js → zh-CN-DOHH7nht.js} +1 -1
  122. package/dist/assets/{zh-TW-PgJbJ5Sy.js → zh-TW-t1qlXGOg.js} +1 -1
  123. package/dist/index.html +6 -6
  124. package/dist/mini-chat.html +6 -6
  125. package/dist/mobile.html +2 -2
  126. package/package.json +1 -1
  127. package/dist/assets/main-DpJ6uDTu.js +0 -169
  128. package/dist/assets/renderMobileApp-DrCAcc_4.js +0 -17
  129. package/dist/assets/src-BgdyhkrP.css +0 -2
  130. package/dist/assets/useMobileSwipeActions-Bso2FqOI.js +0 -1
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Y as t,j as n,k as r,ot as i}from"./platform-CiUKDeXd.js";import{H as a,ot as o,st as s}from"./vendor-base-ui-wXsskyKm.js";import{dr as c}from"./client-B_907PBv.js";import{n as l}from"./vendor-react-BkccXcWz.js";import{s as u}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{c as d}from"./yuriEvents-BFrD5fMU.js";import{D as f,P as p}from"./runtime-file-resource-Bc_ss-sW.js";import{r as m}from"./vendor-reactuses-core-DjKFMfz7.js";import{r as h}from"./useUIStore-C3ewjGgP.js";import{i as g,o as _}from"./session-startup-barrier-DT-hIBRf.js";import{n as v}from"./Icon-DmykXZL1.js";import{G as y,Ia as b,Mi as x,Na as S,Oi as C,Rr as w,Ti as T,f as E,qn as D,t as O}from"./ui-BtnozFKV.js";import{m as k,n as A,p as j}from"./remoteProjectQueries-C8382jM8.js";import{t as ee}from"./i18n-D5tJwyKg.js";import{i as M,n as N,t as P}from"./tooltip-CpTbxEOE.js";import{c as F,n as I,t as L}from"./dropdown-menu-BblI9sN2.js";import{s as R}from"./useGitStore-juwpiPLM.js";import{b as z,h as B,p as V}from"./pwa-C483VkHZ.js";import{t as te}from"./MobileOverlayPanel-C36VWWmN.js";import{l as ne,r as re}from"./quota-BbYx47Ix.js";import{a as H,i as U}from"./sessionLookup-CCHKrhTS.js";import{n as W}from"./openRemoteProjectSession-BAdOlqax.js";var G=l(),K=e(s(),1),q=o(),J=e=>{let t=(0,G.c)(179),{pending:n,totalTokens:r,percentage:i,colorPercentage:a,contextLimit:o,outputLimit:s,size:c,isMobile:l,hideIcon:u,showPercentIcon:d,appearance:f,className:p,valueClassName:m,percentIconClassName:h,onClick:g,pressed:y}=e,b=n!==void 0&&n,x=c===void 0?`default`:c,S=l!==void 0&&l,C=u!==void 0&&u,w=d!==void 0&&d,T=f===void 0?`default`:f,E=y!==void 0&&y,{t:D}=ee(),[O,k]=K.useState(!1),A=typeof a==`number`?a:i,j,F,I,L,R,z,B,V,H,U,W,J,oe,Y,X,se,ce,Z,le,Q,$;if(t[0]!==T||t[1]!==A||t[2]!==o||t[3]!==S||t[4]!==g||t[5]!==s||t[6]!==b||t[7]!==h||t[8]!==i||t[9]!==D||t[10]!==r){let e=b?0:re(i)??0;U=T===`subtle`;let n=ne(A);W=U||b?`var(--surface-muted-foreground)`:n===`critical`?`var(--status-error)`:n===`warn`?`var(--status-warning)`:`var(--status-success)`,B=ie;let a;t[32]===b?a=t[33]:(a=e=>b?`text-muted-foreground`:e>=90?`text-status-error`:e>=75?`text-status-warning`:`text-status-success`,t[32]=b,t[33]=a),V=a,L=U?18:20,R=U?2:3,I=(L-R)/2,j=2*Math.PI*I,F=j*(1-e/100),J=typeof s==`number`?Math.max(s,0):0;let c;t[34]!==o||t[35]!==b||t[36]!==i||t[37]!==J||t[38]!==D||t[39]!==r?(Q=b?D(`contextUsage.pending`):`${Math.min(i,999).toFixed(1)}%`,$=b?`—`:B(r),z=B(o),c=b?[D(`contextUsage.pendingDescription`)]:[D(`contextUsage.tooltip.usage`,{percent:Q}),D(`contextUsage.tooltip.usedOfLimit`,{used:$,limit:z}),D(`contextUsage.tooltip.outputLimit`,{tokens:B(J)})],t[34]=o,t[35]=b,t[36]=i,t[37]=J,t[38]=D,t[39]=r,t[40]=z,t[41]=c,t[42]=Q,t[43]=$):(z=t[40],c=t[41],Q=t[42],$=t[43]),le=c,H=!S&&typeof g==`function`,ce=`0 0 ${L} ${L}`;let l=U?`h-4 w-4 shrink-0 -rotate-90 text-muted-foreground/70`:`h-3.5 w-3.5 -rotate-90`;t[44]!==h||t[45]!==l?(Z=_(l,h),t[44]=h,t[45]=l,t[46]=Z):Z=t[46],oe=`progressbar`,t[47]===D?Y=t[48]:(Y=D(`contextUsage.aria.label`),t[47]=D,t[48]=Y),t[49]!==b||t[50]!==D?(X=b?D(`contextUsage.pending`):void 0,t[49]=b,t[50]=D,t[51]=X):X=t[51],se=b?void 0:Math.round(e),t[0]=T,t[1]=A,t[2]=o,t[3]=S,t[4]=g,t[5]=s,t[6]=b,t[7]=h,t[8]=i,t[9]=D,t[10]=r,t[11]=j,t[12]=F,t[13]=I,t[14]=L,t[15]=R,t[16]=z,t[17]=B,t[18]=V,t[19]=H,t[20]=U,t[21]=W,t[22]=J,t[23]=oe,t[24]=Y,t[25]=X,t[26]=se,t[27]=ce,t[28]=Z,t[29]=le,t[30]=Q,t[31]=$}else j=t[11],F=t[12],I=t[13],L=t[14],R=t[15],z=t[16],B=t[17],V=t[18],H=t[19],U=t[20],W=t[21],J=t[22],oe=t[23],Y=t[24],X=t[25],se=t[26],ce=t[27],Z=t[28],le=t[29],Q=t[30],$=t[31];let ue=L/2,de=L/2,fe;t[52]!==I||t[53]!==R||t[54]!==ue||t[55]!==de?(fe=(0,q.jsx)(`circle`,{cx:ue,cy:de,r:I,fill:`none`,stroke:`var(--interactive-border)`,strokeWidth:R}),t[52]=I,t[53]=R,t[54]=ue,t[55]=de,t[56]=fe):fe=t[56];let pe=L/2,me=L/2,he;t[57]!==j||t[58]!==F||t[59]!==I||t[60]!==R||t[61]!==W||t[62]!==pe||t[63]!==me?(he=(0,q.jsx)(`circle`,{cx:pe,cy:me,r:I,fill:`none`,stroke:W,strokeWidth:R,strokeLinecap:`round`,strokeDasharray:j,strokeDashoffset:F,className:`transition-[stroke-dashoffset,stroke] duration-300`}),t[57]=j,t[58]=F,t[59]=I,t[60]=R,t[61]=W,t[62]=pe,t[63]=me,t[64]=he):he=t[64];let ge;t[65]!==oe||t[66]!==Y||t[67]!==X||t[68]!==se||t[69]!==fe||t[70]!==he||t[71]!==ce||t[72]!==Z?(ge=(0,q.jsxs)(`svg`,{viewBox:ce,className:Z,role:oe,"aria-label":Y,"aria-valuetext":X,"aria-valuenow":se,"aria-valuemin":0,"aria-valuemax":100,children:[fe,he]}),t[65]=oe,t[66]=Y,t[67]=X,t[68]=se,t[69]=fe,t[70]=he,t[71]=ce,t[72]=Z,t[73]=ge):ge=t[73];let _e=ge,ve=E||b?`ml-1 max-w-[14rem] opacity-100`:`ml-0 max-w-0 opacity-0 group-hover:ml-1 group-hover:max-w-[14rem] group-hover:opacity-100 group-focus-visible:ml-1 group-focus-visible:max-w-[14rem] group-focus-visible:opacity-100`,ye;t[74]===ve?ye=t[75]:(ye=_(`inline-flex items-center gap-1.5 overflow-hidden whitespace-nowrap typography-micro font-medium text-foreground transition-[max-width,opacity,margin] duration-200`,ve),t[74]=ve,t[75]=ye);let be;t[76]===Q?be=t[77]:(be=(0,q.jsx)(`span`,{children:Q}),t[76]=Q,t[77]=be);let xe;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,q.jsx)(`span`,{className:`mx-0.5 text-muted-foreground/60`,children:`/`}),t[78]=xe):xe=t[78];let Se;t[79]!==z||t[80]!==$?(Se=(0,q.jsxs)(`span`,{className:`text-muted-foreground`,children:[$,xe,z]}),t[79]=z,t[80]=$,t[81]=Se):Se=t[81];let Ce;t[82]!==ye||t[83]!==be||t[84]!==Se?(Ce=(0,q.jsxs)(`span`,{className:ye,children:[be,Se]}),t[82]=ye,t[83]=be,t[84]=Se,t[85]=Ce):Ce=t[85];let we=Ce,Te;t[86]!==A||t[87]!==V||t[88]!==C||t[89]!==S||t[90]!==U||t[91]!==b||t[92]!==i||t[93]!==_e||t[94]!==w||t[95]!==we||t[96]!==Q||t[97]!==m?(Te=U?(0,q.jsxs)(q.Fragment,{children:[_e,we]}):(0,q.jsxs)(q.Fragment,{children:[!S&&!C&&(0,q.jsx)(v,{name:`donut-chart`,className:`h-4 w-4 flex-shrink-0`}),(0,q.jsx)(`span`,{className:_(`font-medium inline-flex items-center gap-1.5`,m),children:b?(0,q.jsxs)(q.Fragment,{children:[w&&_e,(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:Q})]}):w?(0,q.jsxs)(q.Fragment,{children:[_e,(0,q.jsx)(`span`,{className:`text-foreground`,children:Q})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:V(A),children:Math.min(i,999).toFixed(1)}),`%`]})})]}),t[86]=A,t[87]=V,t[88]=C,t[89]=S,t[90]=U,t[91]=b,t[92]=i,t[93]=_e,t[94]=w,t[95]=we,t[96]=Q,t[97]=m,t[98]=Te):Te=t[98];let Ee=Te,De=U?`gap-0`:`gap-1.5`,Oe=x===`compact`?`typography-micro`:`typography-meta`,ke;t[99]!==p||t[100]!==H||t[101]!==U||t[102]!==E||t[103]!==De||t[104]!==Oe?(ke=_(`app-region-no-drag flex items-center select-none`,De,Oe,H?_(`group rounded-md text-foreground transition-colors`,U?_(`p-1.5 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50`,E&&`bg-interactive-hover/50 text-foreground`):`px-2 py-1.5 hover:bg-interactive-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`):`text-muted-foreground/60`,p),t[99]=p,t[100]=H,t[101]=U,t[102]=E,t[103]=De,t[104]=Oe,t[105]=ke):ke=t[105];let Ae=ke,je;t[106]!==Ee||t[107]!==H||t[108]!==S||t[109]!==g||t[110]!==E||t[111]!==Ae||t[112]!==D?(je=H?(0,q.jsx)(`button`,{type:`button`,className:Ae,"aria-label":D(`contextUsage.aria.label`),"aria-pressed":E,onClick:g,children:Ee}):(0,q.jsx)(`div`,{className:Ae,"aria-label":D(`contextUsage.aria.label`),onClick:S?()=>k(!0):void 0,children:Ee}),t[106]=Ee,t[107]=H,t[108]=S,t[109]=g,t[110]=E,t[111]=Ae,t[112]=D,t[113]=je):je=t[113];let Me=je;if(S){let e;t[114]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>k(!1),t[114]=e):e=t[114];let n;t[115]===D?n=t[116]:(n=D(`contextUsage.mobile.title`),t[115]=D,t[116]=n);let r;t[117]===D?r=t[118]:(r=D(`contextUsage.mobile.usedTokens`),t[117]=D,t[118]=r);let i;t[119]===r?i=t[120]:(i=(0,q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:r}),t[119]=r,t[120]=i);let a;t[121]===$?a=t[122]:(a=(0,q.jsx)(`span`,{className:`typography-meta text-foreground font-medium`,children:$}),t[121]=$,t[122]=a);let o;t[123]!==i||t[124]!==a?(o=(0,q.jsxs)(`div`,{className:`flex justify-between items-center`,children:[i,a]}),t[123]=i,t[124]=a,t[125]=o):o=t[125];let s;t[126]===D?s=t[127]:(s=D(`contextUsage.mobile.contextLimit`),t[126]=D,t[127]=s);let c;t[128]===s?c=t[129]:(c=(0,q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:s}),t[128]=s,t[129]=c);let l;t[130]===z?l=t[131]:(l=(0,q.jsx)(`span`,{className:`typography-meta text-foreground font-medium`,children:z}),t[130]=z,t[131]=l);let u;t[132]!==c||t[133]!==l?(u=(0,q.jsxs)(`div`,{className:`flex justify-between items-center`,children:[c,l]}),t[132]=c,t[133]=l,t[134]=u):u=t[134];let d;t[135]===D?d=t[136]:(d=D(`contextUsage.mobile.outputLimit`),t[135]=D,t[136]=d);let f;t[137]===d?f=t[138]:(f=(0,q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:d}),t[137]=d,t[138]=f);let p;t[139]!==B||t[140]!==J?(p=B(J),t[139]=B,t[140]=J,t[141]=p):p=t[141];let m;t[142]===p?m=t[143]:(m=(0,q.jsx)(`span`,{className:`typography-meta text-foreground font-medium`,children:p}),t[142]=p,t[143]=m);let h;t[144]!==f||t[145]!==m?(h=(0,q.jsxs)(`div`,{className:`flex justify-between items-center`,children:[f,m]}),t[144]=f,t[145]=m,t[146]=h):h=t[146];let g;t[147]===D?g=t[148]:(g=D(`contextUsage.mobile.usage`),t[147]=D,t[148]=g);let v;t[149]===g?v=t[150]:(v=(0,q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:g}),t[149]=g,t[150]=v);let y;t[151]!==A||t[152]!==V?(y=_(`typography-meta font-semibold`,V(A)),t[151]=A,t[152]=V,t[153]=y):y=t[153];let b;t[154]!==y||t[155]!==Q?(b=(0,q.jsx)(`span`,{className:y,children:Q}),t[154]=y,t[155]=Q,t[156]=b):b=t[156];let x;t[157]!==v||t[158]!==b?(x=(0,q.jsxs)(`div`,{className:`flex justify-between items-center pt-1 border-t border-border/40`,children:[v,b]}),t[157]=v,t[158]=b,t[159]=x):x=t[159];let S;t[160]!==o||t[161]!==u||t[162]!==h||t[163]!==x?(S=(0,q.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:(0,q.jsxs)(`div`,{className:`rounded-xl border border-border/40 bg-sidebar/30 px-3 py-2 space-y-1`,children:[o,u,h,x]})}),t[160]=o,t[161]=u,t[162]=h,t[163]=x,t[164]=S):S=t[164];let C;t[165]!==O||t[166]!==n||t[167]!==S?(C=(0,q.jsx)(te,{open:O,onClose:e,title:n,children:S}),t[165]=O,t[166]=n,t[167]=S,t[168]=C):C=t[168];let w;return t[169]!==Me||t[170]!==C?(w=(0,q.jsxs)(q.Fragment,{children:[Me,C]}),t[169]=Me,t[170]=C,t[171]=w):w=t[171],w}if(U)return Me;let Ne;t[172]===Me?Ne=t[173]:(Ne=(0,q.jsx)(M,{asChild:!0,children:Me}),t[172]=Me,t[173]=Ne);let Pe;t[174]===le?Pe=t[175]:(Pe=(0,q.jsx)(N,{children:(0,q.jsx)(`div`,{className:`space-y-0.5`,children:le.map(ae)})}),t[174]=le,t[175]=Pe);let Fe;return t[176]!==Ne||t[177]!==Pe?(Fe=(0,q.jsxs)(P,{children:[Ne,Pe]}),t[176]=Ne,t[177]=Pe,t[178]=Fe):Fe=t[178],Fe};function ie(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toFixed(1).replace(/\.0$/,``)}function ae(e){return(0,q.jsx)(`p`,{className:`typography-micro leading-tight`,children:e},e)}var oe=7,Y=e=>{if(!e)return null;let t=e.replace(/\\/g,`/`);return t===`/`?`/`:t.length>1?t.replace(/\/+$/,``):t},X=e=>{if(!e)return null;let t=e.path.split(/[\\/]/).filter(Boolean);return t[t.length-1]??null},se=(e,t)=>{let n=(0,G.c)(32),r;n[0]===t?r=n[1]:(r=t===void 0?{}:t,n[0]=t,n[1]=r);let{scopeProjectId:i}=r,a=i===void 0?null:i,o=C(ce),s=S(Z),c=x(),l;n[2]===s?l=n[3]:(l=s.map(le).filter(Q),n[2]=s,n[3]=l);let u=l,d;n[4]===u?d=n[5]:(d=e=>e?u.filter(t=>z(e,t.normalizedPath)).sort($)[0]??null:null,n[4]=u,n[5]=d);let f=d,p;bb0:{if(!e){let e;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],n[6]=e):e=n[6],p=e;break bb0}let t;if(n[7]!==o||n[8]!==f||n[9]!==c||n[10]!==a){let e;n[12]!==f||n[13]!==a?(e=e=>!a||f(T(e))?.id===a,n[12]=f,n[13]=a,n[14]=e):e=n[14];let r;n[15]===c?r=n[16]:(r=(e,t)=>V(e,t,c),n[15]=c,n[16]=r),t=Array.from(new Set(o.filter(ue).filter(de).filter(e).sort(r).slice(0,oe).map(fe).filter(pe))),n[7]=o,n[8]=f,n[9]=c,n[10]=a,n[11]=t}else t=n[11];p=t}let m=p,h;n[17]===Symbol.for(`react.memo_cache_sentinel`)?(h=new Map,n[17]=h):h=n[17];let g=K.useRef(h),_;n[18]===m?_=n[19]:(_=e=>{let t=g.current,n=t.size===m.length;if(n){for(let r of m)if(t.get(r)!==(e.directories.get(r)?.status?.current??null)){n=!1;break}}if(n)return t;let r=new Map;return m.forEach(t=>r.set(t,e.directories.get(t)?.status?.current??null)),g.current=r,r},n[18]=m,n[19]=_);let v=R(_),y;bb1:{if(!e){let e;n[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],n[20]=e):e=n[20],y=e;break bb1}let t;if(n[21]!==o||n[22]!==v||n[23]!==f||n[24]!==c||n[25]!==a){let e=new Map;for(let t of o){let n=t.parentID;if(!n||t.time?.archived)continue;let r=e.get(n);r?r.push(t):e.set(n,[t])}e.forEach(e=>{e.sort((e,t)=>V(e,t,c))});let r;n[27]!==f||n[28]!==a?(r=e=>{if(!a)return!0;let t=T(e);return f(t)?.id===a},n[27]=f,n[28]=a,n[29]=r):r=n[29];let i;n[30]===c?i=n[31]:(i=(e,t)=>V(e,t,c),n[30]=c,n[31]=i);let s=o.filter(me).filter(he).filter(r).sort(i).slice(0,oe),l=t=>({session:t,children:(e.get(t.id)??[]).map(e=>l(e)),worktree:null});t=s.map(e=>{let t=T(e),n=f(t),r=X(n),i=t?v.get(t)??null:null;return{node:l(e),projectId:n?.id??null,groupDirectory:t,secondaryMeta:{projectLabel:r,branchLabel:i&&i!==r?i:null}}}),n[21]=o,n[22]=v,n[23]=f,n[24]=c,n[25]=a,n[26]=t}else t=n[26];y=t}return y};function ce(e){return e.activeSessions}function Z(e){return e.projects}function le(e){return{...e,normalizedPath:Y(e.path)}}function Q(e){return e.normalizedPath}function $(e,t){return(t.normalizedPath?.length??0)-(e.normalizedPath?.length??0)}function ue(e){return!e.time?.archived}function de(e){return!e.parentID}function fe(e){return T(e)}function pe(e){return!!e}function me(e){return!e.time?.archived}function he(e){return!e.parentID}function ge(e){let t=(0,G.c)(18),{children:n,variant:r,scopeProjectId:i,align:a}=e,o=r===void 0?`default`:r,s=i===void 0?null:i,c=a===void 0?`start`:a,l=h(ve),u=h(_e),d;t[0]===n?d=t[1]:(d=(0,q.jsx)(F,{asChild:!0,children:n}),t[0]=n,t[1]=d);let f=o===`compact`?`w-[280px]`:`w-[360px]`,p;t[2]===f?p=t[3]:(p=_(`overflow-hidden p-1 max-w-[calc(100vw-32px)]`,f),t[2]=f,t[3]=p);let m;t[4]!==l||t[5]!==s||t[6]!==u||t[7]!==o?(m=l?(0,q.jsx)(ye,{onSelect:()=>u(!1),variant:o,scopeProjectId:s}):null,t[4]=l,t[5]=s,t[6]=u,t[7]=o,t[8]=m):m=t[8];let g;t[9]!==c||t[10]!==p||t[11]!==m?(g=(0,q.jsx)(I,{align:c,sideOffset:6,className:p,children:m}),t[9]=c,t[10]=p,t[11]=m,t[12]=g):g=t[12];let v;return t[13]!==l||t[14]!==u||t[15]!==d||t[16]!==g?(v=(0,q.jsxs)(L,{open:l,onOpenChange:u,modal:!1,children:[d,g]}),t[13]=l,t[14]=u,t[15]=d,t[16]=g,t[17]=v):v=t[17],v}function _e(e){return e.setSessionDropdownOpen}function ve(e){return e.isSessionDropdownOpen}function ye(e){let t=(0,G.c)(7),{onSelect:n,variant:r,scopeProjectId:i}=e,a;t[0]===i?a=t[1]:(a=e=>e.projects.find(t=>t.id===(i??e.activeProjectId)),t[0]=i,t[1]=a);let o=S(a),s;return t[2]!==n||t[3]!==o||t[4]!==i||t[5]!==r?(s=o?.hostId?(0,q.jsx)(Ce,{projectId:o.id,hostId:o.hostId,hubId:o.hubId,onSelect:n,variant:r},`${o.hubId}:${o.hostId}:${o.id}`):(0,q.jsx)(be,{onSelect:n,variant:r,scopeProjectId:i}),t[2]=n,t[3]=o,t[4]=i,t[5]=r,t[6]=s):s=t[6],s}function be(e){let t=(0,G.c)(27),{onSelect:n,variant:r,scopeProjectId:i}=e,o;t[0]===i?o=t[1]:(o={scopeProjectId:i},t[0]=i,t[1]=o);let s=se(!0,o),c=E(Se),l=h(xe),{t:u}=ee(),d;t[2]!==n||t[3]!==c||t[4]!==l?(d=()=>{l(`chat`),n(),c()},t[2]=n,t[3]=c,t[4]=l,t[5]=d):d=t[5];let f=m(d),p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=new Set,t[6]=p):p=t[6];let[g,y]=K.useState(p),b;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(b=e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},t[7]=b):b=t[7];let x=m(b),S,C;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(S=_(`group relative flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none`,`data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover`),C=(0,q.jsx)(v,{name:`chat-new`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}),t[8]=S,t[9]=C):(S=t[8],C=t[9]);let w;t[10]===u?w=t[11]:(w=u(`sessions.sidebar.header.actions.newSession`),t[10]=u,t[11]=w);let T;t[12]===w?T=t[13]:(T=(0,q.jsx)(`span`,{className:`truncate text-[14px] font-normal leading-tight text-foreground`,children:w}),t[12]=w,t[13]=T);let D;t[14]!==f||t[15]!==T?(D=(0,q.jsxs)(a,{onClick:f,className:S,children:[C,T]}),t[14]=f,t[15]=T,t[16]=D):D=t[16];let O;t[17]!==g||t[18]!==s||t[19]!==n||t[20]!==u||t[21]!==x||t[22]!==r?(O=s.length===0?(0,q.jsx)(`div`,{className:`px-3 py-4 text-center typography-meta text-muted-foreground`,children:u(`sessions.switcher.empty`)}):s.map(e=>(0,q.jsx)(De,{item:e,depth:0,variant:r,expandedParents:g,toggleParent:x,closeDropdown:n},e.node.session.id)),t[17]=g,t[18]=s,t[19]=n,t[20]=u,t[21]=x,t[22]=r,t[23]=O):O=t[23];let k;return t[24]!==O||t[25]!==D?(k=(0,q.jsx)(`div`,{className:`max-h-[60vh] overflow-y-auto`,children:(0,q.jsxs)(`div`,{className:`space-y-0.5`,children:[D,O]})}),t[24]=O,t[25]=D,t[26]=k):k=t[26],k}function xe(e){return e.setActiveMainTab}function Se(e){return e.openNewSessionDraft}function Ce(e){let t=(0,G.c)(24),{projectId:n,hostId:r,hubId:i,onSelect:a,variant:o}=e,s=k(!0),c;t[0]!==r||t[1]!==i||t[2]!==n||t[3]!==s.catalog?.hubId||t[4]!==s.catalog?.projects?(c=!i||i===s.catalog?.hubId?s.catalog?.projects.find(e=>e.id===n&&e.hostId===r):void 0,t[0]=r,t[1]=i,t[2]=n,t[3]=s.catalog?.hubId,t[4]=s.catalog?.projects,t[5]=c):c=t[5];let l=c,{t:u}=ee(),d=m(we),f;t[6]!==l||t[7]!==s.error?.message||t[8]!==s.isPending||t[9]!==s.registry||t[10]!==u?(f=s.error?.message??(!s.isPending&&(!s.registry||!l)?u(`remoteProjects.host-unavailable`):void 0),t[6]=l,t[7]=s.error?.message,t[8]=s.isPending,t[9]=s.registry,t[10]=u,t[11]=f):f=t[11];let p=f,h,_;t[12]!==p||t[13]!==r||t[14]!==i?(h=()=>{p&&O.error(p,{id:`remote-switcher:${i}:${r}:catalog`})},_=[p,i,r],t[12]=p,t[13]=r,t[14]=i,t[15]=h,t[16]=_):(h=t[15],_=t[16]),K.useEffect(h,_);let v;return t[17]!==a||t[18]!==l||t[19]!==d||t[20]!==s.registry||t[21]!==u||t[22]!==o?(v=s.registry&&l?(0,q.jsx)(Te,{registry:s.registry,project:l,onSelect:a,variant:o}):(0,q.jsx)(`div`,{className:`px-3 py-4`,children:(0,q.jsx)(g,{size:`xs`,variant:`ghost`,onClick:()=>void d(),children:u(`remoteProjects.retry`)})}),t[17]=a,t[18]=l,t[19]=d,t[20]=s.registry,t[21]=u,t[22]=o,t[23]=v):v=t[23],v}async function we(){try{await A()}catch(e){let t=e;O.error(t instanceof Error?t.message:String(t))}}function Te({registry:e,project:t,onSelect:n,variant:r}){let{t:i}=ee(),o=f(e,t.hostId),s=j(e,t.hostId),c=S(e=>e.projects),l=b(e=>e.remoteSession),u=h(e=>e.isMobile),d=s.data,g=o?.state===`connected`&&t.remoteState===`ok`&&!d?.stale,_=K.useMemo(()=>{let n=new Set(d?.pinnedSessionIds??[]),r=new Map,i=n=>(r.has(n)||r.set(n,p(c,e.hubId,t.hostId,n,d?.worktrees)?.id===t.id),r.get(n));return(d?.directories??[]).flatMap(({directory:e,sessions:t})=>t.filter(e=>!e.parentID&&!e.time.archived).map(t=>({session:t,directory:t.directory||e}))).filter(({directory:e})=>i(e)).sort((e,t)=>V(e.session,t.session,n)).slice(0,7)},[d,c,t.hostId,t.id,e.hubId]),y=s.error?.message,{refetch:x}=s;K.useEffect(()=>{y&&O.error(y,{id:`remote-project:${t.id}:load`,action:{label:i(`remoteProjects.retry`),onClick:()=>void x()}})},[y,t.id,x,i]);let C=m((r,a)=>{try{if(p(c,e.hubId,t.hostId,a,d?.worktrees)?.id!==t.id)throw Error(i(`remoteProjects.host-unavailable`));W(t,e,r,a,u),n()}catch(e){O.error(e instanceof Error?e.message:String(e))}}),w=l?.projectId===t.id&&l.location.hostId===t.hostId&&l.location.hubId===e.hubId?l.location.directory:t.path;return(0,q.jsx)(`div`,{className:`max-h-[60vh] overflow-y-auto`,children:(0,q.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,q.jsxs)(a,{onClick:()=>C(null,w),className:`group relative flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover`,children:[(0,q.jsx)(v,{name:`chat-new`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,q.jsx)(`span`,{className:`truncate text-[14px] font-normal leading-tight text-foreground`,children:i(`sessions.sidebar.header.actions.newSession`)})]}),g?null:(0,q.jsxs)(`div`,{role:`status`,className:`px-3 typography-meta text-muted-foreground`,children:[i(`remoteProjects.state.${o?.state??`offline`}`),` · `,i(`remoteProjects.unknown`)]}),!_.length&&d?(0,q.jsx)(`div`,{className:`px-3 py-4 text-center typography-meta text-muted-foreground`,children:i(`sessions.switcher.empty`)}):null,_.map(({session:n,directory:i})=>(0,q.jsx)(Ee,{registry:e,project:t,projects:c,session:n,directory:i,variant:r,snapshot:d,online:g,navigate:C,selected:l,depth:0,ancestors:[]},`${i}:${n.id}`))]})})}function Ee({registry:e,project:t,projects:n,session:r,directory:i,variant:a,snapshot:o,online:s,navigate:l,selected:f,depth:h,ancestors:_}){let{t:v}=ee(),[y,b]=K.useState(!1),[x,S]=K.useState(30),C=e.resolve({hubId:e.hubId,hostId:t.hostId,directory:i}),w=K.useMemo(()=>({...D(i,void 0,void 0,void 0,C),enabled:!1,staleTime:1/0,gcTime:1/0}),[C,i]),T=u(w,d).data?.current,E=u({queryKey:[...C.queryScope,`navigation-children`,r.id,x],enabled:y&&s,staleTime:3e4,gcTime:1/0,placeholderData:(e,t)=>t&&C.queryScope.every((e,n)=>t.queryKey[n]===e)&&t.queryKey[C.queryScope.length+1]===r.id?e:void 0,queryFn:async({signal:t})=>{let n=[],a,o=!1;for(let s=0;s<Math.ceil(x/30);s++){let s=await C.sdk().session.list({directory:i,parentID:r.id,limit:30,...a?{cursor:a}:{}},{signal:t});if(e.assertCurrent(),C.sdk(),!Array.isArray(s.data))throw Error(`Remote child session list returned no data`);n.push(...s.data.map(c).filter(e=>!e.time?.archived).map(e=>({...e,directory:e.directory||i,time:e.time??{}})));let l=s.cursor?.next||void 0;if(o=!!(l&&l!==a),!o)break;a=l}return{sessions:n,hasMore:o}}},d),{error:k,refetch:A}=E;K.useEffect(()=>{k&&O.error(k.message,{id:`remote-children:${C.key}:${r.id}`,action:{label:v(`remoteProjects.retry`),onClick:()=>void A()}})},[k,C.key,r.id,A,v]);let j=m(({directory:e,payload:t})=>{e&&e!==i||t&&typeof t==`object`&&`type`in t&&typeof t.type==`string`&&/^(session\.(created|updated|deleted|status)|yuri:session-metadata)$/.test(t.type)&&d.invalidateQueries({queryKey:[...C.queryScope,`navigation-children`,r.id,x],exact:!0})});K.useEffect(()=>{if(y&&s)return e.subscribeEvents(t.hostId,j)},[e,t.hostId,i,y,s,j]);let M=o?.directories.flatMap(e=>e.sessions.filter(e=>e.parentID===r.id).map(t=>({...t,directory:t.directory||e.directory})))??[],N=(E.data?.sessions??M).filter(a=>a.id!==r.id&&!_.includes(a.id)&&p(n,e.hubId,t.hostId,a.directory||i,o?.worktrees)?.id===t.id),P=r.metadata?.yuri?.sessionStatus?.type,F=f?.projectId===t.id&&f.location.hubId===e.hubId&&f.location.hostId===t.hostId&&f.location.directory===i&&f.sessionId===r.id;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(je,{session:r,depth:h,variant:a,secondaryMeta:{projectLabel:t.label??t.path.split(/[\\/]/).filter(Boolean).at(-1),branchLabel:T},hasChildren:!!(r.hasChildren||N.length||h>0),isExpanded:y,onToggleExpand:()=>b(e=>!e),isActive:F,unseenCount:o?.unread?.sessions[r.id]?.unreadCount??0,statusType:s?P??`idle`:`unknown`,handleSelect:()=>l(r.id,i)}),y?(0,q.jsxs)(q.Fragment,{children:[N.map(c=>(0,q.jsx)(Ee,{registry:e,project:t,projects:n,variant:a,snapshot:o,online:s,navigate:l,selected:f,directory:c.directory||i,session:c,depth:h+1,ancestors:[..._,r.id]},c.id)),E.data?.hasMore?(0,q.jsx)(g,{size:`xs`,variant:`ghost`,disabled:!s||E.isFetching,onClick:()=>S(e=>e+30),children:v(`remoteProjects.showMore`)}):null]}):null]})}function De(e){let t=(0,G.c)(31),{item:n,depth:r,variant:i,expandedParents:a,toggleParent:o,closeDropdown:s}=e,{node:c,secondaryMeta:l}=n,u=c.session,d=c.children.length>0,f;t[0]!==a||t[1]!==u.id?(f=a.has(u.id),t[0]=a,t[1]=u.id,t[2]=f):f=t[2];let p=f,m;t[3]!==d||t[4]!==u.id||t[5]!==o?(m=d?()=>o(u.id):void 0,t[3]=d,t[4]=u.id,t[5]=o,t[6]=m):m=t[6];let h;t[7]!==s||t[8]!==r||t[9]!==d||t[10]!==p||t[11]!==l||t[12]!==u||t[13]!==m||t[14]!==i?(h=(0,q.jsx)(Oe,{session:u,depth:r,variant:i,secondaryMeta:l,hasChildren:d,isExpanded:p,onToggleExpand:m,closeDropdown:s}),t[7]=s,t[8]=r,t[9]=d,t[10]=p,t[11]=l,t[12]=u,t[13]=m,t[14]=i,t[15]=h):h=t[15];let g;t[16]!==s||t[17]!==r||t[18]!==a||t[19]!==d||t[20]!==p||t[21]!==n.groupDirectory||t[22]!==n.projectId||t[23]!==c.children||t[24]!==l||t[25]!==o||t[26]!==i?(g=d&&p?c.children.map(e=>(0,q.jsx)(De,{item:{node:e,projectId:n.projectId,groupDirectory:n.groupDirectory,secondaryMeta:l},depth:r+1,variant:i,expandedParents:a,toggleParent:o,closeDropdown:s},e.session.id)):null,t[16]=s,t[17]=r,t[18]=a,t[19]=d,t[20]=p,t[21]=n.groupDirectory,t[22]=n.projectId,t[23]=c.children,t[24]=l,t[25]=o,t[26]=i,t[27]=g):g=t[27];let _;return t[28]!==h||t[29]!==g?(_=(0,q.jsxs)(q.Fragment,{children:[h,g]}),t[28]=h,t[29]=g,t[30]=_):_=t[30],_}function Oe(e){let t=(0,G.c)(17),{session:n,depth:r,variant:i,secondaryMeta:a,hasChildren:o,isExpanded:s,onToggleExpand:c,closeDropdown:l}=e,u=E(Ae),d=E(ke),f=y(n.id),p=w(n.id),h=u===n.id,g;t[0]!==l||t[1]!==h||t[2]!==n||t[3]!==d?(g=()=>{h||d(n.id,T(n)??null),l()},t[0]=l,t[1]=h,t[2]=n,t[3]=d,t[4]=g):g=t[4];let _=m(g),v=f?.type??`idle`,b;return t[5]!==r||t[6]!==_||t[7]!==o||t[8]!==h||t[9]!==s||t[10]!==c||t[11]!==a||t[12]!==n||t[13]!==v||t[14]!==p||t[15]!==i?(b=(0,q.jsx)(je,{session:n,depth:r,variant:i,secondaryMeta:a,hasChildren:o,isExpanded:s,onToggleExpand:c,isActive:h,unseenCount:p,statusType:v,handleSelect:_}),t[5]=r,t[6]=_,t[7]=o,t[8]=h,t[9]=s,t[10]=c,t[11]=a,t[12]=n,t[13]=v,t[14]=p,t[15]=i,t[16]=b):b=t[16],b}function ke(e){return e.setCurrentSession}function Ae(e){return e.currentSessionId}function je(e){let t=(0,G.c)(57),{session:n,depth:r,variant:i,secondaryMeta:o,hasChildren:s,isExpanded:c,onToggleExpand:l,isActive:u,unseenCount:d,statusType:f,handleSelect:p}=e,{t:m}=ee(),h;t[0]!==n.title||t[1]!==m?(h=n.title?.trim()||m(`sessions.sidebar.session.untitled`),t[0]=n.title,t[1]=m,t[2]=h):h=t[2];let g=h,y;t[3]===n?y=t[4]:(y=U(H(n)),t[3]=n,t[4]=y);let b=y,x=!!n.parentID,S=d>0&&!x,C=f===`busy`||f===`retry`,w=!C&&S,T;t[5]!==n.time?.created||t[6]!==n.time?.updated?(T=n.time?.updated||n.time?.created||Date.now(),t[5]=n.time?.created,t[6]=n.time?.updated,t[7]=T):T=t[7];let E=T,D;t[8]===E?D=t[9]:(D=B(E),t[8]=E,t[9]=D);let O=D,k;t[10]===o?.projectLabel?k=t[11]:(k=o?.projectLabel?.trim()||null,t[10]=o?.projectLabel,t[11]=k);let A=k,j;t[12]===o?.branchLabel?j=t[13]:(j=o?.branchLabel?.trim()||null,t[12]=o?.branchLabel,t[13]=j);let M=j,N=M&&M!==`HEAD`?M:null,P;t[14]===p?P=t[15]:(P=e=>{if(e.target?.closest(`[data-switcher-expand]`)){e.preventDefault();return}p()},t[14]=p,t[15]=P);let F;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(F=_(`group relative flex w-full cursor-pointer items-start gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none`,`data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover`),t[16]=F):F=t[16];let I=8+r*12,L;t[17]===I?L=t[18]:(L={paddingLeft:I},t[17]=I,t[18]=L);let R;t[19]!==s||t[20]!==c||t[21]!==l||t[22]!==m||t[23]!==i?(R=i===`compact`&&s?(0,q.jsx)(`span`,{role:`button`,tabIndex:-1,"data-switcher-expand":!0,onClick:e=>{e.preventDefault(),e.stopPropagation(),l?.()},className:`inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground`,"aria-label":m(c?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),children:c?(0,q.jsx)(v,{name:`arrow-down-s`,className:`h-3.5 w-3.5`}):(0,q.jsx)(v,{name:`arrow-right-s`,className:`h-3.5 w-3.5`})}):null,t[19]=s,t[20]=c,t[21]=l,t[22]=m,t[23]=i,t[24]=R):R=t[24];let z=u?`text-primary`:`text-foreground`,V;t[25]===z?V=t[26]:(V=_(`min-w-0 truncate text-[14px] font-normal leading-tight`,z),t[25]=z,t[26]=V);let te;t[27]!==g||t[28]!==V?(te=(0,q.jsx)(`span`,{className:V,children:g}),t[27]=g,t[28]=V,t[29]=te):te=t[29];let ne;t[30]===b?ne=t[31]:(ne=b?(0,q.jsx)(`span`,{className:`shrink-0 text-[12px] tabular-nums text-muted-foreground`,children:b}):null,t[30]=b,t[31]=ne);let re;t[32]!==R||t[33]!==te||t[34]!==ne?(re=(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[R,te,ne]}),t[32]=R,t[33]=te,t[34]=ne,t[35]=re):re=t[35];let W;t[36]!==N||t[37]!==s||t[38]!==c||t[39]!==l||t[40]!==A||t[41]!==m||t[42]!==O||t[43]!==i?(W=i==="default"?(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 truncate text-muted-foreground/70 leading-tight`,style:{fontSize:`calc(var(--text-ui-label) * 0.85)`},children:[s?(0,q.jsx)(`span`,{role:`button`,tabIndex:-1,"data-switcher-expand":!0,onClick:e=>{e.preventDefault(),e.stopPropagation(),l?.()},className:`inline-flex h-3 w-3 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground`,"aria-label":m(c?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),children:c?(0,q.jsx)(v,{name:`arrow-down-s`,className:`h-3 w-3`}):(0,q.jsx)(v,{name:`arrow-right-s`,className:`h-3 w-3`})}):null,(0,q.jsx)(`span`,{className:`flex-shrink-0`,children:O}),A?(0,q.jsx)(`span`,{className:`truncate`,children:A}):null,N?(0,q.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-0.5`,children:[(0,q.jsx)(v,{name:`git-branch`,className:`h-3 w-3 flex-shrink-0 text-muted-foreground/70`}),(0,q.jsx)(`span`,{className:`truncate`,children:N})]}):null]}):null,t[36]=N,t[37]=s,t[38]=c,t[39]=l,t[40]=A,t[41]=m,t[42]=O,t[43]=i,t[44]=W):W=t[44];let K;t[45]!==re||t[46]!==W?(K=(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[re,W]}),t[45]=re,t[46]=W,t[47]=K):K=t[47];let J;t[48]!==C||t[49]!==w||t[50]!==m?(J=C||w?(0,q.jsx)(`span`,{className:`flex h-3 w-3 flex-shrink-0 items-center justify-center self-center`,children:C?(0,q.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary animate-busy-pulse`,"aria-label":m(`sessions.sidebar.session.status.active`),title:m(`sessions.sidebar.session.status.active`)}):(0,q.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--status-info)]`,"aria-label":m(`sessions.sidebar.session.status.unread`),title:m(`sessions.sidebar.session.status.unread`)})}):null,t[48]=C,t[49]=w,t[50]=m,t[51]=J):J=t[51];let ie;return t[52]!==L||t[53]!==K||t[54]!==J||t[55]!==P?(ie=(0,q.jsxs)(a,{onClick:P,"data-slot":`session-switcher-item`,className:F,style:L,children:[K,J]}),t[52]=L,t[53]=K,t[54]=J,t[55]=P,t[56]=ie):ie=t[56],ie}var Me=K.memo(function(e){let t=(0,G.c)(45),{visible:i,position:a}=e,o=a===void 0?`right`:a,{t:s}=ee(),[c,l]=K.useState(!1),u,d;if(t[0]===i?(u=t[1],d=t[2]):(u=()=>{if(!i)return;let e=!1;n(`desktop_get_current_window_state`).then(t=>{e||l(!!t?.maximized)}).catch(Ne);let t=e=>{let t=e.detail;l(!!t?.maximized)};return window.addEventListener(`yuri:window-maximized-changed`,t),()=>{e=!0,window.removeEventListener(`yuri:window-maximized-changed`,t)}},d=[i],t[0]=i,t[1]=u,t[2]=d),(0,K.useEffect)(u,d),!i)return null;let f;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=r(),t[3]=f):f=t[3];let p=f===`win32`,m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=_(`app-region-no-drag inline-flex h-12 w-11 items-center justify-center text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,p&&`bg-[var(--surface-background)] backdrop-blur-none`),t[4]=m):m=t[4];let h=m,g=o===`left`?`app-region-no-drag -ml-3 mr-2 flex h-12 shrink-0 items-center`:`app-region-no-drag -mr-3 ml-2 flex h-12 shrink-0 items-center`,y;t[5]===g?y=t[6]:(y=_(g,p&&`bg-[var(--surface-background)] backdrop-blur-none`),t[5]=g,t[6]=y);let b=y,x;t[7]===s?x=t[8]:(x=s(`header.windowControls.groupAria`),t[7]=s,t[8]=x);let S;t[9]===s?S=t[10]:(S=s(`header.windowControls.minimize`),t[9]=s,t[10]=S);let C;t[11]===s?C=t[12]:(C=s(`header.windowControls.minimize`),t[11]=s,t[12]=C);let w;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,q.jsx)(v,{name:`subtract`,className:`h-4 w-4`}),t[13]=w):w=t[13];let T;t[14]!==C||t[15]!==S?(T=(0,q.jsx)(`button`,{type:`button`,className:h,onClick:Pe,title:S,"aria-label":C,children:w}),t[14]=C,t[15]=S,t[16]=T):T=t[16];let E;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>{n(`desktop_toggle_current_window_maximized`).then(e=>l(!!e?.maximized)).catch(Fe)},t[17]=E):E=t[17];let D;t[18]!==c||t[19]!==s?(D=s(c?`header.windowControls.restore`:`header.windowControls.maximize`),t[18]=c,t[19]=s,t[20]=D):D=t[20];let O;t[21]!==c||t[22]!==s?(O=s(c?`header.windowControls.restore`:`header.windowControls.maximize`),t[21]=c,t[22]=s,t[23]=O):O=t[23];let k=c?`fullscreen-exit`:`checkbox-blank`,A;t[24]===k?A=t[25]:(A=(0,q.jsx)(v,{name:k,className:`h-3.5 w-3.5`}),t[24]=k,t[25]=A);let j;t[26]!==D||t[27]!==O||t[28]!==A?(j=(0,q.jsx)(`button`,{type:`button`,className:h,onClick:E,title:D,"aria-label":O,children:A}),t[26]=D,t[27]=O,t[28]=A,t[29]=j):j=t[29];let M;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(M=_(h,`hover:bg-status-error hover:text-status-error-foreground`),t[30]=M):M=t[30];let N;t[31]===s?N=t[32]:(N=s(`header.windowControls.close`),t[31]=s,t[32]=N);let P;t[33]===s?P=t[34]:(P=s(`header.windowControls.close`),t[33]=s,t[34]=P);let F;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,q.jsx)(v,{name:`close`,className:`h-4 w-4`}),t[35]=F):F=t[35];let I;t[36]!==N||t[37]!==P?(I=(0,q.jsx)(`button`,{type:`button`,className:M,onClick:Ie,title:N,"aria-label":P,children:F}),t[36]=N,t[37]=P,t[38]=I):I=t[38];let L;return t[39]!==b||t[40]!==T||t[41]!==j||t[42]!==I||t[43]!==x?(L=(0,q.jsxs)(`div`,{className:b,"aria-label":x,children:[T,j,I]}),t[39]=b,t[40]=T,t[41]=j,t[42]=I,t[43]=x,t[44]=L):L=t[44],L});function Ne(){}function Pe(){n(`desktop_minimize_current_window`)}function Fe(){}function Ie(){n(`desktop_close_current_window`)}function Le(){let e=(0,G.c)(5),n=h(Re),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=i(),e[0]=r):r=e[0];let a=r,o;e[1]===n?o=e[2]:(o=t(n),e[1]=n,e[2]=o);let s=o,c;return e[3]===s?c=e[4]:(c={usesFramelessChrome:a,side:s},e[3]=s,e[4]=c),c}function Re(e){return e.desktopWindowControlsPosition}export{J as i,Me as n,ge as r,Le as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Y as t,j as n,k as r,ot as i}from"./platform-CiUKDeXd.js";import{H as a,ot as o,st as s}from"./vendor-base-ui-wXsskyKm.js";import{dr as c}from"./client-B_907PBv.js";import{n as l}from"./vendor-react-BkccXcWz.js";import{s as u}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{c as d}from"./yuriEvents-BFrD5fMU.js";import{D as f,P as p}from"./runtime-file-resource-Bc_ss-sW.js";import{r as m}from"./vendor-reactuses-core-DjKFMfz7.js";import{r as h}from"./useUIStore-C3ewjGgP.js";import{i as g,o as _}from"./session-startup-barrier-DT-hIBRf.js";import{n as v}from"./Icon-DmykXZL1.js";import{G as y,Ia as b,Mi as x,Na as S,Oi as C,Rr as w,Ti as T,f as E,qn as D,t as O}from"./ui-DyxdnQlj.js";import{m as k,n as A,p as j}from"./remoteProjectQueries-C8382jM8.js";import{t as ee}from"./i18n-DXc6czdR.js";import{i as M,n as N,t as P}from"./tooltip-CpTbxEOE.js";import{c as F,n as I,t as L}from"./dropdown-menu-BblI9sN2.js";import{s as R}from"./useGitStore-B6LCPegX.js";import{b as z,h as B,p as V}from"./pwa-CmLnRiAE.js";import{t as te}from"./MobileOverlayPanel-C36VWWmN.js";import{l as ne,r as re}from"./quota-CqWNkFzw.js";import{a as H,i as U}from"./sessionLookup-9xT7pc4Q.js";import{n as W}from"./openRemoteProjectSession-Driv6jop.js";var G=l(),K=e(s(),1),q=o(),J=e=>{let t=(0,G.c)(179),{pending:n,totalTokens:r,percentage:i,colorPercentage:a,contextLimit:o,outputLimit:s,size:c,isMobile:l,hideIcon:u,showPercentIcon:d,appearance:f,className:p,valueClassName:m,percentIconClassName:h,onClick:g,pressed:y}=e,b=n!==void 0&&n,x=c===void 0?`default`:c,S=l!==void 0&&l,C=u!==void 0&&u,w=d!==void 0&&d,T=f===void 0?`default`:f,E=y!==void 0&&y,{t:D}=ee(),[O,k]=K.useState(!1),A=typeof a==`number`?a:i,j,F,I,L,R,z,B,V,H,U,W,J,oe,Y,X,se,ce,Z,le,Q,$;if(t[0]!==T||t[1]!==A||t[2]!==o||t[3]!==S||t[4]!==g||t[5]!==s||t[6]!==b||t[7]!==h||t[8]!==i||t[9]!==D||t[10]!==r){let e=b?0:re(i)??0;U=T===`subtle`;let n=ne(A);W=U||b?`var(--surface-muted-foreground)`:n===`critical`?`var(--status-error)`:n===`warn`?`var(--status-warning)`:`var(--status-success)`,B=ie;let a;t[32]===b?a=t[33]:(a=e=>b?`text-muted-foreground`:e>=90?`text-status-error`:e>=75?`text-status-warning`:`text-status-success`,t[32]=b,t[33]=a),V=a,L=U?18:20,R=U?2:3,I=(L-R)/2,j=2*Math.PI*I,F=j*(1-e/100),J=typeof s==`number`?Math.max(s,0):0;let c;t[34]!==o||t[35]!==b||t[36]!==i||t[37]!==J||t[38]!==D||t[39]!==r?(Q=b?D(`contextUsage.pending`):`${Math.min(i,999).toFixed(1)}%`,$=b?`—`:B(r),z=B(o),c=b?[D(`contextUsage.pendingDescription`)]:[D(`contextUsage.tooltip.usage`,{percent:Q}),D(`contextUsage.tooltip.usedOfLimit`,{used:$,limit:z}),D(`contextUsage.tooltip.outputLimit`,{tokens:B(J)})],t[34]=o,t[35]=b,t[36]=i,t[37]=J,t[38]=D,t[39]=r,t[40]=z,t[41]=c,t[42]=Q,t[43]=$):(z=t[40],c=t[41],Q=t[42],$=t[43]),le=c,H=!S&&typeof g==`function`,ce=`0 0 ${L} ${L}`;let l=U?`h-4 w-4 shrink-0 -rotate-90 text-muted-foreground/70`:`h-3.5 w-3.5 -rotate-90`;t[44]!==h||t[45]!==l?(Z=_(l,h),t[44]=h,t[45]=l,t[46]=Z):Z=t[46],oe=`progressbar`,t[47]===D?Y=t[48]:(Y=D(`contextUsage.aria.label`),t[47]=D,t[48]=Y),t[49]!==b||t[50]!==D?(X=b?D(`contextUsage.pending`):void 0,t[49]=b,t[50]=D,t[51]=X):X=t[51],se=b?void 0:Math.round(e),t[0]=T,t[1]=A,t[2]=o,t[3]=S,t[4]=g,t[5]=s,t[6]=b,t[7]=h,t[8]=i,t[9]=D,t[10]=r,t[11]=j,t[12]=F,t[13]=I,t[14]=L,t[15]=R,t[16]=z,t[17]=B,t[18]=V,t[19]=H,t[20]=U,t[21]=W,t[22]=J,t[23]=oe,t[24]=Y,t[25]=X,t[26]=se,t[27]=ce,t[28]=Z,t[29]=le,t[30]=Q,t[31]=$}else j=t[11],F=t[12],I=t[13],L=t[14],R=t[15],z=t[16],B=t[17],V=t[18],H=t[19],U=t[20],W=t[21],J=t[22],oe=t[23],Y=t[24],X=t[25],se=t[26],ce=t[27],Z=t[28],le=t[29],Q=t[30],$=t[31];let ue=L/2,de=L/2,fe;t[52]!==I||t[53]!==R||t[54]!==ue||t[55]!==de?(fe=(0,q.jsx)(`circle`,{cx:ue,cy:de,r:I,fill:`none`,stroke:`var(--interactive-border)`,strokeWidth:R}),t[52]=I,t[53]=R,t[54]=ue,t[55]=de,t[56]=fe):fe=t[56];let pe=L/2,me=L/2,he;t[57]!==j||t[58]!==F||t[59]!==I||t[60]!==R||t[61]!==W||t[62]!==pe||t[63]!==me?(he=(0,q.jsx)(`circle`,{cx:pe,cy:me,r:I,fill:`none`,stroke:W,strokeWidth:R,strokeLinecap:`round`,strokeDasharray:j,strokeDashoffset:F,className:`transition-[stroke-dashoffset,stroke] duration-300`}),t[57]=j,t[58]=F,t[59]=I,t[60]=R,t[61]=W,t[62]=pe,t[63]=me,t[64]=he):he=t[64];let ge;t[65]!==oe||t[66]!==Y||t[67]!==X||t[68]!==se||t[69]!==fe||t[70]!==he||t[71]!==ce||t[72]!==Z?(ge=(0,q.jsxs)(`svg`,{viewBox:ce,className:Z,role:oe,"aria-label":Y,"aria-valuetext":X,"aria-valuenow":se,"aria-valuemin":0,"aria-valuemax":100,children:[fe,he]}),t[65]=oe,t[66]=Y,t[67]=X,t[68]=se,t[69]=fe,t[70]=he,t[71]=ce,t[72]=Z,t[73]=ge):ge=t[73];let _e=ge,ve=E||b?`ml-1 max-w-[14rem] opacity-100`:`ml-0 max-w-0 opacity-0 group-hover:ml-1 group-hover:max-w-[14rem] group-hover:opacity-100 group-focus-visible:ml-1 group-focus-visible:max-w-[14rem] group-focus-visible:opacity-100`,ye;t[74]===ve?ye=t[75]:(ye=_(`inline-flex items-center gap-1.5 overflow-hidden whitespace-nowrap typography-micro font-medium text-foreground transition-[max-width,opacity,margin] duration-200`,ve),t[74]=ve,t[75]=ye);let be;t[76]===Q?be=t[77]:(be=(0,q.jsx)(`span`,{children:Q}),t[76]=Q,t[77]=be);let xe;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(xe=(0,q.jsx)(`span`,{className:`mx-0.5 text-muted-foreground/60`,children:`/`}),t[78]=xe):xe=t[78];let Se;t[79]!==z||t[80]!==$?(Se=(0,q.jsxs)(`span`,{className:`text-muted-foreground`,children:[$,xe,z]}),t[79]=z,t[80]=$,t[81]=Se):Se=t[81];let Ce;t[82]!==ye||t[83]!==be||t[84]!==Se?(Ce=(0,q.jsxs)(`span`,{className:ye,children:[be,Se]}),t[82]=ye,t[83]=be,t[84]=Se,t[85]=Ce):Ce=t[85];let we=Ce,Te;t[86]!==A||t[87]!==V||t[88]!==C||t[89]!==S||t[90]!==U||t[91]!==b||t[92]!==i||t[93]!==_e||t[94]!==w||t[95]!==we||t[96]!==Q||t[97]!==m?(Te=U?(0,q.jsxs)(q.Fragment,{children:[_e,we]}):(0,q.jsxs)(q.Fragment,{children:[!S&&!C&&(0,q.jsx)(v,{name:`donut-chart`,className:`h-4 w-4 flex-shrink-0`}),(0,q.jsx)(`span`,{className:_(`font-medium inline-flex items-center gap-1.5`,m),children:b?(0,q.jsxs)(q.Fragment,{children:[w&&_e,(0,q.jsx)(`span`,{className:`text-muted-foreground`,children:Q})]}):w?(0,q.jsxs)(q.Fragment,{children:[_e,(0,q.jsx)(`span`,{className:`text-foreground`,children:Q})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:V(A),children:Math.min(i,999).toFixed(1)}),`%`]})})]}),t[86]=A,t[87]=V,t[88]=C,t[89]=S,t[90]=U,t[91]=b,t[92]=i,t[93]=_e,t[94]=w,t[95]=we,t[96]=Q,t[97]=m,t[98]=Te):Te=t[98];let Ee=Te,De=U?`gap-0`:`gap-1.5`,Oe=x===`compact`?`typography-micro`:`typography-meta`,ke;t[99]!==p||t[100]!==H||t[101]!==U||t[102]!==E||t[103]!==De||t[104]!==Oe?(ke=_(`app-region-no-drag flex items-center select-none`,De,Oe,H?_(`group rounded-md text-foreground transition-colors`,U?_(`p-1.5 text-muted-foreground hover:text-foreground hover:bg-interactive-hover/50`,E&&`bg-interactive-hover/50 text-foreground`):`px-2 py-1.5 hover:bg-interactive-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`):`text-muted-foreground/60`,p),t[99]=p,t[100]=H,t[101]=U,t[102]=E,t[103]=De,t[104]=Oe,t[105]=ke):ke=t[105];let Ae=ke,je;t[106]!==Ee||t[107]!==H||t[108]!==S||t[109]!==g||t[110]!==E||t[111]!==Ae||t[112]!==D?(je=H?(0,q.jsx)(`button`,{type:`button`,className:Ae,"aria-label":D(`contextUsage.aria.label`),"aria-pressed":E,onClick:g,children:Ee}):(0,q.jsx)(`div`,{className:Ae,"aria-label":D(`contextUsage.aria.label`),onClick:S?()=>k(!0):void 0,children:Ee}),t[106]=Ee,t[107]=H,t[108]=S,t[109]=g,t[110]=E,t[111]=Ae,t[112]=D,t[113]=je):je=t[113];let Me=je;if(S){let e;t[114]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>k(!1),t[114]=e):e=t[114];let n;t[115]===D?n=t[116]:(n=D(`contextUsage.mobile.title`),t[115]=D,t[116]=n);let r;t[117]===D?r=t[118]:(r=D(`contextUsage.mobile.usedTokens`),t[117]=D,t[118]=r);let i;t[119]===r?i=t[120]:(i=(0,q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:r}),t[119]=r,t[120]=i);let a;t[121]===$?a=t[122]:(a=(0,q.jsx)(`span`,{className:`typography-meta text-foreground font-medium`,children:$}),t[121]=$,t[122]=a);let o;t[123]!==i||t[124]!==a?(o=(0,q.jsxs)(`div`,{className:`flex justify-between items-center`,children:[i,a]}),t[123]=i,t[124]=a,t[125]=o):o=t[125];let s;t[126]===D?s=t[127]:(s=D(`contextUsage.mobile.contextLimit`),t[126]=D,t[127]=s);let c;t[128]===s?c=t[129]:(c=(0,q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:s}),t[128]=s,t[129]=c);let l;t[130]===z?l=t[131]:(l=(0,q.jsx)(`span`,{className:`typography-meta text-foreground font-medium`,children:z}),t[130]=z,t[131]=l);let u;t[132]!==c||t[133]!==l?(u=(0,q.jsxs)(`div`,{className:`flex justify-between items-center`,children:[c,l]}),t[132]=c,t[133]=l,t[134]=u):u=t[134];let d;t[135]===D?d=t[136]:(d=D(`contextUsage.mobile.outputLimit`),t[135]=D,t[136]=d);let f;t[137]===d?f=t[138]:(f=(0,q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:d}),t[137]=d,t[138]=f);let p;t[139]!==B||t[140]!==J?(p=B(J),t[139]=B,t[140]=J,t[141]=p):p=t[141];let m;t[142]===p?m=t[143]:(m=(0,q.jsx)(`span`,{className:`typography-meta text-foreground font-medium`,children:p}),t[142]=p,t[143]=m);let h;t[144]!==f||t[145]!==m?(h=(0,q.jsxs)(`div`,{className:`flex justify-between items-center`,children:[f,m]}),t[144]=f,t[145]=m,t[146]=h):h=t[146];let g;t[147]===D?g=t[148]:(g=D(`contextUsage.mobile.usage`),t[147]=D,t[148]=g);let v;t[149]===g?v=t[150]:(v=(0,q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:g}),t[149]=g,t[150]=v);let y;t[151]!==A||t[152]!==V?(y=_(`typography-meta font-semibold`,V(A)),t[151]=A,t[152]=V,t[153]=y):y=t[153];let b;t[154]!==y||t[155]!==Q?(b=(0,q.jsx)(`span`,{className:y,children:Q}),t[154]=y,t[155]=Q,t[156]=b):b=t[156];let x;t[157]!==v||t[158]!==b?(x=(0,q.jsxs)(`div`,{className:`flex justify-between items-center pt-1 border-t border-border/40`,children:[v,b]}),t[157]=v,t[158]=b,t[159]=x):x=t[159];let S;t[160]!==o||t[161]!==u||t[162]!==h||t[163]!==x?(S=(0,q.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:(0,q.jsxs)(`div`,{className:`rounded-xl border border-border/40 bg-sidebar/30 px-3 py-2 space-y-1`,children:[o,u,h,x]})}),t[160]=o,t[161]=u,t[162]=h,t[163]=x,t[164]=S):S=t[164];let C;t[165]!==O||t[166]!==n||t[167]!==S?(C=(0,q.jsx)(te,{open:O,onClose:e,title:n,children:S}),t[165]=O,t[166]=n,t[167]=S,t[168]=C):C=t[168];let w;return t[169]!==Me||t[170]!==C?(w=(0,q.jsxs)(q.Fragment,{children:[Me,C]}),t[169]=Me,t[170]=C,t[171]=w):w=t[171],w}if(U)return Me;let Ne;t[172]===Me?Ne=t[173]:(Ne=(0,q.jsx)(M,{asChild:!0,children:Me}),t[172]=Me,t[173]=Ne);let Pe;t[174]===le?Pe=t[175]:(Pe=(0,q.jsx)(N,{children:(0,q.jsx)(`div`,{className:`space-y-0.5`,children:le.map(ae)})}),t[174]=le,t[175]=Pe);let Fe;return t[176]!==Ne||t[177]!==Pe?(Fe=(0,q.jsxs)(P,{children:[Ne,Pe]}),t[176]=Ne,t[177]=Pe,t[178]=Fe):Fe=t[178],Fe};function ie(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toFixed(1).replace(/\.0$/,``)}function ae(e){return(0,q.jsx)(`p`,{className:`typography-micro leading-tight`,children:e},e)}var oe=7,Y=e=>{if(!e)return null;let t=e.replace(/\\/g,`/`);return t===`/`?`/`:t.length>1?t.replace(/\/+$/,``):t},X=e=>{if(!e)return null;let t=e.path.split(/[\\/]/).filter(Boolean);return t[t.length-1]??null},se=(e,t)=>{let n=(0,G.c)(32),r;n[0]===t?r=n[1]:(r=t===void 0?{}:t,n[0]=t,n[1]=r);let{scopeProjectId:i}=r,a=i===void 0?null:i,o=C(ce),s=S(Z),c=x(),l;n[2]===s?l=n[3]:(l=s.map(le).filter(Q),n[2]=s,n[3]=l);let u=l,d;n[4]===u?d=n[5]:(d=e=>e?u.filter(t=>z(e,t.normalizedPath)).sort($)[0]??null:null,n[4]=u,n[5]=d);let f=d,p;bb0:{if(!e){let e;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],n[6]=e):e=n[6],p=e;break bb0}let t;if(n[7]!==o||n[8]!==f||n[9]!==c||n[10]!==a){let e;n[12]!==f||n[13]!==a?(e=e=>!a||f(T(e))?.id===a,n[12]=f,n[13]=a,n[14]=e):e=n[14];let r;n[15]===c?r=n[16]:(r=(e,t)=>V(e,t,c),n[15]=c,n[16]=r),t=Array.from(new Set(o.filter(ue).filter(de).filter(e).sort(r).slice(0,oe).map(fe).filter(pe))),n[7]=o,n[8]=f,n[9]=c,n[10]=a,n[11]=t}else t=n[11];p=t}let m=p,h;n[17]===Symbol.for(`react.memo_cache_sentinel`)?(h=new Map,n[17]=h):h=n[17];let g=K.useRef(h),_;n[18]===m?_=n[19]:(_=e=>{let t=g.current,n=t.size===m.length;if(n){for(let r of m)if(t.get(r)!==(e.directories.get(r)?.status?.current??null)){n=!1;break}}if(n)return t;let r=new Map;return m.forEach(t=>r.set(t,e.directories.get(t)?.status?.current??null)),g.current=r,r},n[18]=m,n[19]=_);let v=R(_),y;bb1:{if(!e){let e;n[20]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],n[20]=e):e=n[20],y=e;break bb1}let t;if(n[21]!==o||n[22]!==v||n[23]!==f||n[24]!==c||n[25]!==a){let e=new Map;for(let t of o){let n=t.parentID;if(!n||t.time?.archived)continue;let r=e.get(n);r?r.push(t):e.set(n,[t])}e.forEach(e=>{e.sort((e,t)=>V(e,t,c))});let r;n[27]!==f||n[28]!==a?(r=e=>{if(!a)return!0;let t=T(e);return f(t)?.id===a},n[27]=f,n[28]=a,n[29]=r):r=n[29];let i;n[30]===c?i=n[31]:(i=(e,t)=>V(e,t,c),n[30]=c,n[31]=i);let s=o.filter(me).filter(he).filter(r).sort(i).slice(0,oe),l=t=>({session:t,children:(e.get(t.id)??[]).map(e=>l(e)),worktree:null});t=s.map(e=>{let t=T(e),n=f(t),r=X(n),i=t?v.get(t)??null:null;return{node:l(e),projectId:n?.id??null,groupDirectory:t,secondaryMeta:{projectLabel:r,branchLabel:i&&i!==r?i:null}}}),n[21]=o,n[22]=v,n[23]=f,n[24]=c,n[25]=a,n[26]=t}else t=n[26];y=t}return y};function ce(e){return e.activeSessions}function Z(e){return e.projects}function le(e){return{...e,normalizedPath:Y(e.path)}}function Q(e){return e.normalizedPath}function $(e,t){return(t.normalizedPath?.length??0)-(e.normalizedPath?.length??0)}function ue(e){return!e.time?.archived}function de(e){return!e.parentID}function fe(e){return T(e)}function pe(e){return!!e}function me(e){return!e.time?.archived}function he(e){return!e.parentID}function ge(e){let t=(0,G.c)(18),{children:n,variant:r,scopeProjectId:i,align:a}=e,o=r===void 0?`default`:r,s=i===void 0?null:i,c=a===void 0?`start`:a,l=h(ve),u=h(_e),d;t[0]===n?d=t[1]:(d=(0,q.jsx)(F,{asChild:!0,children:n}),t[0]=n,t[1]=d);let f=o===`compact`?`w-[280px]`:`w-[360px]`,p;t[2]===f?p=t[3]:(p=_(`overflow-hidden p-1 max-w-[calc(100vw-32px)]`,f),t[2]=f,t[3]=p);let m;t[4]!==l||t[5]!==s||t[6]!==u||t[7]!==o?(m=l?(0,q.jsx)(ye,{onSelect:()=>u(!1),variant:o,scopeProjectId:s}):null,t[4]=l,t[5]=s,t[6]=u,t[7]=o,t[8]=m):m=t[8];let g;t[9]!==c||t[10]!==p||t[11]!==m?(g=(0,q.jsx)(I,{align:c,sideOffset:6,className:p,children:m}),t[9]=c,t[10]=p,t[11]=m,t[12]=g):g=t[12];let v;return t[13]!==l||t[14]!==u||t[15]!==d||t[16]!==g?(v=(0,q.jsxs)(L,{open:l,onOpenChange:u,modal:!1,children:[d,g]}),t[13]=l,t[14]=u,t[15]=d,t[16]=g,t[17]=v):v=t[17],v}function _e(e){return e.setSessionDropdownOpen}function ve(e){return e.isSessionDropdownOpen}function ye(e){let t=(0,G.c)(7),{onSelect:n,variant:r,scopeProjectId:i}=e,a;t[0]===i?a=t[1]:(a=e=>e.projects.find(t=>t.id===(i??e.activeProjectId)),t[0]=i,t[1]=a);let o=S(a),s;return t[2]!==n||t[3]!==o||t[4]!==i||t[5]!==r?(s=o?.hostId?(0,q.jsx)(Ce,{projectId:o.id,hostId:o.hostId,hubId:o.hubId,onSelect:n,variant:r},`${o.hubId}:${o.hostId}:${o.id}`):(0,q.jsx)(be,{onSelect:n,variant:r,scopeProjectId:i}),t[2]=n,t[3]=o,t[4]=i,t[5]=r,t[6]=s):s=t[6],s}function be(e){let t=(0,G.c)(27),{onSelect:n,variant:r,scopeProjectId:i}=e,o;t[0]===i?o=t[1]:(o={scopeProjectId:i},t[0]=i,t[1]=o);let s=se(!0,o),c=E(Se),l=h(xe),{t:u}=ee(),d;t[2]!==n||t[3]!==c||t[4]!==l?(d=()=>{l(`chat`),n(),c()},t[2]=n,t[3]=c,t[4]=l,t[5]=d):d=t[5];let f=m(d),p;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(p=new Set,t[6]=p):p=t[6];let[g,y]=K.useState(p),b;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(b=e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},t[7]=b):b=t[7];let x=m(b),S,C;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(S=_(`group relative flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none`,`data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover`),C=(0,q.jsx)(v,{name:`chat-new`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}),t[8]=S,t[9]=C):(S=t[8],C=t[9]);let w;t[10]===u?w=t[11]:(w=u(`sessions.sidebar.header.actions.newSession`),t[10]=u,t[11]=w);let T;t[12]===w?T=t[13]:(T=(0,q.jsx)(`span`,{className:`truncate text-[14px] font-normal leading-tight text-foreground`,children:w}),t[12]=w,t[13]=T);let D;t[14]!==f||t[15]!==T?(D=(0,q.jsxs)(a,{onClick:f,className:S,children:[C,T]}),t[14]=f,t[15]=T,t[16]=D):D=t[16];let O;t[17]!==g||t[18]!==s||t[19]!==n||t[20]!==u||t[21]!==x||t[22]!==r?(O=s.length===0?(0,q.jsx)(`div`,{className:`px-3 py-4 text-center typography-meta text-muted-foreground`,children:u(`sessions.switcher.empty`)}):s.map(e=>(0,q.jsx)(De,{item:e,depth:0,variant:r,expandedParents:g,toggleParent:x,closeDropdown:n},e.node.session.id)),t[17]=g,t[18]=s,t[19]=n,t[20]=u,t[21]=x,t[22]=r,t[23]=O):O=t[23];let k;return t[24]!==O||t[25]!==D?(k=(0,q.jsx)(`div`,{className:`max-h-[60vh] overflow-y-auto`,children:(0,q.jsxs)(`div`,{className:`space-y-0.5`,children:[D,O]})}),t[24]=O,t[25]=D,t[26]=k):k=t[26],k}function xe(e){return e.setActiveMainTab}function Se(e){return e.openNewSessionDraft}function Ce(e){let t=(0,G.c)(24),{projectId:n,hostId:r,hubId:i,onSelect:a,variant:o}=e,s=k(!0),c;t[0]!==r||t[1]!==i||t[2]!==n||t[3]!==s.catalog?.hubId||t[4]!==s.catalog?.projects?(c=!i||i===s.catalog?.hubId?s.catalog?.projects.find(e=>e.id===n&&e.hostId===r):void 0,t[0]=r,t[1]=i,t[2]=n,t[3]=s.catalog?.hubId,t[4]=s.catalog?.projects,t[5]=c):c=t[5];let l=c,{t:u}=ee(),d=m(we),f;t[6]!==l||t[7]!==s.error?.message||t[8]!==s.isPending||t[9]!==s.registry||t[10]!==u?(f=s.error?.message??(!s.isPending&&(!s.registry||!l)?u(`remoteProjects.host-unavailable`):void 0),t[6]=l,t[7]=s.error?.message,t[8]=s.isPending,t[9]=s.registry,t[10]=u,t[11]=f):f=t[11];let p=f,h,_;t[12]!==p||t[13]!==r||t[14]!==i?(h=()=>{p&&O.error(p,{id:`remote-switcher:${i}:${r}:catalog`})},_=[p,i,r],t[12]=p,t[13]=r,t[14]=i,t[15]=h,t[16]=_):(h=t[15],_=t[16]),K.useEffect(h,_);let v;return t[17]!==a||t[18]!==l||t[19]!==d||t[20]!==s.registry||t[21]!==u||t[22]!==o?(v=s.registry&&l?(0,q.jsx)(Te,{registry:s.registry,project:l,onSelect:a,variant:o}):(0,q.jsx)(`div`,{className:`px-3 py-4`,children:(0,q.jsx)(g,{size:`xs`,variant:`ghost`,onClick:()=>void d(),children:u(`remoteProjects.retry`)})}),t[17]=a,t[18]=l,t[19]=d,t[20]=s.registry,t[21]=u,t[22]=o,t[23]=v):v=t[23],v}async function we(){try{await A()}catch(e){let t=e;O.error(t instanceof Error?t.message:String(t))}}function Te({registry:e,project:t,onSelect:n,variant:r}){let{t:i}=ee(),o=f(e,t.hostId),s=j(e,t.hostId),c=S(e=>e.projects),l=b(e=>e.remoteSession),u=h(e=>e.isMobile),d=s.data,g=o?.state===`connected`&&t.remoteState===`ok`&&!d?.stale,_=K.useMemo(()=>{let n=new Set(d?.pinnedSessionIds??[]),r=new Map,i=n=>(r.has(n)||r.set(n,p(c,e.hubId,t.hostId,n,d?.worktrees)?.id===t.id),r.get(n));return(d?.directories??[]).flatMap(({directory:e,sessions:t})=>t.filter(e=>!e.parentID&&!e.time.archived).map(t=>({session:t,directory:t.directory||e}))).filter(({directory:e})=>i(e)).sort((e,t)=>V(e.session,t.session,n)).slice(0,7)},[d,c,t.hostId,t.id,e.hubId]),y=s.error?.message,{refetch:x}=s;K.useEffect(()=>{y&&O.error(y,{id:`remote-project:${t.id}:load`,action:{label:i(`remoteProjects.retry`),onClick:()=>void x()}})},[y,t.id,x,i]);let C=m((r,a)=>{try{if(p(c,e.hubId,t.hostId,a,d?.worktrees)?.id!==t.id)throw Error(i(`remoteProjects.host-unavailable`));W(t,e,r,a,u),n()}catch(e){O.error(e instanceof Error?e.message:String(e))}}),w=l?.projectId===t.id&&l.location.hostId===t.hostId&&l.location.hubId===e.hubId?l.location.directory:t.path;return(0,q.jsx)(`div`,{className:`max-h-[60vh] overflow-y-auto`,children:(0,q.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,q.jsxs)(a,{onClick:()=>C(null,w),className:`group relative flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover`,children:[(0,q.jsx)(v,{name:`chat-new`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}),(0,q.jsx)(`span`,{className:`truncate text-[14px] font-normal leading-tight text-foreground`,children:i(`sessions.sidebar.header.actions.newSession`)})]}),g?null:(0,q.jsxs)(`div`,{role:`status`,className:`px-3 typography-meta text-muted-foreground`,children:[i(`remoteProjects.state.${o?.state??`offline`}`),` · `,i(`remoteProjects.unknown`)]}),!_.length&&d?(0,q.jsx)(`div`,{className:`px-3 py-4 text-center typography-meta text-muted-foreground`,children:i(`sessions.switcher.empty`)}):null,_.map(({session:n,directory:i})=>(0,q.jsx)(Ee,{registry:e,project:t,projects:c,session:n,directory:i,variant:r,snapshot:d,online:g,navigate:C,selected:l,depth:0,ancestors:[]},`${i}:${n.id}`))]})})}function Ee({registry:e,project:t,projects:n,session:r,directory:i,variant:a,snapshot:o,online:s,navigate:l,selected:f,depth:h,ancestors:_}){let{t:v}=ee(),[y,b]=K.useState(!1),[x,S]=K.useState(30),C=e.resolve({hubId:e.hubId,hostId:t.hostId,directory:i}),w=K.useMemo(()=>({...D(i,void 0,void 0,void 0,C),enabled:!1,staleTime:1/0,gcTime:1/0}),[C,i]),T=u(w,d).data?.current,E=u({queryKey:[...C.queryScope,`navigation-children`,r.id,x],enabled:y&&s,staleTime:3e4,gcTime:1/0,placeholderData:(e,t)=>t&&C.queryScope.every((e,n)=>t.queryKey[n]===e)&&t.queryKey[C.queryScope.length+1]===r.id?e:void 0,queryFn:async({signal:t})=>{let n=[],a,o=!1;for(let s=0;s<Math.ceil(x/30);s++){let s=await C.sdk().session.list({directory:i,parentID:r.id,limit:30,...a?{cursor:a}:{}},{signal:t});if(e.assertCurrent(),C.sdk(),!Array.isArray(s.data))throw Error(`Remote child session list returned no data`);n.push(...s.data.map(c).filter(e=>!e.time?.archived).map(e=>({...e,directory:e.directory||i,time:e.time??{}})));let l=s.cursor?.next||void 0;if(o=!!(l&&l!==a),!o)break;a=l}return{sessions:n,hasMore:o}}},d),{error:k,refetch:A}=E;K.useEffect(()=>{k&&O.error(k.message,{id:`remote-children:${C.key}:${r.id}`,action:{label:v(`remoteProjects.retry`),onClick:()=>void A()}})},[k,C.key,r.id,A,v]);let j=m(({directory:e,payload:t})=>{e&&e!==i||t&&typeof t==`object`&&`type`in t&&typeof t.type==`string`&&/^(session\.(created|updated|deleted|status)|yuri:session-metadata)$/.test(t.type)&&d.invalidateQueries({queryKey:[...C.queryScope,`navigation-children`,r.id,x],exact:!0})});K.useEffect(()=>{if(y&&s)return e.subscribeEvents(t.hostId,j)},[e,t.hostId,i,y,s,j]);let M=o?.directories.flatMap(e=>e.sessions.filter(e=>e.parentID===r.id).map(t=>({...t,directory:t.directory||e.directory})))??[],N=(E.data?.sessions??M).filter(a=>a.id!==r.id&&!_.includes(a.id)&&p(n,e.hubId,t.hostId,a.directory||i,o?.worktrees)?.id===t.id),P=r.metadata?.yuri?.sessionStatus?.type,F=f?.projectId===t.id&&f.location.hubId===e.hubId&&f.location.hostId===t.hostId&&f.location.directory===i&&f.sessionId===r.id;return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(je,{session:r,depth:h,variant:a,secondaryMeta:{projectLabel:t.label??t.path.split(/[\\/]/).filter(Boolean).at(-1),branchLabel:T},hasChildren:!!(r.hasChildren||N.length||h>0),isExpanded:y,onToggleExpand:()=>b(e=>!e),isActive:F,unseenCount:o?.unread?.sessions[r.id]?.unreadCount??0,statusType:s?P??`idle`:`unknown`,handleSelect:()=>l(r.id,i)}),y?(0,q.jsxs)(q.Fragment,{children:[N.map(c=>(0,q.jsx)(Ee,{registry:e,project:t,projects:n,variant:a,snapshot:o,online:s,navigate:l,selected:f,directory:c.directory||i,session:c,depth:h+1,ancestors:[..._,r.id]},c.id)),E.data?.hasMore?(0,q.jsx)(g,{size:`xs`,variant:`ghost`,disabled:!s||E.isFetching,onClick:()=>S(e=>e+30),children:v(`remoteProjects.showMore`)}):null]}):null]})}function De(e){let t=(0,G.c)(31),{item:n,depth:r,variant:i,expandedParents:a,toggleParent:o,closeDropdown:s}=e,{node:c,secondaryMeta:l}=n,u=c.session,d=c.children.length>0,f;t[0]!==a||t[1]!==u.id?(f=a.has(u.id),t[0]=a,t[1]=u.id,t[2]=f):f=t[2];let p=f,m;t[3]!==d||t[4]!==u.id||t[5]!==o?(m=d?()=>o(u.id):void 0,t[3]=d,t[4]=u.id,t[5]=o,t[6]=m):m=t[6];let h;t[7]!==s||t[8]!==r||t[9]!==d||t[10]!==p||t[11]!==l||t[12]!==u||t[13]!==m||t[14]!==i?(h=(0,q.jsx)(Oe,{session:u,depth:r,variant:i,secondaryMeta:l,hasChildren:d,isExpanded:p,onToggleExpand:m,closeDropdown:s}),t[7]=s,t[8]=r,t[9]=d,t[10]=p,t[11]=l,t[12]=u,t[13]=m,t[14]=i,t[15]=h):h=t[15];let g;t[16]!==s||t[17]!==r||t[18]!==a||t[19]!==d||t[20]!==p||t[21]!==n.groupDirectory||t[22]!==n.projectId||t[23]!==c.children||t[24]!==l||t[25]!==o||t[26]!==i?(g=d&&p?c.children.map(e=>(0,q.jsx)(De,{item:{node:e,projectId:n.projectId,groupDirectory:n.groupDirectory,secondaryMeta:l},depth:r+1,variant:i,expandedParents:a,toggleParent:o,closeDropdown:s},e.session.id)):null,t[16]=s,t[17]=r,t[18]=a,t[19]=d,t[20]=p,t[21]=n.groupDirectory,t[22]=n.projectId,t[23]=c.children,t[24]=l,t[25]=o,t[26]=i,t[27]=g):g=t[27];let _;return t[28]!==h||t[29]!==g?(_=(0,q.jsxs)(q.Fragment,{children:[h,g]}),t[28]=h,t[29]=g,t[30]=_):_=t[30],_}function Oe(e){let t=(0,G.c)(17),{session:n,depth:r,variant:i,secondaryMeta:a,hasChildren:o,isExpanded:s,onToggleExpand:c,closeDropdown:l}=e,u=E(Ae),d=E(ke),f=y(n.id),p=w(n.id),h=u===n.id,g;t[0]!==l||t[1]!==h||t[2]!==n||t[3]!==d?(g=()=>{h||d(n.id,T(n)??null),l()},t[0]=l,t[1]=h,t[2]=n,t[3]=d,t[4]=g):g=t[4];let _=m(g),v=f?.type??`idle`,b;return t[5]!==r||t[6]!==_||t[7]!==o||t[8]!==h||t[9]!==s||t[10]!==c||t[11]!==a||t[12]!==n||t[13]!==v||t[14]!==p||t[15]!==i?(b=(0,q.jsx)(je,{session:n,depth:r,variant:i,secondaryMeta:a,hasChildren:o,isExpanded:s,onToggleExpand:c,isActive:h,unseenCount:p,statusType:v,handleSelect:_}),t[5]=r,t[6]=_,t[7]=o,t[8]=h,t[9]=s,t[10]=c,t[11]=a,t[12]=n,t[13]=v,t[14]=p,t[15]=i,t[16]=b):b=t[16],b}function ke(e){return e.setCurrentSession}function Ae(e){return e.currentSessionId}function je(e){let t=(0,G.c)(57),{session:n,depth:r,variant:i,secondaryMeta:o,hasChildren:s,isExpanded:c,onToggleExpand:l,isActive:u,unseenCount:d,statusType:f,handleSelect:p}=e,{t:m}=ee(),h;t[0]!==n.title||t[1]!==m?(h=n.title?.trim()||m(`sessions.sidebar.session.untitled`),t[0]=n.title,t[1]=m,t[2]=h):h=t[2];let g=h,y;t[3]===n?y=t[4]:(y=U(H(n)),t[3]=n,t[4]=y);let b=y,x=!!n.parentID,S=d>0&&!x,C=f===`busy`||f===`retry`,w=!C&&S,T;t[5]!==n.time?.created||t[6]!==n.time?.updated?(T=n.time?.updated||n.time?.created||Date.now(),t[5]=n.time?.created,t[6]=n.time?.updated,t[7]=T):T=t[7];let E=T,D;t[8]===E?D=t[9]:(D=B(E),t[8]=E,t[9]=D);let O=D,k;t[10]===o?.projectLabel?k=t[11]:(k=o?.projectLabel?.trim()||null,t[10]=o?.projectLabel,t[11]=k);let A=k,j;t[12]===o?.branchLabel?j=t[13]:(j=o?.branchLabel?.trim()||null,t[12]=o?.branchLabel,t[13]=j);let M=j,N=M&&M!==`HEAD`?M:null,P;t[14]===p?P=t[15]:(P=e=>{if(e.target?.closest(`[data-switcher-expand]`)){e.preventDefault();return}p()},t[14]=p,t[15]=P);let F;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(F=_(`group relative flex w-full cursor-pointer items-start gap-2 rounded-lg px-2 py-1.5 outline-hidden select-none`,`data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover`),t[16]=F):F=t[16];let I=8+r*12,L;t[17]===I?L=t[18]:(L={paddingLeft:I},t[17]=I,t[18]=L);let R;t[19]!==s||t[20]!==c||t[21]!==l||t[22]!==m||t[23]!==i?(R=i===`compact`&&s?(0,q.jsx)(`span`,{role:`button`,tabIndex:-1,"data-switcher-expand":!0,onClick:e=>{e.preventDefault(),e.stopPropagation(),l?.()},className:`inline-flex h-3.5 w-3.5 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground`,"aria-label":m(c?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),children:c?(0,q.jsx)(v,{name:`arrow-down-s`,className:`h-3.5 w-3.5`}):(0,q.jsx)(v,{name:`arrow-right-s`,className:`h-3.5 w-3.5`})}):null,t[19]=s,t[20]=c,t[21]=l,t[22]=m,t[23]=i,t[24]=R):R=t[24];let z=u?`text-primary`:`text-foreground`,V;t[25]===z?V=t[26]:(V=_(`min-w-0 truncate text-[14px] font-normal leading-tight`,z),t[25]=z,t[26]=V);let te;t[27]!==g||t[28]!==V?(te=(0,q.jsx)(`span`,{className:V,children:g}),t[27]=g,t[28]=V,t[29]=te):te=t[29];let ne;t[30]===b?ne=t[31]:(ne=b?(0,q.jsx)(`span`,{className:`shrink-0 text-[12px] tabular-nums text-muted-foreground`,children:b}):null,t[30]=b,t[31]=ne);let re;t[32]!==R||t[33]!==te||t[34]!==ne?(re=(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[R,te,ne]}),t[32]=R,t[33]=te,t[34]=ne,t[35]=re):re=t[35];let W;t[36]!==N||t[37]!==s||t[38]!==c||t[39]!==l||t[40]!==A||t[41]!==m||t[42]!==O||t[43]!==i?(W=i==="default"?(0,q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 truncate text-muted-foreground/70 leading-tight`,style:{fontSize:`calc(var(--text-ui-label) * 0.85)`},children:[s?(0,q.jsx)(`span`,{role:`button`,tabIndex:-1,"data-switcher-expand":!0,onClick:e=>{e.preventDefault(),e.stopPropagation(),l?.()},className:`inline-flex h-3 w-3 flex-shrink-0 items-center justify-center rounded text-muted-foreground/70 hover:text-foreground`,"aria-label":m(c?`sessions.sidebar.session.subsessions.collapse`:`sessions.sidebar.session.subsessions.expand`),children:c?(0,q.jsx)(v,{name:`arrow-down-s`,className:`h-3 w-3`}):(0,q.jsx)(v,{name:`arrow-right-s`,className:`h-3 w-3`})}):null,(0,q.jsx)(`span`,{className:`flex-shrink-0`,children:O}),A?(0,q.jsx)(`span`,{className:`truncate`,children:A}):null,N?(0,q.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-0.5`,children:[(0,q.jsx)(v,{name:`git-branch`,className:`h-3 w-3 flex-shrink-0 text-muted-foreground/70`}),(0,q.jsx)(`span`,{className:`truncate`,children:N})]}):null]}):null,t[36]=N,t[37]=s,t[38]=c,t[39]=l,t[40]=A,t[41]=m,t[42]=O,t[43]=i,t[44]=W):W=t[44];let K;t[45]!==re||t[46]!==W?(K=(0,q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[re,W]}),t[45]=re,t[46]=W,t[47]=K):K=t[47];let J;t[48]!==C||t[49]!==w||t[50]!==m?(J=C||w?(0,q.jsx)(`span`,{className:`flex h-3 w-3 flex-shrink-0 items-center justify-center self-center`,children:C?(0,q.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-primary animate-busy-pulse`,"aria-label":m(`sessions.sidebar.session.status.active`),title:m(`sessions.sidebar.session.status.active`)}):(0,q.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-[var(--status-info)]`,"aria-label":m(`sessions.sidebar.session.status.unread`),title:m(`sessions.sidebar.session.status.unread`)})}):null,t[48]=C,t[49]=w,t[50]=m,t[51]=J):J=t[51];let ie;return t[52]!==L||t[53]!==K||t[54]!==J||t[55]!==P?(ie=(0,q.jsxs)(a,{onClick:P,"data-slot":`session-switcher-item`,className:F,style:L,children:[K,J]}),t[52]=L,t[53]=K,t[54]=J,t[55]=P,t[56]=ie):ie=t[56],ie}var Me=K.memo(function(e){let t=(0,G.c)(45),{visible:i,position:a}=e,o=a===void 0?`right`:a,{t:s}=ee(),[c,l]=K.useState(!1),u,d;if(t[0]===i?(u=t[1],d=t[2]):(u=()=>{if(!i)return;let e=!1;n(`desktop_get_current_window_state`).then(t=>{e||l(!!t?.maximized)}).catch(Ne);let t=e=>{let t=e.detail;l(!!t?.maximized)};return window.addEventListener(`yuri:window-maximized-changed`,t),()=>{e=!0,window.removeEventListener(`yuri:window-maximized-changed`,t)}},d=[i],t[0]=i,t[1]=u,t[2]=d),(0,K.useEffect)(u,d),!i)return null;let f;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(f=r(),t[3]=f):f=t[3];let p=f===`win32`,m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=_(`app-region-no-drag inline-flex h-12 w-11 items-center justify-center text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,p&&`bg-[var(--surface-background)] backdrop-blur-none`),t[4]=m):m=t[4];let h=m,g=o===`left`?`app-region-no-drag -ml-3 mr-2 flex h-12 shrink-0 items-center`:`app-region-no-drag -mr-3 ml-2 flex h-12 shrink-0 items-center`,y;t[5]===g?y=t[6]:(y=_(g,p&&`bg-[var(--surface-background)] backdrop-blur-none`),t[5]=g,t[6]=y);let b=y,x;t[7]===s?x=t[8]:(x=s(`header.windowControls.groupAria`),t[7]=s,t[8]=x);let S;t[9]===s?S=t[10]:(S=s(`header.windowControls.minimize`),t[9]=s,t[10]=S);let C;t[11]===s?C=t[12]:(C=s(`header.windowControls.minimize`),t[11]=s,t[12]=C);let w;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,q.jsx)(v,{name:`subtract`,className:`h-4 w-4`}),t[13]=w):w=t[13];let T;t[14]!==C||t[15]!==S?(T=(0,q.jsx)(`button`,{type:`button`,className:h,onClick:Pe,title:S,"aria-label":C,children:w}),t[14]=C,t[15]=S,t[16]=T):T=t[16];let E;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>{n(`desktop_toggle_current_window_maximized`).then(e=>l(!!e?.maximized)).catch(Fe)},t[17]=E):E=t[17];let D;t[18]!==c||t[19]!==s?(D=s(c?`header.windowControls.restore`:`header.windowControls.maximize`),t[18]=c,t[19]=s,t[20]=D):D=t[20];let O;t[21]!==c||t[22]!==s?(O=s(c?`header.windowControls.restore`:`header.windowControls.maximize`),t[21]=c,t[22]=s,t[23]=O):O=t[23];let k=c?`fullscreen-exit`:`checkbox-blank`,A;t[24]===k?A=t[25]:(A=(0,q.jsx)(v,{name:k,className:`h-3.5 w-3.5`}),t[24]=k,t[25]=A);let j;t[26]!==D||t[27]!==O||t[28]!==A?(j=(0,q.jsx)(`button`,{type:`button`,className:h,onClick:E,title:D,"aria-label":O,children:A}),t[26]=D,t[27]=O,t[28]=A,t[29]=j):j=t[29];let M;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(M=_(h,`hover:bg-status-error hover:text-status-error-foreground`),t[30]=M):M=t[30];let N;t[31]===s?N=t[32]:(N=s(`header.windowControls.close`),t[31]=s,t[32]=N);let P;t[33]===s?P=t[34]:(P=s(`header.windowControls.close`),t[33]=s,t[34]=P);let F;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,q.jsx)(v,{name:`close`,className:`h-4 w-4`}),t[35]=F):F=t[35];let I;t[36]!==N||t[37]!==P?(I=(0,q.jsx)(`button`,{type:`button`,className:M,onClick:Ie,title:N,"aria-label":P,children:F}),t[36]=N,t[37]=P,t[38]=I):I=t[38];let L;return t[39]!==b||t[40]!==T||t[41]!==j||t[42]!==I||t[43]!==x?(L=(0,q.jsxs)(`div`,{className:b,"aria-label":x,children:[T,j,I]}),t[39]=b,t[40]=T,t[41]=j,t[42]=I,t[43]=x,t[44]=L):L=t[44],L});function Ne(){}function Pe(){n(`desktop_minimize_current_window`)}function Fe(){}function Ie(){n(`desktop_close_current_window`)}function Le(){let e=(0,G.c)(5),n=h(Re),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=i(),e[0]=r):r=e[0];let a=r,o;e[1]===n?o=e[2]:(o=t(n),e[1]=n,e[2]=o);let s=o,c;return e[3]===s?c=e[4]:(c={usesFramelessChrome:a,side:s},e[3]=s,e[4]=c),c}function Re(e){return e.desktopWindowControlsPosition}export{J as i,Me as n,ge as r,Le as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{p as t}from"./runtime-auth-DA-qfGHk.js";import{c as n,f as r}from"./runtime-switch-DEPKHgdL.js";import{st as i}from"./vendor-base-ui-wXsskyKm.js";import{xt as a}from"./gitApiHttp-Dd-FwgCq.js";import{n as o}from"./vendor-react-BkccXcWz.js";import{r as s}from"./vendor-reactuses-core-DjKFMfz7.js";import{t as c}from"./i18n-D5tJwyKg.js";import{a as l,i as u,l as d,o as f,s as p,t as m,u as h}from"./audio-session-BFWjrDbp.js";var g=e(i(),1),_=class{abort;partial;disconnected;socket=null;failure=null;completion=null;text=``;final=!1;finishing=!1;sequence=0;constructor(e,t,n){this.abort=e,this.partial=t,this.disconnected=n}get connected(){return this.socket!==null&&!this.failure&&!this.abort.signal.aborted}async start(e,t){if(t!==`audio/pcm;rate=16000;bits=16`)throw Error(`Direct speech requires 16 kHz PCM16 audio`);let n=await f(h(e,`asr`),this.abort.signal);this.socket=n;try{n.send(u(new TextEncoder().encode(JSON.stringify({user:{uid:`yuri`},audio:{format:`pcm`,codec:`raw`,rate:16e3,bits:16,channel:1},request:{model_name:`bigmodel`,result_type:`full`,enable_itn:!0,enable_punc:!0,enable_nonstream:!0,show_utterances:!0,...e.asrContext?.trim()?{corpus:{context:JSON.stringify({context_type:`dialog_ctx`,context_data:[{text:e.asrContext.trim()}]})}}:{}}}))))}catch(e){throw n.close(),e}this.completion=this.receive().catch(e=>{this.failure=e instanceof Error?e:Error(`Speech recognition failed`),n.close(),!this.abort.signal.aborted&&!this.finishing&&this.disconnected()})}send(e,t){if(!this.connected||this.finishing||this.final||e!==this.sequence)return!1;try{if(t.length>128e3)throw Error(`Speech audio chunk exceeds size limit`);let e=atob(t);if(e.length%2)throw Error(`Invalid PCM audio`);let n=Uint8Array.from(e,e=>e.charCodeAt(0));return this.socket.send(u(n,!0)),this.sequence++,!0}catch{return this.failure=Error(`Unable to send speech audio`),this.socket?.close(),!1}}async finish(e){if(this.failure)throw this.failure;if(!this.socket||e!==this.sequence-1)throw Error(`Incomplete speech audio`);this.finishing=!0,this.socket.send(u(new Uint8Array,!0,!0));let t=setTimeout(()=>{this.failure=Error(`Speech finalization timed out`),this.socket?.close()},3e4);try{if(await this.completion,this.abort.signal.throwIfAborted(),this.failure)throw this.failure;if(!this.final)throw Error(`Incomplete speech recognition`);return{text:this.text}}finally{clearTimeout(t),this.socket.close()}}cancel(){this.abort.abort(),this.socket?.close()}async receive(){for(;;){let e=await l(await this.socket.read(),`asr`);this.abort.signal.throwIfAborted();let t=p(e.payload);if(t.code!==void 0&&![0,1e3,2e7].includes(Number(t.code)))throw Error(`Speech recognition failed`);let n=t.result;if(n!==void 0&&(!n||typeof n!=`object`||Array.isArray(n)))throw Error(`Invalid speech transcript`);if(n&&typeof n==`object`&&`text`in n){if(typeof n.text!=`string`)throw Error(`Invalid speech transcript`);this.text=n.text,e.final||this.partial(this.text)}if(e.final){if(!this.finishing)throw Error(`Speech recognition ended unexpectedly`);this.final=!0;return}}}},v=(e,t,n)=>{let r=Error(e);return r.name=`DictationStreamError`,r.retryable=t,n&&(r.reasonCode=n),r},y=1e4,b=15e3,x=3e4,S=3e4,C=new class{socket=null;connectPromise=null;idleCloseTimer=null;pendingStarts=new Map;pendingFinishes=new Map;connectionListeners=new Set;partialListeners=new Set;activeDictations=0;directStarts=new Map;directSessions=new Map;get isConnected(){if(this.socket?.readyState===WebSocket.OPEN)return!0;for(let e of this.directSessions.values())if(e.connected)return!0;return!1}subscribeConnectionStatus(e){return this.connectionListeners.add(e),()=>{this.connectionListeners.delete(e)}}onPartial(e){return this.partialListeners.add(e),()=>{this.partialListeners.delete(e)}}async ensureConnected(){if(this.socket?.readyState!==WebSocket.OPEN){if(this.connectPromise){await this.connectPromise;return}try{await t()}catch{}this.connectPromise=new Promise((e,t)=>{let n=!1,i;try{let e=r().websocket(`/api/dictation/ws`);i=a(e)}catch(e){this.connectPromise=null,t(e instanceof Error?e:Error(String(e)));return}let o=setTimeout(()=>{if(!n){n=!0,this.connectPromise=null;try{i.close()}catch{}t(Error(`Dictation connection timed out`))}},y);i.onopen=()=>{},i.onmessage=t=>{let r;try{r=JSON.parse(String(t.data))}catch{return}if(!n&&r.type===`ready`){n=!0,clearTimeout(o),this.socket=i,this.connectPromise=null,this.notifyConnection(!0),e();return}this.handleMessage(r)},i.onerror=()=>{window.setTimeout(()=>{n||(n=!0,clearTimeout(o),this.connectPromise=null,t(Error(`Dictation connection failed`)))},250)},i.onclose=e=>{if(!n){n=!0,clearTimeout(o),this.connectPromise=null;let r=e?.reason?`: ${e.reason}`:``;t(Error(`Dictation connection failed${r}`));return}this.socket===i&&(this.socket=null,this.rejectAllPending(Error(`Dictation connection lost`)),this.notifyConnection(!1))}}),await this.connectPromise}}async startDictationStream(e,t){let n=new AbortController;this.directStarts.set(e,n);try{let r=await d(`asr`,n.signal);if(n.signal.throwIfAborted(),r){let i=new _(n,t=>{for(let n of this.partialListeners)n(e,t)},()=>{this.directSessions.delete(e),i.cancel(),this.notifyConnection(!1)});this.directSessions.set(e,i),await i.start(r,t),n.signal.throwIfAborted(),this.notifyConnection(!0);return}await this.ensureConnected(),n.signal.throwIfAborted()}catch(t){throw this.directSessions.get(e)?.cancel(),this.directSessions.delete(e),t}finally{this.directStarts.delete(e)}return this.activeDictations+=1,this.clearIdleCloseTimer(),new Promise((n,r)=>{let i=setTimeout(()=>{this.pendingStarts.delete(e),this.releaseDictation(),r(Error(`Dictation start timed out`))},b);this.pendingStarts.set(e,{resolve:()=>{clearTimeout(i),n()},reject:e=>{clearTimeout(i),this.releaseDictation(),r(e)},timeout:i}),this.send({type:`start`,dictationId:e,format:t})||(clearTimeout(i),this.pendingStarts.delete(e),this.releaseDictation(),r(Error(`Dictation connection lost`)))})}sendDictationStreamChunk(e,t,n){let r=this.directSessions.get(e);return r?r.send(t,n):this.send({type:`chunk`,dictationId:e,seq:t,audio:n})}finishDictationStream(e,t){let n=this.directSessions.get(e);return n?n.finish(t).finally(()=>{n.cancel(),this.directSessions.delete(e)}):new Promise((n,r)=>{let i={resolve:e=>{i.timeout&&clearTimeout(i.timeout),this.releaseDictation(),n(e)},reject:e=>{i.timeout&&clearTimeout(i.timeout),this.releaseDictation(),r(e)},timeout:null};i.timeout=setTimeout(()=>{this.pendingFinishes.delete(e),this.releaseDictation(),r(Error(`Timed out waiting for transcription`))},S),this.pendingFinishes.set(e,i),this.send({type:`finish`,dictationId:e,finalSeq:t})||(this.pendingFinishes.delete(e),i.reject(Error(`Dictation connection lost`)))})}cancelDictationStream(e){this.directStarts.get(e)?.abort(),this.directStarts.delete(e);let t=this.directSessions.get(e);if(t){t.cancel(),this.directSessions.delete(e);return}this.send({type:`cancel`,dictationId:e});let n=this.pendingStarts.get(e);n&&(this.pendingStarts.delete(e),n.reject(Error(`Dictation cancelled`)));let r=this.pendingFinishes.get(e);r&&(this.pendingFinishes.delete(e),r.reject(Error(`Dictation cancelled`))),this.releaseDictation(),this.scheduleIdleCloseIfReady()}handleMessage(e){let t=e.dictationId;if(t)switch(e.type){case`ack`:{let e=this.pendingStarts.get(t);e&&(this.pendingStarts.delete(t),e.resolve());return}case`partial`:for(let n of this.partialListeners)n(t,e.text??``);return;case`finish_accepted`:{let n=this.pendingFinishes.get(t);n&&typeof e.timeoutMs==`number`&&(n.timeout&&clearTimeout(n.timeout),n.timeout=setTimeout(()=>{this.pendingFinishes.delete(t),n.reject(Error(`Timed out waiting for transcription`))},e.timeoutMs+5e3));return}case`final`:{let n=this.pendingFinishes.get(t);n&&(this.pendingFinishes.delete(t),n.resolve({text:e.text??``})),this.scheduleIdleCloseIfReady();return}case`error`:{let n=v(e.error||`Dictation failed`,e.retryable!==!1,e.reasonCode),r=this.pendingStarts.get(t);r&&(this.pendingStarts.delete(t),r.reject(n));let i=this.pendingFinishes.get(t);i&&(this.pendingFinishes.delete(t),i.reject(n)),this.scheduleIdleCloseIfReady();return}}}send(e){if(!this.isConnected||!this.socket)return!1;try{return this.socket.send(JSON.stringify(e)),!0}catch{return!1}}notifyConnection(e){for(let t of this.connectionListeners)t(e)}rejectAllPending(e){for(let[t,n]of this.pendingStarts)this.pendingStarts.delete(t),n.reject(e);for(let[t,n]of this.pendingFinishes)this.pendingFinishes.delete(t),n.reject(e);this.activeDictations=0}releaseDictation(){this.activeDictations=Math.max(0,this.activeDictations-1),this.scheduleIdleCloseIfReady()}scheduleIdleCloseIfReady(){this.activeDictations>0||this.pendingFinishes.size>0||this.pendingStarts.size>0||(this.clearIdleCloseTimer(),this.idleCloseTimer=setTimeout(()=>{if(this.activeDictations===0&&this.pendingFinishes.size===0&&this.pendingStarts.size===0){let e=this.socket;if(this.socket=null,e){try{e.close(1e3,`idle`)}catch{}this.notifyConnection(!1)}}},x))}cancelAllForRuntimeSwitch(){for(let e of this.directStarts.values())e.abort();this.directStarts.clear();for(let e of this.directSessions.values())e.cancel();this.directSessions.clear(),this.clearIdleCloseTimer();let e=this.socket;if(this.socket=null,this.connectPromise=null,this.rejectAllPending(Error(`Runtime changed`)),e){try{e.close(1e3,`runtime switch`)}catch{}this.notifyConnection(!1)}}clearIdleCloseTimer(){this.idleCloseTimer&&=(clearTimeout(this.idleCloseTimer),null)}};typeof window<`u`&&window.addEventListener(`yuri:runtime-endpoint-changed`,()=>{C.cancelAllForRuntimeSwitch()});var w=128,T=`audio/pcm;rate=16000;bits=16`,E=()=>new Promise(e=>setTimeout(e,0)),D=()=>{let e=Math.random().toString(36).slice(2,10);return`dic_${Date.now().toString(16)}${e}`},O=class{client;format;createDictationId;dictationId=null;sendSeq=0;segments=[];streamReady=!1;flushTimer=null;drainWaiters=[];startGeneration=0;startPromise=null;constructor(e){this.client=e.client,this.format=e.format??T,this.createDictationId=e.createDictationId??D}getDictationId(){return this.dictationId}getFinalSeq(){return this.segments.length-1}hasSegments(){return this.segments.length>0}clearAll(){this.dictationId&&this.client.cancelDictationStream(this.dictationId),this.clearScheduledFlush(),this.dictationId=null,this.sendSeq=0,this.segments=[],this.streamReady=!1,this.startPromise=null,this.startGeneration+=1}resetStreamForReplay(){this.dictationId&&this.client.cancelDictationStream(this.dictationId),this.clearScheduledFlush(),this.dictationId=null,this.sendSeq=0,this.streamReady=!1,this.startPromise=null,this.startGeneration+=1}enqueueSegment(e){if(this.segments.push(e),this.client.isConnected){if(!this.dictationId){this.startPromise||this.restartStream().catch(()=>{});return}this.flush()}}flush(){let e=this.dictationId;if(!this.client.isConnected||!e||!this.streamReady)return 0;let t=0;for(;this.sendSeq<this.segments.length&&t<w;){let n=this.sendSeq,r=this.segments[n];if(!this.client.sendDictationStreamChunk(e,n,r))break;this.sendSeq=n+1,t+=1}return this.hasPendingSegments()?this.scheduleFlush():this.resolveDrainWaiters(),t}async restartStream(){this.startGeneration+=1;let e=this.startGeneration,t=this.createDictationId();this.dictationId=t,this.sendSeq=0,this.streamReady=!1;let n=(async()=>{await this.client.startDictationStream(t,this.format),this.startGeneration===e&&this.dictationId===t&&(this.streamReady=!0,this.flush())})().catch(n=>{throw this.startGeneration===e&&this.dictationId===t&&(this.dictationId=null,this.streamReady=!1),n}).finally(()=>{this.startPromise===n&&(this.startPromise=null)});this.startPromise=n,await n}async finish(e){this.dictationId||await this.restartStream(),this.startPromise&&await this.startPromise;let t=this.dictationId;if(!t||!this.streamReady)throw Error(`Failed to start dictation stream`);return this.flush(),await this.waitForFlushDrain(),{dictationId:t,text:(await this.client.finishDictationStream(t,e)).text}}cancel(){this.resetStreamForReplay()}hasPendingSegments(){return this.sendSeq<this.segments.length}scheduleFlush(){this.flushTimer||=setTimeout(()=>{this.flushTimer=null,this.flush()},0)}clearScheduledFlush(){this.resolveDrainWaiters(),this.flushTimer&&=(clearTimeout(this.flushTimer),null)}async waitForFlushDrain(){for(;this.hasPendingSegments();){if(!this.client.isConnected||!this.dictationId||!this.streamReady)throw Error(`Failed to flush dictation stream`);await new Promise(e=>{this.drainWaiters.push(e)}),await E()}}resolveDrainWaiters(){let e=this.drainWaiters;this.drainWaiters=[];for(let t of e)t()}},k=o(),A=16e3,j=A/5,M=()=>{if(typeof window>`u`)return null;let e=window;return e.AudioContext||e.webkitAudioContext||null},N=e=>{let t=Math.max(-1,Math.min(1,e));return Math.round(t<0?t*32768:t*32767)},P=(e,t,n)=>{if(e.length===0)return new Int16Array;if(t===n){let t=new Int16Array(e.length);for(let n=0;n<e.length;n++)t[n]=N(e[n]);return t}let r=t/n,i=Math.max(1,Math.round(e.length/r)),a=new Int16Array(i);for(let t=0;t<i;t++){let n=t*r,i=Math.floor(n),o=Math.min(e.length-1,i+1),s=n-i;a[t]=N(e[i]*(1-s)+e[o]*s)}return a},F=(e,t)=>{if(e.length===0)return t;if(t.length===0)return e;let n=new Int16Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n},I=e=>{let t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n=``;for(let e=0;e<t.length;e++)n+=String.fromCharCode(t[e]);return btoa(n)},L=()=>({stream:null,context:null,source:null,processor:null,gain:null,pending:new Int16Array,started:!1}),R=e=>{if(e)try{e.disconnect()}catch{}},z=()=>typeof navigator>`u`||typeof window>`u`||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!=`function`?!1:M()!==null;function B(e){let t=(0,k.c)(16),[n,r]=(0,g.useState)(0),i=(0,g.useRef)(e.onPcmSegment),a=(0,g.useRef)(e.onError),o,c;t[0]!==e.onError||t[1]!==e.onPcmSegment?(o=()=>{i.current=e.onPcmSegment,a.current=e.onError},c=[e.onPcmSegment,e.onError],t[0]=e.onError,t[1]=e.onPcmSegment,t[2]=o,t[3]=c):(o=t[2],c=t[3]),(0,g.useEffect)(o,c);let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=L(),t[4]=l):l=t[4];let u=(0,g.useRef)(l),d=(0,g.useRef)(0),f;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(f=async()=>{if(u.current.started)return;if(typeof navigator>`u`||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!=`function`)throw Error(`Microphone capture is not supported in this environment`);let e=M();if(!e)throw Error(`AudioContext unavailable`);let t=d.current+=1;m();let n=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,noiseSuppression:!0,echoCancellation:!0,autoGainControl:!0}});if(t!==d.current){n.getTracks().forEach(G);return}let a=new e;try{if(a.state===`suspended`&&await a.resume().catch(W),t!==d.current){n.getTracks().forEach(U),await a.close();return}let e=a.createMediaStreamSource(n),o=a.createScriptProcessor(4096,1,1),s=a.createGain();s.gain.value=0,u.current={stream:n,context:a,source:e,processor:o,gain:s,pending:new Int16Array,started:!0},o.onaudioprocess=e=>{let t=u.current;if(!t.started)return;let n=e.inputBuffer.getChannelData(0),o=0;for(let e=0;e<n.length;e++)o+=n[e]*n[e];let s=Math.sqrt(o/Math.max(1,n.length));r(Math.min(1,Math.max(0,s*2)));let c=P(n,a.sampleRate,A);for(t.pending=F(t.pending,c);t.pending.length>=j;){let e=t.pending.slice(0,j);t.pending=t.pending.slice(j),i.current(I(e))}},e.connect(o),o.connect(s),s.connect(a.destination)}catch(e){let t=e;n.getTracks().forEach(H);try{await a.close()}catch{}throw u.current=L(),t instanceof Error?t:Error(String(t))}},t[5]=f):f=t[5];let p=s(f),h;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(h=async()=>{d.current+=1;let e=u.current;if(e.started=!1,r(0),e.processor)try{e.processor.onaudioprocess=null}catch{}R(e.processor),R(e.source),R(e.gain),e.stream&&e.stream.getTracks().forEach(V);let t=e.pending;if(e.pending=new Int16Array,t.length>0&&i.current(I(t)),e.context)try{await e.context.close()}catch{}u.current===e&&(u.current=L())},t[6]=h):h=t[6];let _=s(h),v,y;t[7]===_?(v=t[8],y=t[9]):(v=()=>()=>{_().catch(e=>{a.current?.(e instanceof Error?e:Error(String(e)))})},y=[_],t[7]=_,t[8]=v,t[9]=y),(0,g.useEffect)(v,y);let b;t[10]===p?b=t[11]:(b=async()=>{try{await p()}catch(e){let t=e,n=t instanceof Error?t:Error(String(t));throw a.current?.(n),n}},t[10]=p,t[11]=b);let x;return t[12]!==_||t[13]!==b||t[14]!==n?(x={start:b,stop:_,volume:n},t[12]=_,t[13]=b,t[14]=n,t[15]=x):x=t[15],x}function V(e){try{e.stop()}catch{}}function H(e){try{e.stop()}catch{}}function U(e){return e.stop()}function W(){}function G(e){return e.stop()}var K=1e3,q=e=>e instanceof Error?e:Error(String(e));function J(e={}){let{t}=c(),{onTranscript:r,onError:i,canStart:a}=e,[o,l]=(0,g.useState)(`idle`),[u,d]=(0,g.useState)(!1),[f,p]=(0,g.useState)(``),[m,h]=(0,g.useState)(0),[_,v]=(0,g.useState)(null),[y,b]=(0,g.useState)(null),x=(0,g.useRef)(o);(0,g.useEffect)(()=>{x.current=o},[o]);let S=(0,g.useRef)(``),w=(0,g.useRef)(null),T=(0,g.useRef)({starting:!1,confirming:!1,cancelling:!1}),E=(0,g.useRef)(0),D=(0,g.useRef)(r),k=(0,g.useRef)(i);(0,g.useEffect)(()=>{D.current=r,k.current=i},[r,i]);let A=(0,g.useRef)(null);A.current||=new O({client:C});let j=s(()=>{w.current&&=(clearInterval(w.current),null)}),M=s(()=>{w.current||=setInterval(()=>{h(e=>e+1)},K)}),N=s(e=>{let n=q(e),r=n.name===`NotFoundError`||n.name===`DevicesNotFoundError`?Error(t(`chat.dictation.error.microphoneNotFound`),{cause:n}):n;v(r.message);let i=n.reasonCode;b(typeof i==`string`?i:null),k.current?.(r)}),P=s(()=>{v(null),b(null)}),F=s(()=>{A.current?.clearAll(),S.current=``,p(``)}),I=s(t=>e.onPartialTranscript?.(t));(0,g.useEffect)(()=>C.onPartial((e,t)=>{let n=A.current?.getDictationId();!n||e!==n||(S.current=t,p(t),I(t))}),[I]),(0,g.useEffect)(()=>C.subscribeConnectionStatus(e=>{if(!e){x.current===`recording`&&A.current?.resetStreamForReplay();return}if(x.current!==`recording`||A.current?.getDictationId())return;let t=E.current;A.current?.restartStream().catch(e=>{E.current===t&&N(e)})}),[N]);let L=B({onPcmSegment:e=>{x.current===`recording`&&A.current?.enqueueSegment(e)},onError:e=>{k.current?.(e)}}),R=(0,g.useRef)(L.stop);(0,g.useEffect)(()=>{R.current=L.stop},[L.stop]);let z=s(e=>{h(0),l(`idle`),x.current=`idle`;let t=e.trim();return F(),t?(D.current?.(t),t):null}),V=s(e=>{A.current?.hasSegments()?(l(`failed`),x.current=`failed`):(l(`idle`),x.current=`idle`),N(e)}),H=s(async()=>{let e=T.current;if(e.starting||e.confirming||e.cancelling||x.current!==`idle`||a&&!a())return;e.starting=!0,d(!0);let t=++E.current;P(),p(``),h(0),l(`recording`),x.current=`recording`,F();try{if(await L.start(),E.current!==t||x.current!==`recording`)return;d(!1),M(),await A.current?.restartStream().catch(e=>{E.current===t&&N(e)})}catch(e){if(E.current!==t)return;await L.stop().catch(()=>void 0),j(),l(`idle`),x.current=`idle`,N(e)}finally{E.current===t&&d(!1),e.starting=!1}}),U=s(async()=>{let e=T.current;if(!e.cancelling&&(x.current===`recording`||x.current===`uploading`)){e.cancelling=!0,d(!1),E.current+=1,j(),h(0),P(),l(`idle`),x.current=`idle`;try{A.current?.cancel()}catch{}F();try{await L.stop()}catch{}finally{e.cancelling=!1}}}),W=s(async()=>{let e=T.current;if(e.confirming||x.current!==`recording`)return null;e.confirming=!0,d(!1);let t=++E.current;P(),j();try{if(await L.stop(),E.current!==t)return null;l(`uploading`),x.current=`uploading`;let e=A.current?.getFinalSeq()??-1;if(e<0)return A.current?.cancel(),z(``);let n=await A.current.finish(e);return E.current===t?z(n.text):null}catch(e){return E.current===t&&V(e),null}finally{e.confirming=!1}}),G=s(async()=>{if(x.current!==`failed`||!A.current?.hasSegments())return null;P();let e=++E.current;l(`uploading`),x.current=`uploading`;try{A.current.resetStreamForReplay();let t=A.current.getFinalSeq(),n=await A.current.finish(t);return E.current===e?z(n.text):null}catch(t){return E.current===e&&V(t),null}}),J=s(()=>{if(x.current!==`failed`)return null;let e=S.current.trim();h(0),l(`idle`),x.current=`idle`,P();try{A.current?.cancel()}catch{}return F(),e?(D.current?.(e),e):null}),Y=s(()=>{h(0),l(`idle`),x.current=`idle`,P(),F()});return(0,g.useEffect)(()=>n(()=>{x.current===`failed`?(E.current+=1,Y()):U()}),[U,Y]),(0,g.useEffect)(()=>{if(o!==`recording`||y!==`model_download_in_progress`)return;let e=setInterval(()=>{x.current!==`recording`||A.current?.getDictationId()||A.current?.restartStream().then(()=>{P()}).catch(e=>{N(e)})},3e3);return()=>clearInterval(e)},[o,y,P,N]),(0,g.useEffect)(()=>()=>{E.current+=1,j(),R.current().catch(()=>void 0),A.current?.cancel()},[j]),{status:o,isRecording:o===`recording`,isStarting:u,isProcessing:o===`uploading`,partialTranscript:f,volume:L.volume,duration:m,error:_,errorReason:y,startDictation:H,confirmDictation:W,cancelDictation:U,retryFailedDictation:G,acceptPartialTranscript:J,discardFailedDictation:Y}}export{z as n,J as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{p as t}from"./runtime-auth-DA-qfGHk.js";import{c as n,f as r}from"./runtime-switch-DEPKHgdL.js";import{st as i}from"./vendor-base-ui-wXsskyKm.js";import{xt as a}from"./gitApiHttp-Dd-FwgCq.js";import{n as o}from"./vendor-react-BkccXcWz.js";import{r as s}from"./vendor-reactuses-core-DjKFMfz7.js";import{t as c}from"./i18n-DXc6czdR.js";import{a as l,i as u,l as d,o as f,s as p,t as m,u as h}from"./audio-session-BFWjrDbp.js";var g=e(i(),1),_=class{abort;partial;disconnected;socket=null;failure=null;completion=null;text=``;final=!1;finishing=!1;sequence=0;constructor(e,t,n){this.abort=e,this.partial=t,this.disconnected=n}get connected(){return this.socket!==null&&!this.failure&&!this.abort.signal.aborted}async start(e,t){if(t!==`audio/pcm;rate=16000;bits=16`)throw Error(`Direct speech requires 16 kHz PCM16 audio`);let n=await f(h(e,`asr`),this.abort.signal);this.socket=n;try{n.send(u(new TextEncoder().encode(JSON.stringify({user:{uid:`yuri`},audio:{format:`pcm`,codec:`raw`,rate:16e3,bits:16,channel:1},request:{model_name:`bigmodel`,result_type:`full`,enable_itn:!0,enable_punc:!0,enable_nonstream:!0,show_utterances:!0,...e.asrContext?.trim()?{corpus:{context:JSON.stringify({context_type:`dialog_ctx`,context_data:[{text:e.asrContext.trim()}]})}}:{}}}))))}catch(e){throw n.close(),e}this.completion=this.receive().catch(e=>{this.failure=e instanceof Error?e:Error(`Speech recognition failed`),n.close(),!this.abort.signal.aborted&&!this.finishing&&this.disconnected()})}send(e,t){if(!this.connected||this.finishing||this.final||e!==this.sequence)return!1;try{if(t.length>128e3)throw Error(`Speech audio chunk exceeds size limit`);let e=atob(t);if(e.length%2)throw Error(`Invalid PCM audio`);let n=Uint8Array.from(e,e=>e.charCodeAt(0));return this.socket.send(u(n,!0)),this.sequence++,!0}catch{return this.failure=Error(`Unable to send speech audio`),this.socket?.close(),!1}}async finish(e){if(this.failure)throw this.failure;if(!this.socket||e!==this.sequence-1)throw Error(`Incomplete speech audio`);this.finishing=!0,this.socket.send(u(new Uint8Array,!0,!0));let t=setTimeout(()=>{this.failure=Error(`Speech finalization timed out`),this.socket?.close()},3e4);try{if(await this.completion,this.abort.signal.throwIfAborted(),this.failure)throw this.failure;if(!this.final)throw Error(`Incomplete speech recognition`);return{text:this.text}}finally{clearTimeout(t),this.socket.close()}}cancel(){this.abort.abort(),this.socket?.close()}async receive(){for(;;){let e=await l(await this.socket.read(),`asr`);this.abort.signal.throwIfAborted();let t=p(e.payload);if(t.code!==void 0&&![0,1e3,2e7].includes(Number(t.code)))throw Error(`Speech recognition failed`);let n=t.result;if(n!==void 0&&(!n||typeof n!=`object`||Array.isArray(n)))throw Error(`Invalid speech transcript`);if(n&&typeof n==`object`&&`text`in n){if(typeof n.text!=`string`)throw Error(`Invalid speech transcript`);this.text=n.text,e.final||this.partial(this.text)}if(e.final){if(!this.finishing)throw Error(`Speech recognition ended unexpectedly`);this.final=!0;return}}}},v=(e,t,n)=>{let r=Error(e);return r.name=`DictationStreamError`,r.retryable=t,n&&(r.reasonCode=n),r},y=1e4,b=15e3,x=3e4,S=3e4,C=new class{socket=null;connectPromise=null;idleCloseTimer=null;pendingStarts=new Map;pendingFinishes=new Map;connectionListeners=new Set;partialListeners=new Set;activeDictations=0;directStarts=new Map;directSessions=new Map;get isConnected(){if(this.socket?.readyState===WebSocket.OPEN)return!0;for(let e of this.directSessions.values())if(e.connected)return!0;return!1}subscribeConnectionStatus(e){return this.connectionListeners.add(e),()=>{this.connectionListeners.delete(e)}}onPartial(e){return this.partialListeners.add(e),()=>{this.partialListeners.delete(e)}}async ensureConnected(){if(this.socket?.readyState!==WebSocket.OPEN){if(this.connectPromise){await this.connectPromise;return}try{await t()}catch{}this.connectPromise=new Promise((e,t)=>{let n=!1,i;try{let e=r().websocket(`/api/dictation/ws`);i=a(e)}catch(e){this.connectPromise=null,t(e instanceof Error?e:Error(String(e)));return}let o=setTimeout(()=>{if(!n){n=!0,this.connectPromise=null;try{i.close()}catch{}t(Error(`Dictation connection timed out`))}},y);i.onopen=()=>{},i.onmessage=t=>{let r;try{r=JSON.parse(String(t.data))}catch{return}if(!n&&r.type===`ready`){n=!0,clearTimeout(o),this.socket=i,this.connectPromise=null,this.notifyConnection(!0),e();return}this.handleMessage(r)},i.onerror=()=>{window.setTimeout(()=>{n||(n=!0,clearTimeout(o),this.connectPromise=null,t(Error(`Dictation connection failed`)))},250)},i.onclose=e=>{if(!n){n=!0,clearTimeout(o),this.connectPromise=null;let r=e?.reason?`: ${e.reason}`:``;t(Error(`Dictation connection failed${r}`));return}this.socket===i&&(this.socket=null,this.rejectAllPending(Error(`Dictation connection lost`)),this.notifyConnection(!1))}}),await this.connectPromise}}async startDictationStream(e,t){let n=new AbortController;this.directStarts.set(e,n);try{let r=await d(`asr`,n.signal);if(n.signal.throwIfAborted(),r){let i=new _(n,t=>{for(let n of this.partialListeners)n(e,t)},()=>{this.directSessions.delete(e),i.cancel(),this.notifyConnection(!1)});this.directSessions.set(e,i),await i.start(r,t),n.signal.throwIfAborted(),this.notifyConnection(!0);return}await this.ensureConnected(),n.signal.throwIfAborted()}catch(t){throw this.directSessions.get(e)?.cancel(),this.directSessions.delete(e),t}finally{this.directStarts.delete(e)}return this.activeDictations+=1,this.clearIdleCloseTimer(),new Promise((n,r)=>{let i=setTimeout(()=>{this.pendingStarts.delete(e),this.releaseDictation(),r(Error(`Dictation start timed out`))},b);this.pendingStarts.set(e,{resolve:()=>{clearTimeout(i),n()},reject:e=>{clearTimeout(i),this.releaseDictation(),r(e)},timeout:i}),this.send({type:`start`,dictationId:e,format:t})||(clearTimeout(i),this.pendingStarts.delete(e),this.releaseDictation(),r(Error(`Dictation connection lost`)))})}sendDictationStreamChunk(e,t,n){let r=this.directSessions.get(e);return r?r.send(t,n):this.send({type:`chunk`,dictationId:e,seq:t,audio:n})}finishDictationStream(e,t){let n=this.directSessions.get(e);return n?n.finish(t).finally(()=>{n.cancel(),this.directSessions.delete(e)}):new Promise((n,r)=>{let i={resolve:e=>{i.timeout&&clearTimeout(i.timeout),this.releaseDictation(),n(e)},reject:e=>{i.timeout&&clearTimeout(i.timeout),this.releaseDictation(),r(e)},timeout:null};i.timeout=setTimeout(()=>{this.pendingFinishes.delete(e),this.releaseDictation(),r(Error(`Timed out waiting for transcription`))},S),this.pendingFinishes.set(e,i),this.send({type:`finish`,dictationId:e,finalSeq:t})||(this.pendingFinishes.delete(e),i.reject(Error(`Dictation connection lost`)))})}cancelDictationStream(e){this.directStarts.get(e)?.abort(),this.directStarts.delete(e);let t=this.directSessions.get(e);if(t){t.cancel(),this.directSessions.delete(e);return}this.send({type:`cancel`,dictationId:e});let n=this.pendingStarts.get(e);n&&(this.pendingStarts.delete(e),n.reject(Error(`Dictation cancelled`)));let r=this.pendingFinishes.get(e);r&&(this.pendingFinishes.delete(e),r.reject(Error(`Dictation cancelled`))),this.releaseDictation(),this.scheduleIdleCloseIfReady()}handleMessage(e){let t=e.dictationId;if(t)switch(e.type){case`ack`:{let e=this.pendingStarts.get(t);e&&(this.pendingStarts.delete(t),e.resolve());return}case`partial`:for(let n of this.partialListeners)n(t,e.text??``);return;case`finish_accepted`:{let n=this.pendingFinishes.get(t);n&&typeof e.timeoutMs==`number`&&(n.timeout&&clearTimeout(n.timeout),n.timeout=setTimeout(()=>{this.pendingFinishes.delete(t),n.reject(Error(`Timed out waiting for transcription`))},e.timeoutMs+5e3));return}case`final`:{let n=this.pendingFinishes.get(t);n&&(this.pendingFinishes.delete(t),n.resolve({text:e.text??``})),this.scheduleIdleCloseIfReady();return}case`error`:{let n=v(e.error||`Dictation failed`,e.retryable!==!1,e.reasonCode),r=this.pendingStarts.get(t);r&&(this.pendingStarts.delete(t),r.reject(n));let i=this.pendingFinishes.get(t);i&&(this.pendingFinishes.delete(t),i.reject(n)),this.scheduleIdleCloseIfReady();return}}}send(e){if(!this.isConnected||!this.socket)return!1;try{return this.socket.send(JSON.stringify(e)),!0}catch{return!1}}notifyConnection(e){for(let t of this.connectionListeners)t(e)}rejectAllPending(e){for(let[t,n]of this.pendingStarts)this.pendingStarts.delete(t),n.reject(e);for(let[t,n]of this.pendingFinishes)this.pendingFinishes.delete(t),n.reject(e);this.activeDictations=0}releaseDictation(){this.activeDictations=Math.max(0,this.activeDictations-1),this.scheduleIdleCloseIfReady()}scheduleIdleCloseIfReady(){this.activeDictations>0||this.pendingFinishes.size>0||this.pendingStarts.size>0||(this.clearIdleCloseTimer(),this.idleCloseTimer=setTimeout(()=>{if(this.activeDictations===0&&this.pendingFinishes.size===0&&this.pendingStarts.size===0){let e=this.socket;if(this.socket=null,e){try{e.close(1e3,`idle`)}catch{}this.notifyConnection(!1)}}},x))}cancelAllForRuntimeSwitch(){for(let e of this.directStarts.values())e.abort();this.directStarts.clear();for(let e of this.directSessions.values())e.cancel();this.directSessions.clear(),this.clearIdleCloseTimer();let e=this.socket;if(this.socket=null,this.connectPromise=null,this.rejectAllPending(Error(`Runtime changed`)),e){try{e.close(1e3,`runtime switch`)}catch{}this.notifyConnection(!1)}}clearIdleCloseTimer(){this.idleCloseTimer&&=(clearTimeout(this.idleCloseTimer),null)}};typeof window<`u`&&window.addEventListener(`yuri:runtime-endpoint-changed`,()=>{C.cancelAllForRuntimeSwitch()});var w=128,T=`audio/pcm;rate=16000;bits=16`,E=()=>new Promise(e=>setTimeout(e,0)),D=()=>{let e=Math.random().toString(36).slice(2,10);return`dic_${Date.now().toString(16)}${e}`},O=class{client;format;createDictationId;dictationId=null;sendSeq=0;segments=[];streamReady=!1;flushTimer=null;drainWaiters=[];startGeneration=0;startPromise=null;constructor(e){this.client=e.client,this.format=e.format??T,this.createDictationId=e.createDictationId??D}getDictationId(){return this.dictationId}getFinalSeq(){return this.segments.length-1}hasSegments(){return this.segments.length>0}clearAll(){this.dictationId&&this.client.cancelDictationStream(this.dictationId),this.clearScheduledFlush(),this.dictationId=null,this.sendSeq=0,this.segments=[],this.streamReady=!1,this.startPromise=null,this.startGeneration+=1}resetStreamForReplay(){this.dictationId&&this.client.cancelDictationStream(this.dictationId),this.clearScheduledFlush(),this.dictationId=null,this.sendSeq=0,this.streamReady=!1,this.startPromise=null,this.startGeneration+=1}enqueueSegment(e){if(this.segments.push(e),this.client.isConnected){if(!this.dictationId){this.startPromise||this.restartStream().catch(()=>{});return}this.flush()}}flush(){let e=this.dictationId;if(!this.client.isConnected||!e||!this.streamReady)return 0;let t=0;for(;this.sendSeq<this.segments.length&&t<w;){let n=this.sendSeq,r=this.segments[n];if(!this.client.sendDictationStreamChunk(e,n,r))break;this.sendSeq=n+1,t+=1}return this.hasPendingSegments()?this.scheduleFlush():this.resolveDrainWaiters(),t}async restartStream(){this.startGeneration+=1;let e=this.startGeneration,t=this.createDictationId();this.dictationId=t,this.sendSeq=0,this.streamReady=!1;let n=(async()=>{await this.client.startDictationStream(t,this.format),this.startGeneration===e&&this.dictationId===t&&(this.streamReady=!0,this.flush())})().catch(n=>{throw this.startGeneration===e&&this.dictationId===t&&(this.dictationId=null,this.streamReady=!1),n}).finally(()=>{this.startPromise===n&&(this.startPromise=null)});this.startPromise=n,await n}async finish(e){this.dictationId||await this.restartStream(),this.startPromise&&await this.startPromise;let t=this.dictationId;if(!t||!this.streamReady)throw Error(`Failed to start dictation stream`);return this.flush(),await this.waitForFlushDrain(),{dictationId:t,text:(await this.client.finishDictationStream(t,e)).text}}cancel(){this.resetStreamForReplay()}hasPendingSegments(){return this.sendSeq<this.segments.length}scheduleFlush(){this.flushTimer||=setTimeout(()=>{this.flushTimer=null,this.flush()},0)}clearScheduledFlush(){this.resolveDrainWaiters(),this.flushTimer&&=(clearTimeout(this.flushTimer),null)}async waitForFlushDrain(){for(;this.hasPendingSegments();){if(!this.client.isConnected||!this.dictationId||!this.streamReady)throw Error(`Failed to flush dictation stream`);await new Promise(e=>{this.drainWaiters.push(e)}),await E()}}resolveDrainWaiters(){let e=this.drainWaiters;this.drainWaiters=[];for(let t of e)t()}},k=o(),A=16e3,j=A/5,M=()=>{if(typeof window>`u`)return null;let e=window;return e.AudioContext||e.webkitAudioContext||null},N=e=>{let t=Math.max(-1,Math.min(1,e));return Math.round(t<0?t*32768:t*32767)},P=(e,t,n)=>{if(e.length===0)return new Int16Array;if(t===n){let t=new Int16Array(e.length);for(let n=0;n<e.length;n++)t[n]=N(e[n]);return t}let r=t/n,i=Math.max(1,Math.round(e.length/r)),a=new Int16Array(i);for(let t=0;t<i;t++){let n=t*r,i=Math.floor(n),o=Math.min(e.length-1,i+1),s=n-i;a[t]=N(e[i]*(1-s)+e[o]*s)}return a},F=(e,t)=>{if(e.length===0)return t;if(t.length===0)return e;let n=new Int16Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n},I=e=>{let t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),n=``;for(let e=0;e<t.length;e++)n+=String.fromCharCode(t[e]);return btoa(n)},L=()=>({stream:null,context:null,source:null,processor:null,gain:null,pending:new Int16Array,started:!1}),R=e=>{if(e)try{e.disconnect()}catch{}},z=()=>typeof navigator>`u`||typeof window>`u`||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!=`function`?!1:M()!==null;function B(e){let t=(0,k.c)(16),[n,r]=(0,g.useState)(0),i=(0,g.useRef)(e.onPcmSegment),a=(0,g.useRef)(e.onError),o,c;t[0]!==e.onError||t[1]!==e.onPcmSegment?(o=()=>{i.current=e.onPcmSegment,a.current=e.onError},c=[e.onPcmSegment,e.onError],t[0]=e.onError,t[1]=e.onPcmSegment,t[2]=o,t[3]=c):(o=t[2],c=t[3]),(0,g.useEffect)(o,c);let l;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(l=L(),t[4]=l):l=t[4];let u=(0,g.useRef)(l),d=(0,g.useRef)(0),f;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(f=async()=>{if(u.current.started)return;if(typeof navigator>`u`||!navigator.mediaDevices||typeof navigator.mediaDevices.getUserMedia!=`function`)throw Error(`Microphone capture is not supported in this environment`);let e=M();if(!e)throw Error(`AudioContext unavailable`);let t=d.current+=1;m();let n=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,noiseSuppression:!0,echoCancellation:!0,autoGainControl:!0}});if(t!==d.current){n.getTracks().forEach(G);return}let a=new e;try{if(a.state===`suspended`&&await a.resume().catch(W),t!==d.current){n.getTracks().forEach(U),await a.close();return}let e=a.createMediaStreamSource(n),o=a.createScriptProcessor(4096,1,1),s=a.createGain();s.gain.value=0,u.current={stream:n,context:a,source:e,processor:o,gain:s,pending:new Int16Array,started:!0},o.onaudioprocess=e=>{let t=u.current;if(!t.started)return;let n=e.inputBuffer.getChannelData(0),o=0;for(let e=0;e<n.length;e++)o+=n[e]*n[e];let s=Math.sqrt(o/Math.max(1,n.length));r(Math.min(1,Math.max(0,s*2)));let c=P(n,a.sampleRate,A);for(t.pending=F(t.pending,c);t.pending.length>=j;){let e=t.pending.slice(0,j);t.pending=t.pending.slice(j),i.current(I(e))}},e.connect(o),o.connect(s),s.connect(a.destination)}catch(e){let t=e;n.getTracks().forEach(H);try{await a.close()}catch{}throw u.current=L(),t instanceof Error?t:Error(String(t))}},t[5]=f):f=t[5];let p=s(f),h;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(h=async()=>{d.current+=1;let e=u.current;if(e.started=!1,r(0),e.processor)try{e.processor.onaudioprocess=null}catch{}R(e.processor),R(e.source),R(e.gain),e.stream&&e.stream.getTracks().forEach(V);let t=e.pending;if(e.pending=new Int16Array,t.length>0&&i.current(I(t)),e.context)try{await e.context.close()}catch{}u.current===e&&(u.current=L())},t[6]=h):h=t[6];let _=s(h),v,y;t[7]===_?(v=t[8],y=t[9]):(v=()=>()=>{_().catch(e=>{a.current?.(e instanceof Error?e:Error(String(e)))})},y=[_],t[7]=_,t[8]=v,t[9]=y),(0,g.useEffect)(v,y);let b;t[10]===p?b=t[11]:(b=async()=>{try{await p()}catch(e){let t=e,n=t instanceof Error?t:Error(String(t));throw a.current?.(n),n}},t[10]=p,t[11]=b);let x;return t[12]!==_||t[13]!==b||t[14]!==n?(x={start:b,stop:_,volume:n},t[12]=_,t[13]=b,t[14]=n,t[15]=x):x=t[15],x}function V(e){try{e.stop()}catch{}}function H(e){try{e.stop()}catch{}}function U(e){return e.stop()}function W(){}function G(e){return e.stop()}var K=1e3,q=e=>e instanceof Error?e:Error(String(e));function J(e={}){let{t}=c(),{onTranscript:r,onError:i,canStart:a}=e,[o,l]=(0,g.useState)(`idle`),[u,d]=(0,g.useState)(!1),[f,p]=(0,g.useState)(``),[m,h]=(0,g.useState)(0),[_,v]=(0,g.useState)(null),[y,b]=(0,g.useState)(null),x=(0,g.useRef)(o);(0,g.useEffect)(()=>{x.current=o},[o]);let S=(0,g.useRef)(``),w=(0,g.useRef)(null),T=(0,g.useRef)({starting:!1,confirming:!1,cancelling:!1}),E=(0,g.useRef)(0),D=(0,g.useRef)(r),k=(0,g.useRef)(i);(0,g.useEffect)(()=>{D.current=r,k.current=i},[r,i]);let A=(0,g.useRef)(null);A.current||=new O({client:C});let j=s(()=>{w.current&&=(clearInterval(w.current),null)}),M=s(()=>{w.current||=setInterval(()=>{h(e=>e+1)},K)}),N=s(e=>{let n=q(e),r=n.name===`NotFoundError`||n.name===`DevicesNotFoundError`?Error(t(`chat.dictation.error.microphoneNotFound`),{cause:n}):n;v(r.message);let i=n.reasonCode;b(typeof i==`string`?i:null),k.current?.(r)}),P=s(()=>{v(null),b(null)}),F=s(()=>{A.current?.clearAll(),S.current=``,p(``)}),I=s(t=>e.onPartialTranscript?.(t));(0,g.useEffect)(()=>C.onPartial((e,t)=>{let n=A.current?.getDictationId();!n||e!==n||(S.current=t,p(t),I(t))}),[I]),(0,g.useEffect)(()=>C.subscribeConnectionStatus(e=>{if(!e){x.current===`recording`&&A.current?.resetStreamForReplay();return}if(x.current!==`recording`||A.current?.getDictationId())return;let t=E.current;A.current?.restartStream().catch(e=>{E.current===t&&N(e)})}),[N]);let L=B({onPcmSegment:e=>{x.current===`recording`&&A.current?.enqueueSegment(e)},onError:e=>{k.current?.(e)}}),R=(0,g.useRef)(L.stop);(0,g.useEffect)(()=>{R.current=L.stop},[L.stop]);let z=s(e=>{h(0),l(`idle`),x.current=`idle`;let t=e.trim();return F(),t?(D.current?.(t),t):null}),V=s(e=>{A.current?.hasSegments()?(l(`failed`),x.current=`failed`):(l(`idle`),x.current=`idle`),N(e)}),H=s(async()=>{let e=T.current;if(e.starting||e.confirming||e.cancelling||x.current!==`idle`||a&&!a())return;e.starting=!0,d(!0);let t=++E.current;P(),p(``),h(0),l(`recording`),x.current=`recording`,F();try{if(await L.start(),E.current!==t||x.current!==`recording`)return;d(!1),M(),await A.current?.restartStream().catch(e=>{E.current===t&&N(e)})}catch(e){if(E.current!==t)return;await L.stop().catch(()=>void 0),j(),l(`idle`),x.current=`idle`,N(e)}finally{E.current===t&&d(!1),e.starting=!1}}),U=s(async()=>{let e=T.current;if(!e.cancelling&&(x.current===`recording`||x.current===`uploading`)){e.cancelling=!0,d(!1),E.current+=1,j(),h(0),P(),l(`idle`),x.current=`idle`;try{A.current?.cancel()}catch{}F();try{await L.stop()}catch{}finally{e.cancelling=!1}}}),W=s(async()=>{let e=T.current;if(e.confirming||x.current!==`recording`)return null;e.confirming=!0,d(!1);let t=++E.current;P(),j();try{if(await L.stop(),E.current!==t)return null;l(`uploading`),x.current=`uploading`;let e=A.current?.getFinalSeq()??-1;if(e<0)return A.current?.cancel(),z(``);let n=await A.current.finish(e);return E.current===t?z(n.text):null}catch(e){return E.current===t&&V(e),null}finally{e.confirming=!1}}),G=s(async()=>{if(x.current!==`failed`||!A.current?.hasSegments())return null;P();let e=++E.current;l(`uploading`),x.current=`uploading`;try{A.current.resetStreamForReplay();let t=A.current.getFinalSeq(),n=await A.current.finish(t);return E.current===e?z(n.text):null}catch(t){return E.current===e&&V(t),null}}),J=s(()=>{if(x.current!==`failed`)return null;let e=S.current.trim();h(0),l(`idle`),x.current=`idle`,P();try{A.current?.cancel()}catch{}return F(),e?(D.current?.(e),e):null}),Y=s(()=>{h(0),l(`idle`),x.current=`idle`,P(),F()});return(0,g.useEffect)(()=>n(()=>{x.current===`failed`?(E.current+=1,Y()):U()}),[U,Y]),(0,g.useEffect)(()=>{if(o!==`recording`||y!==`model_download_in_progress`)return;let e=setInterval(()=>{x.current!==`recording`||A.current?.getDictationId()||A.current?.restartStream().then(()=>{P()}).catch(e=>{N(e)})},3e3);return()=>clearInterval(e)},[o,y,P,N]),(0,g.useEffect)(()=>()=>{E.current+=1,j(),R.current().catch(()=>void 0),A.current?.cancel()},[j]),{status:o,isRecording:o===`recording`,isStarting:u,isProcessing:o===`uploading`,partialTranscript:f,volume:L.volume,duration:m,error:_,errorReason:y,startDictation:H,confirmDictation:W,cancelDictation:U,retryFailedDictation:G,acceptPartialTranscript:J,discardFailedDictation:Y}}export{z as n,J as t};
@@ -1 +1 @@
1
- import{St as e}from"./gitApiHttp-Dd-FwgCq.js";import{n as t}from"./vendor-react-BkccXcWz.js";import{E as n}from"./runtime-file-resource-Bc_ss-sW.js";import{Ia as r,Na as i,_ as a,b as o,f as s,tt as c}from"./ui-BtnozFKV.js";var l=t(),u=()=>{let t=i.getState(),n=t.projects.find(e=>e.id===t.activeProjectId);if(n?.hostId){let e=r.getState().remoteSession;return e?.projectId===n.id&&e.location.hostId===n.hostId&&(!n.hubId||e.location.hubId===n.hubId)?e.location.directory:n.path}let c=s.getState(),l=c.currentSessionId,u=c.newSessionDraft,d=c.worktreeMetadata,f=e.getState().currentDirectory;if(l){let e=o.getState().getAttachment(l),t=a(e);if(t)return t;let n=d.get(l);if(n?.path)return n.path;let r=c.getDirectoryForSession(l);if(r)return r}return u?.open&&(u.bootstrapPendingDirectory||u.directoryOverride)?(u.bootstrapPendingDirectory||u.directoryOverride)??void 0:f??void 0},d=()=>{let t=(0,l.c)(15),u=n(),d=i(f),m=r(p),h=!!(u?.entry.location.hostId||d?.hostId),g;t[0]===h?g=t[1]:(g=e=>h?null:e.currentSessionId,t[0]=h,t[1]=g);let _=s(g),v;t[2]===h?v=t[3]:(v=e=>h?null:e.newSessionDraft,t[2]=h,t[3]=v);let y=s(v),b=c(_),x;t[4]===_?x=t[5]:(x=e=>_?e.getAttachment(_):void 0,t[4]=_,t[5]=x);let S=o(x),C;t[6]===h?C=t[7]:(C=e=>h?void 0:e.worktreeMetadata,t[6]=h,t[7]=C);let w=s(C),T;t[8]===h?T=t[9]:(T=e=>h?void 0:e.currentDirectory,t[8]=h,t[9]=T);let E=e(T);if(u?.entry.location.hostId)return m&&m.projectId===d?.id&&m.location.hostId===u.entry.location.hostId&&m.location.hubId===u.entry.location.hubId?m.location.directory:u.entry.location.directory;if(d?.hostId)return m?.projectId===d.id&&m.location.hostId===d.hostId&&(!d.hubId||m.location.hubId===d.hubId)?m.location.directory:d.path;if(_){let e;t[10]===S?e=t[11]:(e=a(S),t[10]=S,t[11]=e);let n=e;if(n)return n;let r;t[12]!==_||t[13]!==w?(r=w?.get(_),t[12]=_,t[13]=w,t[14]=r):r=t[14];let i=r;if(i?.path)return i.path;if(b)return b}return y?.open&&(y.bootstrapPendingDirectory||y.directoryOverride)?(y.bootstrapPendingDirectory||y.directoryOverride)??void 0:E??void 0};function f(e){return e.projects.find(t=>t.id===e.activeProjectId)}function p(e){return e.remoteSession}export{d as n,u as t};
1
+ import{St as e}from"./gitApiHttp-Dd-FwgCq.js";import{n as t}from"./vendor-react-BkccXcWz.js";import{E as n}from"./runtime-file-resource-Bc_ss-sW.js";import{Ia as r,Na as i,_ as a,b as o,f as s,tt as c}from"./ui-DyxdnQlj.js";var l=t(),u=()=>{let t=i.getState(),n=t.projects.find(e=>e.id===t.activeProjectId);if(n?.hostId){let e=r.getState().remoteSession;return e?.projectId===n.id&&e.location.hostId===n.hostId&&(!n.hubId||e.location.hubId===n.hubId)?e.location.directory:n.path}let c=s.getState(),l=c.currentSessionId,u=c.newSessionDraft,d=c.worktreeMetadata,f=e.getState().currentDirectory;if(l){let e=o.getState().getAttachment(l),t=a(e);if(t)return t;let n=d.get(l);if(n?.path)return n.path;let r=c.getDirectoryForSession(l);if(r)return r}return u?.open&&(u.bootstrapPendingDirectory||u.directoryOverride)?(u.bootstrapPendingDirectory||u.directoryOverride)??void 0:f??void 0},d=()=>{let t=(0,l.c)(15),u=n(),d=i(f),m=r(p),h=!!(u?.entry.location.hostId||d?.hostId),g;t[0]===h?g=t[1]:(g=e=>h?null:e.currentSessionId,t[0]=h,t[1]=g);let _=s(g),v;t[2]===h?v=t[3]:(v=e=>h?null:e.newSessionDraft,t[2]=h,t[3]=v);let y=s(v),b=c(_),x;t[4]===_?x=t[5]:(x=e=>_?e.getAttachment(_):void 0,t[4]=_,t[5]=x);let S=o(x),C;t[6]===h?C=t[7]:(C=e=>h?void 0:e.worktreeMetadata,t[6]=h,t[7]=C);let w=s(C),T;t[8]===h?T=t[9]:(T=e=>h?void 0:e.currentDirectory,t[8]=h,t[9]=T);let E=e(T);if(u?.entry.location.hostId)return m&&m.projectId===d?.id&&m.location.hostId===u.entry.location.hostId&&m.location.hubId===u.entry.location.hubId?m.location.directory:u.entry.location.directory;if(d?.hostId)return m?.projectId===d.id&&m.location.hostId===d.hostId&&(!d.hubId||m.location.hubId===d.hubId)?m.location.directory:d.path;if(_){let e;t[10]===S?e=t[11]:(e=a(S),t[10]=S,t[11]=e);let n=e;if(n)return n;let r;t[12]!==_||t[13]!==w?(r=w?.get(_),t[12]=_,t[13]=w,t[14]=r):r=t[14];let i=r;if(i?.path)return i.path;if(b)return b}return y?.open&&(y.bootstrapPendingDirectory||y.directoryOverride)?(y.bootstrapPendingDirectory||y.directoryOverride)??void 0:E??void 0};function f(e){return e.projects.find(t=>t.id===e.activeProjectId)}function p(e){return e.remoteSession}export{d as n,u as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n}from"./runtime-switch-DEPKHgdL.js";import{a as r,r as i}from"./vendor-zustand-CTekDqaS.js";import{st as a}from"./vendor-base-ui-wXsskyKm.js";import{n as o}from"./vendor-react-BkccXcWz.js";import{Jn as s,Kn as c}from"./ui-BtnozFKV.js";var l=o(),u=e(a(),1),d=e=>e instanceof Error?e.name===`AbortError`||e.name===`CancelledError`||e.name===`Error`&&e.message===`CancelledError`:!1,f=1e4,p=6e4,m=5e3,h=3e4,g=6e4,_=25,v=40,y=2,b=15e3,x=500,S=30,C=20971520,w=new Map,T=new Map,E=new Map,D=new Map,O=new Map,k=new Map,A=new WeakMap,j=e=>{let t=A.get(e);return t||(t=new Set(e.files.map(e=>e.path)),A.set(e,t)),t},M=(e,t)=>`${t}:${e}`,N=e=>T.get(e)??0,P=e=>{let t=N(e)+1;return T.set(e,t),t},F=e=>{let t=(E.get(e)??0)+1;return E.set(e,t),t},I=e=>{let t=w.get(e);if(t)return t;let n=new Set;return w.set(e,n),n},L=()=>({isGitRepo:null,status:null,branches:null,branchesTransportIdentity:null,log:null,identity:null,diffCache:new Map,indexRevision:0,lastRepoCheckAt:0,lastStatusFetch:0,lastStatusChange:0,lastLogFetch:0,lastBranchesFetch:0,lastIdentityFetch:0,logMaxCount:25,isLoadingStatus:!1,isLoadingLog:!1,isLoadingBranches:!1,isLoadingIdentity:!1}),R=(e,t=S,n=C)=>{let r=0;for(let t of e.values())r+=(t.original?.length??0)+(t.modified?.length??0);if(e.size<=t&&r<=n)return e;let i=Array.from(e.entries()).sort((e,t)=>e[1].fetchedAt-t[1].fetchedAt),a=new Map,o=0;for(let e=i.length-1;e>=0;e--){let[r,s]=i[e],c=(s.original?.length??0)+(s.modified?.length??0);if(a.size>=t)break;o+c>n&&a.size>0||(a.set(r,s),o+=c)}return a},z=(e,t)=>!e&&!t?!1:!e||!t||e.remote!==t.remote||e.branch!==t.branch||e.ahead!==t.ahead||e.behind!==t.behind,B=e=>{let t=e?.trim()??``;return t===`?`?``:t},V=(e,t)=>{let n=new Set,r=!1,i=!e;e&&(i=e.ahead!==t.ahead||e.behind!==t.behind||e.current!==t.current||e.tracking!==t.tracking||e.isClean!==t.isClean||t.upstreamComparison!==void 0&&z(e.upstreamComparison,t.upstreamComparison)||t.diffStats!==void 0&&e.diffStats===void 0);let a=new Map;for(let t of e?.files??[])a.set(t.path,t);for(let e of t.files??[]){let t=a.get(e.path);if(!t){n.add(e.path),B(e.index)&&(r=!0);continue}a.delete(e.path),(t.index!==e.index||t.working_dir!==e.working_dir)&&n.add(e.path),!r&&B(t.index)!==B(e.index)&&(r=!0)}for(let[e,t]of a)n.add(e),B(t.index)&&(r=!0);let o=t.diffStats,s=e?.diffStats;if(o!==void 0&&o!==s){let e=s??{};for(let t in o){let r=o[t],i=e[t];(!i||i.insertions!==r.insertions||i.deletions!==r.deletions)&&n.add(t)}for(let t in e)t in o||n.add(t)}return{changed:i||n.size>0,changedPaths:n,indexChanged:r}},H=e=>!e||e.trim().length===0,U=e=>(e||``).trim()===`U`,W=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(U(t)||U(n))return e;let r=t===`?`||n===`?`?`A`:t||n||` `;return{...e,index:r,working_dir:` `}},G=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(U(t)||U(n))return e;let r=n||(t===`A`||t===`?`?`?`:t)||` `;return{...e,index:` `,working_dir:r}},K=e=>H(e.index)&&H(e.working_dir),q=r()(i((e,t)=>({directories:new Map,activeDirectory:null,setActiveDirectory:n=>{let{activeDirectory:r,directories:i}=t();if(r!==n)if(r&&P(r),n&&P(n),n&&!i.has(n)){let t=new Map(i);t.set(n,L()),e({activeDirectory:n,directories:t})}else e({activeDirectory:n})},getDirectoryState:e=>t().directories.get(e)??null,fetchStatus:async(n,r,i={})=>{let a=i.mode??`full`,o=M(n,a),s=D.get(o)??(a===`light`?D.get(M(n,`full`)):void 0);if(s)return s;let c=(async()=>{let{silent:a=!1}=i,{directories:o}=t(),s=o.get(n);if(s||=L(),!a){let r=new Map(t().directories),i=r.get(n)??L();r.set(n,{...i,isLoadingStatus:!0}),e({directories:r})}let c=!1;try{let a=Date.now(),o=s.isGitRepo!==!0||a-(s.lastRepoCheckAt||0)>p,l=s.isGitRepo===!0;if(o&&(l=await r.checkIsGitRepository(n)),!l){let r=new Map(t().directories),i=r.get(n)??s;return r.set(n,{...i,isGitRepo:!1,status:null,isLoadingStatus:!1,lastRepoCheckAt:a,lastStatusFetch:a}),e({directories:r}),!1}let u=await r.getGitStatus(n,i.mode?{mode:i.mode}:void 0),d=t().directories.get(n)??L(),f=k.get(n),m=f?.received===u&&f.stored===d.status?null:V(d.status,u);if(m?.changed){c=!0;let r=new Map(t().directories),i=r.get(n)??L(),{changedPaths:s,indexChanged:l}=m,d=new Map(i.diffCache);for(let e of s)d.delete(e);let f=s.size>0;f&&P(n);let p={...u,diffStats:u.diffStats===void 0&&i.status?.diffStats!==void 0?i.status.diffStats:u.diffStats,upstreamComparison:u.upstreamComparison===void 0?i.status?.upstreamComparison:u.upstreamComparison};r.set(n,{...i,isGitRepo:!0,status:p,diffCache:d,indexRevision:l?i.indexRevision+1:i.indexRevision,lastRepoCheckAt:o?a:i.lastRepoCheckAt,lastStatusFetch:Date.now(),lastStatusChange:f?Date.now():i.lastStatusChange}),e({directories:r}),k.set(n,{received:u,stored:p})}else{k.set(n,{received:u,stored:d.status});let r=new Map(t().directories),i=r.get(n)??L();r.set(n,{...i,isGitRepo:!0,lastRepoCheckAt:o?a:i.lastRepoCheckAt,lastStatusFetch:Date.now(),lastStatusChange:i.lastStatusChange}),e({directories:r})}}catch(e){console.error(`Failed to fetch git status:`,e)}finally{if(!a){let r=new Map(t().directories),i=r.get(n)??L();r.set(n,{...i,isLoadingStatus:!1}),e({directories:r})}}return c})();D.set(o,c);try{return await c}finally{D.get(o)===c&&D.delete(o)}},moveStatusPathsOptimistically:(n,r,i)=>{let a=new Set(r.map(e=>e.trim()).filter(Boolean));if(a.size===0)return null;let{directories:o}=t(),s=o.get(n),c=s?.status??null;if(!s||!c)return c;let l=!1,u=[];for(let e of c.files){if(!a.has(e.path)){u.push(e);continue}let t=i===`stage`?W(e):G(e);t!==e&&(l=!0),K(t)?l=!0:u.push(t)}if(!l)return c;let d=new Map(o);return d.set(n,{...s,status:{...c,files:u,isClean:u.length===0},indexRevision:s.indexRevision+1,lastStatusChange:Date.now()}),e({directories:d}),c},restoreStatus:(n,r)=>{let{directories:i}=t(),a=i.get(n);if(!a)return;let o=new Map(i);o.set(n,{...a,status:r,indexRevision:a.indexRevision+1,lastStatusChange:Date.now()}),e({directories:o})},bumpIndexRevision:n=>{let{directories:r}=t(),i=r.get(n);if(!i)return;let a=new Map(r);a.set(n,{...i,indexRevision:i.indexRevision+1}),e({directories:a})},fetchBranches:async(r,i,a={})=>{let o=n(),l=F(r);{let n=new Map(t().directories),i=n.get(r)??L();n.set(r,{...i,isLoadingBranches:!0}),e({directories:n})}try{let u=a.force?await s(r,i,void 0,o):await c(r,i,void 0,o);if(l!==E.get(r)||o!==n())return;let d=new Map(t().directories),f=d.get(r)??L();d.set(r,{...f,branches:u,branchesTransportIdentity:o,isLoadingBranches:!1,lastBranchesFetch:Date.now()}),e({directories:d})}catch(i){if(d(i)||console.error(`Failed to fetch git branches:`,i),l!==E.get(r)||o!==n())return;let a=new Map(t().directories),s=a.get(r)??L();a.set(r,{...s,isLoadingBranches:!1}),e({directories:a})}},fetchLog:async(n,r,i)=>{let{directories:a}=t(),o=a.get(n),s=i??o?.logMaxCount??25;{let r=new Map(t().directories),i=r.get(n)??L();r.set(n,{...i,isLoadingLog:!0}),e({directories:r})}try{let i=await r.getGitLog(n,{maxCount:s}),a=new Map(t().directories),o=a.get(n)??L();a.set(n,{...o,log:i,isLoadingLog:!1,lastLogFetch:Date.now(),logMaxCount:s}),e({directories:a})}catch(r){console.error(`Failed to fetch git log:`,r);let i=new Map(t().directories),a=i.get(n)??L();i.set(n,{...a,isLoadingLog:!1}),e({directories:i})}},fetchIdentity:async(n,r)=>{{let r=new Map(t().directories),i=r.get(n)??L();r.set(n,{...i,isLoadingIdentity:!0}),e({directories:r})}try{let i=await r.getCurrentGitIdentity(n),a=new Map(t().directories),o=a.get(n)??L();a.set(n,{...o,identity:i,isLoadingIdentity:!1,lastIdentityFetch:Date.now()}),e({directories:a})}catch(r){console.error(`Failed to fetch git identity:`,r);let i=new Map(t().directories),a=i.get(n)??L();i.set(n,{...a,isLoadingIdentity:!1}),e({directories:i})}},fetchAll:async(n,r,i={})=>{let{directories:a}=t(),o=a.get(n);if(!o){o=L();let t=new Map(a);t.set(n,o),e({directories:t})}let{force:s=!1,silentIfCached:c=!1}=i,l=Date.now();await t().fetchStatus(n,r,{silent:c&&!!o?.status});let u=t().directories.get(n);if(!u?.isGitRepo)return;await t().fetchBranches(n,r,{force:s});let d=l-(u.lastLogFetch||0);(s||d>f||!u.log)&&await t().fetchLog(n,r),await t().fetchIdentity(n,r)},getDiff:(e,n)=>t().directories.get(e)?.diffCache.get(n)??null,setDiff:(n,r,i)=>{let a=new Map(t().directories),o=a.get(n)??L(),s=new Map(o.diffCache);s.set(r,{...i,fetchedAt:Date.now()});let c=R(s);a.set(n,{...o,diffCache:c}),e({directories:a})},clearDiffCache:n=>{P(n);let r=new Map(t().directories),i=r.get(n);i&&(r.set(n,{...i,diffCache:new Map}),e({directories:r}))},fetchAllDiffs:async(e,n)=>{let r=t().directories.get(e);if(!r?.status?.files||r.status.files.length===0)return;let i=r.status.files.map(e=>e.path).slice(0,_);await t().prefetchDiffs(e,n,i,{maxFiles:_})},prefetchDiffs:async(n,r,i,a={})=>{let o=t().directories.get(n);if(!o?.status?.files||o.status.files.length===0||i.length===0)return;let{maxFiles:s=v}=a,c=Math.min(Math.max(1,s),S),l=j(o.status),u=o.status.diffStats,d=I(n),f=[],p=new Set;for(let e of i){if(p.size>=c)break;if(!e||p.has(e)||!l.has(e))continue;let t=u?.[e];t&&t.insertions+t.deletions>x||(p.add(e),!o.diffCache.has(e)&&(d.has(e)||f.push(e)))}let m=f;if(m.length===0)return;let h=N(n);if(typeof document<`u`&&document.hidden)return;m.forEach(e=>d.add(e));let g=0,_=[],C=()=>{let e=g;return g+=1,e<m.length?m[e]:null},w=async e=>{let t=r.getGitFileDiff(n,{path:e}),i=new Promise((e,t)=>{setTimeout(()=>t(Error(`Timed out after ${b}ms`)),b)}),a=await Promise.race([t,i]);return{path:e,diff:{original:a.original??``,modified:a.modified??``,isBinary:a.isBinary}}},T=async()=>{for(;;){if(h!==N(n))return;let e=C();if(!e)return;try{_.push(await w(e))}catch{}finally{d.delete(e)}}},E=Math.min(y,m.length);if(await Promise.allSettled(Array.from({length:E},()=>T())),m.forEach(e=>d.delete(e)),h!==N(n))return;let D=new Map(t().directories),O=D.get(n);if(!O)return;let k=new Map(O.diffCache),A=Date.now();_.forEach(e=>{!e.diff.isBinary&&e.diff.original===``&&e.diff.modified===``||k.set(e.path,{...e.diff,fetchedAt:A})});let M=R(k);D.set(n,{...O,diffCache:M}),e({directories:D})},setLogMaxCount:(n,r)=>{let i=new Map(t().directories),a=i.get(n)??L();i.set(n,{...a,logMaxCount:r}),e({directories:i})},ensureStatus:async(e,n)=>{let r=t().directories.get(e),i=Date.now();r?.status&&i-r.lastStatusFetch<m||await t().fetchStatus(e,n,{silent:!!r?.status})},ensureAll:(e,n)=>{let r=O.get(e);if(r)return r;let i=(async()=>{let r=t().directories.get(e),i=Date.now();(!r?.status||r.status.diffStats===void 0||i-(r?.lastStatusFetch??0)>=m)&&await t().fetchStatus(e,n,{silent:!!r?.status});let a=t().directories.get(e);if(!a?.isGitRepo)return;let o=[];(!a.branches||i-a.lastBranchesFetch>=h)&&o.push(t().fetchBranches(e,n)),(!a.log||i-a.lastLogFetch>=f)&&o.push(t().fetchLog(e,n)),(!a.identity||i-a.lastIdentityFetch>=g)&&o.push(t().fetchIdentity(e,n)),o.length>0&&await Promise.all(o)})();return O.set(e,i),i.finally(()=>{O.get(e)===i&&O.delete(e)}),i},refresh:async(e,n={})=>{let{activeDirectory:r}=t();r&&await t().fetchAll(r,e,n)}}),{name:`git-store`})),J=e=>{let t=(0,l.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.status??null:null,t[0]=e,t[1]=n),q(n)},Y=e=>{let r=(0,l.c)(3),i=u.useSyncExternalStore(t,n,n),a;return r[0]!==e||r[1]!==i?(a=t=>{if(!e)return null;let n=t.directories.get(e);return n?.branchesTransportIdentity===i?n.branches:null},r[0]=e,r[1]=i,r[2]=a):a=r[2],q(a)},X=e=>{let t=(0,l.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isGitRepo??null:null,t[0]=e,t[1]=n),q(n)},Z=e=>{let t=(0,l.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.status?.current?.trim()??null:null,t[0]=e,t[1]=n),q(n)},Q=e=>{let t=(0,l.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=new Map,t[0]=n):n=t[0];let r=u.useRef(n),i;return t[1]===e?i=t[2]:(i=t=>{let n=r.current,i=n.size===e.length;if(i)for(let r of e){let e=t.directories.get(r),a=n.get(r);if(!a||(e?.isGitRepo??null)!==a.isGitRepo||(e?.status?.current??null)!==a.branch){i=!1;break}}if(i)return n;let a=new Map;for(let n of e){let e=t.directories.get(n);a.set(n,{isGitRepo:e?.isGitRepo??null,branch:e?.status?.current??null})}return r.current=a,a},t[1]=e,t[2]=i),q(i)},$=e=>{let t=(0,l.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingStatus??!1:!1,t[0]=e,t[1]=n),q(n)},ee=e=>{let t=(0,l.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingBranches??!1:!1,t[0]=e,t[1]=n),q(n)};export{Q as a,X as c,$ as i,Y as n,J as o,ee as r,q as s,Z as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n}from"./runtime-switch-DEPKHgdL.js";import{a as r,r as i}from"./vendor-zustand-CTekDqaS.js";import{st as a}from"./vendor-base-ui-wXsskyKm.js";import{n as o}from"./vendor-react-BkccXcWz.js";import{Jn as s,Kn as c}from"./ui-DyxdnQlj.js";var l=o(),u=e(a(),1),d=e=>e instanceof Error?e.name===`AbortError`||e.name===`CancelledError`||e.name===`Error`&&e.message===`CancelledError`:!1,f=1e4,p=6e4,m=5e3,h=3e4,g=6e4,_=25,v=40,y=2,b=15e3,x=500,S=30,C=20971520,w=new Map,T=new Map,E=new Map,D=new Map,O=new Map,k=new Map,A=new WeakMap,j=e=>{let t=A.get(e);return t||(t=new Set(e.files.map(e=>e.path)),A.set(e,t)),t},M=(e,t)=>`${t}:${e}`,N=e=>T.get(e)??0,P=e=>{let t=N(e)+1;return T.set(e,t),t},F=e=>{let t=(E.get(e)??0)+1;return E.set(e,t),t},I=e=>{let t=w.get(e);if(t)return t;let n=new Set;return w.set(e,n),n},L=()=>({isGitRepo:null,status:null,branches:null,branchesTransportIdentity:null,log:null,identity:null,diffCache:new Map,indexRevision:0,lastRepoCheckAt:0,lastStatusFetch:0,lastStatusChange:0,lastLogFetch:0,lastBranchesFetch:0,lastIdentityFetch:0,logMaxCount:25,isLoadingStatus:!1,isLoadingLog:!1,isLoadingBranches:!1,isLoadingIdentity:!1}),R=(e,t=S,n=C)=>{let r=0;for(let t of e.values())r+=(t.original?.length??0)+(t.modified?.length??0);if(e.size<=t&&r<=n)return e;let i=Array.from(e.entries()).sort((e,t)=>e[1].fetchedAt-t[1].fetchedAt),a=new Map,o=0;for(let e=i.length-1;e>=0;e--){let[r,s]=i[e],c=(s.original?.length??0)+(s.modified?.length??0);if(a.size>=t)break;o+c>n&&a.size>0||(a.set(r,s),o+=c)}return a},z=(e,t)=>!e&&!t?!1:!e||!t||e.remote!==t.remote||e.branch!==t.branch||e.ahead!==t.ahead||e.behind!==t.behind,B=e=>{let t=e?.trim()??``;return t===`?`?``:t},V=(e,t)=>{let n=new Set,r=!1,i=!e;e&&(i=e.ahead!==t.ahead||e.behind!==t.behind||e.current!==t.current||e.tracking!==t.tracking||e.isClean!==t.isClean||t.upstreamComparison!==void 0&&z(e.upstreamComparison,t.upstreamComparison)||t.diffStats!==void 0&&e.diffStats===void 0);let a=new Map;for(let t of e?.files??[])a.set(t.path,t);for(let e of t.files??[]){let t=a.get(e.path);if(!t){n.add(e.path),B(e.index)&&(r=!0);continue}a.delete(e.path),(t.index!==e.index||t.working_dir!==e.working_dir)&&n.add(e.path),!r&&B(t.index)!==B(e.index)&&(r=!0)}for(let[e,t]of a)n.add(e),B(t.index)&&(r=!0);let o=t.diffStats,s=e?.diffStats;if(o!==void 0&&o!==s){let e=s??{};for(let t in o){let r=o[t],i=e[t];(!i||i.insertions!==r.insertions||i.deletions!==r.deletions)&&n.add(t)}for(let t in e)t in o||n.add(t)}return{changed:i||n.size>0,changedPaths:n,indexChanged:r}},H=e=>!e||e.trim().length===0,U=e=>(e||``).trim()===`U`,W=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(U(t)||U(n))return e;let r=t===`?`||n===`?`?`A`:t||n||` `;return{...e,index:r,working_dir:` `}},G=e=>{let t=(e.index||``).trim(),n=(e.working_dir||``).trim();if(U(t)||U(n))return e;let r=n||(t===`A`||t===`?`?`?`:t)||` `;return{...e,index:` `,working_dir:r}},K=e=>H(e.index)&&H(e.working_dir),q=r()(i((e,t)=>({directories:new Map,activeDirectory:null,setActiveDirectory:n=>{let{activeDirectory:r,directories:i}=t();if(r!==n)if(r&&P(r),n&&P(n),n&&!i.has(n)){let t=new Map(i);t.set(n,L()),e({activeDirectory:n,directories:t})}else e({activeDirectory:n})},getDirectoryState:e=>t().directories.get(e)??null,fetchStatus:async(n,r,i={})=>{let a=i.mode??`full`,o=M(n,a),s=D.get(o)??(a===`light`?D.get(M(n,`full`)):void 0);if(s)return s;let c=(async()=>{let{silent:a=!1}=i,{directories:o}=t(),s=o.get(n);if(s||=L(),!a){let r=new Map(t().directories),i=r.get(n)??L();r.set(n,{...i,isLoadingStatus:!0}),e({directories:r})}let c=!1;try{let a=Date.now(),o=s.isGitRepo!==!0||a-(s.lastRepoCheckAt||0)>p,l=s.isGitRepo===!0;if(o&&(l=await r.checkIsGitRepository(n)),!l){let r=new Map(t().directories),i=r.get(n)??s;return r.set(n,{...i,isGitRepo:!1,status:null,isLoadingStatus:!1,lastRepoCheckAt:a,lastStatusFetch:a}),e({directories:r}),!1}let u=await r.getGitStatus(n,i.mode?{mode:i.mode}:void 0),d=t().directories.get(n)??L(),f=k.get(n),m=f?.received===u&&f.stored===d.status?null:V(d.status,u);if(m?.changed){c=!0;let r=new Map(t().directories),i=r.get(n)??L(),{changedPaths:s,indexChanged:l}=m,d=new Map(i.diffCache);for(let e of s)d.delete(e);let f=s.size>0;f&&P(n);let p={...u,diffStats:u.diffStats===void 0&&i.status?.diffStats!==void 0?i.status.diffStats:u.diffStats,upstreamComparison:u.upstreamComparison===void 0?i.status?.upstreamComparison:u.upstreamComparison};r.set(n,{...i,isGitRepo:!0,status:p,diffCache:d,indexRevision:l?i.indexRevision+1:i.indexRevision,lastRepoCheckAt:o?a:i.lastRepoCheckAt,lastStatusFetch:Date.now(),lastStatusChange:f?Date.now():i.lastStatusChange}),e({directories:r}),k.set(n,{received:u,stored:p})}else{k.set(n,{received:u,stored:d.status});let r=new Map(t().directories),i=r.get(n)??L();r.set(n,{...i,isGitRepo:!0,lastRepoCheckAt:o?a:i.lastRepoCheckAt,lastStatusFetch:Date.now(),lastStatusChange:i.lastStatusChange}),e({directories:r})}}catch(e){console.error(`Failed to fetch git status:`,e)}finally{if(!a){let r=new Map(t().directories),i=r.get(n)??L();r.set(n,{...i,isLoadingStatus:!1}),e({directories:r})}}return c})();D.set(o,c);try{return await c}finally{D.get(o)===c&&D.delete(o)}},moveStatusPathsOptimistically:(n,r,i)=>{let a=new Set(r.map(e=>e.trim()).filter(Boolean));if(a.size===0)return null;let{directories:o}=t(),s=o.get(n),c=s?.status??null;if(!s||!c)return c;let l=!1,u=[];for(let e of c.files){if(!a.has(e.path)){u.push(e);continue}let t=i===`stage`?W(e):G(e);t!==e&&(l=!0),K(t)?l=!0:u.push(t)}if(!l)return c;let d=new Map(o);return d.set(n,{...s,status:{...c,files:u,isClean:u.length===0},indexRevision:s.indexRevision+1,lastStatusChange:Date.now()}),e({directories:d}),c},restoreStatus:(n,r)=>{let{directories:i}=t(),a=i.get(n);if(!a)return;let o=new Map(i);o.set(n,{...a,status:r,indexRevision:a.indexRevision+1,lastStatusChange:Date.now()}),e({directories:o})},bumpIndexRevision:n=>{let{directories:r}=t(),i=r.get(n);if(!i)return;let a=new Map(r);a.set(n,{...i,indexRevision:i.indexRevision+1}),e({directories:a})},fetchBranches:async(r,i,a={})=>{let o=n(),l=F(r);{let n=new Map(t().directories),i=n.get(r)??L();n.set(r,{...i,isLoadingBranches:!0}),e({directories:n})}try{let u=a.force?await s(r,i,void 0,o):await c(r,i,void 0,o);if(l!==E.get(r)||o!==n())return;let d=new Map(t().directories),f=d.get(r)??L();d.set(r,{...f,branches:u,branchesTransportIdentity:o,isLoadingBranches:!1,lastBranchesFetch:Date.now()}),e({directories:d})}catch(i){if(d(i)||console.error(`Failed to fetch git branches:`,i),l!==E.get(r)||o!==n())return;let a=new Map(t().directories),s=a.get(r)??L();a.set(r,{...s,isLoadingBranches:!1}),e({directories:a})}},fetchLog:async(n,r,i)=>{let{directories:a}=t(),o=a.get(n),s=i??o?.logMaxCount??25;{let r=new Map(t().directories),i=r.get(n)??L();r.set(n,{...i,isLoadingLog:!0}),e({directories:r})}try{let i=await r.getGitLog(n,{maxCount:s}),a=new Map(t().directories),o=a.get(n)??L();a.set(n,{...o,log:i,isLoadingLog:!1,lastLogFetch:Date.now(),logMaxCount:s}),e({directories:a})}catch(r){console.error(`Failed to fetch git log:`,r);let i=new Map(t().directories),a=i.get(n)??L();i.set(n,{...a,isLoadingLog:!1}),e({directories:i})}},fetchIdentity:async(n,r)=>{{let r=new Map(t().directories),i=r.get(n)??L();r.set(n,{...i,isLoadingIdentity:!0}),e({directories:r})}try{let i=await r.getCurrentGitIdentity(n),a=new Map(t().directories),o=a.get(n)??L();a.set(n,{...o,identity:i,isLoadingIdentity:!1,lastIdentityFetch:Date.now()}),e({directories:a})}catch(r){console.error(`Failed to fetch git identity:`,r);let i=new Map(t().directories),a=i.get(n)??L();i.set(n,{...a,isLoadingIdentity:!1}),e({directories:i})}},fetchAll:async(n,r,i={})=>{let{directories:a}=t(),o=a.get(n);if(!o){o=L();let t=new Map(a);t.set(n,o),e({directories:t})}let{force:s=!1,silentIfCached:c=!1}=i,l=Date.now();await t().fetchStatus(n,r,{silent:c&&!!o?.status});let u=t().directories.get(n);if(!u?.isGitRepo)return;await t().fetchBranches(n,r,{force:s});let d=l-(u.lastLogFetch||0);(s||d>f||!u.log)&&await t().fetchLog(n,r),await t().fetchIdentity(n,r)},getDiff:(e,n)=>t().directories.get(e)?.diffCache.get(n)??null,setDiff:(n,r,i)=>{let a=new Map(t().directories),o=a.get(n)??L(),s=new Map(o.diffCache);s.set(r,{...i,fetchedAt:Date.now()});let c=R(s);a.set(n,{...o,diffCache:c}),e({directories:a})},clearDiffCache:n=>{P(n);let r=new Map(t().directories),i=r.get(n);i&&(r.set(n,{...i,diffCache:new Map}),e({directories:r}))},fetchAllDiffs:async(e,n)=>{let r=t().directories.get(e);if(!r?.status?.files||r.status.files.length===0)return;let i=r.status.files.map(e=>e.path).slice(0,_);await t().prefetchDiffs(e,n,i,{maxFiles:_})},prefetchDiffs:async(n,r,i,a={})=>{let o=t().directories.get(n);if(!o?.status?.files||o.status.files.length===0||i.length===0)return;let{maxFiles:s=v}=a,c=Math.min(Math.max(1,s),S),l=j(o.status),u=o.status.diffStats,d=I(n),f=[],p=new Set;for(let e of i){if(p.size>=c)break;if(!e||p.has(e)||!l.has(e))continue;let t=u?.[e];t&&t.insertions+t.deletions>x||(p.add(e),!o.diffCache.has(e)&&(d.has(e)||f.push(e)))}let m=f;if(m.length===0)return;let h=N(n);if(typeof document<`u`&&document.hidden)return;m.forEach(e=>d.add(e));let g=0,_=[],C=()=>{let e=g;return g+=1,e<m.length?m[e]:null},w=async e=>{let t=r.getGitFileDiff(n,{path:e}),i=new Promise((e,t)=>{setTimeout(()=>t(Error(`Timed out after ${b}ms`)),b)}),a=await Promise.race([t,i]);return{path:e,diff:{original:a.original??``,modified:a.modified??``,isBinary:a.isBinary}}},T=async()=>{for(;;){if(h!==N(n))return;let e=C();if(!e)return;try{_.push(await w(e))}catch{}finally{d.delete(e)}}},E=Math.min(y,m.length);if(await Promise.allSettled(Array.from({length:E},()=>T())),m.forEach(e=>d.delete(e)),h!==N(n))return;let D=new Map(t().directories),O=D.get(n);if(!O)return;let k=new Map(O.diffCache),A=Date.now();_.forEach(e=>{!e.diff.isBinary&&e.diff.original===``&&e.diff.modified===``||k.set(e.path,{...e.diff,fetchedAt:A})});let M=R(k);D.set(n,{...O,diffCache:M}),e({directories:D})},setLogMaxCount:(n,r)=>{let i=new Map(t().directories),a=i.get(n)??L();i.set(n,{...a,logMaxCount:r}),e({directories:i})},ensureStatus:async(e,n)=>{let r=t().directories.get(e),i=Date.now();r?.status&&i-r.lastStatusFetch<m||await t().fetchStatus(e,n,{silent:!!r?.status})},ensureAll:(e,n)=>{let r=O.get(e);if(r)return r;let i=(async()=>{let r=t().directories.get(e),i=Date.now();(!r?.status||r.status.diffStats===void 0||i-(r?.lastStatusFetch??0)>=m)&&await t().fetchStatus(e,n,{silent:!!r?.status});let a=t().directories.get(e);if(!a?.isGitRepo)return;let o=[];(!a.branches||i-a.lastBranchesFetch>=h)&&o.push(t().fetchBranches(e,n)),(!a.log||i-a.lastLogFetch>=f)&&o.push(t().fetchLog(e,n)),(!a.identity||i-a.lastIdentityFetch>=g)&&o.push(t().fetchIdentity(e,n)),o.length>0&&await Promise.all(o)})();return O.set(e,i),i.finally(()=>{O.get(e)===i&&O.delete(e)}),i},refresh:async(e,n={})=>{let{activeDirectory:r}=t();r&&await t().fetchAll(r,e,n)}}),{name:`git-store`})),J=e=>{let t=(0,l.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.status??null:null,t[0]=e,t[1]=n),q(n)},Y=e=>{let r=(0,l.c)(3),i=u.useSyncExternalStore(t,n,n),a;return r[0]!==e||r[1]!==i?(a=t=>{if(!e)return null;let n=t.directories.get(e);return n?.branchesTransportIdentity===i?n.branches:null},r[0]=e,r[1]=i,r[2]=a):a=r[2],q(a)},X=e=>{let t=(0,l.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isGitRepo??null:null,t[0]=e,t[1]=n),q(n)},Z=e=>{let t=(0,l.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.status?.current?.trim()??null:null,t[0]=e,t[1]=n),q(n)},Q=e=>{let t=(0,l.c)(3),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n=new Map,t[0]=n):n=t[0];let r=u.useRef(n),i;return t[1]===e?i=t[2]:(i=t=>{let n=r.current,i=n.size===e.length;if(i)for(let r of e){let e=t.directories.get(r),a=n.get(r);if(!a||(e?.isGitRepo??null)!==a.isGitRepo||(e?.status?.current??null)!==a.branch){i=!1;break}}if(i)return n;let a=new Map;for(let n of e){let e=t.directories.get(n);a.set(n,{isGitRepo:e?.isGitRepo??null,branch:e?.status?.current??null})}return r.current=a,a},t[1]=e,t[2]=i),q(i)},$=e=>{let t=(0,l.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingStatus??!1:!1,t[0]=e,t[1]=n),q(n)},ee=e=>{let t=(0,l.c)(2),n;return t[0]===e?n=t[1]:(n=t=>e?t.directories.get(e)?.isLoadingBranches??!1:!1,t[0]=e,t[1]=n),q(n)};export{Q as a,X as c,$ as i,Y as n,J as o,ee as r,q as s,Z as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n,n as r}from"./runtime-switch-DEPKHgdL.js";import{n as i}from"./runtime-fetch-V-iMWR8t.js";import{I as a,P as o,n as s,y as c}from"./platform-CiUKDeXd.js";import{a as l,i as u,r as d,t as ee}from"./vendor-zustand-CTekDqaS.js";import{ot as f,st as p}from"./vendor-base-ui-wXsskyKm.js";import{t as m}from"./safeStorage-DTOhKN0V.js";import{n as h}from"./client-B_907PBv.js";import{s as g}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{c as _}from"./yuriEvents-BFrD5fMU.js";import{r as v}from"./vendor-reactuses-core-DjKFMfz7.js";import{r as y}from"./useUIStore-C3ewjGgP.js";import{a as te,i as ne,n as re}from"./types-ay6wuGvG.js";import{t as ie}from"./native-config-D_WRbNJv.js";import{i as b}from"./session-startup-barrier-DT-hIBRf.js";import{n as x}from"./Icon-DmykXZL1.js";import{Na as S,Sr as ae,_r as oe,gr as se,t as C}from"./ui-BtnozFKV.js";import{t as ce}from"./i18n-D5tJwyKg.js";import{a as le,i as ue,n as de,o as fe,r as pe,t as me}from"./dialog-DGIsM7rW.js";import{t as he}from"./YuriLogo-Dpy8xIT7.js";import{_ as w,f as ge,p as _e,v as ve}from"./sessionOwnership-B13jZE-0.js";import{a as T,c as E,s as D}from"./mcpQueries-XUc_D3YM.js";import{i as ye,n as be,r as O}from"./SettingsGroup-D-7VEpNl.js";var k=e(p(),1),A=f(),xe=`https://github.com/yee94/yuri`,Se=`${xe}/issues/new`,Ce=800,we={"manual-global":`settings.yuri.about.opencodeManagement.manual-global`,"manual-external":`settings.yuri.about.opencodeManagement.manual-external`,bundled:`settings.yuri.about.opencodeManagement.bundled`,"in-app":`settings.yuri.about.opencodeManagement.in-app`,none:`settings.yuri.about.opencodeManagement.none`},j=e=>typeof e==`string`&&e.trim()?e.trim():null,M=(e,t,a)=>({queryKey:[t,`about`,a,e],queryFn:async({signal:o})=>{if(t!==n()||a!==r())throw Error(`Stale About runtime`);let s=await i(e,{method:`GET`,headers:{Accept:`application/json`},signal:o});if(!s.ok)throw Error(`About snapshot: ${s.status}`);let c=await s.json();if(!c||typeof c!=`object`||Array.isArray(c))throw Error(`Invalid About snapshot`);if(o.aborted||t!==n()||a!==r())throw Error(`Stale About runtime`);return c},retry:!1,staleTime:3e4}),N=({initialUpdateDialogOpen:e=!1})=>{let{t:i}=ce(),[l,u]=k.useState(e),[d,f]=k.useState(!1),[p,m]=k.useState(!1),[h,_]=k.useState(null),[S,ve]=k.useState(null),T=k.useSyncExternalStore(t,n,n),E=k.useSyncExternalStore(t,r,r),D=g(M(`/api/system/info`,T,E)),N=g(M(`/api/opencode/upgrade-status`,T,E)),P=j(D.data?.yuriVersion),F=N.data,I=j(F?.serveVersion)??j(F?.currentVersion),L=j(F?.management),R=L&&Object.hasOwn(we,L)?we[L]:null,z=F?.canManage===!1&&R?i(R):null,B=I&&z?i(`settings.yuri.about.opencodeVersionWithManagement`,{version:I,management:z}):I,Te=F?.canManage===!1?L===`manual-global`?i(`settings.yuri.about.opencodeGuidance.manualGlobal`):L===`manual-external`?i(`settings.yuri.about.opencodeGuidance.manualExternal`):L===`bundled`?i(`settings.yuri.about.opencodeGuidance.bundled`):null:null,V=w(ee(e=>({info:e.info,checking:e.checking,available:e.available,error:e.error,downloading:e.downloading,downloaded:e.downloaded,progress:e.progress,runtimeType:e.runtimeType,checkForUpdates:e.checkForUpdates,downloadUpdate:e.downloadUpdate,restartToUpdate:e.restartToUpdate}))),H=y(e=>e.otaChannelOverride),U=y(e=>e.setOtaChannelOverride),W=s(),[Ee,De]=k.useState(`stable`);k.useEffect(()=>{a()&&c().then(e=>De(e?.includes(`-`)?`beta`:`stable`))},[]);let G=g({queryKey:[`native-update-config`],queryFn:ie,enabled:W,staleTime:1/0,retry:!1}),K=G.data?.channel,q=H===`beta`||H===null&&(a()?Ee:K)===`beta`,[J,Y]=k.useState(!1),[X,Z]=k.useState(()=>oe()),Oe=v(e=>{ae(e),Z(e)}),ke=v(async e=>{if(e){U(`beta`),await w.getState().checkForUpdates();return}U(`stable`),await w.getState().checkForUpdates();let{info:t,otaDecision:n}=w.getState();t?.isChannelRollback===!0&&n?.primaryAction===`apply_ota`&&f(!0)}),Ae=v(()=>{f(!1),U(`beta`),w.getState().checkForUpdates()}),je=v(()=>{f(!1),u(!0),w.getState().downloadUpdate()}),Me=v(e=>{e||Ae()}),Ne=h||i(`settings.yuri.about.state.unknown`),Pe=v(async()=>{if(!J){Y(!0);try{let{outcome:e,eventCount:t}=await se();if(e===`cancelled`)return;if(e===`failed`){C.error(i(`settings.yuri.about.diagnostics.toast.failed`));return}C.success(i(t>0?`settings.yuri.about.diagnostics.toast.exported`:`settings.yuri.about.diagnostics.toast.empty`))}catch{C.error(i(`settings.yuri.about.diagnostics.toast.failed`))}finally{Y(!1)}}});k.useEffect(()=>{let e=!1;return te().then(t=>{e||_(t)}),ne().then(t=>{e||ve(t)}),()=>{e=!0}},[]);let Fe=re(h,S)??Ne,Q=k.useRef(!1);k.useEffect(()=>{if(V.checking)m(!0),Q.current=!0;else if(p){let e=setTimeout(()=>{m(!1),Q.current&&V.error?(C.error(i(`settings.yuri.about.toast.checkFailed`),{description:V.error}),Q.current=!1):Q.current&&!V.available&&!V.error&&(C.success(i(`settings.yuri.about.toast.latestVersion`)),Q.current=!1)},Ce);return()=>clearTimeout(e)}},[i,V.checking,p,V.available,V.error]);let $=V.checking||p;return(0,A.jsxs)(`div`,{className:`yuri-settings-section-stack w-full`,children:[(0,A.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,A.jsx)(he,{width:72,height:72}),(0,A.jsx)(`h2`,{className:`mt-4 typography-ui-header font-semibold text-foreground`,children:`Yuri`})]}),(0,A.jsxs)(be,{className:`yuri-settings-about`,children:[(0,A.jsx)(O,{label:i(`settings.yuri.about.field.clientVersion`),children:(0,A.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:Fe})}),(0,A.jsx)(O,{label:i(`settings.yuri.about.field.instanceYuriVersion`),children:o()?(0,A.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:P||i(`settings.yuri.about.state.unknown`)}):(0,A.jsx)(ge,{transport:T,generation:E,itemId:`about.host-update`,channel:q?`beta`:`stable`,version:P||i(`settings.yuri.about.state.unknown`)},`${T}:${E}`)}),(0,A.jsx)(O,{label:i(`settings.yuri.about.field.instanceOpenCodeVersion`),description:Te,children:(0,A.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:B||i(`settings.yuri.about.state.unknown`)})}),(0,A.jsx)(O,{className:`yuri-settings-split-row-stacked`,copyClassName:`hidden`,children:(0,A.jsxs)(`div`,{className:`flex w-full flex-wrap items-center justify-end gap-2`,children:[(0,A.jsx)(b,{asChild:!0,variant:`outline`,size:`sm`,className:`whitespace-nowrap`,"data-settings-item":`about.feedback`,children:(0,A.jsxs)(`a`,{href:Se,target:`_blank`,rel:`noopener noreferrer`,children:[(0,A.jsx)(x,{name:`question`,className:`size-4`}),i(`settings.yuri.about.actions.submitFeedback`)]})}),!$&&V.available?(0,A.jsxs)(b,{type:`button`,variant:`default`,size:`sm`,className:`whitespace-nowrap`,onClick:()=>u(!0),"data-settings-item":`about.check-updates`,children:[(0,A.jsx)(x,{name:`download`,className:`size-4`}),V.info?.inAppApply?i(`settings.yuri.about.actions.applyOtaToVersion`,{version:V.info?.version||``}):V.info?.manualUpdate?i(`settings.yuri.about.actions.installNativeToVersion`,{version:V.info?.version||``}):i(`settings.yuri.about.actions.updateToVersion`,{version:V.info?.version||``})]}):(0,A.jsxs)(b,{type:`button`,variant:`outline`,size:`sm`,className:`whitespace-nowrap`,onClick:()=>V.checkForUpdates(),"data-settings-item":`about.check-updates`,disabled:$,children:[$?(0,A.jsx)(x,{name:`loader`,className:`size-4 animate-spin`}):(0,A.jsx)(x,{name:`refresh`,className:`size-4`}),i($?`settings.yuri.about.state.checking`:`settings.yuri.about.actions.checkForUpdates`)]})]})}),V.error&&(0,A.jsx)(O,{children:(0,A.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:V.error})}),(W||a())&&(0,A.jsx)(ye,{itemId:`about.beta-updates`,checked:q,onChange:ke,label:i(`settings.yuri.about.betaUpdates.label`),description:i(`settings.yuri.about.betaUpdates.description`),ariaLabel:i(`settings.yuri.about.betaUpdates.label`),disabled:$||W&&!G.data}),(0,A.jsx)(ye,{itemId:`about.diagnostics`,checked:X,onChange:Oe,label:i(`settings.yuri.about.diagnostics.label`),ariaLabel:i(`settings.yuri.about.diagnostics.label`)}),X&&(0,A.jsx)(O,{itemId:`about.export-diagnostics`,label:i(`settings.yuri.about.diagnostics.export`),children:(0,A.jsx)(b,{type:`button`,variant:`outline`,size:`sm`,disabled:J,onClick:()=>void Pe(),children:i(J?`settings.yuri.about.diagnostics.exporting`:`settings.yuri.about.diagnostics.export`)})})]}),(0,A.jsx)(`div`,{className:`flex flex-col items-center gap-3 text-center`,children:(0,A.jsx)(`div`,{className:`flex items-center justify-center gap-5`,children:(0,A.jsxs)(`a`,{href:xe,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground`,children:[(0,A.jsx)(x,{name:`github-fill`,className:`size-5`}),(0,A.jsx)(`span`,{children:`GitHub`})]})})}),(0,A.jsx)(`p`,{className:`text-center typography-ui text-muted-foreground/60`,children:i(`aboutDialog.footerNote`)}),(0,A.jsx)(_e,{open:l,onOpenChange:u,info:V.info,downloading:V.downloading,downloaded:V.downloaded,progress:V.progress,error:V.error,onDownload:V.downloadUpdate,onRestart:V.restartToUpdate,runtimeType:V.runtimeType}),(0,A.jsx)(me,{open:d,onOpenChange:Me,children:(0,A.jsxs)(de,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[(0,A.jsxs)(le,{children:[(0,A.jsx)(fe,{children:i(`settings.yuri.about.betaUpdates.rollback.title`)}),(0,A.jsx)(pe,{children:i(`settings.yuri.about.betaUpdates.rollback.description`,{version:V.info?.version||``})})]}),(0,A.jsxs)(ue,{children:[(0,A.jsx)(b,{type:`button`,size:`sm`,variant:`ghost`,onClick:Ae,children:i(`settings.yuri.about.betaUpdates.rollback.actions.cancel`)}),(0,A.jsx)(b,{type:`button`,size:`sm`,onClick:je,children:i(`settings.yuri.about.betaUpdates.rollback.actions.confirm`)})]})]})})]})},P=16384,F=globalThis,I=e=>{if(F.Buffer)return F.Buffer.from(e,`utf8`).toString(`base64url`);let t=new TextEncoder().encode(e),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.slice(e,e+32768));return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)},L=e=>{try{if(F.Buffer)return F.Buffer.from(e,`base64url`).toString(`utf8`);let t=e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(Math.ceil(e.length/4)*4,`=`),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e+=1)r[e]=n.charCodeAt(e);return new TextDecoder().decode(r)}catch{return null}},R=e=>{if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;try{let e=new URL(t);return e.protocol!==`http:`&&e.protocol!==`https:`?null:(e.hash=``,e.toString().replace(/\/+$/g,``))}catch{return null}},z=e=>{if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;try{let e=new URL(t);return e.protocol!==`ws:`&&e.protocol!==`wss:`||e.username||e.password?null:(e.username=``,e.password=``,e.hash=``,e.search=``,e.toString())}catch{return null}},B=e=>typeof e==`string`&&e.length>0,Te=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;return t.kty!==`EC`||t.crv!==`P-256`||!B(t.x)||!B(t.y)?null:{kty:`EC`,crv:`P-256`,x:t.x,y:t.y}},V=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0,H=e=>{if(!e||typeof e!=`object`)return null;let t=e,n=V(t.priority);if(t.type===`lan`||t.type===`tunnel`){let e=R(t.url);return e?n===void 0?{type:t.type,url:e}:{type:t.type,url:e,priority:n}:null}if(t.type===`relay`){let e=z(t.relayUrl);if(!e)return null;let r=typeof t.serverId==`string`?t.serverId.trim():``;if(!r)return null;let i=Te(t.hostEncPubJwk);if(!i)return null;let a=typeof t.grant==`string`&&t.grant.trim()?t.grant.trim():void 0;return{type:`relay`,relayUrl:e,serverId:r,hostEncPubJwk:i,...a?{grant:a}:{},...n===void 0?{}:{priority:n}}}return null},U=e=>{if(!e||typeof e!=`object`)return null;let t=e;if(t.v!==2)return null;let n=typeof t.pairingId==`string`?t.pairingId.trim():``,r=typeof t.secret==`string`?t.secret.trim():``;if(!n||!r)return null;let i=Array.isArray(t.candidates)?t.candidates.map(H).filter(e=>!!e):[];if(i.length===0)return null;let a=typeof t.expiresAt==`string`&&t.expiresAt.trim()?t.expiresAt.trim():void 0;if(a){let e=Date.parse(a);if(!Number.isFinite(e)||e<=Date.now())return null}let o=typeof t.label==`string`&&t.label.trim()?t.label.trim():void 0,s=typeof t.fingerprint==`string`&&t.fingerprint.trim()?t.fingerprint.trim():void 0;return{v:2,pairingId:n,secret:r,...o?{label:o}:{},...s?{fingerprint:s}:{},...a?{expiresAt:a}:{},candidates:i}},W=e=>({v:2,pairingId:e.pairingId.trim(),secret:e.secret.trim(),...e.label?.trim()?{label:e.label.trim()}:{},...e.fingerprint?.trim()?{fingerprint:e.fingerprint.trim()}:{},...e.expiresAt?.trim()?{expiresAt:e.expiresAt.trim()}:{},candidates:e.candidates}),Ee=e=>{let t=U(e);if(!t)throw Error(`Invalid pairing connection payload`);let n=new URLSearchParams;return n.set(`v`,`2`),n.set(`p`,I(JSON.stringify(t))),`yuri://connect?${n.toString()}`},De=e=>{let t=e.trim();if(!t||t.length>P)return null;let n=t.indexOf(`?`);if(n===-1||!/^(?:yuri|openchamber|openchambery):\/\/connect\/?$/i.test(t.slice(0,n)))return null;let r=null,i=null;for(let e of t.slice(n+1).split(`&`)){let t=e.indexOf(`=`);if(t===-1)continue;let n=e.slice(0,t),a=e.slice(t+1);n===`v`?r=a:n===`p`&&(i=a)}if(r!==`2`||!i||i.length>P)return null;let a=L(i);if(!a||a.length>P)return null;try{return U(JSON.parse(a))}catch{return null}},G=e=>{let t=e.trim();if(!t||t.length>P)return null;try{let e=new URL(t);if([`yuri:`,`openchamber:`,`openchambery:`].includes(e.protocol)&&e.hostname===`connect`){if(e.searchParams.get(`v`)!==`2`)return null;let t=e.searchParams.get(`p`)||``;if(!t||t.length>P)return null;let n=L(t);return!n||n.length>P?null:U(JSON.parse(n))}}catch{}return De(t)},K=()=>{try{let e=S.getState().getActiveProject?.();if(e?.path?.trim())return e.path.trim();let t=h.getDirectory();if(t?.trim())return t.trim()}catch(e){console.warn(`[McpConfigStore] Error resolving config directory:`,e)}return null},q=e=>e?Object.entries(e).map(([e,t])=>({key:e,value:t})):[],J=e=>{let t=e.filter(e=>e.key.trim());if(t.length!==0)return Object.fromEntries(t.map(e=>[e.key.trim(),e.value]))},Y=e=>{if(typeof e==`string`)return e.trim()||void 0},X=l()(d(u((e,t)=>({selectedMcpName:null,mcpDraft:null,setSelectedMcp:t=>e({selectedMcpName:t}),setMcpDraft:t=>e({mcpDraft:t}),loadMcpConfigs:async e=>{let t=K();try{return!e?.force&&T(_,t).length>0||await D(_,t,n()),!0}catch(e){return console.error(`[McpConfigStore] Failed to load MCP configs:`,e),!1}},createMcp:async(e,t)=>{let r=`directory`in(t??{})?t?.directory?.trim()||null:K(),a=t?.transportIdentity??n();try{let t=Z(e),o=r?`?directory=${encodeURIComponent(r)}`:``,s=await i(`/api/config/mcp/${encodeURIComponent(e.name)}${o}`,{method:`POST`,headers:{"Content-Type":`application/json`,...r?{"x-opencode-directory":r}:{}},body:JSON.stringify(t)}),c=await s.json().catch(()=>null);if(!s.ok)throw Error(c?.error||`Failed to create MCP server`);return n()===a?(await D(_,r,a),await E(_,r,a),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}):{ok:!0}}catch(e){return console.error(`[McpConfigStore] Failed to create MCP:`,e),{ok:!1}}},updateMcp:async(e,t,r)=>{let a=`directory`in(r??{})?r?.directory?.trim()||null:K(),o=r?.transportIdentity??n();try{let r=Z(t),s=a?`?directory=${encodeURIComponent(a)}`:``,c=await i(`/api/config/mcp/${encodeURIComponent(e)}${s}`,{method:`PATCH`,headers:{"Content-Type":`application/json`,...a?{"x-opencode-directory":a}:{}},body:JSON.stringify(r)}),l=await c.json().catch(()=>null);if(!c.ok)throw Error(l?.error||`Failed to update MCP server`);return n()===o?(await D(_,a,o),await E(_,a,o),{ok:!0,reloadFailed:l?.reloadFailed===!0,message:l?.message,warning:l?.warning}):{ok:!0}}catch(e){throw console.error(`[McpConfigStore] Failed to update MCP:`,e),e}},deleteMcp:async(r,a)=>{let o=`directory`in(a??{})?a?.directory?.trim()||null:K(),s=a?.transportIdentity??n();try{let a=o?`?directory=${encodeURIComponent(o)}`:``,c=await i(`/api/config/mcp/${encodeURIComponent(r)}${a}`,{method:`DELETE`,headers:o?{"x-opencode-directory":o}:void 0}),l=await c.json().catch(()=>null);if(!c.ok)throw Error(l?.error||`Failed to delete MCP server`);return ve.getState().clearDiagnostic(r,o,s),n()===s?(t().selectedMcpName===r&&e({selectedMcpName:null}),await D(_,o,s),await E(_,o,s),{ok:!0,reloadFailed:l?.reloadFailed===!0,message:l?.message,warning:l?.warning}):{ok:!0}}catch(e){return console.error(`[McpConfigStore] Failed to delete MCP:`,e),{ok:!1}}}}),{name:`mcp-config-store`,storage:m(),partialize:e=>({selectedMcpName:e.selectedMcpName})}),{name:`mcp-config-store`}));function Z(e){let t={};if(e.scope!==void 0&&(t.scope=e.scope),e.type!==void 0&&(t.type=e.type),(e.type===`local`||e.command!==void 0)&&(t.command=(e.command??[]).filter(e=>e.trim())),(e.type===`remote`||e.url!==void 0)&&(t.url=e.url?.trim()??``),e.environment!==void 0&&(t.environment=J(e.environment)??{}),e.headers!==void 0&&(t.headers=J(e.headers)??{}),e.oauthEnabled!==void 0||e.oauthClientId!==void 0||e.oauthClientSecret!==void 0||e.oauthScope!==void 0||e.oauthRedirectUri!==void 0)if(e.oauthEnabled===!1)t.oauth=!1;else{let n={clientId:Y(e.oauthClientId),clientSecret:Y(e.oauthClientSecret),scope:Y(e.oauthScope),redirectUri:Y(e.oauthRedirectUri)};t.oauth=n.clientId||n.clientSecret||n.scope||n.redirectUri?n:e.oauthEnabled?{}:!1}if(e.timeout!==void 0){let n=Number(e.timeout);t.timeout=Number.isFinite(n)&&n>0?n:null}return e.enabled!==void 0&&(t.enabled=e.enabled),t}export{G as a,Ee as i,X as n,N as o,W as r,q as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n,n as r}from"./runtime-switch-DEPKHgdL.js";import{n as i}from"./runtime-fetch-V-iMWR8t.js";import{I as a,P as o,n as s,y as c}from"./platform-CiUKDeXd.js";import{a as l,i as u,r as d,t as ee}from"./vendor-zustand-CTekDqaS.js";import{ot as f,st as p}from"./vendor-base-ui-wXsskyKm.js";import{t as m}from"./safeStorage-DTOhKN0V.js";import{n as h}from"./client-B_907PBv.js";import{s as g}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{c as _}from"./yuriEvents-BFrD5fMU.js";import{r as v}from"./vendor-reactuses-core-DjKFMfz7.js";import{r as y}from"./useUIStore-C3ewjGgP.js";import{a as te,i as ne,n as re}from"./types-s46TxX4o.js";import{t as ie}from"./native-config-rSn3LLz4.js";import{i as b}from"./session-startup-barrier-DT-hIBRf.js";import{n as x}from"./Icon-DmykXZL1.js";import{Na as S,Sr as ae,_r as oe,gr as se,t as C}from"./ui-DyxdnQlj.js";import{t as ce}from"./i18n-DXc6czdR.js";import{a as le,i as ue,n as de,o as fe,r as pe,t as me}from"./dialog-BeFBA6ja.js";import{t as he}from"./YuriLogo-Cp6vWDWp.js";import{_ as w,f as ge,p as _e,v as ve}from"./sessionOwnership-xOCCIVwh.js";import{a as T,c as E,s as D}from"./mcpQueries-BKAVhjr3.js";import{i as ye,n as be,r as O}from"./SettingsGroup-CvaPYznp.js";var k=e(p(),1),A=f(),xe=`https://github.com/yee94/yuri`,Se=`${xe}/issues/new`,Ce=800,we={"manual-global":`settings.yuri.about.opencodeManagement.manual-global`,"manual-external":`settings.yuri.about.opencodeManagement.manual-external`,bundled:`settings.yuri.about.opencodeManagement.bundled`,"in-app":`settings.yuri.about.opencodeManagement.in-app`,none:`settings.yuri.about.opencodeManagement.none`},j=e=>typeof e==`string`&&e.trim()?e.trim():null,M=(e,t,a)=>({queryKey:[t,`about`,a,e],queryFn:async({signal:o})=>{if(t!==n()||a!==r())throw Error(`Stale About runtime`);let s=await i(e,{method:`GET`,headers:{Accept:`application/json`},signal:o});if(!s.ok)throw Error(`About snapshot: ${s.status}`);let c=await s.json();if(!c||typeof c!=`object`||Array.isArray(c))throw Error(`Invalid About snapshot`);if(o.aborted||t!==n()||a!==r())throw Error(`Stale About runtime`);return c},retry:!1,staleTime:3e4}),N=({initialUpdateDialogOpen:e=!1})=>{let{t:i}=ce(),[l,u]=k.useState(e),[d,f]=k.useState(!1),[p,m]=k.useState(!1),[h,_]=k.useState(null),[S,ve]=k.useState(null),T=k.useSyncExternalStore(t,n,n),E=k.useSyncExternalStore(t,r,r),D=g(M(`/api/system/info`,T,E)),N=g(M(`/api/opencode/upgrade-status`,T,E)),P=j(D.data?.yuriVersion),F=N.data,I=j(F?.serveVersion)??j(F?.currentVersion),L=j(F?.management),R=L&&Object.hasOwn(we,L)?we[L]:null,z=F?.canManage===!1&&R?i(R):null,B=I&&z?i(`settings.yuri.about.opencodeVersionWithManagement`,{version:I,management:z}):I,Te=F?.canManage===!1?L===`manual-global`?i(`settings.yuri.about.opencodeGuidance.manualGlobal`):L===`manual-external`?i(`settings.yuri.about.opencodeGuidance.manualExternal`):L===`bundled`?i(`settings.yuri.about.opencodeGuidance.bundled`):null:null,V=w(ee(e=>({info:e.info,checking:e.checking,available:e.available,error:e.error,downloading:e.downloading,downloaded:e.downloaded,progress:e.progress,runtimeType:e.runtimeType,checkForUpdates:e.checkForUpdates,downloadUpdate:e.downloadUpdate,restartToUpdate:e.restartToUpdate}))),H=y(e=>e.otaChannelOverride),U=y(e=>e.setOtaChannelOverride),W=s(),[Ee,De]=k.useState(`stable`);k.useEffect(()=>{a()&&c().then(e=>De(e?.includes(`-`)?`beta`:`stable`))},[]);let G=g({queryKey:[`native-update-config`],queryFn:ie,enabled:W,staleTime:1/0,retry:!1}),K=G.data?.channel,q=H===`beta`||H===null&&(a()?Ee:K)===`beta`,[J,Y]=k.useState(!1),[X,Z]=k.useState(()=>oe()),Oe=v(e=>{ae(e),Z(e)}),ke=v(async e=>{if(e){U(`beta`),await w.getState().checkForUpdates();return}U(`stable`),await w.getState().checkForUpdates();let{info:t,otaDecision:n}=w.getState();t?.isChannelRollback===!0&&n?.primaryAction===`apply_ota`&&f(!0)}),Ae=v(()=>{f(!1),U(`beta`),w.getState().checkForUpdates()}),je=v(()=>{f(!1),u(!0),w.getState().downloadUpdate()}),Me=v(e=>{e||Ae()}),Ne=h||i(`settings.yuri.about.state.unknown`),Pe=v(async()=>{if(!J){Y(!0);try{let{outcome:e,eventCount:t}=await se();if(e===`cancelled`)return;if(e===`failed`){C.error(i(`settings.yuri.about.diagnostics.toast.failed`));return}C.success(i(t>0?`settings.yuri.about.diagnostics.toast.exported`:`settings.yuri.about.diagnostics.toast.empty`))}catch{C.error(i(`settings.yuri.about.diagnostics.toast.failed`))}finally{Y(!1)}}});k.useEffect(()=>{let e=!1;return te().then(t=>{e||_(t)}),ne().then(t=>{e||ve(t)}),()=>{e=!0}},[]);let Fe=re(h,S)??Ne,Q=k.useRef(!1);k.useEffect(()=>{if(V.checking)m(!0),Q.current=!0;else if(p){let e=setTimeout(()=>{m(!1),Q.current&&V.error?(C.error(i(`settings.yuri.about.toast.checkFailed`),{description:V.error}),Q.current=!1):Q.current&&!V.available&&!V.error&&(C.success(i(`settings.yuri.about.toast.latestVersion`)),Q.current=!1)},Ce);return()=>clearTimeout(e)}},[i,V.checking,p,V.available,V.error]);let $=V.checking||p;return(0,A.jsxs)(`div`,{className:`yuri-settings-section-stack w-full`,children:[(0,A.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,A.jsx)(he,{width:72,height:72}),(0,A.jsx)(`h2`,{className:`mt-4 typography-ui-header font-semibold text-foreground`,children:`Yuri`})]}),(0,A.jsxs)(be,{className:`yuri-settings-about`,children:[(0,A.jsx)(O,{label:i(`settings.yuri.about.field.clientVersion`),children:(0,A.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:Fe})}),(0,A.jsx)(O,{label:i(`settings.yuri.about.field.instanceYuriVersion`),children:o()?(0,A.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:P||i(`settings.yuri.about.state.unknown`)}):(0,A.jsx)(ge,{transport:T,generation:E,itemId:`about.host-update`,channel:q?`beta`:`stable`,version:P||i(`settings.yuri.about.state.unknown`)},`${T}:${E}`)}),(0,A.jsx)(O,{label:i(`settings.yuri.about.field.instanceOpenCodeVersion`),description:Te,children:(0,A.jsx)(`span`,{className:`typography-ui-label font-mono text-foreground text-right`,children:B||i(`settings.yuri.about.state.unknown`)})}),(0,A.jsx)(O,{className:`yuri-settings-split-row-stacked`,copyClassName:`hidden`,children:(0,A.jsxs)(`div`,{className:`flex w-full flex-wrap items-center justify-end gap-2`,children:[(0,A.jsx)(b,{asChild:!0,variant:`outline`,size:`sm`,className:`whitespace-nowrap`,"data-settings-item":`about.feedback`,children:(0,A.jsxs)(`a`,{href:Se,target:`_blank`,rel:`noopener noreferrer`,children:[(0,A.jsx)(x,{name:`question`,className:`size-4`}),i(`settings.yuri.about.actions.submitFeedback`)]})}),!$&&V.available?(0,A.jsxs)(b,{type:`button`,variant:`default`,size:`sm`,className:`whitespace-nowrap`,onClick:()=>u(!0),"data-settings-item":`about.check-updates`,children:[(0,A.jsx)(x,{name:`download`,className:`size-4`}),V.info?.inAppApply?i(`settings.yuri.about.actions.applyOtaToVersion`,{version:V.info?.version||``}):V.info?.manualUpdate?i(`settings.yuri.about.actions.installNativeToVersion`,{version:V.info?.version||``}):i(`settings.yuri.about.actions.updateToVersion`,{version:V.info?.version||``})]}):(0,A.jsxs)(b,{type:`button`,variant:`outline`,size:`sm`,className:`whitespace-nowrap`,onClick:()=>V.checkForUpdates(),"data-settings-item":`about.check-updates`,disabled:$,children:[$?(0,A.jsx)(x,{name:`loader`,className:`size-4 animate-spin`}):(0,A.jsx)(x,{name:`refresh`,className:`size-4`}),i($?`settings.yuri.about.state.checking`:`settings.yuri.about.actions.checkForUpdates`)]})]})}),V.error&&(0,A.jsx)(O,{children:(0,A.jsx)(`p`,{className:`typography-meta text-[var(--status-error)]`,children:V.error})}),(W||a())&&(0,A.jsx)(ye,{itemId:`about.beta-updates`,checked:q,onChange:ke,label:i(`settings.yuri.about.betaUpdates.label`),description:i(`settings.yuri.about.betaUpdates.description`),ariaLabel:i(`settings.yuri.about.betaUpdates.label`),disabled:$||W&&!G.data}),(0,A.jsx)(ye,{itemId:`about.diagnostics`,checked:X,onChange:Oe,label:i(`settings.yuri.about.diagnostics.label`),ariaLabel:i(`settings.yuri.about.diagnostics.label`)}),X&&(0,A.jsx)(O,{itemId:`about.export-diagnostics`,label:i(`settings.yuri.about.diagnostics.export`),children:(0,A.jsx)(b,{type:`button`,variant:`outline`,size:`sm`,disabled:J,onClick:()=>void Pe(),children:i(J?`settings.yuri.about.diagnostics.exporting`:`settings.yuri.about.diagnostics.export`)})})]}),(0,A.jsx)(`div`,{className:`flex flex-col items-center gap-3 text-center`,children:(0,A.jsx)(`div`,{className:`flex items-center justify-center gap-5`,children:(0,A.jsxs)(`a`,{href:xe,target:`_blank`,rel:`noopener noreferrer`,className:`flex items-center gap-1.5 typography-ui-label text-muted-foreground transition-colors hover:text-foreground`,children:[(0,A.jsx)(x,{name:`github-fill`,className:`size-5`}),(0,A.jsx)(`span`,{children:`GitHub`})]})})}),(0,A.jsx)(`p`,{className:`text-center typography-ui text-muted-foreground/60`,children:i(`aboutDialog.footerNote`)}),(0,A.jsx)(_e,{open:l,onOpenChange:u,info:V.info,downloading:V.downloading,downloaded:V.downloaded,progress:V.progress,error:V.error,onDownload:V.downloadUpdate,onRestart:V.restartToUpdate,runtimeType:V.runtimeType}),(0,A.jsx)(me,{open:d,onOpenChange:Me,children:(0,A.jsxs)(de,{showCloseButton:!1,className:`max-w-sm gap-5`,children:[(0,A.jsxs)(le,{children:[(0,A.jsx)(fe,{children:i(`settings.yuri.about.betaUpdates.rollback.title`)}),(0,A.jsx)(pe,{children:i(`settings.yuri.about.betaUpdates.rollback.description`,{version:V.info?.version||``})})]}),(0,A.jsxs)(ue,{children:[(0,A.jsx)(b,{type:`button`,size:`sm`,variant:`ghost`,onClick:Ae,children:i(`settings.yuri.about.betaUpdates.rollback.actions.cancel`)}),(0,A.jsx)(b,{type:`button`,size:`sm`,onClick:je,children:i(`settings.yuri.about.betaUpdates.rollback.actions.confirm`)})]})]})})]})},P=16384,F=globalThis,I=e=>{if(F.Buffer)return F.Buffer.from(e,`utf8`).toString(`base64url`);let t=new TextEncoder().encode(e),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.slice(e,e+32768));return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)},L=e=>{try{if(F.Buffer)return F.Buffer.from(e,`base64url`).toString(`utf8`);let t=e.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(Math.ceil(e.length/4)*4,`=`),n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e+=1)r[e]=n.charCodeAt(e);return new TextDecoder().decode(r)}catch{return null}},R=e=>{if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;try{let e=new URL(t);return e.protocol!==`http:`&&e.protocol!==`https:`?null:(e.hash=``,e.toString().replace(/\/+$/g,``))}catch{return null}},z=e=>{if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;try{let e=new URL(t);return e.protocol!==`ws:`&&e.protocol!==`wss:`||e.username||e.password?null:(e.username=``,e.password=``,e.hash=``,e.search=``,e.toString())}catch{return null}},B=e=>typeof e==`string`&&e.length>0,Te=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return null;let t=e;return t.kty!==`EC`||t.crv!==`P-256`||!B(t.x)||!B(t.y)?null:{kty:`EC`,crv:`P-256`,x:t.x,y:t.y}},V=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0,H=e=>{if(!e||typeof e!=`object`)return null;let t=e,n=V(t.priority);if(t.type===`lan`||t.type===`tunnel`){let e=R(t.url);return e?n===void 0?{type:t.type,url:e}:{type:t.type,url:e,priority:n}:null}if(t.type===`relay`){let e=z(t.relayUrl);if(!e)return null;let r=typeof t.serverId==`string`?t.serverId.trim():``;if(!r)return null;let i=Te(t.hostEncPubJwk);if(!i)return null;let a=typeof t.grant==`string`&&t.grant.trim()?t.grant.trim():void 0;return{type:`relay`,relayUrl:e,serverId:r,hostEncPubJwk:i,...a?{grant:a}:{},...n===void 0?{}:{priority:n}}}return null},U=e=>{if(!e||typeof e!=`object`)return null;let t=e;if(t.v!==2)return null;let n=typeof t.pairingId==`string`?t.pairingId.trim():``,r=typeof t.secret==`string`?t.secret.trim():``;if(!n||!r)return null;let i=Array.isArray(t.candidates)?t.candidates.map(H).filter(e=>!!e):[];if(i.length===0)return null;let a=typeof t.expiresAt==`string`&&t.expiresAt.trim()?t.expiresAt.trim():void 0;if(a){let e=Date.parse(a);if(!Number.isFinite(e)||e<=Date.now())return null}let o=typeof t.label==`string`&&t.label.trim()?t.label.trim():void 0,s=typeof t.fingerprint==`string`&&t.fingerprint.trim()?t.fingerprint.trim():void 0;return{v:2,pairingId:n,secret:r,...o?{label:o}:{},...s?{fingerprint:s}:{},...a?{expiresAt:a}:{},candidates:i}},W=e=>({v:2,pairingId:e.pairingId.trim(),secret:e.secret.trim(),...e.label?.trim()?{label:e.label.trim()}:{},...e.fingerprint?.trim()?{fingerprint:e.fingerprint.trim()}:{},...e.expiresAt?.trim()?{expiresAt:e.expiresAt.trim()}:{},candidates:e.candidates}),Ee=e=>{let t=U(e);if(!t)throw Error(`Invalid pairing connection payload`);let n=new URLSearchParams;return n.set(`v`,`2`),n.set(`p`,I(JSON.stringify(t))),`yuri://connect?${n.toString()}`},De=e=>{let t=e.trim();if(!t||t.length>P)return null;let n=t.indexOf(`?`);if(n===-1||!/^(?:yuri|openchamber|openchambery):\/\/connect\/?$/i.test(t.slice(0,n)))return null;let r=null,i=null;for(let e of t.slice(n+1).split(`&`)){let t=e.indexOf(`=`);if(t===-1)continue;let n=e.slice(0,t),a=e.slice(t+1);n===`v`?r=a:n===`p`&&(i=a)}if(r!==`2`||!i||i.length>P)return null;let a=L(i);if(!a||a.length>P)return null;try{return U(JSON.parse(a))}catch{return null}},G=e=>{let t=e.trim();if(!t||t.length>P)return null;try{let e=new URL(t);if([`yuri:`,`openchamber:`,`openchambery:`].includes(e.protocol)&&e.hostname===`connect`){if(e.searchParams.get(`v`)!==`2`)return null;let t=e.searchParams.get(`p`)||``;if(!t||t.length>P)return null;let n=L(t);return!n||n.length>P?null:U(JSON.parse(n))}}catch{}return De(t)},K=()=>{try{let e=S.getState().getActiveProject?.();if(e?.path?.trim())return e.path.trim();let t=h.getDirectory();if(t?.trim())return t.trim()}catch(e){console.warn(`[McpConfigStore] Error resolving config directory:`,e)}return null},q=e=>e?Object.entries(e).map(([e,t])=>({key:e,value:t})):[],J=e=>{let t=e.filter(e=>e.key.trim());if(t.length!==0)return Object.fromEntries(t.map(e=>[e.key.trim(),e.value]))},Y=e=>{if(typeof e==`string`)return e.trim()||void 0},X=l()(d(u((e,t)=>({selectedMcpName:null,mcpDraft:null,setSelectedMcp:t=>e({selectedMcpName:t}),setMcpDraft:t=>e({mcpDraft:t}),loadMcpConfigs:async e=>{let t=K();try{return!e?.force&&T(_,t).length>0||await D(_,t,n()),!0}catch(e){return console.error(`[McpConfigStore] Failed to load MCP configs:`,e),!1}},createMcp:async(e,t)=>{let r=`directory`in(t??{})?t?.directory?.trim()||null:K(),a=t?.transportIdentity??n();try{let t=Z(e),o=r?`?directory=${encodeURIComponent(r)}`:``,s=await i(`/api/config/mcp/${encodeURIComponent(e.name)}${o}`,{method:`POST`,headers:{"Content-Type":`application/json`,...r?{"x-opencode-directory":r}:{}},body:JSON.stringify(t)}),c=await s.json().catch(()=>null);if(!s.ok)throw Error(c?.error||`Failed to create MCP server`);return n()===a?(await D(_,r,a),await E(_,r,a),{ok:!0,reloadFailed:c?.reloadFailed===!0,message:c?.message,warning:c?.warning}):{ok:!0}}catch(e){return console.error(`[McpConfigStore] Failed to create MCP:`,e),{ok:!1}}},updateMcp:async(e,t,r)=>{let a=`directory`in(r??{})?r?.directory?.trim()||null:K(),o=r?.transportIdentity??n();try{let r=Z(t),s=a?`?directory=${encodeURIComponent(a)}`:``,c=await i(`/api/config/mcp/${encodeURIComponent(e)}${s}`,{method:`PATCH`,headers:{"Content-Type":`application/json`,...a?{"x-opencode-directory":a}:{}},body:JSON.stringify(r)}),l=await c.json().catch(()=>null);if(!c.ok)throw Error(l?.error||`Failed to update MCP server`);return n()===o?(await D(_,a,o),await E(_,a,o),{ok:!0,reloadFailed:l?.reloadFailed===!0,message:l?.message,warning:l?.warning}):{ok:!0}}catch(e){throw console.error(`[McpConfigStore] Failed to update MCP:`,e),e}},deleteMcp:async(r,a)=>{let o=`directory`in(a??{})?a?.directory?.trim()||null:K(),s=a?.transportIdentity??n();try{let a=o?`?directory=${encodeURIComponent(o)}`:``,c=await i(`/api/config/mcp/${encodeURIComponent(r)}${a}`,{method:`DELETE`,headers:o?{"x-opencode-directory":o}:void 0}),l=await c.json().catch(()=>null);if(!c.ok)throw Error(l?.error||`Failed to delete MCP server`);return ve.getState().clearDiagnostic(r,o,s),n()===s?(t().selectedMcpName===r&&e({selectedMcpName:null}),await D(_,o,s),await E(_,o,s),{ok:!0,reloadFailed:l?.reloadFailed===!0,message:l?.message,warning:l?.warning}):{ok:!0}}catch(e){return console.error(`[McpConfigStore] Failed to delete MCP:`,e),{ok:!1}}}}),{name:`mcp-config-store`,storage:m(),partialize:e=>({selectedMcpName:e.selectedMcpName})}),{name:`mcp-config-store`}));function Z(e){let t={};if(e.scope!==void 0&&(t.scope=e.scope),e.type!==void 0&&(t.type=e.type),(e.type===`local`||e.command!==void 0)&&(t.command=(e.command??[]).filter(e=>e.trim())),(e.type===`remote`||e.url!==void 0)&&(t.url=e.url?.trim()??``),e.environment!==void 0&&(t.environment=J(e.environment)??{}),e.headers!==void 0&&(t.headers=J(e.headers)??{}),e.oauthEnabled!==void 0||e.oauthClientId!==void 0||e.oauthClientSecret!==void 0||e.oauthScope!==void 0||e.oauthRedirectUri!==void 0)if(e.oauthEnabled===!1)t.oauth=!1;else{let n={clientId:Y(e.oauthClientId),clientSecret:Y(e.oauthClientSecret),scope:Y(e.oauthScope),redirectUri:Y(e.oauthRedirectUri)};t.oauth=n.clientId||n.clientSecret||n.scope||n.redirectUri?n:e.oauthEnabled?{}:!1}if(e.timeout!==void 0){let n=Number(e.timeout);t.timeout=Number.isFinite(n)&&n>0?n:null}return e.enabled!==void 0&&(t.enabled=e.enabled),t}export{G as a,Ee as i,X as n,N as o,W as r,q as t};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{ot as t,st as n}from"./vendor-base-ui-wXsskyKm.js";import{n as r}from"./vendor-react-BkccXcWz.js";import{i,r as a}from"./vendor-reactuses-core-DjKFMfz7.js";import{i as o,o as s}from"./session-startup-barrier-DT-hIBRf.js";import{n as c}from"./Icon-DmykXZL1.js";var l=r(),u=t();function d(e){let t=(0,l.c)(26),{swipe:n,actions:r}=e,{offset:i,dragging:a,actionRailRef:d,closeActions:f}=n,p=i!==0,m=p?`true`:`false`,h=a?`true`:void 0,g=!p&&`pointer-events-none`,_;t[0]===g?_=t[1]:(_=s(`yuri-mobile-session-actions absolute inset-y-0 right-0 z-0 flex items-stretch`,g),t[0]=g,t[1]=_);let v=`translate3d(calc(100% + ${i}px), 0, 0)`,y=p?`transform`:void 0,b;t[2]!==r.length||t[3]!==v||t[4]!==y?(b={"--yuri-mobile-session-action-count":r.length,transform:v,willChange:y,touchAction:`pan-y`},t[2]=r.length,t[3]=v,t[4]=y,t[5]=b):b=t[5];let x=b,S=!p,C=n.handlePointerDown,w=n.handlePointerMove,T=n.finishGesture,E=n.handlePointerCancel,D=n.handleActionClickCapture,O;if(t[6]!==r||t[7]!==f||t[8]!==p){let e;t[10]!==f||t[11]!==p?(e=e=>(0,u.jsxs)(o,{type:`button`,variant:e.variant??(e.destructive?`destructive`:`secondary`),className:s(`yuri-mobile-session-action h-full flex-col rounded-none border-0 px-1 has-[>svg]:px-1`,!e.destructive&&!e.variant&&`bg-interactive-selection text-interactive-selection-foreground hover:bg-interactive-active`),"aria-label":e.ariaLabel??e.label,tabIndex:p?0:-1,onClick:()=>{f(),e.onClick()},children:[(0,u.jsx)(c,{name:e.icon,className:`size-[18px]`}),(0,u.jsx)(`span`,{className:`yuri-mobile-session-action-label max-w-full truncate text-center font-medium`,children:e.label})]},e.ariaLabel??e.label),t[10]=f,t[11]=p,t[12]=e):e=t[12],O=r.map(e),t[6]=r,t[7]=f,t[8]=p,t[9]=O}else O=t[9];let k;return t[13]!==d||t[14]!==n.finishGesture||t[15]!==n.handleActionClickCapture||t[16]!==n.handlePointerCancel||t[17]!==n.handlePointerDown||t[18]!==n.handlePointerMove||t[19]!==m||t[20]!==O||t[21]!==h||t[22]!==_||t[23]!==x||t[24]!==S?(k=(0,u.jsx)(`div`,{ref:d,"data-session-drag-ignore":!0,"data-revealed":m,"data-dragging":h,className:_,style:x,"aria-hidden":S,onPointerDown:C,onPointerMove:w,onPointerUp:T,onPointerCancel:E,onClickCapture:D,children:O}),t[13]=d,t[14]=n.finishGesture,t[15]=n.handleActionClickCapture,t[16]=n.handlePointerCancel,t[17]=n.handlePointerDown,t[18]=n.handlePointerMove,t[19]=m,t[20]=O,t[21]=h,t[22]=_,t[23]=x,t[24]=S,t[25]=k):k=t[25],k}var f=e(n(),1),p=10,m=`yuri:mobile-session-row-revealed`,h=e=>{window.dispatchEvent(new CustomEvent(m,{detail:e}))};function g(e,t,n){let r=(0,l.c)(46),o=n!==void 0&&n,[s,c]=f.useState(0),[u,d]=f.useState(!1),g=f.useRef(null),v=f.useRef(!1),y=f.useRef(!1),b=f.useRef(null),x,S;r[0]===o?(x=r[1],S=r[2]):(x=()=>{o&&(g.current=null,v.current=!0,c(0),d(!1))},S=[o],r[0]=o,r[1]=x,r[2]=S),f.useEffect(x,S);let C;r[3]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>{c(0)},r[3]=C):C=r[3];let w;r[4]===e?w=r[5]:(w=[e],r[4]=e,r[5]=w),f.useEffect(C,w);let T;r[6]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>{g.current=null,c(0),d(!1)},r[6]=T):T=r[6];let E=a(T),D;r[7]!==E||r[8]!==e?(D=t=>{t.detail!==e&&E()},r[7]=E,r[8]=e,r[9]=D):D=r[9],i(m,D);let O;r[10]===s?O=r[11]:(O=()=>s===0?null:window,r[10]=s,r[11]=O);let k=O,A;r[12]===E?A=r[13]:(A=e=>{let t=b.current?.parentElement;t&&!e.composedPath().includes(t)&&E()},r[12]=E,r[13]=A);let j;r[14]===Symbol.for(`react.memo_cache_sentinel`)?(j={passive:!0},r[14]=j):j=r[14],i(`pointerdown`,A,k,j);let M;r[15]===E?M=r[16]:(M=()=>E(),r[15]=E,r[16]=M);let N;r[17]===Symbol.for(`react.memo_cache_sentinel`)?(N={passive:!0},r[17]=N):N=r[17],i(`wheel`,M,k,N);let P;r[18]===E?P=r[19]:(P=()=>E(),r[18]=E,r[19]=P),i(`blur`,P,k);let F;r[20]!==o||r[21]!==s?(F=e=>{if(o||e.button!==0||e.pointerType!==`touch`&&e.pointerType!==`pen`)return;let t=b.current?.offsetWidth??0;t<=0||(g.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,startOffset:s,actionWidth:t,intent:`pending`,fromActionRail:b.current?.contains(e.target)??!1},v.current=!1,y.current=!1)},r[20]=o,r[21]=s,r[22]=F):F=r[22];let I=a(F),L;r[23]!==E||r[24]!==o||r[25]!==e?(L=t=>{if(o)return;let n=g.current;if(!n||n.pointerId!==t.pointerId)return;let r=t.clientX-n.startX,i=t.clientY-n.startY;if(n.intent===`pending`){let a=Math.abs(r),o=Math.abs(i);if(o>p&&o>a){n.intent=`vertical`,g.current=null,n.startOffset!==0&&(v.current=!0,E());return}if(a>p&&a>o){n.intent=`horizontal`,d(!0),v.current=!0,y.current=n.fromActionRail;try{t.currentTarget.setPointerCapture(t.pointerId)}catch{}h(e)}}n.intent===`horizontal`&&(t.preventDefault(),c(Math.max(-n.actionWidth,Math.min(0,n.startOffset+r))))},r[23]=E,r[24]=o,r[25]=e,r[26]=L):L=r[26];let R=a(L),z;r[27]===Symbol.for(`react.memo_cache_sentinel`)?(z=e=>{let t=g.current;if(!t||t.pointerId!==e.pointerId||(g.current=null,t.intent!==`horizontal`))return;d(!1);let n=t.startOffset!==0&&e.clientX-t.startX>p;c(e=>n?0:e<-(t.actionWidth*.35)?-t.actionWidth:0)},r[27]=z):z=r[27];let B=a(z),V;r[28]===Symbol.for(`react.memo_cache_sentinel`)?(V=()=>{let e=g.current;g.current=null,d(!1),c(e?.intent===`horizontal`?e.startOffset:0)},r[28]=V):V=r[28];let H=a(V),U;r[29]===Symbol.for(`react.memo_cache_sentinel`)?(U=e=>{y.current&&(y.current=!1,e.preventDefault(),e.stopPropagation())},r[29]=U):U=r[29];let W=a(U),G;r[30]!==E||r[31]!==e||r[32]!==s||r[33]!==t?(G=()=>{if(v.current){v.current=!1;return}if(s!==0){E();return}h(e),t()},r[30]=E,r[31]=e,r[32]=s,r[33]=t,r[34]=G):G=r[34];let K=a(G),q=a(_),J;return r[35]!==E||r[36]!==u||r[37]!==B||r[38]!==W||r[39]!==q||r[40]!==H||r[41]!==I||r[42]!==R||r[43]!==K||r[44]!==s?(J={offset:s,dragging:u,actionRailRef:b,closeActions:E,handleSelect:K,handlePointerDown:I,handlePointerMove:R,finishGesture:B,handlePointerCancel:H,handleContextMenu:q,handleActionClickCapture:W},r[35]=E,r[36]=u,r[37]=B,r[38]=W,r[39]=q,r[40]=H,r[41]=I,r[42]=R,r[43]=K,r[44]=s,r[45]=J):J=r[45],J}function _(e){e.preventDefault(),e.stopPropagation()}export{d as n,g as t};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t}from"./runtime-switch-DEPKHgdL.js";import{s as n}from"./platform-CiUKDeXd.js";import{ot as r,st as i}from"./vendor-base-ui-wXsskyKm.js";import{St as a}from"./gitApiHttp-Dd-FwgCq.js";import{Rt as o,Xt as s,Zt as c,an as l,ln as u,on as d,un as f,zt as p}from"./client-B_907PBv.js";import{n as m}from"./vendor-react-BkccXcWz.js";import{c as h,o as g,s as _}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{c as v,o as y}from"./yuriEvents-BFrD5fMU.js";import{D as b,E as x,I as S,R as C}from"./runtime-file-resource-Bc_ss-sW.js";import{r as w}from"./vendor-reactuses-core-DjKFMfz7.js";import{r as T}from"./useUIStore-C3ewjGgP.js";import{i as ee,o as E}from"./session-startup-barrier-DT-hIBRf.js";import{n as D}from"./Icon-DmykXZL1.js";import{Ea as O,Hi as k,Ia as A,Ji as j,Qn as M,at as N,et as te,f as P,hr as F,lt as I,mr as L,st as R}from"./ui-BtnozFKV.js";import{t as ne}from"./i18n-D5tJwyKg.js";import{c as z,o as re,s as B}from"./useGitStore-juwpiPLM.js";import{t as ie}from"./connection-hint-_XZ_PuIx.js";import{n as ae,t as V}from"./ProviderLogo-DA98yu7M.js";import{a as oe,l as se,n as H,r as U,u as ce}from"./useQuotaStore-2zTsa_Q9.js";import{a as le,i as ue,l as W,r as G,s as K}from"./quota-BbYx47Ix.js";import{i as de,r as q}from"./icons-Bd-INsoy.js";var J=e(i(),1),Y=m(),X=r();function fe(e){let t=(0,Y.c)(30),{percentage:n,pending:r}=e,i=r!==void 0&&r,{t:a}=ne(),o,s,c,l,u,d,f,p,m;if(t[0]!==i||t[1]!==n||t[2]!==a){c=i?0:G(n)??0;let e=W(n);s=i?`var(--surface-muted-foreground)`:e===`critical`?`var(--status-error)`:e===`warn`?`var(--status-warning)`:`var(--status-success)`,o=2*Math.PI*7.5,l=`0 0 18 18`,u=`size-[18px] -rotate-90`,d=`progressbar`,t[12]===a?f=t[13]:(f=a(`contextUsage.aria.label`),t[12]=a,t[13]=f),t[14]!==i||t[15]!==a?(p=i?a(`contextUsage.pending`):void 0,t[14]=i,t[15]=a,t[16]=p):p=t[16],m=i?void 0:Math.round(c),t[0]=i,t[1]=n,t[2]=a,t[3]=o,t[4]=s,t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=p,t[11]=m}else o=t[3],s=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11];let h;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,X.jsx)(`circle`,{cx:9,cy:9,r:7.5,fill:`none`,stroke:`var(--interactive-border)`,strokeWidth:3}),t[17]=h):h=t[17];let g=o*(1-c/100),_;t[18]!==o||t[19]!==s||t[20]!==g?(_=(0,X.jsx)(`circle`,{cx:9,cy:9,r:7.5,fill:`none`,stroke:s,strokeWidth:3,strokeLinecap:`round`,strokeDasharray:o,strokeDashoffset:g,className:`transition-[stroke-dashoffset,stroke] duration-300`}),t[18]=o,t[19]=s,t[20]=g,t[21]=_):_=t[21];let v;return t[22]!==_||t[23]!==l||t[24]!==u||t[25]!==d||t[26]!==f||t[27]!==p||t[28]!==m?(v=(0,X.jsxs)(`svg`,{viewBox:l,className:u,role:d,"aria-label":f,"aria-valuetext":p,"aria-valuenow":m,"aria-valuemin":0,"aria-valuemax":100,children:[h,_]}),t[22]=_,t[23]=l,t[24]=u,t[25]=d,t[26]=f,t[27]=p,t[28]=m,t[29]=v):v=t[29],v}var Z=(e,t,n)=>g({queryKey:[...e.queryScope,`mobile-session-metadata`,t],staleTime:3e4,gcTime:1/0,retry:!1,queryFn:({signal:e})=>n(e)});function pe(e){let t=S(e);return Z(e,`git`,async n=>{let r={signal:n,query:{directory:e.location.directory},headers:{"x-opencode-directory":e.location.directory}};return(await t.json(`/api/git/check`,r)).isGitRepository?{isGitRepository:!0,current:(await t.json(`/api/git/status`,{...r,query:{...r.query,mode:`light`}})).current}:{isGitRepository:!1,current:null}})}function me(e){let t=S(e);return Z(e,`quota-settings`,async e=>{let n=await t.json(`/api/config/settings`,{signal:e}),r=se.map(e=>e.id),i=Array.isArray(n.usageDropdownProviders)?n.usageDropdownProviders.filter(e=>typeof e==`string`&&(e.startsWith(`magpie:`)||r.includes(e))):r,a={};if(n.usageSelectedModels&&typeof n.usageSelectedModels==`object`)for(let[e,t]of Object.entries(n.usageSelectedModels))Array.isArray(t)&&(a[e]=t.filter(e=>typeof e==`string`));return{providerIds:i,selectedModels:a,displayMode:n.usageDisplayMode===`remaining`?`remaining`:`usage`,autoRefresh:n.usageAutoRefresh===!0,refreshIntervalMs:typeof n.usageRefreshIntervalMs==`number`&&Number.isFinite(n.usageRefreshIntervalMs)?Math.max(3e4,Math.min(3e5,Math.round(n.usageRefreshIntervalMs))):6e4}})}function he(e,t){let n=S(e);return Z(e,`quota:${t}`,async e=>{let r=await n.json(`/api/quota/${encodeURIComponent(t)}`,{signal:e});if(!y(r)||r.providerId!==t)throw Error(`Invalid quota response`);return r})}function ge(e){let t=S(e);return Z(e,`magpie`,async n=>{let r=await t.json(`/api/quota/magpie`,{signal:n,query:{directory:e.location.directory}});if(!Array.isArray(r.sources)||!r.sources.every(e=>e&&typeof e.id==`string`&&Array.isArray(e.results)&&e.results.every(t=>y(t)&&t.source===`magpie`&&t.sourceId===e.id&&t.providerId.startsWith(`magpie:${e.id}:`))))throw Error(`Invalid Magpie quota response`);return r.sources.flatMap(e=>e.results)})}var _e=(e,t)=>{if(!e||typeof e!=`object`)return;let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0},ve=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e),ye=e=>e>=90?`text-[var(--status-error)]`:e>=75?`text-[var(--status-warning)]`:`text-[var(--status-success)]`,be=e=>{let{totalTokens:t,contextLimit:n,isDraft:r}=e;if(!r&&t===null)return{pending:!0,percentage:0,tokens:`—`,colorClass:`text-muted-foreground`};if(t===null||r||t<=0||n<=0)return null;let i=Math.min(t/n*100,999);return{percentage:i,tokens:`${ve(t)}/${ve(n)}`,colorClass:ye(i)}},xe=e=>{for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.role!==`user`)continue;let r=typeof n.model?.providerID==`string`&&n.model.providerID.trim().length>0?n.model.providerID:void 0,i=typeof n.model?.modelID==`string`&&n.model.modelID.trim().length>0?n.model.modelID:void 0;if(r&&i)return{providerID:r,modelID:i}}return null},Se=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``);function Ce(e,t,n){let r=(0,Y.c)(7),{t:i}=ne(),a;if(r[0]!==t||r[1]!==e||r[2]!==n||r[3]!==i){let o=new Map(e.map(Q)),s;r[5]===t?s=r[6]:(s=e=>t.includes(e.id),r[5]=t,r[6]=s),a=ce(e).filter(s).filter(e=>o.get(e.id)?.configured===!0).map(e=>{let t=o.get(e.id),r=[];for(let[e,n]of de(Object.entries(t?.usage?.windows??{}),t?.usage?.accounts))r.push({key:`window-${e}`,label:K(n.label??e),window:n});let a=Object.entries(t?.usage?.models??{}),s=n[e.id]??[];for(let[e,t]of s.length>0?a.filter(e=>{let[t]=e;return s.includes(t)}):a){let n=Object.entries(t.windows??{});if(n.length===0)continue;let[i,a]=n[0];r.push({key:`model-${e}-${i}`,label:K(a.label??i),subtitle:oe(e),window:a})}return{providerId:e.id,providerName:e.name,rows:r,status:!t.ok&&t.error?t.error:r.length===0?i(`header.services.noRateLimitsReported`):null}}),r[0]=t,r[1]=e,r[2]=n,r[3]=i,r[4]=a}else a=r[4];return a}function Q(e){return[e?.providerId,e]}var we=e=>{let t=e.usedPercent;return typeof t!=`number`||!Number.isFinite(t)?`text-foreground`:t>=80?`text-[var(--status-error)]`:t>=50?`text-[var(--status-warning)]`:`text-foreground`},Te=e=>{let t=(0,Y.c)(13),{iconNode:n,iconName:r,label:i,children:a}=e,o;t[0]!==r||t[1]!==n?(o=n??(r?(0,X.jsx)(D,{name:r,className:`size-[18px]`}):null),t[0]=r,t[1]=n,t[2]=o):o=t[2];let s;t[3]===o?s=t[4]:(s=(0,X.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:o}),t[3]=o,t[4]=s);let c;t[5]===i?c=t[6]:(c=(0,X.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:i}),t[5]=i,t[6]=c);let l;t[7]===a?l=t[8]:(l=(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-right typography-ui-label font-medium text-foreground`,children:a}),t[7]=a,t[8]=l);let u;return t[9]!==s||t[10]!==c||t[11]!==l?(u=(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5`,children:[s,c,l]}),t[9]=s,t[10]=c,t[11]=l,t[12]=u):u=t[12],u},$=e=>{let t=(0,Y.c)(30),{groups:n,displayMode:r,isLoading:i,timeFormatPreference:a}=e,{t:o}=ne(),s;t[0]!==r||t[1]!==o?(s=o(r===`remaining`?`header.services.remaining`:`header.services.used`),t[0]=r,t[1]=o,t[2]=s):s=t[2];let c=s;if(n.length===0)return null;let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,X.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:(0,X.jsx)(D,{name:`timer`,className:`size-[18px]`})}),t[3]=l):l=t[3];let u;t[4]===o?u=t[5]:(u=o(`mobile.header.metadata.usage`),t[4]=o,t[5]=u);let d;t[6]===u?d=t[7]:(d=(0,X.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:u}),t[6]=u,t[7]=d);let f;t[8]===i?f=t[9]:(f=i?(0,X.jsx)(D,{name:`refresh`,className:`size-3.5 animate-spin`}):null,t[8]=i,t[9]=f);let p;t[10]===c?p=t[11]:(p=(0,X.jsx)(`span`,{className:`truncate`,children:c}),t[10]=c,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,X.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground`,children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;t[15]!==d||t[16]!==m?(h=(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 px-2.5 pb-1.5`,children:[l,d,m]}),t[15]=d,t[16]=m,t[17]=h):h=t[17];let g;if(t[18]!==r||t[19]!==n||t[20]!==a){let e;t[22]!==r||t[23]!==a?(e=e=>(0,X.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-[var(--surface-muted)] p-2.5`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(V,{providerId:e.providerId,className:`size-4 shrink-0`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground`,children:e.providerName}),e.status&&e.rows.length===0?(0,X.jsx)(`span`,{className:`min-w-0 max-w-[60%] truncate typography-micro text-muted-foreground`,children:e.status}):null]}),e.rows.length>0?(0,X.jsx)(`div`,{className:`mt-1.5 space-y-1`,children:e.rows.map((t,n)=>{let i=q(e.rows.map(Xe),n),o=r===`remaining`?t.window.remainingPercent:t.window.usedPercent,s=le(t.window.valueLabel,o),c=ue(t.window.resetAt,t.window.resetAfterFormatted??t.window.resetAtFormatted,a);return(0,X.jsxs)(J.Fragment,{children:[i?(0,X.jsx)(`div`,{className:E(`typography-micro font-medium uppercase tracking-wide text-muted-foreground`,n>0&&`mt-3 border-t border-[var(--surface-subtle)] pt-2`),children:i}):null,(0,X.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-3`,children:[(0,X.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,X.jsx)(`span`,{className:`truncate typography-ui-label text-muted-foreground`,children:t.subtitle?`${t.subtitle} · ${t.label}`:t.label}),c?(0,X.jsx)(`span`,{className:`min-w-0 truncate typography-micro text-muted-foreground/70`,children:c}):null]}),(0,X.jsx)(`span`,{className:E(`min-w-0 max-w-[60%] shrink-0 truncate typography-ui-label font-semibold tabular-nums`,we(t.window)),children:s===`-`?``:s})]})]},t.key)})}):null,e.status&&e.rows.length>0?(0,X.jsx)(`div`,{className:`mt-1.5 truncate typography-micro text-muted-foreground`,title:e.status,children:e.status}):null]},e.providerId),t[22]=r,t[23]=a,t[24]=e):e=t[24],g=n.map(e),t[18]=r,t[19]=n,t[20]=a,t[21]=g}else g=t[21];let _;t[25]===g?_=t[26]:(_=(0,X.jsx)(`div`,{className:`space-y-1.5`,children:g}),t[25]=g,t[26]=_);let v;return t[27]!==_||t[28]!==h?(v=(0,X.jsxs)(`div`,{className:`pt-2.5`,children:[h,_]}),t[27]=_,t[28]=h,t[29]=v):v=t[29],v},Ee=e=>{let t=(0,Y.c)(52),{open:n,onClose:r,contextDisplay:i,branchLabel:a,usageGroups:o,usageDisplayMode:s,isUsageLoading:c,timeFormatPreference:l,error:u,onRetry:d}=e,{t:f}=ne(),p=J.useRef(null),[m,h]=J.useState(n),[g,_]=J.useState(!1),v,y;t[0]!==n||t[1]!==m?(v=()=>{if(n){h(!0),_(!1);return}if(!m)return;_(!0);let e=window.setTimeout(()=>{h(!1),_(!1)},140);return()=>window.clearTimeout(e)},y=[n,m],t[0]=n,t[1]=m,t[2]=v,t[3]=y):(v=t[2],y=t[3]),J.useEffect(v,y);let b,x;if(t[4]!==r||t[5]!==n?(b=()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},x=[r,n],t[4]=r,t[5]=n,t[6]=b,t[7]=x):(b=t[6],x=t[7]),J.useEffect(b,x),!m)return null;let S;t[8]===f?S=t[9]:(S=f(`mobile.surface.closeAria`),t[8]=f,t[9]=S);let C;t[10]===r?C=t[11]:(C=e=>{e.preventDefault(),r()},t[10]=r,t[11]=C);let w;t[12]!==S||t[13]!==C?(w=(0,X.jsx)(`button`,{type:`button`,className:`pointer-events-auto absolute inset-x-0 bottom-0 cursor-default top-[calc(var(--yuri-safe-area-top,0px)+var(--yuri-mobile-detail-navigation-height,3.5rem)+0.25rem)]`,"aria-label":S,onPointerDown:C}),t[12]=S,t[13]=C,t[14]=w):w=t[14];let T;t[15]===f?T=t[16]:(T=f(`mobile.header.openMetadataAria`),t[15]=f,t[16]=T);let D=g&&`pointer-events-none`,O;t[17]===D?O=t[18]:(O=E(`pointer-events-auto absolute inset-x-3 top-[calc(var(--yuri-safe-area-top,0px)+var(--yuri-mobile-detail-navigation-height,3.5rem)+0.5rem)] overflow-x-hidden overflow-y-auto overscroll-contain rounded-[20px] yuri-mobile-overlay-surface yuri-mobile-overlay-surface--translucent p-2 will-change-transform`,D),t[17]=D,t[18]=O);let k=`${g?`session-metadata-out`:`session-metadata-in`} ${g?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`,A;t[19]===k?A=t[20]:(A={animation:k,maxHeight:`min(72dvh, calc(100dvh - var(--yuri-safe-area-top, 0px) - var(--yuri-mobile-detail-navigation-height, 3.5rem) - 1rem))`},t[19]=k,t[20]=A);let j;t[21]===f?j=t[22]:(j=f(`mobile.header.metadata.branch`),t[21]=f,t[22]=j);let M;t[23]!==a||t[24]!==j?(M=(0,X.jsx)(Te,{iconName:`git-branch`,label:j,children:a}),t[23]=a,t[24]=j,t[25]=M):M=t[25];let N;t[26]!==i||t[27]!==f?(N=i?(0,X.jsx)(Te,{iconNode:(0,X.jsx)(fe,{percentage:i.percentage,pending:i.pending}),label:f(`mobile.header.metadata.context`),children:(0,X.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.5 tabular-nums`,children:[(0,X.jsx)(`span`,{className:E(`font-semibold`,i.colorClass),children:i.pending?f(`contextUsage.pending`):`${i.percentage.toFixed(1)}%`}),(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:i.tokens})]})}):null,t[26]=i,t[27]=f,t[28]=N):N=t[28];let te;t[29]!==c||t[30]!==l||t[31]!==s||t[32]!==o?(te=(0,X.jsx)($,{groups:o,displayMode:s,isLoading:c,timeFormatPreference:l}),t[29]=c,t[30]=l,t[31]=s,t[32]=o,t[33]=te):te=t[33];let P;t[34]!==u||t[35]!==d||t[36]!==f?(P=u?(0,X.jsxs)(`div`,{role:`alert`,className:`px-2.5 py-2 typography-ui-label text-[var(--status-error)]`,children:[u,(0,X.jsx)(ee,{variant:`ghost`,size:`sm`,onClick:d,children:f(`contextPanel.preview.actions.retry`)})]}):null,t[34]=u,t[35]=d,t[36]=f,t[37]=P):P=t[37];let F;t[38]!==M||t[39]!==N||t[40]!==te||t[41]!==P?(F=(0,X.jsxs)(`div`,{className:`space-y-1`,children:[M,N,te,P]}),t[38]=M,t[39]=N,t[40]=te,t[41]=P,t[42]=F):F=t[42];let I;t[43]!==O||t[44]!==A||t[45]!==F||t[46]!==T?(I=(0,X.jsx)(`div`,{ref:p,role:`dialog`,"aria-label":T,className:O,style:A,onPointerDown:Ze,children:F}),t[43]=O,t[44]=A,t[45]=F,t[46]=T,t[47]=I):I=t[47];let L;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,X.jsx)(`style`,{children:`
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t}from"./runtime-switch-DEPKHgdL.js";import{s as n}from"./platform-CiUKDeXd.js";import{ot as r,st as i}from"./vendor-base-ui-wXsskyKm.js";import{St as a}from"./gitApiHttp-Dd-FwgCq.js";import{Rt as o,Xt as s,Zt as c,an as l,ln as u,on as d,un as f,zt as p}from"./client-B_907PBv.js";import{n as m}from"./vendor-react-BkccXcWz.js";import{c as h,o as g,s as _}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{c as v,o as y}from"./yuriEvents-BFrD5fMU.js";import{D as b,E as x,I as S,R as C}from"./runtime-file-resource-Bc_ss-sW.js";import{r as w}from"./vendor-reactuses-core-DjKFMfz7.js";import{r as T}from"./useUIStore-C3ewjGgP.js";import{i as ee,o as E}from"./session-startup-barrier-DT-hIBRf.js";import{n as D}from"./Icon-DmykXZL1.js";import{Ea as O,Hi as k,Ia as A,Ji as j,Qn as M,at as N,et as te,f as P,hr as F,lt as I,mr as L,st as R}from"./ui-DyxdnQlj.js";import{t as ne}from"./i18n-DXc6czdR.js";import{c as z,o as re,s as B}from"./useGitStore-B6LCPegX.js";import{t as ie}from"./connection-hint-B-kOWome.js";import{n as ae,t as V}from"./ProviderLogo-DA98yu7M.js";import{a as oe,l as se,n as H,r as U,u as ce}from"./useQuotaStore-CSn2pk3T.js";import{a as le,i as ue,l as W,r as G,s as K}from"./quota-CqWNkFzw.js";import{i as de,r as q}from"./icons-Bd-INsoy.js";var J=e(i(),1),Y=m(),X=r();function fe(e){let t=(0,Y.c)(30),{percentage:n,pending:r}=e,i=r!==void 0&&r,{t:a}=ne(),o,s,c,l,u,d,f,p,m;if(t[0]!==i||t[1]!==n||t[2]!==a){c=i?0:G(n)??0;let e=W(n);s=i?`var(--surface-muted-foreground)`:e===`critical`?`var(--status-error)`:e===`warn`?`var(--status-warning)`:`var(--status-success)`,o=2*Math.PI*7.5,l=`0 0 18 18`,u=`size-[18px] -rotate-90`,d=`progressbar`,t[12]===a?f=t[13]:(f=a(`contextUsage.aria.label`),t[12]=a,t[13]=f),t[14]!==i||t[15]!==a?(p=i?a(`contextUsage.pending`):void 0,t[14]=i,t[15]=a,t[16]=p):p=t[16],m=i?void 0:Math.round(c),t[0]=i,t[1]=n,t[2]=a,t[3]=o,t[4]=s,t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=p,t[11]=m}else o=t[3],s=t[4],c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],p=t[10],m=t[11];let h;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,X.jsx)(`circle`,{cx:9,cy:9,r:7.5,fill:`none`,stroke:`var(--interactive-border)`,strokeWidth:3}),t[17]=h):h=t[17];let g=o*(1-c/100),_;t[18]!==o||t[19]!==s||t[20]!==g?(_=(0,X.jsx)(`circle`,{cx:9,cy:9,r:7.5,fill:`none`,stroke:s,strokeWidth:3,strokeLinecap:`round`,strokeDasharray:o,strokeDashoffset:g,className:`transition-[stroke-dashoffset,stroke] duration-300`}),t[18]=o,t[19]=s,t[20]=g,t[21]=_):_=t[21];let v;return t[22]!==_||t[23]!==l||t[24]!==u||t[25]!==d||t[26]!==f||t[27]!==p||t[28]!==m?(v=(0,X.jsxs)(`svg`,{viewBox:l,className:u,role:d,"aria-label":f,"aria-valuetext":p,"aria-valuenow":m,"aria-valuemin":0,"aria-valuemax":100,children:[h,_]}),t[22]=_,t[23]=l,t[24]=u,t[25]=d,t[26]=f,t[27]=p,t[28]=m,t[29]=v):v=t[29],v}var Z=(e,t,n)=>g({queryKey:[...e.queryScope,`mobile-session-metadata`,t],staleTime:3e4,gcTime:1/0,retry:!1,queryFn:({signal:e})=>n(e)});function pe(e){let t=S(e);return Z(e,`git`,async n=>{let r={signal:n,query:{directory:e.location.directory},headers:{"x-opencode-directory":e.location.directory}};return(await t.json(`/api/git/check`,r)).isGitRepository?{isGitRepository:!0,current:(await t.json(`/api/git/status`,{...r,query:{...r.query,mode:`light`}})).current}:{isGitRepository:!1,current:null}})}function me(e){let t=S(e);return Z(e,`quota-settings`,async e=>{let n=await t.json(`/api/config/settings`,{signal:e}),r=se.map(e=>e.id),i=Array.isArray(n.usageDropdownProviders)?n.usageDropdownProviders.filter(e=>typeof e==`string`&&(e.startsWith(`magpie:`)||r.includes(e))):r,a={};if(n.usageSelectedModels&&typeof n.usageSelectedModels==`object`)for(let[e,t]of Object.entries(n.usageSelectedModels))Array.isArray(t)&&(a[e]=t.filter(e=>typeof e==`string`));return{providerIds:i,selectedModels:a,displayMode:n.usageDisplayMode===`remaining`?`remaining`:`usage`,autoRefresh:n.usageAutoRefresh===!0,refreshIntervalMs:typeof n.usageRefreshIntervalMs==`number`&&Number.isFinite(n.usageRefreshIntervalMs)?Math.max(3e4,Math.min(3e5,Math.round(n.usageRefreshIntervalMs))):6e4}})}function he(e,t){let n=S(e);return Z(e,`quota:${t}`,async e=>{let r=await n.json(`/api/quota/${encodeURIComponent(t)}`,{signal:e});if(!y(r)||r.providerId!==t)throw Error(`Invalid quota response`);return r})}function ge(e){let t=S(e);return Z(e,`magpie`,async n=>{let r=await t.json(`/api/quota/magpie`,{signal:n,query:{directory:e.location.directory}});if(!Array.isArray(r.sources)||!r.sources.every(e=>e&&typeof e.id==`string`&&Array.isArray(e.results)&&e.results.every(t=>y(t)&&t.source===`magpie`&&t.sourceId===e.id&&t.providerId.startsWith(`magpie:${e.id}:`))))throw Error(`Invalid Magpie quota response`);return r.sources.flatMap(e=>e.results)})}var _e=(e,t)=>{if(!e||typeof e!=`object`)return;let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0},ve=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e),ye=e=>e>=90?`text-[var(--status-error)]`:e>=75?`text-[var(--status-warning)]`:`text-[var(--status-success)]`,be=e=>{let{totalTokens:t,contextLimit:n,isDraft:r}=e;if(!r&&t===null)return{pending:!0,percentage:0,tokens:`—`,colorClass:`text-muted-foreground`};if(t===null||r||t<=0||n<=0)return null;let i=Math.min(t/n*100,999);return{percentage:i,tokens:`${ve(t)}/${ve(n)}`,colorClass:ye(i)}},xe=e=>{for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.role!==`user`)continue;let r=typeof n.model?.providerID==`string`&&n.model.providerID.trim().length>0?n.model.providerID:void 0,i=typeof n.model?.modelID==`string`&&n.model.modelID.trim().length>0?n.model.modelID:void 0;if(r&&i)return{providerID:r,modelID:i}}return null},Se=e=>(e||``).replace(/\\/g,`/`).replace(/\/+$/g,``);function Ce(e,t,n){let r=(0,Y.c)(7),{t:i}=ne(),a;if(r[0]!==t||r[1]!==e||r[2]!==n||r[3]!==i){let o=new Map(e.map(Q)),s;r[5]===t?s=r[6]:(s=e=>t.includes(e.id),r[5]=t,r[6]=s),a=ce(e).filter(s).filter(e=>o.get(e.id)?.configured===!0).map(e=>{let t=o.get(e.id),r=[];for(let[e,n]of de(Object.entries(t?.usage?.windows??{}),t?.usage?.accounts))r.push({key:`window-${e}`,label:K(n.label??e),window:n});let a=Object.entries(t?.usage?.models??{}),s=n[e.id]??[];for(let[e,t]of s.length>0?a.filter(e=>{let[t]=e;return s.includes(t)}):a){let n=Object.entries(t.windows??{});if(n.length===0)continue;let[i,a]=n[0];r.push({key:`model-${e}-${i}`,label:K(a.label??i),subtitle:oe(e),window:a})}return{providerId:e.id,providerName:e.name,rows:r,status:!t.ok&&t.error?t.error:r.length===0?i(`header.services.noRateLimitsReported`):null}}),r[0]=t,r[1]=e,r[2]=n,r[3]=i,r[4]=a}else a=r[4];return a}function Q(e){return[e?.providerId,e]}var we=e=>{let t=e.usedPercent;return typeof t!=`number`||!Number.isFinite(t)?`text-foreground`:t>=80?`text-[var(--status-error)]`:t>=50?`text-[var(--status-warning)]`:`text-foreground`},Te=e=>{let t=(0,Y.c)(13),{iconNode:n,iconName:r,label:i,children:a}=e,o;t[0]!==r||t[1]!==n?(o=n??(r?(0,X.jsx)(D,{name:r,className:`size-[18px]`}):null),t[0]=r,t[1]=n,t[2]=o):o=t[2];let s;t[3]===o?s=t[4]:(s=(0,X.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:o}),t[3]=o,t[4]=s);let c;t[5]===i?c=t[6]:(c=(0,X.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:i}),t[5]=i,t[6]=c);let l;t[7]===a?l=t[8]:(l=(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-right typography-ui-label font-medium text-foreground`,children:a}),t[7]=a,t[8]=l);let u;return t[9]!==s||t[10]!==c||t[11]!==l?(u=(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 rounded-xl px-2.5 py-2.5`,children:[s,c,l]}),t[9]=s,t[10]=c,t[11]=l,t[12]=u):u=t[12],u},$=e=>{let t=(0,Y.c)(30),{groups:n,displayMode:r,isLoading:i,timeFormatPreference:a}=e,{t:o}=ne(),s;t[0]!==r||t[1]!==o?(s=o(r===`remaining`?`header.services.remaining`:`header.services.used`),t[0]=r,t[1]=o,t[2]=s):s=t[2];let c=s;if(n.length===0)return null;let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,X.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center text-muted-foreground`,children:(0,X.jsx)(D,{name:`timer`,className:`size-[18px]`})}),t[3]=l):l=t[3];let u;t[4]===o?u=t[5]:(u=o(`mobile.header.metadata.usage`),t[4]=o,t[5]=u);let d;t[6]===u?d=t[7]:(d=(0,X.jsx)(`span`,{className:`shrink-0 typography-ui-label text-muted-foreground`,children:u}),t[6]=u,t[7]=d);let f;t[8]===i?f=t[9]:(f=i?(0,X.jsx)(D,{name:`refresh`,className:`size-3.5 animate-spin`}):null,t[8]=i,t[9]=f);let p;t[10]===c?p=t[11]:(p=(0,X.jsx)(`span`,{className:`truncate`,children:c}),t[10]=c,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,X.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-center justify-end gap-1.5 typography-ui-label text-muted-foreground`,children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;t[15]!==d||t[16]!==m?(h=(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 px-2.5 pb-1.5`,children:[l,d,m]}),t[15]=d,t[16]=m,t[17]=h):h=t[17];let g;if(t[18]!==r||t[19]!==n||t[20]!==a){let e;t[22]!==r||t[23]!==a?(e=e=>(0,X.jsxs)(`div`,{className:`min-w-0 rounded-xl bg-[var(--surface-muted)] p-2.5`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,X.jsx)(V,{providerId:e.providerId,className:`size-4 shrink-0`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label font-medium text-foreground`,children:e.providerName}),e.status&&e.rows.length===0?(0,X.jsx)(`span`,{className:`min-w-0 max-w-[60%] truncate typography-micro text-muted-foreground`,children:e.status}):null]}),e.rows.length>0?(0,X.jsx)(`div`,{className:`mt-1.5 space-y-1`,children:e.rows.map((t,n)=>{let i=q(e.rows.map(Xe),n),o=r===`remaining`?t.window.remainingPercent:t.window.usedPercent,s=le(t.window.valueLabel,o),c=ue(t.window.resetAt,t.window.resetAfterFormatted??t.window.resetAtFormatted,a);return(0,X.jsxs)(J.Fragment,{children:[i?(0,X.jsx)(`div`,{className:E(`typography-micro font-medium uppercase tracking-wide text-muted-foreground`,n>0&&`mt-3 border-t border-[var(--surface-subtle)] pt-2`),children:i}):null,(0,X.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-3`,children:[(0,X.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,X.jsx)(`span`,{className:`truncate typography-ui-label text-muted-foreground`,children:t.subtitle?`${t.subtitle} · ${t.label}`:t.label}),c?(0,X.jsx)(`span`,{className:`min-w-0 truncate typography-micro text-muted-foreground/70`,children:c}):null]}),(0,X.jsx)(`span`,{className:E(`min-w-0 max-w-[60%] shrink-0 truncate typography-ui-label font-semibold tabular-nums`,we(t.window)),children:s===`-`?``:s})]})]},t.key)})}):null,e.status&&e.rows.length>0?(0,X.jsx)(`div`,{className:`mt-1.5 truncate typography-micro text-muted-foreground`,title:e.status,children:e.status}):null]},e.providerId),t[22]=r,t[23]=a,t[24]=e):e=t[24],g=n.map(e),t[18]=r,t[19]=n,t[20]=a,t[21]=g}else g=t[21];let _;t[25]===g?_=t[26]:(_=(0,X.jsx)(`div`,{className:`space-y-1.5`,children:g}),t[25]=g,t[26]=_);let v;return t[27]!==_||t[28]!==h?(v=(0,X.jsxs)(`div`,{className:`pt-2.5`,children:[h,_]}),t[27]=_,t[28]=h,t[29]=v):v=t[29],v},Ee=e=>{let t=(0,Y.c)(52),{open:n,onClose:r,contextDisplay:i,branchLabel:a,usageGroups:o,usageDisplayMode:s,isUsageLoading:c,timeFormatPreference:l,error:u,onRetry:d}=e,{t:f}=ne(),p=J.useRef(null),[m,h]=J.useState(n),[g,_]=J.useState(!1),v,y;t[0]!==n||t[1]!==m?(v=()=>{if(n){h(!0),_(!1);return}if(!m)return;_(!0);let e=window.setTimeout(()=>{h(!1),_(!1)},140);return()=>window.clearTimeout(e)},y=[n,m],t[0]=n,t[1]=m,t[2]=v,t[3]=y):(v=t[2],y=t[3]),J.useEffect(v,y);let b,x;if(t[4]!==r||t[5]!==n?(b=()=>{if(!n)return;let e=e=>{e.key===`Escape`&&r()};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},x=[r,n],t[4]=r,t[5]=n,t[6]=b,t[7]=x):(b=t[6],x=t[7]),J.useEffect(b,x),!m)return null;let S;t[8]===f?S=t[9]:(S=f(`mobile.surface.closeAria`),t[8]=f,t[9]=S);let C;t[10]===r?C=t[11]:(C=e=>{e.preventDefault(),r()},t[10]=r,t[11]=C);let w;t[12]!==S||t[13]!==C?(w=(0,X.jsx)(`button`,{type:`button`,className:`pointer-events-auto absolute inset-x-0 bottom-0 cursor-default top-[calc(var(--yuri-safe-area-top,0px)+var(--yuri-mobile-detail-navigation-height,3.5rem)+0.25rem)]`,"aria-label":S,onPointerDown:C}),t[12]=S,t[13]=C,t[14]=w):w=t[14];let T;t[15]===f?T=t[16]:(T=f(`mobile.header.openMetadataAria`),t[15]=f,t[16]=T);let D=g&&`pointer-events-none`,O;t[17]===D?O=t[18]:(O=E(`pointer-events-auto absolute inset-x-3 top-[calc(var(--yuri-safe-area-top,0px)+var(--yuri-mobile-detail-navigation-height,3.5rem)+0.5rem)] overflow-x-hidden overflow-y-auto overscroll-contain rounded-[20px] yuri-mobile-overlay-surface yuri-mobile-overlay-surface--translucent p-2 will-change-transform`,D),t[17]=D,t[18]=O);let k=`${g?`session-metadata-out`:`session-metadata-in`} ${g?140:170}ms cubic-bezier(0.32, 0.72, 0, 1) forwards`,A;t[19]===k?A=t[20]:(A={animation:k,maxHeight:`min(72dvh, calc(100dvh - var(--yuri-safe-area-top, 0px) - var(--yuri-mobile-detail-navigation-height, 3.5rem) - 1rem))`},t[19]=k,t[20]=A);let j;t[21]===f?j=t[22]:(j=f(`mobile.header.metadata.branch`),t[21]=f,t[22]=j);let M;t[23]!==a||t[24]!==j?(M=(0,X.jsx)(Te,{iconName:`git-branch`,label:j,children:a}),t[23]=a,t[24]=j,t[25]=M):M=t[25];let N;t[26]!==i||t[27]!==f?(N=i?(0,X.jsx)(Te,{iconNode:(0,X.jsx)(fe,{percentage:i.percentage,pending:i.pending}),label:f(`mobile.header.metadata.context`),children:(0,X.jsxs)(`span`,{className:`inline-flex items-baseline gap-1.5 tabular-nums`,children:[(0,X.jsx)(`span`,{className:E(`font-semibold`,i.colorClass),children:i.pending?f(`contextUsage.pending`):`${i.percentage.toFixed(1)}%`}),(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:i.tokens})]})}):null,t[26]=i,t[27]=f,t[28]=N):N=t[28];let te;t[29]!==c||t[30]!==l||t[31]!==s||t[32]!==o?(te=(0,X.jsx)($,{groups:o,displayMode:s,isLoading:c,timeFormatPreference:l}),t[29]=c,t[30]=l,t[31]=s,t[32]=o,t[33]=te):te=t[33];let P;t[34]!==u||t[35]!==d||t[36]!==f?(P=u?(0,X.jsxs)(`div`,{role:`alert`,className:`px-2.5 py-2 typography-ui-label text-[var(--status-error)]`,children:[u,(0,X.jsx)(ee,{variant:`ghost`,size:`sm`,onClick:d,children:f(`contextPanel.preview.actions.retry`)})]}):null,t[34]=u,t[35]=d,t[36]=f,t[37]=P):P=t[37];let F;t[38]!==M||t[39]!==N||t[40]!==te||t[41]!==P?(F=(0,X.jsxs)(`div`,{className:`space-y-1`,children:[M,N,te,P]}),t[38]=M,t[39]=N,t[40]=te,t[41]=P,t[42]=F):F=t[42];let I;t[43]!==O||t[44]!==A||t[45]!==F||t[46]!==T?(I=(0,X.jsx)(`div`,{ref:p,role:`dialog`,"aria-label":T,className:O,style:A,onPointerDown:Ze,children:F}),t[43]=O,t[44]=A,t[45]=F,t[46]=T,t[47]=I):I=t[47];let L;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,X.jsx)(`style`,{children:`
2
2
  @keyframes session-metadata-in {
3
3
  from { opacity: 0; transform: translateY(-8px) scale(0.985); }
4
4
  to { opacity: 1; transform: translateY(0) scale(1); }