@yuriai/web 0.2.38-beta.2 → 0.2.38-beta.4

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 (216) hide show
  1. package/dist/assets/{AgentAvatar-DNVD6VCV.js → AgentAvatar-CjZAr6nn.js} +1 -1
  2. package/dist/assets/AssistantContactStatus-DoZk9r1D.js +3 -0
  3. package/dist/assets/AssistantUnreadBadge-BJHZUf6Z.js +1 -0
  4. package/dist/assets/AssistantView-DkjXm6xL.js +1 -0
  5. package/dist/assets/DiagramView-Byel_g4U.js +1 -0
  6. package/dist/assets/{FadeInOnReveal-CK7jBcu4.js → FadeInOnReveal-BrPG6IFE.js} +1 -1
  7. package/dist/assets/GuiPluginPage-C6iXAYM8.js +1 -0
  8. package/dist/assets/GuiPluginSurface-DPXPl4xG.js +1 -0
  9. package/dist/assets/GuiPluginWindow-BdtIwEmZ.js +1 -0
  10. package/dist/assets/{Icon-DsN23fuV.js → Icon-C5rHjO1K.js} +1 -1
  11. package/dist/assets/ImageLoadingPlaceholder-Cdj2zS3j.js +1 -0
  12. package/dist/assets/LoadingImage-Gh9OduKR.js +1 -0
  13. package/dist/assets/MarkdownRenderer-DErp8UoS.js +2 -0
  14. package/dist/assets/{MarkdownRendererImpl-ecACjpZw.js → MarkdownRendererImpl-H41Q6Ds9.js} +3 -3
  15. package/dist/assets/MarkstreamRendererImpl-CJcHC4Ts.js +3 -0
  16. package/dist/assets/MobileDetailNavigation-fdYiFD76.js +1 -0
  17. package/dist/assets/MobileResizableSheet-DDzgYZmt.js +1 -0
  18. package/dist/assets/MobileShareBridge-BNPPhHGf.js +3 -0
  19. package/dist/assets/MobileTabPageHeader-ZZPrTJl4.js +2 -0
  20. package/dist/assets/MultiRunWindow-DoeszXM5.js +1 -0
  21. package/dist/assets/OnboardingScreen-BrYqOlrO.js +1 -0
  22. package/dist/assets/{OverlayScrollbar-BLhv7Nq-.js → OverlayScrollbar-8lCP3DZq.js} +1 -1
  23. package/dist/assets/SettingsView-UuXi7Uya.js +29 -0
  24. package/dist/assets/SettingsWindow-DIYoXakh.js +1 -0
  25. package/dist/assets/SetupTourDialog-BF50uUTW.js +1 -0
  26. package/dist/assets/TerminalView-uVsRpvjV.js +8 -0
  27. package/dist/assets/ToolOutputDialog-Bz23N8ob.js +10 -0
  28. package/dist/assets/VoiceSettings-DbbeM4JG.js +2 -0
  29. package/dist/assets/YuriLogo-DcoYyXzq.js +1 -0
  30. package/dist/assets/YuriWordmark-Dlsq3scd.js +1 -0
  31. package/dist/assets/appThemeRegistry-DE7vwd6j.js +1 -0
  32. package/dist/assets/{appearance--vFosLNi.js → appearance-DFsI3pnP.js} +1 -1
  33. package/dist/assets/{assistant-attachment-cache-C-SlEpSB.js → assistant-attachment-cache-Cmzt4xXE.js} +1 -1
  34. package/dist/assets/bootstrap-BhC95qVC.js +1 -0
  35. package/dist/assets/{capgoAdapter-DceVw3SM.js → capgoAdapter-BPZyUAQO.js} +1 -1
  36. package/dist/assets/{checkbox-CJsiyoER.js → checkbox-Dgn0NjAK.js} +1 -1
  37. package/dist/assets/{collapsible-B3zojUm2.js → collapsible-DbkDwHwV.js} +1 -1
  38. package/dist/assets/{context-menu-DFRg1NJF.js → context-menu-HomYNhkr.js} +1 -1
  39. package/dist/assets/desktopHosts-DovfbQPm.js +1 -0
  40. package/dist/assets/desktopRelayRestore-D4pbpNKN.js +1 -0
  41. package/dist/assets/device-DNG0cNwQ.js +2 -0
  42. package/dist/assets/{diagram-OTF8YAve.js → diagram-if-ktgjK.js} +1 -1
  43. package/dist/assets/dialog-0fjbRGoX.js +1 -0
  44. package/dist/assets/{es-CrVDn7XV.js → es-30Wqm-Bx.js} +1 -1
  45. package/dist/assets/{fileMentionTouchSelection-CorehkTj.js → fileMentionTouchSelection-OwF_hr-t.js} +1 -1
  46. package/dist/assets/{fileQueries-BaEKb7SZ.js → fileQueries-D9l0crnM.js} +1 -1
  47. package/dist/assets/fileReferenceActions-BRF8f7uA.js +1 -0
  48. package/dist/assets/{fileReferenceParser-BayaidRM.js → fileReferenceParser-1HHDBUum.js} +1 -1
  49. package/dist/assets/{fr-CCwt5AOu.js → fr-BbWLXNYa.js} +1 -1
  50. package/dist/assets/{gitApi-C6rhS4rG.js → gitApi-dAPSCbXA.js} +8 -8
  51. package/dist/assets/gitApiHttp-B1mApXwC.js +9 -0
  52. package/dist/assets/{gui-CFdPKvfq.js → gui-DN2sVP96.js} +1 -1
  53. package/dist/assets/{historyImportQueries-BrhVXQhP.js → historyImportQueries-DkB2_92i.js} +1 -1
  54. package/dist/assets/host-kMLXU0hK.js +1 -0
  55. package/dist/assets/i18n-BU14awhU.js +1 -0
  56. package/dist/assets/image-loading-DEXNCcCm.js +1 -0
  57. package/dist/assets/{input-B7-PmgcW.js → input-DYmLJuhI.js} +1 -1
  58. package/dist/assets/insertionBoundaries-CYfwgLf1.js +1 -0
  59. package/dist/assets/{ja-BfwjUNPc.js → ja-BI7m9bgW.js} +1 -1
  60. package/dist/assets/{ko-CZQZFkal.js → ko-B89SVFZa.js} +1 -1
  61. package/dist/assets/main-CaueNFt7.js +169 -0
  62. package/dist/assets/main-DrIci_pj.js +2 -0
  63. package/dist/assets/{markdownHeightCache-DlRC53XG.js → markdownHeightCache-D8yqNy2h.js} +1 -1
  64. package/dist/assets/mcpQueries-DO2TKARf.js +1 -0
  65. package/dist/assets/miniChat-BTI2ObZ2.js +2 -0
  66. package/dist/assets/mobile-Cf_sQtW6.js +2 -0
  67. package/dist/assets/mobile-html-network-CsjZ_Ur0.js +2 -0
  68. package/dist/assets/mobile-network-bridge-B_h92A-9.js +1 -0
  69. package/dist/assets/mobileBackNavigation-DxG3cz8q.js +1 -0
  70. package/dist/assets/mobileConnections-CK4dMDCg.js +2 -0
  71. package/dist/assets/modulepreload-polyfill-P2Xu9kJm.js +1 -0
  72. package/dist/assets/multirun-Cd2-PUEk.js +3 -0
  73. package/dist/assets/native-config-C_nB8tLu.js +1 -0
  74. package/dist/assets/pages-CYkE04ml.js +1 -0
  75. package/dist/assets/path-utils-jGozTg9d.js +1 -0
  76. package/dist/assets/pathNormalization-ewtPqJWn.js +1 -0
  77. package/dist/assets/{pl-B6C3vXqv.js → pl-B55Lf3HE.js} +1 -1
  78. package/dist/assets/platform-DMsFWy1a.js +1 -0
  79. package/dist/assets/projectMeta-apTlCt8d.js +1 -0
  80. package/dist/assets/{pt-BR-BUDTNopP.js → pt-BR-CFZj-ECy.js} +1 -1
  81. package/dist/assets/pwa-wwvKWKhX.js +2 -0
  82. package/dist/assets/queue-abort-optimistic-BnynR3mX.js +1 -0
  83. package/dist/assets/react-B-mb0CtR.js +1 -0
  84. package/dist/assets/readiness-0tATst8c.js +1 -0
  85. package/dist/assets/reasoning-projection-client-BEhVknv9.js +1 -0
  86. package/dist/assets/renderElectronMiniChatApp-xQdVdaLB.js +2 -0
  87. package/dist/assets/renderMobileApp-D95eHLRE.js +29 -0
  88. package/dist/assets/{runtime-auth-Bh3htXtG.js → runtime-auth-mjIpsk3N.js} +1 -1
  89. package/dist/assets/runtime-fetch-DKZOpfzo.js +1 -0
  90. package/dist/assets/runtime-file-download-DMY1k1af.js +1 -0
  91. package/dist/assets/runtime-file-resource-CL7EVzOG.js +2 -0
  92. package/dist/assets/runtime-switch-BMjl5Y5W.js +1 -0
  93. package/dist/assets/runtimeAPIRegistry-C2VogTny.js +1 -0
  94. package/dist/assets/runtimeConfig-BfzZj4LK.js +2 -0
  95. package/dist/assets/runtimeEndpointReset-CjKHwDvh.js +149 -0
  96. package/dist/assets/{scheduledTaskNavigation-C8tBjNoP.js → scheduledTaskNavigation-PH-etFzZ.js} +1 -1
  97. package/dist/assets/select-B9Km1pk9.js +1 -0
  98. package/dist/assets/sessionLookup-8gdDN8Tx.js +1 -0
  99. package/dist/assets/sortable-tabs-strip-BU0Puyy0.js +1 -0
  100. package/dist/assets/{speechSettingsQueries-CJqxaC2Q.js → speechSettingsQueries-C9LCquzH.js} +1 -1
  101. package/dist/assets/src-BFQde2OG.css +2 -0
  102. package/dist/assets/{store-Myt_Fv8d.js → store-BNNIbb4k.js} +3 -3
  103. package/dist/assets/terminalApi-BXKIVBPo.js +1 -0
  104. package/dist/assets/textarea-bB6aD-GS.js +1 -0
  105. package/dist/assets/{tooltip-D5Xeh6py.js → tooltip-DgWHbKz2.js} +1 -1
  106. package/dist/assets/{types-DXSnGXVb.js → types-CnJjf4tP.js} +1 -1
  107. package/dist/assets/{uk-Ct9y1Y2t.js → uk-CS2c4Dtj.js} +1 -1
  108. package/dist/assets/{useAppFontEffects-Blo2lGTo.js → useAppFontEffects-DJp1u2mc.js} +35 -35
  109. package/dist/assets/{useAssistantUIStore-CVSFSgJV.js → useAssistantUIStore-Du8puXWz.js} +1 -1
  110. package/dist/assets/useDesktopWindowControlsLayout-DOmb8EnW.js +1 -0
  111. package/dist/assets/useDictation-CyWtsxSn.js +1 -0
  112. package/dist/assets/useEffectiveDirectory-DmGrksdp.js +1 -0
  113. package/dist/assets/{useFontPreferences-DqBoLHp6.js → useFontPreferences-CAdw6cBK.js} +1 -1
  114. package/dist/assets/useMobileHtmlPreviewStore-C03uVLfX.js +1 -0
  115. package/dist/assets/useMobileNavigationStore-CJBLQxTz.js +17 -0
  116. package/dist/assets/usePluginsStore-El9Tx9Q3.js +1 -0
  117. package/dist/assets/useStreamingTextThrottle-BbUkYQhX.js +1 -0
  118. package/dist/assets/useUIStore-BF882_0b.js +1 -0
  119. package/dist/assets/useWorkerHighlightedLines-CZ8YG-Hi.js +7 -0
  120. package/dist/assets/{zh-CN-BegPizz4.js → zh-CN-BpiwUUs4.js} +1 -1
  121. package/dist/assets/{zh-TW-4xftqQQG.js → zh-TW-Bl9CnlGi.js} +1 -1
  122. package/dist/index.html +26 -21
  123. package/dist/mini-chat.html +26 -21
  124. package/dist/mobile.html +4 -32
  125. package/package.json +1 -1
  126. package/server/index.js +10 -0
  127. package/server/lib/gui-customization/DOCUMENTATION.md +2 -0
  128. package/server/lib/gui-customization/skill/SKILL.md +1 -1
  129. package/server/lib/gui-customization/skill/references/global-pages.md +19 -4
  130. package/server/lib/gui-customization/skill/references/gui-api.md +1 -1
  131. package/server/lib/gui-customization/skill/references/icons.md +35 -8
  132. package/server/lib/gui-network/DOCUMENTATION.md +123 -0
  133. package/server/lib/gui-network/native-ios.test.js +127 -0
  134. package/server/lib/gui-network/runtime.js +146 -0
  135. package/server/lib/gui-network/runtime.test.js +129 -0
  136. package/server/lib/preview/proxy-runtime.js +1 -1
  137. package/server/lib/preview/proxy-runtime.test.js +4 -0
  138. package/server/lib/relay/DOCUMENTATION.md +5 -0
  139. package/server/lib/relay/tunnel-host.js +2 -1
  140. package/server/lib/ui-auth/DOCUMENTATION.md +8 -0
  141. package/server/lib/ui-auth/ui-auth.js +6 -0
  142. package/server/lib/ui-auth/ui-auth.test.js +10 -0
  143. package/dist/assets/AssistantContactStatus-C5zpVdGa.js +0 -3
  144. package/dist/assets/AssistantUnreadBadge-7KpCtnd3.js +0 -1
  145. package/dist/assets/AssistantView-BZU6TlwK.js +0 -1
  146. package/dist/assets/DiagramView-CXgsVJ3A.js +0 -1
  147. package/dist/assets/GuiPluginSurface-Bk01hnV6.js +0 -1
  148. package/dist/assets/GuiPluginWindow-BgOCEgEb.js +0 -1
  149. package/dist/assets/ImageLoadingPlaceholder-MfVzv_y1.js +0 -1
  150. package/dist/assets/LoadingImage-MAgXscGl.js +0 -1
  151. package/dist/assets/MarkdownRenderer-DswMDaKf.js +0 -2
  152. package/dist/assets/MarkstreamRendererImpl-Bqbq2VPn.js +0 -3
  153. package/dist/assets/MobileDetailNavigation-CXcMdlRH.js +0 -1
  154. package/dist/assets/MobileResizableSheet-D_PnyzR0.js +0 -1
  155. package/dist/assets/MobileShareBridge-DfgyncNh.js +0 -4
  156. package/dist/assets/MobileTabPageHeader-Bm8nYrzH.js +0 -2
  157. package/dist/assets/MultiRunWindow-CvCgKiyV.js +0 -1
  158. package/dist/assets/OnboardingScreen-BwJ3iMGY.js +0 -1
  159. package/dist/assets/SettingsView-DGduWj3I.js +0 -29
  160. package/dist/assets/SettingsWindow-BM8abllV.js +0 -1
  161. package/dist/assets/SetupTourDialog-vmNGHNXl.js +0 -1
  162. package/dist/assets/TerminalView-BZObkK0H.js +0 -8
  163. package/dist/assets/ToolOutputDialog-CbGuK5bP.css +0 -1
  164. package/dist/assets/ToolOutputDialog-D_CH2A0-.js +0 -10
  165. package/dist/assets/VoiceSettings-Ru8tm8eq.js +0 -2
  166. package/dist/assets/YuriLogo-C5K_9jSK.js +0 -1
  167. package/dist/assets/YuriWordmark-CJ8qJ14A.js +0 -1
  168. package/dist/assets/appThemeRegistry-CcdIpK3S.js +0 -1
  169. package/dist/assets/bootstrap-BzeQds0D.js +0 -9
  170. package/dist/assets/desktop-Brp3xDpd.js +0 -1
  171. package/dist/assets/desktopHosts-qQ2Rz26_.js +0 -1
  172. package/dist/assets/desktopRelayRestore-DifJHAur.js +0 -1
  173. package/dist/assets/device-Db_TcRdX.js +0 -2
  174. package/dist/assets/dialog-CgtwKUKd.js +0 -1
  175. package/dist/assets/fileReferenceActions-D06_lyuL.js +0 -1
  176. package/dist/assets/host-8TDDnZXo.js +0 -1
  177. package/dist/assets/image-loading-D1DfK_bJ.js +0 -1
  178. package/dist/assets/insertionBoundaries-B-ncem5c.js +0 -1
  179. package/dist/assets/main-BMvwUUi4.js +0 -2
  180. package/dist/assets/main-Chq1F31E.js +0 -169
  181. package/dist/assets/mcpQueries-BRFr-Gfm.js +0 -1
  182. package/dist/assets/miniChat-C3vDY9WG.js +0 -2
  183. package/dist/assets/mobile-B2KYTY1c.js +0 -2
  184. package/dist/assets/mobileBackNavigation-ByUDCJde.js +0 -1
  185. package/dist/assets/multirun-F1yOJb2_.js +0 -3
  186. package/dist/assets/native-config-C2j59qnN.js +0 -1
  187. package/dist/assets/path-utils-HRmerlyU.js +0 -1
  188. package/dist/assets/platform-Dids8J9D.js +0 -1
  189. package/dist/assets/projectMeta-C08trpZE.js +0 -1
  190. package/dist/assets/pwa-C956NPB0.js +0 -2
  191. package/dist/assets/queue-abort-optimistic-CWyeG_sJ.js +0 -1
  192. package/dist/assets/react-a6PrrNTm.js +0 -1
  193. package/dist/assets/readiness-CUPPcONt.js +0 -1
  194. package/dist/assets/renderElectronMiniChatApp-DNK4YFG8.js +0 -2
  195. package/dist/assets/renderMobileApp-DagPx3n0.js +0 -28
  196. package/dist/assets/runtime-fetch-9B8F_rKW.js +0 -1
  197. package/dist/assets/runtime-file-download-D4WGSMk-.js +0 -1
  198. package/dist/assets/runtime-file-resource-tDTBpJT_.js +0 -2
  199. package/dist/assets/runtime-switch-ibQIZnws.js +0 -1
  200. package/dist/assets/runtimeConfig-D_McrwNd.js +0 -2
  201. package/dist/assets/runtimeEndpointReset-D-aHzKPN.js +0 -149
  202. package/dist/assets/select-DoYUmvbX.js +0 -1
  203. package/dist/assets/sessionLookup-D2JIMvDo.js +0 -1
  204. package/dist/assets/sortable-tabs-strip-B-W7ADKC.js +0 -1
  205. package/dist/assets/src-CzDk_0Pp.css +0 -2
  206. package/dist/assets/terminalApi-BXf0a2VZ.js +0 -1
  207. package/dist/assets/textarea-BCTNmuPZ.js +0 -1
  208. package/dist/assets/url-DO6Zrx1P.js +0 -1
  209. package/dist/assets/useDesktopWindowControlsLayout-YAxhtSDl.js +0 -1
  210. package/dist/assets/useDictation-Dp2Y3X49.js +0 -1
  211. package/dist/assets/useEffectiveDirectory-Uc8I6wXt.js +0 -1
  212. package/dist/assets/useMobileNavigationStore-SCjA_7jP.js +0 -17
  213. package/dist/assets/usePluginsStore-DfksbEZx.js +0 -1
  214. package/dist/assets/useStreamingTextThrottle-BY1Ynoj1.js +0 -1
  215. package/dist/assets/useUIStore-BsCfUWQw.js +0 -1
  216. package/dist/assets/useWorkerHighlightedLines-DAxMD3fK.js +0 -7
@@ -0,0 +1,2 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,i as n,n as r}from"./runtime-switch-BMjl5Y5W.js";import{n as i}from"./runtime-fetch-DKZOpfzo.js";import{ot as a,st as o}from"./vendor-base-ui-CzHs0bHY.js";import{bt as s,kn as c}from"./gitApiHttp-B1mApXwC.js";import{r as l}from"./useUIStore-BF882_0b.js";import{n as u}from"./vendor-react-DlzBev0S.js";import{l as d,n as f,o as p,s as m}from"./vendor-tanstack-react-query-B-Wpqq5J.js";import{o as h}from"./useMobileHtmlPreviewStore-C03uVLfX.js";import{r as g}from"./vendor-sonner-BEHGipm5.js";import{i as _,r as v,t as y}from"./vendor-reactuses-core-CuTmqEMK.js";import{n as b,t as x}from"./i18n-BU14awhU.js";import{Jn as S,Kn as C,Li as w,Na as T,ji as E,ta as D,ui as O}from"./useMobileNavigationStore-CJBLQxTz.js";import{n as k}from"./Icon-C5rHjO1K.js";import{a as A,i as j,n as M,o as N,r as P,t as F}from"./dialog-0fjbRGoX.js";import{t as I}from"./input-DYmLJuhI.js";import{i as ee,n as L,t as R}from"./tooltip-DgWHbKz2.js";import{r as te}from"./device-DNG0cNwQ.js";import{c as z,d as B,i as V,l as ne,n as H,s as U,t as W}from"./select-B9Km1pk9.js";import{n as re,t as ie}from"./useDictation-CyWtsxSn.js";import{n as ae,t as G}from"./textarea-bB6aD-GS.js";import{a as oe,i as se,o as ce,r as K,t as q}from"./speechSettingsQueries-C9LCquzH.js";import{f as le,g as ue,h as J,m as de,p as Y}from"./usePluginsStore-El9Tx9Q3.js";var fe=u(),X=e(o(),1),Z=a(),pe=X.memo(function(e){let t=(0,fe.c)(24),{checked:n,onChange:r,disabled:i,ariaLabel:a,className:o,iconClassName:s}=e,c=i!==void 0&&i,l;t[0]!==n||t[1]!==c||t[2]!==r?(l=e=>{e.preventDefault(),e.stopPropagation(),!c&&!n&&r()},t[0]=n,t[1]=c,t[2]=r,t[3]=l):l=t[3];let u=l,d;t[4]!==n||t[5]!==c||t[6]!==r?(d=e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),!c&&!n&&r())},t[4]=n,t[5]=c,t[6]=r,t[7]=d):d=t[7];let f=d,p=n?`bg-[color-mix(in_srgb,var(--primary-base)_80%,transparent)] shadow-none hover:bg-[var(--primary-base)]`:`bg-[var(--surface-muted)] shadow-[inset_0_0_0_1px_var(--interactive-border)] hover:bg-[var(--interactive-hover)]`,m;t[8]!==o||t[9]!==p?(m=S(`group/radio relative flex h-[14px] w-[14px] min-h-[14px] min-w-[14px] shrink-0 self-center items-center justify-center rounded-full outline-none`,`transition-[background-color,box-shadow] duration-200 ease-out`,p,`focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-1 focus-visible:ring-offset-background`,`disabled:cursor-not-allowed disabled:opacity-50`,o),t[8]=o,t[9]=p,t[10]=m):m=t[10];let h=!n&&`opacity-0`,g;t[11]!==s||t[12]!==h?(g=S(`block h-[5px] w-[5px] rounded-full bg-white`,h,s),t[11]=s,t[12]=h,t[13]=g):g=t[13];let _;t[14]===g?_=t[15]:(_=(0,Z.jsx)(`span`,{"aria-hidden":!0,className:g}),t[14]=g,t[15]=_);let v;return t[16]!==a||t[17]!==n||t[18]!==c||t[19]!==u||t[20]!==f||t[21]!==m||t[22]!==_?(v=(0,Z.jsx)(`button`,{type:`button`,role:`radio`,onClick:u,onKeyDown:f,disabled:c,"aria-checked":n,"aria-label":a,className:m,children:_}),t[16]=a,t[17]=n,t[18]=c,t[19]=u,t[20]=f,t[21]=m,t[22]=_,t[23]=v):v=t[23],v}),me=e=>(e.replace(/^@/,``).match(/[A-Za-z0-9]/)?.[0]??`?`).toUpperCase(),Q=e=>{let t=(0,fe.c)(26),{name:n,src:r,fallback:i,size:a,className:o,busy:s,marker:c}=e,l=a===void 0?20:a,u=s!==void 0&&s,[d,f]=X.useState(null),p=!!r&&d!==r,m;t[0]===r?m=t[1]:(m=r&&(/^data:image\/svg\+xml[;,]/i.test(r)||/^https:\/\/[^?#]+\.svg(?:[?#]|$)/i.test(r)),t[0]=r,t[1]=m);let h=!!m,g;t[2]===l?g=t[3]:(g=Math.round(l*.3),t[2]=l,t[3]=g);let _;t[4]!==l||t[5]!==g?(_={width:l,height:l,minWidth:l,flexShrink:0,borderRadius:g},t[4]=l,t[5]=g,t[6]=_):_=t[6];let v=_,y;t[7]!==v||t[8]!==i||t[9]!==n||t[10]!==p||t[11]!==l||t[12]!==r||t[13]!==h?(y=p?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`img`,{src:r,alt:``,draggable:!1,referrerPolicy:`no-referrer`,loading:`lazy`,crossOrigin:h?`anonymous`:void 0,style:{...v,opacity:h?0:void 0},className:`object-contain`,onError:()=>f(r??null)},r),h?(0,Z.jsx)(`span`,{"data-plugin-icon-mask":!0,"aria-hidden":!0,className:`pointer-events-none absolute inset-0`,style:{...v,backgroundColor:`currentColor`,maskImage:`url(${JSON.stringify(r)})`,WebkitMaskImage:`url(${JSON.stringify(r)})`,maskMode:`alpha`,maskSize:`contain`,WebkitMaskSize:`contain`,maskPosition:`center`,WebkitMaskPosition:`center`,maskRepeat:`no-repeat`,WebkitMaskRepeat:`no-repeat`}}):null]}):i?(0,Z.jsx)(`span`,{className:`yuri-plugin-icon-placeholder`,style:{...v,display:`grid`,placeItems:`center`,color:`var(--surface-muted-foreground)`},"aria-hidden":!0,children:(0,Z.jsx)(k,{name:i,style:{width:l*.65,height:l*.65}})}):(0,Z.jsx)(`span`,{className:`yuri-plugin-icon-placeholder`,style:{...v,display:`grid`,placeItems:`center`,color:`var(--surface-muted-foreground)`,fontFamily:`var(--font-mono, ui-monospace, monospace)`,fontSize:Math.round(l*.5),fontWeight:500,lineHeight:1},"aria-hidden":!0,children:me(n)}),t[7]=v,t[8]=i,t[9]=n,t[10]=p,t[11]=l,t[12]=r,t[13]=h,t[14]=y):y=t[14];let b=y,x;t[15]===o?x=t[16]:(x=S(`relative inline-flex shrink-0 align-middle`,o),t[15]=o,t[16]=x);let C=u||void 0,w;t[17]!==u||t[18]!==c?(w=u||c?(0,Z.jsx)(`span`,{className:`absolute -bottom-[3px] -right-[3px] inline-flex rounded-full bg-[var(--surface-background)] p-[1.5px]`,"aria-hidden":!0,children:u?(0,Z.jsx)(k,{name:`loader-4`,className:`size-2.5 animate-spin text-[var(--status-info)]`}):c}):null,t[17]=u,t[18]=c,t[19]=w):w=t[19];let T;return t[20]!==v||t[21]!==b||t[22]!==x||t[23]!==C||t[24]!==w?(T=(0,Z.jsxs)(`span`,{className:x,style:v,"data-plugin-icon":!0,"data-plugin-busy":C,children:[b,w]}),t[20]=v,t[21]=b,t[22]=x,t[23]=C,t[24]=w,t[25]=T):T=t[25],T};function he(e,t=!0){if(!t)return{name:e,version:null};let n=e.lastIndexOf(`@`);return n>0?{name:e.slice(0,n),version:e.slice(n+1)||null}:{name:e,version:null}}function ge(e,t,n){return Math.min(n,Math.max(t,e))}function _e(e){if(!Number.isFinite(e))return 0;let t=String(e);if(t.includes(`e-`)){let[,e]=t.split(`e-`);return Number(e)||0}let n=t.split(`.`);return n.length===2?n[1].length:0}function ve(e,t){let n=_e(t);return n<=0?e:Number(e.toFixed(n))}var ye=X.forwardRef(({value:e,onValueChange:t,min:n=-1/0,max:r=1/0,step:i=1,className:a,containerClassName:o,onBlur:s,disabled:c,fallbackValue:l,onClear:u,emptyLabel:d=`—`,...f},p)=>{let{t:m}=x(),[h,g]=X.useState(()=>e===void 0?``:String(e)),{isMobile:_}=te(),v=X.useRef(!1),y=X.useRef(null),b=X.useCallback(()=>{if(typeof document>`u`||typeof window>`u`)return;y.current?.();let e=e=>{e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation?.(),y.current?.()},t=window.setTimeout(()=>{y.current?.()},700);y.current=()=>{window.clearTimeout(t),document.removeEventListener(`click`,e,!0),y.current=null},document.addEventListener(`click`,e,!0)},[]);X.useEffect(()=>()=>{y.current?.()},[]),X.useEffect(()=>{g(e===void 0?``:String(e))},[e]);let C=X.useMemo(()=>e===void 0?l===void 0?Number.isFinite(n)?n:0:l:e,[l,n,e]),w=X.useRef(C);X.useEffect(()=>{w.current=C},[C]);let T=X.useCallback(e=>{let a=ve(ge(e,n,r),i);w.current=a,t(a)},[r,n,t,i]),E=X.useCallback(e=>{let t=e.target.value;if(g(t),t.trim()===``){u?.();return}let n=Number(t);Number.isFinite(n)&&T(n)},[T,u]),D=X.useCallback(t=>{if(h.trim()===``){u||g(e===void 0?``:String(e)),s?.(t);return}let a=Number(h);if(!Number.isFinite(a))g(e===void 0?``:String(e));else{let t=ve(ge(a,n,r),i);t===e?w.current=t:T(a),g(String(t))}s?.(t)},[T,h,r,n,s,u,i,e]),O=!!(c||C>=r),A=!!(c||C<=n),j=()=>{A||T(w.current-i)},M=()=>{O||T(w.current+i)},N=e=>t=>{t.preventDefault(),t.stopPropagation(),v.current=!0,b(),e()},P=e=>t=>{if(v.current){v.current=!1,t.preventDefault(),t.stopPropagation();return}e()};return _?(0,Z.jsxs)(`div`,{"data-slot":`number-input`,className:S(`flex h-9 shrink-0 items-stretch overflow-x-hidden overflow-y-hidden rounded-lg border border-border bg-transparent select-none overscroll-contain`,`[-webkit-user-select:none] [-webkit-touch-callout:none]`,`disabled:pointer-events-none disabled:opacity-50`,o),children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.decreaseAria`),disabled:A,onTouchStart:N(j),onClick:P(j),className:S(`grid h-full min-h-0 w-9 place-items-center overflow-x-hidden overflow-y-hidden border-r border-border p-0 leading-none touch-none`,`text-muted-foreground`,`disabled:pointer-events-none disabled:opacity-50`,!A&&`active:bg-interactive-hover`),children:(0,Z.jsx)(k,{name:`subtract`,className:`block h-4 w-4`})}),(0,Z.jsx)(`div`,{"data-slot":`number-input-value`,className:S(`flex h-full min-w-0 w-14 items-center justify-center bg-transparent px-1.5`,`text-center text-[16px] leading-none text-foreground [font-variant-numeric:tabular-nums]`,a),"aria-live":`polite`,children:e===void 0?d:h}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.increaseAria`),disabled:O,onTouchStart:N(M),onClick:P(M),className:S(`grid h-full min-h-0 w-9 place-items-center overflow-x-hidden overflow-y-hidden border-l border-border p-0 leading-none touch-none`,`text-muted-foreground`,`disabled:pointer-events-none disabled:opacity-50`,!O&&`active:bg-interactive-hover`),children:(0,Z.jsx)(k,{name:`add`,className:`block h-4 w-4`})})]}):(0,Z.jsxs)(`div`,{"data-slot":`number-input`,className:S(`flex h-7 shrink-0 items-stretch overflow-x-hidden overflow-y-hidden rounded-lg border border-border bg-transparent`,`disabled:pointer-events-none disabled:opacity-50`,o),children:[(0,Z.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.decreaseAria`),disabled:A,onClick:()=>T(w.current-i),className:S(`flex h-full w-7 items-center justify-center overflow-x-hidden overflow-y-hidden border-r border-border p-0 leading-none touch-manipulation`,`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`,`disabled:pointer-events-none disabled:opacity-50`),children:(0,Z.jsx)(k,{name:`subtract`,className:`block h-3.5 w-3.5`})}),(0,Z.jsx)(`input`,{...f,"data-slot":`number-input-value`,ref:p,type:`text`,inputMode:f.inputMode??`numeric`,value:h,onChange:E,onBlur:D,disabled:c,spellCheck:!1,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,className:S(`h-full min-w-0 w-14 bg-transparent px-1.5 text-center typography-ui-label leading-none text-foreground [font-variant-numeric:tabular-nums]`,`placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground`,`appearance-none outline-none [appearance:textfield] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,`disabled:pointer-events-none disabled:cursor-not-allowed`,a)}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":m(`numberInput.actions.increaseAria`),disabled:O,onClick:()=>T(w.current+i),className:S(`flex h-full w-7 items-center justify-center overflow-x-hidden overflow-y-hidden border-l border-border p-0 leading-none touch-manipulation`,`text-muted-foreground hover:bg-interactive-hover hover:text-foreground`,`disabled:pointer-events-none disabled:opacity-50`),children:(0,Z.jsx)(k,{name:`add`,className:`block h-3.5 w-3.5`})})]})});ye.displayName=`NumberInput`;var be=(e=c.getDirectory())=>p({queryKey:[n(),r(),`provider-sources`,e??null],queryFn:async({signal:t})=>{let n=await i(`/api/config/providers/sources`,{signal:t,query:e?{directory:e}:void 0});if(!n.ok)throw Error(`Unable to read provider sources`);return await n.json()},staleTime:3e4}),xe=(e,t)=>e.flatMap((e,n)=>t(e)?[{method:e,methodIndex:n}]:[]),Se=(e=c.getDirectory())=>p({queryKey:[n(),r(),`provider-connections`,e??null],queryFn:async({signal:t})=>{let n=c.getSdkClient(),r=e?{directory:e}:void 0,[i,a]=await Promise.all([n.provider.list({location:r},{signal:t}),n.integration.list({location:r},{signal:t})]);return{providers:i.data,integrations:a.data}}});function Ce(e){let t=c.getSdkClient(),n=r(),i=c.getDirectory(),a=i?{directory:i}:void 0,o=new AbortController,s,l,u,d=!1,f=!1,p=!1,m=()=>!o.signal.aborted&&n===r()&&i===c.getDirectory(),h=()=>{clearTimeout(l),clearTimeout(u)},g=()=>{s&&!f&&!p&&n===r()&&(p=!0,t.integration.oauth.cancel({integrationID:e.integrationID,attemptID:s.attemptID,location:a}).catch(()=>void 0))},_=()=>{o.abort(),h(),g()},v=t=>{m()&&(_(),e.onError(t))},y=async()=>{m()&&(f=!0,h(),await e.onSuccess())},b=async()=>{if(!(!m()||!s))try{let n=await t.integration.oauth.status({integrationID:e.integrationID,attemptID:s.attemptID,location:a},{signal:o.signal});if(!m())return;if(n.data.status===`complete`){await y();return}if(n.data.status!==`pending`){v(`complete`);return}l=setTimeout(()=>{b()},1500)}catch{v(`complete`)}};return{cancel:_,isCurrent:m,async start(n){u=setTimeout(()=>v(`start`),3e4);try{if(s=(await t.integration.oauth.connect({integrationID:e.integrationID,methodID:n,location:a},{signal:o.signal})).data,!m()){g();return}if(clearTimeout(u),!s.attemptID||![`auto`,`code`].includes(s.mode)){v(`start`);return}let r=Math.min(6e5,(s.time?.expires??Date.now()+6e5)-Date.now());if(r<=0){v(`complete`);return}u=setTimeout(()=>v(`complete`),r),e.onAttempt(s),s.mode===`auto`&&b()}catch{v(`start`)}},async complete(n){if(!(!m()||!s||s.mode!==`code`||d||!n.trim())){d=!0;try{await t.integration.oauth.complete({integrationID:e.integrationID,attemptID:s.attemptID,code:n.trim(),location:a},{signal:o.signal}),await y()}catch{v(`complete`)}}}}}var we=`opencode`;function Te(e){return e===`opencode-go`?we:e}function Ee(e,t){let n=Te(e);return t?.find(e=>e.id===n)}function De(e){return(e?.connections??[]).some(e=>e.type===`credential`&&e.method===`oauth`)}function Oe(e,t){return t[Te(e)]??t[e]??[]}function ke(e,t){let n=Te(e);return n===e?t[e]||e:t[n]||n}function Ae(e){let t=(0,fe.c)(129),{model:n,existingIds:r,isEditing:i,busy:a,saveError:o,fixedId:s,onSave:c,onClose:l}=e,u=a!==void 0&&a,d=s!==void 0&&s,{t:f}=x(),{isMobile:p}=te(),[m,h]=X.useState(n),[g,_]=X.useState(``),v;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(v=e=>h(t=>({...t,...e})),t[0]=v):v=t[0];let y=v,b;t[1]!==u||t[2]!==m||t[3]!==r||t[4]!==c||t[5]!==f?(b=e=>{if(e.preventDefault(),u)return;let t=m.id.trim(),n=[m.context,m.output].filter(Boolean).map(Number);if(!t||/[\s#]/.test(t)||[`__proto__`,`constructor`,`prototype`].includes(t)||n.some(je)||m.context&&m.output&&Number(m.output)>Number(m.context)){_(f(`settings.providers.custom.invalidModel`));return}if(r.includes(t)){_(f(`settings.providers.custom.invalidModels`));return}c({...m,id:t,name:m.name.trim()})},t[1]=u,t[2]=m,t[3]=r,t[4]=c,t[5]=f,t[6]=b):b=t[6];let S=b,w;t[7]!==u||t[8]!==l?(w=e=>{!e&&!u&&l()},t[7]=u,t[8]=l,t[9]=w):w=t[9];let T=`yuri-settings-workspace ${p?`yuri-settings-workspace-mobile`:`yuri-settings-workspace-desktop`} max-w-lg`,E=i?`settings.providers.custom.editModel`:`settings.providers.custom.addModel`,D;t[10]!==f||t[11]!==E?(D=f(E),t[10]=f,t[11]=E,t[12]=D):D=t[12];let O;t[13]===D?O=t[14]:(O=(0,Z.jsx)(A,{children:(0,Z.jsx)(N,{children:D})}),t[13]=D,t[14]=O);let k;t[15]===f?k=t[16]:(k=f(`settings.providers.custom.modelId`),t[15]=f,t[16]=k);let P;t[17]===f?P=t[18]:(P=f(`settings.providers.custom.modelId`),t[17]=f,t[18]=P);let ee=!d,L;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(L=e=>y({id:e.target.value}),t[19]=L):L=t[19];let R;t[20]!==m.id||t[21]!==d||t[22]!==P||t[23]!==ee?(R=(0,Z.jsx)(I,{"aria-label":P,autoFocus:ee,readOnly:d,required:!0,pattern:`[^\\s#]+`,value:m.id,onChange:L}),t[20]=m.id,t[21]=d,t[22]=P,t[23]=ee,t[24]=R):R=t[24];let z;t[25]!==k||t[26]!==R?(z=(0,Z.jsx)(Y,{label:k,children:R}),t[25]=k,t[26]=R,t[27]=z):z=t[27];let B;t[28]===f?B=t[29]:(B=f(`settings.providers.custom.modelName`),t[28]=f,t[29]=B);let V;t[30]===f?V=t[31]:(V=f(`settings.providers.custom.modelName`),t[30]=f,t[31]=V);let ne;t[32]===Symbol.for(`react.memo_cache_sentinel`)?(ne=e=>y({name:e.target.value}),t[32]=ne):ne=t[32];let H;t[33]!==m.id||t[34]!==m.name||t[35]!==V?(H=(0,Z.jsx)(I,{"aria-label":V,value:m.name,placeholder:m.id,onChange:ne}),t[33]=m.id,t[34]=m.name,t[35]=V,t[36]=H):H=t[36];let U;t[37]!==B||t[38]!==H?(U=(0,Z.jsx)(Y,{label:B,children:H}),t[37]=B,t[38]=H,t[39]=U):U=t[39];let W;t[40]!==z||t[41]!==U?(W=(0,Z.jsxs)(le,{children:[z,U]}),t[40]=z,t[41]=U,t[42]=W):W=t[42];let re;t[43]===f?re=t[44]:(re=f(`settings.providers.custom.moreSettings`),t[43]=f,t[44]=re);let ie;t[45]===re?ie=t[46]:(ie=(0,Z.jsx)(`summary`,{className:`cursor-pointer typography-meta text-muted-foreground marker:text-muted-foreground`,children:re}),t[45]=re,t[46]=ie);let ae;t[47]===f?ae=t[48]:(ae=f(`settings.providers.custom.context`),t[47]=f,t[48]=ae);let G;t[49]===f?G=t[50]:(G=f(`settings.providers.custom.context`),t[49]=f,t[50]=G);let oe=m.context?Number(m.context):void 0,se,ce;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(se=e=>y({context:String(e)}),ce=()=>y({context:``}),t[51]=se,t[52]=ce):(se=t[51],ce=t[52]);let K;t[53]!==G||t[54]!==oe?(K=(0,Z.jsx)(ye,{"aria-label":G,min:1,step:1,value:oe,onValueChange:se,onClear:ce}),t[53]=G,t[54]=oe,t[55]=K):K=t[55];let q;t[56]!==ae||t[57]!==K?(q=(0,Z.jsx)(Y,{label:ae,children:K}),t[56]=ae,t[57]=K,t[58]=q):q=t[58];let ue;t[59]===f?ue=t[60]:(ue=f(`settings.providers.custom.output`),t[59]=f,t[60]=ue);let J;t[61]===f?J=t[62]:(J=f(`settings.providers.custom.output`),t[61]=f,t[62]=J);let pe=m.output?Number(m.output):void 0,me=m.context?Number(m.context):void 0,Q,he;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(Q=e=>y({output:String(e)}),he=()=>y({output:``}),t[63]=Q,t[64]=he):(Q=t[63],he=t[64]);let ge;t[65]!==J||t[66]!==pe||t[67]!==me?(ge=(0,Z.jsx)(ye,{"aria-label":J,min:1,step:1,value:pe,max:me,onValueChange:Q,onClear:he}),t[65]=J,t[66]=pe,t[67]=me,t[68]=ge):ge=t[68];let _e;t[69]!==ue||t[70]!==ge?(_e=(0,Z.jsx)(Y,{label:ue,children:ge}),t[69]=ue,t[70]=ge,t[71]=_e):_e=t[71];let ve;t[72]===f?ve=t[73]:(ve=f(`settings.providers.custom.tools`),t[72]=f,t[73]=ve);let be;t[74]===f?be=t[75]:(be=f(`settings.providers.custom.tools`),t[74]=f,t[75]=be);let xe;t[76]===Symbol.for(`react.memo_cache_sentinel`)?(xe=e=>y({tools:e}),t[76]=xe):xe=t[76];let Se;t[77]!==m.tools||t[78]!==ve||t[79]!==be?(Se=(0,Z.jsx)(de,{label:ve,ariaLabel:be,checked:m.tools,onChange:xe}),t[77]=m.tools,t[78]=ve,t[79]=be,t[80]=Se):Se=t[80];let Ce;t[81]===f?Ce=t[82]:(Ce=f(`settings.providers.custom.vision`),t[81]=f,t[82]=Ce);let we;t[83]===f?we=t[84]:(we=f(`settings.providers.custom.vision`),t[83]=f,t[84]=we);let Te;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(Te=e=>y({vision:e}),t[85]=Te):Te=t[85];let Ee;t[86]!==m.vision||t[87]!==Ce||t[88]!==we?(Ee=(0,Z.jsx)(de,{label:Ce,ariaLabel:we,checked:m.vision,onChange:Te}),t[86]=m.vision,t[87]=Ce,t[88]=we,t[89]=Ee):Ee=t[89];let De;t[90]!==q||t[91]!==_e||t[92]!==Se||t[93]!==Ee?(De=(0,Z.jsxs)(le,{children:[q,_e,Se,Ee]}),t[90]=q,t[91]=_e,t[92]=Se,t[93]=Ee,t[94]=De):De=t[94];let Oe;t[95]!==ie||t[96]!==De?(Oe=(0,Z.jsxs)(`details`,{className:`group yuri-settings-section-stack`,children:[ie,De]}),t[95]=ie,t[96]=De,t[97]=Oe):Oe=t[97];let ke;t[98]!==g||t[99]!==o?(ke=(g||o)&&(0,Z.jsx)(`p`,{role:`alert`,className:`typography-meta text-status-error`,children:g||o}),t[98]=g,t[99]=o,t[100]=ke):ke=t[100];let Ae;t[101]===f?Ae=t[102]:(Ae=f(`settings.common.actions.cancel`),t[101]=f,t[102]=Ae);let Me;t[103]!==u||t[104]!==l||t[105]!==Ae?(Me=(0,Z.jsx)(C,{type:`button`,disabled:u,onClick:l,children:Ae}),t[103]=u,t[104]=l,t[105]=Ae,t[106]=Me):Me=t[106];let Ne=u?`settings.providers.page.actions.saving`:i?`settings.common.actions.saveChanges`:`settings.providers.custom.addModel`,Pe;t[107]!==f||t[108]!==Ne?(Pe=f(Ne),t[107]=f,t[108]=Ne,t[109]=Pe):Pe=t[109];let Fe;t[110]!==u||t[111]!==Pe?(Fe=(0,Z.jsx)(C,{type:`submit`,disabled:u,"aria-busy":u,children:Pe}),t[110]=u,t[111]=Pe,t[112]=Fe):Fe=t[112];let Ie;t[113]!==Me||t[114]!==Fe?(Ie=(0,Z.jsxs)(j,{children:[Me,Fe]}),t[113]=Me,t[114]=Fe,t[115]=Ie):Ie=t[115];let $;t[116]!==S||t[117]!==W||t[118]!==Oe||t[119]!==ke||t[120]!==Ie?($=(0,Z.jsxs)(`form`,{className:`yuri-settings-section-stack`,onSubmit:S,children:[W,Oe,ke,Ie]}),t[116]=S,t[117]=W,t[118]=Oe,t[119]=ke,t[120]=Ie,t[121]=$):$=t[121];let Le;t[122]!==$||t[123]!==T||t[124]!==O?(Le=(0,Z.jsxs)(M,{presentation:`default`,className:T,"aria-describedby":void 0,children:[O,$]}),t[122]=$,t[123]=T,t[124]=O,t[125]=Le):Le=t[125];let Re;return t[126]!==w||t[127]!==Le?(Re=(0,Z.jsx)(F,{open:!0,onOpenChange:w,children:Le}),t[126]=w,t[127]=Le,t[128]=Re):Re=t[128],Re}function je(e){return!Number.isSafeInteger(e)||e<=0}function Me({providerId:e,model:t,inputModalities:a,onClose:o}){let{t:s}=x(),l=d(),[u,f]=X.useState(!1),[p,m]=X.useState(``),h=X.useRef(null),g=X.useRef(!1);X.useEffect(()=>{let e=new AbortController;return h.current=e,()=>e.abort()},[]);let _=v(async u=>{let d=h.current;if(g.current||!d||d.signal.aborted)return;let p=c.getDirectory(),_=r(),v=n(),y=()=>!d.signal.aborted&&r()===_&&n()===v&&c.getDirectory()===p;g.current=!0,f(!0),m(``);let b=!1;try{if(!(await i(`/api/config/providers/model`,{method:`PUT`,signal:d.signal,headers:{"Content-Type":`application/json`},body:JSON.stringify({directory:p,providerId:e,modelId:t.id,name:u.name,tools:u.tools,vision:u.vision,inputModalities:a,context:u.context?Number(u.context):null,output:u.output?Number(u.output):null})})).ok)throw Error(`save`);if(!y()||(b=!0,await D({scopes:[`providers`],mode:`active`,queryDirectory:p,transportIdentity:v}),!y()))return;l.invalidateQueries({queryKey:be(p).queryKey,exact:!0}),o()}catch{y()&&m(s(b?`settings.providers.custom.refreshFailed`:`settings.providers.custom.saveFailed`))}finally{g.current=!1,y()&&f(!1)}});return(0,Z.jsx)(Ae,{model:t,existingIds:[],isEditing:!0,fixedId:!0,busy:u,saveError:p,onSave:e=>void _(e),onClose:o})}function Ne(e){if(!e||typeof e!=`object`||!(`configured`in e)||typeof e.configured!=`boolean`)throw Error(`Invalid credential status`);return{configured:e.configured,...`workspaceId`in e&&typeof e.workspaceId==`string`?{workspaceId:e.workspaceId}:{}}}var Pe=e=>p({queryKey:[n(),r(),`quota-credentials`,e],queryFn:async({signal:t})=>{let n=await i(`/api/quota/credentials/${e}`,{signal:t});if(!n.ok)throw Error(`Unable to read credential status`);return Ne(await n.json())},staleTime:3e4});function Fe({providerId:e,providerName:t}){let{t:a}=x(),{isMobile:o}=te(),s=d(),l=Pe(e),u=m(l),[f,p]=X.useState(!1),[h,g]=X.useState({}),[_,y]=X.useState(!1),[b,S]=X.useState(``),[w,T]=X.useState(!1),E=X.useRef(null),D=X.useRef(!1),ee=`/api/quota/credentials/${e}`;X.useEffect(()=>{let e=new AbortController;return E.current=e,()=>e.abort()},[e]);let L=v(e=>{D.current||(p(e),g(e&&u.data?.workspaceId?{workspaceId:u.data.workspaceId}:{}),S(``),T(!1))}),R=v(async e=>{if(D.current)return;let o=E.current;if(!o||o.signal.aborted)return;let u=r(),d=n(),f=c.getDirectory(),m=()=>!o.signal.aborted&&E.current===o&&r()===u&&n()===d&&c.getDirectory()===f;D.current=!0,y(!0),S(``);try{if(await s.cancelQueries({queryKey:l.queryKey,exact:!0}),!m())return;let n=await i(`${ee}${e===`validate`||e===`import`?`/${e}`:``}`,{method:e===`save`?`PUT`:e===`delete`?`DELETE`:`POST`,signal:o.signal,...e===`save`?{headers:{"Content-Type":`application/json`},body:JSON.stringify(h)}:{}});if(!n.ok)throw Error(`Credential operation failed`);let r=await n.json();if(!m())return;if(e===`validate`&&(!r||typeof r!=`object`||!(`valid`in r)||r.valid!==!0))throw Error(`Invalid validation response`);e!==`validate`&&(s.setQueryData(l.queryKey,Ne(r)),g({}),T(!1),p(!1)),O.success(a(e===`validate`?`settings.providers.quota.validated`:e===`delete`?`settings.providers.quota.deleted`:`settings.providers.page.quotaCredentials.saved`,{provider:t}))}catch{m()&&S(a(`settings.providers.quota.failed`))}finally{D.current=!1,m()&&y(!1)}}),z=(e,t,n)=>(0,Z.jsx)(Y,{label:t,children:(0,Z.jsx)(I,{"aria-label":t,required:e!==`refreshToken`,type:e===`workspaceId`?`text`:`password`,autoComplete:`off`,value:h[e]??``,disabled:_,onChange:t=>g(n=>({...n,[e]:t.target.value})),placeholder:n,className:`w-full font-mono text-xs`})},e);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Y,{itemId:`providers.${e}-credentials`,label:a(`settings.providers.quota.title`),children:(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-end gap-2`,children:[(0,Z.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:a(u.isError?`settings.providers.quota.loadFailed`:u.isPending?`settings.providers.page.state.loading`:u.data.configured?`settings.providers.quota.configured`:`settings.providers.quota.optional`)}),(0,Z.jsxs)(C,{variant:`ghost`,size:`xs`,disabled:u.isPending,onClick:()=>u.isError?void u.refetch():L(!0),children:[a(u.isError?`settings.providers.quota.retry`:`settings.providers.quota.manage`),(0,Z.jsx)(k,{name:`arrow-right-s`,className:`size-3.5`})]})]})}),(0,Z.jsx)(F,{open:f,onOpenChange:L,children:(0,Z.jsxs)(M,{className:`yuri-settings-workspace ${o?`yuri-settings-workspace-mobile`:`yuri-settings-workspace-desktop`} max-w-lg`,children:[(0,Z.jsxs)(A,{children:[(0,Z.jsxs)(N,{children:[t,` · `,a(`settings.providers.quota.title`)]}),(0,Z.jsx)(P,{children:a(`settings.providers.quota.description`)})]}),(0,Z.jsxs)(`form`,{className:`yuri-settings-section-stack`,onSubmit:e=>{e.preventDefault(),R(`save`)},children:[(0,Z.jsxs)(le,{children:[e===`opencode-go`&&z(`workspaceId`,a(`settings.providers.page.openCodeGo.workspaceId`),`wrk_…`),e===`opencode-go`&&z(`authCookie`,a(`settings.providers.page.openCodeGo.authCookie`),`auth=…`),e===`ollama-cloud`&&z(`cookie`,a(`settings.providers.page.openCodeGo.authCookie`),`session=…`),e===`cursor`&&z(`accessToken`,a(`settings.providers.quota.accessToken`),``),e===`cursor`&&z(`refreshToken`,a(`settings.providers.quota.refreshToken`),``)]}),e===`opencode-go`&&(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:a(`settings.providers.page.openCodeGo.help`)}),(e===`cursor`||u.data?.configured)&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e===`cursor`&&(0,Z.jsx)(C,{type:`button`,variant:`ghost`,size:`xs`,disabled:_,onClick:()=>void R(`import`),children:a(`settings.providers.quota.importCursor`)}),u.data?.configured&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(C,{type:`button`,variant:`ghost`,size:`xs`,disabled:_,onClick:()=>void R(`validate`),children:a(`settings.providers.page.openCodeGo.validate`)}),(0,Z.jsx)(C,{type:`button`,variant:`ghost`,size:`xs`,disabled:_,onClick:()=>T(e=>!e),children:a(`settings.providers.page.openCodeGo.delete`)})]})]}),w&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 typography-meta`,children:[(0,Z.jsx)(`span`,{children:a(`settings.providers.quota.deleteHint`)}),(0,Z.jsx)(C,{type:`button`,variant:`destructive`,size:`xs`,disabled:_,onClick:()=>void R(`delete`),children:a(`settings.common.actions.delete`)})]}),b&&(0,Z.jsx)(`p`,{role:`alert`,className:`typography-meta text-status-error`,children:b}),(0,Z.jsxs)(j,{children:[(0,Z.jsx)(C,{type:`button`,size:`sm`,disabled:_,onClick:()=>L(!1),children:a(`settings.common.actions.cancel`)}),(0,Z.jsx)(C,{type:`submit`,size:`sm`,disabled:_,"aria-busy":_,children:a(_?`settings.providers.page.actions.saving`:`settings.providers.page.openCodeGo.save`)})]})]})]})})]})}function Ie(e){let t=(0,fe.c)(47),{id:n,name:r,providerId:i,added:a,disabled:o,capabilities:s,detail:c,onSelect:l,onEdit:u,onToggle:d}=e,{t:f}=x(),p;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Z.jsx)(k,{name:`stack`,className:`size-5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),t[0]=p):p=t[0];let m;t[1]!==n||t[2]!==i?(m=(0,Z.jsx)(B,{modelId:n,providerId:i,className:`size-5 shrink-0`,alt:``,fallback:p}),t[1]=n,t[2]=i,t[3]=m):m=t[3];let h=o||!l,g=`${r||n} (${n})${typeof c==`string`?` · ${c}`:``}`,_=r||n,v;t[4]===_?v=t[5]:(v=(0,Z.jsx)(`span`,{className:`truncate typography-ui-label text-foreground`,children:_}),t[4]=_,t[5]=v);let y;t[6]===c?y=t[7]:(y=c&&(0,Z.jsx)(`span`,{className:`yuri-provider-model-detail truncate text-[10px] leading-4 text-muted-foreground`,children:c}),t[6]=c,t[7]=y);let b;t[8]!==v||t[9]!==y?(b=(0,Z.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2`,children:[v,y]}),t[8]=v,t[9]=y,t[10]=b):b=t[10];let S;t[11]!==l||t[12]!==h||t[13]!==g||t[14]!==b?(S=(0,Z.jsx)(`button`,{type:`button`,disabled:h,onClick:l,title:g,className:`min-w-0 flex-1 rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-foreground/20 disabled:cursor-default`,children:b}),t[11]=l,t[12]=h,t[13]=g,t[14]=b,t[15]=S):S=t[15];let w;t[16]===s?w=t[17]:(w=s.map($),t[16]=s,t[17]=w);let T;t[18]===w?T=t[19]:(T=(0,Z.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:w}),t[18]=w,t[19]=T);let E;t[20]!==a||t[21]!==o||t[22]!==u||t[23]!==f?(E=a&&u&&(0,Z.jsx)(C,{type:`button`,variant:`ghost`,size:`icon`,disabled:o,"aria-label":f(`settings.providers.custom.editModel`),title:f(`settings.providers.custom.editModel`),onClick:u,children:(0,Z.jsx)(k,{name:`settings-3`,className:`size-4`})}),t[20]=a,t[21]=o,t[22]=u,t[23]=f,t[24]=E):E=t[24];let D=a?`settings.providers.custom.removeModel`:`settings.providers.custom.addModel`,O;t[25]!==f||t[26]!==D?(O=f(D),t[25]=f,t[26]=D,t[27]=O):O=t[27];let A=a?`settings.providers.custom.removeModel`:`settings.providers.custom.addModel`,j;t[28]!==f||t[29]!==A?(j=f(A),t[28]=f,t[29]=A,t[30]=j):j=t[30];let M=a?`subtract`:`add`,N;t[31]===M?N=t[32]:(N=(0,Z.jsx)(k,{name:M,className:`size-4`}),t[31]=M,t[32]=N);let P;t[33]!==o||t[34]!==d||t[35]!==O||t[36]!==j||t[37]!==N?(P=(0,Z.jsx)(C,{type:`button`,variant:`ghost`,size:`icon`,disabled:o,"aria-label":O,title:j,onClick:d,children:N}),t[33]=o,t[34]=d,t[35]=O,t[36]=j,t[37]=N,t[38]=P):P=t[38];let F;return t[39]!==a||t[40]!==n||t[41]!==T||t[42]!==E||t[43]!==P||t[44]!==m||t[45]!==S?(F=(0,Z.jsxs)(`div`,{"data-provider-model":n,"data-added":a,className:`yuri-provider-model-row yuri-settings-group-row !min-h-0 !py-1.5 flex min-w-0 items-center gap-2`,children:[m,S,T,E,P]}),t[39]=a,t[40]=n,t[41]=T,t[42]=E,t[43]=P,t[44]=m,t[45]=S,t[46]=F):F=t[46],F}function $(e){let{icon:t,label:n}=e;return(0,Z.jsx)(`span`,{role:`img`,"aria-label":n,title:n,className:`yuri-provider-model-capability inline-flex items-center justify-center rounded-full bg-[var(--surface-muted)] px-2 py-1 text-muted-foreground`,children:(0,Z.jsx)(k,{name:t,className:`size-3.5`})},t)}var Le=e=>p({queryKey:[n(),r(),`custom-provider-models`,e.directory??null,e.draftId,e.revision,e.package,e.baseURL],gcTime:0,retry:!1,refetchOnWindowFocus:!1,queryFn:async({signal:t})=>{let n=await i(`/api/config/providers/custom/models`,{method:`POST`,signal:t,headers:{"Content-Type":`application/json`},body:JSON.stringify({package:e.package,baseURL:e.baseURL,apiKey:e.apiKey})});if(!n.ok)throw Error(`Provider model discovery failed`);let r=await n.json();if(!Array.isArray(r.models)||r.models.some(e=>typeof e?.id!=`string`||typeof e?.name!=`string`))throw Error(`Invalid provider model listing`);return r.models}});function Re(e){let t=(0,fe.c)(102),{input:n,enabled:r,models:i,onSelect:a,onAdd:o,onEdit:s,onRemove:c,onRemoveAll:l}=e,{t:u}=x(),d=y(n.revision,600),f=r&&d===n.revision&&!!n.baseURL,p;t[0]===n?p=t[1]:(p=Le(n),t[0]=n,t[1]=p);let h;t[2]!==f||t[3]!==p?(h={...p,enabled:f},t[2]=f,t[3]=p,t[4]=h):h=t[4];let g=m(h),[_,v]=X.useState(``),b;t[5]===i?b=t[6]:(b=new Map(i.map(Ve)),t[5]=i,t[6]=b);let S=b,w=g.data,T;t[7]===w?T=t[8]:(T=w??[],t[7]=w,t[8]=T);let E;if(t[9]!==S||t[10]!==T){let e;t[12]===S?e=t[13]:(e=e=>!S.has(e.id),t[12]=S,t[13]=e),E=T.filter(e),t[9]=S,t[10]=T,t[11]=E}else E=t[11];let D=E,O;if(t[14]!==i||t[15]!==D||t[16]!==_){let e=_.trim().toLowerCase();O=[...i.map(Be),...D.map(ze)].filter(t=>`${t.id} ${t.name}`.toLowerCase().includes(e)),t[14]=i,t[15]=D,t[16]=_,t[17]=O}else O=t[17];let A=O,j;t[18]===A?j=t[19]:(j=A.slice(0,100),t[18]=A,t[19]=j);let M=j,N;t[20]!==i.length||t[21]!==u?(N=u(`settings.providers.custom.modelsCount`,{count:i.length}),t[20]=i.length,t[21]=u,t[22]=N):N=t[22];let P;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Z.jsx)(k,{name:`search`,className:`pointer-events-none absolute left-2 top-1/2 size-3 -translate-y-1/2 text-muted-foreground`}),t[23]=P):P=t[23];let F;t[24]===u?F=t[25]:(F=u(`settings.providers.page.models.filterPlaceholder`),t[24]=u,t[25]=F);let ee;t[26]===u?ee=t[27]:(ee=u(`settings.providers.page.models.filterPlaceholder`),t[26]=u,t[27]=ee);let L;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(L=e=>v(e.target.value),t[28]=L):L=t[28];let R;t[29]!==_||t[30]!==F||t[31]!==ee?(R=(0,Z.jsxs)(`div`,{className:`relative w-28 min-w-0 sm:w-36`,children:[P,(0,Z.jsx)(I,{bordered:!0,"aria-label":F,placeholder:ee,className:`!h-7 !min-h-0 !pl-7 !pr-2 !text-left !text-xs`,value:_,onChange:L})]}),t[29]=_,t[30]=F,t[31]=ee,t[32]=R):R=t[32];let te=!f||g.isFetching||!D.length,z;t[33]!==w||t[34]!==a?(z=()=>a(w??[]),t[33]=w,t[34]=a,t[35]=z):z=t[35];let B;t[36]===u?B=t[37]:(B=u(`settings.providers.custom.addAllModels`),t[36]=u,t[37]=B);let V;t[38]!==te||t[39]!==z||t[40]!==B?(V=(0,Z.jsx)(C,{type:`button`,size:`xs`,disabled:te,onClick:z,children:B}),t[38]=te,t[39]=z,t[40]=B,t[41]=V):V=t[41];let ne=!r||!i.length,H;t[42]===u?H=t[43]:(H=u(`settings.providers.models.removeAll`),t[42]=u,t[43]=H);let U;t[44]!==l||t[45]!==ne||t[46]!==H?(U=(0,Z.jsx)(C,{type:`button`,size:`xs`,disabled:ne,onClick:l,children:H}),t[44]=l,t[45]=ne,t[46]=H,t[47]=U):U=t[47];let W=!f||g.isFetching,re;t[48]===g?re=t[49]:(re=()=>void g.refetch(),t[48]=g,t[49]=re);let ie=g.isFetching?`size-3.5 motion-safe:animate-spin`:`size-3.5`,G;t[50]===ie?G=t[51]:(G=(0,Z.jsx)(k,{name:`refresh`,className:ie}),t[50]=ie,t[51]=G);let oe;t[52]!==g.isFetching||t[53]!==u?(oe=g.isFetching?u(`settings.providers.page.state.loading`):u(`settings.providers.custom.fetchModels`),t[52]=g.isFetching,t[53]=u,t[54]=oe):oe=t[54];let se;t[55]!==W||t[56]!==re||t[57]!==G||t[58]!==oe?(se=(0,Z.jsxs)(C,{type:`button`,size:`xs`,disabled:W,onClick:re,children:[G,oe]}),t[55]=W,t[56]=re,t[57]=G,t[58]=oe,t[59]=se):se=t[59];let ce=!r,K;t[60]===u?K=t[61]:(K=u(`settings.providers.custom.addModel`),t[60]=u,t[61]=K);let q;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,Z.jsx)(k,{name:`add`,className:`size-3.5`}),t[62]=q):q=t[62];let ue;t[63]!==o||t[64]!==ce||t[65]!==K?(ue=(0,Z.jsx)(C,{type:`button`,size:`xs`,disabled:ce,"aria-label":K,onClick:o,children:q}),t[63]=o,t[64]=ce,t[65]=K,t[66]=ue):ue=t[66];let J;t[67]!==R||t[68]!==V||t[69]!==U||t[70]!==se||t[71]!==ue?(J=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-1`,children:[R,V,U,se,ue]}),t[67]=R,t[68]=V,t[69]=U,t[70]=se,t[71]=ue,t[72]=J):J=t[72];let de;t[73]!==g.isError||t[74]!==u||t[75]!==M.length?(de=g.isError&&M.length>0&&(0,Z.jsx)(`p`,{role:`alert`,className:`typography-meta text-status-error`,children:u(`settings.providers.custom.discoveryFailed`)}),t[73]=g.isError,t[74]=u,t[75]=M.length,t[76]=de):de=t[76];let Y;t[77]!==r||t[78]!==s||t[79]!==c||t[80]!==a||t[81]!==f||t[82]!==u||t[83]!==M?(Y=(0,Z.jsx)(ae,{outerClassName:`max-h-96`,className:`divide-y divide-[var(--yuri-settings-row-divider)]`,children:M.map(e=>(0,Z.jsx)(Ie,{id:e.id,name:e.name,detail:e.name===e.id?void 0:e.id,added:!!e.configured,disabled:!r||!e.configured&&!f,capabilities:[...e.configured?.vision?[{icon:`eye`,label:u(`settings.providers.custom.vision`)}]:[],...e.configured?.tools?[{icon:`tools`,label:u(`settings.providers.custom.tools`)}]:[]],onSelect:()=>e.configured?s(e.configured):a([e.discovered]),onEdit:e.configured?()=>{e.configured&&s(e.configured)}:void 0,onToggle:()=>e.configured?c(e.configured.key):a([e.discovered])},e.id))}),t[77]=r,t[78]=s,t[79]=c,t[80]=a,t[81]=f,t[82]=u,t[83]=M,t[84]=Y):Y=t[84];let pe;t[85]!==g.isError||t[86]!==g.isFetching||t[87]!==g.isSuccess||t[88]!==_||t[89]!==u||t[90]!==M.length?(pe=!M.length&&(0,Z.jsxs)(`div`,{className:`flex min-h-40 flex-col items-center justify-center gap-3 px-4 py-10 text-center text-muted-foreground`,children:[(0,Z.jsx)(k,{name:g.isFetching?`refresh`:_.trim()?`search`:`stack`,"aria-hidden":`true`,className:`size-8 opacity-60${g.isFetching?` motion-safe:animate-spin`:``}`}),(0,Z.jsx)(`p`,{role:g.isError&&!g.isFetching?`alert`:`status`,className:`typography-meta`,children:u(g.isFetching?`settings.providers.page.state.loading`:g.isError?`settings.providers.custom.discoveryFailed`:_.trim()?`settings.providers.page.models.noModelsMatchFilter`:g.isSuccess?`settings.providers.custom.discoveryEmpty`:`settings.providers.custom.emptyModels`)})]}),t[85]=g.isError,t[86]=g.isFetching,t[87]=g.isSuccess,t[88]=_,t[89]=u,t[90]=M.length,t[91]=pe):pe=t[91];let me;t[92]!==A.length||t[93]!==u?(me=A.length>100&&(0,Z.jsx)(`p`,{className:`yuri-settings-group-row typography-meta text-muted-foreground`,children:u(`settings.providers.models.limit`,{count:A.length})}),t[92]=A.length,t[93]=u,t[94]=me):me=t[94];let Q;return t[95]!==J||t[96]!==de||t[97]!==Y||t[98]!==pe||t[99]!==me||t[100]!==N?(Q=(0,Z.jsxs)(le,{className:`[&_[data-settings-action-header]]:flex-wrap [&_[data-settings-action-header]>div:first-child]:flex-none [&_[data-settings-action-header]>div:last-child]:max-w-full`,label:N,actions:J,children:[de,Y,pe,me]}),t[95]=J,t[96]=de,t[97]=Y,t[98]=pe,t[99]=me,t[100]=N,t[101]=Q):Q=t[101],Q}function ze(e){return{id:e.id,name:e.name,configured:void 0,discovered:e}}function Be(e){return{id:e.id,name:e.name,configured:e,discovered:void 0}}function Ve(e){return[e.id,e]}var He=[{label:`OpenAI Chat Completions`,package:`@opencode/ai/providers/openai-compatible`,version:`v1`,path:`/chat/completions`},{label:`OpenAI Responses`,package:`@opencode/ai/providers/openai-compatible/responses`,version:`v1`,path:`/responses`},{label:`Anthropic Messages`,package:`@opencode/ai/providers/anthropic-compatible`,version:`v1`,path:`/messages`},{label:`Google Gemini`,package:`@opencode/ai/providers/google`,version:`v1beta`,path:`/models/{model}:streamGenerateContent?alt=sse`}];function Ue(e,t,n=`{model}`){let r=He.find(e=>e.package===t);if(!r||typeof e!=`string`||!e.trim()||e.includes(`\\`))return null;let i=e.trim().replace(/\/+$/,``),a=i.endsWith(`#`);a&&(i=i.slice(0,-1).replace(/\/+$/,``));try{let e=new URL(i);return![`https:`,`http:`].includes(e.protocol)||e.username||e.password||e.search||e.hash?null:(a&&!r.path.includes(`{model}`)&&i.endsWith(r.path)?i=i.slice(0,-r.path.length):!a&&!/\/v\d+(?:alpha|beta)?(?:\/|$)/i.test(e.pathname)&&(i+=`/${r.version}`),{baseURL:i,requestURL:`${i}${r.path.replace(`{model}`,n||`{model}`)}`,modelsURL:`${i}/models`,inferredVersion:!a&&!/\/v\d+(?:alpha|beta)?(?:\/|$)/i.test(e.pathname)})}catch{return null}}var We=()=>({key:crypto.randomUUID(),id:``,name:``,context:``,output:``,tools:!0,vision:!1}),Ge=e=>new Promise((t,n)=>{let r=()=>{clearTimeout(i),e.removeEventListener(`abort`,r),n(e.reason)},i=setTimeout(()=>{e.removeEventListener(`abort`,r),t()},250);e.addEventListener(`abort`,r,{once:!0}),e.aborted&&r()});function Ke({onCancel:e}){let{t}=x(),a=d(),[o]=X.useState(()=>crypto.randomUUID()),[s,l]=X.useState(0),[u,f]=X.useState(``),[p,m]=X.useState(``),[h,g]=X.useState(``),[_,y]=X.useState(!1),[b,S]=X.useState(null),[T,E]=X.useState([]),[O,A]=X.useState(null),[j,M]=X.useState(!1),[N,P]=X.useState(null),F=N!==null,[ee,L]=X.useState(``),[R,te]=X.useState(0),B=Ue(p,He[s].package,T[0]?.id),ne=X.useMemo(()=>({name:u.trim(),package:He[s].package,settings:{baseURL:B?.baseURL??``},models:Object.fromEntries(T.map(e=>[e.id.trim(),{...e.name.trim()?{name:e.name.trim()}:{},capabilities:{tools:e.tools,input:e.vision?[`text`,`image`]:[`text`],output:[`text`]},...e.context||e.output?{limit:{...e.context?{context:Number(e.context)}:{},...e.output?{output:Number(e.output)}:{}}}:{}}]))}),[u,s,B?.baseURL,T]),re=X.useMemo(()=>T.filter(e=>e.key!==O?.key).map(e=>e.id),[T,O?.key]),ie=X.useRef(null),ae=X.useRef(!1);X.useEffect(()=>{let e=new AbortController;return ie.current=e,()=>e.abort()},[]);let G=v(e=>{E(t=>{let n=new Set(t.map(e=>e.id)),r=[];for(let t of e)n.has(t.id)||(n.add(t.id),r.push({...We(),id:t.id,name:t.name,context:t.context?String(t.context):``,output:t.output?String(t.output):``}));return r.length?[...t,...r]:t}),L(``)}),oe=v(async e=>{if(e.preventDefault(),ae.current||O)return;let o=ie.current;if(!o||o.signal.aborted)return;let s=c.getDirectory(),l=r(),u=n(),d=()=>!o.signal.aborted&&r()===l&&c.getDirectory()===s,f=N;L(``),ae.current=!0,M(!0);try{if(!f){if(!T.length){L(t(`settings.providers.custom.modelsEmpty`));return}if(new Set(T.map(e=>e.id.trim())).size!==T.length){L(t(`settings.providers.custom.invalidModels`));return}let e=await i(`/api/config/providers/custom`,{method:`POST`,signal:o.signal,headers:{"Content-Type":`application/json`},body:JSON.stringify({config:ne,...h.trim()?{apiKey:h.trim()}:{},directory:s})});if(!e.ok){let n=await e.json().catch(()=>null);if(d()&&n?.code===`PROVIDER_CLEANUP_FAILED`){L(t(`settings.providers.custom.cleanupFailed`));return}throw Error(`save`)}let n=await e.json();if(typeof n.providerId!=`string`||!n.providerId)throw Error(`save`);if(!d())return;f=n.providerId,P(f),g(``)}for(let e=0;e<5;e++){if(await D({scopes:[`providers`],mode:`active`,queryDirectory:s,transportIdentity:u}),!d())return;if(w.getState().providers.some(e=>e.id===f))break;if(e===4)throw Error(`refresh`);if(await Ge(o.signal),!d())return}let e=Se(s);a.invalidateQueries({queryKey:e.queryKey,exact:!0}),a.invalidateQueries({queryKey:be(s).queryKey,exact:!0}),w.getState().setSelectedProvider(f)}catch{d()&&L(t(f?`settings.providers.custom.refreshFailed`:`settings.providers.custom.saveFailed`))}finally{ae.current=!1,d()&&M(!1)}});return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`form`,{className:`yuri-settings-section-stack`,onSubmit:oe,children:[(0,Z.jsx)(J,{actions:(0,Z.jsxs)(Z.Fragment,{children:[e&&(0,Z.jsx)(C,{type:`button`,size:`sm`,disabled:j,onClick:e,children:t(`settings.common.actions.cancel`)}),(0,Z.jsx)(C,{type:`submit`,size:`sm`,disabled:j,"aria-busy":j,children:t(j?`settings.providers.page.actions.saving`:F?`settings.providers.page.actions.reconnect`:`settings.common.actions.saveChanges`)})]}),children:e&&(0,Z.jsxs)(C,{type:`button`,variant:`ghost`,size:`sm`,disabled:j,onClick:e,"data-settings-item":`providers.connect`,children:[(0,Z.jsx)(k,{name:`arrow-left-s`,className:`size-4`}),t(`settings.providers.page.connect.selectProviderTitle`)]})}),(0,Z.jsxs)(le,{label:t(`settings.providers.page.connectionDetails.title`),cardClassName:`yuri-settings-equal-controls`,children:[(0,Z.jsx)(Y,{label:t(`settings.providers.custom.name`),children:(0,Z.jsx)(I,{"aria-label":t(`settings.providers.custom.name`),required:!0,value:u,onChange:e=>f(e.target.value),disabled:j||F})}),(0,Z.jsx)(Y,{label:t(`settings.providers.custom.protocol`),children:(0,Z.jsxs)(W,{value:String(s),onValueChange:e=>{l(Number(e)),te(e=>e+1)},disabled:j||F,children:[(0,Z.jsx)(U,{"aria-label":t(`settings.providers.custom.protocol`),children:(0,Z.jsx)(z,{children:He[s].label})}),(0,Z.jsx)(H,{children:He.map((e,t)=>(0,Z.jsx)(V,{value:String(t),children:e.label},e.package))})]})}),(0,Z.jsx)(Y,{label:t(`settings.providers.custom.baseURL`),footer:B&&(0,Z.jsx)(`p`,{className:`mt-1 break-all text-right typography-meta text-muted-foreground`,children:t(`settings.providers.custom.urlExact`,{url:B.requestURL})}),children:(0,Z.jsx)(I,{"aria-label":t(`settings.providers.custom.baseURL`),type:`url`,required:!0,value:p,placeholder:`https://api.example.com`,onChange:e=>{m(e.target.value),te(e=>e+1)},disabled:j||F})}),(0,Z.jsx)(Y,{label:t(`settings.providers.page.auth.apiKeyLabel`),description:t(`settings.providers.custom.optionalKey`),children:(0,Z.jsx)(I,{"aria-label":t(`settings.providers.page.auth.apiKeyLabel`),type:_?`text`:`password`,autoComplete:`off`,value:h,onChange:e=>{g(e.target.value),te(e=>e+1)},disabled:j||F,endAdornment:(0,Z.jsx)(C,{type:`button`,size:`icon`,variant:`ghost`,disabled:j||F,"aria-label":t(`settings.providers.custom.toggleKey`),"aria-pressed":_,onClick:()=>y(e=>!e),children:(0,Z.jsx)(k,{name:_?`eye-off`:`eye`,className:`size-4`})})})})]}),(0,Z.jsx)(Re,{input:{draftId:o,revision:R,directory:c.getDirectory(),package:He[s].package,baseURL:B?.baseURL??``,apiKey:h},enabled:!j&&!F,models:T,onSelect:G,onAdd:()=>A(We()),onEdit:A,onRemoveAll:()=>{E([]),S(null)},onRemove:e=>{let t=T.findIndex(t=>t.key===e);t<0||(S({model:T[t],index:t}),E(t=>t.filter(t=>t.key!==e)))}}),b&&!T.some(e=>e.id===b.model.id)&&(0,Z.jsxs)(`div`,{role:`status`,className:`flex items-center justify-between gap-2 typography-meta text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:t(`settings.providers.models.removed`,{name:b.model.name||b.model.id})}),(0,Z.jsx)(C,{type:`button`,variant:`ghost`,size:`xs`,disabled:j||F,onClick:()=>{E(e=>{let t=[...e];return t.splice(Math.min(b.index,t.length),0,b.model),t}),S(null)},children:t(`settings.providers.models.undo`)})]}),ee&&(0,Z.jsx)(`p`,{role:F?`status`:`alert`,className:`typography-meta ${F?`text-muted-foreground`:`text-status-error`}`,children:ee})]}),O&&(0,Z.jsx)(Ae,{model:O,existingIds:re,isEditing:T.some(e=>e.key===O.key),onClose:()=>A(null),onSave:e=>{E(t=>t.some(t=>t.key===e.key)?t.map(t=>t.key===e.key?e:t):[...t,e]),A(null),L(``)}},O.key)]})}function qe(e){let t=(0,fe.c)(60),{providerId:n,methods:r,apiKey:i,apiKeyEnabled:a,busyKey:o,pendingMethodIndex:s,details:c,codes:l,onKeyChange:u,onSaveKey:d,onStart:f,onCancel:p,onCodeChange:m,onComplete:h,onCopyCode:g,onOpen:_,onCopyLink:v}=e,y=a===void 0||a,{t:b}=x(),[S,w]=(0,X.useState)(!1),[T,E]=(0,X.useState)(r[0]?.methodIndex??`key`),D;t[0]!==r||t[1]!==T?(D=typeof T==`number`&&r.some(e=>e.methodIndex===T)?T:`key`,t[0]=r,t[1]=T,t[2]=D):D=t[2];let O=D;if(!r.length&&!y){let e;t[3]===b?e=t[4]:(e=b(`settings.providers.auth.noMethods`),t[3]=b,t[4]=e);let n;return t[5]===e?n=t[6]:(n=(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:e}),t[5]=e,t[6]=n),n}let A;t[7]!==O||t[8]!==y||t[9]!==o||t[10]!==r||t[11]!==p||t[12]!==b?(A=r.length+Number(y)>1&&(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,"aria-label":b(`settings.providers.page.auth.title`),children:[r.map((e,t)=>{let{method:n,methodIndex:r}=e;return(0,Z.jsxs)(C,{variant:`chip`,size:`xs`,disabled:o?.startsWith(`api:`),"aria-pressed":O===r,onClick:()=>{O!==r&&(p(),E(r))},children:[(0,Z.jsx)(k,{name:`global`,className:`size-3.5`}),n.label||n.name||b(`settings.providers.page.auth.oauthMethodFallback`,{index:String(t+1)})]},r)}),y&&(0,Z.jsxs)(C,{variant:`chip`,size:`xs`,"aria-pressed":O===`key`,onClick:()=>{O!==`key`&&(p(),E(`key`))},children:[(0,Z.jsx)(k,{name:`key`,className:`size-3.5`}),b(`settings.providers.page.auth.apiKeyLabel`)]})]}),t[7]=O,t[8]=y,t[9]=o,t[10]=r,t[11]=p,t[12]=b,t[13]=A):A=t[13];let j;if(t[14]!==O||t[15]!==o||t[16]!==l||t[17]!==c||t[18]!==r||t[19]!==p||t[20]!==m||t[21]!==h||t[22]!==g||t[23]!==v||t[24]!==_||t[25]!==f||t[26]!==s||t[27]!==n||t[28]!==b){let e;t[30]===O?e=t[31]:(e=e=>e.methodIndex===O,t[30]=O,t[31]=e);let i;t[32]!==o||t[33]!==l||t[34]!==c||t[35]!==p||t[36]!==m||t[37]!==h||t[38]!==g||t[39]!==v||t[40]!==_||t[41]!==f||t[42]!==s||t[43]!==n||t[44]!==b?(i=(e,t)=>{let{method:r,methodIndex:i}=e,a=`${n}:${i}`,u=c[a],d=s===i,y=o===`oauth:${n}:${i}`||o===`oauth-complete:${n}:${i}`;return(0,Z.jsx)(le,{children:(0,Z.jsxs)(`div`,{className:`yuri-provider-auth-panel`,children:[(0,Z.jsx)(ne,{providerId:n,className:`size-8`}),(0,Z.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:r.label||r.name||b(`settings.providers.page.auth.oauthMethodFallback`,{index:String(t+1)})}),(r.description||r.help)&&(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:r.description||r.help}),d&&(0,Z.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 typography-meta text-muted-foreground`,children:[(0,Z.jsx)(k,{name:`loader-4`,className:`size-4 motion-safe:animate-spin`}),b(`settings.providers.page.auth.waiting`)]}),u?.instructions&&(0,Z.jsx)(`p`,{className:`max-w-full break-words typography-meta text-muted-foreground`,children:u.instructions}),u?.userCode&&(0,Z.jsxs)(`div`,{className:`flex w-full min-w-0 items-center gap-2`,children:[(0,Z.jsx)(I,{"aria-label":b(`settings.providers.page.actions.copyCode`),value:u.userCode,readOnly:!0,className:`min-w-0 font-mono text-center tracking-widest`}),(0,Z.jsx)(C,{variant:`ghost`,size:`xs`,onClick:()=>g(u.userCode),children:b(`settings.providers.page.actions.copyCode`)})]}),u?.url&&(0,Z.jsxs)(`div`,{className:`flex w-full min-w-0 flex-wrap items-center justify-center gap-2`,children:[(0,Z.jsx)(I,{"aria-label":b(`settings.providers.page.actions.copy`),value:u.url,readOnly:!0,className:`w-full min-w-0 text-xs text-muted-foreground`}),(0,Z.jsxs)(C,{size:`xs`,onClick:()=>_(u.url),children:[b(`settings.providers.page.actions.open`),(0,Z.jsx)(k,{name:`external-link`,className:`size-3.5`})]}),(0,Z.jsx)(C,{variant:`ghost`,size:`xs`,onClick:()=>v(u.url),children:b(`settings.providers.page.actions.copy`)})]}),d&&u?.mode===`code`&&(0,Z.jsxs)(`div`,{className:`flex w-full min-w-0 flex-wrap items-center justify-center gap-2`,children:[(0,Z.jsx)(I,{"aria-label":b(`settings.providers.page.auth.pasteAuthorizationCodePlaceholder`),placeholder:b(`settings.providers.page.auth.pasteAuthorizationCodePlaceholder`),value:l[a]??``,onChange:e=>m(a,e.target.value),className:`font-mono text-xs`}),(0,Z.jsx)(C,{size:`xs`,disabled:y||!l[a]?.trim(),onClick:()=>h(i),children:b(`settings.providers.page.actions.complete`)})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:[!d&&(0,Z.jsx)(C,{size:`sm`,disabled:!!o,onClick:()=>f(i),children:b(`settings.providers.page.actions.connect`)}),d&&(0,Z.jsx)(C,{variant:`ghost`,size:`sm`,onClick:p,children:b(`settings.common.actions.cancel`)})]})]})},a)},t[32]=o,t[33]=l,t[34]=c,t[35]=p,t[36]=m,t[37]=h,t[38]=g,t[39]=v,t[40]=_,t[41]=f,t[42]=s,t[43]=n,t[44]=b,t[45]=i):i=t[45],j=r.filter(e).map(i),t[14]=O,t[15]=o,t[16]=l,t[17]=c,t[18]=r,t[19]=p,t[20]=m,t[21]=h,t[22]=g,t[23]=v,t[24]=_,t[25]=f,t[26]=s,t[27]=n,t[28]=b,t[29]=j}else j=t[29];let M;t[46]!==O||t[47]!==i||t[48]!==y||t[49]!==o||t[50]!==u||t[51]!==d||t[52]!==n||t[53]!==S||t[54]!==b?(M=O===`key`&&y&&(0,Z.jsx)(le,{children:(0,Z.jsxs)(`form`,{className:`yuri-settings-group-row flex min-w-0 flex-col gap-2`,onSubmit:e=>{e.preventDefault(),d()},children:[(0,Z.jsx)(`label`,{htmlFor:`provider-key-${n}`,className:`typography-meta text-muted-foreground`,children:b(`settings.providers.page.auth.apiKeyLabel`)}),(0,Z.jsxs)(`div`,{className:`flex w-full min-w-0 items-center gap-2`,children:[(0,Z.jsx)(I,{bordered:!0,type:S?`text`:`password`,autoComplete:`off`,"aria-label":b(`settings.providers.page.auth.apiKeyLabel`),id:`provider-key-${n}`,disabled:o?.startsWith(`api:`),value:i,onChange:e=>u(e.target.value),placeholder:b(`settings.providers.page.auth.apiKeyPlaceholder`),className:`min-w-0 flex-1 !text-left font-mono text-xs`,endAdornment:(0,Z.jsx)(C,{type:`button`,variant:`ghost`,size:`icon`,disabled:o?.startsWith(`api:`),"aria-label":b(`settings.providers.custom.toggleKey`),"aria-pressed":S,onClick:()=>w(Je),children:(0,Z.jsx)(k,{name:S?`eye-off`:`eye`,className:`size-4`})})}),(0,Z.jsx)(C,{type:`submit`,size:`sm`,disabled:!!o||!i.trim(),children:b(o===`api:${n}`?`settings.providers.page.actions.saving`:`settings.providers.page.actions.saveKey`)})]})]})}),t[46]=O,t[47]=i,t[48]=y,t[49]=o,t[50]=u,t[51]=d,t[52]=n,t[53]=S,t[54]=b,t[55]=M):M=t[55];let N;return t[56]!==A||t[57]!==j||t[58]!==M?(N=(0,Z.jsxs)(`div`,{className:`yuri-provider-auth yuri-settings-section-stack`,children:[A,j,M]}),t[56]=A,t[57]=j,t[58]=M,t[59]=N):N=t[59],N}function Je(e){return!e}function Ye(e){let t=(0,fe.c)(86),{providers:n,search:r,loading:i,error:a,onSearch:o,onSelect:s}=e,{t:c}=x(),l,u,d,f,p,m,h,g,_;if(t[0]!==o||t[1]!==s||t[2]!==n||t[3]!==r||t[4]!==c){let e;t[14]===r?e=t[15]:(e=e=>`${e.name} ${e.id}`.toLowerCase().includes(r.trim().toLowerCase()),t[14]=r,t[15]=e),u=n.filter(e);let i;t[16]===c?i=t[17]:(i=c(`settings.providers.page.connect.title`),t[16]=c,t[17]=i),t[18]===i?g=t[19]:(g=(0,Z.jsx)(`h2`,{className:`typography-ui-header text-foreground`,children:i}),t[18]=i,t[19]=g);let a;t[20]===c?a=t[21]:(a=c(`settings.providers.custom.title`),t[20]=c,t[21]=a);let v;t[22]===s?v=t[23]:(v=()=>s(`__custom_provider__`),t[22]=s,t[23]=v);let y;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,Z.jsx)(k,{name:`settings-3`,className:`size-7 shrink-0 text-muted-foreground`}),t[24]=y):y=t[24];let b;t[25]===c?b=t[26]:(b=c(`settings.providers.custom.title`),t[25]=c,t[26]=b);let x;t[27]===b?x=t[28]:(x=(0,Z.jsx)(`span`,{className:`block typography-ui-label text-foreground`,children:b}),t[27]=b,t[28]=x);let S;t[29]===c?S=t[30]:(S=c(`settings.providers.custom.description`),t[29]=c,t[30]=S);let C;t[31]===S?C=t[32]:(C=(0,Z.jsx)(`span`,{className:`block typography-meta text-muted-foreground`,children:S}),t[31]=S,t[32]=C);let w;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsx)(`span`,{className:`block typography-micro text-muted-foreground`,children:`OpenAI · Anthropic · Gemini`}),t[33]=w):w=t[33];let T;t[34]!==x||t[35]!==C?(T=(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[x,C,w]}),t[34]=x,t[35]=C,t[36]=T):T=t[36];let E;t[37]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Z.jsx)(k,{name:`arrow-right-s`,className:`size-4 shrink-0 text-muted-foreground`}),t[37]=E):E=t[37],t[38]!==a||t[39]!==v||t[40]!==T?(_=(0,Z.jsx)(le,{children:(0,Z.jsxs)(`button`,{type:`button`,className:`yuri-provider-custom-choice`,"aria-label":a,onClick:v,children:[y,T,E]})}),t[38]=a,t[39]=v,t[40]=T,t[41]=_):_=t[41],l=le,t[42]===c?m=t[43]:(m=c(`settings.providers.page.connect.providerField`),t[42]=c,t[43]=m);let D;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,Z.jsx)(k,{name:`search`,className:`pointer-events-none absolute left-2 top-1/2 size-3 -translate-y-1/2 text-muted-foreground`}),t[44]=D):D=t[44];let O;t[45]===c?O=t[46]:(O=c(`settings.providers.page.connect.searchProvidersPlaceholder`),t[45]=c,t[46]=O);let A;t[47]===c?A=t[48]:(A=c(`settings.providers.page.connect.searchProvidersPlaceholder`),t[47]=c,t[48]=A);let j;t[49]===o?j=t[50]:(j=e=>o(e.target.value),t[49]=o,t[50]=j),t[51]!==r||t[52]!==O||t[53]!==A||t[54]!==j?(h=(0,Z.jsxs)(`div`,{className:`relative w-36 min-w-0`,children:[D,(0,Z.jsx)(I,{"aria-label":O,placeholder:A,className:`!h-7 !min-h-0 !pl-7 !pr-2 !text-left !text-xs`,value:r,onChange:j})]}),t[51]=r,t[52]=O,t[53]=A,t[54]=j,t[55]=h):h=t[55],p=`yuri-provider-choices`,d=`yuri-provider-choice-grid`;let M;t[56]!==s||t[57]!==c?(M=e=>(0,Z.jsxs)(`button`,{type:`button`,className:`yuri-provider-choice`,"aria-label":e.name||e.id,onClick:()=>s(e.id),children:[(0,Z.jsx)(ne,{providerId:e.id,className:`size-6 shrink-0`}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`block truncate typography-ui-label`,children:e.name||e.id}),(0,Z.jsx)(`span`,{className:`mt-1 block truncate typography-micro text-muted-foreground`,children:[...new Set(e.methods.map(e=>e.label||c(e.type===`oauth`?`settings.providers.auth.account`:e.type===`key`?`settings.providers.page.auth.apiKeyLabel`:e.type===`env`?`settings.providers.auth.environment`:`settings.providers.auth.managed`)))].join(` / `)||c(`settings.providers.auth.managed`)})]}),(0,Z.jsx)(k,{name:`arrow-right-s`,className:`size-3.5 shrink-0 text-muted-foreground`})]},e.id),t[56]=s,t[57]=c,t[58]=M):M=t[58],f=u.map(M),t[0]=o,t[1]=s,t[2]=n,t[3]=r,t[4]=c,t[5]=l,t[6]=u,t[7]=d,t[8]=f,t[9]=p,t[10]=m,t[11]=h,t[12]=g,t[13]=_}else l=t[5],u=t[6],d=t[7],f=t[8],p=t[9],m=t[10],h=t[11],g=t[12],_=t[13];let v;t[59]!==d||t[60]!==f?(v=(0,Z.jsx)(`div`,{className:d,children:f}),t[59]=d,t[60]=f,t[61]=v):v=t[61];let y;t[62]!==p||t[63]!==v?(y=(0,Z.jsx)(`div`,{className:p,children:v}),t[62]=p,t[63]=v,t[64]=y):y=t[64];let b;t[65]!==i||t[66]!==c?(b=i&&(0,Z.jsx)(`p`,{className:`yuri-settings-group-row typography-meta text-muted-foreground`,children:c(`settings.providers.page.state.loading`)}),t[65]=i,t[66]=c,t[67]=b):b=t[67];let S;t[68]!==i||t[69]!==u||t[70]!==c?(S=!i&&!u.length&&(0,Z.jsx)(`p`,{className:`yuri-settings-group-row typography-meta text-muted-foreground`,children:c(`settings.providers.page.connect.noProvidersFound`)}),t[68]=i,t[69]=u,t[70]=c,t[71]=S):S=t[71];let C;t[72]!==l||t[73]!==b||t[74]!==S||t[75]!==m||t[76]!==h||t[77]!==y?(C=(0,Z.jsxs)(l,{label:m,actions:h,children:[y,b,S]}),t[72]=l,t[73]=b,t[74]=S,t[75]=m,t[76]=h,t[77]=y,t[78]=C):C=t[78];let w;t[79]===a?w=t[80]:(w=a&&(0,Z.jsx)(`p`,{role:`alert`,className:`typography-meta text-status-error`,children:a}),t[79]=a,t[80]=w);let T;return t[81]!==C||t[82]!==w||t[83]!==g||t[84]!==_?(T=(0,Z.jsxs)(Z.Fragment,{children:[g,_,C,w]}),t[81]=C,t[82]=w,t[83]=g,t[84]=_,t[85]=T):T=t[85],T}var Xe=e=>{let t=(0,fe.c)(11),{itemId:n,label:r,description:i,action:a,rows:o,children:s}=e,c=o!==void 0&&o,l;t[0]!==s||t[1]!==c?(l=c?s:(0,Z.jsx)(`div`,{className:`yuri-settings-group-row`,children:s}),t[0]=s,t[1]=c,t[2]=l):l=t[2];let u;t[3]!==a||t[4]!==i||t[5]!==r||t[6]!==l?(u=(0,Z.jsx)(le,{className:`yuri-settings-detail-group [&_[data-settings-action-header]]:flex-wrap [&_[data-settings-action-header]>div:first-child]:flex-none [&_[data-settings-action-header]>div:last-child]:max-w-full`,label:r,actions:a,description:i,children:l}),t[3]=a,t[4]=i,t[5]=r,t[6]=l,t[7]=u):u=t[7];let d;return t[8]!==n||t[9]!==u?(d=(0,Z.jsx)(`div`,{"data-settings-item":n,children:u}),t[8]=n,t[9]=u,t[10]=d):d=t[10],d},Ze=e=>new Intl.NumberFormat(b(),{notation:`compact`,compactDisplay:`short`,maximumFractionDigits:1,minimumFractionDigits:0}).format(e),Qe=e=>{if(typeof e!=`number`||Number.isNaN(e))return null;if(e===0)return`0`;let t=Ze(e);return t.endsWith(`.0`)?t.slice(0,-2):t},$e=`__add_provider__`,et=`__custom_provider__`,tt=e=>{let t=typeof e.type==`string`?e.type:``,n=`${t} ${`${e.name??``} ${e.label??``}`.toLowerCase()}`.toLowerCase();return n.includes(`oauth`)?`oauth`:n.includes(`api`)?`api`:t.toLowerCase()},nt=(e,t,n)=>{let r=t.find(t=>t.id===e);return typeof r?.integrationID==`string`&&r.integrationID?r.integrationID:(n.some(t=>t.id===e),e)},rt=(e,t)=>{let n={},r={},i=new Map(t.filter(e=>typeof e.id==`string`&&e.id.length>0).map(e=>[e.id,e])),a=(e,t)=>{r[e]=t.id??e,n[e]=(t.methods??[]).map(e=>({type:e.type,id:e.id,name:e.label??e.name,label:e.label??e.name}))};for(let n of e){if(typeof n.id!=`string`||!n.id)continue;let r=nt(n.id,e,t),o=i.get(r);o&&a(n.id,o)}for(let e of t)typeof e.id!=`string`||!e.id||n[e.id]||a(e.id,e);return{methodsByProvider:n,integrationIdByProvider:r}},it=e=>{let n=(0,fe.c)(3),{initialConnectionId:i}=e,a=`${X.useSyncExternalStore(t,r,r)}:${s(ot)}:${i??``}`,o;return n[0]!==i||n[1]!==a?(o=(0,Z.jsx)(at,{initialConnectionId:i},a),n[0]=i,n[1]=a,n[2]=o):o=n[2],o},at=({initialConnectionId:e})=>{let{t}=x(),a=w(e=>e.providers),o=w(e=>e.selectedProviderId),s=w(e=>e.setSelectedProvider),u=w(e=>e.getModelMetadata),d=l(e=>e.hiddenModels),f=l(e=>e.toggleHiddenModel),p=l(e=>e.showAllModels),g=l(e=>e.hideAllModels),_=m(Se()),y=m(be()),{methodsByProvider:b,integrationIdByProvider:S}=X.useMemo(()=>rt(_.data?.providers??[],_.data?.integrations??[]),[_.data]),T=_.isPending;X.useEffect(()=>{_.isError&&O.error(t(`settings.providers.page.toast.authMethodsLoadFailed`))},[_.isError,t]);let[te,z]=X.useState({}),[B,V]=X.useState(null),[H,U]=X.useState(``),[W,re]=X.useState(null),[ie,G]=X.useState(null),[oe,se]=X.useState(!e&&o===$e),[ce,K]=X.useState(!1),[q,le]=X.useState(null),[ue,J]=X.useState({}),[de,fe]=X.useState({}),pe=_.isPending,me=_.isError?t(`settings.providers.page.state.unableToLoadProviderList`):null,[Q,he]=X.useState(e??et),[ge,_e]=X.useState(``),[ve,ye]=X.useState(!1),we=o===$e||o===et,Te=X.useRef(null);X.useEffect(()=>{let e=new AbortController;return Te.current=e,()=>e.abort()},[]);let Ae=v(()=>{let e=Te.current;if(!e||e.signal.aborted)return null;let t=c.getDirectory(),i=r();return{directory:t,location:t?{directory:t}:void 0,transportIdentity:n(),signal:e.signal,isCurrent:()=>Te.current===e&&!e.signal.aborted&&r()===i&&c.getDirectory()===t}}),je=X.useRef(null),Ne=v(()=>{je.current?.cancel(),je.current=null,le(null),fe({}),J({}),V(null)});X.useEffect(()=>(Ne(),()=>{je.current?.cancel(),je.current=null}),[o,Q,Ne]),X.useEffect(()=>{o||s($e)},[a,o,s]);let Pe=X.useMemo(()=>(_.data?.integrations??[]).filter(e=>!e.id.startsWith(`mcp_`)&&e.connections.length===0).sort((e,t)=>{let n=(e.name||e.id).toLowerCase(),r=(t.name||t.id).toLowerCase();return n.localeCompare(r)}),[_.data]);X.useEffect(()=>{(o===$e||o===et)&&_.isSuccess&&Q!==et&&!Pe.some(e=>e.id===Q)&&(he(et),se(!0))},[o,Q,Pe,_.isSuccess]),X.useEffect(()=>{if(U(``),re(null),z({}),G(null),K(!1),o===$e||o===et){he(e??et),se(!e&&o===$e),ye(!0);return}ye(!1)},[o,e]);let $=a.find(e=>e.id===o),Le=o?y.data?.[o]:void 0,Re=_.data?.integrations.find(e=>e.id===S[o]),ze=Re?.connections.some(e=>e.type===`env`)===!0,Be=!!Le?.files.length||Re?.connections.some(e=>e.type===`credential`&&!!e.id)===!0,Ve=y.isPending||_.isPending,He=y.isError||_.isError,Ue=ze?t(`settings.providers.delete.environmentHint`):Be?null:t(`settings.providers.delete.runtimeHint`),We=!Ve&&!He&&!Ue,Ge=He?t(`settings.providers.page.toast.providerSourcesLoadFailed`):Ve?t(`settings.providers.page.state.loading`):Ue,Je=De(Re)||o===`opencode-go`&&De(Ee(`opencode-go`,_.data?.integrations))||Le?.auth.type===`external`,Ze=Je?`settings.providers.auth.account`:Le?.auth.type===`api`||Re?.connections.some(e=>e.type===`credential`&&e.method===`key`)?`settings.providers.page.auth.apiKeyLabel`:Re?.connections.some(e=>e.type===`env`)?`settings.providers.auth.environment`:`settings.providers.auth.managed`,nt=o===`opencode`||o===`opencode-go`?`opencode-go`:o===`ollama`||o===`ollama-cloud`?`ollama-cloud`:o===`cursor`?`cursor`:null,it=v(async e=>{let n=te[e]?.trim()??``;if(!n){O.error(t(`settings.providers.page.toast.apiKeyRequired`));return}let r=Ae();if(!r)return;let i=`api:${e}`;V(i);try{let i=S[e]||e;if(await c.getSdkClient().integration.connect.key({integrationID:i,key:n,location:r.location},{signal:r.signal}),!r.isCurrent()||(z(t=>({...t,[e]:``})),await D({scopes:[`providers`],mode:`active`,queryDirectory:r.directory,transportIdentity:r.transportIdentity}),!r.isCurrent()))return;let a=await _.refetch({throwOnError:!0});if(!r.isCurrent())return;y.refetch();let o=a.data?.providers.find(t=>t.id===e||t.integrationID===i);o&&s(o.id),O.success(t(`settings.providers.page.toast.apiKeySaved`))}catch{r.isCurrent()&&O.error(t(`settings.providers.page.toast.apiKeySaveFailed`))}finally{r.isCurrent()&&V(null)}}),at=v(async(e,n)=>{Ne();let r=`oauth:${e}:${n}`;V(r);let i=Oe(e,b)[n],a=typeof i?.id==`string`?i.id:``;if(!a){V(null),O.error(t(`settings.providers.page.toast.oauthStartFailed`));return}let o=ke(e,S),c=S[e]||e,l=Ce({integrationID:o,onAttempt:({attemptID:r,mode:i,url:s,instructions:c})=>{fe({[`${e}:${n}`]:{url:s,instructions:c,mode:i,userCode:/[A-Z0-9]{4}-[A-Z0-9]{4,5}/.exec(c)?.[0]}}),le({providerId:e,methodIndex:n,methodID:a,attemptID:r,mode:i}),i===`code`&&V(null),s&&o!==`claude-code`&&h(s),O.message(t(`settings.providers.page.toast.completeOAuthInBrowser`))},onSuccess:async()=>{if(le(null),fe({}),J({}),await D({scopes:[`providers`],mode:`active`}),!l.isCurrent()||je.current!==l)return;let n=await _.refetch({throwOnError:!0});if(!l.isCurrent()||je.current!==l)return;y.refetch(),O.success(t(`settings.providers.page.toast.oauthCompleted`));let r=n.data?.providers.find(t=>t.id===e)??(o===c?n.data?.providers.find(e=>e.integrationID===o):void 0);r&&s(r.id),V(null)},onError:e=>{V(null),le(null),fe({}),J({}),O.error(t(e===`start`?`settings.providers.page.toast.oauthStartFailed`:`settings.providers.page.toast.oauthCompleteFailed`))}});je.current=l,await l.start(a)}),ot=v(async(e,t)=>{let n=`${e}:${t}`,r=ue[n]?.trim();!r||q?.mode!==`code`||q.providerId!==e||q.methodIndex!==t||(V(`oauth-complete:${e}:${t}`),await je.current?.complete(r))}),st=async e=>{if((await E(e)).ok){O.success(t(`settings.providers.page.toast.oauthLinkCopied`));return}O.error(t(`settings.providers.page.toast.oauthLinkCopyFailed`))},ct=async e=>{if((await E(e)).ok){O.success(t(`settings.providers.page.toast.deviceCodeCopied`));return}O.error(t(`settings.providers.page.toast.deviceCodeCopyFailed`))},lt=v(async e=>{if(!We||e!==o)return;let n=Ae();if(!n)return;let r=`delete:${e}`;V(r);try{let r=c.getSdkClient(),a=S[e],o=a?await r.integration.get({integrationID:a,location:n.location},{signal:n.signal}):void 0;if(!n.isCurrent())return;let l=o?.data.connections??[],u=l.flatMap(e=>e.type===`credential`&&typeof e.id==`string`&&e.id?[e.id]:[]);if(l.some(e=>e.type===`env`)||u.length===0&&!Le?.files.length){O.error(t(`settings.providers.delete.unavailable`)),_.refetch();return}let d=await i(`/api/provider/${encodeURIComponent(e)}/auth`,{method:`DELETE`,signal:n.signal,query:{scope:`config`,...n.directory?{directory:n.directory}:{}}});if(!d.ok)throw Error(`Unable to delete provider configuration`);let f=await d.json();if(!n.isCurrent()||(await Promise.all(u.map(e=>r.credential.remove({credentialID:e},{signal:n.signal}))),!n.isCurrent())||(await D({scopes:[`providers`],mode:`active`,queryDirectory:n.directory,transportIdentity:n.transportIdentity}),!n.isCurrent()))return;let[p]=await Promise.all([_.refetch({throwOnError:!0}),y.refetch({throwOnError:!0})]);if(!n.isCurrent())return;if(p.data?.providers.some(t=>t.id===e)){if(u.length===0&&!f.removed){O.error(t(`settings.providers.delete.unavailable`));return}throw Error(`Provider is still registered after configuration and credential removal`)}K(!1),s($e),O.success(t(`settings.providers.delete.success`))}catch{n.isCurrent()&&O.error(t(`settings.providers.delete.failed`))}finally{n.isCurrent()&&V(null)}}),ut=e=>(0,Z.jsx)(qe,{providerId:e,methods:xe(Oe(e,b),e=>tt(e)===`oauth`),apiKey:te[e]??``,busyKey:B,apiKeyEnabled:b[e]?.some(e=>[`key`,`api`].includes(tt(e)))??!1,pendingMethodIndex:q?.providerId===e?q.methodIndex:void 0,details:de,codes:ue,onKeyChange:t=>z(n=>({...n,[e]:t})),onSaveKey:()=>void it(e),onStart:t=>void at(e,t),onCancel:()=>{Ne(),z({})},onCodeChange:(e,t)=>J(n=>({...n,[e]:t})),onComplete:t=>void ot(e,t),onCopyCode:e=>void ct(e),onOpen:e=>void h(e),onCopyLink:e=>void st(e)},e);if(!we&&a.length===0)return(0,Z.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,Z.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,Z.jsx)(k,{name:`stack`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,Z.jsx)(`p`,{className:`typography-body`,children:t(`settings.providers.page.empty.noProvidersDetected`)}),(0,Z.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:t(`settings.providers.page.empty.checkOpenCodeConfiguration`)})]})});if(we)return(0,Z.jsx)(ae,{outerClassName:`h-full`,className:`w-full`,children:(0,Z.jsxs)(`div`,{className:`yuri-settings-section-stack mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[!oe&&Q!==et&&(0,Z.jsx)(`div`,{"data-settings-item":`providers.connect`,children:(0,Z.jsxs)(C,{variant:`ghost`,size:`sm`,onClick:()=>{Ne(),z({}),se(!0)},children:[(0,Z.jsx)(k,{name:`arrow-left-s`,className:`size-4`}),t(`settings.providers.page.connect.selectProviderTitle`)]})}),oe&&(0,Z.jsx)(`div`,{"data-settings-item":`providers.connect`,className:`yuri-settings-section-stack`,children:(0,Z.jsx)(Ye,{providers:Pe,search:ge,onSearch:_e,loading:pe,error:me,onSelect:e=>{he(e),_e(``),se(!1)}})}),!oe&&(Q===et?(0,Z.jsx)(Ke,{onCancel:()=>se(!0)}):Q&&(0,Z.jsxs)(`div`,{"data-settings-item":`providers.auth`,className:`yuri-settings-section-stack`,children:[(0,Z.jsxs)(`header`,{className:`yuri-provider-identity`,children:[(0,Z.jsx)(ne,{providerId:Q,className:`size-10 shrink-0`}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`h2`,{className:`typography-ui-header text-foreground`,children:Pe.find(e=>e.id===Q)?.name||Q}),(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.providers.page.auth.title`)})]})]}),T?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.providers.page.auth.loadingMethods`)}):ut(Q)]}))]})});if(!$)return(0,Z.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,Z.jsxs)(`div`,{className:`text-center text-muted-foreground`,children:[(0,Z.jsx)(k,{name:`stack`,className:`mx-auto mb-3 h-12 w-12 opacity-50`}),(0,Z.jsx)(`p`,{className:`typography-body`,children:t(`settings.providers.page.empty.selectProviderFromSidebar`)}),(0,Z.jsx)(`p`,{className:`typography-meta mt-1 opacity-75`,children:t(`settings.providers.page.empty.reviewDetailsAndConfigureAuth`)})]})});let dt=Array.isArray($.models)?$.models:[],ft=new Set(d.filter(e=>e.providerID===$.id).map(e=>e.modelID)),pt=dt.filter(e=>!ft.has(e.id)).length,mt=dt.filter(e=>{let t=typeof e?.name==`string`?e.name:``,n=typeof e?.id==`string`?e.id:``,r=H.trim().toLowerCase();return!(r&&!t.toLowerCase().includes(r)&&!n.toLowerCase().includes(r))}).sort((e,t)=>Number(ft.has(e.id))-Number(ft.has(t.id)));return(0,Z.jsx)(ae,{outerClassName:`h-full`,className:`w-full`,children:(0,Z.jsxs)(`div`,{className:`yuri-settings-section-stack mx-auto w-full max-w-3xl p-3 sm:p-6 sm:pt-8`,children:[(0,Z.jsxs)(`div`,{className:`yuri-provider-identity`,children:[(0,Z.jsx)(ne,{providerId:$.id,className:`size-10 shrink-0`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground truncate`,children:$.name||$.id}),(0,Z.jsx)(`p`,{className:`yuri-provider-identity-meta typography-meta text-muted-foreground`,children:(0,Z.jsx)(`span`,{className:`min-w-0 break-all font-mono text-xs`,children:$.id})})]}),(0,Z.jsxs)(R,{delayDuration:0,children:[(0,Z.jsx)(ee,{asChild:!0,children:(0,Z.jsx)(`span`,{tabIndex:We?-1:0,"aria-disabled":!We||!!B,"aria-label":t(`settings.common.actions.delete`),className:`inline-flex shrink-0 ${!We||B?`cursor-not-allowed`:``}`,children:(0,Z.jsx)(C,{variant:`ghost`,size:`icon`,"aria-label":t(`settings.common.actions.delete`),disabled:!!B||!We,onClick:()=>K(!0),children:(0,Z.jsx)(k,{name:`delete-bin`,className:`size-4`})})})}),(0,Z.jsx)(L,{side:`bottom`,align:`end`,sideOffset:6,className:`max-w-[min(22rem,calc(100vw-2rem))] text-left`,children:Ge||t(`settings.common.actions.delete`)})]})]}),(0,Z.jsxs)(Xe,{itemId:`providers.auth`,rows:!0,label:t(`settings.providers.page.connectionDetails.title`),children:[(0,Z.jsx)(Y,{label:t(`settings.providers.page.auth.title`),children:(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-end gap-2`,children:[(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5 typography-meta text-muted-foreground`,children:[(0,Z.jsx)(k,{name:Je?`global`:`key`,className:`size-3.5 shrink-0`}),t(T?`settings.providers.page.state.loading`:Ze)]}),(0,Z.jsxs)(C,{variant:`ghost`,size:`xs`,disabled:B?.startsWith(`api:`),"aria-expanded":ve,onClick:()=>{Ne(),z({}),ye(e=>!e)},children:[t(ve?`settings.common.actions.cancel`:`settings.providers.page.actions.reconnect`),(0,Z.jsx)(k,{name:`arrow-down-s`,className:ve?`size-3.5 rotate-180`:`size-3.5`})]})]})}),(0,Z.jsx)(Y,{itemId:`providers.connection-details`,label:t(`settings.providers.page.connectionDetails.configuredIn`),children:(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,Z.jsx)(`span`,{className:`typography-meta text-muted-foreground break-all`,title:Le?.files.map(e=>e.path).join(`
2
+ `),children:Le?Le.origin===`runtime`?t(`settings.providers.source.runtime`):Le.origin===`builtin`?t(`settings.providers.source.builtin`):Le.files.map(e=>`${t(e.scope===`project`?`settings.providers.page.connectionDetails.source.projectConfig`:e.scope===`custom`?`settings.providers.page.connectionDetails.source.customConfig`:`settings.providers.page.connectionDetails.source.userConfig`)} / ${e.path.split(/[\\/]/).pop()}`).join(`, `):t(y.isError?`settings.providers.page.toast.providerSourcesLoadFailed`:y.isPending?`settings.providers.page.state.loading`:`settings.providers.page.connectionDetails.noActiveSource`)}),y.isError&&Le&&(0,Z.jsx)(`span`,{role:`alert`,className:`typography-meta text-muted-foreground`,children:t(`settings.providers.page.toast.providerSourcesLoadFailed`)})]})}),nt&&(0,Z.jsx)(Fe,{providerId:nt,providerName:nt===`opencode-go`?`OpenCode Go`:nt===`ollama-cloud`?`Ollama Cloud`:`Cursor`},nt)]}),ve&&(T?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.providers.page.auth.loadingMethods`)}):ut($.id)),(0,Z.jsx)(Xe,{itemId:`providers.models`,rows:!0,label:t(`settings.providers.custom.modelsCount`,{count:pt}),action:(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center justify-end gap-2`,children:[(0,Z.jsxs)(`div`,{className:`relative w-28 min-w-0 sm:w-36`,children:[(0,Z.jsx)(k,{name:`search`,className:`pointer-events-none absolute left-2 top-1/2 size-3 -translate-y-1/2 text-muted-foreground`}),(0,Z.jsx)(I,{bordered:!0,value:H,onChange:e=>U(e.target.value),"aria-label":t(`settings.providers.page.models.filterPlaceholder`),placeholder:t(`settings.providers.page.models.filterPlaceholder`),className:`!h-7 !min-h-0 !pl-7 !pr-2 !text-left !text-xs`})]}),(0,Z.jsx)(C,{size:`xs`,disabled:pt===dt.length,onClick:()=>p($.id),children:t(`settings.providers.custom.addAllModels`)}),(0,Z.jsx)(C,{size:`xs`,disabled:pt===0,onClick:()=>{g($.id,dt.map(e=>e.id)),G(null)},children:t(`settings.providers.models.removeAll`)})]}),children:mt.length===0?(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground py-4 text-center`,children:t(`settings.providers.page.models.noModelsMatchFilter`)}):(0,Z.jsx)(`div`,{className:`divide-y divide-[var(--yuri-settings-row-divider)]`,children:mt.slice(0,100).map(e=>{let n=typeof e?.id==`string`?e.id:``,r=typeof e?.name==`string`?e.name:n,i=n?u($.id,n):void 0,a=ft.has(n),o=()=>re({providerId:$.id,inputModalities:i?.modalities?.input??[`text`],model:{key:n,id:n,name:r,context:i?.limit?.context?String(i.limit.context):``,output:i?.limit?.output?String(i.limit.output):``,tools:i?.tool_call===!0,vision:i?.modalities?.input?.includes(`image`)===!0}}),s=Qe(i?.limit?.context),c=Qe(i?.limit?.output),l=[];return i?.tool_call&&l.push({key:`tools`,icon:`tools`,label:t(`settings.providers.page.models.capability.toolCalling`)}),i?.reasoning&&l.push({key:`reasoning`,icon:`brain-ai-3`,label:t(`settings.providers.page.models.capability.reasoning`)}),i?.modalities?.input?.includes(`image`)&&l.push({key:`image`,icon:`file-image`,label:t(`settings.providers.page.models.capability.imageInput`)}),(0,Z.jsx)(Ie,{id:n,name:r,providerId:$.id,added:!a,capabilities:l,detail:[s?`${s} ${t(`settings.providers.page.models.tokenBadge.context`)}`:``,c?`${c} ${t(`settings.providers.page.models.tokenBadge.output`)}`:``].filter(Boolean).join(` · `),onSelect:a?()=>f($.id,n):o,onEdit:o,onToggle:()=>{f($.id,n),G(a?null:{providerId:$.id,modelId:n})}},n)})})}),mt.length>100&&(0,Z.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:t(`settings.providers.models.limit`,{count:mt.length})}),ie?.providerId===$.id&&ft.has(ie.modelId)&&(0,Z.jsxs)(`div`,{role:`status`,className:`flex items-center justify-between gap-2 typography-meta text-muted-foreground`,children:[(0,Z.jsx)(`span`,{children:t(`settings.providers.models.removed`,{name:ie.modelId})}),(0,Z.jsx)(C,{variant:`ghost`,size:`xs`,onClick:()=>{f(ie.providerId,ie.modelId),G(null)},children:t(`settings.providers.models.undo`)})]}),W?.providerId===$.id&&(0,Z.jsx)(Me,{...W,onClose:()=>re(null)},`${$.id}:${W.model.id}`),(0,Z.jsx)(F,{open:ce,onOpenChange:e=>{B||K(e)},children:(0,Z.jsxs)(M,{children:[(0,Z.jsxs)(A,{children:[(0,Z.jsxs)(N,{children:[t(`settings.common.actions.delete`),` `,$.name||$.id]}),(0,Z.jsx)(P,{children:t(`settings.providers.delete.description`)})]}),(0,Z.jsxs)(j,{children:[(0,Z.jsx)(C,{disabled:!!B,onClick:()=>K(!1),children:t(`settings.common.actions.cancel`)}),(0,Z.jsx)(C,{variant:`destructive`,disabled:!!B||!We,onClick:()=>void lt($.id),children:t(`settings.common.actions.delete`)})]})]})})]})})};function ot(e){return e.currentDirectory}var st=e=>{if(!e)return;e.pause();let{src:t}=e;t.startsWith(`blob:`)&&URL.revokeObjectURL(t),e.removeAttribute(`src`),e.load()};function ct(e){let n=(0,fe.c)(82),{onClose:r}=e,{t:i}=x(),[a,o]=(0,X.useState)(``),[s,c]=(0,X.useState)(!1),l;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(l={onTranscript:o},n[0]=l):l=n[0];let u=ie(l),d;n[1]===Symbol.for(`react.memo_cache_sentinel`)?(d=re(),n[1]=d):d=n[1];let f=d,p=u.status===`recording`,m=u.status===`uploading`,h=u.status===`failed`,g;n[2]!==u||n[3]!==h?(g=()=>{c(!1),o(``),h?u.discardFailedDictation():u.cancelDictation()},n[2]=u,n[3]=h,n[4]=g):g=n[4];let y=v(g),b;n[5]!==y||n[6]!==r?(b=()=>{y(),r()},n[5]=y,n[6]=r,n[7]=b):b=n[7];let w=v(b),T,E;n[8]===w?(T=n[9],E=n[10]):(T=()=>t(w),E=[w],n[8]=w,n[9]=T,n[10]=E),(0,X.useEffect)(T,E);let D;n[11]===y?D=n[12]:(D=()=>{document.visibilityState===`hidden`&&y()},n[11]=y,n[12]=D),_(`visibilitychange`,D,document);let O=u.partialTranscript||a,j;n[13]!==u.error||n[14]!==s||n[15]!==m||n[16]!==p||n[17]!==i||n[18]!==O?(j=f?s&&!p&&!m&&!u.error&&!O?i(`settings.voice.volcengine.silence`):``:i(`settings.voice.volcengine.recordingUnsupported`),n[13]=u.error,n[14]=s,n[15]=m,n[16]=p,n[17]=i,n[18]=O,n[19]=j):j=n[19];let I=j,ee=h?`chat.dictation.retry`:p?`settings.voice.volcengine.finishRecording`:m?`chat.dictation.processing`:`settings.voice.volcengine.startRecording`,L;n[20]!==i||n[21]!==ee?(L=i(ee),n[20]=i,n[21]=ee,n[22]=L):L=n[22];let R=L,te;n[23]!==u||n[24]!==h||n[25]!==m||n[26]!==p?(te=()=>{if(!(m||!f)){if(h){u.retryFailedDictation();return}if(p){c(!0),u.confirmDictation();return}o(``),c(!1),u.startDictation()}},n[23]=u,n[24]=h,n[25]=m,n[26]=p,n[27]=te):te=n[27];let z=v(te),B;n[28]===w?B=n[29]:(B=e=>{e||w()},n[28]=w,n[29]=B);let V;n[30]===i?V=n[31]:(V=i(`settings.voice.volcengine.asrTest`),n[30]=i,n[31]=V);let ne;n[32]===V?ne=n[33]:(ne=(0,Z.jsx)(N,{className:`typography-ui-label font-medium`,children:V}),n[32]=V,n[33]=ne);let H;n[34]===i?H=n[35]:(H=i(`settings.voice.volcengine.testHelp`),n[34]=i,n[35]=H);let U;n[36]===H?U=n[37]:(U=(0,Z.jsx)(P,{className:`sr-only`,children:H}),n[36]=H,n[37]=U);let W;n[38]!==ne||n[39]!==U?(W=(0,Z.jsxs)(A,{className:`items-center pt-2 text-center`,children:[ne,U]}),n[38]=ne,n[39]=U,n[40]=W):W=n[40];let ae;n[41]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,Z.jsx)(`circle`,{cx:`72`,cy:`72`,r:`68`,stroke:`currentColor`,strokeWidth:`0.75`,opacity:`0.12`}),n[41]=ae):ae=n[41];let G=p&&`text-[var(--primary-base)]`,oe;n[42]===G?oe=n[43]:(oe=S(G),n[42]=G,n[43]=oe);let se=p?.5:.18,ce;n[44]!==oe||n[45]!==se?(ce=(0,Z.jsxs)(`svg`,{viewBox:`0 0 144 144`,className:`pointer-events-none absolute inset-0 size-full text-foreground`,fill:`none`,"aria-hidden":`true`,children:[ae,(0,Z.jsx)(`circle`,{cx:`72`,cy:`72`,r:`59`,stroke:`currentColor`,strokeWidth:`0.75`,strokeDasharray:`24 161.35`,strokeLinecap:`round`,transform:`rotate(-102 72 72)`,className:oe,opacity:se})]}),n[44]=oe,n[45]=se,n[46]=ce):ce=n[46];let K=p&&`text-[var(--primary-base)]`,q;n[47]===K?q=n[48]:(q=S(`relative size-28 max-h-full rounded-full !bg-transparent text-foreground shadow-none transition-transform duration-200 hover:scale-105 active:scale-95 motion-reduce:transform-none motion-reduce:transition-none`,K),n[47]=K,n[48]=q);let le=!f||m,ue=m||h?`refresh`:p?`stop`:`mic`,J=m&&`animate-spin motion-reduce:animate-none`,de;n[49]===J?de=n[50]:(de=S(`size-12`,J),n[49]=J,n[50]=de);let Y;n[51]!==ue||n[52]!==de?(Y=(0,Z.jsx)(k,{name:ue,className:de}),n[51]=ue,n[52]=de,n[53]=Y):Y=n[53];let pe;n[54]===R?pe=n[55]:(pe=(0,Z.jsx)(`span`,{className:`sr-only`,children:R}),n[54]=R,n[55]=pe);let me;n[56]!==z||n[57]!==R||n[58]!==p||n[59]!==q||n[60]!==le||n[61]!==Y||n[62]!==pe?(me=(0,Z.jsxs)(C,{variant:`ghost`,size:`icon`,className:q,disabled:le,"aria-label":R,"aria-pressed":p,onClick:z,children:[Y,pe]}),n[56]=z,n[57]=R,n[58]=p,n[59]=q,n[60]=le,n[61]=Y,n[62]=pe,n[63]=me):me=n[63];let Q;n[64]!==ce||n[65]!==me?(Q=(0,Z.jsxs)(`div`,{className:`relative flex size-36 shrink-0 items-center justify-center`,children:[ce,me]}),n[64]=ce,n[65]=me,n[66]=Q):Q=n[66];let he;n[67]!==u.error||n[68]!==R||n[69]!==p||n[70]!==I||n[71]!==O?(he=(0,Z.jsx)(`div`,{className:`flex h-12 w-full shrink-0 items-center justify-center overflow-hidden px-2`,children:u.error?(0,Z.jsx)(`p`,{role:`alert`,className:`max-h-full overflow-y-auto break-words text-center typography-meta text-[var(--status-error)]`,children:u.error}):(0,Z.jsx)(`div`,{role:`log`,"aria-live":`polite`,title:O,className:`line-clamp-2 max-h-full break-words text-center typography-ui-label leading-6 text-muted-foreground`,children:O?p&&O.length>80?`…${O.slice(-80)}`:O:I||R})}),n[67]=u.error,n[68]=R,n[69]=p,n[70]=I,n[71]=O,n[72]=he):he=n[72];let ge;n[73]!==Q||n[74]!==he?(ge=(0,Z.jsxs)(`div`,{className:`flex min-h-0 flex-col items-center justify-center gap-3 overflow-y-auto pt-3`,children:[Q,he]}),n[73]=Q,n[74]=he,n[75]=ge):ge=n[75];let _e;n[76]!==W||n[77]!==ge?(_e=(0,Z.jsxs)(M,{className:`h-[min(19rem,calc(100dvh-2rem))] grid-rows-[auto_minmax(0,1fr)] gap-0 overflow-hidden rounded-3xl sm:max-w-[22rem]`,children:[W,ge]}),n[76]=W,n[77]=ge,n[78]=_e):_e=n[78];let ve;return n[79]!==B||n[80]!==_e?(ve=(0,Z.jsx)(F,{open:!0,onOpenChange:B,children:_e}),n[79]=B,n[80]=_e,n[81]=ve):ve=n[81],ve}var lt=[{value:`seed-tts-2.0`,label:`Seed TTS 2.0`},{value:`seed-icl-2.0`,label:`Seed ICL 2.0`}],ut=[{value:`zh_female_vv_uranus_bigtts`,label:`Vivi 2.0`},{value:`zh_female_xiaohe_uranus_bigtts`,label:`小何 2.0`},{value:`zh_male_m191_uranus_bigtts`,label:`云舟 2.0`},{value:`zh_male_taocheng_uranus_bigtts`,label:`小天 2.0`},{value:`zh_male_liufei_uranus_bigtts`,label:`刘飞 2.0`},{value:`zh_female_sophie_uranus_bigtts`,label:`魅力苏菲 2.0`},{value:`zh_female_qingxinnvsheng_uranus_bigtts`,label:`清新女声 2.0`},{value:`zh_female_cancan_uranus_bigtts`,label:`知性灿灿 2.0`},{value:`zh_female_sajiaoxuemei_uranus_bigtts`,label:`撒娇学妹 2.0`},{value:`zh_female_tianmeixiaoyuan_uranus_bigtts`,label:`甜美小源 2.0`},{value:`zh_female_tianmeitaozi_uranus_bigtts`,label:`甜美桃子 2.0`},{value:`zh_female_shuangkuaisisi_uranus_bigtts`,label:`爽快思思 2.0`},{value:`zh_female_peiqi_uranus_bigtts`,label:`佩奇猪 2.0`},{value:`zh_female_linjianvhai_uranus_bigtts`,label:`邻家女孩 2.0`},{value:`zh_male_shaonianzixin_uranus_bigtts`,label:`少年梓辛 2.0`},{value:`zh_male_sunwukong_uranus_bigtts`,label:`猴哥 2.0`},{value:`zh_female_yingyujiaoxue_uranus_bigtts`,label:`Tina老师 2.0`},{value:`zh_female_kefunvsheng_uranus_bigtts`,label:`暖阳女声 2.0`},{value:`zh_female_xiaoxue_uranus_bigtts`,label:`儿童绘本 2.0`},{value:`zh_male_dayi_uranus_bigtts`,label:`大壹 2.0`},{value:`zh_female_mizai_uranus_bigtts`,label:`黑猫侦探社咪仔 2.0`},{value:`zh_female_jitangnv_uranus_bigtts`,label:`鸡汤女 2.0`},{value:`zh_female_meilinvyou_uranus_bigtts`,label:`魅力女友 2.0`},{value:`zh_female_liuchangnv_uranus_bigtts`,label:`流畅女声 2.0`},{value:`zh_male_ruyayichen_uranus_bigtts`,label:`儒雅逸辰 2.0`},{value:`en_male_tim_uranus_bigtts`,label:`Tim`},{value:`en_female_dacey_uranus_bigtts`,label:`Dacey`},{value:`en_female_stokie_uranus_bigtts`,label:`Stokie`}],dt=`$custom`,ft=[{value:`volc.seedasr.sauc.duration`,label:`Seed ASR 2.0 · duration`},{value:`volc.seedasr.sauc.concurrent`,label:`Seed ASR 2.0 · concurrent`},{value:`volc.bigasr.sauc.duration`,label:`Big ASR 1.0 · duration`},{value:`volc.bigasr.sauc.concurrent`,label:`Big ASR 1.0 · concurrent`}];function pt(e){let t=(0,fe.c)(42),{value:n,onChange:r,options:i,label:a,allowCustom:o,disabled:s}=e,c=o===void 0||o,l=s!==void 0&&s,{t:u}=x(),[d,f]=(0,X.useState)(!1),p;if(t[0]!==i||t[1]!==n){let e;t[3]===n?e=t[4]:(e=e=>e.value===n,t[3]=n,t[4]=e),p=i.some(e),t[0]=i,t[1]=n,t[2]=p}else p=t[2];let m=p,h=c&&(d||!m),g=h?dt:n,_;t[5]===r?_=t[6]:(_=e=>{f(e===dt),e!==dt&&r(e)},t[5]=r,t[6]=_);let v;t[7]!==i||t[8]!==u?(v=(0,Z.jsx)(z,{children:e=>e===dt?u(`settings.voice.volcengine.custom`):i.find(t=>t.value===e)?.label??e}),t[7]=i,t[8]=u,t[9]=v):v=t[9];let y;t[10]!==a||t[11]!==v?(y=(0,Z.jsx)(U,{className:`w-full min-w-0`,"aria-label":a,children:v}),t[10]=a,t[11]=v,t[12]=y):y=t[12];let b;t[13]===i?b=t[14]:(b=i.map(mt),t[13]=i,t[14]=b);let S;t[15]!==c||t[16]!==m||t[17]!==n?(S=!c&&!m&&n&&(0,Z.jsx)(V,{value:n,children:n}),t[15]=c,t[16]=m,t[17]=n,t[18]=S):S=t[18];let C;t[19]!==c||t[20]!==u?(C=c&&(0,Z.jsx)(V,{value:dt,children:u(`settings.voice.volcengine.custom`)}),t[19]=c,t[20]=u,t[21]=C):C=t[21];let w;t[22]!==C||t[23]!==b||t[24]!==S?(w=(0,Z.jsxs)(H,{children:[b,S,C]}),t[22]=C,t[23]=b,t[24]=S,t[25]=w):w=t[25];let T;t[26]!==l||t[27]!==w||t[28]!==g||t[29]!==_||t[30]!==y?(T=(0,Z.jsxs)(W,{disabled:l,value:g,onValueChange:_,children:[y,w]}),t[26]=l,t[27]=w,t[28]=g,t[29]=_,t[30]=y,t[31]=T):T=t[31];let E;t[32]!==h||t[33]!==l||t[34]!==a||t[35]!==r||t[36]!==u||t[37]!==n?(E=h&&(0,Z.jsx)(I,{disabled:l,value:n,onChange:e=>r(e.target.value),"aria-label":`${a} (${u(`settings.voice.volcengine.custom`)})`}),t[32]=h,t[33]=l,t[34]=a,t[35]=r,t[36]=u,t[37]=n,t[38]=E):E=t[38];let D;return t[39]!==T||t[40]!==E?(D=(0,Z.jsxs)(`div`,{className:`flex w-full min-w-0 flex-col items-end gap-2`,children:[T,E]}),t[39]=T,t[40]=E,t[41]=D):D=t[41],D}function mt(e){return(0,Z.jsx)(V,{value:e.value,children:(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Z.jsx)(`span`,{children:e.label}),(0,Z.jsx)(`span`,{className:`break-all typography-meta text-muted-foreground`,children:e.description??e.value})]})},e.value)}function ht(e){let t=(0,fe.c)(42),{mode:n,form:r,showCredentials:i}=e,a=i===void 0||i,{t:o}=x(),s=(0,X.useRef)(!0),c,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=()=>(s.current=!0,()=>{s.current=!1}),l=[],t[0]=c,t[1]=l):(c=t[0],l=t[1]),(0,X.useEffect)(c,l);let{values:u,draft:d,saving:f,edit:p,save:m}=r,{voice:h,resourceId:_,asrResourceId:v}=u,y;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(y={enabled:!1},t[2]=y):y=t[2];let{speak:b,stop:S,isPlaying:w,error:T}=ce(y),[E,D]=(0,X.useState)(!1),O;t[3]!==w||t[4]!==n||t[5]!==m||t[6]!==f||t[7]!==b||t[8]!==S||t[9]!==o?(O=async()=>{if(n===`tts`&&w){S();return}if(f)return;let e=await m();if(!(!e||!s.current)){if(!e.configured){g.error(o(`settings.providers.page.toast.apiKeyRequired`));return}n===`asr`?D(!0):b(o(`settings.voice.page.preview.voiceLine`,{voiceName:`Yuri`}))}},t[3]=w,t[4]=n,t[5]=m,t[6]=f,t[7]=b,t[8]=S,t[9]=o,t[10]=O):O=t[10];let k=O,A;t[11]!==d||t[12]!==p||t[13]!==n||t[14]!==f||t[15]!==u.configured||t[16]!==a||t[17]!==o?(A=a&&(0,Z.jsx)(Y,{itemId:`voice.volcengine-${n}-key`,label:o(`settings.voice.page.field.apiKey`),description:(0,Z.jsxs)(Z.Fragment,{children:[o(`settings.voice.volcengine.keyHelp`),` `,(0,Z.jsx)(`a`,{href:`https://console.volcengine.com/speech/new`,target:`_blank`,rel:`noreferrer`,className:`text-primary underline`,children:o(`settings.voice.volcengine.openLink`)})]}),children:(0,Z.jsx)(I,{type:`password`,autoComplete:`off`,disabled:f,placeholder:u.configured&&d.apiKey===void 0?`••••••••`:`API Key`,value:d.apiKey??``,onChange:e=>p({apiKey:e.target.value}),"aria-label":o(`settings.voice.page.field.apiKey`)})}),t[11]=d,t[12]=p,t[13]=n,t[14]=f,t[15]=u.configured,t[16]=a,t[17]=o,t[18]=A):A=t[18];let j;t[19]!==p||t[20]!==T||t[21]!==w||t[22]!==n||t[23]!==_||t[24]!==f||t[25]!==o||t[26]!==k||t[27]!==h?(j=n===`tts`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Y,{itemId:`voice.volcengine-resource`,label:o(`settings.voice.volcengine.resource`),children:(0,Z.jsx)(pt,{value:_,disabled:f,onChange:e=>p({resourceId:e}),options:lt,label:o(`settings.voice.volcengine.resource`)})}),(0,Z.jsx)(Y,{itemId:`voice.volcengine-speaker`,label:o(`settings.voice.volcengine.speaker`),children:(0,Z.jsx)(pt,{value:h,disabled:f,onChange:e=>p({voice:e}),options:_===`seed-tts-2.0`?ut:[],label:o(`settings.voice.volcengine.speaker`)},_)}),(0,Z.jsxs)(Y,{label:o(`settings.voice.page.actions.preview`),children:[(0,Z.jsx)(C,{variant:`outline`,size:`sm`,disabled:!w&&f,"aria-busy":f,onClick:()=>void k(),children:o(w?`settings.voice.volcengine.stop`:`settings.voice.page.actions.preview`)}),T&&(0,Z.jsx)(`span`,{role:`alert`,className:`text-[var(--status-error)]`,children:T})]})]}),t[19]=p,t[20]=T,t[21]=w,t[22]=n,t[23]=_,t[24]=f,t[25]=o,t[26]=k,t[27]=h,t[28]=j):j=t[28];let M;t[29]!==v||t[30]!==p||t[31]!==n||t[32]!==f||t[33]!==u.asrContext||t[34]!==o||t[35]!==k||t[36]!==E?(M=n===`asr`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Y,{itemId:`voice.volcengine-asr-resource`,label:o(`settings.voice.volcengine.asrResource`),children:(0,Z.jsx)(pt,{value:v,disabled:f,onChange:e=>p({asrResourceId:e}),options:ft.map(e=>({...e,description:o(e.value.endsWith(`.duration`)?`settings.voice.volcengine.durationHelp`:`settings.voice.volcengine.concurrentHelp`)})),label:o(`settings.voice.volcengine.asrResource`),allowCustom:!1})}),(0,Z.jsx)(Y,{itemId:`voice.volcengine-asr-context`,className:`yuri-settings-split-row-stacked`,controlClassName:`!w-full !max-w-none`,label:o(`settings.voice.volcengine.asrContext`),description:o(`settings.voice.volcengine.asrContextHelp`),children:(0,Z.jsx)(G,{rows:5,maxLength:2e3,disabled:f,value:u.asrContext,onChange:e=>p({asrContext:e.target.value}),"aria-label":o(`settings.voice.volcengine.asrContext`)})}),(0,Z.jsx)(Y,{itemId:`voice.volcengine-asr-test`,label:o(`settings.voice.volcengine.asrTest`),description:o(`settings.voice.volcengine.testHelp`),children:(0,Z.jsx)(C,{variant:`outline`,size:`sm`,disabled:f,"aria-busy":f,onClick:()=>void k(),children:o(`settings.voice.volcengine.asrTest`)})}),E&&(0,Z.jsx)(ct,{onClose:()=>D(!1)})]}),t[29]=v,t[30]=p,t[31]=n,t[32]=f,t[33]=u.asrContext,t[34]=o,t[35]=k,t[36]=E,t[37]=M):M=t[37];let N;return t[38]!==A||t[39]!==j||t[40]!==M?(N=(0,Z.jsxs)(Z.Fragment,{children:[A,j,M]}),t[38]=A,t[39]=j,t[40]=M,t[41]=N):N=t[41],N}function gt(e,t={}){let{t:i}=x(),[a,o]=(0,X.useState)(()=>t),s=(0,X.useRef)(!0);(0,X.useEffect)(()=>(s.current=!0,()=>{s.current=!1}),[]);let c=f({mutationFn:({patch:e,generation:t,transport:n})=>q(e,t,n),networkMode:`always`,retry:!1,gcTime:0}),l=async()=>{if(c.isPending)return null;let e=r(),t=a;try{let i=await c.mutateAsync({patch:a,generation:e,transport:n()});return!s.current||e!==r()?null:(o(e=>e===t?{}:Object.fromEntries(Object.entries(e).filter(([e,n])=>!Object.is(n,t[e])))),i)}catch{return s.current&&e===r()&&g.error(i(`settings.voice.volcengine.saveFailed`)),null}finally{c.reset()}};return{values:{...e,...a},draft:a,saving:c.isPending,edit:e=>o(t=>({...t,...e})),save:l}}var _t=[{id:`parakeet-tdt-0.6b-v2-int8`,labelKey:`settings.voice.page.stt.model.parakeetV2`,badgeKey:`settings.voice.page.stt.badge.bestForEnglish`,accuracy:5,speed:5,size:`460 MB`},{id:`parakeet-tdt-0.6b-v3-int8`,labelKey:`settings.voice.page.stt.model.parakeetV3`,badgeKey:`settings.voice.page.stt.badge.bestForMultilingual`,accuracy:5,speed:4,size:`465 MB`},{id:`whisper-base-int8`,labelKey:`settings.voice.page.stt.model.whisperBase`,badgeKey:null,accuracy:3,speed:3,size:`200 MB`},{id:`whisper-tiny-int8`,labelKey:`settings.voice.page.stt.model.whisperTiny`,badgeKey:null,accuracy:2,speed:4,size:`115 MB`}],vt=e=>{let t=(0,fe.c)(8),{value:n,label:r}=e,i=`${r}: ${n}/5`,a=`${n/5*100}%`,o;t[0]===a?o=t[1]:(o=(0,Z.jsx)(`span`,{className:`h-1.5 w-12 flex-shrink-0 overflow-hidden rounded-full bg-[var(--interactive-border)]`,"aria-hidden":`true`,children:(0,Z.jsx)(`span`,{className:`block h-full rounded-full bg-[var(--primary-base)]`,style:{width:a}})}),t[0]=a,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,Z.jsx)(`span`,{className:`typography-ui-compact text-muted-foreground`,children:r}),t[2]=r,t[3]=s);let c;return t[4]!==i||t[5]!==o||t[6]!==s?(c=(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,title:i,children:[o,s]}),t[4]=i,t[5]=o,t[6]=s,t[7]=c):c=t[7],c},yt=({selectedModelId:e,onSelect:t})=>{let{t:n}=x(),r=(0,X.useCallback)(e=>n(e),[n]),[a,o]=(0,X.useState)(new Map),[s,c]=(0,X.useState)(null),l=(0,X.useCallback)(async()=>{try{let e=await i(`/api/dictation/status`,{query:{provider:`local`}});if(!e.ok)return;let t=await e.json();Array.isArray(t?.models)&&o(new Map(t.models.map(e=>[e.id,e])))}catch{}},[]);(0,X.useEffect)(()=>{l()},[l]);let u=Array.from(a.values()).some(e=>e.downloading);(0,X.useEffect)(()=>{if(!u)return;let e=setInterval(()=>{l()},2e3);return()=>clearInterval(e)},[u,l]);let d=async e=>{c(e);try{await i(`/api/dictation/models/${encodeURIComponent(e)}/download`,{method:`POST`}),await l()}catch{}finally{c(null)}},f=async e=>{c(e);try{await i(`/api/dictation/models/${encodeURIComponent(e)}`,{method:`DELETE`}),await l()}catch{}finally{c(null)}};return(0,Z.jsx)(`div`,{role:`radiogroup`,"aria-label":n(`settings.voice.page.field.model`),className:`mt-1 w-full min-w-0 space-y-0`,children:_t.map(i=>{let o=e===i.id,c=a.get(i.id)??null;return(0,Z.jsxs)(`div`,{className:`flex w-full items-start gap-2 py-1.5`,children:[(0,Z.jsx)(`div`,{className:`pt-0.5`,children:(0,Z.jsx)(pe,{checked:o,onChange:()=>t(i.id),ariaLabel:r(i.labelKey)})}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 cursor-pointer`,role:`button`,tabIndex:0,onClick:()=>t(i.id),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),t(i.id))},children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[(0,Z.jsx)(`span`,{className:S(`typography-ui-label font-normal`,o?`text-foreground`:`text-foreground/50`),children:r(i.labelKey)}),i.badgeKey?(0,Z.jsx)(`span`,{className:`rounded px-1 text-[9px] font-medium uppercase leading-[14px] tracking-wide`,style:{backgroundColor:`var(--status-success-background)`,color:`var(--status-success)`,border:`1px solid var(--status-success-border)`},children:r(i.badgeKey)}):null]}),(0,Z.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-x-4 gap-y-0.5`,children:[(0,Z.jsx)(vt,{value:i.accuracy,label:n(`settings.voice.page.stt.meta.accuracy`)}),(0,Z.jsx)(vt,{value:i.speed,label:n(`settings.voice.page.stt.meta.speed`)}),(0,Z.jsx)(`span`,{className:`typography-ui-compact tabular-nums text-muted-foreground`,children:i.size})]}),c?.downloadError?(0,Z.jsx)(`p`,{className:`mt-0.5 typography-meta text-[var(--status-error)]`,children:c.downloadError}):null]}),(0,Z.jsx)(`div`,{className:`flex w-14 flex-shrink-0 items-center justify-end gap-1 pt-0.5`,children:c?.installed?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(C,{variant:`ghost`,size:`xs`,className:`h-6 w-6 p-0 text-muted-foreground hover:text-[var(--status-error)]`,disabled:s===i.id,onClick:()=>{f(i.id)},title:n(`settings.voice.page.stt.modelDelete`),"aria-label":n(`settings.voice.page.stt.modelDelete`),children:(0,Z.jsx)(k,{name:`delete-bin`,className:`h-4 w-4`})}),(0,Z.jsx)(k,{name:`checkbox-circle`,className:`h-4 w-4 flex-shrink-0 text-[var(--status-success)]`,"aria-label":n(`settings.voice.page.stt.modelInstalled`)})]}):c?.downloading?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(k,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`typography-ui-compact tabular-nums text-muted-foreground`,children:typeof c.downloadProgress==`number`?`${c.downloadProgress}%`:``})]}):(0,Z.jsx)(C,{variant:`ghost`,size:`xs`,className:`h-6 w-6 p-0`,disabled:s===i.id,onClick:()=>{d(i.id)},title:n(`settings.voice.page.stt.modelDownload`),"aria-label":n(`settings.voice.page.stt.modelDownload`),children:(0,Z.jsx)(k,{name:`download`,className:`h-4 w-4`})})})]},i.id)})})},bt=[{id:0,label:`Alloy (af)`},{id:1,label:`Bella (af)`},{id:2,label:`Nicole (af)`},{id:3,label:`Sarah (af)`},{id:4,label:`Sky (af)`},{id:5,label:`Adam (am)`},{id:6,label:`Michael (am)`},{id:7,label:`Emma (bf)`},{id:8,label:`Isabella (bf)`},{id:9,label:`George (bm)`},{id:10,label:`Lewis (bm)`}],xt=`kokoro-en-v0_19`,St=()=>{let{t:e}=x(),[t,n]=(0,X.useState)(null),[r,a]=(0,X.useState)(!1),o=(0,X.useCallback)(async()=>{try{let e=await i(`/api/dictation/status`,{query:{provider:`local`}});if(!e.ok)return;let t=await e.json(),r=Array.isArray(t?.ttsModels)?t.ttsModels.find(e=>e.id===xt):null;r&&n(r)}catch{}},[]);(0,X.useEffect)(()=>{o()},[o]),(0,X.useEffect)(()=>{if(!t?.downloading)return;let e=setInterval(()=>{o()},2e3);return()=>clearInterval(e)},[t?.downloading,o]);let s=async e=>{a(!0);try{await i(e===`POST`?`/api/dictation/models/${xt}/download`:`/api/dictation/models/${xt}`,{method:e}),await o()}catch{}finally{a(!1)}};return t?(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 py-1.5`,children:[(0,Z.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:`Kokoro`}),(0,Z.jsx)(`span`,{className:`typography-ui-compact tabular-nums text-muted-foreground`,children:`305 MB`}),t.installed?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(k,{name:`checkbox-circle`,className:`h-4 w-4 text-[var(--status-success)]`,"aria-label":e(`settings.voice.page.stt.modelInstalled`)}),(0,Z.jsx)(C,{variant:`ghost`,size:`xs`,className:`h-6 w-6 p-0 text-muted-foreground hover:text-[var(--status-error)]`,disabled:r,onClick:()=>{s(`DELETE`)},title:e(`settings.voice.page.stt.modelDelete`),"aria-label":e(`settings.voice.page.stt.modelDelete`),children:(0,Z.jsx)(k,{name:`delete-bin`,className:`h-4 w-4`})})]}):t.downloading?(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(k,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin text-muted-foreground`}),(0,Z.jsx)(`span`,{className:`typography-ui-compact tabular-nums text-muted-foreground`,children:typeof t.downloadProgress==`number`?`${t.downloadProgress}%`:``})]}):(0,Z.jsx)(C,{variant:`ghost`,size:`xs`,className:`h-6 w-6 p-0`,disabled:r,onClick:()=>{s(`POST`)},title:e(`settings.voice.page.stt.modelDownload`),"aria-label":e(`settings.voice.page.stt.modelDownload`),children:(0,Z.jsx)(k,{name:`download`,className:`h-4 w-4`})}),t.downloadError?(0,Z.jsx)(`span`,{className:`typography-meta text-[var(--status-error)]`,children:t.downloadError}):null]}):null},Ct=[{value:`alloy`,label:`Alloy`},{value:`ash`,label:`Ash`},{value:`ballad`,label:`Ballad`},{value:`coral`,label:`Coral`},{value:`echo`,label:`Echo`},{value:`fable`,label:`Fable`},{value:`nova`,label:`Nova`},{value:`onyx`,label:`Onyx`},{value:`sage`,label:`Sage`},{value:`shimmer`,label:`Shimmer`},{value:`verse`,label:`Verse`},{value:`marin`,label:`Marin`},{value:`cedar`,label:`Cedar`}],wt=e=>{let n=(0,fe.c)(3),{section:i}=e,a=`${(0,X.useSyncExternalStore)(t,r,r)}:${i??`all`}`,o;return n[0]!==i||n[1]!==a?(o=(0,Z.jsx)(Tt,{section:i},a),n[0]=i,n[1]=a,n[2]=o):o=n[2],o};function Tt(e){let t=(0,fe.c)(9),{section:n}=e,{t:r}=x(),i=K(),a;t[0]!==i||t[1]!==r?(a=i.isError&&(0,Z.jsx)(Y,{label:r(`settings.voice.volcengine.loadFailed`),children:(0,Z.jsx)(C,{variant:`outline`,size:`sm`,onClick:()=>void i.refetch(),children:r(`settings.voice.volcengine.retry`)})}),t[0]=i,t[1]=r,t[2]=a):a=t[2];let o=i.data??T,s;t[3]!==n||t[4]!==o?(s=(0,Z.jsx)(Et,{settings:o,section:n}),t[3]=n,t[4]=o,t[5]=s):s=t[5];let c;return t[6]!==a||t[7]!==s?(c=(0,Z.jsxs)(Z.Fragment,{children:[a,s]}),t[6]=a,t[7]=s,t[8]=c):c=t[8],c}var Et=({settings:e,section:t})=>{let{t:n}=x(),{isMobile:r}=te(),a=gt(e),o=gt(e),{voiceProvider:s,speechRate:c,speechPitch:l,speechVolume:u,sayVoice:d,localTtsVoiceId:f,browserVoice:p,openaiVoice:m,openaiApiKey:h,openaiCompatibleUrl:g,openaiCompatibleApiKey:_,openaiCompatibleVoice:y,openaiCompatibleTtsModel:b,showMessageTTSButtons:w,ttsInputMode:T}=a.values,{sttProvider:E,sttServerUrl:D,sttApiKey:O,sttModel:A,sttLocalModel:j,sttLanguage:M,dictationEnabled:N}=o.values,P=e=>a.edit({voiceProvider:e}),F=e=>a.edit({speechRate:e}),B=e=>a.edit({speechPitch:e}),ne=e=>a.edit({speechVolume:e}),re=e=>a.edit({sayVoice:e}),ie=e=>a.edit({localTtsVoiceId:e}),ae=e=>a.edit({browserVoice:e}),G=e=>a.edit({openaiVoice:e}),ce=e=>a.edit({openaiApiKey:e}),K=e=>a.edit({openaiCompatibleUrl:e}),q=e=>a.edit({openaiCompatibleApiKey:e}),J=e=>a.edit({openaiCompatibleVoice:e}),de=e=>a.edit({openaiCompatibleTtsModel:e}),fe=e=>a.edit({ttsInputMode:e}),pe=e=>a.edit({showMessageTTSButtons:e}),me=e=>o.edit({dictationEnabled:e}),Q=e=>o.edit({sttProvider:e}),he=e=>o.edit({sttServerUrl:e}),ge=e=>o.edit({sttApiKey:e}),_e=e=>o.edit({sttModel:e}),ve=e=>o.edit({sttLocalModel:e}),be=e=>o.edit({sttLanguage:e}),{speak:xe,stop:Se,isPlaying:Ce,error:we}=oe(),Te=v(async()=>{if(Ce){Se();return}if(!await a.save())return;let e=bt.find(e=>e.id===f)?.label??String(f);xe(n(`settings.voice.page.preview.voiceLine`,{voiceName:e}))}),[Ee,De]=(0,X.useState)(!1),[Oe,ke]=(0,X.useState)([]),[Ae,je]=(0,X.useState)(!1),[Me,Ne]=(0,X.useState)(null),[Pe,Fe]=(0,X.useState)(!1),[Ie,$]=(0,X.useState)(!1),[Le,Re]=(0,X.useState)(null),[ze,Be]=(0,X.useState)(!1),[Ve,He]=(0,X.useState)(null),[Ue,We]=(0,X.useState)([]),[Ge,Ke]=(0,X.useState)(!1);(0,X.useEffect)(()=>((async()=>{let e=await se.waitForVoices();We(e)})(),`speechSynthesis`in window&&(window.speechSynthesis.onvoiceschanged=()=>{We(window.speechSynthesis.getVoices())}),()=>{`speechSynthesis`in window&&(window.speechSynthesis.onvoiceschanged=null)}),[]);let qe=(0,X.useMemo)(()=>Ue.filter(e=>e.lang).sort((e,t)=>{let n=e.lang.startsWith(`en`),r=t.lang.startsWith(`en`);if(n&&!r)return-1;if(!n&&r)return 1;let i=e.lang.localeCompare(t.lang);return i===0?e.name.localeCompare(t.name):i}),[Ue]),Je=v(async()=>{if(Ge){se.cancelSpeech(),Ke(!1);return}if(!await a.save())return;let e=Ue.find(e=>e.name===p),t=e?.name??n(`settings.voice.page.preview.browserVoiceFallback`),r=n(`settings.voice.page.preview.voiceLine`,{voiceName:t});Ke(!0);let i=new SpeechSynthesisUtterance(r);i.rate=c,i.pitch=l,i.volume=u,e&&(i.voice=e,i.lang=e.lang),i.onend=()=>Ke(!1),i.onerror=()=>Ke(!1),window.speechSynthesis.cancel(),window.speechSynthesis.speak(i)});(0,X.useEffect)(()=>()=>{Ge&&se.cancelSpeech()},[Ge]),(0,X.useEffect)(()=>{if(!w||s!==`openai`&&s!==`openai-compatible`){Fe(h.trim().length>0||e.openaiApiKeyConfigured);return}(async()=>{try{let t=(await(await i(`/api/tts/status`)).json()).available,n=h.trim().length>0||e.openaiApiKeyConfigured;Fe(t||n)}catch{Fe(h.trim().length>0||e.openaiApiKeyConfigured)}})()},[h,e.openaiApiKeyConfigured,w,s]),(0,X.useEffect)(()=>{if(!w){De(!1),ke([]);return}i(`/api/tts/say/status`).then(e=>e.json()).then(e=>{if(De(e.available),e.voices){let t=e.voices.filter((e,t,n)=>n.findIndex(t=>t.name===e.name)===t).sort((e,t)=>e.name.localeCompare(t.name));ke(t)}}).catch(()=>{De(!1)})},[w]);let Ye=v(async()=>{if(Me){st(Me),Ne(null),je(!1);return}if(!await a.save())return;je(!0);let e=null;try{let t=await i(`/api/tts/say/speak`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:n(`settings.voice.page.preview.voiceLine`,{voiceName:d})})});if(!t.ok)throw Error(`Preview failed`);let r=await t.blob(),a=URL.createObjectURL(r);e=new Audio(a),e.onended=()=>{st(e),Ne(null),je(!1)},e.onerror=()=>{st(e),Ne(null),je(!1)},Ne(e),await e.play()}catch{st(e),Ne(null),je(!1)}});(0,X.useEffect)(()=>()=>{st(Me)},[Me]);let Xe=v(async()=>{if(Le){st(Le),Re(null),$(!1);return}if(!await a.save())return;$(!0);let e=null;try{let t=await i(`/api/tts/speak`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:n(`settings.voice.page.preview.voiceLine`,{voiceName:m})})});if(!t.ok){let e=await t.json().catch(()=>({error:`Unknown error`}));throw Error(e.error||`HTTP ${t.status}`)}let r=await t.blob(),a=URL.createObjectURL(r);e=new Audio(a),e.onended=()=>{st(e),Re(null),$(!1)},e.onerror=()=>{st(e),Re(null),$(!1)},Re(e),await e.play()}catch{st(e),Re(null),$(!1)}});(0,X.useEffect)(()=>()=>{st(Le)},[Le]);let Ze=v(async()=>{if(Ve){st(Ve),He(null),Be(!1);return}if(!g.trim()||!await a.save())return;Be(!0);let e=null;try{let t=await i(`/api/tts/speak`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:n(`settings.voice.page.preview.customServerLine`)})});if(!t.ok){let e=await t.json().catch(()=>({error:`Unknown error`}));throw Error(e.error||`HTTP ${t.status}`)}let r=await t.blob(),a=URL.createObjectURL(r);e=new Audio(a),e.onended=()=>{st(e),He(null),Be(!1)},e.onerror=()=>{st(e),He(null),Be(!1)},He(e),await e.play()}catch{st(e),He(null),Be(!1)}});(0,X.useEffect)(()=>()=>{st(Ve)},[Ve]);let Qe=`flex-1 min-w-0 h-1.5 bg-[var(--interactive-border)] rounded-full appearance-none cursor-pointer [&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-[var(--primary-base)] [&::-moz-range-thumb]:w-4 [&::-moz-range-thumb]:h-4 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:bg-[var(--primary-base)] [&::-moz-range-thumb]:border-0 disabled:opacity-50`;return(0,Z.jsxs)(`div`,{className:`yuri-settings-section-stack`,children:[!t&&(0,Z.jsx)(`div`,{className:`space-y-1`,children:(0,Z.jsx)(`h2`,{className:`typography-ui-header font-semibold text-foreground`,children:n(`settings.page.voice.title`)})}),t!==`asr`&&(0,Z.jsx)(`div`,{"data-settings-item":`voice.playback`,children:(0,Z.jsxs)(le,{label:n(`settings.voice.page.section.playbackAndSummary`),actions:(0,Z.jsx)(C,{size:`sm`,disabled:a.saving,"aria-busy":a.saving,onClick:()=>{a.saving||a.save()},children:n(`settings.voice.volcengine.save`)}),children:[(0,Z.jsx)(Y,{label:n(`settings.voice.page.field.messageReadAloudButton`),children:(0,Z.jsx)(ue,{checked:w,onChange:pe,ariaLabel:n(`settings.voice.page.field.messageReadAloudButtonAria`)})}),w&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Y,{label:(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{children:n(`settings.voice.page.field.provider`)}),(0,Z.jsxs)(R,{children:[(0,Z.jsx)(ee,{asChild:!0,children:(0,Z.jsx)(k,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,Z.jsx)(L,{sideOffset:8,className:`max-w-xs`,children:(0,Z.jsxs)(`ul`,{className:`space-y-1`,children:[(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`strong`,{children:n(`settings.voice.page.provider.browser`)}),` `,n(`settings.voice.page.tooltip.browser`)]}),(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`strong`,{children:n(`settings.voice.page.provider.local`)}),` `,n(`settings.voice.page.tooltip.localTts`)]}),(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`strong`,{children:`OpenAI:`}),` `,n(`settings.voice.page.tooltip.openai`)]}),(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`strong`,{children:n(`settings.voice.page.provider.custom`)}),` `,n(`settings.voice.page.tooltip.custom`)]}),(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`strong`,{children:n(`settings.voice.page.provider.say`)}),` `,n(`settings.voice.page.tooltip.say`)]})]})})]})]}),children:(0,Z.jsxs)(W,{value:s,onValueChange:e=>{(e===`browser`||e===`local`||e===`openai`||e===`openai-compatible`||e===`volcengine`||e===`say`&&Ee)&&P(e)},children:[(0,Z.jsx)(U,{"aria-label":n(`settings.voice.page.field.provider`),children:(0,Z.jsx)(z,{children:{browser:n(`settings.voice.page.provider.browser`),volcengine:n(`settings.voice.volcengine.providerOption`),local:n(`settings.voice.page.provider.local`),openai:`OpenAI`,"openai-compatible":n(`settings.voice.page.provider.custom`),say:n(`settings.voice.page.provider.say`)}[s]})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(V,{value:`volcengine`,children:n(`settings.voice.volcengine.providerOption`)}),(0,Z.jsx)(V,{value:`browser`,children:n(`settings.voice.page.provider.browser`)}),(0,Z.jsx)(V,{value:`local`,children:n(`settings.voice.page.provider.local`)}),(0,Z.jsx)(V,{value:`openai`,children:`OpenAI`}),(0,Z.jsx)(V,{value:`openai-compatible`,children:n(`settings.voice.page.provider.custom`)}),Ee&&(0,Z.jsx)(V,{value:`say`,children:n(`settings.voice.page.provider.say`)})]})]})}),s===`volcengine`&&(0,Z.jsx)(ht,{mode:`tts`,form:a}),s===`openai`&&(0,Z.jsx)(Y,{label:(0,Z.jsx)(`span`,{className:S(!Pe&&`text-[var(--status-error)]`),children:n(`settings.voice.page.field.apiKey`)}),description:(0,Z.jsx)(`span`,{className:S(!Pe&&`text-[var(--status-error)]/80`),children:n(Pe&&!h?`settings.voice.page.field.apiKeyHintUsingConfig`:Pe?`settings.voice.page.field.apiKeyHintProvide`:`settings.voice.page.field.apiKeyHintRequired`)}),children:(0,Z.jsxs)(`div`,{className:`relative w-full`,children:[(0,Z.jsx)(I,{type:`password`,value:h,onChange:e=>ce(e.target.value),placeholder:e.openaiApiKeyConfigured&&a.draft.openaiApiKey===void 0?`••••••••`:`sk-...`,className:`w-full pr-8`}),h&&(0,Z.jsx)(`button`,{type:`button`,onClick:()=>ce(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,Z.jsx)(k,{name:`close`,className:`w-3.5 h-3.5`})})]})}),s===`openai-compatible`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Y,{label:(0,Z.jsx)(`span`,{className:S(!g.trim()&&`text-[var(--status-error)]`),children:n(`settings.voice.page.field.serverUrl`)}),description:n(`settings.voice.page.field.serverUrlHint`),children:(0,Z.jsxs)(`div`,{className:`relative w-full`,children:[(0,Z.jsx)(I,{type:`text`,value:g,onChange:e=>K(e.target.value),placeholder:`http://localhost:8880/v1`,className:`w-full pr-8`}),g&&(0,Z.jsx)(`button`,{type:`button`,onClick:()=>K(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,Z.jsx)(k,{name:`close`,className:`w-3.5 h-3.5`})})]})}),(0,Z.jsx)(Y,{label:`API Key`,description:`Optional`,children:(0,Z.jsxs)(`div`,{className:`relative w-full`,children:[(0,Z.jsx)(I,{type:`password`,value:_,onChange:e=>q(e.target.value),placeholder:e.openaiCompatibleApiKeyConfigured&&a.draft.openaiCompatibleApiKey===void 0?`••••••••`:`sk-...`,className:`w-full pr-8`}),_&&(0,Z.jsx)(`button`,{type:`button`,onClick:()=>q(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,Z.jsx)(k,{name:`close`,className:`w-3.5 h-3.5`})})]})}),(0,Z.jsx)(Y,{label:n(`settings.voice.page.field.model`),children:(0,Z.jsx)(`div`,{className:`relative w-full`,children:(0,Z.jsx)(I,{type:`text`,value:b,onChange:e=>de(e.target.value),placeholder:`speaches-ai/Kokoro-82M-v1.0-ONNX`,className:`w-full`})})}),(0,Z.jsx)(Y,{label:n(`settings.voice.page.field.voice`),description:n(`settings.voice.page.field.voiceIdentifierHint`),children:(0,Z.jsxs)(`div`,{className:`flex w-full items-center gap-2`,children:[(0,Z.jsx)(`div`,{className:`relative min-w-0 flex-1`,children:(0,Z.jsx)(I,{type:`text`,value:y,onChange:e=>J(e.target.value),placeholder:`af_sky`,className:`w-full`})}),(0,Z.jsx)(C,{size:`xs`,variant:`ghost`,onClick:Ze,title:n(`settings.voice.page.actions.preview`),disabled:!g.trim(),children:ze?(0,Z.jsx)(k,{name:`stop`,className:`w-3.5 h-3.5`}):(0,Z.jsx)(k,{name:`play`,className:`w-3.5 h-3.5`})})]})})]}),s===`local`&&(0,Z.jsx)(St,{}),s!==`volcengine`&&(0,Z.jsxs)(Y,{label:n(`settings.voice.page.field.voice`),children:[s===`local`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(W,{value:String(f),onValueChange:e=>ie(Number.parseInt(e,10)||0),children:[(0,Z.jsx)(U,{className:`w-fit`,children:(0,Z.jsx)(z,{placeholder:n(`settings.voice.page.field.selectVoicePlaceholder`),children:e=>bt.find(t=>String(t.id)===e)?.label??e})}),(0,Z.jsx)(H,{children:bt.map(e=>(0,Z.jsx)(V,{value:String(e.id),children:e.label},e.id))})]}),(0,Z.jsx)(C,{size:`xs`,variant:`ghost`,onClick:Te,title:n(`settings.voice.page.actions.preview`),children:Ce?(0,Z.jsx)(k,{name:`stop`,className:`w-3.5 h-3.5`}):(0,Z.jsx)(k,{name:`play`,className:`w-3.5 h-3.5`})}),we?(0,Z.jsx)(`span`,{className:`typography-meta text-[var(--status-error)]`,children:we}):null]}),s===`openai`&&Pe&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(W,{value:m,onValueChange:G,children:[(0,Z.jsx)(U,{className:`w-fit`,children:(0,Z.jsx)(z,{placeholder:n(`settings.voice.page.field.selectVoicePlaceholder`)})}),(0,Z.jsx)(H,{children:Ct.map(e=>(0,Z.jsx)(V,{value:e.value,children:e.label},e.value))})]}),(0,Z.jsx)(C,{size:`xs`,variant:`ghost`,onClick:Xe,title:n(`settings.voice.page.actions.preview`),children:Ie?(0,Z.jsx)(k,{name:`stop`,className:`w-3.5 h-3.5`}):(0,Z.jsx)(k,{name:`play`,className:`w-3.5 h-3.5`})})]}),s===`openai-compatible`&&(0,Z.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:n(`settings.voice.page.field.configuredAbove`)}),s===`say`&&Ee&&Oe.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(W,{value:d,onValueChange:re,children:[(0,Z.jsx)(U,{className:`w-fit`,children:(0,Z.jsx)(z,{placeholder:n(`settings.voice.page.field.selectVoicePlaceholder`)})}),(0,Z.jsx)(H,{children:Oe.map(e=>(0,Z.jsx)(V,{value:e.name,children:e.name},e.name))})]}),(0,Z.jsx)(C,{size:`xs`,variant:`ghost`,onClick:Ye,title:n(`settings.voice.page.actions.preview`),children:Ae?(0,Z.jsx)(k,{name:`stop`,className:`w-3.5 h-3.5`}):(0,Z.jsx)(k,{name:`play`,className:`w-3.5 h-3.5`})})]}),s===`browser`&&qe.length>0&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(W,{value:p||`$auto`,onValueChange:e=>ae(e===`$auto`?``:e),children:[(0,Z.jsx)(U,{className:`w-fit max-w-[200px]`,children:(0,Z.jsx)(z,{placeholder:n(`settings.voice.page.field.auto`)})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(V,{value:`$auto`,children:n(`settings.voice.page.field.auto`)}),qe.map(e=>(0,Z.jsxs)(V,{value:e.name,children:[e.name,` (`,e.lang,`)`]},e.name))]})]}),(0,Z.jsx)(C,{size:`xs`,variant:`ghost`,onClick:Je,title:n(`settings.voice.page.actions.preview`),children:Ge?(0,Z.jsx)(k,{name:`stop`,className:`w-3.5 h-3.5`}):(0,Z.jsx)(k,{name:`play`,className:`w-3.5 h-3.5`})})]})]}),(0,Z.jsxs)(Y,{label:n(`settings.voice.page.field.speechRate`),children:[!r&&(0,Z.jsx)(`input`,{type:`range`,min:.5,max:2,step:.1,value:c,onChange:e=>F(Number(e.target.value)),className:Qe}),(0,Z.jsx)(ye,{value:c,onValueChange:F,min:.5,max:2,step:.1,className:`w-16 tabular-nums`})]}),(0,Z.jsxs)(Y,{label:n(`settings.voice.page.field.speechPitch`),children:[!r&&(0,Z.jsx)(`input`,{type:`range`,min:.5,max:2,step:.1,value:l,onChange:e=>B(Number(e.target.value)),className:Qe}),(0,Z.jsx)(ye,{value:l,onValueChange:B,min:.5,max:2,step:.1,className:`w-16 tabular-nums`})]}),(0,Z.jsxs)(Y,{label:n(`settings.voice.page.field.speechVolume`),children:[!r&&(0,Z.jsx)(`input`,{type:`range`,min:0,max:1,step:.1,value:u,onChange:e=>ne(Number(e.target.value)),className:Qe}),r?(0,Z.jsx)(ye,{value:Math.round(u*100),onValueChange:e=>ne(e/100),min:0,max:100,step:10,className:`w-16 tabular-nums`}):(0,Z.jsxs)(`span`,{className:`typography-ui-label text-foreground tabular-nums min-w-[3rem] text-right`,children:[Math.round(u*100),`%`]})]}),(0,Z.jsx)(Y,{label:n(`settings.voice.page.field.ttsInputMode`),children:(0,Z.jsxs)(W,{value:T,onValueChange:e=>{(e===`final`||e===`sanitized`||e===`raw`||e===`summarized`)&&fe(e)},children:[(0,Z.jsx)(U,{className:`w-fit max-w-full`,"aria-label":n(`settings.voice.page.field.ttsInputMode`),children:(0,Z.jsx)(z,{children:()=>n(T===`final`?`settings.voice.page.field.ttsInputModeFinal`:T===`raw`?`settings.voice.page.field.ttsInputModeRaw`:T===`summarized`?`settings.voice.page.field.ttsInputModeSummarized`:`settings.voice.page.field.ttsInputModeSanitized`)})}),(0,Z.jsx)(H,{children:[[`final`,`settings.voice.page.field.ttsInputModeFinal`,`settings.voice.page.field.ttsInputModeFinalDescription`],[`sanitized`,`settings.voice.page.field.ttsInputModeSanitized`,`settings.voice.page.field.ttsInputModeSanitizedDescription`],[`raw`,`settings.voice.page.field.ttsInputModeRaw`,`settings.voice.page.field.ttsInputModeRawDescription`],[`summarized`,`settings.voice.page.field.ttsInputModeSummarized`,`settings.voice.page.field.ttsInputModeSummarizedDescription`]].map(([e,t,r])=>(0,Z.jsx)(V,{value:e,children:(0,Z.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-1 text-left`,children:[(0,Z.jsx)(`span`,{children:n(t)}),(0,Z.jsx)(`span`,{className:`max-w-64 whitespace-normal typography-meta text-muted-foreground`,children:n(r)})]})},e))})]})})]})]})}),t!==`tts`&&(0,Z.jsx)(`div`,{"data-settings-item":`voice.speech-recognition`,children:(0,Z.jsxs)(le,{label:n(`settings.voice.page.section.speechRecognition`),actions:(0,Z.jsx)(C,{size:`sm`,disabled:o.saving,"aria-busy":o.saving,onClick:()=>{o.saving||o.save()},children:n(`settings.voice.volcengine.save`)}),children:[(0,Z.jsx)(Y,{label:n(`settings.voice.page.field.enableVoiceInput`),children:(0,Z.jsx)(ue,{checked:N,onChange:me,ariaLabel:n(`settings.voice.page.field.enableVoiceInputAria`)})}),N&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Y,{label:(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{children:n(`settings.voice.page.field.provider`)}),(0,Z.jsxs)(R,{children:[(0,Z.jsx)(ee,{asChild:!0,children:(0,Z.jsx)(k,{name:`information`,className:`h-3.5 w-3.5 text-muted-foreground/60 cursor-help`})}),(0,Z.jsx)(L,{sideOffset:8,className:`max-w-xs`,children:(0,Z.jsxs)(`ul`,{className:`space-y-1`,children:[(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`strong`,{children:n(`settings.voice.page.provider.local`)}),` `,n(`settings.voice.page.tooltip.sttLocal`)]}),(0,Z.jsxs)(`li`,{children:[(0,Z.jsx)(`strong`,{children:n(`settings.voice.page.provider.server`)}),` `,n(`settings.voice.page.tooltip.sttServer`)]})]})})]})]}),children:(0,Z.jsxs)(W,{value:E,onValueChange:e=>{(e===`local`||e===`openai-compatible`||e===`volcengine`)&&Q(e)},children:[(0,Z.jsx)(U,{"aria-label":n(`settings.voice.page.field.provider`),children:(0,Z.jsx)(z,{children:{local:n(`settings.voice.page.provider.local`),volcengine:n(`settings.voice.volcengine.providerOption`),"openai-compatible":n(`settings.voice.page.provider.server`)}[E]})}),(0,Z.jsxs)(H,{children:[(0,Z.jsx)(V,{value:`volcengine`,children:n(`settings.voice.volcengine.providerOption`)}),(0,Z.jsx)(V,{value:`local`,children:n(`settings.voice.page.provider.local`)}),(0,Z.jsx)(V,{value:`openai-compatible`,children:n(`settings.voice.page.provider.server`)})]})]})}),E===`volcengine`&&(0,Z.jsx)(ht,{mode:`asr`,form:o}),E===`local`&&(0,Z.jsx)(Y,{label:n(`settings.voice.page.field.model`),className:`yuri-settings-split-row-stacked`,children:(0,Z.jsx)(yt,{selectedModelId:j,onSelect:ve})}),E===`openai-compatible`&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Y,{label:(0,Z.jsx)(`span`,{className:S(!D.trim()&&`text-[var(--status-error)]`),children:n(`settings.voice.page.field.serverUrl`)}),description:n(`settings.voice.page.field.sttServerUrlHint`),children:(0,Z.jsxs)(`div`,{className:`relative w-full`,children:[(0,Z.jsx)(I,{type:`text`,value:D,onChange:e=>he(e.target.value),placeholder:`http://localhost:8001/v1`,className:`w-full pr-8`}),D&&(0,Z.jsx)(`button`,{type:`button`,onClick:()=>he(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,Z.jsx)(k,{name:`close`,className:`w-3.5 h-3.5`})})]})}),(0,Z.jsx)(Y,{label:`API Key`,description:`Optional`,children:(0,Z.jsxs)(`div`,{className:`relative w-full`,children:[(0,Z.jsx)(I,{type:`password`,value:O,onChange:e=>ge(e.target.value),placeholder:e.sttApiKeyConfigured&&o.draft.sttApiKey===void 0?`••••••••`:`sk-...`,className:`w-full pr-8`}),O&&(0,Z.jsx)(`button`,{type:`button`,onClick:()=>ge(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,Z.jsx)(k,{name:`close`,className:`w-3.5 h-3.5`})})]})}),(0,Z.jsx)(Y,{label:n(`settings.voice.page.field.model`),children:(0,Z.jsx)(`div`,{className:`relative w-full`,children:(0,Z.jsx)(I,{type:`text`,value:A,onChange:e=>_e(e.target.value),placeholder:`deepdml/faster-whisper-large-v3-turbo-ct2`,className:`w-full`})})}),(0,Z.jsx)(Y,{label:n(`settings.voice.page.field.language`),description:n(`settings.voice.page.field.sttLanguageHint`),children:(0,Z.jsx)(`div`,{className:`relative w-full`,children:(0,Z.jsx)(I,{type:`text`,value:M,onChange:e=>be(e.target.value),placeholder:`auto`,className:`w-full`})})})]})]})]})})]})};export{be as a,Q as c,it as i,pe as l,gt as n,ye as o,ht as r,he as s,wt 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-CzHs0bHY.js";import{n as r}from"./vendor-react-DlzBev0S.js";import{t as i}from"./i18n-BU14awhU.js";import{t as a}from"./useThemeSystem-CNzUUkFn.js";var o=r(),s=e(n(),1),c=(0,s.createContext)(null),l=t(),u=e=>{let t=(0,o.c)(22),{className:n,width:r,height:u,isAnimated:d}=e,f=n===void 0?``:n,p=r===void 0?70:r,m=u===void 0?70:u,h=d!==void 0&&d,{t:g}=i(),_=a(),v=s.useContext(c),y=_?_.currentTheme.metadata.variant!==`light`:typeof window<`u`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches;if(v?.logo){let e=v.logo,n;t[0]===g?n=t[1]:(n=g(`yuriLogo.aria.logo`),t[0]=g,t[1]=n);let r;return t[2]!==v.logo||t[3]!==f||t[4]!==m||t[5]!==n||t[6]!==p?(r=(0,l.jsx)(`img`,{src:e,width:p,height:m,className:f,alt:n,"data-yuri-logo":!0}),t[2]=v.logo,t[3]=f,t[4]=m,t[5]=n,t[6]=p,t[7]=r):r=t[7],r}let b;t[8]===g?b=t[9]:(b=g(`yuriLogo.aria.logo`),t[8]=g,t[9]=b);let x;t[10]===h?x=t[11]:(x=h?(0,l.jsx)(`style`,{children:`@keyframes yuri-logo-breathe{50%{opacity:.65}}.yuri-logo-breathe{animation:yuri-logo-breathe 1.8s ease-in-out infinite}@media(prefers-reduced-motion:reduce){.yuri-logo-breathe{animation:none}}`}):null,t[10]=h,t[11]=x);let S=y?`white`:`black`,C=h?`yuri-logo-breathe`:void 0,w;t[12]!==S||t[13]!==C?(w=(0,l.jsx)(`path`,{fill:S,fillRule:`evenodd`,className:C,d:`M48.34 6.03L47.62 6.07L46.95 6.12L46.64 6.15L46.20 6.21L45.36 6.34L44.97 6.42L44.61 6.48L43.53 6.73L43.27 6.79L43.01 6.86L42.16 7.13L41.77 7.24L41.22 7.41L40.38 7.70L39.25 8.13L38.84 8.30L38.28 8.57L37.62 8.85L37.30 9.01L36.95 9.20L36.25 9.59L35.44 10.06L34.74 10.46L34.40 10.67L33.76 11.16L33.51 11.34L32.95 11.71L32.41 12.10L31.98 12.42L31.81 12.56L31.64 12.71L31.06 13.26L30.53 13.75L29.89 14.37L29.30 14.91L29.11 15.10L28.90 15.33L28.71 15.57L28.17 16.29L27.78 16.77L27.42 17.22L27.26 17.44L26.87 17.99L26.58 18.43L26.27 18.87L25.98 19.32L25.77 19.71L25.04 21.09L24.83 21.54L24.51 22.27L24.32 22.73L24.11 23.31L23.97 23.69L23.84 24.11L23.62 24.79L23.45 25.39L23.37 25.79L23.26 26.22L23.20 26.52L23.10 27.10L23.04 27.49L22.92 28.38L22.88 28.87L22.85 29.36L22.84 29.89L22.83 30.38L22.83 31.01L22.84 31.45L22.87 31.85L22.89 32.21L23.02 33.41L23.08 33.89L23.14 34.20L23.24 34.63L23.36 35.06L23.46 35.50L23.62 36.10L23.79 36.66L23.96 37.16L24.14 37.67L24.41 38.37L24.55 38.70L24.93 39.51L25.38 40.48L25.73 41.20L25.85 41.44L26.10 41.86L26.38 42.32L26.89 43.21L27.25 43.83L27.50 44.30L27.83 44.88L27.96 45.16L28.19 45.65L28.34 46.02L28.52 46.48L28.66 46.90L28.85 47.54L29.02 48.19L29.06 48.41L29.14 48.89L29.23 49.42L29.27 49.82L29.30 50.58L29.30 51.24L29.27 52.09L29.25 52.45L29.23 52.67L29.15 53.38L29.06 53.99L28.78 55.40L28.71 55.79L28.52 56.62L28.36 57.22L28.11 57.93L27.59 59.31L27.47 59.60L27.33 59.88L26.73 61.12L26.64 61.28L26.25 61.92L25.96 62.38L25.53 63.10L25.31 63.44L24.96 63.96L23.92 65.41L23.70 65.69L23.25 66.19L23.05 66.42L22.89 66.64L22.52 67.14L22.14 67.58L21.72 68.10L21.36 68.56L21.25 68.70L21.23 68.74L21.23 68.78L21.26 68.82L21.30 68.83L21.34 68.83L22.18 68.73L23.16 68.63L23.38 68.61L24.10 68.60L25.08 68.60L25.43 68.61L25.97 68.64L26.63 68.72L27.08 68.75L27.25 68.78L28.22 68.92L29.19 69.11L29.41 69.15L30.10 69.33L30.70 69.49L31.08 69.61L31.72 69.81L32.23 69.99L32.97 70.28L33.75 70.61L34.40 70.92L34.80 71.11L35.31 71.38L36.00 71.79L36.55 72.09L36.85 72.28L37.58 72.79L38.10 73.14L38.46 73.41L38.70 73.60L39.82 74.49L40.06 74.68L40.49 75.00L40.77 75.22L41.10 75.52L41.55 75.96L41.98 76.35L42.17 76.53L42.39 76.76L42.72 77.18L42.90 77.38L43.02 77.51L43.47 77.94L43.74 78.24L44.15 78.71L44.64 79.29L44.98 79.71L45.13 79.92L45.26 80.16L45.28 80.20L45.29 80.24L45.27 80.27L45.23 80.29L45.19 80.27L44.95 80.08L44.75 79.90L44.40 79.56L44.07 79.26L43.64 78.87L43.44 78.70L42.77 78.16L42.42 77.89L41.51 77.25L40.74 76.64L39.96 76.05L39.26 75.58L38.54 75.12L37.39 74.44L36.59 73.96L36.31 73.81L35.95 73.63L34.83 73.09L33.89 72.67L33.57 72.52L33.11 72.34L31.78 71.84L31.61 71.78L31.23 71.66L30.79 71.55L29.81 71.27L29.20 71.11L29.03 71.07L28.33 70.93L27.71 70.84L27.32 70.77L27.10 70.74L26.83 70.71L26.39 70.68L25.86 70.61L25.28 70.57L24.96 70.56L24.52 70.56L24.03 70.56L23.76 70.58L23.10 70.64L22.30 70.73L22.08 70.76L21.15 70.92L20.72 71.03L20.33 71.12L19.74 71.31L19.15 71.51L18.77 71.64L18.40 71.80L17.87 72.03L17.71 72.11L17.55 72.20L17.21 72.41L16.74 72.75L16.22 73.09L15.90 73.33L15.61 73.54L15.30 73.80L14.97 74.09L14.52 74.53L14.27 74.78L13.90 75.23L13.34 75.92L13.09 76.24L12.89 76.53L12.31 77.49L12.16 77.76L12.06 77.96L11.97 78.16L11.86 78.45L11.84 78.49L11.84 78.54L11.85 78.58L11.88 78.61L11.93 78.62L12.88 78.37L13.40 78.26L14.01 78.14L14.54 78.03L14.84 77.97L15.59 77.87L16.57 77.77L17.32 77.67L17.50 77.66L17.72 77.65L18.52 77.63L19.82 77.63L20.58 77.63L21.87 77.67L22.31 77.70L22.62 77.72L23.65 77.82L24.00 77.86L24.57 77.95L25.24 78.04L25.98 78.16L26.42 78.24L26.91 78.33L27.26 78.39L27.65 78.47L28.13 78.56L28.57 78.67L28.96 78.74L29.31 78.83L29.74 78.92L30.12 79.04L30.94 79.26L31.54 79.44L32.18 79.64L32.98 79.91L33.79 80.15L33.96 80.21L35.30 80.71L36.63 81.22L37.04 81.39L37.58 81.60L38.49 81.98L39.48 82.39L39.92 82.59L40.36 82.81L40.60 82.92L41.18 83.18L41.92 83.49L42.44 83.73L42.84 83.92L43.73 84.34L44.42 84.66L45.15 85.00L45.51 85.18L46.29 85.60L46.66 85.77L47.13 86.01L47.74 86.29L48.22 86.52L49.54 87.17L50.10 87.46L50.94 87.87L52.09 88.45L53.85 89.22L54.05 89.31L54.52 89.56L54.88 89.74L55.21 89.89L55.58 90.05L56.65 90.50L57.21 90.77L57.70 90.99L58.15 91.17L58.48 91.31L58.94 91.47L59.54 91.67L59.92 91.79L60.30 91.92L60.88 92.13L61.59 92.40L62.01 92.55L62.78 92.78L63.99 93.10L64.68 93.28L65.12 93.37L65.55 93.47L66.25 93.62L67.39 93.81L67.75 93.85L68.06 93.88L69.17 93.95L69.70 93.99L70.02 94.00L70.24 93.99L70.28 93.98L70.32 93.96L70.31 93.92L70.28 93.89L70.21 93.84L70.09 93.79L69.55 93.57L69.06 93.35L68.46 93.06L66.66 92.08L66.00 91.71L65.73 91.55L65.35 91.31L64.91 91.01L64.23 90.58L63.75 90.25L63.32 89.94L63.03 89.73L61.99 88.89L61.42 88.46L61.01 88.12L60.74 87.88L60.22 87.39L59.66 86.82L59.10 86.24L58.62 85.78L58.43 85.59L58.24 85.40L57.95 85.06L57.51 84.56L57.09 84.04L56.42 83.25L56.03 82.77L55.87 82.56L55.64 82.23L55.40 81.91L54.98 81.28L54.78 80.98L54.25 80.10L54.00 79.68L53.37 78.55L53.20 78.23L52.81 77.43L52.64 77.07L52.48 76.66L52.12 75.69L51.96 75.23L51.85 74.89L51.76 74.60L51.60 74.04L51.41 73.21L51.34 72.82L51.25 72.38L51.14 71.77L50.98 71.03L50.79 70.29L50.61 69.65L50.45 69.14L50.26 68.59L50.00 67.97L49.91 67.77L49.82 67.61L49.60 67.23L49.21 66.63L49.05 66.42L48.85 66.17L48.71 66.00L48.56 65.84L48.18 65.46L47.95 65.25L47.74 65.08L46.72 64.29L46.52 64.11L46.12 63.75L45.29 62.94L45.10 62.75L44.65 62.26L44.37 61.91L43.99 61.41L43.64 60.90L43.38 60.48L43.16 60.10L43.03 59.86L42.63 59.06L42.31 58.33L42.23 58.12L42.16 57.91L42.15 57.87L42.15 57.82L42.17 57.78L42.21 57.77L42.25 57.78L42.32 57.84L42.41 57.94L42.49 58.04L42.67 58.30L42.80 58.48L43.19 58.96L43.99 59.86L44.18 60.05L44.38 60.24L44.55 60.38L45.02 60.78L45.97 61.60L46.35 61.91L46.63 62.13L46.99 62.39L47.56 62.75L47.79 62.88L49.13 63.59L49.77 63.91L50.54 64.27L51.31 64.62L51.59 64.74L51.97 64.89L53.02 65.27L53.77 65.53L54.40 65.77L55.12 66.01L55.67 66.18L56.58 66.42L57.52 66.70L59.15 67.14L59.84 67.35L60.30 67.51L60.75 67.69L60.96 67.78L61.20 67.90L61.40 68.00L61.59 68.11L61.81 68.26L62.10 68.47L62.28 68.61L62.41 68.72L62.66 68.97L62.81 69.14L62.93 69.28L63.06 69.46L63.21 69.68L64.12 71.16L64.32 71.46L64.45 71.64L64.65 71.88L65.19 72.53L65.49 72.86L65.84 73.20L66.11 73.44L66.31 73.61L66.91 74.08L67.41 74.45L67.67 74.63L68.04 74.87L68.23 74.98L68.28 74.99L68.32 74.97L68.32 74.92L68.32 74.88L68.31 74.84L68.23 74.67L67.56 73.27L67.47 73.06L67.27 72.52L67.16 72.23L66.93 71.46L66.89 71.28L66.85 71.06L66.81 70.75L66.79 70.49L66.78 70.27L66.77 70.00L66.77 69.60L66.78 69.37L66.81 68.97L66.84 68.71L66.90 68.40L66.95 68.14L67.06 67.75L67.12 67.54L67.27 67.12L67.44 66.66L67.51 66.49L67.61 66.29L67.98 65.58L68.38 64.78L68.51 64.50L68.57 64.38L68.64 64.27L68.74 64.12L68.77 64.09L68.81 64.08L68.85 64.11L68.86 64.16L68.85 64.20L68.83 64.33L68.79 64.46L68.73 64.67L68.60 65.05L68.51 65.35L68.39 65.78L68.33 66.04L68.21 66.61L68.07 67.49L68.01 67.98L67.98 68.29L67.96 68.87L67.96 69.31L67.98 69.76L68.01 70.11L68.06 70.47L68.18 71.03L68.22 71.21L68.37 71.72L68.43 71.89L68.53 72.14L68.75 72.63L68.93 72.98L69.39 73.80L69.56 74.11L69.75 74.51L70.07 75.20L70.25 75.71L70.69 76.97L71.04 77.88L71.14 78.18L71.28 78.65L71.46 79.20L71.58 79.54L71.69 79.78L71.78 79.98L71.94 80.30L72.22 80.81L72.62 81.56L72.82 81.91L72.98 82.17L73.30 82.66L73.62 83.14L73.81 83.39L74.24 83.96L74.41 84.17L74.58 84.37L74.83 84.63L75.05 84.84L75.26 85.02L75.30 85.04L75.34 85.05L75.37 85.02L75.37 84.98L75.36 84.94L75.24 84.65L74.99 84.08L74.62 83.21L74.43 82.67L74.06 81.57L73.92 81.01L73.69 79.91L73.57 79.26L73.52 78.90L73.37 77.53L73.33 77.17L73.32 76.86L73.29 76.06L73.28 75.75L73.29 75.44L73.32 74.81L73.34 74.55L73.57 72.78L73.69 72.07L73.82 71.46L73.98 70.54L74.02 70.28L74.10 69.70L74.17 69.04L74.20 68.64L74.22 68.14L74.21 67.83L74.20 67.61L74.19 67.39L74.14 66.99L74.01 66.20L73.95 65.94L73.83 65.51L73.67 65.05L73.51 64.68L73.27 64.19L72.81 63.28L72.70 63.04L72.65 62.91L72.59 62.75L72.54 62.53L72.51 62.35L72.50 62.18L72.50 62.00L72.50 61.86L72.52 61.69L72.55 61.56L72.58 61.43L72.65 61.26L72.72 61.10L72.81 60.94L72.93 60.76L73.02 60.66L73.11 60.56L73.31 60.38L73.69 60.08L73.82 59.95L73.93 59.82L73.98 59.74L74.02 59.66L74.06 59.58L74.10 59.46L74.12 59.33L74.14 59.24L74.14 59.15L74.14 59.06L74.12 58.97L74.09 58.84L74.05 58.72L74.02 58.63L73.96 58.52L73.91 58.44L73.83 58.33L73.78 58.27L73.68 58.18L73.61 58.13L73.53 58.08L73.45 58.05L73.28 58.00L73.06 57.97L72.74 57.96L72.48 57.97L72.25 57.99L71.86 58.03L71.59 58.08L70.33 58.35L70.11 58.41L69.47 58.59L69.17 58.69L68.58 58.87L68.44 58.89L68.31 58.91L68.27 58.90L68.25 58.87L68.26 58.83L68.28 58.80L68.46 58.66L68.67 58.50L68.93 58.32L69.20 58.16L69.59 57.95L69.79 57.85L70.00 57.76L70.20 57.69L71.26 57.34L71.78 57.19L71.95 57.15L72.56 57.02L72.78 56.98L73.14 56.94L73.71 56.90L73.85 56.88L73.97 56.85L74.10 56.81L74.22 56.75L74.34 56.69L74.46 56.62L74.57 56.55L74.67 56.47L74.77 56.38L74.83 56.31L74.89 56.25L74.97 56.14L75.05 55.98L75.11 55.81L75.13 55.73L75.15 55.60L75.16 55.46L75.16 55.33L75.14 54.93L75.10 54.49L75.07 54.31L75.05 54.18L75.00 54.01L74.92 53.80L74.85 53.64L74.76 53.48L74.61 53.26L74.44 53.05L74.23 52.82L73.98 52.57L73.89 52.47L73.86 52.43L73.85 52.39L73.86 52.35L73.88 52.31L73.92 52.29L73.96 52.28L74.09 52.26L74.27 52.26L74.58 52.26L74.94 52.29L75.11 52.31L75.29 52.35L75.59 52.41L75.94 52.48L76.51 52.61L76.86 52.67L77.17 52.70L77.48 52.72L77.75 52.71L77.97 52.68L78.19 52.64L78.36 52.59L78.53 52.53L78.69 52.45L78.85 52.37L79.00 52.27L79.10 52.19L79.20 52.10L79.29 52.00L79.36 51.89L79.45 51.73L79.50 51.61L79.54 51.48L79.57 51.35L79.58 51.22L79.57 51.09L79.56 50.91L79.53 50.78L79.50 50.65L79.36 50.13L79.25 49.75L79.13 49.27L78.88 48.47L78.48 47.14L78.34 46.72L78.08 45.86L77.99 45.57L77.89 45.22L77.64 44.41L77.48 43.86L77.37 43.42L77.27 43.08L77.11 42.48L76.94 41.83L76.86 41.44L76.77 41.09L76.69 40.66L76.56 40.09L76.39 39.21L76.25 38.47L76.18 38.16L76.14 38.04L76.08 37.87L75.99 37.72L75.88 37.53L75.59 37.13L75.39 36.88L75.28 36.75L75.04 36.49L74.65 36.12L74.48 35.97L74.30 35.84L73.80 35.47L73.35 35.17L72.97 34.95L72.42 34.66L71.81 34.38L70.44 33.83L69.90 33.62L69.39 33.45L68.28 33.11L67.77 32.98L67.64 32.93L67.48 32.86L67.44 32.84L67.41 32.81L67.41 32.78L67.44 32.75L67.49 32.74L67.71 32.73L67.98 32.74L68.20 32.77L68.82 32.86L69.30 32.93L70.14 33.07L70.84 33.21L71.10 33.28L72.17 33.58L72.72 33.75L72.94 33.81L73.44 33.99L73.65 34.07L73.86 34.15L74.54 34.48L74.94 34.67L75.30 34.86L75.69 35.08L75.99 35.27L76.28 35.48L76.58 35.74L76.98 36.10L77.21 36.30L77.32 36.38L77.40 36.40L77.48 36.41L77.56 36.39L77.63 36.35L77.74 36.28L77.84 36.19L77.96 36.06L78.07 35.92L78.14 35.80L78.20 35.69L78.26 35.56L78.30 35.44L78.33 35.31L78.35 35.18L78.36 35.04L78.34 34.73L78.31 34.51L78.28 34.34L78.03 33.25L77.92 32.64L77.82 32.20L77.79 32.02L77.77 31.80L77.72 31.27L77.65 30.16L77.57 29.18L77.39 27.94L77.36 27.72L77.28 27.33L77.20 26.89L77.04 26.20L77.00 26.02L76.85 25.51L76.69 24.95L76.49 24.36L76.40 24.11L76.31 23.81L76.23 23.60L76.14 23.39L76.05 23.19L75.61 22.27L75.23 21.51L74.93 20.96L74.38 19.99L73.64 18.82L73.18 18.17L72.96 17.89L72.11 16.91L71.27 15.87L70.77 15.30L70.49 15.02L70.16 14.71L69.60 14.20L69.17 13.81L68.94 13.60L68.54 13.25L68.16 12.94L67.75 12.59L67.54 12.42L67.22 12.18L66.68 11.79L65.94 11.29L65.20 10.79L64.71 10.48L64.05 10.10L62.65 9.33L62.29 9.14L62.01 9.01L61.73 8.87L60.87 8.51L60.34 8.27L59.93 8.08L59.61 7.94L59.15 7.77L58.13 7.42L57.79 7.32L57.50 7.23L56.86 7.03L56.26 6.86L55.39 6.64L54.74 6.49L54.34 6.42L53.86 6.33L53.29 6.24L52.58 6.15L52.36 6.12L51.11 6.04L50.53 6.01L50.13 6.00L49.38 6.00L48.66 6.01ZM84.78 23.79L84.64 23.81L84.51 23.84L84.08 23.95L83.87 24.03L83.63 24.14L83.51 24.21L83.40 24.28L83.18 24.44L82.99 24.62L82.84 24.79L82.66 25.04L82.52 25.27L82.46 25.39L82.39 25.55L82.33 25.72L82.28 25.84L82.18 26.23L82.13 26.49L82.12 26.63L82.11 26.76L82.12 26.89L82.13 27.07L82.15 27.20L82.18 27.38L82.23 27.60L82.28 27.77L82.36 27.98L82.49 28.26L82.55 28.38L82.62 28.49L82.70 28.60L82.79 28.70L82.97 28.90L83.07 28.99L83.20 29.10L83.42 29.26L83.54 29.32L83.66 29.39L84.06 29.57L84.19 29.61L84.32 29.65L84.58 29.70L84.71 29.72L84.84 29.73L85.16 29.74L85.33 29.73L85.47 29.71L85.82 29.65L86.03 29.60L86.16 29.55L86.36 29.47L86.61 29.35L86.76 29.26L86.91 29.16L87.16 28.98L87.43 28.74L87.52 28.65L87.61 28.55L87.73 28.36L87.88 28.09L87.99 27.84L88.04 27.67L88.08 27.55L88.13 27.28L88.15 27.11L88.16 26.97L88.16 26.66L88.14 26.35L88.10 26.09L88.07 25.95L88.03 25.83L87.92 25.53L87.87 25.41L87.78 25.25L87.72 25.14L87.64 25.03L87.48 24.82L87.29 24.63L87.08 24.46L86.83 24.28L86.59 24.15L86.35 24.04L86.10 23.95L85.62 23.83L85.40 23.79L85.27 23.78L85.09 23.77L84.91 23.78ZM63.90 37.84L63.95 37.83L63.99 37.83L64.15 37.92L64.63 38.23L65.01 38.47L65.60 38.87L66.10 39.16L66.54 39.39L66.78 39.50L67.02 39.61L67.44 39.77L68.36 40.10L68.88 40.25L69.05 40.30L69.22 40.34L69.92 40.46L70.15 40.49L70.37 40.52L71.66 40.61L72.15 40.63L72.59 40.62L72.68 40.63L72.72 40.65L72.75 40.68L72.77 40.72L72.76 40.77L72.74 40.81L72.71 40.84L72.60 40.91L72.41 41.03L72.22 41.13L72.01 41.22L71.68 41.35L71.51 41.41L71.00 41.56L70.87 41.59L70.65 41.62L70.25 41.67L69.98 41.69L69.63 41.68L69.31 41.66L69.00 41.62L68.83 41.59L68.66 41.55L68.11 41.37L67.78 41.24L67.41 41.07L67.09 40.91L66.82 40.76L66.63 40.64L66.45 40.51L65.95 40.13L65.68 39.90L65.38 39.64L65.05 39.33L64.77 39.04L64.51 38.74L64.11 38.26L63.92 38.01L63.90 37.98L63.88 37.93L63.88 37.89Z`}),t[12]=S,t[13]=C,t[14]=w):w=t[14];let T;return t[15]!==f||t[16]!==m||t[17]!==b||t[18]!==x||t[19]!==w||t[20]!==p?(T=(0,l.jsxs)(`svg`,{width:p,height:m,viewBox:`0 0 100 100`,xmlns:`http://www.w3.org/2000/svg`,className:f,role:`img`,"aria-label":b,"data-yuri-logo":!0,children:[x,w]}),t[15]=f,t[16]=m,t[17]=b,t[18]=x,t[19]=w,t[20]=p,t[21]=T):T=t[21],T};export{c as n,u as t};
@@ -0,0 +1 @@
1
+ import"./rolldown-runtime-hePW80VL.js";import{c as e,s as t}from"./runtime-switch-BMjl5Y5W.js";import{a as n,i as r}from"./vendor-zustand-vDaAPGfl.js";import{ot as i,st as a}from"./vendor-base-ui-CzHs0bHY.js";import{po as o}from"./gitApiHttp-B1mApXwC.js";import{n as s}from"./vendor-react-DlzBev0S.js";var c=n()(r(e=>({progress:{},openedRuntime:null,open:t=>e(e=>({openedRuntime:t,progress:{...e.progress,[t]:e.progress[t]??{step:0,dismissed:!1}}})),move:(t,n)=>e(e=>({progress:{...e.progress,[t]:{step:n,dismissed:e.progress[t]?.dismissed??!1}}})),dismiss:t=>e(e=>({openedRuntime:e.openedRuntime===t?null:e.openedRuntime,progress:{...e.progress,[t]:{step:e.progress[t]?.step??0,dismissed:!0}}}))}),{name:`yuri-setup-tour`,version:1,migrate:e=>({progress:Object.fromEntries(Object.entries(e?.progress??{}).map(([e,t])=>[e,t&&typeof t==`object`?{...t,step:t.step===2?3:t.step}:t]))}),storage:o(),partialize:e=>({progress:e.progress}),merge:(e,t)=>{let n=e,r={};if(n?.progress&&typeof n.progress==`object`)for(let[e,t]of Object.entries(n.progress))t&&[0,1,2,3].includes(t.step)&&typeof t.dismissed==`boolean`&&(r[e]={step:t.step,dismissed:t.dismissed});return{...t,progress:r,openedRuntime:null}}}));e(e=>{t(e)&&c.persist.rehydrate()}),a();var l=s(),u=`/assets/yuri-wordmark-DSJqXYVo.svg`,d=i();function f(e){let t=(0,l.c)(5),{className:n,width:r}=e,i=n===void 0?``:n,a=r===void 0?112:r,o=`inline-block shrink-0 ${i}`,s;t[0]===a?s=t[1]:(s={width:a,aspectRatio:`626.723 / 280`,backgroundColor:`currentColor`,mask:`url("${u}") center / contain no-repeat`,WebkitMask:`url("${u}") center / contain no-repeat`},t[0]=a,t[1]=s);let c;return t[2]!==o||t[3]!==s?(c=(0,d.jsx)(`span`,{role:`img`,"aria-label":`Yuri`,className:o,style:s}),t[2]=o,t[3]=s,t[4]=c):c=t[4],c}export{c as n,f as t};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./platform-DMsFWy1a.js";import{a as n}from"./vendor-zustand-vDaAPGfl.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{a as r,n as i}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{r as a}from"./vendor-pierre-diffs-BFiZ3IhI.js";import{s as o}from"./useMobileNavigationStore-CJBLQxTz.js";import{t as s}from"./agentColors-DWSbQXy2.js";import{t as c}from"./rasterizePng-056Poix7.js";var l=`yuri.iosNativeUi`,u=()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(l)===`1`}catch{return!1}},d=e=>{if(!(typeof window>`u`))try{e?window.localStorage.setItem(l,`1`):window.localStorage.removeItem(l)}catch{}},f=n(e=>({enabled:u(),setEnabled:t=>{d(t),e({enabled:t})}})),p=()=>f.getState().enabled,ee=()=>f(ne),te=()=>e()&&t()===`ios`;function ne(e){return e.enabled}var m=5,re=Math.ceil(m/2);function h(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t>>>0}function g(e){let t=Array.from({length:m},()=>Array.from({length:m},()=>!1));if(!e)return t;let n=h(e);for(let e=0;e<m;e++)for(let r=0;r<re;r++){let i=(n&1)==1;n>>>=1,t[e][r]=i,t[e][4-r]=i}return t}var _=`yuri-native-ios-composer`,v=`--yuri-native-composer-height`,y=`--yuri-native-composer-accessory`,ie=33554432,b=`YuriComposer`,x=`#22c55e`,S=32,C=()=>({open:!1,highlightedIndex:0,query:``,highlightColor:``,rows:[]}),w=()=>({text:``,placeholder:``,modelLabel:``,modelVariantLabel:``,modelIcon:``,canSend:!1,canAbort:!1,attachmentCount:0,attachmentPreviews:[],citationRanges:[],chipRanges:[],appearance:`dark`,attachAria:``,attachTitle:``,attachPhotosLabel:``,attachFilesLabel:``,attachCancelLabel:``,sendAria:``,queueAria:``,stopAria:``,modelAria:``,agentAria:``,agentLabel:``,agentColor:x,agentIdenticon:Array.from({length:25},()=>0),agentIcon:``,suppressed:!0,showScrollToBottom:!1,scrollAria:``,autocomplete:C()}),T=r(b),ae=e=>e.isCapacitor&&e.platform===`ios`&&e.pluginAvailable&&e.isMobile&&e.nativeUiEnabled!==!1;function oe(n){return typeof window>`u`?!1:ae({isCapacitor:e(),platform:t(),pluginAvailable:i.isPluginAvailable(b),isMobile:n,nativeUiEnabled:p()})}var se=e=>e.classList.contains(`dark`)?`dark`:`light`,ce=e=>{let t=e?.height;return typeof t!=`number`||!Number.isFinite(t)||t<0?0:t},le=(e,t)=>{if(!(t>0)){e.style.removeProperty(v);return}e.style.setProperty(v,`${Math.round(t)}px`)},ue=(e,t)=>{if(!(t>0)){e.style.removeProperty(y);return}e.style.setProperty(y,`${Math.round(t)}px`)},E=(e,t)=>{e.classList.toggle(_,t),t||(e.style.removeProperty(v),e.style.removeProperty(y))},de=e=>g(e).flat().map(e=>+!!e),D=new Map,O=null,k=e=>{let t=D.get(e);if(t!==void 0)return t;if(typeof document>`u`||typeof getComputedStyle>`u`)return x;!O&&typeof MutationObserver<`u`&&(O=new MutationObserver(()=>{D.clear()}),O.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`style`]}));let n=getComputedStyle(document.documentElement).getPropertyValue(e).trim(),r=document.createElement(`span`);r.style.color=n||`var(${e})`,document.documentElement.appendChild(r);let i=getComputedStyle(r).color;r.remove();let a=/rgba?\(\s*([\d.]+)(?:\s*,\s*|\s+)([\d.]+)(?:\s*,\s*|\s+)([\d.]+)/.exec(i);if(!a)return D.set(e,x),x;let o=e=>Math.max(0,Math.min(255,Math.round(Number(e)))).toString(16).padStart(2,`0`),s=`#${o(a[1])}${o(a[2])}${o(a[3])}`;return D.set(e,s),s},fe=e=>k(s(e).var),A=(e,t)=>e.text===t.text&&e.placeholder===t.placeholder&&e.modelLabel===t.modelLabel&&e.modelVariantLabel===t.modelVariantLabel&&e.modelIcon===t.modelIcon&&e.canSend===t.canSend&&e.canAbort===t.canAbort&&e.attachmentCount===t.attachmentCount&&M(e.attachmentPreviews,t.attachmentPreviews)&&N(e.citationRanges,t.citationRanges)&&P(e.chipRanges,t.chipRanges)&&e.appearance===t.appearance&&e.attachAria===t.attachAria&&e.attachTitle===t.attachTitle&&e.attachPhotosLabel===t.attachPhotosLabel&&e.attachFilesLabel===t.attachFilesLabel&&e.attachCancelLabel===t.attachCancelLabel&&e.sendAria===t.sendAria&&e.queueAria===t.queueAria&&e.stopAria===t.stopAria&&e.modelAria===t.modelAria&&e.agentAria===t.agentAria&&e.agentLabel===t.agentLabel&&e.agentColor===t.agentColor&&e.agentIdenticon.join(``)===t.agentIdenticon.join(``)&&e.agentIcon===t.agentIcon&&e.suppressed===t.suppressed&&e.showScrollToBottom===t.showScrollToBottom&&e.scrollAria===t.scrollAria&&j(e.autocomplete,t.autocomplete),j=(e,t)=>e.open===t.open&&e.highlightedIndex===t.highlightedIndex&&e.query===t.query&&e.highlightColor===t.highlightColor&&e.rows.length===t.rows.length&&e.rows.every((e,n)=>{let r=t.rows[n];return!!(r&&e.id===r.id&&e.title===r.title&&e.subtitle===r.subtitle&&e.badge===r.badge&&e.iconBase64===r.iconBase64)}),M=(e,t)=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return!!(r&&e.id===r.id&&e.filename===r.filename&&e.mime===r.mime&&e.thumbnailBase64===r.thumbnailBase64&&e.removeAria===r.removeAria)}),N=(e,t)=>e.length===t.length&&e.every((e,n)=>e.start===t[n]?.start&&e.end===t[n]?.end),P=(e,t)=>e.length===t.length&&e.every((e,n)=>{let r=t[n];return!!(r&&e.start===r.start&&e.end===r.end&&e.triggerLength===r.triggerLength&&e.color===r.color)}),F=(e,t)=>{if(!e||!t||t.length===0)return[];let n=[],r=0;for(let e of t){let t=r;r+=e.text.length;let i=e.visual;if(!i)continue;let a=i.trigger.length;a<1||t+a>r||i.icon&&n.push({start:t,end:r,triggerLength:a,iconName:i.icon})}return n},I=(e,t)=>e.map(e=>({start:e.start,end:e.end,triggerLength:e.triggerLength,color:t})),L=e=>e.map(e=>`${e.id}:${e.filename}:${e.mimeType}:${e.dataUrl?.length??0}`).join(`|`),R=e=>{let t=e?.id;return typeof t==`string`&&t.trim()?t:``},z=e=>{if(typeof e==`number`&&Number.isFinite(e)&&e>=0)return Math.floor(e);if(typeof e==`string`&&e.trim()){let t=Number(e);if(Number.isFinite(t)&&t>=0)return Math.floor(t)}return null},B=e=>{let t=z(e?.selectionStart);if(t===null)return null;let n=z(e?.selectionEnd);return{start:t,end:n!==null&&n>=t?n:t}},V=e=>z(e?.index)??0,pe=(e,t)=>{let n=Math.max(0,e);return typeof t!=`number`||!Number.isFinite(t)?n:Math.max(0,Math.min(Math.floor(t),n))},me=e=>e.nextText===e.nativeOwnedText?{omitText:!0,forceText:!1}:e.nextText.length===0&&e.nativeOwnedText.length>0||e.preset?{omitText:!1,forceText:!0}:e.echoingNative?{omitText:!0,forceText:!1}:{omitText:!1,forceText:!0},he=e=>e.replacedText!==null&&e.incoming===e.replacedText,ge=e=>setTimeout(e,0),_e=e=>{e.applyDocument(e.text),ge(e.submit)},H=(e,t)=>e===t,ve=(e,t,n,r)=>{if(n.omitText&&e&&A(e,t))return null;let i={};if(n.omitText||(i.text=t.text,n.forceText&&(i.forceText=!0),n.forceText&&typeof r?.caret==`number`&&Number.isFinite(r.caret)&&(i.caret=Math.max(0,Math.floor(r.caret)))),!e){let{text:e,...n}=t;return Object.assign(i,n),i}let a=(n,r)=>{r(e[n],t[n])||(i[n]=t[n])};return a(`placeholder`,H),a(`modelLabel`,H),a(`modelVariantLabel`,H),a(`modelIcon`,H),a(`canSend`,H),a(`canAbort`,H),a(`attachmentCount`,H),a(`attachmentPreviews`,M),a(`citationRanges`,N),a(`chipRanges`,P),a(`appearance`,H),a(`attachAria`,H),a(`attachTitle`,H),a(`attachPhotosLabel`,H),a(`attachFilesLabel`,H),a(`attachCancelLabel`,H),a(`sendAria`,H),a(`queueAria`,H),a(`stopAria`,H),a(`modelAria`,H),a(`agentAria`,H),a(`agentLabel`,H),a(`agentColor`,H),a(`agentIdenticon`,(e,t)=>e.join(``)===t.join(``)),a(`agentIcon`,H),a(`suppressed`,H),a(`showScrollToBottom`,H),a(`scrollAria`,H),a(`autocomplete`,j),Object.keys(i).length===0?null:i},ye=e=>{let t=Array.isArray(e?.skipped)?e.skipped:[],n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=e.name;typeof t==`string`&&t.trim()&&n.push(t)}return n},be=e=>{try{let t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return n}catch{return null}},xe=(e,t=ie)=>{let n=Array.isArray(e?.files)?e.files:[],r=[];for(let e of n){if(!e||typeof e!=`object`)continue;let n=e;if(typeof n.dataBase64!=`string`||n.dataBase64.length===0)continue;let i=be(n.dataBase64);if(!i||i.byteLength===0||i.byteLength>t)continue;let a=typeof n.name==`string`&&n.name.trim()?n.name:`file`,o=typeof n.mime==`string`&&n.mime.trim()?n.mime:`application/octet-stream`;r.push(new File([new Uint8Array(i)],a,{type:o}))}return r},U=80,Se=e=>typeof document>`u`||!e||!e.startsWith(`data:image/`)?Promise.resolve(null):new Promise(t=>{let n=new Image;n.decoding=`async`,n.onload=()=>{try{let e=document.createElement(`canvas`);e.width=U,e.height=U;let r=e.getContext(`2d`);if(!r){t(null);return}r.clearRect(0,0,U,U),r.drawImage(n,0,0,U,U);let i=e.toDataURL(`image/jpeg`,.72),a=i.indexOf(`,`);t(a>=0?i.slice(a+1):null)}catch{t(null)}},n.onerror=()=>t(null),n.src=e}),Ce=e=>c(e,S),W=()=>T,G=((e=W)=>{let t=0,n=null,r=[],i=null,a=``,o=!1,s=!1,c=()=>{n!==null&&(clearTimeout(n),n=null)},l=(e,...t)=>{let n=i;n&&n[e](...t)},u=async()=>{if(r.length>0)return;let t=e(),n=await Promise.all([t.addListener(`textChanged`,e=>{let t=typeof e.text==`string`?e.text:``;a=t,l(`onText`,t,e.composing===!0,B(e))}),t.addListener(`send`,e=>{let t=typeof e.text==`string`?e.text:a;a=t,l(`onSend`,t)}),t.addListener(`abort`,()=>{l(`onAbort`)}),t.addListener(`attach`,()=>{l(`onAttach`)}),t.addListener(`filesPicked`,t=>{l(`onFiles`,xe(t),ye(t)),e().focus()}),t.addListener(`removeAttachment`,e=>{let t=R(e);t&&l(`onRemoveAttachment`,t)}),t.addListener(`openModel`,()=>{l(`onOpenModel`)}),t.addListener(`cycleAgent`,()=>{l(`onCycleAgent`)}),t.addListener(`openAgent`,()=>{l(`onOpenAgent`)}),t.addListener(`heightChanged`,e=>{l(`onHeight`,ce(e))}),t.addListener(`scrollToBottom`,()=>{l(`onScrollToBottom`)}),t.addListener(`autocompleteAccept`,e=>{l(`onAutocompleteAccept`,V(e))}),t.addListener(`autocompleteDismiss`,()=>{l(`onAutocompleteDismiss`)})]);if(r.length>0){for(let e of n)e.remove();return}r=n},d=n=>{t>0||(i=null,o=!1,E(n,!1),e().dismiss())};return{bind(e){i=e},rememberText(e){a=e},rememberState(e){a=e.text},conceal(){o||t===0||(o=!0,e().hide())},reveal(){!o||t===0||(o=!1,e().show())},async warm(){s||t>0||(s=!0,await e().present(w()))},async retain(n,i){c(),t+=1,o=!1,s=!0,a=i.text,E(n,!0),r.length===0&&await u(),await e().present(i)},release(e){t=Math.max(0,t-1),!(t>0)&&(c(),n=setTimeout(()=>{n=null,d(e)},0))},shutdown(n=document.documentElement){c();let r=s||t>0;t=0,s=!1,o=!1,i=null,E(n,!1),r&&e().dismiss()},snapshot(){return{retainCount:t,listenerCount:r.length,hidePending:n!==null,concealed:o,warmed:s}}}})(),we=()=>r(`YuriNavigation`),K=e=>e?.kind===`chat`||e?.kind===`draft`,q=e=>e?e.kind===`draft`||e.kind===`chat`&&e.routes.length<=1:!1,Te=(e,t)=>K(e)&&!K(t),Ee=(e=G)=>{q(o.getState().secondary)&&e.conceal()},De=(e=G)=>{let t=o.subscribe((t,n)=>{Te(n.secondary,t.secondary)&&e.conceal()}),n=[],r=!1;return i.getPlatform()===`ios`&&(async()=>{let t=we(),i=await t.addListener(`backStarted`,()=>{q(o.getState().secondary)&&e.conceal()}),a=await t.addListener(`backCancelled`,()=>{e.reveal()});if(r){i.remove(),a.remove();return}n=[i,a]})(),()=>{r=!0,t();for(let e of n)e.remove();n=[]}},Oe=e=>/^#[0-9a-fA-F]{6}$/.test(e),ke=e=>/^#[0-9a-fA-F]{8}$/.test(e),Ae=(e,t)=>/^[0-9a-fA-F]{2}$/.test(t)?Oe(e)?`${e}${t}`:ke(e)?`${e.slice(0,7)}${t}`:e:e,J=(e,t)=>typeof e==`string`&&e.trim().length>0?e:t,je=e=>{let t=e.colors.syntax.base,n=e.colors.syntax.tokens??{},r=(e,t)=>J(n[e],t);return[{name:`plain`,scope:[`source`,`support.type.property-name.css`],settings:{foreground:t.foreground}},{name:`classes`,scope:[`entity.name.type.class`],settings:{foreground:r(`className`,r(`class`,t.function))}},{name:`interfaces`,scope:[`entity.name.type.interface`,`entity.name.type`],settings:{foreground:r(`interface`,t.type)}},{name:`structs`,scope:[`entity.name.type.struct`],settings:{foreground:r(`struct`,t.function)}},{name:`enums`,scope:[`entity.name.type.enum`],settings:{foreground:r(`enum`,t.function)}},{name:`keys`,scope:[`meta.object-literal.key`,`support.type.property-name`],settings:{foreground:r(`key`,t.function)}},{name:`methods`,scope:[`entity.name.function.method`,`meta.function.method`],settings:{foreground:r(`method`,e.colors.status.success)}},{name:`functions`,scope:[`entity.name.function`,`support.function`,`meta.function-call.generic`],settings:{foreground:t.function,fontStyle:`bold`}},{name:`variables`,scope:[`variable`,`meta.variable`,`variable.other.object.property`],settings:{foreground:t.variable}},{name:`variablesOther`,scope:[`variable.other.object`,`variable.other.readwrite.alias`],settings:{foreground:r(`variableOther`,r(`method`,e.colors.status.success))}},{name:`globalVariables`,scope:[`variable.other.global`,`variable.language.this`],settings:{foreground:r(`variableGlobal`,t.number)}},{name:`localVariables`,scope:[`variable.other.local`],settings:{foreground:r(`variableLocal`,e.colors.surface.elevated)}},{name:`parameters`,scope:[`variable.parameter`,`meta.parameter`],settings:{foreground:r(`parameter`,t.foreground)}},{name:`properties`,scope:[`variable.other.property`,`meta.property`],settings:{foreground:r(`variableProperty`,e.colors.status.info)}},{name:`strings`,scope:[`string`,`string.other.link`,`markup.inline.raw.string.markdown`],settings:{foreground:t.string}},{name:`stringEscapeSequences`,scope:[`constant.character.escape`,`constant.other.placeholder`],settings:{foreground:r(`stringEscape`,t.foreground)}},{name:`keywords`,scope:[`keyword`],settings:{foreground:t.keyword}},{name:`keywordsControl`,scope:[`keyword.control.import`,`keyword.control.from`,`keyword.import`],settings:{foreground:r(`keywordImport`,t.operator)}},{name:`storageModifiers`,scope:[`storage.modifier`,`keyword.modifier`,`storage.type`],settings:{foreground:r(`storageModifier`,t.keyword)}},{name:`comments`,scope:[`comment`,`punctuation.definition.comment`],settings:{foreground:t.comment}},{name:`docComments`,scope:[`comment.documentation`,`comment.line.documentation`],settings:{foreground:r(`commentDoc`,e.colors.surface.mutedForeground)}},{name:`numbers`,scope:[`constant.numeric`],settings:{foreground:t.number}},{name:`booleans`,scope:[`constant.language`],settings:{foreground:r(`boolean`,t.type)}},{name:`operators`,scope:[`keyword.operator`],settings:{foreground:t.operator}},{name:`macros`,scope:[`entity.name.function.preprocessor`,`meta.preprocessor`],settings:{foreground:r(`macro`,t.keyword)}},{name:`preprocessor`,scope:[`meta.preprocessor`],settings:{foreground:r(`preprocessor`,r(`label`,t.number))}},{name:`urls`,scope:[`markup.underline.link`],settings:{foreground:r(`url`,e.colors.status.info)}},{name:`tags`,scope:[`entity.name.tag`],settings:{foreground:r(`tag`,t.keyword)}},{name:`jsxTags`,scope:[`support.class.component`],settings:{foreground:r(`jsxTag`,r(`label`,t.number))}},{name:`attributes`,scope:[`entity.other.attribute-name`,`meta.attribute`],settings:{foreground:r(`tagAttribute`,t.type)}},{name:`types`,scope:[`support.type`],settings:{foreground:t.type}},{name:`constants`,scope:[`variable.other.constant`,`variable.readonly`],settings:{foreground:r(`constant`,t.foreground)}},{name:`labels`,scope:[`entity.name.label`,`punctuation.definition.label`],settings:{foreground:r(`label`,r(`variableGlobal`,t.number))}},{name:`namespaces`,scope:[`entity.name.namespace`,`storage.modifier.namespace`,`markup.bold.markdown`],settings:{foreground:r(`namespace`,t.type)}},{name:`modules`,scope:[`entity.name.module`,`storage.modifier.module`],settings:{foreground:r(`module`,t.operator)}},{name:`typeParameters`,scope:[`variable.type.parameter`,`variable.parameter.type`],settings:{foreground:r(`typeParameter`,t.function)}},{name:`exceptions`,scope:[`keyword.control.exception`,`keyword.control.trycatch`],settings:{foreground:r(`exception`,r(`label`,t.number))}},{name:`decorators`,scope:[`meta.decorator`,`punctuation.decorator`,`entity.name.function.decorator`],settings:{foreground:r(`decorator`,t.type)}},{name:`calls`,scope:[`variable.function`],settings:{foreground:t.foreground}},{name:`punctuation`,scope:[`punctuation`,`punctuation.terminator`,`punctuation.definition.tag`,`punctuation.separator`,`punctuation.definition.string`,`punctuation.section.block`],settings:{foreground:r(`punctuation`,t.comment)}},{name:`yellow`,scope:[`storage.type.numeric.go`,`storage.type.byte.go`,`storage.type.boolean.go`,`storage.type.string.go`,`storage.type.uintptr.go`,`storage.type.error.go`,`storage.type.rune.go`,`constant.language.go`,`support.class.dart`,`keyword.other.documentation`,`storage.modifier.import.java`,`punctuation.definition.list.begin.markdown`,`punctuation.definition.quote.begin.markdown`,`meta.separator.markdown`,`entity.name.section.markdown`],settings:{foreground:t.type}},{name:`green`,scope:[],settings:{foreground:r(`method`,e.colors.status.success)}},{name:`cyan`,scope:[`markup.italic.markdown`,`support.type.python`,`variable.legacy.builtin.python`,`support.constant.property-value.css`,`storage.modifier.attribute.swift`],settings:{foreground:t.string}},{name:`blue`,scope:[],settings:{foreground:t.keyword}},{name:`purple`,scope:[`keyword.channel.go`,`keyword.other.platform.os.swift`],settings:{foreground:t.number}},{name:`magenta`,scope:[`punctuation.definition.heading.markdown`],settings:{foreground:r(`label`,r(`variableGlobal`,t.number))}},{name:`red`,scope:[],settings:{foreground:t.operator}},{name:`orange`,scope:[],settings:{foreground:t.function}}]},Y=e=>{let t=e.colors.surface,n=e.colors.interactive,r=e.colors.status,i=e.colors.syntax.base,a=e.colors.syntax.highlights??{},o=J(a.diffAddedBackground,r.successBackground),s=J(a.diffRemovedBackground,r.errorBackground);return{"editor.background":t.background,"editor.foreground":t.foreground,"editor.hoverHighlightBackground":J(n.hover,t.subtle),"editor.lineHighlightBackground":t.muted,"editor.selectionBackground":n.selection,"editor.selectionHighlightBackground":n.selection,"editor.findMatchBackground":i.type,"editor.findMatchHighlightBackground":Ae(i.type,`cc`),"editor.findRangeHighlightBackground":t.muted,"editor.inactiveSelectionBackground":t.elevated,"editor.lineHighlightBorder":t.elevated,"editor.rangeHighlightBackground":J(n.active,n.borderHover),"notifications.background":t.elevated,"editorInlayHint.typeBackground":t.subtle,"editorInlayHint.typeForeground":t.foreground,"editorWhitespace.foreground":n.borderHover,"editorIndentGuide.background1":t.subtle,"editorHoverWidget.background":t.elevated,"editorLineNumber.activeForeground":J(a.lineNumberActive,t.foreground),"editorLineNumber.foreground":J(a.lineNumber,t.mutedForeground),"editorGutter.background":t.background,"editorGutter.modifiedBackground":r.info,"editorGutter.addedBackground":r.success,"editorGutter.deletedBackground":r.error,"editorBracketMatch.background":t.elevated,"editorBracketMatch.border":t.subtle,"editorError.foreground":r.error,"editorWarning.foreground":r.warning,"editorInfo.foreground":r.info,"diffEditor.insertedTextBackground":o,"diffEditor.removedTextBackground":s,"editorGroupHeader.tabsBackground":t.background,"editorGroup.border":n.border,"tab.activeBackground":t.background,"tab.inactiveBackground":t.muted,"tab.inactiveForeground":t.mutedForeground,"tab.activeForeground":t.foreground,"tab.hoverBackground":t.subtle,"tab.unfocusedHoverBackground":t.subtle,"tab.border":n.border,"tab.activeModifiedBorder":i.type,"tab.inactiveModifiedBorder":r.info,"tab.unfocusedActiveModifiedBorder":i.type,"tab.unfocusedInactiveModifiedBorder":r.info,"editorWidget.background":t.muted,"editorWidget.border":n.border,"editorSuggestWidget.background":t.background,"editorSuggestWidget.border":n.border,"editorSuggestWidget.foreground":t.foreground,"editorSuggestWidget.highlightForeground":t.mutedForeground,"editorSuggestWidget.selectedBackground":t.subtle,"peekView.border":n.border,"peekViewEditor.background":t.background,"peekViewEditor.matchHighlightBackground":t.subtle,"peekViewResult.background":t.muted,"peekViewResult.fileForeground":t.foreground,"peekViewResult.lineForeground":t.mutedForeground,"peekViewResult.matchHighlightBackground":t.subtle,"peekViewResult.selectionBackground":t.elevated,"peekViewResult.selectionForeground":t.mutedForeground,"peekViewTitle.background":t.subtle,"peekViewTitleDescription.foreground":t.mutedForeground,"peekViewTitleLabel.foreground":t.foreground,"merge.currentHeaderBackground":r.success,"merge.currentContentBackground":J(a.diffAdded,r.success),"merge.incomingHeaderBackground":r.info,"merge.incomingContentBackground":J(a.diffModified,r.info),"merge.border":n.border,"merge.commonContentBackground":t.subtle,"merge.commonHeaderBackground":t.muted,"panel.background":t.background,"panel.border":n.border,"panelTitle.activeBorder":n.borderHover,"panelTitle.activeForeground":t.foreground,"panelTitle.inactiveForeground":t.mutedForeground,"statusBar.background":t.background,"statusBar.foreground":t.foreground,"statusBar.border":n.border,"statusBar.debuggingBackground":r.error,"statusBar.debuggingForeground":r.errorForeground,"statusBar.noFolderBackground":t.subtle,"statusBar.noFolderForeground":t.mutedForeground,"titleBar.activeBackground":t.background,"titleBar.activeForeground":t.foreground,"titleBar.inactiveBackground":t.muted,"titleBar.inactiveForeground":t.mutedForeground,"titleBar.border":n.border,"menu.foreground":t.foreground,"menu.background":t.background,"menu.selectionForeground":t.foreground,"menu.selectionBackground":t.subtle,"menu.border":n.border,"editorInlayHint.foreground":t.mutedForeground,"editorInlayHint.background":t.subtle,"terminal.foreground":t.foreground,"terminal.background":t.background,"terminalCursor.foreground":t.foreground,"terminalCursor.background":t.background,"terminal.ansiRed":J(a.diffRemoved,r.error),"terminal.ansiGreen":J(a.diffAdded,r.success),"terminal.ansiYellow":r.warning,"terminal.ansiBlue":J(a.diffModified,r.info),"terminal.ansiMagenta":i.keyword,"terminal.ansiCyan":i.type,"activityBar.background":t.background,"activityBar.foreground":t.foreground,"activityBar.inactiveForeground":t.mutedForeground,"activityBar.activeBorder":t.foreground,"activityBar.border":n.border,"sideBar.background":t.background,"sideBar.foreground":t.foreground,"sideBar.border":n.border,"sideBarTitle.foreground":t.foreground,"sideBarSectionHeader.background":t.muted,"sideBarSectionHeader.foreground":t.foreground,"sideBarSectionHeader.border":n.border,"sideBar.activeBackground":t.subtle,"sideBar.activeForeground":t.foreground,"sideBar.hoverBackground":t.muted,"sideBar.hoverForeground":t.foreground,"list.warningForeground":r.warning,"list.errorForeground":r.error,"list.inactiveSelectionBackground":t.subtle,"list.activeSelectionBackground":t.elevated,"list.inactiveSelectionForeground":t.foreground,"list.activeSelectionForeground":t.foreground,"list.hoverForeground":t.foreground,"list.hoverBackground":t.muted,"input.background":t.muted,"input.foreground":t.foreground,"input.border":n.border,"input.placeholderForeground":t.mutedForeground,"inputOption.activeBorder":n.border,"inputOption.activeBackground":t.elevated,"inputOption.activeForeground":t.foreground,"inputValidation.infoBackground":r.infoBackground,"inputValidation.infoBorder":r.infoBorder,"inputValidation.warningBackground":r.warningBackground,"inputValidation.warningBorder":r.warningBorder,"inputValidation.errorBackground":r.errorBackground,"inputValidation.errorBorder":r.errorBorder,"dropdown.background":t.muted,"dropdown.foreground":t.foreground,"dropdown.border":n.border,"dropdown.listBackground":t.background,"badge.background":e.colors.primary.base,"activityBarBadge.background":e.colors.primary.base,"button.background":e.colors.primary.base,"button.foreground":J(e.colors.primary.foreground,t.background),"badge.foreground":J(e.colors.primary.foreground,t.background),"activityBarBadge.foreground":J(e.colors.primary.foreground,t.background)}};function Me(e){return{name:e.metadata.name,type:e.metadata.variant,colors:Y(e),tokenColors:je(e)}}var Ne=e=>/^#[0-9a-fA-F]{8}$/.test(e),X=e=>Ne(e)?e.slice(0,7):e;function Pe(e,t){return Object.defineProperty(e,"toString",{value:()=>t,enumerable:!1,configurable:!0}),Object.defineProperty(e,Symbol.toPrimitive,{value:()=>t,enumerable:!1,configurable:!0}),e}var Z=new Map,Q=new Set,Fe=(e,t)=>{let n=e.colors?.[`editor.background`],r=e.colors?.[`editor.foreground`],i=n?X(n):void 0,a=r?X(r):void 0;if(!i||!a)throw Error(`Theme "${t}" is missing editor.background/editor.foreground`);let o=e.tokenColors??[];return Pe({...e,name:t,fg:a,bg:i,settings:o},t)},Ie=e=>Me(e),$=e=>{let t=Z.get(e.metadata.id);if(t)return t;let n=Fe(Ie(e),e.metadata.id);return Z.set(e.metadata.id,n),n},Le=e=>{let t=e.metadata.id;if(Q.has(t))return;let n=$(e);a(t,async()=>n),Q.add(t)};export{te as A,Se as C,me as D,k as E,ee as M,f as N,E as O,de as S,pe as T,j as _,G as a,fe as b,ue as c,I as d,ve as f,_e as g,W as h,Ee as i,p as j,he as k,le as l,C as m,$ as n,_ as o,oe as p,De as r,v as s,Le as t,L as u,F as v,Ce as w,se as x,A as y};
@@ -1 +1 @@
1
- import{r as e}from"./themes-BgDJcxRc.js";import{t}from"./theme-validation-BGYdrOu7.js";var n=`yuri.file-icon`,r=`http://www.w3.org/2000/svg`,i=new Set([`svg`,`g`,`path`,`rect`,`circle`,`ellipse`,`line`,`polyline`,`polygon`,`defs`,`linearGradient`,`radialGradient`,`stop`,`clipPath`,`mask`,`use`,`title`,`desc`]),a=e=>e.trim().replace(/^\./,``).toLowerCase();function o(e,t){if(typeof e!=`string`)throw Error(`GUI file icon requires SVG text`);let n=t.get(e);if(n)return n;if(e.length>16384)throw Error(`GUI file icon SVG exceeds 16 KiB`);let a=new TextEncoder().encode(e).byteLength;if(a>16384)throw Error(`GUI file icon SVG exceeds 16 KiB`);if(!/^\s*<svg[\s>]/.test(e)||/<!|<\?/.test(e))throw Error(`Invalid GUI file icon SVG`);let o=new DOMParser().parseFromString(e,`image/svg+xml`),s=o.documentElement;if(s?.localName!==`svg`||s.namespaceURI!==r||o.querySelector(`parsererror`))throw Error(`Invalid GUI file icon SVG`);for(let e of[s,...s.querySelectorAll(`*`)]){if(e.namespaceURI!==r||!i.has(e.localName))throw Error(`Unsupported GUI file icon SVG element`);for(let t of e.attributes){let e=t.name.toLowerCase(),n=t.value.trim();if(e.startsWith(`on`)||e===`style`||e===`xml:base`||n.includes(`\\`)||Array.from(n).some(e=>e.charCodeAt(0)<32)||(e===`href`||e.endsWith(`:href`))&&!/^#[\w.-]+$/.test(n)||/url\s*\(/i.test(n)&&!/^url\(\s*#[\w.-]+\s*\)$/.test(n))throw Error(`Unsupported GUI file icon SVG reference or attribute`)}}let c={source:e,bytes:a,uri:`data:image/svg+xml,${encodeURIComponent(e)}`};return t.set(e,c),c}function s(e){return o(e,new Map).uri}var c=class{plugins=new Map;index=new Map;listeners=new Set;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});get(e,t){if(t?.isDirectory)return;let n=e.split(/[\\/]/).at(-1)??``,r=t?.extension??(n.includes(`.`)?n.slice(n.lastIndexOf(`.`)+1):``),i=this.index.get(a(r));return t?.themeVariant===`light`?i?.light.uri:i?.dark.uri}replace(e,t){if(t.length>64)throw Error(`GUI file icon per-plugin limit exceeded`);if(!t.length){this.remove(e);return}let n=new Map;for(let t of this.plugins.get(e)??[])for(let e of[t.dark,t.light])n.set(e.source,e);let r=new Set,i=t.map(e=>{if(!e||typeof e!=`object`||!(`id`in e)||typeof e.id!=`string`||!e.id.trim()||e.id.length>128||r.has(e.id))throw Error(`Invalid or duplicate GUI file icon id`);if(r.add(e.id),!(`extensions`in e)||!Array.isArray(e.extensions)||!e.extensions.length||e.extensions.length>64)throw Error(`GUI file icon requires 1–64 extensions`);let t=e.extensions.map(e=>{if(typeof e!=`string`)throw Error(`Invalid GUI file icon extension`);let t=a(e);if(!/^[a-z0-9][a-z0-9_+-]{0,63}$/.test(t))throw Error(`Invalid GUI file icon extension`);return t}),i=o(`svg`in e?e.svg:void 0,n),s=`lightSvg`in e&&e.lightSvg!==void 0?o(e.lightSvg,n):i;return{id:e.id,extensions:[...new Set(t)],dark:i,light:s}}),s=i.length,c=i.reduce((e,t)=>e+t.dark.bytes+t.light.bytes,0);for(let[t,n]of this.plugins)t!==e&&(s+=n.length,c+=n.reduce((e,t)=>e+t.dark.bytes+t.light.bytes,0));if(s>512||c>8388608)throw Error(`GUI file icon total limit exceeded`);this.plugins.set(e,i),this.publish()}remove(e){this.plugins.delete(e)&&this.publish()}dispose(){this.plugins.clear(),this.publish(),this.listeners.clear()}publish(){let e=new Map;for(let t of this.plugins.values())for(let n of t)for(let t of n.extensions)e.set(t,n);let t=e.size!==this.index.size||[...e].some(([e,t])=>{let n=this.index.get(e);return n?.dark.uri!==t.dark.uri||n?.light.uri!==t.light.uri});if(this.index=e,t)for(let e of this.listeners)e()}},l=`yuri.theme`,u=`yuri.branding`,d=Object.freeze({themes:[],branding:[]}),f=(e,t)=>JSON.stringify([e,t]);function p(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Expected an appearance object`);return e}function m(e,t){if(t===void 0)return e;if(!t||typeof t!=`object`||Array.isArray(t))return t;let n={...p(e??{})};for(let[e,r]of Object.entries(t)){if([`__proto__`,`prototype`,`constructor`].includes(e))throw Error(`Invalid appearance property`);n[e]=m(n[e],r)}return n}function h(e,t){let n=e=>{if(!Object.values(p(e)).every(e=>typeof e==`string`))throw Error(`Theme tokens must be strings`)};for(let[t,r]of Object.entries(e))if(t===`syntax`)for(let[e,t]of Object.entries(p(r)))e===`languages`?Object.values(p(t)).forEach(n):n(t);else if(t===`tools`||t===`toast`)for(let e of Object.values(p(r)))typeof e!=`string`&&n(e);else if(t===`buttons`||t===`badges`)Object.values(p(r)).forEach(n);else if(t===`charts`){if(!Object.values(p(r)).every(e=>typeof e==`string`||Array.isArray(e)&&e.every(e=>typeof e==`string`)))throw Error(`Invalid chart colors`)}else if(t===`a11y`){if(!Object.values(p(r)).every(e=>typeof e==`string`||typeof e==`boolean`))throw Error(`Invalid accessibility tokens`)}else n(r);t!==void 0&&Object.values(p(t)).forEach(n)}function g(e){if(typeof e!=`string`||e.length>2097152||!/^data:image\/png;base64,iVBORw0KGgo[A-Za-z0-9+/]*={0,2}$/.test(e))throw Error(`Dock icons require an inline PNG data URL, at most 2 MiB`);return e}var _=class{plugins=new Map;order=[];snapshot=d;listeners=new Set;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.snapshot;setOrder(e){e.length===this.order.length&&e.every((e,t)=>e===this.order[t])||(this.order=[...e],this.plugins.size&&this.publish())}replace(n,r,i,a){if(r.length>16||i.length>8)throw Error(`Appearance contribution limit exceeded`);if(!r.length&&!i.length){this.remove(n);return}let o=JSON.stringify([r,i,a]);if(this.plugins.get(n)?.signature===o)return;let c=new TextEncoder().encode(o).byteLength;if(c>8388608)throw Error(`Appearance resources exceed 8 MiB`);let l=new Set,u=(e,t)=>{let r=p(e);if(typeof r.id!=`string`||!r.id.trim()||r.id.length>128||typeof r.title!=`string`||!r.title.trim()||r.title.length>128||l.has(`${t}:${r.id}`))throw Error(`Invalid or duplicate appearance id/title`);return l.add(`${t}:${r.id}`),{value:r,key:f(n,r.id),title:r.title}},d=r.map(n=>{let{value:r,key:i,title:a}=u(n,`theme`);if(r.variant!==`light`&&r.variant!==`dark`)throw Error(`Invalid theme variant`);if(new TextEncoder().encode(JSON.stringify(r)).byteLength>65536)throw Error(`Theme exceeds 64 KiB`);let o=e(r.variant===`dark`),s={...o,metadata:{...o.metadata,id:`gui:${i}`,name:a,variant:r.variant},colors:m(o.colors,r.colors),config:m(o.config,r.config)};if(!t(s))throw Error(`Invalid plugin theme colors`);return h(s.colors,s.config),structuredClone(s)}),_=i.map(e=>{let{value:t,key:r,title:i}=u(e,`brand`);if(t.logo===void 0&&t.dockIcon===void 0)throw Error(`Branding requires a logo or Dock icon`);let o=t.logo===void 0?void 0:p(t.logo),c=t.dockIcon===void 0?void 0:p(t.dockIcon),l=o?s(o.svg):void 0,d=c?g(c.png):void 0;return Object.freeze({key:r,pluginId:n,title:i,native:a,logo:l?{dark:l,light:o?.lightSvg===void 0?l:s(o.lightSvg)}:void 0,dockIcon:d?{dark:d,light:c?.lightPng===void 0?d:g(c.lightPng)}:void 0})}),v=[...this.plugins].filter(([e])=>e!==n).map(([,e])=>e);if(d.length+v.reduce((e,t)=>e+t.themes.length,0)>128||_.length+v.reduce((e,t)=>e+t.branding.length,0)>64||c+v.reduce((e,t)=>e+t.bytes,0)>16777216)throw Error(`Window appearance catalog limit exceeded`);this.plugins.set(n,{themes:d,branding:_,signature:o,bytes:c}),this.publish()}remove(e){this.plugins.delete(e)&&this.publish()}dispose(){this.plugins.clear(),this.publish(),this.listeners.clear()}publish(){let e=new Map(this.order.map((e,t)=>[e,t])),t=[...this.plugins].sort(([t],[n])=>(e.get(t)??-1)-(e.get(n)??-1)).map(([,e])=>e);this.snapshot=t.length?{themes:t.flatMap(e=>e.themes).reverse(),branding:t.flatMap(e=>e.branding).reverse()}:d;for(let e of this.listeners)e()}};export{n as a,_ as i,u as n,c as o,l as r,d as t};
1
+ import{r as e}from"./themes-BgDJcxRc.js";import{t}from"./theme-validation-BGYdrOu7.js";var n=`yuri.file-icon`,r=`http://www.w3.org/2000/svg`,i=new Set([`svg`,`g`,`path`,`rect`,`circle`,`ellipse`,`line`,`polyline`,`polygon`,`defs`,`linearGradient`,`radialGradient`,`stop`,`clipPath`,`mask`,`use`,`title`,`desc`]),a=e=>e.trim().replace(/^\./,``).toLowerCase();function o(e,t){if(typeof e!=`string`)throw Error(`GUI file icon requires SVG text`);let n=t.get(e);if(n)return n;if(e.length>16384)throw Error(`GUI file icon SVG exceeds 16 KiB`);let a=new TextEncoder().encode(e).byteLength;if(a>16384)throw Error(`GUI file icon SVG exceeds 16 KiB`);if(!/^\s*<svg[\s>]/.test(e)||/<!|<\?/.test(e))throw Error(`Invalid GUI file icon SVG`);let o=new DOMParser().parseFromString(e,`image/svg+xml`),s=o.documentElement;if(s?.localName!==`svg`||s.namespaceURI!==r||o.querySelector(`parsererror`))throw Error(`Invalid GUI file icon SVG`);for(let e of[s,...s.querySelectorAll(`*`)]){if(e.namespaceURI!==r||!i.has(e.localName))throw Error(`Unsupported GUI file icon SVG element`);for(let t of e.attributes){let e=t.name.toLowerCase(),n=t.value.trim();if(e.startsWith(`on`)||e===`style`||e===`xml:base`||n.includes(`\\`)||Array.from(n).some(e=>e.charCodeAt(0)<32)||(e===`href`||e.endsWith(`:href`))&&!/^#[\w.-]+$/.test(n)||/url\s*\(/i.test(n)&&!/^url\(\s*#[\w.-]+\s*\)$/.test(n))throw Error(`Unsupported GUI file icon SVG reference or attribute`)}}let c={source:e,bytes:a,uri:`data:image/svg+xml,${encodeURIComponent(e)}`};return t.set(e,c),c}function s(e){return o(e,new Map).uri}var c=class{plugins=new Map;index=new Map;listeners=new Set;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});get(e,t){if(t?.isDirectory)return;let n=e.split(/[\\/]/).at(-1)??``,r=t?.extension??(n.includes(`.`)?n.slice(n.lastIndexOf(`.`)+1):``),i=this.index.get(a(r));return t?.themeVariant===`light`?i?.light.uri:i?.dark.uri}replace(e,t){if(t.length>64)throw Error(`GUI file icon per-plugin limit exceeded`);if(!t.length){this.remove(e);return}let n=new Map;for(let t of this.plugins.get(e)??[])for(let e of[t.dark,t.light])n.set(e.source,e);let r=new Set,i=t.map(e=>{if(!e||typeof e!=`object`||!(`id`in e)||typeof e.id!=`string`||!e.id.trim()||e.id.length>128||r.has(e.id))throw Error(`Invalid or duplicate GUI file icon id`);if(r.add(e.id),!(`extensions`in e)||!Array.isArray(e.extensions)||!e.extensions.length||e.extensions.length>64)throw Error(`GUI file icon requires 1–64 extensions`);let t=e.extensions.map(e=>{if(typeof e!=`string`)throw Error(`Invalid GUI file icon extension`);let t=a(e);if(!/^[a-z0-9][a-z0-9_+-]{0,63}$/.test(t))throw Error(`Invalid GUI file icon extension`);return t}),i=o(`svg`in e?e.svg:void 0,n),s=`lightSvg`in e&&e.lightSvg!==void 0?o(e.lightSvg,n):i;return{id:e.id,extensions:[...new Set(t)],dark:i,light:s}}),s=i.length,c=i.reduce((e,t)=>e+t.dark.bytes+t.light.bytes,0);for(let[t,n]of this.plugins)t!==e&&(s+=n.length,c+=n.reduce((e,t)=>e+t.dark.bytes+t.light.bytes,0));if(s>512||c>8388608)throw Error(`GUI file icon total limit exceeded`);this.plugins.set(e,i),this.publish()}remove(e){this.plugins.delete(e)&&this.publish()}dispose(){this.plugins.clear(),this.publish(),this.listeners.clear()}publish(){let e=new Map;for(let t of this.plugins.values())for(let n of t)for(let t of n.extensions)e.set(t,n);let t=e.size!==this.index.size||[...e].some(([e,t])=>{let n=this.index.get(e);return n?.dark.uri!==t.dark.uri||n?.light.uri!==t.light.uri});if(this.index=e,t)for(let e of this.listeners)e()}},l=`yuri.theme`,u=`yuri.branding`,d=Object.freeze({themes:[],branding:[]}),f=(e,t)=>JSON.stringify([e,t]);function p(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Expected an appearance object`);return e}function m(e,t){if(t===void 0)return e;if(!t||typeof t!=`object`||Array.isArray(t))return t;let n={...p(e??{})};for(let[e,r]of Object.entries(t)){if([`__proto__`,`prototype`,`constructor`].includes(e))throw Error(`Invalid appearance property`);n[e]=m(n[e],r)}return n}function h(e,t){let n=e=>{if(!Object.values(p(e)).every(e=>typeof e==`string`))throw Error(`Theme tokens must be strings`)};for(let[t,r]of Object.entries(e))if(t===`syntax`)for(let[e,t]of Object.entries(p(r)))e===`languages`?Object.values(p(t)).forEach(n):n(t);else if(t===`tools`||t===`toast`)for(let e of Object.values(p(r)))typeof e!=`string`&&n(e);else if(t===`buttons`||t===`badges`)Object.values(p(r)).forEach(n);else if(t===`charts`){if(!Object.values(p(r)).every(e=>typeof e==`string`||Array.isArray(e)&&e.every(e=>typeof e==`string`)))throw Error(`Invalid chart colors`)}else if(t===`a11y`){if(!Object.values(p(r)).every(e=>typeof e==`string`||typeof e==`boolean`))throw Error(`Invalid accessibility tokens`)}else n(r);t!==void 0&&Object.values(p(t)).forEach(n)}function g(e){if(typeof e!=`string`||e.length>2097152||!/^data:image\/png;base64,iVBORw0KGgo[A-Za-z0-9+/]*={0,2}$/.test(e))throw Error(`Dock icons require an inline PNG data URL, at most 2 MiB`);return e}var _=class{plugins=new Map;order=[];snapshot=d;listeners=new Set;subscribe=e=>(this.listeners.add(e),()=>{this.listeners.delete(e)});getSnapshot=()=>this.snapshot;setOrder(e){e.length===this.order.length&&e.every((e,t)=>e===this.order[t])||(this.order=[...e],this.plugins.size&&this.publish())}replace(n,r,i,a){if(r.length>16||i.length>8)throw Error(`Appearance contribution limit exceeded`);if(!r.length&&!i.length){this.remove(n);return}let o=JSON.stringify([r,i,a]);if(this.plugins.get(n)?.signature===o)return;let c=new TextEncoder().encode(o).byteLength;if(c>8388608)throw Error(`Appearance resources exceed 8 MiB`);let l=new Set,u=(e,t)=>{let r=p(e);if(typeof r.id!=`string`||!r.id.trim()||r.id.length>128||typeof r.title!=`string`||!r.title.trim()||r.title.length>128||l.has(`${t}:${r.id}`))throw Error(`Invalid or duplicate appearance id/title`);return l.add(`${t}:${r.id}`),{value:r,key:f(n,r.id),title:r.title}},d=r.map(n=>{let{value:r,key:i,title:a}=u(n,`theme`);if(r.variant!==`light`&&r.variant!==`dark`)throw Error(`Invalid theme variant`);if(new TextEncoder().encode(JSON.stringify(r)).byteLength>65536)throw Error(`Theme exceeds 64 KiB`);let o=e(r.variant===`dark`),s={...o,metadata:{...o.metadata,id:`gui:${i}`,name:a,variant:r.variant},colors:m(o.colors,r.colors),config:m(o.config,r.config)};if(!t(s))throw Error(`Invalid plugin theme colors`);return h(s.colors,s.config),structuredClone(s)}),_=i.map(e=>{let{value:t,key:r,title:i}=u(e,`brand`);if(t.logo===void 0&&t.dockIcon===void 0)throw Error(`Branding requires a logo or Dock icon`);let o=t.logo===void 0?void 0:p(t.logo),c=t.dockIcon===void 0?void 0:p(t.dockIcon),l=o?s(o.svg):void 0,d=c?g(c.png):void 0;return Object.freeze({key:r,pluginId:n,title:i,native:a,logo:l?{dark:l,light:o?.lightSvg===void 0?l:s(o.lightSvg)}:void 0,dockIcon:d?{dark:d,light:c?.lightPng===void 0?d:g(c.lightPng)}:void 0})}),v=[...this.plugins].filter(([e])=>e!==n).map(([,e])=>e);if(d.length+v.reduce((e,t)=>e+t.themes.length,0)>128||_.length+v.reduce((e,t)=>e+t.branding.length,0)>64||c+v.reduce((e,t)=>e+t.bytes,0)>16777216)throw Error(`Window appearance catalog limit exceeded`);this.plugins.set(n,{themes:d,branding:_,signature:o,bytes:c}),this.publish()}remove(e){this.plugins.delete(e)&&this.publish()}dispose(){this.plugins.clear(),this.publish(),this.listeners.clear()}publish(){let e=new Map(this.order.map((e,t)=>[e,t])),t=[...this.plugins].sort(([t],[n])=>(e.get(t)??-1)-(e.get(n)??-1)).map(([,e])=>e);this.snapshot=t.length?{themes:t.flatMap(e=>e.themes).reverse(),branding:t.flatMap(e=>e.branding).reverse()}:d;for(let e of this.listeners)e()}};export{n as a,_ as i,u as n,c as o,l as r,s,d as t};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,c as n,d as r,s as i}from"./runtime-auth-Bh3htXtG.js";import{c as a,i as o}from"./runtime-switch-ibQIZnws.js";import{n as s}from"./runtime-fetch-9B8F_rKW.js";import{d as c,g as l,h as u,i as d,l as f,m as p,n as m,p as h,u as g}from"./runtime-file-resource-tDTBpJT_.js";var _=26214400,v=class extends Error{status;code;constructor(e,t,n=`Failed to upload assistant attachment`){super(n),this.name=`AssistantAttachmentUploadError`,this.status=e,this.code=t}},y=e=>typeof e==`object`&&!!e&&!Array.isArray(e),b=e=>[...new Uint8Array(e)].map(e=>e.toString(16).padStart(2,`0`)).join(``),x=async e=>{let t;if(e instanceof ArrayBuffer)t=e;else if(ArrayBuffer.isView(e)){let n=e;t=n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength)}else t=await e.arrayBuffer();return b(await crypto.subtle.digest(`SHA-256`,t))},S=e=>typeof e==`string`?e.split(`;`)[0]?.trim().toLowerCase():``,C=e=>{if(!Number.isSafeInteger(e)||e<0)throw new v(0,`rejected`,`Invalid attachment size`);if(e>26214400)throw new v(413,`too-large`)},w=(e,t,n={})=>{if(!y(e))throw new v(0,`integrity`,`Attachment response was not a JSON object`);if(e.type!==`file`)throw new v(0,`integrity`,`Attachment response type must be file`);let r=typeof e.attachmentID==`string`?e.attachmentID.trim():``,i=typeof e.sha256==`string`?e.sha256.trim().toLowerCase():``,a=typeof e.size==`number`&&Number.isSafeInteger(e.size)?e.size:NaN,o=S(typeof e.mime==`string`?e.mime:``),s=typeof e.filename==`string`&&e.filename.trim()?e.filename.trim():void 0;if(!r)throw new v(0,`integrity`,`Attachment response missing attachmentID`);if(!/^[a-f0-9]{64}$/i.test(i))throw new v(0,`integrity`,`Attachment response missing sha256`);if(!Number.isSafeInteger(a)||a<0)throw new v(0,`integrity`,`Attachment response missing size`);if(!o)throw new v(0,`integrity`,`Attachment response missing mime`);if((n.enforceUploadLimit===!0||t)&&C(a),t){if(i!==t.sha256.toLowerCase())throw new v(0,`integrity`,`Attachment SHA-256 mismatch`);if(a!==t.size)throw new v(0,`integrity`,`Attachment size mismatch`);if(o!==t.mime)throw new v(0,`integrity`,`Attachment mime mismatch`)}return{type:`file`,attachmentID:r,sha256:i,size:a,mime:o,...s?{filename:s}:{}}},T=async(e,t,n,r)=>{let i=m(),a=typeof e==`string`?e.trim():``,o=typeof n==`string`?n.trim():``;if(!a||!o)throw new v(0,`rejected`,`assistantID and uploadID are required`);if(!(t instanceof Blob))throw new v(0,`rejected`,`file must be a File or Blob`);let c=S(t.type||t.type)||`application/octet-stream`,l=t.type===c?t:new Blob([t],{type:c});C(l.size);let u=await x(l),d=typeof t.name==`string`&&t.name.trim()?t.name.trim():void 0,f;try{f=await s(`/api/yuri/assistants/${encodeURIComponent(a)}/contact/attachments/${encodeURIComponent(o)}`,{method:`PUT`,headers:{"Content-Type":c,"X-Content-SHA256":u,"X-Content-Size":String(l.size),...d?{"X-Attachment-Filename":encodeURIComponent(d)}:{}},body:l,signal:r})}catch{throw new v(0,`unavailable`)}if(f.status===204||f.status===205)throw new v(f.status,`integrity`,`Attachment upload returned empty status`);if(f.status===413)throw new v(413,`too-large`);if(!f.ok)throw new v(f.status,f.status>=500||f.status===0?`unavailable`:`rejected`);let p=f.headers.get(`content-type`)?.toLowerCase()??``;if(p.includes(`text/html`)||p.includes(`text/plain`))throw new v(f.status,`integrity`,`Attachment upload returned non-JSON body`);let h;try{let e=await f.text();if(!e.trim())throw new v(f.status,`integrity`,`Attachment upload returned empty body`);if(!p.includes(`application/json`)&&!e.trim().startsWith(`{`))throw new v(f.status,`integrity`,`Attachment upload returned non-JSON body`);h=JSON.parse(e)}catch(e){throw e instanceof v?e:new v(f.status,`integrity`,`Attachment upload response was not valid JSON`)}let g=w(h,{sha256:u,size:l.size,mime:c});return await i(l,u),g},E=e=>{try{return w(e,void 0,{enforceUploadLimit:!1}),!0}catch{return!1}},D=e({clearAssistantAttachmentCacheAll:()=>G,clearAssistantAttachmentCacheForBearer:()=>W,clearAssistantAttachmentCacheScope:()=>U,getAssistantAttachmentBlob:()=>J,getAssistantAttachmentDisplay:()=>Y,resolveAssistantAttachmentCacheScope:()=>R}),O=g,k=class extends Error{status;code;constructor(e,t,n=`Assistant attachment cache error`){super(n),this.status=e,this.code=t,this.name=`AssistantAttachmentCacheError`}},A=async e=>[...new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e)))].map(e=>e.toString(16).padStart(2,`0`)).join(``),j=0,M,N,P=!1,F=new Map,I=new Map,L=new Set,R=async(e={})=>{let t=e.transportIdentity??o(),r=e.authGeneration??i(),a=(e.bearer??n()).trim();return{transportIdentity:t,authGeneration:r,authScope:a?`b:${await A(a)}`:`m:${r}`,authScopeKind:a?`bearer-hash`:`memory-ephemeral`}},z=e=>`assistant:${e.transportIdentity}:${e.authScope}`,B=e=>`assistant-auth:${e}`,V=()=>{j++;for(let e of L)e.abort();L.clear();for(let e of I.values())e.controller.abort(),e.url&&p(e.url);I.clear();for(let e of F.values()){for(let t=0;t<e.refs;t++)h(e.url);p(e.url)}F.clear()},H=()=>{if(!P&&globalThis.indexedDB){P=!0;for(let e of[`yuri-assistant-attachments`,`openchamber-assistant-attachments`,`openchambery-assistant-attachments`])try{globalThis.indexedDB.deleteDatabase(e)}catch{}}M||=a(V),N||=t(e=>{V(),e.reason!==`endpoint-switch`&&d(e.previousBearerDigest?B(`b:${e.previousBearerDigest}`):void 0)})},U=async(e,t=`scope-cleared`)=>{let n=typeof e==`object`?e:await R();V(),await d(z(n))},W=async(e,t=`forget-bearer`)=>{if(!e.trim())return;let n=B(`b:${await A(e.trim())}`);V(),await d(n)},G=async(e=`cleared`)=>{V(),await d()},K=(e,t,n)=>{if(!e.trim()||!E(t))throw new k(0,`rejected`);if(t.size>n)throw new k(413,`too-large`)},q=async(e,t,n,a)=>{H(),K(e,t,n),a?.throwIfAborted();let o=j,c=await R();if(o!==j)throw new k(0,`stale`);let l=new AbortController,u=()=>l.abort(a?.reason);a?.addEventListener(`abort`,u,{once:!0}),L.add(l);let d;try{a?.throwIfAborted();let u=await f({identity:`/api/yuri/assistants/${encodeURIComponent(e.trim())}/contact/attachments/${encodeURIComponent(t.attachmentID)}`,sha256:t.sha256.toLowerCase(),size:t.size,mime:t.mime,filename:t.filename,persistent:c.authScopeKind===`bearer-hash`,tags:[z(c),B(c.authScope)],signal:l.signal,maxBytes:n,load:async n=>{let a=await s(`/api/yuri/assistants/${encodeURIComponent(e.trim())}/contact/attachments/${encodeURIComponent(t.attachmentID)}`,{method:`GET`,cache:`no-store`,signal:n});if(a.status===401||a.status===403)throw d=new k(a.status,`unauthorized`),await U(c,`unauthorized`),i()===c.authGeneration&&r(),new k(a.status,`unauthorized`);if(!a.ok)throw new k(a.status,a.status===413?`too-large`:a.status>=500?`unavailable`:`rejected`);return a}});if(o!==j)throw new k(0,`stale`);return u}catch(e){throw d||(e instanceof k?e:o===j?l.signal.aborted?new k(0,`aborted`):/descriptor limit|streaming destination/i.test(String(e))?new k(413,`too-large`):new k(0,/fingerprint|size|changed|truncated/i.test(String(e))?`integrity`:`unavailable`):new k(0,`stale`))}finally{L.delete(l),a?.removeEventListener(`abort`,u)}},J=(e,t,n={})=>q(e,t,_,n.signal),Y=async(e,t,n={})=>{H(),K(e,t,O),n.signal?.throwIfAborted();let r=j,i=await R(),a=JSON.stringify([z(i),e,t.attachmentID,t.sha256]),o=e=>{if(r!==j||!c(e)||!u(e))throw p(e),new k(0,`stale`);let t=F.get(a)?.url===e?F.get(a):{url:e,refs:0};t.refs++,F.set(a,t);let n=!1;return{url:e,release:()=>{n||(n=!0,F.get(a)===t&&(h(e),--t.refs===0&&(F.delete(a),p(e))))}}},s=F.get(a);if(s&&c(s.url))return o(s.url);let d=I.get(a);if(!d){let n=new AbortController,i={controller:n,refs:0,promise:Promise.resolve(``)};i.promise=q(e,t,O,n.signal).then(e=>l(e,n.signal,{mimeType:t.mime||e.type})).then(e=>{if(i.url=e,r!==j||n.signal.aborted||i.refs===0)throw p(e),new k(0,`stale`);return e}).catch(e=>{throw I.get(a)===i&&I.delete(a),e}),d=i,I.set(a,d)}let f=d;return f.refs++,new Promise((e,t)=>{let r=!1,i=e=>{--f.refs===0&&(e&&f.controller.abort(),I.get(a)===f&&I.delete(a),e&&f.url&&!F.has(a)&&p(f.url))},s=()=>{r||(r=!0,i(!0),t(new k(0,`aborted`)))};n.signal?.addEventListener(`abort`,s,{once:!0}),n.signal?.aborted&&s(),f.promise.then(a=>{if(n.signal?.removeEventListener(`abort`,s),!r){r=!0;try{e(o(a))}catch(e){t(e)}i(!1)}},e=>{n.signal?.removeEventListener(`abort`,s),!r&&(r=!0,i(!1),t(e))})})};export{T as i,J as n,Y as r,D as t};
1
+ import{n as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,c as n,d as r,s as i}from"./runtime-auth-mjIpsk3N.js";import{c as a,i as o}from"./runtime-switch-BMjl5Y5W.js";import{n as s}from"./runtime-fetch-DKZOpfzo.js";import{d as c,g as l,h as u,i as d,l as f,m as p,n as m,p as h,u as g}from"./runtime-file-resource-CL7EVzOG.js";var _=26214400,v=class extends Error{status;code;constructor(e,t,n=`Failed to upload assistant attachment`){super(n),this.name=`AssistantAttachmentUploadError`,this.status=e,this.code=t}},y=e=>typeof e==`object`&&!!e&&!Array.isArray(e),b=e=>[...new Uint8Array(e)].map(e=>e.toString(16).padStart(2,`0`)).join(``),x=async e=>{let t;if(e instanceof ArrayBuffer)t=e;else if(ArrayBuffer.isView(e)){let n=e;t=n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength)}else t=await e.arrayBuffer();return b(await crypto.subtle.digest(`SHA-256`,t))},S=e=>typeof e==`string`?e.split(`;`)[0]?.trim().toLowerCase():``,C=e=>{if(!Number.isSafeInteger(e)||e<0)throw new v(0,`rejected`,`Invalid attachment size`);if(e>26214400)throw new v(413,`too-large`)},w=(e,t,n={})=>{if(!y(e))throw new v(0,`integrity`,`Attachment response was not a JSON object`);if(e.type!==`file`)throw new v(0,`integrity`,`Attachment response type must be file`);let r=typeof e.attachmentID==`string`?e.attachmentID.trim():``,i=typeof e.sha256==`string`?e.sha256.trim().toLowerCase():``,a=typeof e.size==`number`&&Number.isSafeInteger(e.size)?e.size:NaN,o=S(typeof e.mime==`string`?e.mime:``),s=typeof e.filename==`string`&&e.filename.trim()?e.filename.trim():void 0;if(!r)throw new v(0,`integrity`,`Attachment response missing attachmentID`);if(!/^[a-f0-9]{64}$/i.test(i))throw new v(0,`integrity`,`Attachment response missing sha256`);if(!Number.isSafeInteger(a)||a<0)throw new v(0,`integrity`,`Attachment response missing size`);if(!o)throw new v(0,`integrity`,`Attachment response missing mime`);if((n.enforceUploadLimit===!0||t)&&C(a),t){if(i!==t.sha256.toLowerCase())throw new v(0,`integrity`,`Attachment SHA-256 mismatch`);if(a!==t.size)throw new v(0,`integrity`,`Attachment size mismatch`);if(o!==t.mime)throw new v(0,`integrity`,`Attachment mime mismatch`)}return{type:`file`,attachmentID:r,sha256:i,size:a,mime:o,...s?{filename:s}:{}}},T=async(e,t,n,r)=>{let i=m(),a=typeof e==`string`?e.trim():``,o=typeof n==`string`?n.trim():``;if(!a||!o)throw new v(0,`rejected`,`assistantID and uploadID are required`);if(!(t instanceof Blob))throw new v(0,`rejected`,`file must be a File or Blob`);let c=S(t.type||t.type)||`application/octet-stream`,l=t.type===c?t:new Blob([t],{type:c});C(l.size);let u=await x(l),d=typeof t.name==`string`&&t.name.trim()?t.name.trim():void 0,f;try{f=await s(`/api/yuri/assistants/${encodeURIComponent(a)}/contact/attachments/${encodeURIComponent(o)}`,{method:`PUT`,headers:{"Content-Type":c,"X-Content-SHA256":u,"X-Content-Size":String(l.size),...d?{"X-Attachment-Filename":encodeURIComponent(d)}:{}},body:l,signal:r})}catch{throw new v(0,`unavailable`)}if(f.status===204||f.status===205)throw new v(f.status,`integrity`,`Attachment upload returned empty status`);if(f.status===413)throw new v(413,`too-large`);if(!f.ok)throw new v(f.status,f.status>=500||f.status===0?`unavailable`:`rejected`);let p=f.headers.get(`content-type`)?.toLowerCase()??``;if(p.includes(`text/html`)||p.includes(`text/plain`))throw new v(f.status,`integrity`,`Attachment upload returned non-JSON body`);let h;try{let e=await f.text();if(!e.trim())throw new v(f.status,`integrity`,`Attachment upload returned empty body`);if(!p.includes(`application/json`)&&!e.trim().startsWith(`{`))throw new v(f.status,`integrity`,`Attachment upload returned non-JSON body`);h=JSON.parse(e)}catch(e){throw e instanceof v?e:new v(f.status,`integrity`,`Attachment upload response was not valid JSON`)}let g=w(h,{sha256:u,size:l.size,mime:c});return await i(l,u),g},E=e=>{try{return w(e,void 0,{enforceUploadLimit:!1}),!0}catch{return!1}},D=e({clearAssistantAttachmentCacheAll:()=>G,clearAssistantAttachmentCacheForBearer:()=>W,clearAssistantAttachmentCacheScope:()=>U,getAssistantAttachmentBlob:()=>J,getAssistantAttachmentDisplay:()=>Y,resolveAssistantAttachmentCacheScope:()=>R}),O=g,k=class extends Error{status;code;constructor(e,t,n=`Assistant attachment cache error`){super(n),this.status=e,this.code=t,this.name=`AssistantAttachmentCacheError`}},A=async e=>[...new Uint8Array(await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e)))].map(e=>e.toString(16).padStart(2,`0`)).join(``),j=0,M,N,P=!1,F=new Map,I=new Map,L=new Set,R=async(e={})=>{let t=e.transportIdentity??o(),r=e.authGeneration??i(),a=(e.bearer??n()).trim();return{transportIdentity:t,authGeneration:r,authScope:a?`b:${await A(a)}`:`m:${r}`,authScopeKind:a?`bearer-hash`:`memory-ephemeral`}},z=e=>`assistant:${e.transportIdentity}:${e.authScope}`,B=e=>`assistant-auth:${e}`,V=()=>{j++;for(let e of L)e.abort();L.clear();for(let e of I.values())e.controller.abort(),e.url&&p(e.url);I.clear();for(let e of F.values()){for(let t=0;t<e.refs;t++)h(e.url);p(e.url)}F.clear()},H=()=>{if(!P&&globalThis.indexedDB){P=!0;for(let e of[`yuri-assistant-attachments`,`openchamber-assistant-attachments`,`openchambery-assistant-attachments`])try{globalThis.indexedDB.deleteDatabase(e)}catch{}}M||=a(V),N||=t(e=>{V(),e.reason!==`endpoint-switch`&&d(e.previousBearerDigest?B(`b:${e.previousBearerDigest}`):void 0)})},U=async(e,t=`scope-cleared`)=>{let n=typeof e==`object`?e:await R();V(),await d(z(n))},W=async(e,t=`forget-bearer`)=>{if(!e.trim())return;let n=B(`b:${await A(e.trim())}`);V(),await d(n)},G=async(e=`cleared`)=>{V(),await d()},K=(e,t,n)=>{if(!e.trim()||!E(t))throw new k(0,`rejected`);if(t.size>n)throw new k(413,`too-large`)},q=async(e,t,n,a)=>{H(),K(e,t,n),a?.throwIfAborted();let o=j,c=await R();if(o!==j)throw new k(0,`stale`);let l=new AbortController,u=()=>l.abort(a?.reason);a?.addEventListener(`abort`,u,{once:!0}),L.add(l);let d;try{a?.throwIfAborted();let u=await f({identity:`/api/yuri/assistants/${encodeURIComponent(e.trim())}/contact/attachments/${encodeURIComponent(t.attachmentID)}`,sha256:t.sha256.toLowerCase(),size:t.size,mime:t.mime,filename:t.filename,persistent:c.authScopeKind===`bearer-hash`,tags:[z(c),B(c.authScope)],signal:l.signal,maxBytes:n,load:async n=>{let a=await s(`/api/yuri/assistants/${encodeURIComponent(e.trim())}/contact/attachments/${encodeURIComponent(t.attachmentID)}`,{method:`GET`,cache:`no-store`,signal:n});if(a.status===401||a.status===403)throw d=new k(a.status,`unauthorized`),await U(c,`unauthorized`),i()===c.authGeneration&&r(),new k(a.status,`unauthorized`);if(!a.ok)throw new k(a.status,a.status===413?`too-large`:a.status>=500?`unavailable`:`rejected`);return a}});if(o!==j)throw new k(0,`stale`);return u}catch(e){throw d||(e instanceof k?e:o===j?l.signal.aborted?new k(0,`aborted`):/descriptor limit|streaming destination/i.test(String(e))?new k(413,`too-large`):new k(0,/fingerprint|size|changed|truncated/i.test(String(e))?`integrity`:`unavailable`):new k(0,`stale`))}finally{L.delete(l),a?.removeEventListener(`abort`,u)}},J=(e,t,n={})=>q(e,t,_,n.signal),Y=async(e,t,n={})=>{H(),K(e,t,O),n.signal?.throwIfAborted();let r=j,i=await R(),a=JSON.stringify([z(i),e,t.attachmentID,t.sha256]),o=e=>{if(r!==j||!c(e)||!u(e))throw p(e),new k(0,`stale`);let t=F.get(a)?.url===e?F.get(a):{url:e,refs:0};t.refs++,F.set(a,t);let n=!1;return{url:e,release:()=>{n||(n=!0,F.get(a)===t&&(h(e),--t.refs===0&&(F.delete(a),p(e))))}}},s=F.get(a);if(s&&c(s.url))return o(s.url);let d=I.get(a);if(!d){let n=new AbortController,i={controller:n,refs:0,promise:Promise.resolve(``)};i.promise=q(e,t,O,n.signal).then(e=>l(e,n.signal,{mimeType:t.mime||e.type})).then(e=>{if(i.url=e,r!==j||n.signal.aborted||i.refs===0)throw p(e),new k(0,`stale`);return e}).catch(e=>{throw I.get(a)===i&&I.delete(a),e}),d=i,I.set(a,d)}let f=d;return f.refs++,new Promise((e,t)=>{let r=!1,i=e=>{--f.refs===0&&(e&&f.controller.abort(),I.get(a)===f&&I.delete(a),e&&f.url&&!F.has(a)&&p(f.url))},s=()=>{r||(r=!0,i(!0),t(new k(0,`aborted`)))};n.signal?.addEventListener(`abort`,s,{once:!0}),n.signal?.aborted&&s(),f.promise.then(a=>{if(n.signal?.removeEventListener(`abort`,s),!r){r=!0;try{e(o(a))}catch(e){t(e)}i(!1)}},e=>{n.signal?.removeEventListener(`abort`,s),!r&&(r=!0,i(!1),t(e))})})};export{T as i,J as n,Y as r,D as t};
@@ -0,0 +1 @@
1
+ import{r as e}from"./runtime-ead7P81A.js";var t=()=>globalThis.crypto===void 0?null:{randomUUID:typeof globalThis.crypto.randomUUID==`function`?()=>globalThis.crypto.randomUUID():void 0,getRandomValues:typeof globalThis.crypto.getRandomValues==`function`?e=>globalThis.crypto.getRandomValues(e):void 0},n=(e=t())=>{try{let t=e?.randomUUID?.();if(t)return t}catch{}let n=new Uint8Array(16),r=!1;try{e?.getRandomValues&&(e.getRandomValues(n),r=!0)}catch{}if(!r)for(let e=0;e<n.length;e+=1)n[e]=Math.floor(Math.random()*256);n[6]=n[6]&15|64,n[8]=n[8]&63|128;let i=Array.from(n,e=>e.toString(16).padStart(2,`0`));return`${i.slice(0,4).join(``)}-${i.slice(4,6).join(``)}-${i.slice(6,8).join(``)}-${i.slice(8,10).join(``)}-${i.slice(10).join(``)}`},r={startingApi:`Starting OpenCode API…`,initializing:`Initializing…`,connecting:`Connecting…`,connectingRemote:`Connecting to remote instance…`,connected:`Connected!`,connectionError:`Connection error`,disconnected:`Disconnected`,reconnecting:`Reconnecting…`,initialDataLoadFailed:`OpenCode connected, but initial data load failed.`,cliNotFound:`OpenCode CLI not found. Please install it first.`,providersReady:`✓ Providers`,providersLoading:`… Providers`,agentsReady:`✓ Agents`,agentsLoading:`… Agents`,startingDevServer:e=>`Starting webview dev server (${e})...`,waitingDevServer:(e,t)=>`Waiting for webview dev server (${e})... attempt ${t}`,loadingData:(e,t)=>`Loading data (${e}, ${t})…`},i={startingApi:`Démarrage de l’API OpenCode…`,initializing:`Initialisation…`,connecting:`Connexion…`,connectingRemote:`Connexion à l’instance distante…`,connected:`Connecté !`,connectionError:`Erreur de connexion`,disconnected:`Déconnecté`,reconnecting:`Reconnexion…`,initialDataLoadFailed:`OpenCode est connecté, mais le chargement initial des données a échoué.`,cliNotFound:`L’interface en ligne de commande OpenCode est introuvable. Veuillez l’installer d’abord.`,providersReady:`✓ Fournisseurs`,providersLoading:`… Fournisseurs`,agentsReady:`✓ Agents`,agentsLoading:`… Agents`,startingDevServer:e=>`Démarrage du serveur de développement de la webview (${e})...`,waitingDevServer:(e,t)=>`En attente du serveur de développement de la webview (${e})... tentative ${t}`,loadingData:(e,t)=>`Chargement des données (${e}, ${t})…`},a={startingApi:`正在启动 OpenCode API…`,initializing:`正在初始化…`,connecting:`正在连接…`,connectingRemote:`正在连接远程实例…`,connected:`已连接!`,connectionError:`连接错误`,disconnected:`已断开连接`,reconnecting:`正在重新连接…`,initialDataLoadFailed:`OpenCode 已连接,但初始数据加载失败。`,cliNotFound:`未找到 OpenCode CLI。请先安装它。`,providersReady:`✓ 提供商`,providersLoading:`… 提供商`,agentsReady:`✓ Agent`,agentsLoading:`… Agent`,startingDevServer:e=>`正在启动 webview 开发服务器 (${e})...`,waitingDevServer:(e,t)=>`正在等待 webview 开发服务器 (${e})... 第 ${t} 次尝试`,loadingData:(e,t)=>`正在加载数据 (${e}, ${t})…`},o={startingApi:`正在啟動 OpenCode API…`,initializing:`正在初始化…`,connecting:`正在連線…`,connectingRemote:`正在連線至遠端執行個體…`,connected:`已連線!`,connectionError:`連線錯誤`,disconnected:`已中斷連線`,reconnecting:`正在重新連線…`,initialDataLoadFailed:`OpenCode 已連線,但初始資料載入失敗。`,cliNotFound:`找不到 OpenCode CLI。請先安裝。`,providersReady:`✓ 提供者`,providersLoading:`… 提供者`,agentsReady:`✓ 代理`,agentsLoading:`… 代理`,startingDevServer:e=>`正在啟動 webview 開發伺服器 (${e})...`,waitingDevServer:(e,t)=>`正在等待 webview 開發伺服器 (${e})... 第 ${t} 次嘗試`,loadingData:(e,t)=>`正在載入資料 (${e}, ${t})…`},s={startingApi:`Запуск OpenCode API…`,initializing:`Ініціалізація…`,connecting:`Підключення…`,connectingRemote:`Підключення до віддаленого екземпляра…`,connected:`Підключено!`,connectionError:`Помилка підключення`,disconnected:`Відключено`,reconnecting:`Повторне підключення…`,initialDataLoadFailed:`OpenCode підключено, але початкове завантаження даних не вдалося.`,cliNotFound:`OpenCode CLI не знайдено. Спершу встановіть його.`,providersReady:`✓ Провайдери`,providersLoading:`… Провайдери`,agentsReady:`✓ Агенти`,agentsLoading:`… Агенти`,startingDevServer:e=>`Запуск dev-сервера webview (${e})...`,waitingDevServer:(e,t)=>`Очікування dev-сервера webview (${e})... спроба ${t}`,loadingData:(e,t)=>`Завантаження даних (${e}, ${t})…`},c={startingApi:`Iniciando la API de OpenCode…`,initializing:`Inicializando…`,connecting:`Conectando…`,connectingRemote:`Conectando con la instancia remota…`,connected:`¡Conectado!`,connectionError:`Error de conexión`,disconnected:`Desconectado`,reconnecting:`Reconectando…`,initialDataLoadFailed:`OpenCode se conectó, pero falló la carga inicial de datos.`,cliNotFound:`No se encontró OpenCode CLI. Instálalo primero.`,providersReady:`✓ Proveedores`,providersLoading:`… Proveedores`,agentsReady:`✓ Agentes`,agentsLoading:`… Agentes`,startingDevServer:e=>`Iniciando el servidor de desarrollo de webview (${e})...`,waitingDevServer:(e,t)=>`Esperando el servidor de desarrollo de webview (${e})... intento ${t}`,loadingData:(e,t)=>`Cargando datos (${e}, ${t})…`},l={startingApi:`Iniciando a API do OpenCode…`,initializing:`Inicializando…`,connecting:`Conectando…`,connectingRemote:`Conectando à instância remota…`,connected:`Conectado!`,connectionError:`Erro de conexão`,disconnected:`Desconectado`,reconnecting:`Reconectando…`,initialDataLoadFailed:`OpenCode conectado, mas o carregamento inicial dos dados falhou.`,cliNotFound:`OpenCode CLI não encontrado. Instale-o primeiro.`,providersReady:`✓ Provedores`,providersLoading:`… Provedores`,agentsReady:`✓ Agentes`,agentsLoading:`… Agentes`,startingDevServer:e=>`Iniciando o servidor de desenvolvimento da webview (${e})...`,waitingDevServer:(e,t)=>`Aguardando o servidor de desenvolvimento da webview (${e})... tentativa ${t}`,loadingData:(e,t)=>`Carregando dados (${e}, ${t})…`},u={startingApi:`OpenCode API 시작 중…`,initializing:`초기화 중…`,connecting:`연결 중…`,connectingRemote:`원격 인스턴스에 연결 중…`,connected:`연결됨!`,connectionError:`연결 오류`,disconnected:`연결 끊김`,reconnecting:`다시 연결 중…`,initialDataLoadFailed:`OpenCode에 연결되었지만 초기 데이터 로드에 실패했습니다.`,cliNotFound:`OpenCode CLI를 찾을 수 없습니다. 먼저 설치하세요.`,providersReady:`✓ 공급자`,providersLoading:`… 공급자`,agentsReady:`✓ 에이전트`,agentsLoading:`… 에이전트`,startingDevServer:e=>`webview 개발 서버 시작 중 (${e})...`,waitingDevServer:(e,t)=>`webview 개발 서버 대기 중 (${e})... ${t}번째 시도`,loadingData:(e,t)=>`데이터 로드 중 (${e}, ${t})…`},d={startingApi:`Uruchamianie API OpenCode…`,initializing:`Inicjalizacja…`,connecting:`Łączenie…`,connectingRemote:`Łączenie ze zdalną instancją…`,connected:`Połączono!`,connectionError:`Błąd połączenia`,disconnected:`Rozłączono`,reconnecting:`Ponowne łączenie…`,initialDataLoadFailed:`OpenCode połączony, ale początkowe ładowanie danych nie powiodło się.`,cliNotFound:`Nie znaleziono OpenCode CLI. Najpierw go zainstaluj.`,providersReady:`✓ Dostawcy`,providersLoading:`… Dostawcy`,agentsReady:`✓ Agenci`,agentsLoading:`… Agenci`,startingDevServer:e=>`Uruchamianie serwera deweloperskiego webview (${e})...`,waitingDevServer:(e,t)=>`Oczekiwanie na serwer deweloperski webview (${e})... próba ${t}`,loadingData:(e,t)=>`Ładowanie danych (${e}, ${t})…`},f={startingApi:`OpenCode API を起動中…`,initializing:`初期化中…`,connecting:`接続中…`,connectingRemote:`リモートインスタンスに接続中…`,connected:`接続完了!`,connectionError:`接続エラー`,disconnected:`切断されました`,reconnecting:`再接続中…`,initialDataLoadFailed:`OpenCode に接続しましたが、初期データの読み込みに失敗しました。`,cliNotFound:`OpenCode CLI が見つかりません。先にインストールしてください。`,providersReady:`✓ プロバイダ`,providersLoading:`… プロバイダ`,agentsReady:`✓ エージェント`,agentsLoading:`… エージェント`,startingDevServer:e=>`Webview 開発サーバーを起動中 (${e})...`,waitingDevServer:(e,t)=>`Webview 開発サーバーを待機中 (${e})... 試行 ${t}`,loadingData:(e,t)=>`データを読み込み中 (${e}, ${t})…`},p=e=>m[e],m={en:r,fr:i,"zh-CN":a,"zh-TW":o,uk:s,es:c,"pt-BR":l,ko:u,pl:d,ja:f},h=()=>e();export{h as n,n as r,p as t};
@@ -1 +1 @@
1
- import{a as e,n as t}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{t as n}from"./types-DXSnGXVb.js";var r=e(`CapacitorUpdater`),i=()=>{if(typeof window>`u`)return!1;try{return t.isNativePlatform()&&t.isPluginAvailable(`CapacitorUpdater`)}catch{return!1}},a=()=>{throw new n},o=()=>({async notifyAppReady(){return i()||a(),r.notifyAppReady()},async download(e){return i()||a(),r.download(e)},async next(e){return i()||a(),r.next(e)},async reload(){return i()||a(),r.reload()},async current(){return i()||a(),r.current()},async getDeviceId(){return i()||a(),r.getDeviceId()},async list(){return i()||a(),r.list()},addListener:(async(e,t)=>(i()||a(),r.addListener(e,t)))}),s,c=async()=>s===void 0?i()?(s=o(),s):(s=null,null):s,l=()=>i();export{l as n,c as t};
1
+ import{a as e,n as t}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{t as n}from"./types-CnJjf4tP.js";var r=e(`CapacitorUpdater`),i=()=>{if(typeof window>`u`)return!1;try{return t.isNativePlatform()&&t.isPluginAvailable(`CapacitorUpdater`)}catch{return!1}},a=()=>{throw new n},o=()=>({async notifyAppReady(){return i()||a(),r.notifyAppReady()},async download(e){return i()||a(),r.download(e)},async next(e){return i()||a(),r.next(e)},async reload(){return i()||a(),r.reload()},async current(){return i()||a(),r.current()},async getDeviceId(){return i()||a(),r.getDeviceId()},async list(){return i()||a(),r.list()},addListener:(async(e,t)=>(i()||a(),r.addListener(e,t)))}),s,c=async()=>s===void 0?i()?(s=o(),s):(s=null,null):s,l=()=>i();export{l as n,c as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{J as t,Y as n,ot as r,st as i}from"./vendor-base-ui-CzHs0bHY.js";import{n as a}from"./vendor-react-DlzBev0S.js";import{Jn as o}from"./useMobileNavigationStore-SCjA_7jP.js";import{n as s}from"./Icon-DsN23fuV.js";var c=a(),l=e(i(),1),u=r(),d=l.memo(function(e){let r=(0,c.c)(20),{checked:i,onChange:a,disabled:l,indeterminate:d,ariaLabel:f,className:p,iconClassName:m}=e,h=l!==void 0&&l,g=i||d,_;r[0]===a?_=r[1]:(_=e=>a(!!e),r[0]=a,r[1]=_);let v=g?`border-[color:color-mix(in_srgb,var(--primary-base)_65%,var(--interactive-border))] bg-transparent shadow-none hover:bg-[var(--interactive-hover)] hover:border-[color:color-mix(in_srgb,var(--primary-base)_75%,var(--interactive-border))]`:`border-[var(--interactive-border)] bg-transparent shadow-none hover:bg-[var(--interactive-hover)] hover:border-[var(--interactive-border)]`,y;r[2]!==p||r[3]!==v?(y=o(`group/checkbox relative flex shrink-0 self-center items-center justify-center rounded-[4px] border outline-none`,`h-[14px] w-[14px] min-h-[14px] min-w-[14px]`,`transition-[background-color,border-color,box-shadow] duration-200 ease-out`,v,`focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-1 focus-visible:ring-offset-transparent`,`disabled:cursor-not-allowed disabled:opacity-50`,p),r[2]=p,r[3]=v,r[4]=y):y=r[4];let b;r[5]===m?b=r[6]:(b=o(`flex items-center justify-center text-[var(--primary-base)]`,`data-[unchecked]:hidden`,m),r[5]=m,r[6]=b);let x;r[7]===d?x=r[8]:(x=d?(0,u.jsx)(s,{name:`subtract`,className:o(`h-[10px] w-[10px] min-h-[10px] min-w-[10px]`,`text-[var(--primary-base)]`)}):(0,u.jsx)(s,{name:`check`,className:o(`h-[10px] w-[10px] min-h-[10px] min-w-[10px]`,`text-[var(--primary-base)]`)}),r[7]=d,r[8]=x);let S;r[9]!==b||r[10]!==x?(S=(0,u.jsx)(t,{keepMounted:!0,className:b,children:x}),r[9]=b,r[10]=x,r[11]=S):S=r[11];let C;return r[12]!==f||r[13]!==i||r[14]!==h||r[15]!==d||r[16]!==_||r[17]!==y||r[18]!==S?(C=(0,u.jsx)(n,{checked:i,onCheckedChange:_,disabled:h,indeterminate:d,"aria-label":f,className:y,children:S}),r[12]=f,r[13]=i,r[14]=h,r[15]=d,r[16]=_,r[17]=y,r[18]=S,r[19]=C):C=r[19],C});export{d as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{J as t,Y as n,ot as r,st as i}from"./vendor-base-ui-CzHs0bHY.js";import{n as a}from"./vendor-react-DlzBev0S.js";import{Jn as o}from"./useMobileNavigationStore-CJBLQxTz.js";import{n as s}from"./Icon-C5rHjO1K.js";var c=a(),l=e(i(),1),u=r(),d=l.memo(function(e){let r=(0,c.c)(20),{checked:i,onChange:a,disabled:l,indeterminate:d,ariaLabel:f,className:p,iconClassName:m}=e,h=l!==void 0&&l,g=i||d,_;r[0]===a?_=r[1]:(_=e=>a(!!e),r[0]=a,r[1]=_);let v=g?`border-[color:color-mix(in_srgb,var(--primary-base)_65%,var(--interactive-border))] bg-transparent shadow-none hover:bg-[var(--interactive-hover)] hover:border-[color:color-mix(in_srgb,var(--primary-base)_75%,var(--interactive-border))]`:`border-[var(--interactive-border)] bg-transparent shadow-none hover:bg-[var(--interactive-hover)] hover:border-[var(--interactive-border)]`,y;r[2]!==p||r[3]!==v?(y=o(`group/checkbox relative flex shrink-0 self-center items-center justify-center rounded-[4px] border outline-none`,`h-[14px] w-[14px] min-h-[14px] min-w-[14px]`,`transition-[background-color,border-color,box-shadow] duration-200 ease-out`,v,`focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-1 focus-visible:ring-offset-transparent`,`disabled:cursor-not-allowed disabled:opacity-50`,p),r[2]=p,r[3]=v,r[4]=y):y=r[4];let b;r[5]===m?b=r[6]:(b=o(`flex items-center justify-center text-[var(--primary-base)]`,`data-[unchecked]:hidden`,m),r[5]=m,r[6]=b);let x;r[7]===d?x=r[8]:(x=d?(0,u.jsx)(s,{name:`subtract`,className:o(`h-[10px] w-[10px] min-h-[10px] min-w-[10px]`,`text-[var(--primary-base)]`)}):(0,u.jsx)(s,{name:`check`,className:o(`h-[10px] w-[10px] min-h-[10px] min-w-[10px]`,`text-[var(--primary-base)]`)}),r[7]=d,r[8]=x);let S;r[9]!==b||r[10]!==x?(S=(0,u.jsx)(t,{keepMounted:!0,className:b,children:x}),r[9]=b,r[10]=x,r[11]=S):S=r[11];let C;return r[12]!==f||r[13]!==i||r[14]!==h||r[15]!==d||r[16]!==_||r[17]!==y||r[18]!==S?(C=(0,u.jsx)(n,{checked:i,onCheckedChange:_,disabled:h,indeterminate:d,"aria-label":f,className:y,children:S}),r[12]=f,r[13]=i,r[14]=h,r[15]=d,r[16]=_,r[17]=y,r[18]=S,r[19]=C):C=r[19],C});export{d as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,ot as n,r,st as i,t as a}from"./vendor-base-ui-CzHs0bHY.js";import{n as o}from"./vendor-react-DlzBev0S.js";import{Jn as s}from"./useMobileNavigationStore-SCjA_7jP.js";var c=o(),l=e(i(),1),u=n(),d=r,f=e=>{let n=(0,c.c)(14),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:a,asChild:r,children:i,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let d;n[5]!==r||n[6]!==i?(d=r&&l.isValidElement(i)?{render:i}:{children:i},n[5]=r,n[6]=i,n[7]=d):d=n[7];let f=d,p;n[8]===a?p=n[9]:(p=s(`flex w-full items-center justify-between rounded-lg px-2 py-1.5 text-left text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,a),n[8]=a,n[9]=p);let m;return n[10]!==o||n[11]!==f||n[12]!==p?(m=(0,u.jsx)(t,{className:p,...o,...f}),n[10]=o,n[11]=f,n[12]=p,n[13]=m):m=n[13],m},p=e=>{let t=(0,c.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=s(`overflow-hidden data-[closed]:animate-collapsible-up data-[open]:animate-collapsible-down`,n),t[3]=n,t[4]=i);let o;return t[5]!==r||t[6]!==i?(o=(0,u.jsx)(a,{className:i,...r}),t[5]=r,t[6]=i,t[7]=o):o=t[7],o};export{p as n,f as r,d as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,ot as n,r,st as i,t as a}from"./vendor-base-ui-CzHs0bHY.js";import{n as o}from"./vendor-react-DlzBev0S.js";import{Jn as s}from"./useMobileNavigationStore-CJBLQxTz.js";var c=o(),l=e(i(),1),u=n(),d=r,f=e=>{let n=(0,c.c)(14),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({className:a,asChild:r,children:i,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let d;n[5]!==r||n[6]!==i?(d=r&&l.isValidElement(i)?{render:i}:{children:i},n[5]=r,n[6]=i,n[7]=d):d=n[7];let f=d,p;n[8]===a?p=n[9]:(p=s(`flex w-full items-center justify-between rounded-lg px-2 py-1.5 text-left text-foreground hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,a),n[8]=a,n[9]=p);let m;return n[10]!==o||n[11]!==f||n[12]!==p?(m=(0,u.jsx)(t,{className:p,...o,...f}),n[10]=o,n[11]=f,n[12]=p,n[13]=m):m=n[13],m},p=e=>{let t=(0,c.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=s(`overflow-hidden data-[closed]:animate-collapsible-up data-[open]:animate-collapsible-down`,n),t[3]=n,t[4]=i);let o;return t[5]!==r||t[6]!==i?(o=(0,u.jsx)(a,{className:i,...r}),t[5]=r,t[6]=i,t[7]=o):o=t[7],o};export{p as n,f as r,d as t};
@@ -1 +1 @@
1
- import"./rolldown-runtime-hePW80VL.js";import{A as e,B as t,L as n,R as r,a as i,i as a,ot as o,st as s,z as c}from"./vendor-base-ui-CzHs0bHY.js";import{n as l}from"./vendor-react-DlzBev0S.js";import{Jn as u}from"./useMobileNavigationStore-SCjA_7jP.js";import{n as d,r as f,t as p}from"./dropdown-menu.styles-BDla58Rm.js";var m=l();s();var h=o();function g(e){let t=(0,m.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,h.jsx)(i,{...n}),t[2]=n,t[3]=r),r}function _(e){let t=(0,m.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,h.jsx)(a,{...n}),t[2]=n,t[3]=r),r}function v(e){let t=(0,m.c)(20),i,a,o,s,l;t[0]===e?(i=t[1],a=t[2],o=t[3],s=t[4],l=t[5]):({className:a,positionerClassName:o,children:i,style:l,...s}=e,t[0]=e,t[1]=i,t[2]=a,t[3]=o,t[4]=s,t[5]=l);let f;t[6]===o?f=t[7]:(f=u(`app-region-no-drag z-50`,o),t[6]=o,t[7]=f);let p;t[8]===l?p=t[9]:(p={color:`var(--surface-elevated-foreground)`,...l},t[8]=l,t[9]=p);let g;t[10]===a?g=t[11]:(g=u(d,a),t[10]=a,t[11]=g);let _;t[12]!==i||t[13]!==s||t[14]!==p||t[15]!==g?(_=(0,h.jsx)(c,{"data-slot":`dropdown-menu-content`,style:p,className:g,...s,children:i}),t[12]=i,t[13]=s,t[14]=p,t[15]=g,t[16]=_):_=t[16];let v;return t[17]!==f||t[18]!==_?(v=(0,h.jsx)(r,{children:(0,h.jsx)(n,{className:f,children:_})}),t[17]=f,t[18]=_,t[19]=v):v=t[19],v}function y(e){let n=(0,m.c)(8),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=u(p,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,h.jsx)(t,{className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o}function b(t){let n=(0,m.c)(8),r,i;n[0]===t?(r=n[1],i=n[2]):({className:r,...i}=t,n[0]=t,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=u(f,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,h.jsx)(e,{className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o}export{_ as a,b as i,v as n,y as r,g as t};
1
+ import"./rolldown-runtime-hePW80VL.js";import{A as e,B as t,L as n,R as r,a as i,i as a,ot as o,st as s,z as c}from"./vendor-base-ui-CzHs0bHY.js";import{n as l}from"./vendor-react-DlzBev0S.js";import{Jn as u}from"./useMobileNavigationStore-CJBLQxTz.js";import{n as d,r as f,t as p}from"./dropdown-menu.styles-BDla58Rm.js";var m=l();s();var h=o();function g(e){let t=(0,m.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,h.jsx)(i,{...n}),t[2]=n,t[3]=r),r}function _(e){let t=(0,m.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,h.jsx)(a,{...n}),t[2]=n,t[3]=r),r}function v(e){let t=(0,m.c)(20),i,a,o,s,l;t[0]===e?(i=t[1],a=t[2],o=t[3],s=t[4],l=t[5]):({className:a,positionerClassName:o,children:i,style:l,...s}=e,t[0]=e,t[1]=i,t[2]=a,t[3]=o,t[4]=s,t[5]=l);let f;t[6]===o?f=t[7]:(f=u(`app-region-no-drag z-50`,o),t[6]=o,t[7]=f);let p;t[8]===l?p=t[9]:(p={color:`var(--surface-elevated-foreground)`,...l},t[8]=l,t[9]=p);let g;t[10]===a?g=t[11]:(g=u(d,a),t[10]=a,t[11]=g);let _;t[12]!==i||t[13]!==s||t[14]!==p||t[15]!==g?(_=(0,h.jsx)(c,{"data-slot":`dropdown-menu-content`,style:p,className:g,...s,children:i}),t[12]=i,t[13]=s,t[14]=p,t[15]=g,t[16]=_):_=t[16];let v;return t[17]!==f||t[18]!==_?(v=(0,h.jsx)(r,{children:(0,h.jsx)(n,{className:f,children:_})}),t[17]=f,t[18]=_,t[19]=v):v=t[19],v}function y(e){let n=(0,m.c)(8),r,i;n[0]===e?(r=n[1],i=n[2]):({className:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=u(p,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,h.jsx)(t,{className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o}function b(t){let n=(0,m.c)(8),r,i;n[0]===t?(r=n[1],i=n[2]):({className:r,...i}=t,n[0]=t,n[1]=r,n[2]=i);let a;n[3]===r?a=n[4]:(a=u(f,r),n[3]=r,n[4]=a);let o;return n[5]!==i||n[6]!==a?(o=(0,h.jsx)(e,{className:a,...i}),n[5]=i,n[6]=a,n[7]=o):o=n[7],o}export{_ as a,b as i,v as n,y as r,g as t};
@@ -0,0 +1 @@
1
+ import{E as e}from"./runtime-auth-mjIpsk3N.js";import{S as t,x as n}from"./platform-DMsFWy1a.js";var r=e=>typeof e==`object`&&!!e,i=e=>e.trim().toLowerCase()===`authorization`,a=e=>{if(!r(e))return;let t={};for(let[n,r]of Object.entries(e)){let e=n.trim(),a=typeof r==`string`?r.trim():``;!e||!a||/[\r\n:]/.test(e)||/[\r\n]/.test(a)||i(e)||(t[e]=a)}return Object.keys(t).length>0?t:void 0},o=`connect-link`,s=e=>!!(e.clientToken&&(e.source===`connect-link`||e.relay)),c=(e,t)=>e.source===`connect-link`||e.relay?!0:t.has(e.id),l=(e,t)=>!t.has(e.id)&&c(e,t),u=e=>`relay://${e}`,d=e=>{if(!r(e))return null;let t=_(e,`relayUrl`)||_(e,`relay_url`),n=_(e,`serverId`)||_(e,`server_id`),i=e.hostEncPubJwk??e.host_enc_pub_jwk;return!t||!n||!r(i)?null:{relayUrl:t,serverId:n,hostEncPubJwk:i}},f=/^(t|.*(?:token|auth|secret|api).*)$/i,p=e=>{let t=e.trim();if(!t)return null;try{let e=new URL(t);return e.protocol!==`http:`&&e.protocol!==`https:`?null:t.split(`#`)[0]||null}catch{return null}},m=e=>{let t=p(e);if(!t)return null;try{let e=new URL(t);if((e.pathname.replace(/\/+$/,``)||`/`)===`/connect`&&e.searchParams.has(`t`))return{persistedUrl:e.origin,redeemUrl:e.toString(),kind:`tunnel-connect-link`}}catch{return null}return{persistedUrl:t,redeemUrl:null,kind:`normal-host`}},h=e=>{let t=p(e);if(!t)return e;try{let e=new URL(t);(e.username||e.password)&&(e.username=``,e.password=``);let n=Array.from(new Set(Array.from(e.searchParams.keys())));for(let t of n)f.test(t)&&e.searchParams.set(t,`[REDACTED]`);return e.toString()}catch{return t}},g=(e,t)=>{let n=p(e),r=p(t);if(!n||!r)return!1;try{let e=new URL(n),t=new URL(r);if(e.origin!==t.origin||t.search&&e.search!==t.search)return!1;let i=t.pathname.length>1?t.pathname.replace(/\/+$/,``):t.pathname,a=e.pathname.length>1?e.pathname.replace(/\/+$/,``):e.pathname;return i===`/`||a===i||a.startsWith(`${i}/`)}catch{return!1}},_=(e,t)=>{let n=e[t];return typeof n==`string`?n:null},v=(e,t)=>{let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:null},y=e=>{if(!r(e))return null;let t=_(e,`id`),n=_(e,`label`),i=_(e,`url`),s=_(e,`apiUrl`)||_(e,`api_url`),c=_(e,`clientToken`)||_(e,`client_token`),l=a(e.requestHeaders),u=d(e.relay),f=_(e,`source`)===`connect-link`?o:void 0;return!t||!n||!i&&!u?null:{id:t,label:n,url:i||``,...s?{apiUrl:s}:{},...c?{clientToken:c}:{},...l?{requestHeaders:l}:{},...u?{relay:u}:{},...f?{source:f}:{}}},b=e=>p(e.apiUrl||e.url)||e.apiUrl||e.url,x=()=>n()?(e,n)=>t(e,n):null,S=async()=>{let e=x();if(!e)return{hosts:[],defaultHostId:null,initialHostChoiceCompleted:!1};let t=await e(`desktop_hosts_get`);if(!r(t))return{hosts:[],defaultHostId:null,initialHostChoiceCompleted:!1};let n=t.hosts,i=Array.isArray(n)?n.map(y).filter(e=>!!e):[],a=_(t,`defaultHostId`)||_(t,`default_host_id`)||_(t,`defaultHostID`),o=t.initialHostChoiceCompleted===!0||t.initial_host_choice_completed===!0,s=_(t,`localOrigin`)||_(t,`local_origin`),c=Array.isArray(t.sshHostIds)?t.sshHostIds.filter(e=>typeof e==`string`&&i.some(t=>t.id===e)):void 0;return{hosts:i,defaultHostId:a,initialHostChoiceCompleted:o,localOrigin:s,...c?{sshHostIds:c}:{}}},C=async e=>{let t=x();if(!t)return;let n={hosts:e.hosts,defaultHostId:e.defaultHostId,initialHostChoiceCompleted:e.initialHostChoiceCompleted};e.localClientToken!==void 0&&(n.localClientToken=e.localClientToken),await t(`desktop_hosts_set`,{input:n})},w=async e=>{let t=x();if(!t)throw Error(`Desktop host preparation is unavailable`);let n=y(await t(`desktop_host_prepare`,{hostId:e.id}));if(!n||n.id!==e.id)throw Error(`Invalid prepared desktop host`);return n},T=async()=>{let e=x();if(!e)throw Error(`Local host settings are unavailable`);await e(`desktop_open_local_host_settings`)},E=async()=>{let e=x();if(!e)return``;let t=await e(`desktop_local_client_token_get`).catch(()=>null);return typeof t==`string`?t.trim():``},D=async()=>{let e=x();if(!e)return``;let t=await e(`desktop_install_id_get`).catch(()=>null);return typeof t==`string`?t.trim():``},O=8e3,k=async(t,n)=>{let r=e({relayUrl:t.relayUrl,serverId:t.serverId,hostEncPubJwk:t.hostEncPubJwk}),i=Date.now(),a=!1,o;try{let e=await Promise.race([(async()=>{let e=await r.fetch(`/auth/session`,{headers:n?.clientToken?{Authorization:`Bearer ${n.clientToken}`}:{}});return{response:e,payload:e.ok?await e.json().catch(()=>null):null}})(),new Promise(e=>{o=setTimeout(()=>e(null),O)})]),t=e?.response;return t?.status===401||t?.status===403?{status:`auth`,latencyMs:Math.max(0,Date.now()-i)}:t?.ok?e?.payload?.authenticated===!0?(a=n?.keepTunnel===!0,{status:`ok`,latencyMs:Math.max(0,Date.now()-i),...a?{tunnel:r}:{}}):{status:`auth`,latencyMs:Math.max(0,Date.now()-i)}:{status:`unreachable`,latencyMs:0}}catch{return{status:`unreachable`,latencyMs:0}}finally{o!==void 0&&clearTimeout(o),a||r.close()}},A=async(e,t)=>{let n=x();if(!n)return{status:`unreachable`,latencyMs:0};let i=await n(`desktop_host_probe`,{url:e,clientToken:t?.clientToken||void 0,requestHeaders:t?.requestHeaders||void 0,expectedServerId:t?.expectedServerId||void 0});if(!r(i))return{status:`unreachable`,latencyMs:0};let a=i.status;return{status:a===`ok`||a===`auth`||a===`update-recommended`||a===`incompatible`||a===`wrong-service`||a===`unreachable`?a:`unreachable`,latencyMs:v(i,`latencyMs`)??v(i,`latency_ms`)??0}},j=async(e,t)=>{let n=x();n&&await n(`desktop_new_window_at_url`,{url:e,clientToken:t?.clientToken||void 0,requestHeaders:t?.requestHeaders||void 0})},M=async e=>{let t=x();t&&await t(`desktop_new_window_for_host`,{hostId:e})};export{k as _,D as a,m as b,j as c,b as d,s as f,p as g,g as h,C as i,M as l,c as m,A as n,E as o,l as p,S as r,T as s,o as t,w as u,h as v,u as y};
@@ -0,0 +1 @@
1
+ import{b as e}from"./runtime-auth-mjIpsk3N.js";import{l as t,n,r,t as i}from"./runtime-switch-BMjl5Y5W.js";import{n as a}from"./runtime-fetch-DKZOpfzo.js";import{D as o,et as s}from"./platform-DMsFWy1a.js";import{_ as c,d as l,f as u,g as d,i as f,n as p,r as m,u as h}from"./desktopHosts-DovfbQPm.js";var g=e=>e!==`ok`&&e!==`update-recommended`,_=e=>e.id===`local`?`local`:`host:${e.id}`,v=e=>r()===_(e),y=async(n,r)=>{if(!o())return{ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unsupported`};n=await h(n);let i=d(l(n))||``;if(!i&&!n.relay)return{ok:!1,status:{status:`unreachable`,latencyMs:0},reason:`unreachable`};let a=(r,i)=>{i&&e({relayUrl:r.relayUrl,serverId:r.serverId,hostEncPubJwk:r.hostEncPubJwk},i),t({apiBaseUrl:E(),clientToken:n.clientToken||null,runtimeKey:_(n),relay:r}),O(n.id)},s=e=>{t({apiBaseUrl:e,clientToken:n.clientToken||null,requestHeaders:n.requestHeaders||null,runtimeKey:_(n)})},u={status:`unreachable`,latencyMs:0},f=null,m;if(i){let e=await p(i,{clientToken:n.clientToken||null,requestHeaders:n.requestHeaders||null,expectedServerId:n.relay?.serverId||null}).catch(()=>({status:`unreachable`,latencyMs:0}));u={status:e.status,latencyMs:e.latencyMs},g(e.status)||(f=`direct`)}if(!f&&n.relay){let e=await c(n.relay,{keepTunnel:!0,clientToken:n.clientToken||null}).catch(()=>({status:`unreachable`,latencyMs:0}));e.status===`ok`?(u={status:e.status,latencyMs:e.latencyMs,via:`relay`},f=`relay`,m=`tunnel`in e?e.tunnel:void 0):(!i||e.status===`auth`)&&(u={status:e.status,latencyMs:e.latencyMs})}return f?f===`relay`&&n.relay?(a(n.relay,m),{ok:!0,via:`relay`,status:u}):(s(i),{ok:!0,via:`direct`,status:u}):{ok:!1,status:u,reason:`unreachable`}},b=5e3,x=1500,S=e=>e===`ok`||e===`update-recommended`,C=!1,w=()=>{if(typeof window>`u`)return``;let e=window.__YURI_LOCAL_ORIGIN__;return typeof e==`string`?e.trim():``},T=e=>{if(!e||e===`null`)return!1;try{let t=new URL(e);return(t.protocol===`http:`||t.protocol===`https:`)&&t.origin!==`null`}catch{return!1}},E=()=>{if(typeof window>`u`)return``;let e=window.location.origin;if(T(e))return e;let t=w();return T(t)?t:``},D=async e=>{if(!o()||C)return;let i=`host:${e}`;if(r()!==i)return;let s=n(),c=()=>r()===i&&n()===s;C=!0;try{let n=await m().catch(()=>null);if(!c())return;let r=n?.hosts.find(t=>t.id===e);if(!n||!r?.relay)return;let o=r.apiUrl?d(r.apiUrl):null;if(o&&o.startsWith(`https://`))return;let s=await a(`/api/client-auth/connection/candidates`).catch(()=>null);if(!s?.ok)return;let l=await s.json().catch(()=>null);if(!c()||!l||l.serverId!==r.relay.serverId)return;let u=Array.isArray(l.candidates)?l.candidates:[],h=[];for(let e of u){if(!e||typeof e!=`object`)continue;let t=e;if(t.type!==`lan`||typeof t.url!=`string`)continue;let n=d(t.url);n&&!h.includes(n)&&h.push(n)}if(h.length===0)return;let g=o&&h.includes(o)?o:h[0];if(g!==o&&await f({hosts:n.hosts.map(t=>t.id===e?{...t,apiUrl:g}:t),defaultHostId:n.defaultHostId,initialHostChoiceCompleted:n.initialHostChoiceCompleted}).catch(()=>void 0),!c()||!S((await p(g,{clientToken:r.clientToken||null,requestHeaders:r.requestHeaders||null,expectedServerId:r.relay.serverId}).catch(()=>({status:`unreachable`,latencyMs:0}))).status)||!c())return;t({apiBaseUrl:g,clientToken:r.clientToken||null,requestHeaders:r.requestHeaders||null,runtimeKey:i})}finally{C=!1}},O=e=>{typeof window>`u`||window.setTimeout(()=>{D(e).catch(()=>void 0)},b)},k=async a=>{if(!o())return;let f=r(),g=n(),v=()=>r()===f&&n()===g,y=await m().catch(()=>null);if(!y||!v())return;let b=s(),C=b?.target===`remote`?b.hostId:b?.target===`local`?`local`:null,w=a||C||(y.defaultHostId===`local`?null:y.defaultHostId);if(!w)return;let T=y.hosts.find(e=>e.id===w);if(!T)return;let D=_(T);if(r()===D)return;if(!T.relay){let e=d(l(T));e&&d(i())===e&&(!b||b.status===`ok`)&&t({apiBaseUrl:e,clientToken:T.clientToken||null,requestHeaders:T.requestHeaders||null,runtimeKey:D});return}let k=null,A=!1,j=async n=>{let r=n.apiUrl||!n.relay?d(l(n)):null;if(r){let e,i=await Promise.race([p(r,{clientToken:n.clientToken||null,requestHeaders:n.requestHeaders||null,expectedServerId:n.relay?.serverId}).catch(()=>null),new Promise(t=>{e=setTimeout(()=>t(null),x)})]).finally(()=>{e!==void 0&&clearTimeout(e)});if(!v())return!1;if(i?.status===`auth`&&u(n)&&(k=n.clientToken||null),i&&S(i.status))return t({apiBaseUrl:r,clientToken:n.clientToken||null,requestHeaders:n.requestHeaders||null,runtimeKey:D}),!0}if(!n.relay||!v())return!1;let i=await c(n.relay,{keepTunnel:!0,clientToken:n.clientToken||null});return v()?(i.status===`auth`&&u(n)&&(k=n.clientToken||null),i.status!==`ok`||!i.tunnel?!1:(e(n.relay,i.tunnel),t({apiBaseUrl:E(),clientToken:n.clientToken||null,runtimeKey:D,relay:n.relay}),O(n.id),!0)):(i.tunnel?.close(),!1)};try{if(await j(T)||!v()||(T=await h(T),!v())||await j(T)||!v())return;throw A=!0,Error(`Remote instance is unreachable after initialization`)}catch(e){throw v()&&(window.__YURI_DESKTOP_BOOT_OUTCOME__={target:`remote`,status:A&&k&&k===T.clientToken?`pairing-expired`:`unreachable`,hostId:w,url:l(T)}),e}};export{y as i,v as n,_ as r,k as t};