agentstudio 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (280) hide show
  1. package/config/engineConfig.d.ts +15 -0
  2. package/config/engineConfig.d.ts.map +1 -1
  3. package/config/engineConfig.js +30 -0
  4. package/config/engineConfig.js.map +1 -1
  5. package/config/index.d.ts.map +1 -1
  6. package/config/index.js +14 -0
  7. package/config/index.js.map +1 -1
  8. package/config/paths.d.ts +5 -0
  9. package/config/paths.d.ts.map +1 -1
  10. package/config/paths.js +6 -1
  11. package/config/paths.js.map +1 -1
  12. package/engines/claude/__tests__/supportedModels.test.d.ts +6 -4
  13. package/engines/claude/__tests__/supportedModels.test.d.ts.map +1 -1
  14. package/engines/claude/__tests__/supportedModels.test.js +55 -13
  15. package/engines/claude/__tests__/supportedModels.test.js.map +1 -1
  16. package/engines/claude/aguiAdapter.d.ts.map +1 -1
  17. package/engines/claude/aguiAdapter.js +8 -0
  18. package/engines/claude/aguiAdapter.js.map +1 -1
  19. package/engines/claude/claudeEngine.d.ts +36 -3
  20. package/engines/claude/claudeEngine.d.ts.map +1 -1
  21. package/engines/claude/claudeEngine.js +132 -13
  22. package/engines/claude/claudeEngine.js.map +1 -1
  23. package/index.d.ts.map +1 -1
  24. package/index.js +29 -2
  25. package/index.js.map +1 -1
  26. package/middleware/callChain.d.ts +10 -0
  27. package/middleware/callChain.d.ts.map +1 -0
  28. package/middleware/callChain.js +24 -0
  29. package/middleware/callChain.js.map +1 -0
  30. package/middleware/requestId.d.ts +8 -0
  31. package/middleware/requestId.d.ts.map +1 -0
  32. package/middleware/requestId.js +18 -0
  33. package/middleware/requestId.js.map +1 -0
  34. package/package.json +1 -1
  35. package/prompts/gameDevSystemPrompt.d.ts +15 -0
  36. package/prompts/gameDevSystemPrompt.d.ts.map +1 -0
  37. package/prompts/gameDevSystemPrompt.js +37 -0
  38. package/prompts/gameDevSystemPrompt.js.map +1 -0
  39. package/prompts/vibeGamingPrompt.d.ts +13 -0
  40. package/prompts/vibeGamingPrompt.d.ts.map +1 -0
  41. package/prompts/vibeGamingPrompt.js +125 -0
  42. package/prompts/vibeGamingPrompt.js.map +1 -0
  43. package/public/assets/{AgentsPage-BsZdkqzM.js → AgentsPage-CHee5mUh.js} +1 -1
  44. package/public/assets/{Button-CMTSYiKV.js → Button-D5qiS7CR.js} +1 -1
  45. package/public/assets/ChatPage-B7-rn9mH.js +478 -0
  46. package/public/assets/{CommandForm-DwGvE9A_.js → CommandForm-CMfgHNm5.js} +1 -1
  47. package/public/assets/{CommandsPage-qDWzq8xp.js → CommandsPage-B4rjtVWk.js} +1 -1
  48. package/public/assets/{CursorConfigPage-DpUdJzRi.js → CursorConfigPage-DQ-3b3ti.js} +1 -1
  49. package/public/assets/{DashboardPage-BhqKOzob.js → DashboardPage-BowdW2Xj.js} +1 -1
  50. package/public/assets/{EngineGate-BjHJu955.js → EngineGate-DYNvEEbW.js} +1 -1
  51. package/public/assets/{FileBrowser-DboOOM_v.js → FileBrowser-DHyCacM6.js} +1 -1
  52. package/public/assets/{FileExplorer-x5R0Tcmk.js → FileExplorer-BprfeAH_.js} +1 -1
  53. package/public/assets/GeneralSettingsPage-C6hJ_zTw.js +1 -0
  54. package/public/assets/{HooksPage-DDGc0GGV.js → HooksPage-BwE2Zm3X.js} +1 -1
  55. package/public/assets/{LandingPage-CvY4n9Rh.js → LandingPage-DKvwbGX1.js} +1 -1
  56. package/public/assets/{LoginPage-C-PZfjYC.js → LoginPage-BpZhqRAN.js} +1 -1
  57. package/public/assets/{McpAdminSettingsPage-CIILVzB8.js → McpAdminSettingsPage-DuvsM5TX.js} +1 -1
  58. package/public/assets/{McpPage-B4nQUJag.js → McpPage-Hu8vyMhX.js} +1 -1
  59. package/public/assets/{MemorySettingsPage-eu6tsuUh.js → MemorySettingsPage-gIWSsrES.js} +1 -1
  60. package/public/assets/{ModelsPage-Bb5vSsuc.js → ModelsPage-Cosb3hHI.js} +1 -1
  61. package/public/assets/PluginsPage-CuNui9NV.js +12 -0
  62. package/public/assets/{ProjectSelector-CybrDbBY.js → ProjectSelector-CyBlHb2H.js} +1 -1
  63. package/public/assets/{ProjectsPage-DRl-0B4G.js → ProjectsPage-DYhCvH07.js} +1 -1
  64. package/public/assets/{RulesPage-DUt33RkX.js → RulesPage-C32P_Aqz.js} +1 -1
  65. package/public/assets/{ScheduledTasksPage-CTDYYRIN.js → ScheduledTasksPage-ixn5qoiD.js} +1 -1
  66. package/public/assets/SettingsLayout-C_7jR0Te.js +1 -0
  67. package/public/assets/{SkillsPage-Lzw8I9vR.js → SkillsPage-C-WS4N1Y.js} +1 -1
  68. package/public/assets/{SubagentForm-BzzeWg0W.js → SubagentForm-BbxljQUp.js} +1 -1
  69. package/public/assets/{SubagentsPage-bX2XWdJ0.js → SubagentsPage-D66TBaeN.js} +1 -1
  70. package/public/assets/{SystemInfoPage-nEIQbtwG.js → SystemInfoPage-DXVUncTe.js} +1 -1
  71. package/public/assets/{TelemetrySettingsPage-q167I4G9.js → TelemetrySettingsPage-Cp3vOu7X.js} +1 -1
  72. package/public/assets/{ToastTestPage-j224d3QR.js → ToastTestPage-03up9yZR.js} +1 -1
  73. package/public/assets/{ToolsList-CTsQr53G.js → ToolsList-BZFBEuvQ.js} +1 -1
  74. package/public/assets/UnifiedToolSelector-DJN7ASu1.js +1 -0
  75. package/public/assets/{VersionSettingsPage-BwpwiLyl.js → VersionSettingsPage-DppWaX--.js} +1 -1
  76. package/public/assets/{VoiceSettingsPage-d3l9AWBn.js → VoiceSettingsPage-BWJLeedX.js} +1 -1
  77. package/public/assets/{WebSocketTunnelPage-BqEUE7mr.js → WebSocketTunnelPage-BPeSTgEZ.js} +1 -1
  78. package/public/assets/{_basePickBy-DHabY031.js → _basePickBy-0UeYrifO.js} +1 -1
  79. package/public/assets/{_baseUniq-B1lmu3qr.js → _baseUniq-Q0NUbuSr.js} +1 -1
  80. package/public/assets/{agents-KlPdWQ8K.js → agents-DR9EZMs5.js} +1 -1
  81. package/public/assets/{arc-6sRLTBcr.js → arc-BV8erW1-.js} +1 -1
  82. package/public/assets/{architectureDiagram-VXUJARFQ-kwdTmjuB.js → architectureDiagram-VXUJARFQ-BIodTu6s.js} +1 -1
  83. package/public/assets/{blockDiagram-VD42YOAC-CYO9EYkJ.js → blockDiagram-VD42YOAC-4H3KjsGf.js} +1 -1
  84. package/public/assets/{c4Diagram-YG6GDRKO-gAp3--Ee.js → c4Diagram-YG6GDRKO-J2ovCYEr.js} +1 -1
  85. package/public/assets/channel-gveiJv4S.js +1 -0
  86. package/public/assets/{chunk-4BX2VUAB-DQVsL-J6.js → chunk-4BX2VUAB-D7Mc44O6.js} +1 -1
  87. package/public/assets/{chunk-55IACEB6-DVsfnY5X.js → chunk-55IACEB6-CMASo37Z.js} +1 -1
  88. package/public/assets/{chunk-B4BG7PRW-BNmOvuIn.js → chunk-B4BG7PRW-2T3W2IB6.js} +1 -1
  89. package/public/assets/{chunk-DI55MBZ5-BkucWe8Y.js → chunk-DI55MBZ5-FR9qswmO.js} +1 -1
  90. package/public/assets/{chunk-FMBD7UC4-BsvfEdnB.js → chunk-FMBD7UC4-Bz2LO9q3.js} +1 -1
  91. package/public/assets/{chunk-QN33PNHL-DSecsNtM.js → chunk-QN33PNHL-D7mfK9Pm.js} +1 -1
  92. package/public/assets/{chunk-QZHKN3VN-DhvrZSqy.js → chunk-QZHKN3VN-AkuNbqQU.js} +1 -1
  93. package/public/assets/{chunk-TZMSLE5B-BqQ674GC.js → chunk-TZMSLE5B-DtY3rhWy.js} +1 -1
  94. package/public/assets/classDiagram-2ON5EDUG-f-lJUj27.js +1 -0
  95. package/public/assets/classDiagram-v2-WZHVMYZB-f-lJUj27.js +1 -0
  96. package/public/assets/clone-D5-Tsf9e.js +1 -0
  97. package/public/assets/{cose-bilkent-S5V4N54A-D9ZC6LmB.js → cose-bilkent-S5V4N54A-BuEw-qDX.js} +1 -1
  98. package/public/assets/{dagre-6UL2VRFP-s7YD2ZcY.js → dagre-6UL2VRFP-D-NrLBGh.js} +1 -1
  99. package/public/assets/{diagram-PSM6KHXK-C7jhP5tx.js → diagram-PSM6KHXK-BFjWOHNz.js} +1 -1
  100. package/public/assets/{diagram-QEK2KX5R-B348GmS1.js → diagram-QEK2KX5R-C0YlDb8t.js} +1 -1
  101. package/public/assets/{diagram-S2PKOQOG-Cu-zjwc9.js → diagram-S2PKOQOG-BLKbR12g.js} +1 -1
  102. package/public/assets/{erDiagram-Q2GNP2WA-tM4HKBpy.js → erDiagram-Q2GNP2WA-Cov6xnUk.js} +1 -1
  103. package/public/assets/{flowDiagram-NV44I4VS-DjCIshpi.js → flowDiagram-NV44I4VS-DTMKSJI1.js} +1 -1
  104. package/public/assets/{ganttDiagram-LVOFAZNH-Q6plkI5G.js → ganttDiagram-LVOFAZNH-DR0bcfHY.js} +1 -1
  105. package/public/assets/{gitGraphDiagram-NY62KEGX-B3Uw90Yt.js → gitGraphDiagram-NY62KEGX-CvxYSabY.js} +1 -1
  106. package/public/assets/{graph-Bp0jlxBT.js → graph-BYXvelIL.js} +1 -1
  107. package/public/assets/{index-f67nhEoX.js → index-BIGPvi1D.js} +44 -44
  108. package/public/assets/infoDiagram-F6ZHWCRC-CL9g-UgS.js +2 -0
  109. package/public/assets/{journeyDiagram-XKPGCS4Q-CgQogtHU.js → journeyDiagram-XKPGCS4Q-Df8G0pW8.js} +1 -1
  110. package/public/assets/{kanban-definition-3W4ZIXB7-Cv7kVxyy.js → kanban-definition-3W4ZIXB7-DhoP7TG_.js} +1 -1
  111. package/public/assets/{layout-6bkH32V1.js → layout-CgO4Vp_y.js} +1 -1
  112. package/public/assets/{linear-DWoZ6Tbm.js → linear-CaY74pOB.js} +1 -1
  113. package/public/assets/{mindmap-definition-VGOIOE7T-D5wd9HsH.js → mindmap-definition-VGOIOE7T-CVK2y0WQ.js} +1 -1
  114. package/public/assets/{pieDiagram-ADFJNKIX-8vPxErLm.js → pieDiagram-ADFJNKIX-BQt_waQk.js} +1 -1
  115. package/public/assets/{quadrantDiagram-AYHSOK5B-Pn0NZ9k7.js → quadrantDiagram-AYHSOK5B-DvLFoDeH.js} +1 -1
  116. package/public/assets/{requirementDiagram-UZGBJVZJ-C7u8MiN1.js → requirementDiagram-UZGBJVZJ-C4lqjEUP.js} +1 -1
  117. package/public/assets/{sankeyDiagram-TZEHDZUN-C660O4mw.js → sankeyDiagram-TZEHDZUN-BKIDyl6M.js} +1 -1
  118. package/public/assets/{sequenceDiagram-WL72ISMW-pXBA2_3B.js → sequenceDiagram-WL72ISMW-BeyhJ61U.js} +1 -1
  119. package/public/assets/{stateDiagram-FKZM4ZOC-CxZMM1Lf.js → stateDiagram-FKZM4ZOC-CKyn6eKl.js} +1 -1
  120. package/public/assets/stateDiagram-v2-4FDKWEC3-DogBVcJE.js +1 -0
  121. package/public/assets/{table-Clz57edU.js → table-BgVewkB5.js} +1 -1
  122. package/public/assets/{timeline-definition-IT6M3QCI-Crg44TaP.js → timeline-definition-IT6M3QCI-Cm5SIAmT.js} +1 -1
  123. package/public/assets/tools-crrPnehB.js +1 -0
  124. package/public/assets/{treemap-KMMF4GRG-bFxwBWXw.js → treemap-KMMF4GRG-CUMeoVWM.js} +1 -1
  125. package/public/assets/{ui-components-DjgDPiqV.js → ui-components-D1pZO0y-.js} +1 -1
  126. package/public/assets/{useAgents-8KXN6U61.js → useAgents-M4lcWvy0.js} +1 -1
  127. package/public/assets/{useClaudeVersions-DicHLV6A.js → useClaudeVersions-CKT_fq1t.js} +1 -1
  128. package/public/assets/{useCommands-DbSH48ba.js → useCommands-vaoVPEDI.js} +1 -1
  129. package/public/assets/{useProjects-Bbh6hJMM.js → useProjects-D1ElB-WS.js} +1 -1
  130. package/public/assets/{useSessions-DOa4-xiB.js → useSessions-Dp1kUl43.js} +1 -1
  131. package/public/assets/{xychartDiagram-PRI3JC2R-DG3KmjD-.js → xychartDiagram-PRI3JC2R-Cy-SHDyX.js} +1 -1
  132. package/public/index.html +4 -4
  133. package/routes/a2a.d.ts.map +1 -1
  134. package/routes/a2a.js +27 -7
  135. package/routes/a2a.js.map +1 -1
  136. package/routes/agents.d.ts.map +1 -1
  137. package/routes/agents.js +234 -38
  138. package/routes/agents.js.map +1 -1
  139. package/routes/agui.d.ts.map +1 -1
  140. package/routes/agui.js +44 -1
  141. package/routes/agui.js.map +1 -1
  142. package/routes/gitVersions.d.ts.map +1 -1
  143. package/routes/gitVersions.js +80 -1
  144. package/routes/gitVersions.js.map +1 -1
  145. package/routes/marketplaceSkills.d.ts +18 -0
  146. package/routes/marketplaceSkills.d.ts.map +1 -0
  147. package/routes/marketplaceSkills.js +190 -0
  148. package/routes/marketplaceSkills.js.map +1 -0
  149. package/routes/plugins.d.ts.map +1 -1
  150. package/routes/plugins.js +48 -7
  151. package/routes/plugins.js.map +1 -1
  152. package/routes/projects.d.ts.map +1 -1
  153. package/routes/projects.js +34 -0
  154. package/routes/projects.js.map +1 -1
  155. package/schemas/a2a.d.ts +35 -4
  156. package/schemas/a2a.d.ts.map +1 -1
  157. package/schemas/a2a.js +9 -1
  158. package/schemas/a2a.js.map +1 -1
  159. package/services/__tests__/agentImporter.test.js +197 -0
  160. package/services/__tests__/agentImporter.test.js.map +1 -1
  161. package/services/__tests__/pluginInstaller.test.js +2 -1
  162. package/services/__tests__/pluginInstaller.test.js.map +1 -1
  163. package/services/agentImporter.d.ts +7 -0
  164. package/services/agentImporter.d.ts.map +1 -1
  165. package/services/agentImporter.js +57 -4
  166. package/services/agentImporter.js.map +1 -1
  167. package/services/builtinMarketplaceService.d.ts +56 -0
  168. package/services/builtinMarketplaceService.d.ts.map +1 -0
  169. package/services/builtinMarketplaceService.js +328 -0
  170. package/services/builtinMarketplaceService.js.map +1 -0
  171. package/services/claudeSession.d.ts.map +1 -1
  172. package/services/claudeSession.js +15 -4
  173. package/services/claudeSession.js.map +1 -1
  174. package/services/claudeVersionStorage.js +6 -6
  175. package/services/claudeVersionStorage.js.map +1 -1
  176. package/services/gitVersionService.d.ts +22 -0
  177. package/services/gitVersionService.d.ts.map +1 -1
  178. package/services/gitVersionService.js +117 -19
  179. package/services/gitVersionService.js.map +1 -1
  180. package/services/marketplaceSkillService.d.ts +129 -0
  181. package/services/marketplaceSkillService.d.ts.map +1 -0
  182. package/services/marketplaceSkillService.js +358 -0
  183. package/services/marketplaceSkillService.js.map +1 -0
  184. package/services/marketplaceUpdateService.d.ts.map +1 -1
  185. package/services/marketplaceUpdateService.js +29 -2
  186. package/services/marketplaceUpdateService.js.map +1 -1
  187. package/services/pluginCopyInstall.d.ts +60 -0
  188. package/services/pluginCopyInstall.d.ts.map +1 -0
  189. package/services/pluginCopyInstall.js +290 -0
  190. package/services/pluginCopyInstall.js.map +1 -0
  191. package/services/pluginInstallStrategy.d.ts +39 -0
  192. package/services/pluginInstallStrategy.d.ts.map +1 -0
  193. package/services/pluginInstallStrategy.js +50 -0
  194. package/services/pluginInstallStrategy.js.map +1 -0
  195. package/services/pluginInstaller.d.ts +10 -0
  196. package/services/pluginInstaller.d.ts.map +1 -1
  197. package/services/pluginInstaller.js +70 -20
  198. package/services/pluginInstaller.js.map +1 -1
  199. package/services/pluginParser.d.ts +17 -1
  200. package/services/pluginParser.d.ts.map +1 -1
  201. package/services/pluginParser.js +161 -84
  202. package/services/pluginParser.js.map +1 -1
  203. package/services/pluginPaths.d.ts +3 -3
  204. package/services/pluginPaths.d.ts.map +1 -1
  205. package/services/pluginPaths.js +33 -14
  206. package/services/pluginPaths.js.map +1 -1
  207. package/services/pluginScanner.js +2 -2
  208. package/services/pluginScanner.js.map +1 -1
  209. package/services/pluginSymlink.d.ts +10 -0
  210. package/services/pluginSymlink.d.ts.map +1 -1
  211. package/services/pluginSymlink.js +117 -1
  212. package/services/pluginSymlink.js.map +1 -1
  213. package/services/preSendGuard/__tests__/preSendGuard.test.d.ts +2 -0
  214. package/services/preSendGuard/__tests__/preSendGuard.test.d.ts.map +1 -0
  215. package/services/preSendGuard/__tests__/preSendGuard.test.js +102 -0
  216. package/services/preSendGuard/__tests__/preSendGuard.test.js.map +1 -0
  217. package/services/preSendGuard/configResolver.d.ts +8 -0
  218. package/services/preSendGuard/configResolver.d.ts.map +1 -0
  219. package/services/preSendGuard/configResolver.js +181 -0
  220. package/services/preSendGuard/configResolver.js.map +1 -0
  221. package/services/preSendGuard/index.d.ts +9 -0
  222. package/services/preSendGuard/index.d.ts.map +1 -0
  223. package/services/preSendGuard/index.js +165 -0
  224. package/services/preSendGuard/index.js.map +1 -0
  225. package/services/preSendGuard/providers/httpAuditProvider.d.ts +3 -0
  226. package/services/preSendGuard/providers/httpAuditProvider.d.ts.map +1 -0
  227. package/services/preSendGuard/providers/httpAuditProvider.js +98 -0
  228. package/services/preSendGuard/providers/httpAuditProvider.js.map +1 -0
  229. package/services/preSendGuard/providers/noopProvider.d.ts +3 -0
  230. package/services/preSendGuard/providers/noopProvider.d.ts.map +1 -0
  231. package/services/preSendGuard/providers/noopProvider.js +13 -0
  232. package/services/preSendGuard/providers/noopProvider.js.map +1 -0
  233. package/services/runFinishedHooks.d.ts +29 -0
  234. package/services/runFinishedHooks.d.ts.map +1 -0
  235. package/services/runFinishedHooks.js +57 -0
  236. package/services/runFinishedHooks.js.map +1 -0
  237. package/testing/index.d.ts +18 -0
  238. package/testing/index.d.ts.map +1 -0
  239. package/testing/index.js +25 -0
  240. package/testing/index.js.map +1 -0
  241. package/testing/mockSdkQuery.d.ts +49 -0
  242. package/testing/mockSdkQuery.d.ts.map +1 -0
  243. package/testing/mockSdkQuery.js +209 -0
  244. package/testing/mockSdkQuery.js.map +1 -0
  245. package/testing/scenarioLoader.d.ts +71 -0
  246. package/testing/scenarioLoader.d.ts.map +1 -0
  247. package/testing/scenarioLoader.js +224 -0
  248. package/testing/scenarioLoader.js.map +1 -0
  249. package/types/a2a.d.ts +5 -0
  250. package/types/a2a.d.ts.map +1 -1
  251. package/types/agents.d.ts +32 -0
  252. package/types/agents.d.ts.map +1 -1
  253. package/types/agents.js +1 -0
  254. package/types/agents.js.map +1 -1
  255. package/types/engine.d.ts +6 -0
  256. package/types/engine.d.ts.map +1 -1
  257. package/types/plugins.d.ts +12 -2
  258. package/types/plugins.d.ts.map +1 -1
  259. package/types/preSendGuard.d.ts +51 -0
  260. package/types/preSendGuard.d.ts.map +1 -0
  261. package/types/preSendGuard.js +3 -0
  262. package/types/preSendGuard.js.map +1 -0
  263. package/utils/__tests__/claudeUtils.test.js +89 -1
  264. package/utils/__tests__/claudeUtils.test.js.map +1 -1
  265. package/utils/claudeUtils.d.ts +1 -1
  266. package/utils/claudeUtils.d.ts.map +1 -1
  267. package/utils/claudeUtils.js +92 -37
  268. package/utils/claudeUtils.js.map +1 -1
  269. package/public/assets/ChatPage-D8buVhfb.js +0 -478
  270. package/public/assets/GeneralSettingsPage-DYdwai51.js +0 -1
  271. package/public/assets/PluginsPage-DD92Xk6X.js +0 -12
  272. package/public/assets/SettingsLayout-LGC-0pQl.js +0 -1
  273. package/public/assets/UnifiedToolSelector-BP6fuyzG.js +0 -1
  274. package/public/assets/channel-D9wyZF1L.js +0 -1
  275. package/public/assets/classDiagram-2ON5EDUG-DwEqkkEb.js +0 -1
  276. package/public/assets/classDiagram-v2-WZHVMYZB-DwEqkkEb.js +0 -1
  277. package/public/assets/clone-3wFPaI2j.js +0 -1
  278. package/public/assets/infoDiagram-F6ZHWCRC-HUfwv_JT.js +0 -2
  279. package/public/assets/stateDiagram-v2-4FDKWEC3-CmurzrWf.js +0 -1
  280. package/public/assets/tools-BZTR2NP1.js +0 -1
@@ -1 +1 @@
1
- import{j as e}from"./data-structures-ChC1tqVg.js";import{r as a}from"./monaco-editor-BWfQfpij.js";import{c as me,s as y,a as f,d as K}from"./index-f67nhEoX.js";import{G as ue,j as Q,ad as X,r as A,V as N,l as he,ae as Y,U as Z,_ as W,af as fe,I as be,M as pe,b as ye,ag as je}from"./ui-components-DjgDPiqV.js";import"./syntax-highlighting-DGbNjS3S.js";import"./agents-KlPdWQ8K.js";import"./tools-BZTR2NP1.js";const et=()=>{const ee=me(),[F,te]=a.useState("tunely"),[i,S]=a.useState(null),[d,j]=a.useState(null),[m,z]=a.useState("https://agentstudio.woa.com"),[g,U]=a.useState(""),[k,P]=a.useState("https"),[u,D]=a.useState(!1),[w,b]=a.useState(!1),[B,C]=a.useState(!1),[H,J]=a.useState(!1),[T,p]=a.useState(null),[re,G]=a.useState(!1),[E,x]=a.useState("server"),[l,L]=a.useState(null),[_,q]=a.useState(!1),[ke,ae]=a.useState(null),[we,ve]=a.useState(""),[Ne,Se]=a.useState(""),[Ce,Te]=a.useState(""),[Ee,Ie]=a.useState("4936"),[$e,M]=a.useState(!1),[Ae,Fe]=a.useState(!1),[ze,Ue]=a.useState(!1),[Pe,De]=a.useState(null),[Be,Le]=a.useState(null),[Oe,Re]=a.useState(!1),[We,He]=a.useState(!1),[Je,Ge]=a.useState(null),[_e,O]=a.useState("intro"),[qe,se]=a.useState(!0);a.useEffect(()=>{ne(),v(),xe()},[]),a.useEffect(()=>{if(!d?.connected)return;const t=setInterval(v,5e3);return()=>clearInterval(t)},[d?.connected]);const ne=async()=>{try{const t=await fetch("/api/tunnel/config",{headers:{Authorization:`Bearer ${localStorage.getItem("jwt")}`}});if(!t.ok)throw new Error("Failed to load configuration");const r=await t.json();S(r),z(r.serverUrl||"https://agentstudio.woa.com"),U(r.tunnelName||""),P(r.protocol||"https"),D(r.enabled||!1),r.token&&r.tunnelName?(x("connected"),r.serverUrl&&V(r.serverUrl,!1)):x("server")}catch(t){console.error("Error loading config:",t)}},V=async(t,r=!0)=>{q(!0);try{const o=await fetch("/api/tunnel/server-info",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("jwt")}`},body:JSON.stringify({serverUrl:t})}),h=await o.json();if(!o.ok||!h.success)throw new Error(h.error||`服务器返回错误: HTTP ${o.status}`);const c=h.data,s={name:c.name||"Tunely Server",version:c.version||"1.0.0",domain:{pattern:c.domain?.pattern||"{subdomain}.tunnel",customizable:c.domain?.customizable||"subdomain",suffix:c.domain?.suffix||".tunnel"},websocket:{url:c.websocket?.url||t.replace(/\/+$/,"").replace("https://","wss://").replace("http://","ws://")+"/ws/tunnel"},protocols:c.protocols||["https","http"],instruction:c.instruction};L(s),r&&(y(`已连接到 ${s.name} v${s.version}`),x("domain"))}catch(o){console.error("Error fetching server info:",o),r&&f(o instanceof Error?o.message:"获取服务器信息失败")}finally{q(!1)}},v=a.useCallback(async()=>{try{const t=await fetch("/api/tunnel/status",{headers:{Authorization:`Bearer ${localStorage.getItem("jwt")}`}});if(!t.ok)throw new Error("Failed to load status");const r=await t.json();j(r)}catch(t){console.error("Error loading status:",t)}},[]),oe=async()=>{if(!g.trim()){p({available:!1,reason:"请输入隧道名称"});return}J(!0),p(null);try{const r=await(await fetch(`/api/tunnel/check-name?name=${encodeURIComponent(g.trim())}&serverUrl=${encodeURIComponent(m)}`,{headers:{Authorization:`Bearer ${localStorage.getItem("jwt")}`}})).json();p(r)}catch{p({available:!1,reason:"检查失败,请重试"})}finally{J(!1)}},le=async()=>{if(!g.trim()){f("请输入隧道名称");return}b(!0);try{const t=await fetch("/api/tunnel/create-tunnel",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("jwt")}`},body:JSON.stringify({name:g.trim(),serverUrl:m,autoConnect:u,protocol:k,websocketUrl:l?.websocket?.url,domainSuffix:l?.domain?.suffix})}),r=await t.json();if(!t.ok||!r.success)throw new Error(r.error||"Failed to create tunnel");if(S(r.config),j(r.status),p(null),x("connected"),y(`隧道 "${g}" 创建成功!域名: ${r.domain}`),u){K("正在连接隧道...");let o=0;const h=15,c=setInterval(async()=>{o++,await v(),(await(await fetch("/api/tunnel/status",{headers:{Authorization:`Bearer ${localStorage.getItem("jwt")}`}})).json())?.connected?(y("隧道已连接!"),clearInterval(c)):o>=h&&clearInterval(c)},1e3)}}catch(t){f(t instanceof Error?t.message:"Failed to create tunnel")}finally{b(!1)}},ce=async()=>{C(!0);try{const t=await fetch("/api/tunnel/connect",{method:"POST",headers:{Authorization:`Bearer ${localStorage.getItem("jwt")}`}});if(!t.ok){const o=await t.json();throw new Error(o.error||"Failed to connect")}const r=await t.json();j(r.status),K("隧道连接中..."),setTimeout(v,2e3)}catch(t){f(t instanceof Error?t.message:"Failed to connect")}finally{C(!1)}},ie=async()=>{C(!0);try{const t=await fetch("/api/tunnel/disconnect",{method:"POST",headers:{Authorization:`Bearer ${localStorage.getItem("jwt")}`}});if(!t.ok){const o=await t.json();throw new Error(o.error||"Failed to disconnect")}const r=await t.json();j(r.status),y("已断开隧道连接")}catch(t){f(t instanceof Error?t.message:"Failed to disconnect")}finally{C(!1)}},I=()=>{if(!i?.tunnelName)return null;const t=i.domainSuffix||l?.domain?.suffix||".agentstudio.woa.com";return`${i.tunnelName}${t}`},de=()=>{const t=I();t&&(navigator.clipboard.writeText(`${i?.protocol||"https"}://${t}`),G(!0),setTimeout(()=>G(!1),2e3))},xe=async()=>{M(!0);try{const t=await fetch("/api/cloudflare-tunnel/config",{headers:{Authorization:`Bearer ${localStorage.getItem("jwt")}`}});if(!t.ok)throw new Error("Failed to load Cloudflare configuration");const r=await t.json();ae(r),r.activeTunnel?(O("done"),se(!1)):r.hasApiToken&&r.hasAccountId?O("create"):O("credentials")}catch(t){console.error("Error loading Cloudflare config:",t)}finally{M(!1)}},ge=()=>{const t=()=>e.jsx(e.Fragment,{children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6",children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center gap-2 mb-4",children:[e.jsx(A,{className:"w-5 h-5"}),"配置隧道服务"]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"隧道服务器地址"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:m,onChange:s=>z(s.target.value),placeholder:"https://agentstudio.woa.com",className:"flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent"}),e.jsxs("button",{onClick:()=>V(m),disabled:_||!m.trim(),className:"flex items-center gap-2 px-4 py-2 bg-blue-500 hover:bg-blue-600 text-white rounded-lg disabled:opacity-50",children:[_?e.jsx(N,{className:"w-4 h-4 animate-spin"}):e.jsx(he,{className:"w-4 h-4"}),"连接"]})]}),e.jsx("p",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:'输入隧道服务的地址,点击"连接"获取服务信息'})]})})]})}),r=()=>e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(A,{className:"w-5 h-5"}),"配置隧道域名"]}),e.jsx("button",{onClick:()=>{L(null),x("server")},className:"text-sm text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300",children:"更换服务器"})]}),l&&e.jsx("div",{className:"mb-4 p-3 rounded-lg bg-blue-50 border border-blue-200 dark:bg-blue-900/20 dark:border-blue-800",children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-blue-700 dark:text-blue-300",children:[e.jsx(Y,{className:"w-4 h-4"}),e.jsxs("span",{children:["已连接到 ",e.jsx("strong",{children:l.name})," v",l.version]})]})}),l?.instruction&&e.jsx("div",{className:"mb-4 p-4 rounded-lg bg-blue-50 border border-blue-200 dark:bg-blue-900/20 dark:border-blue-800",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Z,{className:"w-5 h-5 text-blue-600 dark:text-blue-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-blue-800 dark:text-blue-200",children:[e.jsx("p",{className:"font-medium mb-1",children:"服务器说明"}),e.jsx("p",{className:"whitespace-pre-wrap",children:l.instruction})]})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"隧道域名"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"flex-1 flex items-center",children:[e.jsx("select",{value:k,onChange:s=>P(s.target.value),className:"px-3 py-2 bg-gray-100 dark:bg-gray-700 border border-r-0 border-gray-300 dark:border-gray-600 rounded-l-lg text-gray-700 dark:text-gray-300 text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent cursor-pointer",children:(l?.protocols||["https","http"]).map(s=>e.jsxs("option",{value:s,children:[s,"://"]},s))}),e.jsx("input",{type:"text",value:g,onChange:s=>{U(s.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),p(null)},placeholder:"my-agent",className:"flex-1 px-3 py-2 border-y border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent"}),e.jsx("span",{className:"px-3 py-2 bg-gray-100 dark:bg-gray-700 border border-l-0 border-gray-300 dark:border-gray-600 rounded-r-lg text-gray-500 dark:text-gray-400 text-sm whitespace-nowrap",children:l?.domain.suffix||".agentstudio.woa.com"})]}),e.jsxs("button",{onClick:oe,disabled:H||!g.trim(),className:"flex items-center gap-2 px-4 py-2 bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-300 rounded-lg disabled:opacity-50 transition-colors",children:[H?e.jsx(N,{className:"w-4 h-4 animate-spin"}):e.jsx(W,{className:"w-4 h-4"}),"检测"]})]}),T&&e.jsx("div",{className:`mt-2 text-sm flex items-center gap-1 ${T.available?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"}`,children:T.available?e.jsxs(e.Fragment,{children:[e.jsx(Y,{className:"w-4 h-4"}),e.jsxs("span",{children:["名称可用!完整域名: ",k,"://",g,l?.domain.suffix]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Q,{className:"w-4 h-4"}),e.jsx("span",{children:T.reason||"名称不可用"})]})})]}),e.jsxs("div",{className:"flex items-center justify-between py-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"启动时自动连接"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Agent Studio 启动时自动建立隧道连接"})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:u,onChange:s=>D(s.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600"})]})]}),e.jsx("div",{className:"pt-4 border-t border-gray-200 dark:border-gray-700",children:e.jsxs("button",{onClick:le,disabled:w||!g.trim(),className:"flex items-center gap-2 px-4 py-2 bg-blue-500 hover:bg-blue-600 text-white rounded-lg disabled:opacity-50",children:[w?e.jsx(N,{className:"w-4 h-4 animate-spin"}):e.jsx(W,{className:"w-4 h-4"}),"创建隧道"]})})]})]}),o=async()=>{if(await ee({title:"确认删除",message:"确定要删除隧道配置吗?删除后需要重新配置隧道。",confirmText:"删除",cancelText:"取消",variant:"danger"})){b(!0);try{const n=await fetch("/api/tunnel/config",{method:"DELETE",headers:{Authorization:`Bearer ${localStorage.getItem("jwt")}`}});if(!n.ok){const R=await n.json();throw new Error(R.error||"Failed to delete tunnel")}const $=await n.json();S($.config),j($.status),U(""),L(null),x("server"),y("隧道配置已删除")}catch(n){f(n instanceof Error?n.message:"Failed to delete tunnel")}finally{b(!1)}}},h=()=>e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`rounded-lg border p-4 ${d?.connected?"bg-green-50 border-green-200 dark:bg-green-900/20 dark:border-green-800":"bg-gray-50 border-gray-200 dark:bg-gray-800/50 dark:border-gray-700"}`,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4 flex-1",children:[d?.connected?e.jsx(X,{className:"w-6 h-6 text-green-500 flex-shrink-0"}):e.jsx(fe,{className:"w-6 h-6 text-gray-400 flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:d?.connected?"已连接":"未连接"}),d?.connected&&I()&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:[i?.protocol||"https","://",I()]}),e.jsx("button",{onClick:de,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",title:"复制",children:re?e.jsx(W,{className:"w-4 h-4 text-green-500"}):e.jsx(be,{className:"w-4 h-4"})}),e.jsx("a",{href:`${i?.protocol||"https"}://${I()}`,target:"_blank",rel:"noopener noreferrer",className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",title:"在新窗口打开",children:e.jsx(pe,{className:"w-4 h-4"})})]}),d.connectedAt&&e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:["连接时间: ",new Date(d.connectedAt).toLocaleString()]})]}),d?.lastError&&e.jsx("div",{className:"text-sm text-red-500",children:d.lastError})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx("button",{onClick:v,className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700",title:"刷新状态",children:e.jsx(N,{className:"w-4 h-4"})}),d?.connected?e.jsxs("button",{onClick:ie,disabled:B,className:"flex items-center gap-2 px-4 py-2 bg-red-500 hover:bg-red-600 text-white rounded-lg disabled:opacity-50",children:[e.jsx(ye,{className:"w-4 h-4"}),"断开"]}):e.jsxs("button",{onClick:ce,disabled:B,className:"flex items-center gap-2 px-4 py-2 bg-blue-500 hover:bg-blue-600 text-white rounded-lg disabled:opacity-50",children:[e.jsx(je,{className:"w-4 h-4"}),B?"连接中...":"连接"]})]})]})}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(A,{className:"w-5 h-5"}),"隧道配置"]}),e.jsx("button",{onClick:()=>{x("edit")},className:"text-sm text-blue-500 hover:text-blue-600",children:"编辑配置"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"隧道名称"}),e.jsx("p",{className:"font-medium text-gray-900 dark:text-white",children:i?.tunnelName})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"协议"}),e.jsx("p",{className:"font-medium text-gray-900 dark:text-white",children:i?.protocol?.toUpperCase()})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"服务器"}),e.jsx("p",{className:"font-medium text-gray-900 dark:text-white",children:i?.serverUrl})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"自动连接"}),e.jsx("p",{className:"font-medium text-gray-900 dark:text-white",children:i?.enabled?"是":"否"})]})]}),l?.instruction&&e.jsx("div",{className:"mt-4 p-3 rounded-lg bg-blue-50 border border-blue-200 dark:bg-blue-900/20 dark:border-blue-800",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Z,{className:"w-4 h-4 text-blue-600 dark:text-blue-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-xs text-blue-800 dark:text-blue-200",children:[e.jsx("p",{className:"font-medium mb-1",children:"服务器说明"}),e.jsx("p",{className:"whitespace-pre-wrap",children:l.instruction})]})]})}),e.jsx("div",{className:"mt-6 pt-4 border-t border-gray-200 dark:border-gray-700",children:e.jsx("button",{onClick:o,disabled:w,className:"text-sm text-red-500 hover:text-red-600 dark:text-red-400 dark:hover:text-red-300",children:"删除隧道配置"})})]})]}),c=()=>{const s=async()=>{b(!0);try{const n=await fetch("/api/tunnel/config",{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("jwt")}`},body:JSON.stringify({enabled:u,serverUrl:m,protocol:k})});if(!n.ok){const R=await n.json();throw new Error(R.error||"Failed to save config")}const $=await n.json();S($.config),y("配置已保存"),x("connected")}catch(n){f(n instanceof Error?n.message:"Failed to save config")}finally{b(!1)}};return e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(A,{className:"w-5 h-5"}),"编辑隧道配置"]}),e.jsx("button",{onClick:()=>x("connected"),className:"text-sm text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:"取消"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:["隧道名称 ",e.jsx("span",{className:"text-gray-400",children:"(不可修改)"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:i?.tunnelName||"",disabled:!0,className:"flex-1 px-3 py-2 border border-gray-200 dark:border-gray-600 rounded-lg bg-gray-100 dark:bg-gray-700 text-gray-500 dark:text-gray-400 cursor-not-allowed"}),e.jsx("span",{className:"px-3 py-2 bg-gray-100 dark:bg-gray-700 border border-gray-200 dark:border-gray-600 rounded-lg text-gray-500 dark:text-gray-400 text-sm",children:i?.domainSuffix||l?.domain?.suffix||".agentstudio.woa.com"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"服务器地址"}),e.jsx("input",{type:"text",value:m,onChange:n=>z(n.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"https://agentstudio.woa.com"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"访问协议"}),e.jsxs("select",{value:k,onChange:n=>P(n.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent",children:[e.jsx("option",{value:"https",children:"HTTPS"}),e.jsx("option",{value:"http",children:"HTTP"})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"自动连接"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"启动时自动连接隧道"})]}),e.jsx("button",{onClick:()=>D(!u),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${u?"bg-blue-500":"bg-gray-300 dark:bg-gray-600"}`,children:e.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${u?"translate-x-6":"translate-x-1"}`})})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx("button",{onClick:()=>x("connected"),className:"flex-1 px-4 py-2 border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700",children:"取消"}),e.jsx("button",{onClick:s,disabled:w,className:"flex-1 px-4 py-2 bg-blue-500 hover:bg-blue-600 text-white rounded-lg disabled:opacity-50 flex items-center justify-center gap-2",children:w?e.jsxs(e.Fragment,{children:[e.jsx(N,{className:"w-4 h-4 animate-spin"}),"保存中..."]}):"保存配置"})]})]})]})};return e.jsxs("div",{className:"space-y-6",children:[E==="server"&&t(),E==="domain"&&r(),E==="connected"&&h(),E==="edit"&&c()]})};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(ue,{className:"w-7 h-7"}),"隧道接入"]}),e.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"通过隧道让外部网络可以访问本地 Agent Studio"})]}),e.jsx("div",{className:"bg-amber-50 dark:bg-amber-900/20 rounded-lg border border-amber-200 dark:border-amber-800 p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Q,{className:"w-5 h-5 text-amber-500 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-amber-700 dark:text-amber-300",children:[e.jsx("p",{className:"font-medium mb-1",children:"安全提示"}),e.jsx("p",{children:"隧道接入会将本地 Agent Studio 服务暴露到公网,存在一定的安全风险。请确保您了解相关风险后再进行配置。"})]})]})}),e.jsx("div",{className:"border-b border-gray-200 dark:border-gray-700",children:e.jsxs("nav",{className:"-mb-px flex space-x-8",children:[e.jsxs("button",{onClick:()=>te("tunely"),className:`py-4 px-1 border-b-2 font-medium text-sm flex items-center gap-2 ${F==="tunely"?"border-blue-500 text-blue-600 dark:text-blue-400":"border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300 dark:text-gray-400 dark:hover:text-gray-300"}`,children:[e.jsx(X,{className:"w-4 h-4"}),"Tunely (WebSocket)"]}),!1]})}),F==="tunely"&&ge(),F==="cloudflare"&&!1]})};export{et as WebSocketTunnelPage,et as default};
1
+ import{j as e}from"./data-structures-ChC1tqVg.js";import{r as a}from"./monaco-editor-BWfQfpij.js";import{c as me,s as y,a as f,d as M}from"./index-BIGPvi1D.js";import{G as ue,j as Q,ad as X,r as A,V as N,l as he,ae as Y,U as Z,_ as W,af as fe,I as be,N as pe,b as ye,ag as je}from"./ui-components-D1pZO0y-.js";import"./syntax-highlighting-DGbNjS3S.js";import"./agents-DR9EZMs5.js";import"./tools-crrPnehB.js";const et=()=>{const ee=me(),[F,te]=a.useState("tunely"),[i,S]=a.useState(null),[d,j]=a.useState(null),[m,z]=a.useState("https://agentstudio.woa.com"),[g,U]=a.useState(""),[k,P]=a.useState("https"),[u,D]=a.useState(!1),[w,b]=a.useState(!1),[B,C]=a.useState(!1),[H,J]=a.useState(!1),[T,p]=a.useState(null),[re,G]=a.useState(!1),[E,x]=a.useState("server"),[l,L]=a.useState(null),[_,q]=a.useState(!1),[ke,ae]=a.useState(null),[we,ve]=a.useState(""),[Ne,Se]=a.useState(""),[Ce,Te]=a.useState(""),[Ee,Ie]=a.useState("4936"),[$e,V]=a.useState(!1),[Ae,Fe]=a.useState(!1),[ze,Ue]=a.useState(!1),[Pe,De]=a.useState(null),[Be,Le]=a.useState(null),[Oe,Re]=a.useState(!1),[We,He]=a.useState(!1),[Je,Ge]=a.useState(null),[_e,O]=a.useState("intro"),[qe,se]=a.useState(!0);a.useEffect(()=>{ne(),v(),xe()},[]),a.useEffect(()=>{if(!d?.connected)return;const t=setInterval(v,5e3);return()=>clearInterval(t)},[d?.connected]);const ne=async()=>{try{const t=await fetch("/api/tunnel/config",{headers:{Authorization:`Bearer ${localStorage.getItem("jwt")}`}});if(!t.ok)throw new Error("Failed to load configuration");const r=await t.json();S(r),z(r.serverUrl||"https://agentstudio.woa.com"),U(r.tunnelName||""),P(r.protocol||"https"),D(r.enabled||!1),r.token&&r.tunnelName?(x("connected"),r.serverUrl&&K(r.serverUrl,!1)):x("server")}catch(t){console.error("Error loading config:",t)}},K=async(t,r=!0)=>{q(!0);try{const o=await fetch("/api/tunnel/server-info",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("jwt")}`},body:JSON.stringify({serverUrl:t})}),h=await o.json();if(!o.ok||!h.success)throw new Error(h.error||`服务器返回错误: HTTP ${o.status}`);const c=h.data,s={name:c.name||"Tunely Server",version:c.version||"1.0.0",domain:{pattern:c.domain?.pattern||"{subdomain}.tunnel",customizable:c.domain?.customizable||"subdomain",suffix:c.domain?.suffix||".tunnel"},websocket:{url:c.websocket?.url||t.replace(/\/+$/,"").replace("https://","wss://").replace("http://","ws://")+"/ws/tunnel"},protocols:c.protocols||["https","http"],instruction:c.instruction};L(s),r&&(y(`已连接到 ${s.name} v${s.version}`),x("domain"))}catch(o){console.error("Error fetching server info:",o),r&&f(o instanceof Error?o.message:"获取服务器信息失败")}finally{q(!1)}},v=a.useCallback(async()=>{try{const t=await fetch("/api/tunnel/status",{headers:{Authorization:`Bearer ${localStorage.getItem("jwt")}`}});if(!t.ok)throw new Error("Failed to load status");const r=await t.json();j(r)}catch(t){console.error("Error loading status:",t)}},[]),oe=async()=>{if(!g.trim()){p({available:!1,reason:"请输入隧道名称"});return}J(!0),p(null);try{const r=await(await fetch(`/api/tunnel/check-name?name=${encodeURIComponent(g.trim())}&serverUrl=${encodeURIComponent(m)}`,{headers:{Authorization:`Bearer ${localStorage.getItem("jwt")}`}})).json();p(r)}catch{p({available:!1,reason:"检查失败,请重试"})}finally{J(!1)}},le=async()=>{if(!g.trim()){f("请输入隧道名称");return}b(!0);try{const t=await fetch("/api/tunnel/create-tunnel",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("jwt")}`},body:JSON.stringify({name:g.trim(),serverUrl:m,autoConnect:u,protocol:k,websocketUrl:l?.websocket?.url,domainSuffix:l?.domain?.suffix})}),r=await t.json();if(!t.ok||!r.success)throw new Error(r.error||"Failed to create tunnel");if(S(r.config),j(r.status),p(null),x("connected"),y(`隧道 "${g}" 创建成功!域名: ${r.domain}`),u){M("正在连接隧道...");let o=0;const h=15,c=setInterval(async()=>{o++,await v(),(await(await fetch("/api/tunnel/status",{headers:{Authorization:`Bearer ${localStorage.getItem("jwt")}`}})).json())?.connected?(y("隧道已连接!"),clearInterval(c)):o>=h&&clearInterval(c)},1e3)}}catch(t){f(t instanceof Error?t.message:"Failed to create tunnel")}finally{b(!1)}},ce=async()=>{C(!0);try{const t=await fetch("/api/tunnel/connect",{method:"POST",headers:{Authorization:`Bearer ${localStorage.getItem("jwt")}`}});if(!t.ok){const o=await t.json();throw new Error(o.error||"Failed to connect")}const r=await t.json();j(r.status),M("隧道连接中..."),setTimeout(v,2e3)}catch(t){f(t instanceof Error?t.message:"Failed to connect")}finally{C(!1)}},ie=async()=>{C(!0);try{const t=await fetch("/api/tunnel/disconnect",{method:"POST",headers:{Authorization:`Bearer ${localStorage.getItem("jwt")}`}});if(!t.ok){const o=await t.json();throw new Error(o.error||"Failed to disconnect")}const r=await t.json();j(r.status),y("已断开隧道连接")}catch(t){f(t instanceof Error?t.message:"Failed to disconnect")}finally{C(!1)}},I=()=>{if(!i?.tunnelName)return null;const t=i.domainSuffix||l?.domain?.suffix||".agentstudio.woa.com";return`${i.tunnelName}${t}`},de=()=>{const t=I();t&&(navigator.clipboard.writeText(`${i?.protocol||"https"}://${t}`),G(!0),setTimeout(()=>G(!1),2e3))},xe=async()=>{V(!0);try{const t=await fetch("/api/cloudflare-tunnel/config",{headers:{Authorization:`Bearer ${localStorage.getItem("jwt")}`}});if(!t.ok)throw new Error("Failed to load Cloudflare configuration");const r=await t.json();ae(r),r.activeTunnel?(O("done"),se(!1)):r.hasApiToken&&r.hasAccountId?O("create"):O("credentials")}catch(t){console.error("Error loading Cloudflare config:",t)}finally{V(!1)}},ge=()=>{const t=()=>e.jsx(e.Fragment,{children:e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6",children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center gap-2 mb-4",children:[e.jsx(A,{className:"w-5 h-5"}),"配置隧道服务"]}),e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"隧道服务器地址"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:m,onChange:s=>z(s.target.value),placeholder:"https://agentstudio.woa.com",className:"flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent"}),e.jsxs("button",{onClick:()=>K(m),disabled:_||!m.trim(),className:"flex items-center gap-2 px-4 py-2 bg-blue-500 hover:bg-blue-600 text-white rounded-lg disabled:opacity-50",children:[_?e.jsx(N,{className:"w-4 h-4 animate-spin"}):e.jsx(he,{className:"w-4 h-4"}),"连接"]})]}),e.jsx("p",{className:"mt-2 text-xs text-gray-500 dark:text-gray-400",children:'输入隧道服务的地址,点击"连接"获取服务信息'})]})})]})}),r=()=>e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(A,{className:"w-5 h-5"}),"配置隧道域名"]}),e.jsx("button",{onClick:()=>{L(null),x("server")},className:"text-sm text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300",children:"更换服务器"})]}),l&&e.jsx("div",{className:"mb-4 p-3 rounded-lg bg-blue-50 border border-blue-200 dark:bg-blue-900/20 dark:border-blue-800",children:e.jsxs("div",{className:"flex items-center gap-2 text-sm text-blue-700 dark:text-blue-300",children:[e.jsx(Y,{className:"w-4 h-4"}),e.jsxs("span",{children:["已连接到 ",e.jsx("strong",{children:l.name})," v",l.version]})]})}),l?.instruction&&e.jsx("div",{className:"mb-4 p-4 rounded-lg bg-blue-50 border border-blue-200 dark:bg-blue-900/20 dark:border-blue-800",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Z,{className:"w-5 h-5 text-blue-600 dark:text-blue-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-blue-800 dark:text-blue-200",children:[e.jsx("p",{className:"font-medium mb-1",children:"服务器说明"}),e.jsx("p",{className:"whitespace-pre-wrap",children:l.instruction})]})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"隧道域名"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"flex-1 flex items-center",children:[e.jsx("select",{value:k,onChange:s=>P(s.target.value),className:"px-3 py-2 bg-gray-100 dark:bg-gray-700 border border-r-0 border-gray-300 dark:border-gray-600 rounded-l-lg text-gray-700 dark:text-gray-300 text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent cursor-pointer",children:(l?.protocols||["https","http"]).map(s=>e.jsxs("option",{value:s,children:[s,"://"]},s))}),e.jsx("input",{type:"text",value:g,onChange:s=>{U(s.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),p(null)},placeholder:"my-agent",className:"flex-1 px-3 py-2 border-y border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent"}),e.jsx("span",{className:"px-3 py-2 bg-gray-100 dark:bg-gray-700 border border-l-0 border-gray-300 dark:border-gray-600 rounded-r-lg text-gray-500 dark:text-gray-400 text-sm whitespace-nowrap",children:l?.domain.suffix||".agentstudio.woa.com"})]}),e.jsxs("button",{onClick:oe,disabled:H||!g.trim(),className:"flex items-center gap-2 px-4 py-2 bg-gray-100 hover:bg-gray-200 dark:bg-gray-700 dark:hover:bg-gray-600 text-gray-700 dark:text-gray-300 rounded-lg disabled:opacity-50 transition-colors",children:[H?e.jsx(N,{className:"w-4 h-4 animate-spin"}):e.jsx(W,{className:"w-4 h-4"}),"检测"]})]}),T&&e.jsx("div",{className:`mt-2 text-sm flex items-center gap-1 ${T.available?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"}`,children:T.available?e.jsxs(e.Fragment,{children:[e.jsx(Y,{className:"w-4 h-4"}),e.jsxs("span",{children:["名称可用!完整域名: ",k,"://",g,l?.domain.suffix]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Q,{className:"w-4 h-4"}),e.jsx("span",{children:T.reason||"名称不可用"})]})})]}),e.jsxs("div",{className:"flex items-center justify-between py-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"启动时自动连接"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"Agent Studio 启动时自动建立隧道连接"})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:u,onChange:s=>D(s.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-blue-300 dark:peer-focus:ring-blue-800 rounded-full peer dark:bg-gray-700 peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all dark:border-gray-600 peer-checked:bg-blue-600"})]})]}),e.jsx("div",{className:"pt-4 border-t border-gray-200 dark:border-gray-700",children:e.jsxs("button",{onClick:le,disabled:w||!g.trim(),className:"flex items-center gap-2 px-4 py-2 bg-blue-500 hover:bg-blue-600 text-white rounded-lg disabled:opacity-50",children:[w?e.jsx(N,{className:"w-4 h-4 animate-spin"}):e.jsx(W,{className:"w-4 h-4"}),"创建隧道"]})})]})]}),o=async()=>{if(await ee({title:"确认删除",message:"确定要删除隧道配置吗?删除后需要重新配置隧道。",confirmText:"删除",cancelText:"取消",variant:"danger"})){b(!0);try{const n=await fetch("/api/tunnel/config",{method:"DELETE",headers:{Authorization:`Bearer ${localStorage.getItem("jwt")}`}});if(!n.ok){const R=await n.json();throw new Error(R.error||"Failed to delete tunnel")}const $=await n.json();S($.config),j($.status),U(""),L(null),x("server"),y("隧道配置已删除")}catch(n){f(n instanceof Error?n.message:"Failed to delete tunnel")}finally{b(!1)}}},h=()=>e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`rounded-lg border p-4 ${d?.connected?"bg-green-50 border-green-200 dark:bg-green-900/20 dark:border-green-800":"bg-gray-50 border-gray-200 dark:bg-gray-800/50 dark:border-gray-700"}`,children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4 flex-1",children:[d?.connected?e.jsx(X,{className:"w-6 h-6 text-green-500 flex-shrink-0"}):e.jsx(fe,{className:"w-6 h-6 text-gray-400 flex-shrink-0"}),e.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[e.jsx("div",{className:"font-medium text-gray-900 dark:text-white",children:d?.connected?"已连接":"未连接"}),d?.connected&&I()&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-sm text-gray-600 dark:text-gray-300",children:[i?.protocol||"https","://",I()]}),e.jsx("button",{onClick:de,className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",title:"复制",children:re?e.jsx(W,{className:"w-4 h-4 text-green-500"}):e.jsx(be,{className:"w-4 h-4"})}),e.jsx("a",{href:`${i?.protocol||"https"}://${I()}`,target:"_blank",rel:"noopener noreferrer",className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",title:"在新窗口打开",children:e.jsx(pe,{className:"w-4 h-4"})})]}),d.connectedAt&&e.jsxs("div",{className:"text-xs text-gray-500 dark:text-gray-400",children:["连接时间: ",new Date(d.connectedAt).toLocaleString()]})]}),d?.lastError&&e.jsx("div",{className:"text-sm text-red-500",children:d.lastError})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx("button",{onClick:v,className:"p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700",title:"刷新状态",children:e.jsx(N,{className:"w-4 h-4"})}),d?.connected?e.jsxs("button",{onClick:ie,disabled:B,className:"flex items-center gap-2 px-4 py-2 bg-red-500 hover:bg-red-600 text-white rounded-lg disabled:opacity-50",children:[e.jsx(ye,{className:"w-4 h-4"}),"断开"]}):e.jsxs("button",{onClick:ce,disabled:B,className:"flex items-center gap-2 px-4 py-2 bg-blue-500 hover:bg-blue-600 text-white rounded-lg disabled:opacity-50",children:[e.jsx(je,{className:"w-4 h-4"}),B?"连接中...":"连接"]})]})]})}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(A,{className:"w-5 h-5"}),"隧道配置"]}),e.jsx("button",{onClick:()=>{x("edit")},className:"text-sm text-blue-500 hover:text-blue-600",children:"编辑配置"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"隧道名称"}),e.jsx("p",{className:"font-medium text-gray-900 dark:text-white",children:i?.tunnelName})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"协议"}),e.jsx("p",{className:"font-medium text-gray-900 dark:text-white",children:i?.protocol?.toUpperCase()})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"服务器"}),e.jsx("p",{className:"font-medium text-gray-900 dark:text-white",children:i?.serverUrl})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-gray-500 dark:text-gray-400",children:"自动连接"}),e.jsx("p",{className:"font-medium text-gray-900 dark:text-white",children:i?.enabled?"是":"否"})]})]}),l?.instruction&&e.jsx("div",{className:"mt-4 p-3 rounded-lg bg-blue-50 border border-blue-200 dark:bg-blue-900/20 dark:border-blue-800",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(Z,{className:"w-4 h-4 text-blue-600 dark:text-blue-400 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-xs text-blue-800 dark:text-blue-200",children:[e.jsx("p",{className:"font-medium mb-1",children:"服务器说明"}),e.jsx("p",{className:"whitespace-pre-wrap",children:l.instruction})]})]})}),e.jsx("div",{className:"mt-6 pt-4 border-t border-gray-200 dark:border-gray-700",children:e.jsx("button",{onClick:o,disabled:w,className:"text-sm text-red-500 hover:text-red-600 dark:text-red-400 dark:hover:text-red-300",children:"删除隧道配置"})})]})]}),c=()=>{const s=async()=>{b(!0);try{const n=await fetch("/api/tunnel/config",{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("jwt")}`},body:JSON.stringify({enabled:u,serverUrl:m,protocol:k})});if(!n.ok){const R=await n.json();throw new Error(R.error||"Failed to save config")}const $=await n.json();S($.config),y("配置已保存"),x("connected")}catch(n){f(n instanceof Error?n.message:"Failed to save config")}finally{b(!1)}};return e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(A,{className:"w-5 h-5"}),"编辑隧道配置"]}),e.jsx("button",{onClick:()=>x("connected"),className:"text-sm text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",children:"取消"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:["隧道名称 ",e.jsx("span",{className:"text-gray-400",children:"(不可修改)"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:i?.tunnelName||"",disabled:!0,className:"flex-1 px-3 py-2 border border-gray-200 dark:border-gray-600 rounded-lg bg-gray-100 dark:bg-gray-700 text-gray-500 dark:text-gray-400 cursor-not-allowed"}),e.jsx("span",{className:"px-3 py-2 bg-gray-100 dark:bg-gray-700 border border-gray-200 dark:border-gray-600 rounded-lg text-gray-500 dark:text-gray-400 text-sm",children:i?.domainSuffix||l?.domain?.suffix||".agentstudio.woa.com"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"服务器地址"}),e.jsx("input",{type:"text",value:m,onChange:n=>z(n.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent",placeholder:"https://agentstudio.woa.com"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2",children:"访问协议"}),e.jsxs("select",{value:k,onChange:n=>P(n.target.value),className:"w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent",children:[e.jsx("option",{value:"https",children:"HTTPS"}),e.jsx("option",{value:"http",children:"HTTP"})]})]}),e.jsxs("div",{className:"flex items-center justify-between py-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-gray-700 dark:text-gray-300",children:"自动连接"}),e.jsx("p",{className:"text-xs text-gray-500 dark:text-gray-400",children:"启动时自动连接隧道"})]}),e.jsx("button",{onClick:()=>D(!u),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${u?"bg-blue-500":"bg-gray-300 dark:bg-gray-600"}`,children:e.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${u?"translate-x-6":"translate-x-1"}`})})]}),e.jsxs("div",{className:"flex gap-3 pt-4",children:[e.jsx("button",{onClick:()=>x("connected"),className:"flex-1 px-4 py-2 border border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-300 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700",children:"取消"}),e.jsx("button",{onClick:s,disabled:w,className:"flex-1 px-4 py-2 bg-blue-500 hover:bg-blue-600 text-white rounded-lg disabled:opacity-50 flex items-center justify-center gap-2",children:w?e.jsxs(e.Fragment,{children:[e.jsx(N,{className:"w-4 h-4 animate-spin"}),"保存中..."]}):"保存配置"})]})]})]})};return e.jsxs("div",{className:"space-y-6",children:[E==="server"&&t(),E==="domain"&&r(),E==="connected"&&h(),E==="edit"&&c()]})};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white flex items-center gap-2",children:[e.jsx(ue,{className:"w-7 h-7"}),"隧道接入"]}),e.jsx("p",{className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:"通过隧道让外部网络可以访问本地 Agent Studio"})]}),e.jsx("div",{className:"bg-amber-50 dark:bg-amber-900/20 rounded-lg border border-amber-200 dark:border-amber-800 p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Q,{className:"w-5 h-5 text-amber-500 flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-amber-700 dark:text-amber-300",children:[e.jsx("p",{className:"font-medium mb-1",children:"安全提示"}),e.jsx("p",{children:"隧道接入会将本地 Agent Studio 服务暴露到公网,存在一定的安全风险。请确保您了解相关风险后再进行配置。"})]})]})}),e.jsx("div",{className:"border-b border-gray-200 dark:border-gray-700",children:e.jsxs("nav",{className:"-mb-px flex space-x-8",children:[e.jsxs("button",{onClick:()=>te("tunely"),className:`py-4 px-1 border-b-2 font-medium text-sm flex items-center gap-2 ${F==="tunely"?"border-blue-500 text-blue-600 dark:text-blue-400":"border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300 dark:text-gray-400 dark:hover:text-gray-300"}`,children:[e.jsx(X,{className:"w-4 h-4"}),"Tunely (WebSocket)"]}),!1]})}),F==="tunely"&&ge(),F==="cloudflare"&&!1]})};export{et as WebSocketTunnelPage,et as default};
@@ -1 +1 @@
1
- import{e as x,c as b,g as m,k as P,h as p,j as w,l as N,m as c,n as I,t as A,o as M}from"./_baseUniq-B1lmu3qr.js";import{aL as g,ar as E,aM as F,aN as T,aO as _,aP as l,aQ as $,aR as B,aS as S,aT as y}from"./ChatPage-D8buVhfb.js";var L=/\s/;function R(n){for(var r=n.length;r--&&L.test(n.charAt(r)););return r}var G=/^\s+/;function H(n){return n&&n.slice(0,R(n)+1).replace(G,"")}var o=NaN,q=/^[-+]0x[0-9a-f]+$/i,z=/^0b[01]+$/i,C=/^0o[0-7]+$/i,K=parseInt;function Q(n){if(typeof n=="number")return n;if(x(n))return o;if(g(n)){var r=typeof n.valueOf=="function"?n.valueOf():n;n=g(r)?r+"":r}if(typeof n!="string")return n===0?n:+n;n=H(n);var t=z.test(n);return t||C.test(n)?K(n.slice(2),t?2:8):q.test(n)?o:+n}var v=1/0,W=17976931348623157e292;function X(n){if(!n)return n===0?n:0;if(n=Q(n),n===v||n===-v){var r=n<0?-1:1;return r*W}return n===n?n:0}function Y(n){var r=X(n),t=r%1;return r===r?t?r-t:r:0}function fn(n){var r=n==null?0:n.length;return r?b(n):[]}var O=Object.prototype,D=O.hasOwnProperty,dn=E(function(n,r){n=Object(n);var t=-1,i=r.length,a=i>2?r[2]:void 0;for(a&&F(r[0],r[1],a)&&(i=1);++t<i;)for(var f=r[t],e=T(f),s=-1,d=e.length;++s<d;){var u=e[s],h=n[u];(h===void 0||_(h,O[u])&&!D.call(n,u))&&(n[u]=f[u])}return n});function un(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}function J(n){return function(r,t,i){var a=Object(r);if(!l(r)){var f=m(t);r=P(r),t=function(s){return f(a[s],s,a)}}var e=n(r,t,i);return e>-1?a[f?r[e]:e]:void 0}}var U=Math.max;function Z(n,r,t){var i=n==null?0:n.length;if(!i)return-1;var a=t==null?0:Y(t);return a<0&&(a=U(i+a,0)),p(n,m(r),a)}var hn=J(Z);function V(n,r){var t=-1,i=l(n)?Array(n.length):[];return w(n,function(a,f,e){i[++t]=r(a,f,e)}),i}function gn(n,r){var t=$(n)?N:V;return t(n,m(r))}var j=Object.prototype,k=j.hasOwnProperty;function nn(n,r){return n!=null&&k.call(n,r)}function mn(n,r){return n!=null&&c(n,r,nn)}function rn(n,r){return n<r}function tn(n,r,t){for(var i=-1,a=n.length;++i<a;){var f=n[i],e=r(f);if(e!=null&&(s===void 0?e===e&&!x(e):t(e,s)))var s=e,d=f}return d}function on(n){return n&&n.length?tn(n,B,rn):void 0}function an(n,r,t,i){if(!g(n))return n;r=I(r,n);for(var a=-1,f=r.length,e=f-1,s=n;s!=null&&++a<f;){var d=A(r[a]),u=t;if(d==="__proto__"||d==="constructor"||d==="prototype")return n;if(a!=e){var h=s[d];u=void 0,u===void 0&&(u=g(h)?h:S(r[a+1])?[]:{})}y(s,d,u),s=s[d]}return n}function vn(n,r,t){for(var i=-1,a=r.length,f={};++i<a;){var e=r[i],s=M(n,e);t(s,e)&&an(f,I(e,n),s)}return f}export{rn as a,tn as b,V as c,vn as d,on as e,fn as f,hn as g,mn as h,dn as i,Y as j,un as l,gn as m,X as t};
1
+ import{e as x,c as b,g as m,k as P,h as p,j as w,l as N,m as c,n as I,t as A,o as M}from"./_baseUniq-Q0NUbuSr.js";import{aL as g,ar as E,aM as F,aN as T,aO as _,aP as l,aQ as $,aR as B,aS as S,aT as y}from"./ChatPage-B7-rn9mH.js";var L=/\s/;function R(n){for(var r=n.length;r--&&L.test(n.charAt(r)););return r}var G=/^\s+/;function H(n){return n&&n.slice(0,R(n)+1).replace(G,"")}var o=NaN,q=/^[-+]0x[0-9a-f]+$/i,z=/^0b[01]+$/i,C=/^0o[0-7]+$/i,K=parseInt;function Q(n){if(typeof n=="number")return n;if(x(n))return o;if(g(n)){var r=typeof n.valueOf=="function"?n.valueOf():n;n=g(r)?r+"":r}if(typeof n!="string")return n===0?n:+n;n=H(n);var t=z.test(n);return t||C.test(n)?K(n.slice(2),t?2:8):q.test(n)?o:+n}var v=1/0,W=17976931348623157e292;function X(n){if(!n)return n===0?n:0;if(n=Q(n),n===v||n===-v){var r=n<0?-1:1;return r*W}return n===n?n:0}function Y(n){var r=X(n),t=r%1;return r===r?t?r-t:r:0}function fn(n){var r=n==null?0:n.length;return r?b(n):[]}var O=Object.prototype,D=O.hasOwnProperty,dn=E(function(n,r){n=Object(n);var t=-1,i=r.length,a=i>2?r[2]:void 0;for(a&&F(r[0],r[1],a)&&(i=1);++t<i;)for(var f=r[t],e=T(f),s=-1,d=e.length;++s<d;){var u=e[s],h=n[u];(h===void 0||_(h,O[u])&&!D.call(n,u))&&(n[u]=f[u])}return n});function un(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}function J(n){return function(r,t,i){var a=Object(r);if(!l(r)){var f=m(t);r=P(r),t=function(s){return f(a[s],s,a)}}var e=n(r,t,i);return e>-1?a[f?r[e]:e]:void 0}}var U=Math.max;function Z(n,r,t){var i=n==null?0:n.length;if(!i)return-1;var a=t==null?0:Y(t);return a<0&&(a=U(i+a,0)),p(n,m(r),a)}var hn=J(Z);function V(n,r){var t=-1,i=l(n)?Array(n.length):[];return w(n,function(a,f,e){i[++t]=r(a,f,e)}),i}function gn(n,r){var t=$(n)?N:V;return t(n,m(r))}var j=Object.prototype,k=j.hasOwnProperty;function nn(n,r){return n!=null&&k.call(n,r)}function mn(n,r){return n!=null&&c(n,r,nn)}function rn(n,r){return n<r}function tn(n,r,t){for(var i=-1,a=n.length;++i<a;){var f=n[i],e=r(f);if(e!=null&&(s===void 0?e===e&&!x(e):t(e,s)))var s=e,d=f}return d}function on(n){return n&&n.length?tn(n,B,rn):void 0}function an(n,r,t,i){if(!g(n))return n;r=I(r,n);for(var a=-1,f=r.length,e=f-1,s=n;s!=null&&++a<f;){var d=A(r[a]),u=t;if(d==="__proto__"||d==="constructor"||d==="prototype")return n;if(a!=e){var h=s[d];u=void 0,u===void 0&&(u=g(h)?h:S(r[a+1])?[]:{})}y(s,d,u),s=s[d]}return n}function vn(n,r,t){for(var i=-1,a=r.length,f={};++i<a;){var e=r[i],s=M(n,e);t(s,e)&&an(f,I(e,n),s)}return f}export{rn as a,tn as b,V as c,vn as d,on as e,fn as f,hn as g,mn as h,dn as i,Y as j,un as l,gn as m,X as t};
@@ -1 +1 @@
1
- import{bd as S,be as Rn,aQ as T,bf as w,bg as xn,bh as mn,aP as sn,bi as Mn,bj as un,bk as x,aN as N,bl as Cn,bm as on,bn as Fn,bo as E,bb as gn,bp as R,aL as ln,bq as Dn,br as D,bs as Gn,bt as Nn,bu as _,aT as Un,bv as Bn,aO as Kn,bw as Q,bx as jn,by as Hn,aS as qn,aR as cn,b9 as Yn,bz as M}from"./ChatPage-D8buVhfb.js";var Zn="[object Symbol]";function U(n){return typeof n=="symbol"||S(n)&&Rn(n)==Zn}function bn(n,r){for(var e=-1,t=n==null?0:n.length,f=Array(t);++e<t;)f[e]=r(n[e],e,n);return f}var X=w?w.prototype:void 0,J=X?X.toString:void 0;function dn(n){if(typeof n=="string")return n;if(T(n))return bn(n,dn)+"";if(U(n))return J?J.call(n):"";var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}function Qn(){}function pn(n,r){for(var e=-1,t=n==null?0:n.length;++e<t&&r(n[e],e,n)!==!1;);return n}function Xn(n,r,e,t){for(var f=n.length,i=e+-1;++i<f;)if(r(n[i],i,n))return i;return-1}function Jn(n){return n!==n}function Wn(n,r,e){for(var t=e-1,f=n.length;++t<f;)if(n[t]===r)return t;return-1}function zn(n,r,e){return r===r?Wn(n,r,e):Xn(n,Jn,e)}function Vn(n,r){var e=n==null?0:n.length;return!!e&&zn(n,r,0)>-1}function $(n){return sn(n)?xn(n):mn(n)}var kn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,nr=/^\w*$/;function B(n,r){if(T(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||U(n)?!0:nr.test(n)||!kn.test(n)||r!=null&&n in Object(r)}var rr=500;function er(n){var r=Mn(n,function(t){return e.size===rr&&e.clear(),t}),e=r.cache;return r}var tr=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ir=/\\(\\)?/g,fr=er(function(n){var r=[];return n.charCodeAt(0)===46&&r.push(""),n.replace(tr,function(e,t,f,i){r.push(f?i.replace(ir,"$1"):t||e)}),r});function ar(n){return n==null?"":dn(n)}function An(n,r){return T(n)?n:B(n,r)?[n]:fr(ar(n))}function m(n){if(typeof n=="string"||U(n))return n;var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}function yn(n,r){r=An(r,n);for(var e=0,t=r.length;n!=null&&e<t;)n=n[m(r[e++])];return e&&e==t?n:void 0}function sr(n,r,e){var t=n==null?void 0:yn(n,r);return t===void 0?e:t}function K(n,r){for(var e=-1,t=r.length,f=n.length;++e<t;)n[f+e]=r[e];return n}var W=w?w.isConcatSpreadable:void 0;function ur(n){return T(n)||un(n)||!!(W&&n&&n[W])}function Ot(n,r,e,t,f){var i=-1,a=n.length;for(e||(e=ur),f||(f=[]);++i<a;){var s=n[i];e(s)?K(f,s):t||(f[f.length]=s)}return f}function or(n,r,e,t){var f=-1,i=n==null?0:n.length;for(t&&i&&(e=n[++f]);++f<i;)e=r(e,n[f],f,n);return e}function gr(n,r){return n&&x(r,$(r),n)}function lr(n,r){return n&&x(r,N(r),n)}function Tn(n,r){for(var e=-1,t=n==null?0:n.length,f=0,i=[];++e<t;){var a=n[e];r(a,e,n)&&(i[f++]=a)}return i}function hn(){return[]}var cr=Object.prototype,br=cr.propertyIsEnumerable,z=Object.getOwnPropertySymbols,j=z?function(n){return n==null?[]:(n=Object(n),Tn(z(n),function(r){return br.call(n,r)}))}:hn;function dr(n,r){return x(n,j(n),r)}var pr=Object.getOwnPropertySymbols,wn=pr?function(n){for(var r=[];n;)K(r,j(n)),n=Cn(n);return r}:hn;function Ar(n,r){return x(n,wn(n),r)}function On(n,r,e){var t=r(n);return T(n)?t:K(t,e(n))}function G(n){return On(n,$,j)}function yr(n){return On(n,N,wn)}var Tr=Object.prototype,hr=Tr.hasOwnProperty;function wr(n){var r=n.length,e=new n.constructor(r);return r&&typeof n[0]=="string"&&hr.call(n,"index")&&(e.index=n.index,e.input=n.input),e}function Or(n,r){var e=r?on(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var $r=/\w*$/;function _r(n){var r=new n.constructor(n.source,$r.exec(n));return r.lastIndex=n.lastIndex,r}var V=w?w.prototype:void 0,k=V?V.valueOf:void 0;function Sr(n){return k?Object(k.call(n)):{}}var Er="[object Boolean]",Pr="[object Date]",Ir="[object Map]",vr="[object Number]",Lr="[object RegExp]",Rr="[object Set]",xr="[object String]",mr="[object Symbol]",Mr="[object ArrayBuffer]",Cr="[object DataView]",Fr="[object Float32Array]",Dr="[object Float64Array]",Gr="[object Int8Array]",Nr="[object Int16Array]",Ur="[object Int32Array]",Br="[object Uint8Array]",Kr="[object Uint8ClampedArray]",jr="[object Uint16Array]",Hr="[object Uint32Array]";function qr(n,r,e){var t=n.constructor;switch(r){case Mr:return on(n);case Er:case Pr:return new t(+n);case Cr:return Or(n,e);case Fr:case Dr:case Gr:case Nr:case Ur:case Br:case Kr:case jr:case Hr:return Fn(n,e);case Ir:return new t;case vr:case xr:return new t(n);case Lr:return _r(n);case Rr:return new t;case mr:return Sr(n)}}var Yr="[object Map]";function Zr(n){return S(n)&&E(n)==Yr}var nn=R&&R.isMap,Qr=nn?gn(nn):Zr,Xr="[object Set]";function Jr(n){return S(n)&&E(n)==Xr}var rn=R&&R.isSet,Wr=rn?gn(rn):Jr,zr=1,Vr=2,kr=4,$n="[object Arguments]",ne="[object Array]",re="[object Boolean]",ee="[object Date]",te="[object Error]",_n="[object Function]",ie="[object GeneratorFunction]",fe="[object Map]",ae="[object Number]",Sn="[object Object]",se="[object RegExp]",ue="[object Set]",oe="[object String]",ge="[object Symbol]",le="[object WeakMap]",ce="[object ArrayBuffer]",be="[object DataView]",de="[object Float32Array]",pe="[object Float64Array]",Ae="[object Int8Array]",ye="[object Int16Array]",Te="[object Int32Array]",he="[object Uint8Array]",we="[object Uint8ClampedArray]",Oe="[object Uint16Array]",$e="[object Uint32Array]",g={};g[$n]=g[ne]=g[ce]=g[be]=g[re]=g[ee]=g[de]=g[pe]=g[Ae]=g[ye]=g[Te]=g[fe]=g[ae]=g[Sn]=g[se]=g[ue]=g[oe]=g[ge]=g[he]=g[we]=g[Oe]=g[$e]=!0;g[te]=g[_n]=g[le]=!1;function C(n,r,e,t,f,i){var a,s=r&zr,u=r&Vr,b=r&kr;if(a!==void 0)return a;if(!ln(n))return n;var l=T(n);if(l){if(a=wr(n),!s)return Dn(n,a)}else{var o=E(n),c=o==_n||o==ie;if(D(n))return Gn(n,s);if(o==Sn||o==$n||c&&!f){if(a=u||c?{}:Nn(n),!s)return u?Ar(n,lr(a,n)):dr(n,gr(a,n))}else{if(!g[o])return f?n:{};a=qr(n,o,s)}}i||(i=new _);var h=i.get(n);if(h)return h;i.set(n,a),Wr(n)?n.forEach(function(d){a.add(C(d,r,e,d,n,i))}):Qr(n)&&n.forEach(function(d,p){a.set(p,C(d,r,e,p,n,i))});var A=b?u?yr:G:u?N:$,y=l?void 0:A(n);return pn(y||n,function(d,p){y&&(p=d,d=n[p]),Un(a,p,C(d,r,e,p,n,i))}),a}var _e="__lodash_hash_undefined__";function Se(n){return this.__data__.set(n,_e),this}function Ee(n){return this.__data__.has(n)}function P(n){var r=-1,e=n==null?0:n.length;for(this.__data__=new Bn;++r<e;)this.add(n[r])}P.prototype.add=P.prototype.push=Se;P.prototype.has=Ee;function Pe(n,r){for(var e=-1,t=n==null?0:n.length;++e<t;)if(r(n[e],e,n))return!0;return!1}function En(n,r){return n.has(r)}var Ie=1,ve=2;function Pn(n,r,e,t,f,i){var a=e&Ie,s=n.length,u=r.length;if(s!=u&&!(a&&u>s))return!1;var b=i.get(n),l=i.get(r);if(b&&l)return b==r&&l==n;var o=-1,c=!0,h=e&ve?new P:void 0;for(i.set(n,r),i.set(r,n);++o<s;){var A=n[o],y=r[o];if(t)var d=a?t(y,A,o,r,n,i):t(A,y,o,n,r,i);if(d!==void 0){if(d)continue;c=!1;break}if(h){if(!Pe(r,function(p,O){if(!En(h,O)&&(A===p||f(A,p,e,t,i)))return h.push(O)})){c=!1;break}}else if(!(A===y||f(A,y,e,t,i))){c=!1;break}}return i.delete(n),i.delete(r),c}function Le(n){var r=-1,e=Array(n.size);return n.forEach(function(t,f){e[++r]=[f,t]}),e}function H(n){var r=-1,e=Array(n.size);return n.forEach(function(t){e[++r]=t}),e}var Re=1,xe=2,me="[object Boolean]",Me="[object Date]",Ce="[object Error]",Fe="[object Map]",De="[object Number]",Ge="[object RegExp]",Ne="[object Set]",Ue="[object String]",Be="[object Symbol]",Ke="[object ArrayBuffer]",je="[object DataView]",en=w?w.prototype:void 0,F=en?en.valueOf:void 0;function He(n,r,e,t,f,i,a){switch(e){case je:if(n.byteLength!=r.byteLength||n.byteOffset!=r.byteOffset)return!1;n=n.buffer,r=r.buffer;case Ke:return!(n.byteLength!=r.byteLength||!i(new Q(n),new Q(r)));case me:case Me:case De:return Kn(+n,+r);case Ce:return n.name==r.name&&n.message==r.message;case Ge:case Ue:return n==r+"";case Fe:var s=Le;case Ne:var u=t&Re;if(s||(s=H),n.size!=r.size&&!u)return!1;var b=a.get(n);if(b)return b==r;t|=xe,a.set(n,r);var l=Pn(s(n),s(r),t,f,i,a);return a.delete(n),l;case Be:if(F)return F.call(n)==F.call(r)}return!1}var qe=1,Ye=Object.prototype,Ze=Ye.hasOwnProperty;function Qe(n,r,e,t,f,i){var a=e&qe,s=G(n),u=s.length,b=G(r),l=b.length;if(u!=l&&!a)return!1;for(var o=u;o--;){var c=s[o];if(!(a?c in r:Ze.call(r,c)))return!1}var h=i.get(n),A=i.get(r);if(h&&A)return h==r&&A==n;var y=!0;i.set(n,r),i.set(r,n);for(var d=a;++o<u;){c=s[o];var p=n[c],O=r[c];if(t)var Z=a?t(O,p,c,r,n,i):t(p,O,c,n,r,i);if(!(Z===void 0?p===O||f(p,O,e,t,i):Z)){y=!1;break}d||(d=c=="constructor")}if(y&&!d){var I=n.constructor,v=r.constructor;I!=v&&"constructor"in n&&"constructor"in r&&!(typeof I=="function"&&I instanceof I&&typeof v=="function"&&v instanceof v)&&(y=!1)}return i.delete(n),i.delete(r),y}var Xe=1,tn="[object Arguments]",fn="[object Array]",L="[object Object]",Je=Object.prototype,an=Je.hasOwnProperty;function We(n,r,e,t,f,i){var a=T(n),s=T(r),u=a?fn:E(n),b=s?fn:E(r);u=u==tn?L:u,b=b==tn?L:b;var l=u==L,o=b==L,c=u==b;if(c&&D(n)){if(!D(r))return!1;a=!0,l=!1}if(c&&!l)return i||(i=new _),a||jn(n)?Pn(n,r,e,t,f,i):He(n,r,u,e,t,f,i);if(!(e&Xe)){var h=l&&an.call(n,"__wrapped__"),A=o&&an.call(r,"__wrapped__");if(h||A){var y=h?n.value():n,d=A?r.value():r;return i||(i=new _),f(y,d,e,t,i)}}return c?(i||(i=new _),Qe(n,r,e,t,f,i)):!1}function q(n,r,e,t,f){return n===r?!0:n==null||r==null||!S(n)&&!S(r)?n!==n&&r!==r:We(n,r,e,t,q,f)}var ze=1,Ve=2;function ke(n,r,e,t){var f=e.length,i=f;if(n==null)return!i;for(n=Object(n);f--;){var a=e[f];if(a[2]?a[1]!==n[a[0]]:!(a[0]in n))return!1}for(;++f<i;){a=e[f];var s=a[0],u=n[s],b=a[1];if(a[2]){if(u===void 0&&!(s in n))return!1}else{var l=new _,o;if(!(o===void 0?q(b,u,ze|Ve,t,l):o))return!1}}return!0}function In(n){return n===n&&!ln(n)}function nt(n){for(var r=$(n),e=r.length;e--;){var t=r[e],f=n[t];r[e]=[t,f,In(f)]}return r}function vn(n,r){return function(e){return e==null?!1:e[n]===r&&(r!==void 0||n in Object(e))}}function rt(n){var r=nt(n);return r.length==1&&r[0][2]?vn(r[0][0],r[0][1]):function(e){return e===n||ke(e,n,r)}}function et(n,r){return n!=null&&r in Object(n)}function tt(n,r,e){r=An(r,n);for(var t=-1,f=r.length,i=!1;++t<f;){var a=m(r[t]);if(!(i=n!=null&&e(n,a)))break;n=n[a]}return i||++t!=f?i:(f=n==null?0:n.length,!!f&&Hn(f)&&qn(a,f)&&(T(n)||un(n)))}function it(n,r){return n!=null&&tt(n,r,et)}var ft=1,at=2;function st(n,r){return B(n)&&In(r)?vn(m(n),r):function(e){var t=sr(e,n);return t===void 0&&t===r?it(e,n):q(r,t,ft|at)}}function ut(n){return function(r){return r?.[n]}}function ot(n){return function(r){return yn(r,n)}}function gt(n){return B(n)?ut(m(n)):ot(n)}function Ln(n){return typeof n=="function"?n:n==null?cn:typeof n=="object"?T(n)?st(n[0],n[1]):rt(n):gt(n)}function lt(n,r){return n&&Yn(n,r,$)}function ct(n,r){return function(e,t){if(e==null)return e;if(!sn(e))return n(e,t);for(var f=e.length,i=-1,a=Object(e);++i<f&&t(a[i],i,a)!==!1;);return e}}var Y=ct(lt);function bt(n){return typeof n=="function"?n:cn}function $t(n,r){var e=T(n)?pn:Y;return e(n,bt(r))}function dt(n,r){var e=[];return Y(n,function(t,f,i){r(t,f,i)&&e.push(t)}),e}function _t(n,r){var e=T(n)?Tn:dt;return e(n,Ln(r))}function pt(n,r){return bn(r,function(e){return n[e]})}function St(n){return n==null?[]:pt(n,$(n))}function Et(n){return n===void 0}function At(n,r,e,t,f){return f(n,function(i,a,s){e=t?(t=!1,i):r(e,i,a,s)}),e}function Pt(n,r,e){var t=T(n)?or:At,f=arguments.length<3;return t(n,Ln(r),e,f,Y)}var yt=1/0,Tt=M&&1/H(new M([,-0]))[1]==yt?function(n){return new M(n)}:Qn,ht=200;function It(n,r,e){var t=-1,f=Vn,i=n.length,a=!0,s=[],u=s;if(i>=ht){var b=r?null:Tt(n);if(b)return H(b);a=!1,f=En,u=new P}else u=r?[]:s;n:for(;++t<i;){var l=n[t],o=r?r(l):l;if(l=l!==0?l:0,a&&o===o){for(var c=u.length;c--;)if(u[c]===o)continue n;r&&u.push(o),s.push(l)}else f(u,o,e)||(u!==s&&u.push(o),s.push(l))}return s}export{Tn as A,dt as B,Pe as C,Qn as D,P as S,It as a,C as b,Ot as c,$t as d,U as e,_t as f,Ln as g,Xn as h,Et as i,Y as j,$ as k,bn as l,tt as m,An as n,yn as o,bt as p,lt as q,Pt as r,it as s,m as t,ar as u,St as v,Vn as w,En as x,zn as y,yr as z};
1
+ import{bd as S,be as Rn,aQ as T,bf as w,bg as xn,bh as mn,aP as sn,bi as Mn,bj as un,bk as x,aN as N,bl as Cn,bm as on,bn as Fn,bo as E,bb as gn,bp as R,aL as ln,bq as Dn,br as D,bs as Gn,bt as Nn,bu as _,aT as Un,bv as Bn,aO as Kn,bw as Q,bx as jn,by as Hn,aS as qn,aR as cn,b9 as Yn,bz as M}from"./ChatPage-B7-rn9mH.js";var Zn="[object Symbol]";function U(n){return typeof n=="symbol"||S(n)&&Rn(n)==Zn}function bn(n,r){for(var e=-1,t=n==null?0:n.length,f=Array(t);++e<t;)f[e]=r(n[e],e,n);return f}var X=w?w.prototype:void 0,J=X?X.toString:void 0;function dn(n){if(typeof n=="string")return n;if(T(n))return bn(n,dn)+"";if(U(n))return J?J.call(n):"";var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}function Qn(){}function pn(n,r){for(var e=-1,t=n==null?0:n.length;++e<t&&r(n[e],e,n)!==!1;);return n}function Xn(n,r,e,t){for(var f=n.length,i=e+-1;++i<f;)if(r(n[i],i,n))return i;return-1}function Jn(n){return n!==n}function Wn(n,r,e){for(var t=e-1,f=n.length;++t<f;)if(n[t]===r)return t;return-1}function zn(n,r,e){return r===r?Wn(n,r,e):Xn(n,Jn,e)}function Vn(n,r){var e=n==null?0:n.length;return!!e&&zn(n,r,0)>-1}function $(n){return sn(n)?xn(n):mn(n)}var kn=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,nr=/^\w*$/;function B(n,r){if(T(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||U(n)?!0:nr.test(n)||!kn.test(n)||r!=null&&n in Object(r)}var rr=500;function er(n){var r=Mn(n,function(t){return e.size===rr&&e.clear(),t}),e=r.cache;return r}var tr=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ir=/\\(\\)?/g,fr=er(function(n){var r=[];return n.charCodeAt(0)===46&&r.push(""),n.replace(tr,function(e,t,f,i){r.push(f?i.replace(ir,"$1"):t||e)}),r});function ar(n){return n==null?"":dn(n)}function An(n,r){return T(n)?n:B(n,r)?[n]:fr(ar(n))}function m(n){if(typeof n=="string"||U(n))return n;var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}function yn(n,r){r=An(r,n);for(var e=0,t=r.length;n!=null&&e<t;)n=n[m(r[e++])];return e&&e==t?n:void 0}function sr(n,r,e){var t=n==null?void 0:yn(n,r);return t===void 0?e:t}function K(n,r){for(var e=-1,t=r.length,f=n.length;++e<t;)n[f+e]=r[e];return n}var W=w?w.isConcatSpreadable:void 0;function ur(n){return T(n)||un(n)||!!(W&&n&&n[W])}function Ot(n,r,e,t,f){var i=-1,a=n.length;for(e||(e=ur),f||(f=[]);++i<a;){var s=n[i];e(s)?K(f,s):t||(f[f.length]=s)}return f}function or(n,r,e,t){var f=-1,i=n==null?0:n.length;for(t&&i&&(e=n[++f]);++f<i;)e=r(e,n[f],f,n);return e}function gr(n,r){return n&&x(r,$(r),n)}function lr(n,r){return n&&x(r,N(r),n)}function Tn(n,r){for(var e=-1,t=n==null?0:n.length,f=0,i=[];++e<t;){var a=n[e];r(a,e,n)&&(i[f++]=a)}return i}function hn(){return[]}var cr=Object.prototype,br=cr.propertyIsEnumerable,z=Object.getOwnPropertySymbols,j=z?function(n){return n==null?[]:(n=Object(n),Tn(z(n),function(r){return br.call(n,r)}))}:hn;function dr(n,r){return x(n,j(n),r)}var pr=Object.getOwnPropertySymbols,wn=pr?function(n){for(var r=[];n;)K(r,j(n)),n=Cn(n);return r}:hn;function Ar(n,r){return x(n,wn(n),r)}function On(n,r,e){var t=r(n);return T(n)?t:K(t,e(n))}function G(n){return On(n,$,j)}function yr(n){return On(n,N,wn)}var Tr=Object.prototype,hr=Tr.hasOwnProperty;function wr(n){var r=n.length,e=new n.constructor(r);return r&&typeof n[0]=="string"&&hr.call(n,"index")&&(e.index=n.index,e.input=n.input),e}function Or(n,r){var e=r?on(n.buffer):n.buffer;return new n.constructor(e,n.byteOffset,n.byteLength)}var $r=/\w*$/;function _r(n){var r=new n.constructor(n.source,$r.exec(n));return r.lastIndex=n.lastIndex,r}var V=w?w.prototype:void 0,k=V?V.valueOf:void 0;function Sr(n){return k?Object(k.call(n)):{}}var Er="[object Boolean]",Pr="[object Date]",Ir="[object Map]",vr="[object Number]",Lr="[object RegExp]",Rr="[object Set]",xr="[object String]",mr="[object Symbol]",Mr="[object ArrayBuffer]",Cr="[object DataView]",Fr="[object Float32Array]",Dr="[object Float64Array]",Gr="[object Int8Array]",Nr="[object Int16Array]",Ur="[object Int32Array]",Br="[object Uint8Array]",Kr="[object Uint8ClampedArray]",jr="[object Uint16Array]",Hr="[object Uint32Array]";function qr(n,r,e){var t=n.constructor;switch(r){case Mr:return on(n);case Er:case Pr:return new t(+n);case Cr:return Or(n,e);case Fr:case Dr:case Gr:case Nr:case Ur:case Br:case Kr:case jr:case Hr:return Fn(n,e);case Ir:return new t;case vr:case xr:return new t(n);case Lr:return _r(n);case Rr:return new t;case mr:return Sr(n)}}var Yr="[object Map]";function Zr(n){return S(n)&&E(n)==Yr}var nn=R&&R.isMap,Qr=nn?gn(nn):Zr,Xr="[object Set]";function Jr(n){return S(n)&&E(n)==Xr}var rn=R&&R.isSet,Wr=rn?gn(rn):Jr,zr=1,Vr=2,kr=4,$n="[object Arguments]",ne="[object Array]",re="[object Boolean]",ee="[object Date]",te="[object Error]",_n="[object Function]",ie="[object GeneratorFunction]",fe="[object Map]",ae="[object Number]",Sn="[object Object]",se="[object RegExp]",ue="[object Set]",oe="[object String]",ge="[object Symbol]",le="[object WeakMap]",ce="[object ArrayBuffer]",be="[object DataView]",de="[object Float32Array]",pe="[object Float64Array]",Ae="[object Int8Array]",ye="[object Int16Array]",Te="[object Int32Array]",he="[object Uint8Array]",we="[object Uint8ClampedArray]",Oe="[object Uint16Array]",$e="[object Uint32Array]",g={};g[$n]=g[ne]=g[ce]=g[be]=g[re]=g[ee]=g[de]=g[pe]=g[Ae]=g[ye]=g[Te]=g[fe]=g[ae]=g[Sn]=g[se]=g[ue]=g[oe]=g[ge]=g[he]=g[we]=g[Oe]=g[$e]=!0;g[te]=g[_n]=g[le]=!1;function C(n,r,e,t,f,i){var a,s=r&zr,u=r&Vr,b=r&kr;if(a!==void 0)return a;if(!ln(n))return n;var l=T(n);if(l){if(a=wr(n),!s)return Dn(n,a)}else{var o=E(n),c=o==_n||o==ie;if(D(n))return Gn(n,s);if(o==Sn||o==$n||c&&!f){if(a=u||c?{}:Nn(n),!s)return u?Ar(n,lr(a,n)):dr(n,gr(a,n))}else{if(!g[o])return f?n:{};a=qr(n,o,s)}}i||(i=new _);var h=i.get(n);if(h)return h;i.set(n,a),Wr(n)?n.forEach(function(d){a.add(C(d,r,e,d,n,i))}):Qr(n)&&n.forEach(function(d,p){a.set(p,C(d,r,e,p,n,i))});var A=b?u?yr:G:u?N:$,y=l?void 0:A(n);return pn(y||n,function(d,p){y&&(p=d,d=n[p]),Un(a,p,C(d,r,e,p,n,i))}),a}var _e="__lodash_hash_undefined__";function Se(n){return this.__data__.set(n,_e),this}function Ee(n){return this.__data__.has(n)}function P(n){var r=-1,e=n==null?0:n.length;for(this.__data__=new Bn;++r<e;)this.add(n[r])}P.prototype.add=P.prototype.push=Se;P.prototype.has=Ee;function Pe(n,r){for(var e=-1,t=n==null?0:n.length;++e<t;)if(r(n[e],e,n))return!0;return!1}function En(n,r){return n.has(r)}var Ie=1,ve=2;function Pn(n,r,e,t,f,i){var a=e&Ie,s=n.length,u=r.length;if(s!=u&&!(a&&u>s))return!1;var b=i.get(n),l=i.get(r);if(b&&l)return b==r&&l==n;var o=-1,c=!0,h=e&ve?new P:void 0;for(i.set(n,r),i.set(r,n);++o<s;){var A=n[o],y=r[o];if(t)var d=a?t(y,A,o,r,n,i):t(A,y,o,n,r,i);if(d!==void 0){if(d)continue;c=!1;break}if(h){if(!Pe(r,function(p,O){if(!En(h,O)&&(A===p||f(A,p,e,t,i)))return h.push(O)})){c=!1;break}}else if(!(A===y||f(A,y,e,t,i))){c=!1;break}}return i.delete(n),i.delete(r),c}function Le(n){var r=-1,e=Array(n.size);return n.forEach(function(t,f){e[++r]=[f,t]}),e}function H(n){var r=-1,e=Array(n.size);return n.forEach(function(t){e[++r]=t}),e}var Re=1,xe=2,me="[object Boolean]",Me="[object Date]",Ce="[object Error]",Fe="[object Map]",De="[object Number]",Ge="[object RegExp]",Ne="[object Set]",Ue="[object String]",Be="[object Symbol]",Ke="[object ArrayBuffer]",je="[object DataView]",en=w?w.prototype:void 0,F=en?en.valueOf:void 0;function He(n,r,e,t,f,i,a){switch(e){case je:if(n.byteLength!=r.byteLength||n.byteOffset!=r.byteOffset)return!1;n=n.buffer,r=r.buffer;case Ke:return!(n.byteLength!=r.byteLength||!i(new Q(n),new Q(r)));case me:case Me:case De:return Kn(+n,+r);case Ce:return n.name==r.name&&n.message==r.message;case Ge:case Ue:return n==r+"";case Fe:var s=Le;case Ne:var u=t&Re;if(s||(s=H),n.size!=r.size&&!u)return!1;var b=a.get(n);if(b)return b==r;t|=xe,a.set(n,r);var l=Pn(s(n),s(r),t,f,i,a);return a.delete(n),l;case Be:if(F)return F.call(n)==F.call(r)}return!1}var qe=1,Ye=Object.prototype,Ze=Ye.hasOwnProperty;function Qe(n,r,e,t,f,i){var a=e&qe,s=G(n),u=s.length,b=G(r),l=b.length;if(u!=l&&!a)return!1;for(var o=u;o--;){var c=s[o];if(!(a?c in r:Ze.call(r,c)))return!1}var h=i.get(n),A=i.get(r);if(h&&A)return h==r&&A==n;var y=!0;i.set(n,r),i.set(r,n);for(var d=a;++o<u;){c=s[o];var p=n[c],O=r[c];if(t)var Z=a?t(O,p,c,r,n,i):t(p,O,c,n,r,i);if(!(Z===void 0?p===O||f(p,O,e,t,i):Z)){y=!1;break}d||(d=c=="constructor")}if(y&&!d){var I=n.constructor,v=r.constructor;I!=v&&"constructor"in n&&"constructor"in r&&!(typeof I=="function"&&I instanceof I&&typeof v=="function"&&v instanceof v)&&(y=!1)}return i.delete(n),i.delete(r),y}var Xe=1,tn="[object Arguments]",fn="[object Array]",L="[object Object]",Je=Object.prototype,an=Je.hasOwnProperty;function We(n,r,e,t,f,i){var a=T(n),s=T(r),u=a?fn:E(n),b=s?fn:E(r);u=u==tn?L:u,b=b==tn?L:b;var l=u==L,o=b==L,c=u==b;if(c&&D(n)){if(!D(r))return!1;a=!0,l=!1}if(c&&!l)return i||(i=new _),a||jn(n)?Pn(n,r,e,t,f,i):He(n,r,u,e,t,f,i);if(!(e&Xe)){var h=l&&an.call(n,"__wrapped__"),A=o&&an.call(r,"__wrapped__");if(h||A){var y=h?n.value():n,d=A?r.value():r;return i||(i=new _),f(y,d,e,t,i)}}return c?(i||(i=new _),Qe(n,r,e,t,f,i)):!1}function q(n,r,e,t,f){return n===r?!0:n==null||r==null||!S(n)&&!S(r)?n!==n&&r!==r:We(n,r,e,t,q,f)}var ze=1,Ve=2;function ke(n,r,e,t){var f=e.length,i=f;if(n==null)return!i;for(n=Object(n);f--;){var a=e[f];if(a[2]?a[1]!==n[a[0]]:!(a[0]in n))return!1}for(;++f<i;){a=e[f];var s=a[0],u=n[s],b=a[1];if(a[2]){if(u===void 0&&!(s in n))return!1}else{var l=new _,o;if(!(o===void 0?q(b,u,ze|Ve,t,l):o))return!1}}return!0}function In(n){return n===n&&!ln(n)}function nt(n){for(var r=$(n),e=r.length;e--;){var t=r[e],f=n[t];r[e]=[t,f,In(f)]}return r}function vn(n,r){return function(e){return e==null?!1:e[n]===r&&(r!==void 0||n in Object(e))}}function rt(n){var r=nt(n);return r.length==1&&r[0][2]?vn(r[0][0],r[0][1]):function(e){return e===n||ke(e,n,r)}}function et(n,r){return n!=null&&r in Object(n)}function tt(n,r,e){r=An(r,n);for(var t=-1,f=r.length,i=!1;++t<f;){var a=m(r[t]);if(!(i=n!=null&&e(n,a)))break;n=n[a]}return i||++t!=f?i:(f=n==null?0:n.length,!!f&&Hn(f)&&qn(a,f)&&(T(n)||un(n)))}function it(n,r){return n!=null&&tt(n,r,et)}var ft=1,at=2;function st(n,r){return B(n)&&In(r)?vn(m(n),r):function(e){var t=sr(e,n);return t===void 0&&t===r?it(e,n):q(r,t,ft|at)}}function ut(n){return function(r){return r?.[n]}}function ot(n){return function(r){return yn(r,n)}}function gt(n){return B(n)?ut(m(n)):ot(n)}function Ln(n){return typeof n=="function"?n:n==null?cn:typeof n=="object"?T(n)?st(n[0],n[1]):rt(n):gt(n)}function lt(n,r){return n&&Yn(n,r,$)}function ct(n,r){return function(e,t){if(e==null)return e;if(!sn(e))return n(e,t);for(var f=e.length,i=-1,a=Object(e);++i<f&&t(a[i],i,a)!==!1;);return e}}var Y=ct(lt);function bt(n){return typeof n=="function"?n:cn}function $t(n,r){var e=T(n)?pn:Y;return e(n,bt(r))}function dt(n,r){var e=[];return Y(n,function(t,f,i){r(t,f,i)&&e.push(t)}),e}function _t(n,r){var e=T(n)?Tn:dt;return e(n,Ln(r))}function pt(n,r){return bn(r,function(e){return n[e]})}function St(n){return n==null?[]:pt(n,$(n))}function Et(n){return n===void 0}function At(n,r,e,t,f){return f(n,function(i,a,s){e=t?(t=!1,i):r(e,i,a,s)}),e}function Pt(n,r,e){var t=T(n)?or:At,f=arguments.length<3;return t(n,Ln(r),e,f,Y)}var yt=1/0,Tt=M&&1/H(new M([,-0]))[1]==yt?function(n){return new M(n)}:Qn,ht=200;function It(n,r,e){var t=-1,f=Vn,i=n.length,a=!0,s=[],u=s;if(i>=ht){var b=r?null:Tt(n);if(b)return H(b);a=!1,f=En,u=new P}else u=r?[]:s;n:for(;++t<i;){var l=n[t],o=r?r(l):l;if(l=l!==0?l:0,a&&o===o){for(var c=u.length;c--;)if(u[c]===o)continue n;r&&u.push(o),s.push(l)}else f(u,o,e)||(u!==s&&u.push(o),s.push(l))}return s}export{Tn as A,dt as B,Pe as C,Qn as D,P as S,It as a,C as b,Ot as c,$t as d,U as e,_t as f,Ln as g,Xn as h,Et as i,Y as j,$ as k,bn as l,tt as m,An as n,yn as o,bt as p,lt as q,Pt as r,it as s,m as t,ar as u,St as v,Vn as w,En as x,zn as y,yr as z};
@@ -1 +1 @@
1
- import{r as y,W as L,g as qe}from"./monaco-editor-BWfQfpij.js";import{j as v}from"./data-structures-ChC1tqVg.js";import{r as _e}from"./syntax-highlighting-DGbNjS3S.js";import{u as Le}from"./tools-BZTR2NP1.js";import{E as $e,o as Ke}from"./ui-components-DjgDPiqV.js";var U=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},He={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Be=class{#e=He;#t=!1;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}},M=new Be;function Ge(e){setTimeout(e,0)}var D=typeof window>"u"||"Deno"in globalThis;function k(){}function We(e,t){return typeof e=="function"?e(t):e}function G(e){return typeof e=="number"&&e>=0&&e!==1/0}function be(e,t){return Math.max(e+(t||0)-Date.now(),0)}function j(e,t){return typeof e=="function"?e(t):e}function I(e,t){return typeof e=="function"?e(t):e}function oe(e,t){const{type:s="all",exact:r,fetchStatus:i,predicate:n,queryKey:o,stale:a}=e;if(o){if(r){if(t.queryHash!==se(o,t.options))return!1}else if(!q(t.queryKey,o))return!1}if(s!=="all"){const u=t.isActive();if(s==="active"&&!u||s==="inactive"&&u)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||i&&i!==t.state.fetchStatus||n&&!n(t))}function ue(e,t){const{exact:s,status:r,predicate:i,mutationKey:n}=e;if(n){if(!t.options.mutationKey)return!1;if(s){if(A(t.options.mutationKey)!==A(n))return!1}else if(!q(t.options.mutationKey,n))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function se(e,t){return(t?.queryKeyHashFn||A)(e)}function A(e){return JSON.stringify(e,(t,s)=>W(s)?Object.keys(s).sort().reduce((r,i)=>(r[i]=s[i],r),{}):s)}function q(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(s=>q(e[s],t[s])):!1}var ze=Object.prototype.hasOwnProperty;function Se(e,t){if(e===t)return e;const s=ce(e)&&ce(t);if(!s&&!(W(e)&&W(t)))return t;const i=(s?e:Object.keys(e)).length,n=s?t:Object.keys(t),o=n.length,a=s?new Array(o):{};let u=0;for(let h=0;h<o;h++){const l=s?h:n[h],f=e[l],d=t[l];if(f===d){a[l]=f,(s?h<i:ze.call(e,l))&&u++;continue}if(f===null||d===null||typeof f!="object"||typeof d!="object"){a[l]=d;continue}const p=Se(f,d);a[l]=p,p===f&&u++}return i===o&&u===i?e:a}function H(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const s in e)if(e[s]!==t[s])return!1;return!0}function ce(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function W(e){if(!le(e))return!1;const t=e.constructor;if(t===void 0)return!0;const s=t.prototype;return!(!le(s)||!s.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function le(e){return Object.prototype.toString.call(e)==="[object Object]"}function Je(e){return new Promise(t=>{M.setTimeout(t,e)})}function z(e,t,s){return typeof s.structuralSharing=="function"?s.structuralSharing(e,t):s.structuralSharing!==!1?Se(e,t):t}function Ye(e,t,s=0){const r=[...e,t];return s&&r.length>s?r.slice(1):r}function Ve(e,t,s=0){const r=[t,...e];return s&&r.length>s?r.slice(0,-1):r}var re=Symbol();function we(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===re?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function xe(e,t){return typeof e=="function"?e(...t):!!e}var Xe=class extends U{#e;#t;#s;constructor(){super(),this.#s=e=>{if(!D&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#s=e,this.#t?.(),this.#t=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},ie=new Xe;function J(){let e,t;const s=new Promise((i,n)=>{e=i,t=n});s.status="pending",s.catch(()=>{});function r(i){Object.assign(s,i),delete s.resolve,delete s.reject}return s.resolve=i=>{r({status:"fulfilled",value:i}),e(i)},s.reject=i=>{r({status:"rejected",reason:i}),t(i)},s}var Ze=Ge;function et(){let e=[],t=0,s=a=>{a()},r=a=>{a()},i=Ze;const n=a=>{t?e.push(a):i(()=>{s(a)})},o=()=>{const a=e;e=[],a.length&&i(()=>{r(()=>{a.forEach(u=>{s(u)})})})};return{batch:a=>{let u;t++;try{u=a()}finally{t--,t||o()}return u},batchCalls:a=>(...u)=>{n(()=>{a(...u)})},schedule:n,setNotifyFunction:a=>{s=a},setBatchNotifyFunction:a=>{r=a},setScheduler:a=>{i=a}}}var O=et(),tt=class extends U{#e=!0;#t;#s;constructor(){super(),this.#s=e=>{if(!D&&window.addEventListener){const t=()=>e(!0),s=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",s,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",s)}}}}onSubscribe(){this.#t||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#s=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(s=>{s(e)}))}isOnline(){return this.#e}},B=new tt;function st(e){return Math.min(1e3*2**e,3e4)}function Pe(e){return(e??"online")==="online"?B.isOnline():!0}var Y=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function Oe(e){let t=!1,s=0,r;const i=J(),n=()=>i.status!=="pending",o=c=>{if(!n()){const w=new Y(c);d(w),e.onCancel?.(w)}},a=()=>{t=!0},u=()=>{t=!1},h=()=>ie.isFocused()&&(e.networkMode==="always"||B.isOnline())&&e.canRun(),l=()=>Pe(e.networkMode)&&e.canRun(),f=c=>{n()||(r?.(),i.resolve(c))},d=c=>{n()||(r?.(),i.reject(c))},p=()=>new Promise(c=>{r=w=>{(n()||h())&&c(w)},e.onPause?.()}).then(()=>{r=void 0,n()||e.onContinue?.()}),b=()=>{if(n())return;let c;const w=s===0?e.initialPromise:void 0;try{c=w??e.fn()}catch(x){c=Promise.reject(x)}Promise.resolve(c).then(f).catch(x=>{if(n())return;const m=e.retry??(D?0:3),P=e.retryDelay??st,R=typeof P=="function"?P(s,x):P,T=m===!0||typeof m=="number"&&s<m||typeof m=="function"&&m(s,x);if(t||!T){d(x);return}s++,e.onFail?.(s,x),Je(R).then(()=>h()?void 0:p()).then(()=>{t?d(x):b()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:a,continueRetry:u,canStart:l,start:()=>(l()?b():p().then(b),i)}}var Ce=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),G(this.gcTime)&&(this.#e=M.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(D?1/0:300*1e3))}clearGcTimeout(){this.#e&&(M.clearTimeout(this.#e),this.#e=void 0)}},rt=class extends Ce{#e;#t;#s;#i;#r;#a;#o;constructor(e){super(),this.#o=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#s=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=he(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#r?.promise}setOptions(e){if(this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const t=he(this.options);t.data!==void 0&&(this.setData(t.data,{updatedAt:t.dataUpdatedAt,manual:!0}),this.#e=t)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#s.remove(this)}setData(e,t){const s=z(this.state.data,e,this.options);return this.#n({data:s,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),s}setState(e,t){this.#n({type:"setState",state:e,setStateOptions:t})}cancel(e){const t=this.#r?.promise;return this.#r?.cancel(e),t?t.then(k).catch(k):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(e=>I(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===re||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>j(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!be(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#r?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#r?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#s.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#r&&(this.#o?this.#r.cancel({revert:!0}):this.#r.cancelRetry()),this.scheduleGc()),this.#s.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#n({type:"invalidate"})}async fetch(e,t){if(this.state.fetchStatus!=="idle"&&this.#r?.status()!=="rejected"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#r)return this.#r.continueRetry(),this.#r.promise}if(e&&this.setOptions(e),!this.options.queryFn){const a=this.observers.find(u=>u.options.queryFn);a&&this.setOptions(a.options)}const s=new AbortController,r=a=>{Object.defineProperty(a,"signal",{enumerable:!0,get:()=>(this.#o=!0,s.signal)})},i=()=>{const a=we(this.options,t),h=(()=>{const l={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(l),l})();return this.#o=!1,this.options.persister?this.options.persister(a,h,this):a(h)},o=(()=>{const a={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(a),a})();this.options.behavior?.onFetch(o,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==o.fetchOptions?.meta)&&this.#n({type:"fetch",meta:o.fetchOptions?.meta}),this.#r=Oe({initialPromise:t?.initialPromise,fn:o.fetchFn,onCancel:a=>{a instanceof Y&&a.revert&&this.setState({...this.#t,fetchStatus:"idle"}),s.abort()},onFail:(a,u)=>{this.#n({type:"failed",failureCount:a,error:u})},onPause:()=>{this.#n({type:"pause"})},onContinue:()=>{this.#n({type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0});try{const a=await this.#r.start();if(a===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(a),this.#s.config.onSuccess?.(a,this),this.#s.config.onSettled?.(a,this.state.error,this),a}catch(a){if(a instanceof Y){if(a.silent)return this.#r.promise;if(a.revert){if(this.state.data===void 0)throw a;return this.state.data}}throw this.#n({type:"error",error:a}),this.#s.config.onError?.(a,this),this.#s.config.onSettled?.(this.state.data,a,this),a}finally{this.scheduleGc()}}#n(e){const t=s=>{switch(e.type){case"failed":return{...s,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...s,fetchStatus:"paused"};case"continue":return{...s,fetchStatus:"fetching"};case"fetch":return{...s,...Ee(s.data,this.options),fetchMeta:e.meta??null};case"success":const r={...s,data:e.data,dataUpdateCount:s.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#t=e.manual?r:void 0,r;case"error":const i=e.error;return{...s,error:i,errorUpdateCount:s.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:s.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error"};case"invalidate":return{...s,isInvalidated:!0};case"setState":return{...s,...e.state}}};this.state=t(this.state),O.batch(()=>{this.observers.forEach(s=>{s.onQueryUpdate()}),this.#s.notify({query:this,type:"updated",action:e})})}};function Ee(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Pe(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function he(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,s=t!==void 0,r=s?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:s?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:s?"success":"pending",fetchStatus:"idle"}}var it=class extends U{constructor(e,t){super(),this.options=t,this.#e=e,this.#n=null,this.#o=J(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#s=void 0;#i=void 0;#r;#a;#o;#n;#m;#d;#f;#c;#l;#u;#p=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),de(this.#t,this.options)?this.#h():this.updateResult(),this.#b())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return V(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return V(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#S(),this.#w(),this.#t.removeObserver(this)}setOptions(e){const t=this.options,s=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof I(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#x(),this.#t.setOptions(this.options),t._defaulted&&!H(this.options,t)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const r=this.hasListeners();r&&fe(this.#t,s,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==s||I(this.options.enabled,this.#t)!==I(t.enabled,this.#t)||j(this.options.staleTime,this.#t)!==j(t.staleTime,this.#t))&&this.#y();const i=this.#g();r&&(this.#t!==s||I(this.options.enabled,this.#t)!==I(t.enabled,this.#t)||i!==this.#u)&&this.#v(i)}getOptimisticResult(e){const t=this.#e.getQueryCache().build(this.#e,e),s=this.createResult(t,e);return at(this,s)&&(this.#i=s,this.#a=this.options,this.#r=this.#t.state),s}getCurrentResult(){return this.#i}trackResult(e,t){return new Proxy(e,{get:(s,r)=>(this.trackProp(r),t?.(r),r==="promise"&&!this.options.experimental_prefetchInRender&&this.#o.status==="pending"&&this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled")),Reflect.get(s,r))})}trackProp(e){this.#p.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#e.defaultQueryOptions(e),s=this.#e.getQueryCache().build(this.#e,t);return s.fetch().then(()=>this.createResult(s,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#i))}#h(e){this.#x();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(k)),t}#y(){this.#S();const e=j(this.options.staleTime,this.#t);if(D||this.#i.isStale||!G(e))return;const s=be(this.#i.dataUpdatedAt,e)+1;this.#c=M.setTimeout(()=>{this.#i.isStale||this.updateResult()},s)}#g(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#w(),this.#u=e,!(D||I(this.options.enabled,this.#t)===!1||!G(this.#u)||this.#u===0)&&(this.#l=M.setInterval(()=>{(this.options.refetchIntervalInBackground||ie.isFocused())&&this.#h()},this.#u))}#b(){this.#y(),this.#v(this.#g())}#S(){this.#c&&(M.clearTimeout(this.#c),this.#c=void 0)}#w(){this.#l&&(M.clearInterval(this.#l),this.#l=void 0)}createResult(e,t){const s=this.#t,r=this.options,i=this.#i,n=this.#r,o=this.#a,u=e!==s?e.state:this.#s,{state:h}=e;let l={...h},f=!1,d;if(t._optimisticResults){const S=this.hasListeners(),E=!S&&de(e,t),C=S&&fe(e,s,t,r);(E||C)&&(l={...l,...Ee(h.data,e.options)}),t._optimisticResults==="isRestoring"&&(l.fetchStatus="idle")}let{error:p,errorUpdatedAt:b,status:c}=l;d=l.data;let w=!1;if(t.placeholderData!==void 0&&d===void 0&&c==="pending"){let S;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(S=i.data,w=!0):S=typeof t.placeholderData=="function"?t.placeholderData(this.#f?.state.data,this.#f):t.placeholderData,S!==void 0&&(c="success",d=z(i?.data,S,t),f=!0)}if(t.select&&d!==void 0&&!w)if(i&&d===n?.data&&t.select===this.#m)d=this.#d;else try{this.#m=t.select,d=t.select(d),d=z(i?.data,d,t),this.#d=d,this.#n=null}catch(S){this.#n=S}this.#n&&(p=this.#n,d=this.#d,b=Date.now(),c="error");const x=l.fetchStatus==="fetching",m=c==="pending",P=c==="error",R=m&&x,T=d!==void 0,g={status:c,fetchStatus:l.fetchStatus,isPending:m,isSuccess:c==="success",isError:P,isInitialLoading:R,isLoading:R,data:d,dataUpdatedAt:l.dataUpdatedAt,error:p,errorUpdatedAt:b,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:l.dataUpdateCount>0||l.errorUpdateCount>0,isFetchedAfterMount:l.dataUpdateCount>u.dataUpdateCount||l.errorUpdateCount>u.errorUpdateCount,isFetching:x,isRefetching:x&&!m,isLoadingError:P&&!T,isPaused:l.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:P&&T,isStale:ne(e,t),refetch:this.refetch,promise:this.#o,isEnabled:I(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const S=F=>{g.status==="error"?F.reject(g.error):g.data!==void 0&&F.resolve(g.data)},E=()=>{const F=this.#o=g.promise=J();S(F)},C=this.#o;switch(C.status){case"pending":e.queryHash===s.queryHash&&S(C);break;case"fulfilled":(g.status==="error"||g.data!==C.value)&&E();break;case"rejected":(g.status!=="error"||g.error!==C.reason)&&E();break}}return g}updateResult(){const e=this.#i,t=this.createResult(this.#t,this.options);if(this.#r=this.#t.state,this.#a=this.options,this.#r.data!==void 0&&(this.#f=this.#t),H(t,e))return;this.#i=t;const s=()=>{if(!e)return!0;const{notifyOnChangeProps:r}=this.options,i=typeof r=="function"?r():r;if(i==="all"||!i&&!this.#p.size)return!0;const n=new Set(i??this.#p);return this.options.throwOnError&&n.add("error"),Object.keys(this.#i).some(o=>{const a=o;return this.#i[a]!==e[a]&&n.has(a)})};this.#P({listeners:s()})}#x(){const e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;const t=this.#t;this.#t=e,this.#s=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#b()}#P(e){O.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#i)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function nt(e,t){return I(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function de(e,t){return nt(e,t)||e.state.data!==void 0&&V(e,t,t.refetchOnMount)}function V(e,t,s){if(I(t.enabled,e)!==!1&&j(t.staleTime,e)!=="static"){const r=typeof s=="function"?s(e):s;return r==="always"||r!==!1&&ne(e,t)}return!1}function fe(e,t,s,r){return(e!==t||I(r.enabled,e)===!1)&&(!s.suspense||e.state.status!=="error")&&ne(e,s)}function ne(e,t){return I(t.enabled,e)!==!1&&e.isStaleByTime(j(t.staleTime,e))}function at(e,t){return!H(e.getCurrentResult(),t)}function pe(e){return{onFetch:(t,s)=>{const r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,n=t.state.data?.pages||[],o=t.state.data?.pageParams||[];let a={pages:[],pageParams:[]},u=0;const h=async()=>{let l=!1;const f=b=>{Object.defineProperty(b,"signal",{enumerable:!0,get:()=>(t.signal.aborted?l=!0:t.signal.addEventListener("abort",()=>{l=!0}),t.signal)})},d=we(t.options,t.fetchOptions),p=async(b,c,w)=>{if(l)return Promise.reject();if(c==null&&b.pages.length)return Promise.resolve(b);const m=(()=>{const N={client:t.client,queryKey:t.queryKey,pageParam:c,direction:w?"backward":"forward",meta:t.options.meta};return f(N),N})(),P=await d(m),{maxPages:R}=t.options,T=w?Ve:Ye;return{pages:T(b.pages,P,R),pageParams:T(b.pageParams,c,R)}};if(i&&n.length){const b=i==="backward",c=b?ot:me,w={pages:n,pageParams:o},x=c(r,w);a=await p(w,x,b)}else{const b=e??n.length;do{const c=u===0?o[0]??r.initialPageParam:me(r,a);if(u>0&&c==null)break;a=await p(a,c),u++}while(u<b)}return a};t.options.persister?t.fetchFn=()=>t.options.persister?.(h,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},s):t.fetchFn=h}}}function me(e,{pages:t,pageParams:s}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,s[r],s):void 0}function ot(e,{pages:t,pageParams:s}){return t.length>0?e.getPreviousPageParam?.(t[0],t,s[0],s):void 0}var ut=class extends Ce{#e;#t;#s;#i;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#s=e.mutationCache,this.#t=[],this.state=e.state||Re(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#s.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#s.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#s.remove(this))}continue(){return this.#i?.continue()??this.execute(this.state.variables)}async execute(e){const t=()=>{this.#r({type:"continue"})},s={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#i=Oe({fn:()=>this.options.mutationFn?this.options.mutationFn(e,s):Promise.reject(new Error("No mutationFn found")),onFail:(n,o)=>{this.#r({type:"failed",failureCount:n,error:o})},onPause:()=>{this.#r({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#s.canRun(this)});const r=this.state.status==="pending",i=!this.#i.canStart();try{if(r)t();else{this.#r({type:"pending",variables:e,isPaused:i}),await this.#s.config.onMutate?.(e,this,s);const o=await this.options.onMutate?.(e,s);o!==this.state.context&&this.#r({type:"pending",context:o,variables:e,isPaused:i})}const n=await this.#i.start();return await this.#s.config.onSuccess?.(n,e,this.state.context,this,s),await this.options.onSuccess?.(n,e,this.state.context,s),await this.#s.config.onSettled?.(n,null,this.state.variables,this.state.context,this,s),await this.options.onSettled?.(n,null,e,this.state.context,s),this.#r({type:"success",data:n}),n}catch(n){try{throw await this.#s.config.onError?.(n,e,this.state.context,this,s),await this.options.onError?.(n,e,this.state.context,s),await this.#s.config.onSettled?.(void 0,n,this.state.variables,this.state.context,this,s),await this.options.onSettled?.(void 0,n,e,this.state.context,s),n}finally{this.#r({type:"error",error:n})}}finally{this.#s.runNext(this)}}#r(e){const t=s=>{switch(e.type){case"failed":return{...s,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...s,isPaused:!0};case"continue":return{...s,isPaused:!1};case"pending":return{...s,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...s,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...s,data:void 0,error:e.error,failureCount:s.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),O.batch(()=>{this.#t.forEach(s=>{s.onMutationUpdate(e)}),this.#s.notify({mutation:this,type:"updated",action:e})})}};function Re(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var ct=class extends U{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#s=0}#e;#t;#s;build(e,t,s){const r=new ut({client:e,mutationCache:this,mutationId:++this.#s,options:e.defaultMutationOptions(t),state:s});return this.add(r),r}add(e){this.#e.add(e);const t=$(e);if(typeof t=="string"){const s=this.#t.get(t);s?s.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){const t=$(e);if(typeof t=="string"){const s=this.#t.get(t);if(s)if(s.length>1){const r=s.indexOf(e);r!==-1&&s.splice(r,1)}else s[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=$(e);if(typeof t=="string"){const r=this.#t.get(t)?.find(i=>i.state.status==="pending");return!r||r===e}else return!0}runNext(e){const t=$(e);return typeof t=="string"?this.#t.get(t)?.find(r=>r!==e&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){O.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){const t={exact:!0,...e};return this.getAll().find(s=>ue(t,s))}findAll(e={}){return this.getAll().filter(t=>ue(e,t))}notify(e){O.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return O.batch(()=>Promise.all(e.map(t=>t.continue().catch(k))))}};function $(e){return e.options.scope?.id}var lt=class extends U{#e;#t=void 0;#s;#i;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#r()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){const t=this.options;this.options=this.#e.defaultMutationOptions(e),H(this.options,t)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#s,observer:this}),t?.mutationKey&&this.options.mutationKey&&A(t.mutationKey)!==A(this.options.mutationKey)?this.reset():this.#s?.state.status==="pending"&&this.#s.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#s?.removeObserver(this)}onMutationUpdate(e){this.#r(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#s?.removeObserver(this),this.#s=void 0,this.#r(),this.#a()}mutate(e,t){return this.#i=t,this.#s?.removeObserver(this),this.#s=this.#e.getMutationCache().build(this.#e,this.options),this.#s.addObserver(this),this.#s.execute(e)}#r(){const e=this.#s?.state??Re();this.#t={...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset}}#a(e){O.batch(()=>{if(this.#i&&this.hasListeners()){const t=this.#t.variables,s=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};e?.type==="success"?(this.#i.onSuccess?.(e.data,t,s,r),this.#i.onSettled?.(e.data,null,t,s,r)):e?.type==="error"&&(this.#i.onError?.(e.error,t,s,r),this.#i.onSettled?.(void 0,e.error,t,s,r))}this.listeners.forEach(t=>{t(this.#t)})})}},ht=class extends U{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,s){const r=t.queryKey,i=t.queryHash??se(r,t);let n=this.get(i);return n||(n=new rt({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:s,defaultOptions:e.getQueryDefaults(r)}),this.add(n)),n}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){O.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){const t={exact:!0,...e};return this.getAll().find(s=>oe(t,s))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(s=>oe(e,s)):t}notify(e){O.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){O.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){O.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Bt=class{#e;#t;#s;#i;#r;#a;#o;#n;constructor(e={}){this.#e=e.queryCache||new ht,this.#t=e.mutationCache||new ct,this.#s=e.defaultOptions||{},this.#i=new Map,this.#r=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=ie.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#n=B.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#n?.(),this.#n=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),s=this.#e.build(this,t),r=s.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&s.isStaleByTime(j(t.staleTime,s))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:s})=>{const r=s.data;return[t,r]})}setQueryData(e,t,s){const r=this.defaultQueryOptions({queryKey:e}),n=this.#e.get(r.queryHash)?.state.data,o=We(t,n);if(o!==void 0)return this.#e.build(this,r).setData(o,{...s,manual:!0})}setQueriesData(e,t,s){return O.batch(()=>this.#e.findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,s)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){const t=this.#e;O.batch(()=>{t.findAll(e).forEach(s=>{t.remove(s)})})}resetQueries(e,t){const s=this.#e;return O.batch(()=>(s.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const s={revert:!0,...t},r=O.batch(()=>this.#e.findAll(e).map(i=>i.cancel(s)));return Promise.all(r).then(k).catch(k)}invalidateQueries(e,t={}){return O.batch(()=>(this.#e.findAll(e).forEach(s=>{s.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){const s={...t,cancelRefetch:t.cancelRefetch??!0},r=O.batch(()=>this.#e.findAll(e).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let n=i.fetch(void 0,s);return s.throwOnError||(n=n.catch(k)),i.state.fetchStatus==="paused"?Promise.resolve():n}));return Promise.all(r).then(k)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const s=this.#e.build(this,t);return s.isStaleByTime(j(t.staleTime,s))?s.fetch(t):Promise.resolve(s.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(k).catch(k)}fetchInfiniteQuery(e){return e.behavior=pe(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(k).catch(k)}ensureInfiniteQueryData(e){return e.behavior=pe(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return B.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#s}setDefaultOptions(e){this.#s=e}setQueryDefaults(e,t){this.#i.set(A(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#i.values()],s={};return t.forEach(r=>{q(e,r.queryKey)&&Object.assign(s,r.defaultOptions)}),s}setMutationDefaults(e,t){this.#r.set(A(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#r.values()],s={};return t.forEach(r=>{q(e,r.mutationKey)&&Object.assign(s,r.defaultOptions)}),s}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#s.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=se(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===re&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#s.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},ke=y.createContext(void 0),Fe=e=>{const t=y.useContext(ke);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},Gt=({client:e,children:t})=>(y.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),v.jsx(ke.Provider,{value:e,children:t})),Te=y.createContext(!1),dt=()=>y.useContext(Te);Te.Provider;function ft(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var pt=y.createContext(ft()),mt=()=>y.useContext(pt),yt=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},gt=e=>{y.useEffect(()=>{e.clearReset()},[e])},vt=({result:e,errorResetBoundary:t,throwOnError:s,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||xe(s,[e.error,r])),bt=e=>{if(e.suspense){const s=i=>i==="static"?i:Math.max(i??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...i)=>s(r(...i)):s(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},St=(e,t)=>e.isLoading&&e.isFetching&&!t,wt=(e,t)=>e?.suspense&&t.isPending,ye=(e,t,s)=>t.fetchOptimistic(e).catch(()=>{s.clearReset()});function xt(e,t,s){const r=dt(),i=mt(),n=Fe(),o=n.defaultQueryOptions(e);n.getDefaultOptions().queries?._experimental_beforeQuery?.(o),o._optimisticResults=r?"isRestoring":"optimistic",bt(o),yt(o,i),gt(i);const a=!n.getQueryCache().get(o.queryHash),[u]=y.useState(()=>new t(n,o)),h=u.getOptimisticResult(o),l=!r&&e.subscribed!==!1;if(y.useSyncExternalStore(y.useCallback(f=>{const d=l?u.subscribe(O.batchCalls(f)):k;return u.updateResult(),d},[u,l]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),y.useEffect(()=>{u.setOptions(o)},[o,u]),wt(o,h))throw ye(o,u,i);if(vt({result:h,errorResetBoundary:i,throwOnError:o.throwOnError,query:n.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw h.error;return n.getDefaultOptions().queries?._experimental_afterQuery?.(o,h),o.experimental_prefetchInRender&&!D&&St(h,r)&&(a?ye(o,u,i):n.getQueryCache().get(o.queryHash)?.promise)?.catch(k).finally(()=>{u.updateResult()}),o.notifyOnChangeProps?h:u.trackResult(h)}function Ie(e,t){return xt(e,it)}function Wt(e,t){const s=Fe(),[r]=y.useState(()=>new lt(s,e));y.useEffect(()=>{r.setOptions(e)},[r,e]);const i=y.useSyncExternalStore(y.useCallback(o=>r.subscribe(O.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),n=y.useCallback((o,a)=>{r.mutate(o,a).catch(k)},[r]);if(i.error&&xe(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:n,mutateAsync:i.mutate}}const K=[{id:"default",name:"默认服务",url:"http://127.0.0.1:4936",isDefault:!0}],je="backendServices",Pt=()=>{try{const e=localStorage.getItem(je);if(e){const t=JSON.parse(e);return!t.services||t.services.length===0?{services:K,currentServiceId:K[0].id}:t}}catch(e){console.error("Failed to load backend services:",e)}return{services:K,currentServiceId:K[0].id}},ae=e=>{try{localStorage.setItem(je,JSON.stringify(e))}catch(t){console.error("Failed to save backend services:",t)}},Ot=e=>e.services.find(t=>t.id===e.currentServiceId)||null,zt=(e,t,s)=>{const r={...e,services:e.services.map(i=>i.id===t?{...i,...s}:i)};return ae(r),r},Jt=(e,t)=>{if(e.services.find(i=>i.id===t)?.isDefault)return e;const r={...e,services:e.services.filter(i=>i.id!==t),currentServiceId:e.currentServiceId===t?e.services.find(i=>i.id!==t)?.id||null:e.currentServiceId};return ae(r),r},Yt=(e,t)=>{if(!e.services.find(i=>i.id===t))return e;const r={...e,currentServiceId:t};return ae(r),r},Ct=()=>{const e="/api";return e.startsWith("/")&&!e.startsWith("//")},Me=()=>{if(Ct())return window.location.origin;const e=Pt(),t=Ot(e);return t?t.url:"http://127.0.0.1:4936"},Q=()=>Me()+"/api",X=()=>Me()+"/media";X();const Et=Q(),Vt=e=>e?!!(e.name==="TypeError"&&e.message?.includes("fetch")||e.name==="AbortError"||e.message?.includes("AbortError")||e.message?.includes("ERR_CONNECTION_REFUSED")||e.message?.includes("ERR_NETWORK")||e.message?.includes("Failed to fetch")||e.message?.includes("NetworkError")||e.status&&(e.status===0||e.status===502||e.status===503||e.status===504)):!1,ge=e=>{let t;const s=new Set,r=(h,l)=>{const f=typeof h=="function"?h(t):h;if(!Object.is(f,t)){const d=t;t=l??(typeof f!="object"||f===null)?f:Object.assign({},t,f),s.forEach(p=>p(t,d))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>u,subscribe:h=>(s.add(h),()=>s.delete(h))},u=t=e(r,i,a);return a},Rt=(e=>e?ge(e):ge),kt=e=>e;function Ft(e,t=kt){const s=L.useSyncExternalStore(e.subscribe,L.useCallback(()=>t(e.getState()),[e,t]),L.useCallback(()=>t(e.getInitialState()),[e,t]));return L.useDebugValue(s),s}const ve=e=>{const t=Rt(e),s=r=>Ft(t,r);return Object.assign(s,t),s},Tt=(e=>e?ve(e):ve);function It(e,t){let s;try{s=e()}catch{return}return{getItem:i=>{var n;const o=u=>u===null?null:JSON.parse(u,void 0),a=(n=s.getItem(i))!=null?n:null;return a instanceof Promise?a.then(o):o(a)},setItem:(i,n)=>s.setItem(i,JSON.stringify(n,void 0)),removeItem:i=>s.removeItem(i)}}const Z=e=>t=>{try{const s=e(t);return s instanceof Promise?s:{then(r){return Z(r)(s)},catch(r){return this}}}catch(s){return{then(r){return this},catch(r){return Z(r)(s)}}}},jt=(e,t)=>(s,r,i)=>{let n={storage:It(()=>localStorage),partialize:c=>c,version:0,merge:(c,w)=>({...w,...c}),...t},o=!1;const a=new Set,u=new Set;let h=n.storage;if(!h)return e((...c)=>{console.warn(`[zustand persist middleware] Unable to update item '${n.name}', the given storage is currently unavailable.`),s(...c)},r,i);const l=()=>{const c=n.partialize({...r()});return h.setItem(n.name,{state:c,version:n.version})},f=i.setState;i.setState=(c,w)=>(f(c,w),l());const d=e((...c)=>(s(...c),l()),r,i);i.getInitialState=()=>d;let p;const b=()=>{var c,w;if(!h)return;o=!1,a.forEach(m=>{var P;return m((P=r())!=null?P:d)});const x=((w=n.onRehydrateStorage)==null?void 0:w.call(n,(c=r())!=null?c:d))||void 0;return Z(h.getItem.bind(h))(n.name).then(m=>{if(m)if(typeof m.version=="number"&&m.version!==n.version){if(n.migrate){const P=n.migrate(m.state,m.version);return P instanceof Promise?P.then(R=>[!0,R]):[!0,P]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,m.state];return[!1,void 0]}).then(m=>{var P;const[R,T]=m;if(p=n.merge(T,(P=r())!=null?P:d),s(p,!0),R)return l()}).then(()=>{x?.(p,void 0),p=r(),o=!0,u.forEach(m=>m(p))}).catch(m=>{x?.(void 0,m)})};return i.persist={setOptions:c=>{n={...n,...c},c.storage&&(h=c.storage)},clearStorage:()=>{h?.removeItem(n.name)},getOptions:()=>n,rehydrate:()=>b(),hasHydrated:()=>o,onHydrate:c=>(a.add(c),()=>{a.delete(c)}),onFinishHydration:c=>(u.add(c),()=>{u.delete(c)})},n.skipHydration||b(),p||d},Mt=jt,ee=Tt()(Mt((e,t)=>({token:null,tokens:{},isAuthenticated:!1,getToken:s=>{const{tokens:r}=t();return r[s]||null},setToken:s=>{e(r=>({tokens:{...r.tokens,[s.serviceId]:s},token:s,isAuthenticated:!0}))},removeToken:s=>{e(r=>{const i={...r.tokens};delete i[s];const n=r.token,o=n&&typeof n=="object"&&"serviceId"in n&&n.serviceId===s;return{tokens:i,token:o?null:r.token,isAuthenticated:o?!1:r.isAuthenticated}})},logout:()=>e({tokens:{},token:null,isAuthenticated:!1})}),{name:"auth-storage",migrate:(e,t)=>{const s=e;if(s.token&&!s.tokens){const r=s.token;if(typeof r=="object"&&r&&"serviceId"in r)return{...s,tokens:{[r.serviceId]:r}}}return e}}));function te(e){try{const s=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/");return JSON.parse(window.atob(s))}catch{return null}}const Xt=e=>{if(!e)return!0;if(typeof e=="string"){const i=te(e);if(!i||!i.exp)return!0;const n=Math.floor(Date.now()/1e3);return i.exp<=n}const t=te(e.token);if(t&&t.exp){const i=Math.floor(Date.now()/1e3);return t.exp<=i}const s=Date.now()-e.timestamp,r=10080*60*1e3;return s>r},Dt=(e,t=24)=>{if(!e)return!0;const s=typeof e=="string"?e:e.token,r=te(s);if(!r||!r.exp)return!0;const i=Math.floor(Date.now()/1e3),n=t*60*60;return r.exp-i<=n},De=e=>e?typeof e=="object"&&"token"in e?e.token:e:null;async function _(e,t={}){const{skipAuth:s=!1,maxRetries:r=1,...i}=t;let n=0;for(;n<=r;)try{const o=await At(e,i,s);if(o.status===401&&n<r&&!s&&await Qe()){n++;continue}return o}catch(o){if(n>=r){if(o instanceof Error){const a=o;a.requestUrl=e,a.requestMethod=t.method||"GET",a.isRetryable=!0,a.retryAttempt=n,a.maxRetries=r,o.name==="TypeError"&&o.message.includes("fetch")&&(a.message=`Network request failed: ${t.method||"GET"} ${e}`)}throw o}n++,await new Promise(a=>setTimeout(a,1e3))}throw new Error("Max retries exceeded")}async function At(e,t={},s=!1){const r=new Headers(t.headers||{});let i;if(!s){const o=Ae(),{getToken:a}=ee.getState(),u=o?a(o):ee.getState().token;i=De(u)||void 0,i&&(r.set("Authorization",`Bearer ${i}`),Dt(u)&&Qe().catch(console.error))}const n={...t,headers:r};return fetch(e,n).catch(o=>{if(o instanceof Error){const a=o;a.requestUrl=e,a.requestMethod=n.method||"GET",a.hasAuth=!s,a.tokenPresent=!!i,o.name==="TypeError"&&o.message.includes("fetch")&&(a.message=`Failed to connect to server: ${n.method||"GET"} ${e}`)}throw o})}function Ae(){try{const e=localStorage.getItem("backend-services-storage");if(e)return JSON.parse(e).state?.currentService?.id||null}catch(e){console.error("Error getting current service ID:",e)}return null}async function Qe(){try{const e=Ae(),{getToken:t,setToken:s}=ee.getState();if(!e)return!1;const r=t(e);if(!r)return!1;const i=De(r);if(!i)return!1;const n=await fetch(`${Et}/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:i})});if(n.ok){const o=await n.json();if(o.success&&o.token&&o.refreshed){const a={...r,token:o.token,timestamp:Date.now()};return s(a),console.log("Token refreshed successfully via authFetch"),!0}}return!1}catch(e){return console.error("Token refresh failed:",e),!1}}const Ue=e=>{let t=e.match(/window\.presentationConfig\s*=\s*\{[\s\S]*?slides:\s*\[([\s\S]*?)\]/);const s=e.match(/title:\s*["']([^"']+)["']/);if(t||(t=e.match(/presentationConfig\s*=\s*\{[\s\S]*?slides:\s*\[([\s\S]*?)\]/)),t||(t=e.match(/slides:\s*\[([\s\S]*?)\]/)),t||(t=e.match(/window\.slidesConfig\s*=\s*\[([\s\S]*?)\]/)),t||(t=e.match(/slidesConfig\s*=\s*\[([\s\S]*?)\]/)),!t)throw new Error("Invalid slides configuration format");const i=t[1].match(/"([^"]+)"/g),n=i?i.map(a=>a.replace(/"/g,"")):[],o=s?s[1]:"Presentation";return{slides:n,title:o}},Qt=e=>{const t=e.match(/<title>(.*?)<\/title>/i)||e.match(/<h1[^>]*>(.*?)<\/h1>/i);return t?t[1].replace(/<[^>]*>/g,"").trim():""},Zt=e=>Ie({queryKey:["slides",e],queryFn:async()=>{const t=new URLSearchParams;t.set("path","slides.js"),e&&t.set("projectPath",e);const s=await _(`${Q()}/files/read?${t.toString()}`);if(!s.ok){if(s.status===404)return{slides:[],title:"Presentation",total:0};throw new Error("Failed to fetch slides configuration")}const r=await s.json(),{slides:i,title:n}=Ue(r.content),o=new URLSearchParams;e&&o.set("projectPath",e);const a=await _(`${Q()}/files/read-multiple?${o.toString()}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paths:i})});if(!a.ok)throw new Error("Failed to fetch slide files");const u=await a.json();return{slides:i.map((l,f)=>{const d=u.files.find(b=>b.path===l);let p=l.split("/").pop()?.replace(".html","")||`Slide ${f+1}`;if(d?.exists&&d.content){const b=Qt(d.content);b&&(p=b)}return{path:l,title:p,exists:d?.exists||!1,index:f}}),total:i.length,title:n}}}),Ut=(e,t)=>Ie({queryKey:["slide-content",e,t],queryFn:async()=>{const s=new URLSearchParams;s.set("path","slides.js"),s.set("projectPath",t||"");const r=await _(`${Q()}/files/read?${s.toString()}`);if(!r.ok)throw r.status===404?new Error("No slides configuration found. Please create slides.js file first."):new Error("Failed to fetch slides configuration");const i=await r.json(),{slides:n}=Ue(i.content);if(e>=n.length)throw new Error("Slide not found");const o=n[e],a=new URLSearchParams;a.set("path",o),a.set("projectPath",t||"");const u=await _(`${Q()}/files/read?${a.toString()}`);if(!u.ok)throw new Error("Failed to fetch slide content");return{content:(await u.json()).content,path:o,index:e}},enabled:e>=0});var Nt=_e();const qt=qe(Nt);Prism.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/&#x?[\da-f]{1,8};/i]};Prism.languages.markup.tag.inside["attr-value"].inside.entity=Prism.languages.markup.entity;Prism.languages.markup.doctype.inside["internal-subset"].inside=Prism.languages.markup;Prism.hooks.add("wrap",function(e){e.type==="entity"&&(e.attributes.title=e.content.replace(/&amp;/,"&"))});Object.defineProperty(Prism.languages.markup.tag,"addInlined",{value:function(t,s){var r={};r["language-"+s]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:Prism.languages[s]},r.cdata=/^<!\[CDATA\[|\]\]>$/i;var i={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:r}};i["language-"+s]={pattern:/[\s\S]+/,inside:Prism.languages[s]};var n={};n[t]={pattern:RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g,function(){return t}),"i"),lookbehind:!0,greedy:!0,inside:i},Prism.languages.insertBefore("markup","cdata",n)}});Object.defineProperty(Prism.languages.markup.tag,"addAttribute",{value:function(e,t){Prism.languages.markup.tag.inside["special-attr"].push({pattern:RegExp(/(^|["'\s])/.source+"(?:"+e+")"+/\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,"i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[t,"language-"+t],inside:Prism.languages[t]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}});Prism.languages.html=Prism.languages.markup;Prism.languages.mathml=Prism.languages.markup;Prism.languages.svg=Prism.languages.markup;Prism.languages.xml=Prism.languages.extend("markup",{});Prism.languages.ssml=Prism.languages.xml;Prism.languages.atom=Prism.languages.xml;Prism.languages.rss=Prism.languages.xml;(function(e){var t=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;e.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:RegExp("@[\\w-](?:"+/[^;{\s"']|\s+(?!\s)/.source+"|"+t.source+")*?"+/(?:;|(?=\s*\{))/.source),inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:"selector"},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp("\\burl\\((?:"+t.source+"|"+/(?:[^\\\r\n()"']|\\[\s\S])*/.source+")\\)","i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp("^"+t.source+"$"),alias:"url"}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+t.source+")*(?=\\s*\\{)"),lookbehind:!0},string:{pattern:t,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},e.languages.css.atrule.inside.rest=e.languages.css;var s=e.languages.markup;s&&(s.tag.addInlined("style","css"),s.tag.addAttribute("style","css"))})(Prism);const es=y.forwardRef(({slide:e,totalSlides:t,projectPath:s},r)=>{const{t:i}=Le("agents"),n=y.useRef(null),o=y.useRef(null),[a,u]=y.useState(!0),[h,l]=y.useState(!1),[f,d]=y.useState("preview"),[p,b]=y.useState(null),[c,w]=y.useState(1),{data:x}=Ut(e.index,s),m=y.useCallback((g,S,E)=>{try{const C=Date.now(),F=`${X()}/${S}/${E}?t=${C}`;console.log("SlidePreview: Loading iframe with URL:",F),g.src=F}catch(C){console.error("SlidePreview: Error loading iframe:",C),l(!0),u(!1)}},[X]);y.useImperativeHandle(r,()=>({refreshIframe:()=>{const g=n.current;g&&p&&e.path&&m(g,p,e.path)}}),[p,e.path,m]),y.useEffect(()=>{if(!s){console.log("SlidePreview: No projectPath provided");return}(async()=>{try{const S=new URLSearchParams;S.set("projectPath",s);const E=`${Q()}/files/project-id?${S.toString()}`;console.log("SlidePreview: Fetching project ID from:",E);const C=await _(E);if(C.ok){const F=await C.json();console.log("SlidePreview: Got project ID:",F.projectId,"for path:",s),b(F.projectId)}else{console.error("SlidePreview: Failed to fetch project ID, status:",C.status);const F=await C.json().catch(()=>({error:"Unknown error"}));console.error("SlidePreview: Error details:",F)}}catch(S){console.error("SlidePreview: Exception while fetching project ID:",S)}})()},[s]),y.useEffect(()=>{const g=n.current;if(!g||f!=="preview"||!p||!e.path)return;u(!0),l(!1);const S=()=>{u(!1),l(!1)},E=()=>{u(!1),l(!0)};return g.addEventListener("load",S),g.addEventListener("error",E),m(g,p,e.path),()=>{g.removeEventListener("load",S),g.removeEventListener("error",E)}},[f,p,e.path,m]),y.useEffect(()=>{f==="code"&&x&&setTimeout(()=>{qt.highlightAll()},0)},[f,x]);const P=1280/720,R=1280,T=720,N=()=>{if(!o.current)return 1;const S=o.current.getBoundingClientRect(),E=S.width,C=S.height,F=E/R,Ne=C/T;return Math.min(F,Ne,1)};return y.useEffect(()=>{const g=()=>{const E=N();w(E)};g(),window.addEventListener("resize",g);const S=setTimeout(g,100);return()=>{window.removeEventListener("resize",g),clearTimeout(S)}},[f]),v.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md overflow-hidden",children:[v.jsx("div",{className:"h-12 px-4 bg-gray-100 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 flex items-center",children:v.jsxs("div",{className:"flex items-center gap-4",children:[v.jsxs("div",{className:"flex space-x-1",children:[v.jsxs("button",{onClick:()=>d("preview"),className:`flex items-center space-x-2 px-3 py-1.5 text-sm rounded-md transition-colors ${f==="preview"?"bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-300 border border-blue-200 dark:border-blue-700":"text-gray-600 dark:text-gray-300 hover:text-gray-800 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-gray-600"}`,children:[v.jsx($e,{className:"w-4 h-4"}),v.jsx("span",{children:i("slidePreview.tabs.preview")})]}),v.jsxs("button",{onClick:()=>d("code"),className:`flex items-center space-x-2 px-3 py-1.5 text-sm rounded-md transition-colors ${f==="code"?"bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-300 border border-blue-200 dark:border-blue-700":"text-gray-600 dark:text-gray-300 hover:text-gray-800 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-gray-600"}`,children:[v.jsx(Ke,{className:"w-4 h-4"}),v.jsx("span",{children:i("slidePreview.tabs.code")})]})]}),v.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-300 font-medium flex-1",children:e.path?e.path.replace(/\.html$/,""):""}),v.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400 font-medium",children:[e.index+1,"/",t]})]})}),v.jsx("div",{className:"p-4",children:f==="preview"?v.jsxs("div",{ref:o,className:"relative w-full bg-gray-100 dark:bg-gray-900 rounded-lg overflow-hidden",style:{aspectRatio:`${P}`},children:[a&&v.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:v.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:i("slidePreview.loading")})}),h&&v.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:v.jsx("div",{className:"text-sm text-red-500 dark:text-red-400",children:i("slidePreview.loadFailed")})}),e.exists&&p&&v.jsx("div",{className:"absolute top-0 left-0",style:{width:`${R}px`,height:`${T}px`,transform:`scale(${c})`,transformOrigin:"top left"},children:v.jsx("iframe",{ref:n,className:"w-full h-full border-none",style:{display:a||h?"none":"block",width:`${R}px`,height:`${T}px`},scrolling:"no"})}),!e.exists&&!a&&v.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:v.jsx("div",{className:"text-sm text-orange-500 dark:text-orange-400",children:i("slidePreview.fileNotFound")})})]}):v.jsx("div",{className:"relative bg-gray-100 dark:bg-gray-900 rounded-lg overflow-hidden",style:{aspectRatio:`${P}`},children:x?v.jsx("div",{className:"h-full overflow-y-auto",children:v.jsx("pre",{className:"language-html h-full m-0 p-4 text-sm",style:{backgroundColor:"#2d3748"},children:v.jsx("code",{className:"language-html text-gray-100",children:x.content})})}):v.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:v.jsx("div",{className:"text-gray-500 dark:text-gray-400",children:i("slidePreview.loadingCode")})})})})]})});export{Et as A,Bt as Q,es as S,_ as a,Ie as b,Wt as c,Ot as d,Yt as e,zt as f,Q as g,ee as h,Vt as i,Xt as j,De as k,Pt as l,Dt as m,Gt as n,Tt as o,Zt as p,Jt as r,ae as s,Fe as u};
1
+ import{r as y,W as L,g as $e}from"./monaco-editor-BWfQfpij.js";import{j as v}from"./data-structures-ChC1tqVg.js";import{r as Ke}from"./syntax-highlighting-DGbNjS3S.js";import{u as He}from"./tools-crrPnehB.js";import{E as Be,o as Ge}from"./ui-components-D1pZO0y-.js";var U=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},We={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},ze=class{#e=We;#t=!1;setTimeoutProvider(e){this.#e=e}setTimeout(e,t){return this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}},M=new ze;function Je(e){setTimeout(e,0)}var D=typeof window>"u"||"Deno"in globalThis;function k(){}function Ye(e,t){return typeof e=="function"?e(t):e}function G(e){return typeof e=="number"&&e>=0&&e!==1/0}function Se(e,t){return Math.max(e+(t||0)-Date.now(),0)}function j(e,t){return typeof e=="function"?e(t):e}function I(e,t){return typeof e=="function"?e(t):e}function ue(e,t){const{type:s="all",exact:r,fetchStatus:i,predicate:n,queryKey:o,stale:a}=e;if(o){if(r){if(t.queryHash!==se(o,t.options))return!1}else if(!N(t.queryKey,o))return!1}if(s!=="all"){const u=t.isActive();if(s==="active"&&!u||s==="inactive"&&u)return!1}return!(typeof a=="boolean"&&t.isStale()!==a||i&&i!==t.state.fetchStatus||n&&!n(t))}function ce(e,t){const{exact:s,status:r,predicate:i,mutationKey:n}=e;if(n){if(!t.options.mutationKey)return!1;if(s){if(A(t.options.mutationKey)!==A(n))return!1}else if(!N(t.options.mutationKey,n))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function se(e,t){return(t?.queryKeyHashFn||A)(e)}function A(e){return JSON.stringify(e,(t,s)=>W(s)?Object.keys(s).sort().reduce((r,i)=>(r[i]=s[i],r),{}):s)}function N(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(s=>N(e[s],t[s])):!1}var Ve=Object.prototype.hasOwnProperty;function we(e,t){if(e===t)return e;const s=le(e)&&le(t);if(!s&&!(W(e)&&W(t)))return t;const i=(s?e:Object.keys(e)).length,n=s?t:Object.keys(t),o=n.length,a=s?new Array(o):{};let u=0;for(let h=0;h<o;h++){const l=s?h:n[h],f=e[l],d=t[l];if(f===d){a[l]=f,(s?h<i:Ve.call(e,l))&&u++;continue}if(f===null||d===null||typeof f!="object"||typeof d!="object"){a[l]=d;continue}const p=we(f,d);a[l]=p,p===f&&u++}return i===o&&u===i?e:a}function H(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const s in e)if(e[s]!==t[s])return!1;return!0}function le(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function W(e){if(!he(e))return!1;const t=e.constructor;if(t===void 0)return!0;const s=t.prototype;return!(!he(s)||!s.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function he(e){return Object.prototype.toString.call(e)==="[object Object]"}function Xe(e){return new Promise(t=>{M.setTimeout(t,e)})}function z(e,t,s){return typeof s.structuralSharing=="function"?s.structuralSharing(e,t):s.structuralSharing!==!1?we(e,t):t}function Ze(e,t,s=0){const r=[...e,t];return s&&r.length>s?r.slice(1):r}function et(e,t,s=0){const r=[t,...e];return s&&r.length>s?r.slice(0,-1):r}var re=Symbol();function xe(e,t){return!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===re?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Pe(e,t){return typeof e=="function"?e(...t):!!e}var tt=class extends U{#e;#t;#s;constructor(){super(),this.#s=e=>{if(!D&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#s=e,this.#t?.(),this.#t=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},ie=new tt;function J(){let e,t;const s=new Promise((i,n)=>{e=i,t=n});s.status="pending",s.catch(()=>{});function r(i){Object.assign(s,i),delete s.resolve,delete s.reject}return s.resolve=i=>{r({status:"fulfilled",value:i}),e(i)},s.reject=i=>{r({status:"rejected",reason:i}),t(i)},s}var st=Je;function rt(){let e=[],t=0,s=a=>{a()},r=a=>{a()},i=st;const n=a=>{t?e.push(a):i(()=>{s(a)})},o=()=>{const a=e;e=[],a.length&&i(()=>{r(()=>{a.forEach(u=>{s(u)})})})};return{batch:a=>{let u;t++;try{u=a()}finally{t--,t||o()}return u},batchCalls:a=>(...u)=>{n(()=>{a(...u)})},schedule:n,setNotifyFunction:a=>{s=a},setBatchNotifyFunction:a=>{r=a},setScheduler:a=>{i=a}}}var O=rt(),it=class extends U{#e=!0;#t;#s;constructor(){super(),this.#s=e=>{if(!D&&window.addEventListener){const t=()=>e(!0),s=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",s,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",s)}}}}onSubscribe(){this.#t||this.setEventListener(this.#s)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#s=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(s=>{s(e)}))}isOnline(){return this.#e}},B=new it;function nt(e){return Math.min(1e3*2**e,3e4)}function Oe(e){return(e??"online")==="online"?B.isOnline():!0}var Y=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function Ce(e){let t=!1,s=0,r;const i=J(),n=()=>i.status!=="pending",o=c=>{if(!n()){const w=new Y(c);d(w),e.onCancel?.(w)}},a=()=>{t=!0},u=()=>{t=!1},h=()=>ie.isFocused()&&(e.networkMode==="always"||B.isOnline())&&e.canRun(),l=()=>Oe(e.networkMode)&&e.canRun(),f=c=>{n()||(r?.(),i.resolve(c))},d=c=>{n()||(r?.(),i.reject(c))},p=()=>new Promise(c=>{r=w=>{(n()||h())&&c(w)},e.onPause?.()}).then(()=>{r=void 0,n()||e.onContinue?.()}),b=()=>{if(n())return;let c;const w=s===0?e.initialPromise:void 0;try{c=w??e.fn()}catch(x){c=Promise.reject(x)}Promise.resolve(c).then(f).catch(x=>{if(n())return;const m=e.retry??(D?0:3),P=e.retryDelay??nt,R=typeof P=="function"?P(s,x):P,T=m===!0||typeof m=="number"&&s<m||typeof m=="function"&&m(s,x);if(t||!T){d(x);return}s++,e.onFail?.(s,x),Xe(R).then(()=>h()?void 0:p()).then(()=>{t?d(x):b()})})};return{promise:i,status:()=>i.status,cancel:o,continue:()=>(r?.(),i),cancelRetry:a,continueRetry:u,canStart:l,start:()=>(l()?b():p().then(b),i)}}var Ee=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),G(this.gcTime)&&(this.#e=M.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(D?1/0:300*1e3))}clearGcTimeout(){this.#e&&(M.clearTimeout(this.#e),this.#e=void 0)}},at=class extends Ee{#e;#t;#s;#i;#r;#a;#o;constructor(e){super(),this.#o=!1,this.#a=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#i=e.client,this.#s=this.#i.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=de(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#r?.promise}setOptions(e){if(this.options={...this.#a,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const t=de(this.options);t.data!==void 0&&(this.setData(t.data,{updatedAt:t.dataUpdatedAt,manual:!0}),this.#e=t)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#s.remove(this)}setData(e,t){const s=z(this.state.data,e,this.options);return this.#n({data:s,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),s}setState(e,t){this.#n({type:"setState",state:e,setStateOptions:t})}cancel(e){const t=this.#r?.promise;return this.#r?.cancel(e),t?t.then(k).catch(k):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(e=>I(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===re||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>j(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!Se(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#r?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#r?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#s.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#r&&(this.#o?this.#r.cancel({revert:!0}):this.#r.cancelRetry()),this.scheduleGc()),this.#s.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#n({type:"invalidate"})}async fetch(e,t){if(this.state.fetchStatus!=="idle"&&this.#r?.status()!=="rejected"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#r)return this.#r.continueRetry(),this.#r.promise}if(e&&this.setOptions(e),!this.options.queryFn){const a=this.observers.find(u=>u.options.queryFn);a&&this.setOptions(a.options)}const s=new AbortController,r=a=>{Object.defineProperty(a,"signal",{enumerable:!0,get:()=>(this.#o=!0,s.signal)})},i=()=>{const a=xe(this.options,t),h=(()=>{const l={client:this.#i,queryKey:this.queryKey,meta:this.meta};return r(l),l})();return this.#o=!1,this.options.persister?this.options.persister(a,h,this):a(h)},o=(()=>{const a={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#i,state:this.state,fetchFn:i};return r(a),a})();this.options.behavior?.onFetch(o,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==o.fetchOptions?.meta)&&this.#n({type:"fetch",meta:o.fetchOptions?.meta}),this.#r=Ce({initialPromise:t?.initialPromise,fn:o.fetchFn,onCancel:a=>{a instanceof Y&&a.revert&&this.setState({...this.#t,fetchStatus:"idle"}),s.abort()},onFail:(a,u)=>{this.#n({type:"failed",failureCount:a,error:u})},onPause:()=>{this.#n({type:"pause"})},onContinue:()=>{this.#n({type:"continue"})},retry:o.options.retry,retryDelay:o.options.retryDelay,networkMode:o.options.networkMode,canRun:()=>!0});try{const a=await this.#r.start();if(a===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(a),this.#s.config.onSuccess?.(a,this),this.#s.config.onSettled?.(a,this.state.error,this),a}catch(a){if(a instanceof Y){if(a.silent)return this.#r.promise;if(a.revert){if(this.state.data===void 0)throw a;return this.state.data}}throw this.#n({type:"error",error:a}),this.#s.config.onError?.(a,this),this.#s.config.onSettled?.(this.state.data,a,this),a}finally{this.scheduleGc()}}#n(e){const t=s=>{switch(e.type){case"failed":return{...s,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...s,fetchStatus:"paused"};case"continue":return{...s,fetchStatus:"fetching"};case"fetch":return{...s,...Re(s.data,this.options),fetchMeta:e.meta??null};case"success":const r={...s,data:e.data,dataUpdateCount:s.dataUpdateCount+1,dataUpdatedAt:e.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#t=e.manual?r:void 0,r;case"error":const i=e.error;return{...s,error:i,errorUpdateCount:s.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:s.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error"};case"invalidate":return{...s,isInvalidated:!0};case"setState":return{...s,...e.state}}};this.state=t(this.state),O.batch(()=>{this.observers.forEach(s=>{s.onQueryUpdate()}),this.#s.notify({query:this,type:"updated",action:e})})}};function Re(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Oe(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function de(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,s=t!==void 0,r=s?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:s?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:s?"success":"pending",fetchStatus:"idle"}}var ot=class extends U{constructor(e,t){super(),this.options=t,this.#e=e,this.#n=null,this.#o=J(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#s=void 0;#i=void 0;#r;#a;#o;#n;#m;#d;#f;#c;#l;#u;#p=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),fe(this.#t,this.options)?this.#h():this.updateResult(),this.#b())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return V(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return V(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#S(),this.#w(),this.#t.removeObserver(this)}setOptions(e){const t=this.options,s=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof I(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#x(),this.#t.setOptions(this.options),t._defaulted&&!H(this.options,t)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const r=this.hasListeners();r&&pe(this.#t,s,this.options,t)&&this.#h(),this.updateResult(),r&&(this.#t!==s||I(this.options.enabled,this.#t)!==I(t.enabled,this.#t)||j(this.options.staleTime,this.#t)!==j(t.staleTime,this.#t))&&this.#y();const i=this.#g();r&&(this.#t!==s||I(this.options.enabled,this.#t)!==I(t.enabled,this.#t)||i!==this.#u)&&this.#v(i)}getOptimisticResult(e){const t=this.#e.getQueryCache().build(this.#e,e),s=this.createResult(t,e);return ct(this,s)&&(this.#i=s,this.#a=this.options,this.#r=this.#t.state),s}getCurrentResult(){return this.#i}trackResult(e,t){return new Proxy(e,{get:(s,r)=>(this.trackProp(r),t?.(r),r==="promise"&&!this.options.experimental_prefetchInRender&&this.#o.status==="pending"&&this.#o.reject(new Error("experimental_prefetchInRender feature flag is not enabled")),Reflect.get(s,r))})}trackProp(e){this.#p.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#e.defaultQueryOptions(e),s=this.#e.getQueryCache().build(this.#e,t);return s.fetch().then(()=>this.createResult(s,t))}fetch(e){return this.#h({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#i))}#h(e){this.#x();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(k)),t}#y(){this.#S();const e=j(this.options.staleTime,this.#t);if(D||this.#i.isStale||!G(e))return;const s=Se(this.#i.dataUpdatedAt,e)+1;this.#c=M.setTimeout(()=>{this.#i.isStale||this.updateResult()},s)}#g(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#v(e){this.#w(),this.#u=e,!(D||I(this.options.enabled,this.#t)===!1||!G(this.#u)||this.#u===0)&&(this.#l=M.setInterval(()=>{(this.options.refetchIntervalInBackground||ie.isFocused())&&this.#h()},this.#u))}#b(){this.#y(),this.#v(this.#g())}#S(){this.#c&&(M.clearTimeout(this.#c),this.#c=void 0)}#w(){this.#l&&(M.clearInterval(this.#l),this.#l=void 0)}createResult(e,t){const s=this.#t,r=this.options,i=this.#i,n=this.#r,o=this.#a,u=e!==s?e.state:this.#s,{state:h}=e;let l={...h},f=!1,d;if(t._optimisticResults){const S=this.hasListeners(),E=!S&&fe(e,t),C=S&&pe(e,s,t,r);(E||C)&&(l={...l,...Re(h.data,e.options)}),t._optimisticResults==="isRestoring"&&(l.fetchStatus="idle")}let{error:p,errorUpdatedAt:b,status:c}=l;d=l.data;let w=!1;if(t.placeholderData!==void 0&&d===void 0&&c==="pending"){let S;i?.isPlaceholderData&&t.placeholderData===o?.placeholderData?(S=i.data,w=!0):S=typeof t.placeholderData=="function"?t.placeholderData(this.#f?.state.data,this.#f):t.placeholderData,S!==void 0&&(c="success",d=z(i?.data,S,t),f=!0)}if(t.select&&d!==void 0&&!w)if(i&&d===n?.data&&t.select===this.#m)d=this.#d;else try{this.#m=t.select,d=t.select(d),d=z(i?.data,d,t),this.#d=d,this.#n=null}catch(S){this.#n=S}this.#n&&(p=this.#n,d=this.#d,b=Date.now(),c="error");const x=l.fetchStatus==="fetching",m=c==="pending",P=c==="error",R=m&&x,T=d!==void 0,g={status:c,fetchStatus:l.fetchStatus,isPending:m,isSuccess:c==="success",isError:P,isInitialLoading:R,isLoading:R,data:d,dataUpdatedAt:l.dataUpdatedAt,error:p,errorUpdatedAt:b,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:l.dataUpdateCount>0||l.errorUpdateCount>0,isFetchedAfterMount:l.dataUpdateCount>u.dataUpdateCount||l.errorUpdateCount>u.errorUpdateCount,isFetching:x,isRefetching:x&&!m,isLoadingError:P&&!T,isPaused:l.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:P&&T,isStale:ne(e,t),refetch:this.refetch,promise:this.#o,isEnabled:I(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const S=F=>{g.status==="error"?F.reject(g.error):g.data!==void 0&&F.resolve(g.data)},E=()=>{const F=this.#o=g.promise=J();S(F)},C=this.#o;switch(C.status){case"pending":e.queryHash===s.queryHash&&S(C);break;case"fulfilled":(g.status==="error"||g.data!==C.value)&&E();break;case"rejected":(g.status!=="error"||g.error!==C.reason)&&E();break}}return g}updateResult(){const e=this.#i,t=this.createResult(this.#t,this.options);if(this.#r=this.#t.state,this.#a=this.options,this.#r.data!==void 0&&(this.#f=this.#t),H(t,e))return;this.#i=t;const s=()=>{if(!e)return!0;const{notifyOnChangeProps:r}=this.options,i=typeof r=="function"?r():r;if(i==="all"||!i&&!this.#p.size)return!0;const n=new Set(i??this.#p);return this.options.throwOnError&&n.add("error"),Object.keys(this.#i).some(o=>{const a=o;return this.#i[a]!==e[a]&&n.has(a)})};this.#P({listeners:s()})}#x(){const e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;const t=this.#t;this.#t=e,this.#s=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#b()}#P(e){O.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#i)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function ut(e,t){return I(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function fe(e,t){return ut(e,t)||e.state.data!==void 0&&V(e,t,t.refetchOnMount)}function V(e,t,s){if(I(t.enabled,e)!==!1&&j(t.staleTime,e)!=="static"){const r=typeof s=="function"?s(e):s;return r==="always"||r!==!1&&ne(e,t)}return!1}function pe(e,t,s,r){return(e!==t||I(r.enabled,e)===!1)&&(!s.suspense||e.state.status!=="error")&&ne(e,s)}function ne(e,t){return I(t.enabled,e)!==!1&&e.isStaleByTime(j(t.staleTime,e))}function ct(e,t){return!H(e.getCurrentResult(),t)}function me(e){return{onFetch:(t,s)=>{const r=t.options,i=t.fetchOptions?.meta?.fetchMore?.direction,n=t.state.data?.pages||[],o=t.state.data?.pageParams||[];let a={pages:[],pageParams:[]},u=0;const h=async()=>{let l=!1;const f=b=>{Object.defineProperty(b,"signal",{enumerable:!0,get:()=>(t.signal.aborted?l=!0:t.signal.addEventListener("abort",()=>{l=!0}),t.signal)})},d=xe(t.options,t.fetchOptions),p=async(b,c,w)=>{if(l)return Promise.reject();if(c==null&&b.pages.length)return Promise.resolve(b);const m=(()=>{const q={client:t.client,queryKey:t.queryKey,pageParam:c,direction:w?"backward":"forward",meta:t.options.meta};return f(q),q})(),P=await d(m),{maxPages:R}=t.options,T=w?et:Ze;return{pages:T(b.pages,P,R),pageParams:T(b.pageParams,c,R)}};if(i&&n.length){const b=i==="backward",c=b?lt:ye,w={pages:n,pageParams:o},x=c(r,w);a=await p(w,x,b)}else{const b=e??n.length;do{const c=u===0?o[0]??r.initialPageParam:ye(r,a);if(u>0&&c==null)break;a=await p(a,c),u++}while(u<b)}return a};t.options.persister?t.fetchFn=()=>t.options.persister?.(h,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},s):t.fetchFn=h}}}function ye(e,{pages:t,pageParams:s}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,s[r],s):void 0}function lt(e,{pages:t,pageParams:s}){return t.length>0?e.getPreviousPageParam?.(t[0],t,s[0],s):void 0}var ht=class extends Ee{#e;#t;#s;#i;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#s=e.mutationCache,this.#t=[],this.state=e.state||ke(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#s.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#s.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#s.remove(this))}continue(){return this.#i?.continue()??this.execute(this.state.variables)}async execute(e){const t=()=>{this.#r({type:"continue"})},s={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#i=Ce({fn:()=>this.options.mutationFn?this.options.mutationFn(e,s):Promise.reject(new Error("No mutationFn found")),onFail:(n,o)=>{this.#r({type:"failed",failureCount:n,error:o})},onPause:()=>{this.#r({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#s.canRun(this)});const r=this.state.status==="pending",i=!this.#i.canStart();try{if(r)t();else{this.#r({type:"pending",variables:e,isPaused:i}),await this.#s.config.onMutate?.(e,this,s);const o=await this.options.onMutate?.(e,s);o!==this.state.context&&this.#r({type:"pending",context:o,variables:e,isPaused:i})}const n=await this.#i.start();return await this.#s.config.onSuccess?.(n,e,this.state.context,this,s),await this.options.onSuccess?.(n,e,this.state.context,s),await this.#s.config.onSettled?.(n,null,this.state.variables,this.state.context,this,s),await this.options.onSettled?.(n,null,e,this.state.context,s),this.#r({type:"success",data:n}),n}catch(n){try{throw await this.#s.config.onError?.(n,e,this.state.context,this,s),await this.options.onError?.(n,e,this.state.context,s),await this.#s.config.onSettled?.(void 0,n,this.state.variables,this.state.context,this,s),await this.options.onSettled?.(void 0,n,e,this.state.context,s),n}finally{this.#r({type:"error",error:n})}}finally{this.#s.runNext(this)}}#r(e){const t=s=>{switch(e.type){case"failed":return{...s,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...s,isPaused:!0};case"continue":return{...s,isPaused:!1};case"pending":return{...s,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...s,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...s,data:void 0,error:e.error,failureCount:s.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),O.batch(()=>{this.#t.forEach(s=>{s.onMutationUpdate(e)}),this.#s.notify({mutation:this,type:"updated",action:e})})}};function ke(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var dt=class extends U{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#s=0}#e;#t;#s;build(e,t,s){const r=new ht({client:e,mutationCache:this,mutationId:++this.#s,options:e.defaultMutationOptions(t),state:s});return this.add(r),r}add(e){this.#e.add(e);const t=$(e);if(typeof t=="string"){const s=this.#t.get(t);s?s.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){const t=$(e);if(typeof t=="string"){const s=this.#t.get(t);if(s)if(s.length>1){const r=s.indexOf(e);r!==-1&&s.splice(r,1)}else s[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=$(e);if(typeof t=="string"){const r=this.#t.get(t)?.find(i=>i.state.status==="pending");return!r||r===e}else return!0}runNext(e){const t=$(e);return typeof t=="string"?this.#t.get(t)?.find(r=>r!==e&&r.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){O.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){const t={exact:!0,...e};return this.getAll().find(s=>ce(t,s))}findAll(e={}){return this.getAll().filter(t=>ce(e,t))}notify(e){O.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return O.batch(()=>Promise.all(e.map(t=>t.continue().catch(k))))}};function $(e){return e.options.scope?.id}var ft=class extends U{#e;#t=void 0;#s;#i;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#r()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){const t=this.options;this.options=this.#e.defaultMutationOptions(e),H(this.options,t)||this.#e.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#s,observer:this}),t?.mutationKey&&this.options.mutationKey&&A(t.mutationKey)!==A(this.options.mutationKey)?this.reset():this.#s?.state.status==="pending"&&this.#s.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#s?.removeObserver(this)}onMutationUpdate(e){this.#r(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#s?.removeObserver(this),this.#s=void 0,this.#r(),this.#a()}mutate(e,t){return this.#i=t,this.#s?.removeObserver(this),this.#s=this.#e.getMutationCache().build(this.#e,this.options),this.#s.addObserver(this),this.#s.execute(e)}#r(){const e=this.#s?.state??ke();this.#t={...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset}}#a(e){O.batch(()=>{if(this.#i&&this.hasListeners()){const t=this.#t.variables,s=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};e?.type==="success"?(this.#i.onSuccess?.(e.data,t,s,r),this.#i.onSettled?.(e.data,null,t,s,r)):e?.type==="error"&&(this.#i.onError?.(e.error,t,s,r),this.#i.onSettled?.(void 0,e.error,t,s,r))}this.listeners.forEach(t=>{t(this.#t)})})}},pt=class extends U{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,s){const r=t.queryKey,i=t.queryHash??se(r,t);let n=this.get(i);return n||(n=new at({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:s,defaultOptions:e.getQueryDefaults(r)}),this.add(n)),n}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){O.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){const t={exact:!0,...e};return this.getAll().find(s=>ue(t,s))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(s=>ue(e,s)):t}notify(e){O.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){O.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){O.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},Wt=class{#e;#t;#s;#i;#r;#a;#o;#n;constructor(e={}){this.#e=e.queryCache||new pt,this.#t=e.mutationCache||new dt,this.#s=e.defaultOptions||{},this.#i=new Map,this.#r=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=ie.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#n=B.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#n?.(),this.#n=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),s=this.#e.build(this,t),r=s.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&s.isStaleByTime(j(t.staleTime,s))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:s})=>{const r=s.data;return[t,r]})}setQueryData(e,t,s){const r=this.defaultQueryOptions({queryKey:e}),n=this.#e.get(r.queryHash)?.state.data,o=Ye(t,n);if(o!==void 0)return this.#e.build(this,r).setData(o,{...s,manual:!0})}setQueriesData(e,t,s){return O.batch(()=>this.#e.findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,s)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){const t=this.#e;O.batch(()=>{t.findAll(e).forEach(s=>{t.remove(s)})})}resetQueries(e,t){const s=this.#e;return O.batch(()=>(s.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const s={revert:!0,...t},r=O.batch(()=>this.#e.findAll(e).map(i=>i.cancel(s)));return Promise.all(r).then(k).catch(k)}invalidateQueries(e,t={}){return O.batch(()=>(this.#e.findAll(e).forEach(s=>{s.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){const s={...t,cancelRefetch:t.cancelRefetch??!0},r=O.batch(()=>this.#e.findAll(e).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let n=i.fetch(void 0,s);return s.throwOnError||(n=n.catch(k)),i.state.fetchStatus==="paused"?Promise.resolve():n}));return Promise.all(r).then(k)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const s=this.#e.build(this,t);return s.isStaleByTime(j(t.staleTime,s))?s.fetch(t):Promise.resolve(s.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(k).catch(k)}fetchInfiniteQuery(e){return e.behavior=me(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(k).catch(k)}ensureInfiniteQueryData(e){return e.behavior=me(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return B.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#s}setDefaultOptions(e){this.#s=e}setQueryDefaults(e,t){this.#i.set(A(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#i.values()],s={};return t.forEach(r=>{N(e,r.queryKey)&&Object.assign(s,r.defaultOptions)}),s}setMutationDefaults(e,t){this.#r.set(A(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#r.values()],s={};return t.forEach(r=>{N(e,r.mutationKey)&&Object.assign(s,r.defaultOptions)}),s}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#s.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=se(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===re&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#s.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},Fe=y.createContext(void 0),Te=e=>{const t=y.useContext(Fe);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},zt=({client:e,children:t})=>(y.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),v.jsx(Fe.Provider,{value:e,children:t})),Ie=y.createContext(!1),mt=()=>y.useContext(Ie);Ie.Provider;function yt(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var gt=y.createContext(yt()),vt=()=>y.useContext(gt),bt=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},St=e=>{y.useEffect(()=>{e.clearReset()},[e])},wt=({result:e,errorResetBoundary:t,throwOnError:s,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||Pe(s,[e.error,r])),xt=e=>{if(e.suspense){const s=i=>i==="static"?i:Math.max(i??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...i)=>s(r(...i)):s(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},Pt=(e,t)=>e.isLoading&&e.isFetching&&!t,Ot=(e,t)=>e?.suspense&&t.isPending,ge=(e,t,s)=>t.fetchOptimistic(e).catch(()=>{s.clearReset()});function Ct(e,t,s){const r=mt(),i=vt(),n=Te(),o=n.defaultQueryOptions(e);n.getDefaultOptions().queries?._experimental_beforeQuery?.(o),o._optimisticResults=r?"isRestoring":"optimistic",xt(o),bt(o,i),St(i);const a=!n.getQueryCache().get(o.queryHash),[u]=y.useState(()=>new t(n,o)),h=u.getOptimisticResult(o),l=!r&&e.subscribed!==!1;if(y.useSyncExternalStore(y.useCallback(f=>{const d=l?u.subscribe(O.batchCalls(f)):k;return u.updateResult(),d},[u,l]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),y.useEffect(()=>{u.setOptions(o)},[o,u]),Ot(o,h))throw ge(o,u,i);if(wt({result:h,errorResetBoundary:i,throwOnError:o.throwOnError,query:n.getQueryCache().get(o.queryHash),suspense:o.suspense}))throw h.error;return n.getDefaultOptions().queries?._experimental_afterQuery?.(o,h),o.experimental_prefetchInRender&&!D&&Pt(h,r)&&(a?ge(o,u,i):n.getQueryCache().get(o.queryHash)?.promise)?.catch(k).finally(()=>{u.updateResult()}),o.notifyOnChangeProps?h:u.trackResult(h)}function je(e,t){return Ct(e,ot)}function Jt(e,t){const s=Te(),[r]=y.useState(()=>new ft(s,e));y.useEffect(()=>{r.setOptions(e)},[r,e]);const i=y.useSyncExternalStore(y.useCallback(o=>r.subscribe(O.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),n=y.useCallback((o,a)=>{r.mutate(o,a).catch(k)},[r]);if(i.error&&Pe(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:n,mutateAsync:i.mutate}}const K=[{id:"default",name:"默认服务",url:"http://127.0.0.1:4936",isDefault:!0}],Me="backendServices",De=e=>e.replace(/\/+$/,""),Et=()=>{try{const e=localStorage.getItem(Me);if(e){const t=JSON.parse(e);return!t.services||t.services.length===0?{services:K,currentServiceId:K[0].id}:{...t,services:t.services.map(s=>({...s,url:De(s.url)}))}}}catch(e){console.error("Failed to load backend services:",e)}return{services:K,currentServiceId:K[0].id}},ae=e=>{try{localStorage.setItem(Me,JSON.stringify(e))}catch(t){console.error("Failed to save backend services:",t)}},Rt=e=>e.services.find(t=>t.id===e.currentServiceId)||null,Yt=(e,t,s)=>{const r=s.url?{...s,url:De(s.url)}:s,i={...e,services:e.services.map(n=>n.id===t?{...n,...r}:n)};return ae(i),i},Vt=(e,t)=>{if(e.services.find(i=>i.id===t)?.isDefault)return e;const r={...e,services:e.services.filter(i=>i.id!==t),currentServiceId:e.currentServiceId===t?e.services.find(i=>i.id!==t)?.id||null:e.currentServiceId};return ae(r),r},Xt=(e,t)=>{if(!e.services.find(i=>i.id===t))return e;const r={...e,currentServiceId:t};return ae(r),r},oe=()=>{const e="/api";return e.startsWith("/")&&!e.startsWith("//")},Ae=()=>{if(oe())return window.location.origin;const e=Et(),t=Rt(e);return t?t.url:"http://127.0.0.1:4936"},Qe=()=>"",Q=()=>oe()?window.location.origin+Qe()+"/api":Ae()+"/api",X=()=>oe()?window.location.origin+Qe()+"/media":Ae()+"/media";X();const kt=Q(),Zt=e=>e?!!(e.name==="TypeError"&&e.message?.includes("fetch")||e.name==="AbortError"||e.message?.includes("AbortError")||e.message?.includes("ERR_CONNECTION_REFUSED")||e.message?.includes("ERR_NETWORK")||e.message?.includes("Failed to fetch")||e.message?.includes("NetworkError")||e.status&&(e.status===0||e.status===502||e.status===503||e.status===504)):!1,ve=e=>{let t;const s=new Set,r=(h,l)=>{const f=typeof h=="function"?h(t):h;if(!Object.is(f,t)){const d=t;t=l??(typeof f!="object"||f===null)?f:Object.assign({},t,f),s.forEach(p=>p(t,d))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>u,subscribe:h=>(s.add(h),()=>s.delete(h))},u=t=e(r,i,a);return a},Ft=(e=>e?ve(e):ve),Tt=e=>e;function It(e,t=Tt){const s=L.useSyncExternalStore(e.subscribe,L.useCallback(()=>t(e.getState()),[e,t]),L.useCallback(()=>t(e.getInitialState()),[e,t]));return L.useDebugValue(s),s}const be=e=>{const t=Ft(e),s=r=>It(t,r);return Object.assign(s,t),s},jt=(e=>e?be(e):be);function Mt(e,t){let s;try{s=e()}catch{return}return{getItem:i=>{var n;const o=u=>u===null?null:JSON.parse(u,void 0),a=(n=s.getItem(i))!=null?n:null;return a instanceof Promise?a.then(o):o(a)},setItem:(i,n)=>s.setItem(i,JSON.stringify(n,void 0)),removeItem:i=>s.removeItem(i)}}const Z=e=>t=>{try{const s=e(t);return s instanceof Promise?s:{then(r){return Z(r)(s)},catch(r){return this}}}catch(s){return{then(r){return this},catch(r){return Z(r)(s)}}}},Dt=(e,t)=>(s,r,i)=>{let n={storage:Mt(()=>localStorage),partialize:c=>c,version:0,merge:(c,w)=>({...w,...c}),...t},o=!1;const a=new Set,u=new Set;let h=n.storage;if(!h)return e((...c)=>{console.warn(`[zustand persist middleware] Unable to update item '${n.name}', the given storage is currently unavailable.`),s(...c)},r,i);const l=()=>{const c=n.partialize({...r()});return h.setItem(n.name,{state:c,version:n.version})},f=i.setState;i.setState=(c,w)=>(f(c,w),l());const d=e((...c)=>(s(...c),l()),r,i);i.getInitialState=()=>d;let p;const b=()=>{var c,w;if(!h)return;o=!1,a.forEach(m=>{var P;return m((P=r())!=null?P:d)});const x=((w=n.onRehydrateStorage)==null?void 0:w.call(n,(c=r())!=null?c:d))||void 0;return Z(h.getItem.bind(h))(n.name).then(m=>{if(m)if(typeof m.version=="number"&&m.version!==n.version){if(n.migrate){const P=n.migrate(m.state,m.version);return P instanceof Promise?P.then(R=>[!0,R]):[!0,P]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,m.state];return[!1,void 0]}).then(m=>{var P;const[R,T]=m;if(p=n.merge(T,(P=r())!=null?P:d),s(p,!0),R)return l()}).then(()=>{x?.(p,void 0),p=r(),o=!0,u.forEach(m=>m(p))}).catch(m=>{x?.(void 0,m)})};return i.persist={setOptions:c=>{n={...n,...c},c.storage&&(h=c.storage)},clearStorage:()=>{h?.removeItem(n.name)},getOptions:()=>n,rehydrate:()=>b(),hasHydrated:()=>o,onHydrate:c=>(a.add(c),()=>{a.delete(c)}),onFinishHydration:c=>(u.add(c),()=>{u.delete(c)})},n.skipHydration||b(),p||d},At=Dt,ee=jt()(At((e,t)=>({token:null,tokens:{},isAuthenticated:!1,getToken:s=>{const{tokens:r}=t();return r[s]||null},setToken:s=>{e(r=>({tokens:{...r.tokens,[s.serviceId]:s},token:s,isAuthenticated:!0}))},removeToken:s=>{e(r=>{const i={...r.tokens};delete i[s];const n=r.token,o=n&&typeof n=="object"&&"serviceId"in n&&n.serviceId===s;return{tokens:i,token:o?null:r.token,isAuthenticated:o?!1:r.isAuthenticated}})},logout:()=>e({tokens:{},token:null,isAuthenticated:!1})}),{name:"auth-storage",migrate:(e,t)=>{const s=e;if(s.token&&!s.tokens){const r=s.token;if(typeof r=="object"&&r&&"serviceId"in r)return{...s,tokens:{[r.serviceId]:r}}}return e}}));function te(e){try{const s=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/");return JSON.parse(window.atob(s))}catch{return null}}const es=e=>{if(!e)return!0;if(typeof e=="string"){const i=te(e);if(!i||!i.exp)return!0;const n=Math.floor(Date.now()/1e3);return i.exp<=n}const t=te(e.token);if(t&&t.exp){const i=Math.floor(Date.now()/1e3);return t.exp<=i}const s=Date.now()-e.timestamp,r=10080*60*1e3;return s>r},Qt=(e,t=24)=>{if(!e)return!0;const s=typeof e=="string"?e:e.token,r=te(s);if(!r||!r.exp)return!0;const i=Math.floor(Date.now()/1e3),n=t*60*60;return r.exp-i<=n},Ue=e=>e?typeof e=="object"&&"token"in e?e.token:e:null;async function _(e,t={}){const{skipAuth:s=!1,maxRetries:r=1,...i}=t;let n=0;for(;n<=r;)try{const o=await Ut(e,i,s);if(o.status===401&&n<r&&!s&&await Ne()){n++;continue}return o}catch(o){if(n>=r){if(o instanceof Error){const a=o;a.requestUrl=e,a.requestMethod=t.method||"GET",a.isRetryable=!0,a.retryAttempt=n,a.maxRetries=r,o.name==="TypeError"&&o.message.includes("fetch")&&(a.message=`Network request failed: ${t.method||"GET"} ${e}`)}throw o}n++,await new Promise(a=>setTimeout(a,1e3))}throw new Error("Max retries exceeded")}async function Ut(e,t={},s=!1){const r=new Headers(t.headers||{});let i;if(!s){const o=qe(),{getToken:a}=ee.getState(),u=o?a(o):ee.getState().token;i=Ue(u)||void 0,i&&(r.set("Authorization",`Bearer ${i}`),Qt(u)&&Ne().catch(console.error))}const n={...t,headers:r};return fetch(e,n).catch(o=>{if(o instanceof Error){const a=o;a.requestUrl=e,a.requestMethod=n.method||"GET",a.hasAuth=!s,a.tokenPresent=!!i,o.name==="TypeError"&&o.message.includes("fetch")&&(a.message=`Failed to connect to server: ${n.method||"GET"} ${e}`)}throw o})}function qe(){try{const e=localStorage.getItem("backend-services-storage");if(e)return JSON.parse(e).state?.currentService?.id||null}catch(e){console.error("Error getting current service ID:",e)}return null}async function Ne(){try{const e=qe(),{getToken:t,setToken:s}=ee.getState();if(!e)return!1;const r=t(e);if(!r)return!1;const i=Ue(r);if(!i)return!1;const n=await fetch(`${kt}/auth/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:i})});if(n.ok){const o=await n.json();if(o.success&&o.token&&o.refreshed){const a={...r,token:o.token,timestamp:Date.now()};return s(a),console.log("Token refreshed successfully via authFetch"),!0}}return!1}catch(e){return console.error("Token refresh failed:",e),!1}}const _e=e=>{let t=e.match(/window\.presentationConfig\s*=\s*\{[\s\S]*?slides:\s*\[([\s\S]*?)\]/);const s=e.match(/title:\s*["']([^"']+)["']/);if(t||(t=e.match(/presentationConfig\s*=\s*\{[\s\S]*?slides:\s*\[([\s\S]*?)\]/)),t||(t=e.match(/slides:\s*\[([\s\S]*?)\]/)),t||(t=e.match(/window\.slidesConfig\s*=\s*\[([\s\S]*?)\]/)),t||(t=e.match(/slidesConfig\s*=\s*\[([\s\S]*?)\]/)),!t)throw new Error("Invalid slides configuration format");const i=t[1].match(/"([^"]+)"/g),n=i?i.map(a=>a.replace(/"/g,"")):[],o=s?s[1]:"Presentation";return{slides:n,title:o}},qt=e=>{const t=e.match(/<title>(.*?)<\/title>/i)||e.match(/<h1[^>]*>(.*?)<\/h1>/i);return t?t[1].replace(/<[^>]*>/g,"").trim():""},ts=e=>je({queryKey:["slides",e],queryFn:async()=>{const t=new URLSearchParams;t.set("path","slides.js"),e&&t.set("projectPath",e);const s=await _(`${Q()}/files/read?${t.toString()}`);if(!s.ok){if(s.status===404)return{slides:[],title:"Presentation",total:0};throw new Error("Failed to fetch slides configuration")}const r=await s.json(),{slides:i,title:n}=_e(r.content),o=new URLSearchParams;e&&o.set("projectPath",e);const a=await _(`${Q()}/files/read-multiple?${o.toString()}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({paths:i})});if(!a.ok)throw new Error("Failed to fetch slide files");const u=await a.json();return{slides:i.map((l,f)=>{const d=u.files.find(b=>b.path===l);let p=l.split("/").pop()?.replace(".html","")||`Slide ${f+1}`;if(d?.exists&&d.content){const b=qt(d.content);b&&(p=b)}return{path:l,title:p,exists:d?.exists||!1,index:f}}),total:i.length,title:n}}}),Nt=(e,t)=>je({queryKey:["slide-content",e,t],queryFn:async()=>{const s=new URLSearchParams;s.set("path","slides.js"),s.set("projectPath",t||"");const r=await _(`${Q()}/files/read?${s.toString()}`);if(!r.ok)throw r.status===404?new Error("No slides configuration found. Please create slides.js file first."):new Error("Failed to fetch slides configuration");const i=await r.json(),{slides:n}=_e(i.content);if(e>=n.length)throw new Error("Slide not found");const o=n[e],a=new URLSearchParams;a.set("path",o),a.set("projectPath",t||"");const u=await _(`${Q()}/files/read?${a.toString()}`);if(!u.ok)throw new Error("Failed to fetch slide content");return{content:(await u.json()).content,path:o,index:e}},enabled:e>=0});var _t=Ke();const Lt=$e(_t);Prism.languages.markup={comment:{pattern:/<!--(?:(?!<!--)[\s\S])*?-->/,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^<!|>$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/&#x?[\da-f]{1,8};/i]};Prism.languages.markup.tag.inside["attr-value"].inside.entity=Prism.languages.markup.entity;Prism.languages.markup.doctype.inside["internal-subset"].inside=Prism.languages.markup;Prism.hooks.add("wrap",function(e){e.type==="entity"&&(e.attributes.title=e.content.replace(/&amp;/,"&"))});Object.defineProperty(Prism.languages.markup.tag,"addInlined",{value:function(t,s){var r={};r["language-"+s]={pattern:/(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,lookbehind:!0,inside:Prism.languages[s]},r.cdata=/^<!\[CDATA\[|\]\]>$/i;var i={"included-cdata":{pattern:/<!\[CDATA\[[\s\S]*?\]\]>/i,inside:r}};i["language-"+s]={pattern:/[\s\S]+/,inside:Prism.languages[s]};var n={};n[t]={pattern:RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g,function(){return t}),"i"),lookbehind:!0,greedy:!0,inside:i},Prism.languages.insertBefore("markup","cdata",n)}});Object.defineProperty(Prism.languages.markup.tag,"addAttribute",{value:function(e,t){Prism.languages.markup.tag.inside["special-attr"].push({pattern:RegExp(/(^|["'\s])/.source+"(?:"+e+")"+/\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,"i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[t,"language-"+t],inside:Prism.languages[t]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}});Prism.languages.html=Prism.languages.markup;Prism.languages.mathml=Prism.languages.markup;Prism.languages.svg=Prism.languages.markup;Prism.languages.xml=Prism.languages.extend("markup",{});Prism.languages.ssml=Prism.languages.xml;Prism.languages.atom=Prism.languages.xml;Prism.languages.rss=Prism.languages.xml;(function(e){var t=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;e.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:RegExp("@[\\w-](?:"+/[^;{\s"']|\s+(?!\s)/.source+"|"+t.source+")*?"+/(?:;|(?=\s*\{))/.source),inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:"selector"},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp("\\burl\\((?:"+t.source+"|"+/(?:[^\\\r\n()"']|\\[\s\S])*/.source+")\\)","i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp("^"+t.source+"$"),alias:"url"}}},selector:{pattern:RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|`+t.source+")*(?=\\s*\\{)"),lookbehind:!0},string:{pattern:t,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},e.languages.css.atrule.inside.rest=e.languages.css;var s=e.languages.markup;s&&(s.tag.addInlined("style","css"),s.tag.addAttribute("style","css"))})(Prism);const ss=y.forwardRef(({slide:e,totalSlides:t,projectPath:s},r)=>{const{t:i}=He("agents"),n=y.useRef(null),o=y.useRef(null),[a,u]=y.useState(!0),[h,l]=y.useState(!1),[f,d]=y.useState("preview"),[p,b]=y.useState(null),[c,w]=y.useState(1),{data:x}=Nt(e.index,s),m=y.useCallback((g,S,E)=>{try{const C=Date.now(),F=`${X()}/${S}/${E}?t=${C}`;console.log("SlidePreview: Loading iframe with URL:",F),g.src=F}catch(C){console.error("SlidePreview: Error loading iframe:",C),l(!0),u(!1)}},[X]);y.useImperativeHandle(r,()=>({refreshIframe:()=>{const g=n.current;g&&p&&e.path&&m(g,p,e.path)}}),[p,e.path,m]),y.useEffect(()=>{if(!s){console.log("SlidePreview: No projectPath provided");return}(async()=>{try{const S=new URLSearchParams;S.set("projectPath",s);const E=`${Q()}/files/project-id?${S.toString()}`;console.log("SlidePreview: Fetching project ID from:",E);const C=await _(E);if(C.ok){const F=await C.json();console.log("SlidePreview: Got project ID:",F.projectId,"for path:",s),b(F.projectId)}else{console.error("SlidePreview: Failed to fetch project ID, status:",C.status);const F=await C.json().catch(()=>({error:"Unknown error"}));console.error("SlidePreview: Error details:",F)}}catch(S){console.error("SlidePreview: Exception while fetching project ID:",S)}})()},[s]),y.useEffect(()=>{const g=n.current;if(!g||f!=="preview"||!p||!e.path)return;u(!0),l(!1);const S=()=>{u(!1),l(!1)},E=()=>{u(!1),l(!0)};return g.addEventListener("load",S),g.addEventListener("error",E),m(g,p,e.path),()=>{g.removeEventListener("load",S),g.removeEventListener("error",E)}},[f,p,e.path,m]),y.useEffect(()=>{f==="code"&&x&&setTimeout(()=>{Lt.highlightAll()},0)},[f,x]);const P=1280/720,R=1280,T=720,q=()=>{if(!o.current)return 1;const S=o.current.getBoundingClientRect(),E=S.width,C=S.height,F=E/R,Le=C/T;return Math.min(F,Le,1)};return y.useEffect(()=>{const g=()=>{const E=q();w(E)};g(),window.addEventListener("resize",g);const S=setTimeout(g,100);return()=>{window.removeEventListener("resize",g),clearTimeout(S)}},[f]),v.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow-md overflow-hidden",children:[v.jsx("div",{className:"h-12 px-4 bg-gray-100 dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 flex items-center",children:v.jsxs("div",{className:"flex items-center gap-4",children:[v.jsxs("div",{className:"flex space-x-1",children:[v.jsxs("button",{onClick:()=>d("preview"),className:`flex items-center space-x-2 px-3 py-1.5 text-sm rounded-md transition-colors ${f==="preview"?"bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-300 border border-blue-200 dark:border-blue-700":"text-gray-600 dark:text-gray-300 hover:text-gray-800 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-gray-600"}`,children:[v.jsx(Be,{className:"w-4 h-4"}),v.jsx("span",{children:i("slidePreview.tabs.preview")})]}),v.jsxs("button",{onClick:()=>d("code"),className:`flex items-center space-x-2 px-3 py-1.5 text-sm rounded-md transition-colors ${f==="code"?"bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-300 border border-blue-200 dark:border-blue-700":"text-gray-600 dark:text-gray-300 hover:text-gray-800 dark:hover:text-white hover:bg-gray-100 dark:hover:bg-gray-600"}`,children:[v.jsx(Ge,{className:"w-4 h-4"}),v.jsx("span",{children:i("slidePreview.tabs.code")})]})]}),v.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-300 font-medium flex-1",children:e.path?e.path.replace(/\.html$/,""):""}),v.jsxs("div",{className:"text-sm text-gray-500 dark:text-gray-400 font-medium",children:[e.index+1,"/",t]})]})}),v.jsx("div",{className:"p-4",children:f==="preview"?v.jsxs("div",{ref:o,className:"relative w-full bg-gray-100 dark:bg-gray-900 rounded-lg overflow-hidden",style:{aspectRatio:`${P}`},children:[a&&v.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:v.jsx("div",{className:"text-sm text-gray-500 dark:text-gray-400",children:i("slidePreview.loading")})}),h&&v.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:v.jsx("div",{className:"text-sm text-red-500 dark:text-red-400",children:i("slidePreview.loadFailed")})}),e.exists&&p&&v.jsx("div",{className:"absolute top-0 left-0",style:{width:`${R}px`,height:`${T}px`,transform:`scale(${c})`,transformOrigin:"top left"},children:v.jsx("iframe",{ref:n,className:"w-full h-full border-none",style:{display:a||h?"none":"block",width:`${R}px`,height:`${T}px`},scrolling:"no"})}),!e.exists&&!a&&v.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:v.jsx("div",{className:"text-sm text-orange-500 dark:text-orange-400",children:i("slidePreview.fileNotFound")})})]}):v.jsx("div",{className:"relative bg-gray-100 dark:bg-gray-900 rounded-lg overflow-hidden",style:{aspectRatio:`${P}`},children:x?v.jsx("div",{className:"h-full overflow-y-auto",children:v.jsx("pre",{className:"language-html h-full m-0 p-4 text-sm",style:{backgroundColor:"#2d3748"},children:v.jsx("code",{className:"language-html text-gray-100",children:x.content})})}):v.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:v.jsx("div",{className:"text-gray-500 dark:text-gray-400",children:i("slidePreview.loadingCode")})})})})]})});export{kt as A,Wt as Q,ss as S,_ as a,je as b,Jt as c,Rt as d,Xt as e,Yt as f,Q as g,ee as h,Zt as i,es as j,Ue as k,Et as l,Qt as m,De as n,zt as o,jt as p,ts as q,Vt as r,ae as s,Te as u};
@@ -1 +1 @@
1
- import{M as ln,N as an,O as Y,P as O,Q,R as un,S as y,T as tn,V as j,W as _,X as rn,Y as o,Z as sn,$ as on,a0 as fn}from"./ChatPage-D8buVhfb.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,D,S,v,R,V,a){var E=D-l,i=S-h,n=V-v,d=a-R,u=d*E-n*i;if(!(u*u<y))return u=(n*(h-R)-d*(l-v))/u,[l+u*E,h+u*i]}function H(l,h,D,S,v,R,V){var a=l-D,E=h-S,i=(V?R:-R)/j(a*a+E*E),n=i*E,d=-i*a,u=l+n,s=h+d,f=D+n,c=S+d,W=(u+f)/2,t=(s+c)/2,m=f-u,g=c-s,A=m*m+g*g,T=v-R,P=u*c-f*s,I=(g<0?-1:1)*j(on(0,T*T*A-P*P)),M=(P*g-m*I)/A,N=(-P*m-g*I)/A,w=(P*g+m*I)/A,p=(-P*m+g*I)/A,x=M-W,e=N-t,r=w-W,X=p-t;return x*x+e*e>r*r+X*X&&(M=w,N=p),{cx:M,cy:N,x01:-n,y01:-d,x11:M*(v/T-1),y11:N*(v/T-1)}}function hn(){var l=cn,h=yn,D=Q(0),S=null,v=gn,R=dn,V=mn,a=null,E=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-un,c=R.apply(this,arguments)-un,W=rn(c-f),t=c>f;if(a||(a=n=E()),s<u&&(d=s,s=u,u=d),!(s>y))a.moveTo(0,0);else if(W>tn-y)a.moveTo(s*Y(f),s*O(f)),a.arc(0,0,s,f,c,!t),u>y&&(a.moveTo(u*Y(c),u*O(c)),a.arc(0,0,u,c,f,t));else{var m=f,g=c,A=f,T=c,P=W,I=W,M=V.apply(this,arguments)/2,N=M>y&&(S?+S.apply(this,arguments):j(u*u+s*s)),w=_(rn(s-u)/2,+D.apply(this,arguments)),p=w,x=w,e,r;if(N>y){var X=sn(N/u*O(M)),z=sn(N/s*O(M));(P-=X*2)>y?(X*=t?1:-1,A+=X,T-=X):(P=0,A=T=(f+c)/2),(I-=z*2)>y?(z*=t?1:-1,m+=z,g-=z):(I=0,m=g=(f+c)/2)}var Z=s*Y(m),$=s*O(m),B=u*Y(T),C=u*O(T);if(w>y){var F=s*Y(g),G=s*O(g),J=u*Y(A),K=u*O(A),q;if(W<an)if(q=pn(Z,$,J,K,F,G,B,C)){var L=Z-q[0],U=$-q[1],k=F-q[0],b=G-q[1],nn=1/O(fn((L*k+U*b)/(j(L*L+U*U)*j(k*k+b*b)))/2),en=j(q[0]*q[0]+q[1]*q[1]);p=_(w,(u-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}I>y?x>y?(e=H(J,K,Z,$,s,x,t),r=H(F,G,B,C,s,x,t),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),a.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(a.moveTo(Z,$),a.arc(0,0,s,m,g,!t)):a.moveTo(Z,$),!(u>y)||!(P>y)?a.lineTo(B,C):p>y?(e=H(B,C,F,G,u,-p,t),r=H(Z,$,J,K,u,-p,t),a.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,u,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),a.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):a.arc(0,0,u,T,A,t)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +R.apply(this,arguments))/2-an/2;return[Y(d)*n,O(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:Q(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:Q(+n),i):h},i.cornerRadius=function(n){return arguments.length?(D=typeof n=="function"?n:Q(+n),i):D},i.padRadius=function(n){return arguments.length?(S=n==null?null:typeof n=="function"?n:Q(+n),i):S},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:Q(+n),i):v},i.endAngle=function(n){return arguments.length?(R=typeof n=="function"?n:Q(+n),i):R},i.padAngle=function(n){return arguments.length?(V=typeof n=="function"?n:Q(+n),i):V},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};
1
+ import{M as ln,N as an,O as Y,P as O,Q,R as un,S as y,T as tn,V as j,W as _,X as rn,Y as o,Z as sn,$ as on,a0 as fn}from"./ChatPage-B7-rn9mH.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,D,S,v,R,V,a){var E=D-l,i=S-h,n=V-v,d=a-R,u=d*E-n*i;if(!(u*u<y))return u=(n*(h-R)-d*(l-v))/u,[l+u*E,h+u*i]}function H(l,h,D,S,v,R,V){var a=l-D,E=h-S,i=(V?R:-R)/j(a*a+E*E),n=i*E,d=-i*a,u=l+n,s=h+d,f=D+n,c=S+d,W=(u+f)/2,t=(s+c)/2,m=f-u,g=c-s,A=m*m+g*g,T=v-R,P=u*c-f*s,I=(g<0?-1:1)*j(on(0,T*T*A-P*P)),M=(P*g-m*I)/A,N=(-P*m-g*I)/A,w=(P*g+m*I)/A,p=(-P*m+g*I)/A,x=M-W,e=N-t,r=w-W,X=p-t;return x*x+e*e>r*r+X*X&&(M=w,N=p),{cx:M,cy:N,x01:-n,y01:-d,x11:M*(v/T-1),y11:N*(v/T-1)}}function hn(){var l=cn,h=yn,D=Q(0),S=null,v=gn,R=dn,V=mn,a=null,E=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-un,c=R.apply(this,arguments)-un,W=rn(c-f),t=c>f;if(a||(a=n=E()),s<u&&(d=s,s=u,u=d),!(s>y))a.moveTo(0,0);else if(W>tn-y)a.moveTo(s*Y(f),s*O(f)),a.arc(0,0,s,f,c,!t),u>y&&(a.moveTo(u*Y(c),u*O(c)),a.arc(0,0,u,c,f,t));else{var m=f,g=c,A=f,T=c,P=W,I=W,M=V.apply(this,arguments)/2,N=M>y&&(S?+S.apply(this,arguments):j(u*u+s*s)),w=_(rn(s-u)/2,+D.apply(this,arguments)),p=w,x=w,e,r;if(N>y){var X=sn(N/u*O(M)),z=sn(N/s*O(M));(P-=X*2)>y?(X*=t?1:-1,A+=X,T-=X):(P=0,A=T=(f+c)/2),(I-=z*2)>y?(z*=t?1:-1,m+=z,g-=z):(I=0,m=g=(f+c)/2)}var Z=s*Y(m),$=s*O(m),B=u*Y(T),C=u*O(T);if(w>y){var F=s*Y(g),G=s*O(g),J=u*Y(A),K=u*O(A),q;if(W<an)if(q=pn(Z,$,J,K,F,G,B,C)){var L=Z-q[0],U=$-q[1],k=F-q[0],b=G-q[1],nn=1/O(fn((L*k+U*b)/(j(L*L+U*U)*j(k*k+b*b)))/2),en=j(q[0]*q[0]+q[1]*q[1]);p=_(w,(u-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}I>y?x>y?(e=H(J,K,Z,$,s,x,t),r=H(F,G,B,C,s,x,t),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),a.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(a.moveTo(Z,$),a.arc(0,0,s,m,g,!t)):a.moveTo(Z,$),!(u>y)||!(P>y)?a.lineTo(B,C):p>y?(e=H(B,C,F,G,u,-p,t),r=H(Z,$,J,K,u,-p,t),a.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,u,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),a.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):a.arc(0,0,u,T,A,t)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +R.apply(this,arguments))/2-an/2;return[Y(d)*n,O(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:Q(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:Q(+n),i):h},i.cornerRadius=function(n){return arguments.length?(D=typeof n=="function"?n:Q(+n),i):D},i.padRadius=function(n){return arguments.length?(S=n==null?null:typeof n=="function"?n:Q(+n),i):S},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:Q(+n),i):v},i.endAngle=function(n){return arguments.length?(R=typeof n=="function"?n:Q(+n),i):R},i.padAngle=function(n){return arguments.length?(V=typeof n=="function"?n:Q(+n),i):V},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};