@bendyline/gezel-service 1.0.7 → 1.1.0

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 (237) hide show
  1. package/dist/bin/gezeld.js +6253 -3616
  2. package/dist/handboek-content/whats-new/1.26224.md +1 -0
  3. package/dist/handboek-content/whats-new/1.26226.md +1 -0
  4. package/dist/handboek-content/whats-new/1.26231.md +1 -0
  5. package/dist/handboek-content/whats-new/1.26234.md +1 -0
  6. package/dist/handboek-content/whats-new/1.26237.md +1 -0
  7. package/dist/handboek-content/whats-new/1.26244.md +2 -1
  8. package/dist/handboek-content/whats-new/1.26247.md +88 -0
  9. package/dist/handboek-content/whats-new/whats-new-index.md +1 -0
  10. package/dist/index-store/static-index-worker.js +17 -1
  11. package/dist/index.d.ts +473 -209
  12. package/dist/index.js +6251 -3614
  13. package/dist/memory/embed-worker.js +58 -2
  14. package/dist/memory/image-embed-worker.js +8 -0
  15. package/dist/providers/llama-cpp/gguf-metadata-worker.js +2 -0
  16. package/dist/providers/mlx/python/gezel_mlx_server.py +18 -18
  17. package/dist/ui/assets/AmbientDashboardCard-Cf5fi_fY.js +1 -0
  18. package/dist/ui/assets/{AudioEngineSettings-BDrNIGGm.js → AudioEngineSettings-D3L7HOHe.js} +1 -1
  19. package/dist/ui/assets/{BenchmarksView-CHyujjs8.js → BenchmarksView-B68hrLCl.js} +1 -1
  20. package/dist/ui/assets/CatalogBrowser-DEM9t7Es.js +1 -0
  21. package/dist/ui/assets/{ChannelsSettings-Be_W1mr8.js → ChannelsSettings-DtK_k0Ul.js} +1 -1
  22. package/dist/ui/assets/ChatTimelineView-CQ4Sf4Ip.js +7 -0
  23. package/dist/ui/assets/ConfirmDialog-Dt1ed4Fh.js +1 -0
  24. package/dist/ui/assets/ConnectedAppsPanel-Cl8LEkrt.js +1 -0
  25. package/dist/ui/assets/CraftbookEditor-DEQRlQ2p.js +1 -0
  26. package/dist/ui/assets/{CraftbookScriptEditorView-DXIZYZT3.js → CraftbookScriptEditorView-DhXkkIdK.js} +1 -1
  27. package/dist/ui/assets/{CraftbookTabContent-Bm7t_b37.js → CraftbookTabContent-_oIdpQTG.js} +1 -1
  28. package/dist/ui/assets/{CraftbookToolsetSetup-DTEA-3K3.js → CraftbookToolsetSetup-BKg136L1.js} +1 -1
  29. package/dist/ui/assets/{CraftbooksView-C4X99TTe.js → CraftbooksView-Dm2zH-nW.js} +2 -2
  30. package/dist/ui/assets/{DiffpackReviewView-ClcNxtmF.js → DiffpackReviewView-EFLGJnwr.js} +1 -1
  31. package/dist/ui/assets/DocumentDetail-ClDRj2N-.js +1 -0
  32. package/dist/ui/assets/DocumentsView-ny9oieg2.js +1 -0
  33. package/dist/ui/assets/DropdownMenu-S4d9-3j3.js +1 -0
  34. package/dist/ui/assets/Ds4Settings-CeWlm5Vf.js +1 -0
  35. package/dist/ui/assets/EmbeddedChat-Hjrrgpao.js +1 -0
  36. package/dist/ui/assets/{FaceRecognitionCard-D3hdc7uU.js → FaceRecognitionCard-D7ufKqjI.js} +1 -1
  37. package/dist/ui/assets/FileMapView-DRjf59RH.js +1 -0
  38. package/dist/ui/assets/{FoldersSettings-BcNzl4vT.js → FoldersSettings-DDUhaFio.js} +1 -1
  39. package/dist/ui/assets/GezelDetail-Cph6pVGb.js +1 -0
  40. package/dist/ui/assets/{GezelJsonEditor-fOvYclu9.js → GezelJsonEditor-7vDGyBib.js} +1 -1
  41. package/dist/ui/assets/{GezellenView-BTzhHrxi.js → GezellenView-DQhcO1CP.js} +1 -1
  42. package/dist/ui/assets/{GildeUpdatesCard-Bq6XEpLP.js → GildeUpdatesCard-UKKNm_U8.js} +1 -1
  43. package/dist/ui/assets/{GithubSignInChip-CnlTCG8G.js → GithubSignInChip-DjM3qZsL.js} +1 -1
  44. package/dist/ui/assets/{HandboekMediaProvider-BfQW8_Nr.js → HandboekMediaProvider-DixaXTAH.js} +1 -1
  45. package/dist/ui/assets/HandboekView-BeNQqho9.js +1 -0
  46. package/dist/ui/assets/HistoryView-E2szGNGS.js +1 -0
  47. package/dist/ui/assets/{HomeView-CB_5TJIp.css → HomeView-CNeqCFPc.css} +1 -1
  48. package/dist/ui/assets/HomeView-CkiS3DXy.js +1 -0
  49. package/dist/ui/assets/{ImageEngineSettings-BpMfQy4f.js → ImageEngineSettings-BCKT7Gvi.js} +1 -1
  50. package/dist/ui/assets/{ImageRecognitionSettings-Ct-7-Oas.js → ImageRecognitionSettings-DD6syFez.js} +1 -1
  51. package/dist/ui/assets/IncompleteDownloads-BiPaaahS.js +1 -0
  52. package/dist/ui/assets/InstallProgressRow-DyKOI4MU.js +1 -0
  53. package/dist/ui/assets/KnowledgeCatalogsCard-B132vzRa.js +1 -0
  54. package/dist/ui/assets/KnowledgeView-CtPuIlN4.js +1 -0
  55. package/dist/ui/assets/LlamaCppSettings-D6zHcu4W.js +1 -0
  56. package/dist/ui/assets/{MarkdownField-D-0Zw7gM.js → MarkdownField-CK8K3fzj.js} +1 -1
  57. package/dist/ui/assets/MemoriesTree-DzjXzIrM.js +1 -0
  58. package/dist/ui/assets/{MicrophoneSettings-BIaFxyY_.js → MicrophoneSettings-1FH83SCq.js} +1 -1
  59. package/dist/ui/assets/MlxSettings-BYxUqFnJ.js +1 -0
  60. package/dist/ui/assets/ModelPicker-DoXPfQkQ.js +1 -0
  61. package/dist/ui/assets/{NewScriptDialog-D-gkY8TS.js → NewScriptDialog-C5X-7PMt.js} +1 -1
  62. package/dist/ui/assets/NewTaskDialog-Cyqtmigv.js +2 -0
  63. package/dist/ui/assets/{OllamaSettings-oIE2Mech.js → OllamaSettings-DkjmA-sB.js} +1 -1
  64. package/dist/ui/assets/ProjectChat-YEqUME6k.js +5 -0
  65. package/dist/ui/assets/{ProjectConnectionsTab-BZqp-oKI.js → ProjectConnectionsTab-dFCJpW93.js} +1 -1
  66. package/dist/ui/assets/ProjectGitStatusBar-CjZxG54t.js +1 -0
  67. package/dist/ui/assets/{ProjectGithubView-w8suLCsA.js → ProjectGithubView-CQ4-tmPx.js} +1 -1
  68. package/dist/ui/assets/{ProjectMailTab-DGo7eyB8.js → ProjectMailTab-NaScsZJf.js} +1 -1
  69. package/dist/ui/assets/ProjectOverviewView-ChjxbQas.js +1 -0
  70. package/dist/ui/assets/{ProjectTimeline-DRe3D9qY.js → ProjectTimeline-BZpdCisR.js} +1 -1
  71. package/dist/ui/assets/ProjectsView-J77ECk6V.js +7 -0
  72. package/dist/ui/assets/{RecommendedBadge-BKiDixnB.js → RecommendedBadge-D0m68PAu.js} +1 -1
  73. package/dist/ui/assets/{RemoteServersPanel-DGyl6-Rg.js → RemoteServersPanel-BdLOoORu.js} +1 -1
  74. package/dist/ui/assets/ScriptEditorTabs-BFvIiDFZ.js +2 -0
  75. package/dist/ui/assets/ScriptEditorView-B09rm1vz.js +5 -0
  76. package/dist/ui/assets/{ScriptsView-WQc28TmQ.js → ScriptsView-BvNAJXpo.js} +1 -1
  77. package/dist/ui/assets/{SecurityComplianceSettings-DsMEA4J3.js → SecurityComplianceSettings-DzGOnptO.js} +1 -1
  78. package/dist/ui/assets/SessionSwitcher-6okzcxT7.js +1 -0
  79. package/dist/ui/assets/SettingsView-Dur4dLhW.js +3 -0
  80. package/dist/ui/assets/SquisqIntegration-6v3yNOIP.js +2 -0
  81. package/dist/ui/assets/{StorageCleanupDialog-DHqwyMZZ.js → StorageCleanupDialog-OQlomMJD.js} +1 -1
  82. package/dist/ui/assets/{StorageUsageCard-CdT6SU51.js → StorageUsageCard-f6c6qTbM.js} +1 -1
  83. package/dist/ui/assets/Tabs-jE0Z5Tzd.js +1 -0
  84. package/dist/ui/assets/TaskTabContent-0w3kAUWR.js +1 -0
  85. package/dist/ui/assets/TasksView-BVMT4BAY.js +1 -0
  86. package/dist/ui/assets/{TerminalCodeEditor-77pBm6f3.js → TerminalCodeEditor-DO7zLKy-.js} +2 -2
  87. package/dist/ui/assets/ToolsetsEditor-Bb1wD5mV.js +8 -0
  88. package/dist/ui/assets/TransformToolbarButton-BWYkEB0d.js +5 -0
  89. package/dist/ui/assets/UnrecognizedModels-HtdMZUqK.js +1 -0
  90. package/dist/ui/assets/{VideoEngineSettings-DzMeINuv.js → VideoEngineSettings-Dq8Nw_tK.js} +1 -1
  91. package/dist/ui/assets/{WorkspaceIndexPane-DU4yd4Ai.js → WorkspaceIndexPane-fpDz4MwZ.js} +1 -1
  92. package/dist/ui/assets/{api-BX5xXiFs.js → api-BPraLwsh.js} +1 -1
  93. package/dist/ui/assets/chat-thread-memory-Be48zsyG.js +1 -0
  94. package/dist/ui/assets/chunk-6ECMNUIP-DDVjPyfK.js +15 -0
  95. package/dist/ui/assets/{chunk-6N2J7C2B-B5QIrD9m.js → chunk-6N2J7C2B-CsppiLVr.js} +1 -1
  96. package/dist/ui/assets/{chunk-A6N6IN3I-DXok09eC.js → chunk-A6N6IN3I-ofeM4l8g.js} +1 -1
  97. package/dist/ui/assets/chunk-B7GEAZBI-Divd2h1k.js +1 -0
  98. package/dist/ui/assets/chunk-DXYWKZ52-BXcAlClu.js +1 -0
  99. package/dist/ui/assets/chunk-FLR2ARKC-D7wrvQgT.js +2 -0
  100. package/dist/ui/assets/chunk-IIQYS2YH-DKZhWMpn.js +1 -0
  101. package/dist/ui/assets/{chunk-ILCJ3WFD-WRukZ7R1.js → chunk-ILCJ3WFD-CLZxw4Ge.js} +3 -3
  102. package/dist/ui/assets/chunk-OBADJV7C-CDVOcmYt.js +1 -0
  103. package/dist/ui/assets/chunk-Q77KNJIN-BIDRf0aP.js +6 -0
  104. package/dist/ui/assets/chunk-S5PCVMKU-Df5XzhSE.js +6 -0
  105. package/dist/ui/assets/chunk-UBFT2CDQ-FexGDigd.js +31 -0
  106. package/dist/ui/assets/{chunk-USU6HTKB-D5FmDzJU.js → chunk-USU6HTKB-B_p-YcDp.js} +1 -1
  107. package/dist/ui/assets/chunk-VKXOZTYP-BoVvWSBR.js +5 -0
  108. package/dist/ui/assets/{chunk-6RQOV3B3-CwvKotJw.js → chunk-VPWPEMZJ-DRKoa_j0.js} +1 -1
  109. package/dist/ui/assets/{chunk-WATAOG4Y-DXg2lov5.js → chunk-WATAOG4Y-C1EXVPmG.js} +1 -1
  110. package/dist/ui/assets/{container-B7jJtK5V.js → container-Ce94efbg.js} +1 -1
  111. package/dist/ui/assets/csv-62UGQMzZ.js +1 -0
  112. package/dist/ui/assets/data-B2kHjlc5.js +1 -0
  113. package/dist/ui/assets/dist-B9-VrAP8.js +2 -0
  114. package/dist/ui/assets/dist-BaHut5iX.js +2 -0
  115. package/dist/ui/assets/dist-BqGwkOe5.js +225 -0
  116. package/dist/ui/assets/dist-ZnIgkoEi.js +4 -0
  117. package/dist/ui/assets/{dist-BHl1ZAVG.js → dist-l6uUFZMV.js} +2 -2
  118. package/dist/ui/assets/dist-pLLFUPO-.js +1 -0
  119. package/dist/ui/assets/{doc-s6H7T0IO.js → doc-Dr5K49bx.js} +28 -28
  120. package/dist/ui/assets/document-companion-BQk2kS0F.js +1 -0
  121. package/dist/ui/assets/document-import-QoM9UxJr.js +1 -0
  122. package/dist/ui/assets/docx-sXa1Rf41.js +2 -0
  123. package/dist/ui/assets/{epub-B98SgHBz.js → epub-RopMP0ec.js} +4 -4
  124. package/dist/ui/assets/{export-options-Bu-tI6og.js → export-options-f7PKjEBb.js} +1 -1
  125. package/dist/ui/assets/extract-UTAOG7LV-4WDRw1o4.js +1 -0
  126. package/dist/ui/assets/file-browser-c2tf4MIb.js +5 -0
  127. package/dist/ui/assets/html-BGVOMhkv.js +253 -0
  128. package/dist/ui/assets/icons-DWaUNQbT.js +1 -0
  129. package/dist/ui/assets/images-JLBFCDD4-6JitW0hD.js +1 -0
  130. package/dist/ui/assets/index-B8NcxqcR.css +1 -0
  131. package/dist/ui/assets/index-C0DYtvfg.js +34 -0
  132. package/dist/ui/assets/index-J8TOMdvV.js +2 -0
  133. package/dist/ui/assets/{infer-kCLH1C8z.js → infer-LEGOsu64.js} +2 -2
  134. package/dist/ui/assets/ironcalc-BAi5gOlE.js +3 -0
  135. package/dist/ui/assets/layouts-2A7QNF6Y-CVwP7noP.js +1 -0
  136. package/dist/ui/assets/{mail-link-CI6YD6k2.js → mail-link-DXkmCd5b.js} +1 -1
  137. package/dist/ui/assets/markdown-baseline-9B52XlX2.js +1 -0
  138. package/dist/ui/assets/{markdown-Bi9b5f5Y.js → markdown-ryKA_OmY.js} +1 -1
  139. package/dist/ui/assets/materialize-A34OZGEU-xNNKzytx.js +1 -0
  140. package/dist/ui/assets/model-inventory-ykSm_IT5.js +1 -0
  141. package/dist/ui/assets/{model-quantization-BDzrELN_.js → model-quantization-CLO7XLoF.js} +1 -1
  142. package/dist/ui/assets/{monaco-base-BiVSa1J-.js → monaco-base-B1H1U1Sw.js} +1 -1
  143. package/dist/ui/assets/{monaco-setup-UeltVkg_.js → monaco-setup-DjhrGQui.js} +1 -1
  144. package/dist/ui/assets/{new-project-meta-0xhggGA_.js → new-project-meta-_f9sfcRX.js} +1 -1
  145. package/dist/ui/assets/outside-in-D73N1g_b.js +3 -0
  146. package/dist/ui/assets/{pdf-DgTjy3rN.js → pdf-BOjVDlCK.js} +3 -3
  147. package/dist/ui/assets/{pending-drafts-YVW6X55O.js → pending-drafts-B11MKQ9R.js} +1 -1
  148. package/dist/ui/assets/{poppetje-Ce-02Aqi.js → poppetje-DLB8uevw.js} +2 -2
  149. package/dist/ui/assets/pptx-BuxyNxQh.js +6 -0
  150. package/dist/ui/assets/primitives-CWrGZpPI.js +41 -0
  151. package/dist/ui/assets/run-export-ChaMXrKS.js +23 -0
  152. package/dist/ui/assets/squisq-formats-aAdypXoy.js +1 -0
  153. package/dist/ui/assets/standalone-source-q_Zzd1bd.js +11 -0
  154. package/dist/ui/assets/storage-D8pE2zg0.js +1 -0
  155. package/dist/ui/assets/styles-BhnF3s2q.css +1 -0
  156. package/dist/ui/assets/styles-CKVKwqoQ.js +550 -0
  157. package/dist/ui/assets/table-fcouR4db.js +1 -0
  158. package/dist/ui/assets/{terminal-monaco-setup-DNoK2tN4.js → terminal-monaco-setup-BAzrVzeR.js} +1 -1
  159. package/dist/ui/assets/{useCompactLayout-BarJPYcv.js → useCompactLayout-Dtolvzye.js} +0 -0
  160. package/dist/ui/assets/{useCopilotAvailability-BH1nLXQI.js → useCopilotAvailability-3xZvKgTF.js} +1 -1
  161. package/dist/ui/assets/{useDiffpacks-CK8W_OD_.js → useDiffpacks-Dsnr0wtX.js} +1 -1
  162. package/dist/ui/assets/{useGitSync-DWxX5-7K.js → useGitSync-BCTptQsp.js} +1 -1
  163. package/dist/ui/assets/{useShowWorkInProgressFeatures-DwwviLRO.js → useShowWorkInProgressFeatures-BhDNuQiU.js} +1 -1
  164. package/dist/ui/assets/{useTotalRamBytes-WoN_mi-V.js → useTotalRamBytes-DIx-_pf8.js} +1 -1
  165. package/dist/ui/assets/wasm-DdxEDD2H.js +1 -0
  166. package/dist/ui/assets/wasm_bg-DW9Xt_vt.wasm +0 -0
  167. package/dist/ui/assets/xlsx-DyBGuAO1.js +4 -0
  168. package/dist/ui/index.html +19 -18
  169. package/package.json +11 -11
  170. package/dist/ui/assets/AmbientDashboardCard-C1Ee-FKZ.js +0 -1
  171. package/dist/ui/assets/CatalogBrowser-Bz8ZtxPn.js +0 -1
  172. package/dist/ui/assets/ChatTimelineView-Do9EryEH.js +0 -7
  173. package/dist/ui/assets/ConfirmDialog-BHFs6vmJ.js +0 -1
  174. package/dist/ui/assets/ConnectedAppsPanel-BtMayq0R.js +0 -1
  175. package/dist/ui/assets/CraftbookEditor-D5jTzWwF.js +0 -1
  176. package/dist/ui/assets/DocumentDetail-CPU51d04.js +0 -1
  177. package/dist/ui/assets/DocumentsView-B6OyjvJ0.js +0 -1
  178. package/dist/ui/assets/DropdownMenu-D5fCzIrh.js +0 -1
  179. package/dist/ui/assets/Ds4Settings-CrUM_KGP.js +0 -1
  180. package/dist/ui/assets/EmbeddedChat-ue9ia-WY.js +0 -1
  181. package/dist/ui/assets/FileMapView-CxvfDLGA.js +0 -1
  182. package/dist/ui/assets/GezelDetail-DHuqBK55.js +0 -1
  183. package/dist/ui/assets/HandboekView-CPnnyj29.js +0 -1
  184. package/dist/ui/assets/HistoryView-B4VAfEMe.js +0 -1
  185. package/dist/ui/assets/HomeView-ccH60J6f.js +0 -1
  186. package/dist/ui/assets/KnowledgeCatalogsCard-Bi5Rx9Iz.js +0 -1
  187. package/dist/ui/assets/KnowledgeView-DAwjwLZo.js +0 -1
  188. package/dist/ui/assets/LlamaCppSettings-Ceyk9pDP.js +0 -1
  189. package/dist/ui/assets/MemoriesTree-BKZEPJpm.js +0 -1
  190. package/dist/ui/assets/MlxSettings-CG3wfuc3.js +0 -1
  191. package/dist/ui/assets/ModelPicker-CCBVjLMS.js +0 -1
  192. package/dist/ui/assets/NewPathDialog-D4jnNBfP.js +0 -1
  193. package/dist/ui/assets/NewTaskDialog-Ox9D612Z.js +0 -2
  194. package/dist/ui/assets/ProjectChat-DMwKnkW-.js +0 -5
  195. package/dist/ui/assets/ProjectGitStatusBar-C6bkCSby.js +0 -1
  196. package/dist/ui/assets/ProjectOverviewView-NNwXd_QQ.js +0 -1
  197. package/dist/ui/assets/ProjectsView-SBPgYOq8.js +0 -7
  198. package/dist/ui/assets/ScriptEditorTabs-paocQ6dj.js +0 -2
  199. package/dist/ui/assets/ScriptEditorView-N9zSLqqi.js +0 -5
  200. package/dist/ui/assets/SessionSwitcher-C8te7YSe.js +0 -1
  201. package/dist/ui/assets/SettingsView-Brl4JQkW.js +0 -3
  202. package/dist/ui/assets/Tabs-BAY1Q79B.js +0 -1
  203. package/dist/ui/assets/TaskTabContent-CNPJ4DQj.js +0 -1
  204. package/dist/ui/assets/TasksView-DuMjFS8S.js +0 -1
  205. package/dist/ui/assets/ToolsetsEditor-BdxHnIBj.js +0 -8
  206. package/dist/ui/assets/TransformToolbarButton-CVg5nz36.js +0 -5
  207. package/dist/ui/assets/UnrecognizedModels-Cw9Ku_bW.js +0 -1
  208. package/dist/ui/assets/chat-thread-memory-CZGcwgGo.js +0 -1
  209. package/dist/ui/assets/chunk-6ECMNUIP-C1kohb1U.js +0 -15
  210. package/dist/ui/assets/chunk-AONELFLA-Cv2nS9ga.js +0 -1
  211. package/dist/ui/assets/chunk-IIQYS2YH-Dxg6MAfT.js +0 -1
  212. package/dist/ui/assets/chunk-MIKKUKOD-XIkmalSN.js +0 -31
  213. package/dist/ui/assets/chunk-NNJLSQPW-DJA6camf.js +0 -5
  214. package/dist/ui/assets/chunk-S5PCVMKU-DbCZ5AUH.js +0 -6
  215. package/dist/ui/assets/csv-xmd1_Aqd.js +0 -4
  216. package/dist/ui/assets/dist-BPx-FyRH.js +0 -222
  217. package/dist/ui/assets/dist-Bvo52IGx.js +0 -1
  218. package/dist/ui/assets/dist-D5aoNQwk.js +0 -2
  219. package/dist/ui/assets/docx-Cj4A9MhC.js +0 -2
  220. package/dist/ui/assets/extract-UTAOG7LV-C4b7ycaL.js +0 -1
  221. package/dist/ui/assets/file-browser-80qWoVju.js +0 -5
  222. package/dist/ui/assets/html-C9TlzI57.js +0 -253
  223. package/dist/ui/assets/icons-C9dD-bDi.js +0 -1
  224. package/dist/ui/assets/images-ESPQKVTW-D7SgdVJ_.js +0 -1
  225. package/dist/ui/assets/index-D1m4Wx8V.css +0 -1
  226. package/dist/ui/assets/index-DXWR4qW1.js +0 -34
  227. package/dist/ui/assets/layouts-2A7QNF6Y-De2t-YXl.js +0 -1
  228. package/dist/ui/assets/markdown-baseline-HMqF2ChK.js +0 -1
  229. package/dist/ui/assets/outside-in-BFVUUcLa.js +0 -3
  230. package/dist/ui/assets/pptx-6ChgUEf4.js +0 -6
  231. package/dist/ui/assets/primitives-DEsn1shf.js +0 -41
  232. package/dist/ui/assets/run-export-BrYhHj1O.js +0 -23
  233. package/dist/ui/assets/standalone-source-D6mbpa3h.js +0 -11
  234. package/dist/ui/assets/storage-fn4FCEVK.js +0 -1
  235. package/dist/ui/assets/styles-C0EoNJbk.css +0 -1
  236. package/dist/ui/assets/styles-CKr_yrbn.js +0 -541
  237. package/dist/ui/assets/xlsx-DH7sTb3W.js +0 -4
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{J as r}from"./dist-BPx-FyRH.js";import{t as i}from"./api-BX5xXiFs.js";import{lt as a}from"./doc-s6H7T0IO.js";import{n as ee}from"./chunk-MIKKUKOD-XIkmalSN.js";import"./markdown-Bi9b5f5Y.js";import{P as o}from"./chunk-6ECMNUIP-C1kohb1U.js";import{H as s,K as c,M as l,ft as u,j as d,pt as f}from"./index-DXWR4qW1.js";import{n as te}from"./composer-prefill-CbG_i1Rx.js";var p=e(t(),1),m=n(),h=`gezel:knowledge:catalog`,g=`gezel:knowledge:document`,_=50;function v(e){let t=new Map(e.map(e=>[e.id,{...e,children:[]}])),n=[];for(let e of t.values()){let r=e.parentId?t.get(e.parentId):void 0;r?r.children.push(e):n.push(e)}return n}function y(){let[e,t]=(0,p.useState)(null),[n,y]=(0,p.useState)(()=>{try{return window.localStorage.getItem(h)}catch{return null}}),[b,x]=(0,p.useState)([]),[S,C]=(0,p.useState)(null),[w,T]=(0,p.useState)(null),[E,ne]=(0,p.useState)(0),[D,O]=(0,p.useState)(!1),[k,A]=(0,p.useState)(()=>{try{return window.localStorage.getItem(g)}catch{return null}}),[j,M]=(0,p.useState)(null),[N,P]=(0,p.useState)(!1),[F,I]=(0,p.useState)(null),[L,R]=(0,p.useState)(``),[z,B]=(0,p.useState)(null),[V,H]=(0,p.useState)(!1),[U,W]=(0,p.useState)(!1),G=(0,p.useRef)(null),K=u()===`light`?d:void 0;(0,p.useEffect)(()=>{let e=!0,n=c();n&&(y(n.catalogId),n.documentId&&A(n.documentId));let r=()=>{i.listKnowledgeCatalogs().then(n=>{if(!e)return;let r=n.catalogs.filter(e=>e.mounted);t(r),y(e=>(e&&r.some(t=>t.ref.catalogId===e)?e:null)??r[0]?.ref.catalogId??null)}).catch(()=>{e&&t([])})};r(),window.addEventListener(`gezel:knowledge-catalogs-updated`,r);let a=e=>{let t=e.detail;t?.catalogId&&(y(t.catalogId),t.documentId&&A(t.documentId))};return window.addEventListener(`gezel:open-knowledge-document`,a),()=>{e=!1,window.removeEventListener(`gezel:knowledge-catalogs-updated`,r),window.removeEventListener(`gezel:open-knowledge-document`,a)}},[]),(0,p.useEffect)(()=>{try{n&&window.localStorage.setItem(h,n)}catch{}},[n]),(0,p.useEffect)(()=>{if(!n)return;let e=!0;return x([]),C(null),i.knowledgeCatalogTopics(n).then(t=>{e&&x(t.topics)}).catch(()=>{}),()=>{e=!1}},[n]);let q=(0,p.useCallback)(async e=>{if(!n)return;let t=await i.knowledgeCatalogDocuments(n,{...S?{topicId:S}:{},offset:e,limit:_});ne(t.total),T(n=>e===0||!n?t.documents:[...n,...t.documents])},[n,S]);(0,p.useEffect)(()=>{T(null),q(0).catch(()=>T([]))},[q]),(0,p.useEffect)(()=>{if(!n||!k){M(null);return}let e=!0;P(!0),I(null),i.readKnowledgeDocument(n,k).then(t=>{e&&M(t)}).catch(t=>{e&&I(t instanceof Error?t.message:String(t))}).finally(()=>{e&&P(!1)});try{window.localStorage.setItem(g,k)}catch{}return()=>{e=!1}},[n,k]),(0,p.useEffect)(()=>{G.current&&window.clearTimeout(G.current);let e=L.trim();if(!e){B(null),H(!1);return}return H(!0),G.current=window.setTimeout(()=>{i.searchKnowledge({query:e,maxResults:20,...n?{catalogs:[n]}:{}}).then(e=>{B(e.results)}).catch(()=>{B([])}).finally(()=>H(!1))},250),()=>{G.current&&window.clearTimeout(G.current)}},[L,n]);let J=(0,p.useMemo)(()=>e?.find(e=>e.ref.catalogId===n)??null,[e,n]),Y=(0,p.useMemo)(()=>v(b),[b]),X=(0,p.useMemo)(()=>new Map(b.map(e=>[e.id,e.name])),[b]),Z=(0,p.useMemo)(()=>{if(!j)return null;try{return a(ee(j.markdown),{articleId:j.id})}catch{return null}},[j]),Q=(0,p.useMemo)(()=>n&&j?r({catalogId:n,documentId:j.id}):null,[n,j]),re=(0,p.useCallback)(()=>{Q&&navigator.clipboard?.writeText(Q).then(()=>{W(!0),window.setTimeout(()=>W(!1),2e3)})},[Q]),ie=(0,p.useCallback)(()=>{!Q||!j||(te(`default`,`I'm reading "${j.title}" (${Q}). Can you help me with a question about it?\n\n`),s({kind:`project`,id:`default`}))},[Q,j]),ae=(0,p.useCallback)(()=>{f(`knowledge`),s({kind:`area`,area:`settings`})},[]);if(e!==null&&e.length===0)return(0,m.jsx)(`div`,{className:`knowledge-view`,"data-testid":`knowledge-view`,children:(0,m.jsxs)(`div`,{className:`knowledge-empty`,style:{gridColumn:`1 / -1`},children:[(0,m.jsx)(`h2`,{children:`Knowledge`}),(0,m.jsx)(`p`,{className:`muted`,children:`No knowledge catalogs are installed yet. A catalog is a searchable, citable reference library — install one and your gezellen can look things up and cite their sources.`}),(0,m.jsx)(`button`,{type:`button`,onClick:ae,children:`Open knowledge settings`})]})});let $=(e,t)=>(0,m.jsxs)(`li`,{children:[(0,m.jsxs)(`button`,{type:`button`,className:`knowledge-topic-row`,"aria-current":S===e.id?`true`:void 0,onClick:()=>{C(t=>t===e.id?null:e.id),R(``)},children:[(0,m.jsx)(`span`,{children:e.name}),(0,m.jsx)(`span`,{className:`knowledge-topic-count`,children:e.documentCount})]}),e.children.length>0&&(0,m.jsx)(`ul`,{children:e.children.map(e=>$(e,t+1))})]},e.id);return(0,m.jsxs)(`div`,{className:`knowledge-view`,"data-testid":`knowledge-view`,children:[(0,m.jsxs)(`nav`,{className:`knowledge-rail`,"aria-label":`Knowledge catalogs and topics`,children:[e&&e.length>1&&(0,m.jsx)(`select`,{"aria-label":`Catalog`,value:n??``,onChange:e=>{y(e.target.value),A(null)},children:e.map(e=>(0,m.jsx)(`option`,{value:e.ref.catalogId,children:e.name??e.ref.catalogId},e.ref.catalogId))}),J&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`h2`,{className:`knowledge-catalog-name`,children:J.name??n}),(0,m.jsxs)(`p`,{className:`knowledge-catalog-meta`,children:[J.documents??`?`,` documents · `,J.license??``,J.ref.version?` · v${J.ref.version}`:``]})]}),(0,m.jsx)(`input`,{type:`search`,className:`knowledge-rail-search`,placeholder:`Search this catalog…`,"aria-label":`Search knowledge`,value:L,onChange:e=>R(e.target.value)}),(0,m.jsx)(`ul`,{className:`knowledge-topics`,children:Y.map(e=>$(e,0))})]}),(0,m.jsx)(`section`,{className:`knowledge-list`,"aria-label":`Documents`,children:L.trim()?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{className:`knowledge-list-header`,children:`Search results`}),V&&(0,m.jsx)(`p`,{className:`muted small`,style:{padding:`0 1rem`},children:`Searching…`}),!V&&z?.length===0&&(0,m.jsxs)(`p`,{className:`muted small`,style:{padding:`0 1rem`},children:[`No results for “`,L.trim(),`”.`]}),(0,m.jsx)(`ul`,{className:`knowledge-doc-list`,children:(z??[]).map(e=>(0,m.jsx)(`li`,{children:(0,m.jsxs)(`button`,{type:`button`,className:`knowledge-doc-row`,"aria-current":e.documentId===k?`true`:void 0,onClick:()=>{e.documentId&&A(e.documentId)},children:[(0,m.jsx)(`span`,{className:`knowledge-doc-title`,children:e.title}),e.snippet&&(0,m.jsx)(`span`,{className:`knowledge-doc-summary`,children:e.snippet})]})},e.id))})]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`div`,{className:`knowledge-list-header`,children:S?X.get(S)??`Documents`:`All documents`}),w===null&&(0,m.jsx)(`p`,{className:`muted small`,style:{padding:`0 1rem`},children:`Loading…`}),(0,m.jsx)(`ul`,{className:`knowledge-doc-list`,children:(w??[]).map(e=>(0,m.jsx)(`li`,{children:(0,m.jsxs)(`button`,{type:`button`,className:`knowledge-doc-row`,"aria-current":e.id===k?`true`:void 0,onClick:()=>A(e.id),children:[(0,m.jsx)(`span`,{className:`knowledge-doc-title`,children:e.title}),e.summary&&(0,m.jsx)(`span`,{className:`knowledge-doc-summary`,children:e.summary})]})},e.id))}),w&&w.length<E&&(0,m.jsx)(`button`,{type:`button`,className:`knowledge-list-more`,disabled:D,onClick:()=>{O(!0),q(w.length).finally(()=>O(!1))},children:D?`Loading…`:`Show more (${E-w.length} left)`})]})}),(0,m.jsx)(`section`,{className:`knowledge-reader`,"aria-label":`Article`,children:j?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(`header`,{className:`knowledge-reader-header`,children:[(0,m.jsx)(`h2`,{children:j.title}),(0,m.jsxs)(`p`,{className:`knowledge-reader-meta`,children:[X.get(j.topicId)??j.topicId,j.sourceUpdatedAt?` · snapshot ${j.sourceUpdatedAt.slice(0,10)}`:``]})]}),(0,m.jsx)(`div`,{className:`knowledge-reader-body`,children:Z?(0,m.jsx)(o,{doc:Z,className:`gezel-article-view`,theme:l,...K?{surface:K}:{},imageDisplayMode:`inline`,showCover:!1}):(0,m.jsx)(`p`,{className:`error small`,children:`This document could not be rendered.`})}),(0,m.jsxs)(`footer`,{className:`knowledge-reader-footer`,children:[(0,m.jsxs)(`span`,{children:[J?.license??``,j.attribution?.text?` · ${j.attribution.text}`:``]}),(0,m.jsxs)(`span`,{className:`knowledge-footer-actions`,children:[(0,m.jsx)(`button`,{type:`button`,onClick:re,children:U?`Copied`:`Copy citation`}),j.sourceUrl&&(0,m.jsx)(`a`,{href:j.sourceUrl,target:`_blank`,rel:`noreferrer`,children:(0,m.jsx)(`button`,{type:`button`,children:`Open source`})}),(0,m.jsx)(`button`,{type:`button`,onClick:ie,children:`Ask a gezel about this`})]})]})]}):(0,m.jsx)(`div`,{className:`knowledge-empty`,children:N?(0,m.jsx)(`p`,{className:`muted`,children:`Loading…`}):F?(0,m.jsx)(`p`,{className:`error`,children:F}):(0,m.jsx)(`p`,{className:`placeholder`,children:`Pick a document on the left to read it here.`})})})]})}export{y as KnowledgeView};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{B as r,Gt as i,M as a,O as o,mt as s,rt as c,ut as l,yt as u,z as d}from"./dist-BPx-FyRH.js";import{t as f}from"./api-BX5xXiFs.js";import{t as p}from"./model-context-DBqdK0PS.js";import{r as m}from"./model-memory-copy-CeuXAj-T.js";import{t as h}from"./ConfirmDialog-BHFs6vmJ.js";import{Et as g,Tt as _,wt as v,xt as y}from"./index-DXWR4qW1.js";import{t as b}from"./CatalogBrowser-Bz8ZtxPn.js";import{t as x}from"./LicenseButton-D3VmcVG1.js";import{a as S,i as ee,n as C,o as te,r as ne,s as re,t as ie}from"./UnrecognizedModels-Cw9Ku_bW.js";import{t as w}from"./local-engine-label-BR-PGVFE.js";import{a as T,i as E,n as D,r as ae,t as oe}from"./model-quantization-BDzrELN_.js";var O=e(t(),1),k=n();function A(e){return{usableBytes:e.usableBytes,totalRamBytes:e.totalRamBytes,gpuVramBytes:e.gpuMemoryKind===`integrated`?null:e.gpuVramBytes,...e.budgetBytes===void 0?{}:{admissibleBytes:e.budgetBytes}}}function j(e,t){let{totalRamBytes:n,gpuVramBytes:i}=A(t);return r(e,{ctxTokens:u({totalRamBytes:n,gpuVramBytes:i})})}function M(e,t){return a({residentBytes:d(e.llamaCpp.approxSizeBytes,{mmprojBytes:e.llamaCpp.mmproj?.sizeBytes})+j(e,t),isMoE:l(e.tags),...A(t)})}function N(e){return{platform:e.source===`darwin-unified`?`darwin`:`other`,gpuVramBytes:e.gpuVramBytes,...e.gpuMemoryKind?{gpuMemoryKind:e.gpuMemoryKind}:{},totalRamBytes:e.totalRamBytes,usableBytes:e.usableBytes,...e.budgetBytes===void 0?{}:{budgetBytes:e.budgetBytes}}}function se(e){return`~${m(e)}`}function ce(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleDateString(void 0,{year:`numeric`,month:`short`})}function P(e){return e.kind!==`chat-model`||!e.llamaCpp?null:e}var le={"mix of experts":`Only a fraction of the model's parameters run per token, so it's faster than a dense model of the same nominal size.`,vision:`Can accept images alongside text.`,tools:`Supports function/tool calling via the API.`,multimodal:`Handles multiple input types (text + images).`,large:`Heavy model — needs a lot of memory and runs more slowly.`,small:`Compact model — runs quickly on modest hardware.`};function F({onModelsChanged:e,compact:t=!1}){let[n,r]=(0,O.useState)([]),[u,m]=(0,O.useState)(null),[w,T]=(0,O.useState)(!0),[E,F]=(0,O.useState)([]),[I,L]=(0,O.useState)([]),[R,z]=(0,O.useState)(new Map),[B,V]=(0,O.useState)(null),[H,U]=(0,O.useState)(null),[W,G]=(0,O.useState)(null),[K,q]=(0,O.useState)(null),[J,fe]=(0,O.useState)(null),[Y,pe]=(0,O.useState)(!1),[me,he]=(0,O.useState)(null),[ge,_e]=(0,O.useState)(null),[ve,ye]=(0,O.useState)(!1),[be,xe]=(0,O.useState)([]),[Se,Ce]=(0,O.useState)(new Map),[we,Te]=(0,O.useState)([]),Ee=(0,O.useRef)([]),X=(0,O.useRef)(null),De=(0,O.useRef)(!1),Z=(0,O.useCallback)(async()=>{try{let e=await f.listModelFitness();Ce(new Map(e.records.map(e=>[e.key,e]))),Te(e.probing),Ee.current=e.probing}catch{}},[]),Oe=(0,O.useCallback)(async(e,t)=>{_e(e);try{let n=await f.getConfig();await f.updateConfig({nativeVision:{...n.nativeVision??{},[e]:t}}),await Q()}catch{}finally{_e(null)}},[]),ke=(0,O.useCallback)(async()=>{try{let e=await f.listIncompleteLlamaCppModels();F(e.incomplete??[])}catch{}},[]),Q=(0,O.useCallback)(()=>{if(X.current)return X.current;T(!0);let e=(async()=>{try{let e=await f.listLlamaCppModels();r(e.models),L(e.unrecognized??[]),m(null)}catch(e){m(e instanceof Error?e.message:String(e))}finally{T(!1)}Z(),ke()})();return X.current=e,e.then(()=>{X.current===e&&(X.current=null)}),e},[Z,ke]);(0,O.useEffect)(()=>{Q(),f.getMemoryProfile().then(e=>fe(e)).catch(()=>{}),f.getModelContextOverrides(`llama-cpp`).then(()=>ye(!0)).catch(()=>ye(!1))},[Q]),(0,O.useEffect)(()=>{let e=e=>{g(e)===`llama-cpp`&&Q()};return window.addEventListener(v,e),()=>window.removeEventListener(v,e)},[Q]),(0,O.useEffect)(()=>{let e=!1,t=async()=>{try{let t=await f.listLlamaCppActiveInstalls();if(e)return;z(e=>{let n=new Map(e),r=new Set;for(let e of t.installs){r.add(e.catalogId);let t=n.get(e.catalogId);t&&t.origin===`local`||n.set(e.catalogId,{catalogId:e.catalogId,bytesWritten:e.bytesWritten,totalBytes:e.totalBytes,phase:e.phase,origin:`remote`})}for(let[e,t]of n)t.origin===`remote`&&!r.has(e)&&n.delete(e);return n});let n=De.current;De.current=t.installs.length>0,n&&t.installs.length===0&&Q()}catch{}};t();let n=setInterval(()=>void t(),2e3);return()=>{e=!0,clearInterval(n)}},[Q]),(0,O.useEffect)(()=>{let e=!1,t,n=async()=>{await Z(),!e&&(t=setTimeout(()=>void n(),Ee.current.length>0?2e3:15e3))};return n(),()=>{e=!0,t&&clearTimeout(t)}},[Z]);let Ae=(0,O.useCallback)((e,t)=>{if(t.type===`progress`)z(n=>{let r=n.get(e);if(!r)return n;let i=new Map(n),{retrying:a,error:o,...s}=r;return i.set(e,{...s,bytesWritten:t.bytesWritten,totalBytes:t.totalBytes||r.totalBytes,phase:`downloading`}),i});else if(t.type===`retrying`)z(n=>{let r=n.get(e);if(!r)return n;let i=new Map(n);return i.set(e,{...r,retrying:{attempt:t.attempt,maxAttempts:t.maxAttempts,delayMs:t.delayMs,reason:t.reason}}),i});else if(t.type===`verifying`)z(t=>{let n=t.get(e);if(!n)return t;let r=new Map(t);return r.set(e,{...n,phase:`verifying`}),r});else if(t.type===`extracting-metadata`)z(t=>{let n=t.get(e);if(!n)return t;let r=new Map(t);return r.set(e,{...n,phase:`extracting-metadata`}),r});else if(t.type===`done`)t.warning&&V({id:t.id,message:t.warning});else if(t.type===`error`){if(t.mismatch){let n=t.mismatch.file;z(t=>{let n=new Map(t);return n.delete(e),n}),G({catalogId:e,file:n});return}z(n=>{let r=n.get(e);if(!r)return n;let i=new Map(n);return i.set(e,{...r,error:t.error,retrying:void 0}),i}),U(t.error)}},[]),$=(0,O.useCallback)((t,n)=>{if(R.has(t))return;U(null),G(null);let r=new AbortController;z(e=>{let n=new Map(e);return n.set(t,{catalogId:t,bytesWritten:0,totalBytes:0,phase:`downloading`,origin:`local`,controller:r}),n}),(async()=>{try{await f.installLlamaCppModel(t,e=>Ae(t,e),r.signal,n?.skipSha?{skipSha:!0}:void 0),_(`llama-cpp`)}catch(e){if(!r.signal.aborted){let n=`download failed: ${de(e)}`;U(n),z(e=>{let r=e.get(t);if(!r)return e;let i=new Map(e);return i.set(t,{...r,error:r.error??n,retrying:void 0}),i})}}finally{z(e=>{let n=new Map(e),r=n.get(t);return r?.error?(n.set(t,{...r,controller:void 0}),n):(n.delete(t),n)}),Q(),e?.()}})()},[R,Q,Ae,e]),je=(0,O.useCallback)(e=>{G(null),$(e,{skipSha:!0})},[$]),Me=(0,O.useCallback)(e=>{R.get(e)?.controller?.abort(),f.cancelLlamaCppModelInstall(e).catch(()=>{}),z(t=>{let n=new Map(t);return n.delete(e),n})},[R]),Ne=(0,O.useCallback)(async()=>{let t=K;if(t){q(null),m(null),r(e=>e.filter(e=>e.id!==t)),F(e=>e.filter(e=>e.id!==t)),L(e=>e.filter(e=>e.id!==t));try{await f.deleteLlamaCppModel(t),_(`llama-cpp`),await Q(),e?.()}catch(e){m(`delete failed: ${de(e)}`),Q()}}},[K,Q,e]),Pe=(0,O.useMemo)(()=>new Set(n.map(e=>e.id)),[n]),Fe=(0,O.useMemo)(()=>new Set(I.map(e=>e.id)),[I]),Ie=(0,O.useMemo)(()=>{let e=new Map;for(let t of be){let n=P(t.manifest);n&&e.set(n.id,n)}return e},[be]);return(0,k.jsxs)(`div`,{className:`ollama-model-manager`,children:[R.size>0&&(0,k.jsxs)(`div`,{className:`ollama-section`,children:[(0,k.jsx)(`h4`,{children:`Downloading…`}),(0,k.jsx)(`div`,{className:`ollama-pull-list`,children:Array.from(R.values()).map(e=>(0,k.jsx)(ue,{inst:e,onCancel:()=>Me(e.catalogId),onRetry:()=>{z(t=>{let n=new Map(t);return n.delete(e.catalogId),n}),U(null),$(e.catalogId)}},e.catalogId))})]}),(0,k.jsx)(ie,{items:I.filter(e=>!R.has(e.id)),onUpdate:e=>$(e),onRemove:e=>q(e)}),(0,k.jsx)(re,{items:E.filter(e=>!R.has(e.id)),onResume:e=>$(e),onDelete:e=>q(e)}),W&&(0,k.jsxs)(`div`,{className:`ollama-section`,children:[(0,k.jsxs)(`div`,{className:`gz-status-pill gz-status-pill--warn`,style:{marginBottom:`0.5rem`},children:[`⚠ `,(0,k.jsx)(`code`,{children:W.catalogId}),` is newer on Hugging Face than the version Gezel knows about`]}),(0,k.jsxs)(`p`,{style:{marginBottom:`0.5rem`},children:[`The file `,(0,k.jsx)(`code`,{children:W.file}),` changed upstream, so its checksum no longer matches what this version of Gezel pinned. This is almost always a harmless upstream fix — model authors routinely re-publish chat templates and tokenizer configs — but we can't verify it automatically. You can download the current version now, or wait for a Gezel update with a refreshed catalog.`]}),(0,k.jsxs)(`div`,{style:{display:`flex`,gap:`0.75rem`},children:[(0,k.jsx)(`button`,{type:`button`,className:`gz-link-button`,onClick:()=>je(W.catalogId),children:`Download anyway`}),(0,k.jsx)(`button`,{type:`button`,className:`gz-link-button`,onClick:()=>G(null),children:`Dismiss`})]})]}),H&&(0,k.jsx)(`div`,{className:`ollama-section`,children:(0,k.jsx)(`p`,{className:`error`,style:{marginBottom:`0.5rem`},children:H})}),B&&(0,k.jsx)(`div`,{className:`ollama-section`,children:(0,k.jsxs)(`div`,{className:`gz-status-pill gz-status-pill--warn`,style:{marginBottom:`0.5rem`},children:[`⚠ `,B.id,`: `,B.message]})}),!t&&(0,k.jsx)(C,{engine:`llama-cpp`,onModelsChanged:e}),(w||n.length>0||u)&&(0,k.jsxs)(`div`,{className:`ollama-section`,children:[(0,k.jsx)(`h4`,{children:t?`Models on this device`:`Local models`}),w&&n.length===0&&!u&&(0,k.jsx)(`p`,{className:`muted small`,"aria-live":`polite`,children:`Checking shared models… Large models can take a few minutes the first time; later starts use the local verification cache.`}),u&&(0,k.jsx)(`p`,{className:`error`,children:u}),n.length>0&&(0,k.jsx)(`div`,{className:`ollama-model-table-wrap`,children:(0,k.jsxs)(`table`,{className:`ollama-model-table`,children:[(0,k.jsxs)(`colgroup`,{children:[(0,k.jsx)(`col`,{className:`model-name-column`}),(0,k.jsx)(`col`,{}),(0,k.jsx)(`col`,{}),(0,k.jsx)(`col`,{}),(0,k.jsx)(`col`,{}),(0,k.jsx)(`col`,{})]}),(0,k.jsx)(`thead`,{children:(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`th`,{children:`Name`}),(0,k.jsx)(`th`,{children:`Size`}),(0,k.jsx)(`th`,{children:`Quant`}),(0,k.jsx)(`th`,{title:`Effective per-turn context size after Gezel's settings and memory limits`,children:`Context size`}),(0,k.jsx)(`th`,{title:`Representative startup and decode speed with an approximately 20K-token prompt`,children:`Fitness`}),(0,k.jsx)(`th`,{})]})}),(0,k.jsx)(`tbody`,{children:n.map(e=>{let t=R.has(e.id),n=`llama-cpp:${e.id}`,r=Se.get(n),s=Ie.get(e.id),u=e.predictedResidentBytes??d(e.approxSizeBytes,{mmprojBytes:e.mmprojSizeBytes}),m=J?a({residentBytes:u,isMoE:l(s?.tags),...A(J)}):void 0,h=J&&s?c(N(J),{isMoE:l(s.tags),fitTier:m?.tier??`fits`,residentBytes:u}):null;return(0,k.jsxs)(O.Fragment,{children:[(0,k.jsxs)(`tr`,{children:[(0,k.jsx)(`td`,{className:`model-name-table-cell`,children:(0,k.jsxs)(`div`,{className:`model-name-cell`,children:[(0,k.jsx)(`code`,{children:e.id}),(0,k.jsxs)(`div`,{className:`model-name-meta`,children:[h&&(0,k.jsx)(`span`,{className:`gz-status-pill${h.kind===`moe-good-match`?` gz-status-pill--ok`:``}`,title:h.detail,children:h.label}),e.updateAvailable&&(0,k.jsx)(`span`,{className:`gz-status-pill gz-status-pill--warn`,title:e.updateReason??(e.availableVersion?`A newer build is available in the catalog (→ v${e.availableVersion}). Updating downloads only the files that differ.`:`A newer build is available in the catalog.`),children:`update available`})]})]})}),(0,k.jsx)(oe,{model:e}),(0,k.jsx)(`td`,{title:i(e.quantization,e.ggufQuantization),children:o(e.quantization,e.ggufQuantization)}),(0,k.jsx)(`td`,{title:e.effectiveContextWindow?e.overrideContextTokens===void 0?`Gezel will grant up to ${e.effectiveContextWindow.toLocaleString()} tokens per turn${e.contextWindow?`; the model advertises ${e.contextWindow.toLocaleString()} tokens`:``}. The effective size accounts for model tuning, settings, concurrency, and available memory — Adaptive grows it past 64K when fast memory has room.`:`You've set this model to ${e.overrideContextTokens.toLocaleString()} tokens per turn; Gezel grants up to what memory allows (currently ${e.effectiveContextWindow.toLocaleString()}).`:e.contextSizingStatus===`restart-required`?`This model is running with a different context window than the current sizing settings resolve to. Restart the local engine (or let it go idle) so Gezel can re-admit it — no memory change needed.`:e.contextSizingStatus===`insufficient-memory`?`The selected context sizing policy needs${e.contextWindow?` this model's full advertised ${e.contextWindow.toLocaleString()}-token window`:` more context`}, which does not fit in memory safely. Choose Adaptive, unload another model, or free memory before trying again.`:`The effective context size is unavailable.`,children:e.contextSizingStatus===`restart-required`?`Restart needed`:e.contextSizingStatus===`insufficient-memory`?`Won't fit`:(0,k.jsxs)(k.Fragment,{children:[p(e.effectiveContextWindow),e.overrideContextTokens!==void 0&&(0,k.jsx)(`span`,{className:`gz-budget-tag gz-budget-tag-custom model-context-custom-tag`,children:`custom`})]})}),(0,k.jsx)(ne,{entry:r,probing:we.includes(n)}),(0,k.jsx)(`td`,{className:`model-actions-table-cell`,children:(0,k.jsxs)(`div`,{className:`model-actions-cell`,children:[(0,k.jsx)(`div`,{className:`model-action-status`,children:e.readOnly&&(0,k.jsx)(`span`,{className:`muted small`,title:`Provided by the machine-wide install (shared asset store). It can't be removed from here — manage it with the machine installer, or install a user-owned copy to shadow it.`,children:`Machine model`})}),(0,k.jsx)(`div`,{className:`model-action-links`,children:(0,k.jsx)(S,{engine:`llama-cpp`,model:e,updating:t,contextSupported:ve,contextEditorOpen:me===e.id,onToggleContextEditor:()=>he(t=>t===e.id?null:e.id),...e.nativeVisionEnabled===void 0?{}:{visionAction:{enabled:e.nativeVisionEnabled,busy:ge===e.id,onToggle:()=>void Oe(e.id,!e.nativeVisionEnabled)}},fitnessAction:ee(r,we.includes(n),()=>{f.runModelFitnessProbe(`llama-cpp`,e.id).then(()=>Z()).catch(()=>{})}),onUpdate:()=>$(e.id),onDelete:()=>q(e.id)})})]})})]}),me===e.id&&(0,k.jsx)(`tr`,{className:`model-context-editor-row`,children:(0,k.jsx)(`td`,{colSpan:6,children:(0,k.jsx)(te,{engine:`llama-cpp`,model:e,onSaved:Q})})})]},e.id)})})]})})]}),(0,k.jsxs)(`div`,{className:`ollama-section ollama-section--flat ollama-section--download`,children:[(0,k.jsx)(`h4`,{children:`Download a model`}),(0,k.jsxs)(`p`,{className:`muted small`,style:{marginTop:0},children:[`Models are hosted by`,` `,(0,k.jsx)(`a`,{href:`https://huggingface.co`,target:`_blank`,rel:`noreferrer`,style:{color:`inherit`},children:`Hugging Face`}),`, a community library of open, freely available AI models. Your device downloads them directly.`]}),(0,k.jsxs)(`p`,{className:`muted small`,children:[J?`Models that may not fit this machine, and retired models, are hidden by default. `:`Retired models are hidden by default. `,(0,k.jsx)(`button`,{type:`button`,className:`gz-link-button`,onClick:()=>pe(e=>!e),style:{padding:0},children:Y?J?`Hide retired and oversized models`:`Hide retired models`:`Show all models`})]}),(0,k.jsx)(b,{kind:`chat-model`,emptyMessage:`No on-device models in the catalog yet.`,onItemsLoaded:xe,tagTooltips:le,filter:e=>{let t=P(e.manifest);return!(!t||!Y&&s(t)||!Y&&J&&!M(t,J).runnable)},action:e=>{let t=P(e.manifest);if(!t)return null;let n=Pe.has(t.id),r=Fe.has(t.id),i=R.get(t.id),a=i&&i.totalBytes>0?Math.min(100,Math.round(i.bytesWritten/i.totalBytes*100)):null,o=J?M(t,J):null;return(0,k.jsxs)(`div`,{className:`catalog-ollama-action`,children:[(0,k.jsxs)(`div`,{className:`catalog-ollama-meta`,children:[(0,k.jsxs)(`div`,{className:`catalog-ollama-specs muted small`,children:[(0,k.jsx)(D,{repo:t.llamaCpp.huggingfaceRepo}),(0,k.jsx)(`span`,{children:`·`}),(0,k.jsx)(`span`,{children:t.parameterSize}),(0,k.jsx)(`span`,{children:`·`}),(0,k.jsx)(`span`,{children:se(t.llamaCpp.approxSizeBytes)}),ce(t.releasedAt)&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`span`,{children:`·`}),(0,k.jsx)(`span`,{children:ce(t.releasedAt)})]})]}),(0,k.jsxs)(`div`,{className:`catalog-ollama-pills`,children:[(0,k.jsx)(x,{manifest:t,fallbackHref:ae(t.llamaCpp.huggingfaceRepo)}),o&&o.tier!==`fits`&&(0,k.jsx)(`span`,{className:`gz-status-pill ${o.tier===`fits-offload`?`gz-status-pill--ok`:`gz-status-pill--warn`}`,title:o.detail,children:o.label}),(()=>{let n=J&&o?c(N(J),{isMoE:l(e.manifest.tags),fitTier:o.tier,residentBytes:d(t.llamaCpp.approxSizeBytes)+j(t,J)}):null;return n?(0,k.jsx)(`span`,{className:`gz-status-pill${n.kind===`moe-good-match`?` gz-status-pill--ok`:``}`,title:n.detail,children:n.label}):null})()]})]}),(0,k.jsx)(`button`,{type:`button`,disabled:n||r||!!i,onClick:()=>$(t.id),children:n?`On device`:i?i.phase===`downloading`?a===null?`Downloading…`:`Downloading… ${a}%`:i.phase===`verifying`?`Verifying…`:`Reading metadata…`:r?`Needs attention above`:`Download`})]})}})]}),(0,k.jsxs)(`div`,{className:`ollama-section ollama-section--flat`,children:[(0,k.jsx)(y,{}),(0,k.jsx)(`span`,{className:`muted small`,style:{marginLeft:`0.75rem`},children:`Import from a gezel local model package`})]}),(0,k.jsx)(h,{open:K!==null,title:`Delete ${K??``}?`,message:`This removes the downloaded model from your device. It stays available in the catalog — you can download it again any time.`,confirmLabel:`Delete`,danger:!0,onConfirm:Ne,onCancel:()=>q(null)})]})}function ue({inst:e,onCancel:t,onRetry:n}){let r=e.totalBytes>0,i=r?Math.min(100,Math.round(e.bytesWritten/e.totalBytes*100)):0,a;if(e.error)a=e.error;else if(e.retrying){let t=Math.max(1,Math.round(e.retrying.delayMs/1e3));a=`${e.retrying.reason} — retrying in ${t}s (attempt ${e.retrying.attempt}/${e.retrying.maxAttempts})`}else a=e.phase===`downloading`?r?`Downloading ${m(e.bytesWritten)} of ${m(e.totalBytes)} (${i}%)`:e.bytesWritten>0?`Downloading ${m(e.bytesWritten)}…`:`Preparing download…`:e.phase===`verifying`?`Checking download…`:`Reading model info…`;let o=e.phase!==`downloading`||!r;return(0,k.jsxs)(`div`,{className:`ollama-pull${e.error?` ollama-pull-error`:e.retrying?` ollama-pull-warning`:``}`,children:[(0,k.jsxs)(`div`,{className:`ollama-pull-head`,children:[(0,k.jsx)(`code`,{children:e.catalogId}),(0,k.jsx)(`span`,{className:`muted small`,children:a}),e.error?(0,k.jsx)(`button`,{type:`button`,className:`gz-link-button`,onClick:n,children:`Retry`}):(0,k.jsx)(`button`,{type:`button`,className:`gz-link-button`,onClick:t,children:`Cancel`})]}),o?(0,k.jsx)(`div`,{className:`ollama-pull-bar ollama-pull-bar-indeterminate`,children:(0,k.jsx)(`div`,{className:`ollama-pull-bar-fill`})}):(0,k.jsxs)(`div`,{className:`ollama-pull-bar`,children:[(0,k.jsx)(`div`,{className:`ollama-pull-bar-fill`,style:{width:`${i}%`}}),(0,k.jsxs)(`span`,{className:`ollama-pull-bar-label`,children:[i,`%`]})]})]})}function de(e){return e instanceof Error?e.message:String(e)}var I=80,L=40,R=95,z=5;function B(e){return e===`win32`||e===`linux`}function V({config:e,onConfigChanged:t,platform:n}){let r=e?.deviceSafety?.mode??`observe`,i=e?.deviceSafety?.maxStartTemperatureC??I,[a,o]=(0,O.useState)(String(i)),[s,c]=(0,O.useState)(!1),[l,u]=(0,O.useState)(null);(0,O.useEffect)(()=>{o(String(i))},[i]);let d=(0,O.useCallback)(async n=>{if(!s){c(!0),u(null);try{t(await f.updateConfig({deviceSafety:{...e?.deviceSafety??{},...n}}))}catch(e){u(e instanceof Error?e.message:String(e))}finally{c(!1)}}},[e?.deviceSafety,t,s]),p=(0,O.useCallback)(e=>{r!==e&&d({mode:e})},[r,d]),m=(0,O.useCallback)(()=>{let e=Number(a);if(!Number.isInteger(e)||e<L||e>R){u(`Enter a whole number from ${L} to ${R}°C.`);return}if(e===i){u(null);return}d({maxStartTemperatureC:e,resumeTemperatureC:e-z})},[i,d,a]);if(!B(n))return null;let h=Number(a),g=(Math.min(R,Math.max(L,h))-L)/(R-L)*100;return(0,k.jsxs)(`section`,{className:`machine-health-settings`,"aria-labelledby":`machine-health-heading`,children:[(0,k.jsx)(`h4`,{id:`machine-health-heading`,children:`Machine health`}),(0,k.jsx)(`p`,{className:`muted`,style:{marginTop:0},children:`Choose whether Gezel only reports accelerator health or also waits for the machine to cool before starting new on-device work.`}),(0,k.jsxs)(`fieldset`,{className:`gz-tray machine-health-mode`,children:[(0,k.jsx)(`legend`,{className:`sr-only`,children:`Machine health mode`}),(0,k.jsxs)(`button`,{type:`button`,"aria-pressed":r===`observe`,className:`gz-key gz-key--stacked${r===`observe`?` gz-key-active`:``}`,disabled:s,onClick:()=>p(`observe`),children:[(0,k.jsx)(`span`,{children:`Observe`}),(0,k.jsx)(`small`,{children:`Report only`})]}),(0,k.jsxs)(`button`,{type:`button`,"aria-pressed":r===`guard`,className:`gz-key gz-key--stacked${r===`guard`?` gz-key-active`:``}`,disabled:s,onClick:()=>p(`guard`),children:[(0,k.jsx)(`span`,{children:`Manage`}),(0,k.jsx)(`small`,{children:`Pause new work`})]})]}),r===`off`&&(0,k.jsx)(`p`,{className:`muted small machine-health-off-note`,children:`Machine health is disabled by an advanced configuration override. Choose Observe or Manage to turn it back on.`}),(0,k.jsxs)(`div`,{className:`machine-health-temperature-row`,children:[(0,k.jsx)(`label`,{htmlFor:`machine-health-temperature`,children:`Manage temperature`}),(0,k.jsxs)(`div`,{className:`machine-health-temperature-control`,children:[(0,k.jsxs)(`div`,{className:`machine-health-temperature-slider-wrap`,children:[(0,k.jsx)(`input`,{id:`machine-health-temperature`,className:`machine-health-temperature-slider`,type:`range`,min:L,max:R,step:1,value:a,disabled:s,"aria-describedby":`machine-health-temperature-help`,"aria-valuetext":`${a} degrees Celsius`,style:{"--machine-health-temperature-progress":`${g}%`},onChange:e=>o(e.target.value),onPointerUp:e=>e.currentTarget.blur(),onBlur:m,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()}}),(0,k.jsxs)(`div`,{className:`machine-health-temperature-scale`,"aria-hidden":`true`,children:[(0,k.jsxs)(`span`,{children:[L,`°`]}),(0,k.jsxs)(`span`,{className:`machine-health-temperature-default`,children:[I,`° default`]}),(0,k.jsxs)(`span`,{children:[R,`°`]})]})]}),(0,k.jsxs)(`output`,{className:`machine-health-temperature-value`,htmlFor:`machine-health-temperature`,"aria-label":`Manage temperature: ${a} degrees Celsius`,children:[(0,k.jsx)(`span`,{className:`machine-health-temperature-value-number`,children:a}),(0,k.jsx)(`span`,{"aria-hidden":`true`,children:`°C`})]})]})]}),(0,k.jsxs)(`p`,{id:`machine-health-temperature-help`,className:`muted small machine-health-temperature-help`,children:[`In Manage mode, new accelerator work waits above this temperature and resumes after a 5°C cooldown. The default is 80°C. Both modes retain the `,105,`°C emergency cutoff.`]}),s&&(0,k.jsx)(`output`,{className:`muted small machine-health-save-state`,children:`Saving…`}),l&&(0,k.jsx)(`p`,{className:`error small machine-health-save-state`,role:`alert`,children:l})]})}function H(e){return e===!0?`on`:e===!1?`off`:`auto`}function U(e,t){return e===`darwin`?[`metal`]:t===`cuda`?[`cuda`,`vulkan`,`cpu`]:t===`vulkan`?[`vulkan`,`cpu`]:t===`cpu`?[`cpu`]:[`cuda`,`vulkan`,`cpu`]}function W(e){return e===`cuda`?`CUDA (Nvidia GPU)`:e===`vulkan`?`Vulkan (any GPU)`:e===`metal`?`Metal (Apple GPU)`:`CPU only`}function G(e){return e===`amd`?`, AMD GPU detected`:e===`nvidia`?`, Nvidia GPU detected`:e===`intel`?`, Intel GPU detected`:``}function K(e,t){if(!t?.llamaCppBackend)return!1;let n=t.llamaCppBackend,r=e?.llamaCppBackendOverride&&e.llamaCppBackendOverride!==`auto`?e.llamaCppBackendOverride:t.llamaCppDetectedBackend??n;return!t.llamaCppQuarantinedBackends?.includes(r)&&r!==n}function q({config:e,onConfigChanged:t,health:n,title:r}){let[i,a]=(0,O.useState)(e?.llamaCppBaseUrl??``),[o,s]=(0,O.useState)(e?.llamaCppModelPath??``),[c,l]=(0,O.useState)([]),[u,d]=(0,O.useState)(`idle`),[p,m]=(0,O.useState)(`adaptive`),[h,g]=(0,O.useState)(!0),_=(0,O.useRef)(null),v=(0,O.useRef)(!0),y=(0,O.useCallback)(()=>{_.current!==null&&(window.clearTimeout(_.current),_.current=null)},[]);(0,O.useEffect)(()=>(v.current=!0,()=>{v.current=!1,y()}),[y]);let b=(0,O.useCallback)(e=>{v.current&&(y(),d(e))},[y]),x=(0,O.useCallback)(()=>{v.current&&(y(),d(`saved`),_.current=window.setTimeout(()=>{_.current=null,v.current&&d(`idle`)},1200))},[y]);(0,O.useEffect)(()=>{a(e?.llamaCppBaseUrl??``)},[e?.llamaCppBaseUrl]),(0,O.useEffect)(()=>{s(e?.llamaCppModelPath??``)},[e?.llamaCppModelPath]);let S=(0,O.useCallback)(async()=>{try{let e=await f.listLlamaCppModels();l(e.models)}catch{}},[]);(0,O.useEffect)(()=>{S()},[S]),(0,O.useEffect)(()=>{let e=!1;return f.getLlamaCppContextSizing().then(t=>{e||m(t.policy)}).catch(()=>{}).finally(()=>{e||g(!1)}),()=>{e=!0}},[]);let ee=(0,O.useCallback)(async()=>{let e=i.trim();b(`saving`);try{let n=await f.updateConfig({llamaCppBaseUrl:e===``?null:e});if(!v.current)return;t(n),x()}catch{b(`idle`)}},[i,t,x,b]),C=(0,O.useCallback)(async e=>{b(`saving`);try{let n=await f.updateConfig({llamaCppBackendOverride:e===`auto`?null:e});if(!v.current)return;t(n),x()}catch{b(`idle`)}},[t,x,b]),te=(0,O.useCallback)(async e=>{b(`saving`);try{let t=await f.updateLlamaCppContextSizing(e);if(!v.current)return;m(t.policy),x()}catch{b(`idle`)}},[x,b]),ne=(0,O.useCallback)(async()=>{let e=o.trim();b(`saving`);try{let n=await f.updateConfig({llamaCppModelPath:e===``?null:e});if(!v.current)return;t(n),x()}catch{b(`idle`)}},[o,t,x,b]),re=(0,O.useCallback)(async e=>{b(`saving`);try{let n=await f.updateConfig({llamaCppKvCacheType:e===`q8_0`?null:e});if(!v.current)return;t(n),x()}catch{b(`idle`)}},[t,x,b]),ie=(0,O.useCallback)(async e=>{b(`saving`);try{let n=await f.updateConfig({llamaCppFlashAttn:e===`auto`?null:e});if(!v.current)return;t(n),x()}catch{b(`idle`)}},[t,x,b]),D=(0,O.useCallback)(async e=>{b(`saving`);try{let n=await f.updateConfig({llamaCppCpuMoe:e===`auto`?null:e===`on`});if(!v.current)return;t(n),x()}catch{b(`idle`)}},[t,x,b]),ae=(0,O.useCallback)(async e=>{b(`saving`);try{let n=await f.updateConfig({llamaCppSwaFull:e===`auto`?null:e===`on`});if(!v.current)return;t(n),x()}catch{b(`idle`)}},[t,x,b]),oe=(0,O.useCallback)(async e=>{b(`saving`);try{let n=await f.updateConfig({llamaCppSpecType:e===`none`?null:e});if(!v.current)return;t(n),x()}catch{b(`idle`)}},[t,x,b]),A=(0,O.useCallback)(async n=>{b(`saving`);try{let r=await f.updateConfig({defaultModel:{...e?.defaultModel,"llama-cpp":n??void 0}});if(!v.current)return;t(r),x()}catch{b(`idle`)}},[e?.defaultModel,t,x,b]),j=e?.defaultModel?.[`llama-cpp`],M=!!e?.llamaCppBaseUrl;return(0,k.jsxs)(`div`,{children:[(0,k.jsxs)(`section`,{style:{marginBottom:`2rem`},children:[(0,k.jsx)(`h3`,{children:r??w(`llama-cpp`,n?.platform)}),(0,k.jsx)(`p`,{className:`muted`,style:{marginTop:0},children:`Run AI models directly on this device using the llama.cpp engine, making the best use of the hardware you already have. Your conversations stay on your computer — no account to set up, no data sent to the cloud.`}),(0,k.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,k.jsx)(`span`,{className:`muted small`,children:`Status:`}),(0,k.jsx)(`span`,{className:`gz-status-pill gz-status-pill--ok`,children:`ready`}),M&&(0,k.jsx)(`span`,{className:`gz-status-pill gz-status-pill--warn`,title:`Using an external engine at: ${e?.llamaCppBaseUrl}`,children:`using external engine`}),u===`saved`&&(0,k.jsx)(`span`,{className:`muted small`,children:`saved ✓`})]})]}),c.length>1&&(0,k.jsxs)(`section`,{style:{marginBottom:`2rem`},children:[(0,k.jsx)(`h4`,{children:`Default model`}),(0,k.jsx)(`p`,{className:`muted small`,style:{marginTop:0},children:`Which local model new chat sessions use when a gezel doesn't pin one.`}),(0,k.jsx)(`div`,{className:`new-row`,style:{marginTop:`0.5rem`},children:(0,k.jsxs)(`select`,{value:j??``,onChange:e=>void A(e.target.value||void 0),children:[(0,k.jsx)(`option`,{value:``,children:`First local model`}),c.map(e=>(0,k.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.id,`)`]},e.id))]})})]}),(0,k.jsxs)(`section`,{style:{marginBottom:`2rem`},children:[(0,k.jsx)(`h4`,{children:`Models`}),(0,k.jsx)(F,{onModelsChanged:S},p)]}),(0,k.jsx)(T,{provider:`llama-cpp`}),(0,k.jsxs)(`section`,{style:{marginBottom:`2rem`},children:[(0,k.jsx)(`h4`,{style:{marginBottom:`0.5rem`},children:`Concurrent replicas`}),(0,k.jsx)(`p`,{className:`muted small`,style:{marginTop:0},children:`Run multiple copies of the same model so unrelated sessions don't queue behind each other. Weights are shared by the OS via mmap so disk cost stays at one model file; resident memory grows because each clone keeps its own KV cache and activations.`}),(0,k.jsx)(E,{provider:`llama-cpp`,modelId:e?.defaultModel?.[`llama-cpp`]??null,config:e,onConfigChanged:t})]}),(0,k.jsx)(V,{config:e,onConfigChanged:t,platform:window.__GEZEL__?.platform??n?.platform}),(0,k.jsxs)(`details`,{className:`llama-advanced-settings`,children:[(0,k.jsxs)(`summary`,{className:`llama-advanced-summary`,children:[(0,k.jsx)(`span`,{className:`llama-advanced-caret`,"aria-hidden":`true`,children:`›`}),(0,k.jsx)(`h4`,{children:`Advanced`})]}),(0,k.jsx)(`p`,{className:`muted small`,style:{marginTop:`0.75rem`},children:`Tune how the managed on-device engine starts, or override how Gezel connects to it. Most users don't need any of these — the supervised engine handles everything. Set them only when you need a different context policy, are running your own engine process, point at a weights file that isn't in the catalog, or downgrade the accelerator.`}),(0,k.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,k.jsx)(`label`,{htmlFor:`llama-cpp-context-sizing`,className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`Context sizing`}),(0,k.jsxs)(`select`,{id:`llama-cpp-context-sizing`,value:p,disabled:h||u===`saving`||M,onChange:e=>void te(e.target.value),style:{flex:1,maxWidth:`20rem`},children:[(0,k.jsx)(`option`,{value:`adaptive`,children:`Adaptive (recommended)`}),(0,k.jsx)(`option`,{value:`model-max`,children:`Model maximum (strict)`})]})]}),(0,k.jsxs)(`p`,{className:`muted small`,style:{marginTop:`0.25rem`,marginLeft:`10rem`},children:[(0,k.jsx)(`em`,{children:`Adaptive`}),` starts from model tuning (64K by default), reduces concurrency before it shortens a larger tuned window, and grows the window toward the model's maximum when fast memory has room to spare — consolidating down to two concurrent chats when that buys a meaningfully longer window, never fewer. Each model can also be pinned to a specific size from its row in the list below. `,(0,k.jsx)(`em`,{children:`Model maximum`}),` requests the model's full advertised window; if one engine slot cannot hold it safely, the model will not start. This is a machine-wide managed-engine setting. Changing it restarts idle local engines right away; a model that is mid-conversation finishes its current turn first.`,M?` External engine URLs manage their own context size.`:``]}),(0,k.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,k.jsx)(`label`,{htmlFor:`llama-cpp-engine-backend`,className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`Engine backend`}),(0,k.jsxs)(`select`,{id:`llama-cpp-engine-backend`,value:e?.llamaCppBackendOverride??`auto`,onChange:e=>void C(e.target.value),style:{flex:1,maxWidth:`20rem`},children:[(0,k.jsxs)(`option`,{value:`auto`,children:[`Auto-detect`,n?.llamaCppDetectedBackend?` (machine supports: ${n.llamaCppDetectedBackend}${G(n.llamaCppDetectedVendor)})`:``]}),U(n?.platform,n?.llamaCppDetectedBackend).map(e=>(0,k.jsx)(`option`,{value:e,children:W(e)},e))]}),(0,k.jsx)(`span`,{className:`muted`,style:{fontSize:`0.85rem`},children:K(e,n)?`Restart the app to apply`:``})]}),(0,k.jsxs)(`p`,{className:`muted small`,style:{marginTop:`0.25rem`,marginLeft:`10rem`},children:[`Auto-detect picks the fastest backend your machine supports; the other options are downgrades you can pin if the faster path is misbehaving. Switching `,(0,k.jsx)(`em`,{children:`back`}),` to Auto-detect from a pinned override also requires a restart.`]}),(0,k.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,k.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`KV cache quantization`}),(0,k.jsxs)(`select`,{value:e?.llamaCppKvCacheType??`q8_0`,onChange:e=>void re(e.target.value),style:{flex:1,maxWidth:`20rem`},children:[(0,k.jsx)(`option`,{value:`f16`,children:`f16 — full precision (most memory)`}),(0,k.jsx)(`option`,{value:`q8_0`,children:`q8_0 — balanced (default)`}),(0,k.jsx)(`option`,{value:`q4_0`,children:`q4_0 — smallest (most savings)`})]})]}),(0,k.jsxs)(`p`,{className:`muted small`,style:{marginTop:`0.25rem`,marginLeft:`10rem`},children:[`Sets `,(0,k.jsx)(`code`,{children:`--cache-type-k`}),` / `,(0,k.jsx)(`code`,{children:`--cache-type-v`}),` for llama-server. Quantizing the KV cache frees RAM for longer contexts and more concurrent sessions: q8_0 is near-lossless at ~50% savings vs. f16, while q4_0 saves the most but can dent quality on attention-sensitive models. Takes effect the next time the engine starts — restart the app to apply now.`]}),(0,k.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,k.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`Flash attention`}),(0,k.jsxs)(`select`,{value:typeof e?.llamaCppFlashAttn==`string`?e.llamaCppFlashAttn:e?.llamaCppFlashAttn===!0?`on`:`auto`,onChange:e=>void ie(e.target.value),style:{flex:1,maxWidth:`20rem`},children:[(0,k.jsx)(`option`,{value:`auto`,children:`Auto (recommended)`}),(0,k.jsx)(`option`,{value:`on`,children:`On`}),(0,k.jsx)(`option`,{value:`off`,children:`Off`})]})]}),(0,k.jsx)(`p`,{className:`muted small`,style:{marginTop:`0.25rem`,marginLeft:`10rem`},children:`Faster attention on modern GPUs, and effectively required for the fast path under a quantized KV cache (the default). Auto lets llama-server decide; the engine forces it on when the KV cache is quantized. Takes effect the next time the engine starts.`}),(0,k.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,k.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`Speculative decoding`}),(0,k.jsxs)(`select`,{value:e?.llamaCppSpecType??`none`,onChange:e=>void oe(e.target.value),style:{flex:1,maxWidth:`20rem`},children:[(0,k.jsx)(`option`,{value:`none`,children:`Off`}),(0,k.jsx)(`option`,{value:`ngram-mod`,children:`N-gram lookup (no draft model)`}),(0,k.jsx)(`option`,{value:`draft-mtp`,children:`Model MTP head (experimental)`})]})]}),(0,k.jsxs)(`p`,{className:`muted small`,style:{marginTop:`0.25rem`,marginLeft:`10rem`},children:[`Drafts several tokens per step and verifies them against the target model. `,(0,k.jsx)(`em`,{children:`N-gram`}),` `,`needs no extra model and helps most on repetitive or structured output. `,(0,k.jsx)(`em`,{children:`MTP`}),` uses the model's own prediction head, requires compatible downloaded weights, and may change behavior on experimental engine/model combinations. Takes effect the next time the engine starts.`]}),(0,k.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,k.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`MoE expert offload`}),(0,k.jsxs)(`select`,{value:H(e?.llamaCppCpuMoe),onChange:e=>void D(e.target.value),style:{flex:1,maxWidth:`20rem`},children:[(0,k.jsx)(`option`,{value:`auto`,children:`Auto — detect when offload is needed (default)`}),(0,k.jsx)(`option`,{value:`on`,children:`On — always offload experts (--cpu-moe)`}),(0,k.jsx)(`option`,{value:`off`,children:`Off — keep experts on the GPU`})]})]}),(0,k.jsxs)(`p`,{className:`muted small`,style:{marginTop:`0.25rem`,marginLeft:`10rem`},children:[`For big Mixture-of-Experts models on a small GPU: run attention on the GPU while streaming the sparse expert weights from system RAM — lets a model that wouldn't fit in VRAM run anyway. `,(0,k.jsx)(`em`,{children:`Auto`}),` turns this on only for a MoE model that won't fit in VRAM (and sizes a partial split when it can), and leaves dense models and UMA machines alone. Takes effect the next time the engine starts.`]}),(0,k.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,k.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`Full SWA cache`}),(0,k.jsxs)(`select`,{value:H(e?.llamaCppSwaFull),onChange:e=>void ae(e.target.value),style:{flex:1,maxWidth:`20rem`},children:[(0,k.jsx)(`option`,{value:`auto`,children:`Auto — full only when it fits fast memory`}),(0,k.jsx)(`option`,{value:`on`,children:`On — always full cache (--swa-full)`}),(0,k.jsx)(`option`,{value:`off`,children:`Off — memory-efficient windowed cache`})]})]}),(0,k.jsxs)(`p`,{className:`muted small`,style:{marginTop:`0.25rem`,marginLeft:`10rem`},children:[`For sliding-window models (the Gemma family): retain old KV entries that the memory-efficient windowed cache normally discards. This can enable prompt reuse and other cache operations where the engine supports them, but its memory cost grows with context.`,` `,(0,k.jsx)(`em`,{children:`Auto`}),` uses the full cache only when the model weights and full KV cache fit in fast memory — VRAM on a discrete GPU — and otherwise keeps the windowed cache. Takes effect the next time the engine starts.`]}),(0,k.jsxs)(`p`,{className:`muted small`,style:{marginTop:`0.5rem`,marginLeft:`10rem`},children:[`More engine flags (an explicit GPU-layer count, partial expert split, prompt-reuse size, threads, and a raw-flag escape hatch) live in `,(0,k.jsx)(`code`,{children:`config.json`}),` under the`,` `,(0,k.jsx)(`code`,{children:`llamaCpp*`}),` keys.`]}),(0,k.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,k.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`External engine URL`}),(0,k.jsx)(`input`,{type:`text`,placeholder:`e.g. http://127.0.0.1:8080 (leave blank to use the supervised engine)`,value:i,onChange:e=>a(e.target.value),style:{flex:1}}),(0,k.jsx)(`button`,{type:`button`,disabled:u===`saving`||i===(e?.llamaCppBaseUrl??``),onClick:()=>void ee(),children:`Save`})]}),(0,k.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.5rem`,alignItems:`center`},children:[(0,k.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`10rem`},children:`Override model path`}),(0,k.jsx)(`input`,{type:`text`,placeholder:`Absolute path to a .gguf file (overrides the local-models default)`,value:o,onChange:e=>s(e.target.value),style:{flex:1}}),(0,k.jsx)(`button`,{type:`button`,disabled:u===`saving`||o===(e?.llamaCppModelPath??``),onClick:()=>void ne(),children:`Save`})]}),(0,k.jsx)(J,{})]})]})}function J(){let[e,t]=(0,O.useState)({kind:`idle`}),n=(0,O.useCallback)(async()=>{t({kind:`loading`});try{let e=await f.getLlamaCppLog(4096);t({kind:`loaded`,path:e.path,tail:e.tail})}catch(e){t({kind:`error`,message:e instanceof Error?e.message:String(e)})}},[]);return(0,k.jsxs)(`details`,{style:{marginTop:`1rem`},children:[(0,k.jsxs)(`summary`,{style:{cursor:`pointer`,userSelect:`none`},children:[`Engine log`,` `,(0,k.jsx)(`span`,{className:`muted small`,children:`— technical output from llama-server. Useful for bug reports.`})]}),(0,k.jsxs)(`div`,{style:{marginTop:`0.5rem`},children:[(0,k.jsxs)(`div`,{className:`new-row`,style:{alignItems:`center`,gap:`0.5rem`},children:[(0,k.jsx)(`button`,{type:`button`,onClick:()=>void n(),disabled:e.kind===`loading`,children:e.kind===`loading`?`Loading…`:`Refresh`}),e.kind===`loaded`&&e.path&&(0,k.jsx)(`span`,{className:`muted small`,title:e.path,children:e.path}),e.kind===`loaded`&&!e.path&&(0,k.jsx)(`span`,{className:`muted small`,children:`No supervised engine running.`})]}),e.kind===`error`&&(0,k.jsxs)(`div`,{className:`muted small`,style:{marginTop:`0.5rem`,color:`#ff9b9b`},children:[`Couldn't load log: `,e.message]}),e.kind===`loaded`&&e.tail&&(0,k.jsx)(`pre`,{style:{marginTop:`0.5rem`,padding:`0.5rem`,background:`rgba(255,255,255,0.04)`,border:`1px solid rgba(255,255,255,0.1)`,borderRadius:4,maxHeight:`18rem`,overflow:`auto`,fontSize:`0.75rem`,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace`,whiteSpace:`pre-wrap`,wordBreak:`break-all`},children:e.tail}),e.kind===`loaded`&&!e.tail&&e.path&&(0,k.jsx)(`div`,{className:`muted small`,style:{marginTop:`0.5rem`},children:`Log is empty. (Engine may not have started yet — try chatting with an on-device gezel first.)`})]})]})}export{q as LlamaCppSettings};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{t as r}from"./api-BX5xXiFs.js";import{v as i}from"./index-DXWR4qW1.js";import{r as a}from"./TransformToolbarButton-CVg5nz36.js";var o=e(t(),1),s=n();function c({gezelId:e,gezelName:t}){let[n,i]=(0,o.useState)(null),[a,c]=(0,o.useState)(null),[u,f]=(0,o.useState)({loading:!1,content:null,error:null});(0,o.useEffect)(()=>{let t=!1;return i(null),c(null),(async()=>{let[n,a,o]=await Promise.all([r.listMemoryDays(`gezel`,e).then(e=>e.days).catch(()=>[]),r.readMemorySummary(`gezel`,e).then(e=>e.content).catch(()=>``),r.readMemoryLessons(e).then(e=>e.content).catch(()=>``)]);t||i({days:n,summary:a||null,lessons:o||null,expanded:!0})})(),()=>{t=!0}},[e]),(0,o.useEffect)(()=>{if(!a){f({loading:!1,content:null,error:null});return}let t=!1;return f({loading:!0,content:null,error:null}),(async()=>{try{let n=a.kind===`summary`?await r.readMemorySummary(`gezel`,e):a.kind===`lessons`?await r.readMemoryLessons(e):await r.readMemoryDay(`gezel`,e,a.day);t||f({loading:!1,content:n.content,error:null})}catch(e){t||f({loading:!1,content:null,error:e instanceof Error?e.message:String(e)})}})(),()=>{t=!0}},[e,a]);let p=(0,o.useCallback)(()=>{i(e=>e&&{...e,expanded:!e.expanded})},[]);return n===null?(0,s.jsx)(`p`,{className:`muted small`,children:`Loading memories…`}):n.days.length===0&&!n.summary&&!n.lessons?(0,s.jsx)(`p`,{className:`placeholder`,children:`No memories yet. This gezel will build an individual memory over time as you work together.`}):(0,s.jsxs)(`div`,{className:`memories-pane`,"data-testid":`memories-tree`,children:[(0,s.jsxs)(`div`,{className:`memories-tree`,role:`tree`,children:[(0,s.jsxs)(`p`,{className:`memories-tree-total muted small`,children:[n.days.length,` day`,n.days.length===1?``:`s`,` of individual memories.`]}),(0,s.jsx)(l,{gezelName:t,tree:n,onToggle:p,onSelect:c,selected:a})]}),(0,s.jsx)(d,{selected:a,preview:u})]})}function l({gezelName:e,tree:t,onToggle:n,onSelect:r,selected:i}){return(0,s.jsxs)(`div`,{className:`memories-tree-scope`,role:`treeitem`,"aria-expanded":t.expanded,children:[(0,s.jsxs)(`button`,{type:`button`,className:`memories-tree-scope-header`,onClick:n,children:[(0,s.jsx)(`span`,{className:`memories-tree-caret`,"aria-hidden":!0,children:t.expanded?`▾`:`▸`}),(0,s.jsx)(`span`,{className:`memories-tree-scope-label`,children:e}),(0,s.jsxs)(`span`,{className:`muted small`,children:[t.days.length,` day`,t.days.length===1?``:`s`,t.lessons?` + lessons`:``,t.summary?` + summary`:``]})]}),t.expanded&&(0,s.jsxs)(`ul`,{className:`memories-tree-children`,children:[t.lessons&&(0,s.jsx)(u,{active:i?.kind===`lessons`,label:`lessons`,onClick:()=>r({kind:`lessons`,label:`${e} · lessons`})}),t.summary&&(0,s.jsx)(u,{active:i?.kind===`summary`,label:`summary`,onClick:()=>r({kind:`summary`,label:`${e} · summary`})}),t.days.map(t=>(0,s.jsx)(u,{active:i?.kind===`day`&&i.day===t,label:t,onClick:()=>r({kind:`day`,day:t,label:`${e} · ${t}`})},t))]})]})}function u({active:e,label:t,onClick:n}){return(0,s.jsx)(`li`,{children:(0,s.jsx)(`button`,{type:`button`,className:`memories-tree-leaf${e?` memories-tree-leaf-active`:``}`,onClick:n,children:t})})}function d({selected:e,preview:t}){return(0,s.jsx)(`div`,{className:`memories-preview`,children:e?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`header`,{className:`memories-preview-header`,children:(0,s.jsx)(`code`,{children:e.label})}),t.loading&&(0,s.jsx)(`p`,{className:`muted small`,children:`Loading…`}),t.error&&(0,s.jsx)(`p`,{className:`error`,children:t.error}),t.content!==null&&!t.loading&&!t.error&&(0,s.jsx)(`pre`,{className:`memories-preview-body`,children:t.content||`(empty)`})]}):(0,s.jsx)(`p`,{className:`placeholder`,children:`Select a day or lesson on the left to view its contents.`})})}function f({projectId:e,projectName:t}){let[n,i]=(0,o.useState)(null),[a,c]=(0,o.useState)(null),[l,d]=(0,o.useState)(null),[f,m]=(0,o.useState)(null);return(0,o.useEffect)(()=>{let t=!1;return i(null),c(null),d(null),m(null),r.listMemoryDays(`project`,e).then(e=>{t||(i(e.days),d(e.days[0]??null))}).catch(e=>{t||(i([]),c(e instanceof Error?e.message:String(e)))}),()=>{t=!0}},[e]),(0,o.useEffect)(()=>{if(!l){m(null);return}let t=!1,n=l;return m({day:n,loading:!0,content:null,error:null}),r.readMemoryDay(`project`,e,n).then(e=>{t||m({day:n,loading:!1,content:e.content,error:null})}).catch(e=>{t||m({day:n,loading:!1,content:null,error:e instanceof Error?e.message:String(e)})}),()=>{t=!0}},[e,l]),(0,s.jsxs)(`section`,{id:`project-about-memories`,className:`project-about-section project-about-anchor`,children:[(0,s.jsx)(`h3`,{className:`project-about-section-title`,children:`Project memories`}),(0,s.jsx)(`p`,{className:`muted small project-memories-hint`,children:`Notes shared by every gezel working in this project. Changes are saved to the project’s memory files and used in future recall.`}),n===null?(0,s.jsx)(`p`,{className:`muted small`,children:`Loading memories…`}):a?(0,s.jsx)(`p`,{className:`error`,children:a}):n.length===0?(0,s.jsx)(`p`,{className:`placeholder`,children:`No project memories yet. Gezels add shared notes here as work progresses.`}):(0,s.jsxs)(`div`,{className:`project-memories-browser`,children:[(0,s.jsxs)(`div`,{className:`memories-tree project-memories-days`,children:[(0,s.jsxs)(`p`,{className:`memories-tree-total muted small`,children:[n.length,` day`,n.length===1?``:`s`]}),(0,s.jsx)(`ul`,{className:`memories-tree-children project-memories-day-list`,children:n.map(e=>(0,s.jsx)(u,{active:l===e,label:e,onClick:()=>d(e)},e))})]}),(0,s.jsxs)(`div`,{className:`project-memory-editor`,children:[f?.loading&&(0,s.jsx)(`p`,{className:`muted small`,children:`Loading…`}),f?.error&&(0,s.jsx)(`p`,{className:`error`,children:f.error}),f?.content!==null&&f&&!f.loading&&!f.error&&(0,s.jsx)(p,{projectId:e,projectName:t,day:f.day,initial:f.content},`${e}:${f.day}`)]})]})]})}function p({projectId:e,projectName:t,day:n,initial:o}){let c=i({resourceKey:`project:${e}:memory:${n}`,initialValue:o,save:t=>r.updateMemoryDay(`project`,e,n,t)});return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(`div`,{className:`project-memory-editor-heading`,children:(0,s.jsxs)(`code`,{children:[t,` · `,n]})}),(0,s.jsxs)(`div`,{className:`project-memory-source-editor`,children:[(0,s.jsx)(`textarea`,{className:`project-memory-source`,"aria-label":`${t} memory for ${n}`,value:c.desiredValue(),onChange:e=>c.update(e.target.value),spellCheck:!1}),(0,s.jsxs)(`div`,{className:`project-memory-source-status`,children:[(0,s.jsx)(`span`,{children:`Memory markdown`}),(0,s.jsx)(a,{autosave:c})]})]})]})}export{f as n,c as t};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{Gt as r,O as i,mt as a}from"./dist-BPx-FyRH.js";import{t as o}from"./api-BX5xXiFs.js";import{t as s}from"./model-context-DBqdK0PS.js";import{r as c}from"./model-memory-copy-CeuXAj-T.js";import{t as l}from"./ConfirmDialog-BHFs6vmJ.js";import{Et as u,Ft as d,Tt as f,wt as p,xt as m}from"./index-DXWR4qW1.js";import{t as h}from"./CatalogBrowser-Bz8ZtxPn.js";import{t as g}from"./LicenseButton-D3VmcVG1.js";import{a as _,i as v,n as y,o as b,r as x,s as S,t as C}from"./UnrecognizedModels-Cw9Ku_bW.js";import{a as w,i as T,n as E,r as D,t as O}from"./model-quantization-BDzrELN_.js";var k=e(t(),1),A=n(),j=5e3,M=1024*1024,N=512,P=32*1024,F=4*1024,I=256;function L(e){if(e<1024)return`${Math.round(e)} MB`;let t=e/1024;return`${Number.isInteger(t)?t:t.toFixed(1)} GB`}function R({providerName:e,label:t,configuredBudgetMb:n}){let[r,i]=(0,k.useState)(null),[a,s]=(0,k.useState)(n??null),[c,l]=(0,k.useState)(!1),[u,f]=(0,k.useState)(!1),[p,m]=(0,k.useState)(null),h=(0,k.useCallback)(async()=>{try{let t=(await o.getCacheStats()).providers.find(t=>t.providerName===e)??null;i(t)}catch{}},[e]);(0,k.useEffect)(()=>{h();let e=setInterval(()=>void h(),j);return()=>clearInterval(e)},[h]),(0,k.useEffect)(()=>{s(n??null)},[n]);let g=(0,k.useCallback)(async t=>{l(!0),m(null);try{await o.updateConfig({cacheBudgetMb:{[e]:t}}),m(t===void 0?`Reset to auto`:`Saved`),await h()}catch(e){m(`Failed to save: ${e instanceof Error?e.message:String(e)}`)}finally{l(!1)}},[e,h]),_=(0,k.useCallback)(async()=>{f(!0),m(null);try{await o.clearProviderCache(e),m(`Cleared all caches`),await h()}catch(e){m(`Failed to clear: ${e instanceof Error?e.message:String(e)}`)}finally{f(!1)}},[e,h]),v=r?Math.round(r.totalBytes/M):0,y=r?Math.round(r.budgetBytes/M):0,b=d(r?.sessions,r?.warmSessionCount??0),x=r?.defaultBudgetBytes?Math.round(r.defaultBudgetBytes/M):y||2048,S=Math.min(N,x),C=r?.systemRamBytes?Math.max(x,Math.round(r.systemRamBytes/M)-F):Math.max(P,x*2),w=Math.min(Math.max(a??x,S),C),T=a===null||Math.abs(a-x)<=I,E=n!==void 0,D=(a??x)!==(n??x),O=(x-S)/Math.max(1,C-S)*100;return(0,A.jsxs)(`div`,{className:`cache-controls-panel`,children:[(0,A.jsx)(`h4`,{children:`Memory budget`}),(0,A.jsxs)(`p`,{className:`muted small`,children:[`The most memory `,t,` keeps for chat and shared-prefix context before older entries are released.`]}),r&&b.totalCount>0?(0,A.jsxs)(`p`,{className:`muted small`,children:[b.label,` · `,L(v),` used of `,L(y),r.recentHitRate>0&&(0,A.jsxs)(A.Fragment,{children:[` · `,Math.round(r.recentHitRate*100),`% hit rate (last 50 turns)`]})]}):(0,A.jsx)(`p`,{className:`muted small`,children:`No warm cache entries yet — they populate after the first turn.`}),(0,A.jsxs)(`div`,{className:`gz-budget-slider`,children:[(0,A.jsxs)(`div`,{className:`gz-budget-slider-head`,children:[(0,A.jsx)(`strong`,{children:L(w)}),T?(0,A.jsx)(`span`,{className:`gz-budget-tag`,children:`Auto (RAM-aware)`}):(0,A.jsx)(`span`,{className:`gz-budget-tag gz-budget-tag-custom`,children:`Custom`})]}),(0,A.jsxs)(`div`,{className:`gz-budget-track`,children:[(0,A.jsx)(`input`,{type:`range`,min:S,max:C,step:256,value:w,"aria-label":`Memory budget for ${t}`,onChange:e=>s(Number.parseInt(e.target.value,10))}),(0,A.jsxs)(`div`,{className:`gz-budget-marker`,style:{left:`${O}%`},title:`Suggested for this Mac: ${L(x)}`,"aria-hidden":`true`,children:[(0,A.jsx)(`span`,{className:`gz-budget-marker-arrow`,children:`▲`}),(0,A.jsxs)(`span`,{className:`gz-budget-marker-label`,children:[`Auto · `,L(x)]})]})]}),(0,A.jsxs)(`div`,{className:`gz-budget-scale muted small`,children:[(0,A.jsx)(`span`,{children:L(S)}),(0,A.jsx)(`span`,{children:L(C)})]})]}),(0,A.jsxs)(`div`,{className:`cache-budget-actions`,style:{marginTop:`0.75rem`},children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>void g(T?void 0:w),disabled:c||!D,children:c?`Saving…`:`Save`}),E&&(0,A.jsx)(`button`,{type:`button`,onClick:()=>void g(void 0),disabled:c,style:{marginLeft:`0.5rem`},children:`Reset to auto`})]}),(0,A.jsx)(`div`,{style:{marginTop:`0.75rem`},children:(0,A.jsx)(`button`,{type:`button`,onClick:()=>void _(),disabled:u||!r||b.totalCount===0,children:u?`Clearing…`:`Clear all caches`})}),p&&(0,A.jsx)(`p`,{className:`muted small`,style:{marginTop:`0.5rem`},children:p})]})}function z(e){return e.residentBytes??Math.round(e.approxSizeBytes*1.3)}function ee(e,t){return z(e)<=t}function te(e){return`~${c(e)}`}function ne(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleDateString(void 0,{year:`numeric`,month:`short`})}function B(e){return e.kind!==`chat-model`||!e.mlx||e.mlx.disabledReason?null:e}var re={"mix of experts":`Only a fraction of the model's parameters run per token, so it's faster than a dense model of the same nominal size.`,vision:`Can accept images alongside text.`,tools:`Supports function/tool calling via the API.`,multimodal:`Handles multiple input types (text + images).`,large:`Heavy model — needs a lot of memory and runs more slowly.`,small:`Compact model — runs quickly on modest hardware.`};function V({onModelsChanged:e,compact:t=!1}){let[n,c]=(0,k.useState)([]),[d,w]=(0,k.useState)(null),[T,j]=(0,k.useState)([]),[M,N]=(0,k.useState)([]),[P,F]=(0,k.useState)(new Map),[I,L]=(0,k.useState)(null),[R,z]=(0,k.useState)(null),[V,U]=(0,k.useState)(null),[W,G]=(0,k.useState)(null),[K,ae]=(0,k.useState)(null),[q,oe]=(0,k.useState)(!1),[J,se]=(0,k.useState)(`all`),[Y,ce]=(0,k.useState)(null),[le,X]=(0,k.useState)(!1),[ue,de]=(0,k.useState)([]),[fe,pe]=(0,k.useState)(new Map),[me,he]=(0,k.useState)([]),ge=(0,k.useRef)([]),Z=(0,k.useCallback)(async()=>{try{let e=await o.listModelFitness();pe(new Map(e.records.map(e=>[e.key,e]))),he(e.probing),ge.current=e.probing}catch{}},[]),_e=(0,k.useCallback)(async()=>{try{let e=await o.listIncompleteMlxModels();j(e.incomplete??[])}catch{}},[]),Q=(0,k.useCallback)(async()=>{try{let e=await o.listMlxModels();c(e.models),N(e.unrecognized??[]),w(null)}catch(e){w(e instanceof Error?e.message:String(e))}Z(),_e()},[Z,_e]);(0,k.useEffect)(()=>{Q(),o.getMemoryProfile().then(e=>ae(e)).catch(()=>{}),o.getModelContextOverrides(`mlx`).then(()=>X(!0)).catch(()=>X(!1))},[Q]),(0,k.useEffect)(()=>{let e=e=>{u(e)===`mlx`&&Q()};return window.addEventListener(p,e),()=>window.removeEventListener(p,e)},[Q]),(0,k.useEffect)(()=>{let e=!1,t=async()=>{try{let t=await o.listMlxActiveInstalls();if(e)return;F(e=>{let n=new Map(e),r=new Set;for(let e of t.installs){r.add(e.catalogId);let t=n.get(e.catalogId);t&&t.origin===`local`||n.set(e.catalogId,{catalogId:e.catalogId,fileIndex:0,fileCount:1,file:``,bytesWrittenAll:e.bytesWritten,totalBytesAll:e.totalBytes,phase:e.phase,origin:`remote`})}for(let[e,t]of n)t.origin===`remote`&&!r.has(e)&&n.delete(e);return n}),t.installs.length===0&&Q()}catch{}};t();let n=setInterval(()=>void t(),2e3);return()=>{e=!0,clearInterval(n)}},[Q]),(0,k.useEffect)(()=>{let e=!1,t,n=async()=>{await Z(),!e&&(t=setTimeout(()=>void n(),ge.current.length>0?2e3:15e3))};return n(),()=>{e=!0,t&&clearTimeout(t)}},[Z]);let ve=(0,k.useCallback)((e,t)=>{if(t.type===`progress`)F(n=>{let r=n.get(e);if(!r)return n;let i=new Map(n),{retrying:a,error:o,...s}=r;return i.set(e,{...s,fileIndex:t.fileIndex,fileCount:t.fileCount,file:t.file,bytesWrittenAll:t.bytesWrittenAll,totalBytesAll:t.totalBytesAll||r.totalBytesAll,phase:`downloading`}),i});else if(t.type===`retrying`)F(n=>{let r=n.get(e);if(!r)return n;let i=new Map(n);return i.set(e,{...r,retrying:{attempt:t.attempt,maxAttempts:t.maxAttempts,delayMs:t.delayMs,reason:t.reason,file:t.file}}),i});else if(t.type===`verifying`)F(n=>{let r=n.get(e);if(!r)return n;let i=new Map(n);return i.set(e,{...r,file:t.file,phase:`verifying`}),i});else if(t.type===`extracting-metadata`)F(t=>{let n=t.get(e);if(!n)return t;let r=new Map(t);return r.set(e,{...n,phase:`extracting-metadata`}),r});else if(t.type===`done`)t.warning&&L({id:t.id,message:t.warning});else if(t.type===`error`){if(t.mismatch){let n=t.mismatch.file;F(t=>{let n=new Map(t);return n.delete(e),n}),U({catalogId:e,file:n});return}F(n=>{let r=n.get(e);if(!r)return n;let i=new Map(n);return i.set(e,{...r,error:t.error,retrying:void 0}),i}),z(t.error)}},[]),$=(0,k.useCallback)((t,n)=>{if(P.has(t))return;z(null),U(null);let r=new AbortController;F(e=>{let n=new Map(e);return n.set(t,{catalogId:t,fileIndex:0,fileCount:1,file:``,bytesWrittenAll:0,totalBytesAll:0,phase:`downloading`,origin:`local`,controller:r}),n}),(async()=>{try{await o.installMlxModel(t,e=>ve(t,e),r.signal,n?.skipSha?{skipSha:!0}:void 0),f(`mlx`)}catch(e){if(!r.signal.aborted){let n=`download failed: ${H(e)}`;z(n),F(e=>{let r=e.get(t);if(!r)return e;let i=new Map(e);return i.set(t,{...r,error:r.error??n,retrying:void 0}),i})}}finally{F(e=>{let n=new Map(e),r=n.get(t);return r?.error?(n.set(t,{...r,controller:void 0}),n):(n.delete(t),n)}),Q(),e?.()}})()},[P,Q,ve,e]),ye=(0,k.useCallback)(e=>{U(null),$(e,{skipSha:!0})},[$]),be=(0,k.useCallback)(e=>{P.get(e)?.controller?.abort(),o.cancelMlxModelInstall(e).catch(()=>{}),F(t=>{let n=new Map(t);return n.delete(e),n})},[P]),xe=(0,k.useCallback)(async()=>{let t=W;if(t){G(null),w(null),c(e=>e.filter(e=>e.id!==t)),j(e=>e.filter(e=>e.id!==t)),N(e=>e.filter(e=>e.id!==t));try{await o.deleteMlxModel(t),f(`mlx`),await Q(),e?.()}catch(e){w(`delete failed: ${H(e)}`),Q()}}},[W,Q,e]),Se=(0,k.useMemo)(()=>new Set(n.map(e=>e.id)),[n]),Ce=(0,k.useMemo)(()=>new Set(M.map(e=>e.id)),[M]),we=(0,k.useMemo)(()=>{let e=new Set;for(let t of ue){let n=B(t.manifest);n&&e.add(n.category??`general`)}return[`all`,...[`general`,`coding`,`reasoning`,`vision`,`embedding`].filter(t=>e.has(t))]},[ue]);return(0,A.jsxs)(`div`,{className:`ollama-model-manager`,children:[P.size>0&&(0,A.jsxs)(`div`,{className:`ollama-section`,children:[(0,A.jsx)(`h4`,{children:`Downloading…`}),(0,A.jsx)(`div`,{className:`ollama-pull-list`,children:Array.from(P.values()).map(e=>(0,A.jsx)(ie,{inst:e,onCancel:()=>be(e.catalogId),onRetry:()=>{F(t=>{let n=new Map(t);return n.delete(e.catalogId),n}),z(null),$(e.catalogId)}},e.catalogId))})]}),(0,A.jsx)(C,{items:M.filter(e=>!P.has(e.id)),onUpdate:e=>$(e),onRemove:e=>G(e)}),(0,A.jsx)(S,{items:T.filter(e=>!P.has(e.id)),onResume:e=>$(e),onDelete:e=>G(e)}),V&&(0,A.jsxs)(`div`,{className:`ollama-section`,children:[(0,A.jsxs)(`div`,{className:`gz-status-pill gz-status-pill--warn`,style:{marginBottom:`0.5rem`},children:[`⚠ `,(0,A.jsx)(`code`,{children:V.catalogId}),` is newer on Hugging Face than the version Gezel knows about`]}),(0,A.jsxs)(`p`,{style:{marginBottom:`0.5rem`},children:[`The file `,(0,A.jsx)(`code`,{children:V.file}),` changed upstream, so its checksum no longer matches what this version of Gezel pinned. This is almost always a harmless upstream fix — model authors routinely re-publish chat templates and tokenizer configs — but we can't verify it automatically. You can download the current version now, or wait for a Gezel update with a refreshed catalog.`]}),(0,A.jsxs)(`div`,{style:{display:`flex`,gap:`0.75rem`},children:[(0,A.jsx)(`button`,{type:`button`,className:`gz-link-button`,onClick:()=>ye(V.catalogId),children:`Download anyway`}),(0,A.jsx)(`button`,{type:`button`,className:`gz-link-button`,onClick:()=>U(null),children:`Dismiss`})]})]}),R&&(0,A.jsx)(`div`,{className:`ollama-section`,children:(0,A.jsx)(`p`,{className:`error`,style:{marginBottom:`0.5rem`},children:R})}),I&&(0,A.jsx)(`div`,{className:`ollama-section`,children:(0,A.jsxs)(`div`,{className:`gz-status-pill gz-status-pill--warn`,style:{marginBottom:`0.5rem`},children:[`⚠ `,I.id,`: `,I.message]})}),!t&&(0,A.jsx)(y,{engine:`mlx`,onModelsChanged:e}),(n.length>0||d)&&(0,A.jsxs)(`div`,{className:`ollama-section`,children:[(0,A.jsx)(`h4`,{children:t?`Models on this device`:`Local models`}),d&&(0,A.jsx)(`p`,{className:`error`,children:d}),n.length>0&&(0,A.jsx)(`div`,{className:`ollama-model-table-wrap`,children:(0,A.jsxs)(`table`,{className:`ollama-model-table`,children:[(0,A.jsxs)(`colgroup`,{children:[(0,A.jsx)(`col`,{className:`model-name-column`}),(0,A.jsx)(`col`,{}),(0,A.jsx)(`col`,{}),(0,A.jsx)(`col`,{}),(0,A.jsx)(`col`,{}),(0,A.jsx)(`col`,{})]}),(0,A.jsx)(`thead`,{children:(0,A.jsxs)(`tr`,{children:[(0,A.jsx)(`th`,{children:`Name`}),(0,A.jsx)(`th`,{children:`Size`}),(0,A.jsx)(`th`,{children:`Quant`}),(0,A.jsx)(`th`,{title:`Effective per-turn context size after Gezel's configured limit`,children:`Context size`}),(0,A.jsx)(`th`,{title:`Representative startup and decode speed with an approximately 20K-token prompt`,children:`Fitness`}),(0,A.jsx)(`th`,{})]})}),(0,A.jsx)(`tbody`,{children:n.map(e=>{let t=e.updateAvailable===!0,n=!!P.get(e.id),a=`mlx:${e.id}`,c=fe.get(a);return(0,A.jsxs)(k.Fragment,{children:[(0,A.jsxs)(`tr`,{children:[(0,A.jsx)(`td`,{className:`model-name-table-cell`,children:(0,A.jsxs)(`div`,{className:`model-name-cell`,children:[(0,A.jsx)(`code`,{children:e.id}),(0,A.jsx)(`div`,{className:`model-name-meta`,children:t&&(0,A.jsx)(`span`,{className:`gz-status-pill gz-status-pill--warn`,title:e.updateReason??`The catalog ships different model files than the copy on disk. Update to pick them up.`,children:`out of date`})})]})}),(0,A.jsx)(O,{model:e}),(0,A.jsx)(`td`,{title:r(e.quantization),children:i(e.quantization)}),(0,A.jsx)(`td`,{title:e.effectiveContextWindow?e.overrideContextTokens===void 0?`Gezel will grant up to ${e.effectiveContextWindow.toLocaleString()} tokens per turn${e.contextWindow?`; the model advertises ${e.contextWindow.toLocaleString()} tokens`:``}.`:`You've set this model to ${e.overrideContextTokens.toLocaleString()} tokens per turn; Gezel grants up to what memory allows (currently ${e.effectiveContextWindow.toLocaleString()}).`:e.contextSizingStatus===`restart-required`?`This model is running with a different context window than the current sizing settings resolve to. Restart the local engine (or let it go idle) so Gezel can re-admit it — no memory change needed.`:e.contextSizingStatus===`insufficient-memory`?`The requested context window does not fit in memory safely. Unload another model or free memory before trying again.`:`The effective context size is unavailable.`,children:e.contextSizingStatus===`restart-required`?`Restart needed`:e.contextSizingStatus===`insufficient-memory`?`Won't fit`:(0,A.jsxs)(A.Fragment,{children:[s(e.effectiveContextWindow),e.overrideContextTokens!==void 0&&(0,A.jsx)(`span`,{className:`gz-budget-tag gz-budget-tag-custom model-context-custom-tag`,children:`custom`})]})}),(0,A.jsx)(x,{entry:c,probing:me.includes(a)}),(0,A.jsx)(`td`,{className:`model-actions-table-cell`,children:(0,A.jsxs)(`div`,{className:`model-actions-cell`,children:[(0,A.jsx)(`div`,{className:`model-action-status`,children:e.readOnly&&(0,A.jsx)(`span`,{className:`muted small`,title:`Provided by the machine-wide install (shared asset store). It can't be removed from here — manage it with the machine installer, or install a user-owned copy to shadow it.`,children:`Machine model`})}),(0,A.jsx)(`div`,{className:`model-action-links`,children:(0,A.jsx)(_,{engine:`mlx`,model:{...e,updateAvailable:t},updating:n,contextSupported:le,contextEditorOpen:Y===e.id,onToggleContextEditor:()=>ce(t=>t===e.id?null:e.id),fitnessAction:v(c,me.includes(a),()=>{o.runModelFitnessProbe(`mlx`,e.id).then(()=>Z()).catch(()=>{})}),onUpdate:()=>$(e.id),updateLabel:{idle:`Download again`,busy:`Downloading…`},onDelete:()=>G(e.id)})})]})})]}),Y===e.id&&(0,A.jsx)(`tr`,{className:`model-context-editor-row`,children:(0,A.jsx)(`td`,{colSpan:6,children:(0,A.jsx)(b,{engine:`mlx`,model:e,onSaved:Q})})})]},e.id)})})]})})]}),(0,A.jsxs)(`div`,{className:`ollama-section ollama-section--flat ollama-section--download`,children:[(0,A.jsx)(`h4`,{children:`Download a model`}),(0,A.jsxs)(`p`,{className:`muted small`,style:{marginTop:0},children:[`Models are hosted by`,` `,(0,A.jsx)(`a`,{href:`https://huggingface.co`,target:`_blank`,rel:`noreferrer`,style:{color:`inherit`},children:`Hugging Face`}),`, a community library of open, freely available AI models. Your device downloads them directly.`]}),(0,A.jsxs)(`p`,{className:`muted small`,children:[K?`Models that may not fit this machine, and retired models, are hidden by default. `:`Retired models are hidden by default. `,(0,A.jsx)(`button`,{type:`button`,className:`gz-link-button`,onClick:()=>oe(e=>!e),style:{padding:0},children:q?K?`Hide retired and oversized models`:`Hide retired models`:`Show all models`})]}),(0,A.jsx)(`div`,{className:`provider-switch`,style:{marginBottom:`0.5rem`},children:we.map(e=>(0,A.jsx)(`button`,{type:`button`,className:`provider-pill${J===e?` provider-pill-active`:``}`,onClick:()=>se(e),children:e===`all`?`All`:e[0]?.toUpperCase()+e.slice(1)},e))}),(0,A.jsx)(h,{kind:`chat-model`,emptyMessage:`No MLX-format entries in the catalog yet.`,onItemsLoaded:de,tagTooltips:re,filter:e=>{let t=B(e.manifest);return!(!t||!q&&a(t)||J!==`all`&&(t.category??`general`)!==J||!q&&K&&!ee(t.mlx,K.usableBytes))},action:e=>{let t=B(e.manifest);if(!t)return null;let n=Se.has(t.id),r=Ce.has(t.id),i=P.get(t.id),a=i&&i.totalBytesAll>0?Math.min(100,Math.round(i.bytesWrittenAll/i.totalBytesAll*100)):null,o=K?!ee(t.mlx,K.usableBytes):!1;return(0,A.jsxs)(`div`,{className:`catalog-ollama-action`,children:[(0,A.jsxs)(`div`,{className:`catalog-ollama-meta`,children:[(0,A.jsxs)(`div`,{className:`catalog-ollama-specs muted small`,children:[(0,A.jsx)(E,{repo:t.mlx.huggingfaceRepo}),(0,A.jsx)(`span`,{children:`·`}),(0,A.jsx)(`span`,{children:t.parameterSize}),(0,A.jsx)(`span`,{children:`·`}),(0,A.jsx)(`span`,{children:te(t.mlx.approxSizeBytes)}),ne(t.releasedAt)&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`span`,{children:`·`}),(0,A.jsx)(`span`,{children:ne(t.releasedAt)})]})]}),(0,A.jsxs)(`div`,{className:`catalog-ollama-pills`,children:[(0,A.jsx)(g,{manifest:t,fallbackHref:D(t.mlx.huggingfaceRepo)}),o&&(0,A.jsx)(`span`,{className:`gz-status-pill gz-status-pill--warn`,title:`Larger than your estimated inference budget — may run slowly or fail.`,children:`may not fit`})]})]}),(0,A.jsx)(`button`,{type:`button`,disabled:n||r||!!i,onClick:()=>$(t.id),children:n?`On device`:i?i.phase===`downloading`?a===null?`Downloading…`:`Downloading… ${a}%`:i.phase===`verifying`?`Verifying…`:`Reading metadata…`:r?`Needs attention above`:`Download`})]})}})]}),(0,A.jsxs)(`div`,{className:`ollama-section ollama-section--flat`,children:[(0,A.jsx)(m,{}),(0,A.jsx)(`span`,{className:`muted small`,style:{marginLeft:`0.75rem`},children:`Import from a gezel local model package`})]}),(0,A.jsx)(l,{open:W!==null,title:`Delete ${W??``}?`,message:`This removes the downloaded model from your device. It stays available in the catalog — you can download it again any time.`,confirmLabel:`Delete`,danger:!0,onConfirm:xe,onCancel:()=>G(null)})]})}function ie({inst:e,onCancel:t,onRetry:n}){let r=e.totalBytesAll>0,i=r?Math.min(100,Math.round(e.bytesWrittenAll/e.totalBytesAll*100)):0,a;if(e.error)a=e.error;else if(e.retrying){let t=Math.max(1,Math.round(e.retrying.delayMs/1e3)),n=e.fileCount>1?` on shard ${e.fileIndex}/${e.fileCount}`:``;a=`${e.retrying.reason}${n} — retrying in ${t}s (attempt ${e.retrying.attempt}/${e.retrying.maxAttempts})`}else a=e.phase===`downloading`?r?`Downloading ${c(e.bytesWrittenAll)} of ${c(e.totalBytesAll)} (${i}%)`:e.bytesWrittenAll>0?`Downloading ${c(e.bytesWrittenAll)}…`:`Preparing download…`:e.phase===`verifying`?`Checking download${e.file?` (${e.file})`:`…`}`:`Reading model info…`;let o=e.phase!==`downloading`||!r;return(0,A.jsxs)(`div`,{className:`ollama-pull${e.error?` ollama-pull-error`:e.retrying?` ollama-pull-warning`:``}`,children:[(0,A.jsxs)(`div`,{className:`ollama-pull-head`,children:[(0,A.jsx)(`code`,{children:e.catalogId}),(0,A.jsx)(`span`,{className:`muted small`,children:a}),e.error?(0,A.jsx)(`button`,{type:`button`,className:`gz-link-button`,onClick:n,children:`Retry`}):(0,A.jsx)(`button`,{type:`button`,className:`gz-link-button`,onClick:t,children:`Cancel`})]}),o?(0,A.jsx)(`div`,{className:`ollama-pull-bar ollama-pull-bar-indeterminate`,children:(0,A.jsx)(`div`,{className:`ollama-pull-bar-fill`})}):(0,A.jsxs)(`div`,{className:`ollama-pull-bar`,children:[(0,A.jsx)(`div`,{className:`ollama-pull-bar-fill`,style:{width:`${i}%`}}),(0,A.jsxs)(`span`,{className:`ollama-pull-bar-label`,children:[i,`%`]})]})]})}function H(e){return e instanceof Error?e.message:String(e)}var U=typeof navigator<`u`&&/Mac/.test(navigator.platform)&&(navigator.userAgentData?.architecture===`arm`||/Mac.*Apple/i.test(navigator.userAgent));function W({config:e,onConfigChanged:t}){let[n,r]=(0,k.useState)(e?.mlxBaseUrl??``),[i,a]=(0,k.useState)(e?.mlxModelPath??``),[s,c]=(0,k.useState)(e?.mlxPackageSpec??``),[l,u]=(0,k.useState)(null),[d,f]=(0,k.useState)([]),[p,m]=(0,k.useState)(`idle`),[h,g]=(0,k.useState)(null),[_,v]=(0,k.useState)(`idle`);(0,k.useEffect)(()=>{r(e?.mlxBaseUrl??``)},[e?.mlxBaseUrl]),(0,k.useEffect)(()=>{a(e?.mlxModelPath??``)},[e?.mlxModelPath]),(0,k.useEffect)(()=>{c(e?.mlxPackageSpec??``)},[e?.mlxPackageSpec]);let y=(0,k.useCallback)(async()=>{try{let e=await o.getMlxRuntime();u(e)}catch{u(null)}},[]);(0,k.useEffect)(()=>{y()},[y]);let b=(0,k.useCallback)(async()=>{try{let e=await o.listMlxModels();f(e.models)}catch{}},[]);(0,k.useEffect)(()=>{b()},[b]);let x=(0,k.useCallback)(()=>{b(),y()},[b,y]),S=(0,k.useCallback)(async()=>{v(`resetting`);try{await o.resetMlxRuntime(),v(`done`),setTimeout(()=>v(`idle`),3e3),y()}catch(e){v(`idle`),g(e instanceof Error?e.message:String(e))}},[y]),C=(0,k.useCallback)(async()=>{let e=n.trim();m(`saving`);try{t(await o.updateConfig({mlxBaseUrl:e===``?null:e})),m(`saved`),setTimeout(()=>m(`idle`),1200)}catch{m(`idle`)}},[n,t]),E=(0,k.useCallback)(async()=>{let e=i.trim();m(`saving`);try{t(await o.updateConfig({mlxModelPath:e===``?null:e})),m(`saved`),setTimeout(()=>m(`idle`),1200)}catch{m(`idle`)}},[i,t]),D=(0,k.useCallback)(async()=>{let e=s.trim();m(`saving`);try{t(await o.updateConfig({mlxPackageSpec:e===``?null:e})),m(`saved`),setTimeout(()=>m(`idle`),1200)}catch{m(`idle`)}},[s,t]),O=(0,k.useCallback)(async e=>{m(`saving`);try{t(await o.updateConfig({mlxKvBits:e===0?null:e})),m(`saved`),setTimeout(()=>m(`idle`),1200)}catch{m(`idle`)}},[t]),j=(0,k.useCallback)(async n=>{m(`saving`);try{t(await o.updateConfig({defaultModel:{...e?.defaultModel,mlx:n??void 0}})),m(`saved`),setTimeout(()=>m(`idle`),1200)}catch{m(`idle`)}},[e?.defaultModel,t]),M=!!e?.mlxBaseUrl;return(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`section`,{style:{marginBottom:`2rem`},children:[(0,A.jsx)(`h3`,{children:`This Mac (Apple MLX)`}),(0,A.jsx)(`p`,{className:`muted`,style:{marginTop:0},children:`On-device AI powered by Apple's MLX framework, making the best use of the hardware you already have — in many cases the best choice of engine for your Mac. Your conversations stay on your computer: no account to set up, no data sent to the cloud.`}),(0,A.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,A.jsx)(`span`,{className:`muted small`,children:`Status:`}),(0,A.jsx)(`span`,{className:`gz-status-pill gz-status-pill--ok`,children:`ready`})]}),!U&&(0,A.jsx)(`div`,{className:`gz-status-pill gz-status-pill--warn`,style:{marginTop:`0.5rem`,display:`inline-block`},children:`This machine doesn't look like Apple Silicon — chat turns routed to MLX will error out at send time.`}),M&&(0,A.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`},children:[(0,A.jsx)(`span`,{className:`gz-status-pill gz-status-pill--warn`,title:`External engine: ${e?.mlxBaseUrl}`,children:`using external engine`}),p===`saved`&&(0,A.jsx)(`span`,{className:`muted small`,children:`saved ✓`})]})]}),d.length>1&&(0,A.jsxs)(`section`,{style:{marginBottom:`2rem`},children:[(0,A.jsx)(`h4`,{children:`Default model`}),(0,A.jsx)(`p`,{className:`muted small`,style:{marginTop:0},children:`Which local model new chat sessions use when a gezel doesn't pin one.`}),(0,A.jsx)(`div`,{className:`new-row`,style:{marginTop:`0.5rem`},children:(0,A.jsxs)(`select`,{"aria-label":`Default model`,value:e?.defaultModel?.mlx??``,onChange:e=>void j(e.target.value||void 0),children:[(0,A.jsx)(`option`,{value:``,children:`First local model`}),d.map(e=>(0,A.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.id,`)`]},e.id))]})})]}),(0,A.jsx)(`section`,{style:{marginBottom:`2rem`},children:(0,A.jsx)(V,{onModelsChanged:x})}),(0,A.jsx)(w,{provider:`mlx`}),(0,A.jsxs)(`section`,{style:{marginBottom:`2rem`},children:[(0,A.jsx)(`h4`,{style:{marginBottom:`0.5rem`},children:`Concurrent replicas`}),(0,A.jsx)(`p`,{className:`muted small`,style:{marginTop:0},children:`Run multiple copies of the same model so unrelated sessions don't queue behind each other. Weights are shared by the OS via mmap so disk cost stays at one model file; resident memory grows because each clone keeps its own KV cache and activations.`}),(0,A.jsx)(T,{provider:`mlx`,modelId:e?.defaultModel?.mlx??null,config:e,onConfigChanged:t})]}),h&&(0,A.jsxs)(`div`,{className:`muted small`,style:{color:`#ff9b9b`,marginTop:`1rem`},role:`alert`,children:[h,` `,(0,A.jsx)(`button`,{type:`button`,onClick:()=>g(null),children:`dismiss`})]}),(0,A.jsx)(`section`,{style:{marginTop:`2rem`},children:(0,A.jsx)(R,{providerName:`mlx`,label:`This Mac AI`,configuredBudgetMb:e?.cacheBudgetMb?.mlx})}),(0,A.jsxs)(`details`,{className:`mlx-advanced`,style:{marginTop:`2rem`},children:[(0,A.jsx)(`summary`,{style:{cursor:`pointer`},children:(0,A.jsx)(`strong`,{children:`Advanced`})}),(0,A.jsxs)(`section`,{style:{marginTop:`1.25rem`},children:[(0,A.jsx)(`h4`,{style:{marginBottom:`0.35rem`},children:`Python runtime`}),l?(0,A.jsx)(`div`,{className:`muted small`,style:{marginTop:`0.25rem`},children:l.source===null?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(`strong`,{children:`No Python runtime available.`}),` `,l.reason??`Install Python 3.11 or wait for a packaged build that bundles uv.`]}):(0,A.jsxs)(A.Fragment,{children:[`Source: `,(0,A.jsx)(`code`,{children:l.source}),l.uvVersion&&(0,A.jsxs)(A.Fragment,{children:[` `,`· uv `,(0,A.jsx)(`code`,{children:l.uvVersion})]}),l.pythonVersion&&(0,A.jsxs)(A.Fragment,{children:[` `,`· Python `,(0,A.jsx)(`code`,{children:l.pythonVersion})]}),l.installerPath&&(0,A.jsxs)(A.Fragment,{children:[` `,`· `,(0,A.jsx)(`span`,{title:l.installerPath,children:`installer at path`})]})]})}):(0,A.jsx)(`div`,{className:`muted small`,children:`Probing…`}),(0,A.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.5rem`,alignItems:`center`},children:[(0,A.jsx)(`button`,{type:`button`,onClick:()=>void S(),disabled:_===`resetting`,children:_===`resetting`?`Resetting…`:`Reset gezel Python environment`}),_===`done`?(0,A.jsx)(`span`,{className:`gz-status-pill gz-status-pill--ok`,children:`venv was reset ✓`}):(0,A.jsx)(`span`,{className:`muted small`,children:"Deletes the `mlx` venv; the next chat turn re-provisions it."})]})]}),(0,A.jsxs)(`section`,{style:{marginTop:`1.25rem`},children:[(0,A.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.75rem`,alignItems:`center`},children:[(0,A.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`12rem`},children:`External mlx_lm.server URL`}),(0,A.jsx)(`input`,{type:`text`,placeholder:`e.g. http://127.0.0.1:8000 (leave blank for supervised)`,value:n,onChange:e=>r(e.target.value),style:{flex:1}}),(0,A.jsx)(`button`,{type:`button`,disabled:p===`saving`||n===(e?.mlxBaseUrl??``),onClick:()=>void C(),children:`Save`})]}),(0,A.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.5rem`,alignItems:`center`},children:[(0,A.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`12rem`},children:`Override model directory`}),(0,A.jsx)(`input`,{type:`text`,placeholder:`Absolute path to an MLX model dir`,value:i,onChange:e=>a(e.target.value),style:{flex:1}}),(0,A.jsx)(`button`,{type:`button`,disabled:p===`saving`||i===(e?.mlxModelPath??``),onClick:()=>void E(),children:`Save`})]}),(0,A.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.5rem`,alignItems:`center`},children:[(0,A.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`12rem`},children:`mlx-lm package spec`}),(0,A.jsx)(`input`,{type:`text`,placeholder:`e.g. mlx-lm==0.25.3 (blank → latest)`,value:s,onChange:e=>c(e.target.value),style:{flex:1}}),(0,A.jsx)(`button`,{type:`button`,disabled:p===`saving`||s===(e?.mlxPackageSpec??``),onClick:()=>void D(),children:`Save`})]}),(0,A.jsxs)(`div`,{className:`new-row`,style:{marginTop:`0.5rem`,alignItems:`center`},children:[(0,A.jsx)(`label`,{className:`muted`,style:{fontSize:`0.9rem`,minWidth:`12rem`},children:`KV cache quantization`}),(0,A.jsxs)(`select`,{value:String(e?.mlxKvBits??0),onChange:e=>void O(Number(e.target.value)),style:{flex:1},children:[(0,A.jsx)(`option`,{value:`0`,children:`Off — full precision (default)`}),(0,A.jsx)(`option`,{value:`8`,children:`8-bit — about half the memory, near-lossless`}),(0,A.jsx)(`option`,{value:`6`,children:`6-bit — smaller still`}),(0,A.jsx)(`option`,{value:`4`,children:`4-bit — smallest, some quality loss`})]})]}),(0,A.jsx)(`p`,{className:`muted small`,style:{marginTop:`0.35rem`},children:`Compresses the conversation history the model keeps in memory. That history is the biggest cost in a long chat — on a large model with a 256K context it can outweigh the model itself — and 8-bit roughly halves it at close to no quality cost. Only applies while the engine serves one chat at a time; when it is set up to handle several at once, the history stays at full precision. Takes effect the next time the engine starts.`})]})]})]})}export{W as MlxSettings};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{d as r,l as i,m as a,p as o,s}from"./primitives-DEsn1shf.js";import{en as c,j as l,r as u,st as d}from"./dist-BPx-FyRH.js";import{t as f}from"./api-BX5xXiFs.js";import{t as p}from"./GezelJsonEditor-fOvYclu9.js";import{Dt as m,Et as h,wt as g}from"./index-DXWR4qW1.js";var _=e(t(),1),v={type:`number`,title:`Temperature`,description:`How adventurous the model is when picking words. Low values (0–0.3) make replies steady and repeatable — good for code, math, structured output. Mid values (0.5–0.9) feel like a thoughtful conversation. High values (1.0+) get creative but can drift off-topic or start rambling. 0 picks the single most likely word every time.`,minimum:0,maximum:2,multipleOf:.05},y={type:`number`,title:`top_p (nucleus)`,description:`Trims the long tail of unlikely word choices. 0.95 keeps the model honest while letting it surprise you — the modern default. Lower values (0.7–0.85) make replies more predictable and stay in the safe zone. Higher values (close to 1) let weirder picks through. Usually tune temperature first, top_p second.`,minimum:0,maximum:1,multipleOf:.01},b={type:`integer`,title:`top_k`,description:`A hard ceiling on how many word choices the model considers at each step. 20 is what Qwen recommends for thinking mode. 64 is Gemma's default. 1 means 'always pick the single most likely word' — deterministic but flat. Lower top_k = more predictable; higher = more variety.`,minimum:0,maximum:1e3},x={type:`number`,title:`min_p`,description:`A floor on word probability — filters out the really unlikely tokens regardless of top_k. 0 disables. 0.05 is a mild filter that prevents the model from grabbing genuinely rare tokens. Most users leave this at 0 and tune temperature + top_p instead.`,minimum:0,maximum:1,multipleOf:.01},S={type:`integer`,title:`Max reply length (tokens)`,description:`Hard ceiling on how long one reply can be. Counts every word, punctuation mark, and reasoning token. Most chat turns fit in 2k–8k. Reasoning models that 'think out loud' need 16k+ to leave room for the actual answer after the thinking trace. Hitting this cap mid-reply cuts the model off.`,minimum:1,maximum:131072},C={type:`integer`,title:`Seed`,description:`Lock in a specific run. Same seed + same prompt = (usually) the same reply, so you can A/B test prompt changes or reproduce a bug. Leave blank for random. Cloud providers honor seed on a best-effort basis; local engines are stricter.`},w={type:`number`,title:`Repetition penalty`,description:`Punishes the model for re-using words it just said. 1.0 = off (the model is allowed to repeat freely). 1.1 = mild — catches 'I will… I'll… I will…' loops. Push above 1.2 and the model starts dodging legitimate repeats (the word 'the' starts feeling rare), and replies feel oddly stilted.`,minimum:0,maximum:3,multipleOf:.05},T={type:`integer`,title:`Repetition window (tokens)`,description:`How far back the repetition penalty looks. 20–64 catches recent loops without affecting older context. Larger windows (256+) penalize re-using words from much earlier in the chat — usually too aggressive for conversation.`,minimum:1,maximum:8192},E={type:`number`,title:`Frequency penalty`,description:`Penalty that scales with how often a word has already appeared in this reply. Positive values (0.3–0.8) discourage repeating common words; negative values encourage repetition. -2 to 2; usually 0.`,minimum:-2,maximum:2,multipleOf:.05},D={type:`number`,title:`Presence penalty`,description:`Penalty applied once any word has appeared at all in this reply (not scaled by count). Positive values (0.3–0.8) push the model toward new vocabulary; useful for brainstorming. -2 to 2; usually 0.`,minimum:-2,maximum:2,multipleOf:.05},O={type:`object`,title:`DRY anti-repetition (llama only)`,description:`Don't-Repeat-Yourself: catches longer phrase loops that simple repetition penalty misses. Helpful for small local models that get stuck repeating whole sentences. Set multiplier to 0 to disable.`,properties:{multiplier:{type:`number`,title:`Strength`,description:`How hard to penalize repeats. 0 = off. 0.8 is a reasonable starting point — strong enough to break loops without hurting normal repetition.`,minimum:0,maximum:5,multipleOf:.05},base:{type:`number`,title:`Penalty curve`,description:`How fast the penalty grows for longer repeated sequences. Higher = more aggressive on long repeats. 1.75 is the upstream default.`,minimum:0,maximum:5,multipleOf:.05},allowedLength:{type:`integer`,title:`Free length`,description:`Repeats shorter than this don't get penalized. 2 = allow 2-token repeats (small phrases), penalize anything longer.`,minimum:0,maximum:64}}},k={type:`object`,title:`XTC sampler (llama only)`,description:`Exclude-Top-Choices: occasionally throws away the most likely word and picks from the rest. Adds personality and surprise to creative writing. Skip this if you want consistency.`,properties:{probability:{type:`number`,title:`Trigger rate`,description:`How often XTC fires. 0 = never. 0.5 = half the time. Higher values make replies less predictable.`,minimum:0,maximum:1,multipleOf:.01},threshold:{type:`number`,title:`Activation threshold`,description:`Only fires when the top word is more likely than this. 0.1 = activate when the model is fairly sure (most of the time); higher values restrict XTC to high-confidence moments.`,minimum:0,maximum:1,multipleOf:.01}}},A={type:`object`,title:`Reasoning`,description:`Controls how much the model 'thinks out loud' before answering.`,properties:{effort:{type:`string`,enum:[`low`,`medium`,`high`],title:`Reasoning effort`,description:`How hard the model works before replying. Low = quick takes (fast, cheap). Medium = balanced (most common default). High = deep deliberation (slower, more thorough — best for math, code, complex planning). Maps to OpenAI's reasoning.effort and Anthropic's thinking.budget_tokens behind the scenes.`,squisq:{control:`segmented`}},thinkingBudget:{type:`integer`,title:`Thinking budget (tokens)`,description:`Explicit cap on how many tokens the model can spend thinking before it has to answer. Anthropic Claude and Nemotron use this directly. Wins over 'effort' when both are set. Typical values: 2k for quick, 8k for medium, 24k+ for deep reasoning.`,minimum:1,maximum:65536},enableThinking:{type:`boolean`,title:`Show reasoning`,description:`On = the model writes out its thinking before the final answer (often visible as a collapsible 'thinking' block). Off = the model goes straight to the answer. Mainly affects dual-mode local models like Qwen3 and Nemotron Nano/Super — cloud thinking models infer from the reasoning effort/budget.`}}},j={type:`object`,title:`Structured output`,description:`Force the model to produce machine-readable output instead of prose.`,properties:{responseFormat:{type:`string`,enum:[`text`,`json_object`],title:`Output format`,description:`Text = normal prose (default). JSON = the model must emit syntactically-valid JSON. Combine with a JSON Schema below to pin the exact shape.`,squisq:{control:`segmented`,enumLabels:{text:`Text`,json_object:`JSON`}}}}},M={type:`string`,enum:[`auto`,`required`,`none`],title:`Tool calling`,description:`Auto = the model decides whether to call a tool (normal). Required = the model MUST call a tool this turn (good for forcing structured handoffs). None = tools are hidden from the model — pure chat.`,squisq:{control:`segmented`}},N={type:`object`,title:`Reasoning prompt tags`,description:`Markers a user can include in a message to flip reasoning on/off for just that turn. Qwen recognizes /think and /no_think by default.`,properties:{enableThinkingTag:{type:`string`,title:`Enable tag`,description:"Example: `/think`. Adding this to your message turns thinking ON for that turn."},disableThinkingTag:{type:`string`,title:`Disable tag`,description:"Example: `/no_think`. Adding this to your message turns thinking OFF for that turn."}}};function P(e){return{type:`object`,title:`When thinking is on, use these instead`,description:`Some models like Qwen3 and Nemotron Nano want different sampling when reasoning. Only fill in the fields you want to change for thinking mode — the rest fall through to your main Sampling values above.`,properties:e,squisq:{hidden:{field:`reasoning.enableThinking`,truthy:!1}}}}var F={temperature:v,topP:y,topK:b,maxTokens:S,seed:C,frequencyPenalty:E,presencePenalty:D},I={type:`object`,title:`Structured output`,properties:{responseFormat:j.properties.responseFormat,jsonSchema:{type:`object`,title:`JSON Schema`,description:`OpenAI strict mode. Leave empty for free-form JSON.`,additionalProperties:!0}}},L={type:`object`,title:`Advanced tuning (cloud)`,description:`Per-turn sampling, structured output, and reasoning controls. Empty fields fall through to the catalog default. Fields the active provider doesn't support are silently dropped at request build.`,properties:{sampling:{type:`object`,title:`Sampling`,properties:F},samplingWhenThinking:P(F),reasoning:A,output:I,toolChoice:M}},R={temperature:v,topP:y,topK:b,minP:x,maxTokens:S,seed:C,repetitionPenalty:w,repetitionContext:T,frequencyPenalty:E,presencePenalty:D,dry:O,xtc:k},ee={...A,properties:{enableThinking:A.properties.enableThinking}},te={type:`object`,title:`Structured output`,properties:{responseFormat:j.properties.responseFormat,jsonSchema:{type:`object`,title:`JSON Schema`,description:"Pin output to a JSON Schema. Drives llama `--json-schema`. Leave empty for free-form JSON.",additionalProperties:!0},grammar:{type:`string`,title:`GBNF grammar`,description:`Last-resort structured-output knob. llama-only. Multi-line GBNF source.`,maxLength:4096,squisq:{control:`multiline`}}}},ne={type:`object`,title:`Advanced tuning (llama)`,description:`Per-turn sampling, structured output, and reasoning controls. Empty fields fall through to the catalog default.`,properties:{sampling:{type:`object`,title:`Sampling`,properties:R},samplingWhenThinking:P(R),reasoning:ee,output:te,toolChoice:M,promptTags:N}},z={temperature:v,topP:y,topK:b,minP:x,maxTokens:S,seed:C,repetitionPenalty:w,repetitionContext:T},re={...A,properties:{enableThinking:A.properties.enableThinking}},ie={type:`object`,title:`Advanced tuning (MLX)`,description:`Per-turn sampling and reasoning controls. Empty fields fall through to the catalog default.`,properties:{sampling:{type:`object`,title:`Sampling`,properties:z},samplingWhenThinking:P(z),reasoning:re,output:j,toolChoice:M,promptTags:N}},B={temperature:v,topP:y,topK:b,minP:x,maxTokens:S,seed:C,repetitionPenalty:w,repetitionContext:T,frequencyPenalty:E,presencePenalty:D},ae={...A,properties:{enableThinking:A.properties.enableThinking}},oe={type:`object`,title:`Structured output`,properties:{responseFormat:j.properties.responseFormat,jsonSchema:{type:`object`,title:`JSON Schema`,description:"Pin output to a JSON Schema. Maps to Ollama 0.5+ `format: <schema>`. Leave empty for free-form JSON.",additionalProperties:!0}}},se={type:`object`,title:`Advanced tuning (Ollama)`,description:`Per-turn sampling, structured output, and reasoning controls. Empty fields fall through to the catalog default.`,properties:{sampling:{type:`object`,title:`Sampling`,properties:B},samplingWhenThinking:P(B),reasoning:ae,output:oe,promptTags:N}};function ce(e){switch(e){case`llama-cpp`:case`ds4`:return ne;case`mlx`:return ie;case`ollama`:return se;case`openai`:case`anthropic`:case`anthropic-cli`:case`codex-cli`:case`copilot`:return L;case`remote`:return L;default:return e}}var V=n();function le({provider:e,override:t,inherited:n,onSave:r,scopeLabel:i=`this scope`,disabled:a,tuningProfileId:o}){let s=(0,_.useMemo)(()=>ce(e),[e]),l=(0,_.useMemo)(()=>fe(s,n??{}),[s,n]),f=(0,_.useMemo)(()=>H(n??{},t??{}),[n,t]),[m,h]=(0,_.useState)(f),[g,v]=(0,_.useState)(!1),[y,b]=(0,_.useState)(null);(0,_.useEffect)(()=>{h(f)},[f]);let x=(0,_.useCallback)(e=>{h(e??{})},[]),S=(0,_.useMemo)(()=>ue(m,n??{}),[m,n]),C=S!==null,w=(0,_.useMemo)(()=>S?G(S):`(none)`,[S]),T=(0,_.useMemo)(()=>G(m)||`(provider defaults)`,[m]),E=(0,_.useMemo)(()=>G(n??{})||`(provider defaults)`,[n]),D=(0,_.useMemo)(()=>{if(o)return c(o,Object.keys(n?.profiles??{}))},[o,n]),O=(0,_.useMemo)(()=>{if(!o)return null;if(D){let e=d(D)?u[D].label:D,t=D!==o,n=d(o)?u[o].label:o;return t?`${e} (fallback from ${n} — model doesn't define it)`:e}return`${o} (not defined on this model — base tuning applies)`},[o,D]),k=(0,_.useCallback)(async()=>{v(!0),b(null);try{await r(S)}catch(e){b(e instanceof Error?e.message:String(e))}finally{v(!1)}},[S,r]),A=(0,_.useCallback)(async()=>{v(!0),b(null);try{await r(null),h(n??{})}catch(e){b(e instanceof Error?e.message:String(e))}finally{v(!1)}},[n,r]);return(0,V.jsxs)(`div`,{className:`tuning-panel`,children:[(0,V.jsxs)(`div`,{className:`tuning-panel-summary small`,style:{display:`flex`,flexDirection:`column`,gap:`0.25rem`,marginBottom:`0.5rem`},children:[O&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`strong`,{children:`Active voice:`}),` `,(0,V.jsx)(`span`,{className:`muted`,children:O})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`strong`,{children:`Effective now:`}),` `,(0,V.jsx)(`span`,{className:`muted`,children:T})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`strong`,{children:`Inherited default:`}),` `,(0,V.jsx)(`span`,{className:`muted`,children:E})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`strong`,{children:[`Your override for `,i,`:`]}),` `,(0,V.jsx)(`span`,{className:C?``:`muted`,children:w})]})]}),(0,V.jsx)(p,{schema:l,value:m,onChange:x,density:`compact`}),(0,V.jsxs)(`div`,{className:`tuning-panel-actions`,style:{marginTop:`0.5rem`},children:[(0,V.jsx)(`button`,{type:`button`,onClick:k,disabled:a||g,children:g?`Saving…`:C?`Save override for ${i}`:`Save (no override)`}),t&&Object.keys(t).length>0&&(0,V.jsx)(`button`,{type:`button`,onClick:A,disabled:a||g,className:`muted`,style:{marginLeft:`0.5rem`},children:`Reset to inherited defaults`})]}),y&&(0,V.jsx)(`div`,{className:`tuning-panel-error small error`,style:{marginTop:`0.25rem`},children:y})]})}function H(e,t){let n={...e};for(let[e,r]of Object.entries(t)){if(r===void 0)continue;let t=n[e];t&&typeof t==`object`&&!Array.isArray(t)&&r&&typeof r==`object`&&!Array.isArray(r)?n[e]=H(t,r):n[e]=r}return n}function ue(e,t){let n=U(e,t);return n===null?null:n}function U(e,t){let n={},r=!1;for(let[i,a]of Object.entries(e)){let e=t[i];if(a!=null)if(typeof a==`object`&&!Array.isArray(a)&&typeof e==`object`&&e&&!Array.isArray(e)){let t=U(a,e);t!==null&&(n[i]=t,r=!0)}else de(a,e)||(n[i]=a,r=!0)}return r?n:null}function de(e,t){return e===t?!0:typeof e==typeof t?Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((e,n)=>de(e,t[n])):JSON.stringify(e)===JSON.stringify(t):!1}function fe(e,t){return W(e,t)}function W(e,t){let n={...e};if(n.properties){let e={};for(let[r,i]of Object.entries(n.properties))e[r]=W(i,t&&typeof t==`object`?t[r]:void 0);n.properties=e}if(n.type!==`object`&&t!=null){let e=pe(t);if(e!==null){let t=n.description??``;n.description=t?`${t}\n\nDefault: ${e}`:`Default: ${e}`}}return n}function pe(e){return typeof e==`number`?String(e):typeof e==`boolean`?e?`on`:`off`:typeof e==`string`?e:null}function G(e){let t=[];if(e.sampling){let n=e.sampling,r=[];n.temperature!==void 0&&r.push(`temp ${n.temperature}`),n.topP!==void 0&&r.push(`top_p ${n.topP}`),n.topK!==void 0&&r.push(`top_k ${n.topK}`),n.minP!==void 0&&r.push(`min_p ${n.minP}`),n.maxTokens!==void 0&&r.push(`max ${n.maxTokens}`),n.seed!==void 0&&r.push(`seed ${n.seed}`),n.repetitionPenalty!==void 0&&r.push(`rep ${n.repetitionPenalty}`),n.frequencyPenalty!==void 0&&r.push(`freq ${n.frequencyPenalty}`),n.presencePenalty!==void 0&&r.push(`pres ${n.presencePenalty}`),r.length>0&&t.push(r.join(`, `))}if(e.reasoning){let n=e.reasoning;n.effort&&t.push(`effort ${n.effort}`),n.thinkingBudget!==void 0&&t.push(`budget ${n.thinkingBudget}`),n.enableThinking===!0&&t.push(`thinking on`),n.enableThinking===!1&&t.push(`thinking off`)}return e.output?.responseFormat&&e.output.responseFormat!==`text`&&t.push(`format ${e.output.responseFormat}`),e.toolChoice&&t.push(`tools ${e.toolChoice}`),e.samplingWhenThinking&&Object.keys(e.samplingWhenThinking).length>0&&t.push(`+thinking sampling`),e.promptTags?.enableThinkingTag&&t.push(`tag ${e.promptTags.enableThinkingTag}`),t.join(` · `)}var K=new Map,q=new Map,J=new Map;function Y(e){J.set(e,(J.get(e)??0)+1),q.delete(e),K.delete(e)}async function X(e,t=!1){if(t&&Y(e),!t){let t=q.get(e);if(t)return t;let n=K.get(e);if(n)return n}let n=J.get(e)??0,r=(e===`remote`?me():f.listProviderModels(e,t?{refresh:!0}:void 0).then(e=>e.models)).then(t=>((J.get(e)??0)===n&&q.set(e,t),t)).finally(()=>{K.get(e)===r&&K.delete(e)});return K.set(e,r),r}async function me(){let{remotes:e}=await f.listRemotes(),t=[];for(let n of e)try{let{models:e}=await f.listRemoteModels(n.remoteId);for(let r of e)t.push({id:r.id,name:`${n.displayName} · ${r.name}`,...r.supportsTools===void 0?{}:{supportsTools:r.supportsTools},...r.supportsReasoning===void 0?{}:{supportsReasoning:r.supportsReasoning},...r.contextWindow?{contextWindow:r.contextWindow}:{},...r.parameterSize?{parameterSize:r.parameterSize}:{}})}catch{}return t}function Z(e){return e===`mlx`||e===`llama-cpp`}function he(e){return e===`mlx`||e===`llama-cpp`||e===`ds4`}var Q=null,$=null;async function ge(){return Q||$||($=f.listModelFitness().then(e=>(Q=new Map(e.records.map(e=>[e.key,e])),Q)).finally(()=>{$=null}),$)}async function _e(e){let[t,n]=await Promise.all([e===`mlx`?f.listMlxModels():f.listLlamaCppModels(),e===`mlx`?f.listMlxActiveInstalls():f.listLlamaCppActiveInstalls()]);return t.models.length===0?{activeInstallsCount:n.installs.length}:null}function ve({provider:e,value:t,onChange:n,placeholder:c=`Provider default`}){let[u,d]=(0,_.useState)(q.get(e)??null),[f,p]=(0,_.useState)(!q.has(e)),[v,y]=(0,_.useState)(null),[b,x]=(0,_.useState)(null),[S,C]=(0,_.useState)(!1),[w,T]=(0,_.useState)(t??``),[E,D]=(0,_.useState)(Q),[O,k]=(0,_.useState)(0),A=(0,_.useRef)(null);(0,_.useEffect)(()=>{let t=t=>{let n=h(t);n===e&&(A.current=n,Y(e),k(e=>e+1))};return window.addEventListener(g,t),()=>window.removeEventListener(g,t)},[e]),(0,_.useEffect)(()=>{if(e!==`llama-cpp`&&e!==`ds4`)return;let t=!1;return ge().then(e=>{t||D(e)}).catch(()=>{}),()=>{t=!0}},[e]),(0,_.useEffect)(()=>{p(!q.has(e)),d(q.get(e)??null),y(null),x(null),C(!1);let t=!1;return X(e,he(e)&&(A.current===e&&O>0||m(e)>0)).then(async n=>{if(!t){if(Z(e))try{let n=await _e(e);if(t)return;if(n){x(n),p(!1);return}}catch{}d(n),p(!1)}}).catch(async n=>{if(!t){if(Z(e))try{let n=await _e(e);if(t)return;if(n){x(n),p(!1);return}}catch{}y(n.message),p(!1)}}),()=>{t=!0}},[e,O]),(0,_.useEffect)(()=>{T(t??``)},[t]);let j=(0,_.useMemo)(()=>!t||!u?!1:!u.some(e=>e.id===t),[t,u]),M=(0,_.useCallback)(e=>{if(e===`__OTHER__`){C(!0),T(t??``);return}e!==`__CUSTOM__`&&n(e===`__DEFAULT__`?void 0:e)},[n,t]),N=(0,_.useCallback)(()=>{n(w.trim()||void 0),C(!1)},[w,n]);if(f)return(0,V.jsx)(`span`,{className:`muted small`,children:`loading models…`});if(b){let e=b.activeInstallsCount;return(0,V.jsx)(`span`,{className:`muted small`,children:e>0?`No models downloaded; ${e} download${e===1?``:`s`} in progress`:`No models downloaded`})}if(v)return(0,V.jsx)(`span`,{className:`error small`,title:v,children:`failed to load`});if(S)return(0,V.jsxs)(`span`,{className:`model-picker-other`,children:[(0,V.jsx)(`input`,{type:`text`,value:w,onChange:e=>T(e.target.value),placeholder:`Model ID`}),(0,V.jsx)(`button`,{type:`button`,onClick:N,children:`Save`}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>{C(!1),T(t??``)},children:`Cancel`})]});let P=j?`__CUSTOM__`:t||`__DEFAULT__`,F=t?u?.find(e=>e.id===t):void 0,I=F&&F.supportsTools===!1,L=t&&(e===`llama-cpp`||e===`ds4`)?E?.get(`${e}:${t}`):void 0,R=L&&!L.stale&&L.record.status===`probed`?l({fitness:{record:L.record,stale:L.stale,hardwareChanged:L.hardwareChanged}}):null;return(0,V.jsxs)(`span`,{className:`model-picker-wrap`,children:[(0,V.jsxs)(r,{value:P,onValueChange:M,children:[(0,V.jsx)(o,{children:(0,V.jsx)(a,{placeholder:c})}),(0,V.jsxs)(s,{children:[(0,V.jsx)(i,{value:`__DEFAULT__`,children:c}),u?.map(e=>(0,V.jsxs)(i,{value:e.id,children:[e.name,e.supportsReasoning?` · reasoning`:``]},e.id)),j&&(0,V.jsxs)(i,{value:`__CUSTOM__`,children:[t,` (custom)`]}),(0,V.jsx)(i,{value:`__OTHER__`,children:`Other…`})]})]}),I&&(0,V.jsx)(`span`,{className:`model-picker-warn`,title:`This model doesn't support structured tool calls, so gezellen on it can't use MCP tools (read/write files, create tasks, etc.). Pick a tool-capable model (llama3.1+, qwen2.5+, mistral, gpt-oss, etc.) if you need tool use.`,children:`no tools`}),R?.tier===`warn`&&(0,V.jsxs)(`span`,{className:`model-picker-warn`,title:R.detail,children:[`fitness: `,R.label]})]})}function ye({provider:e,model:t,value:n,onChange:c}){let[l,u]=(0,_.useState)(q.get(e)??null);if((0,_.useEffect)(()=>{X(e).then(u).catch(()=>{})},[e]),!t||!l)return null;let d=l.find(e=>e.id===t);if(!d?.supportsReasoning)return null;let f=d.reasoningEfforts??[`low`,`medium`,`high`],p=d.defaultReasoningEffort?`Default (${d.defaultReasoningEffort})`:`Default`;return(0,V.jsxs)(r,{value:n||`__DEFAULT__`,onValueChange:e=>c(e===`__DEFAULT__`?void 0:e),children:[(0,V.jsx)(o,{"aria-label":`Reasoning effort`,children:(0,V.jsx)(a,{})}),(0,V.jsxs)(s,{children:[(0,V.jsx)(i,{value:`__DEFAULT__`,children:p}),f.map(e=>(0,V.jsx)(i,{value:e,children:e},e))]})]})}var be={minimal:`Minimal`,low:`Low`,medium:`Medium`,high:`High`,xhigh:`Extra high`,max:`Maximum`,ultra:`Ultra`};function xe({provider:e,model:t,defaultModel:n,value:r,onChange:i}){let[a,o]=(0,_.useState)(q.get(e)??null);if((0,_.useEffect)(()=>{let t=!1;return X(e).then(e=>{t||o(e)}).catch(()=>{}),()=>{t=!0}},[e]),!a)return(0,V.jsx)(`span`,{className:`muted small`,children:`loading effort levels…`});let s=a.find(e=>e.id===(t??n));if(!s?.supportsReasoning)return null;let c=s.reasoningEfforts??[`low`,`medium`,`high`];return(0,V.jsx)(`div`,{className:`gz-tray reasoning-effort-tray`,role:`radiogroup`,"aria-label":`Reasoning effort`,children:[[void 0,s.defaultReasoningEffort?`Model default (${be[s.defaultReasoningEffort]??s.defaultReasoningEffort})`:`Model default`],...c.map(e=>[e,be[e]??e])].map(([e,t])=>{let n=r===e||!r&&e===void 0;return(0,V.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":n,className:`gz-key${n?` gz-key-active`:``}`,onClick:()=>i(e),children:t},e??`__DEFAULT__`)})})}export{le as i,xe as n,ve as r,ye as t};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{t as r}from"./react-dom-OL4w_gzs.js";import{F as i,G as a,I as o,J as s,K as c,L as l,N as u,P as d,Q as f,R as p,W as m,X as h,Y as g,Z as _,j as v,k as y,q as ee}from"./primitives-DEsn1shf.js";import{a as b,i as te,n as x,o as S,r as C,t as w}from"./DropdownMenu-D5fCzIrh.js";import{n as T}from"./relative-time-B2kBaekd.js";import{t as ne}from"./FileTypeIcon-Cwzl1GkZ.js";var E=e(t(),1),D=Object.defineProperty,O=(e,t)=>D(e,`name`,{value:t,configurable:!0}),k=!!(typeof window<`u`&&window.document&&window.document.createElement);function A(e,t,{checkForDefaultPrevented:n=!0}={}){return O(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}O(A,`composeEventHandlers`);function re(e){if(!k)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}O(re,`getOwnerWindow`);function ie(e){if(!k)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}O(ie,`getOwnerDocument`);function ae(e,t=!1){let{activeElement:n}=ie(e);if(!n?.nodeName)return null;if(j(n)&&n.contentDocument)return ae(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=ie(n).getElementById(e);if(t)return t}}return n}O(ae,`getActiveElement`);function j(e){return e.tagName===`IFRAME`}O(j,`isFrame`);var M=n(),oe=Object.defineProperty,N=(e,t)=>oe(e,`name`,{value:t,configurable:!0});function se(e,t){let n=E.createContext(t);n.displayName=e+`Context`;let r=N(e=>{let{children:t,...r}=e,i=E.useMemo(()=>r,Object.values(r));return(0,M.jsx)(n.Provider,{value:i,children:t})},`Provider`);r.displayName=e+`Provider`;function i(r,i={}){let{optional:a=!1}=i,o=E.useContext(n);if(o)return o;if(t!==void 0)return t;if(!a)throw Error(`\`${r}\` must be used within \`${e}\``)}return N(i,`useContext`),[r,i]}N(se,`createContext`);function P(e,t=[]){let n=[];function r(t,r){let i=E.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=N(t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=E.useMemo(()=>o,Object.values(o));return(0,M.jsx)(s.Provider,{value:c,children:r})},`Provider`);o.displayName=t+`Provider`;function s(n,o,s={}){let{optional:c=!1}=s,l=o?.[e]?.[a]||i,u=E.useContext(l);if(u)return u;if(r!==void 0)return r;if(!c)throw Error(`\`${n}\` must be used within \`${t}\``)}return N(s,`useContext`),[o,s]}N(r,`createContext`);let i=N(()=>{let t=n.map(e=>E.createContext(e));return N(function(n){let r=n?.[e]||t;return E.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])},`useScope`)},`createScope`);return i.scopeName=e,[r,ce(i,...t)]}N(P,`createContextScope`);function ce(...e){let t=e[0];if(e.length===1)return t;let n=N(()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return N(function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return E.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])},`useComposedScopes`)},`createScope`);return n.scopeName=t.scopeName,n}N(ce,`composeContextScopes`);var le=e(r(),1),F=Object.defineProperty,I=(e,t)=>F(e,`name`,{value:t,configurable:!0});function ue(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}I(ue,`setRef`);function de(...e){return t=>{let n=!1,r=e.map(e=>{let r=ue(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():ue(e[t],null)}}}}I(de,`composeRefs`);function L(...e){return E.useCallback(de(...e),e)}I(L,`useComposedRefs`);var fe=Object.defineProperty,R=(e,t)=>fe(e,`name`,{value:t,configurable:!0});function z(e){let t=E.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,s=[];be(r)&&typeof we==`function`&&(r=we(r._payload)),E.Children.forEach(r,e=>{if(ve(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;be(n)&&typeof we==`function`&&(n=we(n._payload)),a=he(t,n),s.push(a?.props?.children)}else s.push(e)}),a?a=E.cloneElement(a,void 0,s):!o&&E.Children.count(r)===1&&E.isValidElement(r)&&(a=r);let c=a?_e(a):void 0,l=L(n,c);if(!a){if(r||r===0)throw Error(o?Ce(e):Se(e));return r}let u=ge(i,a.props??{});return a.type!==E.Fragment&&(u.ref=n?l:c),E.cloneElement(a,u)});return t.displayName=`${e}.Slot`,t}R(z,`createSlot`);var pe=Symbol.for(`radix.slottable`);function me(e){let t=R(e=>`child`in e?e.children(e.child):e.children,`Slottable`);return t.displayName=`${e}.Slottable`,t.__radixId=pe,t}R(me,`createSlottable`);var he=R((e,t)=>{if(`child`in e.props){let t=e.props.child;return E.isValidElement(t)?E.cloneElement(t,void 0,e.props.children(t.props.children)):null}return E.isValidElement(t)?t:null},`getSlottableElementFromSlottable`);function ge(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}R(ge,`mergeProps`);function _e(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}R(_e,`getElementRef`);function ve(e){return E.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===pe}R(ve,`isSlottable`);var ye=Symbol.for(`react.lazy`);function be(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===ye&&`_payload`in e&&xe(e._payload)}R(be,`isLazyComponent`);function xe(e){return typeof e==`object`&&!!e&&`then`in e}R(xe,`isPromiseLike`);var Se=R(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,`createSlotError`),Ce=R(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,`createSlottableError`),we=E.use,Te=Object.defineProperty,Ee=(e,t)=>Te(e,`name`,{value:t,configurable:!0}),B=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=z(`Primitive.${t}`),r=E.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,M.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function De(e,t){e&&le.flushSync(()=>e.dispatchEvent(t))}Ee(De,`dispatchDiscreteCustomEvent`);var Oe=Object.defineProperty,V=(e,t)=>Oe(e,`name`,{value:t,configurable:!0});function ke(e){let t=e+`CollectionProvider`,[n,r]=P(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=V(e=>{let{scope:t,children:n}=e,r=E.useRef(null),a=E.useRef(new Map).current;return(0,M.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})},`CollectionProvider`);o.displayName=t;let s=e+`CollectionSlot`,c=z(s),l=E.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=L(t,a(s,n).collectionRef);return(0,M.jsx)(c,{ref:i,children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=z(u),p=E.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=E.useRef(null),s=L(t,o),c=a(u,n);return E.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,M.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return E.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return V(m,`useCollection`),[{Provider:o,Slot:l,ItemSlot:p},m,r]}V(ke,`createCollection`);var Ae=new WeakMap,je=class e extends Map{static{V(this,`OrderedDict`)}#e;constructor(e){super(e),this.#e=[...super.keys()],Ae.set(this,!0)}set(e,t){return Ae.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,t),this}insert(e,t,n){let r=this.has(t),i=this.#e.length,a=Pe(e),o=a>=0?a:i+a,s=o<0||o>=i?-1:o;if(s===this.size||r&&s===this.size-1||s===-1)return this.set(t,n),this;let c=this.size+ +!r;a<0&&o++;let l=[...this.#e],u,d=!1;for(let e=o;e<c;e++)if(o===e){let i=l[e];l[e]===t&&(i=l[e+1]),r&&this.delete(t),u=this.get(i),this.set(t,n)}else{!d&&l[e-1]===t&&(d=!0);let n=l[d?e:e-1],r=u;u=this.get(n),this.delete(n),this.set(n,r)}return this}with(t,n,r){let i=new e(this);return i.insert(t,n,r),i}before(e){let t=this.#e.indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r,t,n)}after(e){let t=this.#e.indexOf(e);if(t=t===-1||t===this.size-1?-1:t+1,t!==-1)return this.entryAt(t)}setAfter(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r+1,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let t=super.delete(e);return t&&this.#e.splice(this.#e.indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return t!==void 0&&this.delete(t)}at(e){let t=Me(this.#e,e);if(t!==void 0)return this.get(t)}entryAt(e){let t=Me(this.#e,e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return Me(this.#e,e)}from(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return r;n++}}findIndex(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return n;n++}return-1}filter(t,n){let r=[],i=0;for(let e of this)Reflect.apply(t,n,[e,i,this])&&r.push(e),i++;return new e(r)}map(t,n){let r=[],i=0;for(let e of this)r.push([e[0],Reflect.apply(t,n,[e,i,this])]),i++;return new e(r)}reduce(...e){let[t,n]=e,r=0,i=n??this.at(0);for(let n of this)i=r===0&&e.length===1?n:Reflect.apply(t,this,[i,n,r,this]),r++;return i}reduceRight(...e){let[t,n]=e,r=n??this.at(-1);for(let n=this.size-1;n>=0;n--){let i=this.at(n);r=n===this.size-1&&e.length===1?i:Reflect.apply(t,this,[r,i,n,this])}return r}toSorted(t){let n=[...this.entries()].sort(t);return new e(n)}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),r=this.get(n);t.set(n,r)}return t}toSpliced(...t){let n=[...this.entries()];return n.splice(...t),new e(n)}slice(t,n){let r=new e,i=this.size-1;if(t===void 0)return r;t<0&&(t+=this.size),n!==void 0&&n>0&&(i=n-1);for(let e=t;e<=i;e++){let t=this.keyAt(e),n=this.get(t);r.set(t,n)}return r}every(e,t){let n=0;for(let r of this){if(!Reflect.apply(e,t,[r,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return!0;n++}return!1}};function Me(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=Ne(e,t);return n===-1?void 0:e[n]}V(Me,`at`);function Ne(e,t){let n=e.length,r=Pe(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}V(Ne,`toSafeIndex`);function Pe(e){return e!==e||e===0?0:Math.trunc(e)}V(Pe,`toSafeInteger`);function Fe(e){let t=e+`CollectionProvider`,[n,r]=P(t),[i,a]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new je,setItemMap:V(()=>void 0,`setItemMap`)}),o=V(({state:e,...t})=>e?(0,M.jsx)(c,{...t,state:e}):(0,M.jsx)(s,{...t}),`CollectionProvider`);o.displayName=t;let s=V(e=>{let t=h();return(0,M.jsx)(c,{...e,state:t})},`CollectionInit`);s.displayName=t+`Init`;let c=V(e=>{let{scope:t,children:n,state:r}=e,a=E.useRef(null),[o,s]=E.useState(null),c=L(a,s),[l,u]=r;return E.useEffect(()=>{if(!o)return;let e=ze(()=>{});return e.observe(o,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[o]),(0,M.jsx)(i,{scope:t,itemMap:l,setItemMap:u,collectionRef:c,collectionRefObject:a,collectionElement:o,children:n})},`CollectionProviderImpl`);c.displayName=t+`Impl`;let l=e+`CollectionSlot`,u=z(l),d=E.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=L(t,a(l,n).collectionRef);return(0,M.jsx)(u,{ref:i,children:r})});d.displayName=l;let f=e+`CollectionItemSlot`,p=z(f),m=E.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=E.useRef(null),[s,c]=E.useState(null),l=L(t,o,c),{setItemMap:u}=a(f,n),d=E.useRef(i);Ie(d.current,i)||(d.current=i);let m=d.current;return E.useEffect(()=>{let e=m;return u(t=>s?t.has(s)?t.set(s,{...e,element:s}).toSorted(Re):(t.set(s,{...e,element:s}),t.toSorted(Re)):t),()=>{u(e=>!s||!e.has(s)?e:(e.delete(s),new je(e)))}},[s,m,u]),(0,M.jsx)(p,{"data-radix-collection-item":``,ref:l,children:r})});m.displayName=f;function h(){return E.useState(new je)}V(h,`useInitCollection`);function g(t){let{itemMap:n}=a(e+`CollectionConsumer`,t);return n}return V(g,`useCollection`),[{Provider:o,Slot:d,ItemSlot:m},{createCollectionScope:r,useCollection:g,useInitCollection:h}]}V(Fe,`createCollection`);function Ie(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||e[r]!==t[r])return!1;return!0}V(Ie,`shallowEqual`);function Le(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}V(Le,`isElementPreceding`);function Re(e,t){return!e[1].element||!t[1].element?0:Le(e[1].element,t[1].element)?-1:1}V(Re,`sortByDocumentPosition`);function ze(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}V(ze,`getChildListObserver`);var Be=Object.defineProperty,Ve=(e,t)=>Be(e,`name`,{value:t,configurable:!0}),He=E.createContext(void 0);function Ue(e){let t=E.useContext(He);return e||t||`ltr`}Ve(Ue,`useDirection`);var We=Object.defineProperty,Ge=(e,t)=>We(e,`name`,{value:t,configurable:!0});function H(e){let t=E.useRef(e);return E.useEffect(()=>{t.current=e}),E.useMemo(()=>((...e)=>t.current?.(...e)),[])}Ge(H,`useCallbackRef`);var Ke=Object.defineProperty,U=(e,t)=>Ke(e,`name`,{value:t,configurable:!0}),qe=`dismissableLayer.update`,Je=`dismissableLayer.pointerDownOutside`,Ye=`dismissableLayer.focusOutside`,Xe,Ze=E.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Qe=E.forwardRef(U(function(e,t){let{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:s,onDismiss:c,...l}=e,u=E.useContext(Ze),[d,f]=E.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=E.useState({}),h=L(t,f),g=Array.from(u.layers),[_]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=_?g.indexOf(_):-1,y=d?g.indexOf(d):-1,ee=u.layersWithOutsidePointerEventsDisabled.size>0,b=y>=v,te=E.useRef(!1),x=tt(e=>{a?.(e),s?.(e),e.defaultPrevented||c?.()},{ownerDocument:p,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:te,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:E.useCallback(e=>{if(!(e instanceof Node))return!1;let t=[...u.branches].some(t=>t.contains(e));return b&&!t},[u.branches,b])}),S=nt(e=>{if(r&&te.current)return;let t=e.target;[...u.branches].some(e=>e.contains(t))||(o?.(e),s?.(e),e.defaultPrevented||c?.())},p),C=d?y===g.length-1:!1,w=H(e=>{e.key===`Escape`&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))});return E.useEffect(()=>{if(C)return p.addEventListener(`keydown`,w,{capture:!0}),()=>p.removeEventListener(`keydown`,w,{capture:!0})},[p,C,w]),E.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Xe=p.body.style.pointerEvents,p.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),rt(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(d),u.layersWithOutsidePointerEventsDisabled.size===0&&(p.body.style.pointerEvents=Xe))}},[d,p,n,u]),E.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),rt())},[d,u]),E.useEffect(()=>{let e=U(()=>m({}),`handleUpdate`);return document.addEventListener(qe,e),()=>document.removeEventListener(qe,e)},[]),(0,M.jsx)(B.div,{...l,ref:h,style:{pointerEvents:ee?b?`auto`:`none`:void 0,...e.style},onFocusCapture:A(e.onFocusCapture,S.onFocusCapture),onBlurCapture:A(e.onBlurCapture,S.onBlurCapture),onPointerDownCapture:A(e.onPointerDownCapture,x.onPointerDownCapture)})},`DismissableLayer`));function $e(){let e=E.useContext(Ze),[t,n]=E.useState(null);return E.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}U($e,`useDismissableLayerSurface`);var et=U(()=>!0,`IS_TRUE`);function tt(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=et}=t,s=H(e),c=E.useRef(!1),l=E.useRef(!1),u=E.useRef(new Map),d=E.useRef(()=>{});return E.useEffect(()=>{function e(){l.current=!1,i.current=!1,u.current.clear()}U(e,`resetOutsideInteraction`);function t(){return Array.from(u.current.values()).some(Boolean)}U(t,`isOutsideInteractionIntercepted`);function f(e){if(!l.current)return;let t=e.target;t instanceof Node&&[...a].some(e=>e.contains(t))||u.current.set(e.type,!0),e.type===`click`&&window.setTimeout(()=>{l.current&&d.current()},0)}U(f,`handleInteractionCapture`);function p(e){l.current&&u.current.set(e.type,!1)}U(p,`handleInteractionBubble`);let m=U(a=>{if(a.target&&!c.current){let f=function(){n.removeEventListener(`click`,d.current);let r=t();e(),r||it(Je,s,p,{discrete:!0})};if(U(f,`handleAndDispatchPointerDownOutsideEvent`),!o(a.target)){n.removeEventListener(`click`,d.current),e(),c.current=!1;return}let p={originalEvent:a};l.current=!0,i.current=r&&a.button===0,u.current.clear(),!r||a.button!==0?f():(n.removeEventListener(`click`,d.current),d.current=f,n.addEventListener(`click`,d.current,{once:!0}))}else n.removeEventListener(`click`,d.current),e();c.current=!1},`handlePointerDown`),h=[`pointerup`,`mousedown`,`mouseup`,`touchstart`,`touchend`,`click`];for(let e of h)n.addEventListener(e,f,!0),n.addEventListener(e,p);let g=window.setTimeout(()=>{n.addEventListener(`pointerdown`,m)},0);return()=>{window.clearTimeout(g),n.removeEventListener(`pointerdown`,m),n.removeEventListener(`click`,d.current);for(let e of h)n.removeEventListener(e,f,!0),n.removeEventListener(e,p)}},[n,s,r,i,a,o]),{onPointerDownCapture:U(()=>c.current=!0,`onPointerDownCapture`)}}U(tt,`usePointerDownOutside`);function nt(e,t=globalThis?.document){let n=H(e),r=E.useRef(!1);return E.useEffect(()=>{let e=U(e=>{e.target&&!r.current&&it(Ye,n,{originalEvent:e},{discrete:!1})},`handleFocus`);return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:U(()=>r.current=!0,`onFocusCapture`),onBlurCapture:U(()=>r.current=!1,`onBlurCapture`)}}U(nt,`useFocusOutside`);function rt(){let e=new CustomEvent(qe);document.dispatchEvent(e)}U(rt,`dispatchUpdate`);function it(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?De(i,a):i.dispatchEvent(a)}U(it,`handleAndDispatchCustomEvent`);var at=Object.defineProperty,ot=(e,t)=>at(e,`name`,{value:t,configurable:!0}),st=0,ct=null;function lt(e){return ut(),e.children}ot(lt,`FocusGuards`);function ut(){E.useEffect(()=>{ct||={start:dt(),end:dt()};let{start:e,end:t}=ct;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),st++,()=>{st===1&&(ct?.start.remove(),ct?.end.remove(),ct=null),st=Math.max(0,st-1)}},[])}ot(ut,`useFocusGuards`);function dt(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}ot(dt,`createFocusGuard`);var ft=Object.defineProperty,W=(e,t)=>ft(e,`name`,{value:t,configurable:!0}),pt=`focusScope.autoFocusOnMount`,mt=`focusScope.autoFocusOnUnmount`,ht={bubbles:!1,cancelable:!0},gt=E.forwardRef(W(function(e,t){let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=E.useState(null),l=H(i),u=H(a),d=E.useRef(null),f=L(t,c),p=E.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;E.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:G(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||G(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&G(s)};W(e,`handleFocusIn`),W(t,`handleFocusOut`),W(n,`handleMutations`),document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,p.paused]),E.useEffect(()=>{if(s){Ct.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(pt,ht);s.addEventListener(pt,l),s.dispatchEvent(t),t.defaultPrevented||(_t(Et(yt(s)),{select:!0}),document.activeElement===e&&G(s))}return()=>{s.removeEventListener(pt,l),setTimeout(()=>{let t=new CustomEvent(mt,ht);s.addEventListener(mt,u),s.dispatchEvent(t),t.defaultPrevented||G(e??document.body,{select:!0}),s.removeEventListener(mt,u),Ct.remove(p)},0)}}},[s,l,u,p]);let m=E.useCallback(e=>{if(!n&&!r||p.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=vt(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&G(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&G(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,M.jsx)(B.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})},`FocusScope`));function _t(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(G(r,{select:t}),document.activeElement!==n)return}W(_t,`focusFirst`);function vt(e){let t=yt(e);return[bt(t,e),bt(t.reverse(),e)]}W(vt,`getTabbableEdges`);function yt(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:W(e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},`acceptNode`)});for(;n.nextNode();)t.push(n.currentNode);return t}W(yt,`getTabbableCandidates`);function bt(e,t){let n=typeof t.checkVisibility==`function`&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):xt(r,{upTo:t})))return r}W(bt,`findVisible`);function xt(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}W(xt,`isHidden`);function St(e){return e instanceof HTMLInputElement&&`select`in e}W(St,`isSelectableInput`);function G(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&St(e)&&t&&e.select()}}W(G,`focus`);var Ct=wt();function wt(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=Tt(e,t),e.unshift(t)},remove(t){e=Tt(e,t),e[0]?.resume()}}}W(wt,`createFocusScopesStack`);function Tt(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}W(Tt,`arrayRemove`);function Et(e){return e.filter(e=>e.tagName!==`A`)}W(Et,`removeLinks`);var K=globalThis?.document?E.useLayoutEffect:()=>{},Dt=Object.defineProperty,Ot=(e,t)=>Dt(e,`name`,{value:t,configurable:!0}),kt=E.useId||(()=>void 0),At=0;function jt(e){let[t,n]=E.useState(kt());return K(()=>{e||n(e=>e??String(At++))},[e]),e||(t?`radix-${t}`:``)}Ot(jt,`useId`);var Mt=Object.defineProperty,Nt=(e,t)=>Mt(e,`name`,{value:t,configurable:!0});function Pt(e){let[t,n]=E.useState(void 0);return K(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}Nt(Pt,`useSize`);var Ft=Object.defineProperty,q=(e,t)=>Ft(e,`name`,{value:t,configurable:!0}),It=`Popper`,[Lt,Rt]=P(It),[zt,Bt]=Lt(It),Vt=q(e=>{let{__scopePopper:t,children:n}=e,[r,i]=E.useState(null),[a,o]=E.useState(void 0);return(0,M.jsx)(zt,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),Ht=`PopperAnchor`,Ut=E.forwardRef(q(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,a=Bt(Ht,n),o=E.useRef(null),s=a.onAnchorChange,c=L(t,E.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=E.useRef(null);E.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let u=a.placementState&&Xt(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,M.jsx)(B.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})},`PopperAnchor`)),Wt=`PopperContent`,[Gt,Kt]=Lt(Wt),qt=E.forwardRef(q(function(e,t){let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:o=`center`,alignOffset:l=0,arrowPadding:u=0,avoidCollisions:d=!0,collisionBoundary:p=[],collisionPadding:v=0,sticky:y=`partial`,hideWhenDetached:b=!1,updatePositionStrategy:te=`optimized`,onPlaced:x,...S}=e,C=Bt(Wt,n),[w,T]=E.useState(null),ne=L(t,T),[D,O]=E.useState(null),k=Pt(D),A=k?.width??0,re=k?.height??0,ie=r+(o===`center`?``:`-`+o),ae=typeof v==`number`?v:{top:0,right:0,bottom:0,left:0,...v},j=Array.isArray(p)?p:[p],oe=j.length>0,N={padding:ae,boundary:j.filter(Jt),altBoundary:oe},{refs:se,floatingStyles:P,placement:ce,isPositioned:le,middlewareData:F}=_({strategy:`fixed`,placement:ie,whileElementsMounted:q((...e)=>f(...e,{animationFrame:te===`always`}),`whileElementsMounted`),elements:{reference:C.anchor},middleware:[s({mainAxis:i+re,alignmentAxis:l}),d&&g({mainAxis:!0,crossAxis:!1,limiter:y===`partial`?ee():void 0,...N}),d&&a({...N}),h({...N,apply:q(({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)},`apply`)}),D&&m({element:D,padding:u}),Yt({arrowWidth:A,arrowHeight:re}),b&&c({strategy:`referenceHidden`,...N,boundary:oe?N.boundary:void 0})]}),I=C.setPlacementState;K(()=>(I(ce),()=>{I(void 0)}),[ce,I]);let[ue,de]=Xt(ce),fe=H(x);K(()=>{le&&fe?.()},[le,fe]);let R=F.arrow?.x,z=F.arrow?.y,pe=F.arrow?.centerOffset!==0,[me,he]=E.useState();return K(()=>{w&&he(window.getComputedStyle(w).zIndex)},[w]),(0,M.jsx)(`div`,{ref:se.setFloating,"data-radix-popper-content-wrapper":``,style:{...P,transform:le?P.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:me,"--radix-popper-transform-origin":[F.transformOrigin?.x,F.transformOrigin?.y].join(` `),...F.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,M.jsx)(Gt,{scope:n,placedSide:ue,placedAlign:de,onArrowChange:O,arrowX:R,arrowY:z,shouldHideArrow:pe,children:(0,M.jsx)(B.div,{"data-side":ue,"data-align":de,...S,ref:ne,style:{...S.style,animation:le?S.style?.animation:`none`}})})})},`PopperContent`));function Jt(e){return e!==null}q(Jt,`isNotNull`);var Yt=q(e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Xt(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}}),`transformOrigin`);function Xt(e){let[t,n=`center`]=e.split(`-`);return[t,n]}q(Xt,`getSideAndAlignFromPlacement`);var Zt=Vt,Qt=Ut,$t=qt,en=Object.defineProperty,tn=E.forwardRef(((e,t)=>en(e,`name`,{value:t,configurable:!0}))(function(e,t){let{container:n,...r}=e,[i,a]=E.useState(!1);K(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?le.createPortal((0,M.jsx)(B.div,{...r,ref:t}),o):null},`Portal`)),nn=Object.defineProperty,J=(e,t)=>nn(e,`name`,{value:t,configurable:!0});function rn(e,t){return E.useReducer((e,n)=>t[e][n]??e,e)}J(rn,`useStateMachine`);var an=J(e=>{let{present:t,children:n}=e,r=on(t),i=typeof n==`function`?n({present:r.isPresent}):E.Children.only(n),a=cn(r.ref,un(i));return typeof n==`function`||r.isPresent?E.cloneElement(i,{ref:a}):null},`Presence`);function on(e){let[t,n]=E.useState(),r=E.useRef(null),i=E.useRef(e),a=E.useRef(`none`),o=E.useRef(void 0),[s,c]=rn(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return E.useEffect(()=>{s===`mounted`?(a.current=o.current??ln(r.current),o.current=void 0):a.current=`none`},[s]),K(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=ln(t);e?(o.current=s,c(`MOUNT`)):s===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),K(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=J(a=>{let o=ln(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(c(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},`handleAnimationEnd`),s=J(e=>{e.target===t&&(a.current=ln(r.current))},`handleAnimationStart`);return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:E.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=ln(t)}else r.current=null;n(e)},[])}}J(on,`usePresence`);function sn(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}J(sn,`setRef`);function cn(...e){let t=E.useRef(e);return t.current=e,E.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=sn(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():sn(n[e],null)}}},[])}J(cn,`useStableComposedRefs`);function ln(e){return e?.animationName||`none`}J(ln,`getAnimationName`);function un(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}J(un,`getElementRef`);var dn=Object.defineProperty,fn=(e,t)=>dn(e,`name`,{value:t,configurable:!0}),pn=E.useEffectEvent,mn=E.useInsertionEffect;function hn(e){if(typeof pn==`function`)return pn(e);let t=E.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof mn==`function`?mn(()=>{t.current=e}):K(()=>{t.current=e}),E.useMemo(()=>((...e)=>t.current?.(...e)),[])}fn(hn,`useEffectEvent`);var gn=Object.defineProperty,_n=(e,t)=>gn(e,`name`,{value:t,configurable:!0}),vn=E.useInsertionEffect||K;function yn({prop:e,defaultProp:t,onChange:n=_n(()=>{},`onChange`),caller:r}){let[i,a,o]=bn({defaultProp:t,onChange:n}),s=e!==void 0;return[s?e:i,E.useCallback(t=>{if(s){let n=xn(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}_n(yn,`useControllableState`);function bn({defaultProp:e,onChange:t}){let[n,r]=E.useState(e),i=E.useRef(n),a=E.useRef(t);return vn(()=>{a.current=t},[t]),E.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}_n(bn,`useUncontrolledState`);function xn(e){return typeof e==`function`}_n(xn,`isFunction`);var Sn=Symbol(`RADIX:SYNC_STATE`);function Cn(e,t,n,r){let{prop:i,defaultProp:a,onChange:o,caller:s}=t,c=i!==void 0,l=hn(o),u=[{...n,state:a}];r&&u.push(r);let[d,f]=E.useReducer((t,n)=>{if(n.type===Sn)return{...t,state:n.state};let r=e(t,n);return c&&!Object.is(r.state,t.state)&&l(r.state),r},...u),p=d.state,m=E.useRef(p);E.useEffect(()=>{m.current!==p&&(m.current=p,c||l(p))},[p,m,c]);let h=E.useMemo(()=>i===void 0?d:{...d,state:i},[d,i]);return E.useEffect(()=>{c&&!Object.is(i,d.state)&&f({type:Sn,state:i})},[i,d.state,c]),[h,f]}_n(Cn,`useControllableStateReducer`);var wn=Object.defineProperty,Tn=(e,t)=>wn(e,`name`,{value:t,configurable:!0}),En=!1;function Dn(){let[e,t]=E.useState(En);return E.useEffect(()=>{En||(En=!0,t(!0))},[]),e}Tn(Dn,`useIsHydrated`);var On=E.useSyncExternalStore;function kn(){return()=>{}}Tn(kn,`subscribe`);function An(){return On(kn,()=>!0,()=>!1)}Tn(An,`useIsHydratedModern`);var jn=typeof On==`function`?An:Dn,Mn=Object.defineProperty,Y=(e,t)=>Mn(e,`name`,{value:t,configurable:!0}),Nn=`rovingFocusGroup.onEntryFocus`,Pn={bubbles:!1,cancelable:!0},Fn=`RovingFocusGroup`,[In,Ln,Rn]=ke(Fn),[zn,Bn]=P(Fn,[Rn]),[Vn,Hn]=zn(Fn),Un=E.forwardRef(Y(function(e,t){return(0,M.jsx)(In.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,M.jsx)(In.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,M.jsx)(Wn,{...e,ref:t})})})},`RovingFocusGroup`)),Wn=E.forwardRef(Y(function(e,t){let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=E.useRef(null),p=L(t,f),m=Ue(a),[h,g]=yn({prop:o,defaultProp:s??null,onChange:c,caller:Fn}),[_,v]=E.useState(!1),y=H(l),ee=Ln(n),b=E.useRef(!1),[te,x]=E.useState(0);return E.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(Nn,y),()=>e.removeEventListener(Nn,y)},[y]),(0,M.jsx)(Vn,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:E.useCallback(e=>g(e),[g]),onItemShiftTab:E.useCallback(()=>v(!0),[]),onFocusableItemAdd:E.useCallback(()=>x(e=>e+1),[]),onFocusableItemRemove:E.useCallback(()=>x(e=>e-1),[]),children:(0,M.jsx)(B.div,{tabIndex:_||te===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:A(e.onMouseDown,()=>{b.current=!0}),onFocus:A(e.onFocus,e=>{let t=!b.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(Nn,Pn);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=ee().filter(e=>e.focusable);Xn([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}b.current=!1}),onBlur:A(e.onBlur,()=>v(!1))})})},`RovingFocusGroupImpl`)),Gn=`RovingFocusGroupItem`,Kn=E.forwardRef(Y(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=jt(),l=a||c,u=Hn(Gn,n),d=u.currentTabStopId===l,f=Ln(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u,g=jn();return K(()=>{if(!(!g||!r))return p(),()=>m()},[g,r,p,m]),E.useEffect(()=>{if(!(g||!r))return p(),()=>m()},[g,r,p,m]),(0,M.jsx)(In.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,M.jsx)(B.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:A(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:A(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:A(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=Yn(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?Zn(n,r+1):n.slice(r+1)}setTimeout(()=>Xn(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})},`RovingFocusGroupItem`)),qn={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function Jn(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}Y(Jn,`getDirectionAwareKey`);function Yn(e,t,n){let r=Jn(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return qn[r]}Y(Yn,`getFocusIntent`);function Xn(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}Y(Xn,`focusFirst`);function Zn(e,t){return e.map((n,r)=>e[(t+r)%e.length])}Y(Zn,`wrapArray`);var Qn=Un,$n=Kn,er=Object.defineProperty,X=(e,t)=>er(e,`name`,{value:t,configurable:!0}),tr=[`Enter`,` `],nr=[`ArrowDown`,`PageUp`,`Home`],rr=[`ArrowUp`,`PageDown`,`End`],ir=[...nr,...rr];[...tr],[...tr];var ar=`Menu`,[or,sr,cr]=ke(ar),[Z,lr]=P(ar,[cr,Rt,Bn]),ur=Rt(),dr=Bn(),[fr,pr]=Z(ar),[mr,hr]=Z(ar),gr=X(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=ur(t),[c,l]=E.useState(null),u=E.useRef(!1),d=H(a),f=Ue(i);return E.useEffect(()=>{let e=X(()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=X(()=>u.current=!1,`handlePointer`);return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),E.useEffect(()=>{if(!n)return;let e=X(()=>d(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,M.jsx)(Zt,{...s,children:(0,M.jsx)(fr,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,M.jsx)(mr,{scope:t,onClose:E.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},`Menu`),_r=E.forwardRef(X(function(e,t){let{__scopeMenu:n,...r}=e,i=ur(n);return(0,M.jsx)(Qt,{...i,...r,ref:t})},`MenuAnchor`)),vr=`MenuPortal`,[yr,br]=Z(vr,{forceMount:void 0}),xr=X(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=pr(vr,t);return(0,M.jsx)(yr,{scope:t,forceMount:n,children:(0,M.jsx)(an,{present:n||a.open,children:(0,M.jsx)(tn,{asChild:!0,container:i,children:r})})})},`MenuPortal`),Q=`MenuContent`,[Sr,Cr]=Z(Q),wr=E.forwardRef(X(function(e,t){let n=br(Q,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=pr(Q,e.__scopeMenu),o=hr(Q,e.__scopeMenu);return(0,M.jsx)(or.Provider,{scope:e.__scopeMenu,children:(0,M.jsx)(an,{present:r||a.open,children:(0,M.jsx)(or.Slot,{scope:e.__scopeMenu,children:o.modal?(0,M.jsx)(Tr,{...i,ref:t}):(0,M.jsx)(Er,{...i,ref:t})})})})},`MenuContent`)),Tr=E.forwardRef(X(function(e,t){let n=pr(Q,e.__scopeMenu),r=E.useRef(null),i=L(t,r);return E.useEffect(()=>{let e=r.current;if(e)return p(e)},[]),(0,M.jsx)(Or,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:A(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),Er=E.forwardRef(X(function(e,t){let n=pr(Q,e.__scopeMenu);return(0,M.jsx)(Or,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),Dr=z(`MenuContent.ScrollLock`),Or=E.forwardRef(X(function(e,t){let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:m,disableOutsideScroll:h,...g}=e,_=pr(Q,n),v=hr(Q,n),y=ur(n),ee=dr(n),b=sr(n),[te,x]=E.useState(null),S=E.useRef(null),C=L(t,S,_.onContentChange),w=E.useRef(0),T=E.useRef(``),ne=E.useRef(0),D=E.useRef(null),O=E.useRef(`right`),k=E.useRef(0),re=h?l:E.Fragment,ie=h?{as:Dr,allowPinchZoom:!0}:void 0,ae=X(e=>{let t=T.current+e,n=b().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=Gr(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;X((function e(t){T.current=t,window.clearTimeout(w.current),t!==``&&(w.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);E.useEffect(()=>()=>window.clearTimeout(w.current),[]),ut();let j=E.useCallback(e=>O.current===D.current?.side&&qr(e,D.current?.area),[]);return(0,M.jsx)(Sr,{scope:n,searchRef:T,onItemEnter:E.useCallback(e=>{j(e)&&e.preventDefault()},[j]),onItemLeave:E.useCallback(e=>{j(e)||(S.current?.focus(),x(null))},[j]),onTriggerLeave:E.useCallback(e=>{j(e)&&e.preventDefault()},[j]),pointerGraceTimerRef:ne,onPointerGraceIntentChange:E.useCallback(e=>{D.current=e},[]),children:(0,M.jsx)(re,{...ie,children:(0,M.jsx)(gt,{asChild:!0,trapped:i,onMountAutoFocus:A(a,e=>{e.preventDefault(),S.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,M.jsx)(Qe,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:u,onPointerDownOutside:d,onFocusOutside:f,onInteractOutside:p,onDismiss:m,children:(0,M.jsx)(Qn,{asChild:!0,...ee,dir:v.dir,orientation:`vertical`,loop:r,currentTabStopId:te,onCurrentTabStopIdChange:x,onEntryFocus:A(c,e=>{v.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,M.jsx)($t,{role:`menu`,"aria-orientation":`vertical`,"data-state":Br(_.open),"data-radix-menu-content":``,dir:v.dir,...y,...g,ref:C,style:{outline:`none`,...g.style},onKeyDown:A(g.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&ae(e.key));let i=S.current;if(e.target!==i||!ir.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);rr.includes(e.key)&&a.reverse(),Ur(a)}),onBlur:A(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(w.current),T.current=``)}),onPointerMove:A(e.onPointerMove,Jr(e=>{let t=e.target,n=k.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>k.current?`right`:`left`;O.current=t,k.current=e.clientX}}))})})})})})})},`MenuContentImpl`)),kr=`MenuItem`,Ar=`menu.itemSelect`,jr=E.forwardRef(X(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,a=E.useRef(null),o=hr(kr,e.__scopeMenu),s=Cr(kr,e.__scopeMenu),c=L(t,a),l=E.useRef(!1),u=X(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(Ar,{bubbles:!0,cancelable:!0});e.addEventListener(Ar,e=>r?.(e),{once:!0}),De(e,t),t.defaultPrevented?l.current=!1:o.onClose()}},`handleSelect`);return(0,M.jsx)(Mr,{...i,ref:c,disabled:n,onClick:A(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:A(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:A(e.onKeyDown,e=>{n||e.target!==e.currentTarget||s.searchRef.current!==``&&e.key===` `||tr.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),Mr=E.forwardRef(X(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=Cr(kr,n),s=dr(n),c=E.useRef(null),l=L(t,c),[u,d]=E.useState(!1),[f,p]=E.useState(``);return E.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,M.jsx)(or.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,M.jsx)($n,{asChild:!0,...s,focusable:!r,children:(0,M.jsx)(B.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:A(e.onPointerMove,Jr(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:A(e.onPointerLeave,Jr(e=>o.onItemLeave(e))),onFocus:A(e.onFocus,()=>d(!0)),onBlur:A(e.onBlur,()=>d(!1))})})})},`MenuItemImpl`)),[Nr,Pr]=Z(`MenuRadioGroup`,{value:void 0,onValueChange:X(()=>{},`onValueChange`)}),[Fr,Ir]=Z(`MenuItemIndicator`,{checked:!1}),Lr=E.forwardRef(X(function(e,t){let{__scopeMenu:n,...r}=e;return(0,M.jsx)(B.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})},`MenuSeparator`)),[Rr,zr]=Z(`MenuSub`);function Br(e){return e?`open`:`closed`}X(Br,`getOpenState`);function Vr(e){return e===`indeterminate`}X(Vr,`isIndeterminate`);function Hr(e){return Vr(e)?`indeterminate`:e?`checked`:`unchecked`}X(Hr,`getCheckedState`);function Ur(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}X(Ur,`focusFirst`);function Wr(e,t){return e.map((n,r)=>e[(t+r)%e.length])}X(Wr,`wrapArray`);function Gr(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Wr(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}X(Gr,`getNextMatch`);function Kr(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}X(Kr,`isPointInPolygon`);function qr(e,t){return t?Kr({x:e.clientX,y:e.clientY},t):!1}X(qr,`isPointerInGraceArea`);function Jr(e){return t=>t.pointerType===`mouse`?e(t):void 0}X(Jr,`whenMouse`);var Yr=gr,Xr=_r,Zr=xr,Qr=wr,$r=jr,ei=Lr,ti=Object.defineProperty,$=(e,t)=>ti(e,`name`,{value:t,configurable:!0}),ni=`ContextMenu`,[ri,ii]=P(ni,[lr]),ai=lr(),[oi,si]=ri(ni),ci=$(e=>{let{__scopeContextMenu:t,children:n,onOpenChange:r,open:i,dir:a,modal:o=!0}=e,s=E.useRef(!1),[c,l]=yn({prop:i,defaultProp:!1,onChange:r,caller:ni}),u=ai(t);return(0,M.jsx)(oi,{scope:t,open:c,onOpenChange:l,modal:o,hasInteractedRef:s,children:(0,M.jsx)(Yr,{...u,dir:a,open:c,onOpenChange:l,modal:o,children:n})})},`ContextMenu`),li=`ContextMenuTrigger`,ui=E.forwardRef($(function(e,t){let{__scopeContextMenu:n,disabled:r=!1,...i}=e,a=si(li,n),o=ai(n),[s,c]=E.useState({x:0,y:0}),l=E.useMemo(()=>({current:{getBoundingClientRect:$(()=>DOMRect.fromRect({width:0,height:0,...s}),`getBoundingClientRect`)}}),[s]),u=E.useRef(0),d=E.useCallback(()=>window.clearTimeout(u.current),[]),f=$(e=>{a.hasInteractedRef.current=!0,c({x:e.clientX,y:e.clientY}),a.onOpenChange(!0)},`handleOpen`);return E.useEffect(()=>d,[d]),E.useEffect(()=>void(r&&d()),[r,d]),(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(Xr,{...o,virtualRef:l}),(0,M.jsx)(B.span,{"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,...i,ref:t,style:{WebkitTouchCallout:`none`,...e.style},onContextMenu:r?e.onContextMenu:A(e.onContextMenu,e=>{d(),f(e),e.preventDefault()}),onPointerDown:r?e.onPointerDown:A(e.onPointerDown,gi(e=>{d(),a.open&&a.onOpenChange(!1),u.current=window.setTimeout(()=>f(e),700)})),onPointerMove:r?e.onPointerMove:A(e.onPointerMove,gi(d)),onPointerCancel:r?e.onPointerCancel:A(e.onPointerCancel,gi(d)),onPointerUp:r?e.onPointerUp:A(e.onPointerUp,gi(d))})]})},`ContextMenuTrigger`)),di=$(e=>{let{__scopeContextMenu:t,...n}=e,r=ai(t);return(0,M.jsx)(Zr,{...r,...n})},`ContextMenuPortal`),fi=`ContextMenuContent`,pi=E.forwardRef($(function(e,t){let{__scopeContextMenu:n,...r}=e,i=si(fi,n),a=ai(n),o=E.useRef(!1);return(0,M.jsx)(Qr,{...a,...r,ref:t,side:`right`,sideOffset:2,align:`start`,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),!t.defaultPrevented&&o.current&&t.preventDefault(),o.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),!t.defaultPrevented&&!i.modal&&(o.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-context-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-context-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-context-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-context-menu-trigger-height":`var(--radix-popper-anchor-height)`}})},`ContextMenuContent`)),mi=E.forwardRef($(function(e,t){let{__scopeContextMenu:n,...r}=e,i=ai(n);return(0,M.jsx)($r,{...i,...r,ref:t})},`ContextMenuItem`)),hi=E.forwardRef($(function(e,t){let{__scopeContextMenu:n,...r}=e,i=ai(n);return(0,M.jsx)(ei,{...i,...r,ref:t})},`ContextMenuSeparator`));function gi(e){return t=>t.pointerType===`mouse`?void 0:e(t)}$(gi,`whenTouchOrPen`);var _i=ci,vi=ui,yi=di,bi=pi,xi=mi,Si=hi,Ci=_i,wi=vi,Ti=yi,Ei=bi,Di=xi,Oi=Si,ki=[`tree-alpha`,`tree-modified`,`flat-modified`,`flat-issues`,`flat-criticality`],Ai=[`tree-alpha`,`tree-modified`,`flat-modified`],ji=Ai;function Mi(e){return T(e,{seconds:!0,fallback:e})}function Ni(e){if(!Number.isFinite(e)||e<0)return``;if(e<1024)return`${e} ${e===1?`byte`:`bytes`}`;let t=[`KB`,`MB`,`GB`,`TB`],n=e/1024,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r++;return`${n.toFixed(1)} ${t[r]}`}function Pi(e,t){return e.localeCompare(t)}function Fi(e,t){let n=e.mtimeMs,r=t.mtimeMs;return n!==void 0&&r!==void 0&&n!==r?r-n:n!==void 0&&r===void 0?-1:n===void 0&&r!==void 0?1:Pi(e.name,t.name)}function Ii(e,t){let n=e.map(e=>e.children.length>0?{...e,children:Ii(e.children,t)}:e);return n.sort((e,n)=>e.isDirectory===n.isDirectory?e.isDirectory||t===`alpha`?Pi(e.name,n.name):Fi(e,n):e.isDirectory?-1:1),n}var Li={major:10,minor:3,info:1};function Ri(e){let t=new Map;for(let n of e){let e=t.get(n.path);e||(e={path:n.path,total:0,bySeverity:{major:0,minor:0,info:0},score:0},t.set(n.path,e)),e.total+=1,e.bySeverity[n.severity]+=1,e.score+=Li[n.severity]}return[...t.values()]}function zi(e,t){return[...e].sort((e,n)=>{let r=t===`count`?n.total-e.total:n.score-e.score;return r===0?e.path.localeCompare(n.path):r})}function Bi(e){let t=[];for(let n of[`major`,`minor`,`info`]){let r=e[n];r>0&&t.push(`${r} ${n}`)}return t.join(` · `)}function Vi(e,t){return`gezel.projectFilesView:${e}:${t}`}function Hi(e,t){return`gezel.projectFilesHidden:${e}:${t}`}function Ui(e,t){return(t===`workspace`?ki:Ai).includes(e)?e:`tree-alpha`}var Wi=`gezel.documentsFilesView`,Gi=`gezel.documentsFilesHidden`;function Ki(e,t){let n=e.lastIndexOf(`/`);return{name:n>=0?e.slice(n+1):e,path:e,isDirectory:!1,...t===void 0?{}:{mtimeMs:t}}}function qi(e){let t=e.lastIndexOf(`/`);return t>=0?e.slice(0,t):``}function Ji(e){let t=[],n=new Map;for(let t of e)n.set(t.path,{name:t.name,path:t.path,isDirectory:t.isDirectory,...t.mtimeMs===void 0?{}:{mtimeMs:t.mtimeMs},children:[]});for(let r of e){let e=n.get(r.path);if(!e)continue;let i=r.path.includes(`/`)?r.path.slice(0,r.path.lastIndexOf(`/`)):``,a=i?n.get(i):void 0;a?a.children.push(e):t.push(e)}return t}function Yi(e){return e.isDirectory?(0,M.jsx)(`i`,{className:`tree-icon tree-icon-folder fa-regular fa-folder fa-fw`,"aria-hidden":`true`}):(0,M.jsx)(ne,{name:e.name,className:`tree-icon`})}function Xi(e){return e.name}function Zi({entries:e,selectedPath:t,onSelect:n,onIntent:r,onRename:i,onDelete:a,actionsForEntry:o,trailingForEntry:s,defaultExpandedDepth:c=2,iconFor:l=Yi,labelFor:u=Xi,selectableFolders:d=!1,sortMode:f=`none`}){return(0,M.jsx)(M.Fragment,{children:(0,E.useMemo)(()=>f===`none`?Ji(e):Ii(Ji(e),f),[e,f]).map(e=>(0,M.jsx)(Qi,{node:e,depth:0,selectedPath:t,onSelect:n,onIntent:r,onRename:i,onDelete:a,actionsForEntry:o,trailingForEntry:s,defaultExpandedDepth:c,iconFor:l,labelFor:u,selectableFolders:d},e.path))})}function Qi({node:e,depth:t,selectedPath:n,onSelect:r,onIntent:i,onRename:a,onDelete:o,actionsForEntry:s,trailingForEntry:c,defaultExpandedDepth:l,iconFor:u,labelFor:d,selectableFolders:f}){let[p,m]=(0,E.useState)(t<l),h={name:e.name,path:e.path,isDirectory:e.isDirectory,...e.mtimeMs===void 0?{}:{mtimeMs:e.mtimeMs}},g=d(h),_=s?.(h)??[],v=c?.(h),y=!!(a||o||_.length>0),ee=e.isDirectory&&e.children.length>0,T=(0,M.jsxs)(`div`,{className:`tree-row${n===e.path?` tree-row-selected`:``}`,style:{paddingLeft:`${t*12+2}px`},onPointerEnter:()=>i?.(h),onFocus:()=>i?.(h),onPointerDown:()=>i?.(h),children:[ee?(0,M.jsx)(`button`,{type:`button`,className:`tree-toggle`,onClick:()=>m(!p),"aria-expanded":p,"aria-label":p?`Collapse ${g}`:`Expand ${g}`,children:(0,M.jsx)(`span`,{className:`tree-toggle-caret${p?` expanded`:``}`,"aria-hidden":`true`,children:(0,M.jsx)(`svg`,{width:14,height:14,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2.2,strokeLinecap:`round`,strokeLinejoin:`round`,focusable:`false`,"aria-hidden":`true`,children:(0,M.jsx)(`polyline`,{points:`9 6 15 12 9 18`})})})}):(0,M.jsx)(`span`,{className:`tree-toggle-spacer`}),(0,M.jsxs)(`button`,{type:`button`,className:`tree-label`,onClick:()=>{!e.isDirectory||f?r(h):m(!p)},children:[u(h),g]}),v&&(0,M.jsx)(`span`,{className:`tree-row-trailing`,children:v}),y&&(0,M.jsxs)(te,{children:[(0,M.jsx)(S,{asChild:!0,children:(0,M.jsx)(`button`,{type:`button`,className:`tree-actions-trigger`,"aria-label":`Actions for ${g}`,title:`Actions for ${g}`,children:(0,M.jsx)(`span`,{"aria-hidden":`true`,children:`⋯`})})}),(0,M.jsx)(C,{children:(0,M.jsxs)(w,{className:`app-nav-menu tree-actions-menu`,sideOffset:4,align:`end`,children:[a&&(0,M.jsx)(x,{className:`app-nav-menu-item`,onSelect:()=>a(h),children:`Rename…`}),o&&(0,M.jsx)(x,{className:`app-nav-menu-item danger`,onSelect:()=>o(h),children:`Delete…`}),_.length>0&&(a||o)&&(0,M.jsx)(b,{className:`app-nav-menu-separator`}),_.map(e=>(0,M.jsx)(x,{className:`app-nav-menu-item`,disabled:e.disabled,onSelect:()=>void e.onSelect(h),children:e.label},e.label))]})})]})]});return(0,M.jsxs)(`div`,{children:[y?(0,M.jsxs)(Ci,{children:[(0,M.jsx)(wi,{asChild:!0,children:T}),(0,M.jsx)(Ti,{children:(0,M.jsxs)(Ei,{className:`app-nav-menu tree-actions-menu`,children:[a&&(0,M.jsx)(Di,{className:`app-nav-menu-item`,onSelect:()=>a(h),children:`Rename…`}),o&&(0,M.jsx)(Di,{className:`app-nav-menu-item danger`,onSelect:()=>o(h),children:`Delete…`}),_.length>0&&(a||o)&&(0,M.jsx)(Oi,{className:`app-nav-menu-separator`}),_.map(e=>(0,M.jsx)(Di,{className:`app-nav-menu-item`,disabled:e.disabled,onSelect:()=>void e.onSelect(h),children:e.label},e.label))]})})]}):T,ee&&p&&(0,M.jsx)(`div`,{children:e.children.map(e=>(0,M.jsx)(Qi,{node:e,depth:t+1,selectedPath:n,onSelect:r,onIntent:i,onRename:a,onDelete:o,actionsForEntry:s,trailingForEntry:c,defaultExpandedDepth:l,iconFor:u,labelFor:d,selectableFolders:f},e.path))})]})}function $i(e,t){return!t||!e.toLowerCase().endsWith(t.toLowerCase())?e:e.slice(0,-t.length)}function ea({open:e,title:t,placeholder:n,submitLabel:r,onSubmit:a,onCancel:s,initialValue:c=``,suffix:l,fieldLabel:f=`Path`,error:p}){let[m,h]=(0,E.useState)(()=>$i(c,l));return(0,E.useEffect)(()=>{e&&h($i(c,l))},[e,c,l]),(0,M.jsx)(i,{open:e,onOpenChange:e=>{e||s()},children:(0,M.jsxs)(d,{children:[(0,M.jsx)(u,{}),(0,M.jsx)(v,{children:(0,M.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m.trim()&&a(`${$i(m.trim(),l)}${l??``}`)},style:{display:`contents`},children:[(0,M.jsx)(o,{asChild:!0,children:(0,M.jsx)(`h3`,{children:t})}),(0,M.jsxs)(`label`,{children:[f,(0,M.jsxs)(`span`,{className:l?`new-path-input-row`:void 0,children:[(0,M.jsx)(`input`,{value:m,onChange:e=>h($i(e.target.value,l)),placeholder:n}),l&&(0,M.jsx)(`span`,{className:`new-path-input-suffix`,"aria-hidden":`true`,children:l})]})]}),p&&(0,M.jsx)(`p`,{className:`gz-dialog-error`,role:`alert`,children:p}),(0,M.jsxs)(y,{children:[(0,M.jsx)(`button`,{type:`button`,onClick:s,children:`Cancel`}),(0,M.jsx)(`button`,{type:`submit`,className:`primary`,disabled:!m.trim(),children:r})]})]})})]})})}export{Ci as C,Ti as S,Mi as _,Gi as a,Ei as b,ki as c,Fi as d,Bi as f,Ni as g,Vi as h,Ai as i,Ri as l,Hi as m,Zi as n,Wi as o,Ki as p,Yi as r,ji as s,ea as t,Ui as u,qi as v,wi as w,Di as x,zi as y};
@@ -1,2 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{F as r,I as i,N as a,P as ee,d as o,j as te,k as ne,l as s,m as c,p as l,s as re}from"./primitives-DEsn1shf.js";import{Lt as ie,hn as ae}from"./dist-BPx-FyRH.js";import{t as oe}from"./dist-D5aoNQwk.js";import{t as u}from"./api-BX5xXiFs.js";import{t as se}from"./GezelJsonEditor-fOvYclu9.js";import{r as d}from"./new-project-meta-0xhggGA_.js";import{$ as ce,Q as le,X as ue,Z as f,at as de,et as fe,it as pe,nt as me,rt as he,tt as ge}from"./index-DXWR4qW1.js";import{t as _e}from"./CraftbookToolsetSetup-DTEA-3K3.js";import{t as ve}from"./useShowWorkInProgressFeatures-DwwviLRO.js";var p=e(t(),1);function ye(e){if(e instanceof oe){let t=e.details;if(t&&typeof t==`object`&&`error`in t){let e=t.error;if(typeof e==`string`&&e.length>0&&e!==`internal_error`)return e}return e.message}return e instanceof Error?e.message:String(e)}var m=n(),h=`__auto`,be={"one-time":{title:`New Task`,subtitle:`Pick a craftbook — a proven recipe your crew follows step by step — or start blank.`,generalLabel:f.label,generalDescription:f.description,featuredLabel:`Recommended`,featuredTitle:`Recommended`,featuredTagline:`proven recipes for this kind of project`,submitLabel:`Create task`,footnote:`Lands ready to fire — nothing runs until you fire it.`},scheduled:{title:`New Scheduled Task`,subtitle:`Choose a repeatable craftbook, then set when each fresh run should begin.`,generalLabel:`Blank scheduled task`,generalDescription:`Define a repeatable job from scratch and run a fresh copy on a cadence.`,featuredLabel:`For schedules`,featuredTitle:`Scheduled craftbooks`,featuredTagline:`recipes identified as safe for recurring unattended runs`,submitLabel:`Create schedule`,footnote:`Starts active and creates a fresh task on each scheduled run.`},"night-shift":{title:`New Night Shift Task`,subtitle:`Choose work your crew can pick up unattended during the Night Shift window.`,generalLabel:`Blank Night Shift task`,generalDescription:`Define a one-off job that waits for Night Shift before it begins.`,featuredLabel:`For Night Shift`,featuredTitle:`Night Shift craftbooks`,featuredTagline:`recipes identified as safe for unattended overnight work`,submitLabel:`Queue for Night Shift`,footnote:`Starts active, but only runs while Night Shift is on.`}};function g({open:e,creationMode:t=`one-time`,defaultProjectId:n,projects:oe,gezels:g,projectLocked:Ce,onClose:_,onCreated:v}){let y=be[t],we=ve(),[b,Te]=(0,p.useState)(n),[x,S]=(0,p.useState)([]),[Ee,De]=(0,p.useState)(!1),C=(0,p.useRef)(0),[Oe,ke]=(0,p.useState)({}),[Ae,je]=(0,p.useState)(null),[w,Me]=(0,p.useState)(new Set),[T,E]=(0,p.useState)(null),[D,O]=(0,p.useState)(`pick`),[Ne,k]=(0,p.useState)(!1),[A,Pe]=(0,p.useState)(``),[j,M]=(0,p.useState)(`all`),[Fe,N]=(0,p.useState)(!1),[P,F]=(0,p.useState)(``),[I,Ie]=(0,p.useState)(!1),[L,Le]=(0,p.useState)(``),[R,Re]=(0,p.useState)(`Main`),[ze,Be]=(0,p.useState)(``),[Ve,He]=(0,p.useState)(!1),[z,B]=(0,p.useState)({}),[Ue,We]=(0,p.useState)(``),[V,Ge]=(0,p.useState)(`skip`),[H,U]=(0,p.useState)(!1),[Ke,W]=(0,p.useState)(``),[qe,Je]=(0,p.useState)(null),Ye=(0,p.useRef)(0);(0,p.useEffect)(()=>{e&&(Te(n),E(null),k(!1),O(`pick`),Pe(``),M(`all`),N(!1),F(``),Ie(!1),Le(``),Re(`Main`),Be(``),He(!1),B({}),We(``),Ge(`skip`),U(!1),W(``),Je(null))},[e,n]);let Xe=(0,p.useCallback)(async()=>{let e=++C.current;if(!b){if(e!==C.current)return;S([]),De(!0);return}try{let t=await u.listProjectCraftbooks(b);if(e!==C.current)return;let n=ae(t.items??[],we),r=new Set(n.map(e=>e.manifest.id));S(de(n)),ke(t.missingToolsets??{}),je(t.projectType??null),Me(new Set((t.suggestedIds??[]).filter(e=>r.has(e)))),E(e=>e&&!r.has(e)?null:e)}catch{if(e!==C.current)return;S([]),ke({}),je(null),Me(new Set)}finally{e===C.current&&De(!0)}},[b,we]);(0,p.useEffect)(()=>{e&&(De(!1),Xe())},[e,Xe]),(0,p.useEffect)(()=>{!e||!Ee||Fe||(N(!0),(t===`one-time`?w.size>0:x.some(e=>t===`scheduled`?e.manifest.runModes?.scheduled:e.manifest.runModes?.nightShift))&&M(`recommended`))},[e,Ee,Fe,w,t,x]);let G=T?x.find(e=>e.manifest.id===T)??null:null,K=(()=>{if(!G)return null;let e=G.manifest;return(e.steps.find(t=>t.id===e.entryStepId)??e.steps[0])?.suggestedRole??null})(),Ze=t!==`scheduled`&&(G?.manifest.connectors??[]).some(e=>e.typeId===`github-pulls`&&!e.optional),Qe=String(z.number??``).trim();(0,p.useEffect)(()=>{let t=++Ye.current;Je(null),!(!e||!Ze||!b)&&(async()=>{try{let[e,n]=await Promise.all([u.getProjectGitStatus(b),u.listProjectGitHubPulls(b)]);if(t!==Ye.current)return;let{matchingCount:r}=ie(n.pulls??[],e.branch);if(r>0)return;Je(e.branch?`No open pull request for branch "${e.branch}" — enter a pull request number above, or switch branches first.`:`This checkout is not on a branch — enter a pull request number above.`)}catch{}})()},[e,Ze,b]);let $e=(0,p.useCallback)(()=>{E(null),k(!0),B({}),W(``),O(`configure`),I||F(``)},[I]),et=(0,p.useCallback)(()=>{O(`pick`),W(``)},[]),tt=(0,p.useCallback)(e=>{Te(e),E(null),k(!1),B({}),M(`all`),N(!1),W(``)},[]),nt=(0,p.useCallback)(e=>{if(E(e.manifest.id),k(!1),B(ge(e.manifest.paramSchema)),W(``),O(`configure`),I||F(e.manifest.name),!Ve){let t=e.manifest.defaultAssignee;t?.kind===`gezel`&&g.some(e=>e.id===t.gezelId)&&Be(t.gezelId)}},[I,Ve,g]),q=ze||(K?h:g[0]?.id??`__user`),J=q===h?null:q===`__user`?{kind:`user`}:{kind:`gezel`,gezelId:q},Y=(0,p.useMemo)(()=>pe(x),[x]),X=A.trim().toLowerCase(),Z=X.length>0,Q=(0,p.useMemo)(()=>{if(t===`one-time`)return x.filter(e=>w.has(e.manifest.id));let e=t===`scheduled`?`scheduled`:`nightShift`;return x.filter(t=>t.manifest.runModes?.[e]).sort((t,n)=>{let r=+(t.manifest.runModes?.[e]===`recommended`);return+(n.manifest.runModes?.[e]===`recommended`)-r||t.manifest.name.localeCompare(n.manifest.name)})},[x,w,t]),rt=(0,p.useCallback)(e=>{if(t===`one-time`)return w.has(e.manifest.id);let n=t===`scheduled`?`scheduled`:`nightShift`;return e.manifest.runModes?.[n]===`recommended`},[t,w]),it=(0,p.useMemo)(()=>Z?x.filter(e=>`${e.manifest.id} ${e.manifest.name} ${e.manifest.description} ${(e.manifest.tags??[]).join(` `)}`.toLowerCase().includes(X)).sort((e,t)=>{let n=w.has(e.manifest.id)||e.manifest.tags?.includes(`recommended`)?1:0;return(w.has(t.manifest.id)||t.manifest.tags?.includes(`recommended`)?1:0)-n||xe(e,X)-xe(t,X)||e.manifest.name.localeCompare(t.manifest.name)}):x,[x,Z,X,w]),at=!Z||`${y.generalLabel} ${y.generalDescription} blank fresh`.toLowerCase().includes(X),ot=(0,p.useMemo)(()=>{if(Z)return[{id:`search`,title:`Craftbooks`,tagline:`matching "${A.trim()}"`,books:it}];if(j===`recommended`&&Q.length>0)return[{id:`recommended`,title:t===`one-time`&&Ae?`Recommended for ${Ae.label}`:y.featuredTitle,tagline:y.featuredTagline,books:Q}];let e=Y.find(e=>e.id===j);return e?[{id:e.id,title:e.label,tagline:e.tagline,books:x.filter(t=>e.bookIds.has(t.manifest.id))}]:[{id:`all`,title:`All craftbooks`,tagline:void 0,books:x}]},[Z,A,it,j,Q,Ae,Y,x,t,y]),$=G?Oe[G.manifest.id]??[]:[],st=(0,p.useCallback)(async e=>{if(e.preventDefault(),H||D!==`configure`)return;if(W(``),!b){W(`Pick a project.`);return}let n=Ue.trim();if(t===`scheduled`&&!n){W(`Enter a schedule.`);return}if(G){let e=G.manifest;if((Oe[e.id]?.length??0)>0){W(`This craftbook needs its toolsets installed first — see the setup list.`);return}let r=e.paramSchema,i=(Array.isArray(r?.required)?r.required:[]).find(e=>{let t=z[e];return t==null||t===``});if(i){W(`"${i}" is required.`);return}let a=me(z);U(!0);try{let r=t===`scheduled`?await u.createTask(b,{title:P.trim()||e.name,description:`Recurring scheduled task. ${le(e,a)} Each scheduled run creates a fresh task from this recipe.`,steps:[{name:`Wait for schedule`,prompt:`This host holds a recurring schedule. It does not perform the work itself; each tick creates a fresh child task.`}],spawnsCraftbookId:e.id,...G.item.sourceId?{spawnsCraftbookSourceId:G.item.sourceId}:{},...J?{assignee:J}:{},cron:{expression:n,overlap:V},...Object.keys(a).length>0?{spawnsCraftbookParams:a}:{}}):await u.createTask(b,{title:P.trim()||e.name,description:le(e,a),craftbookId:e.id,...G.item.sourceId?{craftbookSourceId:G.item.sourceId}:{},...J?{assignee:J}:{},...t===`one-time`?{dispatchEntry:!0}:{nightShift:{enabled:!0},dispatchEntry:!0},...Object.keys(a).length>0?{craftbookParams:a}:{}});if(t!==`scheduled`&&Object.keys(a).length>0&&r.activeStepId){let e=[`# Invocation parameters`,``];for(let[t,n]of Object.entries(a))e.push(`- **${t}**: ${n}`);await u.appendTaskNote(r.projectId,r.num,{text:e.join(`
2
- `),stepId:r.activeStepId}).catch(()=>{})}await v(r),_()}catch(e){W(ye(e))}finally{U(!1)}return}let r=P.trim();if(!r){W(`Title is required.`);return}if(L.trim().length<40){W(`Description must be at least 40 characters — the job-to-be-done from the user's perspective. What does success look like?`);return}let i=R.split(/\n|,/).map(e=>e.trim()).filter(Boolean).map(e=>({name:e}));i.length===0&&i.push({name:`Main`}),U(!0);try{await v(t===`scheduled`?await u.createTask(b,{title:r,description:L.trim(),steps:[{name:`Wait for schedule`,prompt:`This host holds a recurring schedule. It does not perform the work itself; each tick creates a fresh child task.`}],spawnsSteps:i,...J?{assignee:J}:{},cron:{expression:n,overlap:V}}):await u.createTask(b,{title:r,description:L.trim(),steps:i,...J?{assignee:J}:{},...t===`one-time`?{status:`draft`}:{nightShift:{enabled:!0},dispatchEntry:!0}})),_()}catch(e){W(ye(e))}finally{U(!1)}},[H,D,t,b,G,Oe,z,P,J,L,R,Ue,V,v,_]),ct=G&&fe(G.manifest)?G.manifest.paramSchema:null,lt=H||G!==null&&$.length>0,ut=G?`Craftbook${rt(G)?t===`night-shift`?` · recommended for Night Shift`:t===`scheduled`?` · recommended for schedules`:` · recommended`:``}`:t===`one-time`?`Blank task`:t===`scheduled`?`Blank schedule`:`Blank Night Shift task`,dt=oe.find(e=>e.id===b)?.name??``;return(0,m.jsx)(r,{open:e,onOpenChange:e=>{e||_()},children:(0,m.jsxs)(ee,{children:[(0,m.jsx)(a,{}),(0,m.jsx)(te,{className:`gz-npd gz-ntd gz-npd-step-${D}`,children:(0,m.jsx)(`form`,{onSubmit:st,style:{display:`contents`},children:D===`pick`?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(`header`,{className:`gz-npd-header`,children:[(0,m.jsxs)(`div`,{className:`gz-npd-header-copy`,children:[(0,m.jsx)(i,{asChild:!0,children:(0,m.jsx)(`h3`,{children:y.title})}),(0,m.jsx)(`p`,{className:`gz-npd-header-sub`,children:y.subtitle})]}),(0,m.jsxs)(`div`,{className:`gz-ntd-header-controls`,children:[!Ce&&(0,m.jsxs)(`label`,{className:`gz-ntd-header-project`,children:[(0,m.jsx)(`span`,{children:`Project`}),(0,m.jsxs)(o,{value:b,onValueChange:tt,children:[(0,m.jsx)(l,{children:(0,m.jsx)(c,{})}),(0,m.jsx)(re,{children:oe.map(e=>(0,m.jsx)(s,{value:e.id,children:e.name},e.id))})]})]}),(0,m.jsxs)(`label`,{className:`gz-npd-search`,children:[(0,m.jsx)(`span`,{className:`sr-only`,children:`Search craftbooks`}),(0,m.jsx)(`input`,{type:`search`,value:A,onChange:e=>Pe(e.target.value),placeholder:`Search craftbooks…`})]})]})]}),(0,m.jsxs)(`div`,{className:`gz-npd-body`,children:[(0,m.jsxs)(`nav`,{className:`gz-npd-rail`,"aria-label":`Craftbook shelves`,children:[Q.length>0&&(0,m.jsxs)(`button`,{type:`button`,className:`gz-npd-rail-item${!Z&&j===`recommended`?` active`:``}`,onClick:()=>M(`recommended`),children:[(0,m.jsx)(d,{glyph:`sprout`,size:16}),(0,m.jsx)(`span`,{className:`gz-npd-rail-label`,children:y.featuredLabel}),(0,m.jsx)(`span`,{className:`gz-npd-rail-count`,children:Q.length})]}),(0,m.jsxs)(`button`,{type:`button`,className:`gz-npd-rail-item${!Z&&j===`all`?` active`:``}`,onClick:()=>M(`all`),children:[(0,m.jsx)(d,{glyph:`sheet`,size:16}),(0,m.jsx)(`span`,{className:`gz-npd-rail-label`,children:`All craftbooks`}),(0,m.jsx)(`span`,{className:`gz-npd-rail-count`,children:x.length})]}),Y.map((e,t)=>{let n=Y[t-1]?.family===e.family?null:he(e.family);return(0,m.jsxs)(p.Fragment,{children:[n&&(0,m.jsx)(`span`,{className:`gz-npd-rail-group`,children:n}),(0,m.jsxs)(`button`,{type:`button`,className:`gz-npd-rail-item${!Z&&j===e.id?` active`:``}`,onClick:()=>M(e.id),children:[(0,m.jsx)(d,{glyph:e.glyph,size:16}),(0,m.jsx)(`span`,{className:`gz-npd-rail-label`,children:e.label}),(0,m.jsx)(`span`,{className:`gz-npd-rail-count`,children:e.bookIds.size})]})]},e.id)})]}),(0,m.jsxs)(`div`,{className:`gz-npd-gallery`,role:`radiogroup`,"aria-label":`Task type`,children:[at&&(0,m.jsxs)(`section`,{className:`gz-npd-section`,children:[(0,m.jsx)(`div`,{className:`gz-npd-section-head`,children:(0,m.jsx)(`span`,{className:`gz-npd-section-title`,children:`Start fresh`})}),(0,m.jsx)(`div`,{className:`gz-npd-grid`,children:(0,m.jsx)(Se,{label:y.generalLabel,description:y.generalDescription,glyph:f.glyph,index:0,active:Ne,onSelect:$e})})]}),ot.map(e=>(0,m.jsxs)(`section`,{className:`gz-npd-section`,children:[(0,m.jsxs)(`div`,{className:`gz-npd-section-head`,children:[(0,m.jsx)(`span`,{className:`gz-npd-section-title`,children:e.title}),e.tagline&&(0,m.jsx)(`span`,{className:`gz-npd-section-tagline`,children:e.tagline})]}),e.books.length>0?(0,m.jsx)(`div`,{className:`gz-npd-grid`,children:e.books.map((e,t)=>(0,m.jsx)(Se,{label:e.manifest.name,description:e.manifest.description,glyph:ce(e.manifest),...e.item.iconSvg?{iconSvg:e.item.iconSvg}:{},...e.item.logoUrl?{logoUrl:e.item.logoUrl}:{},suggested:rt(e),index:t+1,active:e.manifest.id===T,onSelect:()=>nt(e)},e.manifest.id))}):(0,m.jsx)(`p`,{className:`gz-npd-empty`,children:Ee?Z?`No craftbooks match your search.`:`No craftbooks here yet.`:`Loading craftbooks…`}),e.id===`recommended`&&x.length>Q.length&&(0,m.jsxs)(`button`,{type:`button`,className:`gz-ntd-show-all`,onClick:()=>M(`all`),children:[`Browse all `,x.length,` craftbooks`]})]},e.id))]})]}),(0,m.jsxs)(`div`,{className:`gz-npd-pane-footer gz-npd-pick-footer`,children:[(0,m.jsx)(`p`,{className:`gz-npd-footnote`,children:`Pick one to see what it does — nothing is created until the next screen.`}),(0,m.jsx)(ne,{children:(0,m.jsx)(`button`,{type:`button`,onClick:_,children:`Cancel`})})]})]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(`header`,{className:`gz-npd-header gz-npd-detail-header`,children:[(0,m.jsxs)(`button`,{type:`button`,className:`gz-npd-back`,onClick:et,children:[(0,m.jsx)(`span`,{"aria-hidden":`true`,children:`‹`}),G?`Craftbooks`:`Back`]}),(0,m.jsxs)(`div`,{className:`gz-npd-detail-id`,children:[(0,m.jsx)(`span`,{className:`gz-npd-detail-art`,"aria-hidden":`true`,children:G?(0,m.jsx)(ue,{...G.item.iconSvg?{iconSvg:G.item.iconSvg}:{},...G.item.logoUrl?{logoUrl:G.item.logoUrl}:{},svgClassName:`gz-npd-hero-art-svg`,fallback:(0,m.jsx)(d,{glyph:ce(G.manifest),size:26})}):(0,m.jsx)(d,{glyph:f.glyph,size:26})}),(0,m.jsxs)(`div`,{className:`gz-npd-header-copy`,children:[(0,m.jsx)(`p`,{className:`gz-npd-hero-eyebrow`,children:ut}),(0,m.jsx)(i,{asChild:!0,children:(0,m.jsx)(`h3`,{className:`gz-npd-hero-name`,children:G?G.manifest.name:y.generalLabel})})]})]}),!Ce&&dt&&(0,m.jsxs)(`p`,{className:`gz-ntd-detail-project`,children:[`in `,(0,m.jsx)(`strong`,{children:dt})]})]}),(0,m.jsxs)(`div`,{className:`gz-npd-detail`,"data-blank":G?void 0:`true`,children:[G&&(0,m.jsxs)(`div`,{className:`gz-npd-brief`,children:[(0,m.jsx)(`p`,{className:`gz-npd-brief-lede`,children:G.manifest.description}),G.manifest.basedOn&&(0,m.jsxs)(`p`,{className:`gz-ntd-based-on`,children:[`Based on`,` `,(0,m.jsx)(`a`,{href:G.manifest.basedOn.url,target:`_blank`,rel:`noreferrer`,children:G.manifest.basedOn.name})]}),(0,m.jsxs)(`div`,{className:`gz-ntd-steps`,children:[(0,m.jsxs)(`p`,{className:`gz-npd-give-eyebrow`,children:[G.manifest.steps.length,` step`,G.manifest.steps.length===1?``:`s`]}),(0,m.jsx)(`ol`,{className:`gz-ntd-steps-list`,children:G.manifest.steps.map(e=>(0,m.jsxs)(`li`,{children:[(0,m.jsxs)(`span`,{className:`gz-ntd-step-head`,children:[(0,m.jsx)(`span`,{className:`gz-ntd-step-name`,children:e.name}),e.suggestedRole&&(0,m.jsx)(`span`,{className:`gz-ntd-step-role`,children:e.suggestedRole})]}),e.description&&(0,m.jsx)(`span`,{className:`gz-ntd-step-note`,children:e.description})]},e.id))})]})]}),(0,m.jsxs)(`div`,{className:`gz-npd-setup`,children:[!G&&(0,m.jsx)(`p`,{className:`gz-npd-brief-lede`,children:y.generalDescription}),(0,m.jsxs)(`div`,{className:`gz-npd-pane-form`,children:[(0,m.jsxs)(`label`,{children:[`Title`,(0,m.jsx)(`input`,{value:P,onChange:e=>{F(e.target.value),Ie(!0)},placeholder:G?G.manifest.name:`e.g. Ship the landing page`})]}),$.length>0&&G&&(0,m.jsxs)(`div`,{className:`gz-ntd-needs`,children:[(0,m.jsx)(`p`,{className:`gz-npd-give-eyebrow`,children:`Needs setup`}),(0,m.jsx)(_e,{missing:$,onAllInstalled:()=>void Xe(),onCancel:et})]}),ct&&$.length===0&&(0,m.jsxs)(`div`,{className:`gz-npd-params`,children:[(0,m.jsx)(`p`,{className:`gz-npd-give-eyebrow`,children:`Parameters`}),(0,m.jsx)(se,{schema:ct,value:z,onChange:e=>{B(e??{}),W(``)},density:`comfortable`})]}),!G&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(`label`,{children:[`Description `,(0,m.jsx)(`span`,{className:`muted`,children:`· a sentence or two`}),(0,m.jsx)(`textarea`,{value:L,onChange:e=>Le(e.target.value),rows:4,placeholder:`What's the problem? What does success look like for the user?`})]}),(0,m.jsxs)(`label`,{children:[`Steps `,(0,m.jsx)(`span`,{className:`muted`,children:`(one per line)`}),(0,m.jsx)(`textarea`,{value:R,onChange:e=>Re(e.target.value),rows:4})]})]}),(0,m.jsxs)(`label`,{children:[`Assign to`,(0,m.jsxs)(o,{value:q,onValueChange:e=>{Be(e),He(!0)},children:[(0,m.jsx)(l,{children:(0,m.jsx)(c,{})}),(0,m.jsxs)(re,{children:[K&&(0,m.jsxs)(s,{value:h,children:[`Auto — the `,K,` for step 1`]}),g.map(e=>(0,m.jsxs)(s,{value:e.id,children:[e.name,e.role?` — ${e.role}`:``]},e.id)),(0,m.jsx)(s,{value:`__user`,children:`Me (no gezel)`})]})]}),q===h?(0,m.jsxs)(`small`,{className:`muted`,children:[`Every step picks its own specialist by role when the task fires. Step 1 goes to the `,K,`, and whoever that turns out to be owns the task.`]}):G&&(0,m.jsx)(`small`,{className:`muted`,children:`Steps that name a role pick their own specialist when the task fires — this only covers steps that name none.`}),q===`__user`&&(0,m.jsx)(`small`,{className:`muted`,children:`Assigned to you — firing won't hand it to a gezel.`})]}),t===`scheduled`&&(0,m.jsxs)(`div`,{className:`gz-ntd-schedule`,children:[(0,m.jsx)(`p`,{className:`gz-npd-give-eyebrow`,children:`Schedule`}),(0,m.jsxs)(`label`,{children:[`Cron expression `,(0,m.jsx)(`span`,{className:`muted`,children:`(UTC, 5-field)`}),(0,m.jsx)(`input`,{value:Ue,placeholder:`e.g. 0 9 * * 1 — every Monday 09:00`,onChange:e=>We(e.target.value)})]}),(0,m.jsxs)(`label`,{children:[`Overlap policy`,(0,m.jsxs)(o,{value:V,onValueChange:e=>Ge(e),children:[(0,m.jsx)(l,{children:(0,m.jsx)(c,{})}),(0,m.jsxs)(re,{children:[(0,m.jsx)(s,{value:`skip`,children:`skip — don't spawn if a prior run is still active`}),(0,m.jsx)(s,{value:`queue`,children:`queue — always spawn, let the runner throttle`}),(0,m.jsx)(s,{value:`concurrent`,children:`concurrent — spawn unconditionally`})]})]})]})]})]})]})]},T??`__general`),(0,m.jsxs)(`div`,{className:`gz-npd-pane-footer gz-npd-detail-footer`,children:[Ke?(0,m.jsx)(`p`,{className:`error small gz-npd-submit-error`,role:`alert`,children:Ke}):qe&&!Qe?(0,m.jsx)(`p`,{className:`gz-npd-footnote gz-ntd-launch-hint`,children:qe}):(0,m.jsx)(`p`,{className:`gz-npd-footnote`,children:t===`one-time`&&G?`Starts immediately — the first gezel gets to work as soon as you create it.`:y.footnote}),(0,m.jsxs)(ne,{children:[(0,m.jsx)(`button`,{type:`button`,onClick:_,disabled:H,children:`Cancel`}),(0,m.jsx)(`button`,{type:`submit`,className:`primary`,disabled:lt,children:H?t===`one-time`&&G?`Starting…`:`Creating…`:t===`one-time`&&G?`Create & start`:y.submitLabel})]})]})]})})})]})})}function xe(e,t){let n=e.manifest.name.toLowerCase();return n===t?0:n.startsWith(t)?1:n.split(/\s+/).some(e=>e.startsWith(t))?2:n.includes(t)?3:`${e.manifest.id} ${(e.manifest.tags??[]).join(` `)}`.toLowerCase().includes(t)?4:5}function Se({label:e,description:t,active:n,iconSvg:r,logoUrl:i,glyph:a,suggested:ee=!1,index:o,onSelect:te}){return(0,m.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":n,"aria-label":e,className:`gz-npd-card${n?` active`:``}${ee?` gz-ntd-card-suggested`:``}`,onClick:te,style:{"--card-i":Math.min(o,11)},children:[(0,m.jsx)(`span`,{className:`gz-npd-card-mark`,"aria-hidden":`true`,children:(0,m.jsx)(ue,{...r?{iconSvg:r}:{},...i?{logoUrl:i}:{},svgClassName:`gz-npd-card-mark-svg`,fallback:(0,m.jsx)(d,{glyph:a,size:22})})}),(0,m.jsx)(`span`,{className:`gz-npd-card-name`,children:e}),(0,m.jsx)(`span`,{className:`gz-npd-card-description`,children:t})]})}export{g as t};
@@ -1,5 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalCodeEditor-77pBm6f3.js","assets/rolldown-runtime-aKtaBQYM.js","assets/jsx-runtime-CEpd2cAX.js","assets/preload-helper-Czpn1I53.js","assets/index-DXWR4qW1.js","assets/react-dom-OL4w_gzs.js","assets/primitives-DEsn1shf.js","assets/Tabs-BAY1Q79B.js","assets/dist-Bvo52IGx.js","assets/dist-BPx-FyRH.js","assets/dist-D5aoNQwk.js","assets/api-BX5xXiFs.js","assets/NewPathDialog-D4jnNBfP.js","assets/DropdownMenu-D5fCzIrh.js","assets/relative-time-B2kBaekd.js","assets/FileTypeIcon-Cwzl1GkZ.js","assets/model-memory-copy-CeuXAj-T.js","assets/model-context-DBqdK0PS.js","assets/StorageCleanupDialog-DHqwyMZZ.js","assets/poppetje-Ce-02Aqi.js","assets/safe-svg-image-NbuPaBIv.js","assets/ConfirmDialog-BHFs6vmJ.js","assets/doc-s6H7T0IO.js","assets/chunk-O7JILDEF-CqcO1qaI.js","assets/chunk-BAOV476U-CEOFYt8X.js","assets/chunk-4VOD55SX-BFSSw0c8.js","assets/chunk-GAZKTT4R-BkP6-w3z.js","assets/chunk-MIKKUKOD-XIkmalSN.js","assets/chunk-XRW6P7IF-BeQQgMVK.js","assets/chunk-7ZAAICW4-BsCpYJH6.js","assets/markdown-Bi9b5f5Y.js","assets/schemas-JY4jmLbC.js","assets/chunk-6ECMNUIP-C1kohb1U.js","assets/inlineIconMarker-BQI2HLeD.js","assets/chunk-TT6ENR6T-CaYjVwjm.js","assets/chunk-DAMIRKTO-CGniCSiM.js","assets/new-project-meta-0xhggGA_.js","assets/chunk-AE3IUKMM-mZjzzO8Z.js","assets/index-D1m4Wx8V.css"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{n as t,t as n}from"./jsx-runtime-CEpd2cAX.js";import{_ as r,g as i,o as a,v as o,y as s}from"./primitives-DEsn1shf.js";import{Ht as c,R as l,hn as u,nt as d,ot as f}from"./dist-BPx-FyRH.js";import{t as p}from"./api-BX5xXiFs.js";import{i as m,n as h,o as g,r as _,t as v}from"./DropdownMenu-D5fCzIrh.js";import{n as y,t as b}from"./relative-time-B2kBaekd.js";import{t as x}from"./preload-helper-Czpn1I53.js";import{A as S,Bt as C,D as w,Lt as T,O as E,b as D,d as O,k,r as ee}from"./index-DXWR4qW1.js";import{t as te}from"./NewTaskDialog-Ox9D612Z.js";import{t as A}from"./useShowWorkInProgressFeatures-DwwviLRO.js";import{i as j,n as M,r as N}from"./ChatTimelineView-Do9EryEH.js";import{a as P,i as F,t as ne}from"./SessionSwitcher-C8te7YSe.js";import{n as I,t as re}from"./ProjectTimeline-DRe3D9qY.js";import{a as ie,c as ae,i as oe,l as se,o as ce,s as le,u as L}from"./chat-thread-memory-CZGcwgGo.js";import{r as R,t as z}from"./completion-data--97asQiQ.js";var B=e(t(),1),V=[/<function=([a-zA-Z_][a-zA-Z0-9_]*)/,/<invoke\s+name="([a-zA-Z_][a-zA-Z0-9_]*)/,/"(?:tool|name|function)"\s*:\s*"([a-zA-Z_][a-zA-Z0-9_]*)"/],H=/<function[=\s>]|<tool_call>|<invoke[\s>]|<parameter[=\s]|<\|tool_call\|>/i,ue=/<\/?think>|<\|?channel\|?>|(?:^|\n)(?:thought|analysis|commentary)\|/i,U=/!\[[^\]]*\]\(/,de=/<think>(?![\s\S]*<\/think>)/i,W=/\{\s*"(?:tool|name|function)"\s*:\s*"[a-zA-Z_][a-zA-Z0-9_]*"/g;function fe(e){if(!e.includes(`{`))return e;let t=``,n=0;W.lastIndex=0;for(let r=W.exec(e);r;r=W.exec(e)){if(r.index<n)continue;let i=0,a=!1,o=!1,s=-1;for(let t=r.index;t<e.length;t++){let n=e[t];if(o)o=!1;else if(n===`\\`&&a)o=!0;else if(n===`"`)a=!a;else if(!a&&n===`{`)i++;else if(!a&&n===`}`&&(i--,i===0)){s=t+1;break}}t+=e.slice(n,r.index),n=s===-1?e.length:s,W.lastIndex=n}return t+e.slice(n)}function G(e){return e.replace(/!\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/@\[([^\]]+)\]\([^)]+\)/g,`@$1`).replace(/\[([^\]]+)\]\([^)]+\)/g,`$1`).replace(/[*_~`#>]+/g,``).replace(/\s+/g,` `).trim()}function K(e){let t=S(e);if(t.length>0)return{name:t[0].name,trusted:!0};for(let t of V){let n=e.match(t);if(n?.[1])return{name:n[1],trusted:!1}}return null}function q(e){if(!e)return``;let t=d(e);if(t)return t;let n=e.search(de),r=n===-1?e:e.slice(0,n),i=G(fe(k(r,{hideMidStreamOpener:!0})));if(i)return i;let a=K(r);return a&&(a.trusted||w(a.name))?`${E(a.name)}…`:a||H.test(r)?`Using a tool…`:ue.test(e)?`Thinking…`:U.test(r)?`Shared an image`:``}function pe(e,t){let n=(0,B.useRef)(new Map),r=(0,B.useRef)(new Set),[i,a]=(0,B.useState)(0),o=(0,B.useMemo)(()=>[...new Set(e)].sort().join(`
3
- `),[e]);return(0,B.useEffect)(()=>{for(let[e,t]of[...n.current])t||n.current.delete(e)},[t]),(0,B.useEffect)(()=>{let e=(o?o.split(`
4
- `):[]).filter(e=>!n.current.has(e)&&!r.current.has(e));if(e.length===0)return;let t=!1;for(let t of e)r.current.add(t);return Promise.all(e.map(async e=>{try{let t=await p.getTaskByRef(e);n.current.set(e,t.status===`complete`||t.status===`canceled`)}catch{n.current.set(e,!1)}finally{r.current.delete(e)}})).then(()=>{t||a(e=>e+1)}),()=>{t=!0}},[o,t]),(0,B.useMemo)(()=>{let e=o?o.split(`
5
- `):[];return new Set(e.filter(e=>n.current.get(e)===!0))},[o,i])}var me=750,J=2e4,he={inflight:0,errored:1,idle:2};function Y(e){let t=Date.parse(e);return Number.isNaN(t)?0:t}function ge(e){let t=e.replace(/\s+/g,` `).trim(),n=``;for(let e of t){if(n.length+e.length>200)break;n+=e}return n}function X(e,t,n){let r=!1,i=e.map(e=>{if(e.id!==t)return e;r=!0;let i=new Set(e.involvedGezelIds??[e.gezelId]);n.from&&i.add(n.from.gezelId);let a=ge(n.content);return{...e,lastActivityAt:n.at,involvedGezelIds:[...i],...a?{lastMessagePreview:a}:{}}});return r?i:null}function _e(e){let{sessions:t,inflight:n,errored:r,now:i,pinnedSessionId:a,groupedTaskRefs:o,finishedTaskRefs:s,liveTools:c,maxInline:l=6}=e,u=[],d=new Map,f=t.filter(e=>!e.archived&&!e.taskRef).reduce((e,t)=>!e||Y(t.lastActivityAt)>Y(e.lastActivityAt)?t:e,null)?.id;for(let e of t){if(e.archived)continue;let t=r.get(e.id)??e.lastTurnError,l=n.has(e.id)?`inflight`:t?`errored`:`idle`,p=l===`inflight`?c?.get(e.id):void 0,m={sessionId:e.id,gezelId:e.gezelId,title:P(F(e.title)),lastActivityAt:e.lastActivityAt,state:l,involvedGezelIds:e.involvedGezelIds&&e.involvedGezelIds.length>0?e.involvedGezelIds:[e.gezelId],...e.lastMessagePreview?{lastMessagePreview:e.lastMessagePreview}:{},...p?{liveToolName:p}:{},...e.taskRef?{taskRef:e.taskRef}:{},...t?{error:t}:{}};if(e.taskRef&&o?.has(e.taskRef)){let t=d.get(e.taskRef);(!t||Y(m.lastActivityAt)>Y(t.lastActivityAt))&&d.set(e.taskRef,m);continue}let h=a!==void 0&&e.id===a;if(l===`idle`&&!h&&e.taskRef&&s?.has(e.taskRef))continue;let g=e.id===f;l===`idle`&&!h&&!g&&i-Y(e.lastActivityAt)>864e5||u.push(m)}u.sort((e,t)=>{let n=he[e.state]-he[t.state];return n===0?Y(t.lastActivityAt)-Y(e.lastActivityAt):n});let p=u.filter(e=>e.state!==`idle`).length,m=Math.max(l,p);for(let e of[a,f]){if(e===void 0)continue;let t=u.findIndex(t=>t.sessionId===e);t>=m&&(m=t+1)}return{pills:u.slice(0,m),overflow:u.slice(m),taskPills:d}}function ve({projectId:e,gezelId:t,pinnedSessionId:n,groupedTaskRefs:r,refreshKey:i}){let[a,o]=(0,B.useState)([]),s=(0,B.useRef)([]),[c,l]=(0,B.useState)(!0),[u,d]=(0,B.useState)(()=>new Set),[f,m]=(0,B.useState)(()=>new Map),[h,g]=(0,B.useState)(()=>new Map),[_,v]=(0,B.useState)(0),y=(0,B.useCallback)(async()=>{try{let n=await p.listChatSessions({projectId:e,...t?{gezelId:t}:{}});s.current=n.sessions,o(n.sessions)}catch{}finally{l(!1)}},[e,t]),b=(0,B.useCallback)(async()=>{try{let{inflight:n}=await p.listInflightTurns({projectId:e,...t?{gezelId:t}:{}});d(new Set(n.map(e=>e.sessionId)))}catch{}},[e,t]);(0,B.useEffect)(()=>{l(!0),y(),b()},[y,b,i,n]),(0,B.useEffect)(()=>{let e=window.setInterval(()=>void b(),J);return()=>window.clearInterval(e)},[b]),(0,B.useEffect)(()=>{let e=window.setInterval(()=>v(e=>e+1),6e4);return()=>window.clearInterval(e)},[]),(0,B.useEffect)(()=>{let e=()=>void y();return window.addEventListener(`gezel:session-error-cleared`,e),()=>window.removeEventListener(`gezel:session-error-cleared`,e)},[y]);let x=(0,B.useCallback)((e,t)=>{g(n=>{if(t===null){if(!n.has(e))return n;let t=new Map(n);return t.delete(e),t}if(n.get(e)===t)return n;let r=new Map(n);return r.set(e,t),r})},[]),S=(0,B.useRef)(null);(0,B.useEffect)(()=>{let n=new AbortController,r=()=>{S.current!==null&&window.clearTimeout(S.current),S.current=window.setTimeout(()=>{S.current=null,y()},me)};return(async()=>{try{for await(let i of C({url:p.projectEventsUrl(e),headers:p.authHeader(),signal:n.signal,fetch:p.getFetch()})){let{event:e,sessionId:n}=i;if(!(t&&i.gezelId!==t)){if(e.type===`tool_args_delta`||e.type===`tool`?x(n,e.name):(e.type===`complete`||e.type===`done`||e.type===`error`||e.type===`cancelled`)&&x(n,null),e.type===`user_message`){d(e=>{if(e.has(n))return e;let t=new Set(e);return t.add(n),t});let t=X(s.current,n,e.message);t?(s.current=t,o(t)):y()}else(e.type===`done`||e.type===`error`||e.type===`cancelled`)&&d(e=>{if(!e.has(n))return e;let t=new Set(e);return t.delete(n),t});if(e.type===`error`)m(t=>{let r=new Map(t);return r.set(n,e.error),r});else if(e.type===`complete`){let t=X(s.current,n,e.message);t&&(s.current=t,o(t)),m(e=>{if(!e.has(n))return e;let t=new Map(e);return t.delete(n),t})}(e.type===`done`||e.type===`complete`)&&r()}}}catch{}})(),()=>{n.abort(),S.current!==null&&(window.clearTimeout(S.current),S.current=null)}},[e,t,y,x]);let w=pe((0,B.useMemo)(()=>{let e=new Set;for(let t of a)t.archived||!t.taskRef||r?.has(t.taskRef)||e.add(t.taskRef);return[...e]},[a,r]),i),{pills:T,overflow:E,taskPills:D}=(0,B.useMemo)(()=>_e({sessions:a,inflight:u,errored:f,now:Date.now(),pinnedSessionId:n,liveTools:h,finishedTaskRefs:w,...r?{groupedTaskRefs:r}:{}}),[a,u,f,h,n,r,w,_]);return{pills:T,overflow:E,taskPills:D,loading:c}}var Z=n(),ye=1440*60*1e3;function be(e){let t=Date.parse(e);return Number.isNaN(t)?0:t}function xe({projectId:e,gezelId:t,gezels:n,activeSessionId:r,activeTaskRef:i,activeTerminalThreadId:a,onFocusThread:o,onFocusTask:s,onFocusTerminal:c,onNewTask:u,refreshKey:d,terminalRefreshKey:f}){let{tasks:y,loading:b}=I({projectId:e,refreshKey:d}),{pills:x,overflow:S,taskPills:C,loading:w}=ve({projectId:e,gezelId:t,pinnedSessionId:r,groupedTaskRefs:(0,B.useMemo)(()=>new Set(y.map(e=>e.ref)),[y]),refreshKey:d}),[T,E]=(0,B.useState)([]),O=c!==void 0;(0,B.useEffect)(()=>{if(!O){E([]);return}let t=!1;return p.listTerminalThreads(e).then(e=>{if(t)return;let n=Date.now()-ye;E(e.threads.filter(e=>!e.archived&&be(e.lastActivityAt)>=n))}).catch(()=>{}),()=>{t=!0}},[e,O,f]);let k=(0,B.useMemo)(()=>T.filter(t=>t.projectId===e),[T,e]),ee=D(),te=e=>{let t=n.find(t=>t.id===e);return t?l({name:t.name,roleBasedName:t.roleBasedName},ee):`someone`},A=e=>[...new Set(e.involvedGezelIds.map(te))].join(`, `),j=[...x,...C.values()],M=j.filter(e=>e.state===`inflight`).length,N=j.filter(e=>e.state===`errored`).length,P=[M>0?`${M} ${M===1?`thread`:`threads`} working`:``,N>0?`${N} needs attention`:``].filter(Boolean).join(`, `),F=!(b||w)&&x.length===0&&k.length===0&&y.length===0,{scrollRef:ne,overflowBar:re}=Se(x.length+S.length+k.length+y.length+ +!!F);return(0,Z.jsxs)(`div`,{className:`chat-pill-row`,role:`toolbar`,"aria-label":`Threads, terminal windows, and tasks`,children:[(0,Z.jsx)(`output`,{className:`sr-only`,children:P}),(0,Z.jsxs)(`div`,{className:`chat-pill-row-scroller`,children:[(0,Z.jsxs)(`div`,{className:`chat-pill-row-scroll`,ref:ne,onScroll:re.onScroll,children:[F&&(0,Z.jsx)(`span`,{className:`chat-pill-row-empty muted small`,children:`No recent threads`}),y.map(e=>{let t=C.get(e.ref);return(0,Z.jsx)(Ae,{task:e,latestThread:t,gezels:n,gezelNames:t?A(t):e.assignee.kind===`gezel`?te(e.assignee.gezelId):`You`,active:e.ref===i,onFocus:s},e.ref)}),x.map(e=>(0,Z.jsx)(we,{pill:e,gezels:n,gezelNames:A(e),active:e.sessionId===r,onFocus:o},e.sessionId)),S.length>0&&(0,Z.jsxs)(m,{children:[(0,Z.jsxs)(g,{className:`chat-pill chat-pill-overflow`,children:[`+`,S.length,` more`]}),(0,Z.jsx)(_,{children:(0,Z.jsx)(v,{className:`chat-rail-section-tab-menu chat-pill-overflow-menu`,align:`start`,sideOffset:4,children:S.map(e=>(0,Z.jsx)(h,{onSelect:()=>o(e),className:`chat-pill-overflow-item chat-pill-${e.state}`,children:(0,Z.jsx)(Te,{pill:e,gezelNames:A(e)})},e.sessionId))})})]}),c&&k.map(e=>(0,Z.jsx)(Ce,{thread:e,active:e.id===a,onFocus:c},e.id))]}),re.node]}),u&&(0,Z.jsx)(`button`,{type:`button`,className:`chat-pill-new-task`,onClick:u,"aria-label":`New task`,title:`New task — pick a craftbook`,children:`Do +`})]})}function Se(e){let t=(0,B.useRef)(null),[n,r]=(0,B.useState)(null),i=(0,B.useCallback)(()=>{let e=t.current;if(!e)return;let{scrollWidth:n,clientWidth:i,scrollLeft:a}=e;if(n-i<2){r(e=>e===null?e:null);return}let o=i/n,s=a/n;r(e=>e&&Math.abs(e.left-s)<5e-4&&Math.abs(e.width-o)<5e-4?e:{left:s,width:o})},[]);return(0,B.useEffect)(()=>{i()},[i,e]),(0,B.useEffect)(()=>{let e=t.current;if(!e||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>i());return n.observe(e),()=>n.disconnect()},[i]),{scrollRef:t,overflowBar:{onScroll:i,node:n&&(0,Z.jsx)(`div`,{className:`chat-pill-row-bar`,"aria-hidden":`true`,onPointerDown:e=>{let r=t.current;if(!r||!n)return;let i=e.currentTarget.getBoundingClientRect(),a=(e.clientX-i.left)/i.width<n.left?-r.clientWidth:r.clientWidth;r.scrollBy({left:a,behavior:`smooth`})},children:(0,Z.jsx)(`div`,{className:`chat-pill-row-bar-thumb`,style:{left:`${n.left*100}%`,width:`${n.width*100}%`},onPointerDown:e=>{let n=t.current,r=e.currentTarget.parentElement;if(!n||!r)return;e.preventDefault(),e.stopPropagation();let i=n.scrollWidth/r.clientWidth,a=e.clientX,o=n.scrollLeft,s=e=>{n.scrollLeft=o+(e.clientX-a)*i},c=()=>{window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c)};window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c)}})})}}}function Ce({thread:e,active:t,onFocus:n}){let r=N(e.workingDir),i=$(e.lastActivityAt),a=e.lastCommand?.replace(/\s+/g,` `).trim()||null,o=a?Q(a,40):null;return(0,Z.jsxs)(`button`,{type:`button`,className:`chat-pill chat-pill-thread chat-pill-terminal${t?` is-active`:``}`,"aria-pressed":t,"aria-label":`Terminal ${r}.${a?` Last command: ${a}.`:``} Updated ${i}`,title:`Terminal · ${r}${a?` · last command: ${a}`:``} · updated ${i}`,onClick:()=>n(e),children:[(0,Z.jsx)(`span`,{className:`chat-pill-thread-line chat-pill-thread-title`,children:`Terminal`}),(0,Z.jsxs)(`span`,{className:`chat-pill-thread-line chat-pill-thread-context`,children:[(0,Z.jsx)(`span`,{className:`terminal-prompt-sigil`,"aria-hidden":`true`,children:`>`}),(0,Z.jsx)(`span`,{className:`chat-pill-message-preview${a?` chat-pill-terminal-command`:``}`,children:o??r})]}),(0,Z.jsxs)(`span`,{className:`chat-pill-thread-line chat-pill-thread-update`,children:[a&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`chat-pill-terminal-folder`,children:r}),(0,Z.jsx)(`span`,{className:`chat-pill-separator`,"aria-hidden":`true`,children:`·`})]}),(0,Z.jsxs)(`span`,{className:`chat-pill-thread-updated-at`,title:b(e.lastActivityAt),children:[`Updated `,i]})]})]})}function we({pill:e,gezels:t,gezelNames:n,active:r,onFocus:i}){let a=t.find(t=>t.id===e.gezelId),o=$(e.lastActivityAt),s=ke(e.state),c=Oe(e),l=`${n} · ${e.title} · updated ${o} · ${s}${e.error?`: ${e.error}`:``}`;return(0,Z.jsx)(`button`,{type:`button`,className:`chat-pill chat-pill-thread chat-pill-${e.state}${r?` is-active`:``}`,"aria-pressed":r,"aria-label":`${n}: ${e.title}. ${c}. Updated ${o}. ${s}`,title:l,onClick:()=>i(e),children:(0,Z.jsx)(Te,{pill:e,gezelNames:n,gezel:a})})}function Te({pill:e,gezelNames:t,gezel:n}){let r=Oe(e);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`chat-pill-thread-line chat-pill-thread-title`,children:Q(e.title,40)}),(0,Z.jsxs)(`span`,{className:`chat-pill-thread-line chat-pill-thread-context`,children:[n&&(0,Z.jsx)(T,{svg:n.icon??null,poppetje:n.poppetje,iconOverride:n.iconOverride,name:t,size:14}),(0,Z.jsx)(`span`,{className:`chat-pill-participants`,children:t}),(0,Z.jsx)(`span`,{className:`chat-pill-separator`,"aria-hidden":`true`,children:`·`}),(0,Z.jsx)(`span`,{className:`chat-pill-message-preview`,children:r})]}),(0,Z.jsxs)(`span`,{className:`chat-pill-thread-line chat-pill-thread-update`,children:[(0,Z.jsxs)(`span`,{className:`chat-pill-thread-updated-at`,title:b(e.lastActivityAt),children:[`Updated `,$(e.lastActivityAt)]}),(0,Z.jsx)(`span`,{className:`chat-pill-separator`,"aria-hidden":`true`,children:`·`}),(0,Z.jsxs)(`span`,{className:`chat-pill-thread-status`,children:[(0,Z.jsx)(`span`,{className:`chat-pill-dot`,"aria-hidden":`true`}),ke(e.state)]})]})]})}var Ee=30,De=34;function Oe(e){if(e.state===`inflight`&&e.liveToolName)return Q(`${E(e.liveToolName)}…`,De);let t=e.lastMessagePreview?q(e.lastMessagePreview):``;return t?Q(t,Ee):`No messages yet`}function Q(e,t){let n=Array.from(e.trim());return n.length<=t?n.join(``):`${n.slice(0,t-1).join(``)}…`}function ke(e){return e===`inflight`?`Working`:e===`errored`?`Needs attention`:`Ready`}function $(e){return y(e,{style:`long`,fallback:e})}function Ae({task:e,latestThread:t,gezels:n,gezelNames:r,active:i,onFocus:a}){let o=e.assignee.kind===`user`,s=e.assignee.kind===`gezel`?e.assignee.gezelId:null,c=t?n.find(e=>e.id===t.gezelId):s?n.find(e=>e.id===s):void 0,l=t?$(t.lastActivityAt):null,u=t?ke(t.state):`Active`,d=t?Oe(t):`No chat yet`,f=t?`Latest chat with ${r}: ${t.title}. ${d}. Updated ${l}. ${u}`:`${d}. Assigned to ${r}. ${u}`;return(0,Z.jsxs)(`button`,{type:`button`,className:`chat-pill chat-pill-thread chat-pill-task${t?` chat-pill-${t.state}`:``}${i?` is-active`:``}`,"aria-pressed":i,"aria-label":`Task ${e.ref}: ${e.title}. ${f}`,title:t?`${e.ref} · ${e.title} · latest chat: ${t.title} · ${r} · updated ${l} · ${u}${t.error?`: ${t.error}`:``}`:o?`${e.ref} · ${e.title} — assigned to you · no chat yet`:`${e.ref} · ${e.title} · no chat yet`,onClick:()=>a(e),children:[(0,Z.jsxs)(`span`,{className:`chat-pill-thread-line chat-pill-task-title`,children:[(0,Z.jsx)(O,{area:`tasks`,size:13,className:`chat-pill-task-icon`}),(0,Z.jsxs)(`span`,{className:`chat-pill-task-number`,children:[`#`,e.num]}),(0,Z.jsx)(`span`,{className:`chat-pill-label`,children:e.title})]}),(0,Z.jsxs)(`span`,{className:`chat-pill-thread-line chat-pill-thread-context`,children:[c&&(0,Z.jsx)(T,{svg:c.icon??null,poppetje:c.poppetje,iconOverride:c.iconOverride,name:r,size:14}),(0,Z.jsx)(`span`,{className:`chat-pill-participants`,children:r}),(0,Z.jsx)(`span`,{className:`chat-pill-separator`,"aria-hidden":`true`,children:`·`}),(0,Z.jsx)(`span`,{className:`chat-pill-message-preview`,children:d})]}),(0,Z.jsxs)(`span`,{className:`chat-pill-thread-line chat-pill-thread-update`,children:[(0,Z.jsx)(`span`,{className:`chat-pill-thread-updated-at`,title:t?b(t.lastActivityAt):void 0,children:l?`Updated ${l}`:e.ref}),(0,Z.jsx)(`span`,{className:`chat-pill-separator`,"aria-hidden":`true`,children:`·`}),(0,Z.jsxs)(`span`,{className:`chat-pill-thread-status`,children:[t?(0,Z.jsx)(`span`,{className:`chat-pill-dot`,"aria-hidden":`true`}):(0,Z.jsx)(`span`,{className:`task-status-dot task-status-active`,"aria-hidden":`true`}),u]})]})]})}function je({projectId:e,workingDir:t,onChangeWorkingDir:n}){let[r,i]=(0,B.useState)([]),[a,o]=(0,B.useState)(null),[c,l]=(0,B.useState)(!1),u=(0,B.useRef)(null);(0,B.useEffect)(()=>{if(!c&&r.length>0)return;let t=!1;return(async()=>{try{let n=await p.listProjectWorkspace(e,void 0,!0);if(t)return;let r=n.files.filter(e=>e.isDirectory).map(e=>{let t=e.path.split(`/`).length-1;return{path:e.path,name:e.name,depth:t}});r.sort((e,t)=>e.path<t.path?-1:+(e.path>t.path)),i(r)}catch(e){if(t)return;o(e instanceof Error?e.message:String(e))}})(),()=>{t=!0}},[e,c]),(0,B.useEffect)(()=>{if(!c)return;function e(e){u.current?.contains(e.target)||l(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[c]);let d=(0,B.useMemo)(()=>[{path:``,name:`/`,depth:0},...r],[r]),f=N(t);return(0,Z.jsxs)(`div`,{className:`folder-tree-switcher`,ref:u,children:[(0,Z.jsx)(`span`,{className:`folder-tree-label`,children:`Folder:`}),(0,Z.jsxs)(`button`,{type:`button`,className:`folder-tree-trigger`,onClick:()=>l(e=>!e),title:`Pick a working folder`,"aria-expanded":c,children:[(0,Z.jsx)(`span`,{className:`folder-tree-trigger-value`,children:f}),(0,Z.jsx)(s,{className:`folder-tree-trigger-caret`})]}),c&&(0,Z.jsxs)(`div`,{className:`folder-tree-popup`,role:`listbox`,children:[a&&(0,Z.jsx)(`div`,{className:`terminal-error-banner`,children:a}),d.map(e=>{let r=e.path===t;return(0,Z.jsx)(`button`,{type:`button`,role:`option`,"aria-selected":r,className:`folder-tree-node${r?` active`:``}`,style:{paddingLeft:`${.4+e.depth*.9}rem`},onClick:()=>{n(e.path),l(!1)},title:e.path||`/`,children:(0,Z.jsx)(`span`,{children:e.path===``?`/`:e.name})},e.path||`__root__`)})]})]})}function Me(){return(0,Z.jsxs)(`div`,{className:`project-chat project-chat-placeholder`,"aria-busy":`true`,children:[(0,Z.jsx)(`span`,{className:`sr-only`,children:`Loading this project's chat…`}),(0,Z.jsx)(`div`,{className:`project-chat-placeholder-timeline`,"aria-hidden":`true`}),(0,Z.jsx)(`div`,{className:`project-chat-compose-shell`,"aria-hidden":`true`,children:(0,Z.jsxs)(`div`,{className:`project-chat-compose-main`,children:[(0,Z.jsx)(`div`,{className:`project-chat-placeholder-band`}),(0,Z.jsx)(`div`,{className:`project-chat-placeholder-entry`})]})})]})}function Ne(e){let t=A(),[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)([]),[o,s]=(0,B.useState)([]),c=(0,B.useRef)(void 0);(0,B.useEffect)(()=>{let n=!1,i=async()=>{try{let t=await p.getProjectIndex(e);n||r(t)}catch{}},o=async()=>{try{let r=await p.listProjectCraftbooks(e);if(n)return;a(u(r.items,t).flatMap(e=>{let t=e.manifest;return t.kind&&t.kind!==`craftbook-template`||!t.id?[]:[{id:t.id,command:t.command??t.id,name:t.name,description:t.description,paramSchema:t.paramSchema}]}))}catch{}},l=async()=>{try{let t=await p.listProjectTools(e);n||s(t.tools)}catch{}},d=async()=>{n||o();try{let t=await p.getProjectIndexStatus(e);if(n)return;let r=t.meta?.scannedAt;r&&r!==c.current?(c.current=r,await i()):t.state===`never`&&await p.refreshProjectIndex(e).catch(()=>{})}catch{}};i(),o(),l();let f=window.setInterval(d,3e4);return()=>{n=!0,window.clearInterval(f)}},[e,t]),(0,B.useEffect)(()=>{R(e,{index:n,craftbooks:i,mcpTools:o})},[e,n,i,o]),(0,B.useEffect)(()=>()=>z(e),[e])}var Pe=(0,B.lazy)(()=>x(()=>import(`./TerminalCodeEditor-77pBm6f3.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38]))),Fe=`build, test, git status, … — Enter runs, Shift+Enter for newline, ↑/↓ recalls history`,Ie=[{section:`commands`,label:`Commands`,title:`Everyday terminal commands, and the tools installed on this machine`,icon:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`path`,{d:`M2.5 4 L6 8 L2.5 12`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,Z.jsx)(`path`,{d:`M8 12 H13.5`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`})]})},{section:`scripts`,label:`Scripts`,title:`Scripts this project already defines — package.json, scripts/, launches`,icon:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`rect`,{x:`3`,y:`2`,width:`10`,height:`12`,rx:`1.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`}),(0,Z.jsx)(`path`,{d:`M5.5 5.5h5M5.5 8h5M5.5 10.5h3`,stroke:`currentColor`,strokeWidth:`1.3`,strokeLinecap:`round`})]})},{section:`tasks`,label:`Tasks`,title:`Craftbooks and workspace skills a gezel can run for you`,icon:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`path`,{d:`M2.5 4.5 L4 6 L6.5 3`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,Z.jsx)(`path`,{d:`M8.5 5 H14`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`}),(0,Z.jsx)(`path`,{d:`M2.5 11 L4 12.5 L6.5 9.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,Z.jsx)(`path`,{d:`M8.5 11.5 H14`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})]})}];function Le({projectId:e,workingDir:t,contextRow:n,toolbarTrailing:s,onSent:c,initialInput:l,onChatEscape:u}){let[d]=(0,B.useState)(()=>l??``),[f,m]=(0,B.useState)(null),[h,g]=(0,B.useState)(null),_=(0,B.useRef)(null),v=(0,B.useRef)([]),y=(0,B.useRef)(-1),b=(0,B.useCallback)(e=>{_.current?.setValue(e),g(null)},[]);Ne(e);let x=(0,B.useCallback)(async n=>{let r=n.trim();if(r!==``){_.current?.setValue(``),m(null),v.current.unshift(r),v.current.length>50&&(v.current.length=50),y.current=-1;try{let n=await p.runTerminalCommand(e,{workingDir:t,input:r});c?.(r,n)}catch(e){m(e instanceof Error?e.message:String(e)),_.current?.focus()}}},[e,t,c]),S=(0,B.useCallback)(()=>{let e=_.current;e&&(x(e.getValue()),e.focus())},[x]),C=(0,B.useCallback)(()=>{if(v.current.length===0)return;let e=Math.min(v.current.length-1,y.current+1);y.current=e,_.current?.setValue(v.current[e])},[]),w=(0,B.useCallback)(()=>{if(y.current<0)return;let e=y.current-1;y.current=e,_.current?.setValue(e<0?``:v.current[e])},[]);return(0,Z.jsxs)(`div`,{className:`terminal-composer`,children:[(0,Z.jsxs)(`div`,{className:`terminal-composer-toolbar`,children:[Ie.map(t=>(0,Z.jsxs)(r,{open:h===t.section,onOpenChange:e=>g(e?t.section:null),children:[(0,Z.jsx)(o,{asChild:!0,children:(0,Z.jsxs)(`button`,{type:`button`,className:`terminal-toolbar-btn`,title:t.title,"aria-label":t.title,children:[(0,Z.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:t.icon}),t.label]})}),(0,Z.jsx)(i,{className:`terminal-commands-popover`,side:`top`,align:`start`,onCloseAutoFocus:e=>{e.preventDefault(),_.current?.focus()},children:(0,Z.jsx)(L,{projectId:e,section:t.section,onStageCommand:b})})]},t.section)),s]}),n,(0,Z.jsx)(`div`,{className:`terminal-composer-fire-row`,children:(0,Z.jsx)(`button`,{type:`button`,className:`terminal-fire-btn`,"aria-label":`Fire`,title:`Fire — run this command (Enter)`,onClick:S,children:(0,Z.jsx)(a,{})})}),(0,Z.jsxs)(`div`,{className:`terminal-composer-input-wrap`,children:[(0,Z.jsx)(`span`,{className:`terminal-prompt-sigil`,children:`>`}),(0,Z.jsx)(B.Suspense,{fallback:(0,Z.jsx)(`div`,{className:`terminal-composer-input`,"aria-busy":`true`}),children:(0,Z.jsx)(Pe,{ref:_,projectId:e,initialValue:d,placeholder:Fe,onSubmit:e=>void x(e),onHistoryPrev:C,onHistoryNext:w,onChatEscape:u})})]}),f&&(0,Z.jsx)(`div`,{className:`terminal-error-banner`,children:f})]})}function Re(e,t){return M(e?.lastHumanActivityAt,t)}function ze({project:e,compact:t=!1}){let[n,r]=(0,B.useState)([]),[i,a]=(0,B.useState)(!1),[o,s]=(0,B.useState)(``);(0,B.useEffect)(()=>{p.listGezels().then(e=>{r(e.gezels),a(!0)}).catch(()=>a(!0))},[e.id,e.voormanGezelId,(e.gezelIds??[]).join(`,`)]),(0,B.useEffect)(()=>{s(``),d(null)},[e.id]);let[c,l]=(0,B.useState)(void 0);(0,B.useEffect)(()=>{l(void 0);let t=!1;return p.listChatSessions({projectId:e.id}).then(e=>{if(t)return;let n=e.sessions.filter(e=>!e.archived&&!e.taskRef)[0];l(n?{gezelId:n.gezelId,...n.lastHumanActivityAt?{lastHumanActivityAt:n.lastHumanActivityAt}:{}}:null)}).catch(()=>{t||l(null)}),()=>{t=!0}},[e.id]);let[u,d]=(0,B.useState)(null),f=(0,B.useCallback)(e=>{d(null),s(e)},[]);(0,B.useEffect)(()=>{if(o)return;let t=ce(oe(e.id))?.gezelId;if(t&&n.some(e=>e.id===t)){s(t),d(null);return}if(c===void 0)return;let r=Re(c,Date.now())&&c&&n.some(e=>e.id===c.gezelId)?c.gezelId:``,i=n.find(t=>t.id===e.voormanGezelId)?.id??``,a=(e.gezelIds??[]).map(e=>n.find(t=>t.id===e)?.id).find(Boolean)??``,l=r||i||a||n[0]?.id||``;l&&(s(l),d(r?null:l))},[o,c,n,e.id,e.voormanGezelId,e.gezelIds]),(0,B.useEffect)(()=>{o&&le(oe(e.id),{gezelId:o})},[e.id,o]);let m=n.find(e=>e.id===o);return!i||n.length>0&&!m?(0,Z.jsx)(Me,{}):n.length===0?(0,Z.jsx)(`p`,{className:`muted project-chat-empty`,children:`No gezellen available to chat with yet. Create one from the Gezellen tab.`}):(0,Z.jsx)(`div`,{className:`project-chat`,children:o&&m&&(0,Z.jsx)(Be,{project:e,selectedGezel:m,recipientGezels:n,isVoorman:m.id===e.voormanGezelId,startFreshThread:m.id===u,onSelectGezel:f,compact:t})})}function Be({project:e,selectedGezel:t,recipientGezels:n,isVoorman:r,startFreshThread:i,onSelectGezel:a,compact:o}){let[s,u]=(0,B.useState)(``),[d,m]=(0,B.useState)(null),[h,g]=(0,B.useState)(!1),[_,v]=(0,B.useState)(0),y=D(),b=l({name:t.name,roleBasedName:t.roleBasedName},y),[x,S]=(0,B.useState)(0),[C,w]=(0,B.useState)([]),[T,E]=(0,B.useState)(`chat`),[O,k]=(0,B.useState)(0),A=(0,B.useCallback)(()=>{k(e=>e+1),E(`chat`)},[]),M=ee()&&f(e);(0,B.useEffect)(()=>{!M&&T===`terminal`&&A()},[M,T,A]);let[N,P]=(0,B.useState)(``),[F,I]=(0,B.useState)(``),[oe,L]=(0,B.useState)(``),R=(0,B.useCallback)(e=>{L(``),P(e),I(e)},[]),[z,V]=(0,B.useState)(``);(0,B.useEffect)(()=>{T!==`terminal`&&z!==``&&V(``)},[T,z]);let[H,ue]=(0,B.useState)(0),[U,de]=(0,B.useState)(null),[W,fe]=(0,B.useState)(null),G=(0,B.useRef)(null),K=(0,B.useRef)(null),q=(0,B.useCallback)((e,n,r)=>{n===t.id?m(r):(G.current=e||null,K.current=r,a(n)),u(e)},[t.id,a]),[pe,me]=(0,B.useState)(null),J=(0,B.useCallback)(e=>{e&&me(t=>({sessionId:e,requestKey:(t?.requestKey??0)+1}))},[]),he=(0,B.useCallback)(async e=>{let t={ref:e.ref,...e.activeStepId?{stepId:e.activeStepId}:{}};try{let{sessions:n}=await p.listTaskSessions(e.projectId,e.num),r=n.find(e=>!e.archived);if(r){q(r.id,r.gezelId,t),J(r.id);return}}catch{}e.assignee.kind===`gezel`&&e.assignee.gezelId?q(``,e.assignee.gezelId,t):m(t)},[q,J]),Y=(0,B.useCallback)(e=>{v(e=>e+1),(e.status===`complete`||e.status===`canceled`)&&m(t=>t?.ref===e.ref?null:t)},[]);(0,B.useEffect)(()=>{let n=G.current;G.current=null,u(n??ce(ie(e.id,t.id))?.sessionId??``),m(K.current),K.current=null},[t.id,e.id]),(0,B.useEffect)(()=>{le(ie(e.id,t.id),{sessionId:s})},[e.id,t.id,s]);let ge=(0,B.useMemo)(()=>ae({role:r?`voorman`:`other`,gezelName:b,gezelGender:t.gender,projectName:e.name,fixedFunctionTool:t.fixedFunction?.tool}),[r,b,t.gender,e.name,t.fixedFunction?.tool]),X=c(t.gender),_e=M?(0,Z.jsxs)(`div`,{className:`compose-mode-tabs`,role:`tablist`,"aria-label":`Compose surface`,children:[(0,Z.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":T===`chat`,"aria-label":`AI chat`,className:`compose-mode-tab`,onClick:A,title:`AI chat (@-mention to talk to a gezel)`,children:[(0,Z.jsx)(`span`,{className:`compose-mode-tab-glyph`,"aria-hidden":`true`,children:`@`}),`Chat`]}),(0,Z.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":T===`terminal`,className:`compose-mode-tab`,onClick:()=>E(`terminal`),title:`Terminal (run shell commands in this project's workspace)`,children:[(0,Z.jsx)(`span`,{className:`compose-mode-tab-glyph`,"aria-hidden":`true`,children:`>`}),`Terminal`]})]}):null;return(0,Z.jsx)(se,{projectId:e.id,skillsProjectId:e.id,compact:o,chatKey:`${e.id}:timeline`,onTaskChanged:Y,banner:({onTaskReference:t})=>(0,Z.jsx)(xe,{projectId:e.id,gezels:n,activeSessionId:T===`chat`&&s||void 0,activeTaskRef:T===`chat`?d?.ref??null:null,activeTerminalThreadId:T===`terminal`?oe:null,refreshKey:_,terminalRefreshKey:H,onFocusThread:e=>{q(e.sessionId,e.gezelId,e.taskRef?{ref:e.taskRef}:null),J(e.sessionId)},onFocusTask:e=>{t(e.ref,{focus:!0}),he(e)},onFocusTerminal:M?t=>{R(t.workingDir),L(t.id),E(`terminal`),de(e=>({threadId:t.id,requestKey:(e?.requestKey??0)+1})),p.getTerminalThread(e.id,t.id).then(e=>{let t=[...e.messages].reverse().find(e=>e.cwd!==void 0)?.cwd;t!==void 0&&I(t)}).catch(()=>{})}:void 0,onNewTask:()=>g(!0)}),children:({onToolActivity:o,onArtifactReference:c,onArtifactSeen:l,onWorkspaceReference:f,onWorkspaceSeen:p,recentReferences:m,onOpenReference:_,onTaskReference:y})=>(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(re,{projectId:e.id,activeSessionId:s||void 0,onFocusSession:(e,t)=>q(e,t,null),onToolActivity:o,onArtifactReference:c,onArtifactSeen:l,onWorkspaceReference:f,onWorkspaceSeen:p,onOpenReference:_,onTaskReference:y,onTerminalWorkingDirChanged:(e,t)=>{I(t)},terminalRefreshKey:H,...W?{terminalSubmission:W}:{},...U?{terminalFocusRequest:U}:{},...pe?{sessionFocusRequest:pe}:{},emptyPlaceholder:r?`Talk to ${b} about running "${e.name}" — planning tasks, delegating, or checking progress.`:`Chat with ${b} about what ${X.subject} ${X.presentBe} working on in "${e.name}".`}),(0,Z.jsx)(`div`,{className:`project-chat-compose-shell`,children:(0,Z.jsx)(`div`,{className:`project-chat-compose-main${T===`terminal`?` project-chat-compose-main-terminal`:``}`,children:T===`chat`?(0,Z.jsx)(j,{gezelId:t.id,gezelName:t.name,gezelRoleBasedName:t.roleBasedName,gezelRole:t.role,gezelIcon:t.icon??null,gezelPoppetje:t.poppetje,gezelIconOverride:t.iconOverride,recipientGezels:n,onPrimaryRecipientChange:a,focusRequestKey:O,projectId:e.id,sessionId:s||void 0,...d?{taskRef:d.ref}:{},...d?.stepId?{stepId:d.stepId}:{},onSessionCreated:e=>{u(e),S(e=>e+1)},onToolActivity:o,recentReferences:m,onOpenReference:_,placeholder:ge,draftScope:`project`,onPivotToMention:e=>{e!==t.id&&(w(e=>e.includes(t.id)?e:[...e,t.id]),a(e))},passiveCcGezelIds:C,onPassiveCcConsumed:()=>w([]),onTerminalEscape:M?e=>{V(e),E(`terminal`)}:void 0,addressLineTrailing:_e,belowAddressLine:(0,Z.jsx)(ne,{gezelId:t.id,projectId:e.id,sessionId:s||void 0,gezelName:b,...d?{taskRef:d.ref}:{},...d?.stepId?{stepId:d.stepId}:{},onSessionIdChange:e=>u(e??``),onNewSessionCreated:()=>k(e=>e+1),refreshKey:x,autoPickNewest:!i||!!d})}):(0,Z.jsx)(Le,{projectId:e.id,workingDir:N,contextRow:(0,Z.jsx)(je,{projectId:e.id,workingDir:F,onChangeWorkingDir:R}),toolbarTrailing:_e,initialInput:z,onSent:(e,t)=>{L(t.threadId),fe({runId:t.runId,threadId:t.threadId,input:e}),ue(e=>e+1)},onChatEscape:A},`terminal:${e.id}`)})}),(0,Z.jsx)(te,{open:h,defaultProjectId:e.id,projects:[e],gezels:n,projectLocked:!0,onClose:()=>g(!1),onCreated:()=>{g(!1),v(e=>e+1)}})]})})}export{ze as ProjectChat};