waterplane 0.0.1 → 0.1.6

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 (1641) hide show
  1. package/CHANGELOG.md +1172 -0
  2. package/DISCLAIMER.md +113 -0
  3. package/LICENSE +21 -0
  4. package/NOTICES.md +78 -0
  5. package/README.md +392 -4
  6. package/SECURITY.md +388 -0
  7. package/bin/waterplane.mjs +5 -0
  8. package/deploy/gh-version +1 -0
  9. package/deploy/node-version +1 -0
  10. package/node_modules/@waterplane/shared/dist/agentfiles.d.ts +118 -0
  11. package/node_modules/@waterplane/shared/dist/agentfiles.js +345 -0
  12. package/node_modules/@waterplane/shared/dist/agentfiles.js.map +1 -0
  13. package/node_modules/@waterplane/shared/dist/artifacts.d.ts +213 -0
  14. package/node_modules/@waterplane/shared/dist/artifacts.js +295 -0
  15. package/node_modules/@waterplane/shared/dist/artifacts.js.map +1 -0
  16. package/node_modules/@waterplane/shared/dist/askrules.d.ts +95 -0
  17. package/node_modules/@waterplane/shared/dist/askrules.js +133 -0
  18. package/node_modules/@waterplane/shared/dist/askrules.js.map +1 -0
  19. package/node_modules/@waterplane/shared/dist/assess/sassapply.d.ts +191 -0
  20. package/node_modules/@waterplane/shared/dist/assess/sassapply.js +152 -0
  21. package/node_modules/@waterplane/shared/dist/assess/sassapply.js.map +1 -0
  22. package/node_modules/@waterplane/shared/dist/assess/sassclean.d.ts +21 -0
  23. package/node_modules/@waterplane/shared/dist/assess/sassclean.js +453 -0
  24. package/node_modules/@waterplane/shared/dist/assess/sassclean.js.map +1 -0
  25. package/node_modules/@waterplane/shared/dist/assess/sassio.d.ts +257 -0
  26. package/node_modules/@waterplane/shared/dist/assess/sassio.js +2 -0
  27. package/node_modules/@waterplane/shared/dist/assess/sassio.js.map +1 -0
  28. package/node_modules/@waterplane/shared/dist/assess/sassslot.d.ts +19 -0
  29. package/node_modules/@waterplane/shared/dist/assess/sassslot.js +136 -0
  30. package/node_modules/@waterplane/shared/dist/assess/sassslot.js.map +1 -0
  31. package/node_modules/@waterplane/shared/dist/assess/sassvocab.d.ts +115 -0
  32. package/node_modules/@waterplane/shared/dist/assess/sassvocab.js +98 -0
  33. package/node_modules/@waterplane/shared/dist/assess/sassvocab.js.map +1 -0
  34. package/node_modules/@waterplane/shared/dist/assess/sasswords.d.ts +140 -0
  35. package/node_modules/@waterplane/shared/dist/assess/sasswords.js +155 -0
  36. package/node_modules/@waterplane/shared/dist/assess/sasswords.js.map +1 -0
  37. package/node_modules/@waterplane/shared/dist/assess.d.ts +58 -0
  38. package/node_modules/@waterplane/shared/dist/assess.js +55 -0
  39. package/node_modules/@waterplane/shared/dist/assess.js.map +1 -0
  40. package/node_modules/@waterplane/shared/dist/attach.d.ts +118 -0
  41. package/node_modules/@waterplane/shared/dist/attach.js +85 -0
  42. package/node_modules/@waterplane/shared/dist/attach.js.map +1 -0
  43. package/node_modules/@waterplane/shared/dist/autocompact.d.ts +125 -0
  44. package/node_modules/@waterplane/shared/dist/autocompact.js +226 -0
  45. package/node_modules/@waterplane/shared/dist/autocompact.js.map +1 -0
  46. package/node_modules/@waterplane/shared/dist/backendsources.d.ts +399 -0
  47. package/node_modules/@waterplane/shared/dist/backendsources.js +3 -0
  48. package/node_modules/@waterplane/shared/dist/backendsources.js.map +1 -0
  49. package/node_modules/@waterplane/shared/dist/billing.d.ts +48 -0
  50. package/node_modules/@waterplane/shared/dist/billing.js +64 -0
  51. package/node_modules/@waterplane/shared/dist/billing.js.map +1 -0
  52. package/node_modules/@waterplane/shared/dist/bindconv.d.ts +47 -0
  53. package/node_modules/@waterplane/shared/dist/bindconv.js +35 -0
  54. package/node_modules/@waterplane/shared/dist/bindconv.js.map +1 -0
  55. package/node_modules/@waterplane/shared/dist/bookmark.d.ts +26 -0
  56. package/node_modules/@waterplane/shared/dist/bookmark.js +40 -0
  57. package/node_modules/@waterplane/shared/dist/bookmark.js.map +1 -0
  58. package/node_modules/@waterplane/shared/dist/brand.d.ts +94 -0
  59. package/node_modules/@waterplane/shared/dist/brand.js +88 -0
  60. package/node_modules/@waterplane/shared/dist/brand.js.map +1 -0
  61. package/node_modules/@waterplane/shared/dist/brandmigrate.d.ts +30 -0
  62. package/node_modules/@waterplane/shared/dist/brandmigrate.js +67 -0
  63. package/node_modules/@waterplane/shared/dist/brandmigrate.js.map +1 -0
  64. package/node_modules/@waterplane/shared/dist/budget.d.ts +247 -0
  65. package/node_modules/@waterplane/shared/dist/budget.js +295 -0
  66. package/node_modules/@waterplane/shared/dist/budget.js.map +1 -0
  67. package/node_modules/@waterplane/shared/dist/buildparams.d.ts +146 -0
  68. package/node_modules/@waterplane/shared/dist/buildparams.js +260 -0
  69. package/node_modules/@waterplane/shared/dist/buildparams.js.map +1 -0
  70. package/node_modules/@waterplane/shared/dist/buildscan.d.ts +99 -0
  71. package/node_modules/@waterplane/shared/dist/buildscan.js +334 -0
  72. package/node_modules/@waterplane/shared/dist/buildscan.js.map +1 -0
  73. package/node_modules/@waterplane/shared/dist/burn.d.ts +137 -0
  74. package/node_modules/@waterplane/shared/dist/burn.js +176 -0
  75. package/node_modules/@waterplane/shared/dist/burn.js.map +1 -0
  76. package/node_modules/@waterplane/shared/dist/chord.d.ts +39 -0
  77. package/node_modules/@waterplane/shared/dist/chord.js +102 -0
  78. package/node_modules/@waterplane/shared/dist/chord.js.map +1 -0
  79. package/node_modules/@waterplane/shared/dist/claudeconfig.d.ts +18 -0
  80. package/node_modules/@waterplane/shared/dist/claudeconfig.js +44 -0
  81. package/node_modules/@waterplane/shared/dist/claudeconfig.js.map +1 -0
  82. package/node_modules/@waterplane/shared/dist/claudeversion.d.ts +17 -0
  83. package/node_modules/@waterplane/shared/dist/claudeversion.js +31 -0
  84. package/node_modules/@waterplane/shared/dist/claudeversion.js.map +1 -0
  85. package/node_modules/@waterplane/shared/dist/clientframe.d.ts +12 -0
  86. package/node_modules/@waterplane/shared/dist/clientframe.js +15 -0
  87. package/node_modules/@waterplane/shared/dist/clientframe.js.map +1 -0
  88. package/node_modules/@waterplane/shared/dist/clihealth/healthcatalog.d.ts +52 -0
  89. package/node_modules/@waterplane/shared/dist/clihealth/healthcatalog.js +137 -0
  90. package/node_modules/@waterplane/shared/dist/clihealth/healthcatalog.js.map +1 -0
  91. package/node_modules/@waterplane/shared/dist/clihealth/healthfixture.d.ts +58 -0
  92. package/node_modules/@waterplane/shared/dist/clihealth/healthfixture.js +189 -0
  93. package/node_modules/@waterplane/shared/dist/clihealth/healthfixture.js.map +1 -0
  94. package/node_modules/@waterplane/shared/dist/clihealth/healthrecord.d.ts +254 -0
  95. package/node_modules/@waterplane/shared/dist/clihealth/healthrecord.js +367 -0
  96. package/node_modules/@waterplane/shared/dist/clihealth/healthrecord.js.map +1 -0
  97. package/node_modules/@waterplane/shared/dist/clihealth/healthrollup.d.ts +36 -0
  98. package/node_modules/@waterplane/shared/dist/clihealth/healthrollup.js +123 -0
  99. package/node_modules/@waterplane/shared/dist/clihealth/healthrollup.js.map +1 -0
  100. package/node_modules/@waterplane/shared/dist/clihealth/healththresholds.d.ts +101 -0
  101. package/node_modules/@waterplane/shared/dist/clihealth/healththresholds.js +103 -0
  102. package/node_modules/@waterplane/shared/dist/clihealth/healththresholds.js.map +1 -0
  103. package/node_modules/@waterplane/shared/dist/clihealth.d.ts +64 -0
  104. package/node_modules/@waterplane/shared/dist/clihealth.js +69 -0
  105. package/node_modules/@waterplane/shared/dist/clihealth.js.map +1 -0
  106. package/node_modules/@waterplane/shared/dist/clirestart.d.ts +66 -0
  107. package/node_modules/@waterplane/shared/dist/clirestart.js +82 -0
  108. package/node_modules/@waterplane/shared/dist/clirestart.js.map +1 -0
  109. package/node_modules/@waterplane/shared/dist/closed.d.ts +41 -0
  110. package/node_modules/@waterplane/shared/dist/closed.js +102 -0
  111. package/node_modules/@waterplane/shared/dist/closed.js.map +1 -0
  112. package/node_modules/@waterplane/shared/dist/collage.d.ts +132 -0
  113. package/node_modules/@waterplane/shared/dist/collage.js +198 -0
  114. package/node_modules/@waterplane/shared/dist/collage.js.map +1 -0
  115. package/node_modules/@waterplane/shared/dist/contextweight.d.ts +169 -0
  116. package/node_modules/@waterplane/shared/dist/contextweight.js +247 -0
  117. package/node_modules/@waterplane/shared/dist/contextweight.js.map +1 -0
  118. package/node_modules/@waterplane/shared/dist/costwindow.d.ts +216 -0
  119. package/node_modules/@waterplane/shared/dist/costwindow.js +430 -0
  120. package/node_modules/@waterplane/shared/dist/costwindow.js.map +1 -0
  121. package/node_modules/@waterplane/shared/dist/ctxwindow.d.ts +92 -0
  122. package/node_modules/@waterplane/shared/dist/ctxwindow.js +107 -0
  123. package/node_modules/@waterplane/shared/dist/ctxwindow.js.map +1 -0
  124. package/node_modules/@waterplane/shared/dist/deskstorage.d.ts +170 -0
  125. package/node_modules/@waterplane/shared/dist/deskstorage.js +140 -0
  126. package/node_modules/@waterplane/shared/dist/deskstorage.js.map +1 -0
  127. package/node_modules/@waterplane/shared/dist/devices.d.ts +52 -0
  128. package/node_modules/@waterplane/shared/dist/devices.js +53 -0
  129. package/node_modules/@waterplane/shared/dist/devices.js.map +1 -0
  130. package/node_modules/@waterplane/shared/dist/dictate.d.ts +178 -0
  131. package/node_modules/@waterplane/shared/dist/dictate.js +345 -0
  132. package/node_modules/@waterplane/shared/dist/dictate.js.map +1 -0
  133. package/node_modules/@waterplane/shared/dist/dictateterms.d.ts +91 -0
  134. package/node_modules/@waterplane/shared/dist/dictateterms.js +180 -0
  135. package/node_modules/@waterplane/shared/dist/dictateterms.js.map +1 -0
  136. package/node_modules/@waterplane/shared/dist/envresolve.d.ts +30 -0
  137. package/node_modules/@waterplane/shared/dist/envresolve.js +76 -0
  138. package/node_modules/@waterplane/shared/dist/envresolve.js.map +1 -0
  139. package/node_modules/@waterplane/shared/dist/fanoutruns.d.ts +25 -0
  140. package/node_modules/@waterplane/shared/dist/fanoutruns.js +88 -0
  141. package/node_modules/@waterplane/shared/dist/fanoutruns.js.map +1 -0
  142. package/node_modules/@waterplane/shared/dist/followup.d.ts +38 -0
  143. package/node_modules/@waterplane/shared/dist/followup.js +68 -0
  144. package/node_modules/@waterplane/shared/dist/followup.js.map +1 -0
  145. package/node_modules/@waterplane/shared/dist/gallery.d.ts +83 -0
  146. package/node_modules/@waterplane/shared/dist/gallery.js +94 -0
  147. package/node_modules/@waterplane/shared/dist/gallery.js.map +1 -0
  148. package/node_modules/@waterplane/shared/dist/halt.d.ts +46 -0
  149. package/node_modules/@waterplane/shared/dist/halt.js +34 -0
  150. package/node_modules/@waterplane/shared/dist/halt.js.map +1 -0
  151. package/node_modules/@waterplane/shared/dist/healthindex.d.ts +485 -0
  152. package/node_modules/@waterplane/shared/dist/healthindex.js +677 -0
  153. package/node_modules/@waterplane/shared/dist/healthindex.js.map +1 -0
  154. package/node_modules/@waterplane/shared/dist/healthindexresponse.d.ts +36 -0
  155. package/node_modules/@waterplane/shared/dist/healthindexresponse.js +84 -0
  156. package/node_modules/@waterplane/shared/dist/healthindexresponse.js.map +1 -0
  157. package/node_modules/@waterplane/shared/dist/healthspend.d.ts +23 -0
  158. package/node_modules/@waterplane/shared/dist/healthspend.js +41 -0
  159. package/node_modules/@waterplane/shared/dist/healthspend.js.map +1 -0
  160. package/node_modules/@waterplane/shared/dist/hints.d.ts +77 -0
  161. package/node_modules/@waterplane/shared/dist/hints.js +607 -0
  162. package/node_modules/@waterplane/shared/dist/hints.js.map +1 -0
  163. package/node_modules/@waterplane/shared/dist/hosts.d.ts +160 -0
  164. package/node_modules/@waterplane/shared/dist/hosts.js +316 -0
  165. package/node_modules/@waterplane/shared/dist/hosts.js.map +1 -0
  166. package/node_modules/@waterplane/shared/dist/hosturl.d.ts +73 -0
  167. package/node_modules/@waterplane/shared/dist/hosturl.js +129 -0
  168. package/node_modules/@waterplane/shared/dist/hosturl.js.map +1 -0
  169. package/node_modules/@waterplane/shared/dist/index.d.ts +283 -0
  170. package/node_modules/@waterplane/shared/dist/index.js +305 -0
  171. package/node_modules/@waterplane/shared/dist/index.js.map +1 -0
  172. package/node_modules/@waterplane/shared/dist/installlog.d.ts +137 -0
  173. package/node_modules/@waterplane/shared/dist/installlog.js +367 -0
  174. package/node_modules/@waterplane/shared/dist/installlog.js.map +1 -0
  175. package/node_modules/@waterplane/shared/dist/intent/budgetpass.d.ts +103 -0
  176. package/node_modules/@waterplane/shared/dist/intent/budgetpass.js +185 -0
  177. package/node_modules/@waterplane/shared/dist/intent/budgetpass.js.map +1 -0
  178. package/node_modules/@waterplane/shared/dist/intent/clean.d.ts +30 -0
  179. package/node_modules/@waterplane/shared/dist/intent/clean.js +492 -0
  180. package/node_modules/@waterplane/shared/dist/intent/clean.js.map +1 -0
  181. package/node_modules/@waterplane/shared/dist/intent/facts.d.ts +320 -0
  182. package/node_modules/@waterplane/shared/dist/intent/facts.js +52 -0
  183. package/node_modules/@waterplane/shared/dist/intent/facts.js.map +1 -0
  184. package/node_modules/@waterplane/shared/dist/intent/kind.d.ts +194 -0
  185. package/node_modules/@waterplane/shared/dist/intent/kind.js +230 -0
  186. package/node_modules/@waterplane/shared/dist/intent/kind.js.map +1 -0
  187. package/node_modules/@waterplane/shared/dist/intent/row.d.ts +433 -0
  188. package/node_modules/@waterplane/shared/dist/intent/row.js +75 -0
  189. package/node_modules/@waterplane/shared/dist/intent/row.js.map +1 -0
  190. package/node_modules/@waterplane/shared/dist/intent/slot.d.ts +137 -0
  191. package/node_modules/@waterplane/shared/dist/intent/slot.js +238 -0
  192. package/node_modules/@waterplane/shared/dist/intent/slot.js.map +1 -0
  193. package/node_modules/@waterplane/shared/dist/intent/target.d.ts +62 -0
  194. package/node_modules/@waterplane/shared/dist/intent/target.js +177 -0
  195. package/node_modules/@waterplane/shared/dist/intent/target.js.map +1 -0
  196. package/node_modules/@waterplane/shared/dist/intent/types.d.ts +455 -0
  197. package/node_modules/@waterplane/shared/dist/intent/types.js +27 -0
  198. package/node_modules/@waterplane/shared/dist/intent/types.js.map +1 -0
  199. package/node_modules/@waterplane/shared/dist/intent/verdict.d.ts +50 -0
  200. package/node_modules/@waterplane/shared/dist/intent/verdict.js +431 -0
  201. package/node_modules/@waterplane/shared/dist/intent/verdict.js.map +1 -0
  202. package/node_modules/@waterplane/shared/dist/intent/words.d.ts +236 -0
  203. package/node_modules/@waterplane/shared/dist/intent/words.js +329 -0
  204. package/node_modules/@waterplane/shared/dist/intent/words.js.map +1 -0
  205. package/node_modules/@waterplane/shared/dist/intent.d.ts +69 -0
  206. package/node_modules/@waterplane/shared/dist/intent.js +65 -0
  207. package/node_modules/@waterplane/shared/dist/intent.js.map +1 -0
  208. package/node_modules/@waterplane/shared/dist/itempaths.d.ts +35 -0
  209. package/node_modules/@waterplane/shared/dist/itempaths.js +55 -0
  210. package/node_modules/@waterplane/shared/dist/itempaths.js.map +1 -0
  211. package/node_modules/@waterplane/shared/dist/keyhint.d.ts +32 -0
  212. package/node_modules/@waterplane/shared/dist/keyhint.js +53 -0
  213. package/node_modules/@waterplane/shared/dist/keyhint.js.map +1 -0
  214. package/node_modules/@waterplane/shared/dist/lanroute.d.ts +86 -0
  215. package/node_modules/@waterplane/shared/dist/lanroute.js +84 -0
  216. package/node_modules/@waterplane/shared/dist/lanroute.js.map +1 -0
  217. package/node_modules/@waterplane/shared/dist/launch.d.ts +110 -0
  218. package/node_modules/@waterplane/shared/dist/launch.js +102 -0
  219. package/node_modules/@waterplane/shared/dist/launch.js.map +1 -0
  220. package/node_modules/@waterplane/shared/dist/launchmodes.d.ts +22 -0
  221. package/node_modules/@waterplane/shared/dist/launchmodes.js +38 -0
  222. package/node_modules/@waterplane/shared/dist/launchmodes.js.map +1 -0
  223. package/node_modules/@waterplane/shared/dist/localrt.d.ts +53 -0
  224. package/node_modules/@waterplane/shared/dist/localrt.js +54 -0
  225. package/node_modules/@waterplane/shared/dist/localrt.js.map +1 -0
  226. package/node_modules/@waterplane/shared/dist/localusage.d.ts +35 -0
  227. package/node_modules/@waterplane/shared/dist/localusage.js +135 -0
  228. package/node_modules/@waterplane/shared/dist/localusage.js.map +1 -0
  229. package/node_modules/@waterplane/shared/dist/naming.d.ts +391 -0
  230. package/node_modules/@waterplane/shared/dist/naming.js +571 -0
  231. package/node_modules/@waterplane/shared/dist/naming.js.map +1 -0
  232. package/node_modules/@waterplane/shared/dist/netfuse.d.ts +60 -0
  233. package/node_modules/@waterplane/shared/dist/netfuse.js +99 -0
  234. package/node_modules/@waterplane/shared/dist/netfuse.js.map +1 -0
  235. package/node_modules/@waterplane/shared/dist/netstall.d.ts +163 -0
  236. package/node_modules/@waterplane/shared/dist/netstall.js +241 -0
  237. package/node_modules/@waterplane/shared/dist/netstall.js.map +1 -0
  238. package/node_modules/@waterplane/shared/dist/nodemin.d.ts +18 -0
  239. package/node_modules/@waterplane/shared/dist/nodemin.js +35 -0
  240. package/node_modules/@waterplane/shared/dist/nodemin.js.map +1 -0
  241. package/node_modules/@waterplane/shared/dist/optins.d.ts +122 -0
  242. package/node_modules/@waterplane/shared/dist/optins.js +252 -0
  243. package/node_modules/@waterplane/shared/dist/optins.js.map +1 -0
  244. package/node_modules/@waterplane/shared/dist/pad.d.ts +263 -0
  245. package/node_modules/@waterplane/shared/dist/pad.js +373 -0
  246. package/node_modules/@waterplane/shared/dist/pad.js.map +1 -0
  247. package/node_modules/@waterplane/shared/dist/pairing.d.ts +120 -0
  248. package/node_modules/@waterplane/shared/dist/pairing.js +130 -0
  249. package/node_modules/@waterplane/shared/dist/pairing.js.map +1 -0
  250. package/node_modules/@waterplane/shared/dist/passive.d.ts +58 -0
  251. package/node_modules/@waterplane/shared/dist/passive.js +36 -0
  252. package/node_modules/@waterplane/shared/dist/passive.js.map +1 -0
  253. package/node_modules/@waterplane/shared/dist/peer.d.ts +311 -0
  254. package/node_modules/@waterplane/shared/dist/peer.js +390 -0
  255. package/node_modules/@waterplane/shared/dist/peer.js.map +1 -0
  256. package/node_modules/@waterplane/shared/dist/period.d.ts +108 -0
  257. package/node_modules/@waterplane/shared/dist/period.js +263 -0
  258. package/node_modules/@waterplane/shared/dist/period.js.map +1 -0
  259. package/node_modules/@waterplane/shared/dist/plugin.d.ts +898 -0
  260. package/node_modules/@waterplane/shared/dist/plugin.js +196 -0
  261. package/node_modules/@waterplane/shared/dist/plugin.js.map +1 -0
  262. package/node_modules/@waterplane/shared/dist/pluginfile.d.ts +25 -0
  263. package/node_modules/@waterplane/shared/dist/pluginfile.js +8 -0
  264. package/node_modules/@waterplane/shared/dist/pluginfile.js.map +1 -0
  265. package/node_modules/@waterplane/shared/dist/pluginlaunch.d.ts +109 -0
  266. package/node_modules/@waterplane/shared/dist/pluginlaunch.js +3 -0
  267. package/node_modules/@waterplane/shared/dist/pluginlaunch.js.map +1 -0
  268. package/node_modules/@waterplane/shared/dist/pluginmaturity.d.ts +26 -0
  269. package/node_modules/@waterplane/shared/dist/pluginmaturity.js +32 -0
  270. package/node_modules/@waterplane/shared/dist/pluginmaturity.js.map +1 -0
  271. package/node_modules/@waterplane/shared/dist/pluginreadings.d.ts +43 -0
  272. package/node_modules/@waterplane/shared/dist/pluginreadings.js +5 -0
  273. package/node_modules/@waterplane/shared/dist/pluginreadings.js.map +1 -0
  274. package/node_modules/@waterplane/shared/dist/pricing.d.ts +249 -0
  275. package/node_modules/@waterplane/shared/dist/pricing.js +388 -0
  276. package/node_modules/@waterplane/shared/dist/pricing.js.map +1 -0
  277. package/node_modules/@waterplane/shared/dist/promptid.d.ts +48 -0
  278. package/node_modules/@waterplane/shared/dist/promptid.js +116 -0
  279. package/node_modules/@waterplane/shared/dist/promptid.js.map +1 -0
  280. package/node_modules/@waterplane/shared/dist/ptysize.d.ts +74 -0
  281. package/node_modules/@waterplane/shared/dist/ptysize.js +77 -0
  282. package/node_modules/@waterplane/shared/dist/ptysize.js.map +1 -0
  283. package/node_modules/@waterplane/shared/dist/queue/queuebind.d.ts +40 -0
  284. package/node_modules/@waterplane/shared/dist/queue/queuebind.js +70 -0
  285. package/node_modules/@waterplane/shared/dist/queue/queuebind.js.map +1 -0
  286. package/node_modules/@waterplane/shared/dist/queue/queueentry.d.ts +175 -0
  287. package/node_modules/@waterplane/shared/dist/queue/queueentry.js +4 -0
  288. package/node_modules/@waterplane/shared/dist/queue/queueentry.js.map +1 -0
  289. package/node_modules/@waterplane/shared/dist/queue/queuelane.d.ts +65 -0
  290. package/node_modules/@waterplane/shared/dist/queue/queuelane.js +45 -0
  291. package/node_modules/@waterplane/shared/dist/queue/queuelane.js.map +1 -0
  292. package/node_modules/@waterplane/shared/dist/queue/queueplan.d.ts +180 -0
  293. package/node_modules/@waterplane/shared/dist/queue/queueplan.js +169 -0
  294. package/node_modules/@waterplane/shared/dist/queue/queueplan.js.map +1 -0
  295. package/node_modules/@waterplane/shared/dist/queue/queueretarget.d.ts +61 -0
  296. package/node_modules/@waterplane/shared/dist/queue/queueretarget.js +94 -0
  297. package/node_modules/@waterplane/shared/dist/queue/queueretarget.js.map +1 -0
  298. package/node_modules/@waterplane/shared/dist/queue/queueretry.d.ts +61 -0
  299. package/node_modules/@waterplane/shared/dist/queue/queueretry.js +66 -0
  300. package/node_modules/@waterplane/shared/dist/queue/queueretry.js.map +1 -0
  301. package/node_modules/@waterplane/shared/dist/queue/queueserial.d.ts +154 -0
  302. package/node_modules/@waterplane/shared/dist/queue/queueserial.js +169 -0
  303. package/node_modules/@waterplane/shared/dist/queue/queueserial.js.map +1 -0
  304. package/node_modules/@waterplane/shared/dist/queue/queueuploads.d.ts +65 -0
  305. package/node_modules/@waterplane/shared/dist/queue/queueuploads.js +79 -0
  306. package/node_modules/@waterplane/shared/dist/queue/queueuploads.js.map +1 -0
  307. package/node_modules/@waterplane/shared/dist/queue/queuewords.d.ts +22 -0
  308. package/node_modules/@waterplane/shared/dist/queue/queuewords.js +55 -0
  309. package/node_modules/@waterplane/shared/dist/queue/queuewords.js.map +1 -0
  310. package/node_modules/@waterplane/shared/dist/queue.d.ts +13 -0
  311. package/node_modules/@waterplane/shared/dist/queue.js +44 -0
  312. package/node_modules/@waterplane/shared/dist/queue.js.map +1 -0
  313. package/node_modules/@waterplane/shared/dist/repocolor.d.ts +159 -0
  314. package/node_modules/@waterplane/shared/dist/repocolor.js +261 -0
  315. package/node_modules/@waterplane/shared/dist/repocolor.js.map +1 -0
  316. package/node_modules/@waterplane/shared/dist/repohealth.d.ts +640 -0
  317. package/node_modules/@waterplane/shared/dist/repohealth.js +117 -0
  318. package/node_modules/@waterplane/shared/dist/repohealth.js.map +1 -0
  319. package/node_modules/@waterplane/shared/dist/repohealthread.d.ts +156 -0
  320. package/node_modules/@waterplane/shared/dist/repohealthread.js +680 -0
  321. package/node_modules/@waterplane/shared/dist/repohealthread.js.map +1 -0
  322. package/node_modules/@waterplane/shared/dist/requirements.d.ts +81 -0
  323. package/node_modules/@waterplane/shared/dist/requirements.js +191 -0
  324. package/node_modules/@waterplane/shared/dist/requirements.js.map +1 -0
  325. package/node_modules/@waterplane/shared/dist/rootchoice.d.ts +52 -0
  326. package/node_modules/@waterplane/shared/dist/rootchoice.js +18 -0
  327. package/node_modules/@waterplane/shared/dist/rootchoice.js.map +1 -0
  328. package/node_modules/@waterplane/shared/dist/schedule/schedaction.d.ts +106 -0
  329. package/node_modules/@waterplane/shared/dist/schedule/schedaction.js +14 -0
  330. package/node_modules/@waterplane/shared/dist/schedule/schedaction.js.map +1 -0
  331. package/node_modules/@waterplane/shared/dist/schedule/schedclean.d.ts +6 -0
  332. package/node_modules/@waterplane/shared/dist/schedule/schedclean.js +180 -0
  333. package/node_modules/@waterplane/shared/dist/schedule/schedclean.js.map +1 -0
  334. package/node_modules/@waterplane/shared/dist/schedule/schedfire.d.ts +76 -0
  335. package/node_modules/@waterplane/shared/dist/schedule/schedfire.js +122 -0
  336. package/node_modules/@waterplane/shared/dist/schedule/schedfire.js.map +1 -0
  337. package/node_modules/@waterplane/shared/dist/schedule/schedhorizon.d.ts +78 -0
  338. package/node_modules/@waterplane/shared/dist/schedule/schedhorizon.js +98 -0
  339. package/node_modules/@waterplane/shared/dist/schedule/schedhorizon.js.map +1 -0
  340. package/node_modules/@waterplane/shared/dist/schedule/schedrule.d.ts +219 -0
  341. package/node_modules/@waterplane/shared/dist/schedule/schedrule.js +162 -0
  342. package/node_modules/@waterplane/shared/dist/schedule/schedrule.js.map +1 -0
  343. package/node_modules/@waterplane/shared/dist/schedule/schedtext.d.ts +37 -0
  344. package/node_modules/@waterplane/shared/dist/schedule/schedtext.js +119 -0
  345. package/node_modules/@waterplane/shared/dist/schedule/schedtext.js.map +1 -0
  346. package/node_modules/@waterplane/shared/dist/schedule/schedwhen.d.ts +54 -0
  347. package/node_modules/@waterplane/shared/dist/schedule/schedwhen.js +70 -0
  348. package/node_modules/@waterplane/shared/dist/schedule/schedwhen.js.map +1 -0
  349. package/node_modules/@waterplane/shared/dist/schedule/schedzone.d.ts +76 -0
  350. package/node_modules/@waterplane/shared/dist/schedule/schedzone.js +159 -0
  351. package/node_modules/@waterplane/shared/dist/schedule/schedzone.js.map +1 -0
  352. package/node_modules/@waterplane/shared/dist/schedule.d.ts +44 -0
  353. package/node_modules/@waterplane/shared/dist/schedule.js +43 -0
  354. package/node_modules/@waterplane/shared/dist/schedule.js.map +1 -0
  355. package/node_modules/@waterplane/shared/dist/screenlog.d.ts +65 -0
  356. package/node_modules/@waterplane/shared/dist/screenlog.js +169 -0
  357. package/node_modules/@waterplane/shared/dist/screenlog.js.map +1 -0
  358. package/node_modules/@waterplane/shared/dist/sendstamp.d.ts +85 -0
  359. package/node_modules/@waterplane/shared/dist/sendstamp.js +96 -0
  360. package/node_modules/@waterplane/shared/dist/sendstamp.js.map +1 -0
  361. package/node_modules/@waterplane/shared/dist/sessionbudget.d.ts +162 -0
  362. package/node_modules/@waterplane/shared/dist/sessionbudget.js +213 -0
  363. package/node_modules/@waterplane/shared/dist/sessionbudget.js.map +1 -0
  364. package/node_modules/@waterplane/shared/dist/sessioncost/costcold.d.ts +99 -0
  365. package/node_modules/@waterplane/shared/dist/sessioncost/costcold.js +94 -0
  366. package/node_modules/@waterplane/shared/dist/sessioncost/costcold.js.map +1 -0
  367. package/node_modules/@waterplane/shared/dist/sessioncost/costcompact.d.ts +125 -0
  368. package/node_modules/@waterplane/shared/dist/sessioncost/costcompact.js +184 -0
  369. package/node_modules/@waterplane/shared/dist/sessioncost/costcompact.js.map +1 -0
  370. package/node_modules/@waterplane/shared/dist/sessioncost/costofseries.d.ts +21 -0
  371. package/node_modules/@waterplane/shared/dist/sessioncost/costofseries.js +31 -0
  372. package/node_modules/@waterplane/shared/dist/sessioncost/costofseries.js.map +1 -0
  373. package/node_modules/@waterplane/shared/dist/sessioncost/costreading.d.ts +174 -0
  374. package/node_modules/@waterplane/shared/dist/sessioncost/costreading.js +302 -0
  375. package/node_modules/@waterplane/shared/dist/sessioncost/costreading.js.map +1 -0
  376. package/node_modules/@waterplane/shared/dist/sessioncost/costtypes.d.ts +209 -0
  377. package/node_modules/@waterplane/shared/dist/sessioncost/costtypes.js +128 -0
  378. package/node_modules/@waterplane/shared/dist/sessioncost/costtypes.js.map +1 -0
  379. package/node_modules/@waterplane/shared/dist/sessioncost/costwords.d.ts +169 -0
  380. package/node_modules/@waterplane/shared/dist/sessioncost/costwords.js +262 -0
  381. package/node_modules/@waterplane/shared/dist/sessioncost/costwords.js.map +1 -0
  382. package/node_modules/@waterplane/shared/dist/sessioncost.d.ts +52 -0
  383. package/node_modules/@waterplane/shared/dist/sessioncost.js +51 -0
  384. package/node_modules/@waterplane/shared/dist/sessioncost.js.map +1 -0
  385. package/node_modules/@waterplane/shared/dist/settings.d.ts +136 -0
  386. package/node_modules/@waterplane/shared/dist/settings.js +303 -0
  387. package/node_modules/@waterplane/shared/dist/settings.js.map +1 -0
  388. package/node_modules/@waterplane/shared/dist/shells.d.ts +140 -0
  389. package/node_modules/@waterplane/shared/dist/shells.js +257 -0
  390. package/node_modules/@waterplane/shared/dist/shells.js.map +1 -0
  391. package/node_modules/@waterplane/shared/dist/slash.d.ts +47 -0
  392. package/node_modules/@waterplane/shared/dist/slash.js +166 -0
  393. package/node_modules/@waterplane/shared/dist/slash.js.map +1 -0
  394. package/node_modules/@waterplane/shared/dist/sourceshape.d.ts +27 -0
  395. package/node_modules/@waterplane/shared/dist/sourceshape.js +141 -0
  396. package/node_modules/@waterplane/shared/dist/sourceshape.js.map +1 -0
  397. package/node_modules/@waterplane/shared/dist/spendwarn.d.ts +37 -0
  398. package/node_modules/@waterplane/shared/dist/spendwarn.js +79 -0
  399. package/node_modules/@waterplane/shared/dist/spendwarn.js.map +1 -0
  400. package/node_modules/@waterplane/shared/dist/statedir.d.ts +11 -0
  401. package/node_modules/@waterplane/shared/dist/statedir.js +34 -0
  402. package/node_modules/@waterplane/shared/dist/statedir.js.map +1 -0
  403. package/node_modules/@waterplane/shared/dist/stream.d.ts +135 -0
  404. package/node_modules/@waterplane/shared/dist/stream.js +117 -0
  405. package/node_modules/@waterplane/shared/dist/stream.js.map +1 -0
  406. package/node_modules/@waterplane/shared/dist/sweep.d.ts +156 -0
  407. package/node_modules/@waterplane/shared/dist/sweep.js +193 -0
  408. package/node_modules/@waterplane/shared/dist/sweep.js.map +1 -0
  409. package/node_modules/@waterplane/shared/dist/sweepfamilies.d.ts +56 -0
  410. package/node_modules/@waterplane/shared/dist/sweepfamilies.js +140 -0
  411. package/node_modules/@waterplane/shared/dist/sweepfamilies.js.map +1 -0
  412. package/node_modules/@waterplane/shared/dist/termpalette.d.ts +17 -0
  413. package/node_modules/@waterplane/shared/dist/termpalette.js +5 -0
  414. package/node_modules/@waterplane/shared/dist/termpalette.js.map +1 -0
  415. package/node_modules/@waterplane/shared/dist/themeoverlay.d.ts +111 -0
  416. package/node_modules/@waterplane/shared/dist/themeoverlay.js +328 -0
  417. package/node_modules/@waterplane/shared/dist/themeoverlay.js.map +1 -0
  418. package/node_modules/@waterplane/shared/dist/tokens.d.ts +198 -0
  419. package/node_modules/@waterplane/shared/dist/tokens.js +320 -0
  420. package/node_modules/@waterplane/shared/dist/tokens.js.map +1 -0
  421. package/node_modules/@waterplane/shared/dist/transcriptfold.d.ts +50 -0
  422. package/node_modules/@waterplane/shared/dist/transcriptfold.js +87 -0
  423. package/node_modules/@waterplane/shared/dist/transcriptfold.js.map +1 -0
  424. package/node_modules/@waterplane/shared/dist/urls.d.ts +53 -0
  425. package/node_modules/@waterplane/shared/dist/urls.js +150 -0
  426. package/node_modules/@waterplane/shared/dist/urls.js.map +1 -0
  427. package/node_modules/@waterplane/shared/dist/usagesources.d.ts +88 -0
  428. package/node_modules/@waterplane/shared/dist/usagesources.js +198 -0
  429. package/node_modules/@waterplane/shared/dist/usagesources.js.map +1 -0
  430. package/node_modules/@waterplane/shared/dist/windowadvice.d.ts +7 -0
  431. package/node_modules/@waterplane/shared/dist/windowadvice.js +50 -0
  432. package/node_modules/@waterplane/shared/dist/windowadvice.js.map +1 -0
  433. package/node_modules/@waterplane/shared/dist/wire/backend.d.ts +223 -0
  434. package/node_modules/@waterplane/shared/dist/wire/backend.js +18 -0
  435. package/node_modules/@waterplane/shared/dist/wire/backend.js.map +1 -0
  436. package/node_modules/@waterplane/shared/dist/wire/backendtokens.d.ts +99 -0
  437. package/node_modules/@waterplane/shared/dist/wire/backendtokens.js +11 -0
  438. package/node_modules/@waterplane/shared/dist/wire/backendtokens.js.map +1 -0
  439. package/node_modules/@waterplane/shared/dist/wire/capture.d.ts +380 -0
  440. package/node_modules/@waterplane/shared/dist/wire/capture.js +46 -0
  441. package/node_modules/@waterplane/shared/dist/wire/capture.js.map +1 -0
  442. package/node_modules/@waterplane/shared/dist/wire/costwindow.d.ts +143 -0
  443. package/node_modules/@waterplane/shared/dist/wire/costwindow.js +16 -0
  444. package/node_modules/@waterplane/shared/dist/wire/costwindow.js.map +1 -0
  445. package/node_modules/@waterplane/shared/dist/wire/install.d.ts +172 -0
  446. package/node_modules/@waterplane/shared/dist/wire/install.js +30 -0
  447. package/node_modules/@waterplane/shared/dist/wire/install.js.map +1 -0
  448. package/node_modules/@waterplane/shared/dist/wire/intent.d.ts +187 -0
  449. package/node_modules/@waterplane/shared/dist/wire/intent.js +2 -0
  450. package/node_modules/@waterplane/shared/dist/wire/intent.js.map +1 -0
  451. package/node_modules/@waterplane/shared/dist/wire/localrt.d.ts +78 -0
  452. package/node_modules/@waterplane/shared/dist/wire/localrt.js +21 -0
  453. package/node_modules/@waterplane/shared/dist/wire/localrt.js.map +1 -0
  454. package/node_modules/@waterplane/shared/dist/wire/localusage.d.ts +121 -0
  455. package/node_modules/@waterplane/shared/dist/wire/localusage.js +23 -0
  456. package/node_modules/@waterplane/shared/dist/wire/localusage.js.map +1 -0
  457. package/node_modules/@waterplane/shared/dist/wire/messages/clientbacklog.d.ts +177 -0
  458. package/node_modules/@waterplane/shared/dist/wire/messages/clientbacklog.js +3 -0
  459. package/node_modules/@waterplane/shared/dist/wire/messages/clientbacklog.js.map +1 -0
  460. package/node_modules/@waterplane/shared/dist/wire/messages/clienthost.d.ts +344 -0
  461. package/node_modules/@waterplane/shared/dist/wire/messages/clienthost.js +3 -0
  462. package/node_modules/@waterplane/shared/dist/wire/messages/clienthost.js.map +1 -0
  463. package/node_modules/@waterplane/shared/dist/wire/messages/clientsession.d.ts +307 -0
  464. package/node_modules/@waterplane/shared/dist/wire/messages/clientsession.js +3 -0
  465. package/node_modules/@waterplane/shared/dist/wire/messages/clientsession.js.map +1 -0
  466. package/node_modules/@waterplane/shared/dist/wire/messages/clientupdates.d.ts +18 -0
  467. package/node_modules/@waterplane/shared/dist/wire/messages/clientupdates.js +5 -0
  468. package/node_modules/@waterplane/shared/dist/wire/messages/clientupdates.js.map +1 -0
  469. package/node_modules/@waterplane/shared/dist/wire/messages/clientwork.d.ts +478 -0
  470. package/node_modules/@waterplane/shared/dist/wire/messages/clientwork.js +3 -0
  471. package/node_modules/@waterplane/shared/dist/wire/messages/clientwork.js.map +1 -0
  472. package/node_modules/@waterplane/shared/dist/wire/messages/hostcore.d.ts +488 -0
  473. package/node_modules/@waterplane/shared/dist/wire/messages/hostcore.js +3 -0
  474. package/node_modules/@waterplane/shared/dist/wire/messages/hostcore.js.map +1 -0
  475. package/node_modules/@waterplane/shared/dist/wire/messages/hosttools.d.ts +338 -0
  476. package/node_modules/@waterplane/shared/dist/wire/messages/hosttools.js +3 -0
  477. package/node_modules/@waterplane/shared/dist/wire/messages/hosttools.js.map +1 -0
  478. package/node_modules/@waterplane/shared/dist/wire/messages/hostupdates.d.ts +16 -0
  479. package/node_modules/@waterplane/shared/dist/wire/messages/hostupdates.js +3 -0
  480. package/node_modules/@waterplane/shared/dist/wire/messages/hostupdates.js.map +1 -0
  481. package/node_modules/@waterplane/shared/dist/wire/messages.d.ts +25 -0
  482. package/node_modules/@waterplane/shared/dist/wire/messages.js +18 -0
  483. package/node_modules/@waterplane/shared/dist/wire/messages.js.map +1 -0
  484. package/node_modules/@waterplane/shared/dist/wire/notify.d.ts +145 -0
  485. package/node_modules/@waterplane/shared/dist/wire/notify.js +96 -0
  486. package/node_modules/@waterplane/shared/dist/wire/notify.js.map +1 -0
  487. package/node_modules/@waterplane/shared/dist/wire/notifylink.d.ts +36 -0
  488. package/node_modules/@waterplane/shared/dist/wire/notifylink.js +44 -0
  489. package/node_modules/@waterplane/shared/dist/wire/notifylink.js.map +1 -0
  490. package/node_modules/@waterplane/shared/dist/wire/onboard.d.ts +121 -0
  491. package/node_modules/@waterplane/shared/dist/wire/onboard.js +11 -0
  492. package/node_modules/@waterplane/shared/dist/wire/onboard.js.map +1 -0
  493. package/node_modules/@waterplane/shared/dist/wire/repo.d.ts +456 -0
  494. package/node_modules/@waterplane/shared/dist/wire/repo.js +30 -0
  495. package/node_modules/@waterplane/shared/dist/wire/repo.js.map +1 -0
  496. package/node_modules/@waterplane/shared/dist/wire/sent.d.ts +127 -0
  497. package/node_modules/@waterplane/shared/dist/wire/sent.js +2 -0
  498. package/node_modules/@waterplane/shared/dist/wire/sent.js.map +1 -0
  499. package/node_modules/@waterplane/shared/dist/wire/session/archive.d.ts +286 -0
  500. package/node_modules/@waterplane/shared/dist/wire/session/archive.js +2 -0
  501. package/node_modules/@waterplane/shared/dist/wire/session/archive.js.map +1 -0
  502. package/node_modules/@waterplane/shared/dist/wire/session/context.d.ts +298 -0
  503. package/node_modules/@waterplane/shared/dist/wire/session/context.js +6 -0
  504. package/node_modules/@waterplane/shared/dist/wire/session/context.js.map +1 -0
  505. package/node_modules/@waterplane/shared/dist/wire/session/contextspark.d.ts +402 -0
  506. package/node_modules/@waterplane/shared/dist/wire/session/contextspark.js +2 -0
  507. package/node_modules/@waterplane/shared/dist/wire/session/contextspark.js.map +1 -0
  508. package/node_modules/@waterplane/shared/dist/wire/session/delivery.d.ts +114 -0
  509. package/node_modules/@waterplane/shared/dist/wire/session/delivery.js +2 -0
  510. package/node_modules/@waterplane/shared/dist/wire/session/delivery.js.map +1 -0
  511. package/node_modules/@waterplane/shared/dist/wire/session/info.d.ts +427 -0
  512. package/node_modules/@waterplane/shared/dist/wire/session/info.js +2 -0
  513. package/node_modules/@waterplane/shared/dist/wire/session/info.js.map +1 -0
  514. package/node_modules/@waterplane/shared/dist/wire/session/launch.d.ts +332 -0
  515. package/node_modules/@waterplane/shared/dist/wire/session/launch.js +2 -0
  516. package/node_modules/@waterplane/shared/dist/wire/session/launch.js.map +1 -0
  517. package/node_modules/@waterplane/shared/dist/wire/session/promptbox.d.ts +181 -0
  518. package/node_modules/@waterplane/shared/dist/wire/session/promptbox.js +2 -0
  519. package/node_modules/@waterplane/shared/dist/wire/session/promptbox.js.map +1 -0
  520. package/node_modules/@waterplane/shared/dist/wire/session.d.ts +16 -0
  521. package/node_modules/@waterplane/shared/dist/wire/session.js +10 -0
  522. package/node_modules/@waterplane/shared/dist/wire/session.js.map +1 -0
  523. package/node_modules/@waterplane/shared/dist/wire/slash.d.ts +31 -0
  524. package/node_modules/@waterplane/shared/dist/wire/slash.js +9 -0
  525. package/node_modules/@waterplane/shared/dist/wire/slash.js.map +1 -0
  526. package/node_modules/@waterplane/shared/dist/wire/sysstat.d.ts +226 -0
  527. package/node_modules/@waterplane/shared/dist/wire/sysstat.js +47 -0
  528. package/node_modules/@waterplane/shared/dist/wire/sysstat.js.map +1 -0
  529. package/node_modules/@waterplane/shared/dist/wire/telemetry.d.ts +645 -0
  530. package/node_modules/@waterplane/shared/dist/wire/telemetry.js +3 -0
  531. package/node_modules/@waterplane/shared/dist/wire/telemetry.js.map +1 -0
  532. package/node_modules/@waterplane/shared/dist/wire/transcript.d.ts +327 -0
  533. package/node_modules/@waterplane/shared/dist/wire/transcript.js +60 -0
  534. package/node_modules/@waterplane/shared/dist/wire/transcript.js.map +1 -0
  535. package/node_modules/@waterplane/shared/dist/wire/updates.d.ts +130 -0
  536. package/node_modules/@waterplane/shared/dist/wire/updates.js +52 -0
  537. package/node_modules/@waterplane/shared/dist/wire/updates.js.map +1 -0
  538. package/node_modules/@waterplane/shared/dist/wire/work.d.ts +699 -0
  539. package/node_modules/@waterplane/shared/dist/wire/work.js +22 -0
  540. package/node_modules/@waterplane/shared/dist/wire/work.js.map +1 -0
  541. package/node_modules/@waterplane/shared/dist/working.d.ts +70 -0
  542. package/node_modules/@waterplane/shared/dist/working.js +208 -0
  543. package/node_modules/@waterplane/shared/dist/working.js.map +1 -0
  544. package/node_modules/@waterplane/shared/package.json +17 -0
  545. package/npm-shrinkwrap.json +250 -0
  546. package/package.json +33 -6
  547. package/packages/extensions/copilot-usage/waterplane-plugin.json +9 -0
  548. package/packages/extensions/ocr/assets/deu.traineddata.gz +0 -0
  549. package/packages/extensions/ocr/assets/eng.traineddata.gz +0 -0
  550. package/packages/extensions/ocr/assets/manifest.json +44 -0
  551. package/packages/extensions/ocr/assets/tesseract-core-lstm.wasm.js +191 -0
  552. package/packages/extensions/ocr/assets/tesseract-core-simd-lstm.wasm.js +191 -0
  553. package/packages/extensions/ocr/assets/worker.min.js +3 -0
  554. package/packages/extensions/ocr/waterplane-plugin.json +11 -0
  555. package/packages/extensions/requirements/waterplane-plugin.json +9 -0
  556. package/packages/extensions/token-stats/waterplane-plugin.json +8 -0
  557. package/packages/host/dist/acks.d.ts +119 -0
  558. package/packages/host/dist/acks.js +268 -0
  559. package/packages/host/dist/acks.js.map +1 -0
  560. package/packages/host/dist/agentfollowup.d.ts +45 -0
  561. package/packages/host/dist/agentfollowup.js +77 -0
  562. package/packages/host/dist/agentfollowup.js.map +1 -0
  563. package/packages/host/dist/agentintents.d.ts +278 -0
  564. package/packages/host/dist/agentintents.js +509 -0
  565. package/packages/host/dist/agentintents.js.map +1 -0
  566. package/packages/host/dist/agents.d.ts +112 -0
  567. package/packages/host/dist/agents.js +517 -0
  568. package/packages/host/dist/agents.js.map +1 -0
  569. package/packages/host/dist/agentwatch.d.ts +42 -0
  570. package/packages/host/dist/agentwatch.js +35 -0
  571. package/packages/host/dist/agentwatch.js.map +1 -0
  572. package/packages/host/dist/androidenv.d.ts +80 -0
  573. package/packages/host/dist/androidenv.js +344 -0
  574. package/packages/host/dist/androidenv.js.map +1 -0
  575. package/packages/host/dist/answergate.d.ts +191 -0
  576. package/packages/host/dist/answergate.js +321 -0
  577. package/packages/host/dist/answergate.js.map +1 -0
  578. package/packages/host/dist/api.d.ts +19 -0
  579. package/packages/host/dist/api.js +62 -0
  580. package/packages/host/dist/api.js.map +1 -0
  581. package/packages/host/dist/apkcheck.d.ts +36 -0
  582. package/packages/host/dist/apkcheck.js +290 -0
  583. package/packages/host/dist/apkcheck.js.map +1 -0
  584. package/packages/host/dist/appready.d.ts +8 -0
  585. package/packages/host/dist/appready.js +16 -0
  586. package/packages/host/dist/appready.js.map +1 -0
  587. package/packages/host/dist/archive.d.ts +95 -0
  588. package/packages/host/dist/archive.js +318 -0
  589. package/packages/host/dist/archive.js.map +1 -0
  590. package/packages/host/dist/artifacts.d.ts +38 -0
  591. package/packages/host/dist/artifacts.js +315 -0
  592. package/packages/host/dist/artifacts.js.map +1 -0
  593. package/packages/host/dist/askbox.d.ts +116 -0
  594. package/packages/host/dist/askbox.js +341 -0
  595. package/packages/host/dist/askbox.js.map +1 -0
  596. package/packages/host/dist/askrules.d.ts +38 -0
  597. package/packages/host/dist/askrules.js +139 -0
  598. package/packages/host/dist/askrules.js.map +1 -0
  599. package/packages/host/dist/assess/hassapply.d.ts +127 -0
  600. package/packages/host/dist/assess/hassapply.js +482 -0
  601. package/packages/host/dist/assess/hassapply.js.map +1 -0
  602. package/packages/host/dist/assess/hassexec.d.ts +160 -0
  603. package/packages/host/dist/assess/hassexec.js +178 -0
  604. package/packages/host/dist/assess/hassexec.js.map +1 -0
  605. package/packages/host/dist/assess/hassinput.d.ts +80 -0
  606. package/packages/host/dist/assess/hassinput.js +264 -0
  607. package/packages/host/dist/assess/hassinput.js.map +1 -0
  608. package/packages/host/dist/assess/hassknobs.d.ts +66 -0
  609. package/packages/host/dist/assess/hassknobs.js +69 -0
  610. package/packages/host/dist/assess/hassknobs.js.map +1 -0
  611. package/packages/host/dist/assess/hassprogress.d.ts +30 -0
  612. package/packages/host/dist/assess/hassprogress.js +165 -0
  613. package/packages/host/dist/assess/hassprogress.js.map +1 -0
  614. package/packages/host/dist/assess/hassrun.d.ts +39 -0
  615. package/packages/host/dist/assess/hassrun.js +269 -0
  616. package/packages/host/dist/assess/hassrun.js.map +1 -0
  617. package/packages/host/dist/assess/hassstore.d.ts +77 -0
  618. package/packages/host/dist/assess/hassstore.js +187 -0
  619. package/packages/host/dist/assess/hassstore.js.map +1 -0
  620. package/packages/host/dist/assess/hassutil.d.ts +28 -0
  621. package/packages/host/dist/assess/hassutil.js +53 -0
  622. package/packages/host/dist/assess/hassutil.js.map +1 -0
  623. package/packages/host/dist/assess.d.ts +60 -0
  624. package/packages/host/dist/assess.js +58 -0
  625. package/packages/host/dist/assess.js.map +1 -0
  626. package/packages/host/dist/auth.d.ts +93 -0
  627. package/packages/host/dist/auth.js +276 -0
  628. package/packages/host/dist/auth.js.map +1 -0
  629. package/packages/host/dist/authroutes.d.ts +36 -0
  630. package/packages/host/dist/authroutes.js +108 -0
  631. package/packages/host/dist/authroutes.js.map +1 -0
  632. package/packages/host/dist/autopull.d.ts +107 -0
  633. package/packages/host/dist/autopull.js +248 -0
  634. package/packages/host/dist/autopull.js.map +1 -0
  635. package/packages/host/dist/backends/claude-endpoint.d.ts +98 -0
  636. package/packages/host/dist/backends/claude-endpoint.js +347 -0
  637. package/packages/host/dist/backends/claude-endpoint.js.map +1 -0
  638. package/packages/host/dist/backends/claude-local.d.ts +51 -0
  639. package/packages/host/dist/backends/claude-local.js +221 -0
  640. package/packages/host/dist/backends/claude-local.js.map +1 -0
  641. package/packages/host/dist/backends/claude-sources.d.ts +53 -0
  642. package/packages/host/dist/backends/claude-sources.js +68 -0
  643. package/packages/host/dist/backends/claude-sources.js.map +1 -0
  644. package/packages/host/dist/backends/claude.d.ts +45 -0
  645. package/packages/host/dist/backends/claude.js +248 -0
  646. package/packages/host/dist/backends/claude.js.map +1 -0
  647. package/packages/host/dist/backends/claudemodels.d.ts +19 -0
  648. package/packages/host/dist/backends/claudemodels.js +122 -0
  649. package/packages/host/dist/backends/claudemodels.js.map +1 -0
  650. package/packages/host/dist/backends/derive.d.ts +81 -0
  651. package/packages/host/dist/backends/derive.js +198 -0
  652. package/packages/host/dist/backends/derive.js.map +1 -0
  653. package/packages/host/dist/backends/index.d.ts +138 -0
  654. package/packages/host/dist/backends/index.js +328 -0
  655. package/packages/host/dist/backends/index.js.map +1 -0
  656. package/packages/host/dist/backends/overhead.d.ts +16 -0
  657. package/packages/host/dist/backends/overhead.js +124 -0
  658. package/packages/host/dist/backends/overhead.js.map +1 -0
  659. package/packages/host/dist/backends/readers.d.ts +57 -0
  660. package/packages/host/dist/backends/readers.js +74 -0
  661. package/packages/host/dist/backends/readers.js.map +1 -0
  662. package/packages/host/dist/backends/registry.d.ts +37 -0
  663. package/packages/host/dist/backends/registry.js +73 -0
  664. package/packages/host/dist/backends/registry.js.map +1 -0
  665. package/packages/host/dist/backends/shell.d.ts +31 -0
  666. package/packages/host/dist/backends/shell.js +127 -0
  667. package/packages/host/dist/backends/shell.js.map +1 -0
  668. package/packages/host/dist/backends/types.d.ts +457 -0
  669. package/packages/host/dist/backends/types.js +2 -0
  670. package/packages/host/dist/backends/types.js.map +1 -0
  671. package/packages/host/dist/backlog/backlogcore.d.ts +36 -0
  672. package/packages/host/dist/backlog/backlogcore.js +2 -0
  673. package/packages/host/dist/backlog/backlogcore.js.map +1 -0
  674. package/packages/host/dist/backlog/backlogedits.d.ts +96 -0
  675. package/packages/host/dist/backlog/backlogedits.js +229 -0
  676. package/packages/host/dist/backlog/backlogedits.js.map +1 -0
  677. package/packages/host/dist/backlog/backlogfollowup.d.ts +7 -0
  678. package/packages/host/dist/backlog/backlogfollowup.js +71 -0
  679. package/packages/host/dist/backlog/backlogfollowup.js.map +1 -0
  680. package/packages/host/dist/backlog/backlogknobs.d.ts +56 -0
  681. package/packages/host/dist/backlog/backlogknobs.js +62 -0
  682. package/packages/host/dist/backlog/backlogknobs.js.map +1 -0
  683. package/packages/host/dist/backlog/backlogsessions.d.ts +217 -0
  684. package/packages/host/dist/backlog/backlogsessions.js +421 -0
  685. package/packages/host/dist/backlog/backlogsessions.js.map +1 -0
  686. package/packages/host/dist/backlog/backlogstore.d.ts +31 -0
  687. package/packages/host/dist/backlog/backlogstore.js +101 -0
  688. package/packages/host/dist/backlog/backlogstore.js.map +1 -0
  689. package/packages/host/dist/backlog/backlogtitles.d.ts +40 -0
  690. package/packages/host/dist/backlog/backlogtitles.js +50 -0
  691. package/packages/host/dist/backlog/backlogtitles.js.map +1 -0
  692. package/packages/host/dist/backlog/backlogwording.d.ts +31 -0
  693. package/packages/host/dist/backlog/backlogwording.js +42 -0
  694. package/packages/host/dist/backlog/backlogwording.js.map +1 -0
  695. package/packages/host/dist/backlog.d.ts +142 -0
  696. package/packages/host/dist/backlog.js +96 -0
  697. package/packages/host/dist/backlog.js.map +1 -0
  698. package/packages/host/dist/billing.d.ts +53 -0
  699. package/packages/host/dist/billing.js +140 -0
  700. package/packages/host/dist/billing.js.map +1 -0
  701. package/packages/host/dist/binguard.d.ts +28 -0
  702. package/packages/host/dist/binguard.js +88 -0
  703. package/packages/host/dist/binguard.js.map +1 -0
  704. package/packages/host/dist/bookmarks.d.ts +24 -0
  705. package/packages/host/dist/bookmarks.js +118 -0
  706. package/packages/host/dist/bookmarks.js.map +1 -0
  707. package/packages/host/dist/branddirs.d.ts +223 -0
  708. package/packages/host/dist/branddirs.js +828 -0
  709. package/packages/host/dist/branddirs.js.map +1 -0
  710. package/packages/host/dist/budget.d.ts +57 -0
  711. package/packages/host/dist/budget.js +153 -0
  712. package/packages/host/dist/budget.js.map +1 -0
  713. package/packages/host/dist/builds.d.ts +178 -0
  714. package/packages/host/dist/builds.js +645 -0
  715. package/packages/host/dist/builds.js.map +1 -0
  716. package/packages/host/dist/buildscan.d.ts +16 -0
  717. package/packages/host/dist/buildscan.js +177 -0
  718. package/packages/host/dist/buildscan.js.map +1 -0
  719. package/packages/host/dist/burnwatch.d.ts +53 -0
  720. package/packages/host/dist/burnwatch.js +141 -0
  721. package/packages/host/dist/burnwatch.js.map +1 -0
  722. package/packages/host/dist/capture/android.d.ts +2 -0
  723. package/packages/host/dist/capture/android.js +144 -0
  724. package/packages/host/dist/capture/android.js.map +1 -0
  725. package/packages/host/dist/capture/captureconfig.d.ts +44 -0
  726. package/packages/host/dist/capture/captureconfig.js +169 -0
  727. package/packages/host/dist/capture/captureconfig.js.map +1 -0
  728. package/packages/host/dist/capture/capturehelpers.d.ts +34 -0
  729. package/packages/host/dist/capture/capturehelpers.js +156 -0
  730. package/packages/host/dist/capture/capturehelpers.js.map +1 -0
  731. package/packages/host/dist/capture/capturekit.d.ts +32 -0
  732. package/packages/host/dist/capture/capturekit.js +47 -0
  733. package/packages/host/dist/capture/capturekit.js.map +1 -0
  734. package/packages/host/dist/capture/capturepass.d.ts +17 -0
  735. package/packages/host/dist/capture/capturepass.js +262 -0
  736. package/packages/host/dist/capture/capturepass.js.map +1 -0
  737. package/packages/host/dist/capture/capturesettle.d.ts +35 -0
  738. package/packages/host/dist/capture/capturesettle.js +77 -0
  739. package/packages/host/dist/capture/capturesettle.js.map +1 -0
  740. package/packages/host/dist/capture/captureverdict.d.ts +132 -0
  741. package/packages/host/dist/capture/captureverdict.js +107 -0
  742. package/packages/host/dist/capture/captureverdict.js.map +1 -0
  743. package/packages/host/dist/capture/garmin.d.ts +2 -0
  744. package/packages/host/dist/capture/garmin.js +294 -0
  745. package/packages/host/dist/capture/garmin.js.map +1 -0
  746. package/packages/host/dist/capture/pixels.d.ts +60 -0
  747. package/packages/host/dist/capture/pixels.js +199 -0
  748. package/packages/host/dist/capture/pixels.js.map +1 -0
  749. package/packages/host/dist/capture/types.d.ts +195 -0
  750. package/packages/host/dist/capture/types.js +2 -0
  751. package/packages/host/dist/capture/types.js.map +1 -0
  752. package/packages/host/dist/capture/web.d.ts +2 -0
  753. package/packages/host/dist/capture/web.js +290 -0
  754. package/packages/host/dist/capture/web.js.map +1 -0
  755. package/packages/host/dist/capture/window.d.ts +2 -0
  756. package/packages/host/dist/capture/window.js +88 -0
  757. package/packages/host/dist/capture/window.js.map +1 -0
  758. package/packages/host/dist/capture.d.ts +116 -0
  759. package/packages/host/dist/capture.js +295 -0
  760. package/packages/host/dist/capture.js.map +1 -0
  761. package/packages/host/dist/claudebin.d.ts +32 -0
  762. package/packages/host/dist/claudebin.js +113 -0
  763. package/packages/host/dist/claudebin.js.map +1 -0
  764. package/packages/host/dist/claudeconfig.d.ts +23 -0
  765. package/packages/host/dist/claudeconfig.js +118 -0
  766. package/packages/host/dist/claudeconfig.js.map +1 -0
  767. package/packages/host/dist/cli/entry.d.ts +1 -0
  768. package/packages/host/dist/cli/entry.js +11 -0
  769. package/packages/host/dist/cli/entry.js.map +1 -0
  770. package/packages/host/dist/cli/index.d.ts +12 -0
  771. package/packages/host/dist/cli/index.js +122 -0
  772. package/packages/host/dist/cli/index.js.map +1 -0
  773. package/packages/host/dist/cli/pair.d.ts +28 -0
  774. package/packages/host/dist/cli/pair.js +94 -0
  775. package/packages/host/dist/cli/pair.js.map +1 -0
  776. package/packages/host/dist/cli/releasesig.d.ts +42 -0
  777. package/packages/host/dist/cli/releasesig.js +60 -0
  778. package/packages/host/dist/cli/releasesig.js.map +1 -0
  779. package/packages/host/dist/cli/selfupdate.d.ts +96 -0
  780. package/packages/host/dist/cli/selfupdate.js +842 -0
  781. package/packages/host/dist/cli/selfupdate.js.map +1 -0
  782. package/packages/host/dist/cli/service.d.ts +100 -0
  783. package/packages/host/dist/cli/service.js +645 -0
  784. package/packages/host/dist/cli/service.js.map +1 -0
  785. package/packages/host/dist/cli/statesnap.d.ts +34 -0
  786. package/packages/host/dist/cli/statesnap.js +135 -0
  787. package/packages/host/dist/cli/statesnap.js.map +1 -0
  788. package/packages/host/dist/cli/windows.d.ts +191 -0
  789. package/packages/host/dist/cli/windows.js +658 -0
  790. package/packages/host/dist/cli/windows.js.map +1 -0
  791. package/packages/host/dist/clifixtures.d.ts +28 -0
  792. package/packages/host/dist/clifixtures.js +193 -0
  793. package/packages/host/dist/clifixtures.js.map +1 -0
  794. package/packages/host/dist/clihealth.d.ts +121 -0
  795. package/packages/host/dist/clihealth.js +301 -0
  796. package/packages/host/dist/clihealth.js.map +1 -0
  797. package/packages/host/dist/clisuggest.d.ts +13 -0
  798. package/packages/host/dist/clisuggest.js +54 -0
  799. package/packages/host/dist/clisuggest.js.map +1 -0
  800. package/packages/host/dist/commitmsg.d.ts +17 -0
  801. package/packages/host/dist/commitmsg.js +98 -0
  802. package/packages/host/dist/commitmsg.js.map +1 -0
  803. package/packages/host/dist/compliance.d.ts +121 -0
  804. package/packages/host/dist/compliance.js +827 -0
  805. package/packages/host/dist/compliance.js.map +1 -0
  806. package/packages/host/dist/composer.d.ts +225 -0
  807. package/packages/host/dist/composer.js +453 -0
  808. package/packages/host/dist/composer.js.map +1 -0
  809. package/packages/host/dist/confirmgate.d.ts +34 -0
  810. package/packages/host/dist/confirmgate.js +114 -0
  811. package/packages/host/dist/confirmgate.js.map +1 -0
  812. package/packages/host/dist/context.d.ts +22 -0
  813. package/packages/host/dist/context.js +92 -0
  814. package/packages/host/dist/context.js.map +1 -0
  815. package/packages/host/dist/contextlimits.d.ts +31 -0
  816. package/packages/host/dist/contextlimits.js +128 -0
  817. package/packages/host/dist/contextlimits.js.map +1 -0
  818. package/packages/host/dist/convfork.d.ts +67 -0
  819. package/packages/host/dist/convfork.js +372 -0
  820. package/packages/host/dist/convfork.js.map +1 -0
  821. package/packages/host/dist/convlog.d.ts +40 -0
  822. package/packages/host/dist/convlog.js +52 -0
  823. package/packages/host/dist/convlog.js.map +1 -0
  824. package/packages/host/dist/costwindow.d.ts +77 -0
  825. package/packages/host/dist/costwindow.js +333 -0
  826. package/packages/host/dist/costwindow.js.map +1 -0
  827. package/packages/host/dist/ctxlog/ctxagents.d.ts +179 -0
  828. package/packages/host/dist/ctxlog/ctxagents.js +419 -0
  829. package/packages/host/dist/ctxlog/ctxagents.js.map +1 -0
  830. package/packages/host/dist/ctxlog/ctxcursor.d.ts +299 -0
  831. package/packages/host/dist/ctxlog/ctxcursor.js +163 -0
  832. package/packages/host/dist/ctxlog/ctxcursor.js.map +1 -0
  833. package/packages/host/dist/ctxlog/ctxproject.d.ts +49 -0
  834. package/packages/host/dist/ctxlog/ctxproject.js +198 -0
  835. package/packages/host/dist/ctxlog/ctxproject.js.map +1 -0
  836. package/packages/host/dist/ctxlog/ctxupdate.d.ts +11 -0
  837. package/packages/host/dist/ctxlog/ctxupdate.js +338 -0
  838. package/packages/host/dist/ctxlog/ctxupdate.js.map +1 -0
  839. package/packages/host/dist/ctxlog.d.ts +56 -0
  840. package/packages/host/dist/ctxlog.js +57 -0
  841. package/packages/host/dist/ctxlog.js.map +1 -0
  842. package/packages/host/dist/ctxwindow.d.ts +17 -0
  843. package/packages/host/dist/ctxwindow.js +106 -0
  844. package/packages/host/dist/ctxwindow.js.map +1 -0
  845. package/packages/host/dist/decisionlog.d.ts +29 -0
  846. package/packages/host/dist/decisionlog.js +167 -0
  847. package/packages/host/dist/decisionlog.js.map +1 -0
  848. package/packages/host/dist/deliver/deliverknobs.d.ts +84 -0
  849. package/packages/host/dist/deliver/deliverknobs.js +85 -0
  850. package/packages/host/dist/deliver/deliverknobs.js.map +1 -0
  851. package/packages/host/dist/deliver/deliverproof.d.ts +25 -0
  852. package/packages/host/dist/deliver/deliverproof.js +123 -0
  853. package/packages/host/dist/deliver/deliverproof.js.map +1 -0
  854. package/packages/host/dist/deliver/deliverreturn.d.ts +12 -0
  855. package/packages/host/dist/deliver/deliverreturn.js +365 -0
  856. package/packages/host/dist/deliver/deliverreturn.js.map +1 -0
  857. package/packages/host/dist/deliver/deliverrun.d.ts +20 -0
  858. package/packages/host/dist/deliver/deliverrun.js +495 -0
  859. package/packages/host/dist/deliver/deliverrun.js.map +1 -0
  860. package/packages/host/dist/deliver/deliverscreen.d.ts +67 -0
  861. package/packages/host/dist/deliver/deliverscreen.js +428 -0
  862. package/packages/host/dist/deliver/deliverscreen.js.map +1 -0
  863. package/packages/host/dist/deliver/delivertypes.d.ts +119 -0
  864. package/packages/host/dist/deliver/delivertypes.js +2 -0
  865. package/packages/host/dist/deliver/delivertypes.js.map +1 -0
  866. package/packages/host/dist/deliver.d.ts +50 -0
  867. package/packages/host/dist/deliver.js +142 -0
  868. package/packages/host/dist/deliver.js.map +1 -0
  869. package/packages/host/dist/deviceledger.d.ts +33 -0
  870. package/packages/host/dist/deviceledger.js +143 -0
  871. package/packages/host/dist/deviceledger.js.map +1 -0
  872. package/packages/host/dist/dictate.d.ts +142 -0
  873. package/packages/host/dist/dictate.js +419 -0
  874. package/packages/host/dist/dictate.js.map +1 -0
  875. package/packages/host/dist/discover.d.ts +20 -0
  876. package/packages/host/dist/discover.js +162 -0
  877. package/packages/host/dist/discover.js.map +1 -0
  878. package/packages/host/dist/diskwatch.d.ts +39 -0
  879. package/packages/host/dist/diskwatch.js +111 -0
  880. package/packages/host/dist/diskwatch.js.map +1 -0
  881. package/packages/host/dist/doctor.d.ts +153 -0
  882. package/packages/host/dist/doctor.js +748 -0
  883. package/packages/host/dist/doctor.js.map +1 -0
  884. package/packages/host/dist/doctorclaude.d.ts +33 -0
  885. package/packages/host/dist/doctorclaude.js +128 -0
  886. package/packages/host/dist/doctorclaude.js.map +1 -0
  887. package/packages/host/dist/doctormac.d.ts +47 -0
  888. package/packages/host/dist/doctormac.js +81 -0
  889. package/packages/host/dist/doctormac.js.map +1 -0
  890. package/packages/host/dist/doctorproc.d.ts +11 -0
  891. package/packages/host/dist/doctorproc.js +36 -0
  892. package/packages/host/dist/doctorproc.js.map +1 -0
  893. package/packages/host/dist/doctorwsl.d.ts +90 -0
  894. package/packages/host/dist/doctorwsl.js +205 -0
  895. package/packages/host/dist/doctorwsl.js.map +1 -0
  896. package/packages/host/dist/echo.d.ts +331 -0
  897. package/packages/host/dist/echo.js +439 -0
  898. package/packages/host/dist/echo.js.map +1 -0
  899. package/packages/host/dist/env.d.ts +16 -0
  900. package/packages/host/dist/env.js +190 -0
  901. package/packages/host/dist/env.js.map +1 -0
  902. package/packages/host/dist/envfiles.d.ts +5 -0
  903. package/packages/host/dist/envfiles.js +43 -0
  904. package/packages/host/dist/envfiles.js.map +1 -0
  905. package/packages/host/dist/extensions/copilot-usage/host/ghquota.d.mts +17 -0
  906. package/packages/host/dist/extensions/copilot-usage/host/ghquota.mjs +96 -0
  907. package/packages/host/dist/extensions/copilot-usage/host/ghquota.mjs.map +1 -0
  908. package/packages/host/dist/extensions/copilot-usage/host/index.d.mts +17 -0
  909. package/packages/host/dist/extensions/copilot-usage/host/index.mjs +102 -0
  910. package/packages/host/dist/extensions/copilot-usage/host/index.mjs.map +1 -0
  911. package/packages/host/dist/extensions/copilot-usage/host/vscodelocal.d.mts +90 -0
  912. package/packages/host/dist/extensions/copilot-usage/host/vscodelocal.mjs +365 -0
  913. package/packages/host/dist/extensions/copilot-usage/host/vscodelocal.mjs.map +1 -0
  914. package/packages/host/dist/extensions/ocr/host/index.d.mts +10 -0
  915. package/packages/host/dist/extensions/ocr/host/index.mjs +4 -0
  916. package/packages/host/dist/extensions/ocr/host/index.mjs.map +1 -0
  917. package/packages/host/dist/extensions/requirements/host/index.d.mts +2 -0
  918. package/packages/host/dist/extensions/requirements/host/index.mjs +63 -0
  919. package/packages/host/dist/extensions/requirements/host/index.mjs.map +1 -0
  920. package/packages/host/dist/extensions/requirements/host/list.d.mts +17 -0
  921. package/packages/host/dist/extensions/requirements/host/list.mjs +125 -0
  922. package/packages/host/dist/extensions/requirements/host/list.mjs.map +1 -0
  923. package/packages/host/dist/extensions/requirements/host/requirements.d.mts +31 -0
  924. package/packages/host/dist/extensions/requirements/host/requirements.mjs +318 -0
  925. package/packages/host/dist/extensions/requirements/host/requirements.mjs.map +1 -0
  926. package/packages/host/dist/extensions/requirements/shared/methods.d.mts +88 -0
  927. package/packages/host/dist/extensions/requirements/shared/methods.mjs +36 -0
  928. package/packages/host/dist/extensions/requirements/shared/methods.mjs.map +1 -0
  929. package/packages/host/dist/fanout.d.ts +89 -0
  930. package/packages/host/dist/fanout.js +273 -0
  931. package/packages/host/dist/fanout.js.map +1 -0
  932. package/packages/host/dist/files.d.ts +211 -0
  933. package/packages/host/dist/files.js +760 -0
  934. package/packages/host/dist/files.js.map +1 -0
  935. package/packages/host/dist/git.d.ts +261 -0
  936. package/packages/host/dist/git.js +787 -0
  937. package/packages/host/dist/git.js.map +1 -0
  938. package/packages/host/dist/gitlog.d.ts +14 -0
  939. package/packages/host/dist/gitlog.js +93 -0
  940. package/packages/host/dist/gitlog.js.map +1 -0
  941. package/packages/host/dist/halt.d.ts +35 -0
  942. package/packages/host/dist/halt.js +160 -0
  943. package/packages/host/dist/halt.js.map +1 -0
  944. package/packages/host/dist/healthwatch.d.ts +90 -0
  945. package/packages/host/dist/healthwatch.js +334 -0
  946. package/packages/host/dist/healthwatch.js.map +1 -0
  947. package/packages/host/dist/host.d.ts +51 -0
  948. package/packages/host/dist/host.js +153 -0
  949. package/packages/host/dist/host.js.map +1 -0
  950. package/packages/host/dist/hoststore.d.ts +24 -0
  951. package/packages/host/dist/hoststore.js +350 -0
  952. package/packages/host/dist/hoststore.js.map +1 -0
  953. package/packages/host/dist/httpio.d.ts +64 -0
  954. package/packages/host/dist/httpio.js +199 -0
  955. package/packages/host/dist/httpio.js.map +1 -0
  956. package/packages/host/dist/installlog.d.ts +25 -0
  957. package/packages/host/dist/installlog.js +137 -0
  958. package/packages/host/dist/installlog.js.map +1 -0
  959. package/packages/host/dist/intents/adapters.d.ts +285 -0
  960. package/packages/host/dist/intents/adapters.js +690 -0
  961. package/packages/host/dist/intents/adapters.js.map +1 -0
  962. package/packages/host/dist/intents/clock.d.ts +105 -0
  963. package/packages/host/dist/intents/clock.js +190 -0
  964. package/packages/host/dist/intents/clock.js.map +1 -0
  965. package/packages/host/dist/intents/contract.d.ts +488 -0
  966. package/packages/host/dist/intents/contract.js +155 -0
  967. package/packages/host/dist/intents/contract.js.map +1 -0
  968. package/packages/host/dist/intents/disk.d.ts +198 -0
  969. package/packages/host/dist/intents/disk.js +588 -0
  970. package/packages/host/dist/intents/disk.js.map +1 -0
  971. package/packages/host/dist/intents/fire.d.ts +112 -0
  972. package/packages/host/dist/intents/fire.js +545 -0
  973. package/packages/host/dist/intents/fire.js.map +1 -0
  974. package/packages/host/dist/intents/ladder.d.ts +7 -0
  975. package/packages/host/dist/intents/ladder.js +408 -0
  976. package/packages/host/dist/intents/ladder.js.map +1 -0
  977. package/packages/host/dist/intents/manager.d.ts +239 -0
  978. package/packages/host/dist/intents/manager.js +292 -0
  979. package/packages/host/dist/intents/manager.js.map +1 -0
  980. package/packages/host/dist/intents/requeue.d.ts +207 -0
  981. package/packages/host/dist/intents/requeue.js +521 -0
  982. package/packages/host/dist/intents/requeue.js.map +1 -0
  983. package/packages/host/dist/intents/watch.d.ts +92 -0
  984. package/packages/host/dist/intents/watch.js +464 -0
  985. package/packages/host/dist/intents/watch.js.map +1 -0
  986. package/packages/host/dist/intents/write.d.ts +238 -0
  987. package/packages/host/dist/intents/write.js +651 -0
  988. package/packages/host/dist/intents/write.js.map +1 -0
  989. package/packages/host/dist/jsonstore.d.ts +50 -0
  990. package/packages/host/dist/jsonstore.js +158 -0
  991. package/packages/host/dist/jsonstore.js.map +1 -0
  992. package/packages/host/dist/keyhints.d.ts +45 -0
  993. package/packages/host/dist/keyhints.js +117 -0
  994. package/packages/host/dist/keyhints.js.map +1 -0
  995. package/packages/host/dist/lanid.d.ts +21 -0
  996. package/packages/host/dist/lanid.js +78 -0
  997. package/packages/host/dist/lanid.js.map +1 -0
  998. package/packages/host/dist/launchfiles.d.ts +64 -0
  999. package/packages/host/dist/launchfiles.js +212 -0
  1000. package/packages/host/dist/launchfiles.js.map +1 -0
  1001. package/packages/host/dist/limit.d.ts +82 -0
  1002. package/packages/host/dist/limit.js +251 -0
  1003. package/packages/host/dist/limit.js.map +1 -0
  1004. package/packages/host/dist/limitlog.d.ts +51 -0
  1005. package/packages/host/dist/limitlog.js +154 -0
  1006. package/packages/host/dist/limitlog.js.map +1 -0
  1007. package/packages/host/dist/limitretry.d.ts +135 -0
  1008. package/packages/host/dist/limitretry.js +115 -0
  1009. package/packages/host/dist/limitretry.js.map +1 -0
  1010. package/packages/host/dist/livesources.d.ts +38 -0
  1011. package/packages/host/dist/livesources.js +26 -0
  1012. package/packages/host/dist/livesources.js.map +1 -0
  1013. package/packages/host/dist/localledger.d.ts +69 -0
  1014. package/packages/host/dist/localledger.js +214 -0
  1015. package/packages/host/dist/localledger.js.map +1 -0
  1016. package/packages/host/dist/localrt.d.ts +164 -0
  1017. package/packages/host/dist/localrt.js +414 -0
  1018. package/packages/host/dist/localrt.js.map +1 -0
  1019. package/packages/host/dist/localslot.d.ts +152 -0
  1020. package/packages/host/dist/localslot.js +269 -0
  1021. package/packages/host/dist/localslot.js.map +1 -0
  1022. package/packages/host/dist/localusage.d.ts +153 -0
  1023. package/packages/host/dist/localusage.js +710 -0
  1024. package/packages/host/dist/localusage.js.map +1 -0
  1025. package/packages/host/dist/login.d.ts +34 -0
  1026. package/packages/host/dist/login.js +126 -0
  1027. package/packages/host/dist/login.js.map +1 -0
  1028. package/packages/host/dist/main.d.ts +1 -0
  1029. package/packages/host/dist/main.js +694 -0
  1030. package/packages/host/dist/main.js.map +1 -0
  1031. package/packages/host/dist/meter.d.ts +23 -0
  1032. package/packages/host/dist/meter.js +121 -0
  1033. package/packages/host/dist/meter.js.map +1 -0
  1034. package/packages/host/dist/naming.d.ts +257 -0
  1035. package/packages/host/dist/naming.js +387 -0
  1036. package/packages/host/dist/naming.js.map +1 -0
  1037. package/packages/host/dist/net.d.ts +78 -0
  1038. package/packages/host/dist/net.js +267 -0
  1039. package/packages/host/dist/net.js.map +1 -0
  1040. package/packages/host/dist/netstats.d.ts +99 -0
  1041. package/packages/host/dist/netstats.js +223 -0
  1042. package/packages/host/dist/netstats.js.map +1 -0
  1043. package/packages/host/dist/notifyprefs.d.ts +12 -0
  1044. package/packages/host/dist/notifyprefs.js +60 -0
  1045. package/packages/host/dist/notifyprefs.js.map +1 -0
  1046. package/packages/host/dist/ocrlocal.d.ts +46 -0
  1047. package/packages/host/dist/ocrlocal.js +297 -0
  1048. package/packages/host/dist/ocrlocal.js.map +1 -0
  1049. package/packages/host/dist/onboard.d.ts +182 -0
  1050. package/packages/host/dist/onboard.js +590 -0
  1051. package/packages/host/dist/onboard.js.map +1 -0
  1052. package/packages/host/dist/onboardroutes.d.ts +31 -0
  1053. package/packages/host/dist/onboardroutes.js +78 -0
  1054. package/packages/host/dist/onboardroutes.js.map +1 -0
  1055. package/packages/host/dist/opendeliveries.d.ts +175 -0
  1056. package/packages/host/dist/opendeliveries.js +538 -0
  1057. package/packages/host/dist/opendeliveries.js.map +1 -0
  1058. package/packages/host/dist/optins.d.ts +14 -0
  1059. package/packages/host/dist/optins.js +252 -0
  1060. package/packages/host/dist/optins.js.map +1 -0
  1061. package/packages/host/dist/origin.d.ts +86 -0
  1062. package/packages/host/dist/origin.js +301 -0
  1063. package/packages/host/dist/origin.js.map +1 -0
  1064. package/packages/host/dist/pair.d.ts +149 -0
  1065. package/packages/host/dist/pair.js +505 -0
  1066. package/packages/host/dist/pair.js.map +1 -0
  1067. package/packages/host/dist/passive.d.ts +58 -0
  1068. package/packages/host/dist/passive.js +187 -0
  1069. package/packages/host/dist/passive.js.map +1 -0
  1070. package/packages/host/dist/paths.d.ts +67 -0
  1071. package/packages/host/dist/paths.js +135 -0
  1072. package/packages/host/dist/paths.js.map +1 -0
  1073. package/packages/host/dist/pathx.d.ts +6 -0
  1074. package/packages/host/dist/pathx.js +35 -0
  1075. package/packages/host/dist/pathx.js.map +1 -0
  1076. package/packages/host/dist/peers/agentpeer.d.ts +58 -0
  1077. package/packages/host/dist/peers/agentpeer.js +249 -0
  1078. package/packages/host/dist/peers/agentpeer.js.map +1 -0
  1079. package/packages/host/dist/peers/client.d.ts +60 -0
  1080. package/packages/host/dist/peers/client.js +96 -0
  1081. package/packages/host/dist/peers/client.js.map +1 -0
  1082. package/packages/host/dist/peers/jobs.d.ts +140 -0
  1083. package/packages/host/dist/peers/jobs.js +424 -0
  1084. package/packages/host/dist/peers/jobs.js.map +1 -0
  1085. package/packages/host/dist/peers/routes.d.ts +50 -0
  1086. package/packages/host/dist/peers/routes.js +191 -0
  1087. package/packages/host/dist/peers/routes.js.map +1 -0
  1088. package/packages/host/dist/peers/serve.d.ts +61 -0
  1089. package/packages/host/dist/peers/serve.js +532 -0
  1090. package/packages/host/dist/peers/serve.js.map +1 -0
  1091. package/packages/host/dist/peers/store.d.ts +64 -0
  1092. package/packages/host/dist/peers/store.js +128 -0
  1093. package/packages/host/dist/peers/store.js.map +1 -0
  1094. package/packages/host/dist/periodspend.d.ts +61 -0
  1095. package/packages/host/dist/periodspend.js +109 -0
  1096. package/packages/host/dist/periodspend.js.map +1 -0
  1097. package/packages/host/dist/permmode.d.ts +90 -0
  1098. package/packages/host/dist/permmode.js +157 -0
  1099. package/packages/host/dist/permmode.js.map +1 -0
  1100. package/packages/host/dist/planbox.d.ts +23 -0
  1101. package/packages/host/dist/planbox.js +123 -0
  1102. package/packages/host/dist/planbox.js.map +1 -0
  1103. package/packages/host/dist/plugins/builtin.d.ts +39 -0
  1104. package/packages/host/dist/plugins/builtin.js +200 -0
  1105. package/packages/host/dist/plugins/builtin.js.map +1 -0
  1106. package/packages/host/dist/plugins/pluginapi.d.ts +34 -0
  1107. package/packages/host/dist/plugins/pluginapi.js +649 -0
  1108. package/packages/host/dist/plugins/pluginapi.js.map +1 -0
  1109. package/packages/host/dist/plugins/pluginassets.d.ts +16 -0
  1110. package/packages/host/dist/plugins/pluginassets.js +44 -0
  1111. package/packages/host/dist/plugins/pluginassets.js.map +1 -0
  1112. package/packages/host/dist/plugins/pluginfiles.d.ts +30 -0
  1113. package/packages/host/dist/plugins/pluginfiles.js +130 -0
  1114. package/packages/host/dist/plugins/pluginfiles.js.map +1 -0
  1115. package/packages/host/dist/plugins/pluginloader.d.ts +59 -0
  1116. package/packages/host/dist/plugins/pluginloader.js +206 -0
  1117. package/packages/host/dist/plugins/pluginloader.js.map +1 -0
  1118. package/packages/host/dist/plugins/pluginregistry.d.ts +249 -0
  1119. package/packages/host/dist/plugins/pluginregistry.js +799 -0
  1120. package/packages/host/dist/plugins/pluginregistry.js.map +1 -0
  1121. package/packages/host/dist/plugins/pluginroutes.d.ts +29 -0
  1122. package/packages/host/dist/plugins/pluginroutes.js +50 -0
  1123. package/packages/host/dist/plugins/pluginroutes.js.map +1 -0
  1124. package/packages/host/dist/plugins/pluginrpc.d.ts +19 -0
  1125. package/packages/host/dist/plugins/pluginrpc.js +28 -0
  1126. package/packages/host/dist/plugins/pluginrpc.js.map +1 -0
  1127. package/packages/host/dist/plugins/pluginstreams.d.ts +109 -0
  1128. package/packages/host/dist/plugins/pluginstreams.js +418 -0
  1129. package/packages/host/dist/plugins/pluginstreams.js.map +1 -0
  1130. package/packages/host/dist/plugins/plugintoolkit/screen.d.ts +9 -0
  1131. package/packages/host/dist/plugins/plugintoolkit/screen.js +21 -0
  1132. package/packages/host/dist/plugins/plugintoolkit/screen.js.map +1 -0
  1133. package/packages/host/dist/plugins/plugintoolkit/sessionfiles.d.ts +6 -0
  1134. package/packages/host/dist/plugins/plugintoolkit/sessionfiles.js +24 -0
  1135. package/packages/host/dist/plugins/plugintoolkit/sessionfiles.js.map +1 -0
  1136. package/packages/host/dist/plugins/plugintoolkit/tail.d.ts +10 -0
  1137. package/packages/host/dist/plugins/plugintoolkit/tail.js +110 -0
  1138. package/packages/host/dist/plugins/plugintoolkit/tail.js.map +1 -0
  1139. package/packages/host/dist/plugins/setupcontrib.d.ts +64 -0
  1140. package/packages/host/dist/plugins/setupcontrib.js +94 -0
  1141. package/packages/host/dist/plugins/setupcontrib.js.map +1 -0
  1142. package/packages/host/dist/proc.d.ts +13 -0
  1143. package/packages/host/dist/proc.js +27 -0
  1144. package/packages/host/dist/proc.js.map +1 -0
  1145. package/packages/host/dist/prompt.d.ts +113 -0
  1146. package/packages/host/dist/prompt.js +565 -0
  1147. package/packages/host/dist/prompt.js.map +1 -0
  1148. package/packages/host/dist/promptbase.d.ts +28 -0
  1149. package/packages/host/dist/promptbase.js +42 -0
  1150. package/packages/host/dist/promptbase.js.map +1 -0
  1151. package/packages/host/dist/promptmerge.d.ts +63 -0
  1152. package/packages/host/dist/promptmerge.js +221 -0
  1153. package/packages/host/dist/promptmerge.js.map +1 -0
  1154. package/packages/host/dist/promptnav.d.ts +29 -0
  1155. package/packages/host/dist/promptnav.js +97 -0
  1156. package/packages/host/dist/promptnav.js.map +1 -0
  1157. package/packages/host/dist/prompts.d.ts +4 -0
  1158. package/packages/host/dist/prompts.js +78 -0
  1159. package/packages/host/dist/prompts.js.map +1 -0
  1160. package/packages/host/dist/ptycap.d.ts +41 -0
  1161. package/packages/host/dist/ptycap.js +192 -0
  1162. package/packages/host/dist/ptycap.js.map +1 -0
  1163. package/packages/host/dist/ptyenv.d.ts +3 -0
  1164. package/packages/host/dist/ptyenv.js +63 -0
  1165. package/packages/host/dist/ptyenv.js.map +1 -0
  1166. package/packages/host/dist/push.d.ts +42 -0
  1167. package/packages/host/dist/push.js +107 -0
  1168. package/packages/host/dist/push.js.map +1 -0
  1169. package/packages/host/dist/pushprogress.d.ts +27 -0
  1170. package/packages/host/dist/pushprogress.js +72 -0
  1171. package/packages/host/dist/pushprogress.js.map +1 -0
  1172. package/packages/host/dist/question.d.ts +60 -0
  1173. package/packages/host/dist/question.js +137 -0
  1174. package/packages/host/dist/question.js.map +1 -0
  1175. package/packages/host/dist/ratelimit.d.ts +44 -0
  1176. package/packages/host/dist/ratelimit.js +68 -0
  1177. package/packages/host/dist/ratelimit.js.map +1 -0
  1178. package/packages/host/dist/render.d.ts +50 -0
  1179. package/packages/host/dist/render.js +138 -0
  1180. package/packages/host/dist/render.js.map +1 -0
  1181. package/packages/host/dist/repohealth.d.ts +113 -0
  1182. package/packages/host/dist/repohealth.js +752 -0
  1183. package/packages/host/dist/repohealth.js.map +1 -0
  1184. package/packages/host/dist/repohealthapproval.d.ts +88 -0
  1185. package/packages/host/dist/repohealthapproval.js +709 -0
  1186. package/packages/host/dist/repohealthapproval.js.map +1 -0
  1187. package/packages/host/dist/repohealthscopes.d.ts +23 -0
  1188. package/packages/host/dist/repohealthscopes.js +124 -0
  1189. package/packages/host/dist/repohealthscopes.js.map +1 -0
  1190. package/packages/host/dist/repos.d.ts +25 -0
  1191. package/packages/host/dist/repos.js +181 -0
  1192. package/packages/host/dist/repos.js.map +1 -0
  1193. package/packages/host/dist/reposkill.d.ts +17 -0
  1194. package/packages/host/dist/reposkill.js +92 -0
  1195. package/packages/host/dist/reposkill.js.map +1 -0
  1196. package/packages/host/dist/reposkilltext.d.ts +16 -0
  1197. package/packages/host/dist/reposkilltext.js +320 -0
  1198. package/packages/host/dist/reposkilltext.js.map +1 -0
  1199. package/packages/host/dist/restartnote.d.ts +17 -0
  1200. package/packages/host/dist/restartnote.js +36 -0
  1201. package/packages/host/dist/restartnote.js.map +1 -0
  1202. package/packages/host/dist/review.d.ts +83 -0
  1203. package/packages/host/dist/review.js +513 -0
  1204. package/packages/host/dist/review.js.map +1 -0
  1205. package/packages/host/dist/rootchoice.d.ts +26 -0
  1206. package/packages/host/dist/rootchoice.js +101 -0
  1207. package/packages/host/dist/rootchoice.js.map +1 -0
  1208. package/packages/host/dist/routes/apihost.d.ts +2 -0
  1209. package/packages/host/dist/routes/apihost.js +532 -0
  1210. package/packages/host/dist/routes/apihost.js.map +1 -0
  1211. package/packages/host/dist/routes/apiio.d.ts +86 -0
  1212. package/packages/host/dist/routes/apiio.js +354 -0
  1213. package/packages/host/dist/routes/apiio.js.map +1 -0
  1214. package/packages/host/dist/routes/apirepofiles.d.ts +7 -0
  1215. package/packages/host/dist/routes/apirepofiles.js +382 -0
  1216. package/packages/host/dist/routes/apirepofiles.js.map +1 -0
  1217. package/packages/host/dist/routes/apirepowork.d.ts +2 -0
  1218. package/packages/host/dist/routes/apirepowork.js +500 -0
  1219. package/packages/host/dist/routes/apirepowork.js.map +1 -0
  1220. package/packages/host/dist/routes/apiroutes.d.ts +14 -0
  1221. package/packages/host/dist/routes/apiroutes.js +20 -0
  1222. package/packages/host/dist/routes/apiroutes.js.map +1 -0
  1223. package/packages/host/dist/routes/apisession.d.ts +2 -0
  1224. package/packages/host/dist/routes/apisession.js +197 -0
  1225. package/packages/host/dist/routes/apisession.js.map +1 -0
  1226. package/packages/host/dist/routes/apistats.d.ts +2 -0
  1227. package/packages/host/dist/routes/apistats.js +220 -0
  1228. package/packages/host/dist/routes/apistats.js.map +1 -0
  1229. package/packages/host/dist/routes/apisystem.d.ts +2 -0
  1230. package/packages/host/dist/routes/apisystem.js +389 -0
  1231. package/packages/host/dist/routes/apisystem.js.map +1 -0
  1232. package/packages/host/dist/routes/apitable.d.ts +180 -0
  1233. package/packages/host/dist/routes/apitable.js +71 -0
  1234. package/packages/host/dist/routes/apitable.js.map +1 -0
  1235. package/packages/host/dist/routes/index.d.ts +19 -0
  1236. package/packages/host/dist/routes/index.js +65 -0
  1237. package/packages/host/dist/routes/index.js.map +1 -0
  1238. package/packages/host/dist/routes/session.d.ts +2 -0
  1239. package/packages/host/dist/routes/session.js +771 -0
  1240. package/packages/host/dist/routes/session.js.map +1 -0
  1241. package/packages/host/dist/routes/system.d.ts +24 -0
  1242. package/packages/host/dist/routes/system.js +530 -0
  1243. package/packages/host/dist/routes/system.js.map +1 -0
  1244. package/packages/host/dist/routes/types.d.ts +283 -0
  1245. package/packages/host/dist/routes/types.js +2 -0
  1246. package/packages/host/dist/routes/types.js.map +1 -0
  1247. package/packages/host/dist/routes/work/workassess.d.ts +2 -0
  1248. package/packages/host/dist/routes/work/workassess.js +182 -0
  1249. package/packages/host/dist/routes/work/workassess.js.map +1 -0
  1250. package/packages/host/dist/routes/work/workbacklog.d.ts +2 -0
  1251. package/packages/host/dist/routes/work/workbacklog.js +329 -0
  1252. package/packages/host/dist/routes/work/workbacklog.js.map +1 -0
  1253. package/packages/host/dist/routes/work/workbuild.d.ts +2 -0
  1254. package/packages/host/dist/routes/work/workbuild.js +250 -0
  1255. package/packages/host/dist/routes/work/workbuild.js.map +1 -0
  1256. package/packages/host/dist/routes/work/workintent.d.ts +2 -0
  1257. package/packages/host/dist/routes/work/workintent.js +167 -0
  1258. package/packages/host/dist/routes/work/workintent.js.map +1 -0
  1259. package/packages/host/dist/routes/work/workschedule.d.ts +2 -0
  1260. package/packages/host/dist/routes/work/workschedule.js +131 -0
  1261. package/packages/host/dist/routes/work/workschedule.js.map +1 -0
  1262. package/packages/host/dist/routes/work.d.ts +10 -0
  1263. package/packages/host/dist/routes/work.js +13 -0
  1264. package/packages/host/dist/routes/work.js.map +1 -0
  1265. package/packages/host/dist/scaffold.d.ts +104 -0
  1266. package/packages/host/dist/scaffold.js +417 -0
  1267. package/packages/host/dist/scaffold.js.map +1 -0
  1268. package/packages/host/dist/screenlog.d.ts +43 -0
  1269. package/packages/host/dist/screenlog.js +209 -0
  1270. package/packages/host/dist/screenlog.js.map +1 -0
  1271. package/packages/host/dist/secrets.d.ts +72 -0
  1272. package/packages/host/dist/secrets.js +258 -0
  1273. package/packages/host/dist/secrets.js.map +1 -0
  1274. package/packages/host/dist/sentlog.d.ts +82 -0
  1275. package/packages/host/dist/sentlog.js +186 -0
  1276. package/packages/host/dist/sentlog.js.map +1 -0
  1277. package/packages/host/dist/server/billingwire.d.ts +24 -0
  1278. package/packages/host/dist/server/billingwire.js +73 -0
  1279. package/packages/host/dist/server/billingwire.js.map +1 -0
  1280. package/packages/host/dist/server/clients.d.ts +52 -0
  1281. package/packages/host/dist/server/clients.js +178 -0
  1282. package/packages/host/dist/server/clients.js.map +1 -0
  1283. package/packages/host/dist/server/ctx.d.ts +118 -0
  1284. package/packages/host/dist/server/ctx.js +2 -0
  1285. package/packages/host/dist/server/ctx.js.map +1 -0
  1286. package/packages/host/dist/server/ctxseal.d.ts +21 -0
  1287. package/packages/host/dist/server/ctxseal.js +24 -0
  1288. package/packages/host/dist/server/ctxseal.js.map +1 -0
  1289. package/packages/host/dist/server/deliveries.d.ts +20 -0
  1290. package/packages/host/dist/server/deliveries.js +276 -0
  1291. package/packages/host/dist/server/deliveries.js.map +1 -0
  1292. package/packages/host/dist/server/firstapp.d.ts +12 -0
  1293. package/packages/host/dist/server/firstapp.js +37 -0
  1294. package/packages/host/dist/server/firstapp.js.map +1 -0
  1295. package/packages/host/dist/server/http.d.ts +34 -0
  1296. package/packages/host/dist/server/http.js +475 -0
  1297. package/packages/host/dist/server/http.js.map +1 -0
  1298. package/packages/host/dist/server/intentDeps.d.ts +36 -0
  1299. package/packages/host/dist/server/intentDeps.js +418 -0
  1300. package/packages/host/dist/server/intentDeps.js.map +1 -0
  1301. package/packages/host/dist/server/intentEvents.d.ts +13 -0
  1302. package/packages/host/dist/server/intentEvents.js +234 -0
  1303. package/packages/host/dist/server/intentEvents.js.map +1 -0
  1304. package/packages/host/dist/server/liveness.d.ts +64 -0
  1305. package/packages/host/dist/server/liveness.js +74 -0
  1306. package/packages/host/dist/server/liveness.js.map +1 -0
  1307. package/packages/host/dist/server/scan.d.ts +41 -0
  1308. package/packages/host/dist/server/scan.js +227 -0
  1309. package/packages/host/dist/server/scan.js.map +1 -0
  1310. package/packages/host/dist/server/sessionEvents.d.ts +40 -0
  1311. package/packages/host/dist/server/sessionEvents.js +509 -0
  1312. package/packages/host/dist/server/sessionEvents.js.map +1 -0
  1313. package/packages/host/dist/server/shutdown.d.ts +11 -0
  1314. package/packages/host/dist/server/shutdown.js +135 -0
  1315. package/packages/host/dist/server/shutdown.js.map +1 -0
  1316. package/packages/host/dist/server/wsops.d.ts +44 -0
  1317. package/packages/host/dist/server/wsops.js +313 -0
  1318. package/packages/host/dist/server/wsops.js.map +1 -0
  1319. package/packages/host/dist/sessionSearch.d.ts +46 -0
  1320. package/packages/host/dist/sessionSearch.js +93 -0
  1321. package/packages/host/dist/sessionSearch.js.map +1 -0
  1322. package/packages/host/dist/sessionbudget.d.ts +61 -0
  1323. package/packages/host/dist/sessionbudget.js +84 -0
  1324. package/packages/host/dist/sessionbudget.js.map +1 -0
  1325. package/packages/host/dist/sessions/boxes.d.ts +112 -0
  1326. package/packages/host/dist/sessions/boxes.js +968 -0
  1327. package/packages/host/dist/sessions/boxes.js.map +1 -0
  1328. package/packages/host/dist/sessions/budgetwatch.d.ts +95 -0
  1329. package/packages/host/dist/sessions/budgetwatch.js +171 -0
  1330. package/packages/host/dist/sessions/budgetwatch.js.map +1 -0
  1331. package/packages/host/dist/sessions/convid.d.ts +72 -0
  1332. package/packages/host/dist/sessions/convid.js +305 -0
  1333. package/packages/host/dist/sessions/convid.js.map +1 -0
  1334. package/packages/host/dist/sessions/core.d.ts +749 -0
  1335. package/packages/host/dist/sessions/core.js +2 -0
  1336. package/packages/host/dist/sessions/core.js.map +1 -0
  1337. package/packages/host/dist/sessions/ctxseries.d.ts +184 -0
  1338. package/packages/host/dist/sessions/ctxseries.js +766 -0
  1339. package/packages/host/dist/sessions/ctxseries.js.map +1 -0
  1340. package/packages/host/dist/sessions/drive.d.ts +207 -0
  1341. package/packages/host/dist/sessions/drive.js +779 -0
  1342. package/packages/host/dist/sessions/drive.js.map +1 -0
  1343. package/packages/host/dist/sessions/haltall.d.ts +36 -0
  1344. package/packages/host/dist/sessions/haltall.js +95 -0
  1345. package/packages/host/dist/sessions/haltall.js.map +1 -0
  1346. package/packages/host/dist/sessions/health.d.ts +88 -0
  1347. package/packages/host/dist/sessions/health.js +108 -0
  1348. package/packages/host/dist/sessions/health.js.map +1 -0
  1349. package/packages/host/dist/sessions/idlewatch.d.ts +34 -0
  1350. package/packages/host/dist/sessions/idlewatch.js +74 -0
  1351. package/packages/host/dist/sessions/idlewatch.js.map +1 -0
  1352. package/packages/host/dist/sessions/knobs.d.ts +315 -0
  1353. package/packages/host/dist/sessions/knobs.js +411 -0
  1354. package/packages/host/dist/sessions/knobs.js.map +1 -0
  1355. package/packages/host/dist/sessions/links.d.ts +53 -0
  1356. package/packages/host/dist/sessions/links.js +209 -0
  1357. package/packages/host/dist/sessions/links.js.map +1 -0
  1358. package/packages/host/dist/sessions/livemode.d.ts +56 -0
  1359. package/packages/host/dist/sessions/livemode.js +300 -0
  1360. package/packages/host/dist/sessions/livemode.js.map +1 -0
  1361. package/packages/host/dist/sessions/record.d.ts +196 -0
  1362. package/packages/host/dist/sessions/record.js +719 -0
  1363. package/packages/host/dist/sessions/record.js.map +1 -0
  1364. package/packages/host/dist/sessions/resume.d.ts +164 -0
  1365. package/packages/host/dist/sessions/resume.js +629 -0
  1366. package/packages/host/dist/sessions/resume.js.map +1 -0
  1367. package/packages/host/dist/sessions/roster.d.ts +164 -0
  1368. package/packages/host/dist/sessions/roster.js +566 -0
  1369. package/packages/host/dist/sessions/roster.js.map +1 -0
  1370. package/packages/host/dist/sessions/sidechannel.d.ts +96 -0
  1371. package/packages/host/dist/sessions/sidechannel.js +726 -0
  1372. package/packages/host/dist/sessions/sidechannel.js.map +1 -0
  1373. package/packages/host/dist/sessions/tmux.d.ts +247 -0
  1374. package/packages/host/dist/sessions/tmux.js +731 -0
  1375. package/packages/host/dist/sessions/tmux.js.map +1 -0
  1376. package/packages/host/dist/sessions/turn.d.ts +237 -0
  1377. package/packages/host/dist/sessions/turn.js +1003 -0
  1378. package/packages/host/dist/sessions/turn.js.map +1 -0
  1379. package/packages/host/dist/sessions/wall.d.ts +117 -0
  1380. package/packages/host/dist/sessions/wall.js +658 -0
  1381. package/packages/host/dist/sessions/wall.js.map +1 -0
  1382. package/packages/host/dist/sessions.d.ts +255 -0
  1383. package/packages/host/dist/sessions.js +758 -0
  1384. package/packages/host/dist/sessions.js.map +1 -0
  1385. package/packages/host/dist/settings.d.ts +40 -0
  1386. package/packages/host/dist/settings.js +171 -0
  1387. package/packages/host/dist/settings.js.map +1 -0
  1388. package/packages/host/dist/settle.d.ts +171 -0
  1389. package/packages/host/dist/settle.js +409 -0
  1390. package/packages/host/dist/settle.js.map +1 -0
  1391. package/packages/host/dist/setupprefs.d.ts +51 -0
  1392. package/packages/host/dist/setupprefs.js +178 -0
  1393. package/packages/host/dist/setupprefs.js.map +1 -0
  1394. package/packages/host/dist/setupwatch.d.ts +39 -0
  1395. package/packages/host/dist/setupwatch.js +249 -0
  1396. package/packages/host/dist/setupwatch.js.map +1 -0
  1397. package/packages/host/dist/shelllinks.d.ts +39 -0
  1398. package/packages/host/dist/shelllinks.js +292 -0
  1399. package/packages/host/dist/shelllinks.js.map +1 -0
  1400. package/packages/host/dist/shells.d.ts +190 -0
  1401. package/packages/host/dist/shells.js +633 -0
  1402. package/packages/host/dist/shells.js.map +1 -0
  1403. package/packages/host/dist/sidecar/sidecarclaude.d.ts +120 -0
  1404. package/packages/host/dist/sidecar/sidecarclaude.js +213 -0
  1405. package/packages/host/dist/sidecar/sidecarclaude.js.map +1 -0
  1406. package/packages/host/dist/sidecar/sidecarname.d.ts +99 -0
  1407. package/packages/host/dist/sidecar/sidecarname.js +163 -0
  1408. package/packages/host/dist/sidecar/sidecarname.js.map +1 -0
  1409. package/packages/host/dist/sidecar/sidecaropenai.d.ts +24 -0
  1410. package/packages/host/dist/sidecar/sidecaropenai.js +129 -0
  1411. package/packages/host/dist/sidecar/sidecaropenai.js.map +1 -0
  1412. package/packages/host/dist/sidecar/sidecarroute.d.ts +65 -0
  1413. package/packages/host/dist/sidecar/sidecarroute.js +158 -0
  1414. package/packages/host/dist/sidecar/sidecarroute.js.map +1 -0
  1415. package/packages/host/dist/sidecar/sidecartasks.d.ts +20 -0
  1416. package/packages/host/dist/sidecar/sidecartasks.js +63 -0
  1417. package/packages/host/dist/sidecar/sidecartasks.js.map +1 -0
  1418. package/packages/host/dist/sidecar/sidecartrust.d.ts +32 -0
  1419. package/packages/host/dist/sidecar/sidecartrust.js +74 -0
  1420. package/packages/host/dist/sidecar/sidecartrust.js.map +1 -0
  1421. package/packages/host/dist/sidecar.d.ts +82 -0
  1422. package/packages/host/dist/sidecar.js +78 -0
  1423. package/packages/host/dist/sidecar.js.map +1 -0
  1424. package/packages/host/dist/signkey.d.ts +57 -0
  1425. package/packages/host/dist/signkey.js +159 -0
  1426. package/packages/host/dist/signkey.js.map +1 -0
  1427. package/packages/host/dist/slash.d.ts +43 -0
  1428. package/packages/host/dist/slash.js +236 -0
  1429. package/packages/host/dist/slash.js.map +1 -0
  1430. package/packages/host/dist/sourceanswer.d.ts +103 -0
  1431. package/packages/host/dist/sourceanswer.js +193 -0
  1432. package/packages/host/dist/sourceanswer.js.map +1 -0
  1433. package/packages/host/dist/speedtest.d.ts +57 -0
  1434. package/packages/host/dist/speedtest.js +137 -0
  1435. package/packages/host/dist/speedtest.js.map +1 -0
  1436. package/packages/host/dist/spendwall.d.ts +33 -0
  1437. package/packages/host/dist/spendwall.js +45 -0
  1438. package/packages/host/dist/spendwall.js.map +1 -0
  1439. package/packages/host/dist/sysstat.d.ts +134 -0
  1440. package/packages/host/dist/sysstat.js +630 -0
  1441. package/packages/host/dist/sysstat.js.map +1 -0
  1442. package/packages/host/dist/tailnetpeers.d.ts +34 -0
  1443. package/packages/host/dist/tailnetpeers.js +116 -0
  1444. package/packages/host/dist/tailnetpeers.js.map +1 -0
  1445. package/packages/host/dist/tailscaleguard.d.ts +11 -0
  1446. package/packages/host/dist/tailscaleguard.js +133 -0
  1447. package/packages/host/dist/tailscaleguard.js.map +1 -0
  1448. package/packages/host/dist/termqueries.d.ts +124 -0
  1449. package/packages/host/dist/termqueries.js +207 -0
  1450. package/packages/host/dist/termqueries.js.map +1 -0
  1451. package/packages/host/dist/themeoverlay.d.ts +74 -0
  1452. package/packages/host/dist/themeoverlay.js +262 -0
  1453. package/packages/host/dist/themeoverlay.js.map +1 -0
  1454. package/packages/host/dist/thumbs.d.ts +69 -0
  1455. package/packages/host/dist/thumbs.js +359 -0
  1456. package/packages/host/dist/thumbs.js.map +1 -0
  1457. package/packages/host/dist/tmuxreq.d.ts +91 -0
  1458. package/packages/host/dist/tmuxreq.js +207 -0
  1459. package/packages/host/dist/tmuxreq.js.map +1 -0
  1460. package/packages/host/dist/tmuxscroll.d.ts +70 -0
  1461. package/packages/host/dist/tmuxscroll.js +206 -0
  1462. package/packages/host/dist/tmuxscroll.js.map +1 -0
  1463. package/packages/host/dist/tokenscan.d.ts +63 -0
  1464. package/packages/host/dist/tokenscan.js +220 -0
  1465. package/packages/host/dist/tokenscan.js.map +1 -0
  1466. package/packages/host/dist/tokenstats.d.ts +115 -0
  1467. package/packages/host/dist/tokenstats.js +763 -0
  1468. package/packages/host/dist/tokenstats.js.map +1 -0
  1469. package/packages/host/dist/toolchain.d.ts +147 -0
  1470. package/packages/host/dist/toolchain.js +468 -0
  1471. package/packages/host/dist/toolchain.js.map +1 -0
  1472. package/packages/host/dist/transcript/transcriptlog.d.ts +134 -0
  1473. package/packages/host/dist/transcript/transcriptlog.js +300 -0
  1474. package/packages/host/dist/transcript/transcriptlog.js.map +1 -0
  1475. package/packages/host/dist/transcript/transcriptparse.d.ts +28 -0
  1476. package/packages/host/dist/transcript/transcriptparse.js +377 -0
  1477. package/packages/host/dist/transcript/transcriptparse.js.map +1 -0
  1478. package/packages/host/dist/transcript/transcriptscreen.d.ts +71 -0
  1479. package/packages/host/dist/transcript/transcriptscreen.js +120 -0
  1480. package/packages/host/dist/transcript/transcriptscreen.js.map +1 -0
  1481. package/packages/host/dist/transcript/transcriptturns.d.ts +139 -0
  1482. package/packages/host/dist/transcript/transcriptturns.js +270 -0
  1483. package/packages/host/dist/transcript/transcriptturns.js.map +1 -0
  1484. package/packages/host/dist/transcript.d.ts +28 -0
  1485. package/packages/host/dist/transcript.js +34 -0
  1486. package/packages/host/dist/transcript.js.map +1 -0
  1487. package/packages/host/dist/transportsurvey.d.ts +10 -0
  1488. package/packages/host/dist/transportsurvey.js +109 -0
  1489. package/packages/host/dist/transportsurvey.js.map +1 -0
  1490. package/packages/host/dist/tree.d.ts +80 -0
  1491. package/packages/host/dist/tree.js +372 -0
  1492. package/packages/host/dist/tree.js.map +1 -0
  1493. package/packages/host/dist/turnagents.d.ts +17 -0
  1494. package/packages/host/dist/turnagents.js +205 -0
  1495. package/packages/host/dist/turnagents.js.map +1 -0
  1496. package/packages/host/dist/uistats.d.ts +18 -0
  1497. package/packages/host/dist/uistats.js +105 -0
  1498. package/packages/host/dist/uistats.js.map +1 -0
  1499. package/packages/host/dist/update.d.ts +100 -0
  1500. package/packages/host/dist/update.js +536 -0
  1501. package/packages/host/dist/update.js.map +1 -0
  1502. package/packages/host/dist/updates/apply.d.ts +45 -0
  1503. package/packages/host/dist/updates/apply.js +362 -0
  1504. package/packages/host/dist/updates/apply.js.map +1 -0
  1505. package/packages/host/dist/updates/catalog.d.ts +11 -0
  1506. package/packages/host/dist/updates/catalog.js +123 -0
  1507. package/packages/host/dist/updates/catalog.js.map +1 -0
  1508. package/packages/host/dist/updates/checker.d.ts +73 -0
  1509. package/packages/host/dist/updates/checker.js +189 -0
  1510. package/packages/host/dist/updates/checker.js.map +1 -0
  1511. package/packages/host/dist/updates/github.d.ts +13 -0
  1512. package/packages/host/dist/updates/github.js +63 -0
  1513. package/packages/host/dist/updates/github.js.map +1 -0
  1514. package/packages/host/dist/updates/gitops.d.ts +16 -0
  1515. package/packages/host/dist/updates/gitops.js +61 -0
  1516. package/packages/host/dist/updates/gitops.js.map +1 -0
  1517. package/packages/host/dist/updates/installrecord.d.ts +26 -0
  1518. package/packages/host/dist/updates/installrecord.js +42 -0
  1519. package/packages/host/dist/updates/installrecord.js.map +1 -0
  1520. package/packages/host/dist/updates/remote.d.ts +10 -0
  1521. package/packages/host/dist/updates/remote.js +54 -0
  1522. package/packages/host/dist/updates/remote.js.map +1 -0
  1523. package/packages/host/dist/updates/restart.d.ts +5 -0
  1524. package/packages/host/dist/updates/restart.js +20 -0
  1525. package/packages/host/dist/updates/restart.js.map +1 -0
  1526. package/packages/host/dist/updates/self.d.ts +19 -0
  1527. package/packages/host/dist/updates/self.js +51 -0
  1528. package/packages/host/dist/updates/self.js.map +1 -0
  1529. package/packages/host/dist/updates/wire.d.ts +18 -0
  1530. package/packages/host/dist/updates/wire.js +21 -0
  1531. package/packages/host/dist/updates/wire.js.map +1 -0
  1532. package/packages/host/dist/usage.d.ts +124 -0
  1533. package/packages/host/dist/usage.js +411 -0
  1534. package/packages/host/dist/usage.js.map +1 -0
  1535. package/packages/host/dist/usagelog.d.ts +53 -0
  1536. package/packages/host/dist/usagelog.js +223 -0
  1537. package/packages/host/dist/usagelog.js.map +1 -0
  1538. package/packages/host/dist/usagesourcelog.d.ts +59 -0
  1539. package/packages/host/dist/usagesourcelog.js +208 -0
  1540. package/packages/host/dist/usagesourcelog.js.map +1 -0
  1541. package/packages/host/dist/usagesources.d.ts +175 -0
  1542. package/packages/host/dist/usagesources.js +462 -0
  1543. package/packages/host/dist/usagesources.js.map +1 -0
  1544. package/packages/host/dist/visualskill.d.ts +36 -0
  1545. package/packages/host/dist/visualskill.js +230 -0
  1546. package/packages/host/dist/visualskill.js.map +1 -0
  1547. package/packages/host/dist/webbundle.d.ts +47 -0
  1548. package/packages/host/dist/webbundle.js +155 -0
  1549. package/packages/host/dist/webbundle.js.map +1 -0
  1550. package/packages/host/dist/wirerecord.d.ts +5 -0
  1551. package/packages/host/dist/wirerecord.js +128 -0
  1552. package/packages/host/dist/wirerecord.js.map +1 -0
  1553. package/packages/host/dist/worktreeleftover.d.ts +27 -0
  1554. package/packages/host/dist/worktreeleftover.js +153 -0
  1555. package/packages/host/dist/worktreeleftover.js.map +1 -0
  1556. package/packages/host/dist/worktreeowner.d.ts +17 -0
  1557. package/packages/host/dist/worktreeowner.js +45 -0
  1558. package/packages/host/dist/worktreeowner.js.map +1 -0
  1559. package/packages/host/package.json +26 -0
  1560. package/packages/web/dist/assets/apple-touch-icon.png +0 -0
  1561. package/packages/web/dist/assets/badge-96.png +0 -0
  1562. package/packages/web/dist/assets/demo-CXlqlYE4.js +23 -0
  1563. package/packages/web/dist/assets/hero.png +0 -0
  1564. package/packages/web/dist/assets/icon-192.png +0 -0
  1565. package/packages/web/dist/assets/icon-32.png +0 -0
  1566. package/packages/web/dist/assets/icon-48.png +0 -0
  1567. package/packages/web/dist/assets/icon-512-maskable.png +0 -0
  1568. package/packages/web/dist/assets/icon-512.png +0 -0
  1569. package/packages/web/dist/assets/icon-dark.svg +43 -0
  1570. package/packages/web/dist/assets/icon-light.svg +42 -0
  1571. package/packages/web/dist/assets/icon.svg +11 -0
  1572. package/packages/web/dist/assets/icons-BbqDBVjw.js +1 -0
  1573. package/packages/web/dist/assets/index-CgPoyb3Y.css +1 -0
  1574. package/packages/web/dist/assets/index-D5JKj8DK.js +169 -0
  1575. package/packages/web/dist/assets/react-CoSyT_xY.js +8 -0
  1576. package/packages/web/dist/assets/rolldown-runtime-BpQH8Ho1.js +1 -0
  1577. package/packages/web/dist/assets/shared-eyaskl5l.js +47 -0
  1578. package/packages/web/dist/assets/sheets-Bjv2L-cG.css +1 -0
  1579. package/packages/web/dist/assets/sheets-BzzL2re1.js +204 -0
  1580. package/packages/web/dist/assets/vendor-BPwPmufs.js +3 -0
  1581. package/packages/web/dist/assets/xterm-BrP-ENHg.css +1 -0
  1582. package/packages/web/dist/assets/xterm-C8zLTNGk.js +16 -0
  1583. package/packages/web/dist/build-id.txt +1 -0
  1584. package/packages/web/dist/demo/media/r1/dot-claude/inbox/swipe-sketch.png +0 -0
  1585. package/packages/web/dist/demo/media/r1/dot-claude/outbox/todo-garden-android-fixed.png +0 -0
  1586. package/packages/web/dist/demo/media/r1/dot-claude/outbox/todo-garden-android.png +0 -0
  1587. package/packages/web/dist/demo/media/r1/dot-claude/outbox/todo-garden-before.png +0 -0
  1588. package/packages/web/dist/demo/media/r1/dot-claude/outbox/todo-garden-date-picker.png +0 -0
  1589. package/packages/web/dist/demo/media/r1/dot-claude/outbox/todo-garden-empty-state.png +0 -0
  1590. package/packages/web/dist/demo/media/r1/dot-claude/outbox/todo-garden-grouped.png +0 -0
  1591. package/packages/web/dist/demo/media/r1/dot-claude/outbox/todo-garden-ios.png +0 -0
  1592. package/packages/web/dist/demo/media/r1/dot-claude/outbox/todo-garden-preview.html +18 -0
  1593. package/packages/web/dist/demo/media/r1/dot-claude/outbox/todo-garden-release-notes.md +21 -0
  1594. package/packages/web/dist/demo/media/r1/dot-claude/outbox/todo-garden-sorted.png +0 -0
  1595. package/packages/web/dist/demo/media/r3/dot-claude/outbox/trail-log-ridge-loop.png +0 -0
  1596. package/packages/web/dist/index.html +84 -0
  1597. package/packages/web/dist/manifest.webmanifest +16 -0
  1598. package/packages/web/dist/sw.js +420 -0
  1599. package/release.json +22 -0
  1600. package/scripts/windows/keeper.ps1 +60 -0
  1601. package/scripts/windows/wsl-setup.sh +173 -0
  1602. package/tools/repohealth/census.mjs +353 -0
  1603. package/tools/repohealth/central.mjs +234 -0
  1604. package/tools/repohealth/constants.mjs +420 -0
  1605. package/tools/repohealth/events.mjs +563 -0
  1606. package/tools/repohealth/fixture.json +17976 -0
  1607. package/tools/repohealth/git.mjs +471 -0
  1608. package/tools/repohealth/html.mjs +601 -0
  1609. package/tools/repohealth/judge.mjs +546 -0
  1610. package/tools/repohealth/lang/typescript-ast.mjs +538 -0
  1611. package/tools/repohealth/metrics/classics.mjs +239 -0
  1612. package/tools/repohealth/metrics/cochange.mjs +234 -0
  1613. package/tools/repohealth/metrics/context.mjs +411 -0
  1614. package/tools/repohealth/metrics/deadexports.mjs +122 -0
  1615. package/tools/repohealth/metrics/dups.mjs +261 -0
  1616. package/tools/repohealth/metrics/hatches.mjs +164 -0
  1617. package/tools/repohealth/metrics/retouch.mjs +326 -0
  1618. package/tools/repohealth/metrics/route.mjs +159 -0
  1619. package/tools/repohealth/metrics/size.mjs +120 -0
  1620. package/tools/repohealth/metrics/tripwires.mjs +258 -0
  1621. package/tools/repohealth/metrics/untested.mjs +308 -0
  1622. package/tools/repohealth/narrate.mjs +342 -0
  1623. package/tools/repohealth/own.mjs +238 -0
  1624. package/tools/repohealth/packs/c.mjs +124 -0
  1625. package/tools/repohealth/packs/common.mjs +205 -0
  1626. package/tools/repohealth/packs/dart.mjs +118 -0
  1627. package/tools/repohealth/packs/index.mjs +83 -0
  1628. package/tools/repohealth/packs/kotlin.mjs +320 -0
  1629. package/tools/repohealth/packs/python.mjs +488 -0
  1630. package/tools/repohealth/packs/shell.mjs +88 -0
  1631. package/tools/repohealth/packs/typescript.mjs +604 -0
  1632. package/tools/repohealth/plot.mjs +462 -0
  1633. package/tools/repohealth/readings.mjs +427 -0
  1634. package/tools/repohealth/scope.mjs +184 -0
  1635. package/tools/repohealth/series.mjs +360 -0
  1636. package/tools/repohealth/snapshot.mjs +431 -0
  1637. package/tools/repohealth/source.mjs +266 -0
  1638. package/tools/repohealth/statefile.mjs +31 -0
  1639. package/tools/repohealth/types.mjs +316 -0
  1640. package/tools/repohealth.mjs +767 -0
  1641. package/tools/skillmap.mjs +109 -0
@@ -0,0 +1,204 @@
1
+ import{n as e}from"./rolldown-runtime-BpQH8Ho1.js";import{$ as t,$a as n,$c as r,$n as i,$o as a,$r as o,$s as s,$t as c,A as l,Aa as u,Ac as d,Ai as f,An as p,Ao as m,Ar as h,As as g,At as _,Ba as v,Bi as y,Bn as b,Bo as x,Br as S,Bs as C,Bt as w,Ca as T,Cc as E,Ci as D,Cn as O,Co as k,Cr as A,Cs as j,Ct as M,D as N,Da as P,Dc as F,Di as ee,Do as te,Dr as ne,Dt as re,Ea as ie,Ei as ae,En as oe,Er as se,Es as ce,Et as le,F as ue,Fc as de,Fi as fe,Fn as pe,Fo as me,Fr as he,Fs as ge,Ft as _e,G as ve,Ga as ye,Gc as be,Gi as xe,Gn as Se,Gr as Ce,Gs as we,Gt as Te,Ha as Ee,Hc as De,Hi as Oe,Hn as ke,Ho as Ae,Hr as je,Hs as Me,Ht as Ne,Ii as Pe,In as Fe,Ir as Ie,Is as Le,It as Re,J as ze,Ja as Be,Jc as Ve,Ji as He,Jn as Ue,Jr as We,Js as Ge,Jt as Ke,K as qe,Ka as Je,Kc as Ye,Ki as Xe,Kn as Ze,Kr as Qe,Ks as $e,Kt as et,L as tt,Lc as nt,Li as rt,Ln as it,Lr as at,Ls as ot,Lt as st,M as ct,Ma as lt,Mc as ut,Mi as dt,Mn as ft,Mr as pt,Mt as mt,N as ht,Na as gt,Nc as _t,Ni as vt,Nn as yt,No as bt,Nr as xt,Ns as St,Nt as Ct,O as wt,Oi as Tt,On as Et,Oo as Dt,Or as Ot,Os as kt,Ot as At,P as jt,Pa as Mt,Pc as Nt,Po as Pt,Pr as Ft,Ps as It,Pt as Lt,Q as Rt,Qa as zt,Qc as Bt,Qi as Vt,Qn as Ht,Qr as Ut,Qs as Wt,Qt as Gt,R as Kt,Rc as qt,Ri as Jt,Rn as Yt,Ro as Xt,Rr as Zt,Rs as Qt,Rt as $t,S as en,Sa as tn,Sc as nn,Si as rn,Sn as an,So as I,Sr as on,Ss as eee,T as tee,Ta as sn,Tc as nee,Ti as cn,To as ln,Tr as un,Tt as ree,U as dn,Ua as iee,Uc as fn,Ui as pn,Un as mn,Uo as hn,Ur as gn,Us as _n,Ut as vn,V as yn,Va as aee,Vi as oee,Vn as see,Vo as bn,Vr as xn,Vs as L,Vt as Sn,Wa as Cn,Wc as wn,Wi as Tn,Wn as En,Wo as Dn,Wr as On,Ws as kn,Wt as cee,X as lee,Xa as uee,Xc as An,Xi as jn,Xn as Mn,Xr as Nn,Xs as Pn,Xt as dee,Y as Fn,Ya as In,Yc as Ln,Yi as Rn,Yn as zn,Yr as Bn,Ys as Vn,Yt as Hn,Z as Un,Za as Wn,Zc as Gn,Zi as Kn,Zn as qn,Zr as Jn,Zs as fee,Zt as pee,_ as Yn,_c as Xn,_n as mee,_o as hee,_r as gee,_s as Zn,a as _ee,ac as vee,ai as yee,al as bee,an as xee,ao as Qn,ar as See,at as Cee,ba as $n,bc as er,bn as tr,bo as wee,bt as Tee,c as Eee,ca as nr,cc as Dee,ci as rr,cl as ir,cn as Oee,co as kee,cr as Aee,ct as jee,d as Mee,da as Nee,dc as Pee,di as Fee,dn as Iee,do as ar,dr as or,ds as Lee,dt as sr,ec as cr,ei as lr,el as ur,en as dr,eo as fr,er as pr,es as mr,f as hr,fa as gr,fc as _r,fn as vr,fo as yr,fr as br,ft as xr,g as Sr,ga as Cr,gc as wr,gi as Tr,gn as Er,go as Dr,gr as Or,gs as kr,h as Ar,hi as jr,ho as Mr,hr as Nr,hs as Pr,ic as Fr,ii as Ir,il as Lr,in as Rr,io as zr,ir as Br,ja as Vr,ji as Hr,jn as Ur,jr as Wr,js as Gr,k as Kr,ka as Ree,ki as qr,kn as Jr,kr as zee,ks as Yr,kt as Bee,l as Vee,la as Hee,li as Xr,ll as Zr,ln as Uee,lo as Qr,lr as Wee,lt as Gee,m as Kee,ma as $r,mn as qee,mo as Jee,mr as ei,ms as ti,n as Yee,na as Xee,nc as Zee,ni,nl as Qee,nn as $ee,no as ri,nr as ii,nt as ete,o as tte,oa as ai,oc as nte,oi as rte,ol as oi,on as ite,oo as ate,or as ote,ot as ste,p as cte,pa as lte,pc as ute,pn as si,po as dte,pr as fte,pt as ci,q as pte,qa as mte,qc as hte,qi as gte,qn as _te,qr as li,qs as ui,qt as di,r as vte,rc as yte,ri as fi,rl as pi,rn as mi,rr as hi,sa as gi,sc as bte,si as _i,sl as vi,sn as yi,so as bi,sr as xte,t as xi,tc as Ste,ti as Cte,tl as Si,tn as wte,to as Ci,tr as Tte,tt as Ete,u as wi,ua as Dte,uc as Ti,ui as Ote,un as Ei,uo as kte,ur as Ate,ut as jte,v as Mte,vc as Di,vn as Oi,vo as Nte,vr as ki,vs as Ai,w as ji,wa as Mi,wc as Ni,wi as Pi,wo as Fi,wr as Ii,ws as Li,wt as Ri,x as zi,xa as Bi,xc as Vi,xn as Hi,xo as Ui,xr as Wi,y as Gi,ya as Ki,yc as qi,yi as Ji,yn as Yi,yo as Xi,yr as Zi,ys as Qi,yt as $i,zc as ea,zi as ta,zn as na,zo as ra,zr as ia,zs as aa,zt as oa}from"./shared-eyaskl5l.js";import{C as sa,D as ca,E as la,S as ua,T as da,_ as fa,a as pa,b as ma,d as ha,g as ga,h as _a,l as va,m as ya,o as ba,p as R,r as xa,s as Sa,u as Ca,v as wa,w as Ta,x as Ea,y as z}from"./demo-CXlqlYE4.js";import{i as Da,r as Oa,t as ka}from"./react-CoSyT_xY.js";import{$ as Aa,$n as ja,$r as Ma,$t as Na,A as Pa,An as Fa,Ar as Ia,At as La,B as Ra,Bi as za,Bn as Ba,Bt as Va,C as Ha,Ci as Ua,Cn as Wa,Cr as Ga,Ct as Ka,D as qa,Di as Ja,Dn as Pte,Dr as Ya,Dt as Fte,E as Ite,Ei as Xa,En as Za,Er as Qa,Et as $a,F as eo,Fi as to,Fn as no,Fr as ro,Ft as io,G as ao,Gi as oo,Gn as Lte,Gr as so,Gt as co,H as lo,Hn as uo,Hr as fo,Ht as po,I as mo,Ii as ho,In as go,Ir as _o,It as vo,Ji as yo,Jn as Rte,Jr as bo,Jt as xo,K as So,Ki as Co,Kn as wo,Kr as To,Kt as zte,L as Eo,Li as Bte,Ln as Vte,Lr as Hte,Lt as Ute,M as Do,Mn as Oo,Mr as Wte,Mt as ko,N as Gte,Ni as Ao,Nn as jo,Nr as Kte,Nt as Mo,Oi as No,On as qte,Or as Po,Ot as Fo,Pi as Jte,Pn as Io,Pr as Lo,Pt as Yte,Q as Ro,Qn as Xte,Qr as Zte,Qt as Qte,Ri as zo,Rn as Bo,Rt as Vo,S as Ho,Si as Uo,Sn as Wo,Sr as Go,St as Ko,T as $te,Ti as qo,Tn as ene,Tr as Jo,Tt as Yo,U as tne,Ui as Xo,Un as Zo,Ur as Qo,Ut as $o,V as es,Vi as ts,Vn as ns,Vr as rs,Vt as is,Wi as as,Wn as nne,Wr as os,Wt as rne,X as ss,Xn as ine,Xr as cs,Xt as ls,Yi as us,Yn as ds,Yr as fs,Yt as ane,Z as ps,Zn as ms,Zr as one,Zt as hs,_ as gs,_i as _s,_n as vs,_r as sne,_t as ys,a as bs,ai as xs,an as Ss,ar as cne,at as Cs,b as ws,bi as Ts,bn as Es,br as lne,bt as Ds,c as Os,cn as ks,cr as As,ct as js,d as Ms,di as Ns,dn as Ps,dr as Fs,dt as Is,ei as Ls,en as Rs,er as zs,et as Bs,f as Vs,fi as Hs,fn as Us,fr as Ws,ft as Gs,g as Ks,gi as qs,gn as Js,gr as Ys,gt as Xs,h as Zs,hi as Qs,hn as $s,hr as ec,ht as tc,i as B,ir as nc,it as rc,j as ic,ji as ac,jn as oc,jr as sc,jt as cc,ki as lc,kn as uc,kr as dc,kt as fc,l as pc,li as mc,ln as hc,lr as gc,lt as _c,mi as vc,mn as yc,mr as bc,mt as xc,n as Sc,ni as Cc,nn as wc,nr as Tc,nt as Ec,o as Dc,oi as Oc,on as kc,or as Ac,ot as jc,p as Mc,pi as Nc,pr as Pc,pt as Fc,q as Ic,qi as Lc,qn as Rc,qr as zc,ri as Bc,rn as Vc,rr as Hc,rt as Uc,s as Wc,sr as Gc,st as Kc,t as qc,ti as Jc,tn as Yc,tr as Xc,tt as Zc,u as Qc,un as $c,ur as el,ut as tl,v as nl,vi as rl,vn as il,vr as al,vt as ol,w as sl,wi as cl,wn as ll,wr as ul,wt as dl,x as fl,xi as pl,xn as ml,xr as hl,xt as gl,y as _l,yi as vl,yr as yl,yt as bl,z as xl,zi as Sl,zn as Cl,zr as wl,zt as Tl}from"./icons-BbqDBVjw.js";import{t as El}from"./vendor-BPwPmufs.js";function Dl(e){if(e===R.syncTs)return!0;if(!e.startsWith(vt))return!1;let t=e.slice(vt.length),n=t.indexOf(`.`);return n>0&&`${I.storagePrefix}${t.slice(n+1)}`===R.syncTs}function Ol(e){let t;try{t=JSON.parse(e)}catch{return e}if(!t||typeof t!=`object`||Array.isArray(t))return e;let n={},r=t;for(let[e,t]of Object.entries(r))zi(e)===null&&(n[e]=t);for(let[e,t]of Object.entries(r)){let r=zi(e);r!==null&&!(r in n)&&(n[r]=t)}return JSON.stringify(n)}function kl(e,t){let n=en(e,t);for(let[,t]of n.copied){if(!Dl(t))continue;let n=e.getItem(t);n!==null&&e.setItem(t,Ol(n))}return n}function Al(){try{let e=globalThis.localStorage;if(!e)return;let t=kl(e,Date.now());t.ran&&(t.copied.length||t.kept.length)&&console.info(`[storage] copied ${t.copied.length} keys from an older name, kept ${t.kept.length} newer ones`)}catch{}}function jl(){try{let e=JSON.parse(globalThis.localStorage?.getItem(R.brandStores)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function Ml(e){try{let t=jl();t.includes(e)||globalThis.localStorage?.setItem(R.brandStores,JSON.stringify([...t,e]))}catch{}}var Nl=[`uploads`,`dictations`,`screenlog`,`pulls`];function Pl(e){return new Promise(t=>{try{let n=indexedDB.open(e);n.onupgradeneeded=()=>{try{n.transaction?.abort()}catch{}},n.onsuccess=()=>t(n.result),n.onerror=e=>{e.preventDefault?.(),t(null)},n.onblocked=()=>t(null)}catch{t(null)}})}function Fl(e,t){return new Promise(n=>{try{let r=e.transaction(t,`readonly`),i=r.objectStore(t),a=i.getAllKeys(),o=i.getAll();r.oncomplete=()=>n({keys:a.result,values:o.result}),r.onerror=()=>n(null),r.onabort=()=>n(null)}catch{n(null)}})}function Il(e,t,n,r){return new Promise(i=>{try{let a=e.transaction(t,`readwrite`),o=a.objectStore(t),s=o.getAllKeys();s.onsuccess=()=>{let e=new Set(s.result.map(e=>JSON.stringify(e)));n.forEach((t,n)=>{e.has(JSON.stringify(t))||o.put(r[n],t)})},a.oncomplete=()=>i(!0),a.onerror=()=>i(!1),a.onabort=()=>i(!1)}catch{i(!1)}})}async function une(e,t){let n=`idb:${e.name}`;if(typeof indexedDB>`u`||jl().includes(n))return;let r=!0;for(let n of t){if(n===e.name)continue;let t=await Pl(n);if(t)try{for(let n of Nl){if(!t.objectStoreNames.contains(n)||!e.objectStoreNames.contains(n))continue;let i=await Fl(t,n);i?i.keys.length&&!await Il(e,n,i.keys,i.values)&&(r=!1):r=!1}}finally{t.close()}}r&&Ml(n)}var Ll=e=>`${e}-pulls-v1`,Rl=Ll(I.slug),zl=k.map(e=>Ll(e.slug)),dne=[Rl,...zl],Bl=null;function fne(){return Bl||=(async()=>{let e=`cache:${Rl}`;if(!(typeof caches>`u`||jl().includes(e))){for(let e of zl){if(!await caches.has(e))continue;let t=await caches.open(e),n=await caches.open(Rl);for(let e of await t.keys()){if(await n.match(e))continue;let r=await t.match(e);r&&await n.put(e,r)}}Ml(e)}})().catch(()=>{}),Bl}function Vl(){try{return globalThis.localStorage??null}catch{return null}}function Hl(e){let t=[];for(let n=0;n<e.length;n++){let r=e.key(n);r!=null&&t.push(r)}return t}function pne(e){if(!e)return null;try{let t=JSON.parse(e),n=e=>ta(e)?e:null;if(!t||typeof t!=`object`)return null;let r={from:n(t.from),to:n(t.to)};return ta(t.drop)&&(r.drop=t.drop),t.parked===!0&&(r.parked=!0),r}catch{return null}}function Ul(e){return Xe(e.getItem(R.hosts))??[]}function Wl(e){return Xe(e.getItem(R.hostsGone))??[]}function Gl(e){let t=e.getItem(R.hostActive);return t&&Ul(e).some(e=>e.id===t)?t:null}function Kl(e){let t=e.getItem(R.hostActive);return Ul(e).find(e=>e.id===t)??null}function ql(e,t){for(let n of t){if(n.op===`remove`){e.removeItem(n.key);continue}let t=e.getItem(n.from);t!==null&&e.setItem(n.to,t)}}function mne(e,t,n){for(let r of Hl(e)){let i=fe(r,t);if(!i||ga(i)||n&&e.getItem(i)!==null)continue;let a=e.getItem(r);a!==null&&e.setItem(i,a)}}function Jl(e){let t=pne(e.getItem(R.hostSwitch));if(!t)return e.getItem(R.hostSwitch)!==null&&e.removeItem(R.hostSwitch),!1;let n=Ul(e),r=e.getItem(R.hostActive),i=t.to&&n.some(e=>e.id===t.to)?t.to:null;if(t.from!==null&&r===t.from){let n=He(Hl(e),ga,t.from,i??`-`),r=Tn(i??`-`),a=Tn(t.from),o=e=>e.op===`copy`&&e.from.startsWith(r),s=e=>e.op===`copy`&&!o(e)||e.op===`remove`&&e.key.startsWith(a),c=e=>e.op===`remove`&&!e.key.startsWith(a);t.parked||(ql(e,n.filter(s)),e.setItem(R.hostSwitch,JSON.stringify({...t,parked:!0}))),ql(e,n.filter(c)),i?e.setItem(R.hostActive,i):e.removeItem(R.hostActive),ql(e,n.filter(o))}else(t.from===null||r===i)&&i&&(e.setItem(R.hostActive,i),mne(e,i,t.from===null));if(t.drop&&t.drop!==e.getItem(R.hostActive)){let n=Ul(e),r=n.find(e=>e.id===t.drop);r&&(e.setItem(R.hosts,Rn(n.filter(e=>e.id!==t.drop))),e.setItem(R.hostsGone,Rn([r,...Wl(e).filter(e=>e.id!==r.id)])))}let a=Kl(e);return a?e.setItem(R.hostBase,a.base):e.removeItem(R.hostBase),e.removeItem(R.hostSwitch),!0}function hne(e){if(e)try{Jl(e),bne(e);let t=gte({hosts:e.getItem(R.hosts),active:e.getItem(R.hostActive),hostBase:e.getItem(R.hostBase)});t.writes.hosts!==void 0&&e.setItem(R.hosts,t.writes.hosts),t.writes.active!==void 0&&e.setItem(R.hostActive,t.writes.active),t.writes.hostBase!==void 0&&e.setItem(R.hostBase,t.writes.hostBase)}catch{}}function Yl(e){return!e||!e.base?null:Pe({base:e.base,ssids:e.ssids??[],auto:e.auto===!0})}function Xl(e,t){let n=jn(t.base);if(!n)return{ok:!1,why:`Not an address. Use a host name or IP, optionally with a port.`};let r=Ul(e);if(r.some(e=>e.base===n))return{ok:!1,why:`That address is already in the list.`};let i=Wl(e),a=i.find(e=>e.base===n),o={id:a?.id??oee([...r,...i].map(e=>e.id)),name:Oe(t.name)??a?.name??Jt(n),base:n};a?.legacy&&!r.some(e=>e.legacy)&&(o.legacy=!0);let s=Yl(t.lan);return s&&(o.lan=s),e.setItem(R.hosts,Rn([...r,o])),a&&e.setItem(R.hostsGone,Rn(i.filter(e=>e.id!==a.id))),{ok:!0,host:o,reused:!!a}}function Zl(e,t,n){let r=Ul(e),i=r.findIndex(e=>e.id===t);if(i<0)return{ok:!1,why:`That host is no longer in the list.`};let a=jn(n.base);if(!a)return{ok:!1,why:`Not an address. Use a host name or IP, optionally with a port.`};if(r.some(e=>e.id!==t&&e.base===a))return{ok:!1,why:`Another host already has that address.`};let o=r[i],s={id:t,name:Oe(n.name)??Jt(a),base:a};o.legacy&&(s.legacy=!0);let c=n.lan===void 0?o.lan??null:Yl(n.lan);c&&(s.lan=c);let l=r.slice();return l[i]=s,e.setItem(R.hosts,Rn(l)),e.getItem(R.hostActive)===t&&e.setItem(R.hostBase,a),{ok:!0,host:s,reused:!1}}function gne(e,t){let n=Ul(e);return n.some(e=>e.id===t)?e.getItem(R.hostActive)===t?{kind:`switch`,next:n.find(e=>e.id!==t)?.id??null}:{kind:`drop`}:null}function _ne(e,t){if(e.getItem(R.hostActive)===t)return!1;let n=Ul(e),r=n.find(e=>e.id===t);return r?(e.setItem(R.hosts,Rn(n.filter(e=>e.id!==t))),e.setItem(R.hostsGone,Rn([r,...Wl(e).filter(e=>e.id!==t)])),!0):!1}function Ql(e,t){t.from===`demohost`&&e.removeItem(R.demo),e.setItem(R.hostSwitch,JSON.stringify(t))}function $l(){try{history.replaceState(null,``,location.pathname)}catch{}location.reload()}function eu(e){let t=Vl();if(!t)return!1;let n=t.getItem(R.hostActive);return n===e||!Ul(t).some(t=>t.id===e)?!1:(Ql(t,{from:ta(n)?n:null,to:e}),$l(),!0)}function vne(e){let t=Vl();if(!t)return null;let n=gne(t,e);return n?n.kind===`drop`?_ne(t,e)?`dropped`:null:(Ql(t,{from:e,to:n.next,drop:e}),$l(),`switching`):null}function tu(e){let t=Vl();if(!t)return{ok:!1,why:`This phone's storage is not available.`};let n=Xl(t,e);if(!n.ok)return n;let r=t.getItem(R.hostActive);return Ql(t,{from:ta(r)&&Ul(t).some(e=>e.id===r)?r:null,to:n.host.id}),$l(),n}function nu(){let e=Vl();return e?Ul(e):[]}function ru(){let e=Vl();return e?Kl(e):null}var iu=`demohost`,yne=`http://demo.invalid:8770`;function au(e){return(typeof e==`string`?e:e?.id)===iu}function ou(e){return e.filter(e=>!au(e))}function su(e){let t=ou(Ul(e)),n=e.getItem(R.demoReturn);return t.find(e=>e.id===n)?.id??t[0]?.id??null}function bne(e){if(e.getItem(R.hostActive)===`demohost`&&!e.getItem(R.demo)&&(Ql(e,{from:iu,to:su(e)}),Jl(e)),e.getItem(R.hostActive)===`demohost`)return;e.removeItem(R.demo);let t=Ul(e);t.some(au)&&e.setItem(R.hosts,Rn(ou(t)));let n=Wl(e);n.some(au)&&e.setItem(R.hostsGone,Rn(ou(n)));let r=Tn(iu);for(let t of Hl(e))t.startsWith(r)&&e.removeItem(t)}function xne(e,t){let n=e.getItem(R.hostActive);if(n===`demohost`)return!1;let r=Ul(e);r.some(au)||e.setItem(R.hosts,Rn([...r,{id:iu,name:`Demo`,base:yne}]));let i=ta(n)&&r.some(e=>e.id===n)?n:null;return i?e.setItem(R.demoReturn,i):e.removeItem(R.demoReturn),e.setItem(R.demo,t),Ql(e,{from:i,to:iu}),!0}function Sne(e){e.removeItem(R.demo),e.getItem(R.hostActive)===`demohost`&&Ql(e,{from:iu,to:su(e)})}function Cne(e){let t=Vl();if(!t)return!1;try{globalThis.sessionStorage?.removeItem(ya(e))}catch{}if(!xne(t,e))return!1;try{history.replaceState(null,``,location.pathname)}catch{}return location.reload(),!0}function wne(){let e=Vl();if(!e)return!1;let t=e.getItem(R.demo);try{t&&globalThis.sessionStorage?.removeItem(ya(t))}catch{}Sne(e);try{history.replaceState(null,``,location.pathname)}catch{}return location.reload(),!0}var Tne=I.wsProtocol,Ene=`${I.wsProtocol}-tok.`;function cu(e){return!!e&&/^[A-Za-z0-9_-]{16,256}$/.test(e)}function lu(e){return typeof e==`string`&&cu(e)}function uu(){let e=z(R.deviceToken);return cu(e)?e:null}function Dne(e){cu(e)&&ua(R.deviceToken,e)}function du(){wa(R.deviceToken)}function One(e,t,n){if(!n||!t)return null;try{return new URL(e).origin===new URL(t).origin?`Bearer ${n}`:null}catch{return null}}function kne(e){return e?[Tne,`${Ene}${e}`]:void 0}function fu(e,t){return(e.trim()||t.trim()||`Android phone`).slice(0,60)}var pu=null;function Ane(e){pu=e}function mu(e){try{pu?.(e)}catch{}}var jne=R.hostBase;function hu(){let e=globalThis.Capacitor;try{return!!e?.isNativePlatform?.()}catch{return!1}}var gu,_u=null;function vu(){return gu===void 0&&(gu=null,hu()&&(gu=jn(z(jne)||``))),gu}function yu(){let e=vu();return e===null?null:_u??e}function bu(e){if(!hu()||vu()===null)return _u=null,null;let t=e===null?null:jn(e);return _u=t&&t!==vu()?t:null,yu()}function xu(){return _u}function Mne(){return ha()?!0:!hu()||yu()!==null}function Su(e){return ha()?pa(e):Kn(vu(),e)}function Cu(){if(ha())return ba;let e=yu();return e?Vt(e,`/ws`):hu()?null:`${location.protocol===`https:`?`wss`:`ws`}://${location.host}/ws`}var wu=!1;function Nne(){if(wu||ha()||!yu())return;wu=!0;let e=()=>yu()??``,t=globalThis.fetch.bind(globalThis),n=e=>One(e,yu(),uu()),r=(e,t)=>t?e.then(e=>(e.status===401&&mu(`http`),e)):e,i=(e,t)=>{if(!t)return e;let n=new Headers(e?.headers);return n.has(`authorization`)?e:(n.set(`authorization`,t),{...e,headers:n})};globalThis.fetch=((a,o)=>{if(typeof a!=`string`&&!(a instanceof URL)){let i=Tu(a.url),s=i===null?a:new Request(Kn(e(),i),a),c=n(s.url);if(c&&!s.headers.has(`authorization`))try{s.headers.set(`authorization`,c)}catch{}return r(t(s,o),c)}let s=String(a),c=s.startsWith(`/`)?s:Tu(s);if(c===null){let e=n(s);return r(t(a,i(o,e)),e)}let l=Kn(e(),c);if(l===c&&c===s)return t(a,o);let u=n(l);return r(t(l,i({credentials:`include`,...o},u)),u)});let a=XMLHttpRequest.prototype.open;if(XMLHttpRequest.prototype.open=function(t,r,...i){let o=String(r),s=o.startsWith(`/`)?o:Tu(o),c=s===null?o:Kn(e(),s),l=a.call(this,t,c,...i),u=n(c);if(u)try{this.setRequestHeader(`authorization`,u),this.addEventListener(`load`,()=>{this.status===401&&mu(`http`)},{once:!0})}catch{}return l},Pne(),typeof navigator<`u`&&typeof navigator.sendBeacon==`function`){let e=navigator.sendBeacon.bind(navigator);navigator.sendBeacon=((t,n)=>{let r=String(t),i=r.startsWith(`/`)?r:Tu(r);return e(i===null?r:Kn(vu()??``,i),n)})}}function Pne(){let e=e=>{let t=vu(),n=yu();return!!t&&e.startsWith(t)||!!n&&e.startsWith(n)},t=(t,n,r)=>(n===`src`||n===`poster`)&&(t instanceof HTMLImageElement||t instanceof HTMLVideoElement)&&typeof r==`string`&&e(r);try{let e=Element.prototype.setAttribute;Element.prototype.setAttribute=function(n,r){if(t(this,n,r)&&!this.crossOrigin)try{this.crossOrigin=`anonymous`}catch{}return e.call(this,n,r)};for(let e of[HTMLImageElement.prototype,HTMLVideoElement.prototype]){let n=Object.getOwnPropertyDescriptor(e,`src`);n?.set&&n.get&&Object.defineProperty(e,"src",{configurable:!0,enumerable:n.enumerable,get:n.get,set(e){if(t(this,`src`,e)&&!this.crossOrigin)try{this.crossOrigin=`anonymous`}catch{}n.set.call(this,e)}})}}catch{}}function Tu(e){try{let t=new URL(e,location.href);return t.origin===location.origin?`${t.pathname}${t.search}${t.hash}`:null}catch{return null}}var V=Da(),Fne=[{label:`smaller`,value:.9},{label:`default`,value:1},{label:`larger`,value:1.15},{label:`largest`,value:1.3},{label:`huge`,value:1.45}],Ine=[{label:`smaller`,value:.9},{label:`default`,value:1},{label:`larger`,value:1.2},{label:`largest`,value:1.4}],Lne=.9,Rne=1.45,zne=.9,Bne=1.4;function Eu(e,t,n){let r=Number(e);return e===null||e.trim()===``||!Number.isFinite(r)?1:Math.min(n,Math.max(t,r))}var Vne=[.6,.7,.8,.9,1,1.15,1.3,1.5],Du=.6,Ou=1.5;function ku(e,t){let n=Math.round(13*e*t);return Number.isFinite(n)?Math.min(28,Math.max(7,n)):13}function Au(e,t,n){let r=Vne,i=0;for(let t=1;t<r.length;t++)Math.abs(r[t]-e)<Math.abs(r[i]-e)&&(i=t);let a=n(e);for(let e=i+t;e>=0&&e<r.length;e+=t)if(n(r[e])!==a)return r[e];return null}var Hne=(e,t,n)=>Au(e,t,e=>ku(n,e)),Une=.6,Wne=1.9;function ju(e,t){let n=e*t;return Number.isFinite(n)?Math.round(Math.min(Wne,Math.max(Une,n))*100)/100:1}var Mu=(e,t,n)=>Au(e,t,e=>ju(n,e)),Nu=()=>Eu(z(R.textScale),Lne,Rne),Pu=()=>Eu(z(R.iconScale),zne,Bne),Fu=()=>Eu(z(R.termZoom),Du,Ou),Gne=()=>ku(Nu(),Fu()),Kne=()=>Eu(z(R.readerZoom),Du,Ou),qne=()=>Eu(z(R.scrollZoom),Du,Ou),Jne=()=>Eu(z(R.gitZoom),Du,Ou),Iu=`app:uiscale`;function Lu(){let e=document.documentElement;e.style.setProperty(`--ui-font`,String(Nu())),e.style.setProperty(`--ui-icon`,String(Pu()));try{window.dispatchEvent(new CustomEvent(Iu))}catch{}}function Yne(e){ua(R.textScale,String(e)),Lu()}function Xne(e){ua(R.iconScale,String(e)),Lu()}function Zne(e){ua(R.termZoom,String(e)),Lu()}function Qne(e){ua(R.readerZoom,String(e)),Lu()}function $ne(e){ua(R.scrollZoom,String(e)),Lu()}function ere(e){ua(R.gitZoom,String(e)),Lu()}function tre(){Lu()}function nre(e){return window.addEventListener(Iu,e),()=>window.removeEventListener(Iu,e)}var Ru=`theme-overlay`,zu={},Bu=null,Vu=new Set,Hu=()=>zu,Uu=()=>zu.displayName??I.name;function rre(e){return Vu.add(e),()=>{Vu.delete(e)}}function Wu(e){Bu=e||null;try{document.title=Bu?`${Bu} — ${Uu()}`:Uu()}catch{}}function Gu(e){try{let t=document.getElementById(Ru);if(!e){t?.remove();return}t||(t=document.createElement(`style`),t.id=Ru,document.head.appendChild(t)),t.textContent!==e&&(t.textContent=e)}catch{}}function Ku(e,t=!0){let{overlay:n}=Yee(e),r=tte(n),i=r?{}:n,a=_ee(i);if(Gu(a),t&&(r?(wa(R.themeOverlay),wa(R.themeOverlayCss)):(ua(R.themeOverlay,JSON.stringify(i)),a?ua(R.themeOverlayCss,a):wa(R.themeOverlayCss))),JSON.stringify(i)===JSON.stringify(zu))return!1;zu=i,Wu(Bu);for(let e of Vu)try{e()}catch{}return!0}function ire(){let e=ma(R.themeOverlay,void 0);e===void 0?Gu(``):Ku(e,!1)}async function are(e){try{let t=await e(`/api/theme`);t&&typeof t==`object`&&`overlay`in t&&Ku(t.overlay)}catch{}}var qu=new Map,Ju=new Set,Yu=!1;function Xu(e){let t=qu.get(e);return t||(t={wroteAt:null,ackedAt:null,superseded:!1},qu.set(e,t)),t}function Zu(){for(let e of Ju)e()}function Qu(e){return Ju.add(e),()=>{Ju.delete(e)}}function $u(e,t){let n=Xu(e);n.wroteAt=t,n.superseded=!1,Zu()}function ed(e,t){let n=Xu(e);n.ackedAt!=null&&n.ackedAt>=t||(n.ackedAt=t,n.superseded=!1,Zu())}function td(e,t){let n=Xu(e);n.ackedAt=t,n.superseded=!0,Zu()}function ore(e){Yu!==e&&(Yu=e,Zu())}function nd(e){let t=qu.get(e);if(!t||t.wroteAt==null&&t.ackedAt==null)return{phase:`unknown`,wroteAt:null,ackedAt:null};let n={wroteAt:t.wroteAt,ackedAt:t.ackedAt};return t.superseded?{phase:`superseded`,...n}:t.wroteAt==null||t.ackedAt!=null&&t.ackedAt>=t.wroteAt?{phase:`synced`,...n}:{phase:Yu?`pending`:`offline`,...n}}var rd={failed:5,superseded:4,pending:3,offline:2,synced:1,unknown:0};function sre(e){let t={phase:`unknown`,wroteAt:null,ackedAt:null};for(let n of e){let e=nd(n);rd[e.phase]>rd[t.phase]&&(t=e)}return t}function id(e,t=`these`,n=!0){let r=n?`are`:`is`,i=n?`were`:`was`;switch(e.phase){case`synced`:return`saved on the desktop — ${t} ${r} on more than this phone`;case`pending`:return`not on the desktop yet — ${t} ${r} still only on this phone`;case`offline`:return`no connection — ${t} ${r} only on this phone until the link is back`;case`superseded`:return`another device wrote a newer version — ${t} ${i} replaced, and nothing of yours was deleted`;case`failed`:return`the send gave up — ${t} never reached the desktop, and the words are still here`;default:return null}}function ad(e){return e.failed?`failed`:e.queued?e.online?`pending`:`offline`:e.onHost?`synced`:`unknown`}function od(e){switch(e){case`synced`:return`on desktop`;case`pending`:return`queued`;case`offline`:return`queued · offline`;case`superseded`:return`replaced`;case`failed`:return`not sent`;default:return null}}function sd(e,t=!1){return t&&e===`synced`?null:od(e)}function cre(e){let t=e.filter(e=>e!==`unknown`).length,n=e.filter(e=>e===`synced`).length;if(n===0)return null;let r=od(`synced`),i=n===t,a=i?t===1?`the one row here`:`all ${t} rows here`:`${n} of the ${t} rows here`;return{word:i?r:`${n} of ${t} ${r}`,title:id({phase:`synced`,wroteAt:null,ackedAt:null},a,i?t!==1:n!==1)}}function lre(e){let t=0;for(let n of e){let e=nd(n).phase;(e===`pending`||e===`offline`)&&t++}return t}function ure(e,t,n){return e&&t!==n}function dre(e,t,n){if(t===void 0||!n)return null;let r;try{r=n(t,e)}catch{return null}return typeof r!=`string`||r===e?null:r}var fre=6e4,pre=3e3,mre=864e5,cd=R.netlog,ld=R.deviceId;function ud(e){return{since:e,rtt:[],send:[],reconnects:0,reloads:0,offlineMs:0,markTs:e,online:!1,sent:0,failed:0,expired:0,ackTimeouts:0,queuedMaxMs:0}}function hre(){let e=Date.now(),t={v:2,log:ud(e),sync:{lastSeenAt:0,parts:{sessions:0,repos:0}},traffic:{since:e,up:0,down:0}},n=z(cd);if(!n)return fd(t);let r;try{r=JSON.parse(n)}catch{return t}let i=r;return!i||typeof i!=`object`?t:i.v===2?{v:2,log:dd(i.log??{},e),sync:{lastSeenAt:Number(i.sync?.lastSeenAt)||0,parts:{sessions:Number(i.sync?.parts?.sessions)||0,repos:Number(i.sync?.parts?.repos)||0}},traffic:{since:Number(i.traffic?.since)||e,up:Math.max(0,i.traffic?.up||0),down:Math.max(0,i.traffic?.down||0)}}:fd({...t,log:dd(i,e)})}function dd(e,t){return typeof e.since!=`number`||t-e.since>mre?ud(t):{...ud(t),...e,rtt:Array.isArray(e.rtt)?e.rtt:[],send:Array.isArray(e.send)?e.send:[]}}function fd(e){try{let t=z(R.netSync);if(t){let n=JSON.parse(t);n&&typeof n.lastSeenAt==`number`&&(e.sync={lastSeenAt:n.lastSeenAt,parts:{sessions:Number(n.parts?.sessions)||0,repos:Number(n.parts?.repos)||0}}),wa(R.netSync)}}catch{}try{let t=z(R.netTraffic);if(t){let n=JSON.parse(t);n&&typeof n.since==`number`&&(e.traffic={since:n.since,up:Math.max(0,n.up|0),down:Math.max(0,n.down|0)}),wa(R.netTraffic)}}catch{}return e}var pd=hre(),md=null;function hd(){md??=window.setTimeout(()=>{md=null,Ta(cd,pd)},pre)}function gd(){md!=null&&(window.clearTimeout(md),md=null),Ta(cd,pd)}var _d=new Set;function vd(...e){for(let t of e)_d.add(t)}var yd=new Set,bd=null;function gre(e){bd=e}function xd(){if(!yd.size||!bd)return;let e=bd();for(let t of yd)t.fn(e)}var _re=12e4,Sd={},Cd=null,wd=`default`,Td=new Set;function Ed(e){Sd=e;for(let e of Td)e()}function vre(e){return Td.add(e),()=>{Td.delete(e)}}function Dd(){return Sd}function yre(e=Date.now(),t){let n=ma(R.hostBoots,{})[wd]?.usualMs;Ed({since:e,usualMs:n,...t?{reason:t}:{}})}function bre(e=Date.now()){Cd??=e}function xre(e,t=Date.now()){wd=e.hostId??`default`;let n=ma(R.hostBoots,{}),r=n[wd],i=Sd.since??Cd??void 0,a=Sd.since!=null;if(Cd=null,!r||r.bootId===e.bootId)return r||(n[wd]={bootId:e.bootId},Ta(R.hostBoots,n)),Sd.since!=null&&Ed({}),null;if(i==null)return n[wd]={...r,bootId:e.bootId},Ta(R.hostBoots,n),null;let o=Math.max(0,t-i),s=e.startedAt!=null&&e.readyAt!=null?Math.max(0,e.readyAt-e.startedAt):void 0;return n[wd]={bootId:e.bootId,usualMs:o},Ta(R.hostBoots,n),Ed({back:{at:t,downMs:o,announced:a,reattachMs:s,...Sd.reason?{reason:Sd.reason}:{}}}),{downMs:o,announced:a}}function Od(e){let t=Math.round(e/1e3);return t<90?`${t} s`:`${Math.round(t/60)} min`}function Sre(e,t){if(e.since!=null){let n=t-e.since,r=e.usualMs==null?``:` · usually ~${Od(e.usualMs)}`,i=n>(e.usualMs==null?_re:e.usualMs*3),a=e.reason?` (${e.reason})`:``;return{text:i?`desktop restarting${a} ${Od(n)} — longer than usual, it may have failed to start`:`desktop restarting${a} · ${Od(n)}${r}`,slow:i}}if(e.back&&t-e.back.at<12e4){let t=e.back.downMs==null?``:` after ${Od(e.back.downMs)}`;return{text:e.back.announced?`desktop restarted${e.back.reason?` (${e.back.reason})`:``} — back${t}`:`desktop restarted unannounced (crash?) — back${t}`,slow:!e.back.announced}}return null}var kd=null,Ad=`connecting`;function jd(e){if(e===Ad)return;let t=Ad;Ad=e;let n=Date.now();t===`open`&&bre(n),pd.log.online||(pd.log.offlineMs+=Math.max(0,n-pd.log.markTs)),pd.log.markTs=n,pd.log.online=e===`open`,ore(e===`open`),e===`closed`&&pd.log.reconnects++,e===`open`?(kd=n,pd.sync.lastSeenAt=n):kd=null,t===`open`||e===`open`?gd():hd(),vd(`status`),xd()}function Md(){return Ad===`open`}var Nd=500,Pd=10,Cre=Nd*Pd,Fd=Array.from({length:Pd},()=>({slot:-1,up:0,down:0})),wre=Date.now();function Id(e,t){if(!Number.isFinite(t)||t<=0)return;let n=Math.round(t);e===`up`?pd.traffic.up+=n:pd.traffic.down+=n;let r=Math.floor(Date.now()/Nd),i=Fd[r%Pd];i.slot!==r&&(i.slot=r,i.up=0,i.down=0),e===`up`?i.up+=n:i.down+=n,hd()}function Tre(e){let t=Math.floor(e/Nd),n=t-9,r=0,i=0;for(let e of Fd)e.slot<n||e.slot>t||(r+=e.up,i+=e.down);let a=Math.max(1e3,Math.min(Cre,e-wre));return{up:r*1e3/a,down:i*1e3/a}}function Ere(){let e=Tre(Date.now());return{since:pd.traffic.since,up:pd.traffic.up,down:pd.traffic.down,upRate:e.up,downRate:e.down}}function Ld(e){return e<1024?`${Math.round(e)} B`:e<1048576?`${Math.round(e/1024)} kB`:e<1073741824?`${(e/1024/1024).toFixed(+(e<10485760))} MB`:`${(e/1024/1024/1024).toFixed(2)} GB`}function Rd(e){return!Number.isFinite(e)||e<1024?null:e<1048576?`${Math.round(e/1024)} kB/s`:`${(e/1024/1024).toFixed(1)} MB/s`}var Dre=class{seq=0;wires=new Map;ring=[];page;deps;constructor(e,t){this.deps=e,this.page=t??e.now().toString(36)}inflight(){return this.wires.size}begin(e,t,n){let r={id:++this.seq,label:e,method:t.toUpperCase(),via:n,started:this.deps.now(),timer:null};this.wires.set(r.id,r),r.timer=this.deps.setTimer(()=>{this.wires.has(r.id)&&(r.snap=this.snapshot(r))},ia);let i=!1;return{progress:(e,t)=>{r.sent=e,t!=null&&(r.total=t)},end:({answered:e,fuseMs:t})=>{if(i)return;i=!0,this.deps.clearTimer(r.timer);let n=Math.max(0,this.deps.now()-r.started),a=S({ageMs:n,fuseFired:t!=null,answered:e}),o=a?r.snap??this.snapshot(r):null;if(this.wires.delete(r.id),!a||!o)return;let s={k:`${this.page}.${r.id}`,label:r.label,method:r.method,ageMs:n,outcome:a,...o};t!=null&&(s.fuseMs=t),r.sent!=null&&(s.sent=r.sent,r.total!=null&&(s.total=r.total)),this.add(s)}}}bodyTimeout(e,t,n){let r={k:`${this.page}.b${++this.seq}`,label:e,method:t.toUpperCase(),phase:`body`,ageMs:n,fuseMs:n,outcome:`timeout`,via:`fetch`,...this.snapshot(null)};this.add(r)}openStalls(){let e=this.deps.now(),t=[];for(let n of this.oldestFirst()){let r=e-n.started;if(r<12e3)continue;let i={k:`${this.page}.${n.id}`,label:n.label,method:n.method,ageMs:r,outcome:`open`,...n.snap??this.snapshot(n)};n.sent!=null&&(i.sent=n.sent,n.total!=null&&(i.total=n.total)),t.push(i)}return t}report(){return{events:this.ring.slice(),open:this.openStalls()}}add(e){xn(this.ring,e,50),this.deps.changed()}oldestFirst(){return[...this.wires.values()].sort((e,t)=>e.started-t.started)}snapshot(e){let t=this.deps.now(),n=this.oldestFirst().filter(t=>t!==e).slice(0,8).map(e=>({label:e.label,ageMs:Math.max(0,t-e.started)})),r=this.deps.context(),i={at:t,via:e?.via??`fetch`,inflight:this.wires.size};return n.length&&(i.peers=n),r.ws&&(i.ws=r.ws),r.visible!=null&&(i.visible=r.visible),r.visForMs!=null&&(i.visForMs=r.visForMs),r.online!=null&&(i.online=r.online),i}},Ore=0,zd=[];function kre(e){let t={id:++Ore,label:e,started:Date.now()};zd.push(t),vd(`ops`),xd();let n=!1;return()=>{if(n)return;n=!0;let e=zd.findIndex(e=>e.id===t.id);e>=0&&zd.splice(e,1),vd(`ops`),xd()}}function Bd(e,t=`GET`){let n=e.split(`?`)[0],r=t!==`GET`;return n.includes(`/artifacts`)||n.includes(`/api/search`)?`loading files`:n.includes(`/inbox/seen`)?`marking inbox read`:n.includes(`/inbox`)?r?`uploading`:`loading inbox`:n.includes(`/artifact`)?r?`deleting file`:`loading file`:n.includes(`/git/status`)?`reading git status`:n.includes(`/git/diff`)?`loading diff`:n.includes(`/git/blob`)?`loading the picture`:n.includes(`/git/text`)?`loading the file`:n.includes(`/git/branches`)?`loading branches`:n.includes(`/git/commit`)?`committing`:n.includes(`/git/push`)?`pushing`:n.includes(`/git/pull`)?`pulling`:n.includes(`/git/checkout`)?`switching branch`:n.includes(`/git/branch`)?`updating branches`:n.includes(`/git/stage`)?`staging`:n.includes(`/compliance`)?r?`applying fixes`:`checking repo setup`:n.includes(`/api/slash`)?`loading commands`:n.includes(`/api/repos`)?`loading repos`:n.includes(`/api/external`)?`looking for sessions`:n.includes(`/api/worktree`)?`creating worktree`:n.includes(`/api/project`)?`creating project`:n.includes(`/api/folder`)?`creating folder`:n.includes(`/api/secret`)?r?`setting secret`:`loading targets`:n.includes(`/api/envfiles`)?`loading env files`:n.includes(`/api/host/screenshot`)?`capturing screen`:n.includes(`/api/host/clipboard`)?`copying to host`:n.includes(`/api/host/stat`)?`reading host load`:n.includes(`/api/auth`)?`signing in`:n.includes(`/api/ui-usage`)?`loading usage`:r?`sending`:`loading`}var Vd=null,Hd=null;function Are(e){Vd=Date.now(),Hd=Math.round(e)}var Ud=null;try{document.addEventListener(`visibilitychange`,()=>{Ud=Date.now()})}catch{}function jre(){let e=Date.now(),t={},n={open:Ad===`open`};Vd!=null&&(n.pongAgeMs=Math.max(0,e-Vd)),Hd!=null&&(n.rttMs=Hd),t.ws=n;try{t.visible=document.visibilityState===`visible`}catch{}Ud!=null&&(t.visForMs=Math.max(0,e-Ud));try{typeof navigator.onLine==`boolean`&&(t.online=navigator.onLine)}catch{}return t}var Wd=new Dre({now:()=>Date.now(),context:jre,setTimer:(e,t)=>setTimeout(e,t),clearTimer:e=>clearTimeout(e),changed:()=>af()});function Gd(e,t,n){return Wd.begin(Bd(e,t),t,n)}function Mre(e,t,n){Wd.bodyTimeout(Bd(e,t),t,n)}function Kd(e){let t=e;return t&&t.name===`TimeoutError`&&typeof t.ms==`number`?t.ms:void 0}var qd=new WeakMap;function Jd(e,t){let n=Kd(t);n!=null&&qd.set(e,n),e.abort()}var Yd=new WeakMap;function Xd(){try{let e=globalThis.fetch.bind(globalThis);globalThis.fetch=(async(t,n)=>{let r=typeof Request<`u`&&t instanceof Request?t:null,i=Gd(typeof t==`string`?t:t instanceof URL?t.href:r?.url??``,n?.method??r?.method??`GET`,`fetch`);try{let r=await e(t,n);return i.end({answered:!0}),r}catch(e){throw i.end({answered:!1,fuseMs:n?.signal?.aborted?Kd(n.signal.reason):void 0}),e}})}catch{}try{let e=XMLHttpRequest.prototype,t=e.open;e.open=function(e,n,...r){return Yd.set(this,{method:String(e||`GET`),url:String(n)}),t.call(this,e,n,...r)};let n=e.send;e.send=function(e){let t=Yd.get(this),r=Gd(t?.url??``,t?.method??`GET`,`xhr`),i=typeof Blob<`u`&&e instanceof Blob?e.size:void 0;i&&r.progress(0,i);try{this.upload?.addEventListener(`progress`,e=>r.progress(e.loaded,e.lengthComputable?e.total:i)),this.addEventListener(`loadend`,()=>r.end({answered:this.status>0,fuseMs:qd.get(this)}))}catch{r.end({answered:!1})}return n.call(this,e)}}catch{}}var Zd=null,Qd=null,$d=``,ef=null,tf=15e3;function nf(){return Wd.openStalls().map(e=>e.k).join(`,`)}function rf(e=!1){if(!Zd||Zd.status!==`open`||!Qd)return;let t=Qd();if(!t||t===`unknown`)return;let n=`${Wd.ring.length}:${Wd.ring[Wd.ring.length-1]?.k??``}|${nf()}`;(e||n!==$d)&&(Zd.send({t:`net.stalls`,deviceId:t,report:Wd.report()}),$d=n)}function af(){ef||=setTimeout(()=>{ef=null,rf()},1e3)}function of(e,t){Zd||(Zd=e,Qd=t,e.on(e=>{e.t===`welcome`&&($d=``,rf(!0))}),setInterval(()=>rf(),tf))}function sf(e,t){!Number.isFinite(t)||t<0||(e.push(Math.round(t)),e.length>200&&e.splice(0,e.length-200))}function cf(e,t){if(!e.length)return;let n=[...e].sort((e,t)=>e-t);return n[Math.min(n.length-1,Math.floor((n.length-1)*t))]}function lf(){let e=z(ld);if(e)return e;try{let e=new Uint8Array(6);crypto.getRandomValues(e);let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return ua(ld,t),t}catch{return`unknown`}}function uf(e){sf(pd.log.rtt,e),Are(e),hd()}function df(){pd.log.reloads++,gd()}function ff(e){pd.log.sent++,sf(pd.log.send,e),pd.log.queuedMaxMs=Math.max(pd.log.queuedMaxMs,Math.round(e)),hd(),vd(`log`)}function pf(){pd.log.failed++,hd(),vd(`log`)}function mf(){pd.log.expired++,hd(),vd(`log`)}function hf(){pd.log.ackTimeouts++,hd(),vd(`log`)}function gf(){let e=Date.now(),t=pd.log.online?0:Math.max(0,e-pd.log.markTs),n=Math.max(1,e-pd.log.since);return{since:pd.log.since,rttP50:cf(pd.log.rtt,.5),rttP95:cf(pd.log.rtt,.95),reconnects:pd.log.reconnects,reloads:pd.log.reloads,offlineShare:Math.min(1,(pd.log.offlineMs+t)/n),sendP50:cf(pd.log.send,.5),sendP95:cf(pd.log.send,.95),sent:pd.log.sent,failed:pd.log.failed,expired:pd.log.expired,ackTimeouts:pd.log.ackTimeouts,queuedMaxMs:pd.log.queuedMaxMs,ua:navigator.userAgent.slice(0,120)}}function _f(){return pd.log.rtt.length<4?null:cf(pd.log.rtt,.95)??null}function vf(){pd.log=ud(Date.now()),pd.log.online=Ad===`open`,pd.traffic={since:Date.now(),up:0,down:0};for(let e of Fd)e.slot=-1,e.up=0,e.down=0;gd(),vd(`log`,`traffic`),xd()}var yf=0;function bf(e){let t=Math.max(0,e|0);t!==yf&&(yf=t,vd(`sends`),xd())}var xf=0,Sf=!1;function Cf(e){let t=Math.max(0,e|0);t!==xf&&(xf=t,t>0&&(Sf=!0),vd(`sends`),xd())}async function wf(e,t,n){let r=kre(Bd(e,t?.method??`GET`));try{return await li(e,t,n)}finally{r()}}function Tf(e,t,n=je,r=`GET`){let i,a=new Promise((e,a)=>{i=setTimeout(()=>{Mre(t,r,n),a(new Ce(t,n))},n)});return Promise.race([e.json(),a]).finally(()=>clearTimeout(i))}async function Ef(e,t,n){let r=await wf(e,n?{signal:n}:void 0,t);if(!r.ok)throw Error(`${r.status} ${e}`);return Tf(r,e,t)}async function Df(e,t,n){let r=await wf(e,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)},n);if(!r.ok){let e=`${r.status}`;try{let t=await r.json(),n=typeof t.message==`string`?t.message:typeof t.error==`string`?t.error:null;n&&(e=`${r.status} ${n}`)}catch{}throw Error(e)}return Tf(r,e,n,`POST`)}async function Of(e,t,n){return Tf(await wf(e,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)},n),e,n,`POST`)}async function kf(e){await wf(e,{method:`DELETE`})}async function Af(e,t,n){if(!e.body)return e.blob();let r=Number(e.headers.get(`content-length`)||0),i=e.body.getReader(),a=[],o=0;for(;;){let s,c=new Promise((n,a)=>{s=setTimeout(()=>{let n=new Ce(e.url,t);n.message=`stalled — no bytes for ${Math.round(t/1e3)}s after ${un(o)}${r?` of ${un(r)}`:``}`,a(n),i.cancel().catch(()=>{})},t)});try{let{done:e,value:t}=await Promise.race([i.read(),c]);if(e)break;a.push(t),o+=t.byteLength,n?.(o,r)}finally{clearTimeout(s)}}return new Blob(a,{type:e.headers.get(`content-type`)||``})}async function jf(e,t){return JSON.parse(await(await Af(e,t)).text())}var Mf={repos:()=>Ef(`/api/repos`).then(e=>e.targets),slash:(e,t)=>Ef(`/api/slash?cwd=${encodeURIComponent(e)}${t?`&backend=${encodeURIComponent(t)}`:``}`),external:()=>Ef(`/api/external`).then(e=>e.sessions),transcript:async(e,t,n=`lite`)=>{let r=new URLSearchParams({id:e});t&&r.set(`since`,String(t)),n===`full`&&r.set(`detail`,`full`);let i=await li(`/api/transcript?${r}`,void 0,On);if(i.status===204)return null;if(!i.ok)throw Error(`${i.status} transcript`);return jf(i,On)},scrollback:async e=>{let t=await wf(`/api/scrollback?id=${encodeURIComponent(e)}`,void 0,On);if(!t.ok)throw Error(`${t.status} scrollback`);let n=await jf(t,On);return{lines:n.lines??[],history:!!n.history,bounded:!!n.bounded,at:n.at??Date.now()}},transcriptTools:async(e,t)=>{let n=new URLSearchParams({id:e,turn:t}),r=await li(`/api/transcript/tools?${n}`,void 0,On);if(!r.ok)throw Error(`${r.status} tool details`);return(await jf(r,12e3)).tools??{}},shellDetail:async(e,t)=>{let n=new URLSearchParams({id:e,pid:String(t)}),r=await li(`/api/shell?${n}`,void 0,On);if(!r.ok){let e=await r.json().catch(()=>({}));throw Error(e.error||`${r.status} shell`)}return jf(r,On)},contextSeries:async(e,t)=>{let n=new URLSearchParams({id:e});t&&n.set(`since`,String(t));let r=await wf(`/api/context?${n}`,void 0,On);if(r.status===204)return null;if(!r.ok)throw Error(`${r.status} context series`);return jf(r,On)}},Nf={tokenStats:(e=!1)=>Ef(`/api/tokenstats${e?`?fresh=1`:``}`,gn),localUsage:()=>Ef(`/api/localusage`),peerJobs:()=>Ef(`/api/peerjobs`).then(e=>Array.isArray(e?.jobs)?e.jobs:[]),backendTokens:(e,t=!1)=>Ef(`/api/tokenstats/${encodeURIComponent(e)}${t?`?fresh=1`:``}`,gn),usageLog:(e=0)=>Ef(`/api/usagelog${e>0?`?hours=${e}`:``}`),usageLogSource:e=>Ef(`/api/usagelog/${encodeURIComponent(e)}`),tokenWindows:(e,t=!1)=>Ef(`/api/tokenwindows?${e.map(e=>`w=${encodeURIComponent(`${e.id}:${Math.round(e.anchor)}:${Math.round(e.lenMs)}`)}`).join(`&`)}${t?`&fresh=1`:``}`,gn),costWindow:(e,t,n=!1)=>Ef(`/api/costwindow?from=${Math.round(e)}&to=${Math.round(t)}${n?`&fresh=1`:``}`,gn)},Pf={inbox:(e,t)=>Ef(`/api/repos/${e}/inbox`,void 0,t).then(e=>e.files),markInboxSeen:e=>fetch(`/api/repos/${e}/inbox/seen`,{method:`POST`}).catch(()=>void 0),markOutboxSeen:e=>fetch(`/api/repos/${e}/artifacts/seen`,{method:`POST`}).catch(()=>void 0),artifacts:(e,t,n,r)=>{let i=new URLSearchParams({scope:t});return n&&i.set(`since`,String(n)),r?.query&&i.set(`q`,r.query),r?.kind&&r.kind!==`all`&&i.set(`kind`,r.kind),r?.limit&&i.set(`limit`,String(r.limit)),Ef(`/api/repos/${e}/artifacts?${i}`,void 0,r?.signal)},search:e=>{let t=new URLSearchParams({scope:e.scope??`repo`});return e.query&&t.set(`q`,e.query),e.kind&&e.kind!==`all`&&t.set(`kind`,e.kind),e.sinceSeconds&&t.set(`since`,String(e.sinceSeconds)),e.repoIds?.length&&t.set(`repos`,e.repoIds.join(`,`)),e.limit&&t.set(`limit`,String(e.limit)),Ef(`/api/search?${t}`,void 0,e.signal)},uploadInbox:(e,t,n,r,i,a)=>new Promise((o,s)=>{let c=new XMLHttpRequest;c.open(`POST`,`/api/repos/${e}/inbox`),c.setRequestHeader(`x-file-name`,encodeURIComponent(n)),a&&c.setRequestHeader(`x-dedupe`,`1`),c.setRequestHeader(`content-type`,t.type||`application/octet-stream`),c.withCredentials=!0,i&&(c.upload.onprogress=e=>i(e.loaded,e.lengthComputable?e.total:t.size));let l=()=>Jd(c,r?.reason);r?.addEventListener(`abort`,l,{once:!0});let u=()=>r?.removeEventListener(`abort`,l);c.onload=()=>{if(u(),c.status<200||c.status>299){let e=Error(`upload failed (${c.status})`);e.permanent=c.status===413||c.status===415,e.responded=!0,s(e)}else try{o(JSON.parse(c.responseText))}catch{let e=Error(`upload failed (${c.status})`);e.responded=!0,s(e)}},c.onerror=()=>{u(),s(Error(`upload failed`))},c.onabort=()=>{u(),s(new DOMException(`aborted`,`AbortError`))},c.send(t)}),fileBlob:e=>wf(e).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.blob()}),deleteInbox:(e,t)=>wf(`/api/repos/${e}/inbox/${encodeURIComponent(t)}`,{method:`DELETE`}).then(e=>e.json()),deleteArtifact:(e,t)=>wf(`/api/repos/${e}/artifact?path=${encodeURIComponent(t)}`,{method:`DELETE`}).then(e=>e.json()),sweepPlan:(e,t)=>wf(`/api/repos/${e}/sweep?scope=${t}`).then(e=>e.json()),sweepRun:(e,t)=>Of(`/api/repos/${e}/sweep`,{paths:t}),transportSurvey:()=>wf(`/api/storage/transport`).then(e=>e.json()),appReadiness:()=>wf(`/api/apps/readiness`).then(e=>e.json()),hostStore:()=>wf(`/api/storage/host`).then(e=>e.json()),hostStoreClear:(e,t)=>Of(`/api/storage/host/clear`,{store:e,at:t})},Ff={newFolder:(e,t)=>Of(`/api/folder`,{parent:e,name:t}),newRepo:(e,t,n={})=>Of(`/api/repo`,{parent:e,name:t,setup:n.setup!==!1,description:n.description}),cloneRepo:(e,t,n)=>Of(`/api/clone`,{parent:e,url:t,name:n||void 0}),onboardPlan:e=>{let t=new URLSearchParams({name:e.name,path:e.path});return e.description&&t.set(`description`,e.description),e.setup===!1&&t.set(`setup`,`0`),Ef(`/api/onboard/plan?${t}`)},onboardJob:()=>Ef(`/api/onboard`),onboardStart:(e,t,n)=>Of(`/api/onboard`,{answers:e,consent:t,confirm:n}),onboardResume:(e,t)=>Of(`/api/onboard/resume`,e?{consent:e,confirm:t}:{}),newWorktree:(e,t)=>Of(`/api/worktree`,{repoId:e,branch:t}),worktreeLeftover:e=>Ef(`/api/repos/${e}/worktree/leftover`),removeWorktree:e=>Of(`/api/repos/${e}/worktree/remove`,{}),artifactUrl:(e,t)=>Su(`/api/repos/${e}/artifact?path=${encodeURIComponent(t)}`),inboxUrl:(e,t)=>Su(`/api/repos/${e}/inbox/${encodeURIComponent(t)}`)};async function If(e,t,n,r,i=gn){let a=new URLSearchParams({path:t,side:n});r&&a.set(`staged`,`1`);let o=await wf(`${e}?${a}`,void 0,i);if(o.status===404)return null;if(o.ok)return o;let s=await o.json().catch(()=>null);throw Error(s?.error||`the desktop answered ${o.status}`)}var Lf=2e4,Rf={gitStatus:e=>Ef(`/api/repos/${e}/git/status`),gitDiff:(e,t,n)=>{let r=new URLSearchParams;return t&&r.set(`path`,t),n&&r.set(`staged`,`1`),Ef(`/api/repos/${e}/git/diff?${r}`).then(e=>e.diff)},gitBlob:async(e,t,n,r,i)=>{let a=await If(`/api/repos/${e}/git/blob`,t,n,r,je);return a?Af(a,Lf,i):null},gitText:async(e,t,n,r)=>(await If(`/api/repos/${e}/git/text`,t,n,r))?.json(),gitStage:(e,t,n)=>Of(`/api/repos/${e}/git/stage`,{path:t,unstage:n}),gitCommit:(e,t,n=!0)=>Of(`/api/repos/${e}/git/commit`,{message:t,all:n},gn),gitMessage:e=>Of(`/api/repos/${e}/git/message`,{},gn),gitLog:e=>Ef(`/api/repos/${e}/git/log`),gitShow:(e,t)=>Ef(`/api/repos/${e}/git/show?${new URLSearchParams({sha:t})}`).then(e=>e.body),gitFetch:e=>Of(`/api/repos/${e}/git/fetch`,{},gn),gitPull:e=>Of(`/api/repos/${e}/git/pull`,{},gn),gitPush:e=>Df(`/api/repos/${e}/git/push`,{background:!0}),gitPushState:e=>Ef(`/api/repos/${e}/git/push`).then(e=>e.push)},zf={archive:(e,t={})=>{let n=new URLSearchParams;return t.offset&&n.set(`offset`,String(t.offset)),t.limit&&n.set(`limit`,String(t.limit)),t.q&&n.set(`q`,t.q),t.bookmarked&&n.set(`bookmarked`,`1`),Ef(`/api/repos/${e}/archive?${n}`,gn)},archiveDelete:async(e,t)=>(await wf(`/api/repos/${e}/archive?id=${encodeURIComponent(t)}`,{method:`DELETE`})).json(),conversations:async(e,t,n={},r)=>{let i=await wf(`/api/conversations?${new URLSearchParams({backend:e,cwd:t,...n.offset?{offset:String(n.offset)}:{},...n.limit?{limit:String(n.limit)}:{},...n.q?{q:n.q}:{}})}`,r?{signal:r}:void 0,gn);if(i.ok)return jf(i,gn);let a=await jf(i,gn).catch(()=>({error:void 0}));throw Error(typeof a.error==`string`&&a.error?a.error:`${i.status}`)},conversationsDelete:async(e,t,n)=>(await wf(`/api/conversations?${new URLSearchParams({backend:e,cwd:t,id:n})}`,{method:`DELETE`})).json(),bookmarkSet:async(e,t,n={})=>(await wf(`/api/repos/${e}/archive/bookmark`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({id:t,...n})})).json(),bookmarkRemove:async(e,t)=>(await wf(`/api/repos/${e}/archive/bookmark?id=${encodeURIComponent(t)}`,{method:`DELETE`})).json(),archivedTranscript:async(e,t,n,r=`lite`)=>{let i=new URLSearchParams({conv:t});n&&i.set(`since`,String(n)),r===`full`&&i.set(`detail`,`full`);let a=await li(`/api/repos/${e}/archive/transcript?${i}`,void 0,On);if(a.status===204)return null;if(!a.ok)throw Error(`${a.status} transcript`);return jf(a,On)},archivedToolDetails:async(e,t,n)=>{let r=new URLSearchParams({conv:t,turn:n}),i=await li(`/api/repos/${e}/archive/transcript/tools?${r}`,void 0,On);if(!i.ok)throw Error(`${i.status} tool details`);return(await jf(i,12e3)).tools??{}},tree:(e,t=``,n)=>{let r=new URLSearchParams;return t&&r.set(`path`,t),n&&r.set(`q`,n),Ef(`/api/repos/${e}/tree?${r}`)},treeFile:(e,t)=>Ef(`/api/repos/${e}/tree/file?path=${encodeURIComponent(t)}`),treeWrite:async(e,t,n,r)=>(await wf(`/api/repos/${e}/tree/file`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({path:t,body:n,baseSha:r})},gn)).json()};function Bf(e){let t=Array.isArray(e?.rows)?e.rows:[];return{...e,rows:t.map(Hn).filter(e=>!!e)}}var Vf={gitBranches:e=>Ef(`/api/repos/${e}/git/branches`).then(e=>e.branches),gitCheckout:(e,t)=>Of(`/api/repos/${e}/git/checkout`,{branch:t},gn),gitCreateBranch:(e,t,n)=>Of(`/api/repos/${e}/git/branch`,{name:t,...n}),gitDeleteBranch:(e,t,n=!1)=>wf(`/api/repos/${e}/git/branch`,{method:`DELETE`,headers:{"content-type":`application/json`},body:JSON.stringify({name:t,force:n})}).then(e=>e.json()),envFiles:e=>Ef(`/api/repos/${e}/envfiles`).then(e=>e.files),secretTargets:()=>Ef(`/api/secret/targets`).then(e=>e.targets),setSecret:e=>Of(`/api/secret`,e),compliance:e=>Ef(`/api/repos/${e}/compliance`),complianceFix:(e,t,n)=>Of(`/api/repos/${e}/compliance/fix`,n?{fixes:t,confirm:n}:{fixes:t}),complianceLimits:(e,t)=>Of(`/api/repos/${e}/compliance/limits`,t),complianceIgnore:(e,t,n)=>Of(`/api/repos/${e}/compliance/ignore`,{id:t,ignore:n}),optIns:e=>Ef(`/api/repos/${e}/optins`).then(Bf),optInChoice:(e,t,n)=>Of(`/api/repos/${e}/optins/choice`,{id:t,choice:n}).then(e=>e.report?{...e,report:Bf(e.report)}:e),hostSetup:()=>Ef(`/api/host/setup`),hostSetupFix:e=>Of(`/api/host/setup/fix`,{fixes:e}),setupPrefs:()=>Ef(`/api/host/setupprefs`),setSetupPrefs:e=>Of(`/api/host/setupprefs`,{autoCompactDefault:e}),repoHealth:(e,t)=>Ef(`/api/repos/${e}/repohealth${t?`?scope=${encodeURIComponent(t)}`:``}`),healthIndex:e=>Ef(`/api/repos/${e}/healthindex`),repoHealthScopes:(e,t)=>Of(`/api/repos/${e}/repohealth/scopes`,{scopes:t}),repoHealthRefresh:(e,t,n,r)=>Of(`/api/repos/${e}/repohealth/refresh`,{...t?{scope:t}:{},...n?{approveEngine:!0,...r?{approveToken:r}:{}}:{}},2e5)},Hf={askRules:()=>wf(`/api/askrules`).then(Wf),setAskRules:(e,t)=>wf(`/api/askrules`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({rules:e,rev:t.rev,confirm:t.confirm})}).then(Wf)},Uf=class extends Error{reread;constructor(e,t){super(e),this.reread=t}};async function Wf(e){let t=null;try{t=await e.json()}catch{}if(e.ok&&t?.ok)return t;throw new Uf(typeof t?.error==`string`?t.error:`${e.status} /api/askrules`,e.status===409||e.status===403)}var Gf={...Hf,rootInfo:()=>Ef(`/api/host/root`),checkRoot:e=>Of(`/api/host/root`,{path:e}),saveRoot:e=>Of(`/api/host/root`,{path:e,save:!0}),hostStat:()=>Ef(`/api/host/stat`),screenshot:async e=>(await wf(`/api/host/screenshot?repo=${encodeURIComponent(e)}`,{method:`POST`})).json(),ocrStatus:async()=>{try{let e=await wf(`/api/host/ocr`);return e.ok?await e.json():{available:!1,reason:`this desktop is running an older host`}}catch{return{available:!1,reason:`the host could not be reached`}}},ocrImage:async e=>{try{let t=await wf(`/api/host/ocr`,{method:`POST`,headers:{"content-type":e.type||`image/jpeg`},body:e},12e4);return t.status===404?{error:`this desktop is running an older host — update it to read pictures on-device`}:await t.json()}catch{return{error:`the host could not be reached`}}},dictateStatus:async()=>{try{let e=await wf(`/api/host/dictate`);return e.ok?await e.json():{available:!1,reason:`this desktop is running an older host`}}catch{return{available:!1,reason:`the host could not be reached`}}},dictate:(e,t={})=>new Promise((n,r)=>{let{lang:i,terms:a,signal:o,onProgress:s}=t,c=new XMLHttpRequest,l=new URLSearchParams;i&&l.set(`lang`,i),a&&l.set(`terms`,a);let u=l.toString();c.open(`POST`,`/api/host/dictate${u?`?${u}`:``}`),c.setRequestHeader(`content-type`,`audio/wav`),c.withCredentials=!0,s&&(c.upload.onprogress=t=>s(t.loaded,t.lengthComputable?t.total:e.size));let d=()=>c.abort();o?.addEventListener(`abort`,d,{once:!0});let f=()=>o?.removeEventListener(`abort`,d);c.onload=()=>{if(f(),c.status<200||c.status>299){let e=Error(`the desktop could not read it (${c.status})`);e.permanent=c.status===413||c.status===415,e.responded=!0,r(e)}else try{n(JSON.parse(c.responseText))}catch{let e=Error(`the desktop answered something this app could not read`);e.responded=!0,r(e)}},c.onerror=()=>{f(),r(Error(`the desktop could not be reached`))},c.onabort=()=>{f(),r(new DOMException(`aborted`,`AbortError`))},c.send(e)}),setClipboard:e=>Of(`/api/host/clipboard`,{text:e}),pluginAsset:(e,t,n)=>wf(`/api/plugin/${encodeURIComponent(e)}/asset/${encodeURIComponent(t)}`,{signal:n,cache:`no-store`},3e4)};function Kf(e,t,n){return li(e,t,n)}async function qf(e,t,n){try{let r=await Kf(e,t,n);return r.ok?await r.json():null}catch{return null}}var Jf={speedtest:{download:async(e,t)=>{let n=performance.now(),r=await fetch(`/api/speedtest/download?bytes=${e}&_=${Date.now()}`,{cache:`no-store`});if(!r.ok||!r.body)throw Error(`download ${r.status}`);let i=r.body.getReader(),a=0;for(;;){let{done:e,value:n}=await i.read();if(e)break;a+=n.byteLength,t?.(a)}let o=performance.now()-n;return{bytes:a,ms:o,mbps:Yf(a,o)}},upload:async e=>{let t=new Uint8Array(e);for(let n=0;n<e;n+=65536)crypto.getRandomValues(t.subarray(n,Math.min(n+65536,e)));let n=performance.now(),r=await(await fetch(`/api/speedtest/upload`,{method:`POST`,headers:{"content-type":`application/octet-stream`},body:t})).json(),i=performance.now()-n;if(!r.ok)throw Error(r.error||`upload failed`);return{bytes:e,ms:i,mbps:Yf(e,i),serverMs:r.ms}},debug:()=>Ef(`/api/speedtest/debug`)},netstats:{get:()=>Ef(`/api/netstats`,void 0),reset:()=>kf(`/api/netstats`),report:e=>Kf(`/api/netstats`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(e),keepalive:!0}).catch(()=>void 0)},push:{key:()=>Ef(`/api/push/key`),subscribe:e=>Of(`/api/push/subscribe`,e),unsubscribe:e=>Of(`/api/push/unsubscribe`,{endpoint:e})},uiUsage:{get:()=>qf(`/api/ui-usage`),flush:e=>Kf(`/api/ui-usage`,{method:`POST`,headers:{"content-type":`application/json`},body:e,keepalive:!0}),reset:()=>Kf(`/api/ui-usage`,{method:`DELETE`}).catch(()=>void 0)},webBundle:{manifest:()=>qf(`/api/webbundle`,{cache:`no-store`}),file:(e,t)=>Kf(`/api/webbundle/file?path=${encodeURIComponent(e)}&v=${encodeURIComponent(t)}`,{cache:`no-store`})},auth:{status:()=>Ef(`/api/auth/status`),login:e=>Of(`/api/auth/login`,{password:e}),logout:()=>Of(`/api/auth/logout`,{})},tailnet:{peers:()=>Ef(`/api/tailnet/peers`,12e3)},pair:{mint:(e=!1)=>Df(`/api/pair/mint`,e?{passive:!0}:{}),redeem:async(e,t,n=null)=>{let r=await wf(`${e}/api/pair/redeem`,{method:`POST`,credentials:`omit`,cache:`no-store`,headers:n?{"content-type":`application/json`,authorization:`Bearer ${n}`}:{"content-type":`application/json`},body:JSON.stringify(t)},1e4),i=null;try{i=await r.json()}catch{}return{status:r.status,body:i}}},peers:{on:async(e,t,n,r,i)=>{let a={};i!==void 0&&(a[`content-type`]=`application/json`),t&&(a.authorization=`Bearer ${t}`);let o=await wf(`${e}${r}`,{method:n,credentials:`omit`,cache:`no-store`,headers:a,...i===void 0?{}:{body:JSON.stringify(i)}},1e4),s=null;try{s=await o.json()}catch{}return{status:o.status,body:s}}},devices:{list:()=>Ef(`/api/devices`),revoke:e=>Df(`/api/devices/revoke`,{id:e})}};function Yf(e,t){return t>0?e*8/(t/1e3)/1e6:0}async function Xf(e){try{if(navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}var H={...Mf,...Nf,...Pf,...Ff,...Rf,...zf,...Vf,...Gf,...Jf};function Zf(e){return e==null?null:typeof e==`string`?e.length:typeof Blob<`u`&&e instanceof Blob?e.size:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:typeof URLSearchParams<`u`&&e instanceof URLSearchParams?e.toString().length:null}function Qf(){try{new PerformanceObserver(e=>{for(let t of e.getEntries()){let e=t.initiatorType;if(e===`fetch`||e===`xmlhttprequest`||e===`beacon`)continue;let n=t.transferSize||t.encodedBodySize||0;n>0&&Id(`down`,n)}}).observe({type:`resource`,buffered:!0})}catch{}}var $f=!1;function ep(){if(!$f){$f=!0;try{let e=globalThis.fetch.bind(globalThis);globalThis.fetch=(async(t,n)=>{let r=Zf(n?.body);r!=null&&Id(`up`,r);let i=await e(t,n),a=Number(i.headers.get(`content-length`));return Number.isFinite(a)&&a>0&&Id(`down`,a),i})}catch{}try{let e=XMLHttpRequest.prototype.send;XMLHttpRequest.prototype.send=function(t){let n=0;try{this.upload?.addEventListener(`progress`,e=>{e.loaded>n&&(Id(`up`,e.loaded-n),n=e.loaded)})}catch{}let r=0;try{this.addEventListener(`progress`,e=>{e.loaded>r&&(Id(`down`,e.loaded-r),r=e.loaded)}),this.addEventListener(`loadend`,()=>{let e=Number(this.getResponseHeader?.(`content-length`));if(Number.isFinite(e)&&e>r&&Id(`down`,e-r),n===0){let e=Zf(t);e!=null&&Id(`up`,e)}})}catch{}return e.call(this,t)}}catch{}Qf(),Xd();try{window.addEventListener(`pagehide`,()=>{gd(),np()}),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`hidden`&&(gd(),np())})}catch{}}}function tp(){H.netstats.report({deviceId:lf(),report:gf()})}function np(){if(!rp)return;let e=JSON.stringify({deviceId:lf(),report:gf()});try{navigator.sendBeacon?navigator.sendBeacon(`/api/netstats`,new Blob([e],{type:`application/json`})):tp()}catch{}}var rp=!1;function ip(){rp||(rp=!0,window.setInterval(()=>{document.visibilityState===`visible`&&tp()},fre))}var ap=3e3,op=2500,sp=fa(R.netPulse,!0),cp=[];function lp(){return sp}function up(e){sp=e,sa(R.netPulse,e),e||(cp=[]),vd(`pulse`),xd()}function dp(e){cp.push(e),cp.length>90&&cp.splice(0,cp.length-90),vd(`pulse`),xd()}var fp=null,pp=!1,mp=null;function hp(e){mp=e,fp??(fp=window.setInterval(gp,ap),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&gp()}))}async function gp(){if(sp&&mp&&document.visibilityState===`visible`&&!pp){if(jd(mp.status),Ad!==`open`)dp({at:Date.now(),ms:null});else{pp=!0;try{dp({at:Date.now(),ms:await mp.probe(op)})}catch{dp({at:Date.now(),ms:null})}finally{pp=!1}}}}function _p(e,t=200){let n=e.filter(e=>e.ms!=null).map(e=>e.ms),r=[...n].sort((e,t)=>e-t),i=r.length?r[Math.floor((r.length-1)/2)]:null,a=r.length?r[r.length-1]:0,o=e.length?e[e.length-1]:null;return{last:o&&o.ms!=null?o.ms:null,median:i,misses:e.length-n.length,ceiling:Math.max(t,a)}}var vp=e=>e.split(/[/\\]/).filter(Boolean).pop()||e,yp=e=>e>=1e9?`${(e/1e9).toFixed(1)} GB`:e>=1e6?`${(e/1e6).toFixed(1)} MB`:e>=1e3?`${Math.round(e/1e3)} KB`:`${e} B`;function bp(e){if(e==null)return`—`;let t=[`B`,`KB`,`MB`,`GB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r++;return`${n>=10||r===0?Math.round(n):n.toFixed(1)} ${t[r]}`}var xp=Nn;function Sp(e){xp=e}function Cp(e){return fi(e,xp)}function wp(e){let t=Cp(e);return{"--repo-hue":`${t}`,"--repo-accent":`hsl(${t} var(--repo-sat) var(--repo-lit))`}}function Tp(e){let t=Math.max(0,Math.round((Date.now()-e)/1e3));if(t<60)return`${t}s ago`;let n=Math.round(t/60);if(n<60)return`${n}m ago`;let r=Math.round(n/60);if(r<24)return`${r}h ago`;let i=Math.round(r/24);return i<60?`${i}d ago`:`${Math.round(i/30)}mo ago`}function Ep(e){return e.running?e.turnActive?0:e.lastTurnAt?Date.now()-e.lastTurnAt:e.idleSince?Date.now()-e.idleSince:0:1/0}function Dp(e){return!e.running||e.turnActive?!0:e.lastTurnAt!=null}function Op(e){let t=Math.max(0,Math.round((Date.now()-e)/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);return r<24?`${r}h`:`${Math.floor(r/24)}d`}function kp(e){if(e<45e3)return`just now`;let t=Math.round(e/6e4);if(t<60)return`${t} min ago`;let n=Math.round(t/60);return n<48?`${n} h ago`:`${Math.round(n/24)} d ago`}function Ap(e,t){let n=Math.max(0,Math.round(((t??Date.now())-e)/1e3));return n<60?`${n}s`:`${Math.floor(n/60)}m ${n%60}s`}var jp=0;function Mp(e){return`${e}_${Date.now().toString(36)}_${(jp++).toString(36)}`}var Np=/\x1b(?:\[[0-9;?]*[ -/]*[@-~]|\][^\x07\x1b]*(?:\x07|\x1b\\))/g,Pp=e=>e.replace(Np,``).replace(/\r(?!\n)/g,`
2
+ `),Fp=(e,t,n)=>Math.min(n,Math.max(t,e));function Ip(e){return new TextDecoder().decode(Uint8Array.from(atob(e),e=>e.charCodeAt(0)))}var Lp=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});function Rp(e){let t=Lp(e);return e-Date.now()>72e6?`${new Date(e).toLocaleDateString([],{weekday:`short`})} ${t}`:t}function zp(e){let t=Math.round((e-Date.now())/1e3);if(t<=0)return`now`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);return r<24?n%60?`${r}h ${n%60}m`:`${r}h`:`${Math.floor(r/24)}d ${r%24}h`}function Bp(e){let t=(e,t,n)=>`${e} ${t==null?`?`:`${t}%`}${n?` · resets ${Rp(n)} (in ${zp(n)})`:``}`;return`Claude usage — ${t(`5-hour session`,e?.sessionPct,e?.sessionResetAt)} · ${t(`week`,e?.weeklyPct,e?.weeklyResetAt)}${e?.checkedAt?` · checked ${Tp(e.checkedAt)}`:``}`}function Vp(e){let t=new Date(e),n=new Date,r=t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});if(t.toDateString()===n.toDateString())return r;let i=(n.getTime()-e)/864e5;return i>=0&&i<6?`${t.toLocaleDateString([],{weekday:`short`})} ${r}`:`${t.toLocaleDateString([],{day:`numeric`,month:`short`,...t.getFullYear()===n.getFullYear()?{}:{year:`numeric`}})} ${r}`}function Hp(e){return e.turnActive||e.lastTurnAt!=null||e.firstPrompt||e.lastPrompt||e.contextUsedTok!=null||e.contextLeft!=null||(e.contextSpark?.pts?.length??0)>0?`started`:e.claudeSessionId||e.backendSessionId?`fresh`:`unknown`}var Up=e=>e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e),Wp=[`sessions`,`repos`],Gp=1e4,Kp=0;function qp(){let e=Date.now();pd.sync.lastSeenAt=e,e-Kp>Gp&&(Kp=e,gd())}function Jp(e){pd.sync.parts[e]=Date.now(),gd(),vd(`sync`),xd()}function Yp(){let e=kd!=null,t=e?Wp.filter(e=>pd.sync.parts[e]<kd):[],n=Wp.map(e=>pd.sync.parts[e]),r=!e||t.length||n.some(e=>!e)?null:Math.min(...n);return{online:e,connectedSince:kd,lastSeenAt:pd.sync.lastSeenAt||null,syncedAt:r,pending:t}}function Xp(){let e=Wp.map(e=>pd.sync.parts[e]);return e.some(e=>!e)?null:Math.min(...e)}function Zp(e){if(!e)return`never`;let t=new Date(e);return new Date().toDateString()===t.toDateString()?Rp(e):`${t.toLocaleDateString([],{weekday:`short`})} ${Rp(e)}`}var Qp=null;function $p(){if(Qp&&!_d.size)return Qp;let e=Qp,t={status:Ad,online:Ad===`open`,now:tm,pulse:e&&!_d.has(`pulse`)&&!_d.has(`status`)?e.pulse:{enabled:sp,status:Ad,samples:cp.slice()},sync:e&&!_d.has(`sync`)&&!_d.has(`status`)?e.sync:Yp(),traffic:e&&!_d.has(`traffic`)?e.traffic:Ere(),log:e&&!_d.has(`log`)&&!_d.has(`status`)?e.log:gf(),ops:e&&!_d.has(`ops`)?e.ops:zd.slice(),stuckSends:yf,outstanding:xf,everOutstanding:Sf||pd.log.sent>0};return _d.clear(),Qp=t,t}gre($p);var em=null,tm=Date.now();function nm(){tm=Date.now(),vd(`traffic`,`log`,`sync`),xd()}function rm(){let e=[...yd].some(e=>e.live);e&&em==null&&(em=window.setInterval(nm,1e3)),!e&&em!=null&&(window.clearInterval(em),em=null)}function im(e,t=!1){let n={fn:e,live:t};return yd.add(n),rm(),e($p()),()=>{yd.delete(n),rm()}}function am(e,t=!1){let n=(0,V.useRef)(e);n.current=e;let[r,i]=(0,V.useState)(()=>e($p()));return(0,V.useEffect)(()=>im(e=>{let t=n.current(e);i(e=>Object.is(e,t)?e:t)},t),[t]),r}function om(e){return e==null?`—`:e<1e3?`${Math.round(e)} ms`:e<6e4?`${(e/1e3).toFixed(1)} s`:`${Math.round(e/6e4)} min`}function sm(e){let t=Math.max(0,Math.round((Date.now()-e)/1e3));return t<90?`${t}s`:t<5400?`${Math.round(t/60)}m`:t<172800?`${Math.round(t/3600)}h`:`${Math.round(t/86400)}d`}function cm(e,t,n){let r=t?.delivery,i=(r?.unsubmitted??0)+(r?.unconfirmed??0);if(i>0)return{tone:`bad`,text:i===1?`1 prompt reached a session but could not be confirmed as running — check that session before re-sending, never retype.`:`${i} prompts reached a session but could not be confirmed as running — check those sessions before re-sending, never retype.`};if(e.failed>0){let t=e.failed,r=n<=0?`Their words are kept — on their queue rows, for as long as it takes; nothing retires one.`:n>=t?`Each one is listed below with its words and what stopped it.`:`The newest ${n} are listed below with their words and what stopped them.`;return{tone:`bad`,text:`${t} send${t>1?`s`:``} stopped trying in the last ${sm(e.since)} — nothing was typed into a session, so nothing ran. ${r}`}}return e.reloads>0?{tone:`warn`,text:`The watchdog hard-reloaded the app ${e.reloads}×. That means the socket stayed dead long enough to look wedged — queued text survives (localStorage), but it is the clearest sign the tunnel is unhealthy.`}:(t?.ackReplays??0)>2?{tone:`warn`,text:`${t.ackReplays} receipts never made it back to a phone, so sends were retried against work the host had already done. Delivery is safe (the ack ledger de-dupes), but the link is dropping return traffic.`}:e.offlineShare>.15?{tone:`warn`,text:`No socket for ${Math.round(e.offlineShare*100)}% of the window. Sends queue and go out on reconnect, but nothing is live in the meantime.`}:(e.rttP95??0)>1500?{tone:`warn`,text:`Round trip is ${om(e.rttP95)} at the 95th percentile — likely a DERP-relayed Tailscale path rather than a direct one. Run the speed test for the direct/relay verdict.`}:{tone:`ok`,text:`Nothing queued has been lost or left unconfirmed in this window.`}}var lm=R.syncTs,um=600,dm=`app:settings`,fm=null,pm=!1,mm=!1,hm=new Map;function gm(){try{let e=JSON.parse(localStorage.getItem(lm)||`{}`),t={};for(let[n,r]of Object.entries(e))typeof r==`number`&&Number.isFinite(r)&&(t[n]=r);return t}catch{return{}}}function _m(e,t){try{let n=gm();n[e]=t,localStorage.setItem(lm,JSON.stringify(n))}catch{}}function vm(e){try{return localStorage.getItem(e)}catch{return null}}var ym=new Map;function bm(e,t){ym.set(e,t)}function xm(e,t,n){pm=!0;let r=!1;try{t===``?localStorage.removeItem(e):localStorage.setItem(e,t),r=!0,_m(e,n)}catch{}finally{pm=!1}return r}function Sm(e,t,n){let r=ym.get(e),i;if(r)try{i=r(t,vm(e))}catch{}let a=typeof i==`string`?i:t;if(ure(xm(e,a,n),a,t)){let t=Math.max(Date.now(),n+1);_m(e,t),$u(e,t),Tm(e)}}function Cm(e){if(hm.delete(e),!fm){Tm(e);return}let t=vm(e)??``,n=gm()[e]??Date.now();fm({t:`settings.set`,key:e,value:t,ts:n,device:lf()})}function wm(e){let t=Date.now();_m(e,t),$u(e,t),Tm(e)}function Tm(e){let t=hm.get(e);t&&clearTimeout(t),hm.set(e,setTimeout(()=>Cm(e),um))}function Em(e){if(fm=e,mm)return;mm=!0;let t;try{t=window.localStorage}catch{return}let n=t.setItem.bind(t),r=t.removeItem.bind(t);if(t.setItem=(e,t)=>{n(e,t),!pm&&Xr(e)&&wm(e)},t.removeItem=e=>{r(e),!pm&&Xr(e)&&wm(e)},t.setItem===n){let e=Object.getPrototypeOf(t),n=e.setItem,r=e.removeItem;e.setItem=function(e,r){n.call(this,e,r),this===t&&!pm&&Xr(e)&&wm(e)},e.removeItem=function(e){r.call(this,e),this===t&&!pm&&Xr(e)&&wm(e)}}}function Dm(e){Om(e)}function Om(e){try{window.dispatchEvent(new CustomEvent(dm,{detail:{key:e}}))}catch{}}function km(e){let t=gm();for(let n of _i){let r=e[n],i=t[n]??0,a=vm(n);if(r&&r.ts>i)r.value===(a??``)?(_m(n,r.ts),ed(n,r.ts)):(Sm(n,r.value,r.ts),td(n,r.ts),Om(n));else if(r&&r.ts===i&&ed(n,r.ts),a!=null&&(!r||i>r.ts)){let e=t[n]||Date.now();t[n]||_m(n,e);let i=r?dre(a,r.value,ym.get(n)):null;if(r&&i!==null){let t=Math.max(Date.now(),e+1,r.ts+1);xm(n,i,t)&&(e=t,Om(n))}$u(n,e),Tm(n)}}}function Am(e,t,n){Xr(e)&&(n<=(gm()[e]??0)?ed(e,n):(vm(e)??``)===t?(_m(e,n),ed(e,n)):(Sm(e,t,n),td(e,n),Om(e)))}function jm(){let e=0,t=Date.now();for(let n of _i)vm(n)!=null&&(_m(n,t+e),Tm(n),e++);return e}function Mm(e,t){let n=n=>{let r=n.detail?.key;r&&(t&&t.length&&!t.includes(r)||e(r))};return window.addEventListener(dm,n),()=>window.removeEventListener(dm,n)}var Nm=R.composeDrafts,Pm=R.composeOutbox,Fm=R.pad,Im=1e3,Lm=R.deadUploads;function Rm(e,t){Um(Lm,[...Hm(Lm,[]).filter(t=>t.p!==e),{p:e,r:t}].slice(-40))}function zm(e){for(let t of Hm(Lm,[]))if(e.includes(t.p))return{relPath:t.p,reason:t.r};return null}function Bm(){let e={};for(let t of Hm(Lm,[]))e[t.p]=t.r;return e}function Vm(e){Um(Lm,Hm(Lm,[]).filter(t=>t.p!==e))}function Hm(e,t){try{let n=z(e);return n?JSON.parse(n):t}catch{return t}}function Um(e,t){Ta(e,t)}function Wm(e){return Hm(Nm,{})[e]??``}function Gm(e,t){let n=Hm(Nm,{});t?n[e]=t:delete n[e],Um(Nm,n)}function Km(){return new Set(Object.keys(Hm(Nm,{})))}function qm(){return Hm(Pm,[])}function Jm(e){Um(Pm,e)}function Ym(){return pe(z(Fm))}function Xm(e){try{localStorage.setItem(Fm,it(e))}catch{return!1}return Dm(Fm),!0}function Zm(){return Ym().notes}function Qm(e){let t=Ym(),n=()=>yt(t.notes.length,Math.round(it(t).length/1024));if(!t.notes.some(t=>t.id===e.id)&&t.notes.length>=400)return n();let r=Yt(t,e);return it(r).length>524288?n():Xm(r)?null:Jr}function $m(e){let t=Ym(),n=Yt(t,e);return it(n).length>524288?yt(t.notes.length,Math.round(it(t).length/1024)):Xm(n)?null:Jr}function eh(e){e.length&&Xm(Fe(Ym(),e,Date.now()))}bm(Fm,(e,t)=>p(e,t,Date.now()).value);function th(e){if(e.status!==`queued`||e.mode===`upload`||e.answer)return!1;if(e.mode!==`op`)return!0;let t=e.op?.t;return t===`fanout.run`||t===`fanout.followup`||t===`session.create`}function nh(e){return e.mode===`op`&&e.op?.t===`session.create`}function rh(e){return nh(e)&&!!e.op?.prompt&&!!e.cwd}function ih(){try{let e=new Uint8Array(8);return crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}catch{return`${Date.now().toString(36)}-${Math.floor(Math.random()*1e9).toString(36)}`}}var ah=`.claude/inbox`;function oh(e){let t=e.lastIndexOf(`.`),n=t>0?e.slice(t):``,r=`${(t>0?e.slice(0,t):e).replace(/[/\\\s]+/g,`_`).slice(0,40)||`file`}-${Date.now().toString(36)}${ih().slice(0,6)}${n}`;return{name:r,relPath:`${ah}/${r}`}}var sh=R.composeSheets,ch=20;function lh(e){return Hm(sh,{})[e]??``}function uh(){return ih()}function dh(e,t,n){let r=Ur(lh(e),t);return r?Qm({id:uh(),ts:Date.now(),...r,...n?{cwd:n}:{}})?`refused`:(mh(e,t),`kept`):(mh(e,t),`seeded`)}function fh(e,t){let n=lh(e).split(`\f`),r=n[0]??``;n[0]=r?`${r}${/\s$/.test(r)?``:` `}${t}`:t,mh(e,n.join(`\f`))}function ph(e){mh(e,``)}function mh(e,t){let n=Hm(sh,{});t?n[e]=t:delete n[e];let r=Object.keys(n);if(r.length>ch)for(let e of r.slice(0,r.length-ch))delete n[e];Um(sh,n)}var hh=1500;function gh(e,t,n={}){let{enabled:r=!0,offline:i=!Md(),fromCache:a,toCache:o}=n,[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(`loading`),[d,f]=(0,V.useState)(null),[p,m]=(0,V.useState)(null),[h,g]=(0,V.useState)(0),_=(0,V.useRef)(e),[v,y]=(0,V.useState)(0),b=(0,V.useRef)(t);b.current=t;let x=(0,V.useRef)({fromCache:a,toCache:o});x.current={fromCache:a,toCache:o};let S=(0,V.useCallback)(e=>{e?.quiet||(c(null),f(null),m(null),u(`loading`)),y(e=>e+1)},[]);return(0,V.useEffect)(()=>{if(_.current=e,!r)return;let t=!1,n=new AbortController,a=e,o=()=>!t&&_.current===a;return g(e=>e+1),(async()=>{try{let e=await Promise.race([x.current.fromCache?.().catch(()=>null)??null,new Promise(e=>setTimeout(()=>e(null),hh))]);if(e&&o()&&(c(e.value),f(Date.now()-e.savedAt),u(`cached`)),i){o()&&!e&&u(`offline`);return}try{let e=await b.current(n.signal);if(!o())return;c(e),f(null),m(null),u(`fresh`);try{await x.current.toCache?.(e)}catch{}}catch(t){if(!o())return;let n=Qe(t);u(e?`cached`:n?`offline`:`error`),m(n?null:String(t?.message||t))}}finally{g(e=>e-1)}})(),()=>{t=!0,n.abort()}},[e,r,i,v]),{data:s,state:l,age:d,error:p,inflight:h>0,reload:S,set:c}}function _h(e,t,n=`listing`){return e!==`cached`||t==null?null:`Cached ${n} from ${kp(t)} — the link is down, so anything added since won't be here.`}var vh={has:e=>!!e.starred,paint:(e,t)=>({...e,starred:t})},yh={has:e=>!!e.followUp,paint:(e,t)=>{if(t)return{...e,followUp:{by:`hand`,at:Date.now()}};let{followUp:n,...r}=e;return r}};function bh(e){try{let t=JSON.parse(e||`{}`);if(!t||typeof t!=`object`||Array.isArray(t))return{};let n={};for(let[e,r]of Object.entries(t))typeof r==`boolean`&&(n[e]=r);return n}catch{return{}}}function xh(e,t,n){if(Object.keys(t).length===0)return e;let r=!1,i=e.map(e=>{let i=t[e.id];return i===void 0||i===n.has(e)?e:(r=!0,n.paint(e,i))});return r?i:e}function Sh(e,t,n,r){let i=Object.keys(e);if(i.length===0)return null;let a=new Map(t.map(e=>[e.id,e])),o={},s=!1;for(let t of i){let i=a.get(t);if(i)r.has(i)===e[t]?s=!0:o[t]=e[t];else{if(n){s=!0;continue}o[t]=e[t]}}return s?o:null}var Ch=null;function wh(e){Ch=e}function U(){if(!Ch)throw Error(`core() before App bound it — a feature ran outside App's lifecycle`);return Ch}function W(e){let t=e,n=new Set;return{get:()=>t,set(e){let r=typeof e==`function`?e(t):e;if(!Object.is(r,t)){t=r;for(let e of[...n])e()}},subscribe(e){return n.add(e),()=>{n.delete(e)}}}}function G(e){return(0,V.useSyncExternalStore)(e.subscribe,e.get,e.get)}var Th=W([]),Nre=W(new Map),Eh=!1;function Pre(e){Eh||(Eh=!0,Th.set(e()))}function Dh(){return U()}function Oh(){return G(Th)}function Fre(e){let t=(0,V.useRef)(e);return t.current=e,t}function kh(e,t,n){let r=new Map(e);return r.set(t,n),r}function Ah(e,t){if(!e.has(t))return e;let n=new Map(e);return n.delete(t),n}var jh=e=>e.charAt(0).toUpperCase()+e.slice(1),Mh=()=>globalThis;function Nh(e){let t=Mh().Capacitor?.Plugins;if(t)return t[`Shell${e}`]??k.map(n=>t[`${jh(n.slug)}${e}`]).find(Boolean)}function Ph(){let e=Mh();return e.ShellAndroidInterface??k.map(t=>e[`${jh(t.slug)}ShellAndroidInterface`]).find(Boolean)}function Fh(e,t,n=`Shell`){let r=Mh(),i=[`shell${e}`,...k.map(t=>`${t.slug}${n}${e}`)];for(let e of i)r[e]=t;return()=>{for(let e of i)delete r[e]}}var Ire=/^feature:([a-z][a-z0-9-]{1,39})\/([a-z][a-z0-9-]{0,39})$/;function Ih(e,t){let n=`feature:${e}/${t}`;if(!Ire.test(n))throw Error(`"${n}" is not a feature sheet id — feature:<id>/<sheet>, lower-case letters, digits and -`);return n}var Lh=new Set([`gallery`,`new`,`backlog`,`git`,`model`,`toolbar`,`browse`,`archive`,`activity`,`clihealth`,`context`,`pull`,`tokens`,`repocolor`,`apps`,`storage`]),Lre=new Set([`swipe`,`image`,`clip`,`collage`,`tokens`,`context`,`repohealth`,`scrollback`,`git`,`text`,`outline`]),Rre=e=>e!==null&&Lre.has(e);function zre(){let e=new URLSearchParams(location.hash.replace(/^#/,``)),t=e.get(`o`),n=e.get(`imgRepo`),r=e.get(`imgPath`),i=n&&r?{repoId:n,relPath:r}:void 0,a=e.get(`dlRepo`),o=e.get(`dlPath`),s=Number(e.get(`dlMtime`)||0),c=a&&o?{repoId:a,relPath:o,name:e.get(`dlName`)||void 0,mtime:s||void 0}:void 0;return{activeId:e.get(`a`)||null,overlay:t&&Lh.has(t)?t:null,image:i,file:c,plugin:e.get(`plugin`)||void 0}}function Bre(e,t){let n=t&&Lh.has(t)?t:null,r=new URLSearchParams;e&&r.set(`a`,e),n&&r.set(`o`,n);let i=r.toString();return i?`#${i}`:``}function Rh(e,t,n=null){return`${e||``}|${t||``}|${n||``}`}function Vre(){return new URLSearchParams(location.search).get(`repo`)||null}function Hre(e,t,n){let r=[],i=null;try{i=new URLSearchParams(location.search).get(`demo`)}catch{}return i&&r.push(`demo=${encodeURIComponent(i)}`),n&&r.push(`repo=${encodeURIComponent(n)}`),location.pathname+(r.length?`?${r.join(`&`)}`:``)+Bre(e,t)}function zh(e){return e.split(`|`)[1]||null}function Ure(e,t){return`${e}#step${t}`}function Bh(e){let t=e.indexOf(`#step`);return t<0?e:e.slice(0,t)}var Wre=`\0vacant`;function Gre(e,t,n){let r=e=>e!==void 0&&e!==`\0vacant`,i=e=>e===`\0vacant`||e!==void 0&&e!==Bh(e),a=t;for(;a>0&&i(e[a]);)a--;if(e[a]===n)return a===t?{kind:`stay`}:{kind:`go`,delta:a-t};let o=e[a],[s,c,l]=n.split(`|`),u=e=>{if(!r(e))return!1;let[t,,n]=Bh(e).split(`|`);return t===s&&n===l};if(!c&&r(o)&&zh(o)&&u(o)){let n=a-1;for(;n>0&&e[n]===`\0vacant`;)n--;if(n>=0&&u(e[n]))return{kind:`go`,delta:n-t}}for(let r=a-1;r>=0;r--)if(e[r]===n)return{kind:`go`,delta:r-t};return{kind:`push`}}function Kre(e,t,n,r=0){if(!e?.navRoute)return{depth:r+1,key:Rh(t.activeId,t.overlay,t.focusRepo??null),activeId:t.activeId,overlay:t.overlay,adopt:!0};let i=e.navDepth||0,a=e.navRoute===n[i]?e.navRoute:null;return{depth:i,key:e.navRoute,activeId:t.activeId,overlay:a?zh(a):t.overlay,adopt:!1}}var Vh={depth:0,keys:[]};function Hh(){Ph()?.setBackDepth?.(Vh.depth)}var Uh=new Map,qre=1;function Jre(e){for(let[t,n]of[...Uh])t<=e||(Uh.delete(t),n.close());let t=Vh.keys[e];return t===`\0vacant`||t!==void 0&&t.includes(`#step`)&&!Uh.has(e)}var Wh=!1;function Yre(){Wh||(Wh=!0,queueMicrotask(()=>{Wh=!1;let e=0;for(;Vh.depth-e>0&&Vh.keys[Vh.depth-e]===`\0vacant`;)e++;e&&(Vh.depth-=e,Vh.keys.length=Vh.depth+1,Hh(),history.go(-e))}))}function Gh(e,t){let n=(0,V.useRef)(t);n.current=t;let[r,i]=(0,V.useState)(0);(0,V.useEffect)(()=>{if(!e)return;let t=qre++,r=Vh.depth;for(;r>0&&Vh.keys[r]===`\0vacant`;)r--;let a=Vh.depth+1,o=Ure(Bh(Vh.keys[r]??``),t);return history.pushState({navRoute:o,navDepth:a},``),Vh.depth=a,Vh.keys[a]=o,Vh.keys.length=a+1,Uh.set(a,{id:t,close:()=>{n.current(),i(e=>e+1)}}),Hh(),()=>{Uh.get(a)?.id===t&&(Uh.delete(a),Vh.keys[a]===o&&(Vh.keys[a]=Wre),Yre())}},[e,r])}function Xre(){return am(e=>e.status)}function Zre(e){let t=Object.keys(e),n={};for(let r of t)n[r]=e[r].load();let r=W(n),i=new Map,a=(t,n,r)=>e[t].same?e[t].same(n,r):Object.is(n,r);function o(e,t){let n=r.get();if(a(e,n[e],t))return;let o=i.get(e);o&&(o.current=t),r.set({...n,[e]:t})}return{get:e=>r.get()[e],set(t,n){e[t].save(n),o(t,e[t].reread?e[t].load():n)},reload(t){o(t,e[t].load())},adopt(n){let r=!1;for(let i of t)e[i].keys?.includes(n)&&(o(i,e[i].load()),r=!0);return r},use(e){return(0,V.useSyncExternalStore)(r.subscribe,()=>r.get()[e])},ref(e){let t=i.get(e);return t||(t={current:r.get()[e]},i.set(e,t)),t},all:()=>r.get(),subscribe:r.subscribe}}var Kh=e=>e!==`0`,Qre=e=>e===`1`,qh=e=>e?`1`:`0`;function $re(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}var Jh=[160,240,320,480,640,960,1280,1600],Yh=R.dataSaver;function Xh(){return z(Yh)===`1`}function eie(e){ua(Yh,e?`1`:`0`)}function Zh(e){let t=Math.min(2,Math.max(1,typeof devicePixelRatio==`number`?devicePixelRatio:1)),n=Math.round(e*(Xh()?1:t));return Jh.find(e=>e>=n)??Jh[Jh.length-1]}function Qh(){return Xh()?960:Zh(Math.min(typeof innerWidth==`number`?innerWidth:400,800))}function $h(e,t,n){return`${e}${e.includes(`?`)?`&`:`?`}thumb=${t}${n?`&v=${Math.floor(n)}`:``}`}function eg(e){return e.type?e.type.startsWith(`image/`):/\.(png|jpe?g|gif|webp|bmp|svg|heic|heif)$/i.test(e.name)}var tg=[`live`,6e4,3e5,9e5,`off`],tie=3e5;function nie(e){if(e===`live`||e===`off`)return e;let t=Number(e);return e&&Number.isFinite(t)&&tg.includes(t)?t:tie}function ng(e){return e===`live`?`live`:e===`off`?`off`:`every ${Math.round(e/6e4)} min`}function rie(e){return e===`live`?`Hidden, the open session keeps streaming. Freshest offline screen, most battery.`:e===`off`?`Hidden, the open session stops. Offline you read the screen as you left it.`:`Hidden, the open session stops and catches up ${ng(e)}. Offline you read a screen at most that old.`}function iie(e){return e!==`live`}function aie(e){return typeof e==`number`?e:null}function rg(){return nie(z(R.bgFresh))}function oie(e){ua(R.bgFresh,String(e))}var sie={dark:`#0b0d10`,light:`#eef1f6`},ig=e=>vte(e,Hu())??sie[e],cie=e=>e===`system`||e===`dark`||e===`light`;function ag(){let e=z(R.theme);return cie(e)?e:`system`}var og=()=>{try{return window.matchMedia(`(prefers-color-scheme: light)`)}catch{return null}};function lie(){return og()?.matches?`light`:`dark`}function sg(){let e=ag();return e===`system`?lie():e}var cg=new Set;function uie(e){return cg.add(e),()=>{cg.delete(e)}}var lg=null;function ug(){let e=sg(),t=ag();try{document.documentElement.setAttribute(`data-theme`,e),document.documentElement.style.colorScheme=e;let t=document.querySelector(`meta[name="theme-color"]`);t&&t.setAttribute(`content`,ig(e))}catch{}try{Ph()?.setTheme?.(e,ig(e))}catch{}if(e!==lg){lg=e;for(let n of cg)try{n(e,t)}catch{}}return e}function die(e){ua(R.theme,e),ug()}function fie(){ug(),rre(()=>{lg=null,ug()});let e=og();if(!e)return;let t=()=>{ag()===`system`&&ug()};typeof e.addEventListener==`function`?e.addEventListener(`change`,t):typeof e.addListener==`function`&&e.addListener(t)}var pie=3e3,mie=55,hie=12e3,dg=80,gie=6e4;function _ie(e){return Math.min(hie,pie+e.length*mie)}var fg=null,pg,mg=new Set,hg=vie(),gg=new Set;function vie(){let e=ma(R.toastLog,[]);return Array.isArray(e)?e.filter(e=>!!e&&typeof e.text==`string`&&Number.isFinite(e.ts)).map(e=>({ts:e.ts,text:e.text,n:Number.isFinite(e.n)&&e.n>0?e.n:1,...e.notif&&typeof e.notif.id==`string`&&typeof e.notif.title==`string`?{notif:e.notif}:{}})).slice(0,dg):[]}function _g(){for(let e of mg)e(fg)}function vg(){for(let e of gg)e(hg)}function yie(e,t,n){let r=hg[0];hg=r&&r.text===e&&t-r.ts<gie?[{ts:t,text:e,n:r.n+1,...n??r.notif?{notif:n??r.notif}:{}},...hg.slice(1)]:[{ts:t,text:e,n:1,...n?{notif:n}:{}},...hg].slice(0,dg),Ta(R.toastLog,hg),vg()}function K(e,t){fg=e,_g(),yie(e,Date.now(),t),pg&&clearTimeout(pg),pg=setTimeout(()=>{pg=void 0,fg=null,_g()},_ie(e))}function yg(){pg&&=(clearTimeout(pg),void 0),fg!==null&&(fg=null,_g())}function bie(e){fg===e&&yg()}function xie(e){return mg.add(e),e(fg),()=>{mg.delete(e)}}function Sie(e){return gg.add(e),e(hg),()=>{gg.delete(e)}}function Cie(e,t){let n=t[0];return n?e===void 0||n.ts>e:!1}function wie(){hg=[],Ta(R.toastLog,hg),vg()}var Tie=25e3,Eie=3e3;function bg(e){return`${(Math.max(0,e)/2**30).toFixed(1)} GB`}function xg(e){return e.reduce((e,t)=>e+(Number.isFinite(t.size)?t.size:0),0)}function Sg(e){return Tg(e,e=>e.reachable?xg(e.models):null)}function Cg(e,t=2**30){let n=0;for(let t of e)t!=null&&t>n&&(n=t);return Math.max(t,n)}function Die(e){return Tg(e,e=>e.gpuPct)}function wg(e){return Tg(e,Eg)}function Oie(e){return Tg(e,e=>e.memTotal>0?Math.max(0,e.memTotal-Dg(e)):null)}function kie(e){return Tg(e,e=>e.sys?.thermal?.cpuTempC)}function Aie(e){return Tg(e,e=>e.sys?.thermal?.gpuTempC)}function jie(e,t){return Tg(e,e=>e.sys?.thermal?.fans.find(e=>e.label===t)?.rpm)}function Tg(e,t){let n=[],r=null;for(let i of e)r!=null&&i.at-r>15e3&&n.push(null),n.push(t(i)??null),r=i.at;return n}function Eg(e){let t=e.sys?.cpu;return t?t.userPct+t.sysPct:e.cpuPct}function Dg(e){return e.sys?.mem?.availableBytes??e.memFree}function Og(e){if(!(e.memTotal>0))return!1;let t=Dg(e);if(t<e.memTotal/10)return!0;let n=e.sys?.mem;return t<e.memTotal/4&&n?.swapTotalBytes!=null&&n.swapTotalBytes>0&&n.swapUsedBytes!=null&&n.swapUsedBytes/n.swapTotalBytes>.8}function kg(e,t){let n=e.gpuPct==null?``:`, GPU ${Math.round(e.gpuPct)}%`,r=`CPU ${Math.round(Eg(e))}% busy${n}, ${bg(Dg(e))} of ${bg(e.memTotal)} available`,i=Og(e)?` — memory is tight`:``;return t?`Last seen: ${r}${i}.`:`${r}${i}.`}function Ag(e){let t={stale:!1,at:null,sample:null};if(e.disabled)return{...t,kind:`disabled`,text:`The local-runner poll is switched off on this desktop (${Fi(`LOCAL_RUNTIME`)}=0). Nothing here is being measured.`};if(e.answeredAt==null&&e.askedAt!=null&&e.online&&e.now-e.askedAt>5e3)return{...t,kind:`unanswered`,text:`This desktop didn’t answer — its ${I.name} may predate this readout.`};if(!e.last)return{...t,kind:`pending`,text:e.online?`Asking this desktop what its local runner is holding…`:`No reading yet — this phone hasn’t heard from the desktop.`};let n=!e.online||e.now-e.last.at>3e4,r=e.last.at,i=e.last;if(!e.last.reachable)return{kind:`unreachable`,stale:n,at:r,sample:i,text:n?`Last seen: the local runner did not answer.`:`The local runner did not answer — nothing is running it, or it is not listening where this desktop looks.`};if(!e.last.models.length)return{kind:`idle`,stale:n,at:r,sample:i,text:n?`Last seen: the runner was up and holding nothing.`:`The runner is up and holding nothing.`};let a=e.last.models.map(e=>e.name).join(`, `),o=bg(xg(e.last.models));return{kind:`holding`,stale:n,at:r,sample:i,text:n?`Last seen: ${a} holding ${o}.`:`${a} ${e.last.models.length===1?`is`:`are`} resident, holding ${o}.`}}function Mie(e,t){return e&&t-e.at<=3e4?e:null}var Nie=[`off`,`auto`,`always`],Pie={off:`off`,auto:`while a model is loaded`,always:`always on`};function Fie(){let e=z(R.localRtBar);if(e===null)return ha()?`auto`:`always`;let t=e.replace(/^"|"$/g,``);return t===`off`||t===`auto`||t===`always`?t:t===`true`?`always`:`off`}var jg=null,Mg=()=>jg??Fie();function Iie(){return Mg()}function Lie(e){Mg()!==e&&(jg=e,ua(R.localRtBar,JSON.stringify(e)),e===`off`&&(Pg=[]),zg(),Wg())}function Rie(e,t){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.reachable&&n.models.length>0)return n.at}return t&&t.reachable&&t.models.length>0?t.at:null}function zie(e,t){return e===`off`?!1:e===`always`||t.holding?!0:t.lastHeldAt!=null&&t.now-t.lastHeldAt<6e4}function Bie(){let e=ma(R.localRt,{});return{last:e.last&&typeof e.last.at==`number`&&Array.isArray(e.last.models)?e.last:null,disabled:e.disabled===!0,seenAt:typeof e.seenAt==`number`?e.seenAt:null}}var Ng=Bie(),Pg=[],Fg=null,Ig=null,Lg=null;function Vie(){Lg??=window.setTimeout(()=>{Lg=null,Ta(R.localRt,Ng)},Eie)}function Hie(){Lg!=null&&(window.clearTimeout(Lg),Lg=null),Ta(R.localRt,Ng)}function Uie(e,t=!1){let n=Date.now();Ig=n,Ng.seenAt=n,Ng.disabled=t,Ng.last=e,t?Pg=[]:(Pg.push(e),Pg.length>120&&Pg.splice(0,Pg.length-120)),Vie(),zg(),Wg()}var Rg=null;function zg(){Rg=null}function Bg(){return Rg||(Rg={enabled:Mg()!==`off`,mode:Mg(),samples:Pg.slice(),last:Pg.length?Pg[Pg.length-1]:Ng.last,disabled:Ng.disabled,askedAt:Fg,answeredAt:Ig,seenAt:Ng.seenAt,now:Ug},Rg)}var Vg=new Set,Hg=null,Ug=Date.now();function Wg(){if(!Vg.size)return;let e=Bg();for(let t of Vg)t.fn(e)}function Wie(){Ug=Date.now(),zg(),Wg()}function Gg(){let e=[...Vg].some(e=>e.live);e&&Hg==null&&(Hg=window.setInterval(Wie,1e3)),!e&&Hg!=null&&(window.clearInterval(Hg),Hg=null)}function Gie(e,t=!1){let n={fn:e,live:t};return Vg.add(n),Gg(),e(Bg()),()=>{Vg.delete(n),Gg()}}function Kg(e,t=!1){let n=(0,V.useRef)(e);n.current=e;let[r,i]=(0,V.useState)(()=>e(Bg()));return(0,V.useEffect)(()=>Gie(e=>{let t=n.current(e);i(e=>Object.is(e,t)?e:t)},t),[t]),r}var qg=null,Jg=null,Yg=0;function Xg(){return Yg++,Zg(),()=>{Yg=Math.max(0,Yg-1),Zg()}}function Zg(){let e=Yg>0;e&&Jg==null&&(Jg=window.setInterval(Qg,Tie),Qg()),!e&&Jg!=null&&(window.clearInterval(Jg),Jg=null)}function Qg(){!qg||Yg<=0||(typeof document>`u`||document.visibilityState===`visible`)&&qg.status===`open`&&(qg.send({t:`localrt.watch`}),Fg=Date.now(),zg(),Wg())}function Kie(e){!qg||qg.status!==`open`?K(`no connection — the local runner lives on the desktop and can't be ejected from here`):(qg.send({t:`localrt.evict`,name:e}),K(`ejecting ${e}…`))}function qie(e){qg||(qg=e,e.on(e=>{e.t===`localrt.sample`?Uie(e.sample,e.disabled===!0):e.t===`localrt.evict`?K(e.ok?`${e.name} ejected`:`could not eject ${e.name}${e.error?` — ${e.error}`:``}`):e.t===`welcome`&&Qg()}),typeof document<`u`&&document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&Qg()}),typeof window<`u`&&window.addEventListener(`pagehide`,()=>Hie()),Zg(),Qg())}var $g=e=>`${e.repoId}:${e.path}`,e_=e=>`file:${$g(e)}`,t_=e=>e.split(`/`).pop()||e;function Jie(e){if(!Array.isArray(e))return[];let t=new Set,n=[];for(let r of e){if(!r||typeof r!=`object`)continue;let{repoId:e,repo:i,path:a,at:o}=r;if(typeof e!=`string`||!e||typeof a!=`string`||!a)continue;let s=$g({repoId:e,path:a});if(t.has(s))continue;t.add(s);let c={repoId:e,repo:typeof i==`string`?i:``,path:a};typeof o==`number`&&Number.isFinite(o)&&o>0&&(c.at=o),n.push(c)}return n}function Yie(e,t,n){let r=$g(t),i=e.filter(e=>$g(e)!==r);return n?[...i,t]:i}var n_=[`open`,`frequent`,`recent`],Xie={open:`in the order opened`,frequent:`most opened first`,recent:`last opened first`};function Zie(e,t){return e&&t?34:0}function Qie(e){if(typeof e==`number`)return Number.isFinite(e)&&e>0?{n:e,at:0}:null;if(!e||typeof e!=`object`)return null;let t=typeof e.n==`number`&&Number.isFinite(e.n)?e.n:0,n=typeof e.at==`number`&&Number.isFinite(e.at)?e.at:0;return t||n?{n:t,at:n}:null}function r_(e){let t={};for(let[n,r]of Object.entries(e??{})){let e=Qie(r);e&&(t[n]=e)}return t}var $ie=2592e6;function i_(e,t,n){let r={},i=n-$ie;for(let n of[...new Set([...Object.keys(e),...Object.keys(t)])].sort()){let a=e[n],o=t[n],s=Math.max(a?.at??0,o?.at??0);s<i||(r[n]={n:Math.max(a?.n??0,o?.n??0),at:s})}return r}function a_(e){try{return r_(JSON.parse(e||`{}`))}catch{return{}}}function eae(e,t,n){let r=JSON.stringify(i_(a_(e),a_(t),n));return r===e?void 0:r}function o_(e){return Math.min(50,Math.max(2,typeof e==`number`&&Number.isFinite(e)?Math.round(e):10))}function tae(e,t,n){if(e.length<=t)return{shown:[...e],hidden:0};let r=e.slice(0,t);if(n&&!r.some(e=>e.id===n)){let i=e.find(e=>e.id===n);i&&(r[t-1]=i)}return{shown:r,hidden:e.length-r.length}}function s_(e){return Math.min(8,Math.max(2,typeof e==`number`&&Number.isFinite(e)?Math.round(e):3))}var c_=`recent`;function nae(e){return n_.includes(e)?e:c_}function l_(e,t){let n=(e.tabTitle??``).trim();if(n)return n;let r=kee(e.title),i=`${t} · `;return t&&r.startsWith(i)&&r.length>i.length?r.slice(i.length):r||t||`session`}function rae(e,t,n){let r=u_(t,n);return[...e].sort((e,t)=>r({key:e.id,createdAt:e.createdAt},{key:t.id,createdAt:t.createdAt}))}function u_(e,t){let n=(e,t)=>e.createdAt-t.createdAt;return e===`open`?n:e===`recent`?(e,r)=>(t[r.key]?.at??0)-(t[e.key]?.at??0)||n(e,r):(e,r)=>(t[r.key]?.n??0)-(t[e.key]?.n??0)||n(e,r)}function d_(e,t,n,r){let i=u_(n,r),a=t.map(e=>({f:e,r:{key:e_(e),createdAt:e.at??0}})).sort((e,t)=>i(e.r,t.r)),o=new Set(e.map(e=>e.id)),s=[],c=0;for(let t of e){if(!(t.companionOf&&t.companionOf!==t.id&&o.has(t.companionOf))){let e={key:t.id,createdAt:t.createdAt};for(;c<a.length&&i(a[c].r,e)<0;)s.push({kind:`file`,file:a[c++].f})}s.push({kind:`session`,tab:t})}for(;c<a.length;)s.push({kind:`file`,file:a[c++].f});return s}function f_(e,t,n){return{...e,[t]:{n:(e[t]?.n??0)+1,at:n}}}function iae(e,t,n=[]){if(!t.length)return e;let r=new Set([...t,...n]),i={};for(let[t,n]of Object.entries(e))r.has(t)&&(i[t]=n);return i}function p_(e,t){return{title:t?`Close “${e}”?`:`Remove “${e}”?`,lines:[t?`The CLI process ends and the tab goes. The conversation itself is kept — reopen it under “Recently closed”, or in Archive.`:`The row goes off the list. The conversation itself is kept — it is in Archive.`],confirmLabel:t?`Close`:`Remove`}}var m_=()=>fa(R.sessionTabs,!0),h_=()=>s_(Ea(R.sessionTabsCount,3)),g_=()=>z(R.sessionTabsSync)!==`0`,__=()=>nae(g_()?z(R.tabOrderShared)??z(R.sessionTabsOrder):z(R.sessionTabsOrder)),v_=()=>o_(Ea(R.sessionTabsLimit,10));function aae(e){sa(R.sessionTabs,e),j_()}function oae(e){ua(R.sessionTabsCount,String(s_(e))),j_()}function sae(e){ua(g_()?R.tabOrderShared:R.sessionTabsOrder,e),j_()}function cae(e){ua(R.sessionTabsSync,e?`1`:`0`),j_()}var lae={app:`data saver`,"phone-data":`the phone's data saver`,battery:`battery saver`};function uae(e){return e.app?`app`:e.battery?`battery`:e.phoneData?`phone-data`:null}function dae(e,t,n){return e!==null&&t&&!n}function fae(){j_()}function pae(e){ua(R.sessionTabsLimit,String(o_(e))),j_()}var y_=()=>Jie(ma(R.tabFiles,[]));function b_(e,t,n=Date.now()){Ta(R.tabFiles,Yie(y_(),t?{...e,at:e.at??n}:e,t)),j_()}function x_(e,t=Date.now()){E_!==e&&(E_=e,e&&Ta(R.tabOpens,f_(S_(),`file:${e}`,t)),j_())}var S_=()=>r_(ma(R.tabOpens,{}));function C_(){let e=z(R.tabOpensShared);return e===null?Object.fromEntries(Object.entries(S_()).filter(([e])=>!e.startsWith(`file:`))):a_(e)}function mae(){return g_()?{...Object.fromEntries(Object.entries(S_()).filter(([e])=>e.startsWith(`file:`))),...C_()}:S_()}function hae(e,t,n){return!t||t===e?null:n.includes(t)?t:null}var w_=[],T_=null,E_=null,D_=null,O_={enabled:!1,count:3,order:c_,tabs:[],hidden:0,activeId:null,files:[],strip:[],all:[],fileActive:null},k_=new Set;function A_(){let e=__(),t=mae(),n=ji(rae(w_,e,t)),{shown:r,hidden:i}=tae(n,v_(),T_),a=y_();O_={enabled:m_(),count:h_(),order:e,tabs:r,hidden:i,activeId:T_,files:a,strip:d_(r,a,e,t),all:d_(n,a,e,t),fileActive:E_}}function j_(){A_();for(let e of k_)e(O_)}function gae(e,t){w_=[...e],T_=t;let n=w_.map(e=>e.id),r=S_(),i=iae(r,n,y_().map(e_)),a=hae(D_,t,n);t||(D_=null);let o=g_();if(a&&(D_=a),a&&o){let e=Date.now();Ta(R.tabOpensShared,i_(f_(C_(),a,e),{},e))}a&&!o?Ta(R.tabOpens,f_(i,a,Date.now())):Object.keys(i).length!==Object.keys(r).length&&Ta(R.tabOpens,i),j_()}function _ae(e){return k_.add(e),e(O_),()=>{k_.delete(e)}}function M_(e){let t=(0,V.useRef)(e);t.current=e;let[n,r]=(0,V.useState)(()=>e(O_));return(0,V.useEffect)(()=>_ae(e=>{let n=t.current(e);r(e=>Object.is(e,n)?e:n)}),[]),n}var N_=`app:tab-attach`,P_=`app:tab-close`,F_=`app:tab-file`;function I_(e,t){try{window.dispatchEvent(new CustomEvent(e,{detail:{id:t}}))}catch{}}var L_=e=>I_(N_,e),R_=e=>I_(P_,e);function z_(e){try{window.dispatchEvent(new CustomEvent(F_,{detail:e}))}catch{}}A_();var B_=e=>e?new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):``,V_=la,H_=e=>e.endedAt??e.sentAt??0,U_=e=>e.reduce((e,t)=>Math.max(e,H_(t)),0);function W_(e){let t=Number(z(V_(e)));return Number.isFinite(t)&&t>0?t:0}function G_(e,t){t>0&&ua(V_(e),String(t))}var K_=e=>e.kind===`tool`?`${e.name} ${e.label} ${e.input??``} ${e.result??``}`:e.text,q_=e=>`${e.prompt}\n${e.blocks.map(K_).join(`
3
+ `)}`,J_=(e,t)=>!!t&&e.toLowerCase().includes(t.toLowerCase()),Y_=R.readerTools;function X_(){let e=z(Y_);return e===`list`||e===`full`?e:`fold`}function vae(e){ua(Y_,e)}var Z_=(e=X_())=>e===`full`?`full`:`lite`,Q_=We,$_=R.hints,yae=450,bae=10;function ev(){try{let e=JSON.parse(z($_)||`{}`),t=e.mode===`press`||e.mode===`off`?e.mode:`first`,n={};for(let[t,r]of Object.entries(e.seen??{}))typeof r==`number`&&(n[t]=r);return{mode:t,seen:n}}catch{return{mode:`first`,seen:{}}}}function tv(e){Ta($_,e)}function xae(){return ev().mode}function Sae(e){tv({...ev(),mode:e})}function nv(){return Object.keys(ev().seen).length}function Cae(){tv({mode:ev().mode,seen:{}})}function rv(e){let t=ev();t.seen[e]=Date.now(),tv(t)}var iv=!1,av=new Set;function ov(){return iv}function sv(e){if(iv!==e){iv=e;for(let t of av)t(e)}}function cv(e){return av.add(e),()=>{av.delete(e)}}var lv=null,uv=new Set;function wae(e){return uv.add(e),e(lv),()=>{uv.delete(e)}}function dv(e){lv=e;for(let t of uv)t(e)}function fv(e){lv&&e&&rv(lv.id),dv(null)}function Tae(){let e=lv;dv(null),e&&(rv(e.id),e.proceed?.())}function Eae(e){let t=Q_[e];t&&dv({id:e,def:t,intercepted:!1})}function pv(e){let t=e.dataset.hint;if(t&&Q_[t])return{id:t,def:Q_[t]};let n=e.getAttribute(`title`)||e.getAttribute(`aria-label`)||``;if(!n.trim())return null;let r=(e.textContent||``).trim().replace(/\s+/g,` `).slice(0,40),[i,...a]=n.split(/\s*[:—]\s+/),o=a.length>0;return{id:t||`title:${n.slice(0,80)}`,def:{title:r||(o?i:`What this does`),what:o&&!r?a.join(` — `):n}}}var mv=null,hv=!1;function gv(e){return!(e instanceof Element)||e.closest(`[data-nohint]`)?null:e.closest(`[data-hint], button[title], button[aria-label]`)}function _v(){if(typeof document>`u`)return;let e=_v;if(e.done)return;e.done=!0;let t,n=null;function r(e){n&&Math.hypot(e.clientX-n.x,e.clientY-n.y)>bae&&i()}function i(){t&&=(clearTimeout(t),void 0),n=null,window.removeEventListener(`pointermove`,r,!0),window.removeEventListener(`pointerup`,i,!0),window.removeEventListener(`pointercancel`,i,!0),window.removeEventListener(`scroll`,i,!0)}document.addEventListener(`pointerdown`,e=>{if(ev().mode===`off`||e.pointerType===`mouse`&&e.button!==0)return;let a=gv(e.target);if(!a)return;let o=pv(a);o&&(n={x:e.clientX,y:e.clientY},window.addEventListener(`pointermove`,r,!0),window.addEventListener(`pointerup`,i,!0),window.addEventListener(`pointercancel`,i,!0),window.addEventListener(`scroll`,i,!0),t=setTimeout(()=>{i(),hv=!0,navigator.vibrate?.(12),dv({...o,intercepted:!1})},yae))},!0),document.addEventListener(`contextmenu`,e=>{hv&&gv(e.target)&&e.preventDefault()},!0),document.addEventListener(`click`,e=>{let t=gv(e.target);if(mv&&t===mv){mv=null;return}if(hv){hv=!1,t&&(e.preventDefault(),e.stopPropagation());return}if(!t)return;let n=ev().mode;if(n===`off`&&!iv)return;let r=pv(t);if(!r)return;let i=Bn({mode:n,explain:iv,def:r.def,seen:!!ev().seen[r.id]});i!==`act`&&(e.preventDefault(),e.stopPropagation(),dv(i===`explain`?{...r,intercepted:!1}:{...r,intercepted:!0,proceed:()=>{mv=t,t.click()}}))},!0)}var vv=new Set;function yv(){return ci(z(R.dictateLang)||`auto`)}function bv(e){ua(R.dictateLang,ci(e));for(let e of vv)e()}function xv(){let e=ma(R.dictateLangs,[]);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function Dae(){return Gee(xv(),yv(),Cv())}function Oae(e){Ta(R.dictateLangs,e);for(let e of vv)e()}function Sv(e){return vv.add(e),()=>{vv.delete(e)}}function kae(){let e=yv();return e===`auto`?typeof navigator<`u`&&navigator.language||`en-US`:e}function Cv(){return typeof navigator<`u`&&navigator.language||void 0}function wv(){return z(R.dictateTerms)||``}function Tv(){return Ete(wv())}function Aae(e){ua(R.dictateTerms,e);for(let e of vv)e()}var Ev=R.usage,jae=2e4;function Mae(){try{let e=JSON.parse(z(Ev)||`{}`);return e&&typeof e==`object`?e:{}}catch{return{}}}var Dv=Mae(),Ov={},kv=null,Av=new Set;function jv(){Ta(Ev,Dv)}function q(e){if(!e)return;let t=Dv[e];t?(t.count++,t.last=Date.now()):Dv[e]={count:1,last:Date.now()},Ov[e]=(Ov[e]||0)+1,jv();for(let e of Av)e();kv===null&&(kv=window.setTimeout(()=>{kv=null,Nv()},jae))}function Mv(e){return Dv[e]?.count??0}function Nv(e=!1){let t=Ov;if(!Object.keys(t).length)return;Ov={};let n=JSON.stringify({counts:t});e&&typeof navigator<`u`&&navigator.sendBeacon?navigator.sendBeacon(`/api/ui-usage`,new Blob([n],{type:`application/json`}))||Pv(t):H.uiUsage.flush(n).catch(()=>Pv(t))}function Pv(e){for(let[t,n]of Object.entries(e))Ov[t]=(Ov[t]||0)+n}async function Nae(){return H.uiUsage.get()}async function Pae(){Dv={},Ov={},jv();for(let e of Av)e();await H.uiUsage.reset()}typeof document<`u`&&document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`hidden`&&Nv(!0)}),typeof window<`u`&&window.addEventListener(`pagehide`,()=>Nv(!0));function Fae(e){let t=0,n=0;for(let r of e)r.working&&t++,n+=Math.max(0,r.agents|0);return{sessions:t,subagents:n,total:t+n}}var Fv={warn:10,alarm:30},Iae=[3,5,8,10,15,20,25,30,40,50,75,100];function Iv(e,t){return typeof e==`number`&&Number.isInteger(e)&&e>=0&&e<=999?e:t}function Lv(e){let t=e&&typeof e==`object`?e:{};return{warn:Iv(t.warn,Fv.warn),alarm:Iv(t.alarm,Fv.alarm)}}function Rv(e,t){return t.alarm>0&&e>t.alarm?`alarm`:t.warn>0&&e>t.warn?`warn`:`ok`}var zv={ok:0,warn:1,alarm:2};function Lae(e,t){return zv[t]>zv[e]}function Bv(e){let t=`${e.sessions} session${e.sessions===1?``:`s`} working`,n=`${e.subagents} subagent${e.subagents===1?``:`s`}`;return`${e.total} agent${e.total===1?``:`s`} running at once on the desktop: ${t} + ${n}`}function Rae(e,t,n){let r=t===`alarm`?n.alarm:n.warn;return`${Bv(e)} — more than your ${t===`alarm`?`limit`:`warning`} of ${r}`}function zae(){return Lv(ma(R.agentWarn,null))}function Bae(e){Ta(R.agentWarn,Lv(e))}var Vae=1e4;function Hae(e,t,n=360){let r=[...e,t];return r.length>n?r.slice(r.length-n):r}function Vv(e,t=e=>e.total){let n=[];for(let r=0;r<e.length;r++)r>0&&e[r].at-e[r-1].at>3e4&&n.push(null),n.push(t(e[r]));return n}function Uae(e,t){return e===`ok`?!1:t==null||zv[e]>zv[t]}function Wae(e){let t=e=>e.agents.length+ +!!e.working;return e.filter(e=>t(e)>0).sort((e,n)=>t(n)-t(e)||e.label.localeCompare(n.label))}var Hv={count:null,rows:[],samples:[],level:`ok`,dismissed:null},Uv=new Set,Wv=null;function Gv(e){Hv=e;for(let e of Uv)e(Hv)}function Kv(){let e=Hv.count;e&&Gv({...Hv,samples:Hae(Hv.samples,{at:Date.now(),...e})})}function Gae(e,t,n){let r=!Hv.count||Hv.count.total!==e.total||Hv.count.sessions!==e.sessions||Hv.count.subagents!==e.subagents;Gv({...Hv,count:e,rows:t,level:n,dismissed:n===`ok`?null:Hv.dismissed}),r&&Kv(),!Wv&&typeof window<`u`&&(Wv=setInterval(Kv,Vae))}function Kae(){Gv({...Hv,dismissed:Hv.level})}function qv(e){let t=(0,V.useRef)(e);t.current=e;let[n,r]=(0,V.useState)(()=>e(Hv));return(0,V.useEffect)(()=>{let e=e=>{let n=t.current(e);r(e=>Object.is(e,n)?e:n)};return Uv.add(e),e(Hv),()=>{Uv.delete(e)}},[]),n}var Jv=()=>qv(e=>e.count),qae=()=>qv(e=>Uae(e.level,e.dismissed));function Yv(e,t,n=!1){return{load:()=>t(z(e)),save:t=>ua(e,qh(t)),keys:n?[e]:void 0}}function Jae(){let e=z(R.typingRoom);if(e!=null)return e===`1`;try{return window.matchMedia?.(`(pointer: coarse)`).matches??!1}catch{return!1}}var Xv=Zre({saver:{load:Xh,save:eie},bgFresh:{load:rg,save:oie},autoSend:Yv(R.autoSend,Kh,!0),serialSessions:Yv(R.serialSessions,Kh,!0),confirmQueue:Yv(R.confirmQueue,Kh,!0),confirmClose:Yv(R.confirmClose,Kh,!0),updatesAutoCheck:{load:()=>![`false`,`0`,`off`].includes((z(R.updatesAutoCheck)??``).trim().toLowerCase()),save:e=>ua(R.updatesAutoCheck,e?`true`:`false`),keys:[R.updatesAutoCheck]},dismissedSelfUpdate:{load:()=>z(R.dismissedSelfUpdate)||``,save:e=>ua(R.dismissedSelfUpdate,e)},launchAsk:{load:()=>fa(R.launchAsk),save:e=>sa(R.launchAsk,e),keys:[R.launchAsk]},spendWarn:{load:()=>Xee(ma(R.spendWarn,null)),save:e=>Ta(R.spendWarn,e),keys:[R.spendWarn],same:(e,t)=>JSON.stringify(e)===JSON.stringify(t)},closeWhenDone:{load:()=>fa(R.closeWhenDone),save:e=>sa(R.closeWhenDone,e),keys:[R.closeWhenDone]},localSessions:{load:()=>z(R.localSessions)??``,save:e=>e?ua(R.localSessions,e):wa(R.localSessions),keys:[R.localSessions]},agentWindowWarn:{load:()=>z(R.agentWindowWarn)??``,save:e=>e?ua(R.agentWindowWarn,e):wa(R.agentWindowWarn),keys:[R.agentWindowWarn]},agentWarn:{load:zae,save:Bae,keys:[R.agentWarn],same:(e,t)=>e.warn===t.warn&&e.alarm===t.alarm},enterSends:Yv(R.enterSends,Kh,!0),cliMode:Yv(R.cliMode,Qre),hints:{load:()=>({mode:xae(),seen:nv()}),save:e=>Sae(e.mode),keys:[R.hints],same:(e,t)=>e.mode===t.mode&&e.seen===t.seen},closeKbOnSend:Yv(R.closeKbOnSend,Kh),shortcutCard:Yv(R.shortcutCard,Kh),btwToCli:{load:()=>{let e=z(R.btwToCli);return e===`switch`||e===`stay`?e:``},save:e=>{e?ua(R.btwToCli,e):wa(R.btwToCli)}},busySend:{load:()=>{let e=z(R.busySend);return e===`now`||e===`idle`?e:``},save:e=>{e?ua(R.busySend,e):wa(R.busySend)}},hintChip:{load:()=>{let e=z(R.hintChip);return e===`asked`||e===`hidden`?e:``},save:e=>{e?ua(R.hintChip,e):wa(R.hintChip)}},typingRoom:{load:Jae,save:e=>ua(R.typingRoom,qh(e))},dismissedUpdate:{load:()=>z(R.dismissedUpdate)||``,save:e=>ua(R.dismissedUpdate,e)},netPulse:{load:lp,save:up},localRtBar:{load:Iie,save:Lie},unfoldToEnd:Yv(R.unfoldToEnd,Kh),repoSort:{load:()=>z(R.repoSort)===`name`?`name`:`sessions`,save:e=>{e===`name`?ua(R.repoSort,e):wa(R.repoSort)}},tabsOn:{load:m_,save:aae},tabsN:{load:h_,save:oae},tabsSort:{load:__,save:sae,keys:[R.tabOrderShared]},tabsSync:{load:g_,save:cae},tabsMax:{load:v_,save:pae},toolsMode:{load:X_,save:vae,keys:[R.readerTools]},theme:{load:ag,save:die},txtScale:{load:Nu,save:Yne},icScale:{load:Pu,save:Xne},tZoom:{load:Fu,save:Zne},rZoom:{load:Kne,save:Qne},dictLang:{load:yv,save:bv,reread:!0},dictLangCodes:{load:xv,save:Oae,reread:!0,same:$re},dictTerms:{load:wv,save:Aae,keys:[R.dictateTerms],reread:!0}});function Zv(e){return Xv.use(e)}function Qv(e,t){Xv.set(e,t)}function Yae(){return rr(z(R.agentWindowWarn))}function Xae(e){return Xv.ref(e)}function Zae(e){q(`action:uiscale.term`),Qv(`tZoom`,e)}function Qae(e){q(`action:uiscale.reader`),Qv(`rZoom`,e)}Mm(e=>{Xv.adopt(e)}),Sv(()=>{for(let e of[`dictLang`,`dictLangCodes`,`dictTerms`])Xv.reload(e)});function $ae(e){let t=Object.entries(e);return{lists:new Map(t.map(([e,t])=>[e,t.v])),at:new Map(t.map(([e,t])=>[e,t.at]))}}function eoe(e,t,n,r){let i=new Map(e.lists),a=new Map(e.at);return i.set(t,n),a.set(t,r),{lists:i,at:a}}function toe(e){let t=W($ae(e.load()));return{...t,put(n,r){let i=e.save(n,r)[n]?.at??Date.now();t.set(e=>eoe(e,n,r,i))}}}var noe=3e5;function roe(e,t,n=60){return[t,...e.filter(e=>e.runId!==t.runId)].slice(0,n)}function ioe(e,t,n){return[...n,...e.filter(e=>e.repoDir!==t)]}function aoe(e,t,n,r=noe){let i=(n?``:e)+t;return i.length>r?i.slice(-r):i}function $v(e){let t=toe(e),n=W([]),r=W(0),i=new Map;return{cfgs:t,runs:n,outTick:r,output:i,outputOf:e=>i.get(e)??``,onList(e,r,i){t.put(e,r),n.set(t=>ioe(t,e,i))},onRun(e){let t=roe(n.get(),e),r=new Set(t.map(e=>e.runId));for(let e of i.keys())r.has(e)||i.delete(e);n.set(t)},onOutput(e,t,n,a){i.set(e,aoe(i.get(e)??``,t,n)),a&&r.set(e=>e+1)}}}var ooe=1e5;function soe(e,t=ooe){let n=null,r=new Map,i=(t,n)=>{let i=r.get(t);i&&(r.delete(t),e.clearTimer(i.timer),i.resolve(n))};return{call(a,o,s,c){let l={ok:!1,error:`no connection — the desktop can't be asked from here`};return e.status()===`open`?new Promise(u=>{let d=e.mintId(),f={t:`plugin.call`,plugin:a,method:o,...s===void 0?{}:{args:s},ackId:d},p=e.setTimer(()=>i(d,{ok:!1,error:`${a} did not answer within ${Math.round(t/1e3)} s`}),t);r.set(d,{plugin:a,method:o,read:c,hostId:n,frame:f,timer:p,resolve:u});let m=!1;try{m=e.trySend(f)}catch(e){i(d,{ok:!1,error:`could not reach the desktop: ${e instanceof Error?e.message:String(e)}`});return}if(!m)i(d,l);else if(!c){let e=r.get(d);e&&(e.frame=null)}}):Promise.resolve(l)},onFrame(t){if(t.t===`plugin.reply`){let e=r.get(t.ackId);if(!e||e.plugin!==t.plugin||e.method!==t.method)return;i(t.ackId,t.ok?{ok:!0,result:t.result}:{ok:!1,error:t.error??`${t.plugin} failed`})}else if(t.t===`welcome`){n=t.hostId??null;for(let[t,a]of[...r])if(a.read&&a.hostId!==n)i(t,{ok:!1,error:`the desktop changed before it answered — ask again`});else if(a.read&&a.frame)try{e.trySend(a.frame)}catch{}else i(t,{ok:!1,error:`the link dropped before ${a.plugin} answered — it may have run; look before trying again`})}},pending:()=>r.size,framesHeld:()=>[...r.values()].filter(e=>e.frame!==null).length}}var coe=null;function ey(){return coe??=soe({status:()=>U().conn.status,trySend:e=>U().conn.trySend(e),mintId:ih,setTimer:(e,t)=>setTimeout(e,t),clearTimer:e=>clearTimeout(e)})}function ty(e){let t=(t,n,r)=>{let i=xa(e,t,n);return i===void 0?ey().call(e,t,n,r):Promise.resolve(i)};return{call:(e,n)=>t(e,n,!1),read:(e,n)=>t(e,n,!0)}}var ny=/^[a-z][a-z0-9-]{0,39}$/,ry=/^[a-zA-Z][a-zA-Z0-9-]{0,39}$/;function iy(e){if(!ny.test(e))throw Error(`extStorage: bad plugin id ${JSON.stringify(e)}`);let t=t=>{if(!ry.test(t))throw Error(`extStorage: bad name ${JSON.stringify(t)}`);return _a(e,t)};return{read:(e,n)=>ma(t(e),n),write:(e,n)=>Ta(t(e),n),remove:e=>wa(t(e))}}var ay=W(null),oy=null;function sy(e){oy?.(),ay.set(e.get()),oy=e.subscribe(()=>ay.set(e.get()))}function cy(e,t){let n=e?.find(e=>e.manifest.id===t);return!!n&&n.enabled&&n.state===`active`}function ly(e,t){for(let n of e)if(n.imageText&&t(n.id))return n.imageText;return null}var uy=()=>[];function dy(e){uy=e}function fy(){let e=hy();return(0,V.useMemo)(()=>ly(uy(),t=>cy(e,t)),[e])}function py(e){return cy(ay.get(),e)}function my(e,t){let n=py(e);return t(n),ay.subscribe(()=>{let r=py(e);r!==n&&(n=r,t(r))})}function hy(){return(0,V.useSyncExternalStore)(ay.subscribe,ay.get,ay.get)}function gy(e){return(0,V.useSyncExternalStore)(ay.subscribe,()=>py(e),()=>py(e))}var _y=null;function vy(){return _y===null&&(_y=rt(hu()?ru():null)),_y}function yy(){return y(hu()?ru():null)}var by=8e3;function xy(e){let t=une(e,yy()).catch(()=>{});return Promise.race([t,new Promise(e=>setTimeout(e,by))]).then(()=>e)}var Sy=13;function Cy(e){e.objectStoreNames.contains(`transcripts`)||e.createObjectStore(`transcripts`),e.objectStoreNames.contains(`pty`)||e.createObjectStore(`pty`),e.objectStoreNames.contains(`uploads`)||e.createObjectStore(`uploads`),e.objectStoreNames.contains(`pulls`)||e.createObjectStore(`pulls`),e.objectStoreNames.contains(`tooldetail`)||e.createObjectStore(`tooldetail`),e.objectStoreNames.contains(`screenlog`)||e.createObjectStore(`screenlog`),e.objectStoreNames.contains(`gallery`)||e.createObjectStore(`gallery`),e.objectStoreNames.contains(`artifacttext`)||e.createObjectStore(`artifacttext`),e.objectStoreNames.contains(`thumbs`)||e.createObjectStore(`thumbs`),e.objectStoreNames.contains(`thumbmeta`)||e.createObjectStore(`thumbmeta`),e.objectStoreNames.contains(`tree`)||e.createObjectStore(`tree`),e.objectStoreNames.contains(`ctxseries`)||e.createObjectStore(`ctxseries`),e.objectStoreNames.contains(`tokenstats`)||e.createObjectStore(`tokenstats`),e.objectStoreNames.contains(`dictations`)||e.createObjectStore(`dictations`),e.objectStoreNames.contains(`extassets`)||e.createObjectStore(`extassets`)}var wy=null;function Ty(){return wy||=new Promise(e=>{if(typeof indexedDB>`u`){e(null);return}let t=!1,n=n=>{t||(t=!0,e(n))};try{let e=indexedDB.open(vy(),Sy);e.onupgradeneeded=()=>Cy(e.result),e.onsuccess=()=>{xy(Dy(e.result)).then(n)},e.onerror=()=>n(null),e.onblocked=()=>{Ey().then(e=>e?xy(e):null).then(n)}}catch{n(null)}}).then(e=>(e||(wy=null),e)),wy}function Ey(){return new Promise(e=>{try{let t=indexedDB.open(vy());t.onsuccess=()=>e(Dy(t.result)),t.onerror=()=>e(null),t.onblocked=()=>e(null)}catch{e(null)}})}function Dy(e){let t=()=>{wy&&=null};return e.onversionchange=()=>{e.close(),t()},e.onclose=t,e}async function Oy(e,t,n){try{let r=await Ty();return r?await new Promise(i=>{let a=r.transaction(e,t),o=n(a.objectStore(e));o.onsuccess=()=>i(o.result),o.onerror=()=>i(null),a.onerror=()=>i(null),a.onabort=()=>i(null)}):null}catch(e){return e?.name!==`NotFoundError`&&(wy=null),null}}var ky=(e,t)=>Oy(e,`readonly`,e=>e.get(t)),Ay=async(e,t,n)=>await Oy(e,`readwrite`,e=>e.put(n,t))!==null,jy=async(e,t)=>{await Oy(e,`readwrite`,e=>e.delete(t))},My=async e=>await Oy(e,`readonly`,e=>e.getAll())??[],Ny=async e=>(await Oy(e,`readonly`,e=>e.getAllKeys())??[]).map(String),Py=async(e,t,n)=>{try{let r=await Ty();return r?await new Promise(i=>{let a=0,o=0;try{let s=r.transaction(e,`readonly`),c=s.objectStore(e).openCursor();c.onsuccess=()=>{let e=c.result;if(e){if(!n||n(String(e.key))){a++;try{o+=t(e.value)||0}catch{}}e.continue()}},c.onerror=()=>i(null),s.oncomplete=()=>i({count:a,bytes:o}),s.onerror=()=>i(null),s.onabort=()=>i(null)}catch{i(null)}}):null}catch(e){return e?.name!==`NotFoundError`&&(wy=null),null}},Fy=async e=>{try{let t=await Ty();return t?await new Promise(n=>{try{let r=t.transaction(e,`readwrite`);r.objectStore(e).clear(),r.oncomplete=()=>n(!0),r.onerror=()=>n(!1),r.onabort=()=>n(!1)}catch{n(!1)}}):!1}catch(e){return e?.name!==`NotFoundError`&&(wy=null),!1}},Iy=async(e,t)=>{try{let n=await Ty();return n?await new Promise(r=>{try{let i=n.transaction(e,`readwrite`),a=i.objectStore(e).openCursor();a.onsuccess=()=>{let e=a.result;e&&(t(String(e.key))&&e.delete(),e.continue())},a.onerror=()=>r(!1),i.oncomplete=()=>r(!0),i.onerror=()=>r(!1),i.onabort=()=>r(!1)}catch{r(!1)}}):!1}catch(e){return e?.name!==`NotFoundError`&&(wy=null),!1}},Ly=`extassets`,Ry=/^[a-z][a-z0-9-]{0,39}$/,zy=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;function By(e){if(!Ry.test(e))throw Error(`extAssets: bad plugin id ${JSON.stringify(e)}`);let t=`${e}/`,n=e=>{if(!zy.test(e))throw Error(`extAssets: bad file name ${JSON.stringify(e)}`);return t+e};return{fetch:(t,r)=>(n(t),H.pluginAsset(e,t,r)),get:async e=>{let t=await ky(Ly,n(e));return t instanceof Blob?t:null},put:(e,t)=>Ay(Ly,n(e),t),remove:e=>jy(Ly,n(e)),list:async()=>(await Ny(Ly)).filter(e=>e.startsWith(t)).map(e=>e.slice(t.length)),clear:()=>Iy(Ly,e=>e.startsWith(t))}}var Vy=15e3,Hy=2e3;function Uy(e){let t=new Set,n=new Map,r=new Map,i=!1,a=0,o=(t,n)=>{try{e.report?.(t,n)}catch{}},s=(e,t,n)=>{try{n()}catch(n){o(`${e.plugin}/${e.name} ${t}`,n)}},c=t=>{try{return e.trySend(t)}catch{return!1}},l=t=>{t.reqId&&n.delete(t.reqId),t.reqId=null,t.openTimer!=null&&(e.clearTimer(t.openTimer),t.openTimer=null)},u=t=>{t.streamId!=null&&r.delete(t.streamId),t.streamId=null,t.ackTimer!=null&&(e.clearTimer(t.ackTimer),t.ackTimer=null)},d=(e,n,r,i)=>{l(e),u(e),t.delete(e),e.state=n,e.reason=i,s(e,`onEnded`,()=>e.cb.onEnded?.(r,i))},f=t=>{l(t);let r=e.mintId(),i={t:`stream.open`,reqId:r,plugin:t.plugin,name:t.name,...t.params===void 0?{}:{params:t.params}};t.sentEpoch=a,c(i)?(t.reqId=r,t.sentParams=t.params,n.set(r,t),t.openTimer=e.setTimer(()=>{t.openTimer=null,t.reqId===r&&d(t,`refused`,`refused`,`the desktop did not answer — it may be running an older version without live streams`)},Vy)):t.sentEpoch=-1},p=e=>{e.ackTimer=null,e.streamId!=null&&e.state===`open`&&c({t:`stream.ack`,streamId:e.streamId,seq:e.lastSeq,rxBytes:e.idBytes})},m=()=>{i=!1;for(let e of t)l(e),u(e),e.state=`opening`;n.clear(),r.clear()},h=(e,t)=>{let n=t-Hy,r=0;for(;r<e.samples.length&&e.samples[r].t<=n;)r++;r&&e.samples.splice(0,r)};return{open(n,r,a,o){let s={plugin:n,name:r,params:a,cb:o,state:`opening`,reqId:null,sentParams:void 0,sentEpoch:-1,openTimer:null,streamId:null,closing:!1,openedAt:null,boundAt:0,rxBytes:0,frames:0,idBytes:0,lastSeq:0,ackTimer:null,samples:[]};return t.add(s),i&&f(s),{setParams(e){let t=$n(e);return t<0||t>8192?!1:(s.params=e,s.state===`open`&&s.streamId!=null&&c({t:`stream.params`,streamId:s.streamId,params:e})&&(s.sentParams=e),!0)},input(e){if(s.state!==`open`||s.streamId==null||!i)return!1;let t=$n(e);return t<0||t>4096?!1:c({t:`stream.input`,streamId:s.streamId,ev:e})},keyframe(){s.state===`open`&&s.streamId!=null&&c({t:`stream.keyframe`,streamId:s.streamId})},close(){s.closing||s.state===`ended`||s.state===`refused`||(s.closing=!0,t.delete(s),s.streamId!=null&&c({t:`stream.close`,streamId:s.streamId}),u(s),s.openTimer!=null&&(e.clearTimer(s.openTimer),s.openTimer=null),s.state=`ended`,s.reason=`closed`)},stats(){let t=e.now();h(s,t);let n=Math.max(1,Math.min(Hy,t-s.boundAt)),r=s.samples.reduce((e,t)=>e+t.bytes,0);return{rxBytes:s.rxBytes,frames:s.frames,kbps:s.state===`open`?r*8/n:0,fps:s.state===`open`?s.samples.length*1e3/n:0,openedAt:s.openedAt,streamId:s.streamId,state:s.state,...s.reason===void 0?{}:{reason:s.reason}}}}},onText(o){switch(o.t){case`welcome`:i=!0,a++;for(let e of t)e.state===`opening`&&e.sentEpoch!==a&&f(e);return;case`error`:o.context===`__status`&&o.message!==`open`&&m();return;case`stream.opened`:{let t=n.get(o.reqId);if(!t||(l(t),t.closing)){c({t:`stream.close`,streamId:o.streamId});return}u(t),t.streamId=o.streamId,r.set(o.streamId,t),t.state=`open`;let i=e.now();t.openedAt??=i,t.boundAt=i,t.idBytes=0,t.lastSeq=0,t.samples=[],t.params!==t.sentParams&&c({t:`stream.params`,streamId:o.streamId,params:t.params})&&(t.sentParams=t.params),s(t,`onOpened`,()=>t.cb.onOpened?.(o.streamId));return}case`stream.refused`:{let e=n.get(o.reqId);if(!e)return;if(e.closing){l(e);return}d(e,`refused`,`refused`,o.reason);return}case`stream.status`:{let e=r.get(o.streamId);e&&s(e,`onStatus`,()=>e.cb.onStatus?.(o.data));return}case`stream.ended`:{let e=r.get(o.streamId);e&&d(e,`ended`,o.cause,o.reason);return}default:return}},onBinary(t){let n=Ki(t);if(!n)return;let i=r.get(n.streamId);if(!i||i.state!==`open`)return;let a=n.payload.byteLength,o=e.now();i.rxBytes+=a,i.idBytes+=a,i.frames++,i.lastSeq=n.seq,i.samples.push({t:o,bytes:a}),i.samples.length>512&&h(i,o),i.ackTimer??=e.setTimer(()=>p(i),250),s(i,`onFrame`,()=>i.cb.onFrame(n))},count:()=>t.size}}var Wy=0,Gy=()=>`st-${Date.now().toString(36)}-${(++Wy).toString(36)}`,Ky=null;function qy(){return Ky??=Uy({trySend:e=>U().conn.trySend(e),mintId:Gy,now:()=>Date.now(),setTimer:(e,t)=>setTimeout(e,t),clearTimer:e=>clearTimeout(e),report:(e,t)=>console.error(`${ln} stream callback failed: ${e}`,t)})}function Jy(e,t,n,r){return qy().open(e,t,n,r)}var Yy=`transcripts`,Xy=12;async function Zy(e){let t={sessionId:e.sessionId,savedAt:Date.now(),doc:e};await Ay(Yy,e.sessionId,t),mb()}async function Qy(e){return(await ky(Yy,e))?.doc??null}async function $y(e){let t=await ky(Yy,e);return t?{value:t.doc,savedAt:t.savedAt}:null}var eb=9e4,tb=new Map,nb=new Map;function rb(e,t=!1){let n=nb.get(e);if(n)return n;let r=ib(e,t).finally(()=>{nb.get(e)===r&&nb.delete(e)});return nb.set(e,r),r}async function ib(e,t){let n=Date.now(),r=tb.get(e)??0;if(!(!t&&n-r<eb*(Xh()?4:1))){tb.set(e,n);try{let t=await Qy(e),n=Z_(),r=t&&(t.detail??`full`)===n?t.updatedAt:void 0,i=await H.transcript(e,r,n);i&&await Zy(i)}catch{tb.set(e,r)}}}function ab(e){e?tb.delete(e):tb.clear()}async function ob(e){if(!sb){sb=!0;try{for(let t of e.slice(0,Xy))await rb(t).catch(()=>void 0)}finally{sb=!1}}}var sb=!1,cb=`tooldetail`,lb=60,ub=(e,t)=>`${e}:${t}`;async function db(e,t,n){let r=ub(e,t);await Ay(cb,r,{key:r,savedAt:Date.now(),tools:n}),pb()}async function fb(e,t){return(await ky(cb,ub(e,t)))?.tools??null}async function pb(){let e=await My(cb);if(e.length<=lb)return;let t=[...e].sort((e,t)=>t.savedAt-e.savedAt).slice(lb);for(let e of t)await jy(cb,e.key)}async function mb(){let e=await My(Yy);if(e.length<=Xy)return;let t=[...e].sort((e,t)=>t.savedAt-e.savedAt).slice(Xy);for(let e of t)await jy(Yy,e.sessionId)}var hb=`ctxseries`,gb=12;async function _b(e){await Ay(hb,e.sessionId,{sessionId:e.sessionId,savedAt:Date.now(),doc:e}),yb()}async function vb(e){let t=await ky(hb,e);return t?{value:t.doc,savedAt:t.savedAt}:null}async function yb(){let e=await My(hb);if(e.length<=gb)return;let t=[...e].sort((e,t)=>t.savedAt-e.savedAt).slice(gb);for(let e of t)await jy(hb,e.sessionId)}var bb=`tokenstats`,xb=`all`,Sb=3;async function Cb(e){await Ay(bb,xb,{v:Sb,savedAt:Date.now(),doc:e})}async function wb(){let e=await ky(bb,xb);return!e||e.v!==Sb||!Tb(e.doc)?null:{value:e.doc,savedAt:e.savedAt}}function Tb(e){return!e||typeof e!=`object`||!e.cost||typeof e.cost.total!=`number`||!e.subagentCost||!e.unpriced||!Array.isArray(e.days)||!Array.isArray(e.models)||!Array.isArray(e.repos)?!1:e.days.every(e=>!!e.cost)&&e.models.every(e=>!!e.cost)&&e.repos.every(e=>!!e.cost)}var Eb=e=>/^[a-z][\w.-]*$/.test(e)&&e!==xb?e:null;async function Db(e,t,n){let r=Eb(e);r&&await Ay(bb,r,{v:t,savedAt:Date.now(),doc:n})}async function Ob(e,t,n){let r=Eb(e);if(!r)return null;let i=await ky(bb,r);return!i||i.v!==t||!n(i.doc)?null:{value:i.doc,savedAt:i.savedAt}}var kb=`gallery`,Ab=24;async function jb(e,t,n,r){let i=xt(e,t);await Ay(kb,i,{key:i,scopeKey:e,savedAt:Date.now(),rows:n,truncated:r,kind:t.kind,since:t.since}),Nb()}async function Mb(e,t){let n=await My(kb),r=he(n.filter(t=>t.scopeKey===e),t);if(!r)return null;let i=r.kind===t.kind&&r.since===t.since;return{rows:r.rows,truncated:r.truncated,savedAt:r.savedAt,exact:i}}async function Nb(){let e=await My(kb);if(e.length<=Ab)return;let t=[...e].sort((e,t)=>t.savedAt-e.savedAt).slice(Ab);for(let e of t)await jy(kb,e.key)}var Pb=`tree`,Fb=120,Ib=(e,t)=>`${e}:${t}`;async function Lb(e,t,n){let r=Ib(e,t);await Ay(Pb,r,{key:r,savedAt:Date.now(),listing:n}),zb()}async function Rb(e,t){let n=await ky(Pb,Ib(e,t));return n?{listing:n.listing,savedAt:n.savedAt}:null}async function zb(){let e=await My(Pb);if(e.length<=Fb)return;let t=[...e].sort((e,t)=>t.savedAt-e.savedAt).slice(Fb);for(let e of t)await jy(Pb,e.key)}var Bb=`artifacttext`,Vb=40,Hb=(e,t,n)=>`${e}:${t}:${Math.round(n)}`;async function Ub(e,t,n,r,i){let a=Hb(e,t,n);await Ay(Bb,a,{key:a,savedAt:Date.now(),text:r,truncated:i}),Gb()}async function Wb(e,t,n){let r=await ky(Bb,Hb(e,t,n));return r?{text:r.text,truncated:r.truncated,savedAt:r.savedAt}:null}async function Gb(){let e=await My(Bb);if(e.length<=Vb)return;let t=[...e].sort((e,t)=>t.savedAt-e.savedAt).slice(Vb);for(let e of t)await jy(Bb,e.key)}var Kb=R.slashCache,qb=20;function Jb(){return ma(Kb,{})}function Yb(e){Ta(Kb,e)}function Xb(e){let t=Jb()[e];return t?{value:t.commands,savedAt:t.ts}:null}function Zb(e,t){let n=Jb();delete n[e],n[e]={ts:Date.now(),commands:t};let r=Object.keys(n);if(r.length>qb)for(let e of r.slice(0,r.length-qb))delete n[e];Yb(n)}var Qb=R.snapHistory,$b=20;function ex(){return ma(Qb,{})}function tx(e){Ta(Qb,e)}function nx(){return new Map(Object.entries(ex()))}function rx(e,t){let n=ex();delete n[e],n[e]=t.slice(-50).map(({output:e,...t})=>t);let r=Object.keys(n);if(r.length>$b)for(let e of r.slice(0,r.length-$b))delete n[e];tx(n)}async function ix(e){let t=await Fy(e);return e===Yy&&ab(),t}var ax=()=>[];function ox(e){ax=e}var sx={peerJobs:()=>H.peerJobs(),tokenStats:{read:e=>H.tokenStats(e),fromCache:wb,toCache:Cb},views:()=>ax(),viewDoc:e=>({read:t=>H.backendTokens(e.id,t),fromCache:()=>Ob(e.id,e.cache.shape,e.cache.usable),toCache:t=>Db(e.id,e.cache.shape,t)}),backendTokens:(e,t)=>H.backendTokens(e,t),localUsage:()=>H.localUsage(),usageLog:e=>H.usageLog(e),sourceHistory:async e=>{try{let t=await H.usageLogSource(e);return t&&Array.isArray(t.samples)?t:null}catch{return null}},tokenWindows:(e,t)=>H.tokenWindows(e,t),costWindow:(e,t,n)=>H.costWindow(e,t,n),refreshUsage(e){let t=U();e?t.conn.status===`open`&&t.conn.send({t:`usage.refresh`}):t.conn.liveAsk({t:`usage.refresh`},`no connection — usage is scraped on the desktop`)}},cx=()=>[];function lx(e){cx=e}var ux=e=>cx(e);function dx(e){return/^https?:\/\/[^\s]+$/i.test(e)}function fx(e){return dx(e)?hu()?(location.href=e,!0):!!window.open(e,`_blank`,`noopener,noreferrer`):!1}async function px(e){try{let t=await H.screenshot(e);return t.file?{file:t.file}:{error:t.error||`the desktop gave no reason`}}catch{return{error:`the desktop could not be reached`}}}function mx(e){let t=Ph();return t?.setImmersive?(t.setImmersive(e),!0):!1}var hx=864e5,gx=36e5,_x=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`];35*hx;var vx=e=>e>=100?`$${Math.round(e)}`:_t(e);function yx(e,t){return e?De(e).find(e=>e.periodId===t&&e.unit===`usd`)?.max??null:null}var bx=e=>e.kind===`calendar`?e.cycle===`month`?0:e.cycle===`week`?2:3:e.kind===`rolling`?1:4;function xx(e,t,n=Date.now()){let r=(e??[]).filter(e=>e.period.unit===`usd`&&e.active&&!(e.resetAt!=null&&n>=e.resetAt));if(!r.length)return null;let i=e=>(yx(t,e.period.id)==null?10:0)+bx(e.period);return r.slice().sort((e,t)=>i(e)-i(t))[0]}function Sx(e,t,n){let r=e=>new Intl.DateTimeFormat(`en-US`,{...n,...e?{timeZone:e}:{}}),i;try{i=r(t)}catch{i=r()}let a=Object.fromEntries(i.formatToParts(e).map(e=>[e.type,e.value]));return[[a.day,a.month,a.year].filter(Boolean).join(` `),a.hour&&a.minute?`${a.hour}:${a.minute}`:``].filter(Boolean).join(` `)}var Cx=e=>{let t=e%100;return`${e}${t>=11&&t<=13?`th`:{1:`st`,2:`nd`,3:`rd`}[e%10]??`th`}`};function wx(e){let t=e.period;return t.kind===`calendar`?t.cycle===`month`?Sx(e.start+216e5,t.tz,(t.anchorDay??1)>1?{day:`numeric`,month:`short`}:{month:`short`}):t.cycle===`week`?`wk`:`today`:t.kind===`rolling`?`30d`:`span`}function Tx(e){return e.kind===`calendar`?e.cycle===`month`?`Where the month went`:e.cycle===`week`?`Where this calendar week went`:`Where today went`:e.kind===`rolling`?`Where the last 30 days went`:`Where this span went`}function Ex(e){if(e.kind===`calendar`)return e.cycle===`month`?`calendar month from the ${(e.anchorDay??1)===1?`1st`:Cx(e.anchorDay??1)} · ${e.tz}`:e.cycle===`week`?`calendar week from ${_x[e.startDow??0]} · ${e.tz}`:`each day · ${e.tz}`;if(e.kind===`rolling`)return`rolling 30 days`;let t=e=>Sx(e,void 0,{day:`numeric`,month:`short`,year:`numeric`});return`${t(e.from)} to ${t(e.to-1)}`}function Dx(e,t,n){let r=e.spentUsd??null;if(r==null)return{pace:null,perDay:null,projected:null};let i=Ln(r,e.start,e.resetAt,n);if(t==null)return{pace:null,perDay:null,projected:i};let a=hte(t,r,e.resetAt,n);if(r>=t)return{pace:`over`,perDay:a,projected:i};let o=Ye(t,e.start,e.resetAt,n);if(o==null||o<t*.01)return{pace:null,perDay:a,projected:i};let s=r/o;return{pace:s>1.1?`ahead`:s<.9?`under`:`on`,perDay:a,projected:i}}var Ox={over:`over the cap`,ahead:`ahead of pace`,on:`on pace`,under:`under pace`};function kx(e,t,n){let r=e.spentUsd;if(r==null||!Number.isFinite(r)||e.resetAt!=null&&n>=e.resetAt)return null;let i=Dx(e,t,n),a=`${wx(e)} ${vx(r)}${t==null?``:` / ${vx(t)}`}${i.pace?` · ${Ox[i.pace]}`:``}`,o=[`${vx(r)} spent${t==null?``:` of a ${vx(t)} cap`} · ${Ex(e.period)}`,...e.resetAt==null?[]:[`resets ${Sx(e.resetAt,e.period.kind===`calendar`?e.period.tz:void 0,{day:`numeric`,month:`short`,hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`})}`],...i.perDay==null?[]:[`${vx(i.perDay)}/day left`],...i.projected==null?[]:[`projected ${vx(i.projected)} at the reset`],`this desktop, list price`];return{text:a,hot:t!=null&&r>=t*.8,title:o.join(` · `)}}function Ax(e,t,n){let r=Dx(e,t,n);return[...r.pace?[Ox[r.pace]]:[],...r.perDay!=null&&r.pace!==`over`?[`${vx(r.perDay)}/day left`]:[],...r.projected==null?[]:[`projected ${vx(r.projected)} at the reset`]]}function jx(e,t){let n=e.resetAt!=null&&e.resetAt<=t,r=e.resetAt==null?t:Math.min(e.resetAt,t),i=e.period.kind===`rolling`?Math.ceil(e.start/gx)*gx:e.start;return r<=i?{refusal:`This period has not begun.`}:i%gx!==0||n&&r%gx!==0?{refusal:`This period starts or ends inside an hour, and the desktop keeps its spend by the hour — no breakdown is drawn rather than one that counts the wrong minutes.`}:r-i>3024e6?{refusal:`This span is longer than 35 days, the most the desktop folds in one read — the figure on the chip is unaffected.`}:{from:i,to:r}}function Mx(e,t){let n=new Map,r=e=>{for(let t of e??[]){let e=n.get(t.model)??{model:t.model,label:nt(t.model)??(t.model||`unknown model`),usd:0,tokens:0};e.usd+=t.cost?.total??0,e.tokens+=(t.totals?.input??0)+(t.totals?.output??0)+(t.totals?.cacheRead??0)+(t.totals?.cacheWrite??0),n.set(t.model,e)}};for(let t of e)r(t.byModel);for(let e of t??[])r(e.byModel);return[...n.values()].sort((e,t)=>t.usd-e.usd||t.tokens-e.tokens)}var Nx=[{id:`month`,label:`calendar month`},{id:`week`,label:`calendar week`},{id:`day`,label:`day`},{id:`rolling30d`,label:`rolling 30 days`},{id:`span`,label:`from – to`}],Px=()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}catch{return`UTC`}},Fx=()=>({kind:`month`,anchorDay:`1`,startDow:1,tz:Px(),from:``,to:``}),Ix=e=>{try{return new Intl.DateTimeFormat(`en`,{timeZone:e}),!0}catch{return!1}};function Lx(e,t=0){let n=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e.trim());if(!n)return null;let[r,i,a]=[Number(n[1]),Number(n[2]),Number(n[3])],o=new Date(r,i-1,a);return o.getFullYear()!==r||o.getMonth()!==i-1||o.getDate()!==a?null:new Date(r,i-1,a+t).getTime()}function Rx(e){let t=e.tz.trim();if((e.kind===`month`||e.kind===`week`||e.kind===`day`)&&(!t||!Ix(t)))return{ok:!1,reason:`“${t}” is not a time zone — try Europe/Berlin or America/New_York`};if(e.kind===`month`){let n=Number(e.anchorDay.trim().replace(/(st|nd|rd|th)$/i,``));return!Number.isInteger(n)||n<1||n>31?{ok:!1,reason:`the billing day is a whole number from 1 to 31`}:{ok:!0,period:{id:`month`,kind:`calendar`,unit:`usd`,cycle:`month`,anchorDay:n,tz:t}}}if(e.kind===`week`)return{ok:!0,period:{id:`calweek`,kind:`calendar`,unit:`usd`,cycle:`week`,startDow:e.startDow,tz:t}};if(e.kind===`day`)return{ok:!0,period:{id:`day`,kind:`calendar`,unit:`usd`,cycle:`day`,tz:t}};if(e.kind===`rolling30d`)return{ok:!0,period:{id:`rolling30d`,kind:`rolling`,unit:`usd`,lenMs:30*hx,scraped:!1}};let n=Lx(e.from),r=Lx(e.to,1);return n==null||r==null?{ok:!1,reason:`type both days as YYYY-MM-DD`}:r<=n?{ok:!1,reason:`the last day has to be on or after the first`}:n%gx!==0||r%gx!==0?{ok:!1,reason:`this phone's midnight is not on a whole UTC hour, and the desktop keeps spend by the hour — a span here would count the wrong minutes`}:{ok:!0,period:{id:`span-${e.from.trim()}`,kind:`span`,unit:`usd`,from:n,to:r}}}function zx(e){let t=e.claudeSessionId?.trim();return t?[`Explain what made one Claude Code session expensive, and outline how it could have been cheaper. Do NOT implement anything — no edits, no commits, no settings changes. This is an analysis; at the end, list the ideas and ask me which (if any) to implement.`,``,`The session: "${e.title}"`,`- working directory: ${e.cwd}`,`- conversation id: ${t}${e.model?`\n- model: ${e.model}`:``}`,`- transcript: find it with \`ls ~/.claude/projects/*/${t}.jsonl\` — its subagents' logs are under ${t}/subagents/ beside it, if that exists.`,``,`The transcript may be very large. Measure it with a script (node or jq over the JSONL "usage" fields), never by reading it whole into this conversation.`,``,`Find out:`,`1. The totals split by token kind (input, cache write, cache read, output) and by main conversation vs subagents, with a list-price estimate for the model(s) used.`,`2. How the context grew turn by turn: the turns where it jumped and what caused each jump (large tool results, file dumps, images, long outputs, pasted content, skill or CLAUDE.md loads).`,`3. Cache behaviour: cache writes after gaps long enough for the cache to expire, compactions, and what they cost.`,`4. The subagents: how many, what each was for, what each cost, and whether any duplicated work.`,`5. The always-on baseline: the size of the first turn's context (system prompt, CLAUDE.md, skill descriptions, tools, MCP servers) and how much of the total it accounts for across all turns.`,`6. Whether the work should have been split into separate sessions, and where.`,``,`Then give concrete, actionable ideas ranked by estimated saving, each naming what to change (a CLAUDE.md or skill trim, a habit, a subagent instead of inline reading, an earlier /compact or fresh session, a setting) and roughly how much it would have saved on this session. Keep the answer short and lead with the three biggest causes.`].join(`
4
+ `):null}var Bx=Oa(),Vx=6048e5,Hx=36e5;function Ux(e,t){return!e||e.weeklyPct==null||e.weeklyResetAt==null||e.weeklyPct<5||e.weeklyResetAt<=t||e.checkedAt-(e.weeklyResetAt-6048e5)<Hx?null:`${e.weeklyResetAt}:${e.checkedAt}:${e.weeklyPct}`}function Wx(e,t,n){if(O(e?.profile))return{kind:`windows`};let r=xx(t?.periods,t?.budget,n),i=r?kx(r,yx(t?.budget,r.period.id),n):null;return i?{kind:`usd`,chip:i}:{kind:`door`}}function Gx(e,t){if(e)return[...e];let n=lte(t);return n?[n]:[]}function Kx(e,t){let n=t?e.filter(e=>e.backend===t):[];return n.length?n:e.filter(e=>e.backend==null)}function qx(e,t){let n=new Set(t.filter(e=>e.running).map(e=>e.backend??`claude`));return e.filter(e=>e.source===`claude`||e.backend==null||e.backend===`claude`||n.has(e.backend))}function Jx(e){let t=t=>e.windows.find(e=>e.id===t),n=t(`session`),r=t(`week`);return{sess:n?Cr(n):null,sessResetAt:n?.resetAt??null,wk:r?Cr(r):null}}var Yx=e=>({sess:e?.sessionPct??null,sessResetAt:e?.sessionResetAt??null,wk:e?.weeklyPct??null}),Xx=(e,t)=>t?.ok?Yx(t):Jx(e),Zx=e=>(e.sess??0)>=80||(e.wk??0)>=80,Qx=e=>e===`claude`?null:e;function $x(e,t){return!!t&&e.length>0&&!e.some(e=>e.source===`claude`)}var eS=e=>e?.length?`\n+ ${e.join(`, `)} not shown here`:``,tS=W(null);function nS(){return G(tS)}var rS=W(null),iS=36e5;function aS(){let e=G(tS),t=G(rS);return!t||!e||Ux(e,Date.now())==null?null:Math.abs(t.resetAt-e.weeklyResetAt)<iS?t.usdPerPct:null}function oS(){let e=G(tS),t=G(rS);return!t?.incl||!e||Ux(e,Date.now())==null?null:Math.abs(t.resetAt-e.weeklyResetAt)<iS?t.incl:null}var sS=W(null),cS=W([]),lS=()=>G(cS),uS=W(null),dS=()=>cS.get(),fS=()=>uS.get();function pS(e){uS.set(e),U().nav.open(`tokens`)}var mS=()=>uS.set(null),hS=()=>G(sS);function gS(){let e=G(sS),t=Dh().world.budget;return Wx(e,t,Date.now())}var _S=null;function vS(e){let t=Ux(e,Date.now());if(!e||!t||t===_S||rS.get()?.key===t)return;_S=t;let n=e.weeklyResetAt-Vx;Promise.all([sx.tokenWindows([{id:`weekcal`,anchor:e.checkedAt,lenMs:e.checkedAt-n}]),sx.peerJobs().catch(()=>null)]).then(([r,i])=>{let a=r.series.find(e=>e.id===`weekcal`)?.windows.find(e=>e.back===0),o=Mte(i,n,e.checkedAt),s=a?.cost.total,c=F(s!=null&&s>0?s+(o?.usd??0):s,e.weeklyPct);c!=null&&Ux(tS.get(),Date.now())===t&&rS.set({key:t,resetAt:e.weeklyResetAt,usdPerPct:c,...o?{incl:o.text}:{}})}).catch(()=>void 0).finally(()=>{_S===t&&(_S=null)})}var J=ka();function yS({options:e,value:t,onChange:n,label:r,className:i}){let a=(0,V.useRef)([]),o=e.findIndex(e=>e.key===t),s=(t,r)=>{let i=t.key===`ArrowDown`||t.key===`ArrowRight`?1:t.key===`ArrowUp`||t.key===`ArrowLeft`?-1:0;if(!i||e.length===0)return;t.preventDefault();let o=(r+i+e.length)%e.length;a.current[o]?.focus(),n(e[o].key)};return(0,J.jsx)(`div`,{role:`radiogroup`,"aria-label":r,className:i?`radio-rows ${i}`:`radio-rows`,children:e.map((e,t)=>{let r=t===o;return(0,J.jsxs)(`button`,{ref:e=>{a.current[t]=e},type:`button`,role:`radio`,"aria-checked":r,tabIndex:r||o<0&&t===0?0:-1,className:r?`radio-row on`:`radio-row`,title:e.title,onClick:()=>{r||n(e.key)},onKeyDown:e=>s(e,t),children:[(0,J.jsx)(`span`,{className:`radio-dot`,"aria-hidden":!0}),(0,J.jsxs)(`span`,{className:`radio-label`,children:[e.label,e.note!=null&&(0,J.jsx)(`span`,{className:`radio-note`,children:e.note})]})]},e.key)})})}var bS=[{id:`sessions`,title:`Sessions`},{id:`notifications`,title:`Notifications`},{id:`appearance`,title:`Appearance`},{id:`writing`,title:`Writing & reading`},{id:`offline`,title:`Offline & data`},{id:`connection`,title:`Connection`},{id:`tools`,title:`Tools & diagnostics`}],xS=[{id:`launch-backend`,group:`sessions`,label:`backend`,keywords:`binary claude engine which runs cli plugin`},{id:`launch-model`,group:`sessions`,label:`model`,keywords:`opus sonnet haiku alias version local hosted default`},{id:`launch-effort`,group:`sessions`,label:`effort`,keywords:`reasoning thinking depth high low`},{id:`launch-permission`,group:`sessions`,label:`permission mode`,keywords:`approvals dangerous skip ask tool calls yolo bypass`},{id:`launch-remote`,group:`sessions`,label:`remote control`,keywords:`claude.ai steer remote-control`},{id:`launch-ask`,group:`sessions`,label:`ask before each launch`,keywords:`prompt every time silently defaults pick`},{id:`spend-warn`,group:`sessions`,label:`spend marks`,keywords:`cost warning orange red triangle threshold dollars percent week alert expensive api`},{id:`confirm-close`,group:`sessions`,label:`ask before closing a session`,keywords:`close confirm uncommitted unmerged warning don't ask again dialog`},{id:`close-when-done`,group:`sessions`,label:`close automatic sessions when done`,keywords:`backlog scheduled linger keep open reap slot auto-close`},{id:`local-sessions`,group:`sessions`,label:`local model sessions at once`,keywords:`ollama qwen gpu runner local model limit cap one at a time concurrent`},{id:`hosted-notice`,group:`sessions`,label:`hosted-model notice`,keywords:`privacy disclaimer acknowledge server third party leaves machine`},{id:`limit-auto`,group:`sessions`,label:`auto-continue after a usage limit`,keywords:`rate limit resume reset blocked wall resurrect`},{id:`budget`,group:`sessions`,label:`usage budget`,keywords:`reserve headroom pause unattended percent ceiling session window`},{id:`budget-session`,group:`sessions`,label:`session ceiling`,keywords:`5-hour window percent reserve pause headroom`},{id:`budget-weekly`,group:`sessions`,label:`weekly ceiling`,keywords:`week cap percent reserve`},{id:`budget-leftover`,group:`sessions`,label:`leftovers in a new week`,keywords:`leftover reset week spare budget before reset waiver`},{id:`billing-profile`,group:`sessions`,label:`billing profile`,keywords:`api key subscription bedrock vertex cloud account detect override console`},{id:`billing-periods`,group:`sessions`,label:`dollar periods and caps`,keywords:`month monthly week day spend cap budget dollars billing cycle anchor rolling span time zone limit`},{id:`ask-rules`,group:`sessions`,label:`ask before`,keywords:`ask rules permission confirm git push force main master deploy publish dangerous irreversible guard tap prod release`},{id:`auto-compact-default`,group:`sessions`,label:`auto-compact window`,keywords:`autoCompactWindow compact context 400k repo setup settings.json threshold`},{id:`notif-feed`,group:`notifications`,label:`open the feed`,keywords:`alerts unread inbox in-app list bell notification`},{id:`notif-kinds`,group:`notifications`,label:`what may fire`,keywords:`mute kinds needs you limit cli backlog prompt not delivered per type`},{id:`phone-setup`,group:`notifications`,label:`phone setup`,keywords:`permission allow android background notifications install unknown apps checklist`},{id:`notif-push`,group:`notifications`,label:`OS push`,keywords:`web push system notification https secure context service worker`},{id:`notif-shell-link`,group:`notifications`,label:`background link`,keywords:`android apk foreground service app closed freezer wake`},{id:`notif-shell-battery`,group:`notifications`,label:`allow background use`,keywords:`battery doze exemption reboot android optimisation optimization`},{id:`theme`,group:`appearance`,label:`theme`,keywords:`dark light mode night follow device colour color scheme`},{id:`text-size`,group:`appearance`,label:`text size`,keywords:`font bigger smaller larger zoom readable accessibility scale`},{id:`icon-size`,group:`appearance`,label:`icon size`,keywords:`glyph bigger smaller tap target thumb scale`},{id:`terminal-zoom`,group:`appearance`,label:`terminal size`,keywords:`console font columns rows grid pty wrap diff cli zoom`},{id:`repo-colours`,group:`appearance`,label:`repo colours`,keywords:`color hue ring pin per repo tab stripe colour blind cvd`},{id:`tabs`,group:`appearance`,label:`session tabs`,keywords:`strip open sessions switch between bar top`},{id:`tabs-count`,group:`appearance`,label:`tabs that fit`,keywords:`how many width narrower wider strip`},{id:`tabs-limit`,group:`appearance`,label:`most tabs shown`,keywords:`limit cap max maximum how many strip hide`},{id:`tabs-order`,group:`appearance`,label:`tab order`,keywords:`sort opened frequent recent where was i`},{id:`tabs-sync`,group:`appearance`,label:`same tab order on every device`,keywords:`sync share phone desktop devices order opened recent across`},{id:`repo-order`,group:`appearance`,label:`repo order`,keywords:`launcher sort alphabetical sessions open busiest list repos rank`},{id:`unfold-to-end`,group:`appearance`,label:`unfolding a repo shows its last row`,keywords:`launcher expand collapse fold scroll bottom end list sessions chevron`},{id:`net-pulse`,group:`appearance`,label:`connection strip`,keywords:`ping latency graph round trip bar link live network`},{id:`local-rt`,group:`appearance`,label:`desktop strip`,keywords:`local runner ollama lm studio model loaded memory pressure cpu gpu utilization machine mac bar`},{id:`agent-warn`,group:`appearance`,label:`warn above this many agents`,keywords:`parallel subagents running at once count concurrent amber notice threshold`},{id:`agent-alarm`,group:`appearance`,label:`alarm above this many agents`,keywords:`parallel subagents running at once count concurrent red limit threshold too many`},{id:`ui-reset`,group:`appearance`,label:`reset UI settings to default`,keywords:`restore defaults factory look layout hidden buttons theme size zoom tabs strips`},{id:`enter-sends`,group:`writing`,label:`what Return does`,keywords:`enter key send newline keyboard compose submit`},{id:`dictate-lang`,group:`writing`,label:`dictation is read as`,keywords:`voice speech microphone mic whisper language german english translate transcribe auto detect`},{id:`dictate-langs`,group:`writing`,label:`languages on the microphone`,keywords:`voice speech dictation picker list offer languages mic which`},{id:`dictate-terms`,group:`writing`,label:`words dictation should know`,keywords:`voice speech vocabulary glossary dictionary custom terms names jargon misheard recognise spelling whisper prompt`},{id:`close-kb-on-send`,group:`writing`,label:`keyboard after Send`,keywords:`keyboard close hide dismiss blur send focus`},{id:`shortcut-card`,group:`writing`,label:`hold Ctrl to see shortcuts`,keywords:`keyboard shortcut shortcuts chord hotkey cheat sheet ctrl cmd command alt option modifier hold card`},{id:`busy-send`,group:`writing`,label:`Send while it works`,keywords:`send busy working turn running queue when free ask now wait`},{id:`btw-to-cli`,group:`writing`,label:`/btw from the reader`,keywords:`btw aside overlay cli terminal switch ask reader`},{id:`typing-room`,group:`writing`,label:`typing room`,keywords:`hide chrome header keyboard space terminal rows full`},{id:`reader-tools`,group:`writing`,label:`tool calls in the reader`,keywords:`transcript fold list full download details offline`},{id:`hints-mode`,group:`writing`,label:`button hints`,keywords:`explain long press help tooltip first time`},{id:`hints-explain`,group:`writing`,label:`explain mode`,keywords:`help what does this button do tap`},{id:`hints-chip`,group:`writing`,label:`? button in the headers`,keywords:`help question mark explain chip hide remove space header launcher`},{id:`hints-reset`,group:`writing`,label:`explain them again`,keywords:`reset dismissed hints help`},{id:`install`,group:`offline`,label:`install this app`,keywords:`pwa home screen add standalone chrome ios safari`},{id:`auto-send`,group:`offline`,label:`auto-send the queue`,keywords:`offline queued messages reconnect deliver hold send now`},{id:`serial-sessions`,group:`offline`,label:`one session at a time per repo`,keywords:`queue parallel serialize worktree agents limit`},{id:`confirm-queue`,group:`offline`,label:`ask on reconnect`,keywords:`queue review before sending offline drafts stale`},{id:`queue-manage`,group:`offline`,label:`manage the queue`,keywords:`queued messages waiting outbox`},{id:`bg-fresh`,group:`offline`,label:`in the background`,keywords:`battery drain power hidden background stream offline dead zone fresh latest screen catch up`},{id:`data-saver`,group:`offline`,label:`data saver`,keywords:`roaming hotel bandwidth smaller images polling mobile`},{id:`downloads`,group:`offline`,label:`downloads`,keywords:`pull files artifacts background fetch resume auto`},{id:`upload-scale`,group:`offline`,label:`upload size`,keywords:`image width shrink annotator camera photo auto slow link`},{id:`hosts`,group:`connection`,label:`hosts`,keywords:`desktop address daemon apk android pair change ip switch add remove lan wifi peer desktops tailnet tailscale computer machine`},{id:`code-folder`,group:`connection`,label:`Code folder`,keywords:`root repos folder scan dev projects directory path where desktop host workspace env variable`},{id:`add-desktop`,group:`connection`,label:`add a desktop`,keywords:`new desktop host computer machine pc mac linux windows tailnet tailscale found discover scan add pair peer`},{id:`web-desktops`,group:`connection`,label:`another desktop, without the app`,keywords:`browser web pwa no app without apk iphone ios pair second desktop another phone home screen address tailnet code`},{id:`demo`,group:`connection`,label:`try the demo`,keywords:`demo sample example pretend fake tour first look leave play store reviewer`},{id:`pair-phone`,group:`connection`,label:`pair another phone`,keywords:`qr code pairing new phone add device scan invite tailscale`},{id:`paired-devices`,group:`connection`,label:`paired devices`,keywords:`revoke sign in token phones ledger last seen remove device`},{id:`app-version`,group:`connection`,label:`app version`,keywords:`apk update build install shell android`},{id:`endpoints`,group:`connection`,label:`how you reach this host`,keywords:`url address lan tailscale https tunnel origin reopen connection`},{id:`lan-password`,group:`connection`,label:`LAN password`,keywords:`auth gate local network secure token login public`},{id:`lan-gate-tailscale`,group:`connection`,label:`gate Tailscale too`,keywords:`password auth peers trusted`},{id:`lan-logout`,group:`connection`,label:`log out this device`,keywords:`auth token sign out lan`},{id:`sync-push`,group:`connection`,label:`push this device's settings`,keywords:`sync host copy conflict templates presets pad toolbar wins`},{id:`token-stats`,group:`tools`,label:`token statistics`,keywords:`usage cost spend money per day model repo cache history tokens`},{id:`tool-secret`,group:`tools`,label:`secret`,keywords:`api key write only env credential`},{id:`desktop-setup`,group:`tools`,label:`desktop setup`,keywords:`checklist mac screen recording accessibility permission grant live desktop helper privacy security system settings`},{id:`tool-repo-setup`,group:`tools`,label:`repo setup`,keywords:`checklist gitignore claude.md context weight check fix`},{id:`tool-speedtest`,group:`tools`,label:`speed test`,keywords:`bandwidth latency diagnostics connection throughput`},{id:`tool-net-health`,group:`tools`,label:`connection health`,keywords:`link prompts delivery retries lost dropped`},{id:`tool-storage`,group:`tools`,label:`storage`,keywords:`space full disk bytes cache clear downloads thumbnails quota evicted free up`},{id:`tool-cli-health`,group:`tools`,label:`CLI health`,keywords:`heuristics detector hook echo probe conversation log broken degraded`},{id:`tool-features`,group:`tools`,label:`feature usage`,keywords:`which features used never analytics track`},{id:`tool-host-stat`,group:`tools`,label:`host stat`,keywords:`cpu memory load desktop mac pressure temperature`},{id:`tool-screenshot`,group:`tools`,label:`screenshot the desktop`,keywords:`capture screen mac image`},{id:`tool-updates`,group:`tools`,label:`updates`,keywords:`update self plugin install available new version restart roll back`},{id:`tool-decisions`,group:`tools`,label:`decision log`,keywords:`activity auto-continue usage limit what a plugin answered suggested history archive`},{id:`updates-auto`,group:`tools`,label:`check daily for updates`,keywords:`update plugin automatic check github new version`},{id:`plugins`,group:`tools`,label:`plugins`,keywords:`plugin extension add-on installed oracle gemini enable disable`}],SS=new Map(xS.map(e=>[e.id,e])),CS=new Map(bS.map(e=>[e.id,e]));function wS(e){let t=CS.get(e.group);return[e.label,e.keywords,t?.title,e.id.replace(/-/g,` `)].filter(Boolean).join(` `).toLowerCase()}var TS=new Map(xS.map(e=>[e.id,wS(e)])),ES=[];function DS(e){for(let t of e)SS.has(t.id)||(ES.push(t),SS.set(t.id,t),TS.set(t.id,wS(t)))}var OS=new Map;function kS(e,t){OS.set(e,t.toLowerCase())}function AS(e,t){let n=t.trim().toLowerCase();if(!n)return!0;let r=TS.get(e);return r==null||jS(OS.has(e)?`${r} ${OS.get(e)}`:r,n)}function jS(e,t){let n=t.trim().toLowerCase();if(!n)return!0;let r=e.toLowerCase();return n.split(/\s+/).every(e=>r.includes(e))}function MS(e,t,n){if(!n.trim())return!0;let r=TS.get(e);return r!=null&&jS(r,n)?!0:jS(t,n)}function NS(e,t){return!t.trim()||[...xS,...ES].some(n=>n.group===e&&AS(n.id,t))}function PS(e,t,n){return n?e===n:AS(e,t)}function FS(e,t,n){return n?SS.get(n)?.group===e:NS(e,t)}function IS(e){return SS.get(e)}function LS(e,t,n,r){if(r){let n=SS.get(r)?.label??r;return e===0?`“${n}” is not on this screen right now — ${t} settings here`:`showing “${n}” only — ${e} of ${t} settings`}let i=n.trim();return i?e===0?`nothing matches “${i}” — ${t} settings on this screen`:`${e} of ${t} settings match “${i}”`:``}function RS(e,t){return`key`+(e===void 0?``:` ${e}`)+(t!==void 0&&t!==``?` ${t}`:``)}var Y=(0,V.forwardRef)(function({variant:e,className:t,...n},r){return(0,J.jsx)(`button`,{className:RS(e,t),...n,ref:r})});function zS(e,t){return`form-hint`+(e?` ${e}`:``)+(t?` ${t}`:``)}function BS(e,t){return`tag`+(e?` ${e}`:``)+(t?` ${t}`:``)}function VS(e){return`set-note`+(e?` ${e}`:``)}var HS=16,US=(0,V.createContext)(null);function WS(e,t=null){return{query:e,only:t,seen:[],shown:[]}}function GS({value:e,children:t}){return(0,J.jsx)(US.Provider,{value:e,children:t})}function KS(e){let t=(0,V.useContext)(US);if(!t||!e)return!0;t.seen.push(e);let n=PS(e,t.query,t.only);return n&&t.shown.push(e),n}function qS(e,t){let n=(0,V.useContext)(US);return!n||n.only?!0:MS(e,t,n.query)}function X(e){let{children:t,more:n}=e;if(!t&&!n)return null;if(!n){let{as:n,className:r,children:i,more:a,...o}=e;return(0,V.createElement)(n??`div`,{className:VS(r),...o},t)}return(0,J.jsxs)(`details`,{className:`set-note set-more`,children:[(0,J.jsx)(`summary`,{children:t}),(0,J.jsx)(`div`,{className:`set-more-body`,children:n})]})}function JS(e){return(0,V.createElement)(`div`,{className:`set-row`,...e})}function YS({tone:e=`bad`,icon:t,children:n}){return(0,J.jsxs)(`div`,{className:`set-note${e===`bad`?` oracle-warn`:``}`,children:[t&&(0,J.jsx)(t,{size:13,style:{verticalAlign:`-2px`,marginRight:4}}),n]})}function XS({id:e,title:t,icon:n,children:r}){let i=(0,V.useContext)(US),a=!!i&&!FS(e,i.query,i.only);return(0,J.jsxs)(`section`,{className:`set-group${a?` gone`:``}`,"data-group":e,children:[(0,J.jsxs)(`h3`,{className:`set-title`,children:[n&&(0,J.jsx)(n,{size:14,style:{verticalAlign:`-2px`,marginRight:5}}),t]}),r]})}function ZS({id:e,label:t,icon:n,on:r,onChange:i,state:a,tone:o,note:s,more:c,children:l}){return KS(e)?(0,J.jsxs)(`div`,{className:`set-item`,children:[(0,J.jsxs)(`button`,{className:`set-sw${r?` on`:``}${o===`danger`?` danger`:``}`,"aria-pressed":r,onClick:i,children:[n&&(0,J.jsx)(n,{size:HS,className:`set-ico`}),(0,J.jsx)(`span`,{className:`set-lbl`,children:t}),(0,J.jsx)(`span`,{className:`set-state`,children:a??(r?`on`:`off`)})]}),(0,J.jsx)(X,{more:c,children:s}),l]}):null}function QS({id:e,label:t,icon:n,value:r,options:i,onChange:a,note:o,more:s,radio:c,children:l}){return KS(e)?(0,J.jsxs)(`div`,{className:`set-item`,children:[(0,J.jsxs)(`div`,{className:`set-lead`,children:[n&&(0,J.jsx)(n,{size:HS,className:`set-ico`}),(0,J.jsx)(`span`,{className:`set-lbl`,children:t})]}),c?(0,J.jsx)(yS,{label:typeof t==`string`?t:void 0,value:String(r),options:i.map(e=>({key:String(e.value),label:e.label,title:e.title})),onChange:e=>{let t=i.find(t=>String(t.value)===e);t&&a(t.value)}}):(0,J.jsx)(`div`,{className:`set-chips`,children:i.map(e=>(0,J.jsxs)(Y,{className:r===e.value?`active`:``,style:e.style,title:e.title,onClick:()=>a(e.value),children:[e.icon&&(0,J.jsx)(e.icon,{size:HS}),` `,e.label]},String(e.value)))}),(0,J.jsx)(X,{more:s,children:o}),l]}):null}function $S({id:e,label:t,icon:n,value:r,options:i,onChange:a,note:o,more:s,children:c}){if(!KS(e))return null;let l=new Set(r);return(0,J.jsxs)(`div`,{className:`set-item`,children:[(0,J.jsxs)(`div`,{className:`set-lead`,children:[n&&(0,J.jsx)(n,{size:HS,className:`set-ico`}),(0,J.jsx)(`span`,{className:`set-lbl`,children:t})]}),(0,J.jsx)(`div`,{className:`set-chips`,children:i.map(e=>(0,J.jsxs)(Y,{className:l.has(e.value)?`active`:``,"aria-pressed":l.has(e.value),title:e.title,onClick:()=>a(i.map(e=>e.value).filter(t=>t===e.value?!l.has(t):l.has(t))),children:[e.icon&&(0,J.jsx)(e.icon,{size:HS}),` `,e.label]},String(e.value)))}),(0,J.jsx)(X,{more:s,children:o}),c]})}function eC({id:e,label:t,icon:n,control:r,note:i,more:a,children:o}){return KS(e)?(0,J.jsxs)(`div`,{className:`set-item`,children:[(0,J.jsxs)(`div`,{className:`set-lead`,children:[n&&(0,J.jsx)(n,{size:HS,className:`set-ico`}),(0,J.jsx)(`span`,{className:`set-lbl`,children:t}),(0,J.jsx)(`span`,{className:`set-pick`,children:r})]}),(0,J.jsx)(X,{more:a,children:i}),o]}):null}function tC({id:e,label:t,icon:n,readout:r,onLess:i,onMore:a,lessLabel:o=`smaller`,moreLabel:s=`bigger`,extra:c,note:l,more:u,children:d}){return KS(e)?(0,J.jsxs)(`div`,{className:`set-item`,children:[(0,J.jsxs)(`div`,{className:`set-lead`,children:[n&&(0,J.jsx)(n,{size:HS,className:`set-ico`}),(0,J.jsx)(`span`,{className:`set-lbl`,children:t})]}),(0,J.jsxs)(`div`,{className:`set-chips`,children:[i&&(0,J.jsxs)(Y,{onClick:i,children:[(0,J.jsx)(ls,{size:HS}),` `,o]}),(0,J.jsx)(`span`,{className:`set-readout`,"aria-live":`polite`,children:r}),a&&(0,J.jsxs)(Y,{onClick:a,children:[(0,J.jsx)(Fo,{size:HS}),` `,s]}),c]}),(0,J.jsx)(X,{more:u,children:l}),d]}):null}function nC({id:e,label:t,icon:n,value:r,min:i,max:a,step:o,readout:s,onInput:c,onCommit:l,note:u,more:d,children:f}){return KS(e)?(0,J.jsxs)(`div`,{className:`set-item`,children:[(0,J.jsxs)(`div`,{className:`set-lead`,children:[n&&(0,J.jsx)(n,{size:HS,className:`set-ico`}),(0,J.jsx)(`span`,{className:`set-lbl`,children:t}),(0,J.jsx)(`span`,{className:`set-state`,children:s})]}),(0,J.jsx)(`input`,{type:`range`,className:`set-range`,min:i,max:a,step:o,value:r,onChange:e=>c(Number(e.target.value)),onPointerUp:l,onKeyUp:l}),(0,J.jsx)(X,{more:d,children:u}),f]}):null}function rC({id:e,label:t,icon:n,onClick:r,opens:i,cant:a,busy:o,tone:s,compact:c,title:l,note:u,more:d,children:f}){return KS(e)?c?(0,J.jsxs)(`button`,{className:`set-door${s?` ${s}`:``}`,title:l,onClick:r,children:[n&&(0,J.jsx)(n,{size:HS}),` `,t]}):(0,J.jsxs)(`div`,{className:`set-item`,children:[a?(0,J.jsxs)(`div`,{className:`set-lead set-cant`,children:[n&&(0,J.jsx)(n,{size:HS,className:`set-ico`}),(0,J.jsx)(`span`,{className:`set-lbl`,children:t}),(0,J.jsx)(`span`,{className:`set-cant-why`,children:a})]}):(0,J.jsxs)(`button`,{className:`set-act${s?` ${s}`:``}${o?` busy`:``}`,title:l,onClick:()=>{o||r()},"aria-busy":o||void 0,children:[o?(0,J.jsx)($s,{size:HS,className:`set-ico spin`}):n&&(0,J.jsx)(n,{size:HS,className:`set-ico`}),(0,J.jsx)(`span`,{className:`set-lbl`,children:t}),i&&!o&&(0,J.jsx)(Hs,{size:HS,className:`set-go`})]}),(0,J.jsx)(X,{more:d,children:u}),f]}):null}function iC({id:e,label:t,icon:n,children:r,note:i,more:a}){return KS(e)?(0,J.jsxs)(`div`,{className:`set-item`,children:[t!=null&&t!==``&&(0,J.jsxs)(`div`,{className:`set-lead`,children:[n&&(0,J.jsx)(n,{size:HS,className:`set-ico`}),(0,J.jsx)(`span`,{className:`set-lbl`,children:t})]}),r,(0,J.jsx)(X,{more:a,children:i})]}):null}function aC({value:e,onChange:t}){return(0,J.jsxs)(`div`,{className:`set-search`,children:[(0,J.jsx)(rc,{size:HS,className:`set-search-ico`}),(0,J.jsx)(`input`,{type:`search`,placeholder:`search settings`,value:e,onChange:e=>t(e.target.value),autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`none`,spellCheck:!1}),e!==``&&(0,J.jsx)(`button`,{className:`set-search-x`,"aria-label":`clear the search`,onClick:()=>t(``),children:(0,J.jsx)(B,{size:HS})})]})}function oC({tally:e,onClear:t}){return!e.only&&!e.query.trim()?null:(0,J.jsxs)(`div`,{className:`filter-bar set-filter-bar`,children:[(0,J.jsx)(`span`,{className:`filter-bar-txt`,children:LS(e.shown.length,e.seen.length,e.query,e.only)}),(0,J.jsxs)(`button`,{className:`filter-bar-clear`,onClick:t,children:[(0,J.jsx)(B,{size:13}),` clear`]})]})}var sC=6e3,cC=null,lC,uC=new Set;function dC(e){cC=e,lC&&clearTimeout(lC),lC=void 0,e&&(lC=setTimeout(()=>{cC=null,lC=void 0;for(let e of uC)e()},sC));for(let e of uC)e()}function fC({children:e,confirm:t=`sure?`,className:n=`key`,title:r,confirmTitle:i,disabled:a,onConfirm:o,...s}){let c=(0,V.useId)(),[,l]=(0,V.useState)(0);(0,V.useEffect)(()=>{let e=()=>l(e=>e+1);return uC.add(e),()=>{uC.delete(e),cC===c&&dC(null)}},[c]);let u=cC===c,d=u?`${n} danger`:n,f={title:u?i??r:r,"aria-label":s[`aria-label`],disabled:a,onClick:()=>{u?(dC(null),o()):dC(c)}},p=/^key(?:\s+|$)(.*)$/.exec(d);return p?(0,J.jsx)(Y,{className:p[1]||void 0,...f,children:u?t:e}):(0,J.jsx)(`button`,{className:d,...f,children:u?t:e})}var pC=null,mC=new Set;function hC(){for(let e of mC)e(pC)}function gC(e){return pC?.resolve(!1,!1,!0),new Promise(t=>{pC={title:e.title,lines:e.lines??[],confirmLabel:e.confirmLabel??`Yes`,cancelLabel:e.cancelLabel??`Cancel`,tone:e.tone??`warn`,resolve:t},hC()})}function _C(e){return pC?.resolve(!1,!1,!0),new Promise(t=>{pC={title:e.title,lines:e.lines??[],confirmLabel:e.confirmLabel??`Yes`,cancelLabel:e.cancelLabel??`Cancel`,tone:e.tone??`info`,rememberLabel:e.rememberLabel??`don't ask again`,resolve:(e,n)=>t({ok:e,remember:n})},hC()})}function vC(e){return pC?.resolve(!1,!1,!0),new Promise(t=>{pC={title:e.title,lines:e.lines??[],confirmLabel:e.confirmLabel,cancelLabel:e.cancelLabel,tone:e.tone??`info`,rememberLabel:e.rememberLabel,altLabel:e.altLabel,resolve:(e,n,r,i)=>t(r?null:{ok:e,remember:n,...i?{alt:!0}:{}})},hC()})}function yC(){let[e,t]=(0,V.useState)(null),[n,r]=(0,V.useState)(!1);(0,V.useEffect)(()=>(mC.add(t),t(pC),()=>{mC.delete(t)}),[]),(0,V.useEffect)(()=>{r(!1)},[e]);let i=(0,V.useCallback)((e,t,n=!1,r=!1)=>{let i=pC;pC=null,hC(),i?.resolve(e,t,n,r)},[]);return e?(0,J.jsx)(`div`,{className:`bl-modal-backdrop confirm-backdrop`,onClick:()=>i(!1,!1,!0),children:(0,J.jsxs)(`div`,{className:`bl-modal confirm-modal`,onClick:e=>e.stopPropagation(),children:[(0,J.jsxs)(`div`,{className:`bl-modal-title`,children:[e.tone===`info`?(0,J.jsx)(oc,{size:15,style:{verticalAlign:`-2px`,marginRight:6}}):(0,J.jsx)(gs,{size:15,style:{verticalAlign:`-2px`,marginRight:6,color:`var(--dead)`}}),e.title]}),e.lines.length>0&&(0,J.jsx)(`ul`,{className:`confirm-lines`,children:e.lines.map((e,t)=>(0,J.jsx)(`li`,{children:e},t))}),e.rememberLabel&&(0,J.jsxs)(`label`,{className:`confirm-remember`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:n,onChange:e=>r(e.target.checked)}),e.rememberLabel]}),(0,J.jsxs)(`div`,{className:`bl-modal-actions`,children:[(0,J.jsx)(`button`,{className:`send confirm-go${e.tone===`info`?` info`:``}`,onClick:()=>i(!0,n),children:e.confirmLabel}),(0,J.jsx)(Y,{onClick:()=>i(!1,n),children:e.cancelLabel}),e.altLabel&&(0,J.jsx)(Y,{onClick:()=>i(!1,n,!1,!0),children:e.altLabel})]})]})}):null}var bC=`claude`,xC=[`low`,`medium`,`high`,`xhigh`,`max`],SC=[`default`,`plan`,`acceptEdits`,`auto`,`dontAsk`,`bypassPermissions`],CC={fork:`transcript`,resumePick:`transcript`,contextSeries:`contextMeter`};function wC(e){return e===`fork`||e===`resumePick`||e===`contextSeries`}function TC(e){return e.backend||`claude`}function EC(e,t){return e?e.find(e=>e.id===(t||`claude`))??null:null}function DC(e,t){return EC(e,t)?.kind===`shell`||t===`shell`}function OC(e){return e?e.filter(t=>!DC(e,t.id)):null}function kC(e){return e?.find(e=>e.kind===`shell`)??null}function AC(e){let t=OC(e);return!!t&&t.length>1}function jC(e,t){return DC(e,t)?`A plain shell on the desktop — no conversation, models or context gauge here.`:null}function MC(e,t){let n=EC(e,t);return!n||n.id===`claude`?null:n.label}function NC(e,t,n){let r=EC(e,t);if(!r)return!0;if(!wC(n))return r.caps[n];let i=r.caps[n];return typeof i==`boolean`?i:r.caps[CC[n]]}function PC(e,t,n){let r=EC(e,t);return!r||NC(e,t,n)?null:IC(n,r.label)}function FC(e){return`${e}'s quota is read (see usage), but no limit wall is detected here, so a session is never held for a reset.`}function IC(e,t){switch(e){case`transcript`:return`this session runs ${t}, which keeps no Claude conversation log — there is no transcript to fork from here. The terminal scrollback is still on this screen.`;case`contextMeter`:return`${t} doesn’t print a context gauge this app can read, so nothing here is measured — this is not a session that has run out of room.`;case`usageLimits`:return`${t} runs against no account quota this app can wait out, so nothing here is counted against one.`;case`slash`:return`${t} doesn’t take Claude’s slash commands, so there is nothing to send one to here.`;case`promptBoxes`:return`${t} doesn’t draw choice boxes this app can read — answer it by typing into the terminal.`;case`hooks`:return`${t} doesn’t report when a turn ends, so “finished” here is inferred from silence rather than known.`;case`effort`:return`${t} has no reasoning-effort setting to pick.`;case`remoteControl`:return`${t} can’t be mirrored to a remote-control session.`;case`fork`:return`${t} keeps its conversation somewhere this app may read and must not rewrite, so a turn here can be read but not forked or reset to. Everything else in the reader works.`;case`resumePick`:return`${t} has no “pick an older conversation” list this desktop knows how to drive — reopening carries on the folder’s own conversation instead.`;case`contextSeries`:return`${t} leaves no context history this app can plot, so nothing here is measured — this is not a session that has run out of room.`}}function LC(e,t){return NC(e,t,`slash`)&&NC(e,t,`promptBoxes`)&&NC(e,t,`hooks`)&&NC(e,t,`transcript`)}function RC(e,t){return LC(e,t)?`claude`:DC(e,t)?`the running command`:EC(e,t)?.label??`the agent`}function zC(e,t,n){return n&&TC({backend:t})===`claude`&&LC(e,t)}function BC(e,t){let n=EC(e,t);return!n||LC(e,t)||n.caps.modes===!0}function VC(e,t){return EC(e,t)?.caps.commands===!0}function HC(e,t){let n=EC(e,t);return n?n.caps.permissionModes.length===0?`${n.label} has no permission modes to switch between, so there is no mode picker${LC(e,t)?` and no ultracode switch`:``} here.`:BC(e,t)?null:`${n.label} takes its permission mode when a session starts; the phone cannot switch it on a running session, so choose it when you start one.`:null}function UC(e,t){return`${LC(e,t)?`claude`:EC(e,t)?.label??`the agent`} is not signed in on the desktop yet: the terminal stays up for its setup (theme, sign-in). The reader comes back once it reaches its prompt.`}function WC(e,t){return`${LC(e,t)?`claude`:EC(e,t)?.label??`the agent`} is set up: back to the reader.`}function GC(e,t,n={}){let r=[];if(DC(e,t))return r;let i=(n,i,a=``)=>{let o=PC(e,t,i);o&&r.push({label:n,reason:o+a})};i(`reader view`,`transcript`),NC(e,t,`transcript`)&&i(`fork or reset to a turn`,`fork`),i(`context graph`,`contextSeries`),LC(e,t)||(EC(e,t)?.caps.usage===!0&&!NC(e,t,`usageLimits`)?r.push({label:`usage limits`,reason:FC(EC(e,t)?.label??`this backend`)}):i(`usage limits`,`usageLimits`),i(`turn-end reports`,`hooks`),i(`readable choice boxes`,`promptBoxes`));let a=n.hiddenSlash??0,o=a>0?`${a} of your header chips ${a===1?`is a Claude slash command and is`:`are Claude slash commands and are`} not offered here`:``;return VC(e,t)?o&&r.push({label:`your Claude header chips`,reason:`${o} — ${EC(e,t)?.label??`this backend`} lists its own commands under /.`}):i(`slash commands`,`slash`,o?` — ${o}.`:``),r}function KC(e,t){let n=EC(e,t);if(!n)return{aliases:[],ids:[],freeText:!0};let r=[...n.models.aliases],i=[...n.models.ids];return{aliases:r,ids:i,freeText:r.length+i.length===0}}function qC(e,t){return EC(e,t)?`This backend did not name its models, so type one.`:`This desktop has not listed its models yet, so type one.`}function JC(e,t,n){return e&&!t&&!n}function YC(e,t){let n=EC(e,t);if(!n)return xC;let r=n.caps.efforts;return r&&r.length>0?r:n.caps.effort?xC:[]}var XC={"Claude Code":`Claude`};function ZC(e,t){let n=EC(e,t)?.label;return n?XC[n]??n:!t||t===`claude`?`Claude`:`CLI`}function QC(e,t){let n=EC(e,t);return n?[...Mn(n.caps)]:SC}function $C(e,t){let n=EC(e,t);return n?[...n.caps.permissionModes]:SC}function ew(e,t){let n=EC(e,t)?.contextWindowTokens;return typeof n!=`number`||!Number.isFinite(n)||n<=0?null:`${n>=1e3?`${Math.round(n/1e3)}k`:String(n)} token window`}function tw(e,t){let n={...e},r=EC(t,n.backend);return DC(t,n.backend)&&(delete n.model,delete n.effort,delete n.permissionMode,delete n.remoteControlled),r?(r.id===`claude`&&delete n.backend,r.caps.effort||delete n.effort,r.caps.remoteControl||delete n.remoteControlled,n.permissionMode&&!Mn(r.caps).includes(n.permissionMode)&&delete n.permissionMode,rw(n)):(t||delete n.backend,rw(n))}function nw(e,t){let n=e.permissionMode;if(!n||DC(t,e.backend))return null;let r=EC(t,e.backend);if(!r||!r.caps.permissionModes.includes(n)||Mn(r.caps).includes(n))return null;let i=zn(r.label,n,r.caps);return i?`${i} This launch goes without it.`:null}function rw(e){return Object.keys(e).forEach(t=>{e[t]||delete e[t]}),e}function iw(e,t,n){let r={backend:t.backend,model:t.model};if(!n)return r;let i=n.backend;return DC(e,i)||!EC(e,i)?r:{backend:i,model:n.model}}var aw={local:`On this desktop`,hosted:`Hosted`,unknown:`Not sure`},ow={local:`Runs on the Mac. No network, no bill, nothing leaves the machine.`,hosted:`Runs on somebody’s server.`,unknown:`This desktop couldn’t say where these run.`},sw=`Your prompts — and the contents of every file the agent reads — leave this machine and are processed on the operator’s servers, under the operator’s terms, not ${I.displayName}’s. Read them before you point one of these at a private repo.`;function cw(e,t){return!!e&&e.includes(t)}function lw(e,t){if(!t)return e.length?[{where:`unknown`,ids:[...e]}]:[];let n={local:[],hosted:[],unknown:[]};for(let r of e){let e=t[r];n[e===`local`||e===`hosted`?e:`unknown`].push(r)}return[`local`,`hosted`,`unknown`].filter(e=>n[e].length>0).map(e=>({where:e,ids:n[e]}))}function uw(e){return e.length>1}function dw(e,t){let n=EC(e,t)?.unavailable;return typeof n==`string`&&n.trim()?n.trim():null}function fw(e,t){let n=EC(e,t)?.measured?.drift;return n&&n.trim()?n.trim():null}function pw(e){let t=[...e.experimental===!0?[`experimental`]:[],...e.unavailable&&e.unavailable.trim()?[`not available now`]:[]];return t.length?`${e.label} (${t.join(`, `)})`:e.label}function mw(e){return!e||e.state!==`down`?null:e.note?.trim()||`The CLI’s own channel is down — turns and questions are read off the screen meanwhile.`}function hw(e,t){return LC(e,t)?null:St(e?.find(e=>e.id===t)?.label||`this backend`)}var gw=[{unit:`usd`,label:`dollars`,example:`2 or 0.50`,prefix:`$`,presets:[`1`,`2`,`5`]},{unit:`tok`,label:`tokens`,example:`500k or 2m`,suffix:`tokens`,presets:[`250k`,`1m`,`3m`]},{unit:`sessionPct`,label:`% of 5h window`,example:`2 or 0.5`,suffix:`% of 5h`,presets:[`5`,`10`,`25`]},{unit:`weeklyPct`,label:`% of week`,example:`5 or 0.5`,suffix:`% of week`,presets:[`5`,`10`,`25`]}];function _w(e,t){return e?gw.filter(e=>!bw(e.unit)||e.unit===t):gw}var vw=e=>gw.find(t=>t.unit===e)??gw[0];function yw(e,t){return e===`usd`?`$${t}`:bw(e)?`${t}%`:t}var bw=e=>e===`sessionPct`||e===`weeklyPct`;function xw(e,t){let n=t.trim().toLowerCase().replace(/\s+/g,``);if(!n)return{ok:!1,reason:`type a number`};e===`usd`&&(n=n.replace(/^\$/,``).replace(/\$$/,``)),bw(e)&&(n=n.replace(/%$/,``));let r=1;if(e===`tok`){let e=/^([\d.,_]+)([kmb])$/.exec(n);e&&(n=e[1],r=e[2]===`k`?1e3:e[2]===`m`?1e6:1e9)}if(n=/^\d+,\d{1,2}$/.test(n)?n.replace(`,`,`.`):n.replace(/[,_]/g,``),!/^(\d+\.?\d*|\.\d+)$/.test(n))return{ok:!1,reason:`“${t.trim()}” is not a number${e===`tok`?` — try 500k or 2m`:``}`};let i=Number(n)*r;return!Number.isFinite(i)||!(i>0)?{ok:!1,reason:`a budget has to be more than zero — clear it to have none`}:bw(e)&&i>100?{ok:!1,reason:`a percent of a window cannot be more than 100`}:{ok:!0,max:i}}function Sw(e){if(e.unit===`tok`){if(e.max>=1e6&&e.max%1e5==0)return`${e.max/1e6}m`;if(e.max>=1e3&&e.max%100==0)return`${e.max/1e3}k`}return String(e.max)}function Cw(e,t,n){if(!bw(e))return null;if(!t)return Gr(`noReading`);let r=n-t.checkedAt;if(r>15e5)return Gr(`stale`,r);let i=e===`sessionPct`?t.sessionUsdPerPct:t.weeklyUsdPerPct;if(i==null||!(i>0))return Gr(`noCalibration`);let a=e===`sessionPct`?`the 5-hour window`:`the week`,o=Math.max(0,Math.round(r/6e4));return`1% of ${a} ≈ ${_t(i)} of list-price spend, from the usage reading ${o} min ago (${j})`}function ww(e){return e<10?e.toFixed(1).replace(/\.0$/,``):String(Math.round(e))}function Tw(e,t,n){return e===`usd`?_t(t):e===`tok`?L(t):`${n?`≈`:``}${ww(t)}%`}function Ew(e,t){return e===`tok`?`${L(t)} tokens`:e===`usd`?_t(t):`≈${ww(t)}% of ${e===`sessionPct`?`the 5-hour window`:`the week`}`}function Dw(e,t,n,r=n,i=!1){return t==null?`${n(e)} so far — the subagent share is not ${i?`stated by this session's backend`:`logged for this session`}`:t>0?`${n(e)} so far — ${r(Math.max(0,e-t))} in this conversation, ${r(t)} in subagents`:`${n(e)} so far, none of it in subagents`}function Ow(e,t,n,r){if(t===void 0)return null;if(bw(e)&&n===void 0&&!t?.source)return t&&t.costUsd!=null?`in dollars, ${Dw(t.costUsd,t.agentCostUsd??null,_t)}`:Gr(t?`unpriced`:`noSpark`);let i=It(e,t,n,r);if(i.value!=null)return Dw(i.value,i.agent,t=>Ew(e,t),bw(e)?t=>Tw(e,t,!0):void 0,!!t?.source);let a=Gr(i.why??`noSpark`,i.why===`stale`&&n?r-n.checkedAt:void 0,e);return bw(e)&&t&&t.costUsd!=null?`${a}. In dollars: ${Dw(t.costUsd,t.agentCostUsd??null,_t)}.`:a}function kw(e,t,n,r){if(!t)return null;let i=It(e.unit,t,n,r);if(i.value==null)return null;let a=bw(e.unit),o=`${Tw(e.unit,i.value,a)} of ${Tw(e.unit,e.max,!1)}`;if(i.value>=e.max)return`${o} — already past it: this session's sends would be held as soon as it is set`;let s=i.value/e.max*100;return`${o} — ${s<1?`under 1`:Math.round(s)}% used`}var Aw=[{key:`soft`,label:`soft (default) — hold queued work, never block me`,note:`At the cap, queued and scheduled sends to this session wait and you are told. What you send yourself still goes, without a question. The switch below decides whether the turn running at that moment gets one Esc; later turns are left to run.`},{key:`hard`,label:`hard — ask before my sends, stop every other turn`,note:`At the cap, queued and scheduled sends wait and you are told. Each send you make yourself asks “send anyway?” first, and that one turn then runs. Every turn you did not send yourself — a subagent reporting back, a chained prompt — is stopped with one Esc, turn after turn.`}];function jw(e){return{title:`Past this session's hard budget`,lines:[`${e}.`,`Send anyway: this message goes and its turn runs to the end. Turns you did not send still get one Esc.`,`Keep it: the words stay in the box. Tap budget hit on the session to raise or clear the budget.`],confirmLabel:`send anyway`,cancelLabel:`keep it`}}kt({});function Mw(e,t,n){if(!e){if(n===void 0)return`No budget on this session.`;let e=It(`usd`,n,null,t).value==null?It(`tok`,n,null,t).value==null?null:`tok`:`usd`,r=e&&Ow(e,n,null,t);return r?`Spent: ${r}.`:null}let r=e.verdict;return r.state===`unknown`?Gr(r.why??`noSpark`,r.why===`stale`&&e.cal?t-e.cal.checkedAt:void 0,r.unit):`${g(r)}${r.state===`over`?`. ${kt(e.cfg)}`:`.`}`}var Nw=e=>`budget ${Yr(e)}`;function Pw({children:e,onClear:t,clearLabel:n=`clear`,clearTitle:r,section:i=!1,className:a}){let o=`${i?`section `:``}filter-bar${a?` ${a}`:``}`;return(0,J.jsxs)(`div`,{className:o,children:[(0,J.jsx)(`span`,{className:`filter-bar-txt`,children:e}),(0,J.jsx)(`button`,{className:`filter-bar-clear`,title:r,onClick:t,children:n})]})}var Fw=(0,V.forwardRef)(function({className:e,...t},n){return(0,J.jsx)(`input`,{ref:n,className:e?`search ${e}`:`search`,...t})});function Iw(e,t){return t.detail?`${e} · ${t.count} · ${t.detail}`:`${e} · ${t.count}`}function Lw(e,t){return e===t?null:t}function Rw(e,t,n){return e.map(e=>{let r=t(e);return{key:e,text:Iw(n(e),r),count:r.count}})}function zw({on:e,busy:t=!1,clears:n=!0,title:r,onClick:i,children:a}){return(0,J.jsx)(`button`,{className:`fchip${e?` on`:``}`,"aria-pressed":e,title:r,onClick:i,children:(0,J.jsxs)(`span`,{className:`fchip-pill`,children:[a,e&&t?(0,J.jsx)(Js,{size:12,className:`spin fchip-x`}):e&&n?(0,J.jsx)(B,{size:13,className:`fchip-x`,"aria-hidden":!0}):null]})})}function Bw({keys:e,bucket:t,label:n,active:r,onPick:i,className:a=`fchips`}){return(0,J.jsx)(`div`,{className:a,children:Rw(e,t,n).map(e=>(0,J.jsx)(zw,{on:r===e.key,onClick:()=>i(Lw(r,e.key)),children:e.text},e.key))})}var Vw=24;function Hw({title:e,icon:t,onClose:n,actions:r,head:i,footer:a,className:o,full:s,children:c}){let l=[`sheet`,s?`sheet-full`:``,o??``].filter(Boolean).join(` `);return(0,J.jsxs)(`div`,{className:l,children:[(0,J.jsx)(Uw,{title:e,icon:t,onClose:n,children:r}),i,s?(0,J.jsx)(`div`,{className:`sheet-full-body`,children:c}):c,a?(0,J.jsx)(`div`,{className:`sheet-actions`,children:a}):null]})}function Uw({title:e,icon:t,onClose:n,brandClass:r,children:i}){return(0,J.jsxs)(`div`,{className:`sheet-head`,children:[(0,J.jsx)(`button`,{className:`back`,onClick:n,"aria-label":`back`,children:(0,J.jsx)(Ns,{size:Vw})}),(0,J.jsxs)(`span`,{className:r?`brand ${r}`:`brand`,children:[t,t?` `:null,e]}),i?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`spacer`}),i]}):null]})}function Ww(e){let[t,n]=(0,V.useState)(()=>Date.now());return(0,V.useEffect)(()=>{let t=window.setInterval(()=>n(Date.now()),e);return()=>window.clearInterval(t)},[e]),t}function Gw({at:e}){return Ww(1e4),(0,J.jsx)(`span`,{className:`muted`,children:Tp(e)})}function Kw({title:e,onClose:t,onRefresh:n,refreshTitle:r,at:i,iconSize:a=16,bare:o=!1,children:s}){let c=(0,J.jsxs)(J.Fragment,{children:[i!=null&&(0,J.jsx)(Gw,{at:i}),s,(0,J.jsx)(Y,{title:r,onClick:n,children:(0,J.jsx)(Ds,{size:a})})]});return(0,J.jsx)(Uw,{title:e,onClose:t,children:o?c:(0,J.jsx)(`span`,{className:`head-acts tight`,children:c})})}function Z({as:e=`div`,tone:t,className:n,...r}){return(0,V.createElement)(e,{className:zS(t,n),...r})}function qw({tone:e,className:t,...n}){return(0,J.jsx)(`span`,{className:BS(e,t),...n})}function Jw(e){return e===`wrap`?`row-wrap`:e===`grow`?`row grow`:`row`}function Yw(e,t){return e+(t?` ${t}`:``)}function Xw({as:e=`div`,kind:t,...n}){return(0,V.createElement)(e,{className:Jw(t),...n})}function Zw({as:e=`span`,className:t,...n}){return(0,V.createElement)(e,{className:Yw(`row-title`,t),...n})}function Q({as:e=`span`,className:t,...n}){return(0,V.createElement)(e,{className:Yw(`row-sub`,t),...n})}function $({res:e,empty:t=!0,thing:n,offlineNote:r,note:i,noun:a=`listing`,children:o}){let s=e?.state===`cached`&&e.age!=null?(0,J.jsxs)(`div`,{className:`empty empty-stale`,children:[`Cached `,a,` from `,kp(e.age),` — the link is down, so anything added since won’t be here.`]}):null;if(!t)return s;let c=n??`this`,l=o??null;if(e)switch(e.state){case`loading`:l=(0,J.jsxs)(J.Fragment,{children:[`Reading `,c,`…`]});break;case`offline`:l=(0,J.jsxs)(J.Fragment,{children:[`No connection — this phone could not reach the desktop, so `,c,` cannot be read.`,r?(0,J.jsxs)(J.Fragment,{children:[` `,r]}):null]});break;case`error`:l=(0,J.jsxs)(J.Fragment,{children:[`The host could not read `,c,e.error?(0,J.jsxs)(J.Fragment,{children:[`: `,e.error]}):`.`]})}return l?(0,J.jsxs)(J.Fragment,{children:[s,(0,J.jsxs)(`div`,{className:`empty empty-msg`,children:[l,i?(0,J.jsxs)(J.Fragment,{children:[` `,i]}):null]})]}):s}function Qw({cants:e,className:t}){if(!e.length)return null;let n=new Map;for(let t of e)n.set(t.reason,[...n.get(t.reason)??[],t.label]);return(0,J.jsx)(`div`,{className:`act-cants${t?` ${t}`:``}`,children:[...n].map(([e,t])=>(0,J.jsxs)(`span`,{className:`act-cant`,children:[(0,J.jsx)(fs,{size:11}),` no `,t.join(`, `),` — `,e]},e))})}function $w({children:e}){return(0,J.jsxs)(`span`,{className:`act-cant act-cant-inline`,children:[(0,J.jsx)(fs,{size:11}),` `,e]})}function eT({cants:e,className:t}){return e.length?(0,J.jsxs)(`details`,{className:`act-cants act-cants-fold${t?` ${t}`:``}`,children:[(0,J.jsxs)(`summary`,{className:`act-cant`,children:[(0,J.jsx)(fs,{size:11}),` Not here: `,e.map(e=>e.label).join(` · `),` `,(0,J.jsx)(Nc,{size:11,"aria-label":`tap for the reasons`})]}),(0,J.jsx)(Qw,{cants:e})]}):null}function tT({of:e,label:t,children:n}){let[r,i]=(0,V.useState)(!1);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{type:`button`,className:`hint-chip explain-chip${r?` open`:``}`,"aria-expanded":r,"aria-label":`what ${e} means`,onClick:e=>{e.stopPropagation(),i(e=>!e)},children:[(0,J.jsx)(cs,{size:13,"aria-hidden":!0}),t?(0,J.jsx)(`span`,{className:`explain-label`,children:t}):null]}),r&&(0,J.jsx)(`div`,{className:`explain-body`,children:n})]})}function nT(){return ma(R.launch,{})}function rT(){try{return new Set(JSON.parse(z(R.hiddenRepos)||`[]`))}catch{return new Set}}function iT(e,t){return ma(e,t)}function aT(e,t){Ta(e,t)}var oT=R.snapAt;function sT(e){aT(R.snapSessions,e),aT(oT,Date.now())}function cT(e){aT(R.snapRepos,e),aT(R.snapReposAt,Date.now())}function lT(){return Ea(R.snapReposAt,0)}function uT(){return ma(R.cmdHistory,[])}function dT(){return ma(R.snippets,[])}var fT=R.sessionOrder;function pT(){try{let e=JSON.parse(z(fT)||`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}var mT=R.collapsedRepos;function hT(){try{let e=JSON.parse(z(mT)||`[]`);return new Set(Array.isArray(e)?e.filter(e=>typeof e==`string`):[])}catch{return new Set}}var gT=R.pendingStars,_T=R.pendingFollowUps;function vT(e){return bh(z(e))}function yT(e,t){Object.keys(t).length===0?wa(e):Ta(e,t)}var bT=40;function xT(){let e=ma(R.snapBuilds,{});if(!e||typeof e!=`object`||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e))r&&Array.isArray(r.v)&&typeof r.at==`number`&&(t[n]=r);return t}function ST(e,t){let n=xT();n[e]={v:t,at:Date.now()};let r=Object.keys(n);if(r.length>bT)for(let e of r.sort((e,t)=>n[e].at-n[t].at).slice(0,r.length-bT))delete n[e];return Ta(R.snapBuilds,n),n}var CT=40;function wT(){let e=ma(R.snapCapture,{});if(!e||typeof e!=`object`||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e))r&&Array.isArray(r.v)&&typeof r.at==`number`&&(t[n]=r);return t}function TT(e,t){let n=wT();n[e]={v:t,at:Date.now()};let r=Object.keys(n);if(r.length>CT)for(let e of r.sort((e,t)=>n[e].at-n[t].at).slice(0,r.length-CT))delete n[e];return Ta(R.snapCapture,n),n}function ET(){let e=ma(R.snapSchedules,{v:[],at:0});return e&&Array.isArray(e.v)&&typeof e.at==`number`?e:{v:[],at:0}}function DT(e){Ta(R.snapSchedules,{v:e.map(({running:e,...t})=>t),at:Date.now()})}function OT(){let e=ma(R.snapCliHealth,null);if(!e||typeof e.at!=`number`||!e.v?.health||!e.v?.rollup)return null;let t=e.v.source,n=t&&typeof t.repo==`string`&&typeof t.stateDir==`string`?{repo:t.repo,stateDir:t.stateDir}:void 0;return{value:{health:qee(e.v.health),rollup:e.v.rollup,source:n},savedAt:e.at}}function kT(e){Ta(R.snapCliHealth,{v:e,at:Date.now()})}function AT(e,t){return e.length>=12?`${e.length} recordings are already waiting for the desktop — nothing is lost, but this one was not kept`:e.reduce((e,t)=>e+t.bytes,0)+t>50331648?`there is already more audio waiting than this phone will hold — this one was not kept`:null}function jT(e,t){let n=e.filter(e=>(e.retryAt??0)<=t);return n.length?n.reduce((e,t)=>e.ts<=t.ts?e:t):null}function MT(e,t){let n=e.tries+1;return{...e,tries:n,retryAt:t+Lee(n)}}function NT(e){return e.map(e=>({...e,retryAt:void 0}))}function PT(e,t){if(e.some(e=>(e.retryAt??0)<=t))return null;let n=e.map(e=>e.retryAt??0).filter(e=>e>t);return n.length?Math.min(...n):null}function FT(e){let t=Math.max(1,Math.round(e));if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;return r?`${n}m ${r}s`:`${n}m`}function IT(e,t){return t&&e>1?`the desktop is reading what you said — ${e-1} more recording${e-1==1?``:`s`} behind it`:t?`the desktop is reading what you said`:e===1?`one recording is waiting for the desktop — it is read the moment the link is back, and the words come to the box`:e>1?`${e} recordings are waiting for the desktop — they are read in the order you said them, the moment the link is back`:null}function LT(e){return!/[\p{L}\p{N}]/u.test(e)}function RT(e){return`${FT(e.seconds)} of what you said is held — the desktop could not be reached. It is read as soon as it can be, and the words come back to the box.`}function zT(e){return`${FT(e)} of dictation came back after the box it was said into had gone — the words are on the pad.`}function BT(e){return`your words came back but could not be parked: ${e}`}var VT=45e3,HT=3e5,UT=`dictations`,WT=[],GT=!1,KT=null,qT=!1,JT=0,YT=new Map,XT=new Set;function ZT(){if(GT)return WT;GT=!0;let e=ma(R.dictations,[]);return WT=Array.isArray(e)?e.filter(e=>!!e&&typeof e.id==`string`).map(e=>({...e,tries:Number(e.tries)||0})):[],WT}function QT(e){WT=e,Ta(R.dictations,e),$T()}function $T(){for(let e of XT)e()}function eE(){return{held:ZT().length,sending:KT!==null}}function tE(e){return XT.add(e),()=>{XT.delete(e)}}async function nE(e,t){let n=AT(ZT(),e.size);if(n)return{error:n};let r=`d_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`;return await Ay(UT,r,e),(await Ny(UT)).includes(r)?(QT([...ZT(),{id:r,ts:Date.now(),seconds:t.seconds,bytes:e.size,lang:t.lang,tries:0}]),aE(),{id:r}):{error:`this phone would not store the recording, so it was not kept`}}function rE(e,t){return YT.set(e,t),()=>{YT.get(e)===t&&YT.delete(e)}}function iE(e){YT.delete(e),QT(ZT().filter(t=>t.id!==e)),jy(UT,e)}async function aE(){if(!qT){qT=!0;try{for(;;){let e=jT(ZT(),Date.now());if(!e){uoe();return}await oE(e)}}finally{qT=!1}}}async function oE(e){let t=await ky(UT,e.id);if(!t){iE(e.id),K(`a recording waiting to be read is no longer on this phone`);return}KT=e.id,$T();let n=new AbortController,r=0,i=()=>{window.clearTimeout(r),r=window.setTimeout(()=>n.abort(),VT)};i();try{let r=ete(Tv()),a=await H.dictate(t,{lang:e.lang,terms:r,signal:n.signal,onProgress:i});`error`in a?(iE(e.id),K(a.error)):await loe(e,a.text)}catch(t){t?.permanent?(iE(e.id),K(t.message)):sE(e)}finally{window.clearTimeout(r),KT=null,$T()}}function sE(e){let t=MT(e,Date.now()),n=!e.told;QT(ZT().map(n=>n.id===e.id?{...t,told:!0}:n)),n&&K(RT(e))}async function loe(e,t){let n=t.trim();if(!n||LT(n)){iE(e.id),K(`nothing was said`);return}let r=YT.get(e.id);if(r&&r(n)){iE(e.id);return}let i=Qm({id:`p_${e.id}`,text:n,ts:Date.now()});i?(QT(ZT().map(t=>t.id===e.id?{...t,tries:t.tries+1,retryAt:Date.now()+HT,told:!0}:t)),e.told||K(BT(i))):(iE(e.id),K(zT(e.seconds)))}function uoe(){window.clearTimeout(JT);let e=PT(ZT(),Date.now());e!==null&&(JT=window.setTimeout(()=>{aE()},Math.max(250,e-Date.now())))}function cE(){ZT().some(e=>e.retryAt)&&QT(NT(ZT())),aE()}function doe(){ZT(),window.addEventListener(`online`,cE);let e=!1;im(t=>{let n=t.status===`open`;n&&!e&&cE(),e=n}),foe(),aE()}async function foe(){let e=await Ny(UT),t=new Set(ZT().map(e=>e.id));for(let n of e)t.has(n)||jy(UT,n)}async function poe(){let e=ZT(),t=KT,n=e.filter(e=>e.id!==t);for(let e of n)await jy(UT,e.id);return QT(e.filter(e=>e.id===t)),{dropped:n.length,bytes:n.reduce((e,t)=>e+(t.bytes||0),0),kept:e.length-n.length}}function moe(e){let t=``;for(let n of e){let e=n.replace(/\s+/g,` `).trim();if(e){if(!t||e.startsWith(t))t=e;else if(t.endsWith(e)||t.startsWith(e))continue;else t=`${t} ${e}`}}return t}var hoe=`phone recogniser`;function lE(e){let t=`dictating with the phone's own recogniser, not the desktop's whisper`;return e.secure?e.canRecord?!e.status||e.status.available?null:`${t}: ${e.status.reason??`the desktop says whisper is not available`}`:`${t}: this browser gives the app no way to record audio`:`${t}: this page is plain http, where the app may not record audio — open it over its https address and whisper takes over`}function goe(e){return e.track===`ended`?`the microphone was taken away (a call, another app, or a headset disconnecting)`:e.ctx===`closed`?`the recording was closed`:e.now-e.lastFrameAt<2e3&&e.now-e.startedAt-e.heardSeconds*1e3<3e3?null:e.visible?e.ctx===`running`?`the audio was interrupted (usually the screen turning off or the app leaving the foreground)`:`the phone paused the audio (usually the screen turning off)`:`the app went to the background or the screen turned off`}function uE(e){let t=Math.max(0,Math.floor(e));return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}function _oe(e,t){return`dictation stopped hearing you at ${uE(e)} — ${t}. Everything up to then is being read; tap the mic to go on.`}var dE=!1;function fE(){let e=window;return e.SpeechRecognition||e.webkitSpeechRecognition||null}var pE=null;function voe(){if(!pE){let e=H.dictateStatus();pE=e,e.then(t=>{!t.available&&pE===e&&(pE=null)})}return pE}function mE(){return typeof navigator<`u`&&!!navigator.mediaDevices?.getUserMedia&&typeof AudioContext<`u`}async function yoe(){let e=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}}),t=new AudioContext({sampleRate:Cee});t.state===`suspended`&&await t.resume();let n=t.createMediaStreamSource(e),r=t.createScriptProcessor(4096,1,1),i={ctx:t,stream:e,node:r,chunks:[],frames:0,openedAt:Date.now(),lastFrameAt:Date.now()};r.onaudioprocess=e=>{i.chunks.push(new Float32Array(e.inputBuffer.getChannelData(0))),i.frames+=e.inputBuffer.length,i.lastFrameAt=Date.now()},n.connect(r);let a=t.createGain();return a.gain.value=0,r.connect(a),a.connect(t.destination),i}function hE(e){try{e.node.onaudioprocess=null,e.node.disconnect()}catch{}for(let t of e.stream.getTracks())try{t.stop()}catch{}e.ctx.close().catch(()=>{})}function boe(e){let t=new Float32Array(e.frames),n=0;for(let r of e.chunks)t.set(r,n),n+=r.length;return new Blob([xr(sr(t),e.ctx.sampleRate).buffer],{type:`audio/wav`})}function gE(){try{navigator.vibrate?.([120,80,120])}catch{}}function _E(e){let[n,r]=(0,V.useState)(!1),[i,a]=(0,V.useState)(fE()?`browser`:null),[o,s]=(0,V.useState)(eE),[c,l]=(0,V.useState)(()=>lE({secure:typeof window<`u`&&window.isSecureContext,canRecord:mE()})),u=(0,V.useRef)(null),d=(0,V.useRef)(null),f=(0,V.useRef)(null),p=(0,V.useRef)(0),[m,h]=(0,V.useState)(0),g=(0,V.useRef)(null),_=(0,V.useRef)(!1),v=(0,V.useRef)(``),y=(0,V.useRef)(e);y.current=e;let b=(0,V.useRef)([]);(0,V.useEffect)(()=>{let e=!0,t=!1,n=()=>{mE()&&!t&&voe().then(n=>{e&&(n.available&&(t=!0,a(`host`)),l(lE({secure:window.isSecureContext,canRecord:!0,status:n})))})};n();let r=$p().status===`open`,i=im(e=>{let t=e.status===`open`;t&&!r&&n(),r=t}),o=tE(()=>s(eE()));return()=>{e=!1,i(),o(),_.current=!0,u.current?.stop(),d.current&&=(hE(d.current),null),f.current&&window.clearInterval(f.current),T();for(let e of b.current)e();b.current=[]}},[]);async function x(){let e;try{e=await yoe()}catch(e){K(e?.name===`NotAllowedError`?`this app has no permission to use the microphone`:`no microphone this app can open`),r(!1),T();return}d.current=e,p.current=Date.now(),h(0),r(!0),w();let t=!1;f.current=window.setInterval(()=>{if(d.current!==e)return;let n=e.frames/e.ctx.sampleRate;h(n);let r=goe({now:Date.now(),startedAt:e.openedAt,heardSeconds:n,lastFrameAt:e.lastFrameAt,track:e.stream.getAudioTracks()[0]?.readyState??`ended`,ctx:e.ctx.state,visible:document.visibilityState===`visible`});r?(gE(),K(_oe(n,r)),S()):(!t&&n>=280&&(t=!0,K(`at ${uE(300)} this part goes to the desktop and a new one starts — keep talking`)),n>=300&&(gE(),S({rollOver:!0}).then(()=>x())))},500)}async function S(e={}){let t=d.current;if(d.current=null,f.current&&=(window.clearInterval(f.current),null),!t)return;e.rollOver||(r(!1),T());let n=t.frames/t.ctx.sampleRate,i=boe(t);if(hE(t),n<.25){K(`nothing was said`);return}let a=await nE(i,{seconds:n,lang:yv()});if(`error`in a){K(a.error);return}let o=y.current.key?.();b.current.push(rE(a.id,e=>{let t=y.current;return t.key?.()===o&&(t.write(ste(t.read(),e)),!0)}))}function C(){let e=fE();if(!e)return;let n=new e;n.lang=kae(),n.continuous=!0,n.interimResults=!0;let i=Tv(),a=y.current.key?.(),o=!1;n.onresult=e=>{if(y.current.key?.()!==a){o||(o=!0,_.current=!0,n.stop(),K(`dictation stopped — you left the box it was writing into; what was recognised is still there`));return}let r=[];for(let t=0;t<e.results.length;t++)r.push(e.results[t][0].transcript);y.current.write(v.current+t(moe(r),i))},n.onerror=e=>{r(!1);let t=e?.error;t&&t!==`no-speech`&&t!==`aborted`&&(_.current=!0,gE(),K(`dictation stopped — this browser's recogniser could not finish. What was already recognised is in the box.`))},n.onend=()=>{r(!1),f.current&&=(window.clearInterval(f.current),null),T(),u.current===n&&(u.current=null),!_.current&&!o&&(gE(),K(`the phone's recogniser stopped listening at ${uE((Date.now()-p.current)/1e3)} — what it heard is in the box; tap the mic to go on`))},u.current=n,_.current=!1,c&&!dE&&(dE=!0,K(c)),n.start(),p.current=Date.now(),h(0),r(!0),w(),f.current=window.setInterval(()=>h((Date.now()-p.current)/1e3),500)}async function w(){try{g.current=await navigator.wakeLock?.request(`screen`)??null}catch{g.current=null}}function T(){g.current?.release().catch(()=>{}),g.current=null}function E(){if(n){d.current?S():(_.current=!0,u.current?.stop());return}let e=y.current.read();v.current=e?e.replace(/\s*$/,``)+` `:``,i===`host`?x():C()}return{supported:i!==null,listening:n,heard:n?uE(m):null,transcribing:o.sending,held:o.held,engine:i,fallback:i===`browser`?c:null,toggle:E}}function xoe(){let[e,t]=(0,V.useState)(yv);(0,V.useEffect)(()=>Sv(()=>t(yv())),[]);let n=Dae(),r=jte(e);return(0,J.jsxs)(`span`,{className:`dict-lang`,title:r,children:[(0,J.jsx)(qte,{size:14}),(0,J.jsx)(`span`,{className:`dict-lang-face`,children:jee(e)}),(0,J.jsx)(`select`,{value:e,"aria-label":`dictation language — ${r}`,onChange:e=>{q(`action:voice.lang`),bv(e.target.value)},children:n.map(e=>(0,J.jsx)(`option`,{value:e.code,children:e.label},e.code))})]})}function Soe({why:e}){return(0,J.jsxs)(`button`,{type:`button`,className:`dict-lang dict-fallback`,onPointerDown:e=>e.preventDefault(),onClick:()=>{q(`action:voice.fallback`),K(e)},"aria-label":e,children:[(0,J.jsx)(Ra,{size:14}),(0,J.jsx)(`span`,{className:`dict-lang-face`,children:hoe})]})}function vE({voice:e,onPointerDown:t,idleTitle:n}){return e.supported?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{type:`button`,className:`mic ${e.listening?`on`:``}${e.transcribing?` busy`:``}`,onPointerDown:t,onClick:()=>{q(`action:voice`),e.toggle()},title:e.listening?`listening ${e.heard??``} — tap to stop`:IT(e.held,e.transcribing)??n??(e.engine===`host`?`Dictate — read on the desktop`:`Dictate`),children:[e.transcribing&&!e.listening?(0,J.jsx)(go,{size:18}):(0,J.jsx)(Na,{size:18}),e.held>0&&(0,J.jsx)(`span`,{className:`mic-badge`,children:e.held}),e.heard&&(0,J.jsx)(`span`,{className:`mic-clock`,children:e.heard})]}),e.listening&&e.engine===`host`&&(0,J.jsx)(xoe,{}),e.listening&&e.fallback&&(0,J.jsx)(Soe,{why:e.fallback})]}):null}var Coe={autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1};function yE({prompts:e,onChange:t,placeholder:n,chain:r,stepPlaceholder:i=`…and then?`,stepHint:a=`then, once the turn before it finishes:`,addLabel:o=`another prompt`,trackAdd:s,autoFocus:c,children:l,inline:u,rows:d,focusRef:f,plain:p}){let m=e[0]??``,h=e.slice(1),g=(n,r)=>{let i=e.length?e.slice():[``];i[n]=r,t(i)},_=e.map(e=>e.trim()).filter(Boolean);return(0,J.jsxs)(`div`,{className:`promptc${u?` promptc-inline`:``}`,children:[(0,J.jsx)(`textarea`,{className:`search promptc-area`,autoFocus:c,rows:u?d??3:void 0,...p?Coe:{},placeholder:n,value:m,onChange:e=>g(0,e.target.value),onFocus:()=>{f&&(f.current=0)},style:{resize:`vertical`,fontFamily:`inherit`}}),l,r&&h.map((n,r)=>(0,J.jsxs)(`div`,{className:`promptc-step`,children:[(0,J.jsx)(Z,{style:{padding:0},children:a}),(0,J.jsx)(`textarea`,{className:`search`,rows:4,placeholder:i,value:n,onChange:e=>g(r+1,e.target.value),onFocus:()=>{f&&(f.current=r+1)},style:{resize:`vertical`,fontFamily:`inherit`}}),(0,J.jsxs)(`div`,{className:`queue-row-acts`,children:[(0,J.jsx)(`span`,{className:`spacer`}),(0,J.jsx)(Y,{variant:`danger`,title:`drop this step`,onClick:()=>t(e.filter((e,t)=>t!==r+1)),children:(0,J.jsx)(ws,{size:16})})]})]},r)),r&&!!_.length&&(0,J.jsx)(`div`,{className:`queue-row-acts promptc-add`,children:(0,J.jsxs)(Y,{title:`add another prompt, delivered after this one's turn ends`,onClick:()=>{s&&q(s),t([...e,``])},children:[(0,J.jsx)(Fo,{size:16}),` `,o]})})]})}function bE({prompts:e,onPrompts:t,busy:n,unavailable:r,onFiles:i,trackImage:a,trackFile:o,focusRef:s,onBrowse:c,browseLabel:l=`in repo`}){let u=(0,V.useRef)(null),d=(0,V.useRef)(null),f=e=>{let t=Array.from(e.target.files??[]);e.target.value=``,t.length&&i(t)};return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(xE,{prompts:e,onPrompts:t,focusRef:s}),(0,J.jsx)(woe,{prompts:e,onPrompts:t,focusRef:s}),r?(0,J.jsxs)($w,{children:[`no attach — `,r]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(Y,{disabled:n,title:`attach an image (mark it up before it goes)`,onClick:()=>{a&&q(a),u.current?.click()},children:[(0,J.jsx)(_s,{size:16}),` `,n?`adding…`:`image`]}),(0,J.jsxs)(Y,{disabled:n,title:`attach a file of any kind (PDF, doc, zip, audio…)`,onClick:()=>{o&&q(o),d.current?.click()},children:[(0,J.jsx)(vo,{size:16}),` file`]}),c&&(0,J.jsxs)(Y,{disabled:n,title:`name a file that is already in this repo — the gallery, and the path comes back into the prompt`,onClick:c,children:[(0,J.jsx)(jo,{size:16}),` `,l]})]}),(0,J.jsx)(`input`,{ref:u,type:`file`,accept:`image/*`,multiple:!0,style:{display:`none`},onChange:f}),(0,J.jsx)(`input`,{ref:d,type:`file`,multiple:!0,style:{display:`none`},onChange:f})]})}function woe({prompts:e,onPrompts:t,focusRef:n}){let[r,i]=(0,V.useState)(null),a=r=>{q(`action:snippet.insert`);let a=Math.min(Math.max(n?.current??0,0),Math.max(e.current.length-1,0)),o=e.current.length?e.current.slice():[``],s=o[a]??``;o[a]=(s&&!/\s$/.test(s)?s+`
5
+ `:s)+r.text,t(o),i(null)};return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(Y,{className:r?`on`:void 0,title:`insert a saved snippet into the turn the caret is in`,onClick:()=>i(e=>e?null:dT()),children:[(0,J.jsx)(Ka,{size:16}),` snippet`]}),r&&(0,J.jsxs)(`div`,{className:`snippet-pop`,children:[(0,J.jsxs)(`div`,{className:`snippet-pop-head`,children:[(0,J.jsx)(`span`,{children:`Snippets`}),(0,J.jsx)(Y,{onClick:()=>i(null),title:`Close`,children:(0,J.jsx)(B,{size:14})})]}),(0,J.jsxs)(`div`,{className:`snippet-pop-list`,children:[r.length===0&&(0,J.jsx)($,{children:`No snippets yet — add them from the compose bar's snippet button, under “manage”.`}),r.map(e=>(0,J.jsxs)(`button`,{className:`snippet-pop-item`,title:e.text,onClick:()=>a(e),children:[(0,J.jsx)(`span`,{className:`snippet-pop-title`,children:e.title}),(0,J.jsx)(`span`,{className:`snippet-pop-preview`,children:e.text.replace(/\s+/g,` `).trim()})]},e.id))]})]})]})}function xE({prompts:e,onPrompts:t,focusRef:n,boxKey:r=`step`}){let i=()=>Math.min(Math.max(n?.current??0,0),Math.max(e.current.length-1,0)),a=_E({key:()=>`${r}:${i()}`,read:()=>e.current[i()]??``,write:n=>{let r=e.current.length?e.current.slice():[``];r[i()]=n,t(r)}});return(0,J.jsx)(vE,{voice:a,idleTitle:`dictate into the turn the caret is in — added to what is already written, never over it`})}function SE(e,t=5){if(!(e>0))return{top:1,ticks:[0,1]};let n=e*1.04,r=n/t,i=10**Math.floor(Math.log10(r)),a=r/i,o=Math.max(1,(a<=1?1:a<=2?2:a<=2.5?2.5:a<=5?5:10)*i),s=Math.ceil(n/o)*o,c=[];for(let e=0;e<=s+o/2;e+=o)c.push(Math.round(e));return{top:s,ticks:c}}function CE(e,t){let n=Math.max(4,Math.ceil(t/e*4-1e-9)),r=e/4*n,i=[];for(let t=0;t<=n;t++)i.push(Math.round(e/4*t));return{top:r,ticks:i}}function wE(e,t,n){return{w:Math.max(1,e-n.left-n.right),h:Math.max(1,t-n.top-n.bottom)}}function TE(e,t,n){return r=>e+t-Math.max(0,Math.min(r,n))/n*t}function EE(e,t,n){if(!e.length)return null;let r=e[0];for(let i of e)Math.abs(n(i)-t)<Math.abs(n(r)-t)&&(r=i);return r}var DE=e=>e.toFixed(1);function OE(e,t,n){return e.length?e.map((e,r)=>`${r?`L`:`M`}${DE(t(e,r))},${DE(n(e,r))}`).join(``):``}function kE(e,t,n,r){return`M${t},${r}L${e.slice(1)}L${n},${r}Z`}function AE(e,t){return`M${e.join(`L`)}L${t.join(`L`)}Z`}var jE=864e5,ME=36e5;function NE(e){let{width:t,height:n,pad:r,points:i}=e,a=e.stepMs&&e.stepMs>0?e.stepMs:jE,{w:o,h:s}=wE(t,n,r),c=i.length?i[0].t:0,l=i.length?i[i.length-1].t:a,u=c-a/2,d=l+a/2,f=Math.max(a,d-u),p=i.reduce((e,t)=>t.v>e?t.v:e,0),m=e.yMax!=null&&e.yMax>0,h=m?e.yMax:SE(p).top,g=m?[0,.25,.5,.75,1].map(t=>t*e.yMax):SE(p).ticks;return{x:r.left,y:r.top,w:o,h:s,t0:u,t1:d,yMax:h,yTicks:g,px:e=>r.left+(e-u)/f*o,py:TE(r.top,s,h),slot:a/f*o,step:a}}function PE(e,t){return OE(t,t=>e.px(t.t),t=>e.py(t.v))}function Toe(e,t){let n=PE(e,t);return n?kE(n,DE(e.px(t[0].t)),DE(e.px(t[t.length-1].t)),DE(e.py(0))):``}function Eoe(e,t,n=14){let r=Math.max(1,Math.min(n,e.slot-2));return t.map(t=>{let n=e.py(t.v);return{x:e.px(t.t)-r/2,y:n,w:r,h:Math.max(+(t.v>0),e.py(0)-n),point:t}})}function FE(e,t,n){return EE(t,e.t0+(n-e.x)/e.w*(e.t1-e.t0),e=>e.t)}function IE(e,t=7){if(e.length<2||t<2)return[];let n=(t-1)*jE,r=[],i=e[0].t,a=0,o=0;for(let s=0;s<e.length;s++){for(o+=e[s].v;a<=s&&e[a].t<e[s].t-n;)o-=e[a].v,a++;e[s].t-i<n||r.push({t:e[s].t,day:e[s].day,v:o/t})}return r}function LE(e){return Number.isFinite(e)?e>=1e6?`${(e/1e6).toFixed(e>=1e7?0:1).replace(/\.0$/,``)}M`:e>=1e3?`${Math.round(e/1e3)}k`:String(Math.round(e)):`?`}function RE(e){return Number.isFinite(e)?e>=1e4?LE(e):e>=1e3?`${(e/1e3).toFixed(1).replace(/\.0$/,``)}k`:String(Math.round(e)):`?`}function zE(e,t){let n=new Date(e),r=`${String(n.getHours()).padStart(2,`0`)}:${String(n.getMinutes()).padStart(2,`0`)}`;return t<1296e5?r:t<12096e5?`${BE(e)} ${r}`:BE(e)}var BE=e=>`${new Date(e).getDate()} ${new Date(e).toLocaleString(void 0,{month:`short`})}`,VE=(e,t)=>e===0?`start`:e===t?`end`:`middle`;function HE(e){let t=e.t1-e.t0;if(e.step<864e5)return[0,.5,1].map((n,r)=>({x:e.x+n*e.w,label:zE(e.t0+n*t,t),anchor:VE(r,2)}));let n=Math.round(t/e.step),r=new Date(e.t0+e.step/2),i=e=>new Date(r.getFullYear(),r.getMonth(),r.getDate()+e).getTime();return n<=1?[{x:e.x+e.w/2,label:BE(i(0)),anchor:`middle`}]:n>7?[0,Math.round((n-1)/2),n-1].map((t,n)=>({x:e.x+n/2*e.w,label:BE(i(t)),anchor:VE(n,2)})):Array.from({length:n},(t,r)=>({x:e.px(i(r)),label:BE(i(r)),anchor:VE(r,n-1)}))}function Doe(e,t,n){let r=e.map(t),i=r.reduce((e,t)=>t>e?t:e,0),a=r.reduce((e,t)=>e+t,0);return e.map((e,t)=>({item:e,label:n(e),value:r[t],frac:i>0?r[t]/i:0,share:a>0?r[t]/a:0,text:L(r[t])}))}function Ooe(e,t,n=1.5){let r=ui(e);if(r<=0)return[];let i=t.map(t=>({k:t,v:e[t.id]})),a=i.filter(e=>e.v>0),o=a.reduce((e,t)=>e+Math.max(0,n-t.v/r*100),0),s=a.filter(e=>e.v/r*100>n).reduce((e,t)=>e+(t.v/r*100-n),0),c=0,l=[];for(let e of i){let t=e.v/r*100;if(e.v<=0)continue;let i=Math.max(n,t);s>0&&t>n&&(i=t-o*(t-n)/s),l.push({kind:e.k.name,slot:e.k.slot,value:e.v,pct:t,x:c,w:i,roomy:i>=14}),c+=i}return l}function koe(e,t,n=2){let r=e.length||24,i=t.w/r,a=Math.max(1,i-n),o=e.reduce((e,t)=>t>e?t:e,0),s=e.reduce((e,t)=>e+t,0);return e.map((e,r)=>{let c=o>0?Math.max(+(e>0),e/o*t.h):0;return{hour:r,value:e,x:t.x+r*i+n/2,y:t.y+t.h-c,w:a,h:c,share:s>0?e/s:0}})}function UE(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}`}var WE=[[/fable/i,1],[/opus/i,3],[/sonnet/i,2],[/haiku/i,0]];function GE(e,t){let n=e=>{let t=WE.findIndex(([,t])=>t===e%5);return(t<0?WE.length:t)*10+Math.floor(e/5)};return n(e)-n(t)}var Aoe=2;function KE(e){if(!e)return null;for(let[t,n]of WE)if(t.test(e))return n;return null}function qE(e){let t=new Map,n=new Set;for(let r of e){let e=KE(r);e==null||n.has(e)||t.has(r)||(n.add(e),t.set(r,e))}return t}function joe(e){let t=e=>(e.match(/\d+/g)??[]).filter(e=>e.length<=2).map(Number),n=(e,t)=>{for(let n=0;n<Math.max(e.length,t.length);n++){let r=(e[n]??-1)-(t[n]??-1);if(r)return r}return 0};return[...e].sort((e,r)=>n(t(r),t(e)))}function Moe(e){let t=new Map,n=new Map;for(let r of e){let e=KE(r),i=e==null?0:n.get(e)??0;e==null||i>Aoe||t.has(r)||(n.set(e,i+1),t.set(r,e+5*i))}return t}function JE(e,t){return e.at?e.at(t):e.id&&t.totals?t.totals[e.id]:0}function YE(e,t,n,r={}){let i=r.normalize!==!1,a=Math.max(1,Math.min(r.maxW??14,e.slot-2));return t.map(t=>{let r=n.reduce((e,n)=>e+JE(n,t),0),o=[];if(r<=0)return{point:t,bands:o};let s=0;for(let c of n){let n=JE(c,t);if(n<=0)continue;let l=i?e.y+e.h-(s+n)/r*e.h:e.py(s+n),u=i?e.y+e.h-s/r*e.h:e.py(s);s+=n,o.push({kind:c.name,slot:c.slot,x:e.px(t.t)-a/2,y:l,w:a,h:Math.max(1,u-l),value:n,pct:n/r*100})}return{point:t,bands:o}})}function XE(e,t=jE,n=4e3){if(e.length<2)return e;if((e[e.length-1].t-e[0].t)/t+1>n)return null;let r=new Map(e.map(e=>[e.day,e])),i=t<864e5?Foe:UE,a=[],o=e[e.length-1].t;for(let n=e[0].t;n<=o+t/2;n=ZE(n,t)){let e=i(n);a.push(r.get(e)??{t:n,day:e,v:0})}return a}function Noe(e,t,n=4e3){if(e.length<2)return e;if((e[e.length-1].t-e[0].t)/864e5+1>n)return null;let r=new Map(e.map(e=>[e.day,e])),i=[],a=e[e.length-1].t;for(let n=e[0].t;n<=a+jE/2;n=ZE(n,jE)){let e=UE(n),a=r.get(e);i.push(a??t(n,e))}return i}function Poe(e){let t=[];for(let n of e){let e=n.label||n.key;t.includes(e)||t.push(e)}let n=Moe(joe(t)),r=t.filter(e=>n.has(e)),i=t.filter(e=>!n.has(e)).map(e=>e.replace(/^claude-/,``));return{bands:r.map(e=>({alias:e,slot:n.get(e)})).sort((e,t)=>GE(e.slot,t.slot)),restSlot:i.length>0?4:null,restName:i.join(`, `)}}function ZE(e,t){if(t!==864e5)return e+t;let n=new Date(e);return n.setDate(n.getDate()+1),n.setHours(0,0,0,0),n.getTime()}function Foe(e){let t=new Date(e);return`${UE(e)}T${String(t.getHours()).padStart(2,`0`)}`}function Ioe(e,t,n){let r=e=>n.reduce((t,n)=>t+JE(n,e),0);if(!t)return e.length?[e.map((e,t)=>t)]:[];let i=[],a=null;return e.forEach((e,t)=>{r(e)>0?(a||(a=[],i.push(a)),a.push(t)):a=null}),i}function Loe(e,t,n,r={}){let i=r.normalize!==!1,a=Ioe(t,i,n),o=Math.max(.5,e.slot/2),s=DE;return n.map(r=>{let c=``;for(let l of a){let a=[],u=[];for(let c of l){let d=t[c],f=n.reduce((e,t)=>e+JE(t,d),0),p=0;for(let e of n){if(e===r)break;p+=JE(e,d)}let m=JE(r,d),h=t=>i?e.y+e.h-(f>0?t/f:0)*e.h:e.py(t),g=e.px(d.t);l.length===1?(a.push(`${s(g-o)},${s(h(p+m))}`,`${s(g+o)},${s(h(p+m))}`),u.unshift(`${s(g-o)},${s(h(p))}`,`${s(g+o)},${s(h(p))}`)):(a.push(`${s(g)},${s(h(p+m))}`),u.unshift(`${s(g)},${s(h(p))}`))}a.length&&(c+=AE(a,u))}return{kind:r.name,slot:r.slot,d:c}})}function Roe(e,t=12e5){let n=e[e.length-1];if(!n||n.pts.length<2)return null;let r=n.pts[0],i=n.pts[n.pts.length-1],a=i.t-r.t;if(a<t)return null;let o=i.v-r.v;return o<0?null:o/a*36e5}function zoe(e,t,n,r){if(e==null||t==null||t<=0||e>=100)return null;let i=r+(100-e)/t*36e5;return n==null?{kind:`full`,at:i}:n<=r?null:i<n?{kind:`full`,at:i}:{kind:`lasts`,pctAtReset:e+t*((n-r)/36e5),resetAt:n}}function Boe(e,t,n=4){let r=t-e;if(!(r>0)||n<2)return[];let i=[3e5,9e5,18e5,ME,2*ME,3*ME,6*ME,12*ME,jE,2*jE,7*jE],a=i.find(e=>r/e<=n)??i[i.length-1],o=new Date(e);o.setHours(0,0,0,0);let s=[];for(let n=o.getTime();n<=t;n+=a)n>=e&&s.push(n);return s}function Voe(e,t,n,r=24){return e===`session`?{t0:n-r*ME,t1:n,isWindow:!1}:t!=null&&t>n?{t0:t-7*jE,t1:t,isWindow:!0}:{t0:n-7*jE,t1:n,isWindow:!1}}function Hoe(e,t){return EE(e.flatMap(e=>e.pts),t,e=>e.t)}function Uoe(e){let t=e.filter(e=>e.rolled).length,n=e.length-1-t;return n<=0&&t<=0?null:{lead:n>0?`A break in the line is a stretch nobody took a reading in.`:null,more:t>0?`A dashed rule is where the window rolled over and the count started again.`:null}}function Woe(e,t,n){return e.map(e=>({t:n(e.hour),day:e.hour,v:t(e)}))}var QE=[`var(--chart-1)`,`var(--chart-2)`,`var(--chart-3)`,`var(--chart-4)`],$E=[...QE,`var(--muted)`,...[65,40].flatMap(e=>[...QE.map(t=>`color-mix(in srgb, ${t} ${e}%, var(--panel))`),`var(--muted)`])],eD=QE[0];function tD({bag:e,whole:t,fmt:n=L,exact:r=Me,children:i}){let a=Ooe(e,ge.map(e=>({id:e.id,slot:e.slot,name:e.name})));return(0,J.jsxs)(`div`,{className:`ts-comp`,children:[(0,J.jsx)(`div`,{className:`ts-bar`,role:`img`,"aria-label":`what the tokens were`,children:a.map(e=>(0,J.jsx)(`span`,{className:`ts-seg`,title:`${e.kind}: ${r(e.value)} (${e.pct<.1?`<0.1`:e.pct.toFixed(1)}%)`,style:{left:`${e.x}%`,width:`${e.w}%`,background:QE[e.slot]}},e.kind))}),(0,J.jsxs)(`div`,{className:`ts-legend`,children:[ge.map(r=>{let i=e[r.id],a=t>0?i/t*100:0;return(0,J.jsxs)(`span`,{className:`ts-leg`,title:`${r.name} — ${r.what}`,children:[(0,J.jsx)(`i`,{style:{background:QE[r.slot]}}),(0,J.jsx)(`b`,{children:r.name}),` `,n(i),(0,J.jsx)(`em`,{children:a<.1?`<0.1%`:`${a.toFixed(+(a<10))}%`})]},r.id)}),i]})]})}function nD({totals:e,scope:t=`corpus`}){let n=Qt(e,t);return n?(0,J.jsxs)(`div`,{className:`empty ts-caveat`,children:[n.cacheNote,n.contextNote?(0,J.jsxs)(J.Fragment,{children:[` `,n.contextNote]}):null,n.advice?(0,J.jsxs)(J.Fragment,{children:[` `,n.advice]}):null]}):null}function rD(){let[e,t]=(0,V.useState)(0),n=(0,V.useRef)(null);return[e,(0,V.useCallback)(e=>{if(n.current?.disconnect(),n.current=null,!e)return;let r=()=>{let t=getComputedStyle(e);return Math.max(0,e.clientWidth-(parseFloat(t.paddingLeft)||0)-(parseFloat(t.paddingRight)||0))};t(r()),typeof ResizeObserver<`u`&&(n.current=new ResizeObserver(()=>t(r())),n.current.observe(e))},[])]}var Goe=`drag across the chart to read a value`;function iD(){return(0,J.jsx)(`span`,{className:`scrub-hint`,children:Goe})}var aD={subscription:`a Claude subscription`,api:`an API key`,cloud:`Bedrock or Vertex`,unknown:`not detected yet`};function Koe(){let e=Dh(),t=hS(),n=e.world.budget?.budget??null,r=(n?.periods??[]).filter(e=>e.unit===`usd`),[i,a]=(0,V.useState)({}),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(!1),[u,d]=(0,V.useState)(Fx),[f,p]=(0,V.useState)(``),m=(t,n)=>e.conn.liveSend({t:`budget.set`,budget:t},n),h=e=>{let t=i[e.id];if(t==null||!n)return;if(a(t=>{let{[e.id]:n,...r}=t;return r}),!t.trim()){if(yx(n,e.id)==null)return;s(null),q(`action:period.cap.clear`),m(be(n,e.id),`cap cleared`);return}let r=xw(`usd`,t);r.ok?(s(null),q(`action:period.cap.set`),m(wn(n,{periodId:e.id,max:r.max,unit:`usd`}),`cap saved`)):s(r.reason)},g=e=>{n&&(q(`action:period.remove`),m(be({...n,periods:(n.periods??[]).filter(t=>t.id!==e.id)},e.id),`period removed`))},_=()=>{if(!n)return;let e=Rx(u);if(!e.ok){s(e.reason);return}let t=null;if(f.trim()){let e=xw(`usd`,f);if(!e.ok){s(e.reason);return}t=e.max}s(null),q(`action:period.add`);let r={...n,periods:[...(n.periods??[]).filter(t=>t.id!==e.period.id),e.period]};m(t==null?r:wn(r,{periodId:e.period.id,max:t,unit:`usd`}),`period saved`),l(!1),p(``),d(Fx())},v=(e,t)=>d(n=>({...n,[e]:t})),y=t?.source===`setting`?t.profile===`unknown`?`auto`:t.profile:`auto`,b=O(t?.profile);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(QS,{id:`billing-profile`,radio:!0,label:`billing profile`,icon:Vs,value:y,options:[{value:`auto`,label:`auto-detect`},{value:`subscription`,label:`subscription`},{value:`api`,label:`API key`},{value:`cloud`,label:`Bedrock / Vertex`}],onChange:t=>{q(`action:billing.set`),e.conn.liveSend({t:`billing.set`,profile:t===`auto`?null:t},t===`auto`?`billing profile: auto-detect`:`billing profile set`)},note:t?t.source===`setting`?(0,J.jsxs)(J.Fragment,{children:[`You set this to `,aD[t.profile],`. Auto-detect clears it.`]}):t.profile===`unknown`?`Not detected — the usage chips show the 5-hour and weekly windows.`:(0,J.jsxs)(J.Fragment,{children:[`Detected: `,aD[t.profile],`.`]}):`This desktop has not reported one — the usage chips show the 5-hour and weekly windows.`,more:(0,J.jsxs)(`p`,{children:[`A subscription is read from `,(0,J.jsx)(`code`,{children:`/usage`}),` (two windows). An API key or a cloud account has no such windows, so the chips show dollars for the period below instead and `,(0,J.jsx)(`code`,{children:`/usage`}),` is not asked.`]})}),(0,J.jsxs)(iC,{id:`billing-periods`,label:`dollar periods and caps`,icon:Jc,note:b&&r.length===0?`Optional on a subscription: a month or a span in dollars beside the two windows.`:void 0,more:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`p`,{children:[`Spend is this desktop's ledger at list price, not your invoice. A cap holds `,(0,J.jsx)(`b`,{children:`automatic`}),` work (the backlog, the queue, timed sends) until the period resets; a prompt you send by hand always goes. The hard stop is Anthropic's own spend limit.`]}),(0,J.jsx)(`p`,{children:`A calendar month starts on its billing day in the zone you name (the 31st means the last day of a short month). A rolling 30 days has no reset, so a schedule cannot wait for it.`})]}),children:[!n&&(0,J.jsx)(X,{children:`Waiting for the desktop's budget.`}),n&&r.map(e=>{let t=yx(n,e.id);return(0,J.jsxs)(`div`,{className:`set-item`,children:[(0,J.jsx)(`div`,{className:`set-lead`,children:(0,J.jsx)(`span`,{className:`set-lbl`,children:Ex(e)})}),(0,J.jsxs)(`div`,{className:`budget-input`,children:[(0,J.jsx)(`span`,{className:`budget-affix`,children:`cap $`}),(0,J.jsx)(`input`,{inputMode:`decimal`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,"aria-label":`cap for ${Ex(e)}`,placeholder:`none`,value:i[e.id]??(t==null?``:String(t)),onChange:t=>a(n=>({...n,[e.id]:t.target.value})),onBlur:()=>h(e),onKeyDown:e=>{e.key===`Enter`&&e.target.blur()}}),(0,J.jsxs)(fC,{className:`key`,confirm:`remove?`,onConfirm:()=>g(e),children:[(0,J.jsx)(B,{size:13}),` remove`]})]})]},e.id)}),n&&r.length===0&&!c&&(0,J.jsx)(X,{children:`No dollar period yet — the chips have nothing to measure.`}),n&&!c&&(0,J.jsx)(`div`,{className:`set-chips`,children:(0,J.jsxs)(Y,{onClick:()=>l(!0),children:[(0,J.jsx)(Fo,{size:13}),` add a period`]})}),n&&c&&(0,J.jsxs)(`div`,{className:`set-item`,children:[(0,J.jsx)(`div`,{className:`set-chips`,role:`group`,"aria-label":`period kind`,children:Nx.map(e=>(0,J.jsx)(Y,{className:u.kind===e.id?`active`:void 0,onClick:()=>v(`kind`,e.id),children:e.label},e.id))}),u.kind===`month`&&(0,J.jsxs)(`div`,{className:`budget-input`,children:[(0,J.jsx)(`span`,{className:`budget-affix`,children:`billing day`}),(0,J.jsx)(`input`,{inputMode:`numeric`,"aria-label":`billing day of the month`,value:u.anchorDay,onChange:e=>v(`anchorDay`,e.target.value)})]}),u.kind===`week`&&(0,J.jsx)(`div`,{className:`set-chips`,role:`group`,"aria-label":`week starts on`,children:_x.map((e,t)=>(0,J.jsx)(Y,{className:u.startDow===t?`active`:void 0,onClick:()=>v(`startDow`,t),children:e},e))}),(u.kind===`month`||u.kind===`week`||u.kind===`day`)&&(0,J.jsxs)(`div`,{className:`budget-input`,children:[(0,J.jsx)(`span`,{className:`budget-affix`,children:`time zone`}),(0,J.jsx)(`input`,{autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,"aria-label":`time zone`,value:u.tz,onChange:e=>v(`tz`,e.target.value)})]}),u.kind===`span`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`budget-input`,children:[(0,J.jsx)(`span`,{className:`budget-affix`,children:`first day`}),(0,J.jsx)(`input`,{type:`date`,"aria-label":`first day`,value:u.from,onChange:e=>v(`from`,e.target.value)})]}),(0,J.jsxs)(`div`,{className:`budget-input`,children:[(0,J.jsx)(`span`,{className:`budget-affix`,children:`last day`}),(0,J.jsx)(`input`,{type:`date`,"aria-label":`last day, included`,value:u.to,onChange:e=>v(`to`,e.target.value)})]})]}),(0,J.jsxs)(`div`,{className:`budget-input`,children:[(0,J.jsx)(`span`,{className:`budget-affix`,children:`cap $`}),(0,J.jsx)(`input`,{inputMode:`decimal`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,placeholder:`none`,"aria-label":`cap in dollars`,value:f,onChange:e=>p(e.target.value)})]}),(0,J.jsxs)(`div`,{className:`set-chips`,children:[(0,J.jsx)(Y,{className:`active`,onClick:_,children:`save period`}),(0,J.jsx)(Y,{onClick:()=>{l(!1),s(null)},children:`cancel`})]})]}),o&&(0,J.jsx)(`div`,{className:`set-warn`,children:o})]})]})}function qoe(){return(0,J.jsx)(rC,{id:`token-stats`,label:`token statistics`,icon:qs,opens:!0,onClick:()=>{q(`overlay:tokens`),U().nav.open(`tokens`)},note:`Every token this desktop has ever used, cumulative and per day, by model and by repo.`,more:(0,J.jsx)(`p`,{children:`Read out of the CLI's own conversation logs, so it covers sessions this app never drove.`})})}var Joe={id:`tokens`,messages:{"usage.status":e=>{tS.set(e.usage),cS.set(Gx(e.readings,e.usage)),vS(e.usage)},welcome:()=>{sS.set(null),cS.set([])},"billing.status":e=>sS.set({profile:e.profile,source:e.source})},settings:[{group:`tools`,order:-20,render:()=>(0,V.createElement)(qoe)},{group:`sessions`,order:11,render:()=>(0,V.createElement)(Koe)}]},oD=W(null);function sD(e){let t=U();t.say.track(`overlay:sessionBudget`),oD.set(e),t.nav.open(`sessionBudget`)}function Yoe(){oD.set(null),U().nav.close(`sessionBudget`)}function cD({initial:e,cal:t,onChange:n,calFor:r,spark:i,windowsOff:a}){let o=(0,V.useId)(),[s,c]=(0,V.useState)(e?.unit??`usd`),[l,u]=(0,V.useState)(e?Sw(e):``),[d,f]=(0,V.useState)(e?.interrupt??!0),[p,m]=(0,V.useState)(e?.hard?`hard`:`soft`),h=Date.now(),g=l.trim()?xw(s,l):null,_=(e,t,r,i=p)=>{let a=t.trim()?xw(e,t):null;n(a&&a.ok?i===`hard`?{unit:e,max:a.max,interrupt:!0,hard:!0}:{unit:e,max:a.max,interrupt:r}:null)},v=vw(s),y=bw(s)?t===void 0?r??null:Cw(s,t,h):null,b=Ow(s,i,t,h),x=g&&g.ok?kw({unit:s,max:g.max},i,t,h):null,S=g&&g.ok?g.max:null;return(0,J.jsxs)(`div`,{className:`budget-field`,children:[(0,J.jsxs)(`div`,{className:`set-item`,children:[(0,J.jsx)(`div`,{className:`set-lead`,children:(0,J.jsx)(`span`,{className:`set-lbl`,children:`measured in`})}),(0,J.jsx)(yS,{label:`budget unit`,options:_w(!!a,e?.unit).map(e=>({key:e.unit,label:e.label})),value:s,onChange:e=>{c(e),_(e,l,d)}})]}),a&&(0,J.jsx)(X,{children:a}),b&&(0,J.jsxs)(`div`,{className:`budget-spent`,children:[(0,J.jsx)(`span`,{className:`budget-k`,children:`spent`}),` `,b]}),(0,J.jsxs)(`div`,{className:`set-item`,children:[(0,J.jsx)(`label`,{className:`set-lead`,htmlFor:o,children:(0,J.jsx)(`span`,{className:`set-lbl`,children:`cap`})}),(0,J.jsxs)(`div`,{className:`budget-input`,children:[v.prefix&&(0,J.jsx)(`span`,{className:`budget-affix`,children:v.prefix}),(0,J.jsx)(`input`,{id:o,value:l,inputMode:`decimal`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,placeholder:`e.g. ${v.example}`,"aria-label":`cap in ${v.label}`,onChange:e=>{u(e.target.value),_(s,e.target.value,d)}}),v.suffix&&(0,J.jsx)(`span`,{className:`budget-affix`,children:v.suffix})]}),(0,J.jsxs)(`div`,{className:`set-chips budget-presets`,role:`group`,"aria-label":`quick picks`,children:[v.presets.map(e=>{let t=xw(s,e),n=t.ok&&S===t.max;return(0,J.jsx)(`button`,{className:`row-chip${n?` on`:``}`,"aria-pressed":n,onClick:()=>{u(e),_(s,e,d)},children:yw(s,e)},e)}),(0,J.jsx)(X,{as:`span`,className:`budget-blank`,children:`a blank field is no budget`})]})]}),g&&!g.ok&&(0,J.jsx)(X,{className:`warn`,children:g.reason}),x&&(0,J.jsx)(`div`,{className:`budget-preview`,children:x}),y&&(0,J.jsx)(X,{children:y}),(0,J.jsxs)(`div`,{className:`set-item`,children:[(0,J.jsx)(`div`,{className:`set-lead`,children:(0,J.jsx)(`span`,{className:`set-lbl`,children:`at the cap`})}),(0,J.jsx)(yS,{label:`what happens at the cap`,options:Aw.map(e=>({key:e.key,label:e.label,note:e.note})),value:p,onChange:e=>{m(e),_(s,l,d,e)}})]}),p===`soft`&&(0,J.jsx)(ZS,{label:`interrupt the running turn when hit`,on:d,onChange:()=>{f(!d),_(s,l,!d)},note:d?`The turn running when the cap is hit gets one Esc, where it is safe to send one.`:`The turn running when the cap is hit is left to finish.`})]})}var Xoe={noSpark:`no turn logged yet`,unpriced:`model has no list price`,noReading:`no usage reading`,stale:`usage reading is old`,noCalibration:`window too young to convert`,notRunning:`not running`,unstated:`backend states no figure`,notClaude:`not claude's window`};function Zoe(e,t){if(!e.sourceSpend&&LC(t,e.backend))return null;let n=t?.find(t=>t.id===e.backend)?.label;return St(n||`this session's backend`)}function Qoe(e,t){let n=e.budget;if(!n||!e.running)return null;let r=n.verdict;if(r.state===`over`){let e=n.cfg.hard?`hard: asks before sends`:`sends held`;return{cls:`ctx-low`,text:`budget hit · ${ce(r)} · ${e}`,title:`${g(r)}. ${kt(n.cfg)}`}}if(r.state===`unknown`){let e=r.why===`stale`&&n.cal?t-n.cal.checkedAt:void 0,i=r.why??`noSpark`;return{cls:`idle`,text:`budget ? — ${Xoe[i]}`,title:Gr(i,e,r.unit)}}return{cls:`ctx-ok`,text:ce(r),title:g(r)}}function $oe(e,t){return`${e}: ${g(t.verdict)}. Its sends are held — raise or clear the budget to release them.`}function ese(e,t,n){if(t)return n.has(e)?{notice:!1,next:n}:{notice:!0,next:new Set([...n,e])};if(!n.has(e))return{notice:!1,next:n};let r=new Set(n);return r.delete(e),{notice:!1,next:r}}function tse(e,t,n){return(e?t.find(t=>t.id===e):null)??n}var nse=e=>`asked the desktop to set the budget — ${e}`,rse=`asked the desktop to clear the budget`,ise=e=>`budget set — ${e}`,ase=`budget cleared — this session's sends are no longer held by it`,ose=1e4;function lD(e,t){return e?!!t&&t.unit===e.unit&&t.max===e.max&&t.interrupt===e.interrupt&&!!t.hard==!!e.hard:!t}var sse=`no connection — the desktop didn't get the budget. Try again when the link is back.`;function cse(e,t){let n=U();return n.say.track(t?`action:sessionBudget.set`:`action:sessionBudget.clear`),n.conn.liveSend({t:`session.budget.set`,id:e,budget:t},t?nse(Yr(t)):rse,sse)}var lse=`A percent is converted from dollars at the window's measured rate; the desktop sends that rate with a budget, so once one is set this line says what 1% is worth — until then nothing is held.`;function use({subject:e,title:t,windowsOff:n}){let r=Ww(3e4),i=e.budget,[a,o]=(0,V.useState)(i?.cfg??null),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(!1);(0,V.useEffect)(()=>{if(!s)return;if(lD(s.cfg,i?.cfg)){U().say.toast(s.cfg?ise(Yr(s.cfg)):ase),c(null),u(!1);return}let e=window.setTimeout(()=>u(!0),ose);return()=>window.clearTimeout(e)},[s,i]);let d=t=>{cse(e.id,t)&&(c({cfg:t}),u(!1))},f=!!a&&!!i&&lD(a,i.cfg),p=(0,J.jsxs)(J.Fragment,{children:[i&&(0,J.jsx)(fC,{className:`key budget-clear`,confirm:`clear it — sure?`,onConfirm:()=>d(null),children:`clear budget`}),a&&!f?(0,J.jsxs)(Y,{variant:`primary`,className:`budget-set`,onClick:()=>d(a),children:[(0,J.jsx)(Qc,{size:14}),` `,i?`change to`:`set budget`,` `,Yr(a)]}):(0,J.jsx)(`span`,{className:`budget-why`,children:f?`This is the budget already set — change the cap above to replace it.`:i?`Type a new cap above to change it.`:`Type a cap or pick one above to set a budget.`})]});return(0,J.jsx)(Hw,{title:`Session budget`,icon:(0,J.jsx)(Qc,{size:18}),onClose:Yoe,footer:p,children:(0,J.jsxs)(`div`,{className:`sheet-scroll`,children:[(0,J.jsxs)(`div`,{className:`set-group`,children:[(0,J.jsx)(`div`,{className:`budget-who`,children:t}),(0,J.jsxs)(`div`,{className:`ctx-cost budget-now`,children:[(0,J.jsxs)(`div`,{className:`ctx-cost-head`,children:[(0,J.jsx)(Qc,{size:14}),(0,J.jsx)(`span`,{children:i?`budget ${Yr(i.cfg)}`:`no budget`})]}),i&&(0,J.jsx)(`div`,{className:`ctx-cost-note`,children:Mw(i,r)})]}),s&&l&&(0,J.jsx)(X,{className:`warn`,children:`The desktop has not confirmed this yet. If it does not, the host there may be an older version that does not know session budgets — then nothing is capped.`}),(0,J.jsx)(X,{children:`What this one conversation may spend, its subagents included. At the cap its sends are held and you are told; raising or clearing the budget lets them go.`})]}),(0,J.jsx)(`div`,{className:`set-group`,children:(0,J.jsx)(cD,{initial:i?.cfg??null,cal:i?i.cal??null:void 0,onChange:o,spark:Li(e),calFor:i?void 0:lse,windowsOff:n},e.id)})]})})}var dse={id:`sessionBudget`,sheets:[{id:`sessionBudget`,persisted:!1,render:e=>{let t=tse(oD.get(),e.world.sessions,e.world.active);return t?(0,V.createElement)(use,{subject:t,title:e.world.sessionRowTitle(t),windowsOff:Zoe(t,e.world.backends)}):null}}]},uD=W(null);function fse(){return G(uD)}function pse(){uD.set(null)}var mse=16;function hse({reconnect:e}){let t=G(uD),[n,r]=(0,V.useState)(``),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(!1),c=async()=>{s(!0),a(null);try{let t=await H.auth.login(n);t.ok?(r(``),pse(),e()):a(t.error||`login failed`)}catch(e){a(String(e.message||e))}finally{s(!1)}};return t?(0,J.jsx)(`div`,{className:`sheet auth-gate`,children:(0,J.jsxs)(`div`,{className:`auth-card`,children:[(0,J.jsxs)(`div`,{className:`auth-title`,children:[(0,J.jsx)(Us,{size:20,style:{verticalAlign:`-3px`,marginRight:6}}),`Locked`]}),t.enabled?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(X,{as:`p`,children:[`This device is on the `,t.kind===`lan`?`local network`:`network`,`, which is password-protected. Enter the password to continue.`]}),(0,J.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),n?o||c():a(`type the password first`)},children:[(0,J.jsx)(`input`,{className:`auth-input`,type:`password`,autoFocus:!0,placeholder:`password`,value:n,onChange:e=>{r(e.target.value),a(null)}}),i&&(0,J.jsx)(X,{className:`oracle-warn`,style:{marginTop:8},children:i}),(0,J.jsx)(Y,{variant:`primary`,type:`submit`,style:{marginTop:12,width:`100%`},children:o?`checking…`:`unlock`})]})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(X,{as:`p`,children:`This device is on the local network, and LAN access is protected — but no password has been set yet. Set one from the desktop itself, or from a phone connected over Tailscale (Settings → LAN access), then retry.`}),(0,J.jsxs)(Y,{style:{marginTop:12},onClick:()=>e(),children:[(0,J.jsx)(xc,{size:mse}),` retry`]})]})]})}):null}var gse={id:`authGate`,messages:{authRequired:e=>uD.set({enabled:e.enabled,kind:e.kind}),welcome:()=>uD.set(null)}};function dD(e){return/\.(png|jpe?g|gif|webp|bmp|svg|heic|heif)$/i.test(e)}function fD(e){return/\.(mp4|webm|mov|m4v|ogv|mkv)$/i.test(e)}function pD(e){return dD(e)||fD(e)}function mD(e){return/\.(mp3|wav|m4a|aac|ogg|oga|opus|flac|aiff|caf|amr)$/i.test(e)}function hD(e){return/\.pdf$/i.test(e)}function gD(e){return/\.html?$/i.test(e)}function _D(e){return vD(e)||gD(e)}function vD(e){return/\.(md|markdown|mdx)$/i.test(e)}function yD(e){return vD(e)||/\.(txt|log|csv|json|ya?ml|toml|ini|diff|patch|sh|html?)$/i.test(e)}function bD(e){return yD(e)||hD(e)||pD(e)||mD(e)}var xD=()=>Ut(ma(R.repoColors,{})),SD=Nn,CD=new Set;function wD(e){SD=e,Sp(e);for(let t of CD)t(e)}var TD=()=>SD;function ED(e){let t=Ut(e);Ta(R.repoColors,t),wD(t)}function _se(){wD(xD())}function DD(){let[e,t]=(0,V.useState)(SD);return(0,V.useEffect)(()=>{e!==SD&&t(SD);let n=e=>t(e);return CD.add(n),()=>{CD.delete(n)}},[]),e}wD(xD());var OD=R.pullState;async function kD(){return await fne(),caches.open(Rl)}var vse=`/__pull-result/`,AD=R.pullAuto,yse=25e3,jD=3e4,MD=[2e3,5e3,1e4,2e4,3e4,6e4,12e4],bse=15e3,xse=6048e5,Sse=8e3;function Cse(e,t,n){let r=`${e} ${t} ${Math.round(n)}`,i=5381;for(let e=0;e<r.length;e++)i=(i*33^r.charCodeAt(e))>>>0;let a=52711;for(let e=r.length-1;e>=0;e--)a=(a*31^r.charCodeAt(e))>>>0;return`l_${i.toString(36)}${a.toString(36)}`}function ND(e){return e.src&&e.src.startsWith(`/api/plugin-file/`)?Su(e.src):Su(`/api/repos/${e.repoId}/artifact?path=${encodeURIComponent(e.relPath)}&download=1`)}function wse(){try{let e=JSON.parse(z(OD)||`{}`);return e&&typeof e==`object`?e:{}}catch{return{}}}function PD(){return z(AD)!==`0`}function Tse(){return globalThis.Capacitor}function FD(){if(ha())return null;let e=Nh(`Pull`);return e&&typeof e.enqueue==`function`?e:null}function ID(){return hu()&&FD()!==null}async function LD(e){let t=FD();if(!t)return null;let n=await t.enqueue(e);return{items:n?.items??[],running:!!n?.running}}async function Ese(e){try{await FD()?.cancel({id:e})}catch{}}async function RD(e){try{await FD()?.discard({id:e})}catch{}}async function Dse(e){let t=FD();if(!t)throw Error(`no native download engine on this device`);await t.publish({id:e})}async function zD(e){let t=FD();if(t&&typeof t.setAuto==`function`)try{await t.setAuto({on:e})}catch{}}async function BD(){let e=FD();if(!e)return{items:[],running:!1};try{let t=await e.list();return{items:t?.items??[],running:!!t?.running}}catch{return{items:[],running:!1}}}function Ose(e){let t=FD();if(!t)return()=>void 0;let n=null,r=!1,i=e=>{r?e.remove():n=e};try{let n=t.addListener(`pullChanged`,t=>e(t?.items??[]));n&&typeof n.then==`function`?n.then(i).catch(()=>void 0):i(n)}catch{}return()=>{r=!0;try{n?.remove()}catch{}}}function kse(e){if(!e)return null;let t=Tse();try{return typeof t?.convertFileSrc==`function`?t.convertFileSrc(e):null}catch{return null}}function Ase(e){let t=e.item.size||e.received;return t>0?Math.min(100,Math.round(e.received/t*100)):0}function VD(e){if(!e||e.state===`done`&&e.evicted)return{phase:`idle`,pct:null,label:`download`,detail:e?.evicted?`downloaded before — the bytes were cleared to save space; fetch it again`:`fetch it to this phone — it resumes by itself if the link drops`};let t=Ase(e);return e.state===`downloading`?{phase:`downloading`,pct:t,label:`downloading · ${t}%`,detail:`open Downloads to watch, pause or cancel it`}:e.state===`queued`||e.state===`paused`?{phase:`queued`,pct:e.received>0?t:null,label:e.state===`paused`?`paused`:`queued`,detail:e.received>0?`${t}% is already here — it resumes from there`:`waiting its turn — open Downloads`}:e.state===`failed`?{phase:`failed`,pct:e.received>0?t:null,label:`retry download`,detail:e.error?`the last attempt failed: ${e.error}`:`the last attempt failed`}:e.savedAt&&!e.saveError?e.saveVia===`browser`?{phase:`saved`,pct:100,label:`save again`,detail:`on this phone · handed to ${e.savedTo} — tap to hand it over again if it never arrived`}:e.savedPresent===!0?{phase:`saved`,pct:100,label:`in Downloads`,detail:`in ${e.savedTo} · nothing to do — a second save would only make another copy beside it`}:e.savedPresent===!1?{phase:`saved`,pct:100,label:`save again`,detail:`it was saved to ${e.savedTo}, and is not in Downloads any more · still on this phone — tap to put it back`}:{phase:`saved`,pct:100,label:`save again`,detail:`on this phone · saved to ${e.savedTo}`}:e.saveHandedAt&&!e.saveError?{phase:`have`,pct:100,label:`check Downloads`,detail:`on this phone · handed to Downloads, and the phone has not said where it went — open Downloads to look`}:{phase:`have`,pct:100,label:`save to phone`,detail:e.saveError?`on this phone — saving it out failed: ${e.saveError}`:`on this phone — put it where a file manager can see it`}}function HD(e){let{phase:t}=VD(e);return t===`saved`&&e?.savedPresent===!0?`open`:t===`have`||t===`saved`?`save`:t===`downloading`||t===`queued`?`open`:`start`}function UD(e,t){return!(e.state!==`done`||e.evicted||!e.autoSave&&!t||e.savedAt||e.saveError||e.saveHandedAt)}function jse(e){return e.state===`downloading`?!1:e.state!==`done`||!!e.evicted}function WD(e,t,n,r){if(e.item.repoId!==t||e.item.relPath!==n)return null;let i=Math.round(r??0),a=Math.round(e.item.mtime??0);return i&&a?i===a?`exact`:null:i&&e.state===`done`&&!e.evicted?null:`loose`}function Mse(e,t,n){return t||!!e.local||e.state===`done`||n}function GD(e,t){return!(!e||e.state!==`downloading`||t.activeId===e.item.id||e.nativeOwned||e.engine===`native`&&t.nativeSupported!==!1||e.engine===`bgfetch`&&t.bgLive!==!1)}function Nse(e,t){return!(!e||e.state!==`queued`||e.nativeOwned||!t.force&&!t.auto&&!e.local||!t.force&&e.attempts>=t.maxAttempts||!t.force&&e.nextRetryAt&&e.nextRetryAt>t.now)}function KD(e,t){return!e&&!t}function qD(e){return e.state===`failed`&&/^http (404|410)\b/.test(e.error??``)}function JD(e,t){return e.filter(e=>e.state!==`done`&&(t||!!e.local||e.state===`downloading`))}function Pse(e){return e.native||!e.android||!e.auto||e.answered?!1:e.records.some(e=>!e.local&&e.state!==`done`)}function Fse(){let e=this.list(),t={};if(e.length<=200)for(let n of e)t[n.item.id]=n;else{let n=e=>this.active===e.item.id||e.local&&e.state!==`done`||e.state===`done`&&!e.savedAt&&!e.evicted,r=[...e.filter(n),...e.filter(e=>!n(e))];for(let e of r.slice(0,200))t[e.item.id]=e;for(let e of r.slice(200))jy(`pulls`,e.item.id),e.nativePath&&RD(e.item.id)}this.records=t,Ta(OD,t),this.emit()}function Ise(e,t){let n=this.records[e];n&&(this.records[e]={...n,...t,updatedAt:Date.now()},this.persist())}function Lse(e){this.dropSuperseded(e.flatMap(e=>e.supersedes??[]));for(let t of e)t.family&&this.dropSuperseded(this.list().filter(e=>e.item.id!==t.id&&e.item.repoId===t.repoId&&(e.item.family??``)===t.family&&e.item.mtime<t.mtime).map(e=>e.item.id));let t=new Set(e.map(e=>e.id));for(let t of e){let e=this.records[t.id];if(e)this.records[t.id]={...e,item:t};else if(this.shadowed(t))continue;else this.records[t.id]={item:t,state:`queued`,received:0,attempts:0,updatedAt:Date.now()}}for(let e of Object.keys(this.records))Mse(this.records[e],t.has(e),this.active===e)||(delete this.records[e],jy(`pulls`,e));this.persist(),this.evictOld(),this.pump()}function Rse(e){this.dropSuperseded(e.supersedes??[]),this.shadowed(e)?this.persist():(this.records[e.id]||(this.records[e.id]={item:e,state:`queued`,received:0,attempts:0,updatedAt:Date.now()},this.persist()),this.pump())}function zse(e,t={}){let n=Math.round(e.mtime??0),r=this.findFor(e.repoId,e.relPath,n);if(r){let i={local:!0};return t.autoSave&&(i.autoSave=!0),!r.item.mtime&&n&&(i.item={...r.item,mtime:n,size:r.item.size||Math.round(e.size??0)}),this.patch(r.item.id,i),jse(r)&&this.retry(r.item.id),r.item.id}let i=Cse(e.repoId,e.relPath,n),a={id:i,repoId:e.repoId,repoDir:e.repoDir??``,repoName:e.repoName??``,name:e.name||e.relPath.split(`/`).pop()||e.relPath,relPath:e.relPath,size:Math.max(0,Math.round(e.size??0)),mtime:n,ts:Date.now(),source:`manual`,...e.src&&e.src.startsWith(`/api/plugin-file/`)?{src:e.src}:{}};return this.records[i]={item:a,state:`queued`,received:0,attempts:0,updatedAt:Date.now(),local:!0,autoSave:!!t.autoSave},this.persist(),this.pump(!0,i),i}function Bse(e,t,n){let r=this.list();return r.find(r=>WD(r,e,t,n)===`exact`)??r.find(r=>WD(r,e,t,n)===`loose`)}function Vse(e){if(this.records[e.id])return!1;let t=this.findFor(e.repoId,e.relPath,e.mtime);return t?.local?(!t.item.mtime&&e.mtime&&(t.item={...t.item,mtime:e.mtime,size:t.item.size||e.size},this.records[t.item.id]={...t,updatedAt:Date.now()}),!0):!1}function Hse(e){let t=!1;for(let n of e){let e=this.records[n];e&&e.state!==`done`&&(this.active===n&&(this.abort?.abort(),this.active=null),delete this.records[n],RD(n),jy(`pulls`,n),t=!0)}t&&this.persist()}function Use(e){let t=this.records[e];t&&(t.state!==`done`||t.evicted)&&t.state!==`downloading`&&(this.patch(e,{state:`queued`,attempts:0,error:void 0,nextRetryAt:void 0,evicted:!1,nativeOwned:!1}),this.pump(!0,e))}async function Wse(e){this.active===e&&(this.abort?.abort(),this.active=null),delete this.records[e],this.removed.add(e),this.persist(),RD(e),await jy(`pulls`,e)}function Gse(e){let t=e??this.active;t&&(this.records[t]?.engine===`native`?(Ese(t),this.patch(t,{state:`paused`,rate:void 0,nextRetryAt:void 0})):this.active===t&&(this.abort?.abort(),this.active=null,this.patch(t,{state:`paused`,rate:void 0,nextRetryAt:void 0})))}function Kse(){for(let e of this.list())(e.state===`queued`||e.state===`paused`||e.state===`failed`)&&this.patch(e.item.id,{state:`queued`,attempts:0,error:void 0,nextRetryAt:void 0,nativeOwned:!1});this.pump(!0)}function qse(){if(this.active)return null;if(this.list().filter(e=>GD(e,{activeId:this.active,nativeSupported:ID()})).length)return`a transfer was interrupted and nothing is carrying it — putting it back in the queue`;let e=this.list().filter(e=>e.state===`queued`||e.state===`paused`||e.state===`failed`);return e.length?!PD()&&e.every(e=>!e.local)?`auto-download is off — tap a file to fetch it now`:KD(navigator.onLine,Md())?`the phone reports no network — will start when it is back`:e.every(e=>e.state===`paused`)?`paused — tap resume`:e.every(qD)?`the desktop no longer has these files — remove them`:e.every(e=>e.state===`failed`||e.attempts>=50)?`stopped after repeated failures — tap retry`:e.every(e=>e.state===`paused`||e.state===`failed`||e.attempts>=50)?`nothing is running — each row below says why`:null:null}var YD=524288,XD=8192;function ZD(){let e=Nh(`Save`);return e&&typeof e.begin==`function`?e:null}function QD(){return hu()&&ZD()!==null}function $D(){return hu()&&typeof ZD()?.find==`function`}async function eO(e,t){let n=ZD();if(!n?.find)return null;try{let r=await n.find({name:e,size:t||void 0});return{present:!!r?.present,where:r?.where,size:r?.size,modified:r?.modified}}catch{return null}}async function Jse(e,t){let n=ZD();if(!n)throw Error(`no native save on this device`);let{token:r}=await n.begin({name:t,mime:e.type===`application/octet-stream`?``:e.type||``});try{for(let t=0;t<e.size;t+=YD){let i=await e.slice(t,Math.min(t+YD,e.size)).arrayBuffer();await n.chunk({token:r,dataBase64:Yse(i)})}let{where:t}=await n.finish({token:r});return t}catch(e){try{await n.abort({token:r})}catch{}throw e}}function Yse(e){let t=new Uint8Array(e),n=``;for(let e=0;e<t.length;e+=XD)n+=String.fromCharCode(...t.subarray(e,e+XD));return btoa(n)}var Xse={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,jfif:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,svg:`image/svg+xml`,bmp:`image/bmp`,avif:`image/avif`,heic:`image/heic`,heif:`image/heif`,ico:`image/x-icon`,tif:`image/tiff`,tiff:`image/tiff`,mp4:`video/mp4`,m4v:`video/x-m4v`,webm:`video/webm`,mov:`video/quicktime`,ogv:`video/ogg`,mkv:`video/x-matroska`,mp3:`audio/mpeg`,m4a:`audio/mp4`,aac:`audio/aac`,wav:`audio/wav`,ogg:`audio/ogg`,flac:`audio/flac`,opus:`audio/opus`,pdf:`application/pdf`,txt:`text/plain`,log:`text/plain`,md:`text/markdown`,csv:`text/csv`,json:`application/json`,html:`text/html`,htm:`text/html`,apk:`application/vnd.android.package-archive`,zip:`application/zip`};function Zse(e){let t=/\.([A-Za-z0-9]+)$/.exec(e);return t&&Xse[t[1].toLowerCase()]||`application/octet-stream`}function tO(e,t){return new Blob(e,{type:Zse(t)})}async function Qse(e){let t=this.records[e];if(t?.engine===`native`&&t.nativePath)return this.saveNative(e,t);let n=await ky(`pulls`,e);if(!n?.blob){let t=`could not read the downloaded bytes on this phone — try again, or fetch it once more`;return this.patch(e,{saveError:t}),{ok:!1,error:t}}if(QD()){let t=await eO(n.name,n.blob.size);if(t?.present)return this.patch(e,{savedTo:t.where,savedAt:Date.now(),saveError:void 0,saveVia:`device`,savedPresent:!0,savedCheckedAt:Date.now()}),{ok:!0,where:t.where,already:!0};try{let t=await Jse(n.blob,n.name);return this.patch(e,{savedTo:t,savedAt:Date.now(),saveError:void 0,saveVia:`device`,savedPresent:!0,savedCheckedAt:Date.now()}),{ok:!0,where:t}}catch(t){let n=t instanceof Error?t.message:String(t);return this.patch(e,{saveError:n}),{ok:!1,error:n}}}let r=URL.createObjectURL(tO([n.blob],n.name)),i=document.createElement(`a`);i.href=r,i.download=n.name,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(r),6e4);let a=`your browser's downloads`;return this.patch(e,{savedTo:a,savedAt:Date.now(),saveError:void 0,saveVia:`browser`}),{ok:!0,where:a}}async function $se(e,t){let n=await eO(t.item.name||t.item.relPath.split(`/`).pop()||t.item.relPath,t.item.size||void 0);if(n?.present)return this.patch(e,{savedTo:n.where,savedAt:Date.now(),saveError:void 0,saveVia:`device`,savedPresent:!0,savedCheckedAt:Date.now()}),{ok:!0,where:n.where,already:!0};try{await Dse(e);let t=Date.now()+Sse;for(;;){let n=await BD();if(!this.records[e])return{ok:!1,error:`the download was removed while it was being saved`};let r=n.items.find(t=>t.id===e);if(r?.where||r?.error){await this.syncNative(n);let t=this.records[e];if(t?.savedTo)return{ok:!0,where:t.savedTo};if(t?.saveError)return{ok:!1,error:t.saveError}}if(Date.now()>=t)break;await new Promise(e=>setTimeout(e,300))}return this.patch(e,{saveHandedAt:Date.now()}),{ok:!1,error:`the phone has not said where it went yet — look in Downloads`}}catch(t){let n=t instanceof Error?t.message:String(t);return this.patch(e,{saveError:n}),{ok:!1,error:n}}}async function ece(e){let t=this.records[e];if(!t||t.state!==`done`||t.evicted||!$D())return;let n=await eO(t.item.name||t.item.relPath.split(`/`).pop()||t.item.relPath,t.item.size||void 0);if(n)return this.patch(e,{savedPresent:n.present,savedCheckedAt:Date.now(),...n.present&&n.where?{savedTo:n.where,savedAt:t.savedAt??Date.now(),saveVia:t.saveVia??`device`,saveError:void 0,saveHandedAt:void 0}:{}}),n.present}async function tce(){if($D())for(let e of this.list())e.state!==`done`||e.evicted||await this.verifySaved(e.item.id)}async function nce(e){let t=this.records[e];if(t?.nativePath){let e=kse(t.nativePath);if(e)return e}let n=await ky(`pulls`,e);return n?.blob?URL.createObjectURL(tO([n.blob],n.name)):null}function rce(){if(this.started)return;this.started=!0,zD(PD());let e=[];for(let t of this.list())t.state===`downloading`&&(t.engine===`native`&&ID()||(t.engine===`bgfetch`&&e.push(t.item.id),this.patch(t.item.id,{state:`queued`,rate:void 0})));addEventListener(`online`,()=>this.pump()),document.addEventListener(`visibilitychange`,()=>{document.hidden||this.pump()}),addEventListener(`pageshow`,()=>this.pump()),setInterval(()=>this.pump(),bse),Ose(e=>{this.syncNative({items:e,running:!0})}),this.syncNative(),this.recoverBackgroundFetches(e).then(()=>this.evictOld()),this.pump()}function ice(e=!1,t){if(this.syncNativeSoon(),this.watchdog(),this.active||!e&&KD(navigator.onLine,Md()))return;let n=PD(),r=Date.now(),i=t=>Nse(t,{auto:n,force:e,maxAttempts:50,now:r}),a=t?this.records[t]:void 0,o=i(a)?a:this.list().find(e=>i(e));o&&(this.active=o.item.id,this.run(o.item.id).finally(()=>{this.active=null,(PD()||this.list().some(e=>e.local&&e.state===`queued`))&&this.pump()}))}function ace(){for(let e of this.list())GD(e,{activeId:this.active,nativeSupported:ID()})&&this.patch(e.item.id,{state:`queued`,rate:void 0});let e=this.active;if(!e)return;let t=this.records[e];t&&t.state===`downloading`&&t.engine!==`bgfetch`&&t.engine!==`native`&&(Date.now()-(t.lastProgressAt??t.updatedAt)<6e4||(this.abort?.abort(),setTimeout(()=>this.pump(),250)))}async function oce(e){let t=this.records[e];if(!t)return;let n=t.received;if(this.patch(e,{state:`downloading`,error:void 0,nextRetryAt:void 0,lastProgressAt:Date.now()}),!await this.startBackgroundFetch(t)&&!await this.startNative(t))try{await this.rangeFetch(e)}catch(t){let r=t,i=r?.name===`AbortError`?`connection stalled`:String(r?.message||t),a=this.records[e];if(!a||a.state===`paused`)return;let o=a.received>n?0:(a.attempts??0)+1,s=!!r?.permanent||o>=50;this.patch(e,{state:s?`failed`:`queued`,attempts:o,error:i,rate:void 0}),s||this.scheduleRetry(e,o)}}function sce(e,t){this.retryTimer&&clearTimeout(this.retryTimer);let n=MD[Math.min(Math.max(1,t)-1,MD.length-1)];this.patch(e,{nextRetryAt:Date.now()+n}),this.retryTimer=setTimeout(()=>{this.retryTimer=null,this.pump()},n)}async function cce(e){if(!ID())return!1;try{let t=await LD({id:e.item.id,url:ND(e.item),name:e.item.name||e.item.relPath.split(`/`).pop()||e.item.relPath,size:e.item.size||void 0,etag:e.etag,autoSave:!!e.autoSave});return this.patch(e.item.id,{engine:`native`,nativeOwned:!0,lastProgressAt:Date.now()}),e.received>0&&!e.nativePath&&jy(`pulls`,e.item.id),t&&await this.syncNative(t),!0}catch(t){return this.patch(e.item.id,{error:t instanceof Error?t.message:String(t)}),!1}}async function lce(e){if(!ID())return;this.lastNativeSync=Date.now();let{items:t,running:n}=e??await BD();for(let e of t){let t=this.records[e.id]??this.adoptNative(e);if(!t){RD(e.id);continue}let r={engine:`native`,nativeOwned:!0,received:e.received,error:e.error||void 0,nextRetryAt:e.nextAt>Date.now()?e.nextAt:void 0};e.size>0&&!t.item.size&&(r.item={...t.item,size:e.size}),e.etag&&(r.etag=e.etag),e.received>t.received&&(r.lastProgressAt=Date.now()),e.state===`done`?(r.state=`done`,r.nativeOwned=!1,r.nativePath=e.path,r.evicted=!e.path,r.rate=void 0,r.nextRetryAt=void 0,r.error=void 0,e.error&&(r.saveError=e.error,r.saveHandedAt=void 0),e.pkg&&(r.pkg=e.pkg,r.pkgLabel=e.pkgLabel,r.pkgVersion=e.pkgVersion),r.install=e.install??``,r.installError=e.installError||void 0,r.installedAt=e.installedAt||void 0,r.installAuto=typeof e.installAuto==`boolean`?e.installAuto:void 0,r.installSnoozedUntil=e.installSnoozedUntil||void 0,r.cleanedAt=e.cleanedAt||void 0,r.cleanedBytes=e.cleanedAt&&e.cleanedBytes||void 0,r.cleanNote=e.cleanNote||void 0,e.cleanedAt&&!e.where&&t.savedTo&&t.saveVia===`device`&&(r.savedTo=void 0,r.savedPresent=void 0,r.savedCheckedAt=void 0),e.where&&(t.savedTo!==e.where&&(r.savedTo=e.where,r.savedAt=Date.now(),r.saveVia=`device`,r.savedPresent=!0,r.savedCheckedAt=Date.now()),r.saveError=void 0,r.saveHandedAt=void 0)):e.state===`failed`?(r.state=`failed`,r.nativeOwned=!1,r.attempts=e.attempts,r.rate=void 0):e.state===`paused`?(r.state=`paused`,r.nativeOwned=!1,r.rate=void 0):e.state===`downloading`?r.state=`downloading`:(t.state===`downloading`||t.state===`queued`)&&(r.state=`queued`,r.attempts=e.attempts,!n&&e.nextAt<=Date.now()&&(r.nativeOwned=!1)),this.patch(e.id,r)}let r=new Set(t.map(e=>e.id));for(let e of this.list())e.nativeOwned&&!r.has(e.item.id)&&this.patch(e.item.id,{nativeOwned:!1,state:e.state===`done`?`done`:`queued`,rate:void 0})}function uce(e){let t=e.origin===`link`?e.item:void 0;if(!t||t.id!==e.id||!t.repoId||!t.relPath||this.removed.has(t.id)||(this.dropSuperseded(t.supersedes??[]),this.shadowed(t)))return;let n={item:t,state:`queued`,received:e.received,attempts:e.attempts,updatedAt:Date.now(),engine:`native`,nativeOwned:!0};return this.records[t.id]=n,this.persist(),LD({id:t.id,url:e.url,name:e.name,size:e.size||void 0,etag:e.etag||void 0}).catch(()=>void 0),n}function dce(){ID()&&(Date.now()-this.lastNativeSync<2e3||this.syncNative())}async function fce(e){if(e.received>0||e.bgBlocked||yu()||ha())return!1;try{if(!(`serviceWorker`in navigator))return!1;let t=await navigator.serviceWorker.ready;if(!t?.backgroundFetch)return!1;let n=await t.backgroundFetch.fetch(e.item.id,[ND(e.item)],{title:e.item.name,downloadTotal:e.item.size,icons:[{src:`/assets/icon-192.png`,sizes:`192x192`,type:`image/png`}]});return this.patch(e.item.id,{engine:`bgfetch`}),this.watchBackgroundFetch(n),!0}catch{return!1}}function pce(e){if(!e)return;let t=e.id;e.addEventListener?.(`progress`,()=>{let n=Number(e.downloaded||0);e.result===`failure`?this.noteBgFailure(t,e.failureReason):this.patch(t,{state:e.result===`success`?`done`:`downloading`,received:n})})}async function mce(){let e=new Set;try{if(!(`serviceWorker`in navigator))return e;let t=await navigator.serviceWorker.ready;if(!t?.backgroundFetch)return e;let n=await t.backgroundFetch.getIds();for(let r of n){let n=await t.backgroundFetch.get(r);n&&(e.add(r),this.watchBackgroundFetch(n))}}catch{}return e}async function hce(e){let t=await this.adoptBackgroundFetches(),n=await this.drainBackgroundResults();await this.importAllCached();for(let r of e){if(t.has(r)||n.has(r))continue;let e=this.records[r];e&&e.state!==`done`&&e.state!==`paused`&&this.noteBgFailure(r,`the download ended while the app was closed`)}}async function gce(){let e=new Set;if(typeof caches>`u`)return e;try{let t=await kD();for(let n of await t.keys()){let r=new URL(n.url).pathname;if(!r.startsWith(`/__pull-result/`))continue;let i=null;try{i=await(await t.match(n))?.json()}catch{}await t.delete(n);let a=String(i?.id||decodeURIComponent(r.slice(15)));a&&this.records[a]&&(e.add(a),this.noteBackgroundResult(a,!!i?.ok,Number(i?.received||0),i?.reason||void 0))}}catch{}return e}async function _ce(e){if(typeof caches<`u`)try{await(await kD()).delete(vse+encodeURIComponent(e))}catch{}}function vce(e,t){let n=this.records[e];if(!n||n.state===`paused`)return;let r=(n.attempts??0)+1,i=r>=50;this.patch(e,{state:i?`failed`:`queued`,attempts:r,error:t||`background fetch failed`,engine:void 0,bgBlocked:!0,rate:void 0}),i||this.scheduleRetry(e,r),this.pump()}function yce(e,t,n,r){this.records[e]&&(this.dropBackgroundResult(e),t?(this.patch(e,{received:n}),this.importFromCache(e).finally(()=>this.pump())):this.noteBgFailure(e,r))}async function bce(e){let t=this.records[e];if(t)try{let n=await kD(),r=ND(t.item),i=await n.match(r);if(!i)return;let a=await i.blob();await this.store(e,a,a.size,t.item.size||a.size,t.item.name),await n.delete(r),this.patch(e,{state:`done`,received:a.size,error:void 0,engine:`bgfetch`})}catch(t){this.patch(e,{state:`queued`,error:String(t?.message||t)})}}async function xce(){if(typeof caches<`u`)for(let e of this.list())e.state!==`done`&&e.state!==`paused`&&await this.importFromCache(e.item.id)}async function Sce(e){let t=this.records[e];if(!t)return;let n=await ky(`pulls`,e),r=n?.blob??new Blob([]),i=n?Math.min(n.received,n.blob?.size??0):0;i!==r.size&&(r=new Blob([]),i=0);let a=new AbortController;this.abort=a;let o=setTimeout(()=>a.abort(),yse),s=e=>{clearTimeout(o),o=setTimeout(()=>a.abort(),e)};try{let n={};i>0&&(n.Range=`bytes=${i}-`),i>0&&t.etag&&(n[`if-range`]=t.etag);let o=await fetch(ND(t.item),{headers:n,signal:a.signal,cache:`no-store`});if(s(jD),o.status===416)throw await jy(`pulls`,e),this.patch(e,{received:0,etag:void 0}),Error(`stored part no longer matches — starting over`);if(!o.ok&&o.status!==206){let e=Error(o.status===403?`http 403 — the host refused this request (origin not allowed)`:`http ${o.status}`);throw e.permanent=o.status===403||o.status===404||o.status===410,e}let c=o.headers.get(`etag`)||void 0;o.status===200&&i>0&&(r=new Blob([]),i=0);let l=o.status===206?Number((o.headers.get(`content-range`)||``).split(`/`)[1]||0)||t.item.size:Number(o.headers.get(`content-length`)||0)||t.item.size;if(!o.body){let n=await o.blob(),a=tO(i>0?[r,n]:[n],t.item.name);await this.store(e,a,a.size,l,t.item.name),this.patch(e,{state:`done`,received:a.size,etag:c,rate:void 0});return}let u=o.body.getReader(),d=[],f=0,p=Date.now();this.patch(e,{engine:`range`,etag:c,received:i,lastProgressAt:Date.now()});let m=async()=>{if(!f)return;let n=Date.now(),a=f;r=tO([r,...d],t.item.name),d=[],f=0,i=r.size,await this.store(e,r,i,l,t.item.name);let o=Math.max(1,n-p)/1e3;p=n;let s=a/o,c=this.records[e]?.rate;this.patch(e,{received:i,rate:c?c*.7+s*.3:s,lastProgressAt:n,wireBytes:(this.records[e]?.wireBytes??0)+a})};try{for(;;){let{done:e,value:t}=await u.read();if(e)break;s(jD),d.push(t),f+=t.byteLength,(f>=1048576||Date.now()-p>=1500)&&await m()}}catch(e){throw await m().catch(()=>void 0),e}if(await m(),l>0&&i<l)throw Error(`incomplete (${i}/${l})`);this.patch(e,{state:`done`,received:i,error:void 0,rate:void 0,nextRetryAt:void 0})}finally{clearTimeout(o)}}async function Cce(e,t,n,r,i){this.records[e]&&await Ay(`pulls`,e,{id:e,blob:t,received:n,total:r,name:i})}async function wce(){let e=Date.now()-xse;for(let t of this.list())t.state===`done`&&!t.evicted&&t.updatedAt<e&&t.received>0&&await this.dropOne(t)}async function Tce(e){await jy(`pulls`,e.item.id),e.nativePath&&await RD(e.item.id),this.patch(e.item.id,{received:0,evicted:!0,nativePath:void 0})}async function Ece(e){let t=0,n=0;for(let r of e){let e=this.records[r];if(!e||e.state!==`done`||e.evicted)continue;let i=e.received||e.item.size||0;await this.dropOne(e),t++,n+=i}return{count:t,bytes:n}}function nO(e){ua(AD,e?`1`:`0`),zD(e),e&&rO.pump(),rO.emit()}var rO=new class{records=wse();listeners=new Set;active=null;abort=null;retryTimer=null;started=!1;lastNativeSync=0;removed=new Set;subscribe(e){return this.listeners.add(e),e(this.list()),()=>{this.listeners.delete(e)}}emit(){let e=this.list();for(let t of this.listeners)t(e)}list(){return Object.values(this.records).sort((e,t)=>t.item.ts-e.item.ts)}get(e){return this.records[e]}persist=Fse;patch=Ise;sync=Lse;add=Rse;addLocal=zse;findFor=Bse;shadowed=Vse;dropSuperseded=Hse;retry=Use;remove=Wse;pause=Gse;resumeAll=Kse;whyIdle=qse;save=Qse;saveNative=$se;verifySaved=ece;verifyAllSaved=tce;objectUrl=nce;start=rce;pump=ice;watchdog=ace;run=oce;scheduleRetry=sce;startNative=cce;syncNative=lce;adoptNative=uce;syncNativeSoon=dce;startBackgroundFetch=fce;watchBackgroundFetch=pce;adoptBackgroundFetches=mce;recoverBackgroundFetches=hce;drainBackgroundResults=gce;dropBackgroundResult=_ce;noteBgFailure=vce;noteBackgroundResult=yce;importFromCache=bce;importAllCached=xce;rangeFetch=Sce;store=Cce;evictOld=wce;dropOne=Tce;dropBytes=Ece};function Dce(e){return!e||e.type!==`pull-result`?!1:(rO.noteBackgroundResult(String(e.id),!!e.ok,Number(e.received||0),e.reason),!0)}var iO=R.artMarks,aO=3e3,oO=null;function sO(){if(oO)return oO;try{let e=z(iO),t=e?JSON.parse(e):null;oO=t&&typeof t==`object`&&t.m&&typeof t.m==`object`?t.m:{}}catch{oO={}}return oO}function Oce(e){let t=Object.keys(e);if(t.length>aO){let n=e=>Math.max(e.d??0,e.o??0);t.sort((t,r)=>n(e[t])-n(e[r]));for(let n of t.slice(0,t.length-aO))delete e[n]}Ta(iO,{v:1,m:e})}var cO=(e,t)=>`${e}:${t}`;function lO(e,t,n){let r=sO()[cO(e,t)];return!r||r.t!==n?`new`:r.d?`downloaded`:r.o?`opened`:`new`}function uO(e,t,n,r){let i=sO(),a=cO(e,t),o=i[a],s=o&&o.t===n?o:{t:n};s[r]=Date.now(),i[a]=s,Oce(i)}function kce(e,t,n){uO(e,t,n,`o`)}function Ace(e,t,n){uO(e,t,n,`d`)}function jce(){return QD()&&z(R.pullAutoSave)!==`0`}function Mce(){return z(R.pullAutoSave)!==`0`}function Nce(e){if(ua(R.pullAutoSave,e?`1`:`0`),e)for(let e of rO.list())UD(e,!0)&&hO(e.item.id,{silent:!0})}var dO=`app:open-downloads`,fO=null;function Pce(e){fO=e}var pO=new Set;function Fce(){dispatchEvent(new CustomEvent(dO))}function mO(e,t={}){let n=e.name||e.relPath.split(`/`).pop()||e.relPath,r=e.repoName&&e.repoDir?void 0:fO?.(e.repoId),i=rO.findFor(e.repoId,e.relPath,e.mtime),a=rO.addLocal({...e,name:n,repoName:e.repoName||r?.repoName,repoDir:e.repoDir||r?.repoDir},{autoSave:!0});if(t.silent)return a;let o=rO.get(a);return o?.state===`done`&&!o.evicted?(hO(a),a):(K(i&&i.received>0?`resuming ${n} — see Downloads`:`downloading ${n} — it saves itself when it lands`),a)}async function hO(e,t={}){let n=rO.get(e)?.item.name??`the file`;if(pO.has(e))t.silent||K(`saving ${n}…`);else{pO.add(e);try{let t=await rO.save(e),r=rO.get(e)?.saveVia;K(t.ok?t.already?`already in ${t.where}`:r===`browser`?`handed to ${t.where} — ${n}`:`saved to ${t.where}`:`could not save ${n} — ${t.error}. It is still on this phone; open Downloads to try again`)}finally{pO.delete(e)}}}function Ice(e,t){switch(HD(t)){case`save`:hO(t.item.id);return;case`open`:Fce();return;default:mO(e)}}function Lce(){return rO.subscribe(e=>{for(let t of e)t.state===`done`&&!t.evicted&&t.item.mtime&&lO(t.item.repoId,t.item.relPath,t.item.mtime)!==`downloaded`&&Ace(t.item.repoId,t.item.relPath,t.item.mtime),UD(t,jce())&&hO(t.item.id,{silent:!0})})}function Rce(e){let[t,n]=(0,V.useState)(),{repoId:r,relPath:i,mtime:a}=e??{repoId:``,relPath:``,mtime:void 0};return(0,V.useEffect)(()=>{if(!r||!i)n(void 0);else return rO.subscribe(()=>n(rO.findFor(r,i,a)))},[r,i,a]),t}function gO({target:e,rec:t,onStart:n,compact:r,className:i,trackId:a}){let o=Rce(t===void 0?e:null),s=t??o,c=VD(s),l=c.phase===`downloading`?(0,J.jsx)(Js,{size:16,className:`spin`}):c.phase===`queued`?(0,J.jsx)(Qo,{size:16}):c.phase===`have`||c.phase===`saved`?(0,J.jsx)(Ra,{size:16}):(0,J.jsx)(Qa,{size:16});return(0,J.jsxs)(Y,{className:`${c.phase===`have`||c.phase===`saved`?`ok`:``} ${i??``}`,title:c.detail,"data-hint":`gallery.pull`,onClick:()=>{a&&q(a),(c.phase===`idle`||c.phase===`failed`)&&n?.(),Ice(e,s)},children:[l,r?null:(0,J.jsxs)(J.Fragment,{children:[` `,c.label]})]})}function _O(e,t){return t===`all`?[...e]:e.filter(e=>e.status===t)}function vO(e,t){let n=_O(e,t);return t===`all`?n.slice(0,8):n}function zce(e,t){return _O(e,t).length-vO(e,t).length}function yO(e){return!!e&&e.status===`running`&&e.watch===!0}var bO=[`failed`,`running`,`done`],xO={running:{chip:`still running`,bar:`still running`},done:{chip:`finished`,bar:`that finished`},failed:{chip:`failed`,bar:`that failed`},cancelled:{chip:`cancelled`,bar:`that were cancelled`}},Bce={anchor:{word:`verified`,tag:`idle`,title:`an oracle was asked and the expected text was on the screen`},stable:{word:`settled`,tag:`coding`,title:`consecutive frames agreed, so nothing was mid-load or mid-animation — a claim about the screen having stopped, not about it being right`},unverified:{word:`unverified`,tag:`dead`,title:`one frame, nothing to compare it against, nobody asked`}};function Vce({repo:e,targets:t,runs:n,backends:r,output:i,outTick:a,onSave:o,onRun:s,onCancel:c,onDownload:l,onClose:u,online:d=!0,listAt:f=0}){let[p,m]=(0,V.useState)(null),[h,g]=(0,V.useState)(`all`),_=_O(n,h),v=vO(n,h),y=zce(n,h),[b,x]=(0,V.useState)(null),S=_.find(e=>e.runId===b)??_[0]??null,C=(0,V.useRef)(null);(0,V.useEffect)(()=>{let e=C.current;e&&(e.scrollTop=e.scrollHeight)},[a,S?.runId]);function w(e){return r.find(t=>t.id===e)}function T(e){o(t.filter(t=>t.id!==e))}function E(e){let n=e.name.trim();if(!n){m(null);return}let r={...e,name:n,dir:e.dir?.trim()||void 0};o(t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?r:t):[...t,r]),m(null)}return Gh(p!==null,()=>m(null)),p?(0,J.jsx)(Kce,{draft:p,backends:r,onCancel:()=>m(null),onSave:E}):(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsxs)(Uw,{title:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(tl,{size:16}),` Capture · `,e.repoName]}),onClose:u,children:[Ci(e)&&(0,J.jsx)(Q,{className:`head-branch`,children:Ci(e)}),d&&(0,J.jsxs)(Y,{title:`add a capture target`,onClick:()=>m({id:Mp(`t`),name:``,backend:`web`}),children:[(0,J.jsx)(Fo,{size:16}),` new`]})]}),(0,J.jsxs)(Z,{children:[`Photograph a running screen and say how much the picture can be trusted — no session, no tokens. The frames and an evidence sidecar land in `,(0,J.jsx)(`span`,{className:`mono`,children:`.claude/outbox/`}),`, so the gallery lists them and an agent can read the verdict instead of the image.`,!d&&` No connection right now: a tap is queued and the capture runs once the link is back.`]}),(0,J.jsxs)(Z,{children:[(0,J.jsx)(La,{size:12,style:{verticalAlign:`-1px`}}),` takes one frame now.`,` `,(0,J.jsx)(hl,{size:12,style:{verticalAlign:`-2px`}}),` `,(0,J.jsx)(`strong`,{children:`watch`}),` keeps the screen open and keeps a frame each time it changes past the target’s threshold — until you stop it, or it hits its own ceiling. That is what makes this a loop rather than a snapshot: leave it watching while you change the code and the outbox fills with the moments that actually moved.`]}),!d&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(Z,{children:[(0,J.jsx)(fo,{size:13,style:{verticalAlign:`-2px`}}),` `,t.length===0?`this device has no copy of this repo's targets`:f?`these targets are this device's copy, last confirmed ${Tp(f)} ago`:`these targets are this device's copy`,` — running one does not need the link.`]}),(0,J.jsx)(Qw,{cants:[{label:`adding, editing or deleting a target`,reason:`capture targets live in a file on the desktop and there is no honest way to hold an edit — the change would be composed now against a file that has moved on`}]})]}),(0,J.jsxs)(`div`,{className:`build-body`,children:[(0,J.jsxs)(`div`,{className:`list build-cmds`,children:[t.map(e=>{let t=n.find(t=>t.targetId===e.id&&t.status===`running`),r=yO(t),i=w(e.backend),a=i&&!i.available,o=i?.reason,l=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(Zw,{children:[e.name,t?(0,J.jsxs)(J.Fragment,{children:[` `,(0,J.jsx)($s,{size:12,className:`spin`})]}):null,r?(0,J.jsxs)(J.Fragment,{children:[` `,(0,J.jsxs)(qw,{tone:`coding`,children:[(0,J.jsx)(hl,{size:11}),` watching`]})]}):null]}),(0,J.jsxs)(Q,{className:`mono`,children:[e.backend,e.dir?` · ${e.dir}`:``,SO(e)?` · ${SO(e)}`:``]})]});return(0,J.jsxs)(V.Fragment,{children:[(0,J.jsxs)(Xw,{kind:`wrap`,children:[a?(0,J.jsx)(Xw,{kind:`grow`,title:e.id,children:l}):(0,J.jsx)(Xw,{as:`button`,kind:`grow`,title:e.id,onClick:()=>{t?(g(`all`),x(t.runId)):(q(`action:capture.run`),s(e.id))},children:l}),t?(0,J.jsx)(Y,{variant:`danger`,title:r?`stop watching — the frames kept so far stay`:`stop this capture`,onClick:()=>c(t.runId),children:(0,J.jsx)(ic,{size:16})}):a?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Y,{title:`take one frame now`,onClick:()=>{q(`action:capture.run`),s(e.id)},children:(0,J.jsx)(La,{size:16})}),(0,J.jsx)(Y,{title:`watch this screen — keep capturing until stopped`,onClick:()=>{q(`action:capture.watch`),s(e.id,!0)},children:(0,J.jsx)(hl,{size:16})})]}),d&&(0,J.jsx)(Y,{title:`edit`,onClick:()=>m(e),children:(0,J.jsx)(Mo,{size:16})}),d&&(0,J.jsx)(Y,{variant:`danger`,title:`delete`,onClick:()=>T(e.id),children:(0,J.jsx)(ws,{size:16})})]}),a&&(0,J.jsx)(Qw,{cants:[{label:`“${e.name}”`,reason:o??`this desktop cannot drive the ${e.backend} backend, and did not say why`}]})]},e.id)}),t.length===0&&(d?(0,J.jsxs)($,{children:[`No capture targets yet. Tap “new” — e.g. name “droplet · home”, backend `,(0,J.jsx)(`span`,{className:`mono`,children:`web`}),`, url `,(0,J.jsx)(`span`,{className:`mono`,children:`http://localhost:5173/`}),`, and an anchor word you expect to be on that screen. The anchor is what lets a capture claim it was `,(0,J.jsx)(`em`,{children:`verified`}),` rather than merely taken.`]}):(0,J.jsx)($,{children:`No connection, and this device has no copy of this repo’s capture targets — it has not had them since it was last on the link. This says nothing about whether the repo has any. Open this sheet once with the link up and they are cached here from then on.`}))]}),n.length>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`section`,children:[`Runs`,bO.map(e=>{let t=_O(n,e).length;return t?(0,J.jsxs)(`button`,{className:`tag tag-filter ${h===e?`on`:``} ${e===`failed`?`dead`:e===`running`?`coding`:`idle`}`,title:`show only the ${t} ${xO[e].chip}`,onClick:()=>{q(`action:capture.filter`),g(h===e?`all`:e),x(null)},children:[t,` `,xO[e].chip]},e):null})]}),h!==`all`&&(0,J.jsxs)(`div`,{className:`section filter-bar`,children:[(0,J.jsxs)(`span`,{className:`filter-bar-txt`,children:[`Only the runs `,xO[h].bar,` · `,_.length,` of `,n.length,_.length===0&&` — nothing here is in that cut`]}),(0,J.jsxs)(`button`,{className:`filter-bar-clear`,title:`clear the filter — show every run for this repo again`,onClick:()=>{q(`action:capture.filter.clear`),g(`all`),x(null)},children:[(0,J.jsx)(B,{size:13}),` clear`]})]}),(0,J.jsx)(`div`,{className:`list build-runs`,children:v.map(e=>{let t=e.verification?Bce[e.verification]:null;return(0,J.jsxs)(`button`,{className:`row ${S?.runId===e.runId?`active`:``}`,onClick:()=>x(e.runId),children:[(0,J.jsxs)(Zw,{children:[e.status===`running`?(0,J.jsx)($s,{size:12,className:`spin`}):null,` `,e.name,` `,(0,J.jsxs)(qw,{className:e.status===`done`?`idle`:e.status===`running`?`coding`:`dead`,children:[e.status,e.exitCode?` ${e.exitCode}`:``]}),yO(e)?(0,J.jsxs)(J.Fragment,{children:[` `,(0,J.jsxs)(qw,{tone:`coding`,children:[(0,J.jsx)(hl,{size:11}),` watching`]})]}):null,t?(0,J.jsxs)(J.Fragment,{children:[` `,(0,J.jsxs)(qw,{className:t.tag,title:t.title,children:[(0,J.jsx)(ss,{size:11}),` `,t.word]})]}):null]}),e.verdict?(0,J.jsx)(Q,{children:e.verdict}):null,(0,J.jsxs)(Q,{children:[Vp(e.finishedAt??e.startedAt),` · `,Ap(e.startedAt,e.finishedAt),` · `,e.backend??`backend not recorded`,e.files?.length?` · ${e.files.length} file${e.files.length>1?`s`:``}`:``]})]},e.runId)})}),y>0&&(0,J.jsxs)(Z,{children:[`Showing the newest `,v.length,` of `,n.length,` runs for this repo.`,bO.some(e=>_O(n,e).length>0)&&` The counts above are over all ${n.length}; tap one to open exactly those.`]})]}),S&&(0,J.jsxs)(`div`,{className:`build-run`,children:[(0,J.jsxs)(Z,{children:[S.status===`running`?yO(S)?`watching — a frame is kept each time the screen changes${S.files?.length?`, ${S.files.length} so far`:``}. Stop it from the target above; the frames already written stay.`:`still going — no reading yet`:(0,J.jsxs)(J.Fragment,{children:[`score `,typeof S.score==`number`?S.score:(0,J.jsx)(`span`,{title:`no scorer on this desktop, so nobody looked — this is not a low score`,children:`n/a`})]}),S.sidecarRelPath?(0,J.jsxs)(J.Fragment,{children:[` · `,(0,J.jsx)(Fs,{size:12,style:{verticalAlign:`-2px`}}),` `,(0,J.jsx)(`span`,{className:`mono`,children:S.sidecarRelPath})]}):null]}),S.files&&S.files.length>0&&(0,J.jsx)(`div`,{className:`list`,children:S.files.map(t=>(0,J.jsx)(Hce,{a:t,repoDir:e.worktreePath,repoName:e.repoName,onDownload:l},t.relPath))}),S.status===`running`&&(0,J.jsx)(Z,{children:yO(S)?`This run is still keeping frames. What is listed here is what the desktop has reported so far — more arrive while it watches, and the verdict is written when it stops.`:`Frames are listed as the desktop reports them; this list is not final until the run finishes.`}),S.status===`done`&&!S.files?.length&&(0,J.jsx)($,{children:`This run finished and wrote no frame — there is nothing to look at.`}),S.status===`failed`&&!S.files?.length&&(0,J.jsx)($,{children:`This run failed before it took a frame. The log below is what it managed to say.`}),(0,J.jsx)(`pre`,{className:`build-log`,ref:C,children:Pp(i.get(S.runId)??``)||`(no output yet)`})]})]})]})}function SO(e){switch(e.backend){case`web`:return e.url??``;case`android`:return e.serial??``;case`garmin`:return[e.screen,e.device].filter(Boolean).join(` · `);case`window`:return e.windowTitle??``}}function Hce({a:e,repoDir:t,repoName:n,onDownload:r}){return(0,J.jsxs)(Xw,{kind:`wrap`,children:[(0,J.jsxs)(Xw,{as:`button`,kind:`grow`,title:e.relPath,onClick:()=>{q(`action:capture.artifact`),r(e)},children:[(0,J.jsxs)(Zw,{children:[(0,J.jsx)(Qa,{size:14}),` `,e.name]}),(0,J.jsx)(Q,{className:`mono`,children:e.relPath}),(0,J.jsxs)(Q,{children:[yp(e.size),e.mtime?` · ${Vp(e.mtime)}`:``]})]}),(0,J.jsx)(gO,{compact:!0,trackId:`action:capture.artifact`,target:{repoId:e.repoId,relPath:e.relPath,name:e.name,size:e.size,mtime:e.mtime,repoDir:t,repoName:n}})]})}function Uce(e){let t=[];for(let n of e.split(/[,\n]/)){let e=/^\s*(\d+)\s*[x×]\s*(\d+)\s*$/.exec(n);if(!e)continue;let r=Number(e[1]),i=Number(e[2]);r>0&&i>0&&t.push({w:r,h:i})}return t}var Wce=e=>(e??[]).map(e=>`${e.w}x${e.h}`).join(`, `);function Gce(e){let t=e.trim();if(!t)return;let n=Number(t.replace(/%$/,``));return Number.isFinite(n)&&n>=0&&n<=100?n:void 0}function Kce({draft:e,backends:t,onCancel:n,onSave:r}){let[i,a]=(0,V.useState)(e.name),[o,s]=(0,V.useState)(e.backend),[c,l]=(0,V.useState)(e.dir??``),[u,d]=(0,V.useState)((e.anchor??[]).join(`, `)),[f,p]=(0,V.useState)(typeof e.diffPct==`number`?String(e.diffPct):``),[m,h]=(0,V.useState)(e.url??``),[g,_]=(0,V.useState)(Wce(e.viewports)),[v,y]=(0,V.useState)(e.theme??``),[b,x]=(0,V.useState)(e.serial??``),[S,C]=(0,V.useState)(e.screen??``),[w,T]=(0,V.useState)(e.device??``),[E,D]=(0,V.useState)(e.windowTitle??``),O=t.find(e=>e.id===o);function k(){let t=u.split(/[,\n]/).map(e=>e.trim()).filter(Boolean),n=Uce(g);q(`action:capture.save`),r({id:e.id,name:i,backend:o,dir:c.trim()||void 0,anchor:t.length?t:void 0,settleMs:e.settleMs,diffPct:Gce(f),url:o===`web`&&m.trim()||void 0,viewports:o===`web`&&n.length?n:void 0,theme:o===`web`&&v?v:void 0,serial:o===`android`&&b.trim()||void 0,screen:o===`garmin`&&S.trim()||void 0,device:o===`garmin`&&w.trim()||void 0,windowTitle:o===`window`&&E.trim()||void 0})}return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:(0,J.jsx)(J.Fragment,{children:e.name?`Edit capture target`:`New capture target`}),onClose:n}),(0,J.jsx)(`div`,{className:`build-body`,children:(0,J.jsxs)(`div`,{className:`form`,children:[(0,J.jsx)(`input`,{className:`search`,placeholder:`Name (e.g. droplet · home)`,value:i,onChange:e=>a(e.target.value),autoFocus:!0}),(0,J.jsx)(yS,{label:`capture backend`,options:kte.map(e=>({key:e,label:e})),value:o,onChange:s}),O?.reason&&(O.available?(0,J.jsx)(Z,{children:O.reason}):(0,J.jsx)(Qw,{cants:[{label:`${o} captures on this desktop`,reason:O.reason}]})),O===void 0&&(0,J.jsxs)(Z,{children:[(0,J.jsx)(fo,{size:13,style:{verticalAlign:`-2px`}}),` This desktop has not said whether it can drive `,(0,J.jsx)(`span`,{className:`mono`,children:o}),`. The target saves either way; a run that cannot happen refuses in words.`]}),(0,J.jsx)(`input`,{className:`search`,placeholder:`Working sub-dir (optional, relative to repo root)`,value:c,onChange:e=>l(e.target.value),style:{fontFamily:`monospace`}}),(0,J.jsx)(`input`,{className:`search`,placeholder:`Anchor text, comma-separated (e.g. TOTAL, Settings)`,value:u,onChange:e=>d(e.target.value)}),(0,J.jsxs)(Z,{children:[`Anchors are what make a capture claim `,(0,J.jsx)(`em`,{children:`verified`}),` instead of merely taken: the backend goes and asks the running thing what text is on its screen. A backend with no oracle — a window grab, a simulator nobody can query — can never answer an anchor however many you set, and says `,(0,J.jsx)(`em`,{children:`settled`}),` at best.`]}),(0,J.jsx)(`input`,{className:`search`,inputMode:`decimal`,placeholder:`Watch: keep a frame past this % changed (blank = the desktop's default)`,value:f,onChange:e=>p(e.target.value)}),(0,J.jsx)(Z,{children:`Only watch runs read this. With no pixel tool on the desktop nothing can be measured, so the gate opens and every frame is kept — the run's output says that is what happened rather than quietly keeping none.`}),o===`web`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`input`,{className:`search`,placeholder:`URL (required — e.g. http://localhost:5173/)`,value:m,onChange:e=>h(e.target.value),style:{fontFamily:`monospace`}}),(0,J.jsx)(`input`,{className:`search`,placeholder:`Viewports, e.g. ${ar.w}x${ar.h}, 1280x800`,value:g,onChange:e=>_(e.target.value),style:{fontFamily:`monospace`}}),(0,J.jsx)(yS,{label:`emulated colour scheme`,options:[``,`light`,`dark`,`both`].map(e=>({key:e||`default`,label:e||`default theme`})),value:v||`default`,onChange:e=>y(e==="default"?``:e)}),(0,J.jsxs)(Z,{children:[`Capture never starts a dev server. A URL that does not answer is refused in words, and the Build sheet is where you start one. Empty viewports means one frame at `,(0,J.jsxs)(`span`,{className:`mono`,children:[ar.w,`×`,ar.h]}),`.`]})]}),o===`android`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`input`,{className:`search`,placeholder:`Device serial (optional)`,value:b,onChange:e=>x(e.target.value),style:{fontFamily:`monospace`}}),(0,J.jsx)(Z,{children:`Empty means the only connected device. With more than one connected and no serial the run refuses rather than guessing which phone you meant.`})]}),o===`garmin`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`input`,{className:`search`,placeholder:`Screen name (ciqkit sim shot <screen>)`,value:S,onChange:e=>C(e.target.value),style:{fontFamily:`monospace`}}),(0,J.jsx)(`input`,{className:`search`,placeholder:`Device (e.g. venu3)`,value:w,onChange:e=>T(e.target.value),style:{fontFamily:`monospace`}})]}),o===`window`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`input`,{className:`search`,placeholder:`Window title (optional)`,value:E,onChange:e=>D(e.target.value)}),(0,J.jsx)(Z,{children:`Resolved best-effort. A title that matches nothing falls back to the whole desktop, and the run’s evidence file records that it did — the picture is never passed off as that window.`})]})]})}),(0,J.jsxs)(`div`,{className:`sheet-actions`,children:[(0,J.jsxs)(Y,{onClick:n,children:[(0,J.jsx)(B,{size:16}),` cancel`]}),(0,J.jsx)(`span`,{className:`spacer`}),i.trim()?(0,J.jsx)(`button`,{className:`send`,onClick:k,children:`Save`}):(0,J.jsx)(Qw,{cants:[{label:`save`,reason:`a target needs a name — it is the label on the button you will tap`}]})]})]})}var CO=$v({load:wT,save:TT}),wO=W(null),TO=W(new Map),qce=e=>`capture:${e}`,Jce=(e,t)=>t?`watch “${e}”`:`capture “${e}”`;function Yce(e,t,n){return e?t?`queued — the watch starts when the link is back`:`queued — the capture runs when the link is back`:t?`watching “${n}” — a frame is kept each time the screen changes`:`capturing “${n}”…`}function Xce(e){return e.status===`done`?e.verdict?`“${e.name}” — ${e.verdict}`:`capture “${e.name}” done`:e.status===`failed`?e.verdict?`“${e.name}” failed — ${e.verdict}`:`capture “${e.name}” failed`:null}function Zce(e,t,n){return(e.get(t)??[]).find(e=>e.id===n)?.name??n}function Qce(e,t,n,r){CO.onList(e,t,n),TO.set(t=>kh(t,e,r))}function $ce(e,t){CO.onRun(e);let n=Xce(e);n&&t.say.toast(n)}function ele(e){let t=U();wO.set(e),t.conn.send({t:`capture.list`,repoDir:e.worktreePath}),t.nav.open(`capture`)}function tle(){let e=wO.get();e&&U().conn.send({t:`capture.list`,repoDir:e.worktreePath})}function nle(e,t){U().conn.liveSend({t:`capture.save`,repoDir:e,targets:t},`capture targets saved`,`no connection — capture targets live on the desktop and can't be edited from here`)}function rle(e,t,n){let r=U(),i=Zce(CO.cfgs.get().lists,e,t),a=r.queue.queueOp({t:`capture.run`,repoDir:e,targetId:t,watch:n?!0:void 0},qce(e),Jce(i,!!n),{cwd:e});r.say.toast(Yce(a,!!n,i))}function ile(e){U().conn.liveSend({t:`capture.cancel`,runId:e},`stopping the capture…`,`no connection — the capture is running on the desktop and can't be stopped from here`)}function ale({repo:e}){let t=Dh(),n=e.worktreePath,r=G(CO.cfgs),i=G(CO.runs),a=G(CO.outTick),o=G(TO).get(n),s=(0,V.useMemo)(()=>i.filter(e=>e.repoDir===n),[i,n]);return(0,J.jsx)(Vce,{repo:e,targets:r.lists.get(n)??[],listAt:r.at.get(n)??0,runs:s,backends:o??[],output:CO.output,outTick:a,online:t.conn.status===`open`,onSave:e=>nle(n,e),onRun:(e,t)=>rle(n,e,t),onCancel:ile,onDownload:e=>t.files.downloadArtifact(e),onClose:()=>t.nav.close(`capture`)})}var ole={id:`capture`,sheets:[{id:`capture`,persisted:!1,render:()=>{let e=wO.get();return e?(0,V.createElement)(ale,{repo:e}):null}}],messages:{welcome:()=>tle(),"capture.list":e=>Qce(e.repoDir,e.targets,e.runs,e.backends),"capture.run":(e,t)=>$ce(e.run,t),"capture.output":(e,t)=>CO.onOutput(e.runId,Ip(e.dataB64),!!e.full,t.nav.overlay===`capture`)}},EO={synced:Bc,pending:rs,offline:fo,superseded:Ds,failed:fs};function DO({keys:e,thing:t=`these`}){let[,n]=(0,V.useState)(0);(0,V.useEffect)(()=>Qu(()=>n(e=>e+1)),[]);let r=sre(e),i=id(r,t);if(!i)return null;let a=EO[r.phase];return(0,J.jsxs)(`div`,{className:`sync-mark sync-${r.phase}`,children:[(0,J.jsx)(a,{size:12}),(0,J.jsx)(`span`,{children:i})]})}function OO({phase:e,thing:t=`it`,plural:n=!1,saidAbove:r=!1}){let i=sd(e,r);if(!i)return null;let a=EO[e];return(0,J.jsxs)(qw,{className:`sync-chip sync-${e}`,title:id({phase:e,wroteAt:null,ackedAt:null},t,n)??void 0,children:[(0,J.jsx)(a,{size:12}),` `,i]})}function sle({phases:e}){let t=cre(e);return t?(0,J.jsxs)(qw,{className:`sync-chip sync-synced`,title:t.title,children:[(0,J.jsx)(Bc,{size:12}),` `,t.word]}):null}function kO(e){let t=e.split(`
6
+ `).map(e=>e.trim()).find(Boolean)??``;return t.length>40?t.slice(0,40)+`…`:t||`untitled`}function AO({snippets:e,onSave:t,onClose:n,heading:r=`Snippets`,hint:i,emptyText:a=`No snippets yet. Tap “new” to add one.`,textPlaceholder:o=`Snippet text…`,onReset:s,trackId:c=`action:snippet.save`}){let[l,u]=(0,V.useState)(null),[d,f]=(0,V.useState)(null);function p(n,r){let i=e.findIndex(e=>e.id===n),a=i+r;if(i===-1||a<0||a>=e.length)return;let o=[...e];[o[i],o[a]]=[o[a],o[i]],t(o)}function m(n){t(e.filter(e=>e.id!==n))}function h(n){let r=n.text.trim();if(!r){u(null);return}let i=n.title.trim()||kO(r),a={...n,title:i,text:r};t(e.some(e=>e.id===n.id)?e.map(e=>e.id===n.id?a:e):[...e,a]),u(null)}function g(n){if(!d)return;let r=(document.elementFromPoint(n.clientX,n.clientY)?.closest(`[data-snid]`))?.getAttribute(`data-snid`);if(!r||r===d)return;let i=e.findIndex(e=>e.id===d),a=e.findIndex(e=>e.id===r);if(i===-1||a===-1)return;let o=[...e],[s]=o.splice(i,1);o.splice(a,0,s),t(o)}return Gh(l!==null,()=>u(null)),l?(0,J.jsx)(cle,{draft:l,textPlaceholder:o,trackId:c,onCancel:()=>u(null),onSave:h}):(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsxs)(Uw,{title:(0,J.jsx)(J.Fragment,{children:r}),onClose:n,children:[s&&(0,J.jsxs)(fC,{className:`key`,title:`restore the shipped list`,confirmTitle:`tap again to throw away every edit and restore the shipped list`,confirm:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(tc,{size:16}),` sure?`]}),onConfirm:s,children:[(0,J.jsx)(tc,{size:16}),` defaults`]}),(0,J.jsxs)(Y,{onClick:()=>u({id:Mp(`sn`),title:``,text:``}),children:[(0,J.jsx)(Fo,{size:16}),` new`]})]}),(0,J.jsx)(DO,{keys:[R.snippets,R.headerCmds],thing:`these templates`}),(0,J.jsxs)(Z,{children:[i??(0,J.jsxs)(J.Fragment,{children:[`Tap the `,(0,J.jsx)(Ka,{size:12}),` button by the compose box to pick a snippet and append it.`]}),` `,`Drag the `,(0,J.jsx)(Zo,{size:12}),` handle (or the arrows) to reorder.`]}),(0,J.jsxs)(`div`,{className:`list`,style:{touchAction:d?`none`:void 0},onPointerMove:g,onPointerUp:()=>f(null),onPointerCancel:()=>f(null),children:[e.map((e,t,n)=>(0,J.jsxs)(`div`,{"data-snid":e.id,className:`row ${d===e.id?`dragging`:``}`,children:[(0,J.jsx)(Y,{className:`drag-handle`,title:`drag to reorder`,style:{touchAction:`none`,cursor:`grab`},onPointerDown:t=>{t.preventDefault(),f(e.id)},children:(0,J.jsx)(Zo,{size:16})}),(0,J.jsx)(`button`,{className:`row-title snippet-title`,title:e.text,onClick:()=>u(e),children:e.title||kO(e.text)}),(0,J.jsx)(Y,{title:`move up`,disabled:t===0,onClick:()=>p(e.id,-1),children:(0,J.jsx)(to,{size:16})}),(0,J.jsx)(Y,{title:`move down`,disabled:t===n.length-1,onClick:()=>p(e.id,1),children:(0,J.jsx)(ts,{size:16})}),(0,J.jsx)(Y,{title:`edit`,onClick:()=>u(e),children:(0,J.jsx)(Mo,{size:16})}),(0,J.jsx)(Y,{variant:`danger`,title:`delete`,onClick:()=>m(e.id),children:(0,J.jsx)(ws,{size:16})})]},e.id)),(0,J.jsx)($,{empty:e.length===0,children:a})]})]})}function cle({draft:e,onCancel:t,onSave:n,textPlaceholder:r,trackId:i}){let[a,o]=(0,V.useState)(e.title),[s,c]=(0,V.useState)(e.text),l=(0,V.useRef)(null);return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:(0,J.jsx)(J.Fragment,{children:e.title||e.text?`Edit`:`New`}),onClose:t}),(0,J.jsxs)(`div`,{className:`form`,children:[(0,J.jsx)(`input`,{className:`search`,placeholder:`Title (optional — first line is used otherwise)`,value:a,onChange:e=>o(e.target.value)}),(0,J.jsx)(`textarea`,{className:`search`,ref:l,rows:10,placeholder:r,autoFocus:!0,value:s,onChange:e=>c(e.target.value),style:{resize:`vertical`,fontFamily:`inherit`}})]}),(0,J.jsxs)(`div`,{className:`sheet-actions`,children:[(0,J.jsxs)(Y,{onClick:t,children:[(0,J.jsx)(B,{size:16}),` cancel`]}),(0,J.jsx)(`span`,{className:`spacer`}),(0,J.jsx)(`button`,{className:`send`,disabled:!s.trim(),onClick:()=>{q(i),n({...e,title:a,text:s})},children:`Save`})]})]})}var lle=[`inbox`,`untracked`,`plugins`],jO=[`outline`,`find`,`refresh`],MO=`scrollback`,NO=`browse`,PO=`star`,FO=`followup`,IO=[{id:`inbox`,name:`new files`,Icon:jo},{id:`untracked`,name:`changed files`,Icon:Ys},{id:`plugins`,name:`plugins`,Icon:Yo},{id:`limit`,name:`auto-continue`,Icon:go},{id:`model`,name:`model`,Icon:Ts},{id:`logins`,name:`logins`,Icon:Xa},{id:`cmd`,name:`cmd`,Icon:lo},{id:`image`,name:`image`,Icon:_s},{id:`file`,name:`attach file`,Icon:vo},{id:`files`,name:`gallery`,Icon:Xte},{id:`browse`,name:`browse files`,Icon:Xc},{id:`diff`,name:`diff`,Icon:ds},{id:`build`,name:`build`,Icon:uo},{id:`ctx`,name:`ctx`,Icon:ms},{id:`usage`,name:`usage`,Icon:Jc},{id:`cpu`,name:`cpu`,Icon:sc},{id:`shot`,name:`shot`,Icon:xo},{id:`clip`,name:`to host clip`,Icon:so},{id:`select`,name:`select`,Icon:_o},{id:`decide`,name:`answer list`,Icon:Vc},{id:`teleport`,name:`teleport`,Icon:Os},{id:`remote`,name:`remote`,Icon:gl},{id:`tasks`,name:`tasks`,Icon:Wo},{id:`backlog`,name:`backlog`,Icon:il},{id:`history`,name:`history`,Icon:Xs},{id:`outline`,name:`outline`,Icon:vs},{id:`sent`,name:`sent`,Icon:Rs},{id:`find`,name:`find`,Icon:rc},{id:`refresh`,name:`refresh reader`,Icon:xc},{id:`scrollback`,name:`scrollback`,Icon:jc},{id:`fork`,name:`fork`,Icon:Rc},{id:`companion`,name:`companion shell`,Icon:Do},{id:`star`,name:`star`,Icon:Pa},{id:`followup`,name:`flag for follow up`,Icon:Ac},{id:`bookmark`,name:`bookmark`,Icon:Ua}],LO=()=>[];function ule(e){LO=e}var RO=()=>[...IO,...LO()],dle=e=>e.includes(`:`);function zO(e,t){let n=e.sort===`used`&&t?.length?t:e.order,r=e=>{let t=n.indexOf(e);return t===-1?2**53-1:t};return RO().map((e,t)=>({t:e,i:t})).sort((e,t)=>r(e.t.id)-r(t.t.id)||e.i-t.i).map(e=>e.t)}function fle(e){let t=new Map(RO().map(e=>[e.id,e]));return(e.pinned??[]).map(e=>t.get(e)).filter(e=>!!e)}function BO(e){return zO({...e,sort:`manual`}).map(e=>e.id).map((e,t)=>({id:e,i:t,n:Mv(`toolbar:${e}`)})).sort((e,t)=>t.n-e.n||e.i-t.i).map(e=>e.id)}function VO(){try{let e={iconsOnly:!1,hidden:[],order:[],sort:`manual`,pinned:[`files`,NO,...jO,MO,PO,FO],...JSON.parse(z(R.toolbar)||`{}`)},t=new Set(IO.map(e=>e.id));if(e.pinned=(Array.isArray(e.pinned)?e.pinned:[]).filter(e=>t.has(e)||dle(e)),e.order.length){let t=lle.filter(t=>!e.order.includes(t));t.length&&(e.order=[...t,...e.order])}if(e.readerPins!==1){let t=jO.filter(t=>!e.pinned.includes(t));e.pinned=[...e.pinned,...t],e.readerPins=1,Ta(R.toolbar,e)}if(e.scrollbackPin!==1&&(e.pinned.includes(`scrollback`)||(e.pinned=[...e.pinned,MO]),e.scrollbackPin=1,Ta(R.toolbar,e)),e.browsePin!==1&&(e.pinned.includes(`browse`)||(e.pinned=[...e.pinned,NO]),e.browsePin=1,Ta(R.toolbar,e)),e.starPin!==1&&(e.pinned.includes(`star`)||(e.pinned=[...e.pinned,PO]),e.starPin=1,Ta(R.toolbar,e)),e.followupPin!==1){if(!e.pinned.includes(`followup`)){let t=e.pinned.indexOf(PO);e.pinned=t===-1?[...e.pinned,FO]:[...e.pinned.slice(0,t+1),FO,...e.pinned.slice(t+1)]}e.followupPin=1,Ta(R.toolbar,e)}return e}catch{return{iconsOnly:!1,hidden:[],order:[],sort:`manual`,pinned:[`files`,NO,...jO,MO,PO,FO],readerPins:1,scrollbackPin:1,browsePin:1,starPin:1,followupPin:1}}}var HO=R.headerCmds,UO=40,WO=24,ple=8e3,GO=[{id:`compact`,title:`/compact`,text:`/compact`},{id:`context`,title:`/context`,text:`/context`},{id:`continue`,title:`continue`,text:`continue`}];function mle(e){let t=e.split(`
7
+ `).map(e=>e.trim()).find(Boolean)??``;return t.length>WO?`${t.slice(0,23)}…`:t||`untitled`}function KO(e){if(!e||typeof e!=`object`)return null;let t=e,n=typeof t.id==`string`?t.id.slice(0,64):``,r=typeof t.text==`string`?t.text.slice(0,ple):``,i=typeof t.title==`string`?t.title.slice(0,WO):``;return!n||!r.trim()?null:{id:n,title:i.trim()||mle(r),text:r}}function qO(){let e=ma(HO,null);if(!e||typeof e!=`object`)return[...GO];let t={list:Array.isArray(e.list)?e.list.map(KO).filter(e=>!!e):[],removed:Array.isArray(e.removed)?e.removed.filter(e=>typeof e==`string`):[]},n=new Set(t.list.map(e=>e.id)),r=new Set(t.removed),i=GO.filter(e=>!n.has(e.id)&&!r.has(e.id));return[...t.list,...i].slice(0,UO)}function hle(e){let t=e.map(KO).filter(e=>!!e).slice(0,UO),n=new Set(t.map(e=>e.id)),r=GO.filter(e=>!n.has(e.id)).map(e=>e.id);Ta(HO,{list:t,removed:r})}function gle(){return wa(HO),[...GO]}function _le(e){return e.trimStart().startsWith(`/`)}function vle(e,t){if(t)return{shown:[...e],hiddenSlash:0};let n=e.filter(e=>!_le(e.text));return{shown:n,hiddenSlash:e.length-n.length}}var yle=new Set([`limit`,`star`,`followup`,`bookmark`]);function ble(e){return!(e&&yle.has(e))}function JO(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function xle(e,t,n){let r=e.indexOf(t),i=r+n;if(r===-1||i<0||i>=e.length)return null;let a=[...e];return[a[r],a[i]]=[a[i],a[r]],a}function Sle(e,t,n){if(!n||n===t)return null;let r=e.indexOf(t),i=e.indexOf(n);if(r===-1||i===-1)return null;let a=[...e];return a.splice(r,1),a.splice(i,0,t),a}var YO=W(VO()),XO=W(qO()),ZO=W([]),QO=W(z(R.toolbarOpen)===`1`);function $O(){return G(YO)}function ek(){return G(XO)}function tk(){return G(ZO)}function Cle(){return G(QO)}function nk(e){let t=G(XO);return(0,V.useMemo)(()=>vle(t,e),[t,e])}function rk(e){YO.set(e),Ta(R.toolbar,e)}function ik(e){let t=YO.get();U().say.track(`action:toolbar.pin`),rk({...t,pinned:JO(t.pinned??[],e)})}function wle(e){let t=YO.get();rk({...t,hidden:JO(t.hidden,e)})}function ak(e,t){let n=YO.get(),r=xle(zO(n).map(e=>e.id),e,t);r&&rk({...n,order:r})}function Tle(e,t){let n=YO.get(),r=Sle(zO(n).map(e=>e.id),e,t);r&&rk({...n,order:r})}function ok(e){let t={...YO.get(),sort:e};rk(t),e===`used`&&ZO.set(BO(t))}function Ele(e){QO.set(e),ua(R.toolbarOpen,e?`1`:`0`)}function Dle(e){ble(e)&&(QO.set(!1),ua(R.toolbarOpen,`0`))}function Ole(e){XO.set(e),hle(e)}function kle(){XO.set(gle())}function Ale(e){let t=$O();(0,V.useEffect)(()=>{let e=YO.get();if(e.sort!==`used`)return;ZO.set(BO(e));let t=setInterval(()=>ZO.set(BO(YO.get())),6e4);return()=>clearInterval(t)},[t.sort,t.order,e])}function jle(){return Mm(e=>{e===R.toolbar?YO.set(VO()):e===R.headerCmds&&XO.set(qO())},[R.toolbar,R.headerCmds])}function Mle(){let e=Dh(),t=ek(),n=$O(),{active:r,backends:i}=e.world,a=nk(e.world.sessionCan(r,`slash`));return(0,J.jsx)(AO,{snippets:t,onSave:Ole,onClose:()=>e.nav.close(`hdrcmd`),heading:`Header commands`,hint:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{children:`One-tap chips in the session header — tapping one sends its text to the session you are in (a slash command runs as a command). The header survives a collapse, so these stay reachable in reader view.`}),r&&a.hiddenSlash>0&&(0,J.jsxs)(`div`,{children:[r.title,` runs `,MC(i,r.backend)??`another backend`,`, which takes no Claude slash commands — so `,a.hiddenSlash,` of these `,a.hiddenSlash===1?`is`:`are`,` not offered in its header. They are still here, still synced, and still offered in every claude session.`]}),(0,J.jsx)(`div`,{className:`pin-head`,children:`Pin toolbar actions into the header`}),(0,J.jsx)(`div`,{className:`pin-cloud`,children:RO().map(e=>{let t=(n.pinned??[]).includes(e.id);return(0,J.jsxs)(Y,{className:`hdr-cmd${t?` active`:``}`,title:t?`unpin ${e.name} from the header`:`pin ${e.name} into the header`,onClick:()=>ik(e.id),children:[(0,J.jsx)(e.Icon,{size:12}),` `,e.name,t?(0,J.jsx)(ko,{size:11}):null]},e.id)})})]}),emptyText:`No header commands. Tap “new” to add one.`,textPlaceholder:`/compact — or any text to send…`,onReset:kle,trackId:`action:hdrcmd.save`})}var sk=16;function Nle(){let e=Dh(),t=$O(),n=ek(),r=tk(),[i,a]=(0,V.useState)(null);return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:`Customize toolbar`,onClose:()=>e.nav.close(`toolbar`)}),(0,J.jsxs)(`div`,{className:`form`,children:[(0,J.jsxs)(Y,{onClick:()=>{e.say.track(`action:hdrcmd.manage`),e.nav.open(`hdrcmd`)},children:[(0,J.jsx)(lo,{size:sk}),` header commands (`,n.length,`) & pins (`,(t.pinned??[]).length,`)`]}),(0,J.jsx)(X,{children:`Header commands are the one-tap chips next to the session title — they stay reachable when the header is collapsed and in reader view.`}),(0,J.jsxs)(Xw,{style:{gap:6},children:[(0,J.jsxs)(Y,{className:(t.sort??`manual`)===`manual`?`active`:``,title:`keep the order you set`,onClick:()=>ok(`manual`),children:[(0,J.jsx)(Zo,{size:sk}),` manual order`]}),(0,J.jsxs)(Y,{className:t.sort===`used`?`active`:``,title:`auto-order by how often you use each action`,onClick:()=>ok(`used`),children:[(0,J.jsx)(qs,{size:sk}),` most used`]})]}),(0,J.jsx)(Z,{children:t.sort===`used`?(0,J.jsx)(J.Fragment,{children:`Auto-sorted by your usage (counts below). The live toolbar re-ranks on session switch and about once a minute — never mid-tap. Switch back to manual to drag or move items with the arrows.`}):(0,J.jsxs)(J.Fragment,{children:[`Drag the `,(0,J.jsx)(Zo,{size:12}),` handle to reorder (or use the arrows). Tap the eye to show/hide an action in the terminal toolbar, and the `,(0,J.jsx)(ko,{size:12}),` to also put it in the session header (where it survives a collapse).`]})})]}),(0,J.jsx)(`div`,{className:`list`,style:{touchAction:i?`none`:void 0},onPointerMove:e=>{if(!i)return;let t=document.elementFromPoint(e.clientX,e.clientY)?.closest(`[data-tbid]`);Tle(i,t?.getAttribute(`data-tbid`))},onPointerUp:()=>a(null),onPointerCancel:()=>a(null),children:zO(t,r).map((e,n,r)=>{let o=!t.hidden.includes(e.id),s=(t.sort??`manual`)===`manual`,c=Mv(`toolbar:${e.id}`);return(0,J.jsxs)(`div`,{"data-tbid":e.id,className:`row ${i===e.id?`dragging`:``}`,children:[s&&(0,J.jsx)(Y,{className:`drag-handle`,title:`drag to reorder`,style:{touchAction:`none`,cursor:`grab`},onPointerDown:t=>{t.preventDefault(),a(e.id)},children:(0,J.jsx)(Zo,{size:sk})}),(0,J.jsxs)(Zw,{children:[(0,J.jsx)(e.Icon,{size:sk}),` `,e.name]}),(0,J.jsx)(`span`,{className:`muted`,title:`used ${c}× on this device`,style:{fontSize:12},children:c||`–`}),s&&(n>0?(0,J.jsx)(Y,{title:`move up`,onClick:()=>ak(e.id,-1),children:(0,J.jsx)(to,{size:sk})}):(0,J.jsx)(`span`,{className:`key`,"aria-hidden":!0,style:{visibility:`hidden`},children:(0,J.jsx)(to,{size:sk})})),s&&(n<r.length-1?(0,J.jsx)(Y,{title:`move down`,onClick:()=>ak(e.id,1),children:(0,J.jsx)(ts,{size:sk})}):(0,J.jsx)(`span`,{className:`key`,"aria-hidden":!0,style:{visibility:`hidden`},children:(0,J.jsx)(ts,{size:sk})})),(0,J.jsx)(Y,{className:(t.pinned??[]).includes(e.id)?`active`:``,title:(t.pinned??[]).includes(e.id)?`unpin from the session header`:`pin into the session header — stays reachable when the header is collapsed and in reader view`,onClick:()=>ik(e.id),children:(0,J.jsx)(ko,{size:sk})}),(0,J.jsx)(Y,{title:o?`hide`:`show`,onClick:()=>wle(e.id),children:o?(0,J.jsx)(hl,{size:sk}):(0,J.jsx)(Go,{size:sk,className:`muted`})})]},e.id)})})]})}var Ple={id:`toolbarCfg`,sheets:[{id:`toolbar`,persisted:!0,render:()=>(0,V.createElement)(Nle)},{id:`hdrcmd`,persisted:!1,render:()=>(0,V.createElement)(Mle)}],boot:()=>jle()},ck={supported:!1,canInstall:!1,silent:!1};function Fle(e){if(!e||typeof e!=`object`)return{};let t=e,n={};return(t.distribution===`dev`||t.distribution===`play`)&&(n.distribution=t.distribution),typeof t.self==`string`&&t.self&&(n.self=t.self),n}function lk(e){return e.distribution===`play`}function uk(e,t){return lk(t)&&!!e&&!!t.self&&e===t.self}var dk=`this build updates through Google Play — install the new version from the Play Store`,Ile=`could not read which app this file is, and this build installs only an app it can name`;function Lle(e){return`new builds of ${e} wait for a tap: this ${I.displayName} comes from Google Play, which does not let it install apps by themselves — every install asks`}var fk=`A build downloaded here installs with the phone's own confirm dialog, one tap each. This ${I.displayName} comes from Google Play, which does not let it install apps by themselves, and it updates itself only through Play.`;function pk(e){let t=(e.name??``).toLowerCase(),n=(e.mime??``).toLowerCase();return t.endsWith(`.apk`)||n===`application/vnd.android.package-archive`}function mk(e){return e.pkgLabel||e.pkg||e.name}function hk(e,t){return!!e.pkg&&t.includes(e.pkg)}function gk(e,t){return t?e.includes(t)?e.filter(e=>e!==t):[...e,t]:[...e]}function Rle(e,t){return!t.supported||!pk(e)||e.state!==`done`?{verb:null,reason:null}:uk(e.pkg,t)?{verb:null,reason:dk}:lk(t)&&!e.pkg?{verb:null,reason:Ile}:e.evicted&&e.cleanedAt?{verb:null,reason:Tk(e)}:e.evicted?{verb:null,reason:`the bytes were cleared to save space — fetch it again to install it`}:t.canInstall?e.install===`installing`?{verb:null,reason:null}:{verb:`install`,reason:null}:{verb:null,reason:`this phone has not allowed ${I.displayName} to install apps`,settings:!0}}function _k(e,t,n,r){switch(e){case`installing`:return`installing…`;case`asked`:return`waiting for you to confirm it on this phone`;case`installed`:return`installed${r?` · ${n} ${r}`:``}`;case`failed`:return`could not install: ${vk(t)}`;default:return null}}function vk(e){if(!e)return`the phone did not say why`;if(/VERIFICATION_FAILURE/.test(e))return`Google Play Protect stopped it — it checks every app from outside the Play Store, and refused this build with nobody there to answer it. Retry with the phone in hand: if Play Protect asks, install anyway. If it refuses without asking, Play Store › Play Protect says why`;if(/Session was abandoned/i.test(e))return`the install was dropped before it finished — Android abandons one when the app is closed mid-install or the confirm dialog goes unanswered. A retry starts a fresh one`;let t=/allocate (\d+) because only (\d+) allocatable/i.exec(e);if(!t)return e;let n=e=>`${Math.ceil(e/1e6)} MB`,r=Number(t[1]),i=Number(t[2]),a=i>0?`only ${n(i)} of it is usable`:`none of it is usable yet`;return`this phone is out of space — it needs ${n(r)} beyond the room Android keeps in reserve (up to 500 MB), and ${a}. Free space until Settings shows about ${n(r+5e8-i)} free, then retry`}function zle(e){return e===`failed`?`retry install`:e===`installed`?`install again`:`install`}function Ble(e){return _k(e.install,e.installError,mk(e),e.pkgVersion)}function yk(e,t,n){if(!t.supported||!pk(e)||!e.pkg)return null;let r=mk(e);return uk(e.pkg,t)?dk:lk(t)?Lle(r):hk(e,n)?t.canInstall?t.silent?e.install===`installed`?`new builds of ${r} install by themselves`:`new builds of ${r} install by themselves — the first one asks once`:`new builds of ${r} install by themselves, and this Android asks every time`:`${r} would install itself once this phone allows it`:`new builds of ${r} wait for a tap`}function Vle(e,t,n){if(!t.supported||!pk(e)||!e.pkg||lk(t))return null;let r=hk(e,n);return{pkg:e.pkg,on:r,label:r?`stop installing ${mk(e)} by itself`:`always install ${mk(e)}`}}function Hle(e,t){if(!e.supported)return null;if(!e.canInstall)return`Allow ${I.displayName} to install apps and a build downloaded here can go straight onto this phone.`;if(lk(e))return fk;if(!t.length)return`No app installs itself yet — turn it on per app under apps.`;let n=t.length;return n===1?`1 app installs itself when a new build arrives.`:`${n} apps install themselves when a new build arrives.`}function bk(e){return e.map(e=>({id:e.item.id,name:e.item.name,state:e.state,evicted:e.evicted,pkg:e.pkg,pkgLabel:e.pkgLabel,pkgVersion:e.pkgVersion,install:e.install,installError:e.installError,installSnoozedUntil:e.installSnoozedUntil,cleanedAt:e.cleanedAt,cleanedBytes:e.cleanedBytes,cleanNote:e.cleanNote,updatedAt:e.updatedAt,repo:e.item.repoName||void 0}))}function xk(e,t,n,r=[]){let i=new Map,a=new Map;for(let t of e){if(!t.pkg||!pk(t))continue;let e=a.get(t.pkg);if((!e||(t.updatedAt??0)>=(e.updatedAt??0))&&a.set(t.pkg,t),t.state!==`done`||t.evicted)continue;let n=i.get(t.pkg);(!n||(t.updatedAt??0)>=(n.updatedAt??0))&&i.set(t.pkg,t)}let o=[],s=new Set,c=(e,i)=>{if(s.has(e))return;s.add(e);let c=t.includes(e),l=i??a.get(e),u=r.filter(t=>t.pkg===e);o.push({pkg:e,label:l?.pkgLabel||u.find(e=>e.label)?.label||e,repo:i?.repo||l?.repo||u.find(e=>e.repo)?.repo||void 0,allowed:c,buildId:i?.id,version:i?.pkgVersion||void 0,install:i?.install,installError:i?.installError||void 0,builtAt:i?.updatedAt,snoozedUntil:i?.installSnoozedUntil||void 0,note:i?yk(i,n,t)??``:Wle(c,n)})};for(let e of t)c(e,i.get(e));for(let[e,t]of i)c(e,t);return o.sort((e,t)=>Number(t.allowed)-Number(e.allowed)||e.label.localeCompare(t.label))}function Sk(e){return e.filter(e=>!!e.buildId&&e.install!==`installed`&&e.install!==`installing`).sort((e,t)=>(t.builtAt??0)-(e.builtAt??0))}function Ule(e,t,n){return!e.snoozedUntil||e.snoozedUntil<=t?null:`notification put off until ${n(e.snoozedUntil)}`}function Wle(e,t){return e?lk(t)?`no build of it on this phone — and this Google Play build installs nothing by itself`:t.canInstall?`installs itself when a build arrives`:`would install itself once this phone allows it`:`no build of it on this phone`}function Gle(e,t){if(!t.supported)return`This device cannot install apps — open ${I.displayName}'s own app to do that.`;if(!t.canInstall)return`Allow ${I.displayName} to install apps and a build downloaded here can go straight onto this phone.`;let n=e.filter(e=>e.allowed).length;return e.length?lk(t)?`${e.length} app${e.length===1?``:`s`} downloaded here. ${fk}`:n?`${n} of ${e.length} install${n===1?`s`:``} itself when a new build arrives.`:`${e.length} app${e.length===1?``:`s`} downloaded here, none of them installing by itself.`:`No app has been downloaded to this phone yet.`}function Kle(e){return _k(e.install,e.installError,e.label,e.version)}function qle(e,t){return!t.supported||!t.canInstall||!e.buildId||e.install===`installing`||uk(e.pkg,t)?null:{id:e.buildId,label:`install ${e.label}${e.version?` ${e.version}`:``} now`}}function Ck(e,t){let n=t?.byPkg[e];if(!t||!n)return{verdict:`unknown`};let r=n.updateOwner??n.installer;return r===t.self?{verdict:`ours`}:{verdict:`other`,by:r}}function wk(e){switch(e){case void 0:return`an installer that left no record (usually adb or Android Studio)`;case`com.android.vending`:return`the Play Store`;case`com.android.shell`:return`adb or Android Studio`;case`com.google.android.packageinstaller`:case`com.android.packageinstaller`:return`the system installer (a file manager or a browser download)`;default:return e}}function Jle(e,t){return t.verdict===`other`?`every update of ${e} will ask: it was first installed by ${wk(t.by)}, and Android lets only that installer update it quietly. Uninstall it once (that deletes its data) and install the next build from here — one dialog, then quiet.`:null}var Yle=[`This phone lets ${I.displayName} install apps (Settings → install unknown apps).`,`The app's auto-install is on here.`,`Its FIRST install came from ${I.displayName}. That one always asks, once; after it Android lets ${I.displayName} update the app quietly. An app first installed from a file manager, a browser, the Play Store or Android Studio stays that installer's and every update asks — uninstall it once and install from here.`,`Every build is signed with the same key. A build signed differently cannot update the installed app at all.`,`The app targets a recent Android version, and the phone runs Android 12 or newer.`];function Xle(e){return e>=1e6?`${Math.round(e/1e6)} MB`:`${Math.max(1,Math.round(e/1e3))} kB`}function Tk(e){let t=`APK deleted after it installed${e.cleanedBytes?` (${Xle(e.cleanedBytes)} freed)`:``} — fetch it again to reinstall`;return e.cleanNote?`${t} · ${e.cleanNote}`:t}function Zle(e){return e===null?`Deleting a build's APK once it has installed needs a newer app build — the next APK you install brings it.`:e?`Once a build installs, its APK is deleted from this phone: the copy inside the app, the copy saved to Downloads, and older builds of the same app. Reinstalling means fetching it again.`:`Installed builds keep their APK on this phone (inside the app, and in Downloads where you saved one) until you clear it. Turn this on to delete it once the build is on.`}function Qle(e){return`delete APK after install: ${e?`on`:`off`}`}function Ek(){let e=Nh(`Install`);return e&&typeof e.install==`function`?e:null}function Dk(){return hu()&&Ek()!==null}async function Ok(){let e=Ek();if(!e)return{caps:ck,allow:[],cleanup:null};try{let t=await e.status();return{caps:{supported:t?.supported!==!1,canInstall:!!t?.canInstall,silent:!!t?.silent,...Fle(t)},allow:Array.isArray(t?.allow)?t.allow.filter(e=>typeof e==`string`):[],cleanup:typeof t?.cleanAfterInstall==`boolean`&&typeof e.setCleanAfterInstall==`function`?t.cleanAfterInstall:null}}catch{return{caps:ck,allow:[],cleanup:null}}}async function kk(e){let t=Ek();if(!t?.sources||!e.length)return null;try{let n=await t.sources({packages:e});return n?.self?{self:n.self,sdk:typeof n.sdk==`number`?n.sdk:void 0,byPkg:n.sources??{}}:null}catch{return null}}async function Ak(){let e=Ek();if(!e)throw Error(`this device has no app installer to open`);await e.openSettings()}async function jk(e){try{await Ek()?.setAllow({packages:e})}catch{}}async function $le(e){let t=Ek();if(!t?.setCleanAfterInstall)throw Error(`this app build cannot do that yet`);await t.setCleanAfterInstall({on:e})}async function Mk(e){let t=Ek();if(!t)throw Error(`this device cannot install apps`);await t.install({id:e})}function Nk(){let e=ma(R.installAllow,[]);return Array.isArray(e)?e.filter(e=>typeof e==`string`&&!!e):[]}function Pk(e){Ta(R.installAllow,e),jk(e)}var Fk=!1;function eue(){Dk()&&(jk(Nk()),!Fk&&(Fk=!0,Mm(()=>{jk(Nk())},[R.installAllow])))}var Ik={entries:[],devices:[],total:0},Lk,Rk=null,zk=new Set;(()=>{let e=ma(R.installLog,{});e?.doc&&Array.isArray(e.doc.entries)&&typeof e.at==`number`&&(Ik=e.doc,Lk=e.at)})();function Bk(){return{doc:Ik,toldAt:Lk,live:Rk?.status===`open`}}function Vk(){let e=Bk();for(let t of zk)t(e)}function tue(e){return zk.add(e),e(Bk()),()=>{zk.delete(e)}}function nue(){return Bk()}function Hk(){return(z(R.deviceName)??``).trim()}function rue(e){ua(R.deviceName,e.trim().slice(0,60)),Gk()}function Uk(){let e=typeof navigator>`u`?``:navigator.userAgent,t=(/Android[^;)]*;\s*([^;)]+?)(?:\s+Build\/[^;)]*)?\s*\)/.exec(e)?.[1]??``).trim();return t.length>1?t.slice(0,60):``}function iue(e){return e.map(e=>({id:e.item.id,name:e.item.name,repo:e.item.repoName,pkg:e.pkg,label:e.pkgLabel,version:e.pkgVersion,install:e.install,installError:e.installError,installedAt:e.installedAt,installAuto:e.installAuto}))}var Wk=``;function Gk(e=!1){if(!Rk||Rk.status!==`open`)return;let t=lf();if(!t||t===`unknown`)return;let n=re(iue(rO.list()));if(!n.length&&!e)return;let r={id:t,...Hk()?{name:Hk()}:{},...Uk()?{model:Uk()}:{}},i=JSON.stringify({device:r,entries:n});(e||i!==Wk)&&(Wk=i,Rk.send({t:`install.report`,device:r,entries:n}))}function aue(e){Rk||(Rk=e,e.on(e=>{e.t===`install.log`?(Ik=e.doc,Lk=Date.now(),Ta(R.installLog,{doc:Ik,at:Lk}),Vk()):e.t===`error`&&e.context===`__status`?Vk():e.t===`welcome`&&(Wk=``,Gk(!0))}),rO.subscribe(()=>Gk()))}var Kk=null;function oue(){Kk=`ready`}function sue(){let e=Kk??`apps`;return Kk=null,e}var qk=e=>`${Math.max(1,Math.round(e/1e6))} MB`,cue=e=>e.split(`/`).pop()??e;function lue(e,t,n){let r=[],i=e.builds.filter(e=>e.apk);switch(r.push(i.length?{id:`build`,half:`repo`,state:`ok`,label:`build command`,text:`${i.map(e=>`"${e.name}"`).join(`, `)} builds it from the Build sheet.`}:e.builds.length?{id:`build`,half:`repo`,state:`warn`,label:`build command`,text:`${e.builds.length} build command${e.builds.length===1?``:`s`}, none named like an APK build — fine if one of them makes it; else an agent's build is the only way one arrives.`}:{id:`build`,half:`repo`,state:`warn`,label:`build command`,text:`No build command in the Build sheet — only an agent's build reaches the phone. Build › set up offers one.`}),r.push(e.newestApk?{id:`outbox`,half:`repo`,state:`ok`,label:`APK in the outbox`,text:`${e.apks} in the outbox, newest ${cue(e.newestApk.rel)} (${qk(e.newestApk.size)}, ${n(t-e.newestApk.mtime)}).`}:{id:`outbox`,half:`repo`,state:`no`,label:`APK in the outbox`,text:`No APK in .claude/outbox/ — a build left in the module's build/ directory never reaches the phone. Have the build copy its APK there.`}),e.key){case`desktop`:case`debug`:case`other`:case`repo`:r.push({id:`key`,half:`repo`,state:`ok`,label:`same signing key`,text:e.key===`desktop`?`Signed with this desktop's key, kept outside the repo.`:e.key===`debug`?`Signed with this desktop's debug key, through keystore.properties.`:e.key===`repo`?`Signed with the repo's own signing config — keep that key.`:`Signed with the key named in keystore.properties.`});break;case`debug-default`:r.push({id:`key`,half:`repo`,state:`warn`,label:`same signing key`,text:`No signing config: each machine's own debug key signs it. Builds from THIS desktop update each other; one from another machine cannot update the app.`});break;case`missing`:r.push({id:`key`,half:`repo`,state:`no`,label:`same signing key`,text:`The build reads keystore.properties and there is none, so it has no key. The repo's setup checklist (signing key) creates and links one.`})}r.push(e.targetSdk===void 0?{id:`sdk`,half:`repo`,state:`unknown`,label:`recent targetSdk`,text:`targetSdk is not a literal in the gradle file, so it was not read.`}:e.targetSdk<33?{id:`sdk`,half:`repo`,state:`no`,label:`recent targetSdk`,text:`targetSdk ${e.targetSdk}: newer Androids ask on every update of an app targeting below 33.`}:{id:`sdk`,half:`repo`,state:`ok`,label:`recent targetSdk`,text:`targetSdk ${e.targetSdk}.`});let a=e.autoPull;return r.push(a.enabled?a.newestMatches===!1?{id:`pull`,half:`repo`,state:`no`,label:`auto-download`,text:`Auto-download is on, but its rule does not take the newest APK${e.newestApk&&a.maxBytes>0&&e.newestApk.size>a.maxBytes?` — ${qk(e.newestApk.size)} is over its ${qk(a.maxBytes)} cap`:` — it is outside the rule's patterns`}. Downloads › auto-download.`}:{id:`pull`,half:`repo`,state:`ok`,label:`auto-download`,text:`On for ${e.repoName}${a.newestMatches?`, and its rule takes the newest APK`:``}.`}:{id:`pull`,half:`repo`,state:`no`,label:`auto-download`,text:`Auto-download is off for ${e.repoName}: a new build waits in the outbox until someone fetches it. Downloads › auto-download turns it on.`}),r}function Jk(e,t,n,r){let{caps:i}=n;if(!i.supported)return[{id:`access`,half:`phone`,state:`unknown`,label:`installs on this device`,text:`This is a browser — only ${I.displayName}'s Android app installs builds.`}];if(lk(i))return[{id:`access`,half:`phone`,state:`no`,label:`installs on this device`,text:`This Google Play build of the app installs nothing by itself.`}];let a=[];a.push(i.canInstall?{id:`access`,half:`phone`,state:`ok`,label:`install access`,text:`This phone lets ${I.displayName} install apps.`}:{id:`access`,half:`phone`,state:`no`,label:`install access`,text:`This phone has not allowed ${I.displayName} to install apps (Settings › install unknown apps).`}),a.push(n.allow.includes(e)?{id:`switch`,half:`phone`,state:`ok`,label:`auto-install`,text:`On here.`}:{id:`switch`,half:`phone`,state:`no`,label:`auto-install`,text:`Off here: a new build waits for a tap.`});let o=Ck(e,n.sources);a.push(o.verdict===`ours`?{id:`owner`,half:`phone`,state:`ok`,label:`first install from here`,text:`Installed, and ${I.displayName} owns its updates — they can go on without a dialog.`}:o.verdict===`other`?{id:`owner`,half:`phone`,state:`no`,label:`first install from here`,text:`First installed by ${wk(o.by)}: Android lets only that installer update it quietly, so every update asks. Uninstall it once (that deletes its data) and install from here.`}:{id:`owner`,half:`phone`,state:`warn`,label:`first install from here`,text:`Not installed on this phone, or the phone kept no record of who installed it. The first install from ${I.displayName} asks once; after it, quiet.`});let s=n.log.filter(t=>t.pkg===e&&t.deviceId===n.me).sort((e,t)=>(t.at??t.reportedAt)-(e.at??e.reportedAt)),c=s[0];if(r?.install===`asked`)a.push({id:`last`,half:`phone`,state:`warn`,label:`last attempt`,text:`Waiting for you to confirm it on this phone.`});else if(!c)a.push({id:`last`,half:`phone`,state:`unknown`,label:`last attempt`,text:`No install of ${t} reported from this phone yet.`});else{let e=n.ago(n.now-(c.at??c.reportedAt)),t=s.slice(0,5),r=t.filter(e=>e.outcome===`failed`).length,i=t.length>1?` ${r} of the last ${t.length} here failed.`:``;a.push(c.outcome===`installed`?{id:`last`,half:`phone`,state:r?`warn`:`ok`,label:`last attempt`,text:`${c.version?`${c.version} `:``}installed ${c.auto?`by itself`:`by tap`}, ${e}.${i}`}:{id:`last`,half:`phone`,state:`no`,label:`last attempt`,text:`${c.version?`${c.version} `:``}failed ${e}: ${vk(c.error)}.${i}`})}return a}function uue(e,t){if(e.pkg)return[e.pkg,...e.variants??[]].find(e=>t.has(e))??e.pkg}function due(e,t,n){let r=new Set([...t.map(e=>e.pkg),...n.allow,...n.log.map(e=>e.pkg),...Object.keys(n.sources?.byPkg??{})]),i=[],a=new Set;for(let o of e??[]){let e=uue(o,r),s=e?t.find(t=>t.pkg===e):void 0,c=s?.label??n.log.find(t=>t.pkg===e&&t.label)?.label??o.repoName,l=lue(o,n.now,n.ago);e?(a.add(e),l.push(...Jk(e,c,n,s))):l.push({id:`repo`,half:`repo`,state:`unknown`,label:`package`,text:`${o.module} names no literal applicationId, so this phone cannot tell which installed app it is.`}),i.push(Yk({pkg:e??o.module,label:c,repo:o.repoName,facts:o,row:s,checks:l}))}for(let r of t){if(a.has(r.pkg))continue;let t=[{id:`repo`,half:`repo`,state:`unknown`,label:`repo on this desktop`,text:e===null?`The desktop has not answered yet.`:`No repo on this desktop builds ${r.pkg}${r.repo?` (it came from ${r.repo} — another desktop, or an applicationId the desktop could not read)`:``}.`},...Jk(r.pkg,r.label,n,r)];i.push(Yk({pkg:r.pkg,label:r.label,repo:r.repo,row:r,checks:t}))}return i.sort((e,t)=>Number(!!t.blocker)-Number(!!e.blocker)||e.label.localeCompare(t.label))}function Yk(e){return{...e,blocker:e.checks.find(e=>e.state===`no`)}}function fue(e){return e.blocker?`not yet — ${e.blocker.label}`:e.checks.some(e=>e.state===`warn`||e.state===`unknown`)?`set up — with a caveat below`:`installs itself`}function Xk(e,t){return t===`all`?[...e]:e.filter(e=>t===`blocked`==!!e.blocker)}function pue({rows:e,caps:t,allow:n,log:r,me:i,onFlip:a,onOpenDownloads:o}){let s=gh(`apps:readiness`,()=>H.appReadiness()),c=s.data?.apps??null,[l,u]=(0,V.useState)(`all`),[d,f]=(0,V.useState)(null),p=(0,V.useMemo)(()=>{let t=new Set(e.map(e=>e.pkg));for(let e of c??[])for(let n of[e.pkg,...e.variants??[]])n&&t.add(n);return[...t].sort()},[e,c]),[m,h]=(0,V.useState)(null);(0,V.useEffect)(()=>{let e=!0;return kk(p).then(t=>{e&&h(t)}),()=>{e=!1}},[p.join(`,`)]);let g=due(c,e,{caps:t,allow:n,sources:m,log:r,me:i,now:Date.now(),ago:kp}),_=Xk(g,`blocked`),v=Xk(g,`ready`),y=Xk(g,l);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(Z,{children:[`Each app's whole chain for a build to install by itself — the desktop's half (from its repo) and this phone's. The first line marked `,(0,J.jsx)(bo,{size:12}),` is what to fix next.`,` `,(0,J.jsxs)(Y,{title:`read the repos again`,onClick:()=>{s.reload({quiet:!0}),q(`action:apps.setup.reload`),K(`reading the repos again`)},children:[(0,J.jsx)(xc,{size:14}),` re-read`]})]}),g.length>0&&(0,J.jsxs)(JS,{children:[(0,J.jsxs)(Y,{className:l===`blocked`?`active`:``,onClick:()=>{u(l===`blocked`?`all`:`blocked`),q(`action:apps.setup.blocked`)},children:[(0,J.jsx)(bo,{size:14}),` not yet · `,_.length]}),(0,J.jsxs)(Y,{className:l===`ready`?`active`:``,onClick:()=>{u(l===`ready`?`all`:`ready`),q(`action:apps.setup.ready`)},children:[(0,J.jsx)(Bc,{size:14}),` set up · `,v.length]})]}),l!==`all`&&(0,J.jsxs)(Z,{children:[y.length,` of `,g.length,` · `,l===`blocked`?`not yet set up`:`set up`,` `,(0,J.jsxs)(Y,{onClick:()=>u(`all`),children:[(0,J.jsx)(B,{size:14}),` show all`]})]}),(0,J.jsxs)(`div`,{className:`list`,children:[c===null&&(0,J.jsx)($,{res:s,thing:`the desktop's repos`,children:`Asking the desktop which repos build an Android app…`}),c!==null&&g.length===0&&(0,J.jsx)($,{res:s,children:`No repo on this desktop builds an Android app, and no app has been downloaded to this phone.`}),y.map(e=>(0,J.jsx)(mue,{r:e,open:d===`${e.repo??``}:${e.pkg}`,onToggle:()=>f(d===`${e.repo??``}:${e.pkg}`?null:`${e.repo??``}:${e.pkg}`),onFlip:()=>a(e.pkg),onOpenDownloads:o},`${e.repo??``}:${e.pkg}`))]})]})}var Zk={ok:Bc,no:bo,warn:xs,unknown:cs},Qk={ok:`pass`,no:`fail`,warn:`warn`,unknown:`ignored`};function mue({r:e,open:t,onToggle:n,onFlip:r,onOpenDownloads:i}){let a=e.blocker,o=a?`no`:e.checks.some(e=>e.state===`warn`)?`warn`:`ok`,s=Zk[o];return(0,J.jsxs)(`div`,{className:`check-row check-${Qk[o]}`,children:[(0,J.jsxs)(Xw,{as:`button`,kind:`grow`,title:t?`hide the checklist`:`show every line of the checklist`,onClick:n,children:[(0,J.jsxs)(`span`,{className:`check-top`,children:[(0,J.jsx)(`span`,{className:`check-icon`,children:(0,J.jsx)(s,{size:16})}),(0,J.jsx)(`span`,{className:`check-label`,children:e.label}),(0,J.jsx)(`span`,{className:`check-kind`,children:t?`hide`:`${e.checks.filter(e=>e.state===`ok`).length}/${e.checks.length}`})]}),(0,J.jsxs)(Q,{className:`mono`,children:[e.pkg,e.repo?` · ${e.repo}`:``]}),(0,J.jsx)(Q,{className:a?`warn`:void 0,children:fue(e)}),!t&&a&&(0,J.jsx)(`span`,{className:`check-detail`,children:a.text})]}),t&&(0,J.jsx)(`ul`,{className:`check-list`,children:[`repo`,`phone`].map(t=>{let n=e.checks.filter(e=>e.half===t);return n.length?[(0,J.jsx)(`li`,{className:`check-kind`,children:t===`repo`?`on the desktop`:`on this phone`},t),...n.map(e=>{let t=Zk[e.state];return(0,J.jsxs)(`li`,{className:`check-row check-${Qk[e.state]}`,children:[(0,J.jsxs)(`span`,{className:`check-top`,children:[(0,J.jsx)(`span`,{className:`check-icon`,children:(0,J.jsx)(t,{size:14})}),(0,J.jsx)(`span`,{className:`check-label`,children:e.label})]}),(0,J.jsx)(`span`,{className:`check-detail`,children:e.text})]},e.id)})]:null})}),a&&(a.id===`switch`||a.id===`access`||a.id===`pull`)&&(0,J.jsxs)(`div`,{className:`row-acts pull-acts`,children:[a.id===`switch`&&(0,J.jsxs)(Y,{variant:`primary`,title:`always install ${e.label}`,onClick:()=>{q(`action:apps.setup.allow`),r()},children:[(0,J.jsx)(Va,{size:16}),` auto-install: on`]}),a.id===`access`&&(0,J.jsxs)(Y,{variant:`primary`,title:`open the phone's install-unknown-apps setting`,onClick:()=>{q(`action:apps.setup.settings`),Ak().catch(()=>K(`this phone has no screen for that switch`))},children:[(0,J.jsx)(Aa,{size:16}),` allow it`]}),a.id===`pull`&&(0,J.jsxs)(Y,{variant:`primary`,title:`the auto-download rule lives in Downloads`,onClick:()=>{q(`action:apps.setup.downloads`),i()},children:[(0,J.jsx)(Qa,{size:16}),` downloads`]})]})]})}function hue({onClose:e,onOpenDownloads:t}){let[n,r]=(0,V.useState)([]),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(void 0),[c,l]=(0,V.useState)(()=>Nk()),[u,d]=(0,V.useState)(()=>nue()),[f,p]=(0,V.useState)(sue),[m,h]=(0,V.useState)(!1),[g,_]=(0,V.useState)(()=>Hk()),[v,y]=(0,V.useState)({});(0,V.useEffect)(()=>tue(d),[]),(0,V.useEffect)(()=>rO.subscribe(r),[]),(0,V.useEffect)(()=>{let e=!0;return Ok().then(t=>{e&&(a(t.caps),s(t.cleanup))}),()=>{e=!1}},[]);let b=i??ck,x=xk(bk(n),c,b,u.doc.entries),[S,C]=(0,V.useState)(null),[w,T]=(0,V.useState)(!1),E=x.map(e=>`${e.pkg}:${e.install??``}`).join(`,`);(0,V.useEffect)(()=>{let e=!0;return kk(x.map(e=>e.pkg)).then(t=>{e&&C(t)}),()=>{e=!1}},[E]);let D=Sk(x),O=f===`ready`?D:x,k=e=>{let t=gk(c,e);l(t),Pk(t),q(`action:apps.allow`),K(t.includes(e)?`new builds of it will install by themselves`:`new builds of it will wait for a tap`)};return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(pl,{size:16}),` Apps`]}),onClose:e}),(0,J.jsxs)(`div`,{className:`segmented`,children:[(0,J.jsxs)(`button`,{className:`seg ${f===`ready`?`on`:``}`,onClick:()=>{p(`ready`),q(`action:apps.pane.ready`)},children:[(0,J.jsx)(No,{size:14}),` ready`,D.length?` · ${D.length}`:``]}),(0,J.jsxs)(`button`,{className:`seg ${f===`apps`?`on`:``}`,onClick:()=>{p(`apps`),q(`action:apps.pane.apps`)},children:[(0,J.jsx)(pl,{size:14}),` apps`,x.length?` · ${x.length}`:``]}),(0,J.jsxs)(`button`,{className:`seg ${f===`setup`?`on`:``}`,onClick:()=>{p(`setup`),q(`action:apps.pane.setup`)},children:[(0,J.jsx)(Wo,{size:14}),` setup`]}),(0,J.jsxs)(`button`,{className:`seg ${f===`log`?`on`:``}`,onClick:()=>{p(`log`),y({}),q(`action:apps.pane.log`)},children:[(0,J.jsx)(Xs,{size:14}),` installed`,u.doc.total?` · ${u.doc.total}`:``]})]}),(0,J.jsx)(`div`,{className:`sheet-scroll`,children:f===`log`?(0,J.jsx)(_ue,{log:u,cut:v,onCut:y,naming:m,draft:g,onNaming:h,onDraft:_}):f===`setup`?i===null?(0,J.jsx)(Z,{children:`Asking this phone what it will allow…`}):(0,J.jsx)(pue,{rows:x,caps:b,allow:c,log:u.doc.entries,me:lf(),onFlip:k,onOpenDownloads:t}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(Z,{children:[i===null?`Asking this phone what it will allow…`:Gle(x,i),i!==null&&Dk()&&!i.canInstall&&(0,J.jsxs)(J.Fragment,{children:[` `,(0,J.jsxs)(Y,{title:`open the phone's install-unknown-apps setting`,onClick:()=>{q(`action:apps.settings`),Ak().catch(()=>K(`this phone has no screen for that switch`))},children:[(0,J.jsx)(Aa,{size:14}),` allow it`]})]})]}),i?.supported&&!lk(i)&&(0,J.jsxs)(Z,{className:`dim`,children:[(0,J.jsxs)(Y,{onClick:()=>{T(e=>!e),q(`action:apps.rules.quiet`)},children:[(0,J.jsx)(Wo,{size:14}),` `,w?`hide`:`when`,` a build installs without asking`]}),w&&(0,J.jsx)(`ol`,{className:`quiet-rules`,children:Yle.map(e=>(0,J.jsx)(`li`,{children:e},e))})]}),i?.supported&&!lk(i)&&o!==void 0&&(0,J.jsxs)(JS,{children:[o!==null&&(0,J.jsxs)(Y,{className:o?`active`:``,onClick:()=>{let e=!o;q(`action:apps.cleanup`),$le(e).then(()=>{s(e),K(e?`an installed build's APK will now be deleted from this phone`:`installed builds keep their APK on this phone`)}).catch(e=>K(e instanceof Error?e.message:`could not change it`))},children:[(0,J.jsx)(ws,{size:14}),` `,Qle(o)]}),(0,J.jsx)(X,{as:`span`,children:Zle(o)})]}),(0,J.jsxs)(Z,{className:`dim`,children:[`Which repo sends builds to this phone at all is the auto-download rule, per repo.`,` `,(0,J.jsx)(Y,{onClick:()=>{q(`action:apps.rules`),t()},children:`downloads`})]}),f===`ready`&&x.length>0&&(0,J.jsxs)(Z,{children:[D.length,` of `,x.length,` app`,x.length===1?``:`s`,` · a build here that has not gone on, newest first — the same ones the phone notified you about, swiped away or put off included`,` `,(0,J.jsxs)(Y,{onClick:()=>p(`apps`),children:[(0,J.jsx)(B,{size:14}),` show all`]})]}),(0,J.jsxs)(`div`,{className:`list`,children:[f===`ready`&&x.length>0&&D.length===0&&(0,J.jsx)($,{children:`Every build on this phone is installed. A new one lands here, and in a notification, when it arrives.`}),x.length===0&&(0,J.jsx)($,{children:`No app here yet. Download a build — an APK a repo drops in its outbox — and it gets a row, with the switch that decides whether the next one installs by itself.`}),O.map(e=>(0,J.jsx)(gue,{row:e,caps:b,ownerNote:lk(b)?null:Jle(e.label,Ck(e.pkg,S)),onFlip:()=>k(e.pkg),logged:u.doc.entries.filter(t=>t.pkg===e.pkg).length,onOpenLog:()=>{p(`log`),y({pkg:e.pkg}),q(`action:apps.rowlog`)}},e.pkg))]})]})})]})}function gue({row:e,caps:t,ownerNote:n,onFlip:r,logged:i,onOpenLog:a}){let o=qle(e,t),s=Kle(e),c=Ule(e,Date.now(),Rp),l=lk(t);return(0,J.jsxs)(`div`,{className:`row-wrap pull-row`,children:[(0,J.jsxs)(Xw,{as:`button`,kind:`grow`,title:e.pkg,onClick:l?void 0:r,children:[(0,J.jsxs)(Zw,{children:[e.allowed?(0,J.jsx)(Va,{size:12}):(0,J.jsx)(Tl,{size:12}),` `,e.label]}),(0,J.jsxs)(Q,{className:`mono`,children:[e.pkg,e.version?` · ${e.version}`:``]}),(0,J.jsx)(Q,{children:e.repo?`from ${e.repo}`:`no repo recorded for it on this phone or in the log`}),(0,J.jsx)(Q,{children:e.note}),n&&(0,J.jsx)(Q,{className:`warn`,children:n}),s&&(0,J.jsx)(Q,{className:e.install===`failed`?`warn`:`dim`,children:s}),c&&(0,J.jsx)(Q,{className:`dim`,children:c})]}),(0,J.jsxs)(`div`,{className:`row-acts pull-acts`,children:[o&&(0,J.jsxs)(Y,{variant:`primary`,title:o.label,onClick:()=>{q(`action:apps.install`),Mk(o.id).catch(e=>K(e instanceof Error?e.message:`could not start the install`))},children:[e.install===`failed`?(0,J.jsx)(xc,{size:16}):(0,J.jsx)(Tl,{size:16}),e.install===`failed`?`retry install`:`install ${e.version||`this build`}`]}),!l&&(0,J.jsxs)(Y,{className:e.allowed?`active`:``,title:e.allowed?`stop installing ${e.label} by itself`:`always install ${e.label}`,onClick:r,children:[(0,J.jsx)(Va,{size:16}),` auto-install: `,e.allowed?`on`:`off`]}),i>0&&(0,J.jsxs)(Y,{title:`everything the log holds about ${e.label}, on every phone`,onClick:a,children:[(0,J.jsx)(Xs,{size:16}),` `,i,` logged`]})]})]})}function _ue({log:e,cut:t,onCut:n,naming:r,draft:i,onNaming:a,onDraft:o}){let{doc:s,toldAt:c,live:l}=e,u=lf(),d=Ri(s.entries,t),f=!!(t.pkg||t.deviceId),p=t.pkg?s.entries.find(e=>e.pkg===t.pkg)?.label||t.pkg:M(s.devices.find(e=>e.id===t.deviceId)??{id:t.deviceId??``}),m=()=>{rue(i),a(!1),K(`this phone is named`)};return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(Z,{children:[c===void 0?`The desktop keeps this log, and has not told this phone yet.`:le(s),!l&&(0,J.jsxs)(J.Fragment,{children:[` `,(0,J.jsxs)(`span`,{className:`warn`,children:[(0,J.jsx)(fo,{size:12}),` `,c===void 0?` no connection to the desktop.`:` the desktop is not reachable — this is what it said ${Vp(c)}.`]})]})]}),(0,J.jsx)(JS,{children:r?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`input`,{className:`search`,value:i,autoFocus:!0,placeholder:`what to call this phone`,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&m()}}),(0,J.jsx)(Y,{onClick:m,children:`save`}),(0,J.jsxs)(Y,{onClick:()=>{o(Hk()),a(!1)},children:[(0,J.jsx)(B,{size:14}),` cancel`]})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(Y,{onClick:()=>{o(Hk()),a(!0),q(`action:apps.name`)},children:[(0,J.jsx)(Mo,{size:14}),` name this phone`]}),(0,J.jsxs)(X,{as:`span`,children:[`This phone reports as `,(0,J.jsx)(`span`,{className:`mono`,children:Hk()||M({id:u})}),`. A name makes the rows below readable when there is more than one device.`]})]})}),s.devices.length>1&&(0,J.jsx)(JS,{children:s.devices.map(e=>(0,J.jsxs)(Y,{className:t.deviceId===e.id?`active`:``,title:e.failures?`${e.installs} installed, ${e.failures} failed on ${M(e)}`:`only what installed on ${M(e)}`,onClick:()=>n(t.deviceId===e.id?{}:{deviceId:e.id}),children:[(0,J.jsx)(Ra,{size:14}),` `,M(e),e.id===u?` (this phone)`:``,` · `,e.installs+e.failures]},e.id))}),f&&(0,J.jsxs)(Z,{children:[d.length,` of `,s.entries.length,` · `,p,` `,(0,J.jsxs)(Y,{onClick:()=>n({}),children:[(0,J.jsx)(B,{size:14}),` show all`]})]}),(0,J.jsxs)(`div`,{className:`list`,children:[d.length===0&&(0,J.jsx)($,{children:f?`Nothing under this filter yet.`:c===void 0?`The desktop has not told this phone what it holds. It sends the log the moment the link is up.`:`No install has been reported yet. A build that installs itself on any phone paired with this desktop is logged here.`}),d.map(e=>(0,J.jsx)(vue,{entry:e,mine:u},e.key))]})]})}function vue({entry:e,mine:t}){return(0,J.jsx)(Xw,{kind:`wrap`,children:(0,J.jsxs)(Xw,{kind:`grow`,title:e.file?`${e.file}${e.repo?` · ${e.repo}`:``}`:void 0,children:[(0,J.jsxs)(Zw,{children:[e.outcome===`installed`?(0,J.jsx)(Va,{size:12}):(0,J.jsx)(B,{size:12}),` `,At(e)]}),(0,J.jsx)(Q,{className:`mono`,children:e.pkg}),(0,J.jsx)(Q,{className:e.outcome===`failed`?`warn`:void 0,children:ree(e,Vp)}),(e.repo||e.file)&&(0,J.jsxs)(Q,{children:[e.file??``,e.repo&&e.file?` · `:``,e.repo?`from ${e.repo}`:``,e.deviceId===t?` · this phone`:``]})]})})}function yue(){let e=Dh();return(0,J.jsx)(hue,{onClose:()=>e.nav.close(`apps`),onOpenDownloads:()=>e.nav.open(`pull`)})}function $k(e){let[t,n]=(0,V.useState)(()=>Date.now());return(0,V.useEffect)(()=>{if(!e)return;let t=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(t)},[e]),t}var eA=e=>e?new Date(e).toLocaleString():``;function bue(e){let t=Math.floor((Date.now()-e)/6e4);return t<0||t>=1440?``:t<1?` · just now`:t<60?` · ${t}m ago`:` · ${Math.floor(t/60)}h ago`}function xue(e){if(!e)return``;let t=new Date(e),n=t.getFullYear()===new Date().getFullYear();return t.toLocaleString(void 0,{year:n?void 0:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}var tA=e=>e>=1e6?`${(e/1e6).toFixed(1)} MB/s`:e>=1e3?`${Math.round(e/1e3)} KB/s`:`${Math.round(e)} B/s`;function Sue(e){return!isFinite(e)||e<=0?``:e<60?`${Math.round(e)}s`:e<3600?`${Math.round(e/60)}m`:`${(e/3600).toFixed(1)}h`}var Cue=[16777216,67108864,268435456,1073741824,0],wue=e=>e===0?`no cap`:yp(e),Tue=[{label:`builds`,patterns:[`*.apk`,`*.aab`,`*.ipa`,`*.iq`,`*.prg`]},{label:`archives`,patterns:[`*.zip`,`*.tgz`,`*.tar`,`*.gz`]},{label:`reports`,patterns:[`*.md`,`*.pdf`,`*.csv`]},{label:`images`,patterns:[`*.png`,`*.jpg`,`*.jpeg`,`*.webp`]}];function Eue({repos:e,configs:t,onLoadConfig:n,onSaveConfig:r,onDismiss:i,onOpenApps:a,rulesFor:o,onClose:s,online:c=!0}){let[l,u]=(0,V.useState)([]),[d,f]=(0,V.useState)(PD()),[p,m]=(0,V.useState)(Mce()),[h,g]=(0,V.useState)(o||e.find(e=>e.isPrimary)?.worktreePath||e[0]?.worktreePath||``),[_,v]=(0,V.useState)(``),[y,b]=(0,V.useState)(o?`rules`:`files`),[x,S]=(0,V.useState)(ck),[C,w]=(0,V.useState)(()=>Nk());(0,V.useEffect)(()=>{let e=!0;return Ok().then(t=>{e&&S(t.caps)}),()=>{e=!1}},[]),(0,V.useEffect)(()=>rO.subscribe(u),[]),(0,V.useEffect)(()=>{rO.verifyAllSaved()},[]),(0,V.useEffect)(()=>{h&&n(h)},[h]);let T=t.get(h)??Hee,E=e=>r(h,{...T,...e}),D=l.filter(e=>e.state!==`done`||e.evicted),O=l.filter(e=>e.state===`done`&&!e.evicted).sort((e,t)=>(t.item.mtime||t.item.ts)-(e.item.mtime||e.item.ts));$k(D.length>0&&y===`files`);let k=rO.whyIdle(),A=D.filter(e=>e.state===`paused`||e.state===`failed`||e.state===`queued`&&!!e.nextRetryAt),j=D.reduce((e,t)=>e+t.received,0),M=D.reduce((e,t)=>e+(t.item.size||t.received),0),N=Hle(x,C),P=typeof navigator<`u`&&`serviceWorker`in navigator&&`BackgroundFetchManager`in self&&!yu()||ID();return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Qo,{size:16}),` Downloads`]}),onClose:s}),(0,J.jsxs)(`div`,{className:`segmented`,children:[(0,J.jsxs)(`button`,{className:`seg ${y===`files`?`on`:``}`,onClick:()=>{b(`files`),q(`action:pull.pane.files`)},children:[(0,J.jsx)(Qa,{size:14}),` files`,l.length?` · ${l.length}`:``]}),(0,J.jsxs)(`button`,{className:`seg ${y===`rules`?`on`:``}`,"data-hint":`pull.auto`,onClick:()=>{b(`rules`),q(`action:pull.pane.rules`)},children:[(0,J.jsx)(Aa,{size:14}),` rules · auto `,d?`on`:`off`]})]}),(0,J.jsx)(`div`,{className:`sheet-scroll`,children:y===`files`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(Z,{children:[`Files a repo produces download to this phone on their own, resuming where they stopped.`,!c&&` Offline right now — queued files start when the link is back.`]}),N&&(0,J.jsxs)(Z,{children:[N,` `,x.canInstall?(0,J.jsxs)(Y,{title:`which of your apps install themselves`,onClick:()=>{q(`action:pull.apps`),a()},children:[(0,J.jsx)(pl,{size:14}),` apps`]}):Dk()?(0,J.jsxs)(Y,{title:`open the phone's install-unknown-apps setting`,onClick:()=>{q(`action:pull.installSettings`),Ak().catch(()=>K(`this phone has no screen for that switch`))},children:[(0,J.jsx)(Aa,{size:14}),` allow it`]}):null]}),(0,J.jsxs)(`details`,{className:`hint-more`,children:[(0,J.jsx)(`summary`,{children:`how this works`}),(0,J.jsx)(`p`,{children:`A rule per repo decides what is worth fetching; the queue below survives a dropped link, a reload, and the app being killed, and picks up from the byte it stopped at.`}),(0,J.jsx)(`p`,{children:P?`Downloads keep running with the app closed.`:`This browser can't download in the background: transfers run while the app is open and resume when you come back.`})]}),(0,J.jsxs)(`div`,{className:`section`,children:[`Downloading`,D.length>0&&(0,J.jsxs)(`span`,{className:`section-hint`,children:[` `,`· `,D.length,M>0&&` · ${yp(j)} of ${yp(M)}`]}),(0,J.jsxs)(`span`,{className:`head-acts`,children:[A.length>0&&(0,J.jsxs)(`button`,{className:`link-btn`,onClick:()=>{rO.resumeAll(),q(`action:pull.resumeall`)},children:[(0,J.jsx)(xc,{size:12}),` resume all`]}),l.length>0&&(0,J.jsxs)(`button`,{className:`link-btn`,"data-hint":`pull.clearall`,onClick:()=>{q(`action:pull.clearall`);for(let e of l)e.local&&(e.state!==`done`||e.evicted)&&rO.remove(e.item.id);i()},children:[(0,J.jsx)(B,{size:12}),` clear queue`]})]})]}),k&&(0,J.jsx)(Z,{tone:`warn`,children:k}),(0,J.jsxs)(`div`,{className:`list`,children:[D.length===0&&(0,J.jsx)($,{children:`Nothing waiting. Files you tap to download land here, and so do the ones a repo's rule fetches on its own.`}),D.map(t=>(0,J.jsx)(rA,{rec:t,repos:e,onDismiss:i,caps:x,allow:C,onAllow:e=>{let t=gk(C,e);w(t),Pk(t)}},t.item.id))]}),O.length>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`section`,children:[`On this phone `,(0,J.jsxs)(`span`,{className:`section-hint`,children:[`· `,O.length]})]}),(0,J.jsx)(`div`,{className:`list`,children:O.map(t=>(0,J.jsx)(rA,{rec:t,repos:e,onDismiss:i,caps:x,allow:C,onAllow:e=>{let t=gk(C,e);w(t),Pk(t)}},t.item.id))})]})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`section`,children:[`This phone `,(0,J.jsx)(`span`,{className:`section-hint`,children:`· the same on every repo`})]}),(0,J.jsxs)(`div`,{className:`set-group`,children:[(0,J.jsxs)(JS,{children:[(0,J.jsxs)(Y,{className:d?`active`:``,onClick:()=>{let e=!d;nO(e),f(e),q(`action:pull.auto`)},children:[d?(0,J.jsx)(vc,{size:14}):(0,J.jsx)(B,{size:14}),` auto-download: `,d?`on`:`off`]}),(0,J.jsxs)(X,{as:`span`,children:[`The master switch. Off, nothing is fetched without a tap — whatever the per-repo rules below say.`,hu()?``:` It is this browser's own: the ${I.displayName} app keeps a separate one, so with the app on this phone too, off here means each file downloads once — in the app.`]})]}),(0,J.jsxs)(JS,{children:[(0,J.jsxs)(Y,{className:p?`active`:``,onClick:()=>{let e=!p;Nce(e),m(e),q(`action:pull.autosave`)},children:[p?(0,J.jsx)(vc,{size:14}):(0,J.jsx)(B,{size:14}),` save to Downloads: `,p?`automatic`:`on tap`]}),(0,J.jsx)(X,{as:`span`,children:QD()?`Every file that finishes downloading is put in the phone's Downloads by itself. A file already there is left alone — saving it again would only add a copy beside it.`:`In a browser the file is handed to the browser's own downloads, which it may refuse unless a tap asked for it — so here this only covers files you tapped.`})]}),Dk()&&(0,J.jsxs)(JS,{children:[(0,J.jsxs)(Y,{onClick:()=>{q(`action:pull.apps`),a()},children:[(0,J.jsx)(pl,{size:14}),` apps`]}),(0,J.jsxs)(X,{as:`span`,children:[`Which of your apps install themselves when a new build lands here. `,N??``]})]})]}),(0,J.jsxs)(`div`,{className:`section`,children:[`Rules `,(0,J.jsx)(`span`,{className:`section-hint`,children:`· per repo, stored with the project`})]}),(0,J.jsx)(`div`,{className:`form`,children:(0,J.jsx)(`select`,{className:`search`,value:h,onChange:e=>g(e.target.value),children:e.map(e=>(0,J.jsxs)(`option`,{value:e.worktreePath,children:[e.repoName,e.isPrimary?``:` · ${e.branch}`]},e.worktreePath))})}),h&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`set-group`,children:[(0,J.jsxs)(JS,{children:[(0,J.jsxs)(Y,{className:T.enabled?`active`:``,onClick:()=>{E({enabled:!T.enabled}),q(`action:pull.enable`)},children:[T.enabled?(0,J.jsx)(vc,{size:14}):(0,J.jsx)(B,{size:14}),` auto-download: `,T.enabled?`on`:`off`]}),(0,J.jsx)(X,{as:`span`,children:`Off means files from this repo are never fetched on their own — a file you tap to download still is, wherever you tap it.`})]}),(0,J.jsxs)(JS,{children:[(0,J.jsx)(yS,{label:`what auto-download watches`,options:[{key:`outbox`,label:`outbox only`},{key:`repo`,label:`whole repo`}],value:T.scope,onChange:e=>E({scope:e})}),(0,J.jsxs)(X,{as:`span`,children:[`The outbox (`,(0,J.jsx)(`span`,{className:`mono`,children:`.claude/outbox`}),`) is the curated repo→phone drop. Whole-repo catches files an agent wrote anywhere, and is noisier by exactly that much.`]})]}),(0,J.jsxs)(JS,{children:[(0,J.jsxs)(Y,{className:T.builds?`active`:``,onClick:()=>E({builds:!T.builds}),children:[`build outputs: `,T.builds?`on`:`off`]}),(0,J.jsx)(X,{as:`span`,children:`Also queue what a build button produces (the APK), wherever it lands.`})]}),(0,J.jsxs)(JS,{children:[(0,J.jsxs)(Y,{className:T.supersede?`active`:``,"data-hint":`pull.supersede`,onClick:()=>{E({supersede:!T.supersede}),q(`action:pull.supersede`)},children:[`newest only: `,T.supersede?`on`:`off`]}),(0,J.jsx)(X,{as:`span`,children:`When a rebuilt version of a file already in the queue turns up, the older ones are dropped and a download in flight for them is cancelled — five APKs of the same build is 100+ MB spent on four files you don't want. A file already ON the phone is never deleted.`})]}),(0,J.jsxs)(JS,{children:[Cue.map(e=>(0,J.jsx)(Y,{className:T.maxBytes===e?`active`:``,onClick:()=>E({maxBytes:e}),children:wue(e)},e)),(0,J.jsx)(X,{as:`span`,children:`Skip anything bigger. A phone should not silently pull a 2 GB tarball over a metered link.`})]})]}),(0,J.jsxs)(`div`,{className:`section`,children:[`Match `,(0,J.jsx)(`span`,{className:`section-hint`,children:`· empty = every file in the scope`})]}),(0,J.jsxs)(`div`,{className:`list`,children:[T.match.map(e=>(0,J.jsxs)(Xw,{kind:`wrap`,children:[(0,J.jsx)(`span`,{className:`row grow`,children:(0,J.jsx)(Zw,{className:`mono`,children:e})}),(0,J.jsx)(Y,{variant:`danger`,title:`remove pattern`,onClick:()=>E({match:T.match.filter(t=>t!==e)}),children:(0,J.jsx)(ws,{size:16})})]},e)),T.match.length===0&&(0,J.jsx)($,{children:`No patterns — everything in the scope matches.`})]}),(0,J.jsxs)(`div`,{className:`form`,children:[(0,J.jsx)(`input`,{className:`search mono`,placeholder:`Pattern, e.g. *.apk or report-*.md`,value:_,onChange:e=>v(e.target.value),onKeyDown:e=>{e.key===`Enter`&&F()}}),(0,J.jsxs)(JS,{children:[(0,J.jsxs)(Y,{disabled:!_.trim(),onClick:F,children:[(0,J.jsx)(Fo,{size:14}),` add`]}),Tue.map(e=>(0,J.jsx)(Y,{onClick:()=>E({match:nA([...T.match,...e.patterns])}),children:e.label},e.label))]})]})]})]})})]});function F(){let e=_.trim();e&&(E({match:nA([...T.match,e])}),v(``))}}var nA=e=>Array.from(new Set(e));function rA({rec:e,repos:t,onDismiss:n,caps:r,allow:i,onAllow:a}){let{item:o,state:s,received:c,error:l,attempts:u,rate:d,nextRetryAt:f,wireBytes:p,evicted:m,saveError:h}=e,g=$k(s===`downloading`||s===`queued`&&!!f),_=o.repoName||t.find(e=>e.id===o.repoId)?.repoName||``,v=o.size||c,y=v>0?Math.min(100,Math.floor(c/v*100)):0,b=Math.max(0,v-c),x=f&&f>g?Math.ceil((f-g)/1e3):0,S=(s===`downloading`&&e.lastProgressAt?g-e.lastProgressAt:0)>12e3,C=s===`downloading`?S?(0,J.jsx)(fo,{size:12}):(0,J.jsx)($s,{size:12,className:`spin`}):s===`done`?(0,J.jsx)(vc,{size:12}):s===`failed`?(0,J.jsx)(gs,{size:12}):s===`paused`?(0,J.jsx)(io,{size:12}):(0,J.jsx)(Qo,{size:12}),w;w=s===`downloading`?S?`stalled at ${y}% · ${yp(c)} of ${yp(v)} kept · retrying by itself`:`${y}% · ${yp(c)} of ${yp(v)}`+(d?` · ${tA(d)}`:``)+(d&&b>0?` · ${Sue(b/d)} left`:``):s===`paused`?`paused · ${yp(c)} of ${yp(v)} kept · tap to resume`:s===`done`?m&&e.cleanedAt?`installed · ${Tk(e)}`:m?`downloaded before · bytes cleared to save space · tap to fetch again`:VD(e).detail:qD(e)?`the desktop no longer has this file · remove it`:s===`failed`?`stopped at ${y}%${c>0?` (${yp(c)} kept)`:``} · tap to retry`:x?`retrying in ${x}s${c>0?` · resumes at ${yp(c)} (${y}%)`:``}`:c>0?`waiting · ${yp(c)} of ${yp(v)} already here (${y}%)`:`waiting to start`;let T={name:o.name,state:s,evicted:m,pkg:e.pkg,pkgLabel:e.pkgLabel,pkgVersion:e.pkgVersion,install:e.install,installError:e.installError},E=Rle(T,r),D=Ble(T),O=yk(T,r,i),k=Vle(T,r,i),A=v>0&&c>0&&s!==`done`;return(0,J.jsxs)(`div`,{className:`row-wrap pull-row`,children:[(0,J.jsxs)(Xw,{as:`button`,kind:`grow`,title:o.relPath,onClick:()=>{if(s===`done`&&!m){if(HD(e)===`save`){q(`action:pull.save`),hO(o.id);return}q(`action:pull.verify`),rO.verifySaved(o.id)}else q(`action:pull.retry`),rO.retry(o.id)},children:[(0,J.jsxs)(Zw,{children:[C,` `,o.name]}),(0,J.jsxs)(Q,{title:o.mtime?`created ${eA(o.mtime)}${o.ts?` · queued ${eA(o.ts)}`:``}`:void 0,children:[e.local?`you`:`auto`,` · `,_?`${_} · `:``,e.pkgVersion?`${e.pkgLabel||e.pkg||`version`} ${e.pkgVersion} · `:``,yp(v)]}),o.mtime?(0,J.jsxs)(Q,{className:`dim`,children:[`created `,xue(o.mtime),bue(o.mtime)]}):null,(0,J.jsx)(Q,{className:s===`failed`||S||h&&s===`done`?`warn`:void 0,children:w}),A&&(0,J.jsx)(`span`,{className:`pull-bar`,children:(0,J.jsx)(`span`,{className:`pull-bar-fill ${s===`downloading`&&!S?`live`:``}`,style:{width:`${y}%`}})}),l&&s!==`done`&&(0,J.jsxs)(Q,{className:`dim`,children:[l,u>1?` · ${u} tries`:``]}),D&&(0,J.jsx)(Q,{className:e.install===`failed`?`warn`:void 0,children:D}),E.reason&&(0,J.jsx)(Q,{className:`dim`,children:E.reason}),O&&O!==E.reason&&(0,J.jsx)(Q,{className:`dim`,children:O}),s!==`done`&&(p??0)>c+1024&&(0,J.jsxs)(Q,{className:`dim`,children:[yp(p??0),` pulled over the link so far`]})]}),(0,J.jsxs)(`div`,{className:`row-acts pull-acts`,children:[s===`downloading`&&e.engine!==`bgfetch`&&(0,J.jsxs)(Y,{"data-hint":`pull.pause`,title:`pause (keeps what has downloaded)`,onClick:()=>{q(`action:pull.pause`),rO.pause(o.id)},children:[(0,J.jsx)(io,{size:16}),` pause`]}),s===`paused`&&(0,J.jsxs)(Y,{"data-hint":`pull.retry`,title:`resume from where it stopped`,onClick:()=>{q(`action:pull.retry`),rO.retry(o.id)},children:[(0,J.jsx)(La,{size:16}),` resume`]}),(s===`queued`||s===`failed`)&&(0,J.jsxs)(Y,{title:c>0?`resume now`:`download now`,onClick:()=>{q(`action:pull.retry`),rO.retry(o.id)},children:[(0,J.jsx)(xc,{size:16}),` `,c>0?`resume`:`download`]}),E.verb===`install`&&(0,J.jsxs)(Y,{variant:`primary`,title:`install ${o.name} on this phone`,onClick:()=>{q(`action:pull.install`),Mk(o.id).catch(e=>K(e instanceof Error?e.message:`could not start the install`))},children:[e.install===`failed`?(0,J.jsx)(xc,{size:16}):e.install===`installed`?(0,J.jsx)(Va,{size:16}):(0,J.jsx)(Tl,{size:16}),zle(e.install)]}),k&&(0,J.jsxs)(Y,{className:k.on?`active`:``,title:k.label,onClick:()=>{q(`action:pull.installAuto`),a(k.pkg)},children:[(0,J.jsx)(Va,{size:16}),` auto-install: `,k.on?`on`:`off`]}),E.settings&&(0,J.jsxs)(Y,{title:`open the phone's install-unknown-apps setting`,onClick:()=>{q(`action:pull.installSettings`),Ak().catch(()=>K(`this phone has no screen for that switch`))},children:[(0,J.jsx)(Aa,{size:16}),` allow installs`]}),s===`done`&&!m&&HD(e)===`save`&&(0,J.jsxs)(Y,{title:`put it where a file manager can see it`,onClick:()=>{q(`action:pull.save`),hO(o.id)},children:[(0,J.jsx)(Gs,{size:16}),` save to phone`]}),s===`done`&&!m?(0,J.jsxs)(fC,{className:`key danger`,title:`delete the downloaded file from this phone`,confirmTitle:`tap again to delete these bytes`,onConfirm:()=>{rO.remove(o.id),e.local||n(o.id),K(`deleted ${o.name} from this phone`)},children:[(0,J.jsx)(ws,{size:16}),` delete`]}):(0,J.jsxs)(Y,{variant:`danger`,title:`remove from the queue (and delete any bytes already fetched)`,onClick:()=>{rO.remove(o.id),e.local||n(o.id)},children:[(0,J.jsx)(ws,{size:16}),` remove`]})]})]})}function Due({records:e,onOpen:t,onRemove:n}){let r=JD(e,PD()),i=$k(r.length>0);if(!r.length)return null;let a=r.find(e=>e.state===`downloading`),o=r.filter(e=>e.state===`failed`),s=r.filter(e=>e.state===`paused`),c=r.reduce((e,t)=>e+Math.max(0,(t.item.size||0)-t.received),0),l=a?a.item.size||a.received:0,u=a?Math.max(0,l-a.received):0,d=a&&l>0?Math.floor(a.received/l*100):0,f=!!a&&i-(a.lastProgressAt??a.updatedAt)>12e3,p=r.length-+!!a,m=c>0?` · ${yp(c)} left`:``;return(0,J.jsxs)(`div`,{className:`outbox-recover pull-strip ${o.length||f?`failed`:a?`sending`:`queued`}`,children:[a?f?(0,J.jsx)(fo,{size:14}):(0,J.jsx)($s,{size:14,className:`spin`}):o.length?(0,J.jsx)(gs,{size:14}):s.length?(0,J.jsx)(io,{size:14}):(0,J.jsx)(Qo,{size:14}),(0,J.jsx)(`span`,{children:a?`${a.item.name} · ${f?`stalled at ${d}%`:`${d}%`}`+(u>0?` · ${yp(u)} left`:``)+(!f&&a.rate?` · ${tA(a.rate)}`:``)+(p>0?` · +${p} more (${yp(c)})`:``):o.length?o.every(qD)?`${o.length} download${o.length>1?`s`:``} no longer on the desktop`:`${o.length} download${o.length>1?`s`:``} stopped${m}`:s.length===r.length?`${s.length} download${s.length>1?`s`:``} paused${m}`:`${r.length} file${r.length>1?`s`:``} to download${m}`}),!a&&o.length>0&&n&&(o.some(e=>e.received>0)?(0,J.jsxs)(fC,{className:`key`,title:`remove the stopped downloads, and the bytes they kept`,confirmTitle:`tap again to drop them and their kept bytes`,onConfirm:()=>n(o),children:[(0,J.jsx)(B,{size:14}),` remove`]}):(0,J.jsxs)(Y,{title:`remove the stopped downloads from the queue`,onClick:()=>n(o),children:[(0,J.jsx)(B,{size:14}),` remove`]})),(0,J.jsxs)(Y,{onClick:t,children:[(0,J.jsx)(Qa,{size:14}),` Downloads`]})]})}var Oue=()=>typeof navigator<`u`&&/Android/i.test(navigator.userAgent);function kue({records:e}){let[t,n]=(0,V.useState)(()=>z(R.pullBrowserAsk)===`1`);if(!Pse({native:hu(),android:Oue(),auto:PD(),answered:t,records:e}))return null;let r=t=>{if(ua(R.pullBrowserAsk,`1`),n(!0),!t){q(`action:pull.browserask.keep`),K(`Auto-download stays on in this browser. Downloads › rules has the switch.`);return}q(`action:pull.browserask.apponly`);let r=e.filter(e=>!e.local&&e.state===`downloading`);nO(!1);for(let e of r)rO.pause(e.item.id);K(`Auto-download is off in this browser${r.length?` and ${r.length===1?r[0].item.name:`${r.length} downloads`} paused here`:``} — the app fetches them. Downloads › rules turns it back on.`)};return(0,J.jsxs)(`div`,{className:`outbox-recover ask`,children:[(0,J.jsx)(Ra,{size:14}),(0,J.jsxs)(`span`,{children:[`Auto-download in this browser too? If the `,I.displayName,` app is on this phone, it already fetches these — keep both on and every file downloads twice.`]}),(0,J.jsxs)(Y,{onClick:()=>r(!0),title:`turn auto-download off in this browser only — the app keeps fetching`,children:[(0,J.jsx)(Ra,{size:14}),` off — app has it`]}),(0,J.jsxs)(Y,{onClick:()=>r(!1),title:`keep auto-download on in this browser`,children:[(0,J.jsx)(Qa,{size:14}),` keep on — no app`]})]})}var iA=W([]),aA=W(new Map),oA=W(null);function Aue(){return G(iA)}function sA(e,t){aA.set(n=>kh(n,e,t))}function jue(e){oA.set(e),U().nav.open(`pull`)}function Mue(){oA.set(null)}function Nue(){rO.start();let e=rO.subscribe(e=>iA.set(e)),t=()=>U().nav.open(`pull`);return window.addEventListener(dO,t),()=>{e(),window.removeEventListener(dO,t)}}function Pue(){let e=Dh(),t=G(aA),n=G(oA);return(0,J.jsx)(Eue,{repos:e.world.repos,configs:t,online:e.conn.status===`open`,onLoadConfig:t=>e.conn.liveAsk({t:`pull.get`,repoDir:t}),onSaveConfig:(t,n)=>{sA(t,n),e.conn.liveSend({t:`pull.save`,repoDir:t,config:n},`auto-download rule saved`,`no connection — the rule lives on the desktop and was not saved`)},onDismiss:t=>e.conn.liveSend({t:`pull.dismiss`,id:t},`dismissed`),rulesFor:n??void 0,onOpenApps:()=>{e.say.track(`overlay:apps`),e.nav.open(`apps`)},onClose:()=>e.nav.close(`pull`)})}var cA=R.uploadScale,lA=R.upKbps,uA=[720,1080,1600,2560];function dA(){let e=z(cA);if(e===`full`||e===`auto`)return e;let t=Number(e);return uA.includes(t)?t:`auto`}function Fue(e){ua(cA,String(e))}function Iue(e,t){if(e<4e4||t<300)return;let n=e/1024/(t/1e3),r=fA(),i=r?r*.6+n*.4:n;ua(lA,String(Math.round(i)))}function fA(){let e=Number(z(lA));return Number.isFinite(e)&&e>0?e:null}var pA=()=>navigator.connection;function Lue(){let e=fA();if(e!==null){let t=e<200;return{kbps:e,source:`measured`,slow:t,label:`${t?`slow link`:`link`} · ${Math.round(e)} kB/s up`}}let t=pA();if(t?.saveData)return{kbps:null,source:`connection`,slow:!0,label:`data saver on`};let n=t?.effectiveType;return n===`slow-2g`||n===`2g`?{kbps:null,source:`connection`,slow:!0,label:`slow link · ${n}`}:n===`3g`?{kbps:null,source:`connection`,slow:!0,label:`slow link · 3g`}:typeof t?.downlink==`number`&&t.downlink>0&&t.downlink<2?{kbps:null,source:`connection`,slow:!0,label:`slow link · ${t.downlink} Mbps`}:n?{kbps:null,source:`connection`,slow:!1,label:n}:{kbps:null,source:`none`,slow:!1,label:`link unknown`}}function mA(){let e=pA(),t=fA();if(t!==null)return t<100?720:t<400?1080:t<1500?1600:0;if(e?.saveData)return 1080;let n=e?.effectiveType;return n===`slow-2g`||n===`2g`?720:n===`3g`||typeof e?.downlink==`number`&&e.downlink>0&&e.downlink<2?1080:0}function hA(){let e=dA();return e===`full`?{width:0,auto:!1}:e===`auto`?{width:mA(),auto:!0}:{width:e,auto:!1}}var gA=e=>e?`${e}px`:`full size`;function Rue(e,t){if(!t||e<=0)return null;let n=Math.round(e/1024/t);return n<60?`~${Math.max(1,n)}s`:`~${Math.round(n/60)}m`}var zue=/^image\/(png|jpeg|webp|bmp|heic|heif)$/i;async function _A(e,t,n){let r={blob:e,name:t,scaled:!1};if(!n||!zue.test(e.type||``)||e.size<12e4)return r;try{let i=await vA(xA(e),null);if(!i)return r;let a=i.width,o=i.height;if(!a||!o)return r;if(a<=n)return bA(i),r;let s=n/a,c=document.createElement(`canvas`);c.width=Math.max(1,Math.round(a*s)),c.height=Math.max(1,Math.round(o*s));let l=c.getContext(`2d`);if(!l)return bA(i),r;l.imageSmoothingQuality=`high`,l.drawImage(i,0,0,c.width,c.height),bA(i);let u=await yA(c,`image/jpeg`,.82);return!u||u.size>=e.size?r:{blob:u,name:t.replace(/\.[A-Za-z0-9]+$/,``)+`.jpg`,scaled:!0,width:c.width,height:c.height}}catch{return r}}var Bue=8e3;function vA(e,t,n=Bue){return new Promise(r=>{let i=setTimeout(()=>r(t),n);e.then(e=>{clearTimeout(i),r(e)},()=>{clearTimeout(i),r(t)})})}var Vue=2e4;async function yA(e,t=`image/jpeg`,n=.9){let r=await vA(new Promise(r=>e.toBlob(r,t,n)),null,Vue);if(r&&r.size>0)return r;try{let r=e.toDataURL(t,n),i=r.indexOf(`,`);if(!r.startsWith(`data:${t}`)||i<0)return null;let a=atob(r.slice(i+1)),o=new Uint8Array(a.length);for(let e=0;e<a.length;e++)o[e]=a.charCodeAt(e);return o.length?new Blob([o],{type:t}):null}catch{return null}}function bA(e){typeof ImageBitmap<`u`&&e instanceof ImageBitmap&&e.close()}async function xA(e){if(typeof createImageBitmap==`function`)try{return await createImageBitmap(e)}catch{}return await new Promise(t=>{let n=URL.createObjectURL(e),r=new Image;r.onload=()=>{URL.revokeObjectURL(n),t(r)},r.onerror=()=>{URL.revokeObjectURL(n),t(null)},r.src=n})}function SA({onChange:e,compact:t}){let[n,r]=(0,V.useState)(()=>dA()),[i,a]=(0,V.useState)(!1),o=Lue(),s=mA(),c=t=>{Fue(t),r(t),q(`action:upload.scale`),e?.(t),a(!1)},l=[{v:`auto`,label:`auto`},{v:`full`,label:`full`},...uA.slice().reverse().map(e=>({v:e,label:`${e}px`}))],u=n===`auto`?`auto → ${gA(s)} · ${o.label}`:`${o.label}`;return t&&!i?(0,J.jsxs)(`button`,{className:`upscale-line`,onClick:()=>a(!0),"aria-expanded":!1,title:`images are re-encoded to this width before they are uploaded`,children:[(0,J.jsx)(ms,{size:12}),` upload `,n===`auto`?`auto → ${gA(s)}`:gA(n===`full`?0:n),` · `,o.label,` · `,(0,J.jsx)(`span`,{className:`upscale-change`,children:`change`})]}):(0,J.jsxs)(`div`,{className:`upscale`,children:[(0,J.jsxs)(`span`,{className:`upscale-head`,title:`images are re-encoded to this width before they are uploaded`,children:[(0,J.jsx)(ms,{size:12}),` upload size`]}),l.map(e=>(0,J.jsx)(Y,{className:n===e.v?`active`:``,onClick:()=>c(e.v),children:e.label},String(e.v))),(0,J.jsx)(`span`,{className:`upscale-note`,children:u})]})}function Hue(){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(rC,{id:`downloads`,label:`downloads`,icon:Qa,opens:!0,onClick:()=>{q(`overlay:pull`),U().nav.open(`pull`)},note:`Every file this app fetches, plus which files a repo produces get fetched on their own.`,more:(0,J.jsxs)(`p`,{children:[`Wherever the tap came from — the gallery, a build's artifacts, a notification. Transfers resume from where a dropped link left them, so a build finishes even across dead spots`,hu()?`, though in this app they only run while it is open — the browser version keeps them going with the app closed`:`, and in an installed Chrome they keep going with the app closed`,`.`]})}),(0,J.jsx)(iC,{id:`upload-scale`,label:``,note:(0,J.jsxs)(J.Fragment,{children:[`Applies to images going UP (annotator, camera, multi-select). `,(0,J.jsx)(`b`,{children:`auto`}),` picks the width from the measured upload rate.`]}),more:(0,J.jsx)(`p`,{children:`A slow link gets a smaller image instead of a minute of blocked Send. The same picker sits above the annotator's send buttons.`}),children:(0,J.jsx)(SA,{})})]})}function Uue(e){let t=e.filter(e=>e.state!==`done`),n=t.reduce((e,t)=>e+t.received,0),r=t.reduce((e,t)=>e+(t.item.size||t.received),0);return{active:t.length,onPhone:e.filter(e=>e.state===`done`&&!e.evicted).length,stuck:t.some(e=>e.state===`failed`||e.state===`paused`),pct:r>0?Math.min(100,Math.floor(n/r*100)):0}}var Wue={id:`pull`,sheets:[{id:`pull`,persisted:!0,render:()=>(0,V.createElement)(Pue),onLeave:Mue},{id:`apps`,persisted:!0,render:()=>(0,V.createElement)(yue)}],messages:{"pull.list":e=>rO.sync(e.items),"pull.new":e=>rO.add(e.item),"pull.config":e=>sA(e.repoDir,e.config)},settings:[{group:`offline`,order:10,render:()=>(0,V.createElement)(Hue)}],boot:Nue};function Gue(e,t){return{when:e?.when??t??{kind:`now`},parkedAt:e?.parkedAt??null}}var CA=`send.compose`;function Kue(e,t){return t!==`refused`||e.padId===void 0&&e.ackId===void 0?e:{...e,padId:void 0,ackId:void 0}}var wA=(()=>{try{return Intl.DateTimeFormat().resolvedOptions().timeZone||``}catch{return``}})(),que=e=>new Date(e-new Date(e).getTimezoneOffset()*6e4).toISOString().slice(0,16);function TA(e,t,n=0){let r=new Date;return r.setDate(r.getDate()+n),r.setHours(e,t,0,0),r.getTime()}function Jue(){let e=Date.now(),t=TA(20,0),n=t<=e,r=(()=>{let e=new Date;return e.setDate(e.getDate()+((8-e.getDay())%7||7)),e.setHours(9,0,0,0),e.getTime()})();return[{key:`1h`,label:`in 1h`,at:e+36e5},{key:`3h`,label:`in 3h`,at:e+108e5},{key:`eve`,label:n?`tomorrow 20:00`:`tonight 20:00`,at:n?TA(20,0,1):t},{key:`tom`,label:`tomorrow 09:00`,at:TA(9,0,1)},{key:`mon`,label:`Mon 09:00`,at:r}]}var EA=[0,30,60,120,180,360],Yue=[10,25,50,75];function DA(e){let t=typeof e==`string`?Number(e.trim()):typeof e==`number`?e:NaN;if(!Number.isFinite(t))return null;let n=Math.round(t);return n>=1&&n<=100?n:null}function Xue(e,t){let n=new Set(Yue);for(let r of[e,t]){let e=DA(r);e!=null&&n.add(e)}return[...n].sort((e,t)=>e-t)}function Zue(e){let t=e.trim();if(!t)return`Type a percentage — 1 to 100 — or pick one above.`;if(DA(t)!=null)return null;let n=Number(t);return Number.isFinite(n)?Math.round(n)===0?`0% left is met by every meter, which is what no condition already says — tap that instead.`:`${t}% is outside 1–100: a window reads 100% at its reset and 0% when it is spent.`:`“${t}” is not a number. 1 to 100.`}var Que=[{min:0,label:`skip it`},{min:120,label:`up to 2h late`},{min:720,label:`up to 12h late`},{min:4320,label:`up to 3 days late`}],OA=e=>({kind:`at`,rule:{kind:`once`,at:Date.now()+e,offsetMin:0},graceMin:120}),$ue=()=>({kind:`at`,rule:{kind:`window`,window:`session`,edge:`before`,offsetMin:-60,oneShot:!0},graceMin:120});function kA(e){if(e<60)return`${e}m`;let t=Math.floor(e/60),n=e%60;return n?`${t}h${n}m`:`${t}h`}function AA(e){let t=typeof e==`number`?e:typeof e==`string`?jA(e):NaN;if(!Number.isFinite(t))return null;let n=Math.round(t);return n>=1&&n<=1440?n:null}function jA(e){let t=e.trim().toLowerCase().replace(/\s+/g,``),n=/^(?:(\d+(?:\.\d+)?)h)?(?:(\d+(?:\.\d+)?)m?)?$/.exec(t);return!t||!n||n[1]==null&&n[2]==null?NaN:Number(n[1]??0)*60+Number(n[2]??0)}function ede(e,t){let n=new Set(EA.filter(e=>e>0));for(let r of[e,t]){let e=AA(r);e!=null&&n.add(e)}return[...n].sort((e,t)=>e-t)}function tde(e){let t=e.trim();if(!t)return`Type a lead — 45m, 4h, 1h30 — or pick one above.`;if(AA(t)!=null)return null;if(t.startsWith(`-`))return`Type how long before, without a minus — the segment above already says before.`;let n=jA(t);return Number.isFinite(n)?Math.round(n)===0?`0 before the reset is the reset itself — that is right after it resets, above.`:`Up to 24h before: the host keeps a lead within a day of the reset.`:`“${t}” is not a duration. Try 45m, 4h or 1h30.`}var MA=e=>e.kind===`repo`||e.kind===`repos`?e.launch:void 0;function NA(e,t){if(e.kind!==`repo`&&e.kind!==`repos`)return e;let{launch:n,...r}=e;return t?{...r,launch:t}:r}var nde=e=>NA(e,null);function PA(e){return!e||!e.model&&!e.effort&&!e.backend?`new-session defaults`:`${e.backend&&e.backend!==`claude`?`${e.backend} · `:``}${e.model||`the default model`}${e.effort?` · ${e.effort}`:``}`}var FA=e=>e&&(e.model||e.effort||e.backend)?`, ${PA(e)}`:``;function IA(e,t){return e.kind===`repo`?t.kind!==`now`:e.kind===`repos`&&t.kind!==`at`}function rde(e,t){return(e.kind===`repo`||e.kind===`repos`)&&e.flagWhenDone===!0&&IA(e,t)?!0:void 0}var LA=e=>e.kind===`repo`||e.kind===`repos`?e.budget:void 0;function RA(e,t){if(e.kind!==`repo`&&e.kind!==`repos`)return e;let{budget:n,...r}=e;return t?{...r,budget:t}:r}function ide(e,t,n){let r=(e.kind===`repo`||e.kind===`repos`)&&e.flagWhenDone&&(!n||IA(e,n))?`, flagged when done`:``;switch(e.kind){case`session`:return t.sessionTitle(e.sessionId);case`repo`:return`${t.repoName(e.cwd)} · a new session${e.resume?`, continued`:``}`+(e.closeWhenDone===!0?`, closes when done`:e.closeWhenDone===!1?`, kept open`:``)+r+FA(e.launch)+(e.budget?`, budget ${Yr(e.budget)}`:``);case`repos`:return(e.dirs.length===1?t.repoName(e.dirs[0]):`${e.dirs.length} repos`)+r+FA(e.launch)+(e.budget?`, budget ${Yr(e.budget)}`:``);case`shell`:return`${t.buildName(e.cwd,e.buildId)} · ${t.repoName(e.cwd)}`}}function ade(e,t,n){let r=MA(e.target),i=ode(e,t,n)+(FA(r)?` · ${PA(r)}`:``);return(e.target.kind===`repo`||e.target.kind===`repos`)&&e.target.budget?`${i} · budget ${Yr(e.target.budget)}`:i}function ode(e,t,n){if(e.when.kind===`at`)return n==null?e.when.rule.kind===`window`?`Save for ${An(e.when.rule)}`:`pick a time it can still reach`:`Save for ${Pr(n)}`;if(e.when.kind===`after`){let n=ti(e.when.title,e.when.onlyIfOk);switch(e.target.kind){case`session`:return`Send to ${t.sessionTitle(e.target.sessionId)} ${n}`;case`repo`:return`Queue for ${t.repoName(e.target.cwd)} · a new session ${n}`;case`repos`:{let r=e.target.dirs.length;return`Fan out to ${r===1?t.repoName(e.target.dirs[0]):`${r} repos`} ${n}`}case`shell`:return`${t.buildName(e.target.cwd,e.target.buildId)} cannot wait for another item`}}let r=e.when.kind===`idle`;switch(e.target.kind){case`session`:return r?`Send to ${t.sessionTitle(e.target.sessionId)} when it's free`:`Send to ${t.sessionTitle(e.target.sessionId)}`;case`repo`:return r?`Queue for ${t.repoName(e.target.cwd)} · a new session when this repo is free`:`Start in ${t.repoName(e.target.cwd)}`;case`repos`:{let n=e.target.dirs.length,r=n===1?t.repoName(e.target.dirs[0]):`${n} repos`;return e.sequential?`Queue in ${r}`:`Fan out to ${r}`}case`shell`:return r?`Queue ${t.buildName(e.target.cwd,e.target.buildId)}`:`Run ${t.buildName(e.target.cwd,e.target.buildId)}`}}function sde(e){return/^queue\b/i.test(e)?e:`Queue · ${e}`}var zA=`those words are running now — changing their when would describe a run that never happened, and posting them again would run them twice`,cde=`this row is one repo's work — send it to several repos and it would be a second copy beside it, so drop its clock first`,lde=`this row runs a prompt — a build is a different thing, so post it as its own and delete this one`;function BA(e,t){return e.when.kind===`at`?e.target.kind===`session`?!t||t.state===`done`||t.state===`canceled`?{kind:`post`}:t.state===`starting`||t.state===`running`?{kind:`refuse`,why:zA}:{kind:`patch`}:{kind:`upsert`}:!t||t.state===`done`||t.state===`canceled`?{kind:`post`}:t.state===`starting`||t.state===`running`?{kind:`refuse`,why:zA}:e.target.kind===`repos`?{kind:`refuse`,why:cde}:e.target.kind===`shell`?{kind:`refuse`,why:lde}:{kind:`patch`}}function ude(e){return e.kind===`now`?`re-timed — the same row, and it goes as soon as the desktop can take it`:e.kind===`idle`?`re-timed — the same row, waiting its turn instead of waiting for its clock`:e.kind===`after`?`re-timed — the same row, and it goes ${ti(e.title,e.onlyIfOk)}`:`re-timed — the same row`}var dde=`no connection — this row's clock lives on the desktop and nothing here changed. Its words are still in the box.`,fde=`write the prompt first`;function pde(e,t,n){let r=e.prompts.map(e=>e.trim()).filter(Boolean);if(e.target.kind!==`shell`&&!r.length)return fde;if(e.target.kind===`repos`&&!e.target.dirs.length)return`pick at least one repo`;if(e.target.kind===`repo`&&!e.target.cwd)return`pick the repo it runs in`;if(e.target.kind===`session`&&!e.target.sessionId)return`pick where it goes`;if(e.when.kind===`at`&&t==null&&e.when.rule.kind===`once`)return`the time it resolves to has already passed`;if(e.when.kind===`at`&&e.target.kind===`shell`)return`a build cannot be scheduled — the clock only fires prompts`;if(e.when.kind===`at`&&e.target.kind===`session`&&!e.target.cwd)return`this session has no repo on it — the clock has nowhere to reopen its conversation`;if(e.when.kind===`after`&&!e.when.id)return`pick the item it waits for`;if(e.when.kind===`after`&&e.target.kind===`shell`)return`a build cannot wait for another item — a chain only queues prompts`;if(e.when.kind===`after`&&e.target.kind===`repos`&&r.length>1)return`a sweep is one prompt — chain a single repo, or send one turn`;let i=BA(e,n);return i.kind===`refuse`?i.why:null}var mde=216e5,hde=e=>e?`If that item fails, this one fails too and says so — it is never left waiting for something that cannot happen twice.`:`It runs either way — “run the tests, then tell me what happened” wants to run when they fail. Tick it to run only after a success.`;function gde(e,t,n){let r=e=>e.state===`running`||e.state===`starting`?0:e.state===`queued`||e.state===`blocked`?1:2;return e.filter(e=>n&&e.id===n||e.trigger.kind===`at`&&ir(e.trigger.rule)?!1:r(e)<2||e.state!==`canceled`&&t-(e.settledAt??e.createdAt)<=mde).sort((e,t)=>r(e)-r(t)||(r(e)===2?(t.settledAt??t.createdAt)-(e.settledAt??e.createdAt):(e.order??0)-(t.order??0)||e.createdAt-t.createdAt))}function VA(e,t,n){return t.kind!==`at`||e.kind!==`session`||!e.cwd?null:`This goes to ${n}. A session lasts as long as its process, so if that one has gone when the clock comes round, the desktop reopens the conversation it was in and sends it there.`}var HA=(e,t)=>e.kind===`at`?Si(e.rule,Date.now(),t):null;function _de(e){return e.kind===`repos`?{off:`all at once — a fresh session in each repo`,on:`one at a time — it waits in each repo's backlog and opens its own session there`}:e.kind===`repo`?{off:`start it straight away, alongside anything else queued for this repo`,on:`wait for this repo's other queued sessions to finish first`}:null}var UA={session:`the session window`,weekly:`the weekly window`},vde={session:`checks the session meter`,weekly:`checks the weekly meter`},WA=e=>e.window===`weekly`?`weekly`:`session`,GA=e=>e.guardWindow??WA(e);function yde(e){let t=WA(e),n=GA(e),r=t===`weekly`?`session`:`weekly`,i=e.minPctLeft;if(e.edge===`after`&&n===t)return`A window that has just reset is empty by definition, so there is nothing to ask about ${UA[t]} at the instant this fires — written like this the condition is dropped and the rule runs every time. Point it at ${UA[r]}, or set it back to no condition.`;let a=e.oneShot===!0?` It stays armed for the next reset, and the next, until one meets the condition — then it runs once.`:``;return n===t?`If less than ${i}% of ${UA[t]} is left when it fires, nothing runs and you get a notification saying it was skipped.${a} A meter the host cannot read counts as not met — the condition exists to stop work, so an unreadable one stops it too.`:`It waits for ${UA[t]} to reset, then asks about ${UA[n]}: unless at least ${i}% of that one is left, nothing runs and you get a notification saying it was skipped.${a}`}function bde(e){let t=e.hours;if(!t)return`Any hour. Set a window and the rule still becomes due when the anchor above says — it waits for the window to open, and how late it counts as is measured from that opening, not from the anchor.`;if(t.from===t.to)return`Both ends name the same minute, which is a window with no width. It is dropped rather than guessed at, so the rule would run at any hour — move one of them.`;let n=`${String(Math.floor(t.from/60)).padStart(2,`0`)}:${String(t.from%60).padStart(2,`0`)}`,r=e.tz?`, ${e.tz}`:``,i=t.from>t.to?` — overnight, through midnight`:``;return`Only ${Qee(e)}${i}${r}. Due outside it, the run waits for ${n} and its lateness is counted from there.`}function xde(e){let t=new Set;for(let n of e.matchAll(/\.claude\/inbox\/[A-Za-z0-9._-]+/g))t.add(n[0]);return[...t]}function Sde(e,t,n){return n===0?`tick the rows to move first`:e.kind===`at`&&t==null&&e.rule.kind===`once`?`the time it resolves to has already passed`:e.kind===`after`&&!e.id?`pick the item it waits for`:null}function Cde(e,t){return`Re-time ${e===1?`it`:`these ${e}`} — ${t}`}var KA=`next in line`;function wde(e,t,n){return!e||n<=0?null:`Held: ${e}${t?` — resumes ${Pr(t)}`:``}. These are queued work, so whatever when you pick, they wait for the budget like the rest of the queue.`}function Tde(e,t,n){switch(e.trigger.kind){case`now`:case`idle`:case`budget`:return!0;case`at`:return typeof e.nextAt==`number`&&e.nextAt<=t;case`after`:{let t=n.get(e.trigger.id);return t?t.state===`done`||!e.trigger.onlyIfOk&&(t.state===`failed`||t.state===`canceled`):!1}default:return!1}}function qA(e,t,n){return e.state!==`queued`&&e.state!==`blocked`||e.blockReason!==`budget`||bn(e,t)?!1:Tde(e,t,n??new Map)}function Ede(e,t,n=Date.now()){let r=new Map(t.map(e=>[e.id,e]));return e.filter(e=>{let t=r.get(e);return!!t&&qA(t,n,r)})}function JA(e){return`let ${e===1?`it`:`these ${e}`} past the budget`}function YA(e,t){return`${e<t?`${e} of the ${t} you ticked are held by the budget; the rest wait on something else. `:``}Lifts the budget for ${e===1?`this row`:`these ${e}`} and nothing else — ${e>1?`rows in the same repo still run one at a time, `:``}wait until free, the session cap and each row's own when all still apply. It lasts until the row starts, or until this budget window resets.`}function Dde(e){return`let ${e} past the budget?`}function Ode(e){return`let ${e===1?`it`:e} past the budget — ${e===1?`it runs`:`they run`} in turn`}function XA(e){return e?`starts it this second in a session of its own — skips the queue: the budget, one at a time and wait until free`:`goes into its session this second — skips the queue: the budget and waiting for that session to be free`}var ZA=`another agent is working in this checkout — this starts a second one beside it`;function QA(e,t,n,r){return e?t.some(t=>t.id!==n&&t.cwd===e&&(t.state===`starting`||t.state===`running`))?!0:(r??[]).some(t=>t.running&&t.turnActive===!0&&t.cwd===e):!1}var kde=`queues an item in its backlog — it runs in turn`,$A=260,ej=e=>{let t=e.trim();return t.length>$A?{title:`${t.slice(0,$A)}…`,clipped:!0}:{title:t,clipped:!1}},tj=e=>`queue:${e}`,nj=e=>`intent:${e}`;function Ade(e){let t=e.filter(e=>e.status===`failed`&&e.mode!==`op`&&e.mode!==`upload`);return t[t.length-1]??null}function jde(e){let t=e.filter(e=>e.status===`failed`);return t.length>0&&t.every(e=>e.mode===`upload`)}function rj(e){return e.mode===`op`&&e.op?.t===`session.create`&&e.op.prompt||e.text}var ij=(e,t,n={})=>{let{note:r,confirm:i,...a}=n;return{id:e,label:t,...a,...r?{note:r}:{},...i?{confirm:i}:{}}},aj=(e,t)=>e?void 0:`no connection — ${t} needs the desktop`,Mde=e=>e.split(`/`).filter(Boolean).pop()||e,Nde=36e5;function oj(e,t,n,r){let i=(e??``).trim();return i?n-t<Nde?i:`recorded when this failed, about a session as it stood then — not something to act on now: “${i}”`:r}var Pde={launch:`launch`,schedule:`schedule`,fanout:`fanout`,build:`build`,assess:`assess`,capture:`build`,work:`backlog`,other:`backlog`},Fde={launch:`prompt`,schedule:`prompt`,fanout:`sweep`,build:`build`,assess:`action`,capture:`build`,work:`prompt`,other:`prompt`};function sj(e){return e.payload.kind===`prompt`&&e.payload.steps.join(`
8
+
9
+ `)||null}function cj(e,t){return e.trigger.kind===`at`&&r({rule:e.trigger.rule,nextAt:e.nextAt,lastOccurrence:e.lastOccurrence},t)}function Ide(e,t){let n=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);return!!e&&!!t&&/\bsession\b/i.test(e)&&RegExp(`(^|[^\\w-])${n}($|[^\\w-])`,`i`).test(e)}function Lde(e,t,n,r){if(e.blockDetail)return e.blockDetail;if(e.blockReason)return Dn(e.blockReason);if(t===`fanout`&&r){let e=r.targets.filter(e=>e.status===`done`).length,t=r.targets.filter(e=>e.status===`failed`).length,n=r.targets.length;return r.finishedAt?t?`${t} of ${n} repos failed${e?`, ${e} finished`:``}`:`all ${n} repos finished`:`${e} of ${n} repos done${t?`, ${t} failed`:``} — still going`}switch(e.state){case`running`:return t===`build`?`running the command now`:t===`capture`?`taking the picture now`:`running in the session now`;case`starting`:return`starting it now`;case`canceled`:return`stopped`;case`failed`:return oj(e.result?.detail,e.settledAt??e.createdAt,n,`it ran and did not finish`);case`done`:if(t===`build`){let t=e.result?.artifacts??[];return t.length&&t.every(e=>e.stale)?`finished — nothing was rebuilt, so these are the newest matching files, not this run's output`:t.length?`finished — ${t.length} ${t.length===1?`file`:`files`} written`:`finished — it wrote no build output`}return t===`schedule`&&cj(e,n)?e.result?.detail??`that instant has passed and this was a one-off — post it again if you still want it`:e.result?.detail??`finished`;default:return e.state===`blocked`?`the desktop is holding this one and did not say why`:t===`schedule`?`armed — it will fire on its own`:`next in line for this repo`}}function lj(e){let t=Pt(e),n=sj(e),r=e.payload.kind===`build`?e.payload:null,i=e.payload.kind===`capture`?e.payload:null;return(t===`schedule`?e.label||Gn(e.title,n??``)||n||e.id:t===`schedule`||t===`build`||t===`assess`||t===`capture`?e.label||e.title||r?.name||i?.name||r?.cmd||n||e.id:e.headline||n||e.label||e.title||e.id).trim()}function Rde(e){if(e.source!==`queue`)return`this one lives on the desktop — run it again from its own row`;if(e.bucket!==`failed`&&e.blockReason!==`sessionGone`)return`this one has not failed — it is still on its way`;if(!e.cwd)return`nothing recorded which repo these words were for`;let t=e.actions.find(e=>e.id===`retry`)??e.actions.find(e=>e.id===`sendNow`);return t?t.disabledReason??null:`this row is not a message that can be sent again`}function uj(e){return e.dismissedAt==null?e.state===`running`||e.state===`starting`?`this one is running — stopping it is “cancel”`:null:`already filed`}function dj(e,t){let n=[],r=[];for(let i of e){let e=t(i);e?r.push({row:i,why:e}):n.push(i)}return{go:n,skip:r}}var fj=3,pj=70;function zde(e,t){let n=[],r=e.length,i=r===1?`row`:`rows`;t.verb===`dismiss`?(n.push(`${r} ${i} filed away as dealt with.`),n.push(`Nothing is deleted: the words, the verdict and the buttons stay on the row, under the “dismissed” chip, and “bring back” undoes this.`)):t.verb===`restore`?n.push(`${r} ${i} back in the list.`):(n.push(`${r} ${r===1?`message goes`:`messages go`} out again as backlog items, each in the repo it was written for.`),n.push(`They run one at a time per repo, each in a new session. Nothing is re-typed and nothing is asked.`));let a=new Map,o=0;for(let t of e)t.cwd?a.set(t.cwd,(a.get(t.cwd)??0)+1):o+=1;let s=[...a.entries()].sort((e,t)=>t[1]-e[1]).map(([e,n])=>`${t.repoName(e)} ${n}`);o&&s.push(`no repo recorded ${o}`),s.length&&n.push(s.join(` · `));for(let t of e.slice(0,fj)){let e=(t.title||``).replace(/\s+/g,` `).trim();n.push(`“${e.length>pj?`${e.slice(0,pj)}…`:e}”`)}return r>fj&&n.push(`…and ${r-fj} more`),t.skipped&&n.push(`${t.skipped} of the selected ${t.skipped===1?`row is`:`rows are`} left alone — each says why on its own row.`),n}function mj(e,t){return e===`failed`?`failed`:e===`done`||e===`canceled`?`done`:e===`running`||e===`starting`?`running`:t===`sessionGone`||t===`gate`||t===`awaitingAnswer`?`needsYou`:t===`notYet`?`scheduled`:`waiting`}function Bde(e,t,n){let{online:r,now:i,deps:a}=t,o=Pt(e),s=Pde[o],c=e.blockReason??null,l=sj(e),u=o===`schedule`&&cj(e,i),d=ej(lj(e)),f=t.sessions?.find(t=>t.id===e.sessionId),p=u?Bt:null,h=e.state===`done`||e.state===`failed`||e.state===`canceled`,g=e.state===`running`||e.state===`starting`,_=e.target.kind===`repo`,v=ra(e)?{note:kde}:_||e.target.kind===`session`?{note:_&&QA(e.cwd,t.intents??[],e.id,t.sessions)?`${XA(_)} — ${ZA}`:XA(_)}:{},y=me(e)?m:``,b=Xt(e)&&e.trigger.kind===`at`?An(e.trigger.rule):``,x=a.repoName(e.cwd),S=e.target.kind===`repo`&&Ide(e.result?.detail,x),C=[e.target.kind===`repos`?`${e.target.dirs.length} ${e.target.dirs.length===1?`repo`:`repos`}`:e.target.kind===`sessions`?`${e.target.sessionIds.length} sessions`:f?.title??(e.target.kind===`repo`?e.resume?`${S?``:`${x} · `}picking up the last conversation`:S?``:`${x} · in a new session`:e.target.kind===`session`?`in ${t.sessions?.find(t=>t.id===e.target.sessionId)?.title??x}`:x),y,b].filter(Boolean).join(` · `),w=e.trigger.kind===`files`?e.trigger.needs:null,T=n?.followUps,E=T?.length?T[T.length-1]:null,D=e.result?.artifacts??[],O=[];if(o===`launch`)O.push(ij(`runNow`,`open it without the files`,{primary:e.state===`blocked`,disabledReason:e.state===`blocked`?aj(r,`opening it`):`it is not waiting any more`}),ij(`cancel`,`call it off`,{danger:!0,disabledReason:h?`it is not waiting any more`:aj(r,`calling it off`)}));else if(o===`schedule`)O.push(ij(`runNow`,`run it now`,{primary:!0,disabledReason:g?`it is firing`:aj(r,`running it`),...v}),ij(`toggle`,e.nextAt==null?`switch it on`:`switch it off`,{disabledReason:p??aj(r,`the switch`)}),ij(`edit`,`edit the schedule`,{disabledReason:aj(r,`an edit`)}),ij(`cancel`,`delete it`,{danger:!0,disabledReason:aj(r,`deleting it`)}));else if(o===`fanout`){let e=n?.targets.find(e=>e.sessionId);O.push(ij(`open`,`open a session from it`,{primary:!0,disabledReason:e?void 0:`no session was opened by this sweep`}),ij(`sendNow`,`send a follow-up to these sessions`,{disabledReason:e?aj(r,`a follow-up`):`no session is left to drive`}))}else o===`build`||o===`capture`?O.push(ij(`download`,D.length===1?`download what it made`:`download (${D.length})`,{primary:D.length>0,disabledReason:D.length?void 0:`it produced no file to fetch`}),ij(`cancel`,`stop it`,{danger:!0,disabledReason:g?aj(r,`stopping it`):`it is not running`}),ij(`runNow`,`run it again`,{disabledReason:aj(r,`a run`)})):O.push(ij(`sendNow`,`run it now`,{primary:e.state===`queued`||e.state===`blocked`,disabledReason:g?`it is running`:e.state===`done`?`it already ran`:aj(r,`running it`),...v}),ij(`check`,`check whether it is already done`,{primary:e.state===`failed`,disabledReason:aj(r,`a check`)}),ij(`edit`,`rewrite it`,{disabledReason:g?`it is running — rewriting it now would change work already in flight`:aj(r,`an edit`)}),ij(`retarget`,`aim it at another session`,{disabledReason:g?`it is running`:aj(r,`a re-aim`)}),ij(`toggle`,e.pinned?`stop firing it on its own`:`fire it on its own`,{disabledReason:h?`it has already run`:aj(r,`the switch`)}),ij(`discard`,`remove it`,{danger:!0,alwaysShown:!0,disabledReason:aj(r,`removing it`)}));e.sessionId&&O.push(ij(`open`,`open the session`,{alwaysShown:!0,disabledReason:f?void 0:`that session is not open any more`}));let k=Lde(e,o,i,n),A=!!e.result?.detail&&k.includes(e.result.detail);return{key:nj(e.id),id:e.id,source:s,kind:Fde[o],state:e.state,bucket:mj(e.state,c),blockReason:c,verdict:k,...d,fullText:l,attachText:o===`build`?null:l,where:C,cwd:e.cwd||null,sessionId:e.sessionId??null,delivery:null,at:e.settledAt??e.startedAt??e.createdAt,createdAt:e.createdAt,dueAt:e.trigger.kind===`at`?e.nextAt??null:e.trigger.kind===`files`&&e.state===`blocked`?e.trigger.deadlineAt:null,asOf:r?null:t.hostSeenAt,progress:w?.length?{done:w.length-(e.missing?.length??0),total:w.length,label:`files`}:n?{done:n.targets.filter(e=>e.status===`done`).length,total:n.targets.length,label:`repos`}:null,targets:n?n.targets.map(e=>({label:e.title||Mde(e.dir),sessionId:e.sessionId,state:Vde[e.status]??`queued`,detail:e.error})):[],lastRun:E?{at:E.at,ok:!0,detail:`follow-up sent to ${E.dirs.length} of them`}:e.result&&!(A&&h&&!e.result.late)?{at:e.result.at,ok:e.result.ok,detail:A?``:e.result.detail,late:e.result.late}:null,attempts:e.attempts??0,actions:O,subject:{source:`intent`,intent:e,run:n}}}var Vde={pending:`queued`,starting:`starting`,running:`running`,done:`done`,failed:`failed`};function Hde(e,t){let n=e.state===`downloading`?`running`:e.state===`done`?`done`:e.state===`failed`?`failed`:e.state===`paused`?`blocked`:`queued`,r=e.item.size?Math.floor(e.received/e.item.size*100):0,i=e.rate?`${hj(Math.round(e.rate))}/s`:null,a=`downloaded${e.item.size?` · ${hj(e.item.size)}`:``}`,o=n===`running`?`${r}% — ${i??`waiting for bytes`}`:n===`failed`?e.error||`the transfer stopped and nothing said why`:n===`blocked`?`paused — it resumes from where it stopped`:n===`done`?e.savedTo?`${a} · ${e.saveVia===`browser`?`handed to`:`saved to`} ${e.savedTo}`:e.evicted?`${a} — the bytes were cleared to make room; fetching again is one tap`:`${a} · on this phone`:r>0?`queued — ${r}% already here from an earlier attempt`:`queued`;return{key:`pull:${e.item.id}`,id:e.item.id,source:`pull`,kind:`download`,state:n,bucket:mj(n,null),blockReason:null,verdict:o,title:e.item.name,clipped:!1,fullText:null,attachText:null,where:e.item.repoName||t.deps.repoName(e.item.repoDir),cwd:e.item.repoDir,sessionId:null,delivery:null,at:e.updatedAt,createdAt:e.item.ts,dueAt:e.nextRetryAt??null,asOf:null,progress:n===`running`||n===`blocked`?{done:e.received,total:e.item.size,label:`bytes`}:null,targets:[],lastRun:null,attempts:e.attempts,actions:[ij(`save`,`save to phone`,{primary:n===`done`&&!e.evicted,disabledReason:n===`done`&&!e.evicted?void 0:`there is nothing downloaded to save yet`}),ij(`retry`,n===`failed`?`try again`:`fetch it now`,{primary:n!==`done`,disabledReason:n===`running`?`it is downloading`:n===`done`&&!e.evicted?`it is already on this phone — save it out instead`:void 0}),ij(`discard`,`drop it`,{danger:!0,alwaysShown:!0})],subject:{source:`pull`,record:e}}}var hj=e=>e>=1e9?`${(e/1e9).toFixed(1)} GB`:e>=1e6?`${(e/1e6).toFixed(1)} MB`:e>=1e3?`${Math.round(e/1e3)} kB`:`${e} B`,Ude=15e4,Wde=new Set([`unconfirmed`]);function gj(e,t){return e.status!==`failed`||e.hostSettled||!e.failState||!Wde.has(e.failState)?!1:t-(e.failedAt??e.sentAt??e.ts)<Ude}function Gde(e){return e===1?`1 message typed — confirming it ran; types it again itself if not`:`${e} messages typed — confirming they ran; types one again itself if not`}var _j=`the desktop is still confirming this one — it may be running, and it re-sends it itself if it never landed`,vj=e=>e.map(e=>({id:e.id,cwd:e.cwd,running:e.running,turnStartedAt:e.turnStartedAt,turnActive:e.turnActive,limitBlocked:e.limit?.blocked,promptKind:e.prompt?.kind,awaitingInput:e.awaitingInput,name:Qr(e)}));function yj(e,t){return mr(e?a(vj(t),[]).get(e):void 0)}var Kde={gate:`gate`,budget:`budget`,sessionBudget:`sessionBudget`,sessionGone:`sessionGone`,serial:`serial`,held:`sessionBusy`,lane:`sessionBusy`,inflight:`sessionBusy`,pendingCreate:`sessionBusy`,backoff:null},qde={held:`held until the agent finishes this turn`,lane:`another message for that session is going out first`,inflight:`a delivery for that session is already in flight`,pendingCreate:`waiting for its session to open`};function Jde(e){switch(e){case`unconfirmed`:return`unconfirmed`;case`unsubmitted`:return`unsubmitted`;case`stale`:return`refused`;case`refused`:return`refused`;default:return`unknown`}}function Yde(e,t){return e.answer?`answer`:e.mode===`upload`?`upload`:e.mode===`op`?t.isCreateOp(e)?`prompt`:`action`:`prompt`}function Xde(e,t){let{deps:n,now:r,online:i}=t,a=Yde(e,n),o=t.queueBlocked?.get(e.ackId),s=(e.mode??`input`)===`input`&&!!t.goneLanes?.has(e.sessionId),c=e.status===`pending`?`starting`:e.status===`failed`?`failed`:`queued`,l=null,u,d=gj(e,r);if(d&&(c=`running`,u=`the desktop is confirming whether it ran — it types it again itself if it never did`),e.status===`queued`){if(!i)l=`offline`;else if(s)l=`sessionGone`;else if(o){if(l=Kde[o],u=qde[o],o===`serial`&&t.sessions&&(u=yj(e.serial,t.sessions)),o===`backoff`){let t=e.retryAt&&e.retryAt>r?e.retryAt-r:null,n=t==null?null:t<6e4?`${Math.max(1,Math.round(t/1e3))}s`:`${Math.round(t/6e4)} min`,i=e.waitReason??`a send just failed`;u=n?`${i} — trying again in ${n}`:`${i} — trying again in a moment`}if(o===`held`){let n=t.sessions?.find(t=>t.id===e.sessionId);n?.limit?.blocked?(l=`limit`,u=void 0):(n?.awaitingInput||n?.prompt&&n.prompt.kind!==`trust`)&&(l=`awaitingAnswer`,u=n.prompt?`the session is waiting on a question — “${(n.prompt.ask||n.prompt.question).slice(0,80)}”`:`the session is showing a dialog it wants an answer to`)}}(l||u)&&(c=`blocked`)}let f=e.failedAt??e.sentAt??e.ts,p=c===`failed`?oj(e.reason,f,r,`it never went — nothing here says why, so treat it as unrun only if the session shows nothing`):c===`starting`?`on its way to the desktop`:l?Dn(l,u):u??`next in line`,m=n.isEditableEntry(e)||e.status===`failed`&&a===`prompt`,h=e.mode===`upload`||e.mode===`op`||!!e.answer,g=e.status===`pending`,_=rj(e),v=a===`upload`?e.upload?.relPath??null:a===`answer`?null:_||null,y=l===`awaitingAnswer`,b=e.status===`failed`?d?_j:e.failState===`unconfirmed`?`it was typed into the session and the desktop could not read the screen back — it may have run. Sending it again could run it twice: open the session and look, or rewrite it to send a fresh copy.`:e.failState===`unsubmitted`?`the words are already sitting in that session's composer — open it and press Return. Sending again would leave two copies.`:e.failState===`stale`?`the desktop refused this one because the question it answers is gone, and it remembers refusing it — a re-send is answered with the same no. Answer the question that is up now.`:e.failState===`refused`?`the desktop answered no and remembers it, so this exact message can only be refused again — rewrite it to send it as a new one.`:void 0:void 0,x=[...y?[ij(`answer`,`answer the question`,{primary:!0})]:[],ij(`sendNow`,e.status===`failed`?`try again`:`send now`,{primary:!y,disabledReason:g?`already on its way`:b??(!i&&e.status!==`failed`?`no connection yet — it goes out when the link is back`:void 0)}),ij(`hold`,e.holdUntilIdle?`send without waiting`:`wait for the agent`,{disabledReason:g?`already on its way`:h?`this one is an action or a file, not text — there is no turn to wait for`:void 0}),ij(`retarget`,`aim it elsewhere`,{disabledReason:g?`already on its way`:e.answer?`an answer names one question box in one session — it cannot go anywhere else`:e.mode===`upload`?`a file goes to the repo inbox its path names`:e.mode===`op`?`this one is an action — its payload already names its own subject`:void 0}),ij(`edit`,`rewrite it`,{primary:!!b,disabledReason:m?void 0:g?`already on its way`:e.answer?`an answer is the option you tapped, not text`:e.mode===`upload`?`a file has no words to rewrite`:`this one is an action, not text`}),ij(`fix`,`fix its files & send`,{disabledReason:e.answer||e.mode===`upload`?`there are no words on this row to rewrite`:void 0}),...e.failState===`unconfirmed`?[ij(`confirmDone`,`save as done`,{disabledReason:d?_j:g?`already on its way`:void 0})]:[],ij(`discard`,`discard`,{danger:!0,alwaysShown:!0,disabledReason:g?`already on its way`:void 0})];e.sessionId&&!e.sessionId.startsWith(`create:`)&&x.push(ij(`open`,`open the session`,{alwaysShown:!0,disabledReason:s?`that session is gone`:void 0}));let S=ej(a===`answer`&&e.answer?`${e.answer.label} — ${e.answer.question}`:_);return{key:tj(e.ackId),id:e.ackId,source:`queue`,kind:a,state:c,bucket:mj(c,l),blockReason:l,verdict:p,...S,fullText:a===`upload`||a===`answer`?null:_,attachText:v,where:n.laneLabel(e),cwd:e.cwd||null,sessionId:e.sessionId.startsWith(`create:`)?null:e.sessionId,delivery:e.status===`failed`?Jde(e.failState):null,at:f,createdAt:e.ts,dueAt:null,asOf:null,progress:null,targets:[],lastRun:null,attempts:e.attempts??0,actions:x,subject:{source:`queue`,entry:e}}}var bj={needsYou:0,failed:1,running:2,waiting:3,scheduled:4,done:5},xj=new Map(Ae.map((e,t)=>[e,t]));function Zde(e,t){let n=bj[e.bucket]-bj[t.bucket];if(n)return n;if(e.bucket===`scheduled`){let n=e.dueAt??2**53-1,r=t.dueAt??2**53-1;if(n!==r)return n-r}if(e.bucket===`waiting`||e.bucket===`needsYou`){let n=e.blockReason?xj.get(e.blockReason)??99:99,r=t.blockReason?xj.get(t.blockReason)??99:99;if(n!==r)return n-r}return t.at-e.at}function Qde(e){let t=[];for(let n of e.outbox??[])t.push(Xde(n,e));let n=e.intents??[],r=new Map;for(let e of Ke(n))r.set(e.id,e);let i=new Set((e.outbox??[]).map(e=>e.ackId));for(let a of n){if(a.archived||a.groupId!=null&&a.groupId!==a.id)continue;let n=a.groupId?r.get(a.groupId)??null:null;if(i.has(a.id)&&(a.state===`queued`||a.state===`blocked`||a.state===`starting`)){let e=t.findIndex(e=>e.subject.source===`queue`&&e.id===a.id);e>=0&&t.splice(e,1)}t.push(Bde(a,e,n))}for(let n of e.pulls??[])t.push(Hde(n,e));let a=e.dismissed;if(a?.size)for(let e of t){let t=a.get(e.key);t!=null&&(e.dismissedAt=t)}let o=e.confirmedDone;if(o?.size)for(let e of t){let t=o.get(e.key);t!=null&&(e.confirmedDoneAt=t,e.bucket=`done`,e.state=`done`,e.blockReason=null,e.verdict=`you marked this done ${new Date(t).toLocaleString()} — the desktop's own check never confirmed it`)}for(let e of t)e.actions.push(ij(`dismiss`,`save for later`,{disabledReason:uj(e)??void 0}));return t.sort(Zde)}var Sj=[{id:`all`,label:`all`},{id:`needsYou`,label:`needs you`},{id:`failed`,label:`failed`},{id:`running`,label:`running`},{id:`waiting`,label:`waiting`},{id:`scheduled`,label:`scheduled`},{id:`done`,label:`done`},{id:`dismissed`,label:`dismissed`}];function $de(e,t){return t===`dismissed`?e.dismissedAt!=null:e.dismissedAt==null?t===`all`||e.bucket===t:!1}function efe(e){let t={all:0,needsYou:0,failed:0,running:0,waiting:0,scheduled:0,done:0,dismissed:0};for(let n of e)n.dismissedAt==null?(t.all+=1,t[n.bucket]+=1):t.dismissed+=1;return t}function tfe(e,t){let n=e.filter(e=>e.dismissedAt==null);if(!t){let e=n.filter(e=>e.blockReason===`offline`).length;if(e)return{text:`${e} ${e===1?`thing is`:`things are`} still on this phone — nothing expires while the link is down`,cut:null}}let r=n.filter(e=>e.bucket===`needsYou`).length;if(r)return{text:`${r} ${r===1?`row needs`:`rows need`} a decision from you`,cut:`needsYou`};let i=n.filter(e=>e.bucket===`failed`).length;return i?{text:`${i} ${i===1?`thing`:`things`} never ran`,cut:`failed`}:null}function Cj(e){if(e.kind===`upload`||e.kind===`download`||e.kind===`build`)return null;let t=(e.fullText??e.title).trim();if(!t)return null;let n=t.toLowerCase().replace(/\s+/g,` `).trim();return n.replace(/[.!?…]+$/u,``).trim()||n}var nfe=new Set(`continue.continue please.please continue.go on.carry on.keep going.done.finished.did it work.any progress.progress.status.update.try again.again.retry.redo.rerun.run it again.ok.okay.k.yes.yep.yeah.sure.no.nope.n.y.thanks.thank you.ty.hi.hello.test.ping.hmm.next.next step.proceed.go.go ahead.stop.wait.fix.fix it.fix this.do it.continue working.and`.split(`.`));function wj(e){let t=Cj(e);return!t||e.clipped||/[\n`/.]/.test(t.slice(1))?!1:nfe.has(t)||/^\/[a-z][\w-]*$/.test(t)?!0:t.split(` `).length===1&&t.length<=3}function rfe(e,t){return t===`ranked`?[...e]:[...e].sort((e,t)=>e.at-t.at)}function ife(e,t,n){let r=new Map;for(let e of t){let t=Cj(e);if(!t)continue;let n=r.get(t);n?n.push(e):r.set(t,[e])}let i=[],a=new Map;for(let t of e){let e=Cj(t),r=n.group&&e?`t:${e}`:t.key,o=a.get(r);if(o){o.rows.push(t),o.oldestAt=Math.min(o.oldestAt,t.at),o.newestAt=Math.max(o.newestAt,t.at),t.cwd&&!o.cwds.includes(t.cwd)&&o.cwds.push(t.cwd);continue}let s={key:r,rows:[t],elsewhere:{done:0,other:0},cwds:t.cwd?[t.cwd]:[],oldestAt:t.at,newestAt:t.at};a.set(r,s),i.push(s)}for(let e of i){let t=Cj(e.rows[0]);if(!t)continue;let n=new Set(e.rows.map(e=>e.key));for(let i of r.get(t)??[])n.has(i.key)||(i.dismissedAt??(i.bucket===`done`?e.elsewhere.done+=1:e.elsewhere.other+=1))}return i}var Tj=e=>!ir(e.rule)&&e.action.kind===`backlog`,afe=e=>e.state===`done`||e.state===`failed`||e.state===`canceled`;function ofe(e,t){return e.archived||e.trigger.kind!==`at`||afe(e)?!1:ur({rule:e.trigger.rule,nextAt:e.nextAt,lastOccurrence:e.lastOccurrence},t)}function Ej(e){return e.archived||e.trigger.kind!==`at`?!1:e.state!==`starting`&&e.state!==`running`&&e.state!==`done`&&e.state!==`canceled`}function Dj(e){let{focus:t,focusIds:n,now:r}=e,i=(e.text??``).trim().toLowerCase(),a=e.intents.filter(e=>Xt(e)&&!e.archived),o=a.filter(e=>ofe(e,r)).sort((e,t)=>(e.nextAt??1/0)-(t.nextAt??1/0)),s=new Set(o.map(e=>e.id)),c=a.filter(e=>!s.has(e.id)&&!e.dismissedAt),l=n?a.filter(e=>n.ids.includes(e.id)):t?o.filter(e=>Qi(e.nextAt,r)===t):o,u=i?l.filter(e=>sfe(e,i)):l,d=[];for(let e of c){let t=d.find(([t])=>t===e.cwd);t?t[1].push(e):d.push([e.cwd,[e]])}let f=t=>e.intents.some(e=>e.id===t.entry.id),p=e.pending.filter(e=>Tj(e.entry)&&!f(e)),m=e.pending.filter(e=>!Tj(e.entry)),h=new Set(m.map(e=>e.entry.id)),g=[...m.map(e=>e.entry),...(e.entries??[]).filter(e=>!h.has(e.id))].sort((e,t)=>(e.nextAt??1/0)-(t.nextAt??1/0)),_=g.filter(e=>ur(e,r)),v=g.filter(e=>!ur(e,r)),y=n?g.filter(e=>n.ids.includes(e.id)):t?_.filter(e=>Qi(e.nextAt,r)===t):_,b=i?y.filter(e=>kj(e,i)):y,x=i?p.filter(e=>kj(e.entry,i)):p,S={soon:0,day:0,twoDay:0,week:0,later:0,unarmed:0,total:0};for(let e of[..._.map(e=>e.nextAt),...o.map(e=>e.nextAt),...p.map(e=>e.entry.nextAt)])S.total++,S[Qi(e,r)]++;return{cards:_,spentCards:v,shownCards:b,pendingCards:m,live:o,gone:c,shown:u,pending:p,shownPending:x,goneByRepo:d,horizon:S,kinds:{rules:_.length,timed:o.length+p.length},standingTotal:S.total,cutTotal:y.length+l.length+p.length,shownTotal:b.length+u.length+x.length}}var Oj=e=>e.split(`/`).filter(Boolean).pop()??``;function sfe(e,t){return`${lj(e)}\n${sj(e)??``}\n${Oj(e.cwd)}`.toLowerCase().includes(t)}function kj(e,t){let n=e.action.text;return`${Gn(e.name,n)??``}\n${n}\n${Aj(e).map(Oj).join(` `)}`.toLowerCase().includes(t)}var Aj=e=>e.action.kind===`fanout`?e.action.dirs:[e.action.repoDir];function cfe(e){let{cuts:t,repoOf:n,now:r}=e,i=new Map,a=(e,t,a)=>{let o=new Set;for(let t of e){let e=t?n(t):null;e&&o.add(e)}for(let e of o){let n=i.get(e);n||(n={ids:[],horizon:{soon:0,day:0,twoDay:0,week:0,later:0,unarmed:0,total:0}},i.set(e,n)),n.ids.push(t),n.horizon.total++,n.horizon[Qi(a??null,r)]++}};for(let e of t.cards)a(Aj(e),e.id,e.nextAt);for(let e of t.live)a([e.cwd],e.id,e.nextAt);for(let e of t.pending)a(Aj(e.entry),e.entry.id,e.entry.nextAt);return i}function lfe(e,t){return`the ${t} on a clock in ${e}`}function jj(e){return e?`schedule deleted — and ${e===1?`the queue row that named it`:`${e} queue rows that named it`}`:`schedule deleted`}var Mj=36e5,Nj=[`hour`,`day`,`week`,`older`],Pj={hour:`past hour`,day:`past 24h`,week:`past week`,older:`older`},ufe=[`running`,`queued`,`failed`,`done`];function Fj(e,t){let n=Math.max(0,t-e);return n<=Mj?`hour`:n<=24*Mj?`day`:n<=168*Mj?`week`:`older`}function Ij(e,t,n){let r=Fj(e,n);if(t===`older`)return r===`older`;let i={hour:0,day:1,week:2,older:3};return i[r]<=i[t]}var dfe=[...n,`none`];function Lj(e){return e.category??`none`}var ffe={bug:ri(`bug`),feature:ri(`feature`),enhancement:ri(`enhancement`),chore:ri(`chore`),none:fr};function pfe(e,t){return t?`show every kind again`:e===`none`?`show only the items nothing has said a kind for — the rows a naming pass is for`:`show only the ${e===`bug`?`bugs`:`${e}s`}`}var Rj=`no connection — the backlog lives on the desktop, so nothing here changed. Adding still queues.`,zj=`no connection — the desktop is holding this one. It stays held; try again when the link is back.`,Bj={status:null,age:null,category:null,ids:null,clock:null},mfe=e=>!!(e.status||e.age||e.category||e.ids||e.clock);function hfe(e,t,n){return!(t.ids&&!t.ids.includes(e.id)||t.status&&e.status!==t.status||t.age&&!Ij(e.createdAt,t.age,n)||t.category&&Lj(e)!==t.category||t.clock&&!e.at)}function gfe(e,t){let n=[];if(e.status&&n.push(e.status),e.category&&n.push(e.category===`none`?`with no kind`:`${e.category===`bug`?`bug`:e.category}s`),e.clock&&n.push(`on a clock`),e.age&&n.push(e.age===`older`?`added over a week ago`:`added in the ${Pj[e.age]}`),e.ids){let e=t?.trim()||`made from these`;return n.length?`${e} · ${n.join(` · `)}`:e}return n.length?`showing ${n.join(` · `)}`:`showing everything`}function Vj(e){return!!e.archived&&e.status!==`running`}function _fe(e,t,n){let r={running:0,queued:0,failed:0,done:0},i={hour:0,day:0,week:0,older:0},a={bug:0,feature:0,enhancement:0,chore:0,none:0},o=0,s={status:0,age:0,category:0,clock:0};for(let c of e){if(t.ids&&!t.ids.includes(c.id))continue;let e=!t.status||c.status===t.status,l=!t.age||Ij(c.createdAt,t.age,n),u=!t.category||Lj(c)===t.category,d=!t.clock||!!c.at;if(l&&u&&d&&(r[c.status]=(r[c.status]??0)+1,s.status++),e&&u&&d){s.age++;for(let e of Nj)Ij(c.createdAt,e,n)&&i[e]++}e&&l&&d&&(a[Lj(c)]++,s.category++),e&&l&&u&&(s.clock++,c.at&&o++)}return{status:r,age:i,category:a,clock:o,pool:s}}function vfe(e,t){let n=(e,t,n,r=!1)=>n||e>0&&(r||e<t);return{status:ufe.filter(r=>n(e.status[r],e.pool.status,t.status===r,r===`failed`||r===`done`)),age:Nj.filter(r=>n(e.age[r],e.pool.age,t.age===r)),category:dfe.filter(r=>n(e.category[r],e.pool.category,t.category===r)),clock:n(e.clock,e.pool.clock,!!t.clock,!0)}}function yfe(e,t){let n=e.fresh+e.aimed;if(n<=0)return null;let r=e.held+e.other,i=r?` The other ${r} here ${r===1?`is`:`are`} not going to start — each row says why.`:``;if(!t)return`auto is off on this desktop, so ${n===1?`this one does not start on its own`:`none of these ${n} start on their own`}. Turn auto back on, or ${n===1?`tap fire on the row to start it now`:`tap fire on a row to start that one now`}.${i}`;let a=n===1?` fire on the row starts it now.`:` fire on a row starts that one now.`,o=e.aimed===0&&n>1?`, in the order you see`:``,s;if(e.aimed===0)s=e.fresh===1?`this one starts when the repo is free, in a session of its own`:`these ${e.fresh} start one at a time in this repo, each in a session of its own${o}`;else if(e.fresh===0)s=e.aimed===1?`this one starts in the session it is aimed at, as soon as that session is free`:`these ${e.aimed} start in their sessions, each as soon as its session is free`;else{let t=e.aimed===1?`1 in the session it is aimed at`:`${e.aimed} in their sessions`;s=`of these ${n}, ${e.fresh} start in a session of their own and ${t}, each as soon as what it waits for is free`}return`auto is on: ${s}.${a}${i}`}function bfe(e,t,n){return`${e} of ${t}${n.ids?`, archived included`:``}`}function xfe(e){return`archive ${e===1?`this one`:`these ${e}`}`}function Sfe(e,t){return`${e===t?`every one of the ${t} rows here is finished`:`${e===1?`one row`:`${e} rows`} of the ${t} shown ${e===1?`is`:`are`} finished and not yet archived — the rest are already archived and are left alone`}. Archiving is not deleting: the words stay, the archived count keeps them, and any one of them can be brought back from its own row.`}function Cfe(e){return e===1?`archived — its words stay, and show archived still lists it`:`${e} archived — their words stay, and show archived still lists them`}function wfe(e){return`assess ${e===1?`this one`:`these ${e}`}`}function Tfe(e,t){return`${e===t?`every one of the ${t} rows here is still open`:`${e===1?`one row`:`${e} rows`} of the ${t} shown ${e===1?`is`:`are`} still open — the rest are finished or running and cannot be judged`}. It still reads the whole repo as evidence — what narrows is which rows it may return a verdict on.`}var Efe=`assess: nothing in this cut is still open — an assessment judges work that is waiting or failed, and these rows are finished or running`;function Dfe(e){return e.filter(e=>!e.archived&&(e.status===`queued`||e.status===`failed`)).map(e=>e.id)}function Ofe(e,t,n){let r=An(e.rule);return e.nextAt!=null&&n===`queued`?`${r} · next ${kr(e.nextAt,t)}`:e.rule.kind===`window`&&n===`queued`?`${r} · waiting for a usage reading`:r}var Hj=e=>e.at?bt(e.at.rule,e.at.graceMin,e.holdForHost):null;function kfe(e){let t=[],n=new Map;for(let r of e){let e=Hj(r);if(!e)continue;let i=n.get(e);i||(i={key:e,at:r.at?.nextAt??null,hold:!!r.holdForHost,items:[]},n.set(e,i),t.push(i)),i.items.push(r)}return t}function Afe(e,t){for(let n of e){let e=n.items.findIndex(e=>e.id===t);if(!(e<0))return n.items.length>1?{idx:e,of:n.items.length}:null}return null}var jfe=[`1st`,`2nd`,`3rd`,`4th`,`5th`,`6th`,`7th`,`8th`,`9th`,`10th`],Mfe=e=>jfe[e-1]??`${e}th`;function Nfe(e){return`${Mfe(e.idx+1)} of ${e.of} on this clock`}function Pfe(e,t){let n=e.items.length,r=e.at==null?`waiting for a usage reading`:`${kr(e.at,t)} · ${new Date(e.at).toLocaleString()}`,i=An(e.items[0].at.rule);return`${n} item${n===1?``:`s`} on one clock — ${i} · ${r}${e.hold?` · held until the desktop is free`:``}`}var Ffe=`moves it among the items waiting on this same clock — the instant does not change, and it never crosses an item on a different clock`;function Ife(e){return`on a clock in ${e}`}function Lfe(e){return`been and gone on a clock in ${e}`}var Uj=`holds until the desktop is free`;function Rfe(e){return e?`${Uj} · survives a dropped clock`:Uj}var Wj=`let past the budget`;function Gj(e){return e?`${Wj} · undo`:Wj}var zfe=`held for the budget again`;function Kj(e){return e===`failed`?`its instant has passed and a one-off cannot be re-armed — drop the clock and it waits its turn, where auto takes it from there`:`drop the clock and it runs in turn instead of at its time — the words and their place in the list stay`}var qj=`clock dropped — it waits its turn like any other item`;function Bfe(e){return e===1?qj:`clocks dropped on ${e} — they wait their turn like any other item`}function Vfe(e){return`drop the clocks on ${e===1?`this one`:`these ${e}`}`}function Hfe(e,t){return`${e===t?`every one of the ${t} rows here carries a clock`:`${e===1?`one row`:`${e} rows`} of the ${t} shown carr${e===1?`ies`:`y`} a clock — the rest have none and are left alone`}. Dropping a clock leaves the words where they are: they wait their turn, auto takes it from there, and any that hold until the desktop is free keep doing so.`}function Jj(e){let t=`it failed, so nothing will pick it up again — put it back in the queue and it runs again `,n=` The failure it had stays on the row. “re-fire” beside it runs it this second instead.`;return e.targetSessionId?`${t}in the session it is aimed at, as soon as that session is free — auto takes it from there. It does not open a session of its own.${n}`:`${t}in a new session of its own when its turn comes, where auto takes it from there.${n}`}function Ufe(){return`it failed, and it is aimed at a session that has closed — nothing re-aims it, so putting it back in the queue would only make it wait for ever instead of stopping. Edit it to pick another session, or take the aim off so it opens a session of its own, and “run it again” comes back.`}var Yj=`put back in the queue — it runs again when its turn comes`;function Wfe(e){return e===1?Yj:`${e} put back in the queue — they run again as their turns come`}function Xj(e,t){return e.status!==`failed`||e.at||e.archived?`none`:e.targetSessionId&&!t.has(e.targetSessionId)?`held-closed`:`offered`}function Zj(e,t){return Xj(e,t)===`offered`}function Gfe(e,t){return e.filter(e=>Zj(e,t)).map(e=>e.id)}function Kfe(e,t){return e.filter(e=>Zj(e,t)&&!!e.targetSessionId).length}function qfe(e){return`run ${e===1?`this one`:`these ${e}`} again`}function Qj(e,t,n=0){return`${e===t?`every one of the ${t} rows here can go back in the queue`:`${e===1?`one row`:`${e} rows`} of the ${t} shown can go back in the queue — the rest carry a clock (they wear “drop the clock”), are aimed at a session that closed, or are set aside, and are left alone`}. ${n===0?`They run again one at a time in this repo, each in a session of its own, as their turns come — auto takes it from there`:n===e?`They run again in the session${e===1?``:`s`} they are aimed at, as ${e===1?`it comes`:`those come`} free — auto takes ${e===1?`it`:`them`} from there`:`${e-n} run again in a session of its own, one at a time in this repo, and ${n} in the session${n===1?``:`s`} ${n===1?`it names`:`they name`}, as those come free — auto takes them from there`}, and the failure each one had stays on its row.`}function Jfe(e,t,n){let r=Yfe(n-e.at),i=e.by===`run`?`started again ${r}`:`put back in the queue ${e.by===`assess`?`by the assessment`:`from the phone`} ${r}`,a=e.n!=null&&e.n>1?` (${Xfe(e.n)} time)`:``,o=e.error?` · failed before: “${e.error}”`:``;return t===`failed`?`failed again — it was ${i}${a}${o}`:t===`done`?`ran after being ${i}${a}${o}`:`${i}${a}${o}`}function Yfe(e){let t=Math.max(0,Math.round(e/1e3));if(t<60)return`${t}s ago`;let n=Math.round(t/60);if(n<60)return`${n}m ago`;let r=Math.round(n/60);if(r<24)return`${r}h ago`;let i=Math.round(r/24);return i<60?`${i}d ago`:`${Math.round(i/30)}mo ago`}function Xfe(e){let t=e%100;return t>=11&&t<=13?`${e}th`:`${e}${[`th`,`st`,`nd`,`rd`][e%10]??`th`}`}function $j(e){return`from the schedule “${e}”`}function Zfe(e){return`the schedule “${e}”`}function Qfe(e){return`written by the schedule “${e}”`}function $fe(e){return`the timed one-off “${e}” that wrote this — set aside, because this row is the account of it`}var epe={hand:`you typed this title`,assess:`titled by the assessment`,name:`titled by the naming pass`};function tpe(e){return e===`hand`?`this title is yours — the assessment and the naming pass will not change it. Clear the field to let them suggest one again.`:`saving makes it yours — the assessment and the naming pass will not change it again. Clear the field to let them suggest one again.`}function eM(e){return`name ${e===1?`this one`:`these ${e}`}`}function npe(e){return e.filter(e=>!e.archived&&(e.status===`queued`||e.status===`failed`)&&(zr(e)===null||!e.category)).map(e=>e.id)}function tM(e,t){return`${e===t?`all ${t} rows here need a title or a kind`:`${e} of the ${t} shown need a title or a kind — the rest have both, or are running, finished or set aside`}. Nothing you typed is replaced.`}function nM(e){return`asked the desktop to ${e} — the titles land on the rows as the pass answers, and anything you typed yourself is left alone`}function rM(e){let t=Math.max(0,Math.round(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m ${t%60}s`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d ${r%24}h`}function iM(e){return Gn(e.label,e.text,40)}var rpe=`A new session (default)`,ipe=`→ the session it was aimed at (closed)`;function ape(e,t){let n=[{value:``,label:rpe}];for(let t of e)n.push({value:t.id,label:`→ ${bi(t)}`});return t&&!e.some(e=>e.id===t)&&n.push({value:t,label:ipe}),n}function ope(e,t){let n=e.status===`queued`&&e.holderSessionId?t.find(t=>t.id===e.holderSessionId&&t.running):void 0;if(!n)return null;let r=Qr(n)??`the session`,i=r.length>32?`${r.slice(0,31)}…`:r;return n.awaitingInput||n.asking||n.prompt&&n.prompt.kind!==`trust`?{sessionId:n.id,label:`answer in '${i}'`,title:`this row waits until that question is answered — open the session to answer it`}:{sessionId:n.id,label:`open '${i}'`,title:`the automatic session this row waits behind — it starts when that one is idle`}}function aM(e){return e.archived||e.status===`running`||e.status===`done`?!1:e.status!==`failed`||!!e.at}function spe(e,t,n){let r=`${e} of ${t} picked`,i=n-t;return`${r}${i>0?` · ${i} ${i===1?`has`:`have`} no box: running, finished, archived, or failed with no clock to move`:``}. A new when replaces each one's — the words, where it goes and the place in the list stay.`}var cpe=`tick the rows to move — the button appears with the count`;function lpe(e,t){return e===1?`re-timed — the same row, now ${t}`:`re-timed ${e} — the same rows, now ${t}`}function upe(e,t,n,r){let i=e===1?`re-timed — now ${t}`:`re-timed ${e} — now ${t}`,a=n.length===1?` on ${n[0]}`:n.length>1?` on each repo's row`:``;return`${i}${`. Off the clock list: ${e===1?`it waits`:`they wait`} in the queue, ⌛${a}`}${r?` — held by the budget until ${r}`:``}.`}function dpe(e){return e===1?`No clock: it leaves the Schedules clock list and waits in its repo's queue — the ⌛ chip on the repo's row.`:`No clock: these leave the Schedules clock list and wait in their repo's queue — the ⌛ chip on the repo's row.`}function fpe(e,t){return t<=0?``:t>=e?` · budget`:` · ${t} budget`}function ppe(e,t){let n=new Set(t.map(e=>e.id)),r=[];for(let t of e){let e=t.items.filter(e=>n.has(e.id)).map(e=>e.id);e.length<2||!t.items[0].at||r.push({key:t.key,rule:An(t.items[0].at.rule),ids:e})}return r}function mpe(e){return`re-time the ${e.ids.length} on “${e.rule}”`}function oM({picked:e,eligible:t,shown:n,onAll:r,onNone:i,onDone:a,onChoose:o,where:s}){return(0,J.jsx)(`div`,{className:`form`,children:(0,J.jsxs)(Z,{children:[spe(e,t,n),(0,J.jsxs)(`div`,{className:`annot-tools wrap`,style:{marginTop:6},children:[e>0?(0,J.jsxs)(Y,{title:`choose the new when — a time, a usage window, a condition, a repeat — for the ticked rows`,onClick:()=>{q(`action:${s}.retime.choose`),o()},children:[(0,J.jsx)(rl,{size:14}),` `,e===1?`new when for it…`:`new when for these ${e}…`]}):(0,J.jsx)(`span`,{children:cpe}),e<t&&(0,J.jsxs)(Y,{title:`tick every row on screen that can be re-timed`,onClick:r,children:[(0,J.jsx)(eo,{size:14}),` all `,t]}),e>0&&(0,J.jsxs)(Y,{title:`untick every row`,onClick:i,children:[(0,J.jsx)(ic,{size:14}),` none`]}),(0,J.jsxs)(Y,{title:`close the pick list — nothing is changed`,onClick:a,children:[(0,J.jsx)(B,{size:14}),` done`]})]})]})})}function sM({children:e}){return(0,J.jsx)(`div`,{className:`retime-layer`,children:e})}function cM({on:e,onToggle:t}){return(0,J.jsx)(`button`,{className:`bl-pick`,"aria-pressed":e,"aria-label":e?`untick this row`:`tick this row to re-time it`,onClick:e=>{e.stopPropagation(),t()},children:e?(0,J.jsx)(eo,{size:18}):(0,J.jsx)(ic,{size:18})})}function lM(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function hpe({i:e,repoName:t,onOpen:n,pick:r}){let i=e.trigger.kind===`at`?e.trigger.rule:null,a=i&&e.nextAt&&!Lr(i,e.nextAt)?pi(i,e.nextAt):null,o=t(e.cwd),s=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`sched-clock-name`,children:lj(e)}),(0,J.jsxs)(`span`,{className:`sched-clock-when`,children:[i?An(i):`on a clock`,e.nextAt?(0,J.jsxs)(J.Fragment,{children:[` · next `,Pr(e.nextAt)]}):null,a?(0,J.jsxs)(J.Fragment,{children:[` · held until `,Pr(a),`, when its hours open`]}):null,e.holdForHost?(0,J.jsx)(J.Fragment,{children:` · waits until free`}):null]}),(0,J.jsx)(`span`,{className:`sched-clock-state`,children:gpe(e)}),e.state===`blocked`&&e.blockReason&&e.blockReason!==`notYet`&&e.blockDetail?(0,J.jsx)(`span`,{className:`sched-clock-why`,children:e.blockDetail}):null]});return r===void 0?n?(0,J.jsxs)(`button`,{className:`sched-clock`,title:`open it in ${o}'s backlog — it is waiting work that happens to carry a clock, and every verb it has is on its row there`,onClick:()=>{q(`action:schedule.clockrow`),n(e.cwd,[e.id],Ife(o))},children:[s,(0,J.jsx)(il,{size:13,className:`sched-clock-go`})]}):(0,J.jsx)(`div`,{className:`sched-clock`,children:s}):r?(0,J.jsxs)(`div`,{className:`sched-clock sched-clock-pick`,role:`button`,onClick:r.toggle,children:[(0,J.jsx)(cM,{on:r.on,onToggle:r.toggle}),(0,J.jsx)(`div`,{className:`sched-clock sched-clock-inner`,children:s})]}):(0,J.jsx)(`div`,{className:`sched-clock`,children:s})}function gpe(e){return e.state===`starting`||e.state===`running`?`running`:e.state===`blocked`?`waiting`:e.state}function _pe({p:e,repoName:t,online:n}){let r=e.entry,i=r.action.kind===`backlog`?t(r.action.repoDir):``;return(0,J.jsxs)(`div`,{className:`sched-clock`,children:[(0,J.jsx)(`span`,{className:`sched-clock-name`,children:Gn(r.name,r.action.text)??r.action.text}),(0,J.jsxs)(`span`,{className:`sched-clock-when`,children:[An(r.rule),r.nextAt&&!e.failed?(0,J.jsxs)(J.Fragment,{children:[` · next `,Pr(r.nextAt)]}):null,i?(0,J.jsxs)(J.Fragment,{children:[` · `,i]}):null]}),(0,J.jsx)(`span`,{className:`sched-clock-state`,children:(0,J.jsx)(OO,{phase:ad({queued:!0,failed:!!e.failed,onHost:!1,online:n}),thing:`this one`})})]})}function vpe({rows:e,pending:t,repoName:n,online:r,onOpen:i,renderRetime:a,counted:o=!0}){let[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(()=>new Set),[d,f]=(0,V.useState)(!1);if(!e.length&&!t.length)return null;let p=r&&!!a,m=e.filter(Ej),h=m.filter(e=>l.has(e.id)).map(e=>e.id),g=s&&p,_=()=>{c(!1),u(new Set)},v=[];for(let t of e){let e=v.find(([e])=>e===t.cwd);e?e[1].push(t):v.push([t.cwd,[t]])}return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`sched-head`,children:[(0,J.jsx)(rl,{size:13}),` On a clock`,o?(0,J.jsxs)(J.Fragment,{children:[` · `,e.length+t.length]}):null,(0,J.jsx)(`span`,{className:`sched-head-note`,children:`waiting in their backlogs — the row is there, this is the door`})]}),p&&!g&&m.length>0&&(0,J.jsx)(`div`,{className:`bl-bulk`,children:(0,J.jsxs)(`button`,{className:`link-btn`,title:`tick the lines you want — in any repo — and move them all to one new time`,onClick:()=>{q(`action:schedule.retime.pick`),c(!0)},children:[(0,J.jsx)(Wo,{size:14}),` `,`pick to re-time`]})}),g&&(0,J.jsx)(oM,{picked:h.length,eligible:m.length,shown:e.length,where:`schedule`,onAll:()=>u(new Set(m.map(e=>e.id))),onNone:()=>u(new Set),onDone:_,onChoose:()=>f(!0)}),d&&a&&h.length>0&&(0,J.jsx)(sM,{children:a(h,{onSent:()=>{f(!1),_()},onCancel:()=>f(!1)})}),t.length>0&&(0,J.jsx)(`div`,{className:`sched-clocks`,children:t.map(e=>(0,J.jsx)(_pe,{p:e,repoName:n,online:r},e.entry.id))}),v.map(([e,t])=>(0,J.jsxs)(`div`,{className:`sched-clocks`,children:[(0,J.jsxs)(`div`,{className:`sched-clocks-repo`,children:[n(e),` · `,t.length]}),t.map(e=>(0,J.jsx)(hpe,{i:e,repoName:n,onOpen:i,pick:g?Ej(e)?{on:l.has(e.id),toggle:()=>u(t=>lM(t,e.id))}:null:void 0},e.id))]},e))]})}function ype({goneByRepo:e,repoName:t,onOpen:n}){return!e.length||!n?null:(0,J.jsxs)(Z,{className:`sched-spent`,children:[(0,J.jsx)(Xs,{size:13,style:{verticalAlign:`-2px`}}),` `,`On a clock, and been and gone — run or missed, the row says which:`,(0,J.jsx)(`div`,{className:`annot-tools`,style:{marginTop:6},children:e.map(([e,r])=>(0,J.jsxs)(Y,{title:`show the ${r.length} timed one-off${r.length===1?``:`s`} of ${t(e)} that have been and gone — they are rows in that backlog, with re-fire and “drop the clock” on them`,onClick:()=>{q(`action:schedule.clockspent`),n(e,r.map(e=>e.id),Lfe(t(e)))},children:[r.length,` in `,t(e)]},e))})]})}var bpe=6048e5;function xpe(e){return vi(e)===`window`?e.window===`weekly`?`weekly`:`session`:null}function uM(e,t,n,r,i){let a=Zr({kind:`window`,window:e},t??void 0);if(a==null||a<=n||a>r+i)return null;let o=e===`weekly`?t?.weeklyPct:t?.sessionPct;return{which:e,pct:typeof o==`number`&&Number.isFinite(o)?o:null,resetAt:a,x:(a-r)/i}}function Spe(e,t,n,r=.07){let i=Math.floor(n/6e4)*6e4,a=i+bpe,o=a-i,s=[],c=new Date(n);for(c.setHours(0,0,0,0),c.setDate(c.getDate()+1);c.getTime()<a;c.setDate(c.getDate()+1))s.push({t:c.getTime(),x:(c.getTime()-i)/o});let l=e.filter(e=>e.enabled!==!1&&typeof e.nextAt==`number`&&e.nextAt>n).sort((e,t)=>e.nextAt-t.nextAt),u=[],d=[],f=[];for(let e of l){let t=e.nextAt;if(t>a){d.push({id:e.id,at:t});continue}let n=(t-i)/o,s=f.findIndex(e=>n-e>=r);s<0?(s=f.length,f.push(n)):f[s]=n,u.push({id:e.id,at:t,x:n,n:u.length+1,anchor:xpe(e.rule),lane:s})}let p=e.filter(e=>e.enabled!==!1&&e.rule.kind===`window`&&e.nextAt==null&&Zr(e.rule,t??void 0)==null).map(e=>e.id);return{from:i,to:a,days:s,session:uM(`session`,t,n,i,o),weekly:uM(`weekly`,t,n,i,o),fires:u,later:d,unread:p,lanes:Math.max(1,f.length)}}function Cpe(e,t){if(!e.anchor)return`on the clock`;let n=e.anchor===`weekly`?t.weekly:t.session,r=e.anchor===`weekly`?`the weekly reset`:`the session reset`;if(!n)return`anchored to ${r}`;let i=e.at-n.resetAt;if(Math.abs(i)<6e4)return`at ${r}`;let a=Math.round(Math.abs(i)/6e4);return`${a>=60?`${Math.floor(a/60)}h${a%60?` ${a%60}m`:``}`:`${a}m`} ${i<0?`before`:`after`} ${r}`}var wpe=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],dM=e=>`${(Math.min(1,Math.max(0,e))*100).toFixed(2)}%`;function fM({w:e,name:t,cls:n}){return e?(0,J.jsxs)(`div`,{className:`swb-lane ${n}`,children:[(0,J.jsxs)(`div`,{className:`swb-lane-lab`,children:[(0,J.jsx)(`b`,{children:t}),e.pct==null?null:(0,J.jsxs)(J.Fragment,{children:[` · `,Math.round(e.pct),`% used`]}),` · resets `,Pr(e.resetAt)]}),(0,J.jsxs)(`div`,{className:`swb-track`,children:[(0,J.jsx)(`span`,{className:`swb-fill`,style:{width:dM(e.x)}}),(0,J.jsx)(`span`,{className:`swb-reset`,style:{left:dM(e.x)}})]})]}):null}function pM({entries:e,usage:t,title:n,now:r=Date.now()}){let i=Spe(e,t,r),a=new Map(e.map(e=>[e.id,e])),o=i.session||i.weekly;return!o&&i.fires.length===0?null:(0,J.jsxs)(`section`,{className:`swb`,"aria-label":`the next seven days against your usage windows`,children:[(0,J.jsxs)(`div`,{className:`swb-title`,children:[(0,J.jsx)(ms,{size:13}),` The next 7 days against your usage windows`]}),(0,J.jsx)(fM,{w:i.weekly,name:`Weekly window`,cls:`weekly`}),(0,J.jsx)(fM,{w:i.session,name:`Session window`,cls:`session`}),(0,J.jsxs)(`div`,{className:`swb-pins`,style:{height:i.lanes*22+4},children:[i.weekly&&(0,J.jsx)(`span`,{className:`swb-rule weekly`,style:{left:dM(i.weekly.x)}}),i.session&&(0,J.jsx)(`span`,{className:`swb-rule session`,style:{left:dM(i.session.x)}}),i.fires.map(e=>(0,J.jsx)(`span`,{className:`swb-pin${e.anchor?` anchored`:``}`,style:{left:dM(e.x),top:e.lane*22+2},"aria-hidden":!0,children:e.n},e.id))]}),(0,J.jsxs)(`div`,{className:`swb-days`,"aria-hidden":!0,children:[(0,J.jsx)(`span`,{className:`swb-day`,style:{left:0},children:`now`}),i.days.filter(e=>e.x>=.09).map(e=>(0,J.jsx)(`span`,{className:`swb-day`,style:{left:dM(e.x)},children:wpe[new Date(e.t).getDay()]},e.t))]}),i.fires.length>0&&(0,J.jsx)(`ol`,{className:`swb-list`,children:i.fires.map(e=>{let t=a.get(e.id);return(0,J.jsxs)(`li`,{children:[(0,J.jsx)(`span`,{className:`swb-pin inline${e.anchor?` anchored`:``}`,children:e.n}),(0,J.jsxs)(`span`,{className:`swb-list-txt`,children:[(0,J.jsx)(`b`,{children:t?n(t):e.id}),` · `,Pr(e.at),` (`,kr(e.at,r),`) · `,Cpe(e,i)]})]},e.id)})}),!o&&(0,J.jsx)(`div`,{className:`swb-note`,children:`The desktop has not read your usage windows yet, so only clock rules are drawn. A rule anchored to a window arms the first time it does.`}),i.unread.length>0&&o&&(0,J.jsxs)(`div`,{className:`swb-note`,children:[i.unread.length===1?`One window rule is`:`${i.unread.length} window rules are`,` not armed — the window it tracks has not been read yet.`]}),i.later.length>0&&(0,J.jsxs)(`div`,{className:`swb-note`,children:[(0,J.jsx)(rl,{size:12,style:{verticalAlign:`-2px`}}),` Further out:`,` `,i.later.map((e,t)=>{let r=a.get(e.id);return(0,J.jsxs)(`span`,{children:[t?`; `:``,r?n(r):e.id,` `,Pr(e.at)]},e.id)})]}),o&&(0,J.jsx)(`div`,{className:`swb-note`,children:(0,J.jsxs)(tT,{of:`the week bar`,label:`how to read it`,children:[`Shaded: the window open now, up to its reset. Filled pins are anchored to a reset, hollow ones to a clock.`,i.session?` Only the session window open now is drawn — the next one starts with the first prompt after its reset, which no clock can place.`:``]})})]})}function Tpe({query:e,setQuery:t,cutTotal:n,shownTotal:r}){let i=e.trim()!==``;return n<=1&&!i?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`section quick-filter`,children:[(0,J.jsx)(rc,{size:14,className:`quick-filter-icon`}),(0,J.jsx)(`input`,{type:`search`,value:e,placeholder:`search these schedules`,"aria-label":`search the schedules by their words or repo`,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`none`,spellCheck:!1,onChange:e=>t(e.target.value),onKeyDown:n=>{n.key===`Escape`&&e&&(n.preventDefault(),n.stopPropagation(),t(``))}}),i&&(0,J.jsxs)(`span`,{className:`quick-filter-n`,children:[r,` of `,n]}),i&&(0,J.jsx)(`button`,{className:`head-act`,"aria-label":`clear the search`,title:`clear the search — every row of the cut again`,onClick:()=>t(``),children:(0,J.jsx)(B,{size:16})})]}),i&&r===0&&(0,J.jsxs)($,{children:[`Nothing here matches “`,e.trim(),`”.`]})]})}var mM=`no connection — it is armed on the desktop and can only be changed there`,hM=`no connection — it lives on the desktop and can only be deleted there`,gM=new Set([mM,hM]);function Epe(e){return e.state===`starting`||e.state===`running`?`running`:e.state===`blocked`?`waiting`:e.state===`queued`?`queued`:e.state}function _M({repos:e,entries:t,onRemove:n,onSetEnabled:r,onRunNow:i,onSkipNext:a,onEdit:o,onClose:s,intents:c=[],sessions:l=[],onOpenSession:u,onOpenBacklog:d,renderRetime:f,online:p=!0,pending:m=[],listAt:h=0,focus:g=null,focusIds:_=null,onClearFocus:v,onOpenSpent:y,usage:b=null}){let x=t=>e.find(e=>e.worktreePath===t)?.repoName??t.split(`/`).pop()??t,[S,C]=(0,V.useState)(null),[w,T]=(0,V.useState)(``),E=w.trim()!==``,D=Date.now(),O=(0,V.useMemo)(()=>Dj({intents:c,entries:t,pending:m,focus:g,focusIds:_,text:w,now:D}),[c,t,m,g,_,w,D]),k=(0,V.useMemo)(()=>new Map(O.pendingCards.map(e=>[e.entry.id,!!e.failed])),[O.pendingCards]),A=(0,V.useMemo)(()=>new Set(t.map(e=>e.id)),[t]),j=O.cards,M=O.spentCards,N=O.shownCards,P=(0,V.useMemo)(()=>N.filter(e=>ir(e.rule)),[N]),F=(0,V.useMemo)(()=>N.filter(e=>!ir(e.rule)),[N]),ee=O.shownTotal,te=O.standingTotal,ne=[P.length,F.length,O.shown.length+O.shownPending.length].filter(e=>e>0).length===1,re=e=>ad({queued:k.has(e.id),failed:k.get(e.id)===!0,onHost:A.has(e.id),online:p}),ie=[...N.map(re),...O.shown.map(()=>`synced`),...O.shownPending.map(e=>ad({queued:!0,failed:!!e.failed,onHost:!1,online:p}))],ae=e=>{let t=e.action,s=k.has(e.id),f=k.get(e.id)===!0,m=re(e),h=!ur(e,D),g=ir(e.rule),_=g&&!e.enabled,v=_?Si(e.rule,D):null,y=Gn(e.name,t.text),b=e.lastResult?.childId?c.find(t=>t.id===e.lastResult.childId):void 0,w=c.find(t=>t.id===e.id),T=w?.state===`blocked`&&w.blockReason&&w.blockReason!==`notYet`?w.blockDetail:void 0,E=b?.sessionId&&l.some(e=>e.id===b.sessionId&&e.running!==!1)?b.sessionId:null,O=e.nextAt&&!Lr(e.rule,e.nextAt)?pi(e.rule,e.nextAt):null,A=t.kind===`backlog`&&t.steps&&t.steps.length>1?` · ${t.steps.length} turns`:``,j=t.kind===`fanout`?`fan-out · ${t.dirs.length} repo${t.dirs.length===1?``:`s`}`:t.autoFire===!1?`${x(t.repoDir)} · added to the backlog, not run${A}`:`a new session in ${x(t.repoDir)}${A}`,M=s||e.nextAt&&!e.running?null:e.running?(0,J.jsxs)(qw,{children:[(0,J.jsx)($s,{size:12,className:`spin`}),` running`]}):h?(0,J.jsx)(qw,{children:`been and gone`}):(0,J.jsx)(qw,{children:e.enabled?Ai.unarmed:_?`paused`:`off`}),N=sd(m,!0)!=null;return(0,J.jsxs)(`div`,{className:`q-card${e.running?` resuming`:``}`,children:[y&&(0,J.jsx)(`div`,{className:`sched-title`,children:y}),(N||M)&&(0,J.jsxs)(`div`,{className:`q-head`,children:[(0,J.jsx)(OO,{phase:m,thing:`this schedule`,saidAbove:!0}),M]}),(0,J.jsxs)(`div`,{className:`approve-hint`,children:[An(e.rule),` · `,j,e.waitUntilFree?(0,J.jsx)(J.Fragment,{children:` · waits until free`}):null,e.nextAt&&!f?(0,J.jsxs)(J.Fragment,{children:[` · next `,Pr(e.nextAt)]}):null,O&&!f?(0,J.jsxs)(J.Fragment,{children:[` · held until `,Pr(O),`, when its hours open`]}):null,v?(0,J.jsxs)(J.Fragment,{children:[` · would next run `,Pr(v),` once resumed`]}):null]}),h&&!s&&(0,J.jsx)(`div`,{className:`approve-hint`,children:`that instant has passed and a one-off cannot be re-armed — run it now, edit it, or post it again`}),!s&&T&&(0,J.jsx)(`div`,{className:`approve-hint`,children:T}),s&&(0,J.jsx)(`div`,{className:`approve-hint`,children:f?(0,J.jsx)(J.Fragment,{children:`the send gave up — this rule is on this phone and nowhere else, and it will not arm itself. Its words are kept; re-send it from the queue, or edit it here to replace the copy that failed.`}):(0,J.jsx)(J.Fragment,{children:`waiting for the link — it is armed on the desktop as soon as the queue drains, and the time above holds (the rule is a wall clock, not a countdown from when it is saved).`})}),(0,J.jsx)(`button`,{className:`bl-text bl-text-btn ${S===e.id?`open`:``}`,title:S===e.id?`collapse`:`expand — the whole prompt this fires`,onClick:()=>C(t=>t===e.id?null:e.id),children:t.text}),e.lastResult&&(0,J.jsxs)(`div`,{className:`approve-hint`,children:[e.lastResult.ok?(0,J.jsx)(Bc,{size:12,style:{verticalAlign:`-2px`}}):(0,J.jsx)(xs,{size:12,style:{verticalAlign:`-2px`}}),` `,Tp(e.lastResult.at),` · `,e.lastResult.detail,e.lastResult.occurrence?(0,J.jsxs)(J.Fragment,{children:[` · due `,Pr(e.lastResult.occurrence)]}):null,e.lastResult.late?` · ran late (the host had been asleep)`:``,b?(0,J.jsxs)(J.Fragment,{children:[` · the item is `,(0,J.jsx)(`b`,{children:Epe(b)})]}):null]}),(()=>{let c={run:f?`the send gave up — the desktop never got it, so there is nothing there to run`:s?`it is still in the send queue — the desktop does not have it yet`:null,toggle:f?`the send gave up — the desktop never got it, so there is nothing there to switch`:s?`it is still in the send queue — the desktop does not have it yet`:p?null:mM,remove:f?`the send gave up — nothing was stored, so there is nothing to delete`:s?`it is still in the send queue — cancel it there instead`:p?null:hM},l=[[`now`,c.run],[g?`pause/resume`:`on/off`,c.toggle&&gM.has(c.toggle)?null:c.toggle],[`delete`,c.remove&&gM.has(c.remove)?null:c.remove]];return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`approve-opts`,children:[c.run?null:(0,J.jsxs)(`button`,{className:`approve-btn`,"data-hint":`schedule.runnow`,title:`Run it now. This does not use up the next scheduled run.`,onClick:()=>{q(`action:schedule.runnow`),i(e.id)},children:[(0,J.jsx)(La,{size:14}),` now`]}),(0,J.jsxs)(`button`,{className:`approve-btn`,"data-hint":`schedule.edit`,onClick:()=>{q(`action:schedule.edit`),o(e)},children:[(0,J.jsx)(Mo,{size:14}),` edit`]})]}),(0,J.jsxs)(`div`,{className:`sched-acts`,children:[E&&u?(0,J.jsxs)(`button`,{className:`link-btn`,"data-hint":`schedule.session`,title:`Open the session this item ran in`,onClick:()=>{q(`action:schedule.session`),u(E)},children:[(0,J.jsx)(qa,{size:13}),` session`]}):t.kind===`backlog`&&d?b?(0,J.jsxs)(`button`,{className:`link-btn`,"data-hint":`schedule.backlogitems`,title:`Show the item this rule wrote, in ${x(t.repoDir)}'s backlog`,onClick:()=>{q(`action:schedule.backlog`),d(t.repoDir,[b.id],Qfe(y||t.text.slice(0,40)))},children:[(0,J.jsx)(il,{size:13}),` backlog · 1 item`]}):(0,J.jsxs)(`button`,{className:`link-btn`,"data-hint":`schedule.backlogitems`,title:`Show ${x(t.repoDir)}'s backlog — this is the list each run of this rule writes into`,onClick:()=>{q(`action:schedule.backlog`),d(t.repoDir)},children:[(0,J.jsx)(il,{size:13}),` backlog`]}):null,g&&e.nextAt&&a&&!s&&p&&(0,J.jsxs)(`button`,{className:`link-btn`,"data-hint":`schedule.skipnext`,title:`Let this one run go by, then carry on as scheduled`,onClick:()=>{q(`action:schedule.skipnext`),a(e.id)},children:[(0,J.jsx)(tne,{size:13}),` skip next`]}),c.toggle?null:(0,J.jsx)(`button`,{className:`link-btn`,"data-hint":`schedule.toggle`,title:g?e.enabled?`Pause it — nothing runs until you resume, and then it carries on at its own times`:`Resume it — the next run is its own next occurrence from now, never the ones it slept through`:e.enabled?`Stop it running`:`Arm it again — the next run is computed from now, not from what was missed`,onClick:()=>{q(`action:schedule.toggle`),r(e.id,!e.enabled)},children:g?e.enabled?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(io,{size:13}),` pause`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(La,{size:13}),` resume`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)($a,{size:13}),` `,e.enabled?`off`:`on`]})}),c.remove?null:(0,J.jsx)(`span`,{className:`sched-acts-hint`,"data-hint":`schedule.remove`,children:(0,J.jsxs)(fC,{className:`link-btn danger`,confirm:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ws,{size:13}),` delete it?`]}),title:`Delete this schedule — the next tap asks once more`,confirmTitle:`Tap again to delete it for good`,onConfirm:()=>{q(`action:schedule.remove`),n(e.id)},children:[(0,J.jsx)(ws,{size:13}),` delete`]})})]}),(0,J.jsx)(Qw,{cants:l.flatMap(([e,t])=>t?[{label:e,reason:t}]:[])})]})})()]},e.id)};return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsxs)(Uw,{title:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(rl,{size:16}),` Schedules`]}),onClose:s,children:[te>0&&!g&&!_&&!E&&(0,J.jsx)(`span`,{className:`muted`,children:te}),(0,J.jsx)(sle,{phases:ie})]}),(0,J.jsxs)(`div`,{className:`sheet-scroll`,children:[(g||_)&&(0,J.jsxs)(`div`,{className:`section filter-bar`,children:[(0,J.jsxs)(`span`,{className:`filter-bar-txt`,children:[_?_.label:g?`showing the ${Ai[g]===`not armed`?`not armed`:`ones ${Ai[g]}`}`:``,` · `,O.cutTotal,` of `,te,O.cutTotal===0&&(_?_.ids.length===1?` — that rule is not on this desktop any more`:` — none of those are on this desktop any more`:` — nothing is in that window any more`)]}),v&&(0,J.jsxs)(`button`,{className:`filter-bar-clear`,title:`clear the filter — show every schedule again`,onClick:()=>{q(`action:schedule.focus.clear`),v()},children:[(0,J.jsx)(B,{size:13}),` clear`]})]}),(0,J.jsx)(Tpe,{query:w,setQuery:T,cutTotal:O.cutTotal,shownTotal:ee}),!p&&(0,J.jsxs)(Z,{children:[(0,J.jsx)(fo,{size:13,style:{verticalAlign:`-2px`}}),` offline — a new or edited schedule is queued and saved when the link is back, so `,(0,J.jsx)(`b`,{children:`edit`}),` still works on every row below (the save replaces the copy it edits rather than arming a second one). What the cards do not show while the link is down is`,` `,(0,J.jsx)(`b`,{children:`pause/resume`}),`, `,(0,J.jsx)(`b`,{children:`on/off`}),`, `,(0,J.jsx)(`b`,{children:`skip next`}),`, `,(0,J.jsx)(`b`,{children:`delete`}),` and the `,(0,J.jsx)(`b`,{children:`session`}),` button: the first four are decisions about a run that may be minutes away and only the host can make them, and the last one needs a desktop to open a session on.`,t.length>0&&(h?` The armed rows are this device's copy, last confirmed ${Tp(h)} ago.`:` The armed rows are this device's copy.`),` `,`Items waiting on a clock are not listed below while the link is down — this device caches the rules, not the rows. Each of them is in its repo's `,(0,J.jsx)(`b`,{children:`backlog`}),`, which does keep a copy.`]}),te===0&&!p&&(0,J.jsx)($,{children:`No copy of the schedule list on this device — whatever is armed on the desktop is still armed.`}),te===0&&p&&(0,J.jsxs)($,{children:[`Nothing is scheduled.`,` `,(0,J.jsx)(tT,{of:`a schedule`,label:`what is one?`,children:`A schedule fires a prompt on its own, at a time you pick — once tonight, or every week two hours before your usage window rolls over.`})]}),j.length===0&&te>0&&!E&&(0,J.jsxs)(Z,{className:`sched-nothing-repeats`,children:[(0,J.jsx)(ol,{size:13,style:{verticalAlign:`-2px`}}),` Nothing repeats — there is no standing rule on this desktop. `,te,` one-off`,te===1?``:`s`,` wait`,te===1?`s`:``,` on a clock in `,te===1?`its repo's backlog`:`their repos' backlogs`,`, where every verb they have lives. A rule that repeats would be a card here; `,(0,J.jsx)(`b`,{children:`new schedule`}),` writes one.`]}),te>0&&(0,J.jsx)(pM,{entries:N,usage:b,now:D,title:e=>Gn(e.name,e.action.text)??e.action.text.split(`
10
+ `)[0]}),P.length>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`sched-head`,children:[(0,J.jsx)(ol,{size:13}),` Repeating`,ne?null:(0,J.jsxs)(J.Fragment,{children:[` · `,P.length]})]}),(0,J.jsx)(`div`,{className:`list`,children:P.map(ae)})]}),F.length>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`sched-head`,children:[(0,J.jsx)(rl,{size:13}),` One-off`,ne?null:(0,J.jsxs)(J.Fragment,{children:[` · `,F.length]})]}),(0,J.jsx)(`div`,{className:`list`,children:F.map(ae)})]}),(0,J.jsx)(vpe,{rows:O.shown,pending:O.shownPending,repoName:x,online:p,onOpen:d,renderRetime:f,counted:!ne}),M.length>0&&!g&&!_&&!E&&(0,J.jsxs)(Z,{className:`sched-spent`,children:[(0,J.jsx)(Xs,{size:13,style:{verticalAlign:`-2px`}}),` `,M.length,` one-off sweep`,M.length===1?` has`:`s have`,` been and gone — run or missed,`,` `,`Activity's row says which — and a one-off cannot be re-armed, so`,` `,M.length===1?`it is not a row here`:`they are not rows here`,` any more.`,y&&(0,J.jsxs)(J.Fragment,{children:[` `,(0,J.jsxs)(Y,{"data-hint":`schedule.spent`,onClick:()=>{q(`action:schedule.spent`),y(M.map(e=>e.id))},children:[`see `,M.length===1?`it`:`them`,` in Activity`]})]})]}),!g&&!_&&!E&&(0,J.jsx)(ype,{goneByRepo:O.goneByRepo,repoName:x,onOpen:d})]}),(0,J.jsx)(`div`,{className:`sheet-actions`,children:(0,J.jsxs)(`button`,{className:`send`,onClick:()=>{q(`action:schedule.new`),o(null)},children:[(0,J.jsx)(Fo,{size:16}),` new schedule`]})})]})}function vM(e){return e.filter(e=>e.mode===`op`&&e.op?.t===`schedule.save`).map(e=>({entry:e.op.entry,failed:e.status===`failed`}))}function yM(e){return`the ${e} one-off${e===1?` that has`:`s that have`} been and gone`}var bM=W(ET().v),xM=W(ET().at),SM=W(null),CM=W(null);function wM(){return G(bM)}function TM(e,t,n){let r=G(bM),i=(0,V.useMemo)(()=>vM(t),[t]);return(0,V.useMemo)(()=>Dj({intents:e,entries:r,pending:i,focus:null,focusIds:null,now:Date.now()}),[e,r,i,n])}function EM(e){bM.set(e),DT(e),xM.set(Date.now())}function DM(e){SM.set(e),U().nav.open(`schedule`)}function OM(e,t){SM.set(null),CM.set({ids:e,label:t}),U().nav.open(`schedule`)}function kM(){SM.set(null),CM.set(null)}function AM(e){let t=U(),{queueOp:n}=t.queue,r=bM.get().find(t=>t.id===e),i=n({t:`schedule.run`,id:e},`fanout`,r?.name||`scheduled run`);t.say.toast(i?`queued — it runs when the link is back`:`running it now`)}function jM(e){let t=U(),n=t.queue.verbs.scheduleQueueRows(e);t.conn.liveSend({t:`schedule.remove`,id:e},jj(n.length),`no connection — this one lives on the desktop and can only be deleted there`)&&t.queue.verbs.dropScheduleQueue(n)}function MM(){let e=Dh(),{liveSend:t}=e.conn,{sessions:n,visibleRepos:r,active:i,intents:a}=e.world,o=G(bM),s=G(xM),c=G(SM),l=G(CM),u=Oh(),d=(0,V.useMemo)(()=>vM(u),[u]);return(0,J.jsx)(_M,{repos:r,entries:o,pending:d,listAt:s,focus:c,focusIds:l,onClearFocus:kM,onOpenSpent:t=>e.nav.openActivity({keys:t.map(nj),label:yM(t.length)}),online:e.conn.status===`open`,usage:e.world.usage,intents:a,sessions:n,onSkipNext:e=>{t({t:`schedule.skipNext`,id:e},`skipping the next run…`,`no connection — a skip has to reach the desktop before the run does`)},onOpenSession:t=>{let r=n.find(e=>e.id===t);r?(e.nav.close(`schedule`),e.nav.attach(r)):e.say.toast(`that session is no longer open`)},onOpenBacklog:(t,n,r)=>e.nav.openBacklogCut(t,n,r),renderRetime:e.send.renderRetime,onEdit:t=>e.nav.openSend(t?e.send.seedFromSchedule(t):{when:OA(36e5),target:{kind:`repo`,cwd:i?.cwd??r.find(e=>e.isPrimary)?.worktreePath??``},cwdHint:i?.cwd??null,origin:`New schedule`}),onRunNow:AM,onSetEnabled:(e,n)=>t({t:`schedule.setEnabled`,id:e,enabled:n},n?`armed`:`switched off`,`no connection — this one is armed on the desktop and can only be changed there`),onRemove:jM,onClose:()=>e.nav.close(`schedule`)})}var NM={id:`schedule`,sheets:[{id:`schedule`,persisted:!1,render:()=>(0,V.createElement)(MM),onLeave:kM}],messages:{"schedule.list":e=>EM(e.entries)}},PM=[`done`,`obsolete`,`superseded`,`merged`];function FM(e){return PM.includes(e)}function IM(e){return`the words for “${e}” are not on this phone`}var LM=`this run's own record of what it judged is what both ends apply from, and this id is not in it — so there is nothing here to agree with, and a tick would do nothing`,RM=`a pad note the run still wants — it is offered below, in its own words, as a backlog item; the pad itself is never edited by this app`;function zM(e,t,n=!1){return n?LM:t===`note`?e===`wanted`?RM:`a pad note — this app never edits the pad, so there is nothing to apply here. If you agree it is done, delete it on the pad.`:e===`unclear`?`nothing to accept — the run did not decide about this one, so it stays exactly as it is`:e===`merged`?`a merge is one decision about all of its items — approve it on the merge itself, below`:null}function BM(e){return e.verdict===`wanted`?e.rank==null?e.failed?`put back in the queue`:null:e.failed?`put back in the queue, position ${e.rank}`:`position ${e.rank} in the order`:null}var VM=`retire this item: its words are kept with the reason on the row, and nothing is built`,HM=`tap to change your mind`;function UM(e){return`${e?``:`each `}where it was already aimed — a session of its own, or the session it names`}function WM(e,t,n=!1){return e===`wanted`?n?{label:`put it back`,title:`put this failed item back in the queue at the position the run proposes — it runs again ${UM(!0)} when its turn comes, and the failure it had stays on the row`,effect:`ticking keeps the item and gives it the position the run proposes; one that failed goes back in the queue and runs again when its turn comes — nothing is started now`,picked:`will be put back in the queue`,pickedTitle:HM}:{label:`keep it`,title:`keep this item and give it the position the run proposes — it does not run it`,effect:`ticking keeps the item and gives it the position the run proposes — nothing is started`,picked:`will be kept`,pickedTitle:HM}:e===`merged`?{label:`accept`,title:`a merge is approved on the merge card itself`,effect:`one decision about all of its items — approved on the card`,picked:`will be retired`,pickedTitle:HM}:e===`unclear`?{label:`accept`,title:`nothing was decided about this one`,effect:`nothing was decided here — these rows are yours to read`,picked:`stays as it is`,pickedTitle:HM}:{label:`retire it`,title:VM,effect:`ticking a row here marks it to be retired when you Apply — its words are kept, with the reason on the row, and nothing is implemented`,picked:`will be retired`,pickedTitle:HM}}var GM={label:`leave it`,picked:`left alone`,title:`leave this one exactly as it is`,pickedTitle:`un-mark it`};function KM(e,t){let n=new Map;for(let e of t)e&&typeof e.id==`string`&&e.id&&n.set(e.id,e);let r=e=>{let t=n.get(e.id),r=t?.source??`intent`,i=e.supersededBy?n.get(e.supersededBy):void 0;return{id:e.id,verdict:e.verdict,source:r,text:t?.text??``,missing:!t,failed:t?.state===`failed`,label:t?.label,headline:e.headline,category:e.category,verdictLabel:In(e.verdict),sentence:mte(e),downgraded:e.downgraded,rank:e.rank,supersededBy:e.supersededBy,supersededByText:i?.text,gid:e.gid,acceptBlocked:zM(e.verdict,r,!t),row:e}},i=e.rows.map(r),a=e.merges.map(e=>qM(e,i,n,r)),o=[];for(let e of zt){let t=i.filter(t=>t.verdict===e),n=e===`merged`?a:[];if(!t.length&&!n.length)continue;e===`wanted`&&t.sort((e,t)=>(e.rank??2**53-1)-(t.rank??2**53-1));let r=e===`merged`?[]:t,s=new Set;for(let e of n)for(let t of e.originals)s.add(t.id);o.push({verdict:e,label:In(e),rows:r,merges:n,count:e===`merged`?s.size:t.length,acceptable:r.filter(e=>!e.acceptBlocked).length,failed:e===`wanted`?r.filter(e=>!e.acceptBlocked&&e.failed).length:0,retires:FM(e),defaultOpen:FM(e),fixedOpen:e===`merged`})}return o}function qM(e,t,n,r){let i=[],a=[];for(let o of e.ids){let s=t.find(e=>e.id===o);s?(i.push(s),s.missing&&a.push(o)):n.has(o)?i.push(r({id:o,verdict:`merged`,evidence:e.rationale,gid:e.gid})):a.push(o)}return{gid:e.gid,prompt:e.prompt,rank:e.rank,rationale:e.rationale,ids:[...e.ids],originals:i,missingIds:a,headline:e.headline,category:e.category}}function JM(e){let t=Gn(e.label,e.text,40),n={kind:e.source===`note`?`pad note`:`backlog item`,suggested:!t&&!!e.headline};t&&(n.name=t);let r=t??(e.headline?.trim()||void 0);return r&&(n.headline=r),e.category&&(n.category=e.category),e.missing&&(n.id=e.id),n}var YM=90;function XM(e){let t=new Map;for(let n of e)n.downgraded&&t.set(n.downgraded,(t.get(n.downgraded)??0)+1);return[...t.entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0])).map(([e,t])=>({down:e,text:uee(e),n:t}))}var ZM=e=>{let t=(e||``).replace(/\s+/g,` `).trim();return t?`“${t.length>YM?`${t.slice(0,YM)}…`:t}”`:`“” (the words for this one are not on this phone)`};function QM(e,t){let n=e.length,r=e.filter(e=>e.failed).length,i=[`${n} ${n===1?`item`:`items`} in ${t.repoName} — ${In(t.verdict)}.`];i.push(FM(t.verdict)?`Nothing is deleted: each row keeps its words and the evidence it was retired on, dimmed rather than hidden, and one tap brings it back.`:r?`${r} of them failed: ${r===1?`it goes`:`they go`} back in the queue and run${r===1?`s`:``} again when ${r===1?`its turn comes`:`their turn comes`}, one at a time in this repo, ${UM(r===1)}. The failure ${r===1?`it`:`they`} had stays on the row. Nothing is retired and nothing is started now.`:`This only sets the order they run in. Nothing is sent and nothing is retired.`);for(let t of e.slice(0,3))i.push(ZM(t.text));return n>3&&i.push(`…and ${n-3} more`),i}var $M=e=>e.retires?`retire`:`keep`,eN=e=>e.slice(0,1).toUpperCase()+e.slice(1);function tN(e,t,n){if(e.verdict===`merged`||e.verdict===`unclear`||!e.acceptable)return null;if(t>=e.acceptable)return{label:`un-tick ${t}`,title:`take the marks off this strip — nothing has been applied yet, so nothing is undone`,confirm:!1};let r=$M(e),i=e.acceptable;if(e.retires)return{label:`${r} all ${i}`,title:`mark all ${i} to be retired when you Apply — their words are kept with the reason on each row, and nothing is implemented. You are shown the repo and 3 of the items first.`,confirm:!0,ask:{title:`${eN(r)} ${i} “${e.label}” in ${n.repoName}?`,confirmLabel:`${eN(r)} ${i}`}};let a=e.failed;return a?{label:`${r} all ${i}`,title:`keep all ${i} and give them the order the run proposes — ${a} of them failed and ${a===1?`is`:`are`} put back in the queue to run again when ${a===1?`its turn comes`:`their turn comes`}, one at a time in this repo, ${UM(a===1)}; nothing is started now and nothing is retired`,confirm:!0,ask:{title:`${eN(r)} ${i} in ${n.repoName} — put ${a} back in the queue?`,confirmLabel:`${eN(r)} ${i}`}}:{label:`${r} all ${i}`,title:`keep all ${i} and give them the order the run proposes — nothing is started and nothing is retired`,confirm:!1}}function nN(e,t){let n=e.originals.length||e.ids.length,r=[`One new prompt replaces ${n} ${n===1?`item`:`items`} in ${t.repoName}.`,`The prompt below was written by the assessment, not by you. The items it replaces are retired with a reason and keep their words.`,ZM(e.prompt)];for(let t of e.originals.slice(0,3))r.push(`replaces ${ZM(t.text)}`);return e.originals.length>3&&r.push(`…and ${e.originals.length-3} more`),e.missingIds.length&&r.push(`${e.missingIds.length} of the items it names ${e.missingIds.length===1?`is`:`are`} not on this phone, so ${e.missingIds.length===1?`its words are`:`their words are`} not shown above.`),r}function rN(e){let t=e.judged,n=[`The run read ${e.repoName} and is saying what it thinks of ${t} ${t===1?`item`:`items`} you wrote — it is a proposal, not a to-do list.`,`retire it / keep it on a row means you agree with that verdict. Nothing happens yet.`,`retire all on a strip agrees with every row on it in one go — you are shown the repo and 3 of the items first.`,`Apply, at the bottom, is the only thing that changes anything: retired items keep their words and go dim in the backlog (one tap brings one back); kept items stay where they are and each still runs in its own session when it fires — a kept item that had failed is put back in the queue and runs again when its turn comes, with its old failure kept on the row; new items are posted to the backlog the same way. Anything you left alone is untouched.`];return e.named&&n.push(`The run also suggested a title and a kind for each item — the switch at the bottom decides whether they are written on the rows. A title you typed yourself is never replaced.`),e.planPath&&n.push(`read the plan opens ${e.planPath}, the run's write-up. It is for reading, not something to run — the work is the items below.`),{lead:`A proposal. Nothing here builds, runs or sends anything.`,lines:n}}function iN(e){return e.rows.size+e.merges.size+e.news.size+(e.splits?.size??0)}function aN(e){return`${e} ticked`}var oN=e=>Array.isArray(e)?new Set(e):e;function sN(e,t,n){let r=oN(t.rows),i=oN(t.merges),a=oN(t.news),o=new Map;for(let e of n)e&&typeof e.id==`string`&&e.id&&o.set(e.id,e);let s=e=>{let t=o.get(e);return!!t&&!t.context&&t.source===`intent`},c=new Set,l=0;for(let t of e.merges)if(i.has(t.gid)){l++;for(let e of t.ids)s(e)&&c.add(e)}let u=0,d=0;for(let t of e.rows)if(r.has(t.id)){if(t.verdict===`wanted`){if(!s(t.id))continue;o.get(t.id)?.state===`failed`?d++:t.rank!=null&&u++}else t.verdict!==`merged`&&t.verdict!==`unclear`&&s(t.id)&&c.add(t.id)}e.news.forEach((e,t)=>{a.has(t)&&l++});let f=0;for(let t of e.rows)(t.headline||t.category)&&s(t.id)&&f++;return{retire:c.size,keep:u,requeue:d,post:l,name:f}}function cN(e,t,n={}){let r=[];return e.retire&&r.push(`retire ${e.retire}`),e.keep&&r.push(`keep ${e.keep} in order`),e.requeue&&r.push(`put ${e.requeue} back in the queue`),e.post&&r.push(`post ${e.post} new`),n.splits&&r.push(`split ${n.splits} in two`),n.ranked&&r.push(`order ${n.pinRanks===!1?`free`:`pinned`}`),n.writeNames&&e.name&&r.push(`title ${e.name}`),r.length?`Apply in ${t} — ${r.join(` · `)}`:`Apply in ${t}`}function lN(e){let t=`Retired items keep their words and can be brought back.`;if(!e)return`${t} Nothing is built or sent by this.`;let n=e===1;return`${t} Nothing is started now: the ${n?`one put back runs`:`${e} put back run`} again when ${n?`its turn comes`:`their turn comes`}, one at a time per repo, ${UM(n)}.`}var uN=new Set([`queued`,`blocked`]);function dN(e,t){if(!e?.applied)return{ids:[],n:0};let n=[];for(let e of t)e&&typeof e.id==`string`&&e.id&&(e.archived||uN.has(e.status??``)&&n.push(e.id));return{ids:n,n:n.length}}function fN(e,t){return e>0?`open the backlog — ${e} waiting in ${t}`:`open the backlog in ${t}`}function pN(e){return e>0?`Opens exactly those ${e} — everything waiting in this repo, filtered, with the clear button on the bar. Nothing else is applied by this — the apply above already happened.`:`Nothing is waiting in this repo, so the list opens unfiltered. Nothing else is applied by this.`}function mN(e){return`everything waiting in ${e}, from the assessment`}function hN(e){let t=[`${e.dismissed} retired`,`${e.ranked} ranked`];return e.requeued&&t.push(`${e.requeued} put back`),e.named&&t.push(`${e.named} titled`),t.push(`${e.posted} posted`),`applied: ${t.join(` · `)}`}var gN={label:`post it`,picked:`will be posted`,title:`add this to the backlog when you Apply — it is not started by this`,pickedTitle:`tap to change your mind`};function _N(e){return`becomes a backlog item in ${e}, in its own session when it fires`}var vN={label:`file it`,picked:`will be filed`,title:`file your own words as a backlog item when you Apply, and take the note off the pad — nothing is started by this`,pickedTitle:HM};function yN(e){return`your note, word for word, becomes a backlog item in ${e} — and comes off the pad once the desktop has it`}function bN(e){return e===1?`your note is on the backlog and off the pad`:`${e} notes are on the backlog and off the pad`}function xN(e,t){if(!Array.isArray(t))return{clear:[],stay:[...e],told:!1};let n=new Set(t),r=[],i=[];for(let t of e)(n.has(t)?r:i).push(t);return{clear:r,stay:i,told:!0}}function SN(e){let t=e.clear.length,n=e.stay.length;return!t&&!n?null:e.told?n?t?`${t===1?`1 note is on the backlog and off the pad`:`${t} notes are on the backlog and off the pad`}; ${n===1?`1 is still on your pad — the desktop did not file it`:`${n} are still on your pad — the desktop did not file them`}`:n===1?`nothing was filed — your note is still on the pad`:`nothing was filed — your ${n} notes are still on the pad`:bN(t):n===1?`your note is left on the pad — the desktop could not say whether it filed it`:`your ${n} notes are left on the pad — the desktop could not say which it filed`}function CN(e){let t=e.run;if(!t)return`no assessment has been run for this repo yet`;if(t.status===`running`)return`the assessment is still running — its verdicts are not final until it finishes`;if(t.status===`failed`)return`the run did not produce a proposal${t.detail?` — ${t.detail}`:``}`;let n=t.proposal;return!n||!(n.rows.length+n.merges.length+n.news.length+(n.splits?.length??0)+(n.conflicts?.length??0))?`this run came back with nothing to decide`:t.status===`applied`?`this proposal has already been applied — run a new assessment to judge what is left now`:e.busy?`the decisions have been sent — waiting for the desktop`:e.picked?e.online?null:`no connection — applying starts work on the desktop, so it cannot be queued from here`:`nothing is ticked yet — tap retire it or keep it on the rows you agree with, or retire all on a strip`}function wN(e){return e.run?.status===`running`?`an assessment is already running for this repo — two of them would propose different verdicts on one list`:e.busy?`the run has been asked for — waiting for the desktop`:e.budgetNote?e.budgetNote:e.online?null:`no connection — the run happens on the desktop`}function TN(e,t){let n=Math.max(e||0,t||0),r=`step${n===1?``:`s`}`,i=t>0&&n>t;return{line:i?`${n} ${r} · last ${t} shown`:`${n} ${r}`,button:i?`last ${t} of ${n} ${r}`:`${n} ${r}`}}function EN(e){let t=Math.max(0,Math.round(e/1e3));if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return t%60?`${n}m ${t%60}s`:`${n}m`;let r=Math.floor(n/60);return n%60?`${r}h ${n%60}m`:`${r}h`}function DN(e){let t=e.detail;switch(e.kind){case`read`:return t?`reading ${t}`:`reading`;case`search`:return t?`searching for ${t}`:`searching`;case`edit`:return t?`writing ${t}`:`writing`;case`run`:return t?`running ${t}`:`running a command`;case`task`:return t?`running an agent: ${t}`:`running an agent`;case`web`:return t?`fetching ${t}`:`fetching`;case`say`:return`thinking it over`;default:return t?`${e.label}: ${t}`:e.label}}function ON(e,t){if(!e||e.status!==`running`)return null;let n=EN(t-e.startedAt),r=e.progress,i=r?.tail.length?r.tail[r.tail.length-1]:null,a=!r||!i?`starting up`:r.wroteOut?`writing its answer`:DN(i),o=r?r.tail.length:0;return{doing:a,elapsed:n,counts:r&&r.steps?TN(r.steps,o).line:void 0,quiet:r&&t-r.at>=9e4?`nothing new for ${EN(t-r.at)}`:void 0,say:r?.say}}var kN=[`inherit`,`keep`,`close`];function AN(e){return e===!0?`close`:e===!1?`keep`:`inherit`}function jN(e){return e===`close`||e!==`keep`&&null}function MN(e){return e===`close`||e!==`keep`&&void 0}var NN=e=>e?`close when done`:`keep open`;function PN(e,t){return e===`close`?`close when done`:e===`keep`?`keep open`:`as set globally (currently: ${NN(t)})`}function FN(e,t){let n=AN(e);return`${(n===`inherit`?t:n===`close`)?`Its session closes itself once the work is done (it stays under Recently closed, reopenable)`:`Its session stays open once the work is done, until you close it`} — ${n===`inherit`?`as set globally`:`this item's own choice`}.`}function IN(e,t){return e===`inherit`?`follows the global setting — ${t?`closes when done`:`stays open`}`:e===`close`?`its session will close when done`:`its session will stay open`}function LN(e){let t=AN(e);return t===`close`?`closes when done`:t===`keep`?`stays open`:null}var RN=e=>!e.targetSessionId,zN=e=>RN(e)&&e.status===`queued`;function BN(e,t){return!e||!t?!1:hn(t).length>=t.max&&/free slot/i.test(e)}function VN(e,t){if(!e)return[];let n=new Map(t.map(e=>[e.id,e])),r=[];for(let t of hn(e)){let e=n.get(t.id);e&&e.running&&r.push({s:e,closeWhenDone:t.closeWhenDone})}return r}function HN(e){return`close one to make room — ${e} working`}function UN(e,t){let n=e.turnActive?`working`:`idle`;return t?`${n} · closes itself when done`:`${n} · stays open until closed`}function WN(e,t){let n=[];for(let r of e){if(r.repoDir!==t)continue;let e=gt(r);e&&n.push(e)}return n}function GN(e,t){return{repoDir:e,ids:[...t.ids],scope:{kind:`slot`,key:t.key},kind:t.kind,at:t.at,period:t.period}}function KN(e,t,n,r){if(r)return null;let i=WN(e,t),a=u(i,n);if(!a.length)return null;let o=Vr(i,n);return o?{id:n,others:a.length,check:GN(t,o)}:null}function qN(e){return`${lt(e.others,e.check.kind)} — check them together?`}var JN=`check`,YN=`not now`,XN=`don't ask in this repo`,ZN=`ask after a timed send`;function QN(e){return`won't ask in ${e} again — “${ZN}” in its backlog brings it back`}function $N(e){return`will ask again in ${e} when a timed send lands beside others`}function eP(e){return e?.at?JSON.stringify([e.at.rule,e.at.nextAt]):null}function tP(e,t,n,r){if(r||n-e.since>6e5)return{kind:`drop`};let i=t.find(t=>t.id===e.id);if(!i||eP(i)===e.was)return{kind:`wait`};let a=KN(t,e.repoDir,e.id,r);return a?{kind:`ask`,ask:a}:{kind:`drop`}}function nP(e,t){return Mt(WN(e,t)).filter(e=>e.ids.length>=2).map(e=>GN(t,e))}function rP(e){return e.kind===`reset`?`at the ${e.period??`usage`} reset, ${Pr(e.at)}`:`at ${Pr(e.at)}`}function iP(e,t){return`check these ${e.ids.length} · ${kr(e.at,t)}`}function aP(e){return`the ${e.ids.length} rows that run together ${rP(e)} — one assessment reads them as a group (rows that contradict each other, a row that is two jobs, their order). Nothing changes until you approve it.`}function oP(e,t,n){if(!e||e.kind!==`slot`)return null;let r=Ree(e.key),i=t?t===2?`these two`:`these ${t}`:`these rows`;return r?`A slot check: ${i} run together ${rP(r)} (${kr(r.at,n)}). It looks for rows that contradict each other, a row that is two jobs, and the order they should go in.`:`A slot check: ${i} run together.`}function sP(e,t){return`${t?`check again`:`check`} ${e===2?`these two`:`these ${e}`} together`}var cP=(e,t)=>({id:t,text:e.get(t)?.text??null}),lP=e=>{let t=new Map;for(let n of e)n?.id&&t.set(n.id,n);return t};function uP(e,t){let n=lP(t);return(e?.conflicts??[]).map(e=>({cid:e.cid,sentence:v(e),rows:e.ids.map(e=>cP(n,e))}))}var dP=`words only — nothing here is applied. Edit one, drop one, or leave them as they are.`,fP=`drop this one`,pP=`archive it?`,mP=`archive this row — its words are kept and the backlog's archived cut brings it back`,hP=`leave them`;function gP(e,t){let n=lP(t);return(e?.splits??[]).map(e=>({sid:e.sid,id:e.id,sentence:Be(e),original:cP(n,e.id),texts:[...e.texts]}))}function _P(e,t){if(!e||e.status===`applied`||e.status===`failed`)return`run`;if(e.status===`running`)return`busy`;let n=e.scopedIds??[];return e.scope?.kind===`slot`&&e.scope.key===t.scope.key&&n.length===t.ids.length&&t.ids.every(e=>n.includes(e))?`same`:`waiting`}function vP(e,t){return e===`busy`?`an assessment is already running here — when it ends, the sheet's check button runs this one`:e===`waiting`?`another proposal is waiting here — decide it, or tap “${sP(t,!0)}” to replace it`:null}function yP(e){let t=[...e.splits];return{rows:[...e.rows],merges:[...e.merges],news:[...e.news],...t.length?{splits:t}:{},pinRanks:e.pinRanks,writeNames:e.writeNames}}function bP(e,t){return[`In ${t}, this row is archived (its words kept):`,e.original.text??`${e.id} — its words are not on this phone`,`and two rows are posted on the same clock:`,`1. ${e.texts[0]??``}`,`2. ${e.texts[1]??``}`]}var xP=[],SP=[],CP=null,wP=null,TP=new Set,EP=()=>{for(let e of TP)e()};function DP(){let e=ma(R.slotAskOff,[]);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}function OP(e){return DP().includes(e)}function kP(e,t){let n=DP().filter(t=>t!==e);Ta(R.slotAskOff,t?[...n,e]:n),t&&(SP=SP.filter(t=>t.repoDir!==e),CP?.check.repoDir===e&&(CP=null)),EP()}function AP(e,t){if(!e||!t||OP(t))return;let n=eP(xP.find(t=>t.id===e));SP=[...SP.filter(t=>t.id!==e),{id:e,repoDir:t,was:n,since:Date.now()}]}function jP(e){if(xP=e,!SP.length)return;let t=Date.now(),n=[],r=null;for(let i of SP){let a=tP(i,e,t,OP(i.repoDir));a.kind===`wait`?n.push(i):a.kind===`ask`&&(r=a.ask)}SP=n,r&&(CP=r,EP())}function MP(){return CP}function NP(e){return TP.add(e),()=>{TP.delete(e)}}function PP(){CP&&(CP=null,EP())}function FP(e){wP=e}function IP(e){return wP?(wP(e),!0):!1}var LP=e=>e.status===`queued`||e.status===`failed`,RP={checking:`checking…`,done:`implemented`,partial:`partial`,questions:`open questions`,not_done:`not done`,error:`check failed`,limited:`not checked — usage limit`},zP={checking:$s,done:vc,partial:Cc,questions:cs,not_done:B,error:gs,limited:go},BP={validating:`validating…`,achieved:`outcome achieved`,likely:`likely achieved`,unlikely:`likely not achieved`,unclear:`unclear`,error:`validate failed`,limited:`not validated — usage limit`},VP={validating:$s,achieved:vc,likely:Cc,unlikely:B,unclear:cs,error:gs,limited:go},HP={bug:vl,feature:ll,enhancement:nl,chore:bs},UP=`__closed`;function WP(e,t,{text:n,repoDir:r,filter:i,showArchived:a},o){let s=(0,V.useMemo)(()=>VN(e.autoSlots,e.sessions),[e.autoSlots,e.sessions]),c=r?e.cutVerbs.assessBlocked?.(r)??null:null,l=e.sessions.filter(e=>e.running&&e.cwd===r),u=(0,V.useMemo)(()=>new Set(e.sessions.filter(e=>e.running).map(e=>e.id)),[e.sessions]),d=e=>Zj(e,u),f=t=>!t.targetSessionId&&QA(t.repoDir,e.intents,t.id,e.sessions),p=e=>Xj(e,u)===`held-closed`,m=e=>!!e.targetSessionId&&!u.has(e.targetSessionId)&&!e.reopensConv,h=e=>!!e.targetSessionId&&!u.has(e.targetSessionId)&&!!e.reopensConv,g=e=>!!e.targetSessionId&&u.has(e.targetSessionId),_=e.activeSession&&e.sessions.some(t=>t.running&&t.id===e.activeSession.id)?e.activeSession:null,v=_&&_.cwd===r?_:null,y=e=>!!_&&e.targetSessionId===_.id&&!!e.autoFire,b=t=>{let n=e.repos.find(e=>e.worktreePath===t);return n?Qn(n):t.split(/[/\\]/).filter(Boolean).pop()||t},x=e.items.filter(e=>e.repoDir===r),S=i.ids||a?x:x.filter(e=>!Vj(e)),C=_fe(S,i,t),w=(0,V.useMemo)(()=>nP(x,r),[x,r]),T=(0,V.useSyncExternalStore)(NP,()=>OP(r)),E=mfe(i),D=E?S.filter(e=>hfe(e,i,t)):S,O=n.trim().toLowerCase(),k=O?D.filter(e=>`${zr(e)??``} ${e.label??``} ${e.text}`.toLowerCase().includes(O)):D,A=x.filter(e=>e.archived).length,j=new Map(e.items.map(e=>[e.id,e])),M=e=>iM(e)??(e.text.length>40?`${e.text.slice(0,40)}…`:e.text),N=(0,V.useMemo)(()=>new Set(e.naming??[]),[e.naming]),P=e=>e.targetSessionId?l.some(t=>t.id===e.targetSessionId)?e.targetSessionId:e.reopensConv?``:UP:``,F=[],ee=k.filter(e=>P(e)===``);ee.length&&F.push({key:``,title:`Each in a new session`,running:!0,items:ee});let te=k.filter(e=>P(e)===UP);te.length&&F.push({key:UP,title:`Aimed at a session that closed`,running:!1,items:te});for(let e of l){let t=k.filter(t=>P(t)===e.id);t.length&&F.push({key:e.id,title:`In ${bi(e)}`,running:!0,items:t})}let ne=F.flatMap(e=>e.items),re=ne.filter(aM),ie=re.filter(e=>o.has(e.id)).map(e=>e.id),ae=(0,V.useMemo)(()=>kfe(S),[S]),oe=ppe(ae,re),se=new Set,ce=e=>!!e.manual||!!e.at&&(e.at.nextAt==null||e.at.nextAt>t);if(e.auto)for(let e of F){if(e.key===`__closed`)continue;let t=e.items.find(e=>e.status===`queued`&&!ce(e));t&&se.add(t.id)}let le={fresh:0,aimed:0,held:0,other:0};for(let e of D){let t=P(e);e.archived?le.other++:e.status===`queued`&&!ce(e)?t===``?le.fresh++:t===`__closed`?le.held++:le.aimed++:e.status===`queued`&&(ce(e)||t===`__closed`)?le.held++:le.other++}return{slotSessions:s,assessWhyNot:c,repoSessions:l,liveSessionIds:u,runAgainOffered:d,fireIntoBusy:f,runAgainHeld:p,targetClosed:m,targetReopens:h,targetLive:g,here:_,hereInRepo:v,queuedHere:y,repoLabel:b,inRepo:x,base:S,counts:C,filtering:E,cut:D,q:O,visible:k,archivedCount:A,byId:j,nameOf:M,namingIds:N,groupKeyOf:P,groups:F,displayOrder:ne,retimeable:re,retimeIds:ie,clockCuts:ae,retimeClocks:oe,nextFireIds:se,clockAhead:ce,focusBreakdown:le,focusWords:i.ids?yfe(le,e.auto):null,bulkClockIds:i.status===`failed`?D.filter(e=>!!e.at).map(e=>e.id):[],bulkRunAgainIds:i.status===`failed`?Gfe(D,u):[],bulkRunAgainAimed:i.status===`failed`?Kfe(D,u):0,bulkDoneIds:i.status===`done`?D.filter(e=>!e.archived).map(e=>e.id):[],assessIds:Dfe(D),nameIds:npe(D),namingHere:x.some(e=>N.has(e.id)),slotCheckList:w,slotAskOff:T}}var GP=R.backlogDraft;function KP(){let[e,t]=(0,V.useState)(()=>(z(GP)??``).trim());return{strandedDraft:e,dropStrandedDraft:()=>{wa(GP),t(``)}}}function qP(e,{displayOrder:t,groupKeyOf:n}){let[r,i]=(0,V.useState)(null),a=e.online,o=(0,V.useRef)({displayOrder:t,groupKeyOf:n,verbs:e.cutVerbs});return o.current={displayOrder:t,groupKeyOf:n,verbs:e.cutVerbs},(0,V.useEffect)(()=>{if(!r)return;let e=e=>{let t=(document.elementFromPoint(e.clientX,e.clientY)?.closest(`[data-blid]`))?.getAttribute(`data-blid`);if(!t||t===r)return;let{displayOrder:n,groupKeyOf:i}=o.current,a=n.find(e=>e.id===r),s=n.find(e=>e.id===t);if(!a||!s||i(a)!==i(s))return;let c=n.map(e=>e.id),l=c.indexOf(r),u=c.indexOf(t);l!==-1&&u!==-1&&(c.splice(l,1),c.splice(u,0,r),o.current.verbs.onReorder(c))},t=()=>i(null);return window.addEventListener(`pointermove`,e,{passive:!1}),window.addEventListener(`pointerup`,t),window.addEventListener(`pointercancel`,t),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,t),window.removeEventListener(`pointercancel`,t)}},[r]),{dragId:r,setDragId:i,canDrag:a}}function JP(e){let[t,n]=(0,V.useState)(null),[r,i]=(0,V.useState)(``),[a,o]=(0,V.useState)(``),[s,c]=(0,V.useState)(``),[l,u]=(0,V.useState)(``),[d,f]=(0,V.useState)(``),[p,m]=(0,V.useState)(``);function h(e){n(e.id),i(e.text),o(e.label??``),c(e.repoDir),u(e.targetSessionId??``),f(e.headline??``),m(e.category??``)}function g(t){let i=r.trim();if(!i)return;let o={};i!==t.text&&(o.text=i),(a||void 0)!==t.label&&(o.label=a);let c=d.trim();c!==(t.headline??``)&&(o.headline=c),p!==(t.category??``)&&(o.category=p),t.status!==`running`&&(s&&s!==t.repoDir&&(o.repoDir=s),(l||``)!==(t.targetSessionId??``)&&(o.targetSessionId=l)),Object.keys(o).length>0&&e.verbs.onUpdate(t.id,o),n(null)}return{editingId:t,setEditingId:n,editText:r,setEditText:i,editLabel:a,setEditLabel:o,editRepo:s,setEditRepo:c,editTarget:l,setEditTarget:u,editHeadline:d,setEditHeadline:f,editCategory:p,setEditCategory:m,beginEdit:h,saveEdit:g}}var YP=R.backlogShowArchived,XP=R.backlogRepo;function ZP(e){let[t,n]=(0,V.useState)(``),r=(()=>{if(e.defaultRepoDir&&e.repos.some(t=>t.worktreePath===e.defaultRepoDir))return e.defaultRepoDir;let t=z(XP);return t&&e.repos.some(e=>e.worktreePath===t)?t:e.items.find(t=>!t.archived&&e.repos.some(e=>e.worktreePath===t.repoDir))?.repoDir??e.repos[0]?.worktreePath??``})(),[i,a]=(0,V.useState)(r),o=(0,V.useRef)(r===e.defaultRepoDir?e.defaultRepoDir:void 0);(0,V.useEffect)(()=>{let t=e.defaultRepoDir;t&&o.current!==t&&e.repos.some(e=>e.worktreePath===t)&&(o.current=t,a(t),u(e=>e.ids?{...e,ids:null}:e),f(void 0))},[e.defaultRepoDir,e.repos]);let[s,c]=(0,V.useState)(()=>z(YP)===`1`),[l,u]=(0,V.useState)(e.focusIds?{...Bj,ids:e.focusIds.ids}:Bj),[d,f]=(0,V.useState)(e.focusIds?.label),p=(e,t)=>{f(t),u(t=>({...t,ids:e}))},m=()=>{f(void 0),u(Bj)},h=(0,V.useRef)(e.focusIds);(0,V.useEffect)(()=>{h.current!==e.focusIds&&(h.current=e.focusIds,e.focusIds&&(f(e.focusIds.label),u({...Bj,ids:e.focusIds.ids})))},[e.focusIds]);function g(e){a(e),e&&ua(XP,e),u(e=>e.ids?{...e,ids:null}:e),f(void 0)}let _=e=>u(t=>({...t,status:t.status===e?null:e})),v=e=>u(t=>({...t,age:t.age===e?null:e})),y=e=>u(t=>({...t,category:t.category===e?null:e})),b=()=>u(e=>({...e,clock:!e.clock||null}));function x(){let e=!s;c(e),e?ua(YP,`1`):wa(YP)}return{text:t,setText:n,repoDir:i,showArchived:s,filter:l,idsLabel:d,showIds:p,clearFilter:m,selectRepo:g,pickStatus:_,pickAge:v,pickCategory:y,pickClock:b,toggleArchived:x}}function QP(){let[e,t]=(0,V.useState)(!1),[n,r]=(0,V.useState)(()=>new Set),[i,a]=(0,V.useState)(!1),[o,s]=(0,V.useState)(new Set),c=e=>s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),[l,u]=(0,V.useState)(new Set),d=e=>u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),[f,p]=(0,V.useState)(new Set),[m,h]=(0,V.useState)(new Set),[g,_]=(0,V.useState)(new Set);return{picking:e,setPicking:t,picked:n,setPicked:r,choosing:i,setChoosing:a,openDetail:o,toggleDetail:c,openValidate:l,toggleValidate:d,openText:f,toggleText:e=>p(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),slotOpen:m,setSlotOpen:h,budgetOpen:g,toggleBudget:e=>_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}}function $P(e,t,n=[]){if(t)return e;let r=new Set(n);return e.filter(e=>e.isPrimary||r.has(e.worktreePath))}function eF(e,t){if(!t)return e;let n=e.findIndex(e=>e.worktreePath===t);return n<0?e:[e[n],...e.slice(0,n),...e.slice(n+1)]}var tF=e=>e.isPrimary?e.repoName:e.branch,nF=e=>e.isPrimary?Ci(e)??``:`worktree · ${e.repoName}`,rF=e=>Qn(e),iF=e=>e.some(e=>!e.isPrimary);function aF({repos:e,home:t,worktreeFilter:n=!0,emptyText:r=`No repos under host root.`,multi:i,selected:a=[],onChange:o,onPick:s,value:c,icon:l,hint:u,label:d,countHint:f,note:p,subLead:m,listClass:h=`list`}){let[g,_]=(0,V.useState)(!1),v=n&&iF(e),y=(0,V.useMemo)(()=>eF(e,t),[e,t]),b=(0,V.useMemo)(()=>[...a,t,c].filter(e=>!!e),[a,t,c]),x=(0,V.useMemo)(()=>$P(y,!v||g,b),[y,v,g,b]),S=(0,V.useMemo)(()=>new Set(a),[a]),C=e=>{if(!i){s?.(e);return}let t=new Set(S);t.has(e.worktreePath)?t.delete(e.worktreePath):t.add(e.worktreePath),o?.([...t])};return(0,J.jsxs)(J.Fragment,{children:[u&&(0,J.jsx)(Z,{children:u}),(d||v||i)&&(0,J.jsxs)(`div`,{className:`section section-head`,children:[(0,J.jsxs)(`span`,{children:[d??(i?`Repos`:``),i&&(0,J.jsxs)(`span`,{className:`section-hint`,children:[` · `,S.size,` selected`,f?` ${f}`:``]})]}),(0,J.jsxs)(`span`,{className:`head-acts`,children:[i&&(0,J.jsx)(`button`,{className:`link-btn`,onClick:()=>o?.(x.map(e=>e.worktreePath)),children:`all`}),i&&(0,J.jsx)(`button`,{className:`link-btn`,onClick:()=>o?.([]),children:`none`}),v&&(0,J.jsx)(`button`,{className:`link-btn ${g?`active`:``}`,onClick:()=>_(e=>!e),children:g?`primaries only`:`worktrees`})]})]}),(0,J.jsxs)(`div`,{className:h,children:[x.map(e=>{let n=!!t&&e.worktreePath===t,r=i?S.has(e.worktreePath):c===e.worktreePath,a=p?.(e);return(0,J.jsxs)(`button`,{className:`row${r?` sched-on`:``}${n?` home`:``}`,onClick:()=>C(e),children:[(0,J.jsxs)(Zw,{children:[i?r?(0,J.jsx)(vc,{size:14}):null:l,` `,tF(e)]}),(0,J.jsxs)(Q,{children:[m?`${m} · `:``,nF(e),n?` · where these words came from`:``,a?` · ${a}`:``]})]},e.id)}),x.length===0&&(0,J.jsx)($,{children:r})]})]})}function oF({repos:e,home:t,worktreeFilter:n=!1,value:r,onChange:i,note:a,keepValue:o,placeholder:s,className:c=`search`,"aria-label":l}){let[u,d]=(0,V.useState)(!1),f=n&&iF(e),p=(0,V.useMemo)(()=>eF(e,t),[e,t]),m=(0,V.useMemo)(()=>$P(p,!f||u,r?[r]:[]),[p,f,u,r]),h=o&&r&&!e.some(e=>e.worktreePath===r)?r:null;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`select`,{className:c,value:r,"aria-label":l,onChange:e=>i(e.target.value),children:[s&&(0,J.jsx)(`option`,{value:``,children:s}),h&&(0,J.jsxs)(`option`,{value:h,children:[h.split(/[/\\]/).filter(Boolean).pop()||h,` (gone)`]}),m.map(e=>(0,J.jsxs)(`option`,{value:e.worktreePath,children:[rF(e),t&&e.worktreePath===t?` · where these words came from`:``,a?.(e)?` · ${a(e)}`:``]},e.id))]}),f&&(0,J.jsx)(`button`,{className:`linkish`,onClick:()=>d(e=>!e),children:u?`primaries only`:`show worktrees`})]})}function sF({m:e}){let{p:t,repoDir:n}=e;return(0,J.jsxs)(Uw,{title:`Backlog`,onClose:t.nav.onClose,children:[n&&(0,J.jsxs)(`button`,{className:`rc`,title:`write something for this repo — the send sheet, with the repo already chosen`,onClick:()=>{q(`action:backlog.send`),t.nav.onOpenSend(n)},children:[(0,J.jsx)(Uc,{size:14}),` send…`]}),(0,J.jsx)(`button`,{className:`rc ${t.auto?`on`:`off`}`,onClick:()=>t.cutVerbs.onSetAuto(!t.auto),children:t.auto?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Ls,{size:14}),` auto`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(zc,{size:14}),` auto off`]})})]})}function cF({m:e}){let{assessIds:t,assessWhyNot:n,cut:r,filtering:i,p:a,repoDir:o,selectRepo:s}=e;return(0,J.jsx)(J.Fragment,{children:(0,J.jsxs)(`div`,{className:`form bl-repobar`,children:[(0,J.jsx)(oF,{repos:a.repos,value:o,onChange:s,"aria-label":`repo`}),a.cutVerbs.onAssess&&o?n?(0,J.jsxs)(Z,{as:`span`,children:[`assess: `,n]}):i&&!t.length?(0,J.jsx)(Z,{as:`span`,children:Efe}):(0,J.jsxs)(Y,{title:i?`judge exactly the open rows in this cut — it still reads the whole repo as evidence, and nothing applies itself`:`read this repo and judge what is left in it — with evidence, and nothing applies itself`,onClick:()=>{q(`action:backlog.assess`),a.cutVerbs.onAssess?.(o,i?t:void 0)},children:[(0,J.jsx)(To,{size:14}),` `,i?wfe(t.length):`assess`]}):null,a.cutVerbs.onAssess&&o&&!n&&i&&t.length>0&&(0,J.jsx)(Z,{as:`span`,children:Tfe(t.length,r.length)})]})})}function lF({m:e}){let{focusWords:t,p:n}=e;return(0,J.jsx)(J.Fragment,{children:!n.auto&&!t&&(0,J.jsx)(`div`,{className:`form`,children:(0,J.jsx)(Z,{children:(0,J.jsxs)(tT,{of:`auto off`,label:`what does auto off stop?`,children:[(0,J.jsx)(`b`,{children:`auto`}),` is off on this desktop: nothing queued anywhere runs until you turn it back on or fire an item by hand.`]})})})})}function uF({m:e}){let{dropStrandedDraft:t,p:n,repoDir:r,strandedDraft:i}=e;return(0,J.jsx)(J.Fragment,{children:i&&(0,J.jsx)(`div`,{className:`form`,children:(0,J.jsxs)(Z,{children:[(0,J.jsx)(`b`,{children:`Kept from before`}),` — this was the old add/search field, so it may be a search you typed:`,` `,`“`,i.length>160?`${i.slice(0,160)}…`:i,`”`,(0,J.jsxs)(`div`,{className:`annot-tools`,style:{marginTop:6},children:[(0,J.jsxs)(Y,{onClick:()=>{let e=i;t(),n.nav.onOpenSend(r,e)},children:[(0,J.jsx)(Uc,{size:14}),` send it`]}),(0,J.jsxs)(fC,{confirm:`discard it?`,title:`throw these words away`,onConfirm:t,children:[(0,J.jsx)(B,{size:14}),` discard`]})]})]})})})}function dF({m:e}){let{here:t,hereInRepo:n,p:r}=e;return(0,J.jsxs)(J.Fragment,{children:[r.online&&!n&&(t?(0,J.jsx)(`div`,{className:`form`,children:(0,J.jsxs)(Z,{children:[`No wait verb on these items: the session you came from (`,(0,J.jsx)(`b`,{children:t.title}),`) is in another repo, and an item can only run in a session opened on its own checkout.`]})}):r.activeSession?(0,J.jsx)(`div`,{className:`form`,children:(0,J.jsx)(Z,{children:`No wait verb on these items: the session you came from is no longer running, so there is nothing to hand one to.`})}):null),!r.online&&(0,J.jsx)(`div`,{className:`form`,children:(0,J.jsxs)(Z,{children:[`Offline — showing the last synced backlog. Every mutation (fire, edit, done, check, validate, continue, reorder, archive, remove) is disabled until the connection is back; `,(0,J.jsx)(`b`,{children:`send…`}),` still queues normally.`]})})]})}function fF({m:e}){let{archivedCount:t,base:n,counts:r,filter:i,filtering:a,pickAge:o,pickCategory:s,pickClock:c,pickStatus:l,setText:u,showArchived:d,text:f,toggleArchived:p}=e,m=vfe(r,i),h=m.status.length>0||m.clock||m.age.length>0||m.category.length>0;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`form bl-searchrow`,children:[(0,J.jsxs)(`div`,{className:`bl-search`,children:[(0,J.jsx)(rc,{size:16,className:`bl-search-icon`}),(0,J.jsx)(`textarea`,{className:`search bl-combo`,rows:1,placeholder:`Search this repo…`,value:f,onChange:e=>u(e.target.value)}),f&&(0,J.jsx)(`button`,{className:`bl-search-clear`,onClick:()=>u(``),title:`clear`,children:(0,J.jsx)(B,{size:16})})]}),t>0&&(0,J.jsxs)(zw,{on:d,onClick:p,title:d?`hide archived items again`:`show this repo's archived items too`,children:[(0,J.jsx)(oo,{size:13,"aria-hidden":!0}),Iw(`archived`,{count:t})]})]}),n.length>0&&h&&(0,J.jsxs)(`div`,{className:`bl-fchips`,children:[(m.status.length>0||m.clock)&&(0,J.jsxs)(`div`,{className:`fchips wrap`,children:[m.status.map(e=>(0,J.jsx)(zw,{on:i.status===e,title:`show only ${e} items${i.age?` from the ${Pj[i.age]}`:``}`,onClick:()=>{q(`action:backlog.filter.status`),l(e)},children:Iw(e,{count:r.status[e]})},e)),m.status.length>0&&m.clock&&(0,J.jsx)(`span`,{className:`fchips-gap`,"aria-hidden":!0}),m.clock&&(0,J.jsxs)(zw,{on:!!i.clock,title:i.clock?`show the items with no clock again`:`show only the ${r.clock} item${r.clock===1?``:`s`} waiting for an instant${i.status?` · ${i.status}`:``} — grouped by the clock they share, in the order they will run`,onClick:()=>{q(`action:backlog.filter.clock`),c()},children:[(0,J.jsx)(rl,{size:12,"aria-hidden":!0}),Iw(`on a clock`,{count:r.clock})]})]}),m.age.length>0&&(0,J.jsx)(`div`,{className:`fchips wrap`,children:m.age.map(e=>(0,J.jsx)(zw,{on:i.age===e,title:`show only ${i.status?`${i.status} `:``}items added ${e===`older`?`over a week ago`:`in the ${Pj[e]}`}`,onClick:()=>{q(`action:backlog.filter.age`),o(e)},children:Iw(Pj[e],{count:r.age[e]})},e))}),m.category.length>0&&(0,J.jsx)(`div`,{className:`fchips wrap`,children:m.category.map(e=>{let t=e===`none`?null:HP[e];return(0,J.jsxs)(zw,{on:i.category===e,title:pfe(e,i.category===e),onClick:()=>{q(`action:backlog.filter.category`),s(e)},children:[t&&(0,J.jsx)(t,{size:12,"aria-hidden":!0}),Iw(ffe[e],{count:r.category[e]})]},e)})})]}),a&&!i.ids&&(0,J.jsx)(pF,{m:e})]})}function pF({m:e}){let{base:t,clearFilter:n,cut:r,filter:i,idsLabel:a}=e;return(0,J.jsxs)(`div`,{className:`section filter-bar`,children:[(0,J.jsxs)(`span`,{className:`filter-bar-txt`,children:[gfe(i,a),` · `,bfe(r.length,t.length,i),r.length===0&&` — nothing here is in that cut`]}),(0,J.jsxs)(`button`,{className:`filter-bar-clear`,title:`clear the filter — show every item in this repo again`,onClick:()=>{q(`action:backlog.filter.clear`),n()},children:[(0,J.jsx)(B,{size:13}),` clear`]})]})}function mF({note:e,children:t}){return(0,J.jsxs)(`div`,{className:`bl-bulk-bar`,children:[(0,J.jsx)(Z,{children:e}),(0,J.jsx)(`div`,{className:`bl-bulk`,children:t})]})}function hF({m:e}){let{bulkClockIds:t,bulkDoneIds:n,bulkRunAgainAimed:r,bulkRunAgainIds:i,cut:a,focusWords:o,p:s,runAgainOffered:c}=e;return(0,J.jsxs)(J.Fragment,{children:[o&&s.auto&&(0,J.jsx)(`div`,{className:`bl-bulk-bar`,children:(0,J.jsx)(Z,{children:(0,J.jsx)(tT,{of:`when these run`,label:`when do these run?`,children:o})})}),o&&!s.auto&&(0,J.jsx)(mF,{note:o,children:(0,J.jsxs)(`button`,{className:`link-btn`,title:`turn the desktop's auto switch back on — the same switch as the chip in this sheet's head`,onClick:()=>{q(`action:backlog.auto.focus`),s.cutVerbs.onSetAuto(!0)},children:[(0,J.jsx)(Ls,{size:14}),` `,`turn auto on`]})}),t.length>1&&s.online&&(0,J.jsx)(mF,{note:Hfe(t.length,a.length),children:(0,J.jsxs)(fC,{className:`link-btn`,confirm:`drop all ${t.length}?`,title:Kj(`failed`),onConfirm:()=>{q(`action:backlog.dropclock.all`),s.cutVerbs.onDropClocks(t)},children:[(0,J.jsx)(yo,{size:14}),` `,Vfe(t.length)]})}),i.length>1&&(0,J.jsx)(mF,{note:Qj(i.length,a.length,r),children:(0,J.jsxs)(fC,{className:`link-btn`,confirm:`run all ${i.length} again?`,title:Qj(i.length,a.length,r),onConfirm:()=>{q(`action:backlog.runagain.all`),s.cutVerbs.onRunAgainMany(a.filter(e=>c(e)).map(e=>({id:e.id,failedAt:e.finishedAt})))},children:[(0,J.jsx)(tc,{size:14}),` `,qfe(i.length)]})}),n.length>1&&s.online&&(0,J.jsx)(mF,{note:Sfe(n.length,a.length),children:(0,J.jsxs)(fC,{className:`link-btn`,confirm:`archive all ${n.length}?`,title:`they keep their words and stay in show archived — any one of them comes back from its own row`,onConfirm:()=>{q(`action:backlog.archive.done`),s.cutVerbs.onArchiveMany(n)},children:[(0,J.jsx)(oo,{size:14}),` `,xfe(n.length)]})})]})}function gF({m:e}){let{choosing:t,cut:n,displayOrder:r,nameIds:i,namingHere:a,p:o,picking:s,repoDir:c,retimeable:l,retimeClocks:u,retimeIds:d,setChoosing:f,setPicked:p,setPicking:m,slotCheckList:h,slotAskOff:g,now:_}=e,v=o.online&&!s&&!!o.cutVerbs.onSlotCheck&&h.length>0,y=o.online&&g,b=o.online&&!s&&l.length>1,x=e=>{q(`action:backlog.retime.clock`),p(new Set(e)),m(!0)},S=i.length>0&&o.online;return(0,J.jsxs)(J.Fragment,{children:[(b||S||v||y)&&(0,J.jsxs)(`div`,{className:`bl-bulk`,children:[b&&(0,J.jsxs)(`button`,{className:`link-btn`,title:`tick several rows and move them all to one new time`,onClick:()=>{q(`action:backlog.retime.pick`),m(!0)},children:[(0,J.jsx)(Wo,{size:14}),` `,`pick to re-time`]}),b&&u.map(e=>(0,J.jsxs)(`button`,{className:`link-btn`,title:`tick every row on this clock — then choose their new when`,onClick:()=>x(e.ids),children:[(0,J.jsx)(rl,{size:14}),` `,mpe(e)]},e.key)),v&&h.map(e=>(0,J.jsxs)(`button`,{className:`link-btn`,title:aP(e),onClick:()=>{q(`action:backlog.slotcheck`),o.cutVerbs.onSlotCheck?.(e)},children:[(0,J.jsx)(To,{size:14}),` `,iP(e,_)]},e.scope.key)),y&&(0,J.jsxs)(`button`,{className:`link-btn`,title:`after you post a timed row here that runs together with others, offer to check them as a group`,onClick:()=>{q(`action:backlog.slotask.on`),kP(c,!1),K($N(vp(c)))},children:[(0,J.jsx)(No,{size:14}),` `,`ask after a timed send`]}),S&&(a?(0,J.jsx)(Qw,{cants:[{label:eM(i.length),reason:`a naming pass is already running for this repo`}]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{className:`link-btn`,"data-hint":`backlog.name`,title:tM(i.length,n.length),onClick:()=>{q(`action:backlog.name`),o.cutVerbs.onName(c,i)},children:[(0,J.jsx)(xl,{size:14}),` `,eM(i.length)]}),(0,J.jsxs)(tT,{of:`naming`,children:[tM(i.length,n.length),(0,J.jsx)(`div`,{className:`bl-cost`,children:`one short toolless call on the cheap model — reads the items' own words and nothing else`})]})]}))]}),o.online&&s&&(0,J.jsx)(`div`,{className:`bl-pick-bar`,children:(0,J.jsx)(oM,{picked:d.length,eligible:l.length,shown:r.length,where:`backlog`,onAll:()=>p(new Set(l.map(e=>e.id))),onNone:()=>p(new Set),onDone:()=>{m(!1),p(new Set)},onChoose:()=>f(!0)})}),t&&d.length>0&&(0,J.jsx)(sM,{children:o.nav.renderRetime(d,{onSent:()=>{f(!1),m(!1),p(new Set)},onCancel:()=>f(!1)})})]})}function _F({m:e,row:t}){let{beginEdit:n,fireIntoBusy:r,here:i,p:a,queuedHere:o,runAgainOffered:s}=e,{it:c}=t,l=r(c)?`${XA(!c.targetSessionId)} — ${ZA}`:XA(!c.targetSessionId),u=ope(c,a.sessions);return(0,J.jsxs)(`div`,{className:`bl-actions`,children:[a.online&&(0,J.jsx)(Y,{title:`edit`,onClick:()=>n(c),children:(0,J.jsx)(Mo,{size:14})}),c.status===`queued`&&i&&i.cwd===c.repoDir&&a.online&&(o(c)?(0,J.jsxs)(Y,{className:`on`,"data-hint":`backlog.queuehere`,title:`waiting for ${i.title} — it goes in when that session is next free, whether or not the global auto switch is on. Tap to take it back off`,onClick:()=>{q(`action:backlog.unqueuehere`),a.verbs.onQueueHere(c.id,``)},children:[(0,J.jsx)(go,{size:14}),` waits for `,i.title]}):(0,J.jsxs)(Y,{"data-hint":`backlog.queuehere`,title:`hand it to ${i.title} — it goes to the bottom of that session's queue and runs when the session is next free, whether or not the global auto switch is on`,onClick:()=>{q(`action:backlog.queuehere`),a.verbs.onQueueHere(c.id,i.id)},children:[(0,J.jsx)(go,{size:14}),` when `,i.title,` is free`]})),c.at&&LP(c)&&a.online&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(Y,{title:`change its time — the send sheet, with this row already in it`,onClick:()=>{q(`action:backlog.editwhen`),a.verbs.onEditWhen(c.id)},children:[(0,J.jsx)(rl,{size:14}),` when`]}),(0,J.jsxs)(fC,{confirm:`drop it?`,title:Kj(c.status),onConfirm:()=>{q(`action:backlog.dropclock`),a.verbs.onDropClock(c.id,c.status)},children:[(0,J.jsx)(yo,{size:14}),` drop the clock`]})]}),u&&(0,J.jsxs)(Y,{"data-hint":`backlog.openholder`,title:u.title,onClick:()=>{q(`action:backlog.openholder`),a.nav.onOpenSession(u.sessionId)},children:[(0,J.jsx)(zo,{size:14}),` `,u.label]}),c.status===`queued`&&a.online&&(0,J.jsx)(Y,{className:c.manual?`primary`:void 0,"data-hint":`backlog.fire`,title:l,onClick:()=>{q(`action:backlog.fire`),a.verbs.onFire(c.id)},children:`fire`}),s(c)&&(0,J.jsxs)(Y,{"data-hint":`backlog.runagain`,title:Jj(c),onClick:()=>{q(`action:backlog.runagain`),a.verbs.onRunAgain(c.id,c.finishedAt)},children:[(0,J.jsx)(tc,{size:14}),` `,`run it again`]}),(c.status===`done`||c.status===`failed`)&&a.online&&(0,J.jsx)(Y,{"data-hint":`backlog.refire`,title:l,onClick:()=>{q(`action:backlog.refire`),a.verbs.onFire(c.id)},children:`re-fire`}),c.sessionId&&(0,J.jsxs)(Y,{title:`go to the session it ran in`,onClick:()=>a.nav.onOpenSession(c.sessionId),children:[(0,J.jsx)(zo,{size:14}),` open`]}),(c.status===`done`||c.status===`failed`||c.status===`running`)&&a.online&&(c.checkStatus===`checking`?(0,J.jsxs)(`span`,{className:`bl-waiting`,children:[(0,J.jsx)(Qs,{size:14}),` checking…`]}):(0,J.jsxs)(Y,{title:`check if implemented`,onClick:()=>a.verbs.onCheck(c.id),children:[(0,J.jsx)(Qs,{size:14}),` check`]})),(c.status===`done`||c.status===`failed`||c.status===`running`)&&a.online&&(c.validateStatus===`validating`?(0,J.jsxs)(`span`,{className:`bl-waiting`,children:[(0,J.jsx)(xl,{size:14}),` validating…`]}):(0,J.jsxs)(Y,{title:`validate the expected outcome & get next steps`,onClick:()=>a.verbs.onValidate(c.id),children:[(0,J.jsx)(xl,{size:14}),` validate`]})),c.status===`running`&&a.online&&(0,J.jsx)(Y,{"data-hint":`backlog.done`,onClick:()=>{q(`action:backlog.done`),a.verbs.onDone(c.id)},children:`done`}),c.status!==`running`&&a.online&&(c.archived?(0,J.jsx)(Y,{title:`unarchive`,onClick:()=>a.verbs.onArchive(c.id,!1),children:(0,J.jsx)(Co,{size:14})}):(0,J.jsx)(Y,{title:`archive`,onClick:()=>a.verbs.onArchive(c.id,!0),children:(0,J.jsx)(oo,{size:14})})),a.online&&(0,J.jsx)(Y,{variant:`danger`,onClick:()=>{q(`action:backlog.remove`),a.verbs.onRemove(c.id)},children:(0,J.jsx)(B,{size:16})})]})}function vF({m:e,row:t}){let{clockCuts:n,namingIds:r,nextFireIds:i,now:a,p:o,targetClosed:s,targetReopens:c}=e,{it:l}=t;return(0,J.jsxs)(`span`,{className:`bl-meta`,children:[(0,J.jsx)(`span`,{className:`tag-${l.status}`,children:l.status}),l.category&&(()=>{let e=HP[l.category];return(0,J.jsxs)(`span`,{className:`bl-chip bl-cat`,children:[(0,J.jsx)(e,{size:11,style:{verticalAlign:`-1px`}}),` `,l.category]})})(),r.has(l.id)&&(0,J.jsxs)(`span`,{className:`bl-chip bl-naming`,title:`a naming pass is reading this row's words right now`,children:[(0,J.jsx)(xl,{size:11,style:{verticalAlign:`-1px`}}),` naming…`]}),(0,J.jsxs)(`span`,{className:`bl-age`,title:`added ${new Date(l.createdAt).toLocaleString()} (${Pj[Fj(l.createdAt,a)]})`,children:[`added `,Tp(l.createdAt)]}),l.status===`running`&&l.startedAt!=null&&(0,J.jsxs)(`span`,{className:`bl-age`,title:`started ${new Date(l.startedAt).toLocaleString()}`,children:[`running `,rM(a-l.startedAt)]}),l.status!==`running`&&l.finishedAt!=null&&(0,J.jsxs)(`span`,{className:`bl-age`,title:`finished ${new Date(l.finishedAt).toLocaleString()}`,children:[l.status===`failed`?`failed`:`finished`,` `,Tp(l.finishedAt),l.startedAt!=null&&l.finishedAt>=l.startedAt?` · took ${rM(l.finishedAt-l.startedAt)}`:``]}),l.checkedAt!=null&&(0,J.jsxs)(`span`,{className:`bl-age`,title:`checked ${new Date(l.checkedAt).toLocaleString()}`,children:[`checked `,Tp(l.checkedAt)]}),l.validatedAt!=null&&(0,J.jsxs)(`span`,{className:`bl-age`,title:`validated ${new Date(l.validatedAt).toLocaleString()}`,children:[`validated `,Tp(l.validatedAt)]}),(l.steps??1)>1&&(0,J.jsxs)(`span`,{className:`bl-age`,title:`delivered one turn at a time, in one session`,children:[l.steps,` turns`]}),l.resume&&(0,J.jsxs)(`span`,{className:`bl-age`,title:`it reopens this repo's last conversation instead of starting clean`,children:[(0,J.jsx)(Xs,{size:11,style:{verticalAlign:`-1px`}}),` continued`]}),RN(l)&&LN(l.closeWhenDone)&&(0,J.jsxs)(`span`,{className:`bl-age`,children:[l.closeWhenDone?(0,J.jsx)(Po,{size:11,style:{verticalAlign:`-1px`}}):(0,J.jsx)(Ya,{size:11,style:{verticalAlign:`-1px`}}),` `,LN(l.closeWhenDone)]}),RN(l)&&l.flagWhenDone&&(0,J.jsxs)(`span`,{className:`bl-age fu-launch`,title:`its session gets the follow-up flag once it is done`,children:[(0,J.jsx)(Ac,{size:11,style:{verticalAlign:`-1px`}}),` flag when done`]}),RN(l)&&l.status===`queued`&&FA(l.launch)&&(0,J.jsxs)(`span`,{className:`bl-age`,children:[`opens on `,PA(l.launch)]}),RN(l)&&l.budget&&(zN(l)&&o.online?(0,J.jsxs)(`button`,{className:`bl-age${e.budgetOpen.has(l.id)?` active`:``}`,"aria-pressed":e.budgetOpen.has(l.id),onClick:()=>e.toggleBudget(l.id),children:[(0,J.jsx)(Qc,{size:11,style:{verticalAlign:`-1px`}}),` `,Nw(l.budget)]}):(0,J.jsxs)(`span`,{className:`bl-age`,children:[(0,J.jsx)(Qc,{size:11,style:{verticalAlign:`-1px`}}),` `,Nw(l.budget)]})),l.at&&(0,J.jsxs)(`span`,{className:`bl-chip bl-clock`,title:`this one waits for an instant rather than for its turn — tap “when” to change it, or “drop the clock” to put it back in the queue`,children:[(0,J.jsx)(rl,{size:11,style:{verticalAlign:`-1px`}}),` `,Ofe(l.at,a,l.status)]}),(()=>{let e=l.at?Afe(n,l.id):null;if(!e)return null;let t=n.find(e=>e.items.some(e=>e.id===l.id)),r=t.items[e.idx-1]?.id,i=t.items[e.idx+1]?.id;return(0,J.jsxs)(`span`,{className:`bl-chip bl-clock-seat`,title:Ffe,children:[Nfe(e),o.online&&r&&(0,J.jsx)(`button`,{className:`bl-seat-move`,"aria-label":`run earlier on this clock`,title:`run it earlier on this clock — moves it among the items waiting on this same clock — the instant does not change, and it never crosses an item on a different clock`,onClick:()=>{q(`action:backlog.clock.up`),o.verbs.onSwap(l.id,r)},children:(0,J.jsx)(to,{size:11})}),o.online&&i&&(0,J.jsx)(`button`,{className:`bl-seat-move`,"aria-label":`run later on this clock`,title:`run it later on this clock — moves it among the items waiting on this same clock — the instant does not change, and it never crosses an item on a different clock`,onClick:()=>{q(`action:backlog.clock.down`),o.verbs.onSwap(l.id,i)},children:(0,J.jsx)(ts,{size:11})})]})})(),l.holdForHost&&(0,J.jsxs)(`span`,{className:`bl-chip bl-hold`,title:`it waits for nothing else to be starting or running anywhere on this desktop — not just in this repo. This is the schedule vocabulary's “wait until free”, and dropping the clock does not drop it`,children:[(0,J.jsx)(go,{size:11,style:{verticalAlign:`-1px`}}),` `,Rfe(!!l.at&&LP(l)&&o.online)]}),bn(l,a)&&(o.online&&l.status===`queued`?(0,J.jsxs)(`button`,{className:`bl-chip bl-hold`,title:`you let this past the usage budget — it still waits its turn; tap to hold it for the budget again`,onClick:()=>{q(`action:backlog.holdforbudget`),o.verbs.onHoldForBudget(l.id)},children:[(0,J.jsx)(ms,{size:11,style:{verticalAlign:`-1px`}}),` `,Gj(!0)]}):(0,J.jsxs)(`span`,{className:`bl-chip bl-hold`,title:`you let this past the usage budget — it still waits its turn; tap to hold it for the budget again`,children:[(0,J.jsx)(ms,{size:11,style:{verticalAlign:`-1px`}}),` `,Gj(!1)]})),i.has(l.id)&&(0,J.jsxs)(`span`,{className:`bl-next`,title:`auto will run this one next`,children:[(0,J.jsx)(La,{size:10,style:{verticalAlign:`-1px`}}),` next`]}),s(l)&&(0,J.jsx)(`span`,{className:`bl-next`,title:`the session it was aimed at has exited — nothing re-aims it; edit it to pick another session, take the aim off, or remove it`,children:`target closed — held`}),c(l)&&(0,J.jsx)(`span`,{className:`bl-next`,title:`the session it was aimed at has exited, but this row remembers the conversation — at its time it reopens that conversation in a session of its own and sends the words there`,children:`session closed — reopens its conversation`}),(()=>{let e=o.nav.scheduleFor?.(l);return e?o.nav.onOpenSchedule?(0,J.jsxs)(`button`,{className:`bl-chip bl-merged`,title:`open the schedule “${e.name}” — the rule that wrote this row`,onClick:()=>{q(`action:backlog.fromschedule`),o.nav.onOpenSchedule(e.id,e.name)},children:[(0,J.jsx)(rl,{size:11,style:{verticalAlign:`-1px`}}),` `,$j(e.name)]}):(0,J.jsxs)(`span`,{className:`bl-chip bl-merged`,children:[(0,J.jsx)(rl,{size:11,style:{verticalAlign:`-1px`}}),` `,$j(e.name)]}):null})(),l.handOrdered&&(0,J.jsxs)(`span`,{className:`bl-chip bl-hand`,title:`its position was decided by you — a drag, or an assessment ranking you approved`,children:[(0,J.jsx)(ns,{size:11,style:{verticalAlign:`-1px`}}),` you placed this`]})]})}function yF({m:e,it:t}){let{editCategory:r,editHeadline:i,editLabel:a,editRepo:o,editTarget:s,editText:c,p:l,repoLabel:u,saveEdit:d,setEditCategory:f,setEditHeadline:p,setEditingId:m,setEditLabel:h,setEditRepo:g,setEditTarget:_,setEditText:v}=e,y=t.status===`running`;return(0,J.jsx)(`div`,{className:`bl-row bl-${t.status} bl-edit`,children:(0,J.jsxs)(`div`,{className:`form`,style:{width:`100%`},children:[(0,J.jsx)(yE,{inline:!0,rows:3,prompts:[c],onChange:e=>v(e[0]??``),placeholder:`Instruction…`}),(0,J.jsx)(`input`,{className:`search`,value:a,onChange:e=>h(e.target.value),placeholder:`Label (optional)`}),(0,J.jsx)(`input`,{className:`search`,value:i,maxLength:80,onChange:e=>p(e.target.value),placeholder:`Suggested title (optional)`}),(0,J.jsx)(Z,{children:tpe(t.headlineBy)}),(0,J.jsxs)(`select`,{className:`search`,value:r,"aria-label":`kind`,onChange:e=>f(e.target.value),children:[(0,J.jsx)(`option`,{value:``,children:`— none —`}),n.map(e=>(0,J.jsx)(`option`,{value:e,children:e},e))]}),y?(0,J.jsx)(Z,{as:`span`,children:u(o)}):(0,J.jsx)(oF,{repos:l.repos,value:o,keepValue:!0,"aria-label":`repo`,onChange:e=>{g(e),_(``)}}),(()=>{let e=ape(l.sessions.filter(e=>e.running&&e.cwd===o),s);return e.length<2||y?null:(0,J.jsx)(`select`,{className:`search`,value:s,"aria-label":`session`,onChange:e=>_(e.target.value),children:e.map(e=>(0,J.jsx)(`option`,{value:e.value,children:e.label},e.value))})})(),(0,J.jsxs)(`div`,{className:`annot-tools`,children:[c.trim()&&l.online&&(0,J.jsx)(`button`,{className:`send`,onClick:()=>d(t),children:`Save`}),(0,J.jsx)(Y,{onClick:()=>m(null),children:`Cancel`})]}),!c.trim()&&(0,J.jsx)(Z,{children:`Nothing to save — type the task text.`}),y&&(0,J.jsx)(Z,{children:`Repo & session can't change while running.`}),!l.online&&(0,J.jsx)(Z,{children:`Offline — edits can't be saved until the connection is back.`})]})},t.id)}function bF({on:e,onSet:t}){return(0,J.jsx)(`div`,{className:`bl-close-chips`,children:(0,J.jsxs)(Y,{className:e?`active`:void 0,"aria-pressed":e,"data-hint":`session.followup`,onClick:()=>t(!e),children:[(0,J.jsx)(Ac,{size:13,fill:e?`currentColor`:`none`}),` Flag for follow up when done`]})})}var xF=`A percent is converted from dollars at the window's measured rate once the session is running — until there is a fresh usage reading, nothing is held.`;function SF({current:e,online:t,onSet:n,windowsOff:r}){let[i,a]=(0,V.useState)(e??null);if(!t)return(0,J.jsx)(`span`,{className:`bl-waiting`,children:`Changing the budget needs the desktop — the link is down.`});let o=!!i&&!!e&&i.unit===e.unit&&i.max===e.max&&i.interrupt===e.interrupt;return(0,J.jsxs)(`div`,{className:`bl-budget-edit`,children:[(0,J.jsx)(cD,{initial:e??null,onChange:a,calFor:xF,windowsOff:r}),(0,J.jsxs)(`div`,{className:`bl-close-chips`,children:[i&&!o&&(0,J.jsxs)(Y,{className:`active`,onClick:()=>n(i),children:[(0,J.jsx)(Qc,{size:13}),` `,e?`change budget`:`set budget`]}),e&&(0,J.jsxs)(Y,{onClick:()=>n(null),children:[(0,J.jsx)(Qc,{size:13}),` clear budget`]})]})]})}function CF({m:e,row:t}){let{fireIntoBusy:n,now:r,openDetail:i,openText:a,openValidate:o,p:s,runAgainHeld:c,runAgainOffered:l,setSlotOpen:u,slotOpen:d,slotSessions:f,targetLive:p,toggleDetail:m,toggleValidate:h}=e,{it:g,agentPosted:_}=t;return(0,J.jsxs)(J.Fragment,{children:[_&&a.has(g.id)&&(0,J.jsx)(`span`,{className:`bl-smart-note`,children:`posted by an agent — edit or delete it like any other`}),g.manual&&g.status===`queued`&&(0,J.jsx)(`span`,{className:`bl-hold`,children:`waits for your tap — nothing starts it by itself`}),g.at&&LP(g)&&s.online&&(0,J.jsx)(`span`,{className:`bl-smart-note`,children:Kj(g.status)}),l(g)&&(0,J.jsx)(`span`,{className:`bl-smart-note`,children:Jj(g)}),s.online&&g.status!==`running`&&(n(g)||g.status===`done`&&!l(g))&&(0,J.jsx)(`span`,{className:`bl-smart-note`,children:XA(!g.targetSessionId)}),c(g)&&(0,J.jsx)(`span`,{className:`bl-smart-note`,children:Ufe()}),g.requeued&&(0,J.jsx)(`span`,{className:`bl-smart-note`,children:Jfe(g.requeued,g.status,r)}),a.has(g.id)&&g.headline&&g.headlineBy&&(0,J.jsx)(`span`,{className:`bl-smart-note`,children:epe[g.headlineBy]}),g.status===`failed`&&g.error&&(0,J.jsx)(`span`,{className:`bl-error`,children:g.error}),s.online&&g.status===`queued`&&s.waiting?.[g.id]&&!(BN(s.waiting[g.id],s.autoSlots)&&f.length>0)&&(p(g)&&/that session/i.test(s.waiting[g.id])?(0,J.jsx)(`button`,{className:`bl-waiting bl-waiting-act`,onClick:()=>s.nav.onOpenSession(g.targetSessionId),title:`go to the session this one is aimed at`,children:s.waiting[g.id]}):(0,J.jsx)(`span`,{className:`bl-waiting`,children:s.waiting[g.id]})),s.online&&g.status===`queued`&&BN(s.waiting?.[g.id],s.autoSlots)&&f.length>0&&(0,J.jsxs)(`div`,{className:`bl-slots`,children:[(0,J.jsxs)(Y,{className:`bl-step${d.has(g.id)?` active`:``}`,onClick:()=>u(e=>lM(e,g.id)),children:[(0,J.jsx)(Po,{size:14}),` `,HN(f.length)]}),d.has(g.id)&&(0,J.jsx)(`ul`,{className:`bl-slot-list`,children:f.map(({s:e,closeWhenDone:t})=>(0,J.jsxs)(`li`,{className:`bl-slot`,children:[(0,J.jsxs)(`button`,{className:`bl-slot-open`,onClick:()=>s.nav.onOpenSession(e.id),children:[(0,J.jsx)(`span`,{className:`bl-slot-title`,children:e.title}),(0,J.jsxs)(`span`,{className:`bl-slot-sub`,children:[`opened `,Tp(e.createdAt),` · `,UN(e,t)]})]}),(0,J.jsxs)(Y,{variant:`danger`,onClick:()=>{q(`action:backlog.slotClose`),s.nav.onCloseSession(e)},children:[(0,J.jsx)(B,{size:14}),` close`]})]},e.id))})]}),a.has(g.id)&&RN(g)&&(0,J.jsxs)(`div`,{className:`bl-close-choice`,children:[(0,J.jsx)(`span`,{className:`bl-smart-note`,children:FN(g.closeWhenDone,s.closeWhenDoneGlobal)}),s.online?(0,J.jsx)(yS,{label:`when this item is done`,options:kN.map(e=>({key:e,label:PN(e,s.closeWhenDoneGlobal)})),value:AN(g.closeWhenDone),onChange:e=>s.verbs.onSetCloseWhenDone(g.id,e)}):(0,J.jsx)(`span`,{className:`bl-waiting`,children:`Changing it needs the desktop — the link is down.`}),s.online&&(0,J.jsx)(bF,{on:!!g.flagWhenDone,onSet:e=>s.verbs.onSetFlagWhenDone(g.id,e)}),s.online&&zN(g)&&!g.budget&&(0,J.jsx)(`div`,{className:`bl-close-chips`,children:(0,J.jsxs)(Y,{className:e.budgetOpen.has(g.id)?`active`:void 0,"aria-pressed":e.budgetOpen.has(g.id),onClick:()=>e.toggleBudget(g.id),children:[(0,J.jsx)(Qc,{size:13}),` budget…`]})})]}),zN(g)&&e.budgetOpen.has(g.id)&&(0,J.jsx)(SF,{current:g.budget,online:s.online,windowsOff:hw(s.backends??null,g.launch?.backend),onSet:t=>{s.verbs.onSetBudget(g.id,t),e.toggleBudget(g.id)}},`${g.id}:${g.budget?`${g.budget.unit}${g.budget.max}${g.budget.interrupt}`:`none`}`),a.has(g.id)&&(0,J.jsx)(`div`,{className:`bl-check-detail`,children:(0,J.jsx)(`div`,{className:`bl-steps`,children:s.online&&(0,J.jsxs)(Y,{className:`bl-step`,title:`open/resume a session seeded with this task as context`,onClick:()=>s.verbs.onContinue(g.id),children:[(0,J.jsx)(zo,{size:14}),` Continue in a session`]})})}),g.checkStatus&&(()=>{let e=g.checkStatus!==`checking`&&!!g.checkDetail,t=i.has(g.id);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(e?`button`:`span`,{className:`bl-check bl-check-${g.checkStatus}`,title:e?`tap for full check details`:g.checkNote||``,onClick:e?()=>m(g.id):void 0,children:[(()=>{let e=zP[g.checkStatus];return(0,J.jsx)(e,{size:12,style:{verticalAlign:`-2px`}})})(),` `,RP[g.checkStatus],g.checkNote?` · ${g.checkNote}`:``,e?t?(0,J.jsx)(Nc,{size:12,style:{verticalAlign:`-2px`}}):(0,J.jsx)(Hs,{size:12,style:{verticalAlign:`-2px`}}):null]}),e&&t&&(0,J.jsxs)(`div`,{className:`bl-check-detail`,children:[(0,J.jsx)(`pre`,{children:g.checkDetail}),(0,J.jsx)(`div`,{className:`bl-steps`,children:s.online&&(0,J.jsxs)(Y,{className:`bl-step`,title:`open/resume a session with this task + verdict as context`,onClick:()=>s.verbs.onContinue(g.id),children:[(0,J.jsx)(zo,{size:14}),` Continue in a session`]})}),g.checkedAt&&(0,J.jsxs)(`span`,{className:`bl-check-when`,children:[`checked `,new Date(g.checkedAt).toLocaleString()]})]})]})})(),g.validateStatus&&(()=>{let e=g.validateStatus!==`validating`&&(!!g.validateDetail||!!g.validateSteps?.length),t=o.has(g.id);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(e?`button`:`span`,{className:`bl-check bl-validate-${g.validateStatus}`,title:e?`tap for validation details & next steps`:g.validateNote||``,onClick:e?()=>h(g.id):void 0,children:[(()=>{let e=VP[g.validateStatus];return(0,J.jsx)(e,{size:12,style:{verticalAlign:`-2px`}})})(),` `,BP[g.validateStatus],g.validateNote?` · ${g.validateNote}`:``,e?t?(0,J.jsx)(Nc,{size:12,style:{verticalAlign:`-2px`}}):(0,J.jsx)(Hs,{size:12,style:{verticalAlign:`-2px`}}):null]}),e&&t&&(0,J.jsxs)(`div`,{className:`bl-check-detail`,children:[g.validateDetail&&(0,J.jsx)(`pre`,{children:g.validateDetail}),!!g.validateSteps?.length&&(0,J.jsxs)(`div`,{className:`bl-steps`,children:[(0,J.jsx)(`span`,{className:`bl-steps-head`,children:`Next steps — tap to run in the CLI:`}),g.validateSteps.map((e,t)=>s.online&&(0,J.jsxs)(Y,{className:`bl-step`,title:e.prompt,onClick:()=>s.verbs.onNextStep(g.id,t),children:[(0,J.jsx)(zo,{size:14}),` `,e.label]},t))]}),(0,J.jsx)(`div`,{className:`bl-steps`,children:s.online&&(0,J.jsxs)(Y,{className:`bl-step`,title:`open/resume a session with this task + verdict as context`,onClick:()=>s.verbs.onContinue(g.id),children:[(0,J.jsx)(zo,{size:14}),` Continue in a session`]})}),g.validatedAt&&(0,J.jsxs)(`span`,{className:`bl-check-when`,children:[`validated `,new Date(g.validatedAt).toLocaleString()]})]})]})})()]})}function wF({m:e,g:t,it:n,idx:r}){let{canDrag:i,clockCuts:a,dragId:o,editingId:s,filter:c,now:l,openText:u,p:d,picked:f,picking:p,setDragId:m,setPicked:h,toggleText:g}=e,_=t.items[r-1]?.id,v=t.items[r+1]?.id,y={it:n,idx:r,g:t,up:_,down:v,agentPosted:me(n)};if(s===n.id)return(0,J.jsx)(yF,{m:e,it:n});let b=(()=>{if(!c.clock||!n.at)return null;let e=Hj(n),r=a.find(t=>t.key===e);return!r||t.items.find(t=>Hj(t)===e)?.id!==n.id?null:(0,J.jsxs)(`div`,{className:`bl-group-head bl-clock-head`,children:[(0,J.jsxs)(`span`,{className:`bl-group-title`,children:[(0,J.jsx)(rl,{size:13}),` `,Pfe(r,l)]}),(0,J.jsx)(`span`,{className:`bl-group-meta`,children:`in this order`})]})})();return(0,J.jsxs)(V.Fragment,{children:[b,(0,J.jsxs)(`div`,{"data-blid":n.id,className:`bl-row bl-${n.status} ${o===n.id?`dragging`:``}`,children:[(0,J.jsxs)(`div`,{className:`bl-head`,children:[p&&aM(n)&&(0,J.jsx)(cM,{on:f.has(n.id),onToggle:()=>h(e=>lM(e,n.id))}),(0,J.jsx)(`span`,{className:`bl-num`,children:r+1}),(0,J.jsxs)(`div`,{className:`bl-main`,children:[(()=>{let e=iM(n);if(e)return(0,J.jsx)(`span`,{className:`bl-label`,children:e});let t=zr(n);if(!t)return null;let r=n.headlineBy!==`hand`;return(0,J.jsxs)(`span`,{className:`bl-label${r?` bl-headline`:``}`,children:[r?(0,J.jsx)(xl,{size:11}):null,r?` `:``,t]})})(),(0,J.jsx)(`button`,{className:`bl-text bl-text-btn ${u.has(n.id)?`open`:``}`,title:u.has(n.id)?`collapse`:`expand — full task & continue in a session`,onClick:()=>g(n.id),children:n.text}),(()=>{let e=Wn(n.text).filter(e=>!/[<>*{}]/.test(e));return e.length?(0,J.jsx)(`div`,{className:`bl-thumbs`,children:e.map(e=>{let t=d.nav.imageSrc(n.repoDir,e);return t?(0,J.jsx)(`button`,{className:`bl-thumb`,title:`view & mark ${e}`,onClick:()=>d.verbs.onEditImage(n,e),children:(0,J.jsx)(`img`,{src:t,alt:``,loading:`lazy`,onError:e=>{e.currentTarget.parentElement.hidden=!0}})},e):null})}):null})(),(0,J.jsx)(vF,{m:e,row:y}),(0,J.jsx)(CF,{m:e,row:y})]}),(0,J.jsxs)(`div`,{className:`bl-order`,children:[i&&(0,J.jsx)(Y,{className:`drag-handle`,title:`drag to reorder`,style:{touchAction:`none`,cursor:`grab`},onPointerDown:e=>{e.preventDefault(),m(n.id)},children:(0,J.jsx)(Zo,{size:14})}),_&&d.online&&(0,J.jsx)(Y,{onClick:()=>d.verbs.onSwap(n.id,_),title:`move up`,children:(0,J.jsx)(to,{size:14})}),v&&d.online&&(0,J.jsx)(Y,{onClick:()=>d.verbs.onSwap(n.id,v),title:`move down`,children:(0,J.jsx)(ts,{size:14})})]})]}),(0,J.jsx)(_F,{m:e,row:y})]})]},n.id)}function TF({m:e}){let{base:t,displayOrder:n,dragId:r,groups:i,hereInRepo:a,q:o}=e;return(0,J.jsxs)(`div`,{className:`list`,style:{touchAction:r?`none`:void 0},children:[n.length===0&&(0,J.jsx)($,{children:t.length===0?`Nothing waiting for this repo — “send…” above writes one.`:o?`No match in this repo.`:`Nothing here matches that filter — ${t.length} item${t.length===1?``:`s`} are hidden by it.`}),i.map(t=>(0,J.jsxs)(`div`,{className:`bl-group`,children:[(0,J.jsxs)(`div`,{className:`bl-group-head`,children:[(0,J.jsxs)(`span`,{className:`bl-group-title`,children:[t.key===`__closed`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Zte,{size:13}),` `,t.title]}):t.key?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(zo,{size:13}),` `,t.title]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Ls,{size:13}),` `,t.title]}),a&&t.key===a.id&&(0,J.jsx)(qw,{className:`bl-here`,children:`on screen`})]}),(0,J.jsx)(`span`,{className:`bl-group-meta`,children:`${t.items.length} item${t.items.length===1?``:`s`}`})]}),t.key===`__closed`&&(0,J.jsx)(`div`,{className:`empty bl-group-empty`,children:`The session each of these was aimed at has exited. Nothing re-aims them: edit one to pick another session or a new one, take the aim off, or remove it.`}),t.items.map((n,r)=>(0,J.jsx)(wF,{m:e,g:t,it:n,idx:r},n.id))]},t.key||`__default`))]})}function EF({m:e}){let{filter:t}=e;return(0,J.jsx)(`div`,{className:`sheet-scroll`,children:t.ids?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(pF,{m:e}),(0,J.jsx)(lF,{m:e}),(0,J.jsx)(gF,{m:e}),(0,J.jsx)(TF,{m:e}),(0,J.jsx)(hF,{m:e}),(0,J.jsx)(cF,{m:e}),(0,J.jsx)(uF,{m:e}),(0,J.jsx)(dF,{m:e}),(0,J.jsx)(fF,{m:e})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(cF,{m:e}),(0,J.jsx)(lF,{m:e}),(0,J.jsx)(uF,{m:e}),(0,J.jsx)(dF,{m:e}),(0,J.jsx)(fF,{m:e}),(0,J.jsx)(gF,{m:e}),(0,J.jsx)(hF,{m:e}),(0,J.jsx)(TF,{m:e})]})},t.ids?t.ids.join(`,`):``)}function DF(e){let t=KP(),n=ZP(e),r=QP(),i=Ww(3e4),a=JP(e),o=WP(e,i,n,r.picked),s=qP(e,o),c={p:e,now:i,...t,...n,...r,...a,...o,...s};return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(sF,{m:c}),(0,J.jsx)(EF,{m:c})]})}function OF(e){return e===`idle`?`When free`:`Send`}function kF(e){return e===`idle`?`Hand it to the desktop and let it go in when this session is free — turn ended, no question open, no usage-limit block`:`Send to this session`}function AF(e,t){return e===`now`?null:t.holder===`phone`?t.phoneHold===`opens-a-view`?t.online?`held on this phone — it opens a view rather than starting a turn, so it goes in when this turn ends. Leave the app open`:`held on this phone — it goes in when the link is back and this turn has ended. Leave the app open`:t.online?`queued — it runs in this session when it opens`:`queued — the session opens and runs this when the link is back`:t.online?`queued on the desktop — it goes in when this session is free`:`queued — it reaches the desktop when the link is back, and goes in when this session is free`}var jF=`kept on the pad — nothing runs it; open the pad to send it or file it onto a backlog`,MF=`nothing in the box to keep — the pad holds words, and there are none yet`;function NF(){return[{key:`now`,label:`now`,icon:`send`,mode:`now`,title:`type it into this session straight away`},{key:`idle`,label:`when it's free`,icon:`hourglass`,mode:`idle`,title:`the desktop holds it and types it in when this session can take it — turn ended, no question open, no usage-limit block`},{key:`pad`,label:`keep it on the pad`,icon:`pad`,mode:null,title:`park the words on the pad — nothing runs them, no backlog, no trigger; you decide later whether they go anywhere`},{key:`elsewhere`,label:`elsewhere or later…`,icon:`elsewhere`,mode:null,title:`a different session, a new one, several repos — or at a time`}]}var PF=`Runs in`;function FF(){return[{key:`this`,label:`this session`,title:`the conversation on screen — it already knows what you have said in it, and every turn pays for that whole window again`},{key:`new`,label:`a new session`,title:`open a fresh session in this repo and run it there — none of this conversation comes with it, which is what makes it cheaper`},{key:`other`,label:`another open session`,title:`one of the other sessions running right now — pick which one below`}]}function IF(e){return FF().find(t=>t.key===e)?.label??`this session`}function LF(e,t){if(e===`this`)return null;if(e===`new`)return`Send opens a NEW session in ${t.repoName||`this repo`} — not the conversation on screen.`;let n=(t.sessionName??``).trim();return n?`Send goes to ${n} — not the conversation on screen.`:`Send is aimed at another session and none is picked — choose one under the chevron, or aim it back here.`}var RF=`aim it here`,zF=`no session picked — choose one under the chevron, or aim it back at this session`;function BF(e){let t=(e??``).trim();return`${t?`“${t}”`:`that session`} has closed — nothing was sent, and the aim is back on this session`}function VF(e,t,n){if(t===`this`)return kF(e);if(t===`new`)return e===`idle`?`Open a fresh session in this repo and run it there when this repo is free — not the conversation on screen`:`Open a fresh session in this repo and run it there — not the conversation on screen`;let r=(n??``).trim()||`another open session`;return e===`idle`?`Hand it to the desktop and let it go in when ${r} is free — not the conversation on screen`:`Send it to ${r} — not the conversation on screen`}function HF(e){return e.how!==`now`||e.explicit||!e.aimedHere||!e.turnActive||e.pending||e.localCmd?e.how:e.pref===``?`ask`:e.pref}var UF={title:`This session is still working`,lines:[`Send now: the words go into the running turn straight away.`,`When it's free: the desktop holds them and sends them once this turn ends.`,`Tap outside to keep the words in the box.`],confirmLabel:`Send now`,cancelLabel:`When it's free`,rememberLabel:`don't ask again`},WF=`When it's free, past the budget`;function GF(e){if(!e)return{...UF,lines:[...UF.lines]};let[t,n,r]=UF.lines;return{...UF,lines:[t,`${n} The usage budget holds it after that: ${e}.`,`When it's free, past the budget: the same, but this prompt does not wait for the budget.`,r],altLabel:WF}}function KF(e){return e?`queued past the budget — the desktop sends it once this turn ends`:`queued past the budget — it reaches the desktop when the link is back, then goes in once this session is free`}function qF(e){return e===`idle`?`won't ask again — Send on a working session now waits until it is free; Settings › Writing & reading › Send while it works changes it`:`won't ask again — Send on a working session now goes straight in; Settings › Writing & reading › Send while it works changes it`}var JF=R.fileMtimes,YF=400,XF=8e3,ZF=(e,t)=>`${e}:${t}`,QF=null;function $F(){if(QF)return QF;try{QF=JSON.parse(z(JF)||`{}`)}catch{QF={}}return QF}function eI(){Ta(JF,QF??{})}var tI=new Map;function nI(e){for(let t of tI.get(e)??[])t()}function rI(e,t){return $F()[ZF(e,t)]}function iI(e,t,n){if(!e||!t||!n)return;let r=$F(),i=ZF(e,t);if(r[i]===n)return;delete r[i],r[i]=n;let a=Object.keys(r);if(a.length>YF)for(let e of a.slice(0,a.length-YF))delete r[e];eI(),nI(i)}function aI(e,t){for(let n of e){let e=n.repoId??t;e&&iI(e,n.relPath,n.mtime)}}var oI=new Set;function sI(e,t){if(!e||!t)return;let n=ZF(e,t);oI.has(n)||$F()[n]||(oI.add(n),(async()=>{try{let n=Su(`/api/repos/${e}/artifact?path=${encodeURIComponent(t)}&stat=1`),r=await li(n,void 0,XF);if(!r.ok)return;let i=await r.json();i?.mtime&&iI(e,t,i.mtime)}catch(e){Qe(e)&&oI.delete(n)}})())}function cI(e,t){let n=e?ZF(e,t):``,[,r]=(0,V.useState)(0);return(0,V.useEffect)(()=>{if(!e)return;let i=()=>r(e=>e+1),a=tI.get(n)??new Set;return tI.set(n,a),a.add(i),sI(e,t),()=>{a.delete(i),a.size||tI.delete(n)}},[n,e,t]),e?rI(e,t):void 0}function lI(e){return Gn(e.name,e.action.text)??(e.name.length>40?`${e.name.slice(0,40)}…`:e.name)}function uI(e){let t=new Map,n=new Map;for(let r of e){let e={id:r.id,name:lI(r)};t.set(r.id,e);let i=r.lastResult?.childId;i&&n.set(i,e)}return{byId:t,byChild:n}}function dI(e,t){let n=new Map,r=new Map;for(let i of e){if(!Xt(i))continue;let e=t(i),a={id:i.id,name:e.length>40?`${e.slice(0,40)}…`:e};n.set(i.id,a);let o=i.result?.childId;o&&r.set(o,a)}return{byId:n,byChild:r}}function fI(e){return e?`reading the repo to judge ${e.length===1?`this one`:`these ${e.length}`} — this takes a while; the proposal lands here`:`reading the repo — this takes a while; the proposal lands here`}function pI(e){return`queued — ${e===1?`it goes`:`all ${e} go`} back in the queue when the link is back`}function mI(){let e=iT(R.snapBacklog,{});return{items:e.items??[],auto:e.auto??!1,waiting:{},naming:[],autoSlots:null,snapAt:e.at??null}}var hI=W(mI()),gI=W(null),_I=W(null),vI=W(new Map),yI=W(null),bI=W(null),xI=W(null),SI=W(new Map);function CI(){return G(hI)}function wI(e){let t=Date.now();hI.set({items:e.items,auto:e.auto,waiting:e.waiting??{},naming:e.naming??[],autoSlots:e.autoSlots??null,snapAt:t}),aT(R.snapBacklog,{items:e.items,auto:e.auto,idleMs:e.idleMs,at:t}),jP(e.items)}function TI(e,t){let n=U().nav.overlay;vI.set(r=>{let i=r.get(e);return t&&i&&n!==`assess`&&i.runId===t.runId&&i.status===`running`&&t.status===`running`?r:t?kh(r,e,t):Ah(r,e)})}function EI(){U().conn.send({t:`assess.state`})}function DI(e,t){SI.set(kh(SI.get(),e,t))}function OI(e,t,n,r){let i=SI.get().get(e);if(i===void 0||(SI.set(Ah(SI.get(),e)),!t||!i.length))return;let a=xN(i,n);a.clear.length&&r(a.clear);let o=SN(a);o&&U().say.toast(o)}function kI(e){gI.set(e.worktreePath),_I.set(null),U().nav.open(`backlog`)}function AI(e){e&&gI.set(e),U().nav.open(`backlog`)}function jI(e,t,n){gI.set(e),_I.set(t?.length?{ids:t,label:n??`made from these`}:null),U().nav.open(`backlog`)}function MI(){_I.set(null)}function NI(e,t){let n=U(),r=e.worktreePath;yI.set(e),bI.set(t?.length?t:null),xI.set(null),n.conn.liveAsk({t:`assess.state`,repoDir:r}),n.nav.open(`assess`),!vI.get().get(r)&&PI(r,t)}function PI(e,t,n){let r=U();r.say.track(`action:assess.run`);let i=r.queue.mintAckId(),a=t?.length?t:void 0,o=a&&n?{scope:n}:{};r.conn.liveSend({t:`assess.run`,repoDir:e,ids:a,...o,ackId:i,firstSentAt:Date.now()},fI(a),`no connection — the assessment runs on the desktop`)&&DI(i,[])}function FI(e,t){let n=U();n.say.track(`action:assess.apply`);let r=n.queue.mintAckId(),i=t.news??[],a=(e.proposal?.news??[]).filter((e,t)=>i.includes(t)&&e.fromNote).map(e=>e.fromNote);n.conn.liveSend({t:`assess.apply`,runId:e.runId,choices:t,ackId:r,firstSentAt:Date.now()},`applying your decisions…`,`no connection — applying starts work on the desktop and can't be queued from here`)&&DI(r,a)}function II(e){let t=U(),n=t.world.repos.find(t=>t.worktreePath===e.repoDir)??t.world.repoForCwd(e.repoDir);if(!n){t.say.toast(`that repo is not on this desktop's list any more`);return}let r=n.worktreePath;yI.set(n),bI.set([...e.ids]),xI.set(e.scope),t.conn.liveAsk({t:`assess.state`,repoDir:r}),t.nav.open(`assess`);let i=_P(vI.get().get(r),e);if(i===`run`){PI(r,e.ids,e.scope);return}let a=vP(i,e.ids.length);a&&t.say.toast(a)}function LI(){yI.set(null),bI.set(null),xI.set(null),U().nav.close(`assess`)}function RI(e,t){let n=U(),r=BI(n,e,t,n.world.intents.find(t=>t.id===e));n.say.toast(r?`queued — it goes back in the queue when the link is back`:Yj)}function zI(e){let t=U(),n=!1;for(let{id:r,failedAt:i}of e)n=BI(t,r,i,t.world.intents.find(e=>e.id===r))||n;t.say.toast(n?pI(e.length):Wfe(e.length))}function BI(e,t,n,r){return e.queue.queueOp({t:`intent.requeue`,id:t,failedAt:n},`intent:${t}`,r?.label||r?.title||`run it again`,{cwd:r?.cwd})}function VI(){let e=Dh(),{liveSend:t,liveSendAll:n}=e.conn,{queueOp:r}=e.queue,{intents:i,sessions:a,visibleRepos:o,active:s,pending:c,budget:l,schedules:u}=e.world,d=e.conn.status===`open`,f=G(hI),p=G(_I),m=G(gI),h=G(vI),g=G(SI),_=Zv(`closeWhenDone`),{cwdVisible:v}=e.world,y=(0,V.useMemo)(()=>f.items.filter(e=>v(e.repoDir)),[f.items,v]),b=(0,V.useMemo)(()=>uI(u),[u]),S=(0,V.useMemo)(()=>dI(i,lj),[i]),C=t=>e.world.repos.find(e=>e.worktreePath===t)?.id;return(0,J.jsx)(DF,{items:y,auto:f.auto,repos:o,backends:e.world.backends,waiting:f.waiting,autoSlots:d?f.autoSlots:null,closeWhenDoneGlobal:_,intents:i,naming:d?f.naming:[],snapAt:f.snapAt,online:d,focusIds:p,activeSession:s&&!c?{id:s.id,cwd:s.cwd,title:s.title||`this session`}:null,sessions:a,defaultRepoDir:m??s?.cwd,verbs:{onSetCloseWhenDone:(e,n)=>t({t:`backlog.update`,id:e,closeWhenDone:jN(n)},IN(n,_),Rj),onSetFlagWhenDone:(e,n)=>t({t:`backlog.update`,id:e,flagWhenDone:n?!0:null},n?`its session gets the follow-up flag once it is done`:`no follow-up flag when it is done`,Rj),onSetBudget:(e,n)=>t({t:`backlog.update`,id:e,budget:n},n?`its session will start with that budget`:`no budget on its session`,Rj),onDropClock:e=>t({t:`intent.update`,id:e,patch:{trigger:{kind:`idle`}}},qj,Rj),onHoldForBudget:e=>t({t:`intent.waive`,id:e,rung:`budget`,on:!1},zfe,Rj),onRunAgain:RI,onEditWhen:t=>{let n=i.find(e=>e.id===t);n?e.nav.openSend(e.send.seedFromIntent(n)):e.say.toast(`that row is gone`)},onRemove:e=>t({t:`backlog.remove`,id:e},`removed`,Rj),onUpdate:(e,n)=>t({t:`backlog.update`,id:e,...n},`saved`,Rj),onQueueHere:(e,n)=>t({t:`backlog.update`,id:e,targetSessionId:n,autoFire:!!n},n?AF(`idle`,{online:d,holder:`desktop`}):`taken off this session's queue`,Rj),onSwap:(e,n)=>t({t:`backlog.swap`,id:e,otherId:n},`reordered`,Rj),onFire:n=>{t({t:`backlog.fire`,id:n},`running it now…`,`no connection — the backlog lives on the desktop, so nothing here changed. Adding still queues.`)&&e.nav.followFire(n)},onDone:e=>t({t:`backlog.done`,id:e},`marked done`,Rj),onArchive:(e,n)=>t({t:`backlog.archive`,id:e,archived:n},n?`archived`:`unarchived`,Rj),onCheck:e=>t({t:`backlog.check`,id:e},`checking…`,Rj),onValidate:e=>t({t:`backlog.validate`,id:e},`validating…`,Rj),onNextStep:(n,r)=>{t({t:`backlog.nextStep`,id:n,step:r},`firing the next step…`,`no connection — the backlog lives on the desktop, so nothing here changed. Adding still queues.`)&&e.nav.followFire(n)},onContinue:n=>{t({t:`backlog.continue`,id:n},`continuing…`,`no connection — the backlog lives on the desktop, so nothing here changed. Adding still queues.`)&&e.nav.followFire(n)},onEditImage:e.files.editBacklogImage},cutVerbs:{onDropClocks:e=>n(e.map(e=>({t:`intent.update`,id:e,patch:{trigger:{kind:`idle`}}})),Bfe(e.length),Rj),onRunAgainMany:zI,onName:(t,n)=>{let i=r({t:`backlog.name`,repoDir:t,ids:n},`name:${t}`,eM(n.length),{cwd:t});e.say.toast(i?`Queued · ${nM(eM(n.length))}`:nM(eM(n.length)))},onReorder:e=>t({t:`backlog.reorder`,ids:e},`order saved`,Rj),onSetAuto:e=>t({t:`backlog.setAuto`,enabled:e},`auto ${e?`on`:`off`}`,Rj),onArchiveMany:e=>n(e.map(e=>({t:`backlog.archive`,id:e,archived:!0})),Cfe(e.length),Rj),onAssess:(e,t)=>{let n=o.find(t=>t.worktreePath===e);n&&NI(n,t)},onSlotCheck:e=>II(e),assessBlocked:e=>h.get(e)??null?null:wN({run:null,online:d,busy:g.size>0,budgetNote:l?.verdict.blocked?fn(l.verdict):null})},nav:{onCloseSession:e.nav.closeSession,scheduleFor:e=>{let t=x(e.origin);return(t?b.byId.get(t):void 0)??b.byChild.get(e.id)??(t?S.byId.get(t):void 0)??S.byChild.get(e.id)??null},onOpenSchedule:(t,n)=>{if(b.byId.has(t)){e.nav.openScheduleCut([t],Zfe(n));return}let r=i.find(e=>e.id===t);r?jI(r.cwd,[t],$fe(n)):e.say.toast(`that schedule is no longer on the desktop`)},renderRetime:e.send.renderRetime,onClose:()=>e.nav.close(`backlog`),onOpenSend:(t,n)=>{let r=o.find(e=>e.worktreePath===t);e.nav.openSend({prompts:n?[n]:void 0,target:{kind:`repo`,cwd:t},when:{kind:`idle`},cwdHint:t,repoId:r?.id??null,origin:n?`Kept from the backlog's old add field`:`From the backlog`})},onOpenSession:t=>{let n=a.find(e=>e.id===t);n&&e.nav.attach(n)},imageSrc:(e,t)=>{let n=C(e);return n?(sI(n,t),$h(H.artifactUrl(n,t),Zh(72),rI(n,t))):null}}})}var HI=new Map,UI=e=>({rows:[...e.rows],merges:[...e.merges],news:[...e.news],rejected:[...e.rejected],pinRanks:e.pinRanks===!0,writeNames:e.writeNames===!0,...e.splits?{splits:[...e.splits]}:{}});function WI(e){if(!e)return null;let t=HI.get(e);return t?UI(t):null}function GI(e,t){e&&HI.set(e,UI(t))}function KI(e){HI.delete(e)}function qI(e){let t=e.run,n=t?.proposal??null,r=(0,V.useMemo)(()=>t?.input?.items??[],[t]),i=t?.runId,[a,o]=(0,V.useState)(()=>new Set(WI(i??``)?.rows??[])),[s,c]=(0,V.useState)(()=>new Set(WI(i??``)?.merges??[])),[l,u]=(0,V.useState)(()=>new Set(WI(i??``)?.news??[])),[d,f]=(0,V.useState)(()=>new Set(WI(i??``)?.rejected??[])),[p,m]=(0,V.useState)(()=>new Set(WI(i??``)?.splits??[])),[h,g]=(0,V.useState)(()=>new Set),_=(0,V.useRef)(i);(0,V.useEffect)(()=>{if(_.current===i)return;let e=_.current;_.current=i,e&&KI(e),o(new Set),c(new Set),u(new Set),f(new Set),m(new Set),g(new Set)},[i]);let v=(0,V.useMemo)(()=>n?KM(n,r):[],[n,r]),y=(0,V.useMemo)(()=>n?aee(n):null,[n]),b=(0,V.useMemo)(()=>uP(n,r),[n,r]),x=(0,V.useMemo)(()=>gP(n,r),[n,r]),S=(0,V.useMemo)(()=>{let e=new Map;for(let t of r)t?.id&&e.set(t.id,t);return e},[r]),C=Ww(t?.status===`running`?1e3:6e4),w=ON(t,C),[T,E]=(0,V.useState)(!1),D=t&&t.status!==`running`?t.progress:void 0,O=iN({rows:a,merges:s,news:l,splits:p}),[k,A]=(0,V.useState)(!1),j=CN({run:t,picked:O,online:e.online,busy:e.busy}),M=wN({run:t,online:e.online,busy:e.busy,budgetNote:e.budgetNote}),N=e.scope?.length??0,P=(0,V.useMemo)(()=>n?n.rows.filter(e=>e.verdict===`wanted`&&e.rank!=null&&a.has(e.id)).length+s.size+l.size:0,[n,a,s,l]),[F,ee]=(0,V.useState)(()=>WI(i??``)?.pinRanks??!0),te=(0,V.useMemo)(()=>n?Ee(n):0,[n]),[ne,re]=(0,V.useState)(()=>WI(i??``)?.writeNames??!0);(0,V.useEffect)(()=>{i&&GI(i,{rows:[...a],merges:[...s],news:[...l],rejected:[...d],pinRanks:F,writeNames:ne,...p.size?{splits:[...p]}:{}})},[i,a,s,l,d,F,ne,p]);let ie=e=>{o(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),f(t=>{let n=new Set(t);return n.delete(`row:${e}`),n})},ae=e=>{c(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),f(t=>{let n=new Set(t);return n.delete(`merge:${e}`),n})},oe=e=>{u(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),f(t=>{let n=new Set(t);return n.delete(`new:${e}`),n})},se=(e,t)=>{f(n=>{let r=new Set(n);return r.delete(e)||(r.add(e),t()),r})},ce=(t,n)=>{let r=t.rows.filter(e=>!e.acceptBlocked);if(!r.length)return;if(r.every(e=>a.has(e.id))){q(`action:assess.untick.${t.verdict}`),o(e=>{let n=new Set(e);for(let e of t.rows)n.delete(e.id);return n});return}q(`action:assess.bulk.${t.verdict}`);let i=()=>{o(e=>{let t=new Set(e);for(let e of r)t.add(e.id);return t}),f(e=>{let t=new Set(e);for(let e of r)t.delete(`row:${e.id}`);return t})},s=n.ask;!n.confirm||!s?i():(async()=>{await gC({title:s.title,lines:QM(r,{repoName:e.repoName,verdict:t.verdict}),confirmLabel:s.confirmLabel})&&i()})()},le=t=>{q(`action:assess.merge`),s.has(t.gid)?ae(t.gid):(async()=>{await gC({title:`Replace ${t.originals.length||t.ids.length} items with one prompt?`,lines:nN(t,{repoName:e.repoName}),confirmLabel:`Approve the merge`})&&ae(t.gid)})()},ue=e=>{m(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),f(t=>{let n=new Set(t);return n.delete(`split:${e}`),n})},de=t=>{q(`action:assess.split`),p.has(t.sid)?ue(t.sid):(async()=>{await gC({title:`Split this item in two?`,lines:bP(t,e.repoName),confirmLabel:`Approve the split`})&&ue(t.sid)})()},fe=()=>{q(`action:assess.apply`),e.onApply(yP({rows:a,merges:s,news:l,splits:p,pinRanks:P>0?F:void 0,writeNames:te>0?ne:void 0})),i&&KI(i)},pe=e.res??{state:e.online?t?`fresh`:`loading`:`offline`},me=!n||!(n.rows.length+n.merges.length+n.news.length+x.length+b.length),he=t?.finishedAt??t?.startedAt,ge=t?.planPath,_e=n?sN(n,{rows:[...a],merges:[...s],news:[...l]},r):null,ve=_e?cN(_e,e.repoName,{writeNames:te>0&&ne,ranked:P,pinRanks:F,splits:p.size}):``,ye=(0,V.useMemo)(()=>t?.applied&&e.onOpenBacklog?dN(t,e.backlog??[]):null,[t,e.backlog,e.onOpenBacklog]),be=N&&e.slot?sP(N,!!t):N?`${t?`run again on`:`assess`} ${N===1?`this one`:`these ${N}`}`:t?`run again`:`assess`;return{conflicts:b,splits:x,pickedSplits:p,setPickedSplits:m,acceptSplit:de,slotIntro:oP(t?.scope,t?.scopedIds?.length,C),p:e,run:t,proposal:n,items:r,runId:i,pickedRows:a,setPickedRows:o,pickedMerges:s,setPickedMerges:c,pickedNews:l,setPickedNews:u,rejected:d,setRejected:f,flipped:h,setFlipped:g,seeded:_,groups:v,counts:y,itemsById:S,now:C,watch:w,logOpen:T,setLogOpen:E,pastSteps:D,picked:O,guideOpen:k,setGuideOpen:A,applyBlocked:j,runBlocked:M,scopeN:N,rankedN:P,pinRanks:F,setPinRanks:ee,nameCount:te,writeNames:ne,setWriteNames:re,toggleRow:ie,toggleMerge:ae,toggleNew:oe,toggleReject:se,bulkGroup:ce,acceptMerge:le,apply:fe,res:pe,nothing:me,finishedAt:he,planPath:ge,applySummary:_e,applyLabel:ve,ready:ye,runLabel:be,guide:rN({repoName:e.repoName,judged:t?.assessableCount??n?.rows.length??0,planPath:ge||void 0,named:te})}}var JI=W(null);function YI(){return G(JI)}function XI(e){let t=U();JI.set(IS(e)?e:null),t.say.track(`action:settings.door`),t.nav.open(`settings`)}var ZI={done:`tag-done`,obsolete:`tag-done`,superseded:`tag-done`,merged:`tag-running`,wanted:`tag-queued`,unclear:`queued`},QI={running:`tag-running`,done:`tag-queued`,failed:`tag-failed`,applied:`tag-done`},$I={read:qo,search:rc,edit:Mo,run:qa,task:Uo,web:wo,say:Rs,tool:bs};function eL({m:e}){let{p:t,run:n,proposal:r,runBlocked:i,scopeN:a,planPath:o,runLabel:s}=e;return(0,J.jsxs)(J.Fragment,{children:[o&&t.onOpenPlan?(0,J.jsxs)(Y,{title:`open ${o}, the write-up the run left for you — for reading; it does not run anything, and your ticks are kept`,onClick:()=>{q(`action:assess.plan`),t.onOpenPlan?.(o)},children:[(0,J.jsx)(Fs,{size:16}),` read the plan`]}):null,r&&t.onDiscard?(0,J.jsxs)(fC,{className:`key`,title:`throw this proposal away without applying any of it`,confirm:`discard it?`,confirmTitle:`nothing is applied, and the items keep their words`,onConfirm:()=>{q(`action:assess.discard`),t.onDiscard?.()},children:[(0,J.jsx)(ws,{size:16}),` discard`]}):null,i?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Qw,{cants:[{label:s,reason:i}]}),t.budgetNote&&i===t.budgetNote&&(0,J.jsxs)(Y,{onClick:()=>XI(`budget`),children:[(0,J.jsx)(Bs,{size:16}),` change the usage budget`]})]}):(0,J.jsxs)(Y,{title:a?`judge ${a===1?`the one row`:`the ${a} rows`} you came here with — it still reads ${t.repoName} as evidence`:n?`read ${t.repoName} again and judge what is left now`:`read ${t.repoName} and judge what is left`,onClick:()=>{q(`action:assess.run`),t.onRun()},children:[(0,J.jsx)(La,{size:16}),` `,s]})]})}function tL({m:e}){let{p:t,setPickedRows:n,setPickedMerges:r,setPickedNews:i,picked:a,applyBlocked:o,apply:s,applySummary:c,applyLabel:l,ready:u}=e;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`act-bulk`,children:[(0,J.jsx)(`span`,{className:`act-bulk-n`,children:aN(a)}),a?(0,J.jsxs)(Y,{title:`un-tick everything — nothing has happened yet, so nothing is undone`,onClick:()=>{q(`action:assess.clear`),n(new Set),r(new Set),i(new Set)},children:[(0,J.jsx)(B,{size:14}),` clear`]}):null,o?(0,J.jsx)(Qw,{cants:[{label:`apply`,reason:o}]}):(0,J.jsxs)(Y,{variant:`primary`,title:l,onClick:s,children:[(0,J.jsx)(Qs,{size:14}),` `,l]}),u?(0,J.jsxs)(Y,{variant:`primary`,className:`asr-route`,title:pN(u.n),onClick:()=>{q(`action:assess.backlog`),t.onOpenBacklog?.(u.ids,mN(t.repoName))},children:[(0,J.jsx)(il,{size:14}),` `,fN(u.n,t.repoName)]}):null]}),(0,J.jsx)(Z,{children:lN(c?.requeue??0)}),u?(0,J.jsx)(Z,{children:pN(u.n)}):null]})}function nL({m:e}){let{run:t,finishedAt:n}=e;return t?(0,J.jsxs)(`div`,{className:`act-triage`,children:[(0,J.jsx)(qw,{className:QI[t.status],children:t.status}),n?(0,J.jsx)(`span`,{className:`act-count`,children:Tp(n)}):null,t.assessableCount==null?null:(0,J.jsxs)(`span`,{className:`act-count`,children:[t.assessableCount,` judged`,t.itemCount!=null&&t.itemCount>t.assessableCount?` · ${t.itemCount-t.assessableCount} read as context`:``]}),t.scopedIds?.length?(0,J.jsxs)(`span`,{className:`act-count`,title:`this run was asked about a cut of the backlog, not the whole repo — it still read the repo as evidence`,children:[t.scope?.kind===`slot`?`slot check ·`:`scoped to`,` `,t.scopedIds.length===1?`1 row`:`${t.scopedIds.length} rows`]}):null,t.applied?(0,J.jsx)(`span`,{className:`act-count`,children:hN(t.applied)}):null]}):null}var rL=`[A-Za-z0-9._~@%+-]+`,iL=`/?(?:${rL}/)*\\.(?:claude/(?:inbox|outbox)|outbox)/${rL}(?:/${rL})*`,aL=/\.claude\/(?:inbox|outbox)\/|(?:^|\/)\.outbox\//,oL=/\.(png|jpe?g|gif|webp|bmp|avif|heic|svg)$/i,sL=/\.(mp4|webm|mov|m4v|ogv|mkv)$/i;function cL(e){let t=e.replace(/[.,;:!?)\]]+$/,``);if(!t||!aL.exec(t))return null;let n=t.indexOf(`.claude/`)>=0?t.indexOf(`.claude/`):t.indexOf(`.outbox/`),r=t.slice(n),i=r.split(`/`).pop()||``;return!i||i===`inbox`||i===`outbox`?null:{raw:t,relPath:r,name:i,image:oL.test(i),video:sL.test(i)}}function lL(e){let t=e.trim();return RegExp(`^(?:${iL})$`).test(t)?cL(t):null}function uL(e){let t=new RegExp(iL,`g`),n=[],r=new Set;for(let i=t.exec(e);i;i=t.exec(e)){let e=cL(i[0]);e&&!r.has(e.relPath)&&(r.add(e.relPath),n.push(e))}return n}function dL(e,t){let n=new RegExp(iL,`g`),r=[],i=!1;for(let a of e.split(`
11
+ `)){let e=a.replace(n,e=>{let n=cL(e);return n&&n.relPath===t?e.slice(n.raw.length):e});if(e===a){r.push(a);continue}i=!0;let o=e.replace(/[ \t]{2,}/g,` `).replace(/[ \t]+([.,;:!?])/g,`$1`).trimEnd();o.trim()&&r.push(o)}return i?r.join(`
12
+ `).trim():e}var fL=RegExp(`^${rL}$`);function pL(e,t){if(!t||!t.length)return null;let n=e.trim();if(!fL.test(n))return null;let r=oL.test(n),i=sL.test(n);if(!r&&!i)return null;let a=null;for(let e of t)if((e.split(`/`).pop()||``)===n&&aL.test(e)){if(a&&a!==e)return null;a=e}return a?{raw:n,relPath:a,name:n,image:r,video:i}:null}function mL(e,t){let n=e.replace(/[?#].*$/,``);if(!n||/^[a-z][a-z0-9+.-]*:/i.test(n)||n.startsWith(`//`))return null;let r;try{r=decodeURIComponent(n)}catch{return null}let i=r.split(`/`).pop()||``,a=oL.test(i),o=sL.test(i);if(!a&&!o)return null;let s=hL(r,t);return s==null?null:{raw:e,relPath:s,name:i,image:a,video:o}}function hL(e,t){let n=e.startsWith(`/`)?[]:t.split(`/`).slice(0,-1);for(let t of e.split(`/`))if(t&&t!==`.`){if(t===`..`){if(!n.length)return null;n.pop()}else n.push(t)}return n.length?n.join(`/`):null}function gL(e,t){if(/^[a-z][a-z0-9+.-]*:/i.test(e)||e.startsWith(`//`))return null;if(e.startsWith(`#`)){let t;try{t=decodeURIComponent(e.slice(1))}catch{return null}return t?{kind:`anchor`,slug:t.toLowerCase()}:null}let n=e.replace(/[?#].*$/,``);if(!n||n.endsWith(`/`))return null;let r;try{r=decodeURIComponent(n)}catch{return null}let i=hL(r,t);return i==null?null:{kind:`file`,relPath:i}}function _L(e){return e.replace(/!?\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/[`*]/g,``).trim().toLowerCase().replace(/[^\p{L}\p{N}\s_-]/gu,``).replace(/\s/g,`-`)}function vL(e){return e.includes(`<!--`)?e.replace(/(`+)[\s\S]*?\1|<!--[\s\S]*?-->/g,(e,t)=>t?e:e.replace(/[^\n]/g,``)):e}var yL=/\[!\[([^\]]*)\]\(([^)\s]+)\)\]\(([^)\s]+)\)/g,bL=/<a\s[^>]*?\bhref="([^"]+)"[^>]*>\s*<img\s([^>]*?)\/?>\s*<\/a>/gi,xL=/<img\s([^>]*?)\/?>/gi,SL=(e,t)=>RegExp(`\\b${t}="([^"]*)"`,`i`).exec(e)?.[1],CL=e=>e.replace(/&quot;/g,`"`).replace(/&#39;/g,`'`).replace(/&lt;/g,`<`).replace(/&gt;/g,`>`).replace(/&amp;/g,`&`);function wL(e){let t=[];for(let n of e.matchAll(yL))t.push({at:n.index,end:n.index+n[0].length,alt:n[1],src:n[2],href:n[3]});for(let n of e.matchAll(bL)){let e=SL(n[2],`src`);e&&t.push({at:n.index,end:n.index+n[0].length,alt:CL(SL(n[2],`alt`)??``),src:CL(e),href:CL(n[1])})}let n=t.slice();for(let r of e.matchAll(xL)){let e=SL(r[1],`src`);e&&!n.some(e=>r.index>=e.at&&r.index<e.end)&&t.push({at:r.index,end:r.index+r[0].length,alt:CL(SL(r[1],`alt`)??``),src:CL(e),href:CL(e)})}return t.sort((e,t)=>e.at-t.at)}var TL=`keep:`,EL=e=>e.startsWith(TL)?e.slice(5):null,DL=12;async function OL(e,t){await Ay(`uploads`,TL+e,{relPath:e,blob:t,ts:Date.now()}),await ML()}async function kL(e){return(await ky(`uploads`,TL+e))?.blob??null}async function AL(){return(await Ny(`uploads`)).map(EL).filter(e=>!!e)}async function jL(e){await jy(`uploads`,TL+e)}async function ML(){let e=(await Ny(`uploads`)).filter(e=>EL(e));if(e.length<=DL)return;let t=await Promise.all(e.map(async e=>({k:e,ts:(await ky(`uploads`,e))?.ts??0})));t.sort((e,t)=>e.ts-t.ts);for(let{k:e}of t.slice(0,t.length-DL))await jy(`uploads`,e)}async function NL(e,t,n,r){let i=uL(e);if(!i.length)return{refs:i,states:[]};let a={onHost:null,sending:_te(n),kept:await AL(),dead:Bm()};if(t&&r){let e=i.some(e=>e.relPath.startsWith(`.claude/inbox/`)),n=i.some(e=>!e.relPath.startsWith(`.claude/inbox/`)),[r,o]=await Promise.all([e?H.inbox(t).catch(()=>null):Promise.resolve([]),n?H.artifacts(t,`outbox`).then(e=>e.files).catch(()=>null):Promise.resolve([])]);a.onHost=r&&o?[...r,...o].map(e=>e.relPath):null}return{refs:i,states:Se(i.map(e=>e.relPath),a)}}async function PL(e,t,n){if(t===`sending`){let t=n.find(t=>t.mode===`upload`&&t.upload?.relPath===e),r=t?await ky(`uploads`,t.ackId):null;if(r)return URL.createObjectURL(r)}if(t===`sending`||t===`kept`||t===`dead`||t===`missing`||t===`unknown`){let t=await kL(e);if(t)return URL.createObjectURL(t)}return null}var FL=`app:open-attachment`;function IL(e){try{window.dispatchEvent(new CustomEvent(FL,{detail:e}))}catch{}}function LL(e){switch(e.state){case`host`:return`in the repo`;case`sending`:return`uploads before this message`;case`kept`:return`not uploaded — the file is still on this phone`;case`dead`:return e.why?`not uploaded — ${e.why}`:`not uploaded`;case`missing`:return`not in the repo, and not on this phone`;case`unknown`:return`can't check without a connection`}}var RL=e=>e.startsWith(TL);async function zL(){return Iy(`uploads`,RL)}var BL=`thumbs`,VL=`thumbmeta`,HL=400,UL=25165824,WL=524288,GL=3,KL=15e3;async function qL(e){let t=await ky(BL,e);return t instanceof Blob&&t.size>0?t:null}async function JL(e){return!!await ky(VL,e)}var YL=new Set,XL=[],ZL=0;function QL(e){!e||e.startsWith(`blob:`)||YL.has(e)||(YL.add(e),XL.push(e),$L())}async function $L(){if(ZL>=GL)return;let e=XL.shift();if(e){ZL++;try{await eR(e)}catch{YL.delete(e)}finally{ZL--,$L()}}}async function eR(e){if(await JL(e))return;let t=await li(e,{cache:`force-cache`},KL),n=t.headers.get(`content-type`)||``;if(!t.ok||!n.startsWith(`image/`))throw Error(`thumb ${t.status}`);let r=await t.blob();if(!r.size||r.size>WL)throw Error(`not a thumbnail`);await Ay(BL,e,r),await Ay(VL,e,{url:e,savedAt:Date.now(),bytes:r.size}),nR()}var tR=!1;async function nR(){if(!tR){tR=!0;try{let e=[...await My(VL)].sort((e,t)=>t.savedAt-e.savedAt),t=e.slice(HL),n=0;for(let r of e.slice(0,HL))n+=r.bytes||0,n>UL&&t.push(r);for(let e of t)await jy(BL,e.url),await jy(VL,e.url),YL.delete(e.url)}finally{tR=!1}}}function rR(e){for(let t of e)QL(t)}async function iR(){YL.clear(),XL.length=0;let e=await Fy(BL),t=await Fy(VL);return e&&t}function aR(e){let[t,n]=(0,V.useState)({src:null,live:!1});return(0,V.useEffect)(()=>{let t=!1,r=null;return n({src:null,live:!1}),e?(qL(e).then(i=>{t||(i?(r=URL.createObjectURL(i),n({src:r,live:!1})):n({src:e,live:!0}))}),()=>{t=!0,r&&URL.revokeObjectURL(r)}):()=>{t=!0}},[e]),t}var oR=96,sR={host:vo,sending:rs,kept:xc,dead:gs,missing:no,unknown:cs};function cR({fref:e,state:t,repoId:n,localSrc:r}){let[i,a]=(0,V.useState)(!1),o=t.state===`host`?n:null,s=cI(o,e.relPath),c=!r&&e.image&&!i&&o?$h(H.artifactUrl(o,e.relPath),Zh(oR),s):null,{src:l,live:u}=aR(c),d=r??l,f=!!d||!!o&&!e.image,p=d?(0,J.jsx)(`img`,{src:d,alt:e.name,loading:`lazy`,onLoad:()=>{c&&u&&s&&QL(c)},onError:()=>a(!0)}):(0,J.jsx)(`span`,{className:`attach-noimg`,children:(0,J.jsx)(Fs,{size:16})});return f?(0,J.jsx)(`button`,{type:`button`,className:`attach-thumb tap`,title:`${e.relPath} — tap to open`,onClick:()=>IL({relPath:e.relPath,repoId:n,state:t.state}),children:p}):(0,J.jsx)(`div`,{className:`attach-thumb`,children:p})}function lR({text:e,repoId:t,outbox:n,online:r,nonce:i,onStates:a,onReattach:o,onReplace:s,onForget:c,onRemove:l,compact:u,debounceMs:d=0}){let[f,p]=(0,V.useState)(e);(0,V.useEffect)(()=>{if(!d){p(e);return}let t=window.setTimeout(()=>p(e),d);return()=>window.clearTimeout(t)},[e,d]);let[m,h]=(0,V.useState)([]),g=(0,V.useRef)([]),[_,v]=(0,V.useState)({}),y=Ue(n);return(0,V.useEffect)(()=>{let e=!1;return(async()=>{let{refs:i,states:o}=await NL(f,t,n,r);if(e)return;h(i.map((e,t)=>({ref:e,state:o[t]}))),a?.(o);let s={},c=[];for(let e=0;e<i.length;e++){if(!i[e].image)continue;let t=await PL(i[e].relPath,o[e].state,n);t&&(s[i[e].relPath]=t,c.push(t))}e?c.forEach(e=>URL.revokeObjectURL(e)):(g.current.forEach(e=>URL.revokeObjectURL(e)),g.current=c,v(s))})(),()=>{e=!0}},[f,t,r,i,y]),(0,V.useEffect)(()=>()=>{g.current.forEach(e=>URL.revokeObjectURL(e))},[]),m.length?(0,J.jsx)(`div`,{className:`attach-strip ${u?`compact`:``}`,children:m.map(({ref:e,state:n})=>{let r=sR[n.state],i=_[e.relPath],a=n.state!==`host`&&n.state!==`sending`,d=l?()=>{h(t=>t.filter(t=>t.ref.relPath!==e.relPath)),l(e.relPath)}:null;return(0,J.jsxs)(`div`,{className:`attach-item ${n.state}`,children:[(0,J.jsx)(cR,{fref:e,state:n,repoId:t,localSrc:i}),(0,J.jsxs)(`div`,{className:`attach-body`,children:[(0,J.jsx)(`span`,{className:`attach-name`,title:e.relPath,children:e.name}),(0,J.jsxs)(`span`,{className:`attach-state`,children:[(0,J.jsx)(r,{size:11}),` `,LL(n)]}),!u&&a&&(0,J.jsxs)(`div`,{className:`attach-acts`,children:[n.state===`kept`&&o&&(0,J.jsxs)(Y,{title:`put this phone's copy back in the send queue, under the same path — the message needs no change`,onClick:()=>o(e.relPath),children:[(0,J.jsx)(xc,{size:14}),` re-attach`]}),s&&(0,J.jsxs)(Y,{title:`pick a different file for this mention — the path in the message is rewritten to the new one`,onClick:()=>s(e.relPath),children:[(0,J.jsx)(vo,{size:14}),` pick a file`]}),c&&(0,J.jsxs)(Y,{variant:`danger`,title:`take this mention out of the message and send the words without it`,onClick:()=>c(e.relPath),children:[(0,J.jsx)(ws,{size:14}),` drop mention`]})]})]}),d&&(0,J.jsx)(`button`,{type:`button`,className:`attach-x`,"aria-label":`remove ${e.name} from the prompt`,onPointerDown:e=>e.preventDefault(),onClick:d,children:(0,J.jsx)(B,{size:16})})]},e.relPath)})}):null}function uR(e){let[t,n]=(0,V.useState)(!1),r=(0,V.useRef)(null);return(0,V.useEffect)(()=>{if(!e||t)return;let i=r.current;if(!i||typeof IntersectionObserver>`u`){n(!0);return}let a=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&(n(!0),a.disconnect())},{rootMargin:`300px`});return a.observe(i),()=>a.disconnect()},[e,t]),[t,r]}function dR({steps:e}){return e.length?(0,J.jsx)(`div`,{className:`assess-log`,children:e.map((e,t)=>{let n=$I[e.kind]??bs;return(0,J.jsxs)(`div`,{className:`assess-step${e.kind===`say`?` assess-step-say`:``}`,children:[(0,J.jsx)(n,{size:12}),(0,J.jsx)(`span`,{className:`assess-step-label`,children:e.label}),e.detail?(0,J.jsx)(`span`,{className:`assess-step-detail`,children:e.detail}):null]},`${e.at}:${t}`)})}):null}function fR({headline:e,suggested:t,category:n}){if(!e&&!n)return null;let r=n?HP[n]:null;return(0,J.jsxs)(J.Fragment,{children:[n&&r?(0,J.jsxs)(`span`,{className:`bl-chip bl-cat`,children:[(0,J.jsx)(r,{size:11}),` `,n]}):null,e?(0,J.jsxs)(`span`,{className:`act-where asr-headline`,children:[t?(0,J.jsx)(xl,{size:11}):null,e]}):null]})}function pR({text:e,repoId:t,outbox:n,online:r}){let i=(0,V.useMemo)(()=>!!e&&uL(e).length>0,[e]),[a,o]=uR(i);return i?(0,J.jsx)(`div`,{ref:o,children:a?(0,J.jsx)(lR,{compact:!0,text:e,repoId:t,outbox:n,online:r}):null}):null}function mR({m:e}){let{p:t,proposal:n,pickedNews:r,setPickedNews:i,rejected:a,toggleNew:o,toggleReject:s}=e;return(0,J.jsx)(J.Fragment,{children:n&&n.news.length?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`section section-head`,children:[(0,J.jsx)(`span`,{children:n.news.some(e=>e.fromNote)?`what it proposes to add`:`missing pieces it proposes`}),(0,J.jsx)(`span`,{className:`section-hint`,children:n.news.some(e=>e.fromNote)?`new items the run wrote, and pad notes of yours it says are still worth doing — offered in your own words`:`prose and a position, and nothing else — these are new items, not verdicts on yours`})]}),n.news.some(e=>!e.fromNote)?(0,J.jsx)(`div`,{className:`act-verdict assess-effect`,children:_N(t.repoName)}):null,n.news.map((e,n)=>{let c=!!e.fromNote,l=c?vN:gN;return(0,J.jsxs)(`div`,{className:`q-card${c?` asr-offer`:``}${a.has(`new:${n}`)?` act-filed`:``}`,children:[(0,J.jsxs)(`div`,{className:`q-head`,children:[c?(0,J.jsx)($o,{size:14}):(0,J.jsx)(Fo,{size:14}),(0,J.jsx)(`span`,{className:`bl-group-title`,children:c?`from your pad`:`a new item`}),e.rank==null?null:(0,J.jsxs)(`span`,{className:`act-count`,children:[`position `,e.rank]})]}),e.headline||e.category?(0,J.jsx)(`div`,{className:`act-head asr-namehead`,children:(0,J.jsx)(fR,{headline:e.headline,suggested:!!e.headline,category:e.category})}):null,c?(0,J.jsx)(`div`,{className:`act-verdict assess-effect`,children:yN(t.repoName)}):null,(0,J.jsx)(`div`,{className:`act-text act-text-full`,children:e.prompt}),(0,J.jsx)(pR,{text:e.prompt,repoId:t.repoId,outbox:t.outbox,online:t.online}),(0,J.jsxs)(`div`,{className:`act-acts`,children:[(0,J.jsxs)(Y,{className:r.has(n)?`primary`:void 0,title:r.has(n)?l.pickedTitle:l.title,onClick:()=>{q(c?`action:assess.accept.note`:`action:assess.accept.new`),o(n)},children:[(0,J.jsx)(vc,{size:16}),` `,r.has(n)?l.picked:l.label]}),(0,J.jsxs)(Y,{className:a.has(`new:${n}`)?`active`:void 0,title:a.has(`new:${n}`)?GM.pickedTitle:c?`leave the note on the pad — nothing is filed and nothing is removed`:`do not add this`,onClick:()=>{q(`action:assess.leave`),s(`new:${n}`,()=>i(e=>{let t=new Set(e);return t.delete(n),t}))},children:[(0,J.jsx)(B,{size:16}),` `,a.has(`new:${n}`)?GM.picked:GM.label]})]})]},n)})]}):null})}function hR({row:e,m:t}){let{p:n}=t;return e.text==null?(0,J.jsxs)(`span`,{className:`act-stale`,children:[(0,J.jsx)(gs,{size:11}),` `,e.id,` — its words are not on this phone`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`act-text act-text-full`,children:e.text}),(0,J.jsx)(pR,{text:e.text,repoId:n.repoId,outbox:n.outbox,online:n.online})]})}function gR({m:e}){let{p:t,conflicts:n,splits:r,pickedSplits:i,setPickedSplits:a,rejected:o,setRejected:s,acceptSplit:c,itemsById:l}=e;if(!n.length&&!r.length)return null;let u=e=>s(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n});return(0,J.jsxs)(J.Fragment,{children:[n.length?(0,J.jsxs)(`div`,{className:`act-group`,children:[(0,J.jsxs)(`div`,{className:`act-group-head`,children:[(0,J.jsx)(qw,{className:`tag-failed`,children:`contradict`}),(0,J.jsx)(`span`,{className:`act-group-n`,children:n.length})]}),(0,J.jsx)(`div`,{className:`act-verdict assess-effect`,children:dP}),n.map(n=>{let r=o.has(`conflict:${n.cid}`);return(0,J.jsxs)(`div`,{className:`q-card${r?` act-filed`:``}`,children:[(0,J.jsxs)(`div`,{className:`q-head`,children:[(0,J.jsx)(Is,{size:14}),(0,J.jsx)(`span`,{className:`bl-group-title`,children:n.sentence})]}),n.rows.map(n=>{let r=l.get(n.id);return(0,J.jsx)(`div`,{className:`act-row`,children:(0,J.jsxs)(`div`,{className:`act-body`,children:[(0,J.jsx)(`span`,{className:`act-head`,children:(0,J.jsx)(`span`,{className:`act-when mono`,children:n.id})}),(0,J.jsx)(hR,{row:n,m:e}),t.online||r&&t.onOpenItem?(0,J.jsxs)(`div`,{className:`act-acts`,children:[r&&t.onOpenItem?(0,J.jsxs)(Y,{title:`show it where its words live`,onClick:()=>{q(`action:assess.conflict.open`),t.onOpenItem?.(r)},children:[(0,J.jsx)(Ga,{size:16}),` open`]}):null,t.online&&t.onEditItem?(0,J.jsxs)(Y,{title:`change its words or its time — the send sheet, with this row in it`,onClick:()=>{q(`action:assess.conflict.edit`),t.onEditItem?.(n.id)},children:[(0,J.jsx)(Mo,{size:16}),` edit`]}):null,t.online&&t.onDropItem?(0,J.jsxs)(fC,{confirm:pP,title:mP,onConfirm:()=>{q(`action:assess.conflict.drop`),t.onDropItem?.(n.id)},children:[(0,J.jsx)(B,{size:16}),` `,fP]}):null]}):null]})},n.id)}),t.online?null:(0,J.jsx)(Z,{children:`No connection — edit and drop wait for the link.`}),(0,J.jsx)(`div`,{className:`act-acts`,children:(0,J.jsxs)(Y,{className:r?`active`:void 0,title:r?`un-mark it`:`leave every row here as it is — nothing is sent either way`,onClick:()=>{q(`action:assess.conflict.ignore`),u(`conflict:${n.cid}`)},children:[(0,J.jsx)(vc,{size:16}),` `,r?`left as they are`:hP]})})]},n.cid)})]}):null,r.length?(0,J.jsxs)(`div`,{className:`act-group`,children:[(0,J.jsxs)(`div`,{className:`act-group-head`,children:[(0,J.jsx)(qw,{className:`tag-running`,children:`split`}),(0,J.jsx)(`span`,{className:`act-group-n`,children:r.length})]}),r.map(n=>{let r=i.has(n.sid),s=o.has(`split:${n.sid}`);return(0,J.jsxs)(`div`,{className:`q-card${s?` act-filed`:``}`,children:[(0,J.jsxs)(`div`,{className:`q-head`,children:[(0,J.jsx)(Rc,{size:14}),(0,J.jsx)(`span`,{className:`bl-group-title`,children:n.sentence})]}),(0,J.jsxs)(`div`,{className:`section section-head`,children:[(0,J.jsx)(`span`,{children:`the item as written`}),(0,J.jsx)(`span`,{className:`section-hint mono`,children:n.id})]}),(0,J.jsx)(`div`,{className:`act-row`,children:(0,J.jsx)(`div`,{className:`act-body`,children:(0,J.jsx)(hR,{row:n.original,m:e})})}),(0,J.jsxs)(`div`,{className:`section section-head`,children:[(0,J.jsx)(`span`,{children:`the two it would become`}),(0,J.jsx)(`span`,{className:`section-hint`,children:`written by the assessment, not by you`})]}),n.texts.map((e,n)=>(0,J.jsx)(`div`,{className:`act-row`,children:(0,J.jsxs)(`div`,{className:`act-body`,children:[(0,J.jsx)(`span`,{className:`act-text act-text-full`,children:e}),(0,J.jsx)(pR,{text:e,repoId:t.repoId,outbox:t.outbox,online:t.online})]})},n)),(0,J.jsxs)(`div`,{className:`act-acts`,children:[(0,J.jsxs)(Y,{className:r?`primary`:void 0,title:r?`approved — tap to un-approve`:`approve: the original is archived (words kept) and these two are posted on its clock`,onClick:()=>c(n),children:[(0,J.jsx)(vc,{size:16}),` `,r?`approved`:`approve the split`]}),(0,J.jsxs)(Y,{className:s?`active`:void 0,title:s?`un-mark it`:`keep it as one item`,onClick:()=>{q(`action:assess.split.leave`),u(`split:${n.sid}`),a(e=>{let t=new Set(e);return t.delete(n.sid),t})},children:[(0,J.jsx)(B,{size:16}),` keep it as one`]})]})]},n.sid)})]}):null]})}function _R({r:e,accepted:t,rejected:n,onAccept:r,onReject:i,onOpen:a,repoId:o,outbox:s,online:c}){let l=WM(e.verdict,e.source,e.failed),u=JM(e),d=e.acceptBlocked;return(0,J.jsxs)(`div`,{className:`act-row${n?` act-filed`:``}${t?` act-running`:``}`,children:[(0,J.jsxs)(`div`,{className:`act-body`,children:[(0,J.jsxs)(`span`,{className:`act-head`,children:[u.headline?null:(0,J.jsx)(`span`,{className:`act-when`,children:u.kind}),(0,J.jsx)(fR,{headline:u.headline,suggested:u.suggested,category:u.category}),u.id?(0,J.jsx)(`span`,{className:`act-when mono`,children:u.id}):null]}),e.missing?(0,J.jsxs)(`span`,{className:`act-stale`,children:[(0,J.jsx)(gs,{size:11}),` `,IM(e.id)]}):(0,J.jsx)(`span`,{className:`act-text act-text-full`,children:e.text}),(0,J.jsx)(pR,{text:e.text,repoId:o,outbox:s,online:c}),(0,J.jsxs)(`span`,{className:`act-verdict${e.downgraded?` act-last-bad`:``}`,children:[e.downgraded?(0,J.jsx)(gs,{size:11}):null,e.sentence]}),(()=>{let t=BM(e);return t?(0,J.jsx)(`span`,{className:`act-verdict`,children:t}):null})(),e.supersededByText?(0,J.jsxs)(`span`,{className:`act-verdict`,children:[`the item said to cover it: “`,e.supersededByText,`”`]}):null,d?(0,J.jsx)($w,{children:d}):null,n?(0,J.jsx)(`span`,{className:`act-filed-note`,children:`left exactly as it is — nothing will happen to it`}):null]}),(0,J.jsxs)(`div`,{className:`act-acts`,children:[d?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(Y,{className:t?`primary`:void 0,title:t?l.pickedTitle:l.title,onClick:r,children:[(0,J.jsx)(vc,{size:16}),` `,t?l.picked:l.label]}),(0,J.jsxs)(Y,{className:n?`active`:void 0,title:n?GM.pickedTitle:GM.title,onClick:i,children:[(0,J.jsx)(B,{size:16}),` `,n?GM.picked:GM.label]})]}),a?(0,J.jsxs)(Y,{title:`show this item where it lives`,onClick:a,children:[(0,J.jsx)(Fs,{size:16}),` open`]}):null]})]})}function vR({card:e,accepted:t,rejected:n,onAccept:r,onReject:i,repoId:a,outbox:o,online:s}){let c=e.originals.length||e.ids.length;return(0,J.jsxs)(`div`,{className:`q-card${n?` act-filed`:``}`,children:[(0,J.jsxs)(`div`,{className:`q-head`,children:[(0,J.jsx)(kc,{size:14}),(0,J.jsxs)(`span`,{className:`bl-group-title`,children:[`one prompt in place of `,c]}),e.rank==null?null:(0,J.jsxs)(`span`,{className:`act-count`,children:[`position `,e.rank]})]}),(0,J.jsx)(`div`,{className:`act-verdict`,children:e.rationale||`no rationale was given — the prompt and the originals below are all there is to judge it on`}),(0,J.jsxs)(`div`,{className:`section section-head`,children:[(0,J.jsx)(`span`,{children:`the prompt it would run`}),(0,J.jsx)(`span`,{className:`section-hint`,children:`written by the assessment, not by you`})]}),e.headline||e.category?(0,J.jsx)(`div`,{className:`act-head asr-namehead`,children:(0,J.jsx)(fR,{headline:e.headline,suggested:!!e.headline,category:e.category})}):null,(0,J.jsx)(`div`,{className:`act-text act-text-full`,children:e.prompt}),(0,J.jsx)(pR,{text:e.prompt,repoId:a,outbox:o,online:s}),(0,J.jsxs)(`div`,{className:`section section-head`,children:[(0,J.jsxs)(`span`,{children:[`it replaces these `,c,`, in full`]}),(0,J.jsx)(`span`,{className:`section-hint mono`,children:e.ids.join(` · `)})]}),e.originals.map(e=>{let t=JM(e);return(0,J.jsx)(`div`,{className:`act-row`,children:(0,J.jsxs)(`div`,{className:`act-body`,children:[(0,J.jsxs)(`span`,{className:`act-head`,children:[t.headline?null:(0,J.jsx)(`span`,{className:`act-when`,children:t.kind}),(0,J.jsx)(fR,{headline:t.headline,suggested:t.suggested,category:t.category}),t.id?(0,J.jsx)(`span`,{className:`act-when mono`,children:t.id}):null]}),e.missing?(0,J.jsxs)(`span`,{className:`act-stale`,children:[(0,J.jsx)(gs,{size:11}),` not on this phone`]}):(0,J.jsx)(`span`,{className:`act-text act-text-full`,children:e.text}),(0,J.jsx)(pR,{text:e.text,repoId:a,outbox:o,online:s})]})},e.id)}),e.missingIds.length?(0,J.jsxs)(`div`,{className:`act-stale`,children:[(0,J.jsx)(gs,{size:11}),` `,e.missingIds.length,` of the items this merge names`,e.missingIds.length===1?` is`:` are`,` not on this phone, so`,e.missingIds.length===1?` its words are`:` their words are`,` not shown above.`]}):null,(0,J.jsxs)(`div`,{className:`act-acts`,children:[(0,J.jsxs)(Y,{className:t?`primary`:void 0,title:t?`approved — tap to un-approve`:`approve this merge: one new item, and all ${c} retired with a reason`,onClick:r,children:[(0,J.jsx)(vc,{size:16}),` `,t?`approved`:`approve the merge`]}),(0,J.jsxs)(Y,{className:n?`active`:void 0,title:n?`un-mark it`:`leave all of them exactly as they are`,onClick:i,children:[(0,J.jsx)(B,{size:16}),` leave all `,c]})]})]})}function yR({m:e}){let{p:t,pickedRows:n,setPickedRows:r,pickedMerges:i,setPickedMerges:a,rejected:o,flipped:s,setFlipped:c,groups:l,itemsById:u,toggleRow:d,toggleReject:f,bulkGroup:p,acceptMerge:m}=e;return(0,J.jsx)(J.Fragment,{children:l.map(e=>{let l=e.fixedOpen||(s.has(e.verdict)?!e.defaultOpen:e.defaultOpen),h=e.verdict===`unclear`?XM(e.rows):[],g=e.rows.filter(e=>!e.acceptBlocked&&n.has(e.id)).length,_=tN(e,g,{repoName:t.repoName});return(0,J.jsxs)(`div`,{className:`act-group`,children:[(0,J.jsxs)(`div`,{className:`act-group-head`,children:[(0,J.jsx)(qw,{className:ZI[e.verdict],children:e.label}),(0,J.jsx)(`span`,{className:`act-group-n`,children:e.count}),_?(0,J.jsxs)(Y,{title:_.title,onClick:()=>p(e,_),children:[(0,J.jsx)(Qs,{size:14}),` `,_.label]}):null,e.fixedOpen?null:(0,J.jsx)(Y,{className:`act-group-more`,title:l?`collapse this`:`show these`,onClick:()=>{q(`action:assess.strip.${e.verdict}`),c(t=>{let n=new Set(t);return n.delete(e.verdict)||n.add(e.verdict),n})},children:l?(0,J.jsx)(mc,{size:14}):(0,J.jsx)(Nc,{size:14})})]}),l&&e.verdict!==`merged`?(0,J.jsx)(`div`,{className:`act-verdict assess-effect`,children:WM(e.verdict,void 0,e.failed>0).effect}):null,l&&h.length?(0,J.jsx)(`div`,{className:`act-group-head`,children:h.map(e=>(0,J.jsxs)(`span`,{className:`act-count`,children:[e.n,` × `,e.text]},e.down))}):null,l?e.merges.map(e=>(0,J.jsx)(vR,{card:e,accepted:i.has(e.gid),rejected:o.has(`merge:${e.gid}`),repoId:t.repoId,outbox:t.outbox,online:t.online,onAccept:()=>m(e),onReject:()=>f(`merge:${e.gid}`,()=>a(t=>{let n=new Set(t);return n.delete(e.gid),n}))},e.gid)):null,l?e.rows.map(e=>{let i=u.get(e.id);return(0,J.jsx)(_R,{r:e,accepted:n.has(e.id),rejected:o.has(`row:${e.id}`),repoId:t.repoId,outbox:t.outbox,online:t.online,onAccept:()=>{q(`action:assess.accept.${e.verdict}`),d(e.id)},onReject:()=>{q(`action:assess.leave`),f(`row:${e.id}`,()=>r(t=>{let n=new Set(t);return n.delete(e.id),n}))},onOpen:i&&t.onOpenItem?()=>{q(`action:assess.open`),t.onOpenItem?.(i)}:void 0},e.id)}):null]},e.verdict)})})}function bR({m:e}){let{rankedN:t,pinRanks:n,setPinRanks:r,nameCount:i,writeNames:a,setWriteNames:o}=e;return t>0||i>0?(0,J.jsxs)(`div`,{className:`asr-asks`,children:[t>0&&(0,J.jsxs)(Z,{className:`asr-pin`,children:[Je(t),(0,J.jsx)(`div`,{className:`asr-answer`,children:(0,J.jsx)(yS,{label:`the order of the rows`,value:n?`keep`:`free`,options:[{key:`keep`,label:`keep this order`},{key:`free`,label:`leave it unmarked`}],onChange:e=>{e===`keep`?(q(`action:assess.pin`),r(!0)):(q(`action:assess.pin.free`),r(!1))}})}),(0,J.jsx)(`div`,{children:ye(n)})]}),i>0&&(0,J.jsxs)(Z,{className:`asr-pin`,children:[Cn(i),(0,J.jsx)(`div`,{className:`asr-answer`,children:(0,J.jsx)(yS,{label:`the run's titles`,value:a?`write`:`skip`,options:[{key:`write`,label:`write them`},{key:`skip`,label:`leave the rows as they are`}],onChange:e=>{e===`write`?(q(`action:assess.name`),o(!0)):(q(`action:assess.name.skip`),o(!1))}})}),(0,J.jsx)(`div`,{children:iee(a)})]})]}):null}function xR({m:e}){let{logOpen:t,setLogOpen:n,pastSteps:r}=e;return(0,J.jsxs)(J.Fragment,{children:[r&&r.tail.length?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`section section-head`,children:[(0,J.jsx)(`span`,{children:`what it looked at`}),(0,J.jsxs)(Y,{title:t?`collapse this`:`show these`,onClick:()=>{q(`action:assess.log`),n(e=>!e)},children:[t?(0,J.jsx)(mc,{size:14}):(0,J.jsx)(Nc,{size:14}),` `,TN(r.steps,r.tail.length).button]})]}),t?(0,J.jsx)(dR,{steps:r.tail}):null]}):null,(0,J.jsx)(bR,{m:e})]})}function SR({m:e}){let{p:t,run:n,proposal:r,counts:i,watch:a,guideOpen:o,setGuideOpen:s,res:c,nothing:l,guide:u}=e;return(0,J.jsxs)(J.Fragment,{children:[i?(0,J.jsx)(`div`,{className:`act-filters`,children:zt.map(e=>(0,J.jsxs)(qw,{className:ZI[e],children:[In(e),` `,(0,J.jsx)(`span`,{className:`act-count`,children:i[e]})]},e))}):null,n?(0,J.jsxs)(`div`,{className:`assess-intro`,children:[e.slotIntro?(0,J.jsx)(`div`,{className:`assess-guide-lead`,children:e.slotIntro}):null,(0,J.jsx)(`div`,{className:`assess-guide-lead`,children:u.lead}),(0,J.jsx)(`div`,{className:`act-group-head`,children:(0,J.jsxs)(Y,{title:o?`hide this`:`what accepting and applying on this screen actually do`,onClick:()=>{q(`action:assess.guide`),s(e=>!e)},children:[o?(0,J.jsx)(mc,{size:14}):(0,J.jsx)(Nc,{size:14}),` how this works`]})}),o?(0,J.jsx)(`ul`,{className:`assess-guide`,children:u.lines.map((e,t)=>(0,J.jsx)(`li`,{children:e},t))}):null]}):null,n?.detail?(0,J.jsx)(Z,{tone:n.status===`failed`?`warn`:void 0,children:n.detail}):null,n?.status===`failed`&&n.envelope?(0,J.jsx)(`div`,{className:`hist-out mono`,children:n.envelope}):null,a?(0,J.jsxs)(`div`,{className:`assess-watch`,children:[(0,J.jsxs)(`div`,{className:`assess-doing`,children:[(0,J.jsx)($s,{size:16,className:`spin`}),(0,J.jsx)(`span`,{children:a.doing})]}),(0,J.jsxs)(`div`,{className:`act-triage`,children:[(0,J.jsx)(`span`,{className:`act-count`,children:a.elapsed}),a.counts?(0,J.jsx)(`span`,{className:`act-count`,children:a.counts}):null,n?.progress?.model?(0,J.jsx)(`span`,{className:`act-count`,children:n.progress.model}):null,a.quiet?(0,J.jsx)(`span`,{className:`act-count warn`,children:a.quiet}):null]}),a.say?(0,J.jsx)(Z,{className:`assess-say`,children:a.say}):null,(0,J.jsx)(dR,{steps:n?.progress?.tail??[]})]}):null,t.online?null:(0,J.jsx)(Z,{tone:`warn`,children:`No connection — this is the last proposal this phone was told about. Applying starts work on the desktop, so it waits for the link; nothing here expires while it is down.`}),(0,J.jsx)($,{res:c,empty:l,thing:`the assessment`,noun:`proposal`,children:n==null?`Nothing has been assessed in ${t.repoName} yet. An assessment reads the repo and says, of everything still open here, what is already done, what no longer applies, what is covered elsewhere and what is still worth doing — with evidence, and nothing is applied until you approve it.`:n.status===`running`?`The assessment is reading the repo — what it is doing is above. It leaves a proposal here when it finishes; you can close this and come back.`:n.status===`failed`?`The run did not produce a proposal, so nothing was decided and nothing was touched.`:`The run came back with nothing to decide — there was nothing still open in this repo.`}),r&&r.notes.length?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`section section-head`,children:[(0,J.jsx)(`span`,{children:`what the app refused`}),(0,J.jsx)(`span`,{className:`section-hint`,children:`shown, not swallowed — a dropped group and a group nobody proposed look identical otherwise`})]}),(0,J.jsx)(`div`,{className:`list`,children:r.notes.map((e,t)=>(0,J.jsxs)(`div`,{className:`act-verdict`,children:[(0,J.jsx)(gs,{size:11}),` `,e]},t))})]}):null]})}function CR(e){let t=qI(e),{run:n,proposal:r}=t;return(0,J.jsx)(Hw,{className:`assess-sheet`,title:(0,J.jsx)(`span`,{title:e.repoDir,children:e.repoName}),icon:(0,J.jsx)(To,{size:18}),onClose:e.onClose,footer:r?(0,J.jsx)(tL,{m:t}):null,actions:(0,J.jsx)(eL,{m:t}),head:n?(0,J.jsx)(nL,{m:t}):null,children:(0,J.jsxs)(`div`,{className:`sheet-scroll`,children:[(0,J.jsx)(SR,{m:t}),(0,J.jsxs)(`div`,{className:`list act-list`,children:[(0,J.jsx)(gR,{m:t}),(0,J.jsx)(yR,{m:t}),(0,J.jsx)(mR,{m:t}),(0,J.jsx)(xR,{m:t})]})]})})}function wR({repo:e}){let t=Dh(),{liveSend:n}=t.conn,{budget:r}=t.world,i=e.worktreePath,a=G(vI).get(i)??null,o=G(SI),s=G(bI),c=G(xI),l=G(hI).items,u=Oh();return(0,J.jsx)(CR,{repoDir:i,repoName:e.repoName,repoId:e.id,outbox:u,run:a,online:t.conn.status===`open`,busy:o.size>0,budgetNote:r?.verdict.blocked?fn(r.verdict):null,scope:s,slot:c,onRun:()=>PI(i,s??void 0,c),onEditItem:e=>{let n=t.world.intents.find(t=>t.id===e);n?t.nav.openSend(t.send.seedFromIntent(n)):t.say.toast(`that row is gone`)},onDropItem:e=>n({t:`backlog.archive`,id:e,archived:!0},`archived — its words are kept; the backlog's archived cut brings it back`,`no connection — archiving waits for the link`),onApply:e=>{a&&FI(a,e)},onDiscard:()=>n({t:`assess.discard`,runId:a?.runId??``},`proposal discarded — nothing was applied`,`no connection — the proposal lives on the desktop`),onOpenPlan:n=>t.files.openFileFrom({repoId:e.id,relPath:n,mtime:a?.planMtime},`assess`),onOpenItem:e=>{e.source===`note`?t.nav.openPadAt(e.id):t.nav.openActivity()},backlog:l.filter(e=>e.repoDir===i),onOpenBacklog:(e,t)=>jI(i,e,t),onClose:LI})}var TR={id:`backlog`,boot:()=>(FP(II),()=>FP(null)),sheets:[{id:`backlog`,persisted:!0,render:()=>(0,V.createElement)(VI),onLeave:MI},{id:`assess`,persisted:!1,render:()=>{let e=yI.get();return e?(0,V.createElement)(wR,{repo:e}):null}}],messages:{welcome:()=>EI(),"backlog.list":e=>wI(e),"assess.state":e=>TI(e.repoDir,e.run)}};function ER({m:e,p:t}){let{selecting:n,pickedRows:r,shown:i,selectVisible:a,clearSelection:o,refire:s,file:c,restorable:l,filter:u}=e;if(!n)return null;let d=u===`dismissed`,f=r.length?[...s.go.length?[]:[{label:`send again`,reason:`none of the selected rows can be sent again — each says why on its own row`}],...d||c.go.length?[]:[{label:`file away`,reason:`the selected rows are running — stopping one is “cancel”`}]]:[];return(0,J.jsxs)(`div`,{className:`act-bulk`,children:[(0,J.jsx)(`span`,{className:`act-bulk-n`,children:r.length?`${r.length} selected`:`none selected — tick rows to act on them`}),i.length?(0,J.jsxs)(Y,{title:`select all ${i.length} rows on screen`,onClick:a,children:[(0,J.jsx)(eo,{size:14}),` all `,i.length]}):null,r.length?(0,J.jsxs)(Y,{title:`clear the selection`,onClick:o,children:[(0,J.jsx)(ic,{size:14}),` none`]}):null,s.go.length?(0,J.jsxs)(Y,{variant:`primary`,"data-hint":`activity.bulkRefire`,title:`send ${s.go.length} again as backlog items, each in the repo it was written for${s.skip.length?` — ${s.skip.length} left alone`:``}`,onClick:()=>{q(`action:activity.bulk.refire`),t.onBulk(`refire`,s.go)},children:[(0,J.jsx)(Uc,{size:14}),` send `,s.go.length,` again`]}):null,d?l.length?(0,J.jsxs)(Y,{title:`put ${l.length} back in the list`,onClick:()=>{q(`action:activity.bulk.restore`),t.onBulk(`restore`,l)},children:[(0,J.jsx)(Co,{size:14}),` bring `,l.length,` back`]}):null:c.go.length?(0,J.jsxs)(Y,{"data-hint":`activity.bulkDismiss`,title:`file ${c.go.length} away as dealt with — nothing is deleted, and “dismissed” brings them back`,onClick:()=>{q(`action:activity.bulk.dismiss`),t.onBulk(`dismiss`,c.go)},children:[(0,J.jsx)(Oo,{size:14}),` file `,c.go.length,` away`]}):null,(0,J.jsx)(Qw,{cants:f})]})}function DR(e,t,n){if(e.all+e.dismissed===0)return{chips:[],none:null};let r=[],i=[],a=null;for(let o of Sj){let s=!n&&t===o.id,c=o.id!==`all`&&o.id!==`dismissed`&&e[o.id]===e.all;o.id===`all`||s||e[o.id]>0&&!c?r.push({id:o.id,text:Iw(o.label,{count:e[o.id]}),on:s}):e[o.id]>0?a=o.id===`needsYou`?`all need you`:`all ${o.label}`:i.push(o.label)}return{chips:r,none:[a,i.length?`nothing ${OR(i)}`:null].filter(Boolean).join(` · `)||null}}function OR(e){return e.length<2?e.join(``):`${e.slice(0,-1).join(`, `)} or ${e[e.length-1]}`}function kR({m:e}){let{filter:t,focus:n,setFocus:r,setFilter:i,counts:a,selecting:o,setSelecting:s,setSelected:c,grouped:l,setGrouped:u,sort:d,setSort:f,debrisCount:p,hideDebris:m,setHideDebris:h}=e,{chips:g,none:_}=DR(a,t,!!n);return(0,J.jsxs)(J.Fragment,{children:[g.length?(0,J.jsx)(`div`,{className:`fchips wrap act-fchips`,children:g.map(e=>(0,J.jsx)(zw,{on:e.on,clears:!1,onClick:()=>{q(`action:activity.filter.${e.id}`),r(null),i(e.id)},children:e.text},e.id))}):null,_?(0,J.jsx)(`div`,{className:`act-none`,children:_}):null,(0,J.jsxs)(`div`,{className:`fchips wrap act-toggles`,children:[(0,J.jsx)(zw,{on:o,title:o?`leave selection mode`:`select rows — deal with many at once`,onClick:()=>{q(`action:activity.select`),s(e=>!e),o&&c(new Set)},children:`select`}),(0,J.jsx)(`span`,{className:`act-hint`,"data-hint":`activity.group`,title:l?`show every copy separately`:`collapse rows that say the same thing`,children:(0,J.jsx)(zw,{on:l,onClick:()=>{q(`action:activity.group`),u(e=>!e)},children:`grouped`})}),(0,J.jsx)(zw,{on:d===`oldest`,title:d===`oldest`?`back to attention order — what needs you first`:`oldest first — the ones that have been waiting longest`,onClick:()=>{q(`action:activity.sort`),f(e=>e===`oldest`?`ranked`:`oldest`)},children:`oldest first`}),p>0||m?(0,J.jsx)(`span`,{className:`act-hint`,"data-hint":`activity.debris`,title:`hide one-word replies — “continue please”, “done?”, a bare /cost. Nothing is deleted.`,children:(0,J.jsx)(zw,{on:m,onClick:()=>{q(`action:activity.debris`),h(e=>!e)},children:p?Iw(`hide chatter`,{count:p}):`hide chatter`})}):null]})]})}function AR({s:e}){let t=ate(e);return t?(0,J.jsxs)(`span`,{className:`row-name`,title:`what the desktop called this conversation`,children:[(0,J.jsx)(xl,{size:11,"aria-hidden":`true`}),` `,t]}):null}var jR={sendNow:Uc,hold:go,retarget:So,edit:Mo,fix:el,retry:Uc,answer:Ss,check:Cs,open:qa,runNow:La,cancel:B,toggle:eo,download:Qa,save:Gs,discard:ws,dismiss:os,confirmDone:Qs},MR={prompt:Ss,answer:eo,upload:el,action:La,sweep:Ro,build:uo,download:Qa},NR={queued:fo,blocked:go,starting:$s,running:$s,done:Qs,failed:gs,canceled:B},PR={landed:`it reached the session`,unconfirmed:`it was written into the session, and nothing confirmed it submitted — do not retype it`,unsubmitted:`it is sitting in the composer, unsent — do not retype it`,refused:`the desktop answered and refused it, so nothing was written`,unreachable:`the desktop never answered — it may have run`,unknown:`nobody recorded whether it ran`};function FR(e,t){let n=Math.round((e-t)/1e3);if(n<=0)return`now`;let r=Math.floor(n/60);if(r<60)return`in ${r||1}m`;let i=Math.floor(r/60);return i<24?r%60?`in ${i}h ${r%60}m`:`in ${i}h`:`in ${Math.floor(i/24)}d`}function IR({a:e,onPress:t}){let n=jR[e.id];return(0,J.jsxs)(Y,{className:e.danger?`danger`:void 0,title:e.label,"data-hint":`activity.${e.id}`,onClick:t,children:[(0,J.jsx)(n,{size:16}),` `,e.label]})}function LR({row:e,now:t,sessions:n,repos:r,pick:i,outbox:a,online:o,review:s,repoIdForCwd:c,onAction:l,onRetarget:u,onOpenSession:d}){let[f,p]=(0,V.useState)(!1),[m,h]=(0,V.useState)(!1),[g,_]=(0,V.useState)(!1),[v,y]=(0,V.useState)(!1),b=s??null,x=b?.checkStatus&&b.checkStatus!==`checking`?b.checkDetail:void 0,S=(0,V.useMemo)(()=>!!e.attachText&&uL(e.attachText).length>0,[e.attachText]),[C,w]=uR(S),T=MR[e.kind],E=NR[e.state],D=e.actions.filter(e=>!e.disabledReason),O=e.actions.filter(e=>e.disabledReason),k=D.find(e=>e.primary)??D[0]??null,A=D.filter(e=>e!==k&&e.alwaysShown),j=D.filter(e=>e!==k&&!e.alwaysShown),M=e.state===`running`||e.state===`starting`,N=t=>{q(`action:activity.${t.id}`),t.id===`retarget`?(_(e=>!e),p(!1)):l(t.id,e)};return(0,J.jsxs)(`div`,{ref:w,className:`act-row act-${e.bucket}${g?` act-aiming`:``}${i?` act-picking`:``}${e.dismissedAt==null?``:` act-filed`}`,children:[i?(0,J.jsx)(`button`,{className:`act-pick${i.checked?` on`:``}`,"aria-label":i.checked?`deselect`:`select`,title:i.checked?`deselect this row`:`select this row`,onClick:i.onToggle,children:i.checked?(0,J.jsx)(eo,{size:18}):(0,J.jsx)(ic,{size:18})}):null,(0,J.jsxs)(`div`,{className:`act-rowmain`,children:[(0,J.jsxs)(`button`,{className:`act-body`,onClick:()=>h(e=>!e),title:e.clipped||e.fullText?`tap for the whole thing`:e.title,children:[(0,J.jsxs)(`span`,{className:`act-head`,children:[(0,J.jsx)(T,{size:12}),(0,J.jsx)(`span`,{className:`act-where`,children:e.where}),(0,J.jsx)(`span`,{className:`act-when`,children:Tp(e.at)})]}),(0,J.jsx)(`span`,{className:`act-text${m?` act-text-full`:``}`,children:m&&e.fullText?e.fullText:e.title}),(0,J.jsxs)(`span`,{className:`act-verdict`,children:[(0,J.jsx)(E,{size:12,className:M?`spin`:void 0}),e.verdict]}),e.delivery?(0,J.jsxs)(`span`,{className:`act-delivery`,children:[(0,J.jsx)(cs,{size:11}),` `,PR[e.delivery]]}):null,e.asOf==null?null:(0,J.jsxs)(`span`,{className:`act-stale`,children:[`last known `,Tp(e.asOf),` — the desktop is not reachable`]}),e.dismissedAt==null?null:(0,J.jsxs)(`span`,{className:`act-filed-note`,children:[(0,J.jsx)(Oo,{size:11}),` filed `,Tp(e.dismissedAt),` — the words are still here`]}),e.dueAt!=null&&e.dueAt>t?(0,J.jsxs)(`span`,{className:`act-due`,children:[(0,J.jsx)(rl,{size:11}),` `,FR(e.dueAt,t),` · `,new Date(e.dueAt).toLocaleString()]}):null,e.progress&&e.progress.total>0?(0,J.jsxs)(`span`,{className:`act-prog`,children:[(0,J.jsx)(`span`,{className:`act-bar`,children:(0,J.jsx)(`i`,{style:{width:`${Math.min(100,Math.round(e.progress.done/e.progress.total*100))}%`}})}),(0,J.jsx)(`span`,{className:`act-prog-n`,children:e.progress.label===`bytes`?`${hj(e.progress.done)} of ${hj(e.progress.total)}`:`${e.progress.done} of ${e.progress.total} ${e.progress.label??``}`})]}):null,e.lastRun?(0,J.jsxs)(`span`,{className:`act-last${e.lastRun.ok?``:` act-last-bad`}`,children:[`last run `,Tp(e.lastRun.at),e.lastRun.late?` (late)`:``,e.lastRun.detail?` — ${e.lastRun.detail}`:``]}):null,e.attempts>1?(0,J.jsxs)(`span`,{className:`act-tries`,children:[e.attempts,` attempts`]}):null]}),S&&C?(0,J.jsx)(lR,{compact:!0,text:e.attachText,repoId:e.cwd?c(e.cwd):null,outbox:a,online:o}):null,b?.checkStatus?(0,J.jsxs)(`div`,{className:`act-check`,children:[(0,J.jsxs)(`button`,{className:`bl-check bl-check-${b.checkStatus}`,disabled:!x,title:x?`tap for the whole check`:b.checkNote||``,onClick:()=>y(e=>!e),children:[(()=>{let e=zP[b.checkStatus];return(0,J.jsx)(e,{size:11,style:{verticalAlign:`-1px`}})})(),` `,RP[b.checkStatus],b.checkNote?` · ${b.checkNote}`:``,x?v?(0,J.jsx)(mc,{size:11}):(0,J.jsx)(Nc,{size:11}):null]}),x&&v?(0,J.jsxs)(`div`,{className:`bl-check-detail`,children:[(0,J.jsx)(`pre`,{children:x}),b.checkedAt?(0,J.jsxs)(`span`,{className:`bl-check-when`,children:[`checked `,new Date(b.checkedAt).toLocaleString()]}):null]}):null]}):null,e.targets.length?(0,J.jsx)(`div`,{className:`act-targets`,children:e.targets.map(e=>(0,J.jsxs)(`div`,{className:`act-target act-t-${e.state}`,children:[(0,J.jsx)(`span`,{className:`act-target-name`,children:e.label}),(0,J.jsx)(`span`,{className:`act-target-state`,children:e.detail??e.state}),e.sessionId?(0,J.jsx)(Y,{title:`open this repo's session`,onClick:()=>d(e.sessionId),children:(0,J.jsx)(qa,{size:14})}):(0,J.jsx)($w,{children:`no session`})]},e.label))}):null,(0,J.jsxs)(`div`,{className:`act-acts`,children:[(0,J.jsxs)(`span`,{className:`act-acts-verbs`,children:[k?(0,J.jsx)(IR,{a:k,onPress:()=>N(k)}):null,A.map(e=>(0,J.jsx)(IR,{a:e,onPress:()=>N(e)},e.id))]}),j.length||O.length&&k?(0,J.jsxs)(Y,{className:`act-more`,title:f?`fewer options`:`more options`,onClick:()=>p(e=>!e),children:[f?(0,J.jsx)(mc,{size:16}):(0,J.jsx)(Nc,{size:16}),` more`]}):null]}),f&&j.length?(0,J.jsx)(`div`,{className:`act-acts act-acts-more`,children:j.map(e=>(0,J.jsx)(IR,{a:e,onPress:()=>N(e)},e.id))}):null,[k,...A,...f?j:[]].filter(e=>!!e?.note).map(e=>(0,J.jsx)(Z,{children:e.note},`note-${e.id}`)),O.length>0&&(f||!k)?(0,J.jsx)(Qw,{cants:O.map(e=>({label:e.label,reason:e.disabledReason}))}):null,g?(0,J.jsxs)(`div`,{className:`act-aim`,children:[(0,J.jsx)(Z,{children:`Keep the words, change where they go.`}),n.filter(t=>t.running&&t.id!==e.sessionId).map(t=>(0,J.jsxs)(`button`,{className:`row`,onClick:()=>{_(!1),u(e,{sessionId:t.id,cwd:t.cwd,mode:`input`})},children:[(0,J.jsxs)(Zw,{children:[(0,J.jsx)(Uc,{size:12}),` `,t.title]}),(0,J.jsx)(AR,{s:t}),(0,J.jsx)(Q,{children:t.turnActive?`working`:`idle`})]},t.id)),(0,J.jsx)(aF,{repos:r,listClass:``,home:e.cwd,subLead:`backlog item`,icon:(0,J.jsx)(Qs,{size:12}),onPick:t=>{_(!1),u(e,{sessionId:t.worktreePath,cwd:t.worktreePath,mode:`backlog`})}})]}):null]})]})}function RR({g:e,now:t,sessions:n,repos:r,outbox:i,online:a,reviews:o,repoIdForCwd:s,selecting:c,selected:l,onToggleRow:u,onToggleGroup:d,onAction:f,onRetarget:p,onOpenSession:m}){let[h,g]=(0,V.useState)(!1),_=e.rows.length,v=e.elsewhere.done,y=e=>c?{checked:l.has(e.key),onToggle:()=>u(e.key)}:void 0;if(_===1&&v===0&&e.elsewhere.other===0)return(0,J.jsx)(LR,{row:e.rows[0],now:t,sessions:n,repos:r,pick:y(e.rows[0]),outbox:i,online:a,review:o?.[e.rows[0].id],repoIdForCwd:s,onAction:f,onRetarget:p,onOpenSession:m});let b=e.rows.every(e=>l.has(e.key));return(0,J.jsxs)(`div`,{className:`act-group`,children:[(0,J.jsxs)(`div`,{className:`act-group-head`,children:[c?(0,J.jsx)(`button`,{className:`act-pick${b?` on`:``}`,"aria-label":b?`deselect these`:`select these`,title:b?`deselect all ${_}`:`select all ${_}`,onClick:()=>d(e),children:b?(0,J.jsx)(eo,{size:18}):(0,J.jsx)(ic,{size:18})}):null,_>1?(0,J.jsxs)(`span`,{className:`act-group-n`,children:[(0,J.jsx)(_o,{size:11}),` ×`,_]}):null,_>1?(0,J.jsxs)(`span`,{className:`act-group-span`,children:[Tp(e.oldestAt),` → `,Tp(e.newestAt)]}):null,v>0?(0,J.jsxs)(`span`,{className:`act-group-ran`,children:[(0,J.jsx)(Qs,{size:11}),` `,v===1?`one of these already ran`:`${v} of these already ran`]}):null,e.elsewhere.other>0?(0,J.jsxs)(`span`,{className:`act-group-else`,children:[e.elsewhere.other,` more elsewhere in the list`]}):null,_>1?(0,J.jsx)(Y,{className:`act-group-more`,title:h?`collapse these`:`show all ${_} copies`,onClick:()=>{q(`action:activity.expand`),g(e=>!e)},children:h?(0,J.jsx)(mc,{size:14}):(0,J.jsx)(Nc,{size:14})}):null]}),(h?e.rows:e.rows.slice(0,1)).map(e=>(0,J.jsx)(LR,{row:e,now:t,sessions:n,repos:r,pick:y(e),outbox:i,online:a,review:o?.[e.id],repoIdForCwd:s,onAction:f,onRetarget:p,onOpenSession:m},e.key))]})}function zR({m:e,p:t}){let{shown:n,focus:r,rows:i,filter:a,counts:o,groups:s,now:c,selecting:l,selected:u,toggleRow:d,toggleGroup:f}=e;return(0,J.jsx)(`div`,{className:`list act-list`,children:n.length===0?(0,J.jsx)(Z,{children:r?`Nothing left of ${r.label} — every one of them has moved on. They are under “all”.`:i.length===0?`Nothing has been posted yet. Everything you send, queue, schedule, build or download shows up here and stays here until it is finished.`:a===`dismissed`?`Nothing filed away yet. Rows you have read and dealt with land here — they keep their words and their buttons, and “bring back” returns them to the list.`:`Nothing under “${Sj.find(e=>e.id===a)?.label}”. ${o.all} ${o.all===1?`row`:`rows`} under “all”${o.dismissed?`, ${o.dismissed} filed away`:``}.`}):s.map(e=>(0,J.jsx)(RR,{g:e,now:c,sessions:t.sessions,repos:t.repos,outbox:t.outbox,online:t.online,reviews:t.reviews,repoIdForCwd:t.repoIdForCwd,selecting:l,selected:u,onToggleRow:d,onToggleGroup:f,onAction:t.onAction,onRetarget:t.onRetarget,onOpenSession:t.onOpenSession},e.key))})}function BR({m:e,online:t}){let{focus:n,setFocus:r,focusMissing:i,headline:a,headlineCut:o,setFilter:s,hideDebris:c,debrisCount:l}=e;return(0,J.jsxs)(J.Fragment,{children:[n?(0,J.jsxs)(Z,{className:`act-focus`,children:[(0,J.jsx)(ja,{size:12}),` showing `,n.label,i>0?` — ${i} of them ${i===1?`has`:`have`} moved on since and ${i===1?`is`:`are`} under “all”`:``,`.`,(0,J.jsxs)(Y,{onClick:()=>{q(`action:activity.focus.clear`),r(null)},children:[(0,J.jsx)(B,{size:14}),` show everything`]})]}):null,a?(0,J.jsxs)(Z,{tone:t?void 0:`warn`,children:[a,o?(0,J.jsxs)(`button`,{className:`link-btn`,onClick:()=>{q(`action:activity.headline.${o}`),s(o)},children:[`show `,a.startsWith(`1 `)?`it`:`them`]}):null]}):null,t?null:(0,J.jsxs)(Z,{tone:`warn`,children:[(0,J.jsx)(fo,{size:12}),` no connection — rows the desktop owns are last known, and each one says when. Nothing here expires while the link is down.`]}),c&&l>0?(0,J.jsxs)(Z,{children:[l,` one-word `,l===1?`reply is`:`replies are`,` hidden — nothing was deleted, tap “hide chatter” again to see them.`]}):null]})}var VR=W(null);function HR(e){VR.set(e?{Sheet:e}:null)}function UR(){return G(VR)?.Sheet??null}var WR=W(null);function GR(e){WR.set(e?{Section:e}:null)}function KR(){return G(WR)?.Section??null}function qR(e){let[t,n]=(0,V.useState)(`all`),[r,i]=(0,V.useState)(()=>e.focus&&e.focus.keys.length?{keys:new Set(e.focus.keys),label:e.focus.label}:null),[a,o]=(0,V.useState)(!1),[s,c]=(0,V.useState)(()=>new Set),[l,u]=(0,V.useState)(!0),[d,f]=(0,V.useState)(!1),[p,m]=(0,V.useState)(`ranked`),h=Ww(1e4),g=(0,V.useMemo)(()=>Qde({now:h,online:e.online,hostSeenAt:e.hostSeenAt,deps:{isEditableEntry:th,isCreateOp:nh,laneLabel:e.laneLabel,repoName:e.repoName},outbox:e.outbox,queueBlocked:e.queueBlocked,goneLanes:new Set(e.goneLanes),intents:e.intents,pulls:e.pulls,sessions:e.sessions,dismissed:e.dismissed,confirmedDone:e.confirmedDone}),[h,e.online,e.hostSeenAt,e.laneLabel,e.repoName,e.outbox,e.queueBlocked,e.goneLanes,e.intents,e.pulls,e.sessions,e.dismissed,e.confirmedDone]),_=(0,V.useMemo)(()=>efe(g),[g]),v=(0,V.useMemo)(()=>rfe(g.filter(e=>r?r.keys.has(e.key):$de(e,t)),p),[g,t,p,r]),y=r?r.keys.size-v.length:0,b=(0,V.useMemo)(()=>v.filter(wj).length,[v]),x=(0,V.useMemo)(()=>d?v.filter(e=>!wj(e)):v,[v,d]),S=(0,V.useMemo)(()=>ife(x,g,{group:l}),[x,g,l]),C=tfe(r?v:g,e.online),w=C?.text??null,T=C&&!r&&C.cut!==t?C.cut:null,E=KR(),D=(0,V.useMemo)(()=>x.filter(e=>s.has(e.key)),[x,s]);return{filter:t,setFilter:n,focus:r,setFocus:i,selecting:a,setSelecting:o,selected:s,setSelected:c,grouped:l,setGrouped:u,hideDebris:d,setHideDebris:f,sort:p,setSort:m,now:h,rows:g,counts:_,shown:x,groups:S,headline:w,headlineCut:T,PeerJobs:E,debrisCount:b,focusMissing:y,pickedRows:D,toggleRow:e=>c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),toggleGroup:e=>c(t=>{let n=new Set(t),r=e.rows.every(e=>n.has(e.key));for(let t of e.rows)r?n.delete(t.key):n.add(t.key);return n}),selectVisible:()=>{q(`action:activity.selectall`),c(new Set(x.map(e=>e.key)))},clearSelection:()=>{q(`action:activity.selectnone`),c(new Set)},refire:dj(D,Rde),file:dj(D,uj),restorable:D.filter(e=>e.dismissedAt!=null)}}function JR(e){let t=qR(e),{PeerJobs:n}=t;return(0,J.jsxs)(Hw,{title:`Activity`,icon:(0,J.jsx)(go,{size:18}),onClose:e.onClose,footer:t.selecting?(0,J.jsx)(ER,{m:t,p:e}):null,head:(0,J.jsx)(kR,{m:t}),children:[(0,J.jsx)(BR,{m:t,online:e.online}),(0,J.jsxs)(`div`,{className:`sheet-scroll`,children:[(0,J.jsx)(zR,{m:t,p:e}),n&&!t.focus&&t.filter===`all`&&(0,J.jsx)(n,{sessions:e.sessions,onOpenSession:e.onOpenSession})]})]})}var YR=1e3;function XR(){let e=ma(R.activityDismissed,{});if(!e||typeof e!=`object`||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e))typeof r==`number`&&Number.isFinite(r)&&(t[n]=r);return t}function ZR(e){let t=Object.keys(e);if(t.length<=YR){Ta(R.activityDismissed,e);return}let n={};for(let r of t.sort((t,n)=>e[n]-e[t]).slice(0,YR))n[r]=e[r];Ta(R.activityDismissed,n)}function QR(){return new Map(Object.entries(XR()))}function $R(e,t=Date.now()){let n=XR();for(let r of e)n[r]??(n[r]=t);return ZR(n),new Map(Object.entries(n))}function ez(e){let t=XR();for(let n of e)delete t[n];return ZR(t),new Map(Object.entries(t))}var tz=1e3;function nz(){let e=ma(R.activityConfirmedDone,{});if(!e||typeof e!=`object`||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e))typeof r==`number`&&Number.isFinite(r)&&(t[n]=r);return t}function rz(e){let t=Object.keys(e);if(t.length<=tz){Ta(R.activityConfirmedDone,e);return}let n={};for(let r of t.sort((t,n)=>e[n]-e[t]).slice(0,tz))n[r]=e[r];Ta(R.activityConfirmedDone,n)}function iz(){return new Map(Object.entries(nz()))}function az(e,t=Date.now()){let n=nz();for(let r of e)n[r]??(n[r]=t);return rz(n),new Map(Object.entries(n))}var oz=W(QR()),sz=W(iz()),cz=W(null),lz=W([]);function uz(){return G(oz)}function dz(){return G(sz)}function fz(e,t){return e===`build`?`build:${t.cwd}`:e===`capture`?`capture:${t.cwd}`:e===`schedule`?`fanout`:`intent:${t.id}`}function pz(e,t){return t?`queued — it runs when the link is back`:e===`launch`?`opening it now, without the files it was waiting for`:e===`build`?`starting the build…`:e===`capture`?`taking the capture…`:`firing it into the session…`}function mz(e,t,n){let r=t-e;return`${e} ${e===1?`message`:`messages`} back as backlog items${n?` — added when the link is back`:``}${r?` · ${r} could not go`:``} · their rows are filed under “dismissed”`}var hz=(e,t)=>e.world.repoForCwd(t)?.repoName??vp(t);function gz(e){cz.set(e?`keys`in e?{keys:e.keys,label:e.label}:{keys:e.entries.map(e=>tj(e.ackId)),label:e.label}:null),U().nav.open(`activity`)}function _z(e,t){gz({entries:e,label:t})}function vz(){cz.set(null),U().nav.close(`activity`)}function yz(){return rO.subscribe(e=>lz.set(e))}function bz(e,t){let n=U();n.say.track(`action:activity.retarget`),e.subject.source===`queue`?n.queue.verbs.retargetQueued(e.id,t):e.subject.source===`intent`?n.conn.liveSend({t:`intent.retarget`,id:e.id,cwd:t.cwd,target:t.mode===`input`?{kind:`session`,sessionId:t.sessionId}:{kind:`repo`}},`aimed at ${hz(n,t.cwd)}`,Rj):n.say.toast(`that row cannot be re-aimed`)}function xz(e,t){let n=U(),{liveSend:r}=n.conn,{queueOp:i}=n.queue,{sessionId:a}=t;n.say.track(`action:activity.${e}`);let o=t.subject,s=()=>{let e=a?n.world.sessions.find(e=>e.id===a):null;e?n.nav.attach(e):n.say.toast(`that session is no longer open`)};if(e===`dismiss`)oz.set($R([t.key])),Cz([t]),n.say.toast(`filed away for later — it's under “dismissed”, nothing was deleted`);else if(e===`confirmDone`)sz.set(az([t.key])),n.say.toast(`marked done — the desktop's own check never confirmed it, this is your call`);else switch(o.source){case`queue`:{let t=o.entry,r=n.queue.verbs;if(e===`answer`){n.nav.open(`questions`),n.say.toast(`answer it here — the queued reply is bound to this question`);return}if(e===`sendNow`){r.sendQueuedNow(t.ackId);return}if(e===`hold`){r.toggleHoldQueued(t.ackId);return}if(e===`discard`){r.removeQueued(t.ackId),n.say.toast(`discarded`);return}if(e===`open`){s();return}n.nav.openSend({prompts:[t.op?.t===`session.create`&&t.op.prompt||t.text],target:n.send.targetFor(t.sessionId,t.cwd),cwdHint:t.cwd,repoId:n.queue.repoIdOf(t),ackId:t.ackId,repair:e===`fix`,origin:t.status===`failed`?`This one never went`:`Queued, not sent yet`,openAfter:!0});return}case`intent`:{let t=o.intent,a=Pt(t);if(e===`open`){s();return}if(e===`runNow`||e===`sendNow`){if(a===`fanout`){n.nav.open(`fanout`),n.say.toast(`follow up from the run below — it picks which of its sessions get it`);return}let e=i({t:`intent.run`,id:t.id},fz(a,t),t.label||t.title||`run it now`,{cwd:t.cwd});n.say.toast(pz(a,e)),!e&&a===`work`&&n.nav.followFire(t.id);return}if(e===`cancel`||e===`discard`){if(a===`build`&&(t.state===`running`||t.state===`starting`)){r({t:`build.cancel`,runId:t.id},`cancelling the build…`,`no connection — the build is running on the desktop and can't be stopped from here`);return}if(a===`capture`&&(t.state===`running`||t.state===`starting`)){r({t:`capture.cancel`,runId:t.id},`stopping the capture…`,`no connection — the capture is running on the desktop and can't be stopped from here`);return}if(a===`schedule`){let e=n.queue.verbs.scheduleQueueRows(t.id);r({t:`schedule.remove`,id:t.id},jj(e.length),`no connection — this one lives on the desktop and can only be deleted there`)&&n.queue.verbs.dropScheduleQueue(e);return}r({t:`intent.cancel`,id:t.id},a===`launch`?`called off — that session will not open`:`removed`,zj);return}if(e===`toggle`){if(a===`schedule`){r({t:`schedule.setEnabled`,id:t.id,enabled:t.nextAt==null},t.nextAt==null?`armed`:`switched off`,`no connection — this one is armed on the desktop and can only be changed there`);return}n.nav.open(`backlog`),n.say.toast(`this one is a per-item switch — it is on the row, in the backlog`);return}if(e===`check`){r({t:`backlog.check`,id:t.id},`checking whether this is already done…`,Rj);return}if(e===`download`){let e=t.result?.artifacts??[];if(!e.length){n.say.toast(`that run left no files`);return}let r=e.map(e=>({...e,repoDir:t.cwd,repoName:n.world.repoForCwd(t.cwd)?.repoName}));if(r.length===1){mO(r[0]);return}for(let e of r)mO(e,{silent:!0});n.say.toast(`downloading ${r.length} files — see Downloads`);return}if(a===`schedule`||Xt(t)){n.nav.openSend(n.send.seedFromIntent(t));return}n.nav.open(`backlog`),n.say.toast(`rewrite it on its row, in the backlog`);return}case`pull`:if(e===`save`){hO(o.record.item.id);return}if(e===`retry`){rO.retry(o.record.item.id),n.say.toast(`fetching it now`);return}if(o.record.local){rO.remove(o.record.item.id),n.say.toast(`removed from Downloads`);return}rO.remove(o.record.item.id),r({t:`pull.dismiss`,id:o.record.item.id},`dropped from Downloads`,`removed here — the desktop's own queue still lists it until the link is back`);return}}function Sz(e,t){if(t.subject.source!==`queue`)return`nothing`;let n=t.subject.entry,r=n.cwd?e.world.repoForCwd(n.cwd):null;if(!r)return`norepo`;let i=rj(n).trim();if(!i)return`nothing`;let a=e.queue.queueBacklog({text:i,repoDir:r.worktreePath,label:i.slice(0,40)});return a===null?`nothing`:(e.queue.drop(n.ackId),a?`queued`:`sent`)}function Cz(e){let t=U();if(t.conn.status===`open`)for(let n of e)n.source!==`queue`&&n.source!==`pull`&&t.conn.send({t:`intent.dismiss`,id:n.id})}function wz(e,t){let n=U();if(n.say.track(`action:activity.bulk.${e}`),!t.length){n.say.toast(`nothing selected`);return}let r=e=>hz(n,e);(async()=>{if(e===`restore`){oz.set(ez(t.map(e=>e.key))),n.say.toast(`${t.length} back in the list`);return}if(!await n.say.confirm({title:e===`dismiss`?`File ${t.length} away?`:`Send ${t.length} again?`,lines:zde(t,{verb:e,repoName:r}),confirmLabel:e===`dismiss`?`File them away`:`Send them again`})){n.say.toast(`left alone`);return}if(e===`dismiss`){oz.set($R(t.map(e=>e.key))),Cz(t),n.say.toast(`${t.length} filed away — nothing was deleted, they are under “dismissed”`);return}let i=0,a=!1,o=[];for(let e of t){let t=Sz(n,e);(t===`sent`||t===`queued`)&&(i++,o.push(e.key),t===`queued`&&(a=!0))}i?(oz.set($R(o)),Cz(t.filter(e=>o.includes(e.key))),n.say.toast(mz(i,t.length,a))):n.say.toast(`nothing left to send from those rows`)})()}function Tz(){let e=Dh(),{sessions:t,visibleRepos:n,intents:r,backlog:i}=e.world,a=Oh(),o=G(lz),s=G(oz),c=G(sz),l=G(cz),u=(0,V.useMemo)(()=>Object.fromEntries(i.map(e=>[e.id,e])),[i]);return(0,J.jsx)(JR,{outbox:a,queueBlocked:e.queue.blocked,goneLanes:e.queue.goneLanes(),intents:r,reviews:u,pulls:o,sessions:t,repos:n,online:e.conn.status===`open`,hostSeenAt:Yp().lastSeenAt,laneLabel:e.queue.laneLabel,repoName:t=>e.world.repoForCwd(t)?.repoName??vp(t),repoIdForCwd:t=>e.world.repoForCwd(t)?.id??null,onAction:xz,onRetarget:bz,dismissed:s,confirmedDone:c,onBulk:wz,focus:l,onOpenSession:n=>{let r=t.find(e=>e.id===n);r?e.nav.attach(r):e.say.toast(`that session is no longer open`)},onClose:vz})}var Ez={id:`activity`,sheets:[{id:`activity`,persisted:!0,render:()=>(0,V.createElement)(Tz)}],boot:()=>yz()},Dz=`pad.editor`;function Oz({repos:e,onDispatch:t,onFile:n,outbox:r,online:i,repoIdForCwd:a,focusId:o,onAttach:s,onAnnotate:c,onClose:l}){let[u,d]=(0,V.useState)(Zm),f=(0,V.useRef)(null);(0,V.useEffect)(()=>{let e=f.current;if(!o||!e)return;e.scrollIntoView({block:`center`}),e.classList.add(`nh-flash`);let t=window.setTimeout(()=>e.classList.remove(`nh-flash`),1400);return()=>window.clearTimeout(t)},[o]),(0,V.useEffect)(()=>Mm(()=>d(Zm()),[R.pad]),[]);let p=lh(Dz),[m,h]=(0,V.useState)(p?lh(`${Dz}.id`)||`new`:null),[g,_]=(0,V.useState)(null),[v,y]=(0,V.useState)(()=>p.split(`\f`)),b=(0,V.useRef)(v),x=(0,V.useRef)(0);function S(e){b.current=e,y(e),mh(Dz,e.join(`\f`))}let C=v[0]??``,[w,T]=(0,V.useState)(()=>lh(`${Dz}.cwd`)),E=e.find(e=>e.worktreePath===w)??null,D=(0,V.useRef)([]),[O,k]=(0,V.useState)(!1),[A,j]=(0,V.useState)(!1),[M,N]=(0,V.useState)([]);(0,V.useEffect)(()=>{if(m===null)return;let e=v.join(`\f`);mh(Dz,e),mh(`${Dz}.id`,e.trim()?m:``),mh(`${Dz}.cwd`,e.trim()?w:``)},[m,v,w]);function P(){mh(Dz,``),mh(`${Dz}.id`,``),mh(`${Dz}.cwd`,``),h(null),_(null),S([``]),T(``),N([]),k(!1),D.current=[]}function F(e,t=E){if(!e.length)return;if(!t){D.current=e,k(!0);return}T(t.worktreePath),mh(`${Dz}.cwd`,t.worktreePath);let n=e.filter(eg),r=e.filter(e=>!eg(e));r.length&&ee(r,t),n.length&&c(n,t)}async function ee(e,t){j(!0);try{let n=await s(e,t);if(!n.length)return;N(e=>[...e,...n]);let r=b.current.length?b.current.slice():[``],i=r[0]??``;r[0]=i?`${i}${/\s$/.test(i)?``:` `}${n.join(` `)}`:n.join(` `),S(r)}finally{j(!1)}}function te(){q(`action:pad.new`),h(`new`),_(null),S([``]),T(``),N([])}function ne(e){h(e.id),_(null),S([e.text,...e.steps??[]]),T(e.cwd??``),N([])}function re(){let e=m,t=b.current.map(e=>e.trim()).filter(Boolean),n=w;if(!e){P();return}if(!t.length){e!==`new`&&eh([e]),P(),d(Zm());return}q(`action:pad.save`);let[r,...i]=t,a=e===`new`,o=a?void 0:Zm().find(t=>t.id===e),s={id:a?`p_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,6)}`:e,text:r,ts:Date.now()};i.length&&(s.steps=i);let c=n||o?.cwd;c&&(s.cwd=c);let l=a?Qm(s):$m(s);l?_(l):(P(),d(Zm()))}function ie(e){q(`action:pad.remove`),eh([e]),d(Zm())}return m===null?(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)($o,{size:16}),` Prompt pad`]}),onClose:l,children:(0,J.jsxs)(Y,{onClick:te,children:[(0,J.jsx)(Fo,{size:16}),` new`]})}),(0,J.jsx)(DO,{keys:[R.pad],thing:`your notes`}),(0,J.jsx)(Z,{children:Et}),(0,J.jsxs)(`div`,{className:`list`,children:[u.length===0&&(0,J.jsx)($,{children:`Nothing on the pad. Tap “new” to park a thought.`}),u.map(s=>{let c=s.cwd?e.find(e=>e.worktreePath===s.cwd):void 0;return(0,J.jsxs)(`div`,{className:`pad-item`,ref:s.id===o?f:void 0,children:[(0,J.jsxs)(`div`,{className:`queue-row`,children:[(0,J.jsxs)(`button`,{className:`queue-text`,onClick:()=>ne(s),title:`tap to edit`,children:[(0,J.jsx)(`span`,{className:`queue-text-body`,children:s.text}),(0,J.jsxs)(`span`,{className:`queue-meta`,children:[(s.steps?.length??0)>0&&(0,J.jsxs)(J.Fragment,{children:[`+`,s.steps.length,` step`,s.steps.length>1?`s`:``,` · `]}),c?(0,J.jsxs)(J.Fragment,{children:[c.isPrimary?c.repoName:`${c.repoName} · ${c.branch}`,` · `]}):null,new Date(s.ts).toLocaleString([],{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})]})]}),(0,J.jsxs)(`div`,{className:`queue-row-acts`,children:[c&&(0,J.jsxs)(Y,{title:oe.title(c.repoName),onClick:()=>{q(`action:pad.file`),n(s,c)},children:[(0,J.jsx)(Es,{size:16}),` `,oe.label]}),(0,J.jsxs)(Y,{title:`send it — pick where and when in one sheet`,onClick:()=>{q(`action:pad.dispatch`),t(s)},children:[(0,J.jsx)(Uc,{size:16}),` send…`]}),(0,J.jsx)(fC,{className:`key danger`,title:`discard`,confirmTitle:`tap again and this note is gone`,confirm:`discard?`,onConfirm:()=>ie(s.id),children:(0,J.jsx)(ws,{size:16})})]})]}),(0,J.jsx)(lR,{compact:!0,text:s.text,repoId:s.cwd?a(s.cwd):null,outbox:r,online:i})]},s.id)})]}),(0,J.jsxs)(`div`,{className:`sheet-actions`,children:[(0,J.jsxs)(Y,{onClick:l,children:[(0,J.jsx)(Ns,{size:16}),` back`]}),(0,J.jsx)(`span`,{className:`spacer`}),(0,J.jsxs)(X,{as:`span`,style:{padding:0},children:[u.length,` note`,u.length===1?``:`s`]})]})]}):(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)($o,{size:16}),` `,m===`new`?`New note`:`Edit note`]}),onClose:P}),(0,J.jsxs)(Z,{children:[`Just the text. You pick where it goes when you get there.`,E&&(0,J.jsxs)(J.Fragment,{children:[` Files go to `,(0,J.jsx)(`strong`,{children:E.repoName}),`'s inbox — that much the note has decided.`]})]}),g&&(0,J.jsx)(Z,{tone:`warn`,children:g}),(0,J.jsxs)(yE,{prompts:v,onChange:S,placeholder:`What should someone do about this?`,chain:!0,stepHint:`then, once that step's turn finishes:`,trackAdd:`action:pad.addprompt`,focusRef:x,autoFocus:!0,children:[M.length>0&&(0,J.jsxs)(Z,{children:[(0,J.jsx)(As,{size:12}),` `,M.length,` file`,M.length>1?`s`:``,` queued for `,E?.repoName??`that repo`,`'s inbox — the paths are in the note above.`]}),(0,J.jsx)(lR,{compact:!0,debounceMs:700,text:C,repoId:E?.id??null,outbox:r,online:i,onRemove:e=>S(b.current.map(t=>dL(t,e)))})]}),O&&(0,J.jsxs)(`div`,{className:`queue-aim attach-aim`,children:[(0,J.jsx)(Z,{children:`Whose inbox do these files go to?`}),(0,J.jsx)(aF,{repos:e,listClass:``,onPick:e=>{let t=D.current;D.current=[],k(!1),F(t,e)}})]}),(0,J.jsxs)(`div`,{className:`sheet-actions`,children:[(0,J.jsxs)(Y,{onClick:P,children:[(0,J.jsx)(B,{size:16}),` cancel`]}),(0,J.jsx)(bE,{prompts:b,onPrompts:S,focusRef:x,busy:A,onFiles:e=>F(e),unavailable:e.length?void 0:`no repos under the host root to upload into`,trackImage:`action:pad.attach`,trackFile:`action:pad.attachfile`}),(0,J.jsx)(`span`,{className:`spacer`}),(0,J.jsx)(`button`,{className:`send`,onClick:re,children:`Save`})]})]})}var kz=W(null);function Az(e){kz.set(e),U().nav.open(`pad`)}function jz(){kz.set(null),U().nav.close(`pad`)}function Mz(e){let t=U();t.say.track(`action:pad.dispatch`),t.nav.openSend({prompts:[e.text,...e.steps??[]],target:t.send.targetFor(void 0,e.cwd),cwdHint:e.cwd??null,repoId:e.cwd?t.world.repoForCwd(e.cwd)?.id??null:null,padId:e.id,repair:uL(e.text).length>0,origin:`From the pad`})}function Nz(e,t){if(!e.cwd)return;let n=U(),r=n.queue.queueBacklog({text:e.text,repoDir:e.cwd,steps:e.steps?.length?[e.text,...e.steps]:void 0});r!==null&&(n.compose.removePadNotes([e.id]),n.say.toast(ft(t.repoName,r)))}function Pz(){let e=Dh(),t=Oh(),n=G(kz);return(0,J.jsx)(Oz,{repos:e.world.visibleRepos,outbox:t,online:e.conn.status===`open`,focusId:n,repoIdForCwd:t=>e.world.repoForCwd(t)?.id??null,onClose:jz,onAttach:(t,n)=>e.files.attachForInbox(n,t),onAnnotate:(t,n)=>e.files.annotate(n,t,`pad`),onDispatch:Mz,onFile:Nz})}var Fz={id:`pad`,sheets:[{id:`pad`,persisted:!1,render:()=>(0,V.createElement)(Pz)}]},Iz=W(null),Lz=W(0);function Rz(){return G(Lz)}var zz=W(null),Bz=W(null),Vz=W(null),Hz=W(null),Uz=W(null),Wz=W(null),Gz=W(new Map(Object.entries(ma(R.newImages,{})))),Kz=W(new Set),qz={ret:`session`,pickRepo:null,sendRepo:null,padRepo:null,backlogEdit:null};function Jz(e){return G(Gz).get(e)??Yz}var Yz=[];function Xz(e){return G(Kz).has(e)}function Zz(e,t){return{repoId:e.repoId,scope:`outbox`,allTime:!0,returnTo:t,openFile:{...e,name:e.name||e.relPath.split(`/`).pop()||e.relPath}}}var Qz=/\.(mp4|webm|mov|m4v|ogv|mkv)$/i,$z=/\.(png|jpe?g|gif|webp|bmp|avif|heic|svg)$/i;function eB(e){return Qz.test(e)}function tB(e){return/\.(md|markdown|mdx)$/i.test(e)}function nB(e){return Qz.test(e)||$z.test(e)}function rB(e){return e.filter(e=>nB(e.relPath))}function iB(e){let t=e.filter(e=>tB(e.relPath)),n=t.filter(e=>e.changed).length,r=e.length-t.length,i=[];return r&&i.push(`${r} new image${r>1?`s`:``}`),t.length-n&&i.push(`${t.length-n} new markdown`),n&&i.push(`${n} markdown edited`),i.join(` · `)}function aB(e,t,n){let r=n=>rB(e.get(n)??[]).findIndex(e=>e.repoId===t.repoId&&e.relPath===t.relPath);if(n&&r(n)>=0)return{sessionId:n,i:r(n)};for(let t of e.keys()){let e=r(t);if(e>=0)return{sessionId:t,i:e}}return null}function oB(e,t,n,r){let i=new Map(e),a=[...i.get(t)??[]];for(let e of r){let t=a.findIndex(t=>t.relPath===e.relPath);if(t<0){a.push({...e,repoId:n});continue}if(!tB(e.relPath)||e.mtime<=a[t].mtime)continue;let[r]=a.splice(t,1),{changed:i,...o}=e;a.push(r.changed?{...e,repoId:n}:{...o,repoId:n})}return i.set(t,a),i}function sB(e,t){if(!e.has(t))return e;let n=new Map(e);return n.delete(t),n}function cB(e){let t={};for(let[n,r]of e)r.length&&(t[n]=r.slice(-60));return t}function lB(e,t,n){let r=t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`),i=RegExp(`${r}(?:\\s*\\(marked:(?:[^()]|\\([^()]*\\))*\\))?`);return i.test(e)?e.replace(i,n):`${e} ${n}`}function uB(e){let t=e.trim(),n=Math.max(2,...[...t.matchAll(/`+/g)].map(e=>e[0].length)),r="`".repeat(n+1);return`Text read off a photo (on-device OCR, the photo itself not sent — glyphs may be misread):\n${r}\n${t}\n${r}\n`}function dB(e,t){return t?`${e} (marked: ${t})`:e}function fB(e,t){return e===`backlog-item`?`backlog`:e===`send`?t?`send`:null:e===`pad`?`pad`:null}function pB(e,t,n,r,i){return e===`session`?n??t:e===`send`?`create:${r??t}`:e===`pad`?`create:${i??t}`:t}function mB(e){return e?.outboxSeenAt!=null&&e.outboxCount>0?{since:e.outboxSeenAt,count:e.outboxCount}:void 0}function hB(e,t){let n=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]);return e.length>0&&e.every(e=>t.some(t=>n(e,t)))}function gB(e){return e.handled||!e.files||!e.repoId||e.editable&&!e.inCompose?`ignore`:e.annotating?`ask`:e.sheet&&!e.inCompose?`ignore`:`route`}function _B(e){let t=U().nav;e?t.open(e):t.overlay&&t.close(t.overlay)}function vB(e){U().compose.insert(e),Xf(e),U().say.toast(`path copied: ${e}`)}function yB(e,t){let n=H.artifactUrl(e,t),r=eB(t);sI(e,t);let i=rI(e,t);return{name:t.split(`/`).pop()||t,relPath:t,url:r?n:$h(n,Qh(),i),fullUrl:n,video:r,repoId:e}}var bB=!1;function xB(e,t){if(!bB){if(bB=!0,e.image){let t=aB(Gz.get(),e.image);Bz.set(t??{items:[yB(e.image.repoId,e.image.relPath)],repoId:e.image.repoId,i:0})}e.file&&t&&Vz.set(Zz(e.file))}}function SB(e){let t=Bz.get()?.revoke;Bz.set(e);let n=Bz.get()?.revoke;t&&t!==n&&URL.revokeObjectURL(t)}function CB(e,t){let n=aB(Gz.get(),e,t);Iz.set(null),SB(n??{items:[yB(e.repoId,e.relPath)],repoId:e.repoId,i:0}),U().nav.open(`swipe`)}function wB(e){U().say.track(`action:newimg.open`),SB({sessionId:e,i:0}),U().nav.open(`swipe`)}function TB(e,t){U().say.track(`action:newimg.open`);let n=rB(Gz.get().get(e)??[]);SB({sessionId:e,i:Math.max(0,n.findIndex(e=>e.relPath===t.relPath))}),U().nav.open(`swipe`)}function EB(e,t,n){U().say.track(`action:read.fileref`),nB(t)?(SB({items:[yB(e,t)],repoId:e,i:0,back:n}),U().nav.open(`swipe`)):(Vz.set(Zz({repoId:e,relPath:t},n)),U().nav.open(`gallery`))}function DB(e){let t=U().nav.overlay;e.state===`host`&&e.repoId?EB(e.repoId,e.relPath,t):PL(e.relPath,e.state,[...U().queue.entries]).then(n=>{n?(U().say.track(`action:attach.openlocal`),SB({items:[{name:e.relPath.split(`/`).pop()||e.relPath,relPath:e.relPath,url:n,repoId:e.repoId??void 0}],repoId:e.repoId??void 0,i:0,back:t,revoke:n}),U().nav.open(`swipe`)):U().say.toast(`no copy of this file on this phone`)})}function OB(){_B(Bz.get()?.back??null),SB(null)}function kB(e,t,n){Gz.set(r=>oB(r,e,t,n)),NB(e),U().say.toast(iB(n))}function AB(e){U().say.track(`action:newimg.ref`),vB(e.relPath)}function jB(e){Gz.set(t=>sB(t,e)),NB(e)}function MB(e){Kz.set(t=>t.has(e)?t:new Set(t).add(e))}function NB(e){Kz.set(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})}function PB(e,t,n,r){Vz.set({repoId:e,scope:t,allTime:n,newCut:r}),U().nav.open(`gallery`)}function FB(e){PB(e,`outbox`,!0,mB(U().world.repos.find(t=>t.id===e)))}function IB(e){Vz.set({repoId:e.id,scope:`outbox`,allTime:!0,returnTo:`send`,insertInto:`send`}),U().nav.open(`gallery`)}function LB(e,t){t===void 0&&U().say.track(`notif:open-file`);let n=t??(U().nav.overlay===`notifications`?`notifications`:void 0);Vz.set(Zz(e,n)),U().nav.open(`gallery`)}function RB(e){mO(e)}function zB(){let e=Vz.get()?.returnTo??null;Vz.set(null),_B(e),U().world.refreshRepos()}function BB(e){Vz.get()?.insertInto===`send`?(U().compose.appendSheetDraft(CA,e),U().say.toast(`added to the prompt`)):vB(e)}function VB(e){let t=U(),n=t.world.repos.find(t=>t.id===e);if(!n)return[];let r=t.world.active?.id;return t.world.sessions.filter(e=>e.cwd===n.worktreePath&&e.running).sort((e,t)=>Number(t.id===r)-Number(e.id===r)).map(e=>({id:e.id,label:l_(e,n.repoName),onScreen:e.id===r}))}function HB(e,t,n){let r=U(),i=r.world.repos.find(e=>e.id===t);if(!i){r.say.toast(`unknown repo`);return}let a=n?r.world.sessions.find(e=>e.id===n&&e.running):void 0;if(n&&!a)r.say.toast(`that session has ended — pick another, or start a new one`);else if(Vz.set(null),_B(null),Xf(e),a)r.nav.attach(a),r.compose.seedDraft(a.id,e),r.say.toast(`opened session · ${e}`);else{let t=r.launch.openCwd(i.worktreePath,Qn(i));t?r.compose.seedDraft(t,e):r.compose.insert(e),r.say.toast(`new session · ${e}`)}}function UB(e,t){let n=U(),r=n.world.repos.find(t=>t.id===e);if(!r)return n.say.toast(`unknown repo — the remarks are kept on the file`),!1;Uz.set(null),Wz.set(null),_B(null),Xf(t);let i=[n.world.active,...n.world.sessions].find(e=>e&&e.cwd===r.worktreePath&&e.running);if(i)return i.id!==n.world.active?.id&&n.nav.attach(i),n.compose.seedDraft(i.id,t),n.say.toast(`remarks are in the prompt — read them over, then send`),!0;let a=n.launch.openCwd(r.worktreePath,Qn(r),!0);return a?n.compose.seedDraft(a,t):n.compose.insert(t),n.say.toast(`new session · remarks are in the prompt`),!0}function WB(e,t,n){U().say.track(`overlay:sweep`),Hz.set({repoId:e,scope:t,back:n}),U().nav.open(`sweep`)}function GB(e){let t=Vz.get()?.repoId??U().world.activeRepo?.id;t&&WB(t,e,`gallery`)}function KB(e){Hz.set(t=>t&&{...t,scope:e})}function qB(){let e=Hz.get()?.back??null;Hz.set(null),_B(e)}function JB(){U().world.refreshRepos()}function YB(e,t=null){Uz.set(e),t&&Wz.set({file:``,back:t}),U().nav.open(`browse`)}function XB(e,t,n){Uz.set(e),Wz.set({file:t,back:n}),U().nav.open(`browse`)}function ZB(){U().nav.open(`gallery`)}function QB(e){return t=>{let n=t.world.activeRepo?.id;n?e(n):t.say.toast(`not a known repo`)}}function $B(){Uz.set(null),U().nav.open(`browse`)}function eV(){let e=Wz.get()?.back??null;Uz.set(null),Wz.set(null),_B(e)}var tV=null,nV=null;function rV(e){qz.ret=`session`,qz.pickRepo=e,tV?.click()}function iV(e){qz.ret=`session`,qz.pickRepo=e,nV?.click()}function aV(e){let t=Array.from(e.files??[]);e.value=``;let n=qz.pickRepo;return qz.pickRepo=null,t.length&&n?{files:t,repoId:n}:null}function oV(e){let t=aV(e);t&&(U().say.track(`action:attach.file`),sV(t.files,t.repoId))}function sV(e,t,n){if(qz.ret=`session`,n?.annotate===!1){_V(e,t);return}let r=e.filter(eg),i=e.filter(e=>!eg(e));i.length&&_V(i,t),r.length&&(r.length===1?uV({source:r[0],repoId:t}):fV(r,t,e=>{qz.ret===`session`?dV(e,t):_V(e,t)}))}function cV(e){let t=aV(e);if(!t)return;let{files:n,repoId:r}=t;n.length===1?uV({source:n[0],repoId:r}):fV(n,r,e=>{qz.ret===`session`?dV(e,r):_V(e,r)})}function lV(){let e=(e,t)=>{let n=document.createElement(`input`);return n.type=`file`,n.multiple=!0,n.hidden=!0,e&&(n.accept=e),n.addEventListener(`change`,()=>t(n)),document.body.appendChild(n),n};return tV=e(`image/*`,cV),nV=e(null,oV),()=>{tV?.remove(),nV?.remove(),tV=nV=null}}function uV(e){Iz.set(e),U().nav.open(`image`)}function dV(e,t){Iz.set({source:e[0],repoId:t,rest:e.slice(1),total:e.length,index:1}),U().nav.open(`image`)}function fV(e,t,n){zz.set({files:e,repoId:t,separate:n}),U().nav.open(`collage`)}function pV(){let e=Iz.get();if(e?.rest&&e.rest.length){let[t,...n]=e.rest;Iz.set({source:t,repoId:e.repoId,rest:n,total:e.total,index:(e.index??1)+1})}else _B(null),Iz.set(null)}function mV(e,t){let n=zz.get();n&&(zz.set(null),uV({source:e,repoId:n.repoId,facts:t}))}function hV(e){let t=zz.get();t&&(zz.set(null),t.separate(e))}function gV(){let e=fB(qz.ret,U().nav.sendSeeded());qz.ret=`session`,zz.set(null),_B(e)}async function _V(e,t){qz.ret=`session`;let n=U(),r=[],i=n.world.repos.find(e=>e.id===t)?.worktreePath??t,a=n.world.active?.id??i,o=``;for(let s of e)try{let{width:e}=hA(),c=await _A(s,s.name,e),l=await n.queue.queueImageUpload(t,c.blob,c.name,a,i);l?r.push(l.relPath):o||=`this browser can't hold files offline — reconnect and re-attach`}catch{o||=`couldn't read that file`}let s=U().say;r.length?(r.forEach(e=>U().compose.insert(e)),await Xf(r.join(` `)),_B(null),Iz.set(null),s.toast(U().conn.status===`open`?`Sent ${r.length} · paths copied`:`${r.length} queued · they upload when the link is back`)):s.toast(o||`Upload failed`)}function vV(){let e=Lz.get();return e?(Lz.set(0),Date.now()-e<yV&&U().nav.overlay==null):!1}var yV=3e3;async function bV(e,t){let n=Iz.get();if(!n)return null;let r=U(),i=r.world.repos.find(e=>e.id===n.repoId)?.worktreePath??n.repoId,a=pB(qz.ret,i,r.world.active?.id??null,qz.sendRepo?.worktreePath,qz.padRepo?.worktreePath);return(await r.queue.queueImageUpload(n.repoId,e,t,a,i))?.relPath??null}function xV(e,t){let n=Iz.get();if(!n)return;let r=U().queue.uploads,i=r.ensureUploadBuf(n.repoId);t===`run`&&(i.submit=!0),t===`queue`&&(i.queue=!0),r.queueUpload(i,e.blob,e.name,e.note,e.size),n.rest&&n.rest.length?(pV(),U().say.toast(`Sent ${n.index}/${n.total} · next…`)):(i.closed=!0,Iz.set(null),_B(null),r.settleUploads(i))}function SV(){let e=Iz.get();if(e?.rest&&e.rest.length){pV(),U().say.toast(`Skipped ${e.index}/${e.total}`);return}let t=U().queue.uploads,n=t.current();n&&(n.closed=!0,t.settleUploads(n));let r=fB(qz.ret,U().nav.sendSeeded());qz.ret=`session`,Iz.set(null),_B(r)}function CV(e,t){let n=Iz.get();if(!n)return;let{repoId:r,rest:i=[]}=n,a=U().queue.uploads,o=a.ensureUploadBuf(r);t===`run`&&(o.submit=!0),t===`queue`&&(o.queue=!0),a.queueUpload(o,e.blob,e.name,e.note,e.size);for(let e of i){let t=e instanceof File?e:fetch(e.url).then(e=>e.blob());a.queueUpload(o,t,e.name)}o.closed=!0,Iz.set(null),_B(null),a.settleUploads(o)}function wV(){let e=fB(qz.ret,U().nav.sendSeeded()),t=U().queue.uploads,n=t.current();qz.ret===`session`&&n&&(n.closed=!0,t.settleUploads(n)),qz.ret=`session`,qz.backlogEdit=null,Iz.set(null),_B(e)}async function TV(e,t){let n=dB(e,t),r=U().say;if(qz.ret===`backlog-item`&&qz.backlogEdit){let{id:t,oldPath:i,text:a}=qz.backlogEdit;qz.backlogEdit=null,qz.ret=`session`;let o=lB(a,i,n);Iz.set(null),U().nav.open(`backlog`),o===a?r.toast(`updated image: ${e}`):U().conn.liveSend({t:`backlog.update`,id:t,text:o},`updated image: ${e}`,`no connection — the marked image will still upload (${e}), but the backlog row lives on the desktop and still names the old one`);return}if(qz.ret===`send`){FV(n);return}if(qz.ret===`pad`){IV(n);return}U().world.active&&U().compose.insert(n),await Xf(n);let i=Iz.get();i?.rest&&i.rest.length?(pV(),r.toast(`Sent ${i.index}/${i.total} · next…`)):(_B(null),Iz.set(null),r.toast(`Sent · path copied: ${e}`))}function EV(e){let t=uB(e),n=U();if(qz.ret===`backlog-item`&&qz.backlogEdit){let{id:e,oldPath:r,text:i}=qz.backlogEdit;qz.backlogEdit=null,qz.ret=`session`,Iz.set(null),n.nav.open(`backlog`),n.conn.liveSend({t:`backlog.update`,id:e,text:lB(i,r,t)},`the image is now its text`,`no connection — the backlog row lives on the desktop and still names the image`);return}qz.ret===`send`?n.compose.appendSheetDraft(CA,t):qz.ret===`pad`?(n.compose.appendSheetDraft(`pad.editor`,t),n.compose.loadSheetDraft(`pad.editor.id`)||n.compose.seedSheetDraft(`pad.editor.id`,`new`)):n.world.active?n.compose.insert(t):Xf(t);let r=Iz.get();r?.rest&&r.rest.length?(pV(),n.say.toast(`Text added ${r.index}/${r.total} · next…`)):(n.say.toast(qz.ret===`session`&&!n.world.active?`text copied — no session open to put it in`:`text added — the photo was not sent`),wV())}function DV(e,t,n){uV({source:{url:e,name:t},repoId:n})}function OV(e,t,n){qz.ret=`session`,DV(e,t,n)}function kV(e){OV(H.artifactUrl(e.repoId,e.relPath),e.name,e.repoId)}function AV(){return U().nav.overlay===`image`&&Iz.get()!=null}async function jV(e){let t=Iz.get();if(!t||!e.length)return!1;let n=[t.source,...t.rest??[]].filter(e=>e instanceof File),r=new Set(n.map(e=>e.size));if(!e.every(e=>r.has(e.size)))return!1;let i=e=>e.arrayBuffer().then(e=>new Uint8Array(e));try{let[t,r]=await Promise.all([Promise.all(e.map(i)),Promise.all(n.filter(t=>e.some(e=>e.size===t.size)).map(i))]);return hB(t,r)}catch{return!1}}function MV(e){let t=Iz.get();if(!t)return;let n=e.filter(eg);e.length>n.length&&_V(e.filter(e=>!eg(e)),t.repoId),n.length&&Iz.set({...t,rest:[...t.rest??[],...n],total:(t.total??1)+n.length,index:t.index??1})}async function NV(e,t,n=`create:${e.worktreePath}`){let r=[];for(let i of t){let t=i,a=i.name;try{let{width:e}=hA(),n=await _A(i,i.name,e);t=n.blob,a=n.name}catch{}let o=await U().queue.queueImageUpload(e.id,t,a,n,e.worktreePath);o?r.push(o.relPath):U().say.toast(`this browser can't hold files offline — reconnect and attach again`)}return r}function PV(e,t,n){t.length&&(qz.ret=n,n===`send`?qz.sendRepo=e:qz.padRepo=e,t.length===1?uV({source:t[0],repoId:e.id}):fV(t,e.id,t=>dV(t,e.id)))}function FV(e){let t=U();t.compose.appendSheetDraft(CA,e);let n=Iz.get();if(n?.rest&&n.rest.length){pV(),t.say.toast(`Attached ${n.index}/${n.total} · next…`);return}qz.ret=`session`,Iz.set(null);let r=t.nav.sendSeeded();_B(r?`send`:null),Xf(e),t.say.toast(r?`attached · the path is in the prompt`:`path copied: ${e}`)}function IV(e){let t=U();t.compose.appendSheetDraft(`pad.editor`,e),t.compose.loadSheetDraft(`pad.editor.id`)||t.compose.seedSheetDraft(`pad.editor.id`,`new`);let n=Iz.get();n?.rest&&n.rest.length?(pV(),t.say.toast(`Attached ${n.index}/${n.total} · next…`)):(qz.ret=`session`,Iz.set(null),t.nav.open(`pad`),Xf(e),t.say.toast(`attached · the path is in the note`))}function LV(e,t){let n=U().world.repos.find(t=>t.worktreePath===e.repoDir)?.id;n?(qz.ret=`backlog-item`,qz.backlogEdit={id:n,oldPath:t,text:e.text},DV(H.artifactUrl(n,t),t.split(`/`).pop()||`image`,n)):U().say.toast(`unknown repo`)}function RV(e,t){let n=t.find(t=>t.relPath===e.relPath),r=Bz.get()?.back??null;SB(null),n?kV(n):e.repoId?OV(e.fullUrl??e.url,e.name,e.repoId):_B(r)}function zV(e,t){let n=t.find(t=>t.relPath===e.relPath);n?AB(n):vB(e.relPath),OB()}function BV(){let e=lV(),t=e=>{let t=e.detail;t&&DB(t)};window.addEventListener(FL,t);let n=Gz.subscribe(()=>Ta(R.newImages,cB(Gz.get()))),r=!1,i=Iz.subscribe(()=>{Iz.get()==null?(r&&Lz.set(Date.now()),r=!1):r=qz.ret===`session`});return()=>{e(),n(),i(),window.removeEventListener(FL,t);let r=Bz.get()?.revoke;r&&URL.revokeObjectURL(r)}}var VV=`#0d1013`,HV=`#000000`,UV=`#ffffff`,WV=`rgba(0,0,0,0.75)`;async function GV(e){let t=[],n=[];for(let r of e){let e=await vA(xA(r),null),i=e?e.width:0,a=e?e.height:0;e&&i>0&&a>0?t.push({name:r.name,file:r,img:e,w:i,h:a}):n.push(r.name)}return{items:t,failed:n}}function KV(e){for(let t of e)typeof ImageBitmap<`u`&&t.img instanceof ImageBitmap&&t.img.close()}var qV=e=>e.map(e=>({w:e.w,h:e.h}));function JV(e,t){if(t===`none`)return 0;let n=see(qV(e));return t===`wide`?n*3:n}function YV(e,t){return mn(qV(e),JV(e,t))}function XV(e){return Array.from({length:e},(e,t)=>t+1)}function ZV(e,t={}){return ke(qV(e),{cols:t.cols,gap:JV(e,t.gap??`thin`),...t.maxWidth?{maxWidth:t.maxWidth}:{}})}var QV=[2600,1800,1200,800];async function $V(e,t={}){if(!e.length)return null;let n=t.maxSide?[t.maxSide,...QV.filter(e=>e<t.maxSide)]:[void 0,...QV];for(let r=0;r<n.length;r++){let i=n[r],a=ke(qV(e),{cols:t.cols,gap:JV(e,t.gap??`thin`),...t.maxWidth?{maxWidth:t.maxWidth}:{},...i?{maxSide:i,maxPixels:i*i}:{}}),o=await eH(e,a,t.labels!==!1&&e.length>1);if(o)return{blob:o,layout:a,label:na(e.length,a.cols),reduced:r>0}}return null}async function eH(e,t,n){let r=document.createElement(`canvas`);try{if(r.width=t.width,r.height=t.height,r.width!==t.width||r.height!==t.height)return null;let i=r.getContext(`2d`);if(!i)return null;i.fillStyle=VV,i.fillRect(0,0,r.width,r.height),i.imageSmoothingQuality=`high`;for(let r of t.cells){let t=e[r.i];if(t){try{i.drawImage(t.img,r.x,r.y,r.w,r.h)}catch{}n&&tH(i,r.x,r.y,r.w,r.h,r.i+1)}}return await yA(r,`image/jpeg`,.9)}catch{return null}finally{r.width=0,r.height=0}}function tH(e,t,n,r,i,a){let o=Math.max(22,Math.round(Math.min(r,i)*.095)),s=Math.round(o*.5),c=String(a);e.font=`800 ${o}px system-ui, -apple-system, sans-serif`,e.textBaseline=`middle`,e.textAlign=`center`;let l=o+s,u=Math.max(l,e.measureText(c).width+s*2),d=Math.max(2,Math.round(o*.11)),f=t+Math.round(o*.35)+d,p=n+Math.round(o*.35)+d;nH(e,f,p,u,l,Math.round(o*.32)),e.fillStyle=HV,e.fill(),e.lineJoin=`round`,e.lineWidth=d*2.4,e.strokeStyle=WV,e.stroke(),e.lineWidth=d,e.strokeStyle=UV,e.stroke(),e.fillStyle=`#ffffff`,e.fillText(c,f+u/2,p+l/2)}function nH(e,t,n,r,i,a){e.beginPath(),e.moveTo(t+a,n),e.arcTo(t+r,n,t+r,n+i,a),e.arcTo(t+r,n+i,t,n+i,a),e.arcTo(t,n+i,t,n,a),e.arcTo(t,n,t+r,n,a),e.closePath()}function rH(e){return`combined-${e}-screens.jpg`}var iH=R.collageGap,aH=R.collageLabels,oH=1200,sH=()=>{let e=z(iH);return e===`none`||e===`wide`?e:`thin`},cH=()=>z(aH)!==`0`;function lH({files:e,onCombine:t,onSeparate:n,onClose:r}){let[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)([]),[c,l]=(0,V.useState)(null),[u,d]=(0,V.useState)(sH),[f,p]=(0,V.useState)(cH),[m,h]=(0,V.useState)(null),[g,_]=(0,V.useState)(!0),[v,y]=(0,V.useState)(!1),[x,S]=(0,V.useState)(null),[C,w]=(0,V.useState)(!1),T=(0,V.useRef)(null),E=(0,V.useRef)(new Map),D=hA();(0,V.useEffect)(()=>{let t=!0,n=[];return GV(e).then(({items:r,failed:i})=>{n=r,t?(a(r),s(e.filter(e=>i.includes(e.name))),r.length<2&&S(r.length?`Only one of these could be read as an image on this device.`:`None of these could be read as an image on this device.`)):KV(r)}),()=>{t=!1,KV(n),T.current&&URL.revokeObjectURL(T.current);for(let e of E.current.values())URL.revokeObjectURL(e);E.current.clear()}},[]),(0,V.useEffect)(()=>{if(!i||i.length<2){_(!1);return}let e=!0;return _(!0),$V(i,{cols:c??void 0,gap:u,labels:f,maxSide:oH}).then(t=>{e&&(_(!1),t?(S(null),T.current&&URL.revokeObjectURL(T.current),T.current=URL.createObjectURL(t.blob),h({url:T.current,bytes:t.blob.size})):S(`This device couldn't draw the combined image.`))}),()=>{e=!1}},[i,c,u,f]);let O=i?.length??e.length,k=i&&i.length>1?YV(i,u):1,A=c??k,j=i&&i.length>1?ZV(i,{cols:A,gap:u,...D.width?{maxWidth:D.width}:{}}):null;function M(e){let t=E.current.get(e);return t||(t=URL.createObjectURL(e.file),E.current.set(e,t)),t}function N(e,t){a(n=>{if(!n)return n;let r=e+t;if(r<0||r>=n.length)return n;let i=n.slice();return[i[e],i[r]]=[i[r],i[e]],i}),q(`action:collage.reorder`)}function P(e){q(`action:collage.layout`),l(e)}function F(e){d(e),ua(iH,e)}function ee(){let e=!f;p(e),ua(aH,e?`1`:`0`)}async function te(){if(!i||i.length<2)return;q(`action:collage.combine`),y(!0),S(null);let e=await $V(i,{cols:c??void 0,gap:u,labels:f,...D.width?{maxWidth:D.width}:{}});e?(w(e.reduced),t(new File([e.blob],rH(i.length),{type:`image/jpeg`}),b(i.length,e.layout.cols,f))):(y(!1),S(`This device couldn't draw the combined image at any size — send them separately instead.`))}return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:(0,J.jsxs)(J.Fragment,{children:[O,` images`]}),onClose:r,children:(0,J.jsx)(`span`,{className:`upscale-note`,children:j?`${j.width} × ${j.height}`:``})}),(0,J.jsx)(Z,{children:`Put them on one canvas so a circle or an arrow can span them — that is the only way to point at something that crosses screens. Or keep them apart and mark each in turn.`}),i&&i.length>1&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`collage-strip`,children:i.map((e,t)=>(0,J.jsxs)(`div`,{className:`collage-chip`,children:[(0,J.jsx)(`img`,{src:M(e),alt:e.name}),(0,J.jsx)(`span`,{className:`collage-chip-n`,children:t+1}),(0,J.jsxs)(`div`,{className:`collage-chip-acts`,children:[(0,J.jsx)(Y,{disabled:t===0,title:`earlier`,onClick:()=>N(t,-1),children:(0,J.jsx)(Ns,{size:14})}),(0,J.jsx)(Y,{disabled:t===i.length-1,title:`later`,onClick:()=>N(t,1),children:(0,J.jsx)(Hs,{size:14})})]})]},`${e.name}-${t}`))}),(0,J.jsxs)(`div`,{className:`upscale`,children:[(0,J.jsxs)(`span`,{className:`upscale-head`,children:[(0,J.jsx)(ene,{size:12}),` arrangement`]}),(0,J.jsxs)(Y,{className:c===null?`active`:``,title:`chosen from the shapes of these images`,onClick:()=>P(null),children:[(0,J.jsx)(xl,{size:13}),` auto`]}),XV(i.length).map(e=>(0,J.jsx)(Y,{className:c===e?`active`:``,onClick:()=>P(e),children:na(i.length,e)},e)),(0,J.jsx)(`span`,{className:`upscale-note`,children:c===null?`auto → ${na(i.length,k)}`:``})]}),(0,J.jsxs)(`div`,{className:`upscale`,children:[(0,J.jsxs)(`span`,{className:`upscale-head`,children:[(0,J.jsx)(Gte,{size:12}),` seam`]}),[`none`,`thin`,`wide`].map(e=>(0,J.jsx)(Y,{className:u===e?`active`:``,onClick:()=>F(e),children:e},e)),(0,J.jsxs)(Y,{className:f?`active`:``,title:`number each panel, so the prompt can say which screen it means`,onClick:ee,children:[(0,J.jsx)(Cl,{size:13}),` numbers`]})]})]}),(0,J.jsx)(`div`,{className:`collage-prev`,children:m?(0,J.jsx)(`img`,{src:m.url,alt:`combined preview`,className:g?`dim`:``}):(0,J.jsx)(`span`,{className:`upscale-note`,children:x?``:`preparing…`})}),(x||o.length>0)&&(0,J.jsxs)(Z,{tone:`warn`,children:[x,o.length>0&&` ${o.length} file${o.length===1?``:`s`} couldn't be decoded on this device and ${o.length===1?`is`:`are`} not in the picture: ${o.map(e=>e.name).join(`, `)}.`]}),m&&!x&&(0,J.jsxs)(Z,{children:[`One image, `,na(O,A),f?`, panels numbered`:``,` · goes to the annotator next, and uploads at `,gA(D.width),D.auto?` (auto)`:``,`.`,C?` This device couldn't draw it at full size, so it was drawn smaller.`:``,` Preview is ${yp(m.bytes)}.`]}),(0,J.jsxs)(`div`,{className:`sheet-actions`,children:[(0,J.jsxs)(Y,{disabled:v,title:`mark each image on its own, one after another`,onClick:()=>{q(`action:collage.separate`),n(i?[...i.map(e=>e.file),...o]:e)},children:[(0,J.jsx)(jo,{size:16}),` keep separate`]}),(0,J.jsxs)(`button`,{className:`send`,disabled:v||!i||i.length<2,onClick:()=>void te(),children:[(0,J.jsx)(vc,{size:16}),` `,v?`combining…`:`combine & mark`]})]})]})}var uH=e=>e===`arrow`||e===`line`||e===`marker`,dH=e=>e===`arrow`||e===`line`;function fH(e){return e===`text`?[`move`,`turn`]:e===`marker`?[`move`,`size`]:dH(e)?[`move`,`tail`,`head`]:[`move`,`size`,`turn`]}function pH(e,t,n,r,i){let a=18/n,o=26/n,s=t.x+t.w/2,c=t.y+t.h/2,l=uH(e.tool)?0:e.angle??0,u=(e,t)=>vH({x:e,y:t},{x:s,y:c},l),d=[];for(let n of fH(e.tool))if(n===`move`){let e=Math.abs(t.w/2*Math.sin(l))+Math.abs(t.h/2*Math.cos(l)),r=c+e,u=c-e,f=r+o+a;d.push(f+a<=i?{knob:n,ax:s,ay:r,x:s,y:f}:{knob:n,ax:s,ay:u,x:s,y:u-o-a})}else if(n===`head`||n===`tail`){let t=_H(e.x1-e.x0,e.y1-e.y0),r=n===`head`?1:-1,i=n===`head`?e.x1:e.x0,s=n===`head`?e.y1:e.y0;d.push({knob:n,ax:i,ay:s,x:i+r*t.x*(o+a),y:s+r*t.y*(o+a)})}else if(n===`size`){if(uH(e.tool)){let t=_H(e.x1-e.x0,e.y1-e.y0);d.push({knob:n,ax:e.x1,ay:e.y1,x:e.x1+t.x*(o+a),y:e.y1+t.y*(o+a)})}else{let e=(o+a)*Math.SQRT1_2,r=u(t.x+t.w,t.y+t.h),i=u(t.x+t.w+e,t.y+t.h+e);d.push({knob:n,ax:r.x,ay:r.y,x:i.x,y:i.y})}}else if(uH(e.tool)){let t=_H(e.x1-e.x0,e.y1-e.y0),r=-t.y,i=t.x;(i>0||i===0&&r>0)&&(r=-r,i=-i);let s=(e.x0+e.x1)/2,c=(e.y0+e.y1)/2;d.push({knob:n,ax:s,ay:c,x:s+r*(o+a),y:c+i*(o+a)})}else{let e=u(s,t.y),r=u(s,t.y-o-a);d.push({knob:n,ax:e.x,ay:e.y,x:r.x,y:r.y})}let f=e=>({x:Math.min(Math.max(e.x,a),Math.max(a,r-a)),y:Math.min(Math.max(e.y,a),Math.max(a,i-a))}),p=[];for(let e of d){let t=e=>p.every(t=>Math.hypot(t.x-e.x,t.y-e.y)>=a*2.2),n=f(e);if(!t(n))search:for(let r=1;r<=12;r++)for(let i of[1,-1]){let a=f(vH(e,{x:s,y:c},i*r*20*Math.PI/180));if(t(a)){n=a;break search}}p.push({...e,x:n.x,y:n.y})}return p}function mH(e,t,n,r){let i=24/r,a=null,o=1/0;for(let r of e){let e=Math.hypot(r.x-t,r.y-n);e<=i&&e<o&&(a=r,o=e)}return a?.knob??null}function hH(e,t,n,r,i,a){let o=r.x-n.x,s=r.y-n.y,c=16/i;if(e===`move`)return{...t,x0:t.x0+o,y0:t.y0+s,x1:t.x1+o,y1:t.y1+s};if(e===`head`||e===`tail`){let n=e===`head`,r=n?t.x0:t.x1,i=n?t.y0:t.y1,a=(n?t.x1:t.x0)+o,l=(n?t.y1:t.y0)+s;if(Math.hypot(a-r,l-i)<c){let e=_H(a-r||(n?t.x1-t.x0:t.x0-t.x1),l-i||(n?t.y1-t.y0:t.y0-t.y1));a=r+e.x*c,l=i+e.y*c}return n?{...t,x1:a,y1:l}:{...t,x0:a,y0:l}}let l=a?.x??(t.x0+t.x1)/2,u=a?.y??(t.y0+t.y1)/2;if(e===`turn`){if(Math.hypot(n.x-l,n.y-u)<c||Math.hypot(r.x-l,r.y-u)<c)return t;let e=Math.atan2(r.y-u,r.x-l)-Math.atan2(n.y-u,n.x-l);if(!uH(t.tool))return{...t,angle:gH((t.angle??0)+e)};let i=vH({x:t.x0,y:t.y0},{x:l,y:u},e),a=vH({x:t.x1,y:t.y1},{x:l,y:u},e);return{...t,x0:i.x,y0:i.y,x1:a.x,y1:a.y}}if(uH(t.tool)){let e=_H(t.x1-t.x0,t.y1-t.y0),n=Math.max(c/2,Math.hypot(t.x1-t.x0,t.y1-t.y0)/2+o*e.x+s*e.y);return{...t,x0:l-e.x*n,y0:u-e.y*n,x1:l+e.x*n,y1:u+e.y*n}}let d=t.angle??0,f=vH({x:o,y:s},{x:0,y:0},-d),p=Math.abs(t.x1-t.x0),m=Math.abs(t.y1-t.y0),h=Math.max(c,p+f.x),g=Math.max(c,m+f.y),_=vH({x:l-p/2,y:u-m/2},{x:l,y:u},d),v=vH({x:h/2,y:g/2},{x:0,y:0},d),y={x:_.x+v.x,y:_.y+v.y};return{...t,x0:y.x-h/2,y0:y.y-g/2,x1:y.x+h/2,y1:y.y+g/2}}function gH(e){let t=e%(Math.PI*2);return t>Math.PI?t-Math.PI*2:t<=-Math.PI?t+Math.PI*2:t}function _H(e,t){let n=Math.hypot(e,t);return n>1e-6?{x:e/n,y:t/n}:{x:1,y:0}}function vH(e,t,n){let r=Math.cos(n),i=Math.sin(n),a=e.x-t.x,o=e.y-t.y;return{x:t.x+a*r-o*i,y:t.y+a*i+o*r}}var yH={move:`#2f80ed`,size:`#f2994a`,turn:`#27ae60`,tail:`#f2994a`,head:`#f2994a`};function bH(e){let t={move:`blue moves`,size:uH(e)?`orange sets the length`:`orange sizes`,turn:`green turns`,tail:`orange drags that end`,head:`orange drags that end`},n=[...new Set(fH(e).map(e=>t[e]))];return n[0][0].toUpperCase()+n.join(` · `).slice(1)}function xH(e,t,n,r,i,a){e.save(),e.strokeStyle=`#fff`,e.lineWidth=a,e.lineCap=`round`,e.lineJoin=`round`;let o=i*.35;if(e.beginPath(),t===`move`){e.moveTo(n-i,r),e.lineTo(n+i,r),e.moveTo(n,r-i),e.lineTo(n,r+i);for(let[t,a]of[[1,0],[-1,0],[0,1],[0,-1]]){let s=n+t*i,c=r+a*i;e.moveTo(s-t*o+a*o,c-a*o+t*o),e.lineTo(s,c),e.lineTo(s-t*o-a*o,c-a*o-t*o)}}else if(t===`head`||t===`tail`)e.arc(n,r,i*.55,0,Math.PI*2);else if(t===`size`){let t=i*.75;e.moveTo(n-t,r-t),e.lineTo(n+t,r+t),e.moveTo(n-t+o*1.4,r-t),e.lineTo(n-t,r-t),e.lineTo(n-t,r-t+o*1.4),e.moveTo(n+t-o*1.4,r+t),e.lineTo(n+t,r+t),e.lineTo(n+t,r+t-o*1.4)}else{let t=-Math.PI*.25;e.arc(n,r,i*.8,t,Math.PI*1.45);let a=n+Math.cos(t)*i*.8,s=r+Math.sin(t)*i*.8;e.moveTo(a-o*1.2,s-o*.2),e.lineTo(a,s),e.lineTo(a+o*.1,s-o*1.2)}e.stroke(),e.restore()}function SH({m:e}){let{tool:t,shapes:n,moveMode:r,selected:i,target:a,setTarget:o,moveNote:s,knobs:c,err:l,cropMode:u,pendingCrop:d,pendingText:f,textDraft:p,setTextDraft:m,textInputRef:h,editRead:g,setEditRead:_,readDraft:v,setReadDraft:y,readInputRef:b,lastBand:x,applyCrop:S,toggleCrop:C,commitText:w,cancelText:T,startEditRead:E,commitRead:D,dropRead:O,hintHidden:k,hideHint:A}=e;return(0,J.jsxs)(J.Fragment,{children:[u?(0,J.jsxs)(`div`,{className:`annot-crop-bar`,children:[(0,J.jsx)(`span`,{className:`annot-hint`,children:d?`crop to ${Math.round(d.w)}×${Math.round(d.h)}`:`drag a box to crop`}),(0,J.jsx)(`button`,{className:`send`,disabled:!d,onClick:S,children:`Apply crop`}),(0,J.jsx)(Y,{onClick:C,children:`cancel`})]}):g==null?f?(0,J.jsxs)(`div`,{className:`annot-crop-bar`,children:[(0,J.jsx)(`input`,{className:`search annot-text-in`,ref:h,value:p,placeholder:`label text`,"aria-label":`label text`,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),w())}}),(0,J.jsx)(`button`,{className:`send`,disabled:!p.trim(),onClick:w,children:`Place`}),(0,J.jsx)(Y,{onClick:T,children:`cancel`})]}):r&&i!=null&&n[i]&&c?(0,J.jsx)(`div`,{className:`annot-hint`,children:s??bH(n[i].tool)}):r&&i!=null&&n[i]?n[i].tool===`text`?(0,J.jsx)(`div`,{className:`annot-hint`,children:`Drag anywhere to move the label — from beside the picture too.`}):(0,J.jsxs)(`div`,{className:`annot-crop-bar`,children:[(0,J.jsx)(Y,{className:a===null?`active`:``,onClick:()=>o(null),"aria-pressed":a===null,children:`whole`}),(0,J.jsx)(Y,{className:a===0?`active`:``,onClick:()=>o(0),"aria-pressed":a===0,children:n[i].tool===`arrow`?`tail`:`A`}),(0,J.jsx)(Y,{className:a===1?`active`:``,onClick:()=>o(1),"aria-pressed":a===1,children:n[i].tool===`arrow`?`head`:`B`}),(0,J.jsx)(`span`,{className:`annot-hint`,children:s??`Drag anywhere — the finger needn't be on the mark · pinch to zoom for finer steps`})]}):k?null:(0,J.jsxs)(`div`,{className:`annot-hint annot-hint-x`,children:[(0,J.jsx)(`span`,{children:r?`Tap a mark to select it`:t===`text`?`Tap where the label goes, then type it · two fingers pinch-zoom & pan`:t===`marker`?`Swipe along a line of text to point at it · Claude reads the words off the picture`:`One finger draws, from beside the picture too · two fingers pinch-zoom & pan · crop trims the image`}),(0,J.jsx)(Y,{onClick:A,"aria-label":`hide this hint for good`,children:(0,J.jsx)(B,{size:14,"aria-hidden":!0})})]}):(0,J.jsxs)(`div`,{className:`annot-crop-bar`,children:[(0,J.jsx)(`input`,{className:`search annot-text-in`,ref:b,value:v,placeholder:`the highlighted words`,"aria-label":`the highlighted words`,onChange:e=>y(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),D())}}),(0,J.jsx)(`button`,{className:`send`,onClick:D,children:`Use`}),(0,J.jsx)(Y,{onClick:()=>{_(null),y(``)},children:`cancel`})]}),x&&!u&&f==null&&g==null&&(0,J.jsx)(`div`,{className:`annot-read`,children:x.read?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`span`,{className:`annot-hint annot-read-text`,children:[`reads: “`,x.read,`”`]}),(0,J.jsx)(Y,{onClick:()=>E(x),children:`edit`}),(0,J.jsx)(Y,{onClick:()=>O(x),children:`drop`})]}):x.reading?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`annot-hint`,children:`reading…`}),(0,J.jsx)(Y,{onClick:()=>E(x),children:`type its words`})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`annot-hint`,children:x.readErr??`the mark says where to look · its words are optional`}),(0,J.jsx)(Y,{onClick:()=>E(x),children:`type its words`})]})}),l&&(0,J.jsx)(`div`,{className:`err`,children:l})]})}var CH=`(min-width: 1280px)`,wH=W(!1),TH=W(!1);function EH(){return G(TH)}function DH(){return G(wH)}if(typeof window<`u`)try{let e=window.matchMedia?.(CH);if(e){let t=()=>wH.set(e.matches);t(),e.addEventListener?.(`change`,t)}}catch{}var OH=null;function kH(e){return OH=e,()=>{OH===e&&(OH=null)}}function AH(){return OH}function jH({m:e}){let{view:t,fitRef:n,zoomed:r,resetZoom:i,configOpen:a,setConfigOpen:o}=e,s=DH(),c=EH(),l=s&&!!e.props.onDispatch,{send:u}=e;return(0,V.useEffect)(()=>l?kH(e=>void u(e)):void 0,[l,u]),(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(Y,{className:r?`active`:``,onClick:i,title:`reset zoom`,"aria-label":`reset zoom`,children:[(0,J.jsx)(Sc,{size:16}),` `,(t.k/(n.current.k||1)).toFixed(1),`×`]}),(0,J.jsx)(Y,{className:a?`active`:``,onClick:()=>o(e=>!e),"aria-pressed":a,title:`customize the toolbar`,"aria-label":`customize the toolbar`,children:(0,J.jsx)(es,{size:16})}),l&&(0,J.jsx)(Y,{className:c?`active`:``,onClick:()=>TH.set(!c),"aria-pressed":c,title:c?`back beside the session (Esc)`:`full screen — the session stays where it is`,"aria-label":c?`exit annotator full screen`:`annotator full screen`,children:c?(0,J.jsx)(hs,{size:16}):(0,J.jsx)($c,{size:16})})]})}function MH({prompt:e}){let[t,n]=(0,V.useState)(()=>fa(R.annPrompt,!1)),r=()=>n(e=>(ua(R.annPrompt,e?`0`:`1`),!e)),i=e.value.trim().split(`
13
+ `)[0];return(0,J.jsxs)(`div`,{className:`ann-prompt`,children:[(0,J.jsxs)(`button`,{className:`ann-prompt-fold`,onClick:r,"aria-expanded":t,title:t?`fold the message box away`:`show the session's message box — typed here, sent with the picture on Send & run`,children:[t?(0,J.jsx)(Nc,{size:14}):(0,J.jsx)(Hs,{size:14}),(0,J.jsx)(Yc,{size:14}),(0,J.jsx)(`span`,{className:`ann-prompt-gist`,children:t?`message for the session`:i||`message for the session — empty`})]}),t&&(0,J.jsx)(yE,{inline:!0,rows:2,prompts:[e.value],onChange:t=>e.onChange(t[0]??``),placeholder:`Message for the session — Send & run sends it with the picture`})]})}function NH({m:e}){let{busy:t,send:n,sendAll:r,readAll:i}=e,{index:a,total:o,onSkip:s,onSendAll:c,onDispatch:l,onText:u}=e.props;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(SA,{compact:!0}),(0,J.jsxs)(`div`,{className:`sheet-actions annot-send-bar`,"data-primary-key":``,children:[s&&(0,J.jsx)(Y,{onClick:s,disabled:t,children:`skip`}),c&&o&&o>1&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Y,{onClick:()=>r(`none`),disabled:t,title:`send this + every remaining image as-is`,children:`Send all`}),(0,J.jsx)(Y,{onClick:()=>r(`run`),disabled:t,title:`send all, then submit once uploads finish`,children:`Send all + submit`}),(0,J.jsxs)(Y,{onClick:()=>r(`queue`),disabled:t,title:`send all, then hand the prompt to the desktop — it goes in when this session is free`,children:[(0,J.jsx)(go,{size:14}),` Send all, then when it's free`]})]}),l&&(!o||o<=1)&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Y,{onClick:()=>n(`run`),disabled:t,title:`attach the image and run the prompt (uploads in the background)`,children:`Send & run`}),(0,J.jsxs)(Y,{onClick:()=>n(`queue`),disabled:t,title:`attach the image and hand the prompt to the desktop — it goes in when this session is free`,children:[(0,J.jsx)(go,{size:14}),` Send & when it's free`]})]}),u&&(0,J.jsxs)(Y,{onClick:()=>void i(),disabled:t,title:`read every word on the desktop and send only the text, not the photo`,children:[(0,J.jsx)(js,{size:14}),` text only`]}),(0,J.jsx)(`button`,{className:`send`,onClick:()=>n(`none`),disabled:t,children:t?`Sending…`:o&&o>1&&(a??1)<o?`Send & next`:`Send to repo`})]})]})}var PH=[{id:`undo`,label:`undo`},{id:`circle`,label:`circle`},{id:`rect`,label:`rectangle`},{id:`arrow`,label:`arrow`},{id:`line`,label:`line`},{id:`text`,label:`text label`},{id:`marker`,label:`highlight text`},{id:`blur`,label:`blur / redact`},{id:`crop`,label:`crop`},{id:`move`,label:`move a mark`},{id:`style`,label:`colour & stroke`},{id:`clear`,label:`clear all marks`}],FH=PH.map(e=>e.id),IH=[`auto`,`left`,`top`],LH={order:FH.slice(),hidden:[],place:`auto`},RH=e=>typeof e==`string`&&FH.includes(e);function zH(e){if(!e||typeof e!=`object`)return{...LH,order:FH.slice()};let t=e,n=new Set,r=[];for(let e of Array.isArray(t.order)?t.order:[])RH(e)&&!n.has(e)&&(n.add(e),r.push(e));return FH.forEach((e,t)=>{if(n.has(e))return;let i=0;for(let e=t-1;e>=0;e--){let t=r.indexOf(FH[e]);if(t>=0){i=t+1;break}}r.splice(i,0,e),n.add(e)}),{order:r,hidden:(Array.isArray(t.hidden)?t.hidden:[]).filter(RH).filter((e,t,n)=>n.indexOf(e)===t),place:IH.includes(t.place)?t.place:`auto`}}function BH(e){return e.order.filter(t=>!e.hidden.includes(t))}function VH(e,t){let n=e.hidden.includes(t)?e.hidden.filter(e=>e!==t):[...e.hidden,t];return{...e,hidden:n}}function HH(e,t,n){let r=e.order.indexOf(t),i=r+n;if(r<0||i<0||i>=e.order.length)return e;let a=e.order.slice();return[a[r],a[i]]=[a[i],a[r]],{...e,order:a}}function UH(e){return e.place===`auto`&&!e.hidden.length&&e.order.every((e,t)=>e===FH[t])}function WH(e,t){if(!e||!t||e.w<1||e.h<1||t.w<1||t.h<1)return null;let n=(e,n)=>Math.min(Math.max(e,0)/t.w,Math.max(n,0)/t.h),r=n(e.w-57,e.h);return n(e.w,e.h-61)>r?`top`:`left`}var GH=[{v:`auto`,label:`auto`},{v:`left`,label:`left`},{v:`top`,label:`top`}];function KH({m:e}){let{layout:t,setLayout:n,setConfigOpen:r}=e,i=e=>PH.find(t=>t.id===e)?.label??e,a=t.order.length-1;return(0,J.jsxs)(`div`,{className:`annot-config`,role:`dialog`,"aria-label":`customize the toolbar`,children:[(0,J.jsxs)(`div`,{className:`annot-config-head`,children:[(0,J.jsx)(`span`,{children:`Toolbar`}),(0,J.jsxs)(Y,{onClick:()=>r(!1),"aria-label":`close the toolbar settings`,children:[(0,J.jsx)(B,{size:16}),` done`]})]}),(0,J.jsxs)(`div`,{className:`annot-config-row`,children:[(0,J.jsx)(`span`,{className:`annot-config-label`,children:`position`}),GH.map(e=>(0,J.jsx)(Y,{className:t.place===e.v?`active`:``,"aria-pressed":t.place===e.v,onClick:()=>n({...t,place:e.v}),children:e.label},e.v))]}),(0,J.jsx)(`div`,{className:`annot-config-hint`,children:t.place===`auto`?`auto: whichever side leaves this picture larger — a row on top for a wide one, a rail on the left for a tall one`:`always on the ${t.place}`}),(0,J.jsx)(`div`,{className:`annot-config-list`,children:t.order.map((e,r)=>{let o=!t.hidden.includes(e);return(0,J.jsxs)(`div`,{className:`annot-config-row ${o?``:`off`}`,children:[(0,J.jsx)(Y,{className:`annot-config-toggle${o?` active`:``}`,"aria-pressed":o,onClick:()=>n(VH(t,e)),children:o?`shown`:`hidden`}),(0,J.jsx)(`span`,{className:`annot-config-label`,children:i(e)}),r>0?(0,J.jsx)(Y,{onClick:()=>n(HH(t,e,-1)),"aria-label":`move ${i(e)} up`,children:(0,J.jsx)(mc,{size:16})}):(0,J.jsx)(`span`,{className:`annot-config-gap`}),r<a?(0,J.jsx)(Y,{onClick:()=>n(HH(t,e,1)),"aria-label":`move ${i(e)} down`,children:(0,J.jsx)(Nc,{size:16})}):(0,J.jsx)(`span`,{className:`annot-config-gap`})]},e)})}),!UH(t)&&(0,J.jsx)(`div`,{className:`annot-config-row`,children:(0,J.jsx)(Y,{onClick:()=>n({...LH,order:LH.order.slice()}),children:`reset to default`})})]})}var qH=[`#ff2d2d`,`#ffd400`,`#3fb950`,`#4c9aff`,`#ffffff`],JH=`#ffd400`,YH=[{label:`S`,factor:.6},{label:`M`,factor:1},{label:`L`,factor:1.8}];function XH(e){return e instanceof File,e.name}var ZH={circle:{tool:`circle`,icon:(0,J.jsx)(zc,{size:16}),label:`circle`},rect:{tool:`rect`,icon:(0,J.jsx)(ic,{size:16}),label:`rectangle`},arrow:{tool:`arrow`,icon:(0,J.jsx)(Bte,{size:16}),label:`arrow`},line:{tool:`line`,icon:(0,J.jsx)(ls,{size:16}),label:`line`},text:{tool:`text`,icon:(0,J.jsx)(Ks,{size:16}),label:`text`},marker:{tool:`marker`,icon:(0,J.jsx)(Vte,{size:16}),label:`highlight text`},blur:{tool:`blur`,icon:(0,J.jsx)(Go,{size:16}),label:`blur or redact`}};function QH({m:e}){let{tool:t,color:n,setColor:r,factor:i,setFactor:a,shapes:o,setShapes:s,moveMode:c,selected:l,setSelected:u,setTarget:d,setMoveNote:f,knobs:p,cropMode:m,paletteOpen:h,setPaletteOpen:g,moveRef:_,toggleCrop:v,pickTool:y,undoShape:b,toggleMove:x,toggleKnobs:S,deleteSelected:C,layout:w}=e,T=YH.find(e=>e.factor===i)?.label??`M`;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`annot-tools annot-bar`,children:BH(w).map(e=>{let r=ZH[e];if(r)return(0,J.jsx)(Y,{className:t===r.tool?`active`:``,onClick:()=>y(r.tool),title:r.label,"aria-label":r.label,"aria-pressed":t===r.tool,children:r.icon},e);switch(e){case`undo`:return(0,J.jsx)(Y,{onClick:b,disabled:!o.length,title:`undo`,"aria-label":`undo the last mark`,children:(0,J.jsx)(Zs,{size:16})},e);case`crop`:return(0,J.jsx)(Y,{className:m?`active`:``,onClick:v,title:`crop`,"aria-label":`crop`,"aria-pressed":m,children:(0,J.jsx)(Ia,{size:16})},e);case`move`:return[(0,J.jsx)(Y,{className:c?`active`:``,onClick:x,disabled:!o.length,title:`move/reshape a mark`,"aria-label":`move a mark`,"aria-pressed":c,children:(0,J.jsx)(rne,{size:16})},e),c&&(0,J.jsx)(Y,{onClick:C,disabled:l==null,title:`delete the selected mark`,"aria-label":`delete the selected mark`,children:(0,J.jsx)(ws,{size:16})},`del`),c&&(0,J.jsx)(Y,{className:p?`active`:``,onClick:S,"aria-pressed":p,title:`knobs: move, size and turn a mark (or drag an arrow's ends) by knobs on strings, instead of dragging from anywhere`,"aria-label":`knobs on the selected mark`,children:`knobs`},`knobs`)];case`style`:return(0,J.jsx)(`button`,{className:`swatch dot annot-style ${h?`on`:``}`,style:{background:n},onClick:()=>g(e=>!e),title:`mark colour and stroke`,"aria-label":`mark colour ${n}, stroke ${T} — tap to change`,"aria-expanded":h,children:T},e);case`clear`:return(0,J.jsx)(Y,{onClick:()=>{_.current=null,u(null),d(null),f(null),s([])},disabled:!o.length,title:`clear all marks`,"aria-label":`clear all marks`,children:(0,J.jsx)(ul,{size:16})},e)}return null})}),h&&(0,J.jsxs)(`div`,{className:`annot-tools annot-palette`,children:[qH.map(e=>(0,J.jsx)(`button`,{className:`swatch ${n===e?`on`:``}`,style:{background:e},onClick:()=>{r(e),g(!1)},title:`colour ${e}`,"aria-label":`colour ${e}`,"aria-pressed":n===e},e)),YH.map(e=>(0,J.jsx)(Y,{className:i===e.factor?`active`:``,onClick:()=>{a(e.factor),g(!1)},title:`stroke ${e.label}`,"aria-label":`stroke ${e.label}`,"aria-pressed":i===e.factor,children:e.label},e.label))]})]})}function $H({m:e}){let{canvasRef:t,wrapRef:n,bodyRef:r,view:i,onDown:a,onMove:o,onUp:s,place:c,configOpen:l}=e;return(0,J.jsxs)(`div`,{className:`annot-body place-${c}`,ref:r,children:[(0,J.jsx)(QH,{m:e}),(0,J.jsx)(`div`,{className:`annot-canvas-wrap`,ref:n,onPointerDown:a,onPointerMove:o,onPointerUp:s,onPointerCancel:s,children:(0,J.jsx)(`canvas`,{ref:t,className:`annot-canvas`,style:{transform:`translate(${i.tx}px, ${i.ty}px) scale(${i.k})`,transformOrigin:`0 0`}})}),l&&(0,J.jsx)(KH,{m:e})]})}function eU({m:e}){let{ocr:t,ocrDraft:n,setOcrDraft:r,readAll:i,closeOcr:a,sendText:o}=e;if(!t)return null;let s=!n.trim();return(0,J.jsxs)(`div`,{className:`annot-ocr`,children:[t.phase===`reading`&&(0,J.jsx)(`div`,{className:`annot-hint`,children:`Reading every word on your desktop… The photo goes no further than that machine.`}),t.phase===`error`&&(0,J.jsx)(`div`,{className:`annot-hint`,children:t.error}),t.phase===`ready`&&(0,J.jsxs)(`div`,{className:`annot-hint`,children:[`Read on your desktop (`,t.engine,`, `,(t.ms/1e3).toFixed(1),` s). Fix anything misread — only this text is sent, never the photo.`]}),(t.phase===`ready`||!s)&&(0,J.jsx)(`textarea`,{className:`annot-ocr-text`,value:n,onChange:e=>r(e.target.value),spellCheck:!1,autoCapitalize:`off`,"aria-label":`text read off the picture`}),t.phase===`ready`&&s&&(0,J.jsx)(`div`,{className:`annot-hint`,children:`Nothing left to send — read again, or go back to the picture.`}),(0,J.jsxs)(`div`,{className:`sheet-actions annot-send-bar`,"data-primary-key":``,children:[(0,J.jsxs)(Y,{onClick:a,children:[(0,J.jsx)(Sl,{size:14}),` picture`]}),t.phase!==`reading`&&(0,J.jsxs)(Y,{onClick:()=>void i(),children:[(0,J.jsx)(xc,{size:14}),` read again`]}),t.phase!==`reading`&&!s&&(0,J.jsxs)(`button`,{className:`send`,onClick:()=>o(n),children:[(0,J.jsx)(js,{size:14}),` Send text only`]})]})]})}var tU={"#ff2d2d":`red`,"#ffd400":`yellow`,"#3fb950":`green`,"#4c9aff":`blue`,"#ffffff":`white`};function nU(e,t,n,r){let i=t/r,a=e/n,o=i<.34?`top`:i>.66?`bottom`:`middle`,s=a<.34?`left`:a>.66?`right`:`center`;return o===`middle`&&s===`center`?`center`:o===`middle`?s:s===`center`?o:`${o}-${s}`}function rU(e){return`${Math.round(Math.max(0,Math.min(1,e))*100)}%`}function iU(e,t,n,r){return`${nU(e,t,n,r)} (x ${rU(e/n)}, y ${rU(t/r)})`}function aU(e,t,n){let r=Math.min(e.x0,e.x1),i=Math.max(e.x0,e.x1),a=Math.min(e.y0,e.y1),o=Math.max(e.y0,e.y1);return`(x ${rU(r/t)}-${rU(i/t)}, y ${rU(a/n)}-${rU(o/n)})`}function oU(e){return`"${e.replace(/\s+/g,` `).trim().replace(/"/g,`''`)}"`}var sU=e=>tU[e.toLowerCase()]||e;function cU(e,t,n){return[e.tool,e.color.toLowerCase(),rU(Math.min(e.x0,e.x1)/t),rU(Math.min(e.y0,e.y1)/n),rU(Math.max(e.x0,e.x1)/t),rU(Math.max(e.y0,e.y1)/n),(e.text??``).trim(),(e.read??``).trim()].join(`|`)}function lU(e,t,n){if(t<=0||n<=0)return[];let r=new Set,i=[];for(let a of e){let e=cU(a,t,n);r.has(e)||(r.add(e),i.push(a))}return i}function uU(e,t,n){switch(e.tool){case`blur`:return`blurred/redacted region ${aU(e,t,n)}`;case`text`:return`text ${oU(e.text||``)} at ${iU(e.x0,e.y0,t,n)}`;case`marker`:return e.read?`highlight over ${oU(e.read)} ${aU(e,t,n)}`:`highlight ${aU(e,t,n)}`;case`arrow`:return`arrow pointing to ${iU(e.x1,e.y1,t,n)}`;case`line`:return`line from ${iU(e.x0,e.y0,t,n)} to ${iU(e.x1,e.y1,t,n)}`;case`rect`:return e.read?`box around ${oU(e.read)} ${aU(e,t,n)}`:`box ${aU(e,t,n)}`;default:return e.read?`circle around ${oU(e.read)} ${aU(e,t,n)}`:`circle ${aU(e,t,n)}`}}function dU(e,t,n,r){let i=lU(e,t,n),a=[];r&&a.push(r);let o=i.length>1,s=new Set(i.map(e=>e.color.toLowerCase())).size<=1;return i.forEach((e,r)=>{let i=o?`#${r+1} `:``,c=s||e.tool===`blur`?``:`${sU(e.color)} `;a.push(`${i}${c}${uU(e,t,n)}`)}),a.join(`; `)}function fU(e,t){return!e||!t||!(t.w>0)||!(t.h>0)?e:`${e}; image ${Math.round(t.w)}x${Math.round(t.h)}`}var pU=new Set([`rect`,`blur`,`marker`]),mU=(e,t)=>Fp(e,0,t);function hU(e,t,n){return Math.max(e.x0,e.x1)>0&&Math.min(e.x0,e.x1)<t&&Math.max(e.y0,e.y1)>0&&Math.min(e.y0,e.y1)<n}function gU(e,t){let n=(e.x0+e.x1)/2,r=(e.y0+e.y1)/2,i=Math.abs(e.x1-e.x0)/2,a=Math.abs(e.y1-e.y0)/2,o=Math.abs(i*Math.cos(t))+Math.abs(a*Math.sin(t)),s=Math.abs(i*Math.sin(t))+Math.abs(a*Math.cos(t));return{x0:n-o,y0:r-s,x1:n+o,y1:r+s}}function _U(e,t,n){let r=e.x1-e.x0,i=e.y1-e.y0,a=0,o=1,s=[[-r,e.x0-0],[r,t-e.x0],[-i,e.y0-0],[i,n-e.y0]];for(let[e,t]of s){if(e===0){if(t<0)return null;continue}let n=t/e;if(e<0){if(n>o)return null;n>a&&(a=n)}else{if(n<a)return null;n<o&&(o=n)}}return{x0:e.x0+a*r,y0:e.y0+a*i,x1:e.x0+o*r,y1:e.y0+o*i}}function vU(e,t,n){if(!(t>0&&n>0))return e;if(e.tool===`text`){let r=mU(e.x0,t),i=mU(e.y0,n);return{...e,x0:r,y0:i,x1:r,y1:i}}if(e.tool===`line`||e.tool===`arrow`){let r=_U(e,t,n);return r?{...e,...r}:null}return e.angle?hU(gU(e,e.angle),t,n)?e:null:hU(e,t,n)?pU.has(e.tool)?{...e,x0:mU(e.x0,t),y0:mU(e.y0,n),x1:mU(e.x1,t),y1:mU(e.y1,n)}:e:null}function yU(e,t){return e.tool!==`text`&&Math.hypot(e.x1-e.x0,e.y1-e.y0)*t<48}function bU(e){let{sel:t,small:n,handleHit:r,pickHit:i,target:a}=e;return t!=null&&!n&&r!=null?{kind:`handle`,i:t,h:r}:i==null?t==null?{kind:`none`}:{kind:`relative`,i:t,h:a}:{kind:`pick`,i}}function xU(e,t,n,r){let i=vU(e,n,r);return i?{mark:i,refused:!1}:{mark:t,refused:!0}}function SU(e){return Math.max(4,Math.round(e.width/220))}function CU(e){return{x:Math.min(e.x0,e.x1),y:Math.min(e.y0,e.y1),w:Math.abs(e.x1-e.x0),h:Math.abs(e.y1-e.y0)}}function wU(e,t){if(!e)return t;let n=t=>Math.max(0,Math.min(t,e.width)),r=t=>Math.max(0,Math.min(t,e.height)),i=n(t.x),a=r(t.y);return{x:i,y:a,w:n(t.x+t.w)-i,h:r(t.y+t.h)-a}}function TU(e){let t=/^#?([0-9a-f]{6})$/i.exec(e.trim());if(!t)return`#fff`;let n=parseInt(t[1],16);return(.299*(n>>16&255)+.587*(n>>8&255)+.114*(n&255))/255>.6?`#111`:`#fff`}function EU(e){if(e.tool===`text`||e.tool===`arrow`||e.tool===`line`)return{x:e.x0,y:e.y0};let t=CU(e);if(!e.angle)return{x:t.x,y:t.y};let n=t.x+t.w/2,r=t.y+t.h/2,i=Math.cos(e.angle),a=Math.sin(e.angle);return{x:n+-t.w/2*i- -t.h/2*a,y:r+-t.w/2*a+-t.h/2*i}}function DU(e,t,n){if(n.tool===`text`){let r=Math.max(16,Math.round(t.width/26))*n.factor;e.save(),e.font=`bold ${r}px ui-sans-serif, system-ui, sans-serif`;let i=e.measureText(n.text||``).width;return e.restore(),{x:n.x0,y:n.y0,w:i,h:r*1.2}}return CU(n)}function OU(e,t,n,r,i,a){let o=i-n,s=a-r,c=o*o+s*s,l=c?Math.max(0,Math.min(1,((e-n)*o+(t-r)*s)/c)):0;return Math.hypot(e-(n+l*o),t-(r+l*s))}function kU(e,t,n,r,i){if(!e)return!1;if(t.tool===`arrow`||t.tool===`line`)return OU(n,r,t.x0,t.y0,t.x1,t.y1)<=i;let a=DU(e.getContext(`2d`),e,t);if(t.angle){let e=a.x+a.w/2,i=a.y+a.h/2,o=Math.cos(-t.angle),s=Math.sin(-t.angle),c=e+(n-e)*o-(r-i)*s,l=i+(n-e)*s+(r-i)*o;n=c,r=l}return n>=a.x-i&&n<=a.x+a.w+i&&r>=a.y-i&&r<=a.y+a.h+i}function AU(e,t,n){if(!n)return;let r=SU(t);e.save(),e.fillStyle=`rgba(0,0,0,.55)`,e.beginPath(),e.rect(0,0,t.width,t.height),e.rect(n.x,n.y,n.w,n.h),e.fill(`evenodd`),e.strokeStyle=`#fff`,e.lineWidth=r,e.setLineDash([r*2.5,r*2.5]),e.strokeRect(n.x,n.y,n.w,n.h),e.restore()}function jU(e,t,n,r){if(!n)return;if(r.angle){let i=CU(r),a=i.x+i.w/2,o=i.y+i.h/2;e.save(),e.beginPath(),e.translate(a,o),e.rotate(r.angle),e.rect(-i.w/2,-i.h/2,i.w,i.h),e.setTransform(1,0,0,1,0,0),e.clip(),jU(e,t,n,{...r,angle:0,...gU(r,r.angle)}),e.restore();return}let{x:i,y:a,w:o,h:s}=wU(t,CU(r));if(o<1||s<1)return;let c=Math.max(8,Math.round(t.width/48)),l=Math.max(1,Math.round(o/c)),u=Math.max(1,Math.round(s/c)),d=document.createElement(`canvas`);d.width=l,d.height=u,d.getContext(`2d`).drawImage(n,i,a,o,s,0,0,l,u),e.save(),e.imageSmoothingEnabled=!1,e.drawImage(d,0,0,l,u,i,a,o,s),e.restore()}function MU(e,t,n){let r=CU(n),i=SU(t)*5*n.factor,a=Math.max(r.h,i),o=r.h>=i?r.y:r.y-(i-r.h)/2;e.save(),e.globalAlpha=.38,e.globalCompositeOperation=`multiply`,e.fillStyle=n.color,e.fillRect(r.x,o,Math.max(r.w,i),a),e.restore()}function NU(e,t,n){if(n.length<2)return;let r=Math.max(10,SU(t)*3.2);n.forEach((n,i)=>{let a=EU(n),o=Math.max(r+2,Math.min(t.width-r-2,a.x-r*.2)),s=Math.max(r+2,Math.min(t.height-r-2,a.y-r*.2));e.save(),e.beginPath(),e.arc(o,s,r,0,Math.PI*2),e.fillStyle=n.tool===`blur`?`#111`:n.color,e.fill(),e.lineWidth=Math.max(1,r*.14),e.strokeStyle=`rgba(0,0,0,.55)`,e.stroke(),e.fillStyle=n.tool===`blur`?`#fff`:TU(n.color),e.font=`bold ${Math.round(r*1.25)}px ui-sans-serif, system-ui, sans-serif`,e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(String(i+1),o,s),e.restore()}),e.textAlign=`start`}function PU(e,t,n,r){if(!r.angle||r.tool===`blur`||r.tool===`arrow`||r.tool===`line`){FU(e,t,n,r);return}let i=DU(e,t,r),a=i.x+i.w/2,o=i.y+i.h/2;e.save(),e.translate(a,o),e.rotate(r.angle),e.translate(-a,-o),FU(e,t,n,r),e.restore()}function FU(e,t,n,r){if(r.tool===`blur`){jU(e,t,n,r);return}if(r.tool===`marker`){MU(e,t,r);return}let i=SU(t)*r.factor;if(e.strokeStyle=r.color,e.fillStyle=r.color,e.lineWidth=i,e.lineCap=`round`,e.lineJoin=`round`,r.tool===`rect`)e.strokeRect(r.x0,r.y0,r.x1-r.x0,r.y1-r.y0);else if(r.tool===`circle`)e.beginPath(),e.ellipse((r.x0+r.x1)/2,(r.y0+r.y1)/2,Math.abs(r.x1-r.x0)/2,Math.abs(r.y1-r.y0)/2,0,0,Math.PI*2),e.stroke();else if(r.tool===`arrow`||r.tool===`line`){let t=Math.atan2(r.y1-r.y0,r.x1-r.x0),n=i*4;if(e.beginPath(),e.moveTo(r.x0,r.y0),e.lineTo(r.x1,r.y1),e.stroke(),r.tool===`line`)return;e.beginPath(),e.moveTo(r.x1,r.y1),e.lineTo(r.x1-n*Math.cos(t-Math.PI/6),r.y1-n*Math.sin(t-Math.PI/6)),e.lineTo(r.x1-n*Math.cos(t+Math.PI/6),r.y1-n*Math.sin(t+Math.PI/6)),e.closePath(),e.fill()}else if(r.tool===`text`&&r.text){let n=Math.max(16,Math.round(t.width/26))*r.factor;e.font=`bold ${n}px ui-sans-serif, system-ui, sans-serif`,e.textBaseline=`top`,e.lineWidth=Math.max(2,n/8),e.strokeStyle=`rgba(0,0,0,.65)`,e.strokeText(r.text,r.x0,r.y0),e.fillText(r.text,r.x0,r.y0)}}function IU(e,t,n,r,i,a){let o=DU(e,t,n),s=Math.max(1,SU(t)*.6),c=yU(n,r),l=c?Math.max(s*3,48/r/2):s*3;if(e.save(),n.angle&&n.tool!==`arrow`&&n.tool!==`line`){let t=o.x+o.w/2,r=o.y+o.h/2;e.translate(t,r),e.rotate(n.angle),e.translate(-t,-r)}if(e.strokeStyle=`#4c9aff`,e.lineWidth=s,e.setLineDash([s*3,s*3]),e.strokeRect(o.x-l,o.y-l,o.w+l*2,o.h+l*2),e.setLineDash([]),i)e.restore(),RU(e,t,n,r);else if(n.angle)e.restore();else{if(n.tool!==`text`&&!c){let r=SU(t)*1.8;[[0,n.x0,n.y0],[1,n.x1,n.y1]].forEach(([t,n,i])=>{e.beginPath(),e.arc(n,i,r,0,Math.PI*2),e.fillStyle=a===t?`#4c9aff`:`#fff`,e.fill(),e.stroke()})}e.restore()}}function LU(e,t,n){return pH(t,DU(e.getContext(`2d`),e,t),n,e.width,e.height)}function RU(e,t,n,r){let i=18/r,a=LU(t,n,r);e.save(),e.lineCap=`round`;for(let t of a)e.beginPath(),e.moveTo(t.ax,t.ay),e.lineTo(t.x,t.y),e.strokeStyle=`rgba(255,255,255,0.85)`,e.lineWidth=4/r,e.stroke(),e.strokeStyle=`#4c9aff`,e.lineWidth=2/r,e.stroke();for(let t of a)e.beginPath(),e.arc(t.x,t.y,i,0,Math.PI*2),e.fillStyle=yH[t.knob],e.fill(),e.lineWidth=2/r,e.strokeStyle=`#fff`,e.stroke(),xH(e,t.knob,t.x,t.y,i*.5,2/r);e.restore()}function zU(e){let{canvasRef:t,wrapRef:n,imgRef:r,setTool:i,color:a,setColor:o,factor:s,setShapes:c,setMoveMode:l,setSelected:u,selectedRef:d,setTarget:f,targetRef:p,setMoveNote:m,setKnobs:h,moveRef:g,setCropMode:_,pendingCrop:v,setPendingCrop:y,cropDrag:b,pendingText:x,setPendingText:S,textDraft:C,setTextDraft:w,textInputRef:T,idRef:E,setPaletteOpen:D,setView:O,viewRef:k,fitRef:A,redraw:j,clampToImage:M}=e;async function N(){let e=r.current,i=t.current;if(!e||!i||!v)return;let{x:a,y:o,w:s,h:l}=M(v);if(s<1||l<1){y(null);return}let u=document.createElement(`canvas`);u.width=Math.round(s),u.height=Math.round(l),u.getContext(`2d`).drawImage(e,a,o,s,l,0,0,u.width,u.height);try{r.current=await createImageBitmap(u)}catch{r.current=u}i.width=u.width,i.height=u.height,c(e=>e.map(e=>({...e,x0:e.x0-a,y0:e.y0-o,x1:e.x1-a,y1:e.y1-o})).map(e=>vU(e,u.width,u.height)).filter(e=>e!=null));let d=n.current?.getBoundingClientRect();if(d){let e=Math.min(d.width/u.width,d.height/u.height),t={k:e,tx:(d.width-u.width*e)/2,ty:(d.height-u.height*e)/2};A.current=t,O(t)}y(null),_(!1),j()}function P(){b.current=null,y(null),l(!1),u(null),f(null),m(null),g.current=null,ae(),_(e=>!e)}function F(e){e!==`text`&&ae(),D(!1),e===`marker`&&a.toLowerCase()===`#ffffff`&&o(JH),i(e)}function ee(){g.current=null,u(null),f(null),m(null),c(e=>e.slice(0,-1))}function te(){g.current=null,f(null),m(null),l(e=>(e?u(null):(b.current=null,y(null),_(!1)),!e))}function ne(){g.current=null,f(null),p.current=null,m(null),h(e=>(sa(R.annKnobs,!e),!e))}function re(){let e=d.current;e!=null&&(g.current=null,u(null),f(null),m(null),c(t=>t.filter((t,n)=>n!==e)))}function ie(){let e=x,n=C.trim();if(S(null),w(``),T.current?.blur(),!e||!n)return;let r=t.current,i={tool:`text`,x0:e.x,y0:e.y,x1:e.x,y1:e.y,color:a,factor:s,text:n,id:E.current++};c(e=>[...e,r?vU(i,r.width,r.height):i])}function ae(){S(null),w(``),T.current?.blur()}function oe(){k.current=A.current,j(),O(A.current)}return{applyCrop:N,toggleCrop:P,pickTool:F,undoShape:ee,toggleMove:te,toggleKnobs:ne,deleteSelected:re,commitText:ie,cancelText:ae,resetZoom:oe}}function BU(e){let{canvasRef:t,wrapRef:n,tool:r,color:i,factor:a,setShapes:o,shapesRef:s,dragRef:c,moveMode:l,setSelected:u,selectedRef:d,setTarget:f,targetRef:p,setMoveNote:m,knobsRef:h,moveRef:g,cropMode:_,setPendingCrop:v,cropDrag:y,setPendingText:b,setTextDraft:x,textInputRef:S,idRef:C,setView:w,viewRef:T,fitRef:E,pointers:D,gesture:O,redraw:k,clampToImage:A}=e,j=(e,n,r,i)=>kU(t.current,e,n,r,i),M=(e,t)=>LU(e,t,T.current.k||1);function N(){let e=t.current,n=T.current.k||1;return Math.max(6,24/n,e?e.width/90:0)}function P(e){let n=t.current,r=n.getBoundingClientRect();return{x:(e.clientX-r.left)/r.width*n.width,y:(e.clientY-r.top)/r.height*n.height}}function F(e){let t=n.current.getBoundingClientRect();return{x:e.clientX-t.left,y:e.clientY-t.top}}function ee(e,t,n){let r=s.current;for(let i=r.length-1;i>=0;i--)if(j(r[i],e,t,n))return i;return null}function te(e){if(e.preventDefault(),D.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),e.currentTarget.setPointerCapture(e.pointerId),D.current.size===2){c.current=null,g.current=null;let e=[...D.current.values()],t=Math.hypot(e[0].x-e[1].x,e[0].y-e[1].y),n={x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},r=F({clientX:n.x,clientY:n.y}),i=T.current;O.current={startDist:t,startK:i.k,cx:(r.x-i.tx)/i.k,cy:(r.y-i.ty)/i.k},y.current=null,k();return}if(_){let{x:t,y:n}=P(e);y.current={x0:t,y0:n,x1:t,y1:n},v(null);return}if(l){m(null);let{x:n,y:r}=P(e),i=N(),a=T.current.k||1,o=s.current,c=d.current,l=c!=null&&o[c]?c:null,_=l==null?void 0:o[l],v=_?yU(_,a)||!!_.angle:!1;if(h.current){let s=t.current,c=_?mH(M(s,_),n,r,a):null;if(c){g.current={i:l,base:_,live:_,gx:n,gy:r,handle:null,sx:e.clientX,sy:e.clientY,fromEmpty:!1,knob:c};return}let f=ee(n,r,i);if(f!=null){d.current=f,u(f),g.current={i:f,base:o[f],live:o[f],gx:n,gy:r,handle:null,sx:e.clientX,sy:e.clientY,fromEmpty:!1,knob:`move`},k();return}l!=null&&(g.current={i:l,base:_,live:_,gx:n,gy:r,handle:null,sx:e.clientX,sy:e.clientY,fromEmpty:!0,idle:!0});return}let y=null;if(_&&_.tool!==`text`&&!v){let e=1/0;for(let t of[0,1]){let a=t===0?_.x0:_.x1,o=t===0?_.y0:_.y1,s=Math.hypot(n-a,r-o);s<=i*1.4&&s<e&&(e=s,y=t)}}let b=ee(n,r,i),x=bU({sel:l,small:v,handleHit:y,pickHit:b,target:p.current});if(x.kind===`handle`){g.current={i:x.i,base:_,live:_,gx:n,gy:r,handle:x.h,sx:e.clientX,sy:e.clientY,fromEmpty:!1};return}if(x.kind===`pick`){x.i!==l&&(f(null),p.current=null),d.current=x.i,u(x.i),g.current={i:x.i,base:o[x.i],live:o[x.i],gx:n,gy:r,handle:null,sx:e.clientX,sy:e.clientY,fromEmpty:!1},k();return}if(x.kind===`relative`){g.current={i:l,base:_,live:_,gx:n,gy:r,handle:x.h,sx:e.clientX,sy:e.clientY,fromEmpty:!0};return}return}if(r===`text`)return;let{x:n,y:o}=P(e);c.current={tool:r,x0:n,y0:o,x1:n,y1:o,color:i,factor:a,id:C.current++}}function ne(e){if(D.current.has(e.pointerId)&&D.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),O.current&&D.current.size>=2){let e=[...D.current.values()],t=Math.hypot(e[0].x-e[1].x,e[0].y-e[1].y),n={x:(e[0].x+e[1].x)/2,y:(e[0].y+e[1].y)/2},r=F({clientX:n.x,clientY:n.y}),i=O.current,a=E.current.k,o=Math.min(a*8,Math.max(a,i.startK*(t/i.startDist)));w({k:o,tx:r.x-i.cx*o,ty:r.y-i.cy*o});return}if(_&&y.current){let{x:t,y:n}=P(e);y.current={...y.current,x1:t,y1:n},k();return}if(l){let n=g.current;if(!n||n.idle)return;let{x:r,y:i}=P(e);if(n.knob){let e=t.current,a=DU(e.getContext(`2d`),e,n.base);n.live=hH(n.knob,n.base,{x:n.gx,y:n.gy},{x:r,y:i},T.current.k||1,{x:a.x+a.w/2,y:a.y+a.h/2}),k();return}let a=r-n.gx,o=i-n.gy;n.live=n.handle===0?{...n.base,x0:n.base.x0+a,y0:n.base.y0+o}:n.handle===1?{...n.base,x1:n.base.x1+a,y1:n.base.y1+o}:{...n.base,x0:n.base.x0+a,y0:n.base.y0+o,x1:n.base.x1+a,y1:n.base.y1+o},k();return}if(!c.current)return;let{x:n,y:r}=P(e);c.current={...c.current,x1:n,y1:r},k()}function re(e){if(D.current.delete(e.pointerId),D.current.size<2&&(O.current=null),!(D.current.size>0)){if(_){if(y.current){let e=A(CU(y.current));y.current=null,v(e.w>12&&e.h>12?e:null),k()}}else if(l){let n=g.current;if(g.current=null,n){if(n.fromEmpty&&Math.hypot(e.clientX-n.sx,e.clientY-n.sy)<8){d.current=null,p.current=null,u(null),f(null),k();return}if(n.idle){k();return}let r=t.current,{mark:i,refused:a}=r?xU(n.live,n.base,r.width,r.height):{mark:n.live,refused:!1};a?k():o(e=>e.map((e,t)=>t===n.i?{...e,x0:i.x0,y0:i.y0,x1:i.x1,y1:i.y1,angle:i.angle}:e)),m(a?`That would take it off the picture — left where it was.`:null)}else k()}else if(r===`text`){let{x:t,y:n}=P(e);b({x:t,y:n}),x(``),requestAnimationFrame(()=>S.current?.focus())}else if(c.current){let e=c.current;c.current=null;let n=t.current,r=n?vU(e,n.width,n.height):e;r&&(Math.abs(r.x1-r.x0)>6||Math.abs(r.y1-r.y0)>6)?o(e=>[...e,r]):k()}}}return{onDown:te,onMove:ne,onUp:re}}function VU(e){let{setShapes:t,readTextRef:n,editRead:r,setEditRead:i,readDraft:a,setReadDraft:o,readInputRef:s}=e;function c(e,n){t(t=>t.map(t=>t.id===e?{...t,...n}:t))}function l(e){i(e.id),o(e.read??``),requestAnimationFrame(()=>s.current?.focus())}function u(){let e=r,t=a.trim();i(null),o(``),s.current?.blur(),e!=null&&(t?n.current.set(e,t):n.current.delete(e),c(e,{read:t||void 0,readErr:t?void 0:`no words on this mark`,readBy:`hand`,reading:!1}))}function d(e){n.current.delete(e.id),c(e.id,{read:void 0,readErr:`words dropped`,readBy:`hand`,reading:!1})}return{patchShape:c,startEditRead:l,commitRead:u,dropRead:d}}var HU=new Set([`marker`,`rect`,`circle`]),UU=1e4,WU=2e3;function GU(e){let t=e=>Math.round(e);return[e.tool,t(e.x0),t(e.y0),t(e.x1),t(e.y1),Math.round((e.angle??0)*1e3)].join(`|`)}function KU(e,t,n){let r=new Map(e.map(e=>[e.id,e])),i=[];for(let e of t.keys()){let t=r.get(e);(!n||!t||t.readBy===`hand`)&&i.push(e)}return n?{start:e.filter(e=>HU.has(e.tool)&&e.readBy!==`hand`&&t.get(e.id)!==GU(e)),abort:i}:{start:[],abort:i}}function qU(e,t,n,r){let i={x0:Math.min(e.x0,e.x1),y0:Math.min(e.y0,e.y1),x1:Math.max(e.x0,e.x1),y1:Math.max(e.y0,e.y1)};if(e.tool===`marker`&&i.y1-i.y0<r){let e=(i.y0+i.y1)/2;i={...i,y0:e-r/2,y1:e+r/2}}e.angle&&e.tool!==`marker`&&(i=gU(i,e.angle));let a=Math.max(4,Math.round(Math.min(i.x1-i.x0,i.y1-i.y0)*.08)),o=Math.max(0,Math.floor(i.x0-a)),s=Math.max(0,Math.floor(i.y0-a)),c=Math.min(t,Math.ceil(i.x1+a)),l=Math.min(n,Math.ceil(i.y1+a));return c-o<2||l-s<2?null:{x:o,y:s,w:c-o,h:l-s}}function JU(e,t){return Math.min(4,WU/Math.max(e,t,1))}function YU(e){return(e??``).replace(/\s+/g,` `).trim()||null}function XU(e){let{canvasRef:t,imgRef:n,setShapes:r,genRef:i,readsRef:a}=e,o=(e,t)=>r(n=>n.map(n=>n.id===e?t(n):n));function s(e){a.current.get(e)?.ctl?.abort(),a.current.delete(e)}function c(){for(let e of[...a.current.keys()])s(e)}function l(e,t){let{start:n,abort:r}=KU(e,new Map([...a.current].map(([e,t])=>[e,t.key])),!!t);for(let e of r){let t=!!a.current.get(e)?.ctl;s(e),t&&o(e,e=>e.reading?{...e,reading:!1}:e)}if(t)for(let r of n)u(r,e,t)}async function u(e,t,n){s(e.id);let r=new AbortController,c={key:GU(e),ctl:r};a.current.set(e.id,c);let l=i.current;o(e.id,e=>({...e,reading:!0,readErr:void 0,...e.readBy===`phone`?{read:void 0,readBy:void 0}:{}}));let u=setTimeout(()=>r.abort(),UU),f=null,p=`no words found in this mark`;try{let i=await d(e,t);i?f=YU(await ZU(n.read(i,{signal:r.signal}),r.signal)):p=`this mark is too small to read`}catch{p=r.signal.aborted?`not read within ${UU/1e3} s`:`this phone could not read it`}finally{clearTimeout(u)}a.current.get(e.id)===c&&i.current===l&&(c.ctl=void 0,o(e.id,e=>e.readBy===`hand`?{...e,reading:!1}:f?{...e,reading:!1,read:f,readBy:`phone`,readErr:void 0}:{...e,reading:!1,read:void 0,readBy:void 0,readErr:p}))}async function d(e,r){let i=t.current,a=n.current;if(!i||!a)return null;let o=r.find(t=>t.id===e.id),s=qU(e,i.width,i.height,SU(i)*5*(o?.factor??1));if(!s)return null;let c=a,l=r.filter(e=>e.tool===`blur`);if(l.length){let e=document.createElement(`canvas`);e.width=i.width,e.height=i.height;let t=e.getContext(`2d`);if(!t)return null;t.drawImage(a,0,0);for(let n of l)PU(t,e,a,n);c=e}let u=JU(s.w,s.h),d=document.createElement(`canvas`);d.width=Math.max(1,Math.round(s.w*u)),d.height=Math.max(1,Math.round(s.h*u));let f=d.getContext(`2d`);return f?(f.imageSmoothingEnabled=!0,f.imageSmoothingQuality=`high`,f.drawImage(c,s.x,s.y,s.w,s.h,0,0,d.width,d.height),yA(d,`image/png`)):null}return{sync:l,abortAll:c}}function ZU(e,t){return t.aborted?Promise.reject(Error(`aborted`)):new Promise((n,r)=>{let i=()=>r(Error(`aborted`));t.addEventListener(`abort`,i,{once:!0}),e.then(e=>{t.removeEventListener(`abort`,i),n(e)},e=>{t.removeEventListener(`abort`,i),r(e)})})}function QU(e){let{source:t,repoId:n,facts:r,onUploaded:i,onDispatch:a,onPark:o,onSendAll:s,canvasRef:c,shapes:l,shapesRef:u,busy:d,setBusy:f,setErr:p,readTextRef:m,redraw:h}=e;function g(){let e=c.current;h(!0);let n=l.length>0,r=yA(e,`image/png`).then(e=>{if(!e)throw Error(`this device could not encode the marked-up image`);return e}),i=XH(t).replace(/\.[^.]+$/,``).replace(/[/\\]/g,`_`)||`image`;return{blob:r,name:n?`${i}-marked.png`:`${i}.png`,note:_(e.width,e.height),size:{w:e.width,h:e.height}}}function _(e,t){return dU(u.current.map(e=>({...e})).map(e=>({...e,read:m.current.get(e.id)??e.read})),e,t,r)||void 0}async function v(){let e=g();return{...e,blob:await e.blob}}async function y(e=`none`){if(c.current&&!d){if(q(e===`queue`?`action:image.queue`:`action:image.send`),p(null),a)f(!0),a(g(),e);else{f(!0);try{let{blob:e,name:t,note:r,size:a}=await v(),s=async()=>{let e=await Promise.resolve(r);return e?fU(e,a??null):void 0};if(o){let n=await o(e,t);if(n){i(n,await s());return}}try{let r=await H.uploadInbox(n,e,t);r.saved?.[0]&&iI(n,r.saved[0].relPath,r.saved[0].mtime),r.saved?.[0]?i(r.saved[0].relPath,await s()):p(r.skipped?.[0]?.error||`upload failed`)}catch(n){let r=o?await o(e,t):null;r?i(r,await s()):p(String(n))}}catch(e){p(String(e))}finally{f(!1)}}}}function b(e){c.current&&s&&!d&&(q(e===`queue`?`action:image.queue`:`action:image.send`),f(!0),p(null),s(g(),e))}return{send:y,sendAll:b}}function $U(e){let{canvasRef:t,genRef:n,redraw:r,setOcr:i,setOcrDraft:a,onText:o}=e;async function s(){let e=t.current;if(!e)return;q(`action:image.ocr`);let o=n.current;i({phase:`reading`}),r(!0);let s=await yA(e,`image/jpeg`,.92);if(o!==n.current)return;if(!s){i({phase:`error`,error:`this device could not encode the picture`});return}let c=await H.ocrImage(s);o===n.current&&(`error`in c?i({phase:`error`,error:c.error}):(a(c.text),i({phase:`ready`,engine:c.engine,ms:c.ms})))}function c(){i(null)}function l(e){let t=e.trim();t&&o&&(q(`action:image.ocr.send`),o(t))}return{readAll:s,closeOcr:c,sendText:l}}function eW(e){let t=(0,V.useRef)(null),[n,r]=(0,V.useState)(null);return(0,V.useEffect)(()=>{let n=t.current,i=e.current;if(!n||!i||typeof ResizeObserver>`u`)return;let a=new ResizeObserver(()=>{let e=n.getBoundingClientRect();r(WH({w:e.width,h:e.height},i.width?{w:i.width,h:i.height}:null))});return a.observe(n),a.observe(i),()=>a.disconnect()},[e]),{bodyRef:t,side:n}}function tW({source:e,repoId:t,index:n,total:r,facts:i,onUploaded:a,onDispatch:o,onPark:s,onSkip:c,onSendAll:l,onText:u,onClose:d}){let f=(0,V.useRef)(null),p=(0,V.useRef)(null),m=(0,V.useRef)(null),[h,g]=(0,V.useState)(`circle`),[_,v]=(0,V.useState)(qH[0]),[y,b]=(0,V.useState)(1),[x,S]=(0,V.useState)([]),C=(0,V.useRef)(x);C.current=x;let w=(0,V.useRef)(null),[T,E]=(0,V.useState)(!1),[D,O]=(0,V.useState)(null),k=(0,V.useRef)(D);k.current=D;let[A,j]=(0,V.useState)(null),M=(0,V.useRef)(A);M.current=A;let[N,P]=(0,V.useState)(null),[F,ee]=(0,V.useState)(()=>fa(R.annKnobs)),[te,ne]=(0,V.useState)(()=>fa(R.annHintHidden)),re=()=>{sa(R.annHintHidden,!0),ne(!0)},ie=(0,V.useRef)(F);ie.current=F;let ae=(0,V.useRef)(null),[oe,se]=(0,V.useState)(!1),[ce,le]=(0,V.useState)(null),[ue,de]=(0,V.useState)(!1),[fe,pe]=(0,V.useState)(null),me=(0,V.useRef)(null),[he,ge]=(0,V.useState)(null),[_e,ve]=(0,V.useState)(``),ye=(0,V.useRef)(null),be=(0,V.useRef)(1),xe=(0,V.useRef)(new Map),Se=(0,V.useRef)(0),[Ce,we]=(0,V.useState)(null),[Te,Ee]=(0,V.useState)(``),De=(0,V.useRef)(null),Oe=fy(),ke=(0,V.useRef)(new Map),[Ae,je]=(0,V.useState)(!1),[Me,Ne]=(0,V.useState)(null),[Pe,Fe]=(0,V.useState)(``),[Ie,Le]=(0,V.useState)(()=>zH(ma(R.annTools,null))),Re=e=>{Le(e),Ta(R.annTools,e)},[ze,Be]=(0,V.useState)(!1),{bodyRef:Ve,side:He}=eW(f),Ue=Ie.place===`auto`?He??`auto`:Ie.place,[We,Ge]=(0,V.useState)({k:1,tx:0,ty:0}),Ke=(0,V.useRef)(We);Ke.current=We;let qe=(0,V.useRef)({k:1,tx:0,ty:0}),Je=(0,V.useRef)(new Map),Ye=(0,V.useRef)(null);(0,V.useEffect)(()=>{let t=null,n=!1;S([]),Ne(null),Fe(``),Se.current++,we(null),O(null),j(null),P(null),ae.current=null,le(null),se(!1);let r=(e,t)=>{let n=f.current;n.width=e,n.height=t;let r=p.current?.getBoundingClientRect();if(r){let n=Math.min(r.width/e,r.height/t),i={k:n,tx:(r.width-e*n)/2,ty:(r.height-t*n)/2};qe.current=i,Ge(i)}Xe()},i=async e=>{try{let t=await createImageBitmap(e);return n?void 0:(m.current=t,r(t.width,t.height),!0)}catch{return!1}};return(async()=>{if(e instanceof File){if(await i(e))return;let a=new Image;t=URL.createObjectURL(e),a.onload=()=>{n||(m.current=a,r(a.naturalWidth,a.naturalHeight))},a.onerror=()=>!n&&le(`Can't decode this image format on this device.`),a.src=t}else try{let t=await fetch(e.url).then(e=>e.blob());await i(t)||le(`Can't load this image.`)}catch{le(`Can't load this image.`)}})(),()=>{n=!0,t&&URL.revokeObjectURL(t)}},[e]),(0,V.useEffect)(()=>{document.activeElement?.blur()},[]),(0,V.useEffect)(()=>{let e=p.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(()=>{let t=f.current,n=e.getBoundingClientRect();if(!t||!t.width||!t.height||n.width<1||n.height<1)return;let r=Math.min(n.width/t.width,n.height/t.height),i={k:r,tx:(n.width-t.width*r)/2,ty:(n.height-t.height*r)/2},a=Math.abs(Ke.current.k-qe.current.k)<=qe.current.k*.02;qe.current=i,a&&(Ke.current=i,Xe(),Ge(i))});return t.observe(e),()=>t.disconnect()},[]),(0,V.useEffect)(Xe,[x,ue,fe,D,T,A,F]),(0,V.useEffect)(()=>{!x.length&&T&&(E(!1),O(null),j(null))},[x.length,T]);function Xe(e=!1){let t=f.current,n=m.current;if(!t||!n)return;let r=t.getContext(`2d`);r.drawImage(n,0,0);let i=ae.current,a=i?C.current.map((e,t)=>t===i.i?i.live:e):C.current,o=w.current?[...a,w.current]:a;for(let e of o)PU(r,t,n,e);NU(r,t,lU(a,t.width,t.height)),ue&&AU(r,t,me.current?CU(me.current):fe);let s=k.current;!e&&!ue&&s!=null&&a[s]&&IU(r,t,a[s],Ke.current.k||1,ie.current,M.current)}function Ze(e){return wU(f.current,e)}let Qe={source:e,repoId:t,facts:i,onUploaded:a,onDispatch:o,onPark:s,onSendAll:l,canvasRef:f,wrapRef:p,imgRef:m,tool:h,setTool:g,color:_,setColor:v,factor:y,shapes:x,setShapes:S,shapesRef:C,dragRef:w,moveMode:T,setMoveMode:E,selected:D,setSelected:O,selectedRef:k,target:A,setTarget:j,targetRef:M,setMoveNote:P,setKnobs:ee,knobsRef:ie,moveRef:ae,busy:oe,setBusy:se,setErr:le,cropMode:ue,setCropMode:de,pendingCrop:fe,setPendingCrop:pe,cropDrag:me,pendingText:he,setPendingText:ge,textDraft:_e,setTextDraft:ve,textInputRef:ye,idRef:be,readTextRef:xe,genRef:Se,editRead:Ce,setEditRead:we,readDraft:Te,setReadDraft:Ee,readInputRef:De,setPaletteOpen:je,setView:Ge,viewRef:Ke,fitRef:qe,pointers:Je,gesture:Ye,redraw:Xe,clampToImage:Ze},$e=zU(Qe),et=VU(Qe),tt=BU(Qe),{send:nt,sendAll:rt}=QU(Qe),it=$U({canvasRef:f,genRef:Se,redraw:Xe,setOcr:Ne,setOcrDraft:Fe,onText:u}),at=XU({canvasRef:f,imgRef:m,setShapes:S,genRef:Se,readsRef:ke});(0,V.useEffect)(()=>at.sync(x,Oe),[x,Oe]),(0,V.useEffect)(()=>()=>at.abortAll(),[]);let ot=We.k>qe.current.k*1.02,st=[...x].reverse().find(e=>e.tool===`marker`||!!Oe&&(e.tool===`rect`||e.tool===`circle`));return{props:{index:n,total:r,onSkip:c,onSendAll:l,onDispatch:o,onText:u,onClose:d},canvasRef:f,wrapRef:p,tool:h,color:_,setColor:v,factor:y,setFactor:b,shapes:x,setShapes:S,moveMode:T,selected:D,setSelected:O,target:A,setTarget:j,moveNote:N,setMoveNote:P,knobs:F,busy:oe,err:ce,cropMode:ue,pendingCrop:fe,pendingText:he,textDraft:_e,setTextDraft:ve,textInputRef:ye,editRead:Ce,setEditRead:we,readDraft:Te,setReadDraft:Ee,readInputRef:De,paletteOpen:Ae,setPaletteOpen:je,view:We,fitRef:qe,layout:Ie,setLayout:Re,configOpen:ze,setConfigOpen:Be,bodyRef:Ve,place:Ue,moveRef:ae,zoomed:ot,lastBand:st,hintHidden:te,hideHint:re,...$e,...et,...tt,send:nt,sendAll:rt,ocr:Me,ocrDraft:Pe,setOcrDraft:Fe,...it}}function nW(e){let t=tW(e);Gh(t.ocr!==null,t.closeOcr);let{index:n,total:r,onClose:i}=e;return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{onClose:i,title:r&&r>1?`Mark & send · ${n??1}/${r}`:`Mark & send image`,children:(0,J.jsx)(jH,{m:t})}),e.prompt&&(0,J.jsx)(MH,{prompt:e.prompt}),(0,J.jsx)($H,{m:t}),t.ocr?(0,J.jsx)(eU,{m:t}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(SH,{m:t}),(0,J.jsx)(NH,{m:t})]})]})}var rW=6,iW=0;function aW(){if(iW)return iW;iW=4096;try{let e=document.createElement(`canvas`).getContext(`webgl`),t=e?.getParameter(e.MAX_TEXTURE_SIZE);typeof t==`number`&&t>0&&(iW=t)}catch{}return iW}function oW(e,t){let n=Math.max(e,t)*(window.devicePixelRatio||1);return n?Fp(aW()/n,2,rW):rW}function sW({src:e,alt:t,onNav:n,onError:r}){let i=(0,V.useRef)(null),a=(0,V.useRef)(null),[o,s]=(0,V.useState)({s:1,x:0,y:0}),[c,l]=(0,V.useState)(!1),u=(0,V.useRef)(o);u.current=o;let d=(0,V.useRef)(new Map),f=(0,V.useRef)(null),p=(0,V.useRef)(null),m=(0,V.useRef)(0),[h,g]=(0,V.useState)(null);(0,V.useEffect)(()=>{s({s:1,x:0,y:0})},[e]);function _(e,t=!1){let n=a.current,r=i.current,o=Number.isFinite(e.s)?Fp(e.s,1,rW):1;n&&n.offsetWidth&&(o=Math.min(o,oW(n.offsetWidth,n.offsetHeight)));let s=Number.isFinite(e.x)?e.x:0,c=Number.isFinite(e.y)?e.y:0;if(n&&r){let e=Math.max(0,(n.offsetWidth*o-r.clientWidth)/2),i=Math.max(0,(n.offsetHeight*o-r.clientHeight)/2);t||(s=Fp(s,-e,e)),c=Fp(c,-i,i)}return{s:o,x:s,y:c}}let v=()=>{let e=[...d.current.values()];return e.length>=2?e:null};function y(){let e=v();if(!e)return;let t=Math.hypot(e[0].x-e[1].x,e[0].y-e[1].y),n=i.current?.getBoundingClientRect(),r=n?n.left+n.width/2:0,a=n?n.top+n.height/2:0;f.current={dist:t||1,mx:(e[0].x+e[1].x)/2-r,my:(e[0].y+e[1].y)/2-a,s:u.current.s,x:u.current.x,y:u.current.y},p.current=null}function b(e){if(e.target.setPointerCapture?.(e.pointerId),d.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),l(!0),d.current.size>=2)y();else{let t=e.timeStamp;t-m.current<300?(s(e=>_(e.s>1?{s:1,x:0,y:0}:{s:2.5,x:0,y:0})),m.current=0):m.current=t,p.current={x:e.clientX,y:e.clientY,tx:u.current.x,ty:u.current.y}}}function x(e){let t=d.current.get(e.pointerId);if(!t)return;t.x=e.clientX,t.y=e.clientY;let r=v();if(r&&f.current){e.stopPropagation();let t=f.current,n=Math.hypot(r[0].x-r[1].x,r[0].y-r[1].y),a=i.current?.getBoundingClientRect(),o=(r[0].x+r[1].x)/2-(a?a.left+a.width/2:0),c=(r[0].y+r[1].y)/2-(a?a.top+a.height/2:0),l=Fp(t.s*n/t.dist,1,rW);s(_({s:l,x:o-(t.mx-t.x)*(l/t.s),y:c-(t.my-t.y)*(l/t.s)}))}else if(p.current&&u.current.s>1){e.stopPropagation();let t=p.current;s(n=>_({s:n.s,x:t.tx+(e.clientX-t.x),y:t.ty+(e.clientY-t.y)}))}else if(p.current&&n){let t=p.current;s(n=>({...n,x:t.tx+(e.clientX-t.x)}))}}function S(e){if(d.current.delete(e.pointerId),d.current.size<2&&(f.current=null),d.current.size===1){let[e]=[...d.current.values()];p.current={x:e.x,y:e.y,tx:u.current.x,ty:u.current.y}}if(d.current.size===0){if(l(!1),p.current&&u.current.s<=1&&n&&e.type!==`pointercancel`){let t=e.clientX-p.current.x,r=e.clientY-p.current.y;Math.abs(t)>60&&Math.abs(t)>Math.abs(r)*1.5&&n(t<0?1:-1)}s(e=>e.s<=1?{s:1,x:0,y:0}:_(e)),p.current=null}}let C=o.s>1.01;return(0,J.jsxs)(`div`,{ref:i,className:`zoom-stage`,onPointerDown:b,onPointerMove:x,onPointerUp:S,onPointerCancel:S,children:[h===e?(0,J.jsxs)(`div`,{className:`img-missing`,children:[(0,J.jsx)(no,{size:22}),(0,J.jsx)(`span`,{className:`img-missing-name`,children:t}),(0,J.jsx)(`span`,{children:`couldn’t load this image — the host may be unreachable`})]}):(0,J.jsx)(`img`,{ref:a,src:e,alt:t,draggable:!1,onLoad:()=>s(e=>_(e)),onError:()=>{g(e),r?.()},style:{transform:`translate(${o.x}px, ${o.y}px) scale(${o.s})`,willChange:c?`transform`:`auto`}}),C&&(0,J.jsxs)(`button`,{className:`zoom-reset`,"aria-label":`reset zoom`,onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),s({s:1,x:0,y:0})},children:[(0,J.jsx)(hs,{size:16}),` `,o.s.toFixed(1),`×`]})]})}function cW({items:e,index:t,onIndex:n,onAnnotate:r,onReference:i,onClose:a}){let o=e[t],[s,c]=(0,V.useState)(!1);(0,V.useEffect)(()=>{c(!1)},[t]);let l=r=>{let i=t+r;i>=0&&i<e.length&&n(i)};return(0,V.useEffect)(()=>{let e=e=>{e.key===`ArrowRight`?l(1):e.key===`ArrowLeft`?l(-1):e.key===`Escape`&&(e.preventDefault(),a())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)}),(0,V.useEffect)(()=>{o||a()},[o,a]),o?(0,J.jsxs)(`div`,{className:`viewer`,onClick:a,children:[(0,J.jsx)(`button`,{className:`viewer-close`,onClick:a,"aria-label":`close`,children:(0,J.jsx)(B,{size:22})}),(0,J.jsxs)(`div`,{className:`viewer-body`,onClick:e=>e.stopPropagation(),children:[o.video?(0,J.jsx)(`video`,{className:`viewer-video`,src:o.url,controls:!0,autoPlay:!0,playsInline:!0},o.relPath):(0,J.jsx)(sW,{src:s&&o.fullUrl?o.fullUrl:o.url,alt:o.name,onNav:e.length>1?l:void 0},`${o.relPath}:${s?`full`:`fit`}`),(0,J.jsx)(`div`,{className:`viewer-path mono`,children:o.relPath}),(0,J.jsxs)(`div`,{className:`sheet-actions`,children:[e.length>1&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Y,{onClick:()=>l(-1),disabled:t===0,"aria-label":`previous`,children:(0,J.jsx)(Ns,{size:16})}),(0,J.jsxs)(`span`,{className:`viewer-count`,children:[t+1,` / `,e.length]}),(0,J.jsx)(Y,{onClick:()=>l(1),disabled:t===e.length-1,"aria-label":`next`,children:(0,J.jsx)(Hs,{size:16})})]}),!o.video&&o.fullUrl&&o.fullUrl!==o.url&&!s&&(0,J.jsx)(Y,{title:`load the original file instead of the screen-sized copy`,onClick:()=>c(!0),children:`full res`}),!o.video&&r&&(0,J.jsxs)(Y,{onClick:()=>r(o),children:[(0,J.jsx)(Mo,{size:16}),` mark`]}),o.repoId&&(0,J.jsx)(gO,{target:{repoId:o.repoId,relPath:o.relPath,name:o.name},trackId:`action:swipe.download`}),(0,J.jsx)(`button`,{className:`send`,onClick:()=>i(o),children:`ref path`})]})]})]}):null}function lW(){let e=G(zz);return e?(0,J.jsx)(lH,{files:e.files,onCombine:mV,onSeparate:hV,onClose:gV}):null}function uW(){let e=G(Iz);return DH()&&!!e&&qz.ret===`session`&&!!U().world.active}function dW(){let e=G(Iz),t=uW();if(!e)return null;let n=qz.ret===`session`,r=!!e.total&&e.total>1,i=U(),a=n&&!t&&i.world.active?{value:i.compose.draft,onChange:e=>{U().compose.typeOn(U().compose.draft,e)||U().say.toast(`The message box changed meanwhile — that key was not applied`)}}:void 0;return(0,J.jsx)(nW,{prompt:a,source:e.source,repoId:e.repoId,index:e.index,total:e.total,facts:e.facts,onUploaded:TV,onDispatch:n?xV:void 0,onPark:bV,onSkip:r?SV:void 0,onSendAll:r&&n?CV:void 0,onText:EV,onClose:wV})}function fW(){let e=G(Bz),t=G(Gz);if(!e)return null;let n=e.sessionId?rB(t.get(e.sessionId)??[]):[],r=e.items??n.map(e=>({name:e.name,relPath:e.relPath,url:eB(e.relPath)?H.artifactUrl(e.repoId,e.relPath):$h(H.artifactUrl(e.repoId,e.relPath),Qh(),e.mtime),fullUrl:H.artifactUrl(e.repoId,e.relPath),video:eB(e.relPath)}));return(0,J.jsx)(cW,{items:r,index:Math.min(e.i,Math.max(0,r.length-1)),onIndex:e=>SB(t=>t&&{...t,i:e}),onAnnotate:e.revoke?void 0:e=>RV(e,n),onReference:e=>zV(e,n),onClose:OB})}var pW=[{label:`10m`,long:`10 minutes`,secs:600},{label:`4h`,long:`4 hours`,secs:14400},{label:`24h`,long:`24 hours`,secs:86400}];function mW(e){return e===`outbox`?14400:void 0}var hW=[{label:`images`,value:`image`},{label:`docs`,value:`doc`}],gW=4e5,_W={new:`new — not opened on this device yet`,opened:`opened in ${I.name} on this device`,downloaded:`downloaded to this phone`};function vW(e){if(!e)return``;let t=Date.now()-e,n=Math.floor(t/6e4);if(n<1)return`just now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function yW(e){return e?new Date(e).toLocaleString():``}var bW=(e,t)=>t.repoId??e,xW=(e,t,n)=>e===`inbox`?H.inboxUrl(bW(t,n),n.name):H.artifactUrl(bW(t,n),n.relPath),SW=(e,t,n)=>$h(xW(e,t,n),Zh(140),n.mtime),CW=(e,t,n,r)=>n?xW(e,t,r):$h(xW(e,t,r),Qh(),r.mtime),wW=e=>dD(e.relPath)&&(e.size??0)>=49152;function TW({openFile:e,onClose:t}){let[n,r]=(0,V.useState)(e?{...e,size:e.size??0,mtime:e.mtime??0,ctime:e.mtime??0}:null),i=(0,V.useRef)(!!e),a=e=>{i.current=!1,r(e)};return Gh(n!==null&&!i.current,()=>a(null)),{open:n,showFile:a,closeDoc:()=>{i.current?(i.current=!1,t()):a(null)}}}function EW({repoId:e,repos:t,initialScope:n,initialAllTime:r,initialNew:i}){let a=!!e,o=n??(a?`outbox`:`all`),[s,c]=(0,V.useState)(o),l=i?Math.max(1,Math.ceil((Date.now()-i.since)/1e3)):void 0,[u,d]=(0,V.useState)(l??(r?void 0:mW(o))),[f,p]=(0,V.useState)(!!l),m=e=>{c(e),d(mW(e)),P(60),p(!1)},[h,g]=(0,V.useState)(`all`),[_,v]=(0,V.useState)(``),[y,b]=(0,V.useState)([]),[x,S]=(0,V.useState)(!1),[C,w]=(0,V.useState)(!0),[T,E]=(0,V.useState)(null),[D,O]=(0,V.useState)(null),[k,A]=(0,V.useState)(null),[j,M]=(0,V.useState)(0),[N,P]=(0,V.useState)(60),F=(t??[]).map(e=>e.id).join(`,`),ee={kind:h,since:s===`inbox`?void 0:u},te=Ft(s,e,F);return(0,V.useEffect)(()=>{let t=!1,n=new AbortController,r=!1;w(!0),E(null),A(null);let i=(n,i,a)=>{if(!t&&(r=!0,b(n),S(i),w(!1),E(null),O(null),aI(n,e),!_.trim())){let e=a??{rows:n,cov:ee,truncated:i};jb(te,e.cov,e.rows,e.truncated)}},a=async n=>{let i=await Mb(te,ee);if(t||r)return!1;if(!i)return n&&w(!1),!1;let a=pt(i.rows,{...ee,query:_},pD,Date.now());return aI(a,e),b(a.slice(0,N)),S(a.length>N||i.exact&&i.truncated),O(i.savedAt),n&&w(!1),!0};a(!1);let o=e=>{t||a(!0).then(n=>{if(t)return;w(!1);let r=Qe(e)?`the host didn't answer`:String(e?.message||e||`request failed`);A(n?r:null),E(n?null:r)})};return s===`all`?H.search({query:_,kind:h,scope:`repo`,sinceSeconds:u,repoIds:F?F.split(`,`):void 0,limit:N,signal:n.signal}).then(e=>i(e.hits,e.truncated)).catch(o):s===`inbox`?(H.markInboxSeen(e),H.inbox(e,n.signal).then(e=>{let t=pt(e,{kind:h,query:_},pD,Date.now());i(t.slice(0,N),t.length>N,{rows:e,cov:{kind:`all`},truncated:!1})}).catch(o)):(s===`outbox`&&H.markOutboxSeen(e),H.artifacts(e,s,u,{query:_,kind:h,limit:N,signal:n.signal}).then(e=>i(e.files,e.truncated)).catch(o)),()=>{t=!0,n.abort()}},[e,F,s,u,h,_,j,N]),(0,V.useEffect)(()=>{D!=null||T||rR(y.filter(e=>dD(e.relPath)||fD(e.relPath)).slice(0,24).map(t=>SW(s,e,t)))},[y,D,T]),(0,V.useEffect)(()=>{P(60)},[u,h,_,e]),{singleRepo:a,scope:s,changeScope:m,since:u,setSince:d,newSecs:l,onNewCut:f,setOnNewCut:p,kind:h,setKind:g,query:_,setQuery:v,files:y,truncated:x,loading:C,loadErr:T,cachedAt:D,staleWhy:k,setReload:M,setLimit:P}}function DW({open:e,scope:t,repoId:n}){let[r,i]=(0,V.useState)(!1),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(null),[d,f]=(0,V.useState)(!1),[p,m]=(0,V.useState)(0);return(0,V.useEffect)(()=>{i(!1)},[e?.relPath,e?.repoId]),(0,V.useEffect)(()=>{e&&t!==`inbox`&&(kce(bW(n,e),e.relPath,e.mtime),m(e=>e+1))},[e?.relPath,e?.repoId,t]),(0,V.useEffect)(()=>{if(c(null),f(!1),u(null),!e||!yD(e.relPath)){o(null);return}let r=!1,i=!1,a=e.relPath,s=bW(n,e),l=e.mtime,d=l>0,p=async()=>{let e=d?await Wb(s,a,l):null;return r||i||!e?!1:(o({path:a,text:e.text,truncated:e.truncated}),u(e.savedAt),!0)};return p(),Kf(xW(t,n,e)).then(e=>e.ok?e.text():Promise.reject(Error(`HTTP ${e.status}`))).then(e=>{if(r)return;i=!0;let t={path:a,text:e.slice(0,gW),truncated:e.length>gW};o(t),u(null),d&&Ub(s,a,l,t.text,t.truncated)}).catch(e=>{r||p().then(t=>{r||t||(o(null),c(Qe(e)?`the host didn't answer, and this device has no saved copy`:String(e?.message||e)))})}),()=>{r=!0}},[e?.relPath,e?.repoId,t]),{fullRes:r,setFullRes:i,doc:a,docErr:s,docCachedAt:l,docRaw:d,setDocRaw:f,markTick:p,setMarkTick:m}}function OW(e,t,n){let r=n(t);return e.some(e=>n(e)===r)?e.filter(e=>n(e)!==r):[...e,t]}function kW(e){return e===0?`Tap the pictures to combine, in the order you want them numbered.`:e===1?`1 picked — tap one more: a combined picture needs at least two.`:`${e} picked, numbered in the order you tapped them.`}function AW(e){let[t,n]=(0,V.useState)(null),r=t=>`${e.repoOf(t)}:${t.relPath}`;return{picked:t,pickIndex:e=>t?t.findIndex(t=>r(t)===r(e)):-1,canPick:!!e.onCombine&&e.singleRepo&&e.files.filter(e=>dD(e.relPath)).length>=2,startPick:()=>{q(`action:gallery.pick`),n([])},cancelPick:()=>n(null),togglePicked:e=>{dD(e.relPath)&&n(t=>OW(t??[],e,r))},combinePicked:()=>{if(!t||t.length<2||!e.onCombine)return;q(`action:gallery.combine`);let r=t.map(t=>({url:e.urlFor(t),name:t.name,repoId:e.repoOf(t)}));n(null),e.onCombine(r)}}}function jW(e){let{repoId:t,openFile:n,onClose:r}=e,{open:i,showFile:a,closeDoc:o}=TW({openFile:n,onClose:r}),[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(null),d=e=>{u(e),window.setTimeout(()=>u(t=>t===e?null:t),4e3)},[f,p]=(0,V.useState)(new Set),m=e=>p(t=>t.has(e)?t:new Set(t).add(e)),[h,g]=(0,V.useState)([]);(0,V.useEffect)(()=>rO.subscribe(g),[]);let _=EW(e),{scope:v,files:y,loading:b,setReload:x}=_,S=DW({open:i,scope:v,repoId:t}),{fullRes:C,docRaw:w,markTick:T}=S,E=e=>e&&b?(0,J.jsxs)(J.Fragment,{children:[` `,(0,J.jsx)(Js,{size:12,className:`spin`})]}):null,D=e=>bW(t,e),O=e=>xW(v,t,e),k=e=>SW(v,t,e),A=e=>CW(v,t,C,e),j=e=>v===`inbox`||e.relPath.startsWith(`.claude/inbox/`),M=e=>{if(v===`inbox`)return null;let t=lO(D(e),e.relPath,e.mtime);return t===`new`&&v!==`outbox`?null:t},N=e=>{let t=D(e);return h.find(n=>n.item.repoId===t&&n.item.relPath===e.relPath&&Math.round(n.item.mtime)===Math.round(e.mtime))},P=e=>({repoId:D(e),relPath:e.relPath,name:e.name,size:e.size,mtime:e.mtime,repoName:e.repoName}),F=e=>{let t=VD(e);return t.phase===`have`||t.phase===`saved`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Ra,{size:11}),` on phone`]}):t.phase===`downloading`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Js,{size:11,className:`spin`}),` `,t.pct,`%`]}):t.phase===`failed`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(gs,{size:11}),` stopped`]}):t.phase===`idle`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Qa,{size:11}),` was here`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Qo,{size:11}),` queued`]})},ee=i?N(i):void 0,te=ee?.state===`done`?ee.item.id:null,[ne,re]=(0,V.useState)(null);(0,V.useEffect)(()=>{if(re(null),!te)return;let e=null,t=!1;return rO.objectUrl(te).then(n=>{n&&(t?URL.revokeObjectURL(n):(e=n,re(n)))}),()=>{t=!0,e&&URL.revokeObjectURL(e)}},[te]);let ie=e=>ne??A(e),ae=e=>ne??O(e),oe=!!i&&gD(i.relPath)&&!w,se=y.filter(e=>dD(e.relPath)),ce=i?se.findIndex(e=>e.relPath===i.relPath&&e.repoId===i.repoId):-1;function le(e){let t=ce>=0?se[ce+e]:void 0;t&&a(t)}(0,V.useEffect)(()=>{if(!i)return;let e=e=>{e.key===`ArrowRight`?le(1):e.key===`ArrowLeft`?le(-1):e.key===`Escape`&&(e.preventDefault(),o())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)});async function ue(e){try{return await H.deleteInbox(D(e),e.name),x(e=>e+1),!0}catch(t){return d(Qe(t)?`Could not delete ${e.name} — the host didn't answer. The file is still on the desktop.`:`Could not delete ${e.name} — ${String(t?.message||t)}`),!1}}async function de(e){q(`action:gallery.delete`),await ue(e)&&a(null)}let fe=AW({onCombine:e.onCombine,singleRepo:_.singleRepo,files:y,repoOf:D,urlFor:O});async function pe(e){let t=await Xf(e);c(t?e:null),setTimeout(()=>c(null),1500)}return{props:e,..._,...S,open:i,showFile:a,closeDoc:o,copied:s,note:l,badSrc:f,markBad:m,busyMark:E,repoOf:D,urlFor:O,thumbFor:k,canFullRes:wW,isInboxFile:j,markOf:M,pullOf:N,dlTarget:P,pullBadge:F,localUrl:ne,mediaSrc:ie,fileSrc:ae,htmlLive:oe,imgs:se,openIdx:ce,nav:le,removeInbox:ue,del:de,copy:pe,...fe}}function MW(e,t,n,r){let i=`${e} new since you last looked`;return n||t===e?i:r?`${i} · newest ${t} shown`:`${i} · ${t} still here`}function NW(e){let t=pW.find(t=>t.secs===e);return t?`Nothing from the last ${t.long}.`:null}function PW({m:e}){let{scope:t,loading:n,singleRepo:r,changeScope:i,kind:a,setKind:o,since:s,setSince:c,newSecs:l,onNewCut:u,setOnNewCut:d}=e,{initialNew:f}=e.props,p=(e,r)=>(0,J.jsxs)(`button`,{className:`seg${t===e?` on`:``}${t===e&&n?` busy`:``}`,"aria-pressed":t===e,onClick:()=>i(e),children:[r,t===e&&n?(0,J.jsx)(Js,{size:13,className:`spin`}):null]}),m=(e,t,r,i)=>(0,J.jsx)(zw,{on:e,busy:e&&n,title:i,onClick:r,children:t}),h=()=>{c(void 0),d(!1)};return(0,J.jsxs)(J.Fragment,{children:[r&&(0,J.jsxs)(`div`,{className:`segmented gallery-scope`,children:[p(`inbox`,`inbox`),p(`outbox`,`outbox`),p(`repo`,`this repo`),p(`all`,`all repos`)]}),(0,J.jsxs)(`div`,{className:`fchips gallery-filters`,children:[hW.map(e=>(0,J.jsx)(V.Fragment,{children:m(a===e.value,e.label,()=>o(a===e.value?`all`:e.value))},e.value)),t!==`inbox`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`fchips-gap`,"aria-hidden":!0}),l!==void 0&&m(u,`${f.count} new`,()=>{u?h():(c(l),d(!0))},`the ${f.count} file${f.count>1?`s`:``} added since you last opened this outbox — the badge you tapped`),pW.map(e=>(0,J.jsx)(V.Fragment,{children:m(!u&&s===e.secs,e.label,()=>{!u&&s===e.secs?h():(c(e.secs),d(!1))},`only files from the last ${e.long}`)},e.label))]})]})]})}function FW({m:e}){let{scope:t,loading:n,files:r,truncated:i,query:a,setQuery:o,singleRepo:s,setSince:c,onNewCut:l,setOnNewCut:u,loadErr:d,setReload:f,cachedAt:p,staleWhy:m,note:h,open:g}=e,{onClose:_,onSweep:v,onSurvey:y,initialNew:b}=e.props,x=r.length;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(Uw,{title:`Images & documents`,onClose:_,children:[(x>0||n)&&(0,J.jsx)(`span`,{className:`gallery-meta`,title:ha()?void 0:`build 39b9d075`,children:n&&!x?(0,J.jsx)(Js,{size:12,className:`spin`}):`${x}${i?`+`:``} file${x===1&&!i?``:`s`}`}),v&&s&&(t===`inbox`||t===`outbox`)&&(0,J.jsx)(Y,{className:`gallery-head-btn`,title:`clear out old ${t} files`,"aria-label":`clear out old ${t} files`,onClick:()=>v(t),children:(0,J.jsx)(ws,{size:17})}),y&&t===`all`&&(0,J.jsx)(Y,{className:`gallery-head-btn`,title:`what is taking space, repo by repo`,"aria-label":`what is taking space`,onClick:y,children:(0,J.jsx)(Ba,{size:17})})]}),(0,J.jsx)(`div`,{className:`form`,children:(0,J.jsxs)(`div`,{className:`search-row`,children:[(0,J.jsx)(rc,{size:16}),(0,J.jsx)(`input`,{className:`search`,placeholder:t===`all`?`Search every repo by name`:`Search by name`,value:a,onChange:e=>o(e.target.value)}),a&&(0,J.jsx)(Y,{"aria-label":`clear the search`,onClick:()=>o(``),children:(0,J.jsx)(B,{size:14})})]})}),(0,J.jsx)(PW,{m:e}),l&&(0,J.jsx)(Pw,{onClear:()=>{c(void 0),u(!1)},clearLabel:`show all`,children:MW(b.count,x,n,i)}),d&&(0,J.jsxs)(`div`,{className:`gallery-note err`,children:[(0,J.jsx)(gs,{size:14}),(0,J.jsxs)(`span`,{children:[`Could not load the list (`,d,`)`,x?` — showing what was already loaded`:``,`.`]}),(0,J.jsxs)(Y,{onClick:()=>f(e=>e+1),children:[(0,J.jsx)(xc,{size:14}),` retry`]})]}),p!=null&&(0,J.jsxs)(`div`,{className:`gallery-note`,children:[(0,J.jsx)(fo,{size:14}),(0,J.jsx)(`span`,{children:m?`Showing the list this phone last saw, ${vW(p)} — ${m}.`:`Showing the list this phone last saw, ${vW(p)} — refreshing…`}),m&&(0,J.jsxs)(Y,{onClick:()=>f(e=>e+1),children:[(0,J.jsx)(xc,{size:14}),` retry`]})]}),h&&!g&&(0,J.jsx)(`div`,{className:`gallery-note`,children:h})]})}var IW=[[/^(md|markdown|txt|log|rst|pdf)$/,Fs],[/^(html?|json|ya?ml|toml|xml|js|mjs|ts|tsx|css|sh|py|diff|patch)$/,sne],[/^(csv|tsv|xlsx?|ods)$/,Ws],[/^(zip|tar|gz|tgz|7z|rar)$/,yl],[/^(apk|aab|ipa)$/,Vo],[/^(mp3|m4a|wav|ogg|opus|flac|aac)$/,ec]];function LW({name:e}){let t=e.lastIndexOf(`.`),n=t>0?e.slice(t+1).toLowerCase():``,r=IW.find(([e])=>e.test(n))?.[1]??gc;return(0,J.jsxs)(`span`,{className:`doc`,"aria-hidden":!0,children:[(0,J.jsx)(r,{size:30,strokeWidth:1.5}),n&&(0,J.jsx)(`span`,{className:`doc-ext`,children:n})]})}function RW({url:e,name:t,missing:n,onMissing:r}){let{src:i,live:a}=aR(e);return n?(0,J.jsxs)(`span`,{className:`img-missing`,children:[(0,J.jsx)(no,{size:18}),(0,J.jsx)(`span`,{className:`img-missing-name`,children:t})]}):i?(0,J.jsx)(`img`,{src:i,alt:t,loading:`lazy`,decoding:`async`,onLoad:()=>{a&&QL(e)},onError:r}):(0,J.jsx)(`span`,{className:`thumb-blank`})}function zW({src:e,poster:t,name:n}){let{src:r,live:i}=aR(t);return(0,V.useEffect)(()=>{i&&QL(t)},[i,t]),(0,J.jsx)(`video`,{src:e,poster:r??void 0,title:n,muted:!0,playsInline:!0,preload:`none`})}function BW({m:e}){let{picked:t,canPick:n,startPick:r,cancelPick:i,combinePicked:a}=e;return t?(0,J.jsxs)(`div`,{className:`annot-tools gallery-pick on`,children:[(0,J.jsx)(`span`,{className:`viewer-doc-note`,children:kW(t.length)}),(0,J.jsxs)(Y,{onClick:i,children:[(0,J.jsx)(B,{size:14}),` cancel`]}),t.length>=2&&(0,J.jsxs)(`button`,{className:`send`,onClick:a,children:[(0,J.jsx)(Za,{size:14}),` combine `,t.length]})]}):n?(0,J.jsx)(`div`,{className:`annot-tools gallery-pick`,children:(0,J.jsxs)(Y,{"aria-label":`pick pictures to combine`,onClick:r,children:[(0,J.jsx)(Za,{size:14}),` combine pictures…`]})}):null}function VW({m:e}){let{files:t,loading:n,loadErr:r,query:i,kind:a,scope:o,truncated:s,showFile:c,badSrc:l,markBad:u,urlFor:d,thumbFor:f,markOf:p,pullOf:m,pullBadge:h,isInboxFile:g,removeInbox:_,setLimit:v,onNewCut:y,since:b,setSince:x,setOnNewCut:S}=e,C=e=>y&&p(e)===`new`?null:p(e),w=o!==`inbox`&&!y?NW(b):null,{picked:T,pickIndex:E,togglePicked:D}=e;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(BW,{m:e}),(0,J.jsxs)(`div`,{className:`grid${n&&t.length?` stale`:``}`,children:[t.map(e=>(0,J.jsxs)(`div`,{className:`thumb-wrap${E(e)>=0?` picked`:``}`,children:[T&&E(e)>=0&&(0,J.jsx)(`span`,{className:`thumb-pick`,"aria-hidden":`true`,children:E(e)+1}),(0,J.jsxs)(`button`,{className:`thumb`,"aria-pressed":T&&dD(e.relPath)?E(e)>=0:void 0,onClick:()=>T?D(e):c(e),children:[dD(e.relPath)?(0,J.jsx)(RW,{url:f(e),name:e.name,missing:l.has(f(e)),onMissing:()=>u(f(e))}):fD(e.relPath)?(0,J.jsx)(zW,{src:d(e),poster:f(e),name:e.name}):(0,J.jsx)(LW,{name:e.name}),(0,J.jsx)(`span`,{className:`thumb-name`,children:e.name}),(0,J.jsxs)(`span`,{className:`thumb-date`,title:yW(e.ctime??e.mtime),children:[vW(e.ctime??e.mtime),e.size?(0,J.jsxs)(`span`,{className:`thumb-size`,children:[` · `,yp(e.size)]}):null]}),e.repoName&&(0,J.jsx)(`span`,{className:`thumb-repo`,children:e.repoName}),(0,J.jsxs)(`span`,{className:`thumb-badges`,children:[C(e)&&!m(e)&&(0,J.jsx)(`span`,{className:`thumb-mark ${C(e)}`,title:_W[C(e)],children:C(e)===`new`?(0,J.jsx)(`span`,{className:`sr-only`,children:`new`}):C(e)===`downloaded`?(0,J.jsx)(Qa,{size:11}):(0,J.jsx)(hl,{size:11})}),m(e)&&(0,J.jsx)(`span`,{className:`thumb-pull ${m(e).state}`,title:VD(m(e)).detail,children:h(m(e))})]})]}),g(e)&&(0,J.jsx)(fC,{className:`thumb-del`,title:`delete ${e.name}`,confirmTitle:`tap again to delete ${e.name}`,confirm:(0,J.jsx)(gs,{size:14}),onConfirm:()=>{_(e)},children:(0,J.jsx)(ws,{size:14})})]},`${e.repoId??``}:${e.relPath}`)),t.length===0&&n&&Array.from({length:8},(e,t)=>(0,J.jsx)(`div`,{className:`thumb-wrap`,children:(0,J.jsx)(`div`,{className:`thumb skel-thumb`})},`skel-${t}`)),t.length===0&&!n&&!r&&(0,J.jsx)($,{children:i||a!==`all`?`No matches.`:w?(0,J.jsxs)(J.Fragment,{children:[w,` `,(0,J.jsx)(`button`,{className:`link-btn`,onClick:()=>{x(void 0),S(!1)},children:`show older files`})]}):o===`outbox`?`The outbox is empty. Claude puts screenshots and files meant for your phone in .claude/outbox. To see images anywhere in the repo, switch to this repo.`:`Nothing here yet.`})]}),s&&(0,J.jsxs)(`div`,{className:`annot-tools`,children:[(0,J.jsxs)(Y,{onClick:()=>{q(`action:gallery.more`),v(e=>e+60)},children:[`load `,60,` more`]}),(0,J.jsxs)(`span`,{className:`viewer-doc-note`,children:[`showing the newest `,t.length]})]})]})}function HW(e,t){if(!t)return e;let n=e.toLowerCase(),r=t.toLowerCase();if(!n.includes(r))return e;let i=[],a=0,o=n.indexOf(r),s=0;for(;o!==-1;)o>a&&i.push(e.slice(a,o)),i.push((0,J.jsx)(`mark`,{className:`tr-hit`,children:e.slice(o,o+t.length)},s++)),a=o+t.length,o=n.indexOf(r,a);return a<e.length&&i.push(e.slice(a)),i}var UW=132;function WW({fref:e,ctx:t,q:n,wide:r,opens:i}){let[a,o]=(0,V.useState)(!1),s=cI(t.repoId,e.relPath),c=r?/\.gif$/i.test(e.relPath)?void 0:Qh():Zh(UW),l=e.image&&!a?t.url(e.relPath,c,s):null,{src:u,live:d}=aR(l);return l?(0,J.jsxs)(`button`,{type:`button`,className:`fileref fileref-img${r?` fileref-wide`:``}`,title:`${i??e.relPath} — tap to open`,onClick:()=>t.open(i??e.relPath),children:[u&&(0,J.jsx)(`img`,{src:u,alt:e.name,loading:`lazy`,onLoad:()=>{d&&s&&c&&QL(l)},onError:()=>o(!0)}),(0,J.jsx)(`span`,{className:`fileref-name`,children:HW(e.raw,n)})]}):(0,J.jsxs)(`button`,{type:`button`,className:`fileref`,title:`${e.relPath} — tap to open`,onClick:()=>t.open(e.relPath),children:[(0,J.jsx)(Fs,{size:12}),HW(e.raw,n)]})}var GW=RegExp(`\`([^\`\\n]+)\`|\\*\\*([^*]+)\\*\\*|\\*([^*\\s](?:[^*]*[^*\\s])?)\\*|\\[([^\\]]+)\\]\\(([^)\\s]+)\\)|(https?://[^\\s<>()"']+)|(${iL})`,`g`);function KW(e,t,n,r,i){if(/^(?:https?:|mailto:)/i.test(e))return(0,J.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,children:HW(t,n)},r);let a=i?.docPath==null?null:gL(e,i.docPath);if(a?.kind===`file`&&i){let e=a.relPath;return(0,J.jsx)(`button`,{type:`button`,className:`md-link`,title:e,onClick:()=>i.open(e),children:HW(t,n)},r)}return a?.kind===`anchor`&&i?.slugs?.has(a.slug)?(0,J.jsx)(`button`,{type:`button`,className:`md-link`,onClick:e=>qW(e.currentTarget,a.slug),children:HW(t,n)},r):t.trim()===e.trim()?(0,J.jsx)(`code`,{children:HW(e,n)},r):(0,J.jsxs)(`span`,{children:[HW(t,n),` `,(0,J.jsx)(`code`,{children:e})]},r)}function qW(e,t){let n=`[data-slug="${CSS.escape(t)}"]`;for(let t=e.parentElement;t;t=t.parentElement){let e=t.querySelector(n);if(e){e.scrollIntoView({behavior:`smooth`,block:`start`});return}}}function JW(e,t,n,r){let i=[],a=0,o=0,s=new RegExp(GW),c=(e,n)=>{if(!r)return null;let i=cL(e);return i?{node:(0,J.jsx)(WW,{fref:i,ctx:r,q:t},n),rest:e.slice(i.raw.length)}:null};for(let l=s.exec(e);l;l=s.exec(e)){let s=l[4]!==void 0&&e[l.index-1]===`!`&&l.index>a;if(l.index>a){let r=e.slice(a,l.index);s&&(r=r.slice(0,-1)),r&&i.push((0,J.jsx)(`span`,{children:HW(r,t)},`${n}t${o++}`))}if(l[1]!==void 0){let e=lL(l[1])?null:pL(l[1],r?.known),a=lL(l[1])?c(l[1].trim(),`${n}f${o++}`):e&&r?{node:(0,J.jsx)(WW,{fref:e,ctx:r,q:t},`${n}f${o++}`),rest:``}:null;i.push(a?a.node:(0,J.jsx)(`code`,{children:HW(l[1],t)},`${n}c${o++}`))}else if(l[2]!==void 0)i.push((0,J.jsx)(`b`,{children:JW(l[2],t,`${n}b${o}`,r)},`${n}b${o++}`));else if(l[3]!==void 0)i.push((0,J.jsx)(`i`,{children:JW(l[3],t,`${n}i${o}`,r)},`${n}i${o++}`));else if(l[4]!==void 0){let e=lL(l[5])?c(l[5],`${n}f${o++}`):null,a=!e&&s&&r?.docPath!=null?mL(l[5],r.docPath):null;i.push(e?e.node:a&&r?(0,J.jsx)(WW,{fref:{...a,raw:l[4]},ctx:r,q:t,wide:!0},`${n}f${o++}`):KW(l[5],l[4],t,`${n}a${o++}`,r))}else if(l[6]!==void 0)i.push((0,J.jsx)(`a`,{href:l[6],target:`_blank`,rel:`noreferrer`,children:HW(l[6],t)},`${n}u${o++}`));else{let e=c(l[7],`${n}f${o++}`);e?(i.push(e.node),e.rest&&i.push((0,J.jsx)(`span`,{children:HW(e.rest,t)},`${n}t${o++}`))):i.push((0,J.jsx)(`span`,{children:HW(l[7],t)},`${n}t${o++}`))}a=l.index+l[0].length}return a<e.length&&i.push((0,J.jsx)(`span`,{children:HW(e.slice(a),t)},`${n}t${o++}`)),i}function YW(e,t,n,r){if(r?.docPath==null||!/\[!\[|<(?:a|img|p|div|br|center)\b|<\/(?:p|div|center)>/i.test(e))return JW(e,t,n,r);e=e.replace(/<\/?(?:p|div|center)\b[^>]*>|<br\s*\/?>/gi,` `).trim();let i=[],a=0,o=0;for(let s of wL(e)){let c=mL(s.src,r.docPath);if(!c?.image||s.at<a)continue;s.at>a&&i.push(...JW(e.slice(a,s.at),t,`${n}l${o}`,r));let l=mL(s.href,r.docPath);i.push((0,J.jsx)(WW,{fref:{...c,raw:s.alt},ctx:r,q:t,wide:!0,opens:l?.relPath},`${n}v${o++}`)),a=s.end}return a<e.length&&i.push(...JW(e.slice(a),t,`${n}l${o}`,r)),i}function XW(e){let t=e.trim(),n=[],r=``;for(let e=0;e<t.length;e++){let i=t[e];i===`\\`&&t[e+1]===`|`?(r+=`|`,e++):i===`|`?(n.push(r),r=``):r+=i}return n.push(r),n.length&&!n[0].trim()&&t.startsWith(`|`)&&n.shift(),n.length&&!n[n.length-1].trim()&&t.endsWith(`|`)&&n.pop(),n.map(e=>e.trim())}function ZW(e){if(!e.includes(`|`)||!e.includes(`-`))return null;let t=XW(e);if(!t.length)return null;let n=[];for(let e of t){if(!/^:?-+:?$/.test(e))return null;n.push(e.startsWith(`:`)&&e.endsWith(`:`)?`center`:e.endsWith(`:`)?`right`:`left`)}return n}function QW({src:e,q:t,onCopy:n,files:r}){let[i,a]=(0,V.useState)(!1);return(0,J.jsxs)(`div`,{className:`tr-code tr-mdsnip`,children:[(0,J.jsxs)(`div`,{className:`tr-code-head`,children:[(0,J.jsx)(`span`,{children:`markdown`}),(0,J.jsxs)(`span`,{className:`tr-code-acts`,children:[(0,J.jsx)(Y,{onClick:()=>a(e=>!e),children:i?`rendered`:`source`}),(0,J.jsx)(Y,{title:`copy`,onClick:()=>n(e),children:(0,J.jsx)(_o,{size:12})})]})]}),i?(0,J.jsx)(`pre`,{children:HW(e,t)}):(0,J.jsx)(`div`,{className:`tr-mdsnip-body`,children:(0,J.jsx)(eG,{src:e,q:t,onCopy:n,files:r})})]})}function $W(e){let t=new Set;return e.forEach((e,n)=>{if(!(n%2))for(let n of e.matchAll(/^#{1,6}\s+(.*?)\s*$/gm))t.add(_L(n[1]))}),t}function eG({src:e,q:t,onCopy:n,files:r,lineTag:i}){let a=[],o=e.split(/```/).map((e,t)=>t%2?e:vL(e));r?.docPath!=null&&!r.slugs&&(r={...r,slugs:$W(o)});let s=0,c=(e,t,n)=>{if(!i)return{className:n};let r=i(e+1,t+1);return{className:[n,r.className].filter(Boolean).join(` `)||void 0,"data-l0":e+1,"data-l1":t+1,"data-n":r.badge}};return o.forEach((e,o)=>{let l=s;if(s+=e.split(`
14
+ `).length-1,o%2==1){let u=e.indexOf(`
15
+ `),d=u===-1?``:e.slice(0,u).trim(),f=(u===-1?e:e.slice(u+1)).replace(/\n$/,``);if(/^(md|markdown|mdx)$/i.test(d)){let e=(0,J.jsx)(QW,{src:f,q:t,onCopy:n,files:r},`m${o}`);a.push(i?(0,J.jsx)(`div`,{...c(l,s,`tr-mdsnip-wrap`),children:e},`m${o}`):e);return}a.push((0,V.createElement)(`div`,{...c(l,s,`tr-code`),key:`c${o}`},(0,J.jsxs)(`div`,{className:`tr-code-head`,children:[(0,J.jsx)(`span`,{children:d||`code`}),(0,J.jsx)(Y,{title:`copy code`,onClick:()=>n(f),children:(0,J.jsx)(_o,{size:12})})]}),(0,J.jsx)(`pre`,{children:HW(f,t)})));return}let u=e.split(`
16
+ `),d=[],f=0,p=null,m=e=>{if(!d.length)return;let n=d.join(`
17
+ `);a.push((0,V.createElement)(`p`,{...c(l+f,l+f+d.length-1,`tr-p`),key:e},YW(n,t,e,r))),d=[]},h=e=>{if(!p)return;let n=p,o=n.items.map((a,o)=>(0,V.createElement)(`li`,{...i?c(l+n.at[o],l+n.to[o],``):{},key:o},YW(a,t,`${e}i${o}`,r)));a.push(n.ordered?(0,J.jsx)(`ol`,{className:`tr-list`,children:o},e):(0,J.jsx)(`ul`,{className:`tr-list`,children:o},e)),p=null};for(let e=0;e<u.length;e++){let i=`${o}-${e}`,s=u[e].replace(/\s+$/,``),g=s.includes(`|`)?ZW(u[e+1]??``):null;if(g){m(`p${i}`),h(`l${i}`);let n=XW(s),o=[],d=e+2;for(;d<u.length&&u[d].includes(`|`);d++)o.push(XW(u[d]));let f=Math.max(n.length,...o.map(e=>e.length)),p=(e,t)=>e[t]??``;a.push((0,V.createElement)(`div`,{...c(l+e,l+d-1,`tr-table-wrap`),key:`tw${i}`},(0,J.jsxs)(`table`,{className:`tr-table`,children:[(0,J.jsx)(`thead`,{children:(0,J.jsx)(`tr`,{children:Array.from({length:f},(e,a)=>(0,J.jsx)(`th`,{style:{textAlign:g[a]??`left`},children:JW(p(n,a),t,`th${i}-${a}`,r)},a))})}),(0,J.jsx)(`tbody`,{children:o.map((e,n)=>(0,J.jsx)(`tr`,{children:Array.from({length:f},(a,o)=>(0,J.jsx)(`td`,{style:{textAlign:g[o]??`left`},children:JW(p(e,o),t,`td${i}-${n}-${o}`,r)},o))},n))})]}))),e=d-1;continue}let _=/^(#{1,6})\s+(.*)$/.exec(s),v=/^\s*[-*+]\s+(.*)$/.exec(s),y=/^\s*\d+[.)]\s+(.*)$/.exec(s),b=/^>\s?(.*)$/.exec(s);if(_)m(`p${i}`),h(`l${i}`),a.push((0,V.createElement)(`div`,{...c(l+e,l+e,`tr-h tr-h${_[1].length}`),"data-slug":r?.slugs?_L(_[2]):void 0,key:`h${i}`},JW(_[2],t,`h${i}`,r)));else if(v||y){m(`p${i}`);let t=!!y,n=(v??y)[1];p&&p.ordered!==t&&h(`l${i}`),p??={ordered:t,items:[],at:[],to:[]},p.items.push(n),p.at.push(e),p.to.push(e)}else if(b){m(`p${i}`),h(`l${i}`);let o=[b[1]],s=e+1;for(let e;s<u.length&&(e=/^>\s?(.*)$/.exec(u[s].replace(/\s+$/,``)));s++)o.push(e[1]);a.push((0,V.createElement)(`blockquote`,{...c(l+e,l+s-1,`tr-quote`),key:`q${i}`},(0,J.jsx)(eG,{src:o.join(`
18
+ `),q:t,onCopy:n,files:r}))),e=s-1}else if(!s.trim())m(`p${i}`),h(`l${i}`);else if(p&&/^\s/.test(s)){let t=p.items.length-1;p.items[t]+=`
19
+ `+s.trim(),p.to[t]=e}else h(`l${i}`),d.length||(f=e),d.push(s)}m(`pe${o}`),h(`le${o}`)}),(0,J.jsx)(J.Fragment,{children:a})}function tG(e){let{onContinueInSession:t,sessionsIn:n}=e.props;return t&&n?n(e.repoId):[]}function nG(e,t){q(t?`action:gallery.toSession`:`action:gallery.toNewSession`),e.setPicking(!1),e.props.onContinueInSession?.(e.relPath,e.repoId,t)}function rG(e){if(!e.props.onContinueInSession)return null;let t=tG(e);return(0,J.jsxs)(J.Fragment,{children:[t.length===1&&(0,J.jsxs)(Y,{title:`put this file's path in that session's prompt`,onClick:()=>nG(e,t[0].id),children:[(0,J.jsx)(zo,{size:16}),` `,t[0].label]}),t.length>1&&(0,J.jsxs)(Y,{title:`pick which live session gets this file's path`,onClick:()=>e.setPicking(!e.picking),children:[(0,J.jsx)(zo,{size:16}),` session · `,t.length]}),(0,J.jsxs)(Y,{title:`start a new session in this repo with this file's path in its prompt`,onClick:()=>nG(e,null),children:[(0,J.jsx)(Fo,{size:16}),` new session`]})]})}function iG(e){let t=tG(e);return!e.picking||t.length<2?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`viewer-doc-note`,children:[t.length,` live sessions in `,e.repoName||`this repo`,` — the path goes into the prompt of the one you pick`]}),(0,J.jsx)(`div`,{className:`list`,children:t.map(t=>(0,J.jsxs)(Xw,{as:`button`,onClick:()=>nG(e,t.id),children:[(0,J.jsxs)(Zw,{children:[(0,J.jsx)(qa,{size:14}),` `,t.label]}),t.onScreen&&(0,J.jsx)(Q,{children:`on screen behind the gallery`})]},t.id))})]})}function aG({m:e}){let{open:t,closeDoc:n,repoOf:r,localUrl:i,fullRes:a,mediaSrc:o,fileSrc:s,imgs:c,nav:l,setDocRaw:u,docRaw:d,doc:f,docErr:p,docCachedAt:m,htmlLive:h,pullOf:g,dlTarget:_,files:v,showFile:y,openIdx:b,copied:x,copy:S,canFullRes:C,setFullRes:w,urlFor:T,setMarkTick:E,isInboxFile:D,del:O,note:k}=e,{onAnnotate:A,onInsertPath:j,onClose:M}=e.props,[N,P]=(0,V.useState)(null);if(!t)return null;let F={relPath:t.relPath,repoId:r(t),repoName:t.repoName,props:e.props,picking:N===t.relPath,setPicking:e=>P(e?t.relPath:null)};return(0,J.jsxs)(`div`,{className:`viewer`,onClick:()=>n(),children:[(0,J.jsx)(`button`,{className:`viewer-close`,onClick:()=>n(),"aria-label":`close`,children:(0,J.jsx)(B,{size:22})}),(0,J.jsxs)(`div`,{className:`viewer-body`,onClick:e=>e.stopPropagation(),children:[dD(t.relPath)?(0,J.jsx)(sW,{src:o(t),alt:t.name,onNav:c.length>1?l:void 0},`${r(t)}:${t.relPath}:${i?`local`:a?`full`:`fit`}`):fD(t.relPath)?(0,J.jsx)(`video`,{className:`viewer-video`,src:s(t),controls:!0,autoPlay:!0,playsInline:!0},`${r(t)}:${t.relPath}:${i?`local`:`net`}`):yD(t.relPath)?(0,J.jsxs)(`div`,{className:`viewer-doc`,children:[_D(t.relPath)&&(0,J.jsxs)(`div`,{className:`viewer-doc-bar`,children:[(0,J.jsx)(Y,{onClick:()=>u(e=>!e),children:d?`rendered`:`source`}),f?.truncated&&!h&&(0,J.jsxs)(`span`,{className:`viewer-doc-note`,children:[`showing the first `,400,` KB — download for the rest`]}),m!=null&&!h&&(0,J.jsxs)(`span`,{className:`viewer-doc-note`,children:[(0,J.jsx)(fo,{size:12}),` saved copy from `,vW(m)]})]}),h?(0,J.jsx)(`iframe`,{className:`viewer-html`,src:s(t),title:t.name,sandbox:`allow-scripts`,referrerPolicy:`no-referrer`},`${r(t)}:${t.relPath}:${i?`local`:`net`}`):p?(0,J.jsxs)($,{children:[`Could not load this file (`,p,`). `,(0,J.jsx)(gO,{rec:g(t),target:_(t)})]}):!f||f.path!==t.relPath?(0,J.jsx)($,{children:`Loading…`}):vD(t.relPath)&&!d?(0,J.jsx)(`div`,{className:`viewer-doc-body`,children:(0,J.jsx)(eG,{src:f.text,q:``,onCopy:e=>Xf(e),files:{repoId:r(t),url:(e,n,i)=>{let a=H.artifactUrl(r(t),e);return n?$h(a,n,i):a},open:e=>{let n=v.find(t=>t.relPath===e);n?y(n):mO({repoId:r(t),relPath:e})},known:v.filter(e=>r(e)===r(t)).map(e=>e.relPath),docPath:t.relPath}})}):(0,J.jsxs)(`pre`,{className:`viewer-doc-pre`,children:[f.text,f.truncated?`
20
+ … (truncated — download for the rest)`:``]})]}):mD(t.relPath)?(0,J.jsx)(`audio`,{className:`viewer-audio`,src:s(t),controls:!0,preload:`metadata`},`${r(t)}:${t.relPath}:${i?`local`:`net`}`):hD(t.relPath)?(0,J.jsxs)(`div`,{className:`viewer-doc`,children:[(0,J.jsx)(`iframe`,{className:`viewer-pdf`,src:s(t),title:t.name}),(0,J.jsxs)(`div`,{className:`viewer-doc-note`,children:[(0,J.jsx)(gO,{rec:g(t),target:_(t)}),` if the preview stays blank`]})]}):(0,J.jsxs)(`div`,{className:`viewer-none`,children:[(0,J.jsx)(Pc,{size:28}),(0,J.jsx)(`span`,{children:`no preview for this kind of file — the actions below download it or copy its path`})]}),(0,J.jsxs)(`div`,{className:`viewer-path mono`,children:[t.repoName?`${t.repoName} · `:``,t.relPath]}),(0,J.jsxs)(`div`,{className:`viewer-path`,children:[`created `,yW(t.ctime??t.mtime),b>=0&&c.length>1?` · ${b+1} / ${c.length}`:``]}),i&&(0,J.jsxs)(`div`,{className:`viewer-doc-note`,children:[(0,J.jsx)(Ra,{size:12}),` shown from the copy already on this phone — no host needed`]}),m!=null&&!_D(t.relPath)&&(0,J.jsxs)(`div`,{className:`viewer-doc-note`,children:[(0,J.jsx)(fo,{size:12}),` saved copy from `,vW(m)]}),(0,J.jsxs)(`div`,{className:`sheet-actions`,children:[(0,J.jsxs)(Y,{onClick:()=>n(),children:[(0,J.jsx)(Ns,{size:16}),` back`]}),(0,J.jsx)(Y,{onClick:()=>S(t.relPath),children:x===t.relPath?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(vc,{size:16}),` copied`]}):`copy path`}),C(t)&&!a&&!i&&(0,J.jsxs)(Y,{"data-hint":`gallery.fullres`,title:`load the original file instead of the screen-sized copy`,onClick:()=>{q(`action:gallery.fullres`),w(!0)},children:[`full res`,t.size?` (${Math.round(t.size/1024)} KB)`:``]}),dD(t.relPath)&&(0,J.jsxs)(Y,{onClick:()=>{q(`action:gallery.annotate`),A(T(t),t.name,r(t))},children:[(0,J.jsx)(Mo,{size:16}),` annotate`]}),(0,J.jsx)(gO,{rec:g(t),target:_(t),trackId:`action:gallery.download`,onStart:()=>E(e=>e+1)}),D(t)&&(0,J.jsx)(Y,{variant:`danger`,onClick:()=>O(t),children:`delete`}),(0,J.jsx)(rG,{...F}),(0,J.jsx)(`button`,{className:`send`,onClick:()=>{j(t.relPath),M()},children:`insert path`})]}),(0,J.jsx)(iG,{...F}),k&&(0,J.jsx)(`div`,{className:`viewer-doc-note`,children:k})]})]})}function oG(e){let t=jW(e);return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(FW,{m:t}),(0,J.jsx)(VW,{m:t}),(0,J.jsx)(aG,{m:t})]})}function sG(e,t,n=t){let r=Math.min(t,n),i=Math.max(t,n);return!e||!e.open?{from:r,to:i,open:!0}:e.from===r&&e.to===i?null:{from:Math.min(e.from,r),to:Math.max(e.to,i),open:!1}}function cG(e,t){return e===t?`${e}`:`${e}-${t}`}function lG(e,t){return e===t?`line ${e}`:`lines ${e}–${t}`}function uG(e){return e.slice().sort((e,t)=>e.from-t.from||e.to-t.to)}function dG(e,t,n=t){let r=[];return e.forEach((e,i)=>{e.from<=n&&e.to>=t&&r.push(i+1)}),r}function fG(e,t,n){return e.slice(Math.max(0,t-1),Math.max(0,n))}function pG(e,t,n){if(t<1||t-1+n.length>e.length)return!1;for(let r=0;r<n.length;r++)if(e[t-1+r]!==n[r])return!1;return!0}function mG(e,t){return e.map(e=>{if(!e.quote.length)return e;if(pG(t,e.from,e.quote))return e.moved?{...e,moved:!1}:e;let n=-1;for(let r=1;r+e.quote.length-1<=t.length;r++)t[r-1]===e.quote[0]&&pG(t,r,e.quote)&&(n<0||Math.abs(r-e.from)<Math.abs(n-e.from))&&(n=r);return n<0?e.moved?e:{...e,moved:!0}:{...e,from:n,to:n+e.quote.length-1,moved:!1}})}function hG(e){return e.length>160?`${e.slice(0,159)}…`:e}function gG(e){return(e.length>4?[...e.slice(0,3).map(hG),`… ${e.length-4} more lines …`,hG(e[e.length-1])]:e.map(hG)).map(e=>e.trim()?`> ${e}`:`>`)}function _G(e,t){let n=uG(t).filter(e=>e.text.trim());if(!n.length)return null;let r=n.map((t,n)=>[`${n+1}. ${e}:${cG(t.from,t.to)}${t.moved?` (these lines have changed since — quoted as they read then)`:``}`,...gG(t.quote),t.text.trim()].join(`
21
+ `));return`Remarks on ${e} (${n.length}):\n\n${r.join(`
22
+
23
+ `)}\n`}var vG=(e,t)=>`${e}\n${t}`;function yG(e,t){let n=ma(R.fileRemarks,{})[vG(e,t)];return n&&Array.isArray(n.remarks)?n:{remarks:[]}}function bG(e,t,n){let r=ma(R.fileRemarks,{}),i=vG(e,t);!n.remarks.length&&!n.draft?.text.trim()?delete r[i]:r[i]=n,Ta(R.fileRemarks,r)}function xG(e,t){return yG(e,t).remarks.length}var SG=()=>`${Date.now().toString(36)}${Math.random().toString(36).slice(2,6)}`;function CG({repoId:e,path:t,body:n,rendered:r,files:i,onCopy:a,onSend:o,onCount:s}){let c=(0,V.useMemo)(()=>n.split(`
24
+ `),[n]),l=(0,V.useRef)(null);l.current??=yG(e,t);let[u,d]=(0,V.useState)(()=>mG(l.current.remarks,c)),f=l.current.draft,[p,m]=(0,V.useState)(f?{from:f.from,to:f.to,open:!1}:null),[h,g]=(0,V.useState)(f?.text??``),[_,v]=(0,V.useState)(f?.editId),[y,b]=(0,V.useState)(!1);(0,V.useEffect)(()=>{d(e=>mG(e,c))},[c]),(0,V.useEffect)(()=>{bG(e,t,{remarks:u,draft:p&&(h.trim()||_)?{from:p.from,to:p.to,text:h,editId:_}:void 0}),s?.(u.length)},[e,t,u,p,h,_,s]);let x=(0,V.useMemo)(()=>uG(u),[u]),S=(e,t)=>!!p&&e<=p.to&&t>=p.from,C=(e,t)=>{m(n=>sG(n,e,t))},w=e=>{let t=e.target.closest(`[data-l]`);if(!t)return;let n=Number(t.dataset.l);n&&C(n,n)},T=e=>{let t=e.target.closest(`[data-l0]`);t&&e.currentTarget.contains(t)&&(e.preventDefault(),e.stopPropagation(),C(Number(t.dataset.l0),Number(t.dataset.l1)))},E=()=>{m(null),g(``),v(void 0)},D=()=>{if(!p||!h.trim())return;let e=fG(c,p.from,p.to);q(_?`action:files.remark.edit`:`action:files.remark`),d(t=>_?t.map(t=>t.id===_?{...t,from:p.from,to:p.to,quote:e,text:h,moved:!1}:t):[...t,{id:SG(),from:p.from,to:p.to,quote:e,text:h}]),E()},O=e=>{m({from:e.from,to:e.to,open:!1}),g(e.text),v(e.id),b(!1)},k=e=>{d(t=>t.filter(t=>t.id!==e)),_===e&&E()},A=()=>{let e=_G(t,u);e&&(q(`action:files.remarks.send`),o(e)&&(d([]),E()))},j=(0,V.useRef)([h]);j.current=[h];let M=_?x.findIndex(e=>e.id===_)+1:0,N=(0,V.useMemo)(()=>{let e=new Map;return x.forEach((t,n)=>e.set(t.from,[...e.get(t.from)??[],n+1])),e},[x]),P=p?lG(p.from,p.to):``,F=p?`${P[0].toUpperCase()}${P.slice(1)} marked${p.open?` — tap another to stretch the mark, or say what should change.`:`.`}`:`Tap a ${r?`paragraph`:`line`} to mark it — then tap another to mark everything between.`;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{className:`rv-hint`,children:F}),r?(0,J.jsx)(`div`,{className:`viewer-doc-body rv-md`,onClickCapture:T,children:(0,J.jsx)(eG,{src:n,q:``,onCopy:a,files:i,lineTag:(e,t)=>{let n=x.flatMap((n,r)=>n.from>=e&&n.from<=t?[r+1]:[]);return{className:[S(e,t)?`rv-sel`:``,dG(x,e,t).length?`rv-marked`:``].filter(Boolean).join(` `)||void 0,badge:n.length?n.join(`,`):void 0}}})}):(0,J.jsx)(`div`,{className:`rv-src mono`,onClick:w,children:c.map((e,t)=>{let n=t+1,r=dG(x,n).length>0,i=N.get(n);return(0,J.jsxs)(`div`,{"data-l":n,className:`rv-line${S(n,n)?` rv-sel`:``}${r?` rv-marked`:``}`,children:[(0,J.jsx)(`span`,{className:`rv-no`,children:i?(0,J.jsx)(`b`,{className:`rv-badge`,children:i.join(`,`)}):n}),(0,J.jsx)(`span`,{className:`rv-txt`,children:e||` `})]},n)})}),p?(0,J.jsxs)(`div`,{className:`rv-compose`,children:[(0,J.jsxs)(`div`,{className:`rv-compose-head`,children:[(0,J.jsx)(wc,{size:16}),(0,J.jsxs)(`span`,{className:`grow`,children:[M?`Remark ${M} · `:``,lG(p.from,p.to)]}),h.trim()?(0,J.jsx)(fC,{title:`cancel this remark`,confirm:`discard words?`,onConfirm:E,children:(0,J.jsx)(B,{size:16})}):(0,J.jsx)(Y,{title:`cancel`,onClick:E,children:(0,J.jsx)(B,{size:16})})]}),(0,J.jsx)(yE,{inline:!0,rows:2,prompts:[h],onChange:e=>g(e[0]??``),placeholder:`What should change here? Type or dictate.`}),(0,J.jsxs)(`div`,{className:`sheet-actions rv-compose-acts`,children:[(0,J.jsx)(xE,{prompts:j,onPrompts:e=>g(e[0]??``),boxKey:`remark:${e}:${t}`}),(0,J.jsx)(`span`,{className:`spacer`}),h.trim()?(0,J.jsx)(`button`,{className:`send`,onClick:D,children:_?`Save remark`:`Add remark`}):(0,J.jsx)(Z,{as:`span`,className:`rv-why`,children:`Say what should change to add it.`})]})]}):u.length>0&&(0,J.jsxs)(`div`,{className:`rv-compose`,children:[(0,J.jsxs)(`div`,{className:`sheet-actions rv-compose-acts`,children:[(0,J.jsxs)(Y,{onClick:()=>b(e=>!e),children:[y?(0,J.jsx)(Nc,{size:16}):(0,J.jsx)(Hs,{size:16}),` `,u.length,` remark`,u.length===1?``:`s`]}),(0,J.jsx)(`span`,{className:`spacer`}),(0,J.jsxs)(`button`,{className:`send`,onClick:A,children:[(0,J.jsx)(Ec,{size:16}),` Send `,u.length===1?`remark`:`${u.length} remarks`,` to the chat`]})]}),y&&(0,J.jsx)(`div`,{className:`rv-list`,children:x.map((e,t)=>(0,J.jsxs)(`div`,{className:`rv-item`,children:[(0,J.jsx)(`b`,{className:`rv-badge`,children:t+1}),(0,J.jsxs)(`div`,{className:`grow`,children:[(0,J.jsxs)(`div`,{className:`rv-item-where`,children:[lG(e.from,e.to),e.moved?` · these lines have changed since`:``]}),(0,J.jsx)(`div`,{className:`rv-item-text`,children:e.text})]}),(0,J.jsx)(Y,{title:`edit this remark`,onClick:()=>O(e),children:(0,J.jsx)(Mo,{size:16})}),(0,J.jsx)(fC,{title:`delete this remark`,confirm:`delete?`,onConfirm:()=>k(e.id),children:(0,J.jsx)(ws,{size:16})})]},e.id))})]})]})}function wG(e){let t=e.trim();return t===`??`?`new`:t.includes(`D`)?`deleted`:t.startsWith(`R`)?`renamed`:t.includes(`A`)?`added`:`modified`}function TG({repoId:e,repoName:t,socketOpen:n,onInsertPath:r,onRemarks:i,initialFile:a,onClose:o}){let[s,c]=(0,V.useState)(()=>a&&a.includes(`/`)?a.slice(0,a.lastIndexOf(`/`)):``),[l,u]=(0,V.useState)(null),[d,f]=(0,V.useState)(!1),[p,m]=(0,V.useState)(``),[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)(null),y=gh(`${e}:${s}`,()=>H.tree(e,s),{fromCache:async()=>{let t=await Rb(e,s);return t?{value:t.listing,savedAt:t.savedAt}:null},toCache:t=>Lb(e,s,t)}),b=y.data,x=(0,V.useCallback)(e=>{g(null),u(null),e===s?y.reload():c(e)},[s,y]);async function S(){let t=p.trim();if(t){q(`action:files.search`),f(!0),u(null);try{let n=await H.tree(e,s,t);y.set(n),g(t)}catch{u(`search needs the host — showing this folder only`)}finally{f(!1)}}}async function C(t){if(t.dir)m(``),c(t.path);else if(q(`action:files.open`),u(null),!n){let n=await Wb(e,t.path,t.mtime);if(!n){u(`no link — "${t.name}" isn't cached on the phone`);return}v({path:t.path,size:t.size,mtime:t.mtime,body:n.text,truncated:n.truncated,editable:!1})}else{f(!0);try{let n=await H.treeFile(e,t.path);v(n),n.body!=null&&Ub(e,n.path,n.mtime,n.body,!!n.truncated)}catch{let n=await Wb(e,t.path,t.mtime);n?v({path:t.path,size:t.size,mtime:t.mtime,body:n.text,truncated:n.truncated,editable:!1}):u(`couldn't open ${t.name}`)}finally{f(!1)}}}let w=(0,V.useRef)(!!a),T=(0,V.useRef)(!1);(0,V.useEffect)(()=>{a&&!T.current&&(T.current=!0,C({name:a.split(`/`).pop()||a,path:a,dir:!1,size:0,mtime:0}))},[a]);let E=()=>{v(null),y.reload({quiet:!0})};if(Gh(_?!w.current:s!==``,()=>{_?E():(m(``),c(s.includes(`/`)?s.slice(0,s.lastIndexOf(`/`)):``))}),_)return(0,J.jsx)(EG,{repoId:e,repoName:t??``,file:_,socketOpen:n,onReopen:async()=>{try{v(await H.treeFile(e,_.path))}catch{}},onInsertPath:r,onRemarks:i,onOpenPath:e=>void C({name:e.split(`/`).pop()||e,path:e,dir:!1,size:0,mtime:0}),onClose:()=>{w.current?o():E()}});let D=p.trim().toLowerCase(),O=(b?.entries??[]).filter(e=>!D||e.name.toLowerCase().includes(D)||h&&e.path.toLowerCase().includes(D)),k=s?s.split(`/`):[];return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:(0,J.jsxs)(J.Fragment,{children:[`Files`,t?` · ${t}`:``]}),onClose:o,children:(0,J.jsx)(Y,{title:`refresh`,onClick:()=>x(s),children:(0,J.jsx)(xc,{size:16})})}),(0,J.jsxs)(`div`,{className:`crumbs`,children:[(0,J.jsx)(`button`,{className:`crumb ${s?``:`here`}`,onClick:()=>{m(``),c(``)},children:`/`}),k.map((e,t)=>(0,J.jsx)(`button`,{className:`crumb ${t===k.length-1?`here`:``}`,onClick:()=>{m(``),c(k.slice(0,t+1).join(`/`))},children:e},t))]}),(0,J.jsx)(`div`,{className:`form`,children:(0,J.jsxs)(Xw,{kind:`wrap`,children:[(0,J.jsx)(`input`,{className:`search grow`,placeholder:`Filter this folder…`,value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&S()}}),p&&(0,J.jsx)(`button`,{className:`row-act`,title:`clear`,onClick:()=>{m(``),h&&x(s)},children:(0,J.jsx)(B,{size:16})}),(0,J.jsx)(`button`,{className:`row-act`,title:`search this folder and everything under it`,disabled:!p.trim(),onClick:S,children:(0,J.jsx)(rc,{size:16})})]})}),h&&(0,J.jsxs)(Z,{children:[`Matches for “`,h,`” under /`,s,` — build and dependency folders are not searched.`]}),y.state===`cached`&&(0,J.jsx)(Z,{children:_h(y.state,y.age)}),y.state===`offline`&&(0,J.jsx)(Z,{children:`No link, and this folder isn't cached on the phone.`}),y.state===`error`&&(0,J.jsxs)(Z,{children:[`Couldn't read this folder: `,y.error]}),b?.truncated&&(0,J.jsxs)(Z,{children:[`Long folder — showing the first `,b.entries.length,` entries.`]}),l&&(0,J.jsx)(Z,{children:l}),(0,J.jsxs)(`div`,{className:`list`,children:[(d||y.state===`loading`)&&!b&&(0,J.jsx)($,{children:`Reading this folder…`}),b&&O.length===0&&(0,J.jsx)($,{children:D?`Nothing matches.`:`Empty folder.`}),O.map(e=>(0,J.jsxs)(`button`,{className:`row grow ${e.ignored?`dim`:``}`,onClick:()=>C(e),children:[(0,J.jsx)(`span`,{className:`row-ico`,children:e.dir?(0,J.jsx)(zs,{size:16}):(0,J.jsx)(gc,{size:16})}),(0,J.jsxs)(Zw,{className:`mono`,children:[h?e.path:e.name,e.dir?`/`:``]}),e.status&&(0,J.jsx)(`span`,{className:`gstat g-${wG(e.status)}`,children:wG(e.status)}),(0,J.jsx)(Q,{children:e.dir?e.count==null?``:`${e.count}`:`${yp(e.size)} · ${Tp(e.mtime)}`})]},e.path))]})]})}function EG({repoId:e,repoName:t,file:n,socketOpen:r,onReopen:i,onInsertPath:a,onRemarks:o,onOpenPath:s,onClose:c}){let[l,u]=(0,V.useState)(!1),d=$g({repoId:e,path:n.path}),f=M_(e=>e.files.some(e=>$g(e)===d)),p=M_(e=>e.enabled);(0,V.useEffect)(()=>(x_(d),()=>x_(null)),[d]);function m(){q(`action:files.pin`),b_({repoId:e,repo:t,path:n.path},!f);let r=t_(n.path);K(f?`unpinned ${r}`:p?`pinned ${r} to the tab strip`:`pinned ${r} — the tab strip is off, turn it on in Settings to see it`)}let[h,g]=(0,V.useState)(!1),[_,v]=(0,V.useState)(()=>xG(e,n.path));(0,V.useEffect)(()=>{v(xG(e,n.path))},[e,n.path]);let[y,b]=(0,V.useState)(!1),x=dD(n.path)||fD(n.path),S=(vD(n.path)||x)&&!n.binary,C=!!o&&!n.binary&&n.body!=null&&(!x||/\.svg$/i.test(n.path)),[w,T]=(0,V.useState)(!1);(0,V.useEffect)(()=>T(!1),[n.path,n.mtime]);let E=H.artifactUrl(e,n.path),D={repoId:e,url:(t,n,r)=>{let i=H.artifactUrl(e,t);return n?$h(i,n,r):i},open:s,docPath:n.path},O=fD(n.path)||/\.(gif|svg)$/i.test(n.path)?E:$h(E,Qh(),n.mtime),k={repoId:e,relPath:n.path,name:n.path.split(`/`).pop(),size:n.size,mtime:n.mtime},[A,j]=(0,V.useState)(n.body??``),[M,N]=(0,V.useState)(null),[P,F]=(0,V.useState)(!1),[ee,te]=(0,V.useState)(!1),ne=(0,V.useRef)(n.sha??``);(0,V.useEffect)(()=>{j(n.body??``),ne.current=n.sha??``},[n]);let re=A!==(n.body??``),ie=re&&n.editable&&r&&!ee;async function ae(){if(!ie)return;q(`action:files.save`),te(!0),N(null);let t=await H.treeWrite(e,n.path,A,ne.current).catch(()=>({ok:!1,error:`the host didn't answer — nothing was written`,code:`failed`}));te(!1),t.ok?(ne.current=t.sha,N(`Saved.`),u(!1),Ub(e,n.path,t.mtime,A,!1),i()):t.code===`stale`?(F(!0),N(`Changed on disk since you opened it — nothing was written. Your text is still here; reload to take the version on disk instead.`)):N(t.error)}async function oe(){te(!0),await i(),te(!1),F(!1),N(null),u(!1)}let se=n.editable?r?null:`the link is down — saving needs the host, and a write held until later would land on a file that moved on`:n.binary?`binary file`:n.truncated?`too big to edit here — showing the start of it`:`read-only (opened from the phone's cache)`,ce=n.body!=null&&!n.truncated&&!n.binary?Oee(n.path,n.body):null;return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsxs)(Uw,{title:n.path,brandClass:`mono`,onClose:c,children:[(0,J.jsx)(Y,{className:f?`active`:``,title:f?`unpin from the tab strip`:`pin to the tab strip — one tap back to this file from anywhere`,"aria-pressed":f,onClick:m,children:f?(0,J.jsx)(cc,{size:16}):(0,J.jsx)(ko,{size:16})}),C&&!l&&(0,J.jsxs)(Y,{className:h?`active`:``,title:h?`back to reading — the remarks are kept`:`mark lines and say what should change — sent to the chat as one message`,onClick:()=>{q(`action:files.review`),g(!h)},children:[(0,J.jsx)(wc,{size:16}),_>0&&(0,J.jsx)(`span`,{className:`key-count`,children:_})]}),n.editable&&!h&&(0,J.jsx)(Y,{className:l?`active`:``,title:l?`stop editing`:`edit`,onClick:()=>{q(`action:files.edit`),u(!l)},children:l?(0,J.jsx)(hl,{size:16}):(0,J.jsx)(Mo,{size:16})}),(0,J.jsx)(gO,{target:k,compact:!0,trackId:`action:files.download`}),(0,J.jsx)(Y,{title:`use this path in the prompt`,onClick:()=>{a(n.path),c()},children:(0,J.jsx)(Jte,{size:16})})]}),(0,J.jsxs)(Z,{children:[yp(n.size),` · `,Tp(n.mtime),ce?` · ${Uee(ce,e=>e.toLocaleString())}`:``,se&&!h?` · ${se}`:``,re?` · unsaved`:``,h&&re?` · remarks name the lines as saved on disk, not your unsaved edits`:``,!h&&_>0?` · ${_} remark${_===1?``:`s`} waiting`:``,S&&!l&&(0,J.jsx)(Y,{className:`md-toggle`,onClick:()=>b(e=>!e),children:y?`rendered`:`source`})]}),h&&o?(0,J.jsx)(CG,{repoId:e,path:n.path,body:n.body??``,rendered:vD(n.path)&&!y,files:D,onCopy:e=>void Xf(e),onCount:v,onSend:e=>o(n.path,e)},n.path):x&&!l&&(n.binary||!y)?w?(0,J.jsxs)($,{children:[`Couldn't load this `,fD(n.path)?`clip`:`picture`,` — it comes from the desktop, so it needs the link.`,(0,J.jsx)(gO,{target:k,trackId:`action:files.download`})]}):fD(n.path)?(0,J.jsx)(`video`,{className:`viewer-video`,src:O,controls:!0,preload:`metadata`,onError:()=>T(!0)},O):(0,J.jsx)(sW,{src:O,alt:n.path,onError:()=>T(!0)},O):n.binary?(0,J.jsxs)($,{children:[`Binary — nothing to show.`,(0,J.jsx)(gO,{target:k,trackId:`action:files.download`})]}):l?(0,J.jsx)(`textarea`,{className:`code-edit mono`,value:A,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,autoComplete:`off`,onChange:e=>j(e.target.value)}):S&&!y?(0,J.jsx)(`div`,{className:`viewer-doc-body`,children:(0,J.jsx)(eG,{src:A,q:``,onCopy:e=>void Xf(e),files:D})}):(0,J.jsx)(`pre`,{className:`code-view mono`,children:A}),P&&(0,J.jsx)(Z,{children:`Saving again would overwrite whatever was written there — so it is not offered. Copy your text out if you need it, then reload.`}),(0,J.jsxs)(`div`,{className:`sheet-actions`,children:[re&&!P&&(0,J.jsxs)(`button`,{className:`send`,onClick:ae,disabled:!ie,children:[(0,J.jsx)(Gs,{size:16}),` Save`]}),P&&(0,J.jsxs)(Y,{onClick:async()=>N(await Xf(A)?`Your version is on the clipboard.`:`Couldn't reach the clipboard — select the text instead.`),children:[(0,J.jsx)(_o,{size:16}),` Copy mine`]}),(P||re)&&(0,J.jsx)(Y,{onClick:oe,disabled:ee,children:`Reload from disk`})]}),M&&(0,J.jsx)(Z,{children:M})]})}function DG({repoId:e,repoName:t,scope:n,onScope:r,onDone:i,onClose:a}){let[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(null),[u,d]=(0,V.useState)(!0),[f,p]=(0,V.useState)(null),[m,g]=(0,V.useState)(null),[_,v]=(0,V.useState)(!1),[y,b]=(0,V.useState)(null),[x,S]=(0,V.useState)(()=>Date.now());async function C(){d(!0),l(null);try{let t=await H.sweepPlan(e,n),r=Date.now();s({rows:t.rows,total:Wr(t.rows),counts:Ot(t.rows,r)}),S(r)}catch{l(`Couldn’t read this repo’s files — the desktop didn’t answer.`),s(null)}finally{d(!1)}}(0,V.useEffect)(()=>{p(null),g(null),b(null),C()},[e,n]);let w=e=>{p(e),g(null)},T=e=>{g(e),p(null)},E=(0,V.useMemo)(()=>o?f?se(o.rows,f,x):m?Zi(o.rows,m):null:null,[o,f,m,x]),D=(0,V.useMemo)(()=>o&&n===`outbox`?{counts:gee(o.rows),n:Or(o.rows)}:null,[o,n]);async function O(){if(E&&E.rows.length){v(!0);try{let t=E.rows.map(e=>e.relPath),n=await H.sweepRun(e,t);if(n.error){l(n.error);return}let r={deleted:n.deleted,bytes:n.bytes,missing:n.missing??[],failed:n.failed??[]};b(r),i(r),p(null),g(null),await C()}catch{l(`The sweep didn’t reach the desktop. Nothing here says whether it ran — re-open this sheet to see what is still there.`)}finally{v(!1)}}}return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:`Clear out old files`,onClose:a,children:u&&(0,J.jsx)(Js,{size:13,className:`spin`})}),(0,J.jsxs)(Z,{children:[t,` · `,Ii[n],`. Pick how far back, look at what it would delete, then confirm. Nothing goes until you do.`]}),(0,J.jsxs)(`div`,{className:`annot-tools`,children:[[`outbox`,`inbox`].map(e=>(0,J.jsx)(Y,{className:n===e?`active`:``,onClick:()=>r(e),children:e},e)),(0,J.jsxs)(Y,{onClick:()=>void C(),children:[(0,J.jsx)(Ds,{size:14}),` re-read`]})]}),c&&(0,J.jsx)(Z,{tone:`warn`,children:c}),o&&(0,J.jsx)(Bw,{className:`annot-tools sweep-ages`,keys:on,active:f,onPick:w,label:e=>A[e],bucket:e=>({count:o.counts[e].count,detail:un(o.counts[e].bytes)})}),o&&D&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Bw,{className:`annot-tools sweep-ages`,keys:fte,active:m,onPick:T,label:e=>ei[e],bucket:e=>({count:D.counts[e].count,detail:un(D.counts[e].bytes)})}),(0,J.jsxs)(Z,{children:[`A build family is the same artifact across builds — the version, the hash and the build number vary, everything else is its name. `,D.n,` `,D.n===1?`family`:`families`,` here.`]})]}),o&&!E&&(0,J.jsx)(Z,{children:o.total.count?(0,J.jsxs)(J.Fragment,{children:[o.total.count,` file`,o.total.count===1?``:`s`,` here, `,un(o.total.bytes),` in all. Pick a cut above to see what would go.`]}):(0,J.jsxs)(J.Fragment,{children:[`Nothing in this repo’s `,n,`.`]})}),E&&(0,J.jsxs)(Pw,{onClear:()=>{p(null),g(null)},children:[E.count,` of `,o.total.count,` files · `,un(E.bytes),` of `,un(o.total.bytes),` — `,f?A[f]:ei[m]]}),E&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`list sweep-list`,children:E.rows.map(e=>(0,J.jsxs)(`div`,{className:`row sweep-row`,children:[(0,J.jsx)(`span`,{className:`sweep-path mono`,children:e.relPath}),(0,J.jsxs)(`span`,{className:`sweep-meta`,children:[un(e.size),` · `,Tp(e.mtime)]})]},e.relPath))}),(0,J.jsxs)(`div`,{className:`form`,children:[(0,J.jsx)(Z,{children:f?zee(E,f):ki(E,m,D?.n??0)}),E.count>0?(0,J.jsxs)(fC,{className:`send danger`,confirm:`Yes — delete ${E.count} · ${un(E.bytes)}`,disabled:_,onConfirm:()=>void O(),children:[(0,J.jsx)(ws,{size:14}),` `,_?`Deleting…`:f?ne(E):Nr(E)]}):(0,J.jsx)(Qw,{className:`form-hint`,cants:[{label:`delete`,reason:f?`nothing in this ${n} is ${A[f]}.`:`every file here is among the newest ${m} of its build family.`}]})]})]}),y&&(0,J.jsxs)(`div`,{className:`form`,children:[(0,J.jsx)(Z,{className:y.failed.length?`warn`:void 0,children:h(y)}),y.failed.length>0&&(0,J.jsx)(`div`,{className:`list`,children:y.failed.map(e=>(0,J.jsx)(`div`,{className:`row sweep-row`,children:(0,J.jsx)(`span`,{className:`sweep-path mono`,children:e})},e))})]})]})}function OG(e){let t=e[0]?.repoId;!t||e.length<2||(qz.ret=`session`,Promise.all(e.map(async e=>{let t=await H.fileBlob(e.url);return new File([t],e.name,{type:t.type||`image/png`})})).then(e=>fV(e,t,e=>dV(e,t)),()=>U().say.toast(`Could not fetch the pictures from the desktop — nothing was combined.`)))}function kG(){let e=Dh(),t=G(Vz);return(0,J.jsx)(oG,{repoId:t?.repoId??e.world.activeRepo?.id??void 0,repos:e.world.visibleRepos,initialScope:t?.scope,initialAllTime:t?.allTime,initialNew:t?.newCut,openFile:t?.openFile,onClose:zB,onInsertPath:BB,onContinueInSession:HB,sessionsIn:VB,onSweep:GB,onSurvey:()=>{e.say.track(`overlay:storage`),e.nav.open(`storage`)},onAnnotate:OV,onCombine:OG})}function AG(){let e=Dh(),t=G(Hz),n=t?e.world.repos.find(e=>e.id===t.repoId)??null:null;return!t||!n?null:(0,J.jsx)(DG,{repoId:n.id,repoName:n.repoName,scope:t.scope,onScope:KB,onDone:t=>{JB(),t.deleted&&e.say.toast(h(t))},onClose:qB})}function jG(){let e=Dh(),t=G(Uz),n=G(Wz),r=e.world.repos.find(n=>n.id===(t??e.world.activeRepo?.id))??null;return r?(0,J.jsx)(TG,{repoId:r.id,repoName:r.repoName,initialFile:n?.file,socketOpen:e.conn.status===`open`,onInsertPath:BB,onRemarks:(e,t)=>UB(r.id,t),onClose:eV},`${r.id}:${n?.file??``}`):(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:`Files`,onClose:eV}),(0,J.jsx)($,{children:`That repo is not in the listing any more — pick one from the launcher.`})]})}function MG({sessionId:e}){let t=Jz(e),n=Xz(e);return t.length?n?(0,J.jsxs)(`button`,{className:`newimg-pill`,onClick:()=>NB(e),title:`show new files`,children:[(0,J.jsx)(jo,{size:14}),` new `,t.length]}):(0,J.jsxs)(`div`,{className:`newimg-strip`,children:[(0,J.jsxs)(`div`,{className:`newimg-ctl`,children:[(0,J.jsxs)(`span`,{className:`newimg-label`,children:[(0,J.jsx)(jo,{size:14}),` new `,t.length]}),(0,J.jsxs)(`div`,{className:`newimg-ctl-btns`,children:[(0,J.jsx)(`button`,{className:`newimg-min`,onClick:()=>MB(e),title:`minimize`,children:(0,J.jsx)(hs,{size:14})}),(0,J.jsx)(`button`,{className:`newimg-x`,onClick:()=>jB(e),title:`dismiss`,children:(0,J.jsx)(B,{size:14})})]})]}),t.map(t=>{let n=(t.name.split(`.`).pop()||``).toUpperCase();if(tB(t.relPath))return(0,J.jsxs)(`div`,{className:`newimg`,children:[(0,J.jsxs)(`button`,{className:`newimg-thumb newimg-doc`,onClick:()=>EB(t.repoId,t.relPath),title:`${t.relPath} — ${t.changed?`edited`:`new`} this session · tap to read`,children:[(0,J.jsx)(Fs,{size:18}),(0,J.jsx)(`span`,{className:`newimg-doc-name`,children:t.name}),(0,J.jsx)(`span`,{className:`newimg-type`,children:t.changed?`${n} · edited`:n})]}),(0,J.jsx)(`button`,{className:`newimg-ref`,onClick:()=>AB(t),title:`insert path: ${t.relPath}`,children:`ref`})]},t.relPath);let r=eB(t.relPath);return(0,J.jsxs)(`div`,{className:`newimg`,children:[(0,J.jsxs)(`button`,{className:`newimg-thumb`,onClick:()=>TB(e,t),title:`${t.name} — tap to open · swipe between images`,children:[r?(0,J.jsx)(`video`,{src:H.artifactUrl(t.repoId,t.relPath),poster:$h(H.artifactUrl(t.repoId,t.relPath),Zh(120),t.mtime),muted:!0,playsInline:!0,preload:`none`}):(0,J.jsx)(`img`,{src:$h(H.artifactUrl(t.repoId,t.relPath),Zh(120),t.mtime),alt:t.name,loading:`lazy`,decoding:`async`}),n&&(0,J.jsx)(`span`,{className:`newimg-type`,children:n})]}),(0,J.jsx)(`button`,{className:`newimg-ref`,onClick:()=>AB(t),title:`insert path: ${t.relPath}`,children:`ref`})]},t.relPath)})]}):null}function NG({sessionId:e}){let t=Jz(e).filter(e=>nB(e.relPath)).length;return t<=0?null:(0,J.jsxs)(qw,{className:`img tag-filter`,role:`button`,tabIndex:0,title:`${t} new image${t>1?`s`:``} from this session — tap to browse them`,onPointerDown:e=>e.stopPropagation(),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),t.stopPropagation(),wB(e))},onClick:t=>{t.stopPropagation(),wB(e)},children:[(0,J.jsx)(jo,{size:12}),` `,t]})}function PG({repo:e,dismiss:t}){return!e||e.outboxCount<=0?null:(0,J.jsxs)(Y,{className:`count`,title:`${e.outboxCount} new outbox file${e.outboxCount>1?`s`:``} since last opened — open gallery`,onClick:()=>{t(),FB(e.id)},children:[(0,J.jsx)(jo,{size:16}),` `,e.outboxCount]},`inbox`)}var FG={id:`images`,sheets:[{id:`collage`,persisted:!1,render:()=>zz.get()?(0,V.createElement)(lW):null},{id:`image`,persisted:!1,render:()=>Iz.get()?(0,V.createElement)(dW):null},{id:`swipe`,persisted:!1,render:()=>Bz.get()?(0,V.createElement)(fW):null},{id:`gallery`,persisted:!0,render:()=>(0,V.createElement)(kG)},{id:`sweep`,persisted:!1,render:e=>{let t=Hz.get();return t&&e.world.repos.some(e=>e.id===t.repoId)?(0,V.createElement)(AG):null}},{id:`browse`,persisted:!0,render:()=>(0,V.createElement)(jG)}],commands:[{id:`image`,run:QB(rV)},{id:`file`,run:QB(iV)},{id:`files`,run:QB(ZB)},{id:`browse`,run:QB($B)}],messages:{"session.images":e=>kB(e.id,e.repoId,e.images)},toolbarItems:[{id:`inbox`,render:(e,t)=>{let n=e.world.activeRepo;return n&&n.outboxCount>0?(0,V.createElement)(PG,{repo:n,dismiss:t.dismiss}):null}}],boot:()=>{let e=BV(),t=e=>{let t=e.detail;if(!t)return;let n=U().nav.overlay;XB(t.repoId,t.path,n===`browse`?Wz.get()?.back??null:n)};return window.addEventListener(F_,t),()=>{e(),window.removeEventListener(F_,t)}}};function IG(e){let t=qr(e);return t?{address:t.base,code:t.code}:null}function LG(e){let t=qr(e.address);if(t)return t;let n=jn(e.address),r=ae(e.code);return n&&r?{base:n,code:r}:null}function RG(e){let t=Tt(e);return t?{kind:`ask`,target:t}:{kind:`invalid`}}var zG=`That pairing link isn't valid`;function BG(e){return`A pairing link asks to connect this phone to ${e.base.replace(/^https?:\/\//,``)}. Nothing is sent until you tap pair.`}var VG=[`bad-request`,`unknown`,`expired`,`used`,`rate-limited`,`no-password`];function HG(e,t){let n=t&&typeof t==`object`?t:{};if(n.ok===!0&&n.host&&typeof n.host==`object`){let e=n.host;if(typeof e.base==`string`&&typeof e.name==`string`)return n}return n.ok===!1&&VG.includes(n.error)?{ok:!1,error:n.error,message:typeof n.message==`string`?n.message:``}:e===429?{ok:!1,error:`rate-limited`,message:``}:{ok:!1,error:`bad-reply`,message:`The desktop answered ${e}, not a pairing reply. Is that the ${I.displayName} daemon?`}}function UG(e){return e.error===`no-password`?e.message||ee(`no-password`):e.error===`network`||e.error===`bad-reply`?e.message:ee(e.error)}function WG(e,t,n){return t===n?[e]:n===null?[e,xe(e,t)]:[xe(e,t)]}function GG(e,t){let n=Ul(e).find(e=>e.base===t);if(!n)return null;let r=n.id===Gl(e)?R.deviceToken:xe(R.deviceToken,n.id),i=e.getItem(r);return lu(i)?i:null}function KG(e,t,n){let r=jn(t.host.base)??n.base,i=t.host.lanBase?jn(t.host.lanBase):null,a=i?{base:i,ssids:t.host.lanSsids??[],auto:!1}:null,o=Ul(e).find(e=>e.base===r||e.base===n.base)??null,s=!1;if(o){if(!o.lan&&a){let t=Zl(e,o.id,{name:o.name,base:o.base,lan:a});t.ok&&(o=t.host)}}else{let n=Xl(e,{name:t.host.name,base:r,lan:a});if(!n.ok)return n;o=n.host,s=!0}let c=Gl(e),l=[],u=(t,n)=>{for(let r of WG(t,o.id,c))e.setItem(r,n),l.push(r)};if(lu(t.token)){if(u(R.deviceToken,t.token),t.scope===`passive`)u(R.passive,`1`);else for(let t of WG(R.passive,o.id,c))e.removeItem(t)}let d=t.lanIdentity;return d&&typeof d.hostId==`string`&&typeof d.secret==`string`&&d.secret.length>=16&&u(R.lanIdentity,JSON.stringify({hostId:d.hostId,secret:d.secret})),{ok:!0,host:o,added:s,isActive:o.id===c,wrote:l}}var qG=`app:shell-nudge`,JG=`app:shell-open`;function YG(){if(ha())return null;let e=Nh(`Link`);return e&&typeof e.start==`function`?e:null}function XG(){return hu()&&YG()!==null}async function ZG(){let e=YG();if(!e)return null;try{let t=await e.isSupported();return typeof t.powerSave==`boolean`?t.powerSave:null}catch{return null}}async function QG(){let e=YG();if(!e)return null;try{return await e.status()}catch{return null}}async function $G(){let e=YG();if(!e)return null;let t=vu(),n=Vt(t,`/ws`);if(!n)return null;try{await e.requestNotifications()}catch{}let r=t?t.replace(/^https?:\/\//,``):`host`;return e.start({url:n,protocol:2,label:r})}async function eK(){let e=YG();if(e)try{await e.stop()}catch{}}async function tK(){let e=YG();if(e)try{await e.requestBatteryExemption()}catch{}}async function nK(){let e=YG();if(!e)return!1;let t=!1;try{t=(await e.requestNotifications()).granted}catch{}if(t)return!0;if(typeof e.openNotificationSettings==`function`)try{await e.openNotificationSettings()}catch{}return!1}var rK=-1;function iK(e){let t=YG();if(!t)return;let n=Math.max(0,Math.floor(e));n!==rK&&(rK=n,t.setQueueDepth({depth:n}).catch(()=>{rK=-1}))}var aK=null,oK=new Set;function sK(e){if(oK.add(e),aK){let t=aK;aK=null,e(t)}return()=>{oK.delete(e)}}var cK=null,lK=new Set;function uK(e){if(lK.add(e),cK){let t=cK;cK=null,e(t)}return()=>{lK.delete(e)}}function dK(){Fh(`Nudge`,e=>{try{window.dispatchEvent(new CustomEvent(qG,{detail:{reason:e}}))}catch{}}),Fh(`Open`,e=>{if(!e)return!0;try{window.dispatchEvent(new CustomEvent(JG,{detail:{sessionId:e}}))}catch{}if(oK.size===0)return aK=e,!1;for(let t of oK)t(e);return!0}),Fh(`Pair`,e=>{let t=RG(e);if(t.kind===`invalid`)return K(zG),!0;if(lK.size===0)return cK=t.target,!0;for(let e of lK)e(t.target);return!0})}function fK(e){let t=e.firstPrompt?.trim()||void 0,n=e.pinnedPrompt?.trim()||void 0,r=n??(e.lastPrompt?.trim()||void 0),i={};return t&&(i.first=t),(r&&r!==t||!t&&r)&&(i.now=r,i.nowKind=n?`pinned`:`latest`),i}function pK(e){let t=fK(e);return!t.first&&!t.now?null:(0,J.jsxs)(`span`,{className:`prompt-pair${e.className?` ${e.className}`:``}`,children:[t.first&&(0,J.jsxs)(`span`,{className:`pp-part pp-start`,children:[(0,J.jsxs)(`span`,{className:`pp-label`,children:[(0,J.jsx)(Ac,{size:11}),` Started`]}),(0,J.jsx)(`span`,{className:`pp-text`,children:t.first})]}),t.now&&(0,J.jsxs)(`span`,{className:`pp-part pp-now`,children:[(0,J.jsxs)(`span`,{className:`pp-label`,children:[t.nowKind===`pinned`?(0,J.jsx)(ko,{size:11}):(0,J.jsx)(Lo,{size:11}),` `,t.nowKind===`pinned`?`Pinned`:`Latest`]}),(0,J.jsx)(`span`,{className:`pp-text`,children:t.now})]})]})}var mK=e=>!!e.followUp;function hK(e,t){return e?{n:e.n+1,tone:e.tone===t?t:`mixed`}:{n:1,tone:t}}function gK(e,t){let n=new Map;for(let r of e){if(!mK(r))continue;let e=t(r);n.set(e,hK(n.get(e),r.followUp.by))}return n}function _K(e){let t=null;for(let n of e.values())t=t?{n:t.n+n.n,tone:t.tone===n.tone?n.tone:`mixed`}:{...n};return t}function vK(e,t){return`${e} session${e===1?``:`s`} flagged for follow up${t?` in ${t}`:``} — tap to show only ${e===1?`that one`:`those`}`}function yK(e){if(!e.turnModel&&!e.turnEffort)return e;let t=e.turnEffort??e.effort;if(!e.turnModel)return{...e,effort:t};let n=/^claude-([a-z]+)-/.exec(e.turnModel)?.[1],r=e.model?.replace(/\[1m\]$/i,``).replace(/^claude-/,``).split(`-`)[0],i=n&&n===r?e.model:n??e.turnModel.replace(/^claude-/,``);return{...e,model:i,effort:t}}function bK(e,t=null){return e.running?e.limit?.blocked?`limit`:e.prompt||e.awaitingInput||e.asking?`wait`:DC(t,e.backend)?`done`:e.idle?e.agents?.length?`coding`:e.shellList?Kr(e.shellList,Date.now()).working>0?`coding`:`done`:e.shells?`coding`:`done`:`coding`:`exited`}var xK={exited:`exited`,limit:`at the usage limit`,wait:`waiting for your answer`,done:`idle`,coding:`working`,starred:`starred`,followup:`flagged for follow up`,shells:`running background shells`,worktrees:`worktrees`};function SK(e,t,n=null){return t===`starred`?!!e.starred:t===`followup`?mK(e):t===`shells`?!!e.shellList?.length:t!==`worktrees`&&bK(e,n)===t}var CK=e=>e?e.replace(/^claude-/,``):``;function wK(e,t,n=null){return DC(n,e.backend)?t||`Shell`:[t||null,CK(e.model)||`default`,e.effort,e.permissionMode&&e.permissionMode!=="default"?e.permissionMode:null].filter(Boolean).join(` · `)}function TK(e,t=null){let n=bK(e,t);if(n===`exited`)return{cls:`dead`,title:``,body:`exited`};let r=e.limit;if(n===`limit`&&r?.needsYou&&!r.nextAttemptAt)return{cls:`limit-manual`,title:`blocked — it needs you: ${r.needsYou}; resume it once that is sorted`,body:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(go,{size:12}),` blocked · needs you`]})};if(n===`limit`&&r?.spend){let e=r.nextAttemptAt??r.resetAt;return{cls:r.autoContinue&&e?`limit-auto`:`limit-manual`,title:e?`at a spend limit — resumes ~${Rp(e)}${r.attempts?` · attempt ${r.attempts}`:``}`:`at a spend limit — it needs you: add credit or raise the limit, then resume`,body:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(go,{size:12}),` `,e?`spend · resumes ${Rp(e)}`:`spend limit · needs you`]})}}if(n===`limit`&&r){let e=r.autoContinue?`at the usage limit${r.resetAt?` — reset ~${Rp(r.resetAt)}`:``}${r.nextAttemptAt?`; "continue" is scheduled for ${Rp(r.nextAttemptAt)}`:``}${r.attempts?` · attempt ${r.attempts}`:``}`:`at the usage limit — auto-continue is off for this session, resume manually`,t=r.resuming?` · resuming`:r.queuePos&&r.queuePos>1?` · #${r.queuePos}`:``;return{cls:r.autoContinue?`limit-auto`:`limit-manual`,title:e+(r.queuePos?` · #${r.queuePos} in the resume queue (they resume one at a time)`:``),body:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(go,{size:12}),` limit`,r.autoContinue?r.nextAttemptAt?` · auto ${Rp(r.nextAttemptAt)}`:` · auto`:` · manual`,t]})}}if(n===`wait`)return{cls:`wait`,title:e.prompt?``:e.awaitingInput?`a dialog is open in the CLI — open the session to answer`:e.asking?`the turn ended on a question — “${e.asking.text}”`:``,body:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Ls,{size:12}),` `,e.asking&&!e.prompt&&!e.awaitingInput?`asked you`:`waiting`]})};if(n===`done`&&DC(t,e.backend))return{cls:`idle`,title:`a plain shell — it has no turns to finish`,body:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(qa,{size:12}),` shell`]})};if(n===`done`)return{cls:`idle`,title:``,body:(0,J.jsxs)(J.Fragment,{children:[`done`,e.idleSince?` · ${Tp(e.idleSince)}`:``]})};let i=e.agents?.length??0;return i&&e.idle?{cls:`coding`,title:e.agents.map(e=>e.what).join(` · `)+` — open the session to see what they are doing`,body:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Uo,{size:12}),` `,i,` agent`,i===1?``:`s`]})}:{cls:`coding`,title:``,body:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)($s,{size:12,className:`spin`}),` coding`]})}}function EK(e,t=Date.now()){let n=Yn(e.peerWait,t);if(!n)return null;let r=e.peerWait?.state;return{cls:r===`failed`||r===`refused`||r===`unreachable`?`limit`:`wait`,title:``,body:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Wa,{size:12}),` `,n]})}}function DK(e){let t=Sr(e.contextSpark?.costUsd,e.peerJobs);return t?{cls:`idle`,title:`${t.text} — list-price estimates, each measured on the desktop that spent it; never added into one figure`,body:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Wa,{size:12}),` `,t.text]})}:null}function OK(e){let t=Kee(e.peerJob);return t?{cls:`idle`,title:`${t} — another desktop handed this session its work; its answer goes back there`,body:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Wa,{size:12}),` `,t]})}:null}function kK(e){return(e.peerJobs??[]).flatMap(e=>{let t=cte(e);return t?[{key:e.jobId,text:t,bad:e.state===`failed`||e.state===`refused`||e.state===`unreachable`}]:[]})}function AK(e){if(!e.running||e.contextLeft==null)return null;let t=e.contextLeft;return{cls:t<=15?`ctx-low`:t<=40?`ctx-mid`:`ctx-ok`,title:`${t}% of the context window free`,body:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Ts,{size:12}),` `,t,`%`]})}}function jK(e){if(!e.running)return null;let t=Dee(e.contextSpark,{lastTurnAt:e.lastTurnAt,turnActive:e.turnActive,now:Date.now()});return!t||!t.chip?null:{cls:t.level===`steep`?`cost-steep`:t.level===`heavy`?`cost-heavy`:`cost-warm`,title:`${t.note}${t.advice?`\n\n${t.advice}`:``}\n\nTap the context readout for the whole picture. Nothing here stops you.`,body:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(nl,{size:12}),` `,t.chip]}),reading:t}}function MK({s:e,repoLabel:t,backendLabel:n,backends:r}){let i=TK(e,r),a=AK(e),o=jK(e),s=EK(e),c=DK(e),l=OK(e),u=kK(e);return(0,J.jsxs)(`span`,{className:`sess-facts`,children:[(0,J.jsxs)(`span`,{className:`sess-facts-tags`,children:[(0,J.jsx)(qw,{className:i.cls,title:i.title,children:i.body}),a&&(0,J.jsx)(qw,{className:a.cls,title:a.title,children:a.body}),o&&(0,J.jsx)(qw,{className:o.cls,title:o.title,children:o.body}),s&&(0,J.jsx)(qw,{className:s.cls,title:s.title,children:s.body}),c&&(0,J.jsx)(qw,{className:c.cls,title:c.title,children:c.body}),l&&(0,J.jsx)(qw,{className:l.cls,title:l.title,children:l.body}),(0,J.jsx)(Q,{className:`row-launch`,children:wK(yK(e),n,r)}),e.createdAt&&e.running&&(0,J.jsxs)(Q,{title:`session open for ${Op(e.createdAt)} — started ${new Date(e.createdAt).toLocaleString()}`,children:[(0,J.jsx)(os,{size:11}),` `,Op(e.createdAt)]}),t&&(0,J.jsx)(Q,{children:t})]}),u.map(e=>(0,J.jsx)(Q,{className:`peer-job-line${e.bad?` warn`:``}`,children:e.text},e.key)),(0,J.jsx)(pK,{firstPrompt:e.firstPrompt,lastPrompt:e.lastPrompt,pinnedPrompt:e.pinnedPrompt})]})}function NK(e){return e.claudeSessionId??e.backendSessionId}function PK(e){return e?`resumes exactly this conversation`:`carries on this folder’s most recent conversation — which may not be this one`}function FK(e){return[...e].sort((e,t)=>e.repoName.localeCompare(t.repoName)||(e.isPrimary===t.isPrimary?e.branch.localeCompare(t.branch):e.isPrimary?-1:1))}function IK({root:e,repos:t,onOpen:n,onChanged:r,onClose:i,backends:a,backend:o,onBackend:s,onBuildApp:c}){let[l,u]=(0,V.useState)(`repo`),d=a?fw(a,o??`claude`):null,[f,p]=(0,V.useState)(``),[m,h]=(0,V.useState)(``),[g,_]=(0,V.useState)(``),[v,y]=(0,V.useState)(!0),[b,x]=(0,V.useState)(t[0]?.id??``),[S,C]=(0,V.useState)(``),[w,T]=(0,V.useState)(null),[E,D]=(0,V.useState)(null),[O,k]=(0,V.useState)(!1),A=t.filter(e=>e.isPrimary),j=l===`clone`?`Clone & open`:l===`repo`?`Create project & open`:l===`folder`?`Create folder`:`Create worktree & open`,M=l===`worktree`?A.length?S?``:`name the new branch first`:`no repo on this desktop to branch from`:l===`clone`?g.trim()?``:`paste a URL first`:f?``:`name the new ${l===`repo`?`project`:`folder`} first`;async function N(){k(!0),T(null);try{if(l===`folder`){let t=await H.newFolder(e,f);T(t.error?`Error: ${t.error}`:`Created ${t.path}`),t.path&&r()}else if(l===`clone`){q(`action:repo.clone`);let t=await H.cloneRepo(e,g.trim(),f.trim());if(t.error)T(`Error: ${t.error}`);else{r();let e=t.path.split(`/`).pop()||`clone`;t.warning?(D({path:t.path,title:e}),T(`Cloned into ${t.path}${t.branch?` on ${t.branch}`:``} — ${t.warning}`)):n(t.path,e)}}else if(l===`repo`){q(v?`action:repo.new.project`:`action:repo.new.bare`);let t=await H.newRepo(e,f,{setup:v,description:m});t.error?T(`Error: ${t.error}`):(r(),t.warning?(D({path:t.path,title:f}),T(`Created ${t.path} on ${t.branch}${t.files?.length?` · ${t.files.join(`, `)}`:``} — ${t.warning}`)):n(t.path,f))}else{let e=await H.newWorktree(b,S);e.error?T(`Error: ${e.error}`):(r(),n(e.path,`${t.find(e=>e.id===b)?.repoName} · ${e.branch}`))}}catch(e){T(Qe(e)?`No connection — a project is created on the desktop, so this needs the link. Nothing was written.`:`Error: ${String(e?.message||e)}`)}finally{k(!1)}}return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:`New`,onClose:i}),(0,J.jsxs)(`div`,{className:`annot-tools`,children:[(0,J.jsx)(Y,{className:l===`repo`?`active`:``,onClick:()=>u(`repo`),children:`project`}),(0,J.jsx)(Y,{className:l===`clone`?`active`:``,onClick:()=>u(`clone`),children:`clone`}),(0,J.jsx)(Y,{className:l===`folder`?`active`:``,onClick:()=>u(`folder`),children:`folder`}),(0,J.jsx)(Y,{className:l===`worktree`?`active`:``,onClick:()=>u(`worktree`),children:`worktree`})]}),(0,J.jsxs)(`div`,{className:`form`,children:[(0,J.jsx)(Z,{children:e}),l===`clone`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`input`,{className:`search`,type:`url`,inputMode:`url`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,placeholder:`https://github.com/owner/repo or git@host:owner/repo`,value:g,onChange:e=>_(e.target.value),autoFocus:!0}),(0,J.jsx)(`input`,{className:`search`,placeholder:`folder name (optional — taken from the URL)`,value:f,onChange:e=>p(e.target.value)}),(0,J.jsx)(Z,{children:`Cloned on the desktop with its own git sign-in, so private repos work where the desktop can reach them. The phone's inbox and outbox are excluded in this clone only — the project itself is not changed. A big repo takes a while; this sheet waits.`})]}),l!==`worktree`&&l!==`clone`&&(0,J.jsx)(`input`,{className:`search`,placeholder:l===`repo`?`new project name`:`new folder name`,value:f,onChange:e=>p(e.target.value),autoFocus:!0}),l===`repo`&&c&&(0,J.jsxs)(Y,{className:`new-buildapp`,onClick:c,children:[(0,J.jsx)(ys,{size:14}),` build an app — a phone app or a web page from a template, built and ready to change`]}),l===`repo`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`input`,{className:`search`,placeholder:`one line: what is it? (optional)`,value:m,onChange:e=>h(e.target.value)}),(0,J.jsxs)(Y,{className:v?`active`:``,onClick:()=>y(!v),children:[v&&(0,J.jsx)(vc,{size:14}),` set up for phone use`]}),(0,J.jsx)(Z,{children:v?`git init on main + first commit, .gitignore, README, CLAUDE.md, and the .claude/outbox drop the phone gallery reads.`:`bare git init + empty first commit only.`})]}),l===`worktree`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`select`,{className:`search`,value:b,onChange:e=>x(e.target.value),children:A.map(e=>(0,J.jsx)(`option`,{value:e.id,children:e.repoName},e.id))}),(0,J.jsx)(`input`,{className:`search`,placeholder:`new branch name`,value:S,onChange:e=>C(e.target.value)})]}),a&&a.length>1&&s&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`select`,{className:`search`,value:o??`claude`,onChange:e=>s(e.target.value===`claude`?void 0:e.target.value),children:a.map(e=>(0,J.jsx)(`option`,{value:e.id,children:pw(e)},e.id))}),(0,J.jsxs)(Z,{children:[`The session this opens runs `,a.find(e=>e.id===(o??`claude`))?.label??`the default`,`. Every new session does, until you change it back.`,d?(0,J.jsxs)(J.Fragment,{children:[` `,d]}):null]})]}),O?(0,J.jsxs)(Z,{children:[(0,J.jsx)(Js,{size:13,className:`spin`,style:{verticalAlign:`-2px`}}),` `,l===`clone`?`Cloning on the desktop — a big repo takes a while`:`Working…`]}):M?(0,J.jsx)(Qw,{cants:[{label:j,reason:M}]}):(0,J.jsx)(`button`,{className:`send`,onClick:N,children:j}),w&&(0,J.jsx)(Z,{children:w}),E&&(0,J.jsx)(`button`,{className:`send`,onClick:()=>n(E.path,E.title),children:`Open session anyway`})]})]})}function LK({backends:e,backend:t,value:n,onChange:r,placeholder:i}){let[a,o]=(0,V.useState)(null);(0,V.useEffect)(()=>Xg(),[]);let s=Kg(e=>Mie(e.last,e.now),!0),c=KC(e,t),l=EC(e,t)?.models.note?.trim()||null;if(c.freeText){let e=(0,J.jsx)(`input`,{className:`search`,placeholder:i??`model id (blank = this backend’s default)`,value:n??``,onChange:e=>r(e.target.value.trim()||void 0)});return l?(0,J.jsxs)(`div`,{className:`model-field`,children:[e,(0,J.jsx)(X,{children:l})]}):e}let u=new Set([...c.aliases,...c.ids]),d=n&&!u.has(n)?n:null,f=EC(e,t),p=lw(c.ids,f?.models.where),m=f?.models.zeroCost,h=uw(p),g=a&&p.some(e=>e.where===a)?a:null,_=g?p.filter(e=>e.where===g):p,v=g?ow[g]:null,y=f?.models.where,b=!!n&&y?.[n]===`hosted`,x=n&&y?.[n]===`local`&&s?See(s.models,ote(n),s.memFree):null,S=n?vr(f?.models.contextWindow?.[n],f?.models.overheadTok?.[n]):null,C=g===`hosted`||b,w=b?cw(m,n):(p.find(e=>e.where===`hosted`)?.ids??[]).some(e=>cw(m,e));return(0,J.jsxs)(`div`,{className:`model-field`,children:[h&&(0,J.jsx)(`div`,{className:`fchips wrap model-where`,children:p.map(e=>(0,J.jsxs)(zw,{on:g===e.where,onClick:()=>o(g===e.where?null:e.where),children:[aw[e.where],` · `,e.ids.length]},e.where))}),v&&(0,J.jsx)(X,{children:v}),x&&(0,J.jsx)(X,{children:x}),S&&(0,J.jsx)(X,{children:S}),C&&(0,J.jsxs)(`div`,{className:`model-warn`,children:[(0,J.jsx)(gs,{size:14}),(0,J.jsx)(`span`,{children:sw})]}),C&&w&&(0,J.jsxs)(`div`,{className:`model-warn`,children:[(0,J.jsx)(gs,{size:14}),(0,J.jsx)(`span`,{children:`Free of charge is not free of cost: providers of no-charge tiers commonly keep prompts and completions to train on. Check what this one takes before sending anything you would not publish.`})]}),(0,J.jsxs)(`select`,{value:n??``,onChange:e=>r(e.target.value||void 0),children:[(0,J.jsx)(`option`,{value:``,children:`default`}),d&&(0,J.jsxs)(`option`,{value:d,children:[d,` — not in this list`]}),c.aliases.length>0&&!g&&(0,J.jsx)(`optgroup`,{label:`Aliases — always the newest`,children:c.aliases.map(e=>(0,J.jsx)(`option`,{value:e,children:e},e))}),_.map(e=>(0,J.jsx)(`optgroup`,{label:e.where===`unknown`&&p.length===1?`Versions`:aw[e.where],children:e.ids.map(e=>(0,J.jsx)(`option`,{value:e,children:e},e))},e.where))]}),l&&(0,J.jsx)(X,{children:l}),g&&n&&!_.some(e=>e.ids.includes(n))&&(0,J.jsxs)(X,{children:[`Still set to `,(0,J.jsx)(`code`,{children:n}),`, which is not in this group.`]})]})}function RK(e){return e.aliases.length>0?e.aliases:e.ids}function zK(e,t,n=[]){let r=RK(e).filter(e=>e===t||!n.includes(e)),i=t&&!r.slice(0,9).includes(t)?8:9,a=r.slice(0,i);return t&&!a.includes(t)&&a.push(t),a}function BK(e){return e.replace(/^claude-/i,``).replace(/\[1m\]$/i,` 1M`)}function VK(e,t,n,r=8){return Math.max(r,Math.min(e+6,n-t-r))}function HK(e,t){return-Math.PI/2+e*2*Math.PI/t}function UK(e,t){return t.rings<=1?t.rOut:t.rIn+e*(t.rOut-t.rIn)/(t.rings-1)}function WK(e,t,n){let r=HK(e,n.spokes),i=UK(t,n);return{x:i*Math.cos(r),y:i*Math.sin(r)}}function GK(e,t,n){let r=Math.hypot(e,t),i=n.rings>1?(n.rOut-n.rIn)/(n.rings-1):n.rOut-n.rIn;if(r<Math.min(n.rIn*.45,n.rIn-i/2)||r>n.rOut+Math.max(i,18))return null;let a=2*Math.PI,o=((Math.atan2(t,e)+Math.PI/2)%a+a)%a;return{spoke:Math.round(o/(a/n.spokes))%n.spokes,ring:n.rings<=1?0:Math.max(0,Math.min(n.rings-1,Math.round((r-n.rIn)/i)))}}function KK(e,t,n){let r=t.model!==e.model,i=t.effort!=null&&t.effort!==e.effort;if(!r&&!i)return{kind:`none`};let a=n.slash&&n.effort;if(!n.slash||i&&!a)return{kind:`relaunch`,patch:{...r?{model:t.model}:{},...i?{effort:t.effort}:{}}};let o=[];return r&&o.push(`/model ${t.model}`),i&&o.push(`/effort ${t.effort}`),{kind:`live`,commands:o,...r?{model:t.model}:{},...i?{effort:t.effort}:{}}}function qK(e,t){let n=JK(e,t);return n&&qt(n)?n:null}function JK(e,t){if(!e)return null;let n=e.replace(/\[1m\]$/i,``);return n.startsWith(`claude-`)?n:/^(opus|sonnet|haiku|fable)$/.test(n)?t.map(e=>e.replace(/\[1m\]$/i,``)).find(e=>e.startsWith(`claude-${n}-`))??null:null}function YK(e,t){if(!e.turnModel)return{model:e.model,effort:e.effort,from:`launch`};let n=e.turnModel;return{model:JK(e.model,t.ids)===n?e.model:t.aliases.find(e=>!/\[1m\]$/i.test(e)&&JK(e,t.ids)===n)??n,effort:e.turnEffort??e.effort,from:`turn`}}function XK(e,t,n){return t.from===`turn`&&(!e.model||e.model===t.model||JK(e.model,n)!=null&&JK(e.model,n)===JK(t.model,n))&&(!e.effort||e.effort===t.effort)}function ZK(e){let t=e.to.model!==e.from.model,n=e.to.effort!=null&&e.to.effort!==e.from.effort;if(!t&&!n)return null;if(e.cold===!0)return`Nothing has run here for over an hour and a half, so the cache has very likely expired already — the next turn re-writes the context whatever you pick, and switching adds nothing to that.`;if(t){let t=`The prompt cache belongs to one model, so the next turn re-writes`;if(e.tok==null||e.tok<=0)return`${t} the whole context into the new model's cache instead of re-reading it.`;let n=qK(e.to.model,e.ids),r=qK(e.from.model,e.ids),i=n?qt(n):null,a=r?qt(r):null,o=`all ${er(e.tok)} tokens of context`;if(!i)return`${t} ${o} instead of re-reading them. No list price for ${e.to.model}, so no figure.`;let s=e.tok*i.input*2/1e6,c=a?e.tok*(a.cacheRead??a.input*.1)/1e6:null;return`${t} ${o}: ≈ ${_t(s)} at list prices (as ${n})${c==null?``:`, where staying re-reads it for ≈ ${_t(c)}`}. Turns after that run at the new model's rates.`}let r=`Changing effort resets the conversation part of the cache, so the next turn re-writes`,i=e.tok!=null&&e.baseTok!=null?Math.max(0,e.tok-e.baseTok):null;if(i==null||i<=0)return`${r} the conversation instead of re-reading it.`;let a=qK(e.from.model,e.ids),o=a?qt(a):null;if(!o)return`${r} about ${er(i)} tokens instead of re-reading them.`;let s=i*o.input*2/1e6,c=i*(o.cacheRead??o.input*.1)/1e6;return`${r} about ${er(i)} tokens: ≈ ${_t(s)} at list prices, where re-reading them costs ≈ ${_t(c)}.`}var QK=380,$K=300,eq=40,tq=112,nq=128;function rq({spokes:e,efforts:t,current:n,value:r,onPick:i}){let a={spokes:e.length,rings:Math.max(1,t.length),rIn:eq,rOut:tq},o=n?.model?e.indexOf(n.model):-1,s=n?.effort?t.indexOf(n.effort):-1,c=r?e.indexOf(r.model):-1,l=r?.effort?t.indexOf(r.effort):t.length===0&&r?0:-1,u=(0,V.useRef)(null),d=(0,V.useRef)(!1),f=n=>{let r=u.current?.getScreenCTM();if(!r)return;let o=new DOMPoint(n.clientX,n.clientY).matrixTransform(r.inverse()),s=GK(o.x,o.y,a);s&&i({model:e[s.spoke],effort:t.length>0?t[s.ring]:null})},p=HK(.5,a.spokes);return(0,J.jsxs)(`svg`,{ref:u,className:`model-wheel`,viewBox:`-190 -150 ${QK} ${$K}`,role:`img`,"aria-label":`model and effort wheel`,onPointerDown:e=>{d.current=!0,e.currentTarget.setPointerCapture(e.pointerId),f(e)},onPointerMove:e=>{d.current&&f(e)},onPointerUp:()=>{d.current=!1},onPointerCancel:()=>{d.current=!1},children:[Array.from({length:a.rings},(e,t)=>(0,J.jsx)(`circle`,{cx:0,cy:0,r:UK(t,a),className:`mw-ring`},t)),e.map((e,t)=>{let n=HK(t,a.spokes),r=Math.cos(n),i=Math.abs(r)<.2?`middle`:r>0?`start`:`end`,s=`mw-label${t===o?` cur`:``}${t===c?` sel`:``}`;return(0,J.jsxs)(`g`,{children:[(0,J.jsx)(`line`,{x1:0,y1:0,x2:tq*r,y2:tq*Math.sin(n),className:`mw-spoke`}),(0,J.jsx)(`text`,{x:nq*r,y:nq*Math.sin(n),textAnchor:i,dominantBaseline:`middle`,className:s,children:BK(e)})]},e)}),t.length>1&&t.map((e,t)=>{let n=UK(t,a);return(0,J.jsx)(`text`,{x:n*Math.cos(p),y:n*Math.sin(p),textAnchor:`middle`,dominantBaseline:`middle`,className:`mw-effort${l===t?` sel`:``}`,children:e},e)}),e.map((e,n)=>Array.from({length:a.rings},(r,i)=>{let u=WK(n,i,a),d=n===o&&(t.length===0||i===s),f=n===c&&i===l;return(0,J.jsx)(`circle`,{cx:u.x,cy:u.y,r:f?8:d?6.5:3.5,className:`mw-node${d?` cur`:``}${f?` sel`:``}`},`${e}:${i}`)})),(0,J.jsx)(`circle`,{cx:0,cy:0,r:3,className:`mw-hub`})]})}function iq({cat:e,efforts:t,current:n,value:r,onPick:i,onClear:a,now:o,says:s,children:c}){let[l,u]=(0,V.useState)(()=>ma(R.wheelHidden,[])),d=n?.model??r?.model,f=zK(e,d,l),p=RK(e),m=p.filter(e=>!l.includes(e)),h=e=>{let t=l.includes(e)?l.filter(t=>t!==e):[...l,e];u(t),Ta(R.wheelHidden,t),t.includes(e)&&r?.model===e&&e!==d&&a?.()};return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`mw-now muted`,children:o}),(0,J.jsx)(Z,{className:`mw-says`,children:s}),(0,J.jsx)(rq,{spokes:f,efforts:t,current:n,value:r,onPick:i}),c,p.length>1&&(0,J.jsxs)(`div`,{className:`mw-models`,children:[(0,J.jsxs)(`div`,{className:`mw-models-head muted`,children:[`On the wheel · `,f.length,` of `,p.length]}),(0,J.jsx)(`div`,{className:`mw-chips`,children:p.map(e=>{let t=!l.includes(e);return(0,J.jsx)(`button`,{className:`row-chip${t?` on`:``}`,"aria-pressed":t,onClick:()=>h(e),children:BK(e)},e)})}),d&&l.includes(d)&&(0,J.jsxs)(Z,{children:[BK(d),` stays on the wheel while it is `,n?`this session’s model`:`the pick`,`.`]}),m.length>9&&(0,J.jsxs)(Z,{children:[`The wheel holds `,9,`; the first `,9,` chips that are on are drawn.`]})]})]})}var aq=e=>TC({backend:e})===bC;function oq(e,t){return{...e,backend:t.backend,model:t.model,...aq(t.backend)?{effort:t.effort}:{}}}function sq({backends:e,value:t,onChange:n,defaults:r,nowLead:i,children:a}){let{backend:o,model:s,effort:c}=t,l=aq(o),[u,d]=(0,V.useState)(!1),f=AC(e),p=e=>n({backend:e,model:void 0,effort:e===r.backend?r.effort:void 0}),m=e=>n({...t,model:e}),h=YC(e,o),g=KC(e,o),_=l?zK(g,s):[],v=o===r.backend&&s===r.model&&c===r.effort,y=ew(e,o),b=fw(e,o);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(JS,{children:[f&&(0,J.jsxs)(`label`,{children:[`backend`,(0,J.jsx)(`select`,{value:o??`claude`,onChange:e=>p(e.target.value===`claude`?void 0:e.target.value),children:OC(e).map(e=>(0,J.jsx)(`option`,{value:e.id,children:pw(e)},e.id))})]}),!l&&(0,J.jsxs)(`label`,{children:[`model`,(0,J.jsx)(LK,{backends:e,backend:o,value:s,onChange:m})]}),y&&(0,J.jsxs)(X,{as:`span`,children:[y,`.`]}),b&&(0,J.jsx)(X,{as:`span`,children:b}),a]}),l&&_.length>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(iq,{cat:g,efforts:h,value:s?{model:s,effort:c??null}:null,onPick:e=>n({...t,model:e.model,...e.effort?{effort:e.effort}:{}}),now:(0,J.jsxs)(J.Fragment,{children:[i,` `,s||`the default model`,h.length>0?` · ${c||`default effort`}`:``]}),says:`Tap or drag to a point${h.length>0?` — centre is low effort, the rim is max`:``}.`}),(0,J.jsxs)(`div`,{className:`sched-days`,children:[(0,J.jsx)(`button`,{className:`row-chip${u?` on`:``}`,"aria-pressed":u,onClick:()=>d(!u),children:`a specific version…`}),!v&&(0,J.jsx)(`button`,{className:`row-chip`,onClick:()=>n({backend:r.backend,model:r.model,effort:r.effort}),children:`back to my defaults`})]}),u&&(0,J.jsx)(JS,{children:(0,J.jsx)(LK,{backends:e,backend:o,value:s,onChange:m})})]})]})}function cq({title:e,backends:t,defaults:n,budget:r,onStart:i,onRecheck:a,onClose:o}){let[s,c]=(0,V.useState)(!1),[l]=(0,V.useState)(()=>{let e=ma(R.launchLast,null),r=iw(t,n,e),i=!!e&&r.backend===e.backend&&r.model===e.model;return{...r,effort:i?e.effort??n.effort:n.effort}}),[u,d]=(0,V.useState)(l.backend),[f,p]=(0,V.useState)(l.model),[m,h]=(0,V.useState)(l.effort),g=aq(u),[_,v]=(0,V.useState)(r??null),[y,b]=(0,V.useState)(!!r),x=AC(t),S=dw(t,u);return(0,J.jsxs)(`div`,{className:`sheet`,"data-primary-key":``,children:[(0,J.jsx)(Uw,{title:`Start with…`,onClose:o}),(0,J.jsxs)(`div`,{className:`sheet-scroll`,children:[(0,J.jsxs)(Z,{children:[e,` — `,x?`which binary and which model`:`which model`,g?` and effort`:``,` this session runs. Just this one: your new-session defaults don’t change, and everything else about the launch (`,g?`permission mode`:`effort, permission mode`,`) still comes from them.`]}),(0,J.jsxs)(`div`,{className:`form`,children:[(0,J.jsx)(sq,{backends:t,defaults:n,nowLead:`Starts on`,value:{backend:u,model:f,effort:m},onChange:e=>{d(e.backend),p(e.model),h(e.effort)}}),(0,J.jsx)(`div`,{className:`sched-days budget-chip-row`,children:(0,J.jsxs)(`button`,{className:`row-chip${_?` on`:``}`,"aria-pressed":y,onClick:()=>b(!y),children:[(0,J.jsx)(Qc,{size:13}),` `,_?Nw(_):`budget…`]})}),y&&(0,J.jsx)(cD,{initial:_??r??null,onChange:v,windowsOff:hw(t,u),calFor:`A percent is converted from dollars at the window's measured rate once this session is running — until there is a fresh usage reading, nothing is held.`}),(0,J.jsx)(Z,{children:`Closing this starts nothing — nothing is queued until you press Start.`})]})]}),(0,J.jsx)(`div`,{className:`sheet-actions`,children:S?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`act-cants`,children:(0,J.jsx)($w,{children:S})}),a&&(0,J.jsxs)(`button`,{className:`send`,onClick:()=>{c(!0),a()},children:[(0,J.jsx)(Ds,{size:14}),` Check again`]}),s&&(0,J.jsx)(Z,{children:`Asked the desktop to look again — if the sentence above is still here, it is still not reachable. Start appears here by itself once it is.`})]}):(0,J.jsxs)(`button`,{className:`send`,onClick:()=>{Ta(R.launchLast,{backend:u,model:f,...g?{effort:m}:{}}),i(oq(n,{backend:u,model:f,effort:m}),_)},children:[(0,J.jsx)(La,{size:14}),` Start `,e]})})]})}function lq({title:e,backends:t,launch:n,onAccept:r,onClose:i}){let a=EC(t,n.backend),o=n.model??``,s=cw(a?.models.zeroCost,o);return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:`Before this starts`,onClose:i}),(0,J.jsxs)(Z,{children:[e,` would run `,(0,J.jsx)(`b`,{children:o}),a&&a.id!==`claude`?(0,J.jsxs)(J.Fragment,{children:[` on `,a.label]}):null,`, which is a hosted model — it runs on somebody’s server, not on the Mac.`]}),(0,J.jsxs)(`div`,{className:`form`,children:[(0,J.jsxs)(`div`,{className:`model-warn`,children:[(0,J.jsx)(gs,{size:14}),(0,J.jsx)(`span`,{children:sw})]}),s&&(0,J.jsxs)(`div`,{className:`model-warn`,children:[(0,J.jsx)(gs,{size:14}),(0,J.jsx)(`span`,{children:`Free of charge is not free of cost: providers of no-charge tiers commonly keep prompts and completions to train on. Check what this one takes before sending anything you would not publish.`})]}),(0,J.jsxs)(Z,{children:[`The long form is §2 of `,(0,J.jsx)(`b`,{children:`DISCLAIMER.md`}),` in this repo.`]}),(0,J.jsxs)(`button`,{className:`send`,onClick:r,children:[(0,J.jsx)(La,{size:14}),` I understand — start `,e]}),(0,J.jsx)(Z,{children:`Closing this starts nothing — nothing is queued until you accept. Asked once on this phone; the settings screen can bring it back.`})]})]})}var uq=W(void 0),dq=W(!1),fq=W(new Set),pq=W(null),mq=()=>G(uq),hq=()=>G(dq);function gq(e){return e.demo?`none`:e.job&&(e.job.state===`running`||e.job.state===`stopped`)?`job`:e.dismissed||!e.online||!_q(e)?`none`:`first-run`}function _q(e){return e.sessions===0&&e.recent===0&&e.closed===0}function vq(e){return e<=0?null:`Or tap + now on one of your ${e} repo${e===1?``:`s`} below to open a session in it.`}var yq=[`otter`,`maple`,`comet`,`pebble`,`tulip`,`harbor`,`falcon`,`meadow`,`lantern`,`ember`,`willow`,`quartz`,`breeze`,`cedar`,`puffin`,`sparrow`,`river`,`aurora`,`clover`,`nova`];function bq(e=Math.random){return`hello-${yq[Math.min(yq.length-1,Math.max(0,Math.floor(e()*yq.length)))]}`}function xq(e){return e?`android`:`web`}function Sq(e){let t=e.describe?e.description.trim():``;return{name:e.name.trim(),path:e.path,...t?{description:t}:{},setup:e.setup}}function Cq(e){return e.name.trim()?e.describe&&!e.description.trim()?`Say in one line what it should do, or choose plain hello world.`:null:`Give the app a name first.`}function wq(e){if(typeof e!=`number`||!Number.isFinite(e)||e<=0)return;let t=Math.max(1,Math.round(e/1048576));return t>=1e3?`about ${(t/1024).toFixed(1)} GB to download`:`about ${t} MB to download`}var Tq=`This browser cannot install apps: the APK will be in the gallery to download, and the ${I.displayName} app on an Android phone installs it.`;function Eq(e,t){return e.consent.map(e=>({id:e.id,what:e.what,required:e.required,...e.where&&!e.what.includes(e.where)?{where:e.where}:{},...wq(e.bytes)?{size:wq(e.bytes)}:{},...e.link?{link:e.link}:{},...e.phone&&e.id===`installApps`&&!t?{cant:Tq}:{}}))}function Dq(e){let t={};for(let n of e)n.cant||(t[n.id]=!0);return t}function Oq(e,t){let n={};for(let r of e)t[r.id]===!0&&!r.cant&&(n[r.id]=!0);return n}function kq(e,t){let n=e.filter(e=>e.required&&t[e.id]!==!0);if(!n.length)return null;let r=n.some(e=>e.id===`toolchain`);return`Go needs ${n.length===1?`the line`:`the lines`} marked "needed" ticked.`+(r?` Without the Android build tools, a web page needs nothing installed.`:``)}function Aq(e){return e.steps.filter(e=>e.needed).map(e=>e.what)}var jq={scaffold:`repo`,toolchain:`toolchain`,"signing-key":`signingKey`,session:`session`},Mq={pending:`pending`,running:`running`,done:`done`,skipped:`skipped`,failed:`stopped`,"needs-you":`stopped`,"needs-consent":`stopped`};function Nq(e){let t=Math.max(0,Math.floor(e/1e3)),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60,a=e=>String(e).padStart(2,`0`);return n?`${n}:${a(r)}:${a(i)}`:`${r}:${a(i)}`}function Pq(e,t){return e.steps.map(e=>{let n={id:e.id,icon:Mq[e.status]??`pending`,what:e.what};e.note&&(n.note=e.note);let r=e.startedAt,i=e.endedAt;if(e.status===`running`&&typeof r==`number`?n.clock=Nq(t-r):e.status===`done`&&typeof r==`number`&&typeof i==`number`&&i-r>=1e3&&(n.clock=Nq(i-r)),e.status===`needs-consent`){let t=jq[e.id];n.fix=t?{verb:`allow`,consent:t}:{verb:`retry`}}else(e.status===`failed`||e.status===`needs-you`)&&(n.fix={verb:`retry`});return e.command&&(e.status===`failed`||e.status===`needs-you`)&&(n.command=e.command),n})}function Fq(e,t){return e.verb===`allow`?`allow it and carry on`:t===`needs-you`?`I ran it — carry on`:`retry`}function Iq(e){return e.state===`done`?`${e.name} is ready.`:e.state===`stopped`?`Stopped: ${e.summary}`:e.summary&&e.summary!==`starting`?e.summary:`Making ${e.name}…`}function Lq(e){if(!e.artifact||!e.repoId)return null;let t=e.artifact.split(`/`).pop()||e.artifact;return{repoId:e.repoId,relPath:e.artifact,name:t}}function Rq(e,t,n){if(e.consent.session!==!0)return{kind:`none`,why:`You chose not to run claude in the new repo; open a session from its row when you want one.`};if(e.sessionId){if(!t.has(e.sessionId))return{kind:`wait`,why:`The session is open on the desktop but not on this phone's list yet; try again in a moment.`};let r=!e.answers.description&&!n&&e.suggestedPrompt?e.suggestedPrompt:null;return{kind:`attach`,sessionId:e.sessionId,seed:r}}return e.intentId?{kind:`follow`,intentId:e.intentId}:{kind:`wait`,why:`The session has not opened yet.`}}function zq(e,t){return!t||e.includes(t)?[...e]:[...e,t]}var Bq=`Android's "install unknown apps" is off for ${I.displayName}, so the app cannot be installed yet. Turn it on once; every later build installs quietly.`,Vq=`This desktop's ${I.displayName} does not build first apps yet: update it, then try again.`;function Hq(){let e=U();e.say.track(`overlay:onboard`),e.nav.open(`onboard`)}function Uq(){U().nav.close(`onboard`)}function Wq(){pq.set(null)}function Gq(){dq.set(!0)}function Kq(e){uq.set(t=>t&&e&&t.id===e.id&&t.updatedAt>e.updatedAt?t:e)}async function qq(){try{Kq((await H.onboardJob())?.job??null)}catch{uq.get()===void 0&&uq.set(null)}}function Jq(e,t){if(Qe(e))return`No connection — ${t} needs the desktop. Nothing was started.`;let n=String(e?.message??e);return/^404\b/.test(n)?Vq:`${t} failed: ${n}`}async function Yq(e){try{let t=await H.onboardPlan(e);return t.ok?t:{error:t.error??`the desktop refused these answers`}}catch(e){return{error:Jq(e,`Reading the plan`)}}}async function Xq(e,t,n){U().say.track(`action:onboard.go`);try{let r=await H.onboardStart(e,t,n);return!r.ok||!r.job?{error:r.error??`the desktop did not start the job`}:(Kq(r.job),pq.set(r.job.id),t.installApps===!0&&Qq(r.job.packageId),{ok:!0,job:r.job})}catch(e){return{error:Jq(e,`Starting`)}}}async function Zq(e){U().say.track(`action:onboard.resume`);try{let t;if(e){let e=await H.onboardJob();Kq(e?.job??null),t=e?.confirm}let n=await H.onboardResume(e,t);return!n.ok||!n.job?n.error??`the desktop did not carry on`:(Kq(n.job),null)}catch(e){return Jq(e,`Carrying on`)}}function Qq(e){if(!e)return;let t=Nk(),n=zq(t,e);n.length!==t.length&&Pk(n)}async function $q(){if(!Dk())return null;let{caps:e}=await Ok();return e.supported?!e.canInstall:null}async function eJ(){try{await Ak()}catch(e){U().say.toast(String(e?.message??e))}}function tJ(e){let t=U(),n=Rq(e,new Set(t.world.sessions.map(e=>e.id)),fq.get().has(e.id));if(n.kind===`none`||n.kind===`wait`){t.say.toast(n.why);return}if(t.say.track(`action:onboard.handoff`),n.kind===`follow`){t.nav.followFire(n.intentId),t.say.toast(`Your description is the first prompt; the session opens when it starts.`);return}let r=t.world.sessions.find(e=>e.id===n.sessionId);n.seed&&(t.compose.seedDraft(r.id,n.seed),fq.set(t=>new Set([...t,e.id]))),t.nav.attach(r),n.seed&&t.say.toast(`A first prompt is in the box: change it or send it.`)}function nJ(e,t){let n=U();t===`web`?n.files.openArtifact(e):n.files.downloadArtifact(e)}function rJ(){let e=mq(),t=G(pq);(0,V.useEffect)(()=>{uq.get()===void 0&&qq()},[]);let n=Dk(),r=!!e&&(e.state!==`done`||e.id===t),[i,a]=(0,V.useState)(r?`progress`:`questions`),[o,s]=(0,V.useState)(()=>({name:bq(),path:xq(n),describe:!1,description:``,setup:!0})),[c,l]=(0,V.useState)(null),[u,d]=(0,V.useState)(null),[f,p]=(0,V.useState)(!1),m=(0,V.useRef)(e!==void 0);(0,V.useEffect)(()=>{m.current||e===void 0||(m.current=!0,e&&(e.state!==`done`||e.id===t)&&a(`progress`))},[e,t]),(0,V.useEffect)(()=>{e&&e.state===`running`&&i!==`progress`&&a(`progress`)},[e,i]),Gh(i===`consent`,()=>{a(`questions`),d(null)});let h=async e=>{p(!0),d(null);let t=await Yq(Sq(e));p(!1),`steps`in t?(l(t),a(`consent`)):d(t.error)},g=i===`progress`&&e?e.name:`Build your first app`,_=(0,J.jsx)(ys,{size:18});if(i===`progress`&&e)return(0,J.jsx)(Hw,{title:g,icon:_,onClose:Uq,children:(0,J.jsx)(sJ,{job:e,onAnother:()=>{Wq(),l(null),s(e=>({...e,name:bq()})),a(`questions`)}})});if(i===`consent`&&c)return(0,J.jsx)(iJ,{plan:c,canInstall:n,title:g,icon:_,onBack:()=>{a(`questions`),d(null)},onWeb:()=>{let e={...o,path:`web`};s(e),h(e)},onStarted:()=>a(`progress`)});let v=Cq(o),y=e=>{s(t=>({...t,...e})),d(null)};return(0,J.jsx)(Hw,{title:g,icon:_,onClose:Uq,footer:v?(0,J.jsx)(`span`,{className:`onb-why`,children:v}):(0,J.jsx)(`button`,{className:`send onb-next`,onClick:()=>void h(o),children:f?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)($s,{size:14,className:`spin`}),` asking the desktop…`]}):`Next: see what this will do`}),children:(0,J.jsxs)(`div`,{className:`sheet-scroll`,children:[(0,J.jsxs)(`div`,{className:`set-group`,children:[(0,J.jsx)(`div`,{className:`onb-q`,children:`What is it called?`}),(0,J.jsx)(`input`,{className:`search onb-name`,value:o.name,onChange:e=>y({name:e.target.value}),autoCapitalize:`none`,autoCorrect:`off`,spellCheck:!1,"aria-label":`app name`}),(0,J.jsx)(X,{children:`It becomes a new folder on your desktop, under the host root.`})]}),(0,J.jsxs)(`div`,{className:`set-group`,children:[(0,J.jsx)(`div`,{className:`onb-q`,children:`What should it do?`}),(0,J.jsxs)(`div`,{className:`onb-choice`,children:[(0,J.jsx)(Y,{className:o.describe?``:`active`,onClick:()=>y({describe:!1}),children:`plain hello world`}),(0,J.jsx)(Y,{className:o.describe?`active`:``,onClick:()=>y({describe:!0}),children:`describe it`})]}),o.describe&&(0,J.jsx)(`input`,{className:`search`,placeholder:`one line: what should the app do?`,value:o.description,onChange:e=>y({description:e.target.value}),"aria-label":`description`}),(0,J.jsx)(X,{children:o.describe?`The hello world is built first, so the tools are proven; then your line is the new session's first prompt.`:`A working hello world, built from a template. Changing it is your first prompt.`})]}),(0,J.jsxs)(`div`,{className:`set-group`,children:[(0,J.jsx)(`div`,{className:`onb-q`,children:`Where does it run?`}),(0,J.jsxs)(`div`,{className:`onb-choice`,children:[(0,J.jsxs)(Y,{className:o.path===`android`?`active`:``,onClick:()=>y({path:`android`}),children:[(0,J.jsx)(Ra,{size:14}),` phone app (Android)`]}),(0,J.jsxs)(Y,{className:o.path===`web`?`active`:``,onClick:()=>y({path:`web`}),children:[(0,J.jsx)(Lc,{size:14}),` web page`]})]}),(0,J.jsx)(X,{children:o.path===`android`?`Needs the Android build tools on the desktop; the next screen says what is missing before anything is downloaded.`:`Needs nothing installed. The page opens in the gallery here.`})]}),(0,J.jsxs)(`div`,{className:`set-group`,children:[(0,J.jsxs)(Y,{className:`onb-tick${o.setup?` active`:``}`,onClick:()=>y({setup:!o.setup}),children:[o.setup?(0,J.jsx)(mo,{size:14}):(0,J.jsx)(ic,{size:14}),` set this repo up for the phone (recommended)`]}),(0,J.jsx)(X,{children:`The setup checklist's one-tap fixes, run as one step.`})]}),u&&(0,J.jsx)(`div`,{className:`set-group`,children:(0,J.jsx)(X,{className:`warn`,role:`alert`,children:u})})]})})}function iJ({plan:e,canInstall:t,title:n,icon:r,onBack:i,onWeb:a,onStarted:o}){let s=Eq(e,t),[c,l]=(0,V.useState)(()=>Dq(s)),[u,d]=(0,V.useState)(null),[f,p]=(0,V.useState)(!1),m=kq(s,c),h=async()=>{p(!0),d(null);let t=await Xq({name:e.name,path:e.path,...e.firstPrompt?{description:e.firstPrompt}:{},setup:e.steps.some(e=>e.id===`setup`&&e.needed)},Oq(s,c),e.confirm);p(!1),`error`in t?d(t.error):o()};return(0,J.jsx)(Hw,{title:n,icon:r,onClose:i,footer:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Y,{className:`onb-cancel`,onClick:i,children:`Cancel`}),m?(0,J.jsx)(`span`,{className:`onb-why`,children:m}):(0,J.jsx)(`button`,{className:`send onb-go`,onClick:()=>void h(),children:f?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)($s,{size:14,className:`spin`}),` starting…`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ys,{size:14}),` Go`]})})]}),children:(0,J.jsxs)(`div`,{className:`sheet-scroll`,children:[(0,J.jsxs)(`div`,{className:`set-group`,children:[(0,J.jsxs)(`div`,{className:`onb-q`,children:[e.path===`android`?`A phone app`:`A web page`,` called `,e.name]}),(0,J.jsx)(X,{children:`Go allows exactly what is ticked below, and nothing else. Nothing is downloaded, created or installed before you tap it. Cancel goes back to the questions.`})]}),e.signIn&&(0,J.jsx)(`div`,{className:`set-group`,children:(0,J.jsx)(X,{className:`warn`,role:`status`,children:e.signIn})}),(0,J.jsx)(`div`,{className:`set-group onb-lines`,children:s.map(e=>(0,J.jsx)(aJ,{row:e,on:c[e.id]===!0,onToggle:()=>l(t=>({...t,[e.id]:t[e.id]!==!0})),onWeb:e.id===`toolchain`?a:void 0},e.id))}),(0,J.jsxs)(`div`,{className:`set-group`,children:[(0,J.jsx)(`div`,{className:`onb-q`,children:`Then, in order`}),(0,J.jsx)(`ol`,{className:`onb-steps`,children:Aq(e).map((e,t)=>(0,J.jsx)(`li`,{children:e},t))})]}),u&&(0,J.jsx)(`div`,{className:`set-group`,children:(0,J.jsx)(X,{className:`warn`,role:`alert`,children:u})})]})})}function aJ({row:e,on:t,onToggle:n,onWeb:r}){return(0,J.jsxs)(`div`,{className:`onb-line${e.required?` needed`:``}`,"data-line":e.id,children:[e.cant?(0,J.jsxs)(`div`,{className:`onb-line-what`,children:[(0,J.jsx)(Ma,{size:16}),` `,(0,J.jsx)(`span`,{children:e.what})]}):(0,J.jsxs)(`button`,{className:`onb-line-what onb-tick${t?` active`:``}`,onClick:n,"aria-pressed":t,children:[t?(0,J.jsx)(mo,{size:16}):(0,J.jsx)(ic,{size:16}),` `,(0,J.jsx)(`span`,{children:e.what})]}),(0,J.jsxs)(`div`,{className:`onb-line-facts`,children:[(0,J.jsx)(`span`,{className:`onb-tag`,children:e.required?`needed`:`optional`}),e.where&&(0,J.jsx)(`span`,{className:`mono`,children:e.where}),e.size&&(0,J.jsx)(`span`,{children:e.size})]}),e.cant&&(0,J.jsx)(X,{children:e.cant}),(e.link||r)&&(0,J.jsxs)(`div`,{className:`onb-line-acts`,children:[e.link&&(0,J.jsxs)(Y,{onClick:()=>{fx(e.link)||U().say.toast(`Could not open ${e.link}`)},children:[(0,J.jsx)(Ga,{size:13}),` read the licence`]}),r&&(0,J.jsxs)(Y,{onClick:r,children:[(0,J.jsx)(Lc,{size:13}),` make a web page instead (nothing to install)`]})]})]})}var oJ={pending:(0,J.jsx)(zc,{size:16}),running:(0,J.jsx)($s,{size:16,className:`spin`}),done:(0,J.jsx)(vc,{size:16}),skipped:(0,J.jsx)(Ma,{size:16}),stopped:(0,J.jsx)(po,{size:16})};function sJ({job:e,onAnother:t}){let n=Pq(e,Ww(1e3)),[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(!1),[s,c]=(0,V.useState)(null),l=e.answers.path===`android`,u=Lq(e);(0,V.useEffect)(()=>{if(!l||e.consent.installApps!==!0)return;let t=!1;return $q().then(e=>{t||c(e)}),()=>{t=!0}},[l,e.consent.installApps,e.state]);let d=async e=>{o(!0),i(null);let t=await Zq(e.fix?.consent?{[e.fix.consent]:!0}:void 0);o(!1),t&&i(t)};return(0,J.jsxs)(`div`,{className:`sheet-scroll`,children:[(0,J.jsxs)(`div`,{className:`set-group`,children:[(0,J.jsx)(`div`,{className:`onb-q${e.state===`stopped`?` warn`:``}`,children:Iq(e)}),e.state===`running`&&(0,J.jsx)(X,{children:`This keeps going on the desktop if you leave this screen; the launcher shows where it is.`})]}),(0,J.jsxs)(`div`,{className:`set-group onb-check`,children:[n.map(t=>{let n=e.steps.find(e=>e.id===t.id)?.status;return(0,J.jsxs)(`div`,{className:`onb-row ${t.icon}`,"data-step":t.id,children:[(0,J.jsx)(`span`,{className:`onb-row-icon`,children:oJ[t.icon]}),(0,J.jsxs)(`div`,{className:`onb-row-body`,children:[(0,J.jsxs)(`div`,{className:`onb-row-what`,children:[t.what,t.clock&&(0,J.jsxs)(`span`,{className:`onb-clock`,children:[` · `,t.clock]})]}),t.note&&(0,J.jsx)(X,{children:t.note}),t.command&&(0,J.jsxs)(X,{children:[`do it yourself: `,(0,J.jsx)(`code`,{children:t.command})]}),t.fix&&(0,J.jsxs)(Y,{onClick:()=>void d(t),children:[a?(0,J.jsx)($s,{size:13,className:`spin`}):(0,J.jsx)(uo,{size:13}),` `,Fq(t.fix,n)]})]})]},t.id)}),r&&(0,J.jsx)(X,{className:`warn`,role:`alert`,children:r})]}),e.state===`stopped`&&(0,J.jsxs)(`div`,{className:`set-group`,children:[(0,J.jsxs)(Y,{onClick:t,children:[(0,J.jsx)(ys,{size:14}),` start over with other answers`]}),(0,J.jsx)(X,{children:`What was already made stays on the desktop; a new start replaces this stopped job.`})]}),e.state===`done`&&(0,J.jsxs)(`div`,{className:`set-group onb-done`,children:[u&&(0,J.jsx)(Y,{onClick:()=>nJ(u,e.answers.path),children:l?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Ra,{size:14}),` install `,u.name]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Lc,{size:14}),` open the page`]})}),s&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(X,{className:`warn`,children:Bq}),(0,J.jsxs)(Y,{onClick:()=>void eJ(),children:[(0,J.jsx)(Ra,{size:14}),` open Android's setting`]})]}),e.consent.session===!0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{className:`send onb-open`,onClick:()=>tJ(e),children:[(0,J.jsx)(qa,{size:14}),` open the session in `,e.name]}),(0,J.jsxs)(X,{children:[(0,J.jsx)(Rs,{size:12}),` `,e.answers.description?`Your description is the session's first prompt.`:`A first prompt waits in the box there; change it or send it.`]})]}),(0,J.jsxs)(Y,{onClick:t,children:[(0,J.jsx)(ys,{size:14}),` build another app`]})]})]})}function cJ({repos:e,demo:t,onDemo:n}){let r=Dh(),i=mq(),a=hq(),o=gq({online:r.conn.status===`open`,sessions:r.world.sessions.length,recent:r.world.recent.length,closed:r.world.closed.length,job:i,dismissed:a,demo:t});if(o===`none`)return null;let s=vq(e);if(o===`job`&&i){let e=i.state===`stopped`;return(0,J.jsxs)(`div`,{className:`onb-card`,"data-card":`job`,children:[(0,J.jsxs)(`button`,{className:`onb-card-head onb-card-job`,onClick:Hq,children:[e?(0,J.jsx)(po,{size:18}):(0,J.jsx)($s,{size:18,className:`spin`}),(0,J.jsx)(`span`,{children:e?`${i.name} is waiting for you`:`Making ${i.name}`})]}),(0,J.jsx)(`div`,{className:`onb-card-body`,children:i.summary})]})}return(0,J.jsxs)(`div`,{className:`onb-card`,"data-card":`first-run`,children:[(0,J.jsxs)(`div`,{className:`onb-card-head`,children:[(0,J.jsx)(Ls,{size:18}),` `,(0,J.jsx)(`span`,{children:`Start here`}),(0,J.jsx)(`button`,{className:`onb-card-x`,"aria-label":`not now`,title:`not now — hide this until the app reloads`,onClick:Gq,children:(0,J.jsx)(B,{size:16})})]}),(0,J.jsxs)(`div`,{className:`onb-card-body`,children:[`This desktop has not run a session from the phone yet. Pick one way in.`,s&&(0,J.jsxs)(J.Fragment,{children:[` `,s]})]}),(0,J.jsxs)(`div`,{className:`onb-card-acts`,children:[(0,J.jsxs)(`button`,{className:`send onb-build`,onClick:Hq,children:[(0,J.jsx)(ys,{size:16}),` Build your first app`]}),!s&&(0,J.jsxs)(Y,{onClick:()=>{Gq(),r.say.toast(`No repos under the host root yet: new, in the menu, makes one.`)},children:[(0,J.jsx)(Tc,{size:16}),` Open an existing repo`]}),(0,J.jsxs)(Y,{onClick:()=>{r.say.track(`action:onboard.demo`),n()},children:[(0,J.jsx)(one,{size:16}),` Try the demo`]})]})]})}var lJ={id:`onboard`,sheets:[{id:`onboard`,persisted:!1,render:()=>(0,V.createElement)(rJ)}],messages:{"onboard.progress":e=>Kq(e.job),welcome:()=>{qq()}}};function uJ({m:e}){let{seed:t,outbox:n,online:r,onReattach:i,onReplace:a,promptsRef:o,focusStep:s,text:c,attachCwd:l,attachRepo:u,repoId:d,ready:f,blockers:p,prompts:m,states:h,setStates:g,nonce:_,shots:v,updatePrompts:y,guard:b}=e;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(Z,{children:[t.origin?`${t.origin} · `:``,r?`Write it, check the two lines below, send.`:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(fo,{size:12}),` No connection — this is queued and goes out the moment the link is back.`]})]}),(0,J.jsxs)(yE,{prompts:m,onChange:y,placeholder:`What should it do?`,chain:!0,stepHint:`then, once that step's turn finishes:`,trackAdd:`action:send.addprompt`,focusRef:s,autoFocus:!t.prompts?.length,children:[v.length>0&&(0,J.jsxs)(Z,{children:[(0,J.jsx)(As,{size:12}),` `,v.length,` file`,v.length>1?`s`:``,` queued for `,u?.repoName??`that repo`,`'s inbox — the paths are in the prompt above.`]}),(0,J.jsx)(lR,{compact:!t.repair,debounceMs:700,text:c,repoId:d,outbox:n,online:r,nonce:_,onStates:t.repair?g:void 0,onReattach:t.repair&&i&&d&&l?e=>void b(()=>i(e,d,l)):void 0,onReplace:t.repair&&a&&d&&l?e=>void b(async()=>{let t=await a(e,d,l);t&&y(o.current.map(n=>n.split(e).join(t)))}):void 0,onForget:t.repair?e=>y(o.current.map(t=>dL(t,e))):void 0,onRemove:t.repair?void 0:e=>y(o.current.map(t=>dL(t,e)))}),t.repair&&h.length>0&&(0,J.jsx)(Z,{className:f?``:`warn`,children:f?h.length===1?`The file it names will be there.`:`Every file it names will be there.`:r?`${p.length} of ${h.length} ${p.length===1?`file is`:`files are`} not going to arrive. Fix or drop ${p.length===1?`it`:`them`} above, or send anyway and the agent will find nothing at ${p.length===1?`that path`:`those paths`}.`:`No connection, so the repo can't be checked — what this says about the files is only what this phone knows.`})]})]})}function dJ({m:e}){let{budgetHeld:t,onPastBudget:n}=e,r=e.retime;return(0,J.jsxs)(Z,{children:[`A new `,(0,J.jsx)(`b`,{children:`when`}),` for the `,r.ids.length===1?`row`:`${r.ids.length} rows`,` you ticked — each keeps its own words, where it goes and its place in its list. Only the when changes.`,t&&t.ids.length>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{style:{marginTop:6},children:wde(t.note,t.resumeAt,t.ids.length)}),n&&(0,J.jsxs)(`div`,{style:{marginTop:6},children:[YA(t.ids.length,r.ids.length),(0,J.jsx)(`div`,{className:`annot-tools wrap`,style:{marginTop:6},children:(0,J.jsxs)(fC,{confirm:Dde(t.ids.length),title:YA(t.ids.length,r.ids.length),onConfirm:()=>{q(`action:send.retime.pastbudget`),n(t.ids)},children:[(0,J.jsx)(La,{size:14}),` `,JA(t.ids.length)]})})]})]})]})}function fJ({m:e}){let{seed:t,online:n,onBrowseRepoFiles:r,onClose:i,retime:a,promptsRef:o,focusStep:s,blocker:c,label:l,attachRepo:u,ready:d,when:f,busy:p,updatePrompts:m,pick:h,go:g}=e;return(0,J.jsxs)(`div`,{className:`sheet-actions`,children:[!a&&(0,J.jsx)(bE,{prompts:o,onPrompts:m,focusRef:s,busy:p,unavailable:u?void 0:`pick where it goes first, a file needs a repo's inbox to land in`,onFiles:e=>void h(e),onBrowse:r&&u?()=>{q(`action:send.browse`),r(u)}:void 0,trackImage:`action:send.attach`,trackFile:`action:send.attachfile`}),(0,J.jsxs)(Y,{onClick:i,children:[(0,J.jsx)(B,{size:16}),` cancel`]}),(0,J.jsx)(`span`,{className:`spacer`}),c&&c!==`write the prompt first`?(0,J.jsx)($w,{children:c}):(0,J.jsxs)(`button`,{className:`send`,disabled:!!c||p,onClick:g,children:[f.kind===`at`?(0,J.jsx)(rl,{size:16}):t.repair&&!d?(0,J.jsx)(gs,{size:16}):(0,J.jsx)(Uc,{size:16}),` `,n||f.kind===`at`?l:sde(l)]})]})}function pJ({m:e}){let{target:t,setTarget:n,when:r,launchOpen:i,setLaunchOpen:a}=e,o=e.backends??null,s=e.launchDefaults??{},c=MA(t),l=c??s;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`sched-days`,style:{marginTop:6},children:(0,J.jsxs)(`button`,{className:`row-chip${c?` on`:``}`,"aria-pressed":i,onClick:()=>a(!i),children:[(0,J.jsx)(sc,{size:13}),` model: `,PA(c)]})}),i&&(0,J.jsx)(`div`,{className:`form`,children:(0,J.jsx)(sq,{backends:o,defaults:s,nowLead:t.kind===`repos`?`Every repo starts on`:`Starts on`,value:{backend:l.backend,model:l.model,effort:l.effort},onChange:e=>n(t=>NA(t,oq(s,e))),children:(0,J.jsxs)(X,{as:`span`,children:[c?`Just this send — your new-session defaults don’t change.`:r.kind===`now`?`Nothing picked: it starts on your new-session defaults.`:`Nothing picked: the desktop opens it on its own defaults.`,` `,c&&(0,J.jsx)(`button`,{className:`link-btn`,onClick:()=>n(nde),children:`use the defaults`})]})})})]})}function mJ({target:e,when:t,setTarget:n}){if(!IA(e,t)||e.kind!==`repo`&&e.kind!==`repos`)return null;let r=e.flagWhenDone===!0;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`sched-days`,style:{marginTop:6},children:(0,J.jsxs)(`button`,{className:`row-chip${r?` on`:``}`,"aria-pressed":r,"data-hint":`session.followup`,onClick:()=>n({...e,flagWhenDone:!r||void 0}),children:[(0,J.jsx)(Ac,{size:13,fill:r?`currentColor`:`none`}),` Flag for follow up when done`]})}),r&&(0,J.jsxs)(Z,{children:[e.kind===`repos`?`Each session it opens`:`The session it opens`,` gets the follow-up flag once it is done — not if it failed or stopped on a usage limit.`]})]})}var hJ=e=>`${String(Math.floor(e/60)).padStart(2,`0`)}:${String(e%60).padStart(2,`0`)}`;function gJ(e){let[t,n]=e.split(`:`).map(Number);return!Number.isFinite(t)||!Number.isFinite(n)?null:Math.min(1439,Math.max(0,t*60+n))}function _J(e){let t=e.state===`running`||e.state===`starting`?`running now`:e.state===`queued`||e.state===`blocked`?`waiting`:e.state===`failed`?`finished — it failed`:`finished`,n=e.cwd.split(`/`).filter(Boolean).pop()??``;return n?`${t} · ${n}`:t}function vJ(e,t,n){let r=n?e.find(e=>e.cwd===n):null;return r?{kind:`session`,sessionId:r.id,cwd:r.cwd}:n?{kind:`repo`,cwd:n}:e[0]?{kind:`session`,sessionId:e[0].id,cwd:e[0].cwd}:{kind:`repo`,cwd:(t.find(e=>e.isPrimary)??t[0])?.worktreePath??``}}function yJ(e,t){let n=t&&e.find(e=>e.cwd===t)||e[0];return n?{kind:`session`,sessionId:n.id,cwd:n.cwd}:{kind:`repo`,cwd:t??``}}function bJ(e,t,n){return e.kind===`repos`?e.dirs[0]??n??``:e.kind!==`shell`&&`cwd`in e&&e.cwd?e.cwd:n??t.find(e=>e.isPrimary)?.worktreePath??t[0]?.worktreePath??``}function xJ(e,t){if(e.kind===`repos`)return e.dirs;let n=(e.kind===`shell`||`cwd`in e?e.cwd:``)||t||``;return n?[n]:[]}function SJ({m:e}){let{seed:t,repos:n,live:r,names:i,closeGlobal:a,seqMeans:o,target:s,setTarget:c,when:l,sequential:u,setSequential:d,open:f,setOpen:p,budgetOpen:m,setBudgetOpen:h}=e,g=LA(s),_=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`sched-days`,style:{marginTop:6},children:(0,J.jsxs)(`button`,{className:`row-chip${g?` on`:``}`,"aria-pressed":m,onClick:()=>h(!m),children:[(0,J.jsx)(Qc,{size:13}),` `,g?Nw(g):`budget…`]})}),m&&(0,J.jsx)(cD,{initial:g??null,onChange:e=>c(t=>RA(t,e)),windowsOff:hw(e.backends??null,`launch`in s?s.launch?.backend:void 0),calFor:`A percent is converted from dollars at the window's measured rate once the session is running — until there is a fresh usage reading, nothing is held.`})]}),v=(0,J.jsx)(pJ,{m:e}),y=(0,J.jsx)(mJ,{target:s,when:l,setTarget:c});return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{className:`send-sum`,onClick:()=>p(f===`to`?null:`to`),children:[(0,J.jsx)(`span`,{className:`send-sum-k`,children:`To`}),(0,J.jsx)(`span`,{className:`send-sum-v`,children:ide(s,i,l)}),f===`to`?(0,J.jsx)(Nc,{size:14}):(0,J.jsx)(Hs,{size:14})]}),VA(s,l,s.kind===`session`?i.sessionTitle(s.sessionId):``)&&(0,J.jsx)(Z,{children:VA(s,l,s.kind===`session`?i.sessionTitle(s.sessionId):``)}),f===`to`&&(0,J.jsxs)(`div`,{className:`send-exp`,children:[(0,J.jsx)(yS,{label:`Where it goes`,value:s.kind===`session`||s.kind===`repo`||s.kind===`repos`?s.kind:null,options:[...r.length?[{key:`session`,label:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Uc,{size:13}),` this session`]}),title:`type it into a session that is open right now`}]:[],{key:`repo`,label:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(La,{size:13}),` a new session`]}),title:`open a session for these words and run them there`},{key:`repos`,label:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Eo,{size:13}),` several repos`]}),title:`one prompt, several repos`}],onChange:e=>c(e===`session`?yJ(r,t.cwdHint):NA(RA(e===`repo`?{kind:`repo`,cwd:bJ(s,n,t.cwdHint)}:{kind:`repos`,dirs:xJ(s,t.cwdHint)},LA(s)),MA(s)))}),!r.length&&(0,J.jsx)(Qw,{cants:[{label:`“this session”`,reason:`nothing is open on this desktop right now`}]}),s.kind===`session`&&(0,J.jsxs)(`div`,{className:`pad-pick`,children:[(0,J.jsx)(Z,{children:`Which session?`}),r.map(e=>(0,J.jsxs)(`button`,{className:`row${s.sessionId===e.id?` sched-on`:``}`,onClick:()=>c({kind:`session`,sessionId:e.id,cwd:e.cwd}),children:[(0,J.jsx)(Zw,{children:e.title}),(0,J.jsx)(AR,{s:e}),(0,J.jsx)(Q,{children:e.turnActive?`working`:`idle`})]},e.id)),!r.length&&(0,J.jsx)($,{children:`No live sessions.`})]}),s.kind===`repo`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(oF,{repos:n,home:t.cwdHint??null,value:s.cwd,worktreeFilter:!0,onChange:e=>c({...s,cwd:e}),"aria-label":`repo`}),(0,J.jsx)(`div`,{className:`sched-days`,style:{marginTop:6},children:(0,J.jsxs)(`button`,{className:`row-chip${s.resume?` on`:``}`,onClick:()=>c({...s,resume:!s.resume||void 0}),children:[(0,J.jsx)(Xs,{size:13}),` pick up its last conversation`]})}),(0,J.jsx)(Z,{children:s.resume?`It reopens this repo's last conversation and carries on in it — everything that one read is already in the window, and every turn pays for it again.`:`Otherwise it starts clean — cheaper for anything that does not need what the last one knew.`}),l.kind!==`now`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsx)(`span`,{children:`Its session once the work is done`})}),(0,J.jsx)(yS,{label:`Its session once the work is done`,value:AN(s.closeWhenDone),options:kN.map(e=>({key:e,label:(0,J.jsxs)(J.Fragment,{children:[e===`close`?(0,J.jsx)(Po,{size:13}):e===`keep`?(0,J.jsx)(Ya,{size:13}):null,` `,PN(e,a)]})})),onChange:e=>c({...s,closeWhenDone:MN(e)})}),(0,J.jsx)(Z,{children:FN(s.closeWhenDone,a)})]}),y,v,_]}),s.kind===`repos`&&(0,J.jsx)(aF,{multi:!0,repos:n,home:t.cwdHint??null,selected:s.dirs,listClass:`pad-pick`,onChange:e=>c(t=>NA(RA({kind:`repos`,dirs:e},LA(t)),MA(t))),countHint:u?`· one at a time in each`:`· a fresh session in each`}),s.kind===`repos`&&y,s.kind===`repos`&&v,s.kind===`repos`&&_,s.kind===`shell`&&(0,J.jsxs)(Z,{children:[`A build command — a shell in `,(0,J.jsx)(`b`,{children:i.repoName(s.cwd)}),`, no agent and no session.`]}),o&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsx)(`span`,{children:`How many at once`})}),(0,J.jsx)(yS,{label:`How many at once`,value:u?`sequential`:`parallel`,options:[{key:`parallel`,label:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Eo,{size:13}),` all at once`]})},{key:`sequential`,label:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ml,{size:13}),` one at a time`]})}],onChange:e=>d(e===`sequential`)})]}),o&&(0,J.jsx)(Z,{children:u?o.on:o.off})]})]})}function CJ({m:e}){let{retime:t,setWhen:n,more:r,setMore:i,patchRule:a}=e,o=e.when,s=e.rule;return(0,J.jsx)(J.Fragment,{children:r?(0,J.jsxs)(J.Fragment,{children:[s.kind===`weekly`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsxs)(`span`,{children:[`Lead time `,(0,J.jsx)(`span`,{className:`section-hint`,children:`· fire before the time above`})]})}),(0,J.jsx)(`div`,{className:`sched-days`,children:EA.map(e=>(0,J.jsx)(`button`,{className:`row-chip${(s.offsetMin??0)===-e?` on`:``}`,onClick:()=>a({offsetMin:-e}),children:e===0?`on time`:`${e<60?`${e}m`:`${e/60}h`} before`},e))}),(0,J.jsx)(Z,{children:`The time above is the thing you are tracking — a usage window rolling over, a nightly deploy. The lead is when to act on it. Keeping them apart means a moved reset is one field to change.`})]}),(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsxs)(`span`,{children:[`Only between `,(0,J.jsx)(`span`,{className:`section-hint`,children:`· the hours it may run, over whichever anchor is set`})]})}),(0,J.jsx)(`div`,{className:`sched-days`,children:(0,J.jsx)(`button`,{className:`row-chip${s.hours?``:` on`}`,title:`no run window — it may run at whatever hour the anchor lands on`,onClick:()=>a({hours:void 0}),children:`any time`})}),(0,J.jsxs)(`div`,{className:`search-row sched-row`,children:[(0,J.jsx)(`span`,{children:`from`}),(0,J.jsx)(`input`,{className:`search`,type:`time`,"aria-label":`run window opens`,value:hJ(s.hours?.from??420),onChange:e=>{let t=gJ(e.target.value);t!=null&&a({hours:{from:t,to:s.hours?.to??1320}})}}),(0,J.jsx)(`span`,{children:`to`}),(0,J.jsx)(`input`,{className:`search`,type:`time`,"aria-label":`run window closes`,value:hJ(s.hours?.to??1320),onChange:e=>{let t=gJ(e.target.value);t!=null&&a({hours:{from:s.hours?.from??420,to:t}})}})]}),(0,J.jsx)(Z,{children:bde(s)}),(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsx)(`span`,{children:`If the host was asleep`})}),(0,J.jsx)(`div`,{className:`sched-days`,children:Que.map(e=>(0,J.jsx)(`button`,{className:`row-chip${o.graceMin===e.min?` on`:``}`,onClick:()=>n({...o,graceMin:e.min}),children:e.label},e.min))}),!t&&(0,J.jsx)(`input`,{className:`search`,placeholder:`name it — “weekly security sweep”`,value:o.name??``,onChange:e=>n({...o,name:e.target.value})})]}):(0,J.jsx)(`button`,{className:`linkish`,onClick:()=>i(!0),children:`more — lead time, run hours, late runs, a name`})})}function wJ({m:e}){let{leadOpen:t,setLeadOpen:n,savedLead:r,setSavedLead:i,leadRaw:a,setLeadRaw:o,patchRule:s}=e,c=e.rule;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`sched-days`,children:[ede(r,-(c.offsetMin??0)).map(e=>(0,J.jsx)(`button`,{className:`row-chip${(c.offsetMin??0)===-e?` on`:``}`,onClick:()=>s({offsetMin:-e}),children:kA(e)},e)),(0,J.jsx)(`button`,{className:`row-chip${t?` on`:``}`,title:`type a lead the chips don't cover — it is kept on this phone and offered beside them next time`,onClick:()=>n(e=>!e),children:`another…`})]}),t&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`search-row sched-row`,children:[(0,J.jsx)(`input`,{className:`search`,type:`text`,inputMode:`text`,autoCapitalize:`off`,autoCorrect:`off`,placeholder:`45m, 4h, 1h30`,value:a,onChange:e=>{o(e.target.value);let t=AA(e.target.value);t!=null&&(s({offsetMin:-t}),i(t),ua(R.schedLeadMin,String(t)))}}),(0,J.jsx)(`span`,{children:`before`})]}),(0,J.jsx)(Z,{children:tde(a)??`Read as ${kA(AA(a))} before the reset. Kept on this phone — offered as a chip on the next rule you write.`})]})]})}function TJ({m:e}){let{anchorW:t,guardW:n,pctOpen:r,setPctOpen:i,savedPct:a,setSavedPct:o,pctRaw:s,setPctRaw:c,patchRule:l}=e,u=e.rule;return(0,J.jsx)(J.Fragment,{children:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsx)(`span`,{children:`Which usage window`})}),(0,J.jsx)(yS,{label:`Which usage window`,value:u.window===`weekly`?`weekly`:`session`,options:[{key:`session`,label:`session window`},{key:`weekly`,label:`weekly window`}],onChange:e=>l({window:e})}),(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsx)(`span`,{children:`When in the window`})}),(0,J.jsx)(yS,{label:`When in the window`,value:u.edge===`after`?`after`:`before`,onChange:e=>l(e===`before`?{edge:`before`,offsetMin:Math.min(0,u.offsetMin??-60)}:{edge:`after`,offsetMin:0}),options:[{key:`before`,label:`before it resets`,title:`spend what is left before the window rolls over`},{key:`after`,label:`right after it resets`,title:`start the moment the allowance is back`}]}),(u.edge??`before`)===`before`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsx)(`span`,{children:`How long before`})}),(0,J.jsx)(wJ,{m:e})]}),(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsxs)(`span`,{children:[`Only if there is headroom `,(0,J.jsx)(`span`,{className:`section-hint`,children:`· checked when it fires, not now`})]})}),(0,J.jsxs)(`div`,{className:`sched-days`,children:[(0,J.jsx)(`button`,{className:`row-chip${u.minPctLeft==null?` on`:``}`,title:`run whatever the meter says`,onClick:()=>l({minPctLeft:void 0}),children:`no condition`}),Xue(a,u.minPctLeft).map(e=>(0,J.jsxs)(`button`,{className:`row-chip${u.minPctLeft===e?` on`:``}`,onClick:()=>l({minPctLeft:e}),children:[e,`% left`]},e)),(0,J.jsx)(`button`,{className:`row-chip${r?` on`:``}`,title:`type a percentage the chips don't cover — it is kept on this phone and offered beside them next time`,onClick:()=>i(e=>!e),children:`another…`})]}),r&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`search-row sched-row`,children:[(0,J.jsx)(`span`,{children:`at least`}),(0,J.jsx)(`input`,{className:`search`,type:`number`,inputMode:`numeric`,min:1,max:100,step:1,value:s,onChange:e=>{c(e.target.value);let t=DA(e.target.value);t!=null&&(l({minPctLeft:t}),o(t),ua(R.schedPctLeft,String(t)))}}),(0,J.jsx)(`span`,{children:`% left`})]}),(0,J.jsx)(Z,{children:Zue(s)??`Kept on this phone — ${DA(s)}% left is offered as a chip on the next rule you write.`})]}),u.minPctLeft!=null&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsxs)(`span`,{children:[`…in which window `,(0,J.jsx)(`span`,{className:`section-hint`,children:`· the meter it reads, not the reset it waits for`})]})}),(0,J.jsx)(yS,{label:`Which meter the condition reads`,value:n,options:[`session`,`weekly`].map(e=>({key:e,label:vde[e]})),onChange:e=>l({guardWindow:e===t?void 0:e})}),(0,J.jsx)(Z,{children:yde(u)})]}),(0,J.jsx)(Z,{children:`Anchored to the reset, not to a clock: the session window slides with whenever you last started using it, so there is no time of day that means the same thing twice. Nothing is armed until the host has read the window once.`})]})})}function EJ({m:e}){let{usage:t,preview:n,days:r,recurs:i,quickKey:a,setQuickKey:o,patchRule:s,replaceRule:c}=e,l=e.when,u=e.rule,d=e.anchor;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsx)(`span`,{children:`How often`})}),(0,J.jsx)(yS,{label:`How often`,value:(d===`window`?i:u.kind===`weekly`)?`repeating`:`once`,options:[{key:`once`,label:`once`,title:`fire the next one and stop`},{key:`repeating`,label:`repeating`,title:d===`window`?`every time that window resets`:`every week, on the days below`}],onChange:e=>{o(null),c(oi(d,e===`repeating`,u,Date.now(),wA))}}),u.kind===`once`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`sched-days`,children:Jue().map(e=>(0,J.jsx)(`button`,{className:`row-chip${a===e.key?` on`:``}`,title:Pr(e.at),onClick:()=>{o(e.key),s({at:e.at})},children:e.label},e.key))}),(0,J.jsxs)(`div`,{className:`search-row sched-row`,children:[(0,J.jsx)(`span`,{children:`at`}),(0,J.jsx)(`input`,{className:`search`,type:`datetime-local`,value:que(u.at??Date.now()+36e5),onChange:e=>{let t=new Date(e.target.value).getTime();Number.isFinite(t)&&(o(null),s({at:t}))}})]})]}),u.kind===`weekly`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`sched-days`,children:[bee.map((e,t)=>(0,J.jsx)(`button`,{className:`row-chip${r.includes(t)?` on`:``}`,title:r.includes(t)?`stop running on ${e}`:`also run on ${e}`,onClick:()=>s({days:r.includes(t)?r.filter(e=>e!==t):[...r,t].sort()}),children:e},e)),(0,J.jsx)(`button`,{className:`row-chip${r.length===0?` on`:``}`,title:`every day`,onClick:()=>s({days:[]}),children:`daily`})]}),(0,J.jsxs)(`div`,{className:`search-row sched-row`,children:[(0,J.jsx)(`span`,{children:`at`}),(0,J.jsx)(`input`,{className:`search`,type:`time`,value:`${String(u.hour??18).padStart(2,`0`)}:${String(u.minute??0).padStart(2,`0`)}`,onChange:e=>{let[t,n]=e.target.value.split(`:`).map(Number);Number.isFinite(t)&&Number.isFinite(n)&&s({hour:t,minute:n})}}),(0,J.jsx)(`input`,{className:`search`,placeholder:`Europe/Berlin`,value:u.tz??``,title:`The zone the time above is written in. Stored as a zone, not an instant, so daylight saving can't shift the run by an hour.`,onChange:e=>s({tz:e.target.value.trim()})})]}),!u.tz&&(0,J.jsx)(Z,{children:`No zone — the host's own clock decides, which is a different time than yours whenever the two machines disagree.`}),(0,J.jsx)(`button`,{className:`row-chip${u.oneShot===!0?` on`:``}`,title:`run the next matching day above, then stop — instead of every week`,onClick:()=>s({oneShot:u.oneShot!==!0||void 0}),children:`just the next one`})]}),u.kind===`window`&&(0,J.jsx)(TJ,{m:e}),(0,J.jsx)(CJ,{m:e}),(0,J.jsx)(Z,{children:n==null?u.kind===`window`?(0,J.jsxs)(J.Fragment,{children:[`Not armed yet — the desktop arms this the first time it reads the window. `,An(u),`.`]}):(0,J.jsx)(J.Fragment,{children:`This never fires — the time it resolves to has already passed. Pick a later one.`}):(0,J.jsxs)(J.Fragment,{children:[`Next fire: `,(0,J.jsx)(`b`,{children:Pr(n)}),` · `,kr(n),u.tz?` (anchor in ${u.tz})`:``,i?``:` · then it stops`]})}),u.kind===`window`&&(0,J.jsx)(pM,{usage:t,title:()=>l.name?.trim()||`this schedule`,entries:[{id:`draft`,name:``,enabled:!0,rule:u,createdAt:0,graceMin:0,nextAt:n,action:{kind:`backlog`,repoDir:``,text:``}}]})]})}function DJ({m:e}){let{retime:t,atMemo:n,rule:r,preview:i,chainRows:a,waitsForFiles:o,anchor:s,target:c,when:l,setWhen:u,open:d,setOpen:f,setAnchor:p,setAfter:m,leaveAt:h}=e;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{className:`send-sum`,onClick:()=>f(d===`when`?null:`when`),children:[(0,J.jsx)(`span`,{className:`send-sum-k`,children:`When`}),(0,J.jsx)(`span`,{className:`send-sum-v`,children:Zn(l,i)}),d===`when`?(0,J.jsx)(Nc,{size:14}):(0,J.jsx)(Hs,{size:14})]}),d===`when`&&(0,J.jsxs)(`div`,{className:`send-exp`,children:[(0,J.jsx)(yS,{label:`When to run it`,value:l.kind===`now`||l.kind===`idle`?l.kind:null,options:[{key:`now`,label:t?`next in line`:`now`},{key:`idle`,label:`when it's free`,title:`hold it until the target can take it — turn ended, no question open, no usage-limit block`}],onChange:e=>h({kind:e})}),t&&l.kind!==`at`&&(0,J.jsx)(Z,{children:dpe(t.ids.length)}),l.kind!==`at`&&n.current&&(0,J.jsxs)(Z,{children:[`The schedule you set is kept — tap `,(0,J.jsx)(`b`,{children:`at a time`}),` or `,(0,J.jsx)(`b`,{children:`a usage window`}),` to get it back.`]}),l.kind===`idle`&&(0,J.jsx)(Z,{children:c.kind===`repo`?`When this repo is free: a slot on the desktop, and nothing else running in this checkout. The desktop holds it — this phone can be shut.`:c.kind===`repos`?`Each one starts when its own repo is free. The desktop holds them — this phone can be shut.`:`Turn ended, no question open, no usage-limit block. The desktop holds it, so this phone can be shut.`}),(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsx)(`span`,{children:`What it waits for`})}),(0,J.jsx)(yS,{label:`What it waits for`,value:l.kind===`at`?s===`window`?`window`:`clock`:l.kind===`after`?`after`:null,options:[{key:`clock`,label:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(rl,{size:13}),` at a time`]})},{key:`window`,label:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ms,{size:13}),` a usage window`]}),title:`anchor this to a usage window resetting, rather than to a time of day`},{key:`after`,label:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Wa,{size:13}),` after another…`]}),title:`wait for another item to finish, rather than for a time`}],onChange:e=>{e===`after`?m():p(e)}}),l.kind===`after`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`pad-pick`,children:[(0,J.jsx)(Z,{children:`Which item does it wait for?`}),a.map(e=>(0,J.jsxs)(`button`,{className:`row${l.id===e.id?` sched-on`:``}`,onClick:()=>u({...l,id:e.id,title:lj(e)}),children:[(0,J.jsx)(Zw,{children:lj(e)}),(0,J.jsx)(Q,{children:_J(e)})]},e.id)),!a.length&&(0,J.jsx)($,{children:`Nothing to wait for — this desktop is holding no work that is running, queued, or finished in the last few hours.`})]}),(0,J.jsx)(`div`,{className:`sched-days`,children:(0,J.jsx)(`button`,{className:`row-chip${l.onlyIfOk?` on`:``}`,onClick:()=>u({...l,onlyIfOk:!l.onlyIfOk||void 0}),children:`only if it succeeded`})}),(0,J.jsx)(Z,{children:hde(l.onlyIfOk)}),(0,J.jsx)(Z,{children:`The desktop holds this, with no deadline: if it was asleep when that item finished, this still goes in when it wakes. A chain is not a schedule — it has no clock to arm and appears in Activity as work, not in Schedules.`})]}),l.kind===`at`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`sched-days`,style:{marginTop:6},children:(0,J.jsxs)(`button`,{className:`row-chip${l.waitUntilFree?` on`:``}`,onClick:()=>u({...l,waitUntilFree:!l.waitUntilFree}),children:[(0,J.jsx)(go,{size:13}),` hold until the desktop is free`]})}),(0,J.jsx)(Z,{children:l.waitUntilFree?`Still due at the time above — but held, once due, until this repo's own session is free and nothing else on the desktop is starting or running.`:`Fires at the time above whatever else is running. Tick it to hold instead — the fix for a dozen repos anchored to the same reset all going off in one burst.`})]}),l.kind===`at`&&r&&s&&(0,J.jsx)(EJ,{m:e})]}),!t&&o>0&&l.kind!==`at`&&(0,J.jsxs)(Z,{children:[(0,J.jsx)(As,{size:12}),` It names `,o,` file`,o>1?`s`:``,` in the inbox — the desktop holds the send until `,o>1?`they have`:`it has`,` arrived, even with this app closed.`]})]})}function OJ(e){let{seed:t,sessions:n,repos:r,usage:i,intents:a,buildName:o,onAttach:s,onAnnotate:c,resume:l,onDecide:u,onSend:d,onClose:f}=e,p=(0,V.useMemo)(()=>n.filter(e=>e.running),[n]),m=t.draftKey??`send.compose`,h=t.retime??null,[g,_]=(0,V.useState)(()=>{let e=h?null:lh(m);return e?e.split(`\f`):t.prompts?.length?t.prompts:[``]}),v=(0,V.useRef)(g);function y(e){v.current=e,_(e),h||mh(m,e.join(`\f`))}(0,V.useEffect)(()=>{h||mh(m,g.join(`\f`))},[m,g,h]);let b={repoName:e=>r.find(t=>t.worktreePath===e)?.repoName??e.split(`/`).filter(Boolean).pop()??e,sessionTitle:e=>n.find(t=>t.id===e)?.title??`that session`,buildName:o},x=Gue(l,t.when),S=l?.target??t.target??vJ(p,r,t.cwdHint),[C,w]=(0,V.useState)(()=>S),[T,E]=(0,V.useState)(()=>x.when),D=Zv(`closeWhenDone`),[O,k]=(0,V.useState)(()=>l?.sequential??!!t.sequential),A=(0,V.useRef)(u);A.current=u,(0,V.useEffect)(()=>{A.current?.({target:C,when:T,sequential:O,parkedAt:ve.current??void 0})},[C,T,O]);let[j,M]=(0,V.useState)(h?`when`:null),[N,P]=(0,V.useState)(!1),[F,ee]=(0,V.useState)(!1),[te,ne]=(0,V.useState)(!1),[re,ie]=(0,V.useState)(null),[ae,oe]=(0,V.useState)(!1),[se,ce]=(0,V.useState)(()=>DA(z(R.schedPctLeft))),[le,ue]=(0,V.useState)(()=>String(DA(z(R.schedPctLeft))??``)),[de,fe]=(0,V.useState)(!1),[pe,me]=(0,V.useState)(()=>AA(z(R.schedLeadMin))),[he,ge]=(0,V.useState)(()=>{let e=AA(z(R.schedLeadMin));return e==null?``:kA(e)}),_e=(0,V.useRef)({}),ve=(0,V.useRef)(x.parkedAt),ye=(0,V.useRef)(0),[be,xe]=(0,V.useState)([]),[Se,Ce]=(0,V.useState)(0),[we,Te]=(0,V.useState)(!1),[Ee,De]=(0,V.useState)([]),Oe=g[0]??``,ke={prompts:g,target:C,when:T,sequential:O},Ae=HA(T,i??void 0),je=(0,V.useMemo)(()=>t.scheduleId?a.find(e=>e.id===t.scheduleId)??null:null,[a,t.scheduleId]),Me=h?Sde(T,Ae,h.ids.length):pde(ke,Ae,je),Ne=h?Cde(h.ids.length,T.kind===`at`?An(T.rule):T.kind===`now`?KA:Zn(T,Ae)):ade(ke,b,Ae),Pe=T.kind===`at`||T.kind===`after`?null:_de(C),Fe=(0,V.useRef)(Date.now()),Ie=(0,V.useMemo)(()=>gde(a,Fe.current,t.scheduleId).filter(e=>!h?.ids.includes(e.id)),[a,t.scheduleId,h]),Le=C.kind===`repos`?C.dirs[0]??t.cwdHint??``:C.cwd,Re=r.find(e=>e.worktreePath===Le)??null,ze=t.repoId??Re?.id??null,Be=xde(Oe).length;async function Ve(e){if(!we){Te(!0);try{return await e()}finally{Te(!1),Ce(e=>e+1)}}}async function He(e){if(!e.length||!Re)return;let t=e.filter(e=>/^image\//.test(e.type)),n=e.filter(e=>!/^image\//.test(e.type));if(n.length){Te(!0);try{let e=await s(n,Re);if(e.length){De(t=>[...t,...e]);let t=v.current.length?v.current.slice():[``],n=t[0]??``;t[0]=n?`${n}${/\s$/.test(n)?``:` `}${e.join(` `)}`:e.join(` `),y(t)}}finally{Te(!1)}}t.length&&c(t,Re)}function Ue(e){E(t=>t.kind===`at`?{...t,rule:{...t.rule,...e}}:t)}function We(e){E(t=>t.kind===`at`?{...t,rule:e}:t)}function Ge(e){if(T.kind!==`at`){let t=ve.current;if(t&&t.kind===`at`){let n=vi(t.rule)===e?t.rule:_e.current[e];E({...t,rule:n??oi(e,!1,t.rule,Date.now(),wA)});return}E(e===`window`?$ue():OA(36e5));return}ie(null);let t=vi(T.rule);t!==e&&(_e.current[t]=T.rule);let n=_e.current[e];We(n??oi(e,!1,T.rule,Date.now(),wA))}function Ke(){if(T.kind===`after`)return;let e=Ie[0];qe({kind:`after`,id:e?.id??``,title:e?lj(e):void 0})}function qe(e){T.kind===`at`&&(ve.current=T),E(e)}function Je(){if(Me)return;q(`action:send.post`);let e=v.current.map(e=>e.trim()).filter(Boolean);d({prompts:e,target:C,when:T,sequential:O,launchChosen:!0})&&(h||mh(m,``),f())}let Ye=Ze(be),Xe=En(be),Qe=T.kind===`at`?T.rule:null,$e=Qe?.days??[],et=Qe?vi(Qe):null,tt=Qe?ir(Qe):!1,nt=Qe?WA(Qe):`session`,rt=Qe?GA(Qe):`session`;return{...e,live:p,draftKey:m,retime:h,promptsRef:v,names:b,resumed:x,seededTarget:S,closeGlobal:D,decideRef:A,ruleMemo:_e,atMemo:ve,focusStep:ye,text:Oe,intent:ke,preview:Ae,editing:je,blocker:Me,label:Ne,seqMeans:Pe,openedAt:Fe,chainRows:Ie,attachCwd:Le,attachRepo:Re,repoId:ze,waitsForFiles:Be,ready:Ye,blockers:Xe,rule:Qe,days:$e,anchor:et,recurs:tt,anchorW:nt,guardW:rt,prompts:g,setPrompts:_,target:C,setTarget:w,when:T,setWhen:E,sequential:O,setSequential:k,open:j,setOpen:M,more:N,setMore:P,budgetOpen:F,setBudgetOpen:ee,launchOpen:te,setLaunchOpen:ne,quickKey:re,setQuickKey:ie,pctOpen:ae,setPctOpen:oe,savedPct:se,setSavedPct:ce,pctRaw:le,setPctRaw:ue,leadOpen:de,setLeadOpen:fe,savedLead:pe,setSavedLead:me,leadRaw:he,setLeadRaw:ge,states:be,setStates:xe,nonce:Se,setNonce:Ce,busy:we,setBusy:Te,shots:Ee,setShots:De,updatePrompts:y,guard:Ve,pick:He,patchRule:Ue,replaceRule:We,setAnchor:Ge,setAfter:Ke,leaveAt:qe,go:Je}}function kJ(e){let t=OJ(e),{retime:n,onDiscard:r,onClose:i}=t;return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:n?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(rl,{size:16}),` Re-time`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Uc,{size:16}),` Send`]}),onClose:i,children:r&&!n&&(0,J.jsxs)(Y,{variant:`danger`,title:`throw this message away — the words go too`,onClick:()=>{q(`action:send.discard`),r(),i()},children:[(0,J.jsx)(B,{size:16}),` discard`]})}),(0,J.jsxs)(`div`,{className:`sheet-scroll`,children:[n?(0,J.jsx)(dJ,{m:t}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(uJ,{m:t}),(0,J.jsx)(SJ,{m:t})]}),(0,J.jsx)(DJ,{m:t})]}),(0,J.jsx)(fJ,{m:t})]})}var AJ=te(`builds.json`),jJ=`\`${AJ}\` is a JSON array of objects \`{ "id", "name", "cmd", "dir", "params" }\`:
25
+ - It is COMMITTED with the repo, so every checkout gets the buttons. An entry whose command names a path that exists on this desktop alone (a \`JAVA_HOME\`, a local SDK) goes in \`${Dt(`builds.json`)}\` instead — same shape, gitignored; there an entry with a shared entry's \`id\` replaces it on this desktop only.
26
+ - \`id\`: short unique slug. If the file already exists, KEEP the ids that are there.
27
+ - \`name\`: short button label, e.g. "Release APK". It is read on a phone, so keep it short.
28
+ - \`cmd\`: ONE shell command line, run by the login shell.
29
+ - \`dir\`: repo-relative working sub-dir, or omit for the repo root.
30
+ - \`params\` (optional): what the button ASKS before it runs — an array of \`{ "id", "label", "kind", "options", "optionsCmd", "default", "hint" }\`.
31
+ - Use this instead of writing one button per member of a monorepo. One "Screenshot app" with an \`app\` parameter beats forty buttons.
32
+ - \`id\`: \`[A-Za-z][A-Za-z0-9_]*\`. Referenced in \`cmd\` and \`dir\` as \`{{id}}\`, and exported to the command as \`${Dr(`<ID>`)}\` (upper-cased) whether or not the command line names it.
33
+ - \`kind\`: \`"text"\` (typed on a phone keyboard — avoid where a list is possible) or \`"choice"\` (a drop-down).
34
+ - A choice gets its options from a fixed \`options: ["a","b"]\`, or from \`optionsCmd\` — a shell one-liner run IN THE REPO ROOT when the form opens, one option per line of stdout (e.g. \`ls -1 apps\`). Prefer \`optionsCmd\` where the list can change: a hard-coded list of a monorepo's apps goes stale the week somebody adds one.
35
+ - \`default\`: used when nobody is asked — a schedule, a chain, "run it now". A parameter with no default REFUSES those runs in words rather than guessing, which is correct for "which app" and wrong for "which flavour"; give a default where one is genuinely safe.
36
+ - The value is substituted VERBATIM, so quote the placeholder in the command if a value could contain spaces: \`--app "{{app}}"\`. A placeholder no parameter declares is left as written, and the command fails loudly.`,MJ=`- Every command must be non-interactive, must not need a TTY, must not push, deploy, publish, tag or release anything, and must not need a secret that isn't already on this machine.
37
+ - Check the command actually exists (the npm script is in package.json, the gradle task is real, the script is executable). Do NOT run the builds themselves.
38
+ ${`- Do NOT copy artifacts into \`.claude/outbox/\`, do NOT stamp a version or a timestamp into the output's file name, and do NOT delete old builds. ${I.name} does all three itself after every run: it collects what the build produced into \`.claude/outbox/\`, names it after the repo + variant + the project's own version, and removes older builds of the same artifact. A command that also does it produces a second copy under a second name.
39
+ - Let the build write wherever it natively writes (\`build/outputs/…\`, \`dist/\`, \`target/\`). If the tool can be told to put the project's version in the file name natively, that is fine and is kept; anything else is renamed for you.`}`,NJ=`Set up ${I.name}'s build buttons for this repo.
40
+
41
+ ${I.name} can run shell commands in this repo without a Claude session — the escape hatch for when you are rate-limited. The buttons come from \`${AJ}\` here.
42
+
43
+ 1. Work out how this project really builds and packages, from the repo itself: package.json scripts, gradlew tasks, Makefile, Cargo.toml, pyproject, CMake, Xcode schemes, monorepo sub-dirs, and the CI workflow files (CI is usually the most honest source).
44
+ 2. Write the file. ${jJ}
45
+ If the file already exists, merge into it and keep the ids that are already there.
46
+ 3. Prefer commands that produce a downloadable artifact (apk/aab/ipa/zip/dmg/whl/tgz/…) — ${I.name} collects those into \`.claude/outbox/\` under a versioned name and offers them for download when a run finishes. Then add the everyday ones worth having on a phone: full build, unit tests, lint/typecheck.
47
+ 4. Where this repo holds many buildable members (a monorepo of apps, flavours, targets), write ONE parameterised button rather than one button each.
48
+ ${MJ}
49
+ 5. Finish with one line per button you wrote, and say what you skipped and why.`;function PJ(e){let t=[];return e.brief?.trim()&&t.push(`- What I want: ${e.brief.trim()}`),e.name?.trim()&&t.push(`- Button label so far: "${e.name.trim()}"`),e.cmd?.trim()&&t.push(`- Command so far: \`${e.cmd.trim()}\``),e.dir?.trim()&&t.push(`- Working sub-dir so far: \`${e.dir.trim()}\``),t.join(`
50
+ `)}function FJ(e,t){let n=PJ(e),r=t?` in ${t}`:``,i=n?`Here is what I have typed into the form so far — treat it as the brief, finish it and correct it:\n${n}`:e.existing?`I have not said what to change. Read the entry named below and improve it — or ask me what I want before writing anything.`:`I have not said what the button should do yet. ASK me what I want before writing anything — do not invent a build button.`,a=e.existing&&e.id?`Edit the EXISTING entry with id \`${e.id}\` in place. Do not add a second entry and do not touch any other entry in the file.`:`ADD exactly ONE entry. Keep every entry already in the file exactly as it is — same ids, same commands.`;return`Add one build button to ${I.name} for this repo${r}.
51
+
52
+ ${I.name} runs these shell commands without a Claude session — the escape hatch for when you are rate-limited. The buttons come from \`${AJ}\` here, and I am on the phone with the "new build" form open.
53
+
54
+ ${i}
55
+
56
+ ${a}
57
+
58
+ ${jJ}
59
+
60
+ Work out the real command from the repo itself (package.json scripts, gradlew tasks, Makefile, monorepo sub-dirs, the CI workflows — CI is usually the most honest source), rather than guessing a plausible one.
61
+
62
+ If the same command would otherwise be copied per app/flavour/target, give the entry a \`params\` question instead of writing several buttons.
63
+
64
+ ${MJ}
65
+
66
+ Finish with one line: the button you wrote, its command, and what it will ask for when I tap it.`}var IJ=`work it out`,LJ=`say what this button should do, then have Claude work out THIS one build command from the repo and write it into ${AJ} — the whole-repo “set up” is the sheet's other button`,RJ=`What should this button do?`,zJ=`e.g. take a screenshot of one Garmin app — let me pick which app when I tap run`,BJ=`The name, command and sub-dir above go with this. Nothing is sent until you tap “work it out”, and it writes only this one entry.`,VJ=`say what the button should do first — a session with no brief starts guessing`;function HJ(e){let t=e.params??[];return t.length?`asks for ${t.map(e=>e.label||e.id).join(`, `)}`:``}function UJ(e){let t=Math.max(0,...[...e.matchAll(/`+/g)].map(e=>e[0].length));return"`".repeat(Math.max(3,t+1))}function WJ(e){let t=e.upstream??`its upstream`,n=e.ahead?` (${e.ahead} commit${e.ahead>1?`s`:``} ahead)`:``,r=e.verb===`push`?`Pushing \`${e.branch}\`${n} to \`${t}\` failed on this desktop${e.took?` after ${e.took}`:``}.`:`Pulling \`${t}\` into \`${e.branch}\` failed on this desktop.`,i=UJ(e.error),a=e.verb===`push`?`Find the cause and fix it. Re-run the check that failed until it passes, then commit the fix. Leave the push to me — I'll retry it from the phone.`:`Find out why and get the branch to where the pull can go through, without losing any local commit or uncommitted edit. Don't push.`;return[r,``,`This is what the phone's git screen showed. It is only the last lines of the output, so re-run the failing step yourself for the whole of it.`,``,i,e.error.trim(),i,``,a].join(`
67
+ `)}function GJ(e,t){return{prompts:[WJ(e)],target:{kind:`repo`,cwd:t.worktreePath},cwdHint:t.worktreePath,repoId:t.id,origin:`From ${t.repoName}'s git screen — the failed ${e.verb}`}}function KJ(e,t=300){let n=e.replace(/\s+$/,``).split(`
68
+ `);return n.length<=t?{text:n.join(`
69
+ `),cut:0}:{text:n.slice(-t).join(`
70
+ `),cut:n.length-t}}function qJ(e,t,n){let{text:r,cut:i}=KJ(t),a=UJ(r),o=e.params&&Object.keys(e.params).length?` with ${Object.entries(e.params).map(([e,t])=>`${e}=${t}`).join(`, `)}`:``,s=e.status===`failed`?`failed${e.exitCode==null?``:` (exit ${e.exitCode})`}`:e.status===`running`?`is still running`:`finished`,c=e.status===`failed`?`Find the cause and fix it. Re-run the command until it passes, then commit the fix.`:`Look through it and tell me anything that needs fixing — warnings, slow steps, anything that looks wrong. Don't change anything yet.`;return[`The build "${e.name}"${o} ${s} on this desktop${n?` after ${n}`:``}.`,``,`Command: \`${e.cmd}\``,`Ran in: \`${e.cwd}\``,``,i?`This is the last 300 lines of its output (${i} earlier lines left out) — re-run the command for the whole of it.`:`This is its whole output as the phone's build sheet showed it.`,``,a,r,a,``,c].join(`
71
+ `)}function JJ(e,t,n,r){return{prompts:[qJ(e,t,r)],target:{kind:`repo`,cwd:n.worktreePath},cwdHint:n.worktreePath,repoId:n.id,origin:`From ${n.repoName}'s build sheet — the run of “${e.name}”`}}function YJ({r:e,text:t,logRef:n,onSendLog:r}){return(0,J.jsxs)(J.Fragment,{children:[t.trim()&&(0,J.jsxs)(`div`,{className:`sheet-actions build-log-acts`,children:[(0,J.jsxs)(Y,{onClick:async()=>{q(`action:build.copyLog`),K(await Xf(t)?`Copied: the run's log.`:`Couldn't reach the clipboard. Select the log below instead.`)},title:`copy this run's output to the clipboard`,children:[(0,J.jsx)(_o,{size:16}),` `,`copy log`]}),r&&(0,J.jsxs)(Y,{onClick:()=>{q(`action:build.sendLog`),r(e,t,Ap(e.startedAt,e.finishedAt))},title:`open the Send sheet with this log, the command and its exit, aimed at a new session in this repo — nothing is sent yet`,children:[(0,J.jsx)(Do,{size:16}),` `,`send to a session…`]})]}),(0,J.jsx)(`pre`,{className:`build-log`,ref:n,children:t||XJ(e)})]})}function XJ(e){return e.status===`running`?`(no output yet)`:`(no output kept — the desktop holds a run's output in memory, so a restart since it ran clears it; or the command printed nothing)`}var ZJ=`${I.sharedDirName}/builds.json`,QJ=`${I.stateDirName}/builds.json`;function $J(e,t,n){if(!e)return;let r=new Set(t.map(e=>e.id)),i=new Set(e.filter(e=>r.has(e)));return n&&(n.local&&r.has(n.id)?i.add(n.id):i.delete(n.id)),[...i]}function eY(e,t){return e?t?`This desktop gets its own version, kept in ${QJ}; other checkouts keep the shared one.`:`Kept in ${QJ} on this desktop only, never committed.`:`Committed in ${ZJ}, so every checkout of this repo gets it.`}var tY=`this desktop only`;function nY({local:e,wasShared:t,onChange:n}){return(0,J.jsx)(QS,{label:`Where it lives`,value:e?`local`:`shared`,onChange:e=>{q(`action:build.scope`),n(e===`local`)},options:[{value:`shared`,label:`Every checkout`,icon:ds},{value:`local`,label:`This desktop only`,icon:Pte}],note:eY(e,t)})}function rY({draft:e,candidates:t,candidatesTotal:n,online:r,saved:i,scope:a,onAssist:o,onDelete:s,onCancel:c,onSave:l}){let[u,d]=(0,V.useState)(a?.local??!1),[f,p]=(0,V.useState)(e.name),[m,h]=(0,V.useState)(e.cmd),[g,_]=(0,V.useState)(e.dir??``),[v,y]=(0,V.useState)(e.params??[]),[b,x]=(0,V.useState)(null),S=!e.cmd&&!e.name,[C,w]=(0,V.useState)(S),T=Bee(t??[],S?`${f} ${g}`.trim():``);function E(e){q(`action:build.suggest.use`),p(e.name),h(e.cmd),_(e.dir??``),w(!1)}let D=Xi({cmd:m,dir:g,params:v});return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:(0,J.jsx)(J.Fragment,{children:e.cmd||e.name?`Edit build`:`New build`}),onClose:c,children:(0,J.jsxs)(Y,{title:LJ,onClick:()=>x(e=>e===null?``:null),children:[(0,J.jsx)(pc,{size:16}),` `,IJ]})}),(0,J.jsxs)(`div`,{className:`form`,children:[(0,J.jsx)(`input`,{className:`search`,placeholder:`Name (e.g. Release APK)`,value:f,onChange:e=>p(e.target.value),autoFocus:!0}),(0,J.jsx)(`textarea`,{className:`search`,rows:3,placeholder:`Command (e.g. ./gradlew assembleRelease)`,value:m,onChange:e=>h(e.target.value),style:{resize:`vertical`,fontFamily:`monospace`}}),(0,J.jsx)(`input`,{className:`search`,placeholder:`Working sub-dir (optional, relative to repo root)`,value:g,onChange:e=>_(e.target.value),style:{fontFamily:`monospace`}})]}),b===null?(0,J.jsxs)(Z,{children:[`Tap `,(0,J.jsx)(pc,{size:12,style:{verticalAlign:`-2px`}}),` `,IJ,` to say what you want in a sentence and have Claude work this one command out of the repo — one turn, this entry only.`]}):(0,J.jsxs)(`div`,{className:`build-assist`,children:[(0,J.jsx)(`div`,{className:`section`,children:RJ}),(0,J.jsx)(yE,{inline:!0,rows:3,placeholder:zJ,prompts:[b],onChange:e=>x(e[0]??``),autoFocus:!0}),(0,J.jsx)(Z,{children:BJ}),(0,J.jsxs)(`div`,{className:`sheet-actions`,children:[(0,J.jsxs)(Y,{onClick:()=>x(null),children:[(0,J.jsx)(B,{size:16}),` cancel`]}),(0,J.jsx)(`span`,{className:`spacer`}),b.trim()||f.trim()||m.trim()?(0,J.jsxs)(`button`,{className:`send`,onClick:()=>o({id:e.id,brief:b,name:f,cmd:m,dir:g,existing:i}),children:[(0,J.jsx)(pc,{size:14}),` `,IJ]}):(0,J.jsx)(Qw,{cants:[{label:IJ,reason:VJ}]})]})]}),(0,J.jsx)(iY,{params:v,cmd:m,dir:g,unknown:D,onChange:y}),(0,J.jsx)(`div`,{className:`sheet-actions`,children:(0,J.jsx)(Y,{onClick:()=>{C||q(`action:build.suggest.open`),w(!C)},children:t===null?r?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)($s,{size:16,className:`spin`}),` reading the repo…`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(fo,{size:16}),` no connection`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(rc,{size:16}),` `,C?`hide`:`suggest`,` (`,T.length,`)`]})})}),C&&(0,J.jsxs)(`div`,{className:`build-suggest`,children:[(0,J.jsxs)(Z,{children:[`From this repo’s own files — package.json scripts, gradle tasks, Makefile targets, CI workflow steps, scripts. Tap one to fill the fields above; nothing is saved or run until you tap Save.`,t!==null&&n>t.length&&` Showing the top ${t.length} of ${n} found.`]}),(0,J.jsxs)(`div`,{className:`list`,children:[T.map(e=>(0,J.jsxs)(Xw,{as:`button`,onClick:()=>E(e),children:[(0,J.jsxs)(Zw,{children:[e.name,e.already?(0,J.jsxs)(J.Fragment,{children:[` `,(0,J.jsxs)(qw,{className:`idle`,children:[(0,J.jsx)(vc,{size:11}),` already a button`]})]}):null]}),(0,J.jsxs)(Q,{className:`mono`,children:[e.dir?`${e.dir}$ `:``,e.cmd]}),(0,J.jsx)(Q,{children:e.source}),e.note?(0,J.jsxs)(Q,{className:`warn`,children:[(0,J.jsx)(gs,{size:12}),` `,e.note]}):null]},`${e.dir??``}|${e.cmd}`)),T.length===0&&(t===null?r?(0,J.jsx)($,{children:`Reading this repo’s manifests…`}):(0,J.jsx)($,{children:`No connection, so this repo’s files could not be read — the scan happens on the desktop. Type the command above; it is saved when the link is back.`}):t.length===0?(0,J.jsx)($,{children:`Nothing in this repo describes a build — no package.json scripts, no gradle or Make targets, no CI steps. Type the command above, or close this and tap “set up” to have Claude work it out from the repo.`}):(0,J.jsxs)($,{children:[`None of this repo’s `,t.length,` known commands match “`,`${f} ${g}`.trim(),`”. Clear the Name field to see all of them.`]}))]})]}),a&&(0,J.jsx)(nY,{local:u,wasShared:i&&!a.local,onChange:d}),(0,J.jsxs)(`div`,{className:`sheet-actions`,children:[(0,J.jsxs)(Y,{onClick:c,children:[(0,J.jsx)(B,{size:16}),` cancel`]}),i&&(0,J.jsxs)(fC,{title:`delete this build command`,confirm:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ws,{size:16}),` delete it?`]}),onConfirm:()=>{q(`action:build.delete`),s()},children:[(0,J.jsx)(ws,{size:16}),` delete`]}),(0,J.jsx)(`span`,{className:`spacer`}),(0,J.jsx)(`button`,{className:`send`,disabled:!m.trim(),onClick:()=>{q(`action:build.save`),l({...e,name:f,cmd:m,dir:g,params:dte(v)},u)},children:`Save`})]})]})}function iY({params:e,cmd:t,dir:n,unknown:r,onChange:i}){let[a,o]=(0,V.useState)(e.length>0||r.length>0),s=(t,n)=>i(e.map((e,r)=>r===t?{...e,...n}:e));return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`sheet-actions`,children:[(0,J.jsxs)(Y,{onClick:()=>o(!a),children:[(0,J.jsx)(cs,{size:16}),` `,a?`hide`:`asks for`,` (`,e.length,`)`]}),a&&(0,J.jsxs)(Y,{onClick:()=>i([...e,{id:``,kind:`text`}]),children:[(0,J.jsx)(Fo,{size:16}),` question`]})]}),r.length>0&&(0,J.jsxs)(Z,{tone:`warn`,children:[(0,J.jsx)(gs,{size:13,style:{verticalAlign:`-2px`}}),` `,r.map(e=>`{{${e}}}`).join(`, `),` `,r.length===1?`is`:`are`,` in the command but nothing here answers `,r.length===1?`it`:`them`,` — the shell will see the braces. Add a question with that id, or fix the spelling.`]}),a&&(0,J.jsxs)(`div`,{className:`build-params`,children:[(0,J.jsxs)(Z,{children:[`A question is asked when you tap run. Its value is put into the command at `,(0,J.jsx)(`span`,{className:`mono`,children:`{{id}}`}),` — and into the environment as `,(0,J.jsx)(`span`,{className:`mono`,children:Dr(`id`)}),`, whether the command names it or not. One question beats one button per app.`]}),e.map((r,a)=>(0,J.jsxs)(`div`,{className:`build-param`,children:[(0,J.jsxs)(JS,{children:[(0,J.jsxs)(`label`,{children:[`id`,(0,J.jsx)(`input`,{className:`search mono`,placeholder:`app`,value:r.id,onChange:e=>s(a,{id:e.target.value.trim()})})]}),(0,J.jsxs)(`label`,{children:[`label`,(0,J.jsx)(`input`,{className:`search`,placeholder:`Garmin app`,value:r.label??``,onChange:e=>s(a,{label:e.target.value})})]}),(0,J.jsxs)(`label`,{children:[`kind`,(0,J.jsxs)(`select`,{value:r.kind,onChange:e=>s(a,{kind:e.target.value}),children:[(0,J.jsx)(`option`,{value:`text`,children:`typed in`}),(0,J.jsx)(`option`,{value:`choice`,children:`picked from a list`})]})]}),r.kind===`choice`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`label`,{children:[`list command`,(0,J.jsx)(`input`,{className:`search mono`,placeholder:`ls -1 apps`,value:r.optionsCmd??``,onChange:e=>s(a,{optionsCmd:e.target.value})})]}),(0,J.jsx)(X,{as:`span`,children:`Run in the repo root when the form opens, one option per line. Leave it empty and type the options below instead — a list that can change is better read than transcribed.`}),(0,J.jsxs)(`label`,{children:[`or fixed options`,(0,J.jsx)(`input`,{className:`search`,placeholder:`debug, release`,value:(r.options??[]).join(`, `),onChange:e=>s(a,{options:e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)})})]})]}),(0,J.jsxs)(`label`,{children:[`default`,(0,J.jsx)(`input`,{className:`search mono`,placeholder:`(none — an unattended run is refused)`,value:r.default??``,onChange:e=>s(a,{default:e.target.value})})]}),(0,J.jsx)(X,{as:`span`,children:`With no default, a run nobody is watching — a schedule, a chain, “run it now” — is refused in words rather than guessing this value.`})]}),(0,J.jsxs)(`div`,{className:`sheet-actions`,children:[(0,J.jsx)(Q,{children:r.id&&(t+` `+n).includes(`{{${r.id}}}`)?(0,J.jsxs)(J.Fragment,{children:[`in the command as `,(0,J.jsx)(`span`,{className:`mono`,children:`{{${r.id}}}`})]}):r.id?(0,J.jsxs)(J.Fragment,{children:[`only in the environment — the command does not name `,(0,J.jsx)(`span`,{className:`mono`,children:`{{${r.id}}}`})]}):(0,J.jsxs)(J.Fragment,{children:[`an id is `,(0,J.jsx)(`span`,{className:`mono`,children:`app`}),`, `,(0,J.jsx)(`span`,{className:`mono`,children:`flavour`}),` — a letter, then letters, digits or underscores`]})}),(0,J.jsx)(`span`,{className:`spacer`}),(0,J.jsx)(Y,{variant:`danger`,title:`remove this question`,onClick:()=>i(e.filter((e,t)=>t!==a)),children:(0,J.jsx)(ws,{size:16})})]})]},a)),e.length===0&&(0,J.jsx)($,{children:`This button asks nothing — every tap runs the same command. Add a question to run it against one app, flavour or target.`})]})]})}function aY({build:e,options:t,online:n,onApprove:r,onCancel:i,onRun:a}){let[o,s]=(0,V.useState)(()=>{let t={};for(let n of e.params??[])n.default&&(t[n.id]=n.default);return t}),{values:c,missing:l}=Nte(e.params,o),u=wee(e.cmd,c);return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(La,{size:16}),` `,e.name]}),onClose:i}),(0,J.jsxs)(Z,{tone:`mono`,children:[e.dir?`${e.dir}$ `:``,e.cmd]}),(0,J.jsx)(`div`,{className:`build-params`,children:(e.params??[]).map(e=>(0,J.jsx)(oY,{p:e,value:o[e.id]??``,answer:t?.[e.id],online:n,onApprove:t=>r(e.id,t),asked:t!==void 0,onChange:t=>s(n=>({...n,[e.id]:Jee(t)}))},e.id))}),(0,J.jsxs)(`div`,{className:`sheet-actions`,children:[(0,J.jsxs)(Y,{onClick:i,children:[(0,J.jsx)(B,{size:16}),` cancel`]}),(0,J.jsx)(`span`,{className:`spacer`}),l.length===0&&u.length===0?(0,J.jsxs)(`button`,{className:`send`,onClick:()=>a(c),children:[(0,J.jsx)(La,{size:14}),` Run`]}):(0,J.jsx)(Qw,{cants:[{label:`run`,reason:l.length?Mr(l):Ui(u)}]})]}),!n&&(0,J.jsxs)(Z,{children:[(0,J.jsx)(fo,{size:13,style:{verticalAlign:`-2px`}}),` No connection: the run is queued and starts with these values once the link is back.`]})]})}function oY({p:e,value:t,answer:n,online:r,asked:i,onChange:a,onApprove:o}){let s=n?.options??e.options??[],c=!!n?.needsApproval,l=e.kind===`choice`&&!!e.optionsCmd&&!n&&!e.options?.length,u=e.kind===`text`||!s.length&&!l;return(0,J.jsx)(`div`,{className:`build-param`,children:(0,J.jsxs)(JS,{children:[(0,J.jsxs)(`label`,{children:[hee(e),u?(0,J.jsx)(`input`,{className:`search mono`,value:t,autoFocus:!t,onChange:e=>a(e.target.value)}):l?(0,J.jsx)(X,{as:`span`,children:r?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)($s,{size:13,className:`spin`,style:{verticalAlign:`-2px`}}),` reading the list…`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(fo,{size:13,style:{verticalAlign:`-2px`}}),` no connection — the list is read on the desktop`]})}):(0,J.jsxs)(`select`,{value:t,onChange:e=>a(e.target.value),children:[(0,J.jsx)(`option`,{value:``,children:`— pick one —`}),s.map(e=>(0,J.jsx)(`option`,{value:e,children:e},e))]})]}),e.hint&&(0,J.jsx)(X,{as:`span`,children:e.hint}),c&&(0,J.jsxs)(X,{children:[(0,J.jsx)(ss,{size:12,style:{verticalAlign:`-2px`}}),` This list comes from a command in the repo's committed build file. It has not been run on this desktop yet:`,(0,J.jsx)(`div`,{className:`mono`,children:n?.cmd??e.optionsCmd}),r?(0,J.jsxs)(Y,{onClick:()=>o(n?.cmd??e.optionsCmd??``),children:[(0,J.jsx)(ss,{size:14}),` Run this listing`]}):(0,J.jsxs)(`span`,{children:[(0,J.jsx)(fo,{size:12,style:{verticalAlign:`-2px`}}),` no connection — the listing runs on the desktop.`]}),(0,J.jsx)(`span`,{children:` You can also type the value instead.`})]}),!c&&e.optionsCmd&&!e.options?.length&&(0,J.jsxs)(X,{as:`span`,children:[`from `,(0,J.jsx)(`span`,{className:`mono`,children:e.optionsCmd}),` in the repo`,n?.total&&n.total>s.length?` · showing ${s.length} of ${n.total}`:``]}),n?.error&&(0,J.jsxs)(X,{as:`span`,className:`warn`,children:[(0,J.jsx)(gs,{size:12,style:{verticalAlign:`-2px`}}),` `,n.error,` — type the value instead.`]}),u&&!e.optionsCmd&&e.kind===`choice`&&i&&!s.length&&(0,J.jsx)(X,{as:`span`,children:`no options to offer — type the value.`})]})})}function sY({policy:e,online:t,onSave:n}){if(!e||!n)return null;let r=t=>n({...e,...t}),i=(0,J.jsxs)(J.Fragment,{children:[`Every build here: `,Wi(e),`.`]});return(0,J.jsxs)(`div`,{className:`artifact-policy`,children:[(0,J.jsxs)(`div`,{className:`section ap-head`,children:[`What a build leaves`,t&&(0,J.jsxs)(tT,{of:`what a build leaves`,children:[i,` `,(0,J.jsx)(`b`,{children:`collect + name`}),` copies what a build produces into .claude/outbox under a name carrying the repo, the variant and the version; `,(0,J.jsx)(`b`,{children:`remove older`}),` then deletes older builds of the same artifact from the outbox — never anything else.`]})]}),t?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ZS,{label:`collect + name`,icon:Vo,on:e.collect,onChange:()=>{q(`action:build.collect`),r({collect:!e.collect})}}),e.collect&&(0,J.jsx)(ZS,{label:`remove older`,icon:ws,on:e.prune,onChange:()=>{q(`action:build.prune`),r({prune:!e.prune})}}),e.collect&&e.prune&&(0,J.jsxs)(`div`,{className:`ap-keep`,children:[`keep`,e.keep>1&&(0,J.jsx)(Y,{"aria-label":`keep one fewer`,title:`keep one fewer build of each artifact`,onClick:()=>r({keep:e.keep-1}),children:(0,J.jsx)(ls,{size:14})}),(0,J.jsx)(`span`,{className:`ap-keep-n`,"aria-live":`polite`,children:e.keep}),e.keep<50&&(0,J.jsx)(Y,{"aria-label":`keep one more`,title:`keep one more build of each artifact`,onClick:()=>r({keep:e.keep+1}),children:(0,J.jsx)(Fo,{size:14})})]})]}):(0,J.jsxs)(Z,{children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(Vo,{size:13,style:{verticalAlign:`-2px`}}),` `,i]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(fo,{size:13,style:{verticalAlign:`-2px`}}),` this is this device's copy — changing it needs the desktop, where the policy lives with the project.`]})]})]})}function cY({a:e,repoDir:t,repoName:n,onDownload:r}){return(0,J.jsxs)(Xw,{kind:`wrap`,children:[(0,J.jsxs)(Xw,{as:`button`,kind:`grow`,title:e.relPath,onClick:()=>{q(`action:build.artifact`),r(e)},children:[(0,J.jsxs)(Zw,{children:[(0,J.jsx)(Qa,{size:14}),` `,e.name]}),(0,J.jsxs)(Q,{children:[yp(e.size),e.mtime?` · ${Vp(e.mtime)}`:``,e.stale?` · unchanged by this run (already up to date)`:``]})]}),(0,J.jsx)(gO,{compact:!0,trackId:`action:build.artifact`,target:{repoId:e.repoId,relPath:e.relPath,name:e.name,size:e.size,mtime:e.mtime,repoDir:t,repoName:n}})]})}function lY({repo:e,builds:t,runs:n,output:r,outTick:i,onSave:a,localIds:o,onRun:s,onCancel:c,onDownload:l,onSetup:u,onSendLog:d,onScan:f,onAskOptions:p,onClose:m,candidates:h=null,candidatesTotal:g=0,paramOptions:_,online:v=!0,listAt:y=0,policy:b,onSavePolicy:x}){let[S,C]=(0,V.useState)(null),[w,T]=(0,V.useState)(null),[E,D]=(0,V.useState)(null),O=E===``?null:n.find(e=>e.runId===E)??n[0]??null,k=(0,V.useRef)(null),A=(0,V.useRef)(null);(0,V.useEffect)(()=>{let e=k.current;e&&(e.scrollTop=e.scrollHeight)},[i,O?.runId]),(0,V.useEffect)(()=>{E&&A.current?.scrollIntoView({block:`nearest`})},[E]);function j(e){let n=t.filter(t=>t.id!==e);a(n,$J(o,n)),C(null)}function M(e,n=!1){let r=e.cmd.trim();if(!r){C(null);return}let i={...e,cmd:r,name:e.name.trim()||`build`,dir:e.dir?.trim()||void 0},s=t.some(t=>t.id===e.id)?t.map(t=>t.id===e.id?i:t):[...t,i];a(s,$J(o,s,{id:e.id,local:n})),C(null)}function N(e){C(e),f()}function P(e){e.params?.length?(q(`action:build.ask`),T(e),p(e.id)):(q(`action:build.run`),s(e.id))}return Gh(S!==null,()=>C(null)),Gh(w!==null,()=>T(null)),S?(0,J.jsx)(rY,{draft:S,candidates:h,candidatesTotal:g,online:v,saved:t.some(e=>e.id===S.id),scope:o?{local:o.includes(S.id)}:null,onDelete:()=>j(S.id),onAssist:t=>{q(`action:build.one`),u(FJ(t,e.repoName))},onCancel:()=>C(null),onSave:M}):w?(0,J.jsx)(aY,{build:w,options:_?.[w.id],online:v,onApprove:(e,t)=>{q(`action:build.approve-options`),p(w.id,{paramId:e,cmd:t})},onCancel:()=>T(null),onRun:e=>{q(`action:build.run`),s(w.id,e),T(null)}}):(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsxs)(Uw,{title:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(uo,{size:16}),` Build · `,e.repoName]}),onClose:m,children:[Ci(e)&&(0,J.jsx)(Q,{className:`head-branch`,children:Ci(e)}),(0,J.jsxs)(Y,{title:`ask Claude to work out this repo's build commands`,onClick:()=>{q(`action:build.setup`),u(NJ)},children:[(0,J.jsx)(pc,{size:16}),` set up`]}),v&&(0,J.jsxs)(Y,{title:`add a build command`,onClick:()=>N({id:Mp(`b`),name:``,cmd:``,dir:``}),children:[(0,J.jsx)(Fo,{size:16}),` new`]})]}),(0,J.jsxs)(Z,{children:[`Runs in a shell on the desktop, no tokens spent`,` `,(0,J.jsx)(tT,{of:`the build sheet`,children:`Works while Claude is rate-limited. What it produces is offered for download under its run.`})]}),!v&&(0,J.jsxs)(Z,{children:[(0,J.jsx)(fo,{size:13,style:{verticalAlign:`-2px`}}),` `,`No connection: a tap is queued and the build starts once the link is back. Adding, editing or deleting a command needs the link.`,t.length>0&&(y?` These commands are this device's copy, last confirmed ${Tp(y)} ago.`:` These commands are this device's copy.`)]}),(0,J.jsxs)(`div`,{className:`build-body`,children:[(0,J.jsxs)(`div`,{className:`list build-cmds`,children:[t.map(e=>{let t=n.find(t=>t.buildId===e.id&&t.status===`running`);return(0,J.jsxs)(Xw,{kind:`wrap`,children:[(0,J.jsxs)(Xw,{as:`button`,kind:`grow`,title:e.cmd,onClick:()=>{t?D(t.runId):P(e)},children:[(0,J.jsxs)(Zw,{children:[e.name,t?(0,J.jsxs)(J.Fragment,{children:[` `,(0,J.jsx)($s,{size:12,className:`spin`})]}):null]}),(0,J.jsxs)(Q,{className:`mono build-cmd`,children:[e.dir?`${e.dir}$ `:``,e.cmd]}),e.params?.length?(0,J.jsx)(Q,{children:HJ(e)}):null,o?.includes(e.id)?(0,J.jsx)(Q,{children:tY}):null]}),t?(0,J.jsx)(Y,{variant:`danger`,title:`cancel build`,onClick:()=>c(t.runId),children:(0,J.jsx)(ic,{size:16})}):(0,J.jsx)(Y,{title:e.params?.length?`run build — it asks first`:`run build`,onClick:()=>P(e),children:(0,J.jsx)(La,{size:16})}),v&&(0,J.jsx)(Y,{title:`edit or delete`,onClick:()=>N(e),children:(0,J.jsx)(Mo,{size:16})})]},e.id)}),t.length===0&&(v?(0,J.jsxs)($,{children:[`No build commands yet — tap “set up” or “new”.`,` `,(0,J.jsx)(tT,{of:`the two ways to add one`,label:`what do those do?`,children:`“set up” opens a session that reads the repo and writes them for you — do it while Claude still has tokens, since this sheet is what you fall back to when it doesn’t. “new” writes one yourself.`})]}):(0,J.jsx)($,{children:`No connection, and this device has no copy of this repo’s build commands — it has not had them since it was last on the link. This says nothing about whether the repo has any. Open this sheet once with the link up and they are cached here from then on.`}))]}),(0,J.jsx)(sY,{policy:b,online:v,onSave:x}),n.length>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`section`,children:`Runs`}),(0,J.jsx)(`div`,{className:`list build-runs`,children:n.slice(0,8).map(t=>{let n=Pp(r.get(t.runId)??``),i=O?.runId===t.runId&&(0,J.jsx)(YJ,{r:t,text:n,logRef:k,onSendLog:d});return(0,J.jsxs)(`div`,{className:`build-run-item`,children:[(0,J.jsxs)(`button`,{className:`row ${O?.runId===t.runId?`active`:``}`,onClick:()=>D(O?.runId===t.runId?``:t.runId),children:[(0,J.jsxs)(Zw,{children:[t.status===`running`?(0,J.jsx)($s,{size:12,className:`spin`}):null,` `,t.name,` `,(0,J.jsxs)(qw,{className:t.status===`done`?`idle`:t.status===`running`?`coding`:`dead`,children:[t.status,t.exitCode?` ${t.exitCode}`:``]})]}),t.params&&Object.keys(t.params).length>0&&(0,J.jsx)(Q,{className:`mono`,children:Object.entries(t.params).map(([e,t])=>`${e}=${t}`).join(` · `)}),(0,J.jsxs)(Q,{children:[Vp(t.finishedAt??t.startedAt),` · `,Ap(t.startedAt,t.finishedAt),t.artifacts?.length?` · ${t.artifacts.length} artifact${t.artifacts.length>1?`s`:``}`:``]}),O?.runId===t.runId?(0,J.jsx)(mc,{size:16,className:`build-run-fold`}):(0,J.jsx)(Nc,{size:16,className:`build-run-fold`})]}),O?.runId===t.runId&&(0,J.jsxs)(`div`,{className:`build-run`,ref:A,children:[t.status!==`done`&&i,t.artifacts&&t.artifacts.length>0&&(0,J.jsx)(`div`,{className:`list`,children:t.artifacts.map(t=>(0,J.jsx)(cY,{a:t,repoDir:e.worktreePath,repoName:e.repoName,onDownload:l},t.relPath))}),t.status===`done`&&!t.artifacts?.length&&(0,J.jsx)($,{children:`Build finished, no downloadable file found (nothing matching apk/aab/zip/… in the repo).`}),t.status===`done`&&i]})]},t.runId)})})]})]})]})}var uY=e=>`build:${e}`,dY=e=>`build “${e}”`;function fY(e,t){return e?`queued — the build starts when the link is back`:`starting “${t}”…`}function pY(e){return e.status===`done`?`build “${e.name}” done`:e.status===`failed`?`build “${e.name}” failed`:null}function mY(e,t,n){return(e.get(t)??[]).find(e=>e.id===n)?.name??n}function hY(e,t){let n=e.find(e=>e.repoDir===t.worktreePath&&e.status===`running`);if(n)return{name:n.name};let r=t.buildRunning;return r&&!e.some(e=>e.runId===r.runId)?{name:r.name}:null}var gY=W(new Map),_Y=$v({load:xT,save:ST}),vY=W(null),yY=W(new Map),bY=W(new Map),xY=W(new Map);function SY(e,t){return mY(_Y.cfgs.get().lists,e,t)}function CY(){let{lists:e}=G(_Y.cfgs);return(0,V.useCallback)((t,n)=>mY(e,t,n),[e])}function wY(e){return hY(G(_Y.runs),e)}function TY(e,t){gY.set(n=>kh(n,e,t))}function EY(e,t){xY.set(n=>kh(n,e,t))}function DY(e,t,n){bY.set(r=>kh(r,e,{...r.get(e)??{},[t]:n}))}function OY(e,t,n){yY.set(r=>kh(r,e,{list:t,total:n}))}function kY(e,t){_Y.onRun(e);let n=pY(e);n&&t.say.toast(n)}function AY(e){let t=U();vY.set(e),t.conn.send({t:`build.list`,repoDir:e.worktreePath}),t.conn.send({t:`artifacts.get`,repoDir:e.worktreePath}),t.nav.open(`build`)}function jY(){let e=vY.get();e&&U().conn.send({t:`build.list`,repoDir:e.worktreePath})}function MY(e,t,n){U().conn.liveSend({t:`build.save`,repoDir:e,builds:t,...n?{local:n}:{}},`build commands saved`,`no connection — build commands live on the desktop and can't be edited from here`)}function NY(e,t,n){let r=U(),i=yr(SY(e,t),n),a=r.queue.queueOp({t:`build.run`,repoDir:e,buildId:t,params:n},uY(e),dY(i),{cwd:e});r.say.toast(fY(a,i))}function PY(e){U().conn.liveSend({t:`build.cancel`,runId:e},`cancelling the build…`,`no connection — the build is running on the desktop and can't be stopped from here`)}function FY(e,t){let n=U();n.nav.close(`build`),n.nav.startSessionWithPrompt(e.worktreePath,Qn(e),[t])}function IY(e,t){xY.set(n=>kh(n,e,t)),U().conn.liveSend({t:`artifacts.save`,repoDir:e,policy:t},`saved — it applies to every build in this repo`,`no connection — what a build does with its output lives on the desktop and was not saved`)}function LY(e,t,n){n&&bY.set(r=>{let i=r.get(e)?.[t];if(!i||!(n.paramId in i))return r;let{[n.paramId]:a,...o}=i;return kh(r,e,{...r.get(e)??{},[t]:o})}),U().conn.send(n?{t:`build.options`,repoDir:e,buildId:t,approve:!0,paramId:n.paramId,cmd:n.cmd}:{t:`build.options`,repoDir:e,buildId:t})}function RY(e){U().conn.send({t:`build.scan`,repoDir:e})}function zY({repo:e}){let t=Dh(),n=e.worktreePath,r=G(_Y.cfgs),i=G(_Y.runs),a=G(_Y.outTick),o=G(yY).get(n),s=G(bY).get(n),c=G(gY).get(n),l=G(xY).get(n),u=(0,V.useMemo)(()=>i.filter(e=>e.repoDir===n),[i,n]);return(0,J.jsx)(lY,{repo:e,builds:r.lists.get(n)??[],listAt:r.at.get(n)??0,runs:u,output:_Y.output,outTick:a,online:t.conn.status===`open`,localIds:c,onSave:(e,t)=>MY(n,e,t),onRun:(e,t)=>NY(n,e,t),onCancel:PY,onDownload:e=>t.files.downloadArtifact(e),onSetup:t=>FY(e,t),onSendLog:(n,r,i)=>t.nav.openSend(JJ(n,r,e,i)),candidates:o?.list??null,candidatesTotal:o?.total??0,paramOptions:s,policy:l,onSavePolicy:e=>IY(n,e),onAskOptions:(e,t)=>LY(n,e,t),onScan:()=>RY(n),onClose:()=>t.nav.close(`build`)})}var BY={id:`build`,sheets:[{id:`build`,persisted:!1,render:()=>{let e=vY.get();return e?(0,V.createElement)(zY,{repo:e}):null}}],commands:[{id:`build`,run:e=>{let t=e.world.activeRepo;t?AY(t):e.say.toast(`not a known repo`)}}],messages:{welcome:()=>jY(),"artifacts.config":e=>EY(e.repoDir,e.policy),"build.list":e=>{_Y.onList(e.repoDir,e.builds,e.runs),TY(e.repoDir,e.localIds)},"build.options":e=>DY(e.repoDir,e.buildId,e.options),"build.candidates":e=>OY(e.repoDir,e.candidates,e.total),"build.run":(e,t)=>kY(e.run,t),"build.output":(e,t)=>_Y.onOutput(e.runId,Ip(e.dataB64),!!e.full,t.nav.overlay===`build`)}};function VY(e){if(!e.link)return null;let t=[{id:`link`,label:`background link`,done:e.link.enabled,why:`keeps the connection with the app closed: queued sends go out, downloads start, alerts arrive`},{id:`notifications`,label:`notifications`,done:e.link.notifications,why:`alerts, download progress and the one-tap install have nowhere to appear without it`},{id:`battery`,label:`background use`,done:e.link.batteryExempt,why:`a phone that dozes the app refuses to start a download or reconnect from the background`}];return e.canInstall!==null&&t.push({id:`install`,label:`install apps`,done:e.canInstall,why:`lets a downloaded build install from its notification or the Apps list`}),t}function HY(e){return`${e.filter(e=>e.done).length} of ${e.length} ready`}function UY(e){let t=e.filter(e=>!e.done).map(e=>e.label);return t.length?`Phone setup ${HY(e)} — still missing: ${t.join(`, `)}.`:null}function WY(e,t){let n=t?[...e]:e.filter(e=>!e.done);return{shown:n,hidden:e.length-n.length}}function GY(){let[e,t]=(0,V.useState)(null),n=(0,V.useCallback)(()=>{(async()=>{let e=await QG(),n=Dk()?await Ok().then(e=>e.caps.supported?e.caps.canInstall:null).catch(()=>null):null;t(VY({link:e,canInstall:n}))})()},[]);return(0,V.useEffect)(()=>{n();let e=()=>{document.visibilityState===`visible`&&n()};return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[n]),{steps:e,refresh:n}}var KY=[`Every agent session ${I.displayName} started on this desktop ends now, with the tools it is running — open or in the background.`,`Background model runs (review, naming, assessments) stop too.`,`Nothing automatic starts again until you lift the halt: schedules, the backlog and limit resumes wait.`,`Shell sessions keep running. AI started outside ${I.displayName}, and cloud sessions, are not reached.`],qY=e=>{let t=new Date(e);return`${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`};function JY(e,t=Date.now()){let n=`All AI halted${e.since==null?``:t-e.since<72e6?` since ${qY(e.since)}`:` since ${new Date(e.since).toLocaleDateString()}`}.`;return e.receipt&&e.since!=null&&e.receipt.at>=e.since?`${n} ${P(e.receipt)}`:`${n} Stopping…`}var YY=W({...ie});function XY(){return G(YY)}function ZY(e){YY.set(()=>e)}async function QY(){await gC({title:`Halt all AI on this desktop?`,lines:[...KY],confirmLabel:`Halt everything`,tone:`warn`})&&U().conn.liveSend({t:`host.halt`,on:!0},`halting — every agent session is being stopped`,`not halted: no link to the desktop right now`)}function $Y(){U().conn.liveSend({t:`host.halt`,on:!1},`halt lifted — automatic work may start again; stopped sessions stay closed`,`still halted: no link to the desktop right now`)}var eX={id:`halt`,messages:{"halt.state":e=>ZY(e.halt)},launcherItems:[{id:`halt`,label:`Halt`,icon:is,order:90,open:()=>void QY()}],menuItems:[{id:`halt`,label:`halt all AI`,icon:is,order:90,open:()=>void QY()}]};function tX(e){return e.state===`error`?{tone:`bad`,text:`not loaded: ${e.error?.trim()||`the desktop gave no reason`}`}:e.state===`off`?{tone:`dim`,text:`off — not activated; nothing of it runs on the desktop`}:{tone:`ok`,text:`active`}}function nX(e){return(e.manifest.env??Object.keys(e.env??{})).map(t=>({name:t,set:e.env?.[t]===!0}))}function rX(e,t){if(e.kind===`number`){let n=t.trim(),r=n===``?NaN:Number(n);return Number.isFinite(r)?r<e.min||r>e.max?{ok:!1,why:`${e.label}: ${r} is outside ${e.min}–${e.max}`}:{ok:!0,value:r}:{ok:!1,why:`${e.label}: "${t}" is not a number`}}let n=e.kind===`switch`?t===`true`:t,r=T(e,n);return r===void 0?{ok:!1,why:`${e.label}: that value is not one it accepts`}:{ok:!0,value:r}}function iX(e,t,n){return e.values[t]===n?null:{[t]:n}}function aX(e,t){return e.values[t.key]??t.default}function oX(e){let t=e.manifest;return[t.name,t.id,t.description??``,`use ${t.name}`,...(t.settings??[]).flatMap(e=>[e.label,...e.kind===`choice`?e.options.map(e=>e.label):[]]),...(t.actions??[]).map(e=>e.label)].filter(Boolean).join(` `)}function sX(e){return(e??[]).map(oX).join(` `)}function cX(e){return(e.manifest.actions??[]).filter(e=>e.scope===`global`)}function lX(e,t){let n=[],r=t.backend??`claude`;for(let i of e??[]){if(i.state!==`active`)continue;let e=i.manifest;if(e.backends?.length&&!e.backends.includes(r))continue;let a=t.pluginToggles?.[e.id]??{},o=(e.toggles??[]).map(e=>{let t=typeof a[e.id]==`boolean`;return{def:e,on:t?a[e.id]:e.default,overridden:t}}),s=(e.actions??[]).filter(e=>e.scope===`session`),c=e.answers?t.pluginAnswer?.[e.id]===!0:null;(o.length||s.length||c!==null)&&n.push({id:e.id,name:e.name,toggles:o,mayAnswer:c,actions:s})}return n}function uX(e){let t=e.label.trim()||`a request`,n=Number.isInteger(e.uses)&&e.uses>0?e.uses:0;return`${t} — ${n?`answered ${n} time${n===1?``:`s`} without asking`:`not used yet`}`}function dX(e,t){return Object.entries(e.pluginRules??{}).filter(([,e])=>Array.isArray(e)&&e.length).sort(([e],[t])=>e.localeCompare(t)).map(([e,n])=>({id:e,name:mX(t,e),lines:n.map(uX)}))}function fX(e){let t=!e.on;return t===e.def.default?null:t}function pX(e,t){return Object.entries(e.pluginBadges??{}).filter(([,e])=>e&&typeof e.text==`string`&&e.text.trim()).sort(([e],[t])=>e.localeCompare(t)).map(([e,n])=>({id:e,name:mX(t,e),badge:n}))}function mX(e,t){return e?.find(e=>e.manifest.id===t)?.manifest.name||t}function hX(e,t,n){return`${e}\u0000${t}\u0000${n??``}`}function gX(e){return e.source===`limit`?`limit`:`plugin:${e.plugin??`?`}`}function _X(e,t){return e===`limit`?`usage limit`:mX(t,e.replace(/^plugin:/,``))}function vX(e){let t=new Map;for(let n of e)t.set(gX(n),(t.get(gX(n))??0)+1);return[...t].map(([e,t])=>({key:e,n:t})).sort((e,t)=>e.key===`limit`?-1:t.key===`limit`?1:e.key.localeCompare(t.key))}function yX(e,t){let n=e.filter(e=>!t.sessionId||e.sessionId===t.sessionId),r=n.filter(e=>!t.source||gX(e)===t.source);return{inScope:n,shown:r.filter(e=>t.showArchived||!e.archived).slice().sort((e,t)=>t.ts-e.ts),archived:r.filter(e=>e.archived).length}}function bX(e){return e.replace(/\x1b\[[0-9;?]*[ -/]*[@-~]/g,``).replace(/\x1b[@-Z\\-_]/g,``).replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g,``).replace(/\r/g,`
72
+ `).replace(/[ \t]+\n/g,`
73
+ `).replace(/\n{3,}/g,`
74
+
75
+ `).trim()}var xX=I.githubOrg;function SX(e,t){return!e||e.source===`local`||!t?`managed by you`:t.fromOrg?`from ${xX}`:`from ${t.url}`}function CX(e){return e&&e.kind===`branch`?`untagged, tracks ${e.ref}`:null}function wX(e,t){return e?.catalog.find(e=>e.installed?.id===t)??null}function TX(e,t){let n=Bi(t);return e.map(e=>{let r=wX(t,e.manifest.id),i=n.find(t=>t.kind===`plugin`&&t.id===e.manifest.id)??null;return{id:e.manifest.id,name:e.manifest.name,version:e.manifest.version,maturity:sn(e.manifest),source:SX(r?.installed,r),due:i,fromOrg:r?.fromOrg===!0,url:r?.url??``,untagged:CX(r?.latest)}})}function EX(e){return(e?.catalog??[]).filter(e=>!e.installed).map(e=>({repo:e.repo,name:e.name,description:e.description,fromOrg:e.fromOrg===!0,url:e.url,untagged:CX(e.latest),maturity:sn({maturity:e.maturity}),ref:e.latest?.ref??null,action:e.problems.length>0||!e.latest?{kind:`problems`,words:e.problems.length>0?e.problems:[`Nothing installable was found in it.`]}:{kind:`install`}}))}function DX(e){return e?[{key:`self`},...e.catalog.map(e=>({key:e.repo,entry:e}))]:[]}function OX(e){return new Set(Bi(e).map(e=>e.kind===`self`?`self`:e.repo))}function kX(e){return Bi(e).length}function Dpe(e,t){let n=DX(e);if(!t)return{shown:n,total:n.length};let r=OX(e);return{shown:n.filter(e=>r.has(e.key)),total:n.length}}function Ope(e,t){return`Showing the ${e} with an update: ${e} of ${t}`}function kpe(e,t){return e===void 0?`not checked yet`:`checked ${kp(Math.max(0,t-e))}`}function Ape(e,t){if(e===void 0||e<=t)return null;let n=Math.ceil((e-t)/6e4);return n<=1?`next check possible in under a minute`:`next check possible in ${n} min`}function jpe(e,t){let n=Bi(t).some(e=>e.kind===`self`);return{headline:e.latest&&n?`${e.current} → ${e.latest}`:`${e.current} · up to date`,notes:e.notes?e.notes:null,showUpdate:e.canApply&&n,showRollback:e.canApply&&!!e.rollbackTo,command:!e.canApply&&n?e.command??null:null,why:!e.canApply&&n?e.why??null:null}}var AX=`It runs with full access to this desktop.`;function jX(e){return e.fromOrg===!0?{from:xX,not:``}:{from:e.url??`outside `+xX,not:` Not from ${xX}.`}}function Mpe(e){let t=jX(e);return`Install ${[e.name,e.ref].filter(Boolean).join(` `)} from ${t.from} on ${e.desktop}?${t.not} ${AX}`}function Npe(e){let t=jX(e);return`Update ${e.name}${e.from?` from ${e.from}`:``} to ${e.to} from ${t.from} on ${e.desktop}?${t.not} ${AX}`}function Ppe(e){return`Install the plugin at ${e.url} on ${e.desktop}? Not from ${xX}. ${AX}`}function Fpe(e){return`Update ${e.desktop} from ${e.current} to ${e.to}? The desktop restarts; sessions keep running.`}function Ipe(e){return`Roll ${e.desktop} back from ${e.current} to ${e.to}? The desktop restarts; sessions keep running.`}function Lpe(e){let t=e.trim();return t?/^https:\/\/[^\s/]+\/\S+$/.test(t)?{ok:!0,url:t}:{ok:!1,why:`That is not an https:// repository address.`}:{ok:!1,why:`Type the plugin's repository address first.`}}function Rpe(e){return e.kind===`self`||e.kind===`self-rollback`}function zpe(e,t,n=!1){let r=[];return e.restart===`restarting`&&r.push(`restarting the desktop…`),(e.restart===`manual`||e.restart===`offer`)&&r.push(`restart the desktop to load it`),e.ok&&n&&t&&Rpe(t)&&r.push(`the phone picks up the new UI next`),{note:r.length?r.join(` · `):null,restartButton:e.restart===`offer`}}function Bpe(e){return e.ok&&e.restart===`restarting`}var Vpe=6e5;function Hpe(e,t,n=Date.now()){return e?t===null?n-e.at<=Vpe:e.at!==t:!1}function Upe(e,t=!1){return e.ok?`${e.message}${t?` — the phone picks up the new UI next`:``}`:`Update failed: ${e.message}`}function Wpe(e,t){let n=Bi(e).find(e=>e.kind===`self`);return n?{show:t!==n.latest,text:`${I.displayName} ${n.current} → ${n.latest} available`,sig:n.latest}:{show:!1,text:``,sig:``}}function Gpe(e,t){return!!e&&e.pending&&t-(e.at??0)<18e4}var MX=W(null),NX=W({}),PX=W({}),FX=W([]),IX=W(null),LX=W(null),RX=W({}),zX=W(!1);function Kpe(){return G(LX)}function BX(e){switch(e.kind){case`plugin-install`:return`install:${e.repo??e.url??``}`;case`plugin-update`:return`update:${e.id}`;default:return e.kind}}var VX=`no connection — plugins run on the desktop`;function qpe(){return Mp(`pa`)}function HX(e){let t=PX.get();if(!(e in t))return;let n={...t};delete n[e],PX.set(n)}function UX(e,t,n){let r=iX(e,t,n);r&&(HX(e.manifest.id),U().conn.liveSend({t:`plugin.set`,id:e.manifest.id,values:r},`${e.manifest.name}: saved`,VX))}function Jpe(e,t){PX.set({...PX.get(),[e]:t})}function Ype(e,t){HX(e.manifest.id),U().conn.liveSend({t:`plugin.enable`,id:e.manifest.id,enabled:t},`${e.manifest.name} ${t?`on`:`off`}`,VX)}function WX(e,t,n){let r=qpe(),i=n?{t:`plugin.action`,id:e,action:t,sessionId:n,reqId:r}:{t:`plugin.action`,id:e,action:t,reqId:r};U().conn.liveAsk(i,VX)&&NX.set({...NX.get(),[hX(e,t,n)]:{reqId:r,pending:!0}})}function Xpe(e,t,n,r,i){U().conn.liveSend({t:`plugin.sessionToggle`,id:e,sessionId:t,toggle:n,value:r},`${i}: ${r===null?`back to default`:r?`on`:`off`}`,VX)}function Zpe(e,t,n,r){U().conn.liveSend({t:`plugin.sessionAnswer`,id:e,sessionId:n,value:r},r?`${t} may answer here`:`${t} only suggests here`,VX)}function Qpe(e){let t=NX.get(),n=Object.keys(t).find(n=>t[n].reqId===e.reqId);n&&(NX.set({...t,[n]:{reqId:e.reqId,pending:!1,ok:e.ok,message:e.message}}),U().say.toast(`${eme(e.id)}: ${e.message}`))}function $pe(e){PX.set({...PX.get(),[e.id]:e.error})}function eme(e){return MX.get()?.find(t=>t.manifest.id===e)?.manifest.name||e}function GX(e){let t=U();IX.set(e),t.conn.liveAsk(e?{t:`decisions.get`,sessionId:e}:{t:`decisions.get`}),t.say.track(`overlay:decisions`),t.nav.open(`decisions`)}var tme={suggested:{label:`suggested`,Icon:Ha,cls:`sug`},answered:{label:`answered`,Icon:Ec,cls:`fire`},autofired:{label:`answered`,Icon:Ec,cls:`fire`},abstained:{label:`no suggestion`,Icon:fs,cls:`muted`},blocked:{label:`left for you · high-stakes`,Icon:ps,cls:`defer`},capped:{label:`capped`,Icon:ns,cls:`muted`},error:{label:`error`,Icon:gs,cls:`err`}},KX={blocked:{label:`usage limit`,Icon:go,cls:`defer`},attempt:{label:`auto-continue`,Icon:Ec,cls:`fire`},resumed:{label:`resumed`,Icon:vc,cls:`sug`},gaveup:{label:`gave up`,Icon:gs,cls:`err`}};function nme(){let e=Dh(),t=G(FX),n=G(IX),r=G(MX),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)(new Set),u=n?e.world.sessions.find(e=>e.id===n):void 0,{inScope:d,shown:f,archived:p}=yX(t,{sessionId:n,source:i,showArchived:o}),m=o?d:d.filter(e=>!e.archived),h=vX(m),g=e=>l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),_=e.conn,v=(e,t)=>_.liveSend({t:`decisions.archive`,id:e,archived:t},t?`archived`:`unarchived`),y=e=>_.liveSend({t:`decisions.delete`,id:e},`deleted`),b=e=>(0,J.jsxs)(`span`,{className:`hist-acts`,children:[(0,J.jsx)(`button`,{className:`row-act`,title:e.archived?`un-archive`:`archive (hide)`,onClick:()=>v(e.id,!e.archived),children:(0,J.jsx)(oo,{size:16})}),(0,J.jsx)(fC,{className:`row-act`,title:`delete permanently`,confirmTitle:`tap again to delete this log entry for good`,confirm:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ws,{size:16}),` sure?`]}),onConfirm:()=>y(e.id),children:(0,J.jsx)(ws,{size:16})})]});return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsxs)(Uw,{title:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(jc,{size:16,style:{verticalAlign:`-3px`,marginRight:4}}),`Decision log`,u?` · ${u.title}`:``]}),onClose:()=>{IX.set(null),e.nav.close(`decisions`)},children:[(0,J.jsx)(fC,{className:`key`,title:`archive every entry in the log — every session and source, not just this cut`,confirmTitle:`tap again to archive every unarchived entry, in every session`,confirm:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(oo,{size:14}),` all?`]}),onConfirm:()=>_.liveSend({t:`decisions.archiveAll`},`all archived`),children:(0,J.jsx)(oo,{size:14})}),(0,J.jsx)(Y,{title:`refresh`,onClick:()=>_.liveAsk(n?{t:`decisions.get`,sessionId:n}:{t:`decisions.get`}),children:(0,J.jsx)(Ds,{size:14})})]}),(0,J.jsxs)(Z,{children:[`Done or proposed for a session without a tap.`,(0,J.jsx)(tT,{of:`the decision log`,children:`Each row is a usage-limit auto-continue, or a plugin's suggestion or answer with what it was shown and why it chose.`})]}),(h.length>1||p>0)&&(0,J.jsxs)(`div`,{className:`fchips wrap olog-kinds`,children:[h.length>1&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(zw,{on:i===null,clears:!1,onClick:()=>a(null),children:[`all · `,m.length]}),h.map(e=>(0,J.jsxs)(zw,{on:i===e.key,onClick:()=>a(i===e.key?null:e.key),children:[e.key===`limit`?(0,J.jsx)(go,{size:12}):(0,J.jsx)(Yo,{size:12}),` `,_X(e.key,r),` · `,e.n]},e.key))]}),p>0&&(0,J.jsxs)(J.Fragment,{children:[h.length>1&&(0,J.jsx)(`span`,{className:`fchips-gap`,"aria-hidden":!0}),(0,J.jsxs)(zw,{on:o,onClick:()=>s(e=>!e),title:o?`hide the archived entries again`:`also show the ${p} archived`,children:[`archived · `,p]})]})]}),i&&(0,J.jsxs)(Pw,{onClear:()=>a(null),children:[`Showing `,_X(i,r),` only: `,f.length,` of `,m.length]}),(0,J.jsxs)(`div`,{className:`list hist`,children:[(0,J.jsx)($,{empty:f.length===0,children:d.length?`Nothing in this cut.`:`No decisions yet.`}),f.map(e=>e.source===`limit`?(0,J.jsx)(rme,{e,showSession:!n,acts:b(e)},e.id):(0,J.jsx)(ime,{e,showSession:!n,acts:b(e),list:r,open:c.has(e.id),onToggle:()=>g(e.id)},e.id))]})]})}function rme({e,showSession:t,acts:n}){let r=KX[e.phase??`blocked`]??KX.blocked;return(0,J.jsxs)(`div`,{className:`olog-row${e.archived?` archived`:``}`,children:[(0,J.jsxs)(`div`,{className:`olog-head`,children:[(0,J.jsxs)(qw,{className:`oracle-${r.cls}`,children:[(0,J.jsx)(r.Icon,{size:12}),` `,r.label]}),t&&(0,J.jsx)(`span`,{className:`olog-sess`,children:e.sessionTitle}),(0,J.jsx)(Q,{className:`olog-time`,children:Tp(e.ts)}),n]}),(0,J.jsx)(`div`,{className:`olog-q open`,children:e.question}),e.rationale&&(0,J.jsx)(`div`,{className:`olog-rationale`,children:e.rationale})]})}function ime({e,showSession:t,acts:n,list:r,open:i,onToggle:a}){let o=tme[e.outcome]??{label:e.outcome,Icon:Yo,cls:`muted`},s=_X(gX(e),r),c=bX(e.question),l=e.options.length===0,u=e.confidence?(0,J.jsxs)(`span`,{className:`olog-conf`,children:[` · `,Math.round(e.confidence*100),`% sure`]}):null,d=(e.inTok??0)+(e.outTok??0),f=[e.model,e.images==null?``:`${e.images} image${e.images===1?``:`s`}`,d?`${d} tok`:``].filter(Boolean);return(0,J.jsxs)(`div`,{className:`olog-row${e.archived?` archived`:``}`,children:[(0,J.jsxs)(`div`,{className:`olog-head`,children:[(0,J.jsxs)(qw,{className:`oracle-${o.cls}`,children:[(0,J.jsx)(o.Icon,{size:12}),` `,o.label]}),(0,J.jsxs)(qw,{children:[(0,J.jsx)(Yo,{size:12}),` `,s]}),e.choice!=null&&(0,J.jsxs)(qw,{className:`oracle-choice`,children:[`chose `,e.choice]}),t&&(0,J.jsx)(`span`,{className:`olog-sess`,children:e.sessionTitle}),(0,J.jsx)(Q,{className:`olog-time`,children:Tp(e.ts)}),n]}),(0,J.jsxs)(`div`,{className:`olog-section`,children:[(0,J.jsx)(`div`,{className:`olog-label`,children:l?`Agent asked`:`Decision`}),(0,J.jsx)(`div`,{className:`olog-q ${i?`open`:``}`,children:c||(0,J.jsx)(Q,{children:`(no text captured)`})})]}),e.error&&(0,J.jsxs)(`div`,{className:`oracle-warn`,children:[(0,J.jsx)(gs,{size:12}),` `,e.error]}),(e.answer||e.rationale)&&(0,J.jsxs)(`div`,{className:`olog-section`,children:[(0,J.jsxs)(`div`,{className:`olog-label`,children:[(0,J.jsx)(Uo,{size:12}),` `,s,e.answer?` answered`:``,u]}),e.answer&&(0,J.jsx)(`div`,{className:`olog-answer`,children:l?`“${e.answer}”`:e.answer}),e.rationale&&(0,J.jsx)(`div`,{className:`olog-rationale`,children:e.rationale})]}),(0,J.jsx)(`button`,{className:`hist-more`,onClick:a,children:i?`hide detail`:`show detail`}),i&&(0,J.jsxs)(`div`,{className:`oracle-detail`,children:[e.options.length>0&&(0,J.jsxs)(`div`,{className:`olog-section`,children:[(0,J.jsx)(`div`,{className:`olog-label`,children:`Options`}),(0,J.jsx)(`div`,{className:`oracle-opts`,children:e.options.map(t=>(0,J.jsxs)(`span`,{className:`oracle-opt ${t.index===e.choice?`chosen`:``}`,children:[t.index,`. `,t.label]},t.index))})]}),f.length>0&&(0,J.jsx)(`div`,{className:`olog-meta`,children:f.join(` · `)}),e.contextSent&&(0,J.jsxs)(`div`,{className:`olog-section`,children:[(0,J.jsxs)(`div`,{className:`olog-label`,children:[`What `,s,` was shown`]}),(0,J.jsx)(`pre`,{className:`hist-out open`,children:bX(e.contextSent)})]})]})]})}var qX=`no connection — updates run on the desktop and can't be started from here`;function JX(){return ru()?.name||`the desktop`}function YX(){U().conn.liveAsk({t:`updates.get`},qX)}function ame(){U().conn.liveAsk({t:`updates.check`},`no connection — the desktop can't be asked to check from here`)&&zX.set(!0)}async function XX(e,t,n){if(!await gC({title:t,confirmLabel:n}))return!1;let r=Mp(`up`);return U().conn.liveAsk({t:`updates.apply`,target:e,reqId:r,ackId:r},qX)?(RX.set({...RX.get(),[BX(e)]:{reqId:r,target:e,pending:!0,at:Date.now()}}),!0):!1}function ome(e){let t=LX.get(),n=e.status;LX.set(n),zX.set(!1);let r=n.lastApply;if(r){let e=RX.get(),t=BX(r.target),n=e[t];n&&n.pending&&r.at>=n.at-5e3&&RX.set({...e,[t]:{reqId:n.reqId,target:n.target,pending:!1,ok:r.ok,message:r.message,restart:r.restart}})}let i=n.self.lastResult,a=r&&(!i||r.at>=i.at)?r:i,o=Number(z(R.updatesReceiptSeen));if(a&&Hpe(a,Number.isFinite(o)&&o>0?o:null,Date.now())){ua(R.updatesReceiptSeen,String(a.at));let e=r&&a===r?RX.get()[BX(r.target)]:void 0;(!e||e.pending||e.message!==a.message)&&U().say.toast(Upe(a,!!t&&t.self.current!==n.self.current))}else a&&!(o>0)&&ua(R.updatesReceiptSeen,String(a.at))}function sme(e){let t=RX.get(),n=Object.keys(t).find(n=>t[n].reqId===e.reqId);n&&(RX.set({...t,[n]:{reqId:e.reqId,target:t[n].target,pending:!1,ok:e.ok,message:e.message,restart:e.restart}}),U().say.toast(e.message))}function cme(e,t,n,r){XX({kind:`plugin-install`,repo:e},Mpe({name:t,ref:n,desktop:JX(),...r}),`install`)}function lme(e){return XX({kind:`plugin-install`,url:e},Ppe({url:e,desktop:JX()}),`install`)}function ZX(e,t,n,r,i){XX({kind:`plugin-update`,id:e},Npe({name:t,from:n,to:r,desktop:JX(),...i}),`update`)}function ume(e,t){XX({kind:`self`},Fpe({desktop:JX(),current:e,to:t}),`update`)}function dme(e,t){XX({kind:`self-rollback`},Ipe({desktop:JX(),current:e,to:t}),`roll back`)}function fme(){XX({kind:`restart`},`Restart ${JX()}? Sessions keep running.`,`restart`)}function QX(){let e=U();YX(),e.say.track(`overlay:updates`),e.nav.open(`updates`)}function $X({m:e}){return(0,J.jsx)(qw,{title:`${e.label}: ${e.meaning}`,children:e.label})}function eZ({status:e}){let t=Ww(3e4),n=G(zX);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`plugin-head`,children:[(0,J.jsx)(Q,{children:[kpe(e?.checkedAt,t),Ape(e?.nextCheckAt,t)].filter(Boolean).join(` · `)}),(0,J.jsxs)(Y,{title:`check for updates now`,onClick:ame,children:[n?(0,J.jsx)(Js,{size:14,className:`spin`}):(0,J.jsx)(Ds,{size:14}),` `,n?`checking`:`check now`]})]}),e?.error&&(0,J.jsx)(YS,{children:e.error})]})}function tZ({target:e}){let t=G(RX)[BX(e)],n=Ww(3e4);if(!t)return null;if(Gpe(t,n))return(0,J.jsxs)(X,{children:[(0,J.jsx)(Js,{size:12,className:`spin`}),` working on the desktop…`]});if(t.pending)return(0,J.jsx)(X,{children:`No answer yet. If the desktop restarted, its result shows here when the phone reconnects.`});let r=zpe({ok:t.ok,restart:t.restart},t.target,Bpe({ok:t.ok,restart:t.restart}));return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(YS,{tone:t.ok?`plain`:`bad`,children:t.message}),r.note&&(0,J.jsx)(X,{children:r.note}),r.restartButton&&(0,J.jsx)(Y,{onClick:fme,children:`restart the desktop`})]})}function nZ({r:e}){return(0,J.jsxs)(`div`,{className:`plugin-sec`,children:[(0,J.jsxs)(`div`,{className:`plugin-head`,children:[(0,J.jsx)(`b`,{children:e.name}),` `,e.ref&&(0,J.jsx)(Q,{children:e.ref}),e.untagged&&(0,J.jsx)(Q,{children:e.untagged}),(0,J.jsx)($X,{m:e.maturity}),e.action.kind===`install`&&(0,J.jsxs)(Y,{title:`install ${e.name} from ${e.fromOrg?xX:e.url}`,onClick:()=>cme(e.repo,e.name,e.ref,{fromOrg:e.fromOrg,url:e.url}),children:[(0,J.jsx)(Qa,{size:14}),` install`]})]}),e.description&&(0,J.jsx)(X,{children:e.description}),e.action.kind===`problems`&&e.action.words.map(e=>(0,J.jsx)(YS,{children:e},e)),(0,J.jsx)(tZ,{target:{kind:`plugin-install`,repo:e.repo}})]})}function pme(){return(0,J.jsxs)(tT,{of:`the maturity tags`,children:[Mi.map(e=>{let t=sn({maturity:e});return(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`b`,{children:t.label}),`: `,t.meaning,`. `]},e)}),`Plugins that name no maturity are `,(0,J.jsx)(`b`,{children:sn({}).label}),`: `,sn({}).meaning,`.`]})}function mme({status:e}){if(!e)return null;let t=EX(e);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(Z,{children:[`Available from `,xX,` `,(0,J.jsx)(pme,{})]}),t.length===0&&(0,J.jsx)(X,{children:e.error?`The list could not be loaded.`:`Nothing else is listed there.`}),t.map(e=>(0,J.jsx)(nZ,{r:e},e.repo))]})}function rZ(){let[e,t]=(0,V.useState)(``),[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(null),o=()=>{let t=Lpe(e);t.ok?(r(null),a(t.url),lme(t.url)):r(t.why)};return(0,J.jsxs)(`div`,{className:`plugin-sec`,children:[(0,J.jsx)(Z,{children:`Add by URL`}),(0,J.jsxs)(`div`,{className:`plugin-field`,children:[(0,J.jsx)(`input`,{type:`text`,inputMode:`url`,value:e,placeholder:`https://github.com/owner/plugin`,onChange:e=>{t(e.target.value),r(null)},onKeyDown:e=>{e.key===`Enter`&&o()}}),(0,J.jsxs)(Y,{onClick:o,children:[(0,J.jsx)(Qa,{size:14}),` install`]})]}),n&&(0,J.jsx)(YS,{children:n}),i&&(0,J.jsx)(tZ,{target:{kind:`plugin-install`,url:i}})]})}function hme({status:e}){let[t,n]=(0,V.useState)(!1),r=e.self,i=jpe(r,e);return(0,J.jsxs)(`div`,{className:`plugin-sec`,children:[(0,J.jsxs)(`div`,{className:`plugin-head`,children:[(0,J.jsx)(`b`,{children:I.displayName}),` `,(0,J.jsx)(Q,{children:i.headline}),i.notes&&(0,J.jsx)(Y,{title:`what changed`,onClick:()=>n(e=>!e),children:t?`hide notes`:`notes`}),i.showUpdate&&r.latest&&(0,J.jsxs)(Y,{variant:`primary`,onClick:()=>ume(r.current,r.latest),children:[(0,J.jsx)(Qa,{size:14}),` update`]}),i.showRollback&&r.rollbackTo&&(0,J.jsxs)(Y,{title:`go back to ${r.rollbackTo}`,onClick:()=>dme(r.current,r.rollbackTo),children:[(0,J.jsx)(tc,{size:14}),` roll back`]})]}),t&&i.notes&&(0,J.jsx)(`pre`,{className:`update-log`,children:i.notes}),i.why&&(0,J.jsx)(X,{children:i.why}),i.command&&(0,J.jsxs)(X,{children:[(0,J.jsx)(`code`,{children:i.command}),` `,(0,J.jsx)(Y,{title:`copy the command`,onClick:()=>void Xf(i.command),children:`copy`})]}),(0,J.jsx)(tZ,{target:{kind:`self`}}),(0,J.jsx)(tZ,{target:{kind:`self-rollback`}})]})}function gme(){return(0,J.jsx)(rC,{id:`tool-decisions`,compact:!0,label:`decision log`,icon:jc,title:`every usage-limit auto-continue and every plugin suggestion or answer`,onClick:()=>GX(null)})}function _me(){let e=Dh(),t=G(MX),n=G(LX),r=TX(t??[],n);return(0,V.useEffect)(()=>{e.conn.status===`open`&&e.conn.send({t:`plugin.list`})},[]),(0,J.jsxs)(iC,{id:`plugins`,label:`plugins`,icon:Yo,note:`Code that runs on the desktop and extends ${I.displayName}, with full access to it. A new or changed plugin takes effect after the desktop restarts.`,children:[t===null&&(0,J.jsx)(X,{children:`The desktop has not listed its plugins yet.`}),t?.length===0&&(0,J.jsxs)(X,{children:[`No plugins installed. Install one below, or put a folder under `,(0,J.jsxs)(`code`,{children:[`~/.config/`,I.configDirName,`/plugins/`]}),` on the desktop (or list its path in `,(0,J.jsxs)(`code`,{children:[`~/.config/`,I.configDirName,`/plugin-paths.json`]}),`); the desktop loads plugins when it starts.`]}),t?.map(e=>(0,J.jsx)(yme,{p:e,row:r.find(t=>t.id===e.manifest.id)},e.source)),(0,J.jsx)(eZ,{status:n}),(0,J.jsx)(mme,{status:n}),(0,J.jsx)(rZ,{})]})}var vme={ok:Bc,bad:bo,dim:Cc};function yme({p:e,row:t}){let n=e.manifest,r=G(PX)[n.id],i=G(NX),a=tX(e),o=vme[a.tone],s=nX(e);return qS(`plugins`,oX(e))?(0,J.jsxs)(`div`,{className:`plugin-sec`,children:[(0,J.jsxs)(`div`,{className:`plugin-head`,children:[(0,J.jsx)(`b`,{children:n.name}),` `,(0,J.jsxs)(Q,{children:[`v`,n.version]}),t?.untagged&&(0,J.jsx)(Q,{children:t.untagged}),t&&(0,J.jsx)($X,{m:t.maturity}),n.experimental===!0&&n.maturity===void 0&&(0,J.jsx)(qw,{children:`experimental`}),(0,J.jsxs)(qw,{className:`plugin-${a.tone}`,children:[(0,J.jsx)(o,{size:12}),` `,e.state]})]}),t?.due&&(0,J.jsxs)(`div`,{className:`plugin-head`,children:[(0,J.jsxs)(Q,{children:[t.due.from??`v${n.version}`,` → `,t.due.to]}),(0,J.jsxs)(Y,{variant:`primary`,onClick:()=>ZX(n.id,n.name,t.due.from,t.due.to,{fromOrg:t.fromOrg,url:t.url}),children:[(0,J.jsx)(Qa,{size:14}),` update`]})]}),(0,J.jsx)(tZ,{target:{kind:`plugin-update`,id:n.id}}),n.description&&(0,J.jsx)(X,{children:n.description}),(0,J.jsxs)(X,{className:`plugin-src`,children:[t?.source,` · `,(0,J.jsx)(Tc,{size:12}),` `,(0,J.jsx)(`code`,{children:e.source})]}),a.tone!==`ok`&&(0,J.jsx)(YS,{tone:a.tone===`bad`?`bad`:`plain`,children:a.text}),e.status&&e.state===`active`&&(0,J.jsx)(YS,{tone:e.status.tone===`bad`?`bad`:`plain`,icon:e.status.tone===`ok`?Bc:gs,children:e.status.text}),e.manifestLegacy&&(0,J.jsxs)(YS,{icon:gs,children:[`This plugin still uses an older manifest file name. It loads, but rename it to `,(0,J.jsx)(`code`,{children:tn}),`; the old name will stop working in a later release.`]}),r&&(0,J.jsx)(YS,{icon:gs,children:r}),(0,J.jsx)(ZS,{label:`use ${n.name}`,icon:Yo,on:e.enabled,onChange:()=>Ype(e,!e.enabled),note:e.enabled?void 0:`Off: the desktop does not activate it, and it sees nothing.`}),s.length>0&&(0,J.jsxs)(X,{className:`plugin-env`,children:[(0,J.jsx)(Fa,{size:12}),` `,s.map((e,t)=>(0,J.jsxs)(`span`,{children:[t>0&&` · `,(0,J.jsx)(`code`,{children:e.name}),` `,e.set?`set`:`not set`]},e.name)),s.some(e=>!e.set)&&(0,J.jsx)(J.Fragment,{children:` — set it with the secret tool, or in the desktop's environment.`})]}),e.state!==`error`&&(n.settings??[]).map(t=>(0,J.jsx)(bme,{p:e,f:t},t.key)),e.state===`active`&&cX(e).map(e=>{let t=i[hX(n.id,e.id)];return(0,J.jsx)(rC,{label:e.label,icon:La,note:e.note,busy:t?.pending===!0,onClick:()=>WX(n.id,e.id),children:t&&!t.pending&&(0,J.jsx)(YS,{tone:t.ok?`plain`:`bad`,children:t.message})},e.id)}),e.state!==`active`&&cX(e).length>0&&(0,J.jsxs)(X,{children:[`Its `,cX(e).length===1?`action is`:`${cX(e).length} actions are`,` here once it is active.`]})]}):null}function bme({p:e,f:t}){let n=aX(e,t);switch(t.kind){case`switch`:return(0,J.jsx)(ZS,{label:t.label,on:n===!0,note:t.note,onChange:()=>UX(e,t.key,n!==!0)});case`choice`:return t.options.length<=4?(0,J.jsx)(QS,{label:t.label,value:String(n),note:t.note,options:t.options.map(e=>({value:e.value,label:e.label})),onChange:n=>UX(e,t.key,n)}):(0,J.jsx)(eC,{label:t.label,note:t.note,control:(0,J.jsxs)(`select`,{value:String(n),onChange:n=>UX(e,t.key,n.target.value),children:[!t.options.some(e=>e.value===n)&&(0,J.jsx)(`option`,{value:String(n),children:String(n)}),t.options.map(e=>(0,J.jsx)(`option`,{value:e.value,children:e.label},e.value))]})});case`number`:case`text`:return(0,J.jsx)(xme,{p:e,f:t,value:String(n)})}}function xme({p:e,f:t,value:n}){let[r,i]=(0,V.useState)(null),a=r??n,o=r!==null&&r!==n,s=()=>{if(r===null)return;let n=rX(t,r);n.ok?(UX(e,t.key,n.value),i(null)):Jpe(e.manifest.id,n.why)},c=t.kind===`number`?[t.unit,`${t.min}–${t.max}`].filter(Boolean).join(` · `):``,l=[t.note,c].filter(Boolean).join(` — `)||void 0,u=t.kind===`text`&&t.multiline;return(0,J.jsx)(iC,{label:t.label,note:l,children:(0,J.jsxs)(`div`,{className:`plugin-field${u?` multi`:``}`,children:[u?(0,J.jsx)(`textarea`,{rows:6,value:a,placeholder:t.placeholder,onChange:e=>i(e.target.value)}):(0,J.jsx)(`input`,{type:`text`,inputMode:t.kind===`number`?`decimal`:void 0,value:a,placeholder:t.kind===`text`?t.placeholder:void 0,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`&&s()}}),o&&(0,J.jsx)(Y,{onClick:s,children:`save`}),o&&(0,J.jsx)(Y,{onClick:()=>i(null),children:`undo edit`}),!o&&String(t.default)!==n&&(0,J.jsx)(fC,{className:`key`,title:`put the plugin's own default back`,confirmTitle:`tap again to replace the stored value with the default`,confirm:(0,J.jsx)(J.Fragment,{children:`replace it?`}),onConfirm:()=>UX(e,t.key,t.default),children:`reset to default`})]})})}function Sme(){let e=kX(G(LX));return(0,J.jsx)(rC,{id:`tool-updates`,compact:!0,icon:Qa,label:e>0?`updates · ${e}`:`updates`,title:e>0?`${e} with an update — a tap opens exactly those`:`${I.displayName} and plugin updates`,onClick:QX})}function Cme(){let e=Zv(`updatesAutoCheck`);return(0,J.jsx)(ZS,{id:`updates-auto`,label:`check daily for updates`,icon:Qa,on:e,onChange:()=>Qv(`updatesAutoCheck`,!e),note:`The desktop looks for a new ${I.displayName} and new plugin versions once a day. A check only looks; nothing installs until you confirm.`})}function wme(){let e=Dh(),t=G(LX),[n,r]=(0,V.useState)(!1);(0,V.useEffect)(()=>{YX()},[]);let i=kX(t),a=!n&&i>0,{shown:o,total:s}=Dpe(t,a);return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Qa,{size:16,style:{verticalAlign:`-3px`,marginRight:4}}),`Updates`]}),onClose:()=>e.nav.close(`updates`)}),(0,J.jsxs)(Z,{children:[I.displayName,` on the desktop, and plugins from `,xX,`. A check only looks; nothing installs until you confirm.`]}),(0,J.jsx)(eZ,{status:t}),a&&(0,J.jsx)(Pw,{onClear:()=>r(!0),clearLabel:`show all`,children:Ope(o.length,s)}),(0,J.jsxs)(`div`,{className:`list hist`,children:[(0,J.jsx)($,{empty:!t,children:`The desktop has not reported its updates yet.`}),t&&o.map(e=>(0,J.jsx)(Tme,{r:e},e.key)),t&&!a&&(0,J.jsx)(rZ,{})]})]})}function Tme({r:e}){let t=G(LX);if(!t)return null;if(!(`entry`in e))return(0,J.jsx)(hme,{status:t});let n=e.entry;if(!n.installed){let e=EX({...t,catalog:[n]})[0];return e?(0,J.jsx)(nZ,{r:e}):null}let r=n.installed,i=OX(t).has(n.repo);return(0,J.jsxs)(`div`,{className:`plugin-sec`,children:[(0,J.jsxs)(`div`,{className:`plugin-head`,children:[(0,J.jsx)(Yo,{size:14}),` `,(0,J.jsx)(`b`,{children:n.name}),` `,(0,J.jsxs)(Q,{children:[r.ref??`v${r.version}`,i&&n.latest?` → ${n.latest.ref}`:``]}),CX(n.latest)&&(0,J.jsx)(Q,{children:CX(n.latest)}),(0,J.jsx)($X,{m:sn({maturity:n.maturity})}),(0,J.jsx)(qw,{children:SX(r,n)}),i&&n.latest&&(0,J.jsxs)(Y,{variant:`primary`,onClick:()=>ZX(r.id,n.name,r.ref,n.latest.ref,{fromOrg:n.fromOrg===!0,url:n.url}),children:[(0,J.jsx)(Qa,{size:14}),` update`]})]}),!i&&(0,J.jsx)(X,{children:r.source===`local`?`Put there by hand — the manager never updates it.`:`Up to date.`}),n.problems.map(e=>(0,J.jsx)(X,{children:e},e)),(0,J.jsx)(tZ,{target:{kind:`plugin-update`,id:r.id}})]})}var iZ=16;function Eme({active:e,label:t,dismiss:n,openMenu:r}){let i=G(MX),a=G(NX);if(!e||e.id.startsWith(`pending:`))return null;let o=lX(i,e),s=dX(e,i);if(!o.length&&!s.length)return null;if(!t){let e=[...new Set([...o,...s].map(e=>e.name))].join(`, `);return(0,J.jsx)(Y,{title:`${e}: this session's switches — opens the menu`,"aria-label":`${e} session switches`,onClick:r,children:(0,J.jsx)(Yo,{size:iZ})})}return(0,J.jsxs)(J.Fragment,{children:[s.map(e=>(0,J.jsxs)(`div`,{className:`plugin-menu`,role:`group`,"aria-label":`${e.name} standing rules`,children:[(0,J.jsxs)(`div`,{className:`plugin-menu-head`,children:[(0,J.jsx)(Yo,{size:12}),` `,e.name,` · won't ask again, this session only`]}),e.lines.map((e,t)=>(0,J.jsx)(`div`,{className:`plugin-menu-note`,children:e},t))]},`rules-${e.id}`)),o.map(t=>(0,J.jsxs)(`div`,{className:`plugin-menu`,role:`group`,"aria-label":t.name,children:[(0,J.jsxs)(`div`,{className:`plugin-menu-head`,children:[(0,J.jsx)(Yo,{size:12}),` `,t.name]}),t.toggles.map(n=>(0,J.jsxs)(Y,{className:n.on?`active`:void 0,"aria-pressed":n.on,title:n.def.note,onClick:()=>Xpe(t.id,e.id,n.def.id,fX(n),`${t.name} · ${n.def.label}`),children:[n.on?(0,J.jsx)(Ho,{size:iZ}):(0,J.jsx)(fl,{size:iZ}),` `,n.def.label,`: `,n.on?`on`:`off`,n.overridden?``:` (default)`]},n.def.id)),t.mayAnswer!==null&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(Y,{className:t.mayAnswer?`active`:void 0,"aria-pressed":t.mayAnswer,onClick:()=>Zpe(t.id,t.name,e.id,!t.mayAnswer),children:[(0,J.jsx)(Uo,{size:iZ}),` let `,t.name,` answer: `,t.mayAnswer?`on`:`off`]}),(0,J.jsxs)(`div`,{className:`plugin-menu-note`,children:[t.mayAnswer?`${t.name} may pick an option in this session's choice boxes without a tap.`:`Off: ${t.name} can only suggest here.`,` `,I.displayName,` itself still refuses permission, plan, trust and destructive boxes, whatever this says.`]})]}),t.actions.map(r=>{let i=a[hX(t.id,r.id,e.id)];return(0,J.jsxs)(Y,{title:r.note,onClick:()=>{n(),WX(t.id,r.id,e.id)},children:[(0,J.jsx)(La,{size:iZ}),` `,r.label,i?.pending?` …`:``]},r.id)})]},t.id))]})}function Dme({s:e}){let t=pX(e,G(MX));return t.length?(0,J.jsx)(J.Fragment,{children:t.map(({id:e,name:t,badge:n})=>(0,J.jsx)(Ome,{name:t,badge:n},e))}):null}function Ome({name:e,badge:t}){return(0,J.jsxs)(qw,{className:`plugin-badge plugin-${t.tone}`,title:`${e}: ${t.text}`,children:[(0,J.jsx)(Yo,{size:12}),` `,t.text]})}var kme={id:`plugins`,sheets:[{id:`decisions`,persisted:!1,render:()=>(0,V.createElement)(nme)},{id:`updates`,persisted:!1,render:()=>(0,V.createElement)(wme)}],messages:{"plugin.list":e=>{MX.set(e.plugins),kS(`plugins`,sX(e.plugins))},"plugin.actionResult":e=>Qpe(e),"plugin.error":e=>$pe(e),"decisions.log":e=>FX.set(e.entries),"updates.status":e=>ome(e),"updates.result":e=>sme(e)},settings:[{group:`tools`,order:-6,render:()=>(0,V.createElement)(Sme)},{group:`tools`,order:-5,render:()=>(0,V.createElement)(gme)},{group:`tools`,order:9,render:()=>(0,V.createElement)(Cme)},{group:`tools`,order:10,render:()=>(0,V.createElement)(_me)}],toolbarItems:[{id:`plugins`,render:(e,t)=>(0,V.createElement)(Eme,{active:t.active,label:t.label,dismiss:t.dismiss,openMenu:t.openMenu})}]},aZ=W({});function Ame(e){return G(aZ)[e]}function jme(e,t,n,r,i){let a=l(e.cliVersion,n);if(!a||a.installed!==t)return`drop`;let o=ct(a,{turnActive:e.turnActive,agents:e.agents?.length,shells:e.shells,resumeId:r});return o.cant?`drop`:o.loses||i>0?`wait`:`fire`}var Mme=2e3,oZ=null;function Nme(e,t){aZ.set(n=>({...n,[e]:t})),U().say.track(`action:session.cliRestartIdle`),oZ??=setInterval(lZ,Mme),lZ()}function sZ(e){e in aZ.get()&&(aZ.set(t=>{let{[e]:n,...r}=t;return r}),Object.keys(aZ.get()).length||cZ())}function cZ(){oZ&&clearInterval(oZ),oZ=null}function lZ(){let e=U().world.sessions;for(let t of Object.keys(aZ.get())){let n=e.find(e=>e.id===t);!n||!n.running?sZ(t):Pme(n)}}function Pme(e){let t=aZ.get()[e.id];if(!t)return;let n=U(),r=n.queue.entries.filter(t=>t.sessionId===e.id&&t.status!==`failed`).length,i=jme(e,t,n.world.update?.current,NK(e),r);i!==`wait`&&(sZ(e.id),i!==`drop`&&(n.launch.relaunch(e,{},{quiet:!0}),n.say.toast(`${e.title} was idle — restarting it on Claude ${t}, same conversation`)))}var Fme={id:`cliRestart`,boot:()=>cZ},uZ=`desktop`,Ime=`screen`,Lme=`Let the phone control this desktop`,dZ={codec:`h264`,source:{kind:`display`},maxWidth:1280,fps:30,bitrateKbps:4e3,auto:!0,jpegQuality:50,grayscale:!1,keyframeEverySec:0,cursor:!0},fZ=[{id:`auto`,label:`Auto`,hint:`Follows the connection, up to 4 Mbit/s`,set:{codec:`h264`,widthFactor:1,fps:30,bitrateKbps:4e3,auto:!0}},{id:`saver`,label:`Data saver`,hint:`For cellular: 8 fps, about 150 kbit/s`,set:{codec:`h264`,widthFactor:.6,fps:8,bitrateKbps:150,auto:!1}},{id:`balanced`,label:`Balanced`,hint:`15 fps, about 800 kbit/s`,set:{codec:`h264`,widthFactor:1,fps:15,bitrateKbps:800,auto:!1}},{id:`sharp`,label:`Sharp text`,hint:`Full resolution for reading code, about 3 Mbit/s`,set:{codec:`h264`,widthFactor:0,fps:30,bitrateKbps:3e3,auto:!1}},{id:`stills`,label:`Stills`,hint:`A JPEG every half second. Works without the video decoder`,set:{codec:`jpeg`,widthFactor:1,fps:2,jpegQuality:40,auto:!1}}];function Rme(e,t,n){let r=fZ.find(e=>e.id===t);if(!r)return e;let{widthFactor:i,...a}=r.set,o=i===0?0:Math.round(mZ(n,320,4096,1280)*i);return hZ({...e,...a,maxWidth:o})}var pZ={maxWidth:[0,7680],fps:[1,60],bitrateKbps:[50,2e4],jpegQuality:[1,100],keyframeEverySec:[0,300]};function mZ(e,t,n,r){return typeof e!=`number`||!Number.isFinite(e)?r:Math.min(n,Math.max(t,e))}function zme(e){if(!e||typeof e!=`object`)return;let t=e,n=mZ(t.x,0,1,NaN),r=mZ(t.y,0,1,NaN),i=mZ(t.w,0,1,NaN),a=mZ(t.h,0,1,NaN);if([n,r,i,a].some(Number.isNaN))return;let o=Math.min(i,1-n),s=Math.min(a,1-r);if(!(o<.02||s<.02)&&!(n===0&&r===0&&o>=1&&s>=1))return{x:n,y:r,w:o,h:s}}function Bme(e){let t=e&&typeof e==`object`?e:{};return t.kind===`window`&&Number.isInteger(t.id)&&t.id>0?{kind:`window`,id:t.id}:t.kind===`front`?{kind:`front`}:Number.isInteger(t.id)&&t.id>=0?{kind:`display`,id:t.id}:{kind:`display`}}function hZ(e){let t=e&&typeof e==`object`?e:{},n=dZ,r={codec:t.codec===`jpeg`?`jpeg`:`h264`,source:Bme(t.source),maxWidth:Math.round(mZ(t.maxWidth,...pZ.maxWidth,n.maxWidth)),fps:Math.round(mZ(t.fps,...pZ.fps,n.fps)),bitrateKbps:Math.round(mZ(t.bitrateKbps,...pZ.bitrateKbps,n.bitrateKbps)),auto:typeof t.auto==`boolean`?t.auto:n.auto,jpegQuality:Math.round(mZ(t.jpegQuality,...pZ.jpegQuality,n.jpegQuality)),grayscale:t.grayscale===!0,keyframeEverySec:Math.round(mZ(t.keyframeEverySec,...pZ.keyframeEverySec,n.keyframeEverySec)),cursor:typeof t.cursor==`boolean`?t.cursor:n.cursor},i=zme(t.crop);return i&&(r.crop=i),r}var Vme=`Escape.Tab.Return.Backspace.Delete.Space.ArrowUp.ArrowDown.ArrowLeft.ArrowRight.Home.End.PageUp.PageDown.F1.F2.F3.F4.F5.F6.F7.F8.F9.F10.F11.F12`.split(`.`),Hme=2e3;function Ume(e){return 1+2.5*Math.min(1.2,Math.max(0,e-.25))}var gZ=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y),_Z=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),vZ=e=>{let t=0,n=0,r=0;for(let i of e)t+=i.x,n+=i.y,r++;return r?{x:t/r,y:n/r}:{x:0,y:0}},yZ=e=>Math.min(1,Math.max(0,e));function Wme(e,t){let n=t.mode,r=t.cursor??{x:.5,y:.5},i=new Map,a=`idle`,o=null,s=!1,c=0,l=0,u={x:0,y:0},d=0,f={x:0,y:0},p=!1,m=()=>({x:r.x,y:r.y}),h=e=>({t:`input`,ev:e}),g=t=>e.toSource(t),_=()=>{let[e,t]=[...i.values()];return[e,t]},v=(e,t)=>{let r=n===`trackpad`||o!=null&&gZ(e,o)<=30,i=o&&t-o.t<=350&&r?Math.min(3,o.n+1):1;return o={t,x:e.x,y:e.y,n:i},i},y=(t,n,i)=>{let a=Ume(Math.hypot(t,n)/Math.max(1,i)),o=e.unitsPerPx();return r={x:yZ(r.x+t*a*o.x),y:yZ(r.y+n*a*o.y)},[{t:`cursor`,at:m()},h({k:`move`,...m()})]},b=()=>{let e=[...i.values()][0];return a===`drag`&&e?[h({k:`up`,b:`l`,...g(e)})]:a===`tpdrag`?[h({k:`up`,b:`l`,...m()})]:[]};return{get mode(){return n},get phase(){return a},cursor:()=>m(),setCursor(e){r={x:yZ(e.x),y:yZ(e.y)}},setMode(e){let t=i.size===1?b():[];return n=e,i.clear(),a=`idle`,o=null,s=!1,t},nextTick(){if(a!==`pending`||n!==`touch`)return null;let e=[...i.values()][0];return e?e.t0+500:null},down(e){if(i.size>=3)return[];let t=[];if(i.size===2)return i.set(e.id,{x:e.x,y:e.y,x0:e.x,y0:e.y,t0:e.t,lt:e.t}),a===`spent`||(a=`pan3`,f=vZ(i.values())),t;if(i.size===1){if(t.push(...b()),i.set(e.id,{x:e.x,y:e.y,x0:e.x,y0:e.y,t0:e.t,lt:e.t}),a===`spent`)return t;let[n,r]=_();return a=`two`,c=e.t,p=!1,l=d=gZ(n,r),u=f=_Z(n,r),t}return i.set(e.id,{x:e.x,y:e.y,x0:e.x,y0:e.y,t0:e.t,lt:e.t}),a=`pending`,s=n===`trackpad`&&o!=null&&e.t-o.t<=350,t},move(t){let r=i.get(t.id);if(!r)return[];let c=r.x,v=r.y,b=t.t-r.lt;if(r.x=t.x,r.y=t.y,r.lt=t.t,i.size===1){if(a===`pending`){if(gZ(r,{x:r.x0,y:r.y0})<=8)return[];if(n===`touch`)return a=`drag`,[h({k:`down`,b:`l`,...g({x:r.x0,y:r.y0})}),h({k:`move`,...g(r)})];if(n===`view`)return a=`pan`,[{t:`pan`,d:{x:r.x-r.x0,y:r.y-r.y0}}];let e=[];return s?(a=`tpdrag`,o=null,e.push(h({k:`down`,b:`l`,...m()}))):a=`tpmove`,e.push(...y(r.x-r.x0,r.y-r.y0,t.t-r.t0)),e}return a===`drag`?[h({k:`move`,...g(r)})]:a===`pan`?[{t:`pan`,d:{x:r.x-c,y:r.y-v}}]:a===`tpmove`||a===`tpdrag`?y(r.x-c,r.y-v,b):[]}if(a===`pan3`){if(i.size!==3)return[];let e=vZ(i.values()),t={x:e.x-f.x,y:e.y-f.y};return f=e,t.x||t.y?[{t:`pan`,d:t}]:[]}if(i.size!==2||a===`spent`)return[];let[x,S]=_(),C=gZ(x,S),w=_Z(x,S),T=[];if(a===`two`){let e=Math.abs(C-l),t=gZ(w,u);if(e>24)a=`pinch`;else if(t>8&&e<t)a=n===`view`?`pan`:`scroll`;else return[];p=!0}if(a===`pinch`)T.push({t:`zoom`,factor:d>0?C/d:1,at:f,pan:{x:w.x-f.x,y:w.y-f.y}});else if(a===`pan`)T.push({t:`pan`,d:{x:w.x-f.x,y:w.y-f.y}});else if(a===`scroll`){let t=e.srcPxPerPx();if(t===null)return d=C,f=w,[];let r=Math.round((w.x-f.x)*t),i=Math.round((w.y-f.y)*t);if(r||i)T.push(h({k:`scroll`,...n===`trackpad`?m():g(w),dx:r,dy:i}));else return[]}return d=C,f=w,T},up(e){let t=i.get(e.id);if(!t)return[];t.x=e.x,t.y=e.y;let r=i.size;if(i.delete(e.id),r===3)return a=`spent`,[];if(r===2){let t=[];return a===`two`&&!p&&e.t-c<=300&&n===`trackpad`&&t.push(h({k:`click`,b:`r`,...m(),n:1})),a=`spent`,t}let o=a;switch(a=`idle`,s=!1,o){case`pending`:{if(n===`view`)return[];let r=v(t,e.t);return[h({k:`click`,b:`l`,...n===`trackpad`?m():g({x:t.x0,y:t.y0}),n:r})]}case`drag`:return[h({k:`up`,b:`l`,...g(t)})];case`tpdrag`:return[h({k:`up`,b:`l`,...m()})];default:return[]}},cancel(e){if(!i.has(e.id))return[];let t=i.size===1?b():[];return i.delete(e.id),a=i.size?`spent`:`idle`,s=!1,t},tick(e){if(a!==`pending`||n!==`touch`)return[];let t=[...i.values()][0];return!t||e-t.t0<500?[]:(a=`long`,o=null,[h({k:`click`,b:`r`,...g({x:t.x0,y:t.y0}),n:1})])}}}function Gme(e){let t=[];return{push(n){let r=t[t.length-1];n.k===`move`&&r?.k===`move`?t[t.length-1]=n:n.k===`scroll`&&r?.k===`scroll`&&r.x===n.x&&r.y===n.y&&Math.abs(r.dx+n.dx)<=e&&Math.abs(r.dy+n.dy)<=e?t[t.length-1]={...r,dx:r.dx+n.dx,dy:r.dy+n.dy}:t.push(n)},drain(){let e=t;return t=[],e},get size(){return t.length}}}var bZ=[`cmd`,`alt`,`ctrl`,`shift`],Kme={cmd:`⌘`,alt:`⌥`,ctrl:`⌃`,shift:`⇧`},xZ={cmd:`Command`,alt:`Option`,ctrl:`Control`,shift:`Shift`};function qme(e){return[typeof e==`string`?e:``]}function Jme(e,t){let n=e.includes(t)?e.filter(e=>e!==t):[...e,t];return bZ.filter(e=>n.includes(e))}function Yme(e,t){return{ev:{k:`key`,key:t,mods:bZ.filter(t=>e.includes(t))},held:[]}}function Xme(e,t=[],n=500){let r=[...e.replace(/\r\n?/g,`
76
+ `)];if(t.length&&r.length===1&&r[0]!==`
77
+ `)return[Yme(t,r[0]).ev];let i=[],a=[],o=()=>{for(let e=0;e<a.length;e+=n)i.push({k:`text`,s:a.slice(e,e+n).join(``)});a=[]};for(let e of r)e===`
78
+ `?(o(),i.push({k:`key`,key:`Return`,mods:[]})):a.push(e);return o(),i}var Zme=[{id:`esc`,label:`Esc`,title:`Esc`,key:`Escape`},{id:`tab`,label:`Tab`,title:`Tab`,key:`Tab`},{id:`up`,label:`up`,title:`up arrow`,key:`ArrowUp`},{id:`down`,label:`down`,title:`down arrow`,key:`ArrowDown`},{id:`left`,label:`left`,title:`left arrow`,key:`ArrowLeft`},{id:`right`,label:`right`,title:`right arrow`,key:`ArrowRight`},{id:`ctrlc`,label:`^C`,title:`Control-C`,key:`c`,mods:[`ctrl`]},{id:`bksp`,label:`bksp`,title:`Backspace — delete the character before the cursor`,key:`Backspace`},{id:`ret`,label:`ret`,title:`Return`,key:`Return`}];function Qme(e,t){let n=bZ.filter(n=>e.includes(n)||(t.mods??[]).includes(n));return{k:`key`,key:t.key,mods:n}}function $me(e,t=[]){if(e.isComposing)return null;let n=bZ.filter(n=>t.includes(n)||(n===`cmd`?e.metaKey:n===`alt`?e.altKey:n===`ctrl`?e.ctrlKey:e.shiftKey)),r=n.some(e=>e!==`shift`),i=e.key===`Enter`?`Return`:e.key;return Vme.includes(i)?{k:`key`,key:i,mods:n}:[...i].length===1?r?{k:`key`,key:/^Key([A-Z])$/.exec(e.code)?.[1]?.toLowerCase()??/^Digit(\d)$/.exec(e.code)?.[1]??i.toLowerCase(),mods:n}:{k:`text`,s:i}:null}function SZ(e){let t=[];for(let n=0;n+2<e.length;n++)if(e[n]===0&&e[n+1]===0){if(e[n+2]===1){t.push({at:n,len:3}),n+=2;continue}if(e[n+2]===0&&n+3<e.length&&e[n+3]===1){t.push({at:n,len:4}),n+=3;continue}}let n=[];for(let r=0;r<t.length;r++){let i=t[r].at+t[r].len,a=r+1<t.length?t[r+1].at:e.length;if(a<=i)continue;let o=e.subarray(i,a);n.push({type:o[0]&31,data:o})}return n}function ehe(e){return SZ(e).some(e=>e.type===5)}function the(e){return SZ(e).find(e=>e.type===7)?.data??null}function nhe(e,t){let n=[],r=0;for(let i=1;i<e.length&&n.length<t;i++){let t=e[i];r>=2&&t===3?r=0:(n.push(t),r=t===0?r+1:0)}return n}var CZ=e=>e.toString(16).toUpperCase().padStart(2,`0`);function rhe(e){if(e.length<4||(e[0]&31)!=7)return null;let[t,n,r]=nhe(e,3);return t===void 0||n===void 0||r===void 0?null:`avc1.${CZ(t)}${CZ(n)}${CZ(r)}`}function ihe(e){let t=the(e);return t?rhe(t):null}var ahe=`avc1.4D401F`,wZ=null;function ohe(){return wZ??=(async()=>{try{let e=globalThis.VideoDecoder;return typeof e==`function`&&!!(await e.isConfigSupported({codec:ahe,optimizeForLatency:!0})).supported}catch{return!1}})(),wZ}var she=1e3,che=3,lhe=90,uhe=class{canvas;ev;dec=null;codec=``;waitKey=!0;lastAsk=0;errors=0;drawnAny=!1;ts=0;meta=new Map;pending=null;raf=0;jpegSeq=0;jpegShown=0;hold=null;closed=!1;constructor(e,t){this.canvas=e,this.ev=t}reset(){this.closeDecoder(),this.waitKey=!0,this.hold=null}close(){this.closed=!0,this.reset(),this.raf&&cancelAnimationFrame(this.raf),this.raf=0,this.pending&&=(this.pending.img.close(),null),this.meta.clear()}push(e,t,n,r){if(this.closed)return;if(e===2){this.jpeg(t,n,r);return}if(e!==1)return;let i=ehe(t);if(this.hold)this.hold.length<lhe?this.hold.push({key:i,data:t.slice(),arrival:n,tag:r}):(this.hold=null,this.waitKey=!0);else if(this.waitKey&&!i)this.askKey();else{if(i){let e=ihe(t)??`avc1.4D401F`;if(!this.dec||this.dec.state===`closed`||e!==this.codec){this.hold=[{key:i,data:t.slice(),arrival:n,tag:r}],this.configure(e);return}}this.decode(i,t,n,r)}}askKey(){let e=performance.now();e-this.lastAsk<she||(this.lastAsk=e,this.ev.onNeedKey())}async configure(e){let t=[{codec:e,optimizeForLatency:!0,hardwareAcceleration:`prefer-hardware`},{codec:e,optimizeForLatency:!0}],n=null;for(let e of t)try{if((await VideoDecoder.isConfigSupported(e)).supported){n=e;break}}catch{}if(this.closed)return;if(!n){this.hold=null,this.ev.onUnsupported(`this phone cannot decode ${e}`);return}this.closeDecoder();try{let t=new VideoDecoder({output:e=>this.output(e),error:e=>this.failed(e)});t.configure(n),this.dec=t,this.codec=e,this.waitKey=!1}catch(e){this.hold=null,this.failed(e);return}let r=this.hold??[];this.hold=null;for(let e of r)this.decode(e.key,e.data,e.arrival,e.tag)}decode(e,t,n,r){if(!this.dec||this.dec.state!==`configured`){this.waitKey=!0,this.askKey();return}let i=++this.ts*1e3;if(this.meta.set(i,{arrival:n,tag:r}),this.meta.size>120){let e=this.meta.keys().next().value;e!==void 0&&this.meta.delete(e)}try{this.dec.decode(new EncodedVideoChunk({type:e?`key`:`delta`,timestamp:i,data:t}))}catch(e){this.failed(e)}}output(e){let t=this.meta.get(e.timestamp);this.meta.delete(e.timestamp),this.closed||!t?e.close():this.show({img:e,arrival:t.arrival,tag:t.tag})}failed(e){this.closeDecoder(),this.waitKey=!0,this.errors++,!this.drawnAny&&this.errors>=che?this.ev.onUnsupported(`the video decoder failed on every keyframe`):(this.lastAsk=0,this.askKey())}closeDecoder(){if(this.dec&&this.dec.state!==`closed`)try{this.dec.close()}catch{}this.dec=null,this.codec=``}jpeg(e,t,n){let r=++this.jpegSeq;createImageBitmap(new Blob([e],{type:`image/jpeg`})).then(e=>{this.closed||r<this.jpegShown?e.close():(this.jpegShown=r,this.show({img:e,arrival:t,tag:n}))},()=>{})}show(e){this.pending&&this.pending.img.close(),this.pending=e,this.raf||=requestAnimationFrame(()=>this.draw())}draw(){this.raf=0;let e=this.pending;if(this.pending=null,!e||this.closed){e?.img.close();return}let t=`displayWidth`in e.img?e.img.displayWidth:e.img.width,n=`displayHeight`in e.img?e.img.displayHeight:e.img.height;this.canvas.width!==t&&(this.canvas.width=t),this.canvas.height!==n&&(this.canvas.height=n);let r=this.canvas.getContext(`2d`);try{r?.drawImage(e.img,0,0,t,n)}finally{e.img.close()}this.drawnAny=!0,this.errors=0,this.ev.onDrawn(performance.now()-e.arrival,t,n,e.tag)}},TZ=[{id:`fit`,label:`fit phone`,factor:1},{id:`half`,label:`½ phone`,factor:.5},{id:`third`,label:`⅓ phone`,factor:1/3},{id:`native`,label:`native`,factor:0}],dhe=[2,5,8,15,30,60],fhe=[150,300,800,1500,3e3,6e3],phe=[20,40,60,80],EZ=[{s:0,label:`on demand`},{s:5,label:`5 s`},{s:10,label:`10 s`},{s:30,label:`30 s`}],mhe=[0,20,50,100,250],DZ={codec:`h264`,res:`fit`,fps:15,bitrateKbps:800,jpegQuality:50,grayscale:!1,keyframeEverySec:0,cursor:!0},hhe={preset:`auto`,custom:DZ,source:{kind:`display`},cropToView:!0,cellularSaver:!0,capMb:0,mode:`touch`},ghe=new Set(fZ.map(e=>e.id)),OZ=(e,t,n)=>t.includes(e)?e:n,kZ=(e,t,n,r)=>typeof e==`number`&&Number.isFinite(e)?Math.min(n,Math.max(t,Math.round(e))):r;function AZ(e){let t=e&&typeof e==`object`?e:{},n=t.custom&&typeof t.custom==`object`?t.custom:{},r=hhe,i=DZ,a=hZ({source:t.source}).source;return{preset:t.preset===`custom`||ghe.has(t.preset)?t.preset:r.preset,custom:{codec:n.codec===`jpeg`?`jpeg`:`h264`,res:OZ(n.res,TZ.map(e=>e.id),i.res),fps:kZ(n.fps,1,60,i.fps),bitrateKbps:kZ(n.bitrateKbps,50,2e4,i.bitrateKbps),jpegQuality:kZ(n.jpegQuality,1,100,i.jpegQuality),grayscale:n.grayscale===!0,keyframeEverySec:kZ(n.keyframeEverySec,0,300,i.keyframeEverySec),cursor:typeof n.cursor==`boolean`?n.cursor:i.cursor},source:a,cropToView:typeof t.cropToView==`boolean`?t.cropToView:r.cropToView,cellularSaver:typeof t.cellularSaver==`boolean`?t.cellularSaver:r.cellularSaver,capMb:kZ(t.capMb,0,1e5,r.capMb),mode:OZ(t.mode,[`touch`,`trackpad`,`view`],r.mode)}}function _he(e,t){let n=t.presetOverride??e.preset,r={...dZ,source:e.source},i,a;if(n===`custom`){let n=e.custom;a=TZ.find(e=>e.id===n.res)?.factor??1,i=hZ({...r,codec:n.codec,fps:n.fps,bitrateKbps:n.bitrateKbps,auto:!1,jpegQuality:n.jpegQuality,grayscale:n.codec===`jpeg`&&n.grayscale,keyframeEverySec:n.keyframeEverySec,cursor:n.cursor,maxWidth:a===0?0:Math.round(jZ(t.phonePx)*a)})}else a=fZ.find(e=>e.id===n)?.set.widthFactor??1,i=Rme(r,n,t.phonePx);return t.forceJpeg&&i.codec!==`jpeg`&&(i={...i,codec:`jpeg`,fps:Math.min(i.fps,5),grayscale:!1}),e.cropToView&&t.crop&&(i=hZ({...i,crop:t.crop,maxWidth:Math.round(jZ(t.phonePx)*(a>0?a:1))})),i}var jZ=e=>Math.min(4096,Math.max(320,Number.isFinite(e)&&e>0?e:1280));function vhe(e,t){return!t||!e.cellularSaver||e.preset===`saver`||e.preset===`stills`?{note:null}:{override:`saver`,note:`On cellular — started in Data saver instead of ${MZ(e.preset)}.`}}function MZ(e){return e===`custom`?`Custom`:fZ.find(t=>t.id===e)?.label??e}function NZ(e,t,n){return t?n==null?`${e} · now: measuring…`:`${e} · now: ${PZ(n)}`:e}function PZ(e){return e>=1e3?`${(e/1e3).toFixed(1)} Mbit/s`:`${Math.round(e)} kbit/s`}function yhe(e){let t=e?.connection;return typeof t?.type==`string`?t.type:null}var bhe=`The desktop isn't serving a live view — update the host`,xhe=`Grant Screen Recording to wp-desktop in System Settings → Privacy & Security on the desktop`;function FZ(e){if(e.k===`unknown`)return!0;if(e.k===`failed`)return bhe;let t=e.r;return t.available?t.screenRecording!==!1||xhe:t.reason?.trim()||`Live desktop needs a Mac, or a Windows desktop with the host in WSL, for now`}function She(e){let t=FZ(e);return t===`Grant Screen Recording to wp-desktop in System Settings → Privacy & Security on the desktop`||t}function IZ(e){return e?`This phone's browser can't decode H.264 video — showing stills.`:`This connection can't decode video (not a secure context) — showing stills. Open ${I.displayName} over https to get video.`}function LZ(e,t){return e===`view`?`View only — nothing you do here reaches the desktop. Pick Touch or Trackpad to control it.`:t&&!t.control.on?`${t.control.reason?.trim()||`Control is off: turn on "Let the phone control this desktop" in Settings › Tools & diagnostics › plugins › Live desktop.`} Zoom and pan still work; nothing is sent.`:null}var RZ=`turn on control`,Che=`ask macOS for Accessibility`;function whe(e,t){if(e===`view`||!t||t.control.on)return[];let n=t.control.needs??[],r=[];return n.includes(`setting`)&&r.push({need:`setting`,button:RZ,text:`Control is switched off here ("${Lme}"). Tap ${RZ} — clicks and keys from this phone then reach every app on the desktop.`}),n.includes(`accessibility`)&&r.push({need:`accessibility`,button:Che,text:`macOS has not given wp-desktop Accessibility, so it drops every click and key. On the Mac, System Settings → Privacy & Security → Accessibility: turn on wp-desktop. macOS's dialog only opens that pane — its "Open System Settings" grants nothing until the switch is on. This phone cannot flip it: until it is on, nothing from here clicks, so this step needs the Mac itself (or another remote-control app).`}),r}function The(e){return`${e===1?`One thing stops`:`${e} things stop`} your taps reaching the desktop. Zoom and pan still work; nothing is sent.`}var Ehe=`Opened on another screen — tap take it back to show it here again (the other screen's view then ends).`;function zZ(e){return e?`Sent to the desktop, then Return.`:`Sent to the desktop.`}function Dhe(e,t){return e?`Only part of it was sent to the desktop (${e} of ${t}) — the link dropped.`:`Not sent — the link dropped.`}function Ohe(e){return e!==`replaced`}function khe(e,t,n,r){return e===`opening`?n?`Asking the desktop for its screen…`:`No connection — the view opens when the link is back.`:e===`ended`&&r===`replaced`?Ehe:e===`ended`?`The live view ended: ${t||`the desktop stopped it`}.`:e===`refused`?`The desktop did not open a live view: ${t||`no reason given`}.`:null}var BZ=`screenshot`,Ahe=`screenshot — the whole desktop at full resolution, saved into this session's repo's .claude/outbox/ (the gallery)`,jhe=`No screenshot: there is no repo to put it in — open the desktop from a session; it goes into that repo's .claude/outbox/.`,Mhe=`No screenshot: no connection to the desktop.`,Nhe=`Taking a screenshot of the desktop…`;function Phe(e,t){return`file`in e?`Screenshot saved to ${t}/${e.file.relPath} — full resolution, in the gallery.`:`No screenshot: ${e.error.trim().replace(/\.$/,``)||`no reason given`}.`}function Fhe(e){return`The desktop's capture stopped: ${(e??``).trim().replace(/[.\s]+$/,``)||`no reason given`}.`}function Ihe(e,t){if(e.kind!==`display`||e.id===void 0||t.k!==`ok`)return null;let n=t.r.displays;return n.length===0||n.some(t=>t.id===e.id)?null:`The display picked earlier is not on the desktop any more — macOS renumbers displays when a monitor reconnects or the Mac restarts. It has ${n.length===1?`one display`:`${n.length} displays`} now.`}var VZ=Ih(`desktop`,`view`),HZ=ty(uZ),UZ=iy(uZ),WZ=W({k:`unknown`}),GZ=null;function KZ(){return U().conn.status===`open`?(GZ??=HZ.read(`probe`,{}).then(e=>{WZ.set(e.ok?{k:`ok`,r:e.result,at:Date.now()}:{k:`failed`,error:e.error,at:Date.now()})}).finally(()=>{GZ=null}),GZ):Promise.resolve()}var qZ=()=>She(WZ.get()),JZ=W(null);async function YZ(e){JZ.set(`Asking the desktop…`);let t=await HZ.call(`grant`,{kind:e});JZ.set(t.ok?t.result.note:`The desktop could not ask: ${t.error}`)}function Lhe(){U().conn.liveSend({t:`plugin.set`,id:uZ,values:{control:!0}},`Control switched on`,`no connection — control is switched on the desktop`)}var XZ=W(AZ(UZ.read(`quality`,null)));function ZZ(e){let t=AZ({...XZ.get(),...e});XZ.set(t),UZ.write(`quality`,t)}function QZ(){KZ(),U().nav.open(VZ)}function $Z(){tQ(),U().nav.close(VZ)}var eQ=W({on:!1,value:``,seq:0,reopen:!1}),Rhe=`a password field on the live desktop`;function zhe(e){eQ.set(t=>e?{...t,on:!0}:{on:!1,value:``,seq:t.seq+1,reopen:!1})}function Bhe(e){eQ.set(t=>({...t,value:e}))}function tQ(){eQ.set(e=>({...e,value:``,seq:e.seq+1,reopen:!1}))}function Vhe(e,t){let n=eQ.get();if(!t||!n.on||n.seq!==e)return!1;let r=U().nav.overlay!==VZ;return eQ.set({...n,value:t,reopen:r}),r&&QZ(),!0}function Hhe(){let e=eQ.get().reopen;return e&&eQ.set(e=>({...e,reopen:!1})),e}var nQ=W(qme(UZ.read(`draft`,null)));function rQ(e){nQ.set([e]),e?UZ.write(`draft`,e):UZ.remove(`draft`)}var iQ=W({busy:!1,line:null,file:null}),Uhe=15e3,aQ=null;function oQ(e){aQ&&=(clearTimeout(aQ),null),iQ.set(e),!e.busy&&e.line&&(aQ=setTimeout(()=>{aQ=null,iQ.set({busy:!1,line:null,file:null})},Uhe))}function Whe(){oQ({busy:!1,line:null,file:null})}async function Ghe(){if(iQ.get().busy)return;let e=U(),t=e.world.activeRepo;if(!t){oQ({busy:!1,line:jhe,file:null});return}if(e.conn.status!==`open`){oQ({busy:!1,line:Mhe,file:null});return}e.say.track(`action:desktop.shot`),oQ({busy:!0,line:Nhe,file:null});let n=await px(t.id);oQ({busy:!1,line:Phe(n,t.repoName),file:`file`in n?{repoId:t.id,relPath:n.file.relPath,mtime:n.file.mtime}:null})}function Khe(){let e=iQ.get().file;e&&U().files.openFileFrom(e,VZ)}var sQ=()=>({videoBytes:0,keyBytes:0,frames:0,keyframes:0,inputs:0,lat:[]});function qhe(e,t,n){return n?{...e,keyBytes:e.keyBytes+t,frames:e.frames+1,keyframes:e.keyframes+1}:{...e,videoBytes:e.videoBytes+t,frames:e.frames+1}}function cQ(e,t){return t?{...e,inputs:e.inputs+t}:e}function Jhe(e,t){if(!Number.isFinite(t)||t<0)return e;let n=e.lat.length>=30?[...e.lat.slice(-29),t]:[...e.lat,t];return{...e,lat:n}}function lQ(e){if(!e.lat.length)return null;let t=[...e.lat].sort((e,t)=>e-t);return Math.round(t[Math.floor(t.length/2)])}var uQ=e=>e.videoBytes+e.keyBytes,dQ=e=>e>=1e7?(e/1e6).toFixed(0):(e/1e6).toFixed(1);function Yhe(e,t,n){let r=lQ(n);return`${Math.round(e)} kbps · ${Math.round(t)} fps · ${r??`—`} ms · ${dQ(uQ(n))} MB`}function Xhe(e,t){let n=[`this view: ${dQ(uQ(e))} MB — video ${dQ(e.videoBytes)} MB, keyframes ${dQ(e.keyBytes)} MB (${e.keyframes} of ${e.frames} frames)`,`sent up: ${e.inputs} input event${e.inputs===1?``:`s`}`,t?.width&&t.height?`picture: ${t.width}×${t.height}${t.codec?` ${t.codec===`jpeg`?`JPEG`:`H.264`}`:``}`:`picture: not yet known`];t?.bitrateKbps!=null&&n.push(`${t.auto?`Auto is at`:`bitrate cap`}: ${Math.round(t.bitrateKbps)} kbit/s`);let r=lQ(e);return n.push(r==null?`latency: — (no frame drawn yet)`:`latency: ${r} ms from arrival on this phone to the screen (not counting the network)`),n}function Zhe(e,t,n=0){return t>0&&uQ(e)-n>=t*1e6}function Qhe(e){return`Paused after ${e} MB — the data cap you set for one view. Resume starts another ${e} MB.`}var fQ={x:0,y:0,w:1,h:1},pQ=(e,t)=>e.w*t.zoom;function mQ(e,t){return e.w<=0||e.h<=0||t<=0?1:Math.min(1,e.h/(t*e.w))}function hQ(e,t,n){let r=Math.min(8,Math.max(mQ(e,t),n.zoom)),i=e.w*r,a=e.w/i,o=e.h/i,s=(e,t,n)=>e<=t?-(t-e)/2:Math.min(e-t,Math.max(0,n));return{zoom:r,ox:s(1,a,n.ox),oy:s(t,o,n.oy)}}function gQ(e,t){return hQ(e,t,{zoom:1,ox:0,oy:0})}function _Q(e,t,n,r){let i=pQ(e,n),a=n.ox+r.x/i,o=n.oy+r.y/i,s=e=>Math.min(1,Math.max(0,e));return{x:s(a),y:s(t>0?o/t:0)}}function vQ(e,t,n,r){let i=pQ(e,n);return{x:(r.x-n.ox)*i,y:(r.y*t-n.oy)*i}}function $he(e,t,n,r){let i=pQ(e,n);return{left:(r.x-n.ox)*i,top:(r.y*t-n.oy)*i,width:r.w*i,height:r.h*t*i}}function ege(e,t,n,r,i,a={x:0,y:0}){let o=pQ(e,n),s=n.ox+i.x/o,c=n.oy+i.y/o,l=Math.min(8,Math.max(mQ(e,t),n.zoom*r)),u=e.w*l;return hQ(e,t,{zoom:l,ox:s-(i.x+a.x)/u,oy:c-(i.y+a.y)/u})}function yQ(e,t,n,r){let i=pQ(e,n);return hQ(e,t,{...n,ox:n.ox-r.x/i,oy:n.oy-r.y/i})}function tge(e,t,n){if(t<=0)return null;let r=pQ(e,n),i=Math.max(0,n.ox),a=Math.min(1,n.ox+e.w/r),o=Math.max(0,n.oy/t),s=Math.min(1,(n.oy+e.h/r)/t),c={x:i,y:o,w:Math.max(0,a-i),h:Math.max(0,s-o)};if(c.x<=.005&&c.y<=.005&&c.w>=.995-c.x&&c.h>=.995-c.y)return null;let l=e=>Math.round(e*1e4)/1e4;return{x:l(c.x),y:l(c.y),w:l(c.w),h:l(c.h)}}function bQ(e,t){if(!e||!t)return!e&&!t;let n=.002;return Math.abs(e.x-t.x)<n&&Math.abs(e.y-t.y)<n&&Math.abs(e.w-t.w)<n&&Math.abs(e.h-t.h)<n}var xQ=e=>({arriving:e??fQ,named:null});function nge(e,t){return t?bQ(t,e.arriving)?e.named?{arriving:e.arriving,named:null}:e:{arriving:e.arriving,named:t}:e}function rge(e,t){return t&&e.named?{arriving:e.named,named:null}:e}function ige(e,t,n,r,i=24){let a=Math.min(i,e.w/4,e.h/4),o=0,s=0;return r.x<a?o=a-r.x:r.x>e.w-a&&(o=e.w-a-r.x),r.y<a?s=a-r.y:r.y>e.h-a&&(s=e.h-a-r.y),o||s?yQ(e,t,n,{x:o,y:s}):n}function age(e,t,n){return e?.srcWidth&&e.srcHeight?e.srcHeight/e.srcWidth:t&&t.w>0&&t.h>0&&n.w>0&&n.h>0?t.h/n.h/(t.w/n.w):9/16}var SQ=.32;function oge(e,t){if(e.w<=0||e.h<=0||t<=0)return null;let n=Math.min(160,e.w*SQ),r=n*t,i=Math.min(160,e.h*SQ);return r>i&&(r=i,n=r/t),n<40||r<24?null:{w:Math.round(n),h:Math.round(r)}}function CQ(e,t,n,r){let i=pQ(e,n);if(i<=0||t<=0)return{left:0,top:0,width:r.w,height:r.h};let a=Math.max(0,n.ox),o=Math.min(1,n.ox+e.w/i),s=Math.max(0,n.oy/t),c=Math.min(1,(n.oy+e.h/i)/t);return{left:a*r.w,top:s*r.h,width:Math.max(0,o-a)*r.w,height:Math.max(0,c-s)*r.h}}function wQ(e,t){let n=e=>Math.min(1,Math.max(0,e));return{x:e.w>0?n(t.x/e.w):0,y:e.h>0?n(t.y/e.h):0}}function sge(e,t,n){let r=pQ(e,n)||1;return{x:n.ox+e.w/r/2,y:t>0?(n.oy+e.h/r/2)/t:0}}function cge(e,t,n,r){let i=pQ(e,n)||1;return hQ(e,t,{...n,ox:r.x-e.w/i/2,oy:r.y*t-e.h/i/2})}function lge(e,t,n,r,i){let a=CQ(e,t,n,i),o={x:r.x*i.w,y:r.y*i.h};if(!(o.x>=a.left&&o.x<=a.left+a.width&&o.y>=a.top&&o.y<=a.top+a.height))return{x:0,y:0};let s=sge(e,t,n);return{x:r.x-s.x,y:r.y-s.y}}function TQ(e,t,n,r,i){return cge(e,t,n,{x:r.x-i.x,y:r.y-i.y})}var uge=e=>e.pointerType===`mouse`&&e.button===1,EQ=320;function dge(e){if(!e||typeof e!=`object`)return null;let t=e;return typeof t.state!=`string`||!t.control||typeof t.control.on!=`boolean`?null:t}var fge=class{ui=W({phase:`checking`,status:null,kbps:0,fps:0,meter:sQ(),mode:XZ.get().mode,held:[],note:null,override:void 0,noVideo:null,drawn:!1,auto:!1,zoomed:!1,map:null});handle=null;player=null;wrap=null;canvas=null;dot=null;box={w:0,h:0};view={zoom:1,ox:0,oy:0};touched=!1;pic=null;mapCanvas=null;mapRect=null;snap=null;snapAt=0;grab=null;midPan=null;track=xQ(null);drawnRegion=fQ;sent=null;forceJpeg=!1;started=!1;capFrom=0;meter=sQ();gestures=Wme({toSource:e=>_Q(this.box,this.aspect(),this.view,e),unitsPerPx:()=>{let e=pQ(this.box,this.view)||1;return{x:1/e,y:1/(e*this.aspect())}},srcPxPerPx:()=>this.srcPxPerPx()},{mode:XZ.get().mode});coalesce=Gme(Hme);flushRaf=0;tickTimer=null;cropTimer=null;statTimer=null;unsub=null;firstStart=!0;heldOff=!1;attach(e,t,n){this.wrap=e,this.canvas=t,this.dot=n,this.player=new uhe(t,{onDrawn:(e,t,n,r)=>this.drawn(e,t,n,r),onNeedKey:()=>this.handle?.keyframe(),onUnsupported:()=>this.unsupported()}),this.unsub=XZ.subscribe(()=>this.choiceChanged()),this.statTimer=setInterval(()=>this.refreshNumbers(),500)}dispose(){this.stop(),this.player?.close(),this.player=null,this.unsub?.(),this.statTimer&&clearInterval(this.statTimer),this.cropTimer&&clearTimeout(this.cropTimer),this.tickTimer&&clearTimeout(this.tickTimer),this.flushRaf&&cancelAnimationFrame(this.flushRaf)}resize(e){e.w<=0||e.h<=0||(e.w!==this.box.w||e.h!==this.box.h)&&(this.box=e,this.view=this.touched?hQ(e,this.aspect(),this.view):gQ(e,this.aspect()),this.remap(),this.layout(),this.applyParams())}async start(){if(this.started||this.heldOff)return;this.started=!0,this.patch({phase:`checking`,reason:void 0,cause:void 0});let e=await ohe();if(!this.started)return;if(e||(this.forceJpeg=!0,this.patch({noVideo:IZ(globalThis.isSecureContext===!0)})),this.firstStart){this.firstStart=!1;let e=vhe(XZ.get(),yhe(globalThis.navigator)===`cellular`);this.patch({override:e.override,note:e.note})}let t=this.params();this.sent=t,this.track=xQ(t.crop),this.player?.reset(),this.patch({phase:`opening`,drawn:!1,auto:t.auto&&t.codec===`h264`}),this.handle=Jy(uZ,Ime,t,{onFrame:e=>this.frame(e),onStatus:e=>this.statusIn(e),onOpened:()=>{this.player?.reset(),this.track=xQ(this.sent?.crop),this.handle?.keyframe(),this.patch({phase:`open`})},onEnded:(e,t)=>{this.handle=null,this.started=!1,this.heldOff=!Ohe(e),this.player?.reset(),this.patch({phase:e===`refused`?`refused`:`ended`,reason:t,cause:e})}})}stop(){this.started=!1,this.handle?.close(),this.handle=null,this.player?.reset(),this.ui.get().phase!==`paused`&&!this.heldOff&&this.patch({phase:`stopped`})}retry(){this.heldOff=!1,this.stop(),this.start()}pause(){this.stop(),this.patch({phase:`paused`})}resume(){this.capFrom=uQ(this.meter),this.patch({phase:`stopped`}),this.start()}frame(e){let t=performance.now(),n=e.kind===2||!!(e.flags&1);this.meter=qhe(this.meter,e.payload.byteLength,n),this.track=rge(this.track,n),this.player?.push(e.kind,e.payload,t,this.track.arriving),Zhe(this.meter,XZ.get().capMb,this.capFrom)&&this.pause()}statusIn(e){let t=dge(e);if(!t)return;this.track=nge(this.track,t.crop);let n=this.aspect();this.patch({status:t}),Math.abs(this.aspect()-n)>1e-4&&this.reaspect()}drawn(e,t,n,r){this.meter=Jhe(this.meter,e);let i=this.aspect(),a=r!==this.drawnRegion||!this.pic||this.pic.w!==t||this.pic.h!==n;this.drawnRegion=r,this.pic={w:t,h:n},this.snapshot(r),Math.abs(this.aspect()-i)>1e-4?this.reaspect():a&&this.layout(),this.ui.get().drawn||this.patch({drawn:!0})}unsupported(){this.forceJpeg||(this.forceJpeg=!0,this.patch({noVideo:IZ(globalThis.isSecureContext===!0)}),this.applyParams())}refreshNumbers(){let e=this.handle?.stats(),t=this.ui.get().phase,n=e&&(e.state===`opening`||e.state===`open`)&&(t===`open`||t===`opening`)?e.state:t;this.patch({kbps:e?.kbps??0,fps:e?.fps??0,meter:this.meter,phase:n})}params(){let e=XZ.get(),t=e.cropToView?tge(this.box,this.aspect(),this.view):null,n=globalThis.devicePixelRatio||1;return _he(e,{phonePx:Math.round((this.box.w||globalThis.innerWidth||390)*n),crop:t,forceJpeg:this.forceJpeg,presetOverride:this.ui.get().override})}applyParams(){if(!this.handle)return;let e=this.params();if(this.sent&&JSON.stringify(e)===JSON.stringify(this.sent))return;let t=!bQ(e.crop,this.sent?.crop);this.handle.setParams(e)&&(this.sent=e,t&&this.handle.keyframe(),this.patch({auto:e.auto&&e.codec===`h264`}))}choiceChanged(){let e=XZ.get();e.mode!==this.gestures.mode&&(this.send(this.gestures.setMode(e.mode)),e.mode===`trackpad`&&this.gestures.setCursor(_Q(this.box,this.aspect(),this.view,{x:this.box.w/2,y:this.box.h/2})),this.patch({mode:e.mode}),this.layout()),this.applyParams()}dropOverride(){this.ui.get().override&&(this.patch({override:void 0,note:null}),this.applyParams())}srcWidth(){let e=this.ui.get().status?.srcWidth;return typeof e==`number`&&e>0?e:null}srcPxPerPx(){let e=this.srcWidth();return e===null?null:e/(pQ(this.box,this.view)||1)}aspect(){return age(this.ui.get().status,this.pic,this.drawnRegion)}reaspect(){this.view=this.touched?hQ(this.box,this.aspect(),this.view):gQ(this.box,this.aspect()),this.remap(),this.layout()}remap(){let e=oge(this.box,this.aspect()),t=this.ui.get().map;(e?.w!==t?.w||e?.h!==t?.h)&&(this.patch({map:e}),this.paintMap())}layout(){let e=this.aspect();if(this.canvas){let t=$he(this.box,e,this.view,this.drawnRegion),n=this.canvas.style;n.left=`${t.left}px`,n.top=`${t.top}px`,n.width=`${t.width}px`,n.height=`${t.height}px`}if(this.dot){let t=this.gestures.mode===`trackpad`;if(this.dot.style.display=t?`block`:`none`,t){let t=vQ(this.box,e,this.view,this.gestures.cursor());this.dot.style.transform=`translate(${t.x}px, ${t.y}px)`}}this.layoutMap()}attachMap(e,t){this.mapCanvas=e,this.mapRect=t,this.grab=null,this.paintMap(),this.layoutMap()}layoutMap(){let e=this.ui.get().map;if(!this.mapRect||!e)return;let t=CQ(this.box,this.aspect(),this.view,e),n=this.mapRect.style;n.left=`${t.left}px`,n.top=`${t.top}px`,n.width=`${t.width}px`,n.height=`${t.height}px`}snapshot(e){if(!this.canvas||e.x>.005||e.y>.005||e.w<.995||e.h<.995)return;let t=performance.now();if(this.snap&&t-this.snapAt<1e3)return;this.snapAt=t;let n=this.snap??=document.createElement(`canvas`),r=EQ,i=Math.max(1,Math.round(EQ*this.aspect()));n.width!==r&&(n.width=r),n.height!==i&&(n.height=i);try{n.getContext(`2d`)?.drawImage(this.canvas,0,0,r,i)}catch{return}this.paintMap()}paintMap(){let e=this.mapCanvas,t=this.ui.get().map;if(!e||!t)return;let n=globalThis.devicePixelRatio||1,r=Math.round(t.w*n),i=Math.round(t.h*n);e.width!==r&&(e.width=r),e.height!==i&&(e.height=i);let a=e.getContext(`2d`);a&&(this.snap?a.drawImage(this.snap,0,0,r,i):(a.fillStyle=`#222`,a.fillRect(0,0,r,i)))}mapDown(e){let t=this.ui.get().map;if(!t)return;let n=wQ(t,e);this.grab=lge(this.box,this.aspect(),this.view,n,t),this.view=TQ(this.box,this.aspect(),this.view,n,this.grab),this.viewMoved()}mapMove(e){let t=this.ui.get().map;t&&this.grab&&(this.view=TQ(this.box,this.aspect(),this.view,wQ(t,e),this.grab),this.viewMoved())}mapUp(){this.grab=null}viewMoved(){this.touched=!0,this.ui.get().zoomed||this.patch({zoomed:!0}),this.layout(),this.cropTimer&&clearTimeout(this.cropTimer),this.cropTimer=setTimeout(()=>{this.cropTimer=null,this.applyParams()},300)}fit(){this.touched=!1,this.view=gQ(this.box,this.aspect()),this.viewMoved(),this.touched=!1,this.patch({zoomed:!1})}local(e){let t=this.wrap.getBoundingClientRect();return{id:e.pointerId,x:e.clientX-t.left,y:e.clientY-t.top,t:performance.now()}}pointerDown(e){if(this.wrap){try{this.wrap.setPointerCapture(e.pointerId)}catch{}if(uge(e)){let t=this.local(e);this.midPan={id:e.pointerId,x:t.x,y:t.y}}else this.send(this.gestures.down(this.local(e))),this.armTick()}}pointerMove(e){if(this.wrap){if(this.midPan?.id===e.pointerId){let t=this.local(e),n={x:t.x-this.midPan.x,y:t.y-this.midPan.y};this.midPan={id:e.pointerId,x:t.x,y:t.y},(n.x||n.y)&&this.send([{t:`pan`,d:n}])}else this.send(this.gestures.move(this.local(e)))}}pointerUp(e){this.wrap&&(this.midPan?.id===e.pointerId?this.midPan=null:(this.send(this.gestures.up(this.local(e))),this.armTick()))}pointerCancel(e){this.wrap&&(this.midPan?.id===e.pointerId?this.midPan=null:this.send(this.gestures.cancel(this.local(e))))}wheel(e){if(!this.wrap)return;let t=this.wrap.getBoundingClientRect(),n={x:e.clientX-t.left,y:e.clientY-t.top};if(e.ctrlKey){this.send([{t:`zoom`,factor:Math.exp(-e.deltaY/200),at:n,pan:{x:0,y:0}}]);return}if(this.gestures.mode===`view`){this.send([{t:`pan`,d:{x:-e.deltaX,y:-e.deltaY}}]);return}let r=this.srcPxPerPx();if(r===null)return;let i=this.gestures.mode===`trackpad`?this.gestures.cursor():_Q(this.box,this.aspect(),this.view,n),a=Math.round(-e.deltaX*r),o=Math.round(-e.deltaY*r);(a||o)&&this.send([{t:`input`,ev:{k:`scroll`,...i,dx:a,dy:o}}])}armTick(){this.tickTimer&&=(clearTimeout(this.tickTimer),null);let e=this.gestures.nextTick();e!=null&&(this.tickTimer=setTimeout(()=>{this.tickTimer=null,this.send(this.gestures.tick(performance.now()))},Math.max(0,e-performance.now())+5))}send(e){for(let t of e)if(t.t===`zoom`)this.view=ege(this.box,this.aspect(),this.view,t.factor,t.at,t.pan),this.viewMoved();else if(t.t===`pan`)this.view=yQ(this.box,this.aspect(),this.view,t.d),this.viewMoved();else if(t.t===`cursor`){let e=vQ(this.box,this.aspect(),this.view,t.at),n=ige(this.box,this.aspect(),this.view,e);n===this.view?this.layout():(this.view=n,this.viewMoved())}else this.queue(t.ev)}blocked(){let e=this.ui.get();return LZ(e.mode,e.status)||(!this.handle||e.phase!==`open`?`The live view is not open — nothing can be sent until it is.`:null)}queue(e){this.blocked()||(this.coalesce.push(e),this.flushRaf||=requestAnimationFrame(()=>{this.flushRaf=0,this.flush()}))}flush(){let e=0;for(let t of this.coalesce.drain())this.handle?.input(t)&&e++;return this.meter=cQ(this.meter,e),e}sendNow(e){let t=this.blocked();if(t)return U().say.toast(t),!1;this.flush();let n=0;for(let t of e){if(!this.handle?.input(t))break;n++}return this.meter=cQ(this.meter,n),n<e.length&&U().say.toast(Dhe(n,e.length)),n===e.length}toggleMod(e){this.patch({held:Jme(this.ui.get().held,e)})}pressRowKey(e){this.sendNow([Qme(this.ui.get().held,e)])&&this.patch({held:[]})}typeText(e,t){let n=Xme(e,this.ui.get().held);if(t&&n.push({k:`key`,key:`Return`,mods:[]}),!n.length)return!1;let r=this.sendNow(n);return r&&this.patch({held:[]}),r}pressKeyboard(e){if(this.blocked())return!1;let t=$me(e,this.ui.get().held);return!t||(this.flush(),!this.handle?.input(t))?!1:(this.meter=cQ(this.meter,1),this.ui.get().held.length&&this.patch({held:[]}),!0)}patch(e){this.ui.set(t=>({...t,...e}))}},DQ=16,pge={up:(0,J.jsx)(to,{size:DQ}),down:(0,J.jsx)(ts,{size:DQ}),left:(0,J.jsx)(Sl,{size:DQ}),right:(0,J.jsx)(zo,{size:DQ}),ret:(0,J.jsx)(ro,{size:DQ}),bksp:(0,J.jsx)(dc,{size:DQ})},mge={touchAction:`pan-x`,flex:`0 0 auto`};function hge({ctl:e,held:t,typing:n,onType:r}){return(0,J.jsxs)(`div`,{className:`keys`,style:mge,children:[(0,J.jsxs)(Y,{className:n?`active`:void 0,title:n?`close the typing box (what you wrote stays)`:`type words on the desktop`,"aria-label":`type`,onClick:r,children:[(0,J.jsx)(uc,{size:DQ}),` type`]}),bZ.map(n=>{let r=t.includes(n);return(0,J.jsx)(Y,{className:r?`active`:void 0,"aria-pressed":r,title:r?`${xZ[n]} is held for the next key — tap to let go`:`${xZ[n]} — held for the next key, then released`,onClick:()=>e.toggleMod(n),children:Kme[n]},n)}),Zme.map(t=>(0,J.jsx)(Y,{title:t.title,"aria-label":t.title,onClick:()=>e.pressRowKey(t),children:pge[t.id]??t.label},t.id))]})}var gge={x:.94,y:.12},OQ=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0&&e<=1;function _ge(e){let t=e;return t&&OQ(t.x)&&OQ(t.y)?{x:t.x,y:t.y}:gge}function vge(e,t,n,r,i){let a=(e,t)=>{if(t<=i)return .5;let n=i/2;return Math.min(t-n,Math.max(n,e))/t};return{x:a(e,n),y:a(t,r)}}var kQ=44,AQ=iy(uZ);function yge({open:e,onToggle:t}){let[n,r]=(0,V.useState)(()=>_ge(AQ.read(`handleSpot`,null))),i=(0,V.useRef)(null),a=e=>{let t=e.currentTarget.parentElement?.getBoundingClientRect();return t?vge(e.clientX-t.left,e.clientY-t.top,t.width,t.height,kQ):null};return(0,J.jsx)(Y,{className:e?`active`:void 0,"aria-pressed":e,"aria-label":`controls`,title:e?`hide the controls — drag to move this button`:`show the controls (exit, close, screenshot, keys) — drag to move this button`,style:{position:`absolute`,zIndex:3,width:kQ,height:kQ,minWidth:kQ,padding:0,borderRadius:kQ/2,left:`calc(${n.x*100}% - ${kQ/2}px)`,top:`calc(${n.y*100}% - ${kQ/2}px)`,display:`flex`,alignItems:`center`,justifyContent:`center`,touchAction:`none`,opacity:e?.95:.6,boxShadow:`0 0 4px #000`,...e?{background:`linear-gradient(var(--pick-fill), var(--pick-fill)), var(--raise)`}:null},onPointerDown:e=>{e.currentTarget.setPointerCapture(e.pointerId),i.current={x:e.clientX,y:e.clientY,moved:!1}},onPointerMove:e=>{let t=i.current;if(!t||!t.moved&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<8)return;t.moved=!0;let n=a(e);n&&r(n)},onPointerUp:e=>{let n=i.current;if(i.current=null,!n)return;if(!n.moved){t();return}let o=a(e);o&&(r(o),AQ.write(`handleSpot`,o))},onPointerCancel:()=>{i.current=null},children:(0,J.jsx)(Jo,{size:20})})}var bge={position:`absolute`,right:8,bottom:8,zIndex:2,touchAction:`none`,cursor:`move`,border:`1px solid rgba(255,255,255,0.7)`,boxShadow:`0 0 4px #000`,background:`#222`,opacity:.9},xge={position:`absolute`,left:0,top:0,width:0,height:0,pointerEvents:`none`,border:`2px solid var(--accent)`,boxShadow:`0 0 0 1px #000`,boxSizing:`border-box`},Sge=`overview — the whole desktop; drag the outline, or press anywhere on it, to move the zoomed view there (the middle mouse button also drags the picture)`;function Cge({ctl:e,map:t}){let n=(0,V.useRef)(null),r=(0,V.useRef)(null),i=(0,V.useRef)(null);return(0,V.useEffect)(()=>{let t=n.current;if(!t)return;e.attachMap(r.current,i.current);let a=e=>{let n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}},o=n=>{n.preventDefault(),n.stopPropagation();try{t.setPointerCapture(n.pointerId)}catch{}e.mapDown(a(n))},s=n=>{t.hasPointerCapture(n.pointerId)&&(n.preventDefault(),e.mapMove(a(n)))},c=()=>e.mapUp(),l=e=>e.preventDefault();return t.addEventListener(`pointerdown`,o),t.addEventListener(`pointermove`,s),t.addEventListener(`pointerup`,c),t.addEventListener(`pointercancel`,c),t.addEventListener(`contextmenu`,l),()=>{t.removeEventListener(`pointerdown`,o),t.removeEventListener(`pointermove`,s),t.removeEventListener(`pointerup`,c),t.removeEventListener(`pointercancel`,c),t.removeEventListener(`contextmenu`,l),e.attachMap(null,null)}},[e]),(0,V.useEffect)(()=>{e.attachMap(r.current,i.current)},[e,t.w,t.h]),(0,J.jsxs)(`div`,{ref:n,style:{...bge,width:t.w,height:t.h},title:Sge,"aria-label":`overview of the whole desktop`,children:[(0,J.jsx)(`canvas`,{ref:r,style:{display:`block`,width:t.w,height:t.h}}),(0,J.jsx)(`div`,{ref:i,style:xge})]})}var wge={position:`absolute`,inset:0,zIndex:2,overflowY:`auto`,touchAction:`pan-y`,background:`var(--bg)`,paddingBottom:`calc(env(safe-area-inset-bottom) + 12px)`},Tge={display:`flex`,alignItems:`center`,gap:8,padding:`8px 12px`,borderBottom:`1px solid var(--line)`},jQ={display:`flex`,flexWrap:`wrap`,gap:6,padding:`4px 14px 8px`},MQ={minHeight:38,padding:`4px 10px`};function NQ({label:e,opts:t,value:n,show:r,onPick:i,radio:a}){return(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`section-hint`,style:{padding:`6px 14px 0`},children:e}),a?(0,J.jsx)(`div`,{style:{padding:`2px 14px 8px`},children:(0,J.jsx)(yS,{label:e,value:String(r(n)),onChange:e=>i(t.find(t=>String(r(t))===e)),options:t.map(e=>({key:String(r(e)),label:r(e)}))})}):(0,J.jsx)(`div`,{style:jQ,children:t.map(e=>(0,J.jsx)(Y,{className:e===n?`active`:void 0,style:MQ,"aria-pressed":e===n,onClick:()=>i(e),children:r(e)},String(r(e))))})]})}function PQ({label:e,on:t,hint:n,onFlip:r}){return(0,J.jsxs)(`li`,{className:`check-row`,children:[(0,J.jsxs)(Y,{className:t?`active`:void 0,style:{alignSelf:`flex-start`,...MQ},"aria-pressed":t,onClick:r,children:[e,`: `,t?`on`:`off`]}),(0,J.jsx)(Z,{style:{padding:0},children:n})]})}var Ege=(e,t)=>e.kind===t.kind&&(e.kind===`front`||(`id`in e?e.id:void 0)===(`id`in t?t.id:void 0));function Dge({c:e}){let t=G(WZ),[n,r]=(0,V.useState)(null),i=t.k===`ok`?t.r.displays:[],a=e=>ZZ({source:e}),o=(e,t,n,r,i)=>(0,J.jsxs)(Y,{className:t?`active`:void 0,style:{...MQ,textAlign:`left`},"aria-pressed":t,onClick:()=>a(i),children:[n,` `,r]},e);return(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`div`,{className:`section-hint`,style:{padding:`6px 14px 0`},children:`source`}),(0,J.jsxs)(`div`,{style:jQ,children:[i.length===0&&o(`main`,e.source.kind===`display`,(0,J.jsx)(xo,{size:14}),`the main display`,{kind:`display`}),i.map((t,n)=>o(`d${t.id}`,e.source.kind===`display`&&(e.source.id??(t.main?t.id:-1))===t.id,(0,J.jsx)(xo,{size:14}),`display ${n+1} · ${t.width}×${t.height}${t.main?` (main)`:``}`,{kind:`display`,id:t.id})),o(`front`,e.source.kind===`front`,(0,J.jsx)(co,{size:14}),`the front window (follows focus)`,{kind:`front`}),(0,J.jsxs)(Y,{style:MQ,onClick:()=>{r(null),HZ.read(`windows`,{}).then(e=>r(e.ok?{list:e.result.windows}:{error:e.error}))},children:[(0,J.jsx)(Lc,{size:14}),` one window…`]})]}),n&&`error`in n&&(0,J.jsxs)(Z,{tone:`warn`,style:{padding:`0 14px`},children:[`The window list did not come: `,n.error]}),n&&`list`in n&&(n.list.length===0?(0,J.jsx)(Z,{style:{padding:`0 14px`},children:`The desktop reports no windows it can show.`}):(0,J.jsx)(`div`,{style:jQ,children:n.list.map(t=>o(`w${t.id}`,Ege(e.source,{kind:`window`,id:t.id}),(0,J.jsx)(Lc,{size:14}),`${t.app}${t.title?` — ${t.title}`:``}`,{kind:`window`,id:t.id}))}))]})}function Oge({k:e}){let t=t=>ZZ({custom:{...e,...t}}),n=e.codec===`h264`;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(NQ,{radio:!0,label:`codec`,opts:[`h264`,`jpeg`],value:e.codec,show:e=>e===`h264`?`H.264 video`:`JPEG stills`,onPick:e=>t({codec:e})}),(0,J.jsx)(NQ,{label:`resolution`,opts:TZ.map(e=>e.id),value:e.res,show:e=>TZ.find(t=>t.id===e).label,onPick:e=>t({res:e})}),(0,J.jsx)(NQ,{label:`frames per second, at most`,opts:dhe,value:e.fps,show:String,onPick:e=>t({fps:e})}),n&&(0,J.jsx)(NQ,{label:`bitrate cap`,opts:fhe,value:e.bitrateKbps,show:PZ,onPick:e=>t({bitrateKbps:e})}),n&&(0,J.jsx)(NQ,{label:`keyframe refresh`,opts:EZ.map(e=>e.s),value:e.keyframeEverySec,show:e=>EZ.find(t=>t.s===e).label,onPick:e=>t({keyframeEverySec:e})}),!n&&(0,J.jsx)(NQ,{label:`JPEG quality`,opts:phe,value:e.jpegQuality,show:String,onPick:e=>t({jpegQuality:e})}),(0,J.jsxs)(`ul`,{className:`check-list`,children:[!n&&(0,J.jsx)(PQ,{label:`grayscale`,on:e.grayscale,hint:`Gray stills: fewer bytes each, colour gone.`,onFlip:()=>t({grayscale:!e.grayscale})}),(0,J.jsx)(PQ,{label:`cursor`,on:e.cursor,hint:`Draw the desktop's own mouse pointer into the picture.`,onFlip:()=>t({cursor:!e.cursor})})]}),(0,J.jsx)(Z,{style:{padding:`0 14px`},children:n?`JPEG quality and grayscale are for JPEG stills.`:`Bitrate and keyframe refresh are for H.264 video.`})]})}function kge({ctl:e,ui:t,onClose:n}){let r=G(XZ),i=t.override??r.preset,a=t.phase===`open`&&t.meter.frames>0?t.kbps:null;return(0,J.jsxs)(`div`,{style:wge,children:[(0,J.jsxs)(`div`,{style:Tge,children:[(0,J.jsx)(`b`,{style:{flex:1},children:`Quality`}),(0,J.jsx)(Y,{title:`close — the view keeps these settings`,"aria-label":`close`,onClick:n,children:(0,J.jsx)(B,{size:16})})]}),(0,J.jsx)(`div`,{style:{padding:`4px 14px 8px`},children:(0,J.jsx)(yS,{label:`quality preset`,value:i,onChange:t=>{ZZ({preset:t}),e.dropOverride()},options:[...fZ.map(e=>({key:e.id,label:e.label,note:NZ(e.hint,i===e.id,a)})),{key:`custom`,label:`Custom`,note:NZ(`Every knob, below`,i===`custom`,a)}]})}),i===`custom`&&(0,J.jsx)(Oge,{k:r.custom}),(0,J.jsx)(Dge,{c:r}),(0,J.jsxs)(`ul`,{className:`check-list`,children:[(0,J.jsx)(PQ,{label:`Crop to view`,on:r.cropToView,hint:`Zoomed in, stream only what is on screen, at this phone's own resolution — small text stays sharp for a fraction of the bytes.`,onFlip:()=>ZZ({cropToView:!r.cropToView})}),(0,J.jsx)(PQ,{label:`Data saver on cellular`,on:r.cellularSaver,hint:`Start in Data saver when this phone is on a cellular connection, and say so.`,onFlip:()=>ZZ({cellularSaver:!r.cellularSaver})})]}),(0,J.jsx)(NQ,{label:`data cap — pause after this many MB in one view`,opts:mhe,value:r.capMb,show:e=>e===0?`no cap`:`${e} MB`,onPick:e=>ZZ({capMb:e})})]})}function FQ({worded:e,style:t}){let n=G(iQ),r=n.busy?Js:_s;return(0,J.jsxs)(Y,{style:t,title:Ahe,"aria-label":BZ,"aria-busy":n.busy,onClick:()=>void Ghe(),children:[(0,J.jsx)(r,{size:15,className:n.busy?`spin`:void 0}),e?` ${BZ}`:null]})}var Age={display:`flex`,alignItems:`center`,gap:8,padding:`6px 8px 6px 12px`,background:`var(--panel)`,borderTop:`1px solid var(--line)`,color:`var(--fg)`},IQ={minHeight:36,padding:`4px 10px`,flex:`0 0 auto`};function jge(){let e=G(iQ);return e.line?(0,J.jsxs)(Z,{style:Age,role:`status`,children:[(0,J.jsx)(`div`,{style:{flex:`1 1 auto`,minWidth:0,overflowWrap:`anywhere`},children:e.line}),e.file&&(0,J.jsxs)(Y,{style:IQ,title:`open the screenshot — closing it comes back here`,onClick:Khe,children:[(0,J.jsx)(Io,{size:15}),` open`]}),!e.busy&&(0,J.jsx)(Y,{style:IQ,title:`dismiss`,"aria-label":`dismiss`,onClick:Whe,children:(0,J.jsx)(B,{size:15})})]}):null}var Mge=[{id:`touch`,label:`Touch`,title:`Touch — a tap clicks where your finger is, a long press right-clicks, a drag drags, two fingers scroll, three fingers move the zoomed view`,icon:ns},{id:`trackpad`,label:`Trackpad`,title:`Trackpad — one finger moves a cursor, a tap clicks at it, a two-finger tap right-clicks, two fingers scroll, double-tap and drag to drag, three fingers move the zoomed view`,icon:zte},{id:`view`,label:`View only`,title:`View only — nothing is sent to the desktop; one finger pans`,icon:hl}],Nge={padding:`6px 8px`,gap:4},Pge={minHeight:40,padding:`4px 6px`,fontSize:`calc(13px * var(--ui-font, 1))`},LQ={padding:`4px 12px`},Fge={display:`flex`,flexDirection:`column`,alignItems:`flex-start`,gap:6,marginTop:6},Ige={minHeight:36,padding:`4px 10px`};function Lge({ctl:e,ui:t,onFull:n}){let[r,i]=(0,V.useState)(!1),a=LZ(t.mode,t.status),o=whe(t.mode,t.status),s=G(JZ);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`segmented`,style:Nge,children:[Mge.map(e=>(0,J.jsxs)(`button`,{className:`seg${t.mode===e.id?` on`:``}`,style:Pge,title:e.title,"aria-pressed":t.mode===e.id,onClick:()=>ZZ({mode:e.id}),children:[(0,J.jsx)(e.icon,{size:15}),` `,e.label]},e.id)),(0,J.jsx)(FQ,{}),(0,J.jsx)(Y,{title:`fullscreen — the desktop gets the whole screen`,"aria-label":`fullscreen`,onClick:n,children:(0,J.jsx)(hc,{size:15})})]}),(0,J.jsx)(`button`,{className:`form-hint`,style:{...LQ,background:`none`,border:0,textAlign:`left`,width:`100%`,cursor:`pointer`},title:`what this view costs — tap for the split`,"aria-expanded":r,onClick:()=>i(!r),children:Yhe(t.kbps,t.fps,t.meter)}),r&&(0,J.jsx)(Z,{style:LQ,children:Xhe(t.meter,t.status&&{...t.status,auto:t.auto}).map(e=>(0,J.jsx)(`div`,{children:e},e))}),o.length>0?(0,J.jsxs)(Z,{tone:`warn`,style:LQ,children:[(0,J.jsx)(`div`,{children:The(o.length)}),o.map((e,t)=>(0,J.jsxs)(`div`,{style:Fge,children:[(0,J.jsxs)(`div`,{children:[o.length>1?`${t+1}. `:``,e.text]}),e.need===`setting`?(0,J.jsxs)(fC,{className:`key primary`,confirm:`tap again: every app on the desktop`,onConfirm:Lhe,children:[(0,J.jsx)($a,{size:15}),` `,e.button]}):(0,J.jsxs)(Y,{style:Ige,onClick:()=>void YZ(`accessibility`),children:[(0,J.jsx)(ss,{size:15}),` `,e.button]}),e.need===`accessibility`&&s&&(0,J.jsx)(Q,{as:`div`,children:s})]},e.need))]}):a&&(0,J.jsx)(Z,{tone:`warn`,style:LQ,children:a}),t.note&&(0,J.jsxs)(Z,{style:LQ,children:[t.note,` `,(0,J.jsxs)(Y,{style:{minHeight:32,padding:`2px 8px`},onClick:()=>e.dropOverride(),children:[`use `,MZ(XZ.get().preset)]})]}),t.noVideo&&(0,J.jsx)(Z,{tone:`warn`,style:LQ,children:t.noVideo})]})}var Rge={flex:`0 0 auto`,maxHeight:`40%`,overflowY:`auto`,touchAction:`pan-y`,background:`var(--panel)`,borderTop:`1px solid var(--line)`,padding:`8px 8px 0`};function zge({ctl:e,onClose:t}){let n=G(nQ),r=G(eQ),[i,a]=(0,V.useState)(!1),o=t=>{if(r.on){if(!r.value){U().say.toast(`Type the password first — or fill it from a stored login.`);return}if(!e.typeText(r.value,t))return;tQ(),a(!1),U().say.toast(zZ(t));return}let i=n[0]??``;!i&&!t?U().say.toast(`Nothing to type yet — write it in the box first.`):e.typeText(i,t)&&(rQ(``),U().say.toast(zZ(t)))},s={sessionId:null,askLine:Rhe,fill:e=>Vhe(r.seq,e)},c=r.on?ux(s):[];return(0,J.jsxs)(`div`,{style:Rge,children:[r.on?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`secret-ask`,children:[(0,J.jsx)(Fa,{size:12}),`protected — typed straight in, never kept as a draft; the box's words wait underneath`]}),(0,J.jsxs)(`div`,{className:`secret-row`,children:[(0,J.jsx)(`input`,{type:i?`text`:`password`,value:r.value,autoFocus:!0,onChange:e=>Bhe(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.nativeEvent.isComposing&&(e.preventDefault(),o(!1))},placeholder:`password`,autoCapitalize:`none`,autoCorrect:`off`,autoComplete:`off`,spellCheck:!1,enterKeyHint:`send`}),(0,J.jsx)(Y,{"aria-pressed":i,title:i?`hide what is typed`:`show what is typed`,onClick:()=>a(e=>!e),children:i?(0,J.jsx)(Go,{size:16}):(0,J.jsx)(hl,{size:16})})]})]}):(0,J.jsx)(yE,{inline:!0,plain:!0,rows:2,autoFocus:!0,prompts:n,onChange:e=>rQ(e[0]??``),placeholder:`Words for the desktop — typed where its cursor is`}),(0,J.jsxs)(`div`,{className:`queue-row-acts`,children:[(0,J.jsxs)(Y,{title:`type these words on the desktop`,onClick:()=>o(!1),children:[(0,J.jsx)(Ks,{size:16}),` type`]}),(0,J.jsxs)(Y,{title:`type these words, then press Return`,onClick:()=>o(!0),children:[(0,J.jsx)(ro,{size:16}),` type + Return`]}),(0,J.jsxs)(Y,{"aria-pressed":r.on,className:r.on?`active`:void 0,title:r.on?`back to the typing box — the masked words are dropped`:`protected: a masked field for a password, kept nowhere`,onClick:()=>{zhe(!r.on),a(!1)},children:[(0,J.jsx)(yc,{size:16}),` protected`]}),c.map(e=>(0,J.jsxs)(Y,{title:e.unavailable??e.label,onClick:()=>{e.unavailable?U().say.toast(e.unavailable):e.open()},children:[(0,J.jsx)(e.icon,{size:16}),` `,e.label]},e.key)),(0,J.jsx)(`span`,{className:`spacer`}),(0,J.jsx)(Y,{title:r.on?`close — the masked words stay until the view closes`:`close — what you wrote stays for next time`,onClick:t,children:(0,J.jsx)(B,{size:16})})]})]})}var RQ={position:`absolute`,inset:0,display:`flex`,flexDirection:`column`},Bge={...RQ,position:`fixed`,zIndex:80,background:`#000`,paddingTop:`env(safe-area-inset-top)`,paddingBottom:`env(safe-area-inset-bottom)`,paddingLeft:`env(safe-area-inset-left)`,paddingRight:`env(safe-area-inset-right)`},zQ={position:`absolute`,zIndex:2,minHeight:36,padding:`4px 10px`,opacity:.85},Vge={position:`relative`,flex:`1 1 auto`,minHeight:0},Hge={position:`absolute`,inset:0,overflow:`hidden`,touchAction:`none`,background:`#000`},Uge={position:`absolute`,left:0,top:0,width:0,height:0,imageRendering:`auto`},Wge={position:`absolute`,left:-7,top:-7,width:14,height:14,borderRadius:7,pointerEvents:`none`,display:`none`,background:`var(--accent)`,border:`2px solid #fff`,boxShadow:`0 0 3px #000`},Gge={position:`absolute`,left:12,right:12,bottom:12,zIndex:2,padding:`8px 12px`,borderRadius:10,pointerEvents:`none`,background:`var(--panel)`,border:`1px solid var(--line)`,textAlign:`center`},Kge=5e3,BQ={position:`absolute`,left:12,right:12,top:12,zIndex:1,padding:`10px 12px`,borderRadius:10,background:`var(--panel)`,border:`1px solid var(--line)`,display:`flex`,flexDirection:`column`,gap:8},VQ=()=>navigator.keyboard,HQ=()=>{VQ()?.lock?.().catch(()=>{})};function qge(){let e=(0,V.useMemo)(()=>new fge,[]),t=G(e.ui),n=G(XZ),r=G(WZ),i=G(JZ),a=Xre(),[o,s]=(0,V.useState)(()=>Hhe()?`type`:null),[c,l]=(0,V.useState)(!1),[u,d]=(0,V.useState)(!1),[f,p]=(0,V.useState)(!1);(0,V.useEffect)(()=>{if(d(!1),!c){p(!1);return}p(!0);let e=setTimeout(()=>p(!1),Kge);return()=>clearTimeout(e)},[c]);let m=!c||u||o===`type`;Gh(o!==null,()=>s(null));let h=(0,V.useMemo)(()=>{let e=document.createElement(`div`);return e.style.display=`contents`,e},[]),g=(0,V.useRef)(null);(0,V.useLayoutEffect)(()=>{(c?document.body:g.current)?.appendChild(h)},[c,h]),(0,V.useLayoutEffect)(()=>()=>h.remove(),[h]);let _=(0,V.useRef)(null),v=(0,V.useRef)(null),y=(0,V.useRef)(null),b=FZ(r),x=b===!0;(0,V.useEffect)(()=>{a===`open`&&KZ()},[a]),(0,V.useEffect)(()=>{let t=_.current,n=v.current,r=y.current;if(!t||!n||!r)return;e.attach(t,n,r);let i=new ResizeObserver(()=>e.resize({w:t.clientWidth,h:t.clientHeight}));i.observe(t),e.resize({w:t.clientWidth,h:t.clientHeight});let a=t=>{t.preventDefault(),e.pointerDown(t)},o=t=>{t.preventDefault(),e.pointerMove(t)},s=t=>e.pointerUp(t),c=t=>e.pointerCancel(t),l=t=>{t.preventDefault(),e.wheel(t)},u=e=>e.preventDefault(),d=e=>{e.button===1&&e.preventDefault()};return t.addEventListener(`pointerdown`,a),t.addEventListener(`pointermove`,o),t.addEventListener(`pointerup`,s),t.addEventListener(`pointercancel`,c),t.addEventListener(`wheel`,l,{passive:!1}),t.addEventListener(`contextmenu`,u),t.addEventListener(`mousedown`,d),t.addEventListener(`auxclick`,d),()=>{i.disconnect(),t.removeEventListener(`pointerdown`,a),t.removeEventListener(`pointermove`,o),t.removeEventListener(`pointerup`,s),t.removeEventListener(`pointercancel`,c),t.removeEventListener(`wheel`,l),t.removeEventListener(`contextmenu`,u),t.removeEventListener(`mousedown`,d),t.removeEventListener(`auxclick`,d),e.dispose()}},[e]),(0,V.useEffect)(()=>{if(!c)return;let e=document.documentElement;mx(!0);let t=!1;!document.fullscreenElement&&e.requestFullscreen?(t=!0,e.requestFullscreen().then(HQ,()=>{t=!1})):document.fullscreenElement&&HQ();let n=()=>{t&&!document.fullscreenElement&&l(!1)};return document.addEventListener(`fullscreenchange`,n),()=>{document.removeEventListener(`fullscreenchange`,n),mx(!1),VQ()?.unlock?.(),t&&document.fullscreenElement&&document.exitFullscreen().catch(()=>{})}},[c]),(0,V.useEffect)(()=>{if(!x||t.mode===`view`)return;let n=t=>{let n=t.target;n&&(n.isContentEditable||/^(INPUT|TEXTAREA|SELECT)$/.test(n.tagName))||e.pressKeyboard(t)&&t.preventDefault()};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,x,t.mode]),(0,V.useEffect)(()=>{if(!x){e.stop();return}let t=()=>{document.visibilityState===`visible`?e.start():e.stop()};return t(),document.addEventListener(`visibilitychange`,t),()=>{document.removeEventListener(`visibilitychange`,t),e.stop()}},[e,x]);let S=khe(t.phase===`checking`||t.phase===`stopped`?`opening`:t.phase,t.reason??t.status?.reason,a===`open`,t.cause),C=t.phase===`open`&&t.status?.state===`error`?Fhe(t.status.reason):null,w=C?Ihe(n.source,r):null,T=n.source.kind===`front`,E=(0,V.useRef)({kind:`display`}),D=()=>{T?ZZ({source:E.current}):(E.current=n.source,ZZ({source:{kind:`front`}}))},O=t.phase===`open`&&!t.drawn&&!C?`Waiting for the first picture…`:null;return(0,J.jsxs)(Hw,{full:!0,title:`Desktop`,icon:(0,J.jsx)(xo,{size:16}),onClose:o===null?$Z:()=>s(null),actions:(0,J.jsxs)(J.Fragment,{children:[x&&(0,J.jsxs)(Y,{className:T?`active`:void 0,"aria-pressed":T,title:T?`streaming the front window, following focus — tap to go back to the previous source`:`stream only the front window, following focus`,onClick:D,children:[(0,J.jsx)(co,{size:16}),` focus`]}),(0,J.jsxs)(Y,{className:o===`quality`?`active`:void 0,title:`Quality — presets, bitrate, source, data cap`,onClick:()=>s(o===`quality`?null:`quality`),children:[(0,J.jsx)(es,{size:16}),` quality`]}),(0,J.jsxs)(Y,{title:`close the desktop view — open it again from the session's ☰ menu`,onClick:$Z,children:[(0,J.jsx)(B,{size:16}),` close`]})]}),head:x?(0,J.jsx)(Lge,{ctl:e,ui:t,onFull:()=>l(!0)}):void 0,children:[(0,J.jsx)(`div`,{ref:g,style:RQ}),(0,Bx.createPortal)((0,J.jsxs)(`div`,{style:c?Bge:RQ,children:[(0,J.jsxs)(`div`,{style:Vge,children:[(0,J.jsxs)(`div`,{ref:_,style:Hge,children:[(0,J.jsx)(`canvas`,{ref:v,style:Uge}),(0,J.jsx)(`div`,{ref:y,style:Wge})]}),x&&t.zoomed&&t.map&&m&&(0,J.jsx)(Cge,{ctl:e,map:t.map})]}),x&&t.zoomed&&m&&(0,J.jsxs)(Y,{style:{...zQ,left:8,top:8},title:`fit the desktop's width again (and stream all of it)`,onClick:()=>e.fit(),children:[(0,J.jsx)(Ic,{size:15}),` fit`]}),c&&(0,J.jsx)(yge,{open:u,onToggle:()=>{p(!1),d(!u)}}),c&&f&&(0,J.jsx)(`div`,{style:Gge,children:`Controls are behind the ⋯ button — tap it to show them, drag it out of the way.`}),c&&u&&(0,J.jsxs)(Y,{style:{...zQ,right:8,top:8},title:`leave fullscreen`,onClick:()=>l(!1),children:[(0,J.jsx)(Qte,{size:15}),` exit`]}),c&&u&&(0,J.jsxs)(Y,{style:{...zQ,right:8,top:52},title:`close the desktop view — open it again from the session's ☰ menu`,onClick:$Z,children:[(0,J.jsx)(B,{size:15}),` close`]}),c&&u&&x&&(0,J.jsx)(FQ,{worded:!0,style:{...zQ,right:8,top:96}}),!x&&(0,J.jsxs)(`div`,{style:BQ,children:[(0,J.jsx)(`div`,{children:b}),b===`Grant Screen Recording to wp-desktop in System Settings → Privacy & Security on the desktop`&&(0,J.jsxs)(Y,{variant:`primary`,style:{alignSelf:`flex-start`},onClick:()=>void YZ(`screen`),children:[(0,J.jsx)(ss,{size:16}),` ask macOS for Screen Recording`]}),b===`Grant Screen Recording to wp-desktop in System Settings → Privacy & Security on the desktop`&&i&&(0,J.jsx)(Q,{as:`div`,children:i}),(0,J.jsxs)(Y,{style:{alignSelf:`flex-start`},onClick:()=>void KZ(),children:[(0,J.jsx)(Ds,{size:16}),` ask the desktop again`]})]}),x&&t.phase===`paused`&&(0,J.jsxs)(`div`,{style:BQ,children:[(0,J.jsx)(`div`,{children:Qhe(XZ.get().capMb)}),(0,J.jsx)(Y,{style:{alignSelf:`flex-start`},onClick:()=>e.resume(),children:`resume`})]}),x&&t.phase!==`paused`&&(S||C||O)&&(0,J.jsxs)(`div`,{style:BQ,children:[(0,J.jsx)(`div`,{children:C??S??O}),w&&(0,J.jsx)(`div`,{children:w}),w&&(0,J.jsxs)(Y,{style:{alignSelf:`flex-start`},onClick:()=>{ZZ({source:{kind:`display`}}),e.retry()},children:[(0,J.jsx)(xo,{size:16}),` `,`use the main display`]}),(t.phase===`ended`||t.phase===`refused`||C)&&(t.cause===`replaced`&&!C?(0,J.jsxs)(Y,{style:{alignSelf:`flex-start`},title:`show the live view here again — the other screen's view ends`,onClick:()=>e.retry(),children:[(0,J.jsx)(ane,{size:16}),` `,`take it back`]}):(0,J.jsxs)(Y,{style:{alignSelf:`flex-start`},onClick:()=>e.retry(),children:[(0,J.jsx)(Ds,{size:16}),` retry`]}))]}),x&&(0,J.jsx)(jge,{}),o===`type`&&x&&(0,J.jsx)(zge,{ctl:e,onClose:()=>s(null)}),x&&t.mode!==`view`&&m&&(0,J.jsx)(hge,{ctl:e,held:t.held,typing:o===`type`,onType:()=>s(o===`type`?null:`type`)}),o===`quality`&&(0,J.jsx)(kge,{ctl:e,ui:t,onClose:()=>s(null)})]}),h)]})}var Jge=e({manifest:()=>Yge}),Yge={id:`desktop`,sheets:[{id:Ih(`desktop`,`view`),persisted:!1,render:()=>(0,V.createElement)(qge)}],sessionViews:[{id:`desktop`,label:`Desktop`,icon:xo,available:qZ,open:()=>QZ()}],launcherItems:[{id:`desktop`,label:`Desktop`,icon:xo,order:10,available:qZ,open:()=>QZ()}],messages:{welcome:()=>{KZ()}}},Xge=6e4,Zge=/^[A-Za-z0-9][A-Za-z0-9._-]*$/,Qge=new Set([`worker`,`core`,`core-simd`,`lang`]);function UQ(e){let t=e;if(!t||t.format!==1||!Array.isArray(t.files))return null;let n=[];for(let e of t.files){let t=e;if(!t||typeof t.file!=`string`||!Zge.test(t.file)||!Qge.has(t.role)||typeof t.bytes!=`number`||!(t.bytes>0)||typeof t.sha256!=`string`||!/^[0-9a-f]{64}$/.test(t.sha256)||t.role===`lang`&&(typeof t.lang!=`string`||!/^[a-z_]{3,10}$/.test(t.lang)))return null;n.push({file:t.file,role:t.role,bytes:t.bytes,sha256:t.sha256,...t.lang?{lang:t.lang}:{},...typeof t.name==`string`?{name:t.name}:{}})}return n.some(e=>e.role===`worker`)&&n.some(e=>e.role===`core`)&&n.some(e=>e.role===`lang`)?{files:n}:null}function WQ(e,t){let n=t&&e.files.find(e=>e.role===`core-simd`)||e.files.find(e=>e.role===`core`);return e.files.filter(e=>e.role===`worker`||e.role===`lang`||e===n)}var $ge=e=>e.filter(e=>e.role===`lang`).map(e=>e.lang),e_e=e=>e.filter(e=>e.role===`lang`).map(e=>e.name??e.lang),GQ=e=>e.reduce((e,t)=>e+t.bytes,0),KQ=e=>(e/1e6).toFixed(1),t_e=e=>e.join(` + `),qQ=(e,t,n,r)=>`Downloading ${e} of ${t} · ${KQ(n)} of ${KQ(r)} MB`,n_e=(e,t)=>`Ready · ${t_e(e)} · ${KQ(t)} MB, works offline`,r_e=e=>`Off. Its reader (${KQ(e)} MB) is still on this phone — delete it, or keep it for when you switch it back on.`;function JQ(e,t){return e===null?`The desktop could not be reached to download the reader.`:t?`The desktop refused the download: ${t}.`:`The desktop answered ${e} for the reader's files.`}function i_e(e){let t=[];for(let n of Array.isArray(e)?e:[])for(let e of Array.isArray(n?.paragraphs)?n.paragraphs:[])for(let n of Array.isArray(e?.lines)?e.lines:[])for(let e of Array.isArray(n?.words)?n.words:[])typeof e?.text==`string`&&typeof e?.confidence==`number`&&t.push({text:e.text,confidence:e.confidence});return t}function a_e(e){let t=e.filter(e=>e.confidence>=60).map(e=>e.text.replace(/\s+/g,` `).trim()).filter(e=>/[\p{L}\p{N}]/u.test(e)).join(` `).replace(/\s+/g,` `).trim();if(!t)return null;if(t.length<=200)return t;let n=t.slice(0,200),r=n.lastIndexOf(` `);return`${(r>100?n.slice(0,r):n).trimEnd()}…`}var o_e=new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11]),s_e=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function c_e(e){let t=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),n=new Uint32Array(64),r=e.length,i=new Uint8Array(128),a=Math.floor(r/64),o=r-a*64;i.set(e.subarray(a*64)),i[o]=128;let s=o+9>64?128:64,c=r*8,l=new DataView(i.buffer);l.setUint32(s-8,Math.floor(c/4294967296)),l.setUint32(s-4,c>>>0);let u=(e,r)=>{for(let t=0;t<16;t++){let i=r+t*4;n[t]=e[i]<<24|e[i+1]<<16|e[i+2]<<8|e[i+3]}for(let e=16;e<64;e++){let t=n[e-15],r=n[e-2],i=(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3,a=(r>>>17|r<<15)^(r>>>19|r<<13)^r>>>10;n[e]=n[e-16]+i+n[e-7]+a|0}let i=t[0],a=t[1],o=t[2],s=t[3],c=t[4],l=t[5],u=t[6],d=t[7];for(let e=0;e<64;e++){let t=(c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7),r=c&l^~c&u,f=d+t+r+s_e[e]+n[e]|0,p=((i>>>2|i<<30)^(i>>>13|i<<19)^(i>>>22|i<<10))+(i&a^i&o^a&o)|0;d=u,u=l,l=c,c=s+f|0,s=o,o=a,a=i,i=f+p|0}t[0]=t[0]+i|0,t[1]=t[1]+a|0,t[2]=t[2]+o|0,t[3]=t[3]+s|0,t[4]=t[4]+c|0,t[5]=t[5]+l|0,t[6]=t[6]+u|0,t[7]=t[7]+d|0};for(let t=0;t<a;t++)u(e,t*64);for(let e=0;e<s;e+=64)u(i,e);return[...t].map(e=>(e>>>0).toString(16).padStart(8,`0`)).join(``)}async function l_e(e){let t=globalThis.crypto?.subtle;if(t)try{let n=await t.digest(`SHA-256`,e);return[...new Uint8Array(n)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}catch{}return c_e(e)}var YQ=W({k:`off`,kept:null}),XQ=By(`ocr`),ZQ=iy(`ocr`),QQ=`manifest.json`,$Q=`verified`,u_e=3e4,e$=0,t$=null,n$=()=>{try{return typeof WebAssembly==`object`&&WebAssembly.validate(o_e)}catch{return!1}};async function r$(e){try{let t=await e.json();return typeof t.error==`string`?t.error:null}catch{return null}}async function d_e(e,t,n){let r;try{r=await XQ.fetch(e.file,t)}catch{throw Error(JQ(null,null))}if(!r.ok)throw Error(JQ(r.status,await r$(r)));if(!r.body){let e=await r.blob();return n(e.size),e}let i=r.body.getReader(),a=[],o=0,s=()=>{i.cancel().catch(()=>{})};t.addEventListener(`abort`,s,{once:!0});try{for(;;){let e,t=await Promise.race([i.read(),new Promise((t,n)=>{e=setTimeout(()=>{s(),n(Error(`The download stalled — the desktop stopped sending.`))},u_e)})]).finally(()=>clearTimeout(e));if(t.done)break;a.push(t.value),o+=t.value.length,n(o)}}finally{t.removeEventListener(`abort`,s)}if(t.aborted)throw Error(`stopped`);return new Blob(a)}async function f_e(e,t){if(t[e.file]!==e.sha256)return!1;let n=await XQ.get(e.file);return!!n&&n.size===e.bytes}async function i$(){let e=await XQ.get(QQ);if(!e)return null;try{return UQ(JSON.parse(await e.text()))}catch{return null}}async function p_e(e){let t=null;try{t=await XQ.fetch(QQ,e)}catch{t=null}if(t?.ok){let e=await t.blob(),n=null;try{n=UQ(JSON.parse(await e.text()))}catch{n=null}if(!n)throw Error(`The desktop's reader files are from a version this app cannot use — update the desktop.`);return{m:n,fresh:e}}let n=await i$();if(n)return{m:n,fresh:null};throw Error(t?JQ(t.status,await r$(t)):JQ(null,null))}async function a$(){let e=++e$;t$?.abort(),t$=new AbortController;let t=t$.signal,n=()=>e===e$;YQ.set({k:`checking`});try{let{m:e,fresh:r}=await p_e(t),i=WQ(e,n$()),a={...ZQ.read($Q,{})},o=[];for(let e of i)await f_e(e,a)||o.push(e);if(o.length&&!r)throw Error(JQ(null,null));let s=GQ(o),c=0;for(let e=0;e<o.length;e++){let r=o[e];if(!n())return;YQ.set({k:`downloading`,line:qQ(e+1,o.length,c,s)});let i=await d_e(r,t,t=>{n()&&YQ.set({k:`downloading`,line:qQ(e+1,o.length,c+t,s)})});if(i.size!==r.bytes)throw Error(`${r.file} arrived with ${i.size} bytes instead of ${r.bytes} — not kept. Try again.`);if(await l_e(new Uint8Array(await i.arrayBuffer()))!==r.sha256)throw Error(`${r.file} did not match the desktop's checksum — not kept. Try again.`);if(!await XQ.put(r.file,i))throw Error(`This phone would not store the reader (out of space, or storage is blocked for this page).`);a[r.file]=r.sha256,ZQ.write($Q,a),c+=r.bytes}r&&await XQ.put(QQ,r);let l=new Set([QQ,...i.map(e=>e.file)]);for(let e of await XQ.list())l.has(e)||(await XQ.remove(e),delete a[e]);ZQ.write($Q,a),n()&&YQ.set({k:`ready`,bytes:GQ(i),line:n_e(e_e(i),GQ(i))})}catch(e){n()&&!t.aborted&&YQ.set({k:`error`,error:e.message||`The reader could not be downloaded.`})}}async function m_e(){let e=++e$;t$?.abort(),t$=null,YQ.set({k:`off`,kept:null});let t=await o$();e===e$&&YQ.set({k:`off`,kept:t})}async function o$(){let e=0;for(let t of await XQ.list())e+=(await XQ.get(t))?.size??0;return e}async function h_e(){let e=++e$,t=await XQ.clear();ZQ.remove($Q);let n=await o$();return e===e$&&YQ.set({k:`off`,kept:n}),t&&n===0}async function g_e(){let e=await i$();if(!e)return null;let t=WQ(e,n$()),n=ZQ.read($Q,{}),r=async e=>e&&n[e.file]===e.sha256?XQ.get(e.file):null,i=await r(t.find(e=>e.role===`worker`)),a=await r(t.find(e=>e.role===`core`||e.role===`core-simd`));if(!i||!a)return null;let o=[];for(let e of $ge(t)){let n=await r(t.find(t=>t.lang===e));if(!n)return null;o.push({code:e,data:n})}return{worker:i,core:a,langs:o}}var __e=45e3,v_e=1;async function y_e(e){let t=new Uint8Array(await e.slice(0,2).arrayBuffer());if(t[0]!==31||t[1]!==139)return new Uint8Array(await e.arrayBuffer());if(typeof DecompressionStream>`u`)throw Error(`this browser cannot unpack the language data`);let n=e.stream().pipeThrough(new DecompressionStream(`gzip`));return new Uint8Array(await new Response(n).arrayBuffer())}function b_e(e){let t=0,n=new Map,r=e=>{for(let[t,r]of n)clearTimeout(r.t),r.no(e),n.delete(t)};return e.onmessage=({data:e})=>{let t=n.get(`${e?.action}-${e?.jobId}`);t&&e.status!==`progress`&&(clearTimeout(t.t),n.delete(`${e.action}-${e.jobId}`),e.status===`resolve`?t.ok(e.data):t.no(Error(String(e.data))))},e.onerror=e=>{e.preventDefault?.(),r(Error(e.message||`the reader stopped`))},{call(r,i,a=__e){let o=`j${++t}`;return new Promise((t,s)=>{let c=setTimeout(()=>{n.delete(`${r}-${o}`),s(Error(`${r} took too long`))},a);n.set(`${r}-${o}`,{ok:t,no:s,t:c}),e.postMessage({workerId:`wp-ocr`,jobId:o,action:r,payload:i})})},end(){r(Error(`the reader was stopped`)),e.terminate()}}}async function x_e(e){let t=URL.createObjectURL(e.core),n=URL.createObjectURL(e.worker),r=URL.createObjectURL(new Blob([`importScripts(${JSON.stringify(t)});\nimportScripts(${JSON.stringify(n)});\n`],{type:`text/javascript`})),i=null;try{i=b_e(new Worker(r)),await i.call(`load`,{options:{lstmOnly:!0,corePath:t,logging:!1}}),await i.call(`loadLanguage`,{langs:[],options:{cacheMethod:`none`,gzip:!0,lstmOnly:!0}});for(let t of e.langs)await i.call(`FS`,{method:`writeFile`,args:[`./${t.code}.traineddata`,await y_e(t.data)]});return await i.call(`initialize`,{langs:e.langs.map(e=>e.code).join(`+`),oem:v_e,config:{}}),await i.call(`setParameters`,{params:{tessedit_pageseg_mode:`6`,user_defined_dpi:`300`}}),i}catch(e){throw i?.end(),e}finally{URL.revokeObjectURL(r),URL.revokeObjectURL(n),URL.revokeObjectURL(t)}}function S_e(e,t=Xge){let n=null,r=null,i=Promise.resolve(),a=0,o=()=>{a++,r&&=(clearTimeout(r),null);let e=n;n=null,e?.then(e=>e.end(),()=>{})},s=()=>{if(!n){let t=a;n=e().then(e=>{if(!e)throw Error(`the reader is not downloaded`);return x_e(e)}),n.catch(()=>{a===t&&(n=null)})}return n},c=()=>{r&&clearTimeout(r),r=setTimeout(o,t)};return{async read(e,t,n=2e4){if(t.aborted)return null;r&&=(clearTimeout(r),null);let a=i.then(async()=>{if(t.aborted)return null;let r=await s();if(t.aborted)return null;let i=new Uint8Array(await e.arrayBuffer());try{return a_e(i_e((await r.call(`recognize`,{image:i,options:{},output:{text:!1,blocks:!0}},n))?.blocks))}catch(e){throw o(),e}});i=a.catch(()=>null);let l=new Promise(e=>t.addEventListener(`abort`,()=>e(null),{once:!0}));try{return await Promise.race([a,l])}catch{return null}finally{i.then(c)}},stop:o,warm:()=>n!==null}}function C_e(){let e=G(YQ),t=gy(`ocr`);return(0,J.jsxs)(iC,{id:`ocr-reader`,label:`text in marks`,icon:js,children:[t&&e.k===`checking`&&(0,J.jsxs)(X,{children:[(0,J.jsx)(Js,{size:12}),` Checking the reader on this phone…`]}),t&&e.k===`downloading`&&(0,J.jsxs)(X,{children:[(0,J.jsx)(Qa,{size:12}),` `,e.line]}),t&&e.k===`ready`&&(0,J.jsxs)(X,{children:[(0,J.jsx)(Bc,{size:12}),` `,e.line]}),t&&e.k===`error`&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(Z,{tone:`warn`,children:[(0,J.jsx)(gs,{size:12}),` `,e.error]}),(0,J.jsxs)(Y,{onClick:()=>{a$()},children:[(0,J.jsx)(xc,{size:14}),` try again`]})]}),t&&e.k===`off`&&(0,J.jsxs)(X,{children:[(0,J.jsx)(Js,{size:12}),` Starting…`]}),!t&&e.k===`off`&&e.kept?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(X,{children:r_e(e.kept)}),(0,J.jsxs)(fC,{confirm:`delete ${KQ(e.kept)} MB?`,onConfirm:()=>{h_e()},children:[(0,J.jsx)(ws,{size:14}),` delete download`]})]}):null,!t&&(e.k!==`off`||!e.kept)&&(0,J.jsx)(X,{children:`Off. Switch it on in Settings › Tools & diagnostics › plugins (Text in marks): it downloads its reader (English + German, about 8 MB) from this desktop once and then works offline.`})]})}var w_e=e({manifest:()=>T_e}),s$=S_e(g_e),T_e={id:`ocr`,imageText:{read:(e,{signal:t})=>s$.read(e,t)},boot:()=>my(`ocr`,e=>{e?a$():(s$.stop(),m_e())}),settings:[{group:`tools`,order:31,render:()=>(0,V.createElement)(C_e),rows:[{id:`ocr-reader`,label:`text in marks`,keywords:`ocr read words text recognition highlight box circle marks image picture tesseract english german offline download`}]}]},c$={status:null,area:null};function l$(e,t,n){if(t.status&&e.status!==t.status||t.area&&e.area!==t.area)return!1;let r=n.trim().toLowerCase();return!r||`${e.id} ${e.area} ${e.text}`.toLowerCase().includes(r)}var E_e=(e,t,n)=>r=>({count:e.filter(e=>l$(e,{...t,status:r},n)).length}),D_e=(e,t,n)=>r=>({count:e.filter(e=>l$(e,{...t,area:r},n)).length}),O_e=(e,t,n)=>e.filter(e=>l$(e,t,n));function k_e(e,t,n,r){let i=[];return e.status&&i.push(e.status),e.area&&i.push(`area ${e.area}`),t.trim()&&i.push(`“${t.trim()}”`),i.length?[`${n} of ${r}`,...i].join(` · `):null}var u$=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function A_e(e,t){let n=e.lastRun?Date.parse(e.lastRun):NaN,r=e.promptsBehind;if(!Number.isFinite(n))return r==null?`never built`:`never built — ${u$(r,`prompt`)} to read`;let i=[`last built ${t(n)}`];return r!=null&&i.push(`${u$(r,`prompt`)} behind`),e.commitsBehind!=null&&e.commitsBehind>0&&i.push(u$(e.commitsBehind,`commit`)),i.join(` · `)}function j_e(e){return e.map(e=>{let t=jt(e),n=[t.date,t.session?`session ${t.session}`:t.note].filter(Boolean);return n.length?n.join(` · `):e.trim()}).join(` · `)}var d$=Ih(`requirements`,`list`),f$=ty(`requirements`),p$={repo:null,cut:c$,q:``,open:null,jump:!1},m$=W(p$),h$=W(new Map),g$=W(new Map),_$=(e,t,n)=>e.set(e=>new Map(e).set(t,n)),M_e=3e5,v$=new Set;function N_e(e,t=c$){m$.set({repo:e,cut:t,q:``,open:null,jump:!1}),U().nav.open(d$)}function P_e(){m$.set(p$),U().nav.close(d$)}async function y$(e){let t=await f$.read(`list`,{repo:e.id}),n=Date.now();if(_$(h$,e.id,{at:n,res:t}),t.ok){let r=t.result;_$(g$,e.id,{at:n,res:{ok:!0,result:{setUp:r.setUp,built:!!r.lastRun,total:r.items.length,requested:r.items.filter(e=>e.status===`requested`).length}}})}}async function F_e(e){let t=g$.get().get(e.id);if(!(v$.has(e.id)||t&&Date.now()-t.at<M_e||U().conn.status!==`open`)){v$.add(e.id);try{_$(g$,e.id,{at:Date.now(),res:await f$.read(`summary`,{repo:e.id})})}finally{v$.delete(e.id)}}}async function I_e(e){let t=await f$.call(`setup`,{repo:e.id});U().say.toast(t.ok?t.result.note:`could not set up: ${t.error}`),t.ok&&(g$.set(t=>{let n=new Map(t);return n.delete(e.id),n}),await y$(e))}async function b$(e,t=U()){let n=await f$.call(`update`,{repo:e.id});if(!n.ok){t.say.toast(`the update was not handed over: ${n.error}`);return}let{intentId:r,existing:i}=n.result,a=t.world.backlog.find(e=>e.id===r);t.say.toast(i?`already waiting in the backlog`:!a||a.status===`queued`?`handed to ${e.repoName}'s agent — waiting in the backlog for your tap`:`handed over — ${a.status}`),t.nav.openBacklogCut(e.worktreePath,[r],`the requirements update`)}function L_e(e,t){m$.set(n=>({...n,cut:t?n.cut:c$,q:t?n.q:``,open:e,jump:!0}))}var R_e={display:`-webkit-box`,WebkitLineClamp:2,WebkitBoxOrient:`vertical`,overflow:`hidden`};function z_e({it:e,list:t,repo:n,open:r,onToggle:i,onFocus:a}){let o=r?Nc:Hs,s=e.supersededBy?t.items.find(t=>t.id===e.supersededBy):null;return(0,J.jsxs)(`li`,{className:`check-row req-${e.status}`,"data-req":e.id,children:[(0,J.jsxs)(Y,{style:{textAlign:`left`,justifyContent:`flex-start`,gap:6,width:`100%`},"aria-expanded":r,onClick:i,children:[(0,J.jsx)(o,{size:14}),(0,J.jsx)(`span`,{className:`mono`,children:e.id}),` · `,e.status]}),(0,J.jsx)(`div`,{style:r?void 0:R_e,children:e.text}),r&&(0,J.jsxs)(J.Fragment,{children:[e.asked.length>0&&(0,J.jsxs)(Z,{children:[`asked: `,j_e(e.asked)]}),e.shipped.map(e=>{let r=t.commits[e];return r?(0,J.jsxs)(Y,{style:{textAlign:`left`,justifyContent:`flex-start`,gap:6},onClick:()=>U().nav.openGit(n.id),children:[(0,J.jsx)(Rte,{size:14}),` `,e,` — `,r.subject,r.date?` (${r.date})`:``]},e):(0,J.jsxs)(Z,{children:[e,` — not in this repo’s history`]},e)}),e.supersededBy&&(s?(0,J.jsxs)(Y,{style:{textAlign:`left`,justifyContent:`flex-start`},onClick:()=>a(s.id),children:[`superseded by `,s.id]}):(0,J.jsxs)(Z,{children:[`superseded by `,e.supersededBy,` — not in this list`]}))]})]})}var B_e=12;function V_e(){let e=G(m$),t=G(h$);Ww(3e4);let n=e.repo;(0,V.useEffect)(()=>{n&&y$(n)},[n?.id]);let r=n?t.get(n.id):void 0,i=(0,V.useRef)(null);(0,V.useEffect)(()=>{e.jump&&e.open&&i.current!==e.open&&(i.current=e.open,document.querySelector(`[data-req="${e.open}"]`)?.scrollIntoView({block:`center`}),m$.set(e=>e.jump?{...e,jump:!1}:e)),e.open||(i.current=null)},[e.open,e.jump]);let a=(0,J.jsx)(Kw,{title:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Wo,{size:16}),` requirements · `,n?.repoName??``]}),onClose:P_e,onRefresh:()=>{n&&y$(n)},refreshTitle:`read the list again`,at:r?.at??null});if(!n)return(0,J.jsxs)(`div`,{className:`sheet`,children:[a,(0,J.jsx)(`div`,{className:`empty`,children:`No repo chosen — open this from a repo’s menu.`})]});if(!r)return(0,J.jsxs)(`div`,{className:`sheet`,children:[a,(0,J.jsx)(`div`,{className:`empty`,children:`Reading the list…`})]});if(!r.res.ok)return(0,J.jsxs)(`div`,{className:`sheet`,children:[a,(0,J.jsxs)(`div`,{className:`empty`,children:[`The list could not be read: `,r.res.error]})]});let o=r.res.result,{cut:s,q:c}=e;if(!o.setUp)return(0,J.jsxs)(`div`,{className:`sheet`,children:[a,(0,J.jsxs)(`div`,{className:`empty`,children:[`The requirements list is optional and not set up in `,o.repoName,`. Setting it up writes two files — a skill that tells the agent the format, and an index — and spends nothing. After that this sheet lists what you asked for, and the update goes to this repo’s agent through the backlog.`]}),(0,J.jsx)(`div`,{className:`annot-tools wrap`,children:(0,J.jsx)(Y,{onClick:()=>void I_e(n),children:`set up`})})]});let l=O_e(o.items,s,c),u=k_e(s,c,l.length,o.items.length),d=E_e(o.items,s,c),f=D_e(o.items,s,c),p=(0,J.jsx)(Bw,{keys:o.areas,bucket:f,label:e=>e,active:s.area,onPick:e=>m$.set(t=>({...t,cut:{...t.cut,area:e}})),className:`annot-tools wrap`});return(0,J.jsxs)(`div`,{className:`sheet`,children:[a,(0,J.jsxs)(`div`,{className:`sheet-scroll`,children:[(0,J.jsxs)(`div`,{className:`annot-tools wrap`,children:[(0,J.jsx)(Z,{as:`span`,style:{flex:`1 1 14em`},children:A_e(o,Tp)}),o.scriptFound?(0,J.jsx)(Y,{onClick:()=>void b$(n),children:`update`}):(0,J.jsx)(Z,{as:`span`,children:`This host cannot find the build script, so it cannot hand the update over — the setup checklist says where it looked.`})]}),o.promptsBehind!=null&&o.promptsBehind>=o.stalePrompts&&(0,J.jsxs)(Z,{style:{padding:`0 14px`},children:[`That is `,o.stalePrompts,` or more prompts behind — the repo’s setup checklist flags it too.`]}),(0,J.jsx)(`div`,{className:`search-row`,children:(0,J.jsx)(Fw,{placeholder:`search the list`,value:c,onChange:e=>m$.set(t=>({...t,q:e.target.value}))})}),(0,J.jsx)(Bw,{keys:ht,bucket:d,label:e=>e,active:s.status,onPick:e=>m$.set(t=>({...t,cut:{...t.cut,status:e}})),className:`annot-tools wrap`}),o.areas.length>B_e&&!s.area?(0,J.jsxs)(`details`,{children:[(0,J.jsxs)(Z,{as:`summary`,style:{padding:`8px 14px`},children:[`areas · `,o.areas.length]}),p]}):p,u&&(0,J.jsx)(Pw,{section:!0,onClear:()=>m$.set(e=>({...e,cut:c$,q:``})),children:u}),o.items.length===0?(0,J.jsx)(`div`,{className:`empty`,children:`Built, but no items yet — the first update has nothing to list.`}):l.length===0?(0,J.jsxs)(`div`,{className:`empty`,children:[`Nothing matches this cut — `,o.items.length,` items are hidden by it.`]}):(0,J.jsx)(`ul`,{className:`check-list`,children:l.map(t=>(0,J.jsx)(z_e,{it:t,list:o,repo:n,open:e.open===t.id,onToggle:()=>m$.set(e=>({...e,open:e.open===t.id?null:t.id})),onFocus:e=>L_e(e,l.some(t=>t.id===e))},t.id))})]})]})}var H_e={check:`requirements`,fix:`requirements`,fixVerb:`set up`,agentVerb:`update the list in this repo`,guidance:"Run the command quoted above from the repo root; it spends a few cents of model calls and leaves an uncommitted diff under `docs/requirements/`. Do not commit it. Then check the diff the way the run cannot: for each item still marked `requested`, look in the code — if it is clearly there, change its status line to `shipped` and add the commit that brought it (`git log -S`/`git blame`). Flag duplicates, items that describe a change rather than an end state, and anything that contradicts another item. Touch nothing else in the list, and end with a short summary of the diff for me to review."},U_e=e({manifest:()=>K_e});function W_e(e){F_e(e);let t=g$.get().get(e.id)?.res;return t?.ok?t.result.setUp?`requirements · ${t.result.requested} requested`:`requirements — not set up`:`requirements`}function G_e(e){let t=g$.get().get(e.id)?.res;return t?.ok&&t.result.setUp&&t.result.requested>0?{status:`requested`,area:null}:void 0}var K_e={id:`requirements`,setupRows:[{...H_e,agent:e=>{b$(e)}}],sheets:[{id:Ih(`requirements`,`list`),persisted:!1,render:()=>(0,V.createElement)(V_e)}],repoActions:[{id:`list`,icon:Wo,label:e=>W_e(e),run:e=>N_e(e,G_e(e))}]};function x$(e){let t=Object.entries(e).filter(([,e])=>Number.isFinite(e)&&e>0),n=t.reduce((e,[,t])=>e+t,0);return t.map(([e,t])=>({kind:e,n:t,share:n>0?t/n:null})).sort((e,t)=>t.n-e.n||e.kind.localeCompare(t.kind))}function S$(e){return x$(e).reduce((e,t)=>e+t.n,0)}function C$(e){let t=x$(e.totals.kinds);return t.length===0?null:{total:t.reduce((e,t)=>e+t.n,0),rows:t,turns:e.totals.turns}}function w$(e){if(!e.unit)return null;let t=Object.entries(e.unit.perDay).filter(([,e])=>Number.isFinite(e)).map(([e,t])=>({day:e,n:t})).sort((e,t)=>e.day.localeCompare(t.day));return t.length===0?null:{name:e.unit.name,total:t.reduce((e,t)=>e+t.n,0),days:t}}function T$(e,t){return t?t.available===!1?t.reason?.trim()||`${e} has no token ledger on this desktop.`:!C$(t)&&!w$(t)?`${e} has a ledger but nothing is counted in it yet.`:null:null}function q_e(e,t=14){return e.days.slice(-t).map(e=>({day:e.day,total:S$(e.kinds),rows:x$(e.kinds),turns:e.turns,...e.byModel?{byModel:e.byModel.map(e=>({key:e.key,total:S$(e.kinds),turns:e.turns}))}:{}}))}function J_e(e,t=String){let n=`${e.turns.toLocaleString()} turns`;return e.rows.length===0?`nothing counted, ${n}`:`${t(e.total)} tokens, ${n} — ${e.rows.map(e=>`${e.kind} ${t(e.n)}`).join(`, `)}`}function Y_e(e,t,n){return t.sliceOf?`${e}: ${t.sliceOf}. Counted in their own kinds, never added to the Claude Code tab’s figures.`:`${e} sessions only — counted in ${e}’s own kinds${n?` and ${n}`:``}, never added to another ledger.`}function X_e(e,t){return`over ${t.toLocaleString()} turns${e.sessions==null?``:`, ${e.sessions.toLocaleString()} sessions`}`}function Z_e(e,t){let n=e.cost;if(!n)return null;let r=n.models.map(e=>{if(`unpriced`in e)return{key:e.key,text:e.unpriced,priced:!1};let n=e.source===`local`?`runs on this machine (its catalogue prices it at zero)`:e.source===`user`?`your price for ${e.pattern??e.key}`:`Anthropic list price`;return{key:e.key,text:`${t(e.total,e.currency)} — ${n}`,priced:!0}});return{totals:n.totals.map(e=>t(e.total,e.currency)),lines:r,problems:n.problems??[],pricesFile:n.pricesFile}}function Q_e(e,t=[]){return e?e.filter(e=>e.id!==`claude`&&!t.includes(e.id)).map(e=>({id:e.id,label:e.label})):[]}function $_e(e){return e.days.map(e=>({t:C(e.day),day:e.day,v:S$(e.kinds)})).sort((e,t)=>e.t-t.t)}function eve(e){return e.map(e=>({t:C(e.day),day:e.day,v:e.n})).sort((e,t)=>e.t-t.t)}function tve(e){return x$(Object.fromEntries(e.models.map(e=>[e.label||e.key,S$(e.kinds)])))}function nve({items:e}){return e.length?(0,J.jsxs)(`div`,{className:`ts-insights`,children:[(0,J.jsxs)(`div`,{className:`ts-insights-head`,children:[(0,J.jsx)(ll,{size:14}),` What drives the cost `,(0,J.jsx)(k$,{muted:!0,children:`whole record · not cut to the span`})]}),e.map(e=>(0,J.jsxs)(`div`,{className:`ts-insight`,children:[(0,J.jsx)(`div`,{className:`ts-insight-head`,children:e.head}),(0,J.jsx)(`div`,{className:`ts-insight-body`,children:e.body}),e.tryThis&&(0,J.jsxs)(`div`,{className:`ts-insight-try`,children:[(0,J.jsx)(`b`,{children:`Try:`}),` `,e.tryThis]})]},e.id))]}):null}function E$(e){return e==null?``:new Date(e).toLocaleDateString(void 0,{day:`numeric`,month:`short`})}function rve(e){let t=E$(e.firstAt),n=E$(e.lastAt);return t&&n&&t!==n?`${t} – ${n}`:t||n}var D$=5;function ive({rows:e,total:t,pts:n,nameOf:r,onExplain:i,isLive:a,onOpen:o}){let[s,c]=(0,V.useState)(!1);if(!e.length)return null;let l=s?e:e.slice(0,D$);return(0,J.jsxs)(`div`,{className:`ts-convos`,children:[l.map(e=>{let s=e.cost.total,c=r?.(e.id)??`${e.label} · ${e.id.slice(0,8)}`,l=ui(e.totals)>0?Math.round(ui(e.agentTotals)/ui(e.totals)*100):0,u=t>0?s/t:0,d=n?.(s,e)??null,f=_e(e);return(0,J.jsxs)(`div`,{className:`ts-convo`,children:[(0,J.jsxs)(`div`,{className:`ts-barhead`,children:[(0,J.jsx)(`span`,{className:`ts-barlabel`,children:c}),(0,J.jsxs)(`span`,{className:`ts-barval`,children:[_t(s),t>0&&(0,J.jsxs)(`em`,{children:[u<.01?`<1`:Math.round(u*100),`%`]})]})]}),(0,J.jsxs)(`div`,{className:`ts-convo-facts`,children:[e.label,` · `,rve(e),` · `,L(ui(e.totals)),` tokens`,e.agents>0&&(0,J.jsxs)(J.Fragment,{children:[` · `,e.agents,` subagents (`,l,`% of it)`]}),e.coldUsd?(0,J.jsxs)(J.Fragment,{children:[` · `,_t(e.coldUsd),` re-caching after breaks`]}):null,d?(0,J.jsxs)(J.Fragment,{children:[` · `,d]}):null]}),f&&(0,J.jsx)(`div`,{className:`ts-convo-facts`,children:f}),i&&(0,J.jsxs)(`div`,{className:`ts-convo-acts`,children:[(0,J.jsxs)(Y,{onClick:()=>i(e,c),children:[(0,J.jsx)(Cs,{size:13}),` explain the cost`]}),o&&a?.(e.id)&&(0,J.jsxs)(Y,{onClick:()=>o(e.id),children:[(0,J.jsx)(qs,{size:13}),` context & cost`]})]})]},e.id)}),e.length>D$&&(0,J.jsx)(Y,{className:`ts-convos-more`,onClick:()=>c(e=>!e),children:s?`show the top ${D$}`:`show all ${e.length}`})]})}function O$({title:e,chips:t,caption:n,children:r}){return(0,J.jsxs)(`section`,{className:`ts-scope`,children:[(0,J.jsxs)(`div`,{className:`ts-scope-head`,children:[(0,J.jsx)(`div`,{className:`ts-scope-title`,children:e}),(0,J.jsx)(`div`,{className:`ts-scope-chips`,children:t}),n&&(0,J.jsx)(`div`,{className:`ts-scope-caption`,children:n})]}),(0,J.jsx)(`div`,{className:`ts-scope-body`,children:r})]})}function k$({children:e,muted:t=!1}){return(0,J.jsx)(`span`,{className:`ts-scope-tag${t?` ts-scope-tag-muted`:``}`,children:e})}var A$=(e,t)=>t>0?Math.round(e/t*100):0;function j$(e){let t=0,n=0;for(let r of e)t+=r.cost.total,n+=r.turns;return{usd:t,turns:n}}function M$(e,t){let n=new Date(e);n.setHours(0,0,0,0),n.setDate(n.getDate()-t);let r=e=>String(e).padStart(2,`0`);return`${n.getFullYear()}-${r(n.getMonth()+1)}-${r(n.getDate())}`}function ave(e,t){let n=[],r=e.cost.total,i=ui(e.totals);if(r<=0||i<=0)return n;let a=A$(e.totals.cacheWrite,i),o=A$(e.cost.cacheWrite,r);o>=15&&o>a*2&&n.push({id:`writes`,head:`Cache writes: ${a<1?`<1`:a}% of tokens, ${o}% of cost`,body:`Writing context into the cache costs up to 20× reading it back, so every new session, every compaction and every resume after a long break pays that rate on everything it carries.`,tryThis:`Fewer, longer-lived sessions per task, and a smaller always-on baseline (CLAUDE.md, skill descriptions, MCP tools) — it is written once per session.`});let s=e.coldStarts?.premiumUsd??0;s>0&&A$(s,r)>=2&&n.push({id:`cold`,head:`${_t(s)} (${A$(s,r)}%) spent re-caching after breaks`,body:`${L(e.coldStarts?.count??0)} requests came back to a cache that had expired and re-wrote the whole window instead of re-reading it.`,tryThis:`Finish or /compact a big session before stepping away; pick a large one up again the next morning in a fresh session with a short hand-over note.`});let c=A$(e.subagentCost.total,r);c>=15&&n.push({id:`agents`,head:`Subagents: ${c}% of cost across ${L(e.subagentLogs)} runs`,body:`Every subagent starts its own context from the baseline and pays to cache it, so many short agents cost more than their output suggests.`,tryThis:`Brief agents tightly, give each one package of work, and run mechanical lanes on a cheaper model.`});let l=e.top??[];if(l.length>=3&&e.conversations>20){let t=Math.min(5,l.length),i=A$(l.slice(0,t).reduce((e,t)=>e+t.cost.total,0),r);i>=10&&n.push({id:`concentration`,head:`${t} of ${L(e.conversations)} conversations are ${i}% of the cost`,body:`The long conversations re-send everything they hold on every turn, so a handful of them dominate — they are listed below.`,tryThis:`Ask one of them to explain itself: each row below can start a session that reads its log and names what made it expensive.`})}let u=e.days.filter(e=>e.day>M$(t,7)&&e.day<=M$(t,0)),d=e.days.filter(e=>e.day>M$(t,14)&&e.day<=M$(t,7)),f=j$(u),p=j$(d);if(f.turns>=20&&p.turns>=20&&f.usd>0&&p.usd>0){let e=f.usd/f.turns,t=p.usd/p.turns,r=Math.round((e-t)/t*100);Math.abs(r)>=10&&n.push({id:`trend`,head:`A request costs ${Math.abs(r)}% ${r>0?`more`:`less`} than the week before`,body:`${_t(e)} per request over the last 7 days against ${_t(t)} the 7 before (${_t(f.usd)} vs ${_t(p.usd)} in all).`,tryThis:r>0?`Longer conversations or a dearer model are the usual cause — the costliest conversations below say which.`:void 0})}let m=null;for(let t of e.models){if(t.priced===!1)continue;let e=A$(ui(t),i),n=A$(t.cost.total,r);n>=10&&n-e>=5&&(!m||n-e>m.u-m.t)&&(m={label:t.label,t:e,u:n})}return m&&n.push({id:`model`,head:`${m.label}: ${m.t}% of tokens, ${m.u}% of cost`,body:`Per token it is the dearest model you run a lot of.`,tryThis:`Route reading, searching and mechanical edits to a cheaper model and keep it for planning and review.`}),n}var N$=36e5,P$=[{id:`session`,label:`This 5h window`,long:`the five-hour session window running now`,lenMs:5*N$,resetOf:e=>e.sessionResetAt,pctOf:e=>e.sessionPct},{id:`week`,label:`This week window`,long:`the weekly window running now`,lenMs:6048e5,resetOf:e=>e.weeklyResetAt,pctOf:e=>e.weeklyPct}];function ove(e,t,n,r){let i=n?e.resetOf(n):null;if(i==null)return{why:`no-reset`};if(i<=r)return{why:`rolled`,resetAt:i};let a=i-e.lenMs,o=et(a),s=t?.hoursFrom??null;if(s==null||s>o)return{why:`short`,fromHour:o,hoursFrom:s};let c=(t?.hours??[]).filter(e=>sve(e.hour)>=o),l=c.reduce((e,t)=>Le(e,t),Vn()),u=c.reduce((e,t)=>d(e,t.cost),ea()),f=c.some(e=>Array.isArray(e.byModel));return{id:e.id,label:e.label,long:e.long,back:0,openedAt:a,fromHour:o,leadMs:a-o,resetAt:i,hours:c,totals:l,cost:u,models:f?I$(c,t?.models??[]):[],modelSplit:f}}function F$(e){return e.openedAt!==void 0}function I$(e,t){let n=new Map,r=new Map;for(let t of e)for(let e of t.byModel??[])Le(n.get(e.model)??n.set(e.model,Vn()).get(e.model),e.totals),d(r.get(e.model)??r.set(e.model,ea()).get(e.model),e.cost);let i=new Map(t.map(e=>[e.key,e.priced]));return[...n.entries()].map(([e,t])=>({key:e,label:nt(e)??e,...t,cost:r.get(e)??ea(),...i.has(e)?{priced:i.get(e)}:{}})).sort((e,t)=>ui(t)-ui(e))}function sve(e){let[t,n,r]=e.slice(0,10).split(`-`).map(Number),i=Number(e.slice(11,13));return new Date(t,(n||1)-1,r||1,i||0,0,0,0).getTime()}function cve(e,t){let n=e=>new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`}),r=e=>new Date(e).toLocaleDateString(void 0,{day:`numeric`,month:`short`}),i=e.resetAt-e.fromHour>26*N$,a=i?`${r(e.fromHour)}, ${n(e.fromHour)}`:n(e.fromHour),o=lve(e.leadMs,n(e.openedAt));if(e.back>0){let t=et(e.resetAt);return`Counted from ${a} to ${i?`${r(t)}, ${n(t)}`:n(t)}, ${R$(t-e.fromHour)} of hour buckets.${o}`}return`Counted from ${a} to now, ${R$(t-e.fromHour)} of hour buckets.${o}`}function L$(e,t,n){let r=Math.round(Math.abs(e)/6e4);return r?e>0?`the first hour is counted whole, ${r} min wider than the ${t}`:r===1?`the first minute of the ${t} falls before ${n} and is left out`:`the first ${r} minutes of the ${t} fall before ${n} and are left out`:null}function lve(e,t){let n=L$(e,`window`,`the first hour bucket`);return n?` The window itself opened at ${t}; the finest bucket on record is an hour, so the cut starts at the nearest hour: ${n}.`:``}function R$(e){let t=Math.max(0,Math.round(e/N$));return t<48?`${t} ${t===1?`hour`:`hours`}`:`${Math.round(t/24)} days`}function uve(e,t){return t.why===`no-reset`?`The /usage screen did not name a reset time for ${e.long}, so there is no instant to count from.`:t.why===`rolled`?`The last /usage reading described a window that has since reset, so the one running now has no known start. Re-read it above.`:t.hoursFrom==null?`No hourly detail on this desktop yet — the host records it from the next scan of the conversation logs onward, and ${e.long} can only be cut out of hours.`:`Hourly detail is kept from ${new Date(t.hoursFrom).toLocaleDateString(void 0,{day:`numeric`,month:`short`})} onward, which does not reach back to the start of ${e.long}.`}function dve(e){return e?P$.map(t=>({id:t.id,anchor:t.resetOf(e)??0,lenMs:t.lenMs})).filter(e=>e.anchor>0):[]}function z$(e){if(!e||!(e.lenMs>0)||!(e.anchor>0))return[];let t=new Map(e.windows.map(e=>[e.back,e])),n=[];for(let r=0;r<800;r++){let i=e.anchor-r*e.lenMs,a=i-e.lenMs;if(e.oldestHour==null||i<=e.oldestHour)break;let o=t.get(r),s=e.oldestHour<=et(a);n.push({back:r,openedAt:a,resetAt:i,totals:s?o?B$(o):Vn():null,cost:s?o?.cost??ea():null})}return n.reverse()}function B$(e){return{input:e.input,output:e.output,cacheRead:e.cacheRead,cacheWrite:e.cacheWrite,cacheWrite1h:e.cacheWrite1h,turns:e.turns}}function fve(e,t,n,r){if(!t||!(t.anchor>0))return{why:`no-reset`};let i=t.anchor-n*t.lenMs,a=i-t.lenMs,o=et(a);if(t.oldestHour==null||t.oldestHour>o)return{why:`short`,fromHour:o,hoursFrom:t.oldestHour};let s=t.windows.find(e=>e.back===n),c=s?B$(s):Vn(),l=!!s?.byModel||!s;return{id:e.id,label:e.label,long:n===0?e.long:pve(e,a,i),back:n,openedAt:a,fromHour:o,leadMs:a-o,resetAt:i,totals:c,cost:s?.cost??ea(),models:s?.byModel?mve(s.byModel,r):[],modelSplit:l}}function pve(e,t,n){return`the ${e.id===`session`?`five-hour session window`:`weekly window`} that ran ${V$(t,n)}`}function V$(e,t){let n=e=>new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`}),r=e=>new Date(e).toLocaleDateString(void 0,{day:`numeric`,month:`short`});return t-e>26*N$?`${r(e)} – ${r(t)}`:new Date(e).toDateString()===new Date(t).toDateString()?`${r(e)}, ${n(e)}–${n(t)}`:`${r(e)} ${n(e)} – ${r(t)} ${n(t)}`}function mve(e,t){let n=new Map(t.map(e=>[e.key,e.priced]));return e.map(e=>({key:e.model,label:nt(e.model)??e.model,...e.totals,cost:e.cost,...n.has(e.model)?{priced:n.get(e.model)}:{}})).sort((e,t)=>ui(t)-ui(e))}function hve(e,t){return!(t>0)||!(e>0)?0:Math.min(1,Math.sqrt(e/t))}function gve(e,t){return e>0?Math.max(1,Math.min(t-1,Math.ceil(e*(t-1)))):0}var H$={top:10,right:10,bottom:20,left:46},U$=[{id:`session`,label:`5h session`},{id:`week`,label:`Limit week`},{id:`30`,label:`30 days`,days:30},{id:`90`,label:`90 days`,days:90},{id:`all`,label:`All time`}];function W$(e){return e===`session`||e===`week`}function G$(e){return U$.find(t=>t.id===e)?.days??null}function K$(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}`}function _ve(e,t){let n=new Date(t);return new Date(n.getFullYear(),n.getMonth(),n.getDate()-(e-1)).getTime()}function vve(e,t,n){if(W$(e.id))return t?{from:t.fromHour,to:Math.min(t.resetAt,n)}:null;let r=G$(e.id);return r?{from:_ve(r,n),to:n}:null}function yve(e,t){if(!t)return[...e];let n=K$(t.from),r=K$(Math.max(t.from,t.to-1));return e.filter(e=>e.day>=n&&e.day<=r)}function bve(e,t,n){return t?e.filter(e=>{let r=n(e.hour);return r>=t.from&&r<t.to}):[...e]}function xve(e,t){return e!=null&&t!=null&&e<=t.from}function Sve(e,t){let n=e.reduce((e,t)=>Le(e,t),Vn()),r=e.reduce((e,t)=>d(e,t.cost),ea()),i=e.some(e=>Array.isArray(e.byModel));return{totals:n,cost:r,models:i?I$(e,t):[],modelSplit:i,days:[...e]}}function Cve(e){let t=Array.from({length:24},(e,t)=>({hour:t,...Vn(),cost:ea()}));for(let n of e){let e=Number(n.hour.slice(11,13));!Number.isInteger(e)||e<0||e>23||(Le(t[e],n),d(t[e].cost,n.cost))}return t}function wve(e){let t=new Date(e);return t.getHours()===0&&t.getMinutes()===0?t.toLocaleDateString(void 0,{weekday:`short`}):t.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}function q$(e){let t=new Date(e),n=t.toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`}),r=new Date;if(t.toDateString()===r.toDateString())return n;let i=new Date(r.getTime()+864e5);return t.toDateString()===i.toDateString()?`tomorrow ${n}`:`${t.toLocaleDateString(void 0,{weekday:`short`,day:`numeric`,month:`short`})} ${n}`}function J$(e){return e.replace(/^claude-/,``)}function Tve(e){let t=Math.round(e/36e5);return t>=48?`${Math.round(t/24)} days`:`${t} hours`}function Y$(e){return new Date(e).toLocaleString(void 0,{day:`numeric`,month:`short`,hour:`2-digit`,minute:`2-digit`})}function X$(e,t){if(!(t<=0))return`${_n(e/t)} of it`}function Eve(e){return e.firstAt==null||e.lastAt==null?0:Math.round((e.lastAt-e.firstAt)/864e5)+1}function Z$({totals:e,cost:t,money:n}){let r=n?{input:t.input,output:t.output,cacheRead:t.cacheRead,cacheWrite:t.cacheWrite,cacheWrite1h:0,turns:0}:e;return n?(0,J.jsx)(tD,{bag:r,whole:t.total,fmt:_t,exact:_t}):(0,J.jsx)(tD,{bag:r,whole:ui(e)})}function Dve({doc:e,money:t=!1}){let n=e.totals,r=ot(n),i=we(n),a=[...e.days].sort((e,t)=>ui(t)-ui(e))[0],o=ui(n)>0?ui(e.subagents)/ui(n)*100:0,s=[...e.days].sort((e,t)=>t.cost.total-e.cost.total)[0],c=e.days.length?e.cost.total/e.days.length:0,l=n.turns?e.cost.total/n.turns:0,u=[{label:`Per turn`,value:_t(l),note:`over ${L(n.turns)} turns`},{label:`Per active day`,value:_t(c),note:`over ${e.days.length} days`},...s?[{label:`Dearest day`,value:_t(s.cost.total),note:new Date(C(s.day)).toLocaleDateString(void 0,{day:`numeric`,month:`short`})}]:[],{label:`Subagents`,value:_t(e.subagentCost.total),note:`${Math.round(e.subagentCost.total/Math.max(1e-9,e.cost.total)*100)}% of the spend`},{label:`Output`,value:_t(e.cost.output),note:`${Math.round(e.cost.output/Math.max(1e-9,e.cost.total)*100)}% of the spend, 0.2% of the tokens`},{label:`Cache`,value:_t(e.cost.cacheRead+e.cost.cacheWrite),note:`${Math.round((e.cost.cacheRead+e.cost.cacheWrite)/Math.max(1e-9,e.cost.total)*100)}% of the spend`}],d=[{label:`Turns`,value:L(n.turns),note:`${L(i??0)} per turn`,title:`${Me(n.turns)} assistant turns`},{label:`Active days`,value:String(e.days.length),note:e.days.length?`of ${Eve(e)} since the first`:void 0},{label:`Served from cache`,value:r==null?`—`:`${r.toFixed(1)}%`,note:`of everything sent in`},{label:`Subagents`,value:L(ui(e.subagents)),note:`${o.toFixed(0)}% of the total`},...a?[{label:`Busiest day`,value:L(ui(a)),note:new Date(C(a.day)).toLocaleDateString(void 0,{day:`numeric`,month:`short`})}]:[],{label:`Output`,value:L(n.output),note:`what the model wrote`}];return(0,J.jsx)(`div`,{className:`ts-tiles`,children:(t?u:d).map(e=>(0,J.jsxs)(`div`,{className:`ts-tile`,title:e.title,children:[(0,J.jsx)(`div`,{className:`ts-tile-v`,children:e.value}),(0,J.jsx)(`div`,{className:`ts-tile-l`,children:e.label}),e.note&&(0,J.jsx)(`div`,{className:`ts-tile-n`,children:e.note})]},e.label))})}function Ove({cut:e,money:t=!1}){let n=e.totals,r=ot(n),i=we(n),a=ui(n),o=Math.max(0,e.resetAt-Date.now()),s=n.turns?e.cost.total/n.turns:0,c=t?[{label:`Per turn`,value:_t(s),note:`over ${L(n.turns)} turns`},{label:`Output`,value:_t(e.cost.output),note:X$(e.cost.output,e.cost.total)},{label:`Cache`,value:_t(e.cost.cacheRead+e.cost.cacheWrite),note:X$(e.cost.cacheRead+e.cost.cacheWrite,e.cost.total)},e.back>0?{label:`Ran until`,value:Y$(e.resetAt),note:`${e.back} window${e.back===1?``:`s`} ago`}:{label:`Resets in`,value:zp(e.resetAt),note:o>0?`on this window`:`any moment`}]:[{label:`Turns`,value:L(n.turns),note:`${L(i??0)} per turn`,title:`${Me(n.turns)} assistant turns`},{label:`Served from cache`,value:r==null?`—`:`${r.toFixed(1)}%`,note:`of everything sent in`},e.hours?{label:`Hours counted`,value:String(e.hours.length),note:`buckets with a turn in them`}:{label:`Ran`,value:Y$(e.openedAt),note:`for ${Tve(e.resetAt-e.openedAt)}`},{label:`Output`,value:L(n.output),note:a?X$(n.output,a):`what the model wrote`}];return(0,J.jsx)(`div`,{className:`ts-tiles`,children:c.map(e=>(0,J.jsxs)(`div`,{className:`ts-tile`,title:e.title,children:[(0,J.jsx)(`div`,{className:`ts-tile-v`,children:e.value}),(0,J.jsx)(`div`,{className:`ts-tile-l`,children:e.label}),e.note&&(0,J.jsx)(`div`,{className:`ts-tile-n`,children:e.note})]},e.label))})}function kve({days:e,totals:t,cost:n,calendarDays:r,money:i=!1}){let a=t,o=ot(a),s=we(a),c=[...e].sort((e,t)=>ui(t)-ui(e))[0],l=[...e].sort((e,t)=>t.cost.total-e.cost.total)[0],u=e=>new Date(C(e)).toLocaleDateString(void 0,{day:`numeric`,month:`short`}),d=i?[{label:`Per turn`,value:_t(a.turns?n.total/a.turns:0),note:`over ${L(a.turns)} turns`},{label:`Per active day`,value:_t(e.length?n.total/e.length:0),note:`over ${e.length} days`},...l?[{label:`Dearest day`,value:_t(l.cost.total),note:u(l.day)}]:[],{label:`Output`,value:_t(n.output),note:X$(n.output,n.total)},{label:`Cache`,value:_t(n.cacheRead+n.cacheWrite),note:X$(n.cacheRead+n.cacheWrite,n.total)}]:[{label:`Turns`,value:L(a.turns),note:`${L(s??0)} per turn`,title:`${Me(a.turns)} assistant turns`},{label:`Active days`,value:String(e.length),note:`of ${r}`},{label:`Served from cache`,value:o==null?`—`:`${o.toFixed(1)}%`,note:`of everything sent in`},...c?[{label:`Busiest day`,value:L(ui(c)),note:u(c.day)}]:[],{label:`Output`,value:L(a.output),note:`what the model wrote`}];return(0,J.jsx)(`div`,{className:`ts-tiles`,children:d.map(e=>(0,J.jsxs)(`div`,{className:`ts-tile`,title:e.title,children:[(0,J.jsx)(`div`,{className:`ts-tile-v`,children:e.value}),(0,J.jsx)(`div`,{className:`ts-tile-l`,children:e.label}),e.note&&(0,J.jsx)(`div`,{className:`ts-tile-n`,children:e.note})]},e.label))})}var Q$=`other repos`;function Ave(e,t){let n=e.slice(0,4),r=new Map;for(let e of n){let n=t?.get(e);n!=null&&n>=0&&n<4&&r.set(e,n)}let i=new Set(r.values());for(let e of n){if(r.has(e))continue;let t=0;for(;i.has(t);)t++;r.set(e,t),i.add(t)}return r}function jve(e,t){let n=new Map,r=0;for(let i of e){let e=i.cost?.total;if(!(e>0)||!Number.isFinite(e))continue;let a=t.get(i.repo);if(a==null){r+=e;continue}let o=n.get(a)??{key:i.repo,label:i.label,usd:0};o.usd+=e,n.set(a,o)}let i=[],a=0;for(let e of[...n.keys()].sort((e,t)=>e-t)){let t=n.get(e);i.push({key:t.key,label:t.label,slot:e,usd:t.usd,v0:a,v1:a+t.usd}),a+=t.usd}return r>0&&i.push({key:`\0other`,label:Q$,slot:-1,usd:r,v0:a,v1:a+r}),i}function Mve(e,t){let n=e.filter(e=>t.has(e.repo)).map(e=>({key:e.repo,label:e.label,slot:t.get(e.repo)})).sort((e,t)=>e.slot-t.slot);return e.length>n.length?[...n,{key:`\0other`,label:Q$,slot:-1}]:n}var $$=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],e1=e=>`${String(new Date(e).getHours()).padStart(2,`0`)}:00`;function t1(e){return`${$$[new Date(e).getDay()]} ${e1(e)}–${e1(e+Ct)}`}function Nve(e){let t=e.byRepo.filter(e=>e.cost?.total>0).slice().sort((e,t)=>t.cost.total-e.cost.total),n=t.slice(0,2).map(e=>`${e.label} ${_t(e.cost.total)}`),r=t.length-n.length,i=n.length?` · ${n.join(`, `)}${r>0?`, ${r} ${r===1?`other`:`others`}`:``}`:``,a=e.convoIds.length+(e.restConvos>0?e.restConvos:0);return`${t1(e.t)} · ${_t(e.usd)}${i} · ${a} ${a===1?`session`:`sessions`}`}var Pve=168*Ct;function Fve(e,t){let n=e?.weeklyResetAt;if(n==null||!Number.isFinite(n)||n<=t)return null;let r=n-Pve,i=et(r);return{from:i,openedAt:r,key:`${i}`}}function Ive(e,t){if(!e)return null;if(e.id===`week`&&e.back===0&&t&&t.from===e.fromHour)return`week`;let n=et(e.resetAt);return{from:e.fromHour,toHour:n,key:`${e.fromHour}:${n}`}}function n1(e,t){return!e||t==null||!Array.isArray(e.convos)||!Array.isArray(e.hours)||!e.cost||!e.agentCost?null:e.from===Math.round(t)?e:null}function r1(e,t){return e.state===`offline`?t===`window`?`No connection — the repo split for a window is folded on the desktop.`:`No connection — where the week went is folded on the desktop.`:e.state===`error`?/^404\b/.test(e.error??``)?t===`window`?`This desktop’s host predates the per-window repo split; tap All time for the all-time one.`:`This desktop’s host predates the week view — it answers once the host is updated.`:`The desktop could not fold ${t===`window`?`this window’s`:`the week’s`} conversations${e.error?` (${e.error})`:``}.`:t===`window`?`Folding this window’s conversations on the desktop…`:`Folding the week’s conversations on the desktop…`}function Lve(e){if(!e)return null;if(`usdPerPt`in e){let t=e.stretches;return`≈ pts: ${_t(e.usdPerPt)} per weekly point, measured over ${t} ${t===1?`stretch`:`stretches`} of readings since the reset (${j}).`}return Sn(e)}function Rve(e,t,n){let r=L$(t-e.fromHour,`week`,`the first column`),i=new Date(t),a=$$[i.getDay()],o=`${String(i.getHours()).padStart(2,`0`)}:${String(i.getMinutes()).padStart(2,`0`)}`,s=Math.max(0,Math.floor((n-t)/Ct));return`Since the weekly reset, ${a} ${o} — ${s>=24?`${Math.floor(s/24)} d ${s%24} h`:`${s} h`} ago${r?`: ${r}`:``}.`}function i1(e,t){if(Number.isFinite(e)&&e>0)return _t(e);let n=Ni(t);return n?`${n} tokens`:null}var a1=e=>Number.isFinite(e)&&e>0;function zve(e,t){return t!=null&&Number.isFinite(t)&&e.firstAt!=null&&e.firstAt>=et(t)}function o1(e,t){let n=t.restText(null);return n?`Lists ${e} of ${t.total} ${t.total===1?`session`:`sessions`} — ${n}, counted in every total above.`:null}function s1(e){return e>0?`${e} more ${e===1?`session is`:`sessions are`} in this row’s total, not listed.`:null}function c1(e,t,n){let r=e+(t>0?t:0);return`${r} ${r===1?`session`:`sessions`} · ${L(n)} tokens`}function l1(e,t){return t>0&&Number.isFinite(e)?Math.round(e/t*100):null}var Bve={top:10,right:34,bottom:20,left:46};function u1(e){return e===-1?`var(--muted)`:QE[e]??`var(--muted)`}function Vve({buckets:e,slots:t,samples:n,everyMs:r,from:i,now:a,width:o,picked:s,onPick:c,limitAxis:l=!0,height:u=170}){let d=(0,V.useRef)(null),f=(0,V.useRef)(null),p=(0,V.useRef)(null),m=Math.max(i,new Date(a).setMinutes(0,0,0)),h=Ct/2,g=NE({width:o,height:u,pad:Bve,points:[{t:i+h,v:0,day:``},...e.map(e=>({t:e.t+h,v:e.usd,day:e.hour})),{t:m+h,v:0,day:``}].sort((e,t)=>e.t-t.t),stepMs:Ct}),_=Math.max(1,Math.min(10,g.slot*(g.slot>4?.75:.9))),v=e=>g.y+g.h-Math.max(0,Math.min(100,e))/100*g.h,y=i,b=m+Ct,x=n.filter(e=>e.t>=y&&e.t<=b),S=di(x,`week`,Math.max(27e5,r*3)),C=e=>e.pts.map((e,t)=>`${t?`L`:`M`}${g.px(e.t).toFixed(1)},${v(e.v).toFixed(1)}`).join(``),w=s?e.find(e=>e.hour===s)??null:null,T=t=>{let n=d.current?.getBoundingClientRect();if(!n?.width||!e.length)return null;let r=(t.clientX-n.left)/n.width*o,i=g.t0+(r-g.x)/g.w*(g.t1-g.t0),a=null;for(let t of e)(!a||Math.abs(t.t+h-i)<Math.abs(a.t+h-i))&&(a=t);return a&&Math.abs(a.t+h-i)<=Math.max(36e5,(g.t1-g.t0)/g.w*6)?a.hour:null};return(0,J.jsxs)(`svg`,{ref:d,className:`ctx-chart`,width:o,height:u,viewBox:`0 0 ${o} ${u}`,role:`img`,"aria-label":l?`dollars per hour since the weekly reset, stacked by repo, with the weekly limit percentage`:`dollars per hour, stacked by repo`,onPointerDown:e=>{f.current=s;let t=T(e);p.current=t,t&&c(t===s?null:t)},onPointerMove:e=>{if(!e.buttons)return;let t=T(e);t&&t!==s&&t!==p.current&&(p.current=null,c(t))},onPointerCancel:()=>c(f.current),children:[g.yTicks.map(e=>(0,J.jsx)(`line`,{x1:g.x,x2:g.x+g.w,y1:g.py(e),y2:g.py(e),stroke:`var(--line)`,strokeWidth:1},e)),e.map(e=>{let n=g.px(e.t+h)-_/2;return(0,J.jsxs)(`g`,{children:[jve(e.byRepo,t).map(e=>{let t=g.py(e.v1);return(0,J.jsx)(`rect`,{x:n,y:t,width:_,height:Math.max(e.usd>0?.75:0,g.py(e.v0)-t),fill:u1(e.slot)},e.key)}),!e.byRepo.some(e=>e.cost?.total>0)&&e.usd>0&&(0,J.jsx)(`rect`,{x:n,y:g.py(e.usd),width:_,height:Math.max(.75,g.py(0)-g.py(e.usd)),fill:`var(--muted)`})]},e.hour)}),w&&(0,J.jsx)(`rect`,{x:g.px(w.t+h)-_/2-2,y:g.y,width:_+4,height:g.h,rx:2,fill:`none`,stroke:`var(--fg)`,strokeOpacity:.7,strokeWidth:1.25,pointerEvents:`none`}),S.map((e,t)=>(0,J.jsxs)(`g`,{pointerEvents:`none`,children:[e.rolled&&e.pts.length>0&&(0,J.jsx)(`line`,{x1:g.px(e.pts[0].t),x2:g.px(e.pts[0].t),y1:g.y,y2:g.y+g.h,stroke:`var(--fg)`,strokeOpacity:.3,strokeWidth:1,strokeDasharray:`3 3`}),(0,J.jsx)(`path`,{d:C(e),fill:`none`,stroke:`var(--fg)`,strokeOpacity:.75,strokeWidth:1.5,strokeLinejoin:`round`,strokeLinecap:`round`}),e.pts.length===1&&(0,J.jsx)(`circle`,{cx:g.px(e.pts[0].t),cy:v(e.pts[0].v),r:2,fill:`var(--fg)`})]},t)),g.yTicks.map(e=>(0,J.jsx)(`text`,{className:`ctx-tick`,x:g.x-6,y:g.py(e)+3.5,textAnchor:`end`,children:Nt(e)},`t${e}`)),l&&[0,50,100].map(e=>(0,J.jsxs)(`g`,{children:[(0,J.jsx)(`line`,{x1:g.x+g.w,x2:g.x+g.w+4,y1:v(e),y2:v(e),stroke:`var(--muted)`,strokeWidth:1}),(0,J.jsxs)(`text`,{className:`ctx-tick`,x:g.x+g.w+6,y:v(e)+3.5,textAnchor:`start`,children:[e,`%`]})]},`r${e}`)),HE(g).map((e,t)=>(0,J.jsx)(`text`,{className:`ctx-tick`,x:e.x,y:u-6,textAnchor:e.anchor,children:e.label},t))]})}var d1=8,f1=8,Hve=110;function Uve({doc:e,res:t,openedAt:n,samples:r,everyMs:i,cal:a,span:o,compact:s=!1,nameOf:c,onExplain:l,isLive:u,onOpenConvo:d}){let[f,p]=(0,V.useState)(null),[m,h]=(0,V.useState)(`repo`),[g,_]=(0,V.useState)(()=>new Set),[v,y]=rD(),b=(0,V.useMemo)(()=>e?Te(e):null,[e]),x=f&&b?.buckets.some(e=>e.hour===f)?f:null,S=(0,V.useMemo)(()=>b?b.convosIn(x):[],[b,x]),C=(0,V.useMemo)(()=>e?vn(e.convos,e.rest):[],[e]),w=(0,V.useRef)(null),T=(0,V.useMemo)(()=>{let e=Ave(C.map(e=>e.repo),w.current);return w.current=e,e},[C]),E=x?void 0:e?.rest,D=(0,V.useMemo)(()=>m===`repo`?vn(S,E).map(e=>({key:`r:${e.repo}`,label:e.label,usd:e.cost.total,tok:ui(e.totals),agentUsd:e.agentCost.total,convos:e.convos,more:e.more,facts:c1(e.convos.length,e.more,ui(e.totals))})):$t(S,E).map(e=>({key:`l:${e.key}`,label:e.label,usd:e.cost.total,tok:ui(e.totals),agentUsd:e.agentCost.total,convos:e.convos,more:e.more,facts:`${Lt[e.kind]??e.kind} · ${c1(e.convos.length,e.more,ui(e.totals))}`})),[m,S,E]),O=e=>_(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),k=Date.now(),A=!o||!!e?.convos.some(e=>e.launch)||!!e?.rest?.some(e=>e.launch),j=b&&b.total>0&&A&&(!s||g.has(`*list`)||x)?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Y,{className:m===`repo`?`active`:void 0,onClick:()=>h(`repo`),children:`by repo`}),(0,J.jsx)(Y,{className:m===`launch`?`active`:void 0,onClick:()=>h(`launch`),children:`by launch`})]}):null;if(n==null)return(0,J.jsx)(O$,{title:`Where the week went`,chips:null,children:(0,J.jsx)(`div`,{className:`empty ts-caveat`,children:`No weekly reset instant on hand yet — re-read the limits above.`})});if(!e)return(0,J.jsx)(O$,{title:`Where the week went`,chips:null,children:(0,J.jsx)(`div`,{className:`empty ts-caveat`,children:r1(t,`week`)})});let M=e.cost.total,N=ui(e.totals),P=Ne(M,a),F=l1(e.agentCost.total,M),ee=x?b.buckets.find(e=>e.hour===x)??null:null,te=Mve(C,T),ne=g.has(`*all`)?D:D.slice(0,d1),re=Lve(a);return(0,J.jsxs)(O$,{title:`Where the week went`,chips:j,caption:(0,J.jsxs)(J.Fragment,{children:[o?o.caption:Rve(e,n,k),` `,(0,J.jsxs)(k$,{children:[o?o.tag:`since reset`,` · in `,a1(e.cost.total)?`money`:`tokens`]}),` `,s?null:(0,J.jsxs)(J.Fragment,{children:[`The `,(0,J.jsx)(`em`,{children:`count in`}),` switch does not reach this box.`]})]}),children:[!s&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`ts-hero-wrap`,children:[(0,J.jsx)(`div`,{className:`ts-hero`,children:a1(M)?_t(M):L(N)}),(0,J.jsxs)(`div`,{className:`ts-hero-sub`,children:[a1(M)?(0,J.jsxs)(J.Fragment,{children:[`at list prices`,P?(0,J.jsxs)(J.Fragment,{children:[` · `,P]}):null,F==null?null:(0,J.jsxs)(J.Fragment,{children:[` · `,F,`% subagents`]}),` · `,L(N),` tokens`]}):(0,J.jsx)(J.Fragment,{children:`tokens · no list price covers them`}),` `,`across `,b.total,` `,b.total===1?`session`:`sessions`]})]}),(0,J.jsx)(Z$,{totals:e.totals,cost:e.cost,money:a1(M)}),ui(e.unpriced)>0&&(0,J.jsxs)(`div`,{className:`empty ts-caveat`,children:[L(ui(e.unpriced)),` tokens ran on a model with no published rate and are `,(0,J.jsx)(`b`,{children:`not`}),` in this figure.`]})]}),b.total?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`ts-week-chart`,ref:y,children:v>0&&b&&(0,J.jsx)(Vve,{buckets:b.buckets,slots:T,samples:r,everyMs:i,from:e.fromHour,now:k,width:v,picked:x,onPick:p,limitAxis:!o||r.length>0,height:s?Hve:void 0})}),(0,J.jsxs)(`div`,{className:`ctx-legend ctx-legend-stack`,children:[te.map(e=>(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`svg`,{width:`10`,height:`10`,"aria-hidden":!0,children:(0,J.jsx)(`rect`,{x:`0`,y:`1`,width:`10`,height:`8`,rx:`2`,fill:u1(e.slot)})}),e.label]},e.key)),(!o||r.length>0)&&(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`svg`,{width:`14`,height:`10`,"aria-hidden":!0,children:(0,J.jsx)(`line`,{x1:`0`,x2:`14`,y1:`5`,y2:`5`,stroke:`var(--fg)`,strokeOpacity:.75,strokeWidth:1.5})}),`weekly limit, % (right axis)`]})]}),(0,J.jsx)(`div`,{className:`ctx-readout`,children:ee?Nve(ee):`Tap a column to list only the sessions that ran in that hour.`}),!s&&(0,J.jsxs)(`div`,{className:`empty ts-caveat`,children:[`An hour is a whole column, so the first one starts on the hour nearest `,o?`the start of the span`:`the reset`,` (said above); an hour nothing ran in is a gap.`]}),x&&(0,J.jsxs)(`div`,{className:`ts-filter ts-week-filter`,children:[(0,J.jsx)(`span`,{children:b.filterText(x)}),(0,J.jsxs)(Y,{onClick:()=>p(null),children:[(0,J.jsx)(B,{size:13}),` clear`]})]}),s&&!x&&!g.has(`*list`)?(0,J.jsxs)(Y,{className:`ts-convos-more`,onClick:()=>O(`*list`),children:[(0,J.jsx)(Nc,{size:13}),` list the week by `,m===`repo`?`repo`:`launch`,` (`,D.length,`)`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsxs)(`span`,{children:[m===`repo`?`By repo`:`By launch`,` `,(0,J.jsxs)(k$,{children:[x?`sessions that ran ${t1(ee.t)} · their week`:o?o.tag:`since reset`,` · in `,a1(M)?`money`:`tokens`]})]})}),(0,J.jsxs)(`div`,{className:`ts-convos`,children:[ne.map(e=>(0,J.jsx)(Wve,{g:e,total:M,totalTok:N,cal:a,open:g.has(e.key),allSessions:g.has(`${e.key}#all`),onToggle:()=>O(e.key),onAll:()=>O(`${e.key}#all`),nameOf:c,onExplain:l,isLive:u,onOpenConvo:d},e.key)),D.length>d1&&(0,J.jsx)(Y,{className:`ts-convos-more`,onClick:()=>O(`*all`),children:g.has(`*all`)?`show the top ${d1}`:`show all ${D.length}`}),x?b.restText(x)&&(0,J.jsxs)(`div`,{className:`empty ts-caveat`,children:[b.restText(x),` — the host folds the cheapest sessions by repo and launch, without their hours.`]}):o1(e.convos.length,b)&&(0,J.jsx)(`div`,{className:`empty ts-caveat`,children:o1(e.convos.length,b)}),s&&!x&&(0,J.jsxs)(Y,{className:`ts-convos-more`,onClick:()=>O(`*list`),children:[(0,J.jsx)(mc,{size:13}),` fold the list`]})]})]})]}):(0,J.jsxs)(`div`,{className:`empty ts-caveat`,children:[`Nothing has run on this desktop `,o?`in the ${o.tag}`:`since the weekly reset`,`.`]}),re&&(!s||g.has(`*list`)||x)&&(0,J.jsx)(`div`,{className:`empty ts-caveat`,children:re}),(0,J.jsxs)(`details`,{className:`hint-more ctx-method`,children:[(0,J.jsx)(`summary`,{children:`how the week is read`}),s&&(0,J.jsxs)(`p`,{children:[`An hour is a whole column, so the first one starts on the hour nearest `,o?`the start of the span`:`the reset`,`; an hour nothing ran in is a gap.`]}),(0,J.jsxs)(`p`,{children:[`The desktop folds every conversation log with a turn `,o?`in the ${o.tag}`:`since the weekly reset`,` — closed sessions included — and names each from the sessions it still remembers; one nobody named is its repo and the first characters of its id. A session counts its subagents in, and is grouped by what opened it: a fan-out run, a backlog item, a schedule, or your own hand.`]}),!o&&(0,J.jsx)(`p`,{children:`Points are dollars divided by what one weekly point cost while the readings above climbed — the ledger’s spend over each run of readings without a reset, against how far the weekly figure rose. It is refused when the runs disagree, and when it disagrees with the per-reading rate (this week’s spend over the percent read). That check leaves out work handed to peer desktops, which the per-prompt week share counts.`})]})]})}function Wve({g:e,total:t,totalTok:n,cal:r,open:i,allSessions:a,onToggle:o,onAll:s,nameOf:c,onExplain:l,isLive:u,onOpenConvo:d}){let f=a1(t)?e.usd/t:n>0?e.tok/n:0,p=i1(e.usd,e.tok),m=Ne(e.usd,r),h=l1(e.agentUsd,e.usd),g=a?e.convos:e.convos.slice(0,f1);return(0,J.jsxs)(`div`,{className:`ts-convo`,children:[(0,J.jsxs)(`div`,{className:`ts-week-rowhead`,role:`button`,tabIndex:0,"aria-expanded":i,onClick:o,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),o())},children:[(0,J.jsxs)(`div`,{className:`ts-barhead`,children:[(0,J.jsx)(`span`,{className:`ts-barlabel`,children:e.label}),(0,J.jsxs)(`span`,{className:`ts-barval`,children:[p,(0,J.jsxs)(`em`,{children:[f<.01?`<1`:Math.round(f*100),`%`]}),i?(0,J.jsx)(mc,{size:14,className:`ts-week-chev`}):(0,J.jsx)(Nc,{size:14,className:`ts-week-chev`})]})]}),(0,J.jsx)(`div`,{className:`ts-bartrack`,children:(0,J.jsx)(`span`,{className:`ts-barfill`,style:{width:`${Math.max(1,f*100)}%`}})}),(0,J.jsxs)(`div`,{className:`ts-convo-facts`,children:[e.facts,m?(0,J.jsxs)(J.Fragment,{children:[` · `,m]}):null,h==null?null:(0,J.jsxs)(J.Fragment,{children:[` · `,h,`% subagents`]})]})]}),i&&(0,J.jsxs)(`div`,{className:`ts-week-sessions`,children:[g.map(e=>(0,J.jsx)(Gve,{c:e,cal:r,nameOf:c,onExplain:l,isLive:u,onOpenConvo:d},e.id)),e.convos.length>f1&&(0,J.jsx)(Y,{className:`ts-convos-more`,onClick:s,children:a?`show the top ${f1}`:`show all ${e.convos.length} sessions`}),s1(e.more)&&(0,J.jsx)(`div`,{className:`empty ts-caveat`,children:s1(e.more)})]})]})}function Gve({c:e,cal:t,nameOf:n,onExplain:r,isLive:i,onOpenConvo:a}){let o=e.title??n?.(e.id)??`${e.label} · ${e.id.slice(0,8)}`,s=Ne(e.cost.total,t),c=l1(e.agentCost.total,e.cost.total),l=_e(e),u=e.live||!!i?.(e.id);return(0,J.jsxs)(`div`,{className:`ts-week-session`,children:[(0,J.jsxs)(`div`,{className:`ts-barhead`,children:[(0,J.jsx)(`span`,{className:`ts-barlabel`,children:o}),(0,J.jsxs)(`span`,{className:`ts-barval`,children:[i1(e.cost.total,ui(e.totals)),s?(0,J.jsx)(`em`,{children:s}):null]})]}),(0,J.jsxs)(`div`,{className:`ts-convo-facts`,children:[e.label,` · `,L(ui(e.totals)),` tokens`,e.agents>0&&(0,J.jsxs)(J.Fragment,{children:[` · `,e.agents,` subagents`,c==null?``:` (${c}% of it)`]}),e.peakCtx?(0,J.jsxs)(J.Fragment,{children:[` · peak `,L(e.peakCtx),` context`]}):null,u&&(0,J.jsxs)(J.Fragment,{children:[` · `,(0,J.jsx)(qw,{className:`ts-week-live`,children:`live`})]})]}),l&&(0,J.jsx)(`div`,{className:`ts-convo-facts`,children:l}),r&&(0,J.jsxs)(`div`,{className:`ts-convo-acts`,children:[(0,J.jsxs)(Y,{onClick:()=>r(e,o),children:[(0,J.jsx)(Cs,{size:13}),` explain the cost`]}),a&&i?.(e.id)&&(0,J.jsxs)(Y,{onClick:()=>a(e.id),children:[(0,J.jsx)(qs,{size:13}),` context & cost`]})]})]})}var p1=8;function Kve({state:e,cap:t,doc:n,res:r,refusal:i,now:a}){let[o,s]=(0,V.useState)(`repo`),[c,l]=(0,V.useState)(!1),u=Tx(e.period),d=(0,V.useMemo)(()=>n?vn(n.convos,n.rest).map(e=>({key:e.repo,label:e.label,usd:e.cost.total,tok:ui(e.totals),facts:c1(e.convos.length,e.more,ui(e.totals))})):[],[n]),f=(0,V.useMemo)(()=>n?Mx(n.convos,n.rest).map(e=>({key:e.model,label:e.label,usd:e.usd,tok:e.tokens,facts:`${L(e.tokens)} tokens`})):[],[n]);if(i)return(0,J.jsx)(O$,{title:u,chips:null,children:(0,J.jsx)(`div`,{className:`empty ts-caveat`,children:i})});if(!n)return(0,J.jsx)(O$,{title:u,chips:null,children:(0,J.jsx)(`div`,{className:`empty ts-caveat`,children:r1(r,`window`)})});let p=n.cost.total,m=ui(n.totals),h=o===`repo`?d:f,g=c?h:h.slice(0,p1),_=Ax({...e,spentUsd:p},t,a),v=n.convosTotal??n.convos.length;return(0,J.jsxs)(O$,{title:u,chips:p>0||m>0?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Y,{className:o===`repo`?`active`:void 0,onClick:()=>s(`repo`),children:`by repo`}),(0,J.jsx)(Y,{className:o===`model`?`active`:void 0,onClick:()=>s(`model`),children:`by model`})]}):null,caption:(0,J.jsxs)(J.Fragment,{children:[`This desktop only, at list price — not your invoice. `,(0,J.jsxs)(k$,{children:[e.resetAt==null?`trailing`:`this period so far`,` · in `,a1(p)?`money`:`tokens`]})]}),children:[(0,J.jsxs)(`div`,{className:`ts-hero-wrap`,children:[(0,J.jsx)(`div`,{className:`ts-hero`,children:a1(p)?_t(p):L(m)}),(0,J.jsxs)(`div`,{className:`ts-hero-sub`,children:[t!=null&&(0,J.jsxs)(J.Fragment,{children:[`of a `,vx(t),` cap · `]}),_.map(e=>(0,J.jsxs)(`span`,{children:[e,` · `]},e)),L(m),` tokens across `,v,` `,v===1?`session`:`sessions`]})]}),(0,J.jsx)(Z$,{totals:n.totals,cost:n.cost,money:a1(p)}),ui(n.unpriced)>0&&(0,J.jsxs)(`div`,{className:`empty ts-caveat`,children:[L(ui(n.unpriced)),` tokens ran on a model with no published rate and are `,(0,J.jsx)(`b`,{children:`not`}),` in this figure.`]}),h.length?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsx)(`span`,{children:o===`repo`?`By repo`:`By model`})}),(0,J.jsxs)(`div`,{className:`ts-convos`,children:[g.map(e=>{let t=a1(p)?e.usd/p:m>0?e.tok/m:0;return(0,J.jsxs)(`div`,{className:`ts-convo`,children:[(0,J.jsxs)(`div`,{className:`ts-barhead`,children:[(0,J.jsx)(`span`,{className:`ts-barlabel`,children:e.label}),(0,J.jsxs)(`span`,{className:`ts-barval`,children:[i1(e.usd,e.tok),(0,J.jsxs)(`em`,{children:[t<.01?`<1`:Math.round(t*100),`%`]})]})]}),(0,J.jsx)(`div`,{className:`ts-bartrack`,children:(0,J.jsx)(`span`,{className:`ts-barfill`,style:{width:`${Math.max(1,t*100)}%`}})}),(0,J.jsx)(`div`,{className:`ts-convo-facts`,children:e.facts})]},e.key)}),h.length>p1&&(0,J.jsx)(Y,{className:`ts-convos-more`,onClick:()=>l(e=>!e),children:c?`show the top ${p1}`:`show all ${h.length}`})]})]}):(0,J.jsx)(`div`,{className:`empty ts-caveat`,children:`Nothing has run on this desktop in this period.`})]})}var m1=88,h1=36,qve=78;function g1({samples:e,which:t,reset:n,pct:r,everyMs:i,width:a,hours:o=24,name:s}){let[c,l]=rD(),u=a??c,d=(0,V.useRef)(null),[f,p]=(0,V.useState)(null),m=(0,V.useRef)(null),h=Math.max(27e5,i*3),g=Math.floor(Date.now()/6e4)*6e4,_=Voe(t,n,g,o),v=(0,V.useMemo)(()=>e.filter(e=>e.t>=_.t0&&e.t<=Math.max(_.t1,g+6e4)),[e,_.t0,_.t1,g]),y=(0,V.useMemo)(()=>di(v,t,h),[v,t,h]),b=(0,V.useMemo)(()=>Roe(y),[y]),x=zoe(r,b,n,Date.now()),S=y.flatMap(e=>e.pts);if(S.length<2)return(0,J.jsx)(`div`,{className:`ts-spark-none`,children:v.length?`Only one reading kept so far, so there is no line to draw yet.`:`No earlier readings kept yet — the history fills in as the screen is read.`});let C=Date.now(),w=Math.max(_.t1,S[S.length-1].t),T=_.t0,E=w-C>6e4?C:null,D=_.isWindow?`This week’s window, since ${q$(T)}`:t===`week`?`Last 7 days`:o>24&&o%24==0?`Last ${o/24} days`:`Last ${o}h`,O=Math.max(1,u-h1),k=e=>h1+(e-T)/Math.max(1,w-T)*O,A=e=>82-Math.max(0,Math.min(100,e))/100*76,j=e=>e.pts.map((e,t)=>`${t?`L`:`M`}${k(e.t).toFixed(1)},${A(e.v).toFixed(1)}`).join(``),M=e=>{if(e.pts.length<2)return``;let t=A(0).toFixed(1);return`M${k(e.pts[0].t).toFixed(1)},${t}L${j(e).slice(1)}L${k(e.pts[e.pts.length-1].t).toFixed(1)},${t}Z`},N=Boe(T,w,Math.max(2,Math.floor(O/qve))),P=Uoe(y),F=f==null?null:S.find(e=>e.t===f)??null,ee=e=>{let t=d.current?.getBoundingClientRect();if(!t?.width)return null;let n=(e.clientX-t.left)/t.width*u-h1;return T+Math.max(0,Math.min(O,n))/O*(w-T)},te=(e,t=!1)=>{let n=ee(e);if(n==null)return;let r=Hoe(y,n);r&&p(t&&r.t===f?null:r.t)};return(0,J.jsxs)(`div`,{className:`ts-spark`,ref:l,children:[u>0&&(0,J.jsxs)(`svg`,{ref:d,className:`ts-spark-svg`,width:u,height:103,viewBox:`0 0 ${u} 103`,role:`img`,"aria-label":`${s??(t===`session`?`five-hour`:`weekly`)} window, ${D}, ${S.length} readings`,onPointerDown:e=>{m.current=f,te(e,!0)},onPointerMove:e=>{(e.buttons||e.pointerType!==`mouse`)&&te(e)},onPointerLeave:e=>{e.pointerType===`mouse`&&p(null)},onPointerCancel:()=>p(m.current),children:[(0,J.jsx)(`rect`,{x:h1,y:0,width:O,height:m1,rx:4,fill:`var(--fg)`,fillOpacity:.05}),[0,50,100].map(e=>(0,J.jsxs)(`g`,{children:[(0,J.jsx)(`line`,{x1:h1,x2:u,y1:A(e),y2:A(e),stroke:`var(--line)`,strokeWidth:1,strokeOpacity:e===50?.55:1}),(0,J.jsxs)(`text`,{className:`ts-spark-ylab`,x:31,y:A(e)+3.5,textAnchor:`end`,children:[e,`%`]})]},e)),N.map((e,t)=>(0,J.jsx)(`text`,{className:`ts-spark-tick`,x:k(e),y:99,textAnchor:t===0?`start`:t===N.length-1?`end`:`middle`,children:wve(e)},e)),E!=null&&(0,J.jsxs)(`g`,{pointerEvents:`none`,children:[(0,J.jsx)(`line`,{x1:k(E),x2:k(E),y1:0,y2:m1,stroke:`var(--fg)`,strokeOpacity:.45,strokeWidth:1}),(0,J.jsx)(`text`,{className:`ts-spark-tick`,x:k(E)-3,y:10,textAnchor:`end`,children:`now`})]}),y.map((e,t)=>(0,J.jsxs)(`g`,{children:[e.rolled&&e.pts.length>0&&(0,J.jsx)(`line`,{x1:k(e.pts[0].t),x2:k(e.pts[0].t),y1:2,y2:86,stroke:`var(--fg)`,strokeOpacity:.3,strokeWidth:1,strokeDasharray:`3 3`}),(0,J.jsx)(`path`,{d:M(e),fill:eD,fillOpacity:.16}),(0,J.jsx)(`path`,{d:j(e),fill:`none`,stroke:eD,strokeWidth:1.75,strokeLinejoin:`round`,strokeLinecap:`round`}),e.pts.length===1&&(0,J.jsx)(`circle`,{cx:k(e.pts[0].t),cy:A(e.pts[0].v),r:2.5,fill:eD})]},t)),(0,J.jsx)(`circle`,{cx:k(S[S.length-1].t),cy:A(S[S.length-1].v),r:3,fill:eD,stroke:`var(--panel)`,strokeWidth:1.5}),F&&(0,J.jsxs)(`g`,{pointerEvents:`none`,children:[(0,J.jsx)(`line`,{x1:k(F.t),x2:k(F.t),y1:0,y2:m1,stroke:`var(--fg)`,strokeOpacity:.35,strokeWidth:1}),(0,J.jsx)(`circle`,{cx:k(F.t),cy:A(F.v),r:4.5,fill:`var(--panel)`,stroke:`var(--fg)`,strokeOpacity:.7,strokeWidth:2})]})]}),(0,J.jsx)(`div`,{className:`ts-spark-scrub`,children:F?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`b`,{children:q$(F.t)}),` · `,(0,J.jsxs)(`b`,{children:[F.v,`% used`]}),F.r?(0,J.jsxs)(J.Fragment,{children:[` · in the window that reset `,q$(F.r)]}):null]}):(0,J.jsx)(iD,{})}),(0,J.jsxs)(`div`,{className:`ts-spark-sub`,children:[D,`, `,S.length,` readings`,b!=null&&(0,J.jsxs)(J.Fragment,{children:[` · `,(0,J.jsxs)(`b`,{children:[`+`,b.toFixed(+(b<10)),`%/h`]}),` this window`]}),x?.kind===`full`&&(0,J.jsxs)(J.Fragment,{children:[` · `,(0,J.jsxs)(`b`,{children:[`full around `,q$(x.at)]}),` — in `,zp(x.at),`, at that rate`]}),x?.kind===`lasts`&&(0,J.jsxs)(J.Fragment,{children:[` · on track for `,(0,J.jsxs)(`b`,{children:[`~`,Math.round(x.pctAtReset),`%`]}),` by the reset at that rate`]}),P?.lead&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`br`,{}),P.lead]}),P?.more&&(0,J.jsxs)(J.Fragment,{children:[` `,(0,J.jsx)(tT,{of:`the dashed rule`,label:`dashed rule`,children:P.more})]})]})]})}function Jve({usage:e,onRefresh:t,history:n,cuts:r,scope:i,onScope:a,compact:o=!1}){(0,V.useEffect)(()=>{t&&(e?.checkedAt&&Date.now()-e.checkedAt<48e4||t(!0))},[]);let s=n,c=s?.samples??[],l=[...new Set([...r?.entries()??[]].filter(([,e])=>!F$(e)).map(([e,t])=>uve(P$.find(t=>t.id===e),t)))],u=[{label:`5-hour session`,which:`session`,pct:e?.sessionPct??null,reset:e?.sessionResetAt??null,note:`A rolling five-hour window. This is the one you can sit out.`},{label:`Week (all models)`,which:`week`,pct:e?.weeklyPct??null,reset:e?.weeklyResetAt??null,note:`The account-wide week, across every model. This is the one that strands you for days.`}];return(0,J.jsxs)(`div`,{className:`ts-lims`,children:[(0,J.jsxs)(`div`,{className:`section section-head`,children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(ms,{size:12,style:{verticalAlign:`-2px`,marginRight:4}}),`Right now`]}),t&&(0,J.jsxs)(Y,{onClick:()=>t(),title:`re-read the CLI’s /usage screen (spawns a short claude probe)`,children:[(0,J.jsx)(_c,{size:14}),` re-read`]})]}),u.map(e=>(0,J.jsxs)(`div`,{className:`ts-lim`,children:[(0,J.jsxs)(`div`,{className:`ts-barhead`,children:[(0,J.jsx)(`span`,{className:`ts-barlabel`,children:e.label}),(0,J.jsx)(`span`,{className:`ts-barval${e.pct!=null&&e.pct>=80?` hot`:``}`,children:e.pct==null?`—`:`${e.pct}% used`})]}),(0,J.jsx)(`div`,{className:`ts-bartrack`,children:(0,J.jsx)(`span`,{className:`ts-barfill${e.pct!=null&&e.pct>=80?` hot`:``}`,style:{width:`${e.pct??0}%`}})}),(0,J.jsx)(g1,{samples:c,which:e.which,reset:e.reset,pct:e.pct,everyMs:s?.everyMs??0}),(0,J.jsx)(Yve,{cut:r?.get(e.which),scope:i,onScope:a}),(0,J.jsxs)(`div`,{className:`ts-lim-sub`,children:[e.reset?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(os,{size:11,style:{verticalAlign:`-1px`}}),` Resets `,q$(e.reset),` — in `,zp(e.reset),`. `]}):e.pct==null?null:(0,J.jsx)(J.Fragment,{children:`The screen did not name a reset time for this window. `}),!o&&e.note]})]},e.label)),(0,J.jsxs)(`div`,{className:`empty ts-foot`,children:[e?.remembered?(0,J.jsxs)(J.Fragment,{children:[`Kept from before this desktop’s daemon last restarted, read `,Tp(e.checkedAt),` — nothing has re-read the CLI’s `,(0,J.jsx)(`code`,{children:`/usage`}),` screen since, so both windows can only have filled further. Tap `,(0,J.jsx)(`em`,{children:`re-read`}),` for the live figure. `]}):e?.checkedAt?(0,J.jsxs)(J.Fragment,{children:[`Read off the CLI’s own `,(0,J.jsx)(`code`,{children:`/usage`}),` screen `,Tp(e.checkedAt),e.ok?``:`, which could not be parsed`,`. `]}):(0,J.jsxs)(J.Fragment,{children:[`The `,(0,J.jsx)(`code`,{children:`/usage`}),` screen has not been read yet on this desktop, so these two windows are unknown. `]}),!o&&`The history below comes from the conversation logs, not from this.`,l.map(e=>(0,J.jsxs)(`span`,{children:[` `,e]},e))]})]})}function Yve({cut:e,scope:t,onScope:n}){if(!e||!F$(e))return null;let r=ui(e.totals);if(!r)return(0,J.jsx)(`div`,{className:`ts-lim-used none`,children:`Nothing counted in this window yet.`});let i=t===e.id,a=e.models[0],o=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`b`,{children:L(r)}),` tokens · `,(0,J.jsx)(`b`,{children:_t(e.cost.total)}),` at list prices`,e.modelSplit&&a?(0,J.jsxs)(J.Fragment,{children:[` · `,e.models.length===1?(0,J.jsxs)(J.Fragment,{children:[`all on `,J$(a.label)]}):(0,J.jsxs)(J.Fragment,{children:[_n(ui(a)/r),` `,J$(a.label),`, `,e.models.length-1,` more`]})]}):null]});return n?(0,J.jsx)(`button`,{type:`button`,className:`ts-lim-used${i?` active`:``}`,onClick:()=>n(i?`all`:e.id),title:i?`back to the all-time readouts`:`take the readouts below down to this window`,children:o}):(0,J.jsx)(`div`,{className:`ts-lim-used`,children:o})}function _1({rows:e,name:t=e=>e}){let n=e[0]?.n??0;return(0,J.jsx)(`div`,{className:`ts-bars`,children:e.map(e=>(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`div`,{className:`ts-barhead`,children:[(0,J.jsx)(`span`,{className:`ts-barlabel`,children:t(e.kind)}),(0,J.jsxs)(`span`,{className:`ts-barval`,children:[L(e.n),e.share!=null&&(0,J.jsx)(`em`,{children:_n(e.share)})]})]}),(0,J.jsx)(`div`,{className:`ts-bartrack`,children:(0,J.jsx)(`span`,{className:`ts-barfill`,style:{width:`${Math.max(1,n>0?e.n/n*100:0)}%`}})})]},e.kind))})}function v1({label:e,value:t,subs:n,title:r}){return(0,J.jsxs)(`div`,{className:`row ctx-row ts-numrow`,title:r,children:[(0,J.jsx)(Zw,{children:e}),(0,J.jsx)(`span`,{className:`ts-num`,children:t}),n.length>0&&(0,J.jsx)(`span`,{className:`row-meta`,children:n.map(e=>(0,J.jsx)(Q,{children:e},e))})]})}function y1({pts:e,width:t,kind:n,slots:r=!1,maxColW:i,money:a=!1,trend:o,stepMs:s,label:c}){let l=NE({width:t,height:170,pad:H$,points:e,stepMs:s}),u=!!s&&s<864e5,[d,f]=(0,V.useState)(null),p=(0,V.useRef)(null),m=(0,V.useCallback)(n=>{let r=p.current?.getBoundingClientRect();r&&f(FE(l,e,(n.clientX-r.left)/r.width*t))},[l,e,t]);if(!e.length)return(0,J.jsx)(`div`,{className:`empty`,children:u?`No hours in this window.`:`No days in this window.`});let h=n===`columns`?Eoe(l,e,i):[],g=Math.max(1,Math.min((i??14)+8,l.slot-2));return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`svg`,{ref:p,className:`ctx-chart`,width:t,height:170,viewBox:`0 0 ${t} 170`,onPointerDown:m,onPointerMove:m,onPointerLeave:()=>f(null),onPointerCancel:()=>f(null),role:`img`,"aria-label":c??(n===`area`?`cumulative tokens over time`:`tokens per day`),children:[l.yTicks.map(e=>(0,J.jsx)(`line`,{x1:l.x,x2:l.x+l.w,y1:l.py(e),y2:l.py(e),stroke:`var(--line)`,strokeWidth:1},e)),r&&n===`columns`&&e.map(e=>(0,J.jsx)(`rect`,{x:l.px(e.t)-g/2,y:l.y,width:g,height:l.h,rx:3,fill:`var(--fg)`,fillOpacity:.045},`s${e.day}`)),n===`area`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`path`,{d:Toe(l,e),fill:eD,fillOpacity:.14}),(0,J.jsx)(`path`,{d:PE(l,e),fill:`none`,stroke:eD,strokeWidth:2,strokeLinejoin:`round`,strokeLinecap:`round`}),e.length===1&&(0,J.jsx)(`circle`,{cx:l.px(e[0].t),cy:l.py(e[0].v),r:4,fill:eD})]}):h.map((e,t)=>(0,J.jsx)(`rect`,{x:e.x,y:e.y,width:e.w,height:e.h,rx:Math.min(2,e.w/2),fill:eD,fillOpacity:d&&d.day===e.point.day?1:.78},t)),o&&o.length>1&&(0,J.jsx)(`path`,{d:PE(l,o),fill:`none`,stroke:`var(--fg)`,strokeOpacity:.5,strokeWidth:1.5,strokeDasharray:`4 3`,strokeLinejoin:`round`,strokeLinecap:`round`}),l.yTicks.map(e=>(0,J.jsx)(`text`,{className:`ctx-tick`,x:l.x-6,y:l.py(e)+3.5,textAnchor:`end`,children:a?Nt(e):L(e)},`t${e}`)),r?e.map(e=>(0,J.jsx)(`text`,{className:`ctx-tick`,x:l.px(e.t),y:164,textAnchor:`middle`,children:new Date(e.t).toLocaleDateString(void 0,{weekday:`short`})},`d${e.day}`)):HE(l).map((e,t)=>(0,J.jsx)(`text`,{className:`ctx-tick`,x:e.x,y:164,textAnchor:e.anchor,children:e.label},t)),d&&n===`area`&&(0,J.jsxs)(`g`,{children:[(0,J.jsx)(`line`,{x1:l.px(d.t),x2:l.px(d.t),y1:l.y,y2:l.y+l.h,stroke:`var(--fg)`,strokeOpacity:.35,strokeWidth:1}),(0,J.jsx)(`circle`,{cx:l.px(d.t),cy:l.py(d.v),r:4.5,fill:eD,stroke:`var(--panel)`,strokeWidth:2})]})]}),(0,J.jsx)(`div`,{className:`ctx-readout`,children:d?`${u?`${new Date(d.t).toLocaleDateString(void 0,{day:`numeric`,month:`short`})} ${new Date(d.t).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}`:new Date(d.t).toLocaleDateString(void 0,{weekday:r?`short`:void 0,day:`numeric`,month:`short`,year:`numeric`})} · ${d.v>0?a?_t(d.v):Me(d.v):`nothing recorded`}`:(0,J.jsx)(iD,{})})]})}function Xve({rows:e,width:t,bands:n,slots:r=!1,maxColW:i}){let a=(e,t)=>(e.src.agents??[]).filter(e=>t(nt(e.model)??e.model)).reduce((e,t)=>e+t.count,0),o=new Set(n.bands.map(e=>e.alias)),s=[...n.bands.map(e=>({slot:e.slot,name:e.alias.replace(/^claude-/,``),at:t=>a(t,t=>t===e.alias)})),...n.restSlot==null?[]:[{slot:n.restSlot,name:n.restName,at:e=>a(e,e=>!o.has(e))}]],c=e.map(e=>({t:e.t,day:e.day,v:s.reduce((t,n)=>t+(n.at?n.at(e):0),0)})),l=Math.max(1,...c.map(e=>e.v)),u=NE({width:t,height:94,pad:H$,points:c,yMax:l}),d=l<=4?Array.from({length:l+1},(e,t)=>t):[0,Math.round(l/2),l],f=YE(u,e,s,{normalize:!1,maxW:i});return e.length?(0,J.jsxs)(`svg`,{className:`ctx-chart`,width:t,height:94,viewBox:`0 0 ${t} 94`,role:`img`,"aria-label":`subagents started per day, by model`,children:[d.map(e=>(0,J.jsx)(`line`,{x1:u.x,x2:u.x+u.w,y1:u.py(e),y2:u.py(e),stroke:`var(--line)`,strokeWidth:1},e)),f.map(({point:e,bands:t})=>t.map((t,n)=>(0,J.jsx)(`rect`,{x:t.x,y:t.y,width:t.w,height:Math.max(1,t.h-1),rx:1.5,fill:$E[t.slot]??eD,fillOpacity:.92,children:(0,J.jsx)(`title`,{children:`${e.day} — ${t.value} × ${t.kind}`})},`${e.day}-${n}`))),d.map(e=>(0,J.jsx)(`text`,{className:`ctx-tick`,x:u.x-6,y:u.py(e)+3.5,textAnchor:`end`,children:e},`t${e}`)),r?e.map(e=>(0,J.jsx)(`text`,{className:`ctx-tick`,x:u.px(e.t),y:88,textAnchor:`middle`,children:new Date(e.t).toLocaleDateString(void 0,{weekday:`short`})},`d${e.day}`)):HE(u).map((e,t)=>(0,J.jsx)(`text`,{className:`ctx-tick`,x:e.x,y:88,textAnchor:e.anchor,children:e.label},t))]}):(0,J.jsx)(`div`,{className:`empty`,children:`No days in this window.`})}var Zve=`reading:`;function Qve(e,t=[]){return gr(e,2**53-1).segments.filter(e=>e.source!==`claude`&&!t.includes(e.source)).map(e=>({source:e.source,label:e.label}))}var $ve=e=>gr(e,3).total;function eye(e,t){return!e||t<2?null:`opened on ${e} · 1 of ${t} sources`}var tye=(e,t)=>(e??[]).find(e=>e.source===t)?.label??t;function nye(e,t,n){return!e||!t||t!==e?null:eye(tye(n,e),$ve(n))}function rye(e){let t=Cr(e),n=[e.id];return t!=null&&n.push(`${t}% used`),typeof e.used==`number`&&typeof e.limit==`number`&&n.push(`${e.used} / ${e.limit}${e.unitName?` ${e.unitName}`:``}`),n.join(` · `)}function iye(e,t){if(!e||!Array.isArray(e.samples))return[];let n=[];for(let r of e.samples){let e=Array.isArray(r?.w)?r.w.find(e=>e?.id===t):void 0;!e||typeof e.pct!=`number`||!Number.isFinite(e.pct)||e.pct<0||e.pct>100||typeof r.t==`number`&&Number.isFinite(r.t)&&n.push({t:r.t,pct:e.pct,r:typeof e.resetAt==`number`&&Number.isFinite(e.resetAt)?e.resetAt:null})}return n.sort((e,t)=>e.t-t.t)}var aye=e=>e.map(e=>({t:e.t,s:e.pct,w:null,sr:e.r,wr:null}));function oye(e,t){return!e||e===`claude`?{source:`claude`,extraId:null}:t.guests.includes(e)?{source:e,extraId:null}:t.ledgers.includes(e)?{source:`claude`,extraId:e}:t.backendOf&&t.ledgers.includes(t.backendOf)?{source:`claude`,extraId:t.backendOf}:t.chips.includes(e)?{source:`claude`,extraId:Zve+e}:{source:`claude`,extraId:null}}function sye(e,t){let n=e??[];return n.find(e=>e.source===t)??n.find(e=>e.backend===t)??null}var cye=168;function b1({reading:e,online:t,ledger:n=!1}){let r=e?.source??null,[i,a]=(0,V.useState)(null);return(0,V.useEffect)(()=>{if(a(null),!r||!t)return;let e=!0;return sx.sourceHistory(r).then(t=>{e&&a(t)}),()=>{e=!1}},[r,t,e?.checkedAt]),e?(0,J.jsxs)(`div`,{className:`ts-lims`,children:[(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsxs)(`span`,{children:[(0,J.jsx)(ms,{size:12,style:{verticalAlign:`-2px`,marginRight:4}}),e.label,` quota`]})}),e.windows.map(t=>{let n=Cr(t);if(n==null)return null;let r=n>=80;return(0,J.jsxs)(`div`,{className:`ts-lim`,children:[(0,J.jsxs)(`div`,{className:`ts-barhead`,children:[(0,J.jsx)(`span`,{className:`ts-barlabel`,children:rye(t)}),(0,J.jsxs)(`span`,{className:`ts-barval${r?` hot`:``}`,children:[n,`% used`]})]}),(0,J.jsx)(`div`,{className:`ts-bartrack`,children:(0,J.jsx)(`span`,{className:`ts-barfill${r?` hot`:``}`,style:{width:`${n}%`}})}),i?(0,J.jsx)(g1,{samples:aye(iye(i,t.id)),which:`session`,reset:t.resetAt??null,pct:n,everyMs:0,hours:cye,name:`${e.label} ${t.id}`}):(0,J.jsx)(`div`,{className:`ts-spark-none`,children:`No kept readings could be read from this desktop.`}),(0,J.jsx)(`div`,{className:`ts-lim-sub`,children:t.resetAt?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(os,{size:11,style:{verticalAlign:`-1px`}}),` Resets `,q$(t.resetAt),` — in `,zp(t.resetAt),`.`]}):(0,J.jsx)(J.Fragment,{children:`The source did not name a reset time for this window.`})})]},t.id)}),(0,J.jsxs)(`div`,{className:`empty ts-foot`,children:[e.remembered?(0,J.jsxs)(J.Fragment,{children:[`Kept from before this desktop’s daemon last restarted, read `,Tp(e.checkedAt),` — nothing has re-read `,e.label,` since, so this can only have filled further.`]}):(0,J.jsxs)(J.Fragment,{children:[`Read `,Tp(e.checkedAt),`.`]}),n?(0,J.jsxs)(J.Fragment,{children:[` `,`The quota is `,e.label,`’s account; the figures below are only this desktop’s sessions.`]}):(0,J.jsxs)(J.Fragment,{children:[` `,`No token ledger for `,e.label,` on this desktop — only its quota is read, so there is no total and no price.`]})]})]}):(0,J.jsx)(`div`,{className:`empty ts-caveat`,children:`This source has no reading right now, so there is nothing to show for it.`})}var lye=e=>x$(e).map(e=>`${e.kind} ${L(e.n)}`);function x1(e){let t=XE(e)??e;return{pts:t,trend:t.length>7?IE(t,7):[]}}function uye({id:e,label:t,online:n,fresh:r,reading:i=null,table:a=!1,onTable:o}){let s=gh(`backendtokens:${e}:${r}`,()=>sx.backendTokens(e,r>0),{offline:!n}),[c,l]=rD(),u=s.data,d=T$(t,u),f=u&&u.available===!0&&!d?u:null,p=f?C$(f):null,m=f?w$(f):null,h=f?Z_e(f,ut):null,g=(0,V.useMemo)(()=>f?x1($_e(f)):null,[f]),_=(0,V.useMemo)(()=>m?x1(eve(m.days)):null,[m]),v=f?tve(f):[],y=e=>e>7?` Dashed: the 7-day mean.`:``;return(0,J.jsxs)(`div`,{className:`list ts-list`,ref:l,children:[i&&(0,J.jsx)(b1,{reading:i,online:n,ledger:!0}),(0,J.jsx)($,{res:s,empty:!u,thing:`${t}’s token statistics`,noun:`scan`,children:null}),d&&(0,J.jsx)(`div`,{className:`empty ts-caveat`,children:d}),f&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`empty ts-caveat`,children:Y_e(t,f,m?.name)}),p&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`ts-hero-wrap`,children:[(0,J.jsx)(`div`,{className:`ts-hero`,title:`${Me(p.total)} tokens`,children:L(p.total)}),(0,J.jsxs)(`div`,{className:`ts-hero-sub`,children:[`tokens `,X_e(f,p.turns),` — of which:`]})]}),(0,J.jsx)(_1,{rows:p.rows})]}),o&&(p||m)&&(0,J.jsxs)(`div`,{className:`ts-filter`,role:`group`,"aria-label":`show as`,children:[(0,J.jsx)(`span`,{className:`ctx-stackpick-lab`,children:`show as`}),(0,J.jsx)(Y,{className:a?void 0:`active`,onClick:()=>o(!1),children:`chart`}),(0,J.jsx)(Y,{className:a?`active`:void 0,onClick:()=>o(!0),children:`values`})]}),p&&g&&g.pts.length>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsxs)(`span`,{children:[`Tokens per day `,(0,J.jsxs)(`span`,{className:`section-hint`,children:[`· `,a?`newest first`:`all days kept`]})]})}),a?[...q_e(f)].reverse().map(e=>(0,J.jsx)(v1,{label:e.day,value:e.rows.length?L(e.total):`—`,subs:[e.rows.length?`${e.turns.toLocaleString()} turns`:J_e(e,L),...e.rows.map(e=>`${e.kind} ${L(e.n)}`),...e.byModel&&e.byModel.length>1?e.byModel.map(e=>`${e.key} ${L(e.total)}`):[],...e.byModel&&e.byModel.length===1?[`all ${e.byModel[0].key}`]:[]]},e.day)):c>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(y1,{pts:g.pts,width:c,kind:`columns`,trend:g.trend,label:`${t} tokens per day`}),(0,J.jsxs)(`div`,{className:`empty ts-foot`,children:[`Every token kind summed per day.`,y(g.pts.length)]})]})]}),m&&_&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsxs)(`span`,{children:[m.name,` `,(0,J.jsx)(`span`,{className:`section-hint`,children:`· all time`})]})}),(0,J.jsxs)(`div`,{className:`ts-hero-wrap`,children:[(0,J.jsx)(`div`,{className:`ts-hero`,children:L(m.total)}),(0,J.jsxs)(`div`,{className:`ts-hero-sub`,children:[m.name,`. This is the unit `,t,` is billed in; it is not tokens.`]})]}),a?m.days.slice(-14).reverse().map(e=>(0,J.jsx)(v1,{label:e.day,value:L(e.n),subs:[m.name]},e.day)):c>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(y1,{pts:_.pts,width:c,kind:`columns`,trend:_.trend,label:`${m.name} per day`}),(0,J.jsxs)(`div`,{className:`empty ts-foot`,children:[m.name,` per day.`,y(_.pts.length)]})]})]}),h&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsxs)(`span`,{children:[`Cost `,(0,J.jsx)(`span`,{className:`section-hint`,children:`· by model`})]})}),h.totals.length>0&&(0,J.jsxs)(`div`,{className:`empty ts-caveat`,children:[(0,J.jsx)(`b`,{children:h.totals.join(` · `)}),` for the priced models`,h.totals.length>1?` — one figure per currency, never converted`:``,h.lines.some(e=>!e.priced)?`; the unpriced ones below are not in it`:``,`.`]}),h.lines.map(e=>(0,J.jsx)(v1,{label:e.key,value:``,subs:[e.text]},e.key)),h.problems.map(e=>(0,J.jsxs)(`div`,{className:`empty ts-caveat`,children:[`Refused in `,h.pricesFile,`: `,e]},e))]}),f.models.length>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsxs)(`span`,{children:[`By model `,(0,J.jsx)(`span`,{className:`section-hint`,children:`· tokens, all time`})]})}),a||v.length===0?f.models.map(e=>(0,J.jsx)(v1,{label:e.label,title:e.key,value:L(S$(e.kinds)),subs:[`${e.turns.toLocaleString()} turns`,...lye(e.kinds)]},e.key)):(0,J.jsx)(_1,{rows:v})]}),f.scannedAt>0&&(0,J.jsxs)(`div`,{className:`empty ts-foot`,children:[`Read at `,new Date(f.scannedAt).toLocaleTimeString(),`.`]})]})]})}function dye(e){return e.filter(e=>e.def.hasData(e.doc??null))}function fye(e){if(!e.length)return null;let t=e.map(e=>e.def.label);return`Claude Code sessions only — ${t.length===1?t[0]:`${t.slice(0,-1).join(`, `)} and ${t[t.length-1]}`} sessions are counted on their own ${t.length===1?`view`:`views`}.`}var pye=120,S1=5;function mye({cut:e,grid:t,onScope:n}){let r=(0,V.useMemo)(()=>{let e=z$(t);return e.length?e[0].back:0},[t]),i=e.back<r,a=e.back>0;return(0,J.jsxs)(`div`,{className:`ts-wstep`,children:[i?(0,J.jsxs)(Y,{onClick:()=>n({id:e.id,back:e.back+1}),title:`the window before this one`,children:[(0,J.jsx)(Ns,{size:14}),` older`]}):(0,J.jsx)(`span`,{className:`ts-wstep-end`,children:`the record stops here`}),(0,J.jsx)(`span`,{className:`ts-wstep-at`,children:e.back===0?`the window running now`:V$(e.openedAt,e.resetAt)}),a?(0,J.jsxs)(Y,{onClick:()=>n({id:e.id,back:e.back-1}),title:`the window after this one`,children:[`newer `,(0,J.jsx)(Hs,{size:14})]}):(0,J.jsx)(`span`,{className:`ts-wstep-end`,children:`nothing newer has happened`})]})}function hye({grids:e,res:t,money:n,scope:r,onScope:i}){let a=P$.filter(t=>e.has(t.id));return a.length?(0,J.jsxs)(`div`,{className:`ts-heats`,children:[a.map(t=>(0,J.jsx)(gye,{spec:t,grid:e.get(t.id),money:n,scope:r,onScope:i},t.id)),(t.state===`cached`||t.state===`offline`)&&(0,J.jsx)(`div`,{className:`empty ts-caveat`,children:`These grids are the last copy this phone had.`}),(0,J.jsxs)(`div`,{className:`empty ts-caveat`,children:[`Oldest first; the last box is the window running now. An `,(0,J.jsx)(`b`,{children:`empty`}),` box ran nothing, which is a reading; an `,(0,J.jsx)(`b`,{children:`outlined`}),` one is a window the hour record does not reach, which is not.`]}),(0,J.jsxs)(`details`,{className:`hint-more ctx-method`,children:[(0,J.jsx)(`summary`,{children:`how to read the boxes`}),(0,J.jsxs)(`p`,{children:[`A tap cuts every readout above down to that one window. Shaded by`,` `,(0,J.jsx)(`b`,{children:n?`list-price cost`:`tokens`}),` against the busiest box in ITS OWN grid — the two never share a scale, because a week holds about thirty-four five-hour windows. The scale is square-rooted, so a box twice as dark is rather more than twice as busy.`,` `,`Each box counts from the hour nearest the moment its window opened to the hour nearest its reset — the same rule the live readout above states — so every hour is in exactly one box, and a box is off its window by at most half an hour at each end.`]})]})]}):null}function gye({spec:e,grid:t,money:n,scope:r,onScope:i}){let a=(0,V.useMemo)(()=>z$(t),[t]),o=(0,V.useCallback)(e=>e.totals?n?e.cost?.total??0:ui(e.totals):null,[n]),s=a.map(o),c=s.reduce((e,t)=>Math.max(e,t??0),0),l=s.filter(e=>e!=null).length,u=s.filter(e=>(e??0)>0).length;if(!a.length)return null;let d=e=>n?_t(e):`${L(e)} tokens`,f=a.length>pye;return(0,J.jsxs)(`div`,{className:`ts-heat`,children:[(0,J.jsxs)(`div`,{className:`section section-head`,children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(nne,{size:12,style:{verticalAlign:`-2px`,marginRight:4}}),e.id===`session`?`Five-hour windows`:`Weekly windows`]}),(0,J.jsxs)(`span`,{className:`ts-heat-n`,children:[u,` of `,l,` had anything in them`]})]}),(0,J.jsx)(`div`,{className:`ts-heat-grid${f?` dense`:``}`,children:a.map((t,n)=>{let a=s[n],o=r?.id===e.id&&r.back===t.back,l=a==null?0:gve(hve(a,c),S1),u=V$(t.openedAt,t.resetAt),f=a==null?`outside the hour record`:a>0?d(a):`nothing counted`;return(0,J.jsx)(`button`,{type:`button`,className:`ts-heat-b s${l}${a==null?` unknown`:``}${t.back===0?` now`:``}${o?` on`:``}`,"aria-label":`${u} — ${f}`,title:`${u} — ${f}`,onClick:()=>i(o?null:{id:e.id,back:t.back})},t.back)})}),(0,J.jsxs)(`div`,{className:`ts-heat-key`,children:[(0,J.jsx)(`span`,{className:`ts-heat-key-l`,children:`less`}),Array.from({length:S1},(e,t)=>(0,J.jsx)(`span`,{className:`ts-heat-b s${t}`,"aria-hidden":`true`},t)),(0,J.jsxs)(`span`,{className:`ts-heat-key-l`,children:[`more`,c>0?` · busiest ${d(c)}`:``]})]})]})}function _ye({slots:e,width:t,money:n}){let r={top:8,right:6,bottom:18,left:6},i={x:r.left,y:r.top,w:Math.max(1,t-r.left-r.right),h:Math.max(1,120-r.top-r.bottom)},a=e.map(e=>n?e.cost.total:ui(e)),o=koe(a,i),[s,c]=(0,V.useState)(null),l=o.reduce((e,t)=>t.value>e.value?t:e,o[0]),u=l&&l.value>0?l:null;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`svg`,{className:`ctx-chart`,width:t,height:120,viewBox:`0 0 ${t} 120`,role:`img`,"aria-label":`usage by hour of the day, all time`,children:[o.map(e=>(0,J.jsx)(`rect`,{x:e.x,y:i.y,width:e.w,height:i.h,rx:2,fill:`var(--fg)`,fillOpacity:.045,onPointerDown:()=>c(e.hour),onPointerEnter:()=>c(e.hour)},`s${e.hour}`)),o.map(e=>(0,J.jsx)(`rect`,{x:e.x,y:e.y,width:e.w,height:e.h,rx:Math.min(2,e.w/2),fill:eD,fillOpacity:s!=null&&s!==e.hour?.45:.85},e.hour)),[0,6,12,18].map(e=>(0,J.jsx)(`text`,{className:`ctx-tick`,x:o[e].x+o[e].w/2,y:115,textAnchor:`middle`,children:String(e).padStart(2,`0`)},e))]}),(0,J.jsx)(`div`,{className:`ctx-readout`,children:s==null?u?`busiest hour ${String(u.hour).padStart(2,`0`)}:00 · ${_n(u.share)} of everything`:`nothing recorded`:`${String(s).padStart(2,`0`)}:00 — ${a[s]>0?`${n?_t(a[s]):Me(a[s])} · ${_n(o[s].share)} of the day`:`nothing, ever`}`})]})}function C1({rows:e,money:t=!1,bands:n}){let r=e=>t?e.cost.total:ui(e),i=Doe([...e].sort((e,t)=>r(t)-r(e)),r,e=>e.label);return i.length?(0,J.jsx)(`div`,{className:`ts-bars`,children:i.map(e=>(0,J.jsxs)(`div`,{className:`ts-barrow`,children:[(0,J.jsxs)(`div`,{className:`ts-barhead`,children:[(0,J.jsx)(`span`,{className:`ts-barlabel`,title:e.item.key,children:e.label}),(0,J.jsxs)(`span`,{className:`ts-barval`,children:[t?_t(e.value):e.text,t&&e.item.priced===!1?(0,J.jsx)(`em`,{children:`no list price`}):(0,J.jsx)(`em`,{children:_n(e.share)})]})]}),(0,J.jsx)(`div`,{className:`ts-bartrack`,children:n&&e.item.byModel?.length?(0,J.jsx)(vye,{group:e.item,frac:e.frac,money:t,bands:n}):(0,J.jsx)(`span`,{className:`ts-barfill`,style:{width:`${Math.max(1,e.frac*100)}%`}})})]},e.item.key))}):(0,J.jsx)(`div`,{className:`empty`,children:`Nothing recorded.`})}function w1({bands:e}){let t=[...e.bands.map(e=>({slot:e.slot,name:e.alias.replace(/^claude-/,``)})),...e.restSlot==null?[]:[{slot:e.restSlot,name:e.restName}]];return t.length<2?null:(0,J.jsx)(`div`,{className:`ctx-legend ctx-legend-stack`,children:t.map(e=>(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`svg`,{width:`10`,height:`10`,"aria-hidden":!0,children:(0,J.jsx)(`rect`,{x:`0`,y:`1`,width:`10`,height:`8`,rx:`2`,fill:$E[e.slot]??eD})}),e.name]},e.name))})}function vye({group:e,frac:t,money:n,bands:r}){let i=new Map(r.bands.map(e=>[e.alias,e.slot])),a=e=>{let t=r.bands.findIndex(t=>t.slot===e);return t<0?r.bands.length:t},o=e=>n?e.cost.total:ui(e.totals),s=new Map;for(let t of e.byModel??[]){let e=nt(t.model)??t.model,n=i.get(e),a=n==null?`\0rest`:e,c=s.get(a)??{slot:n??r.restSlot??$E.length-1,name:n==null?r.restName:e.replace(/^claude-/,``),v:0};c.v+=o(t),s.set(a,c)}let c=[...s.values()].filter(e=>e.v>0).sort((e,t)=>a(e.slot)-a(t.slot)),l=c.reduce((e,t)=>e+t.v,0);return!c.length||l<=0?(0,J.jsx)(`span`,{className:`ts-barfill`,style:{width:`${Math.max(1,t*100)}%`}}):(0,J.jsx)(`span`,{className:`ts-barfill ts-barfill-split`,style:{width:`${Math.max(1,t*100)}%`},children:c.map(e=>(0,J.jsx)(`span`,{className:`ts-barseg`,title:`${e.name}: ${n?_t(e.v):L(e.v)} (${_n(e.v/l)})`,style:{width:`${e.v/l*100}%`,background:$E[e.slot]??eD}},e.name))})}function T1({doc:e,days:t,cut:n=null,part:r,repos:i=null,reposNote:a}){let o=[...t].reverse();return r===`days`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsxs)(`span`,{children:[`By day `,(0,J.jsx)(`span`,{className:`section-hint`,children:`· newest first`})]})}),o.map(e=>(0,J.jsx)(E1,{label:e.day,t:e,cost:e.cost},e.day)),!o.length&&(0,J.jsx)(`div`,{className:`empty`,children:`No days in this window.`})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsxs)(`span`,{children:[`By model`,n?(0,J.jsxs)(`span`,{className:`section-hint`,children:[` · `,n.long]}):null]})}),n?n.modelSplit?n.models.map(e=>(0,J.jsx)(E1,{label:e.label,t:e,cost:e.cost},e.key)):(0,J.jsx)(`div`,{className:`empty`,children:`No model split in this desktop’s hour buckets yet — the host records one from the next scan on. The tokens and money above are counted either way.`}):e.models.map(e=>(0,J.jsx)(E1,{label:e.label,t:e,cost:e.cost},e.key)),(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsxs)(`span`,{children:[`By repo`,n?(0,J.jsxs)(`span`,{className:`section-hint`,children:[` · `,n.long]}):null]})}),n?i?i.map(e=>(0,J.jsx)(E1,{label:e.label,t:e,title:e.key,cost:e.cost},e.key)):(0,J.jsx)(`div`,{className:`empty`,children:a}):e.repos.map(e=>(0,J.jsx)(E1,{label:e.label,t:e,title:e.key,cost:e.cost},e.key))]})}function E1({label:e,t,title:n,cost:r}){return(0,J.jsxs)(`div`,{className:`row ctx-row ts-numrow`,title:n,children:[(0,J.jsx)(Zw,{children:e}),(0,J.jsx)(`span`,{className:`ts-num`,children:Me(ui(t))}),r&&(0,J.jsx)(`span`,{className:`ts-num ts-cost`,children:_t(r.total)}),(0,J.jsxs)(`span`,{className:`row-meta`,children:[(0,J.jsxs)(Q,{children:[`in `,L(t.input)]}),(0,J.jsxs)(Q,{children:[`out `,L(t.output)]}),(0,J.jsxs)(Q,{children:[`cache r `,L(t.cacheRead)]}),(0,J.jsxs)(Q,{children:[`cache w `,L(t.cacheWrite)]}),(0,J.jsxs)(Q,{children:[Me(t.turns),` turns`]})]})]})}function yye({doc:e,money:t,table:n,active:r,dcut:i,scope:a,setScope:o,grids:s,hist:c,shownTotals:l,shownCost:u,shownTok:d,coldNote:f,scopeWords:p,bands:m,canModel:h,days:g,scopeRepos:_,scopeRes:v,reposRefusal:y,top:b,pts:x,weekTwin:S,nameOf:C,onExplain:w,isLive:T,onOpenConvo:E}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(O$,{title:`Totals`,chips:null,caption:r?(0,J.jsxs)(J.Fragment,{children:[cve(r,Date.now()),S&&(0,J.jsxs)(J.Fragment,{children:[` Counted from the desktop’s hour record, like the figure under the limit bar; `,(0,J.jsx)(`em`,{children:`Where the week went`}),` folds each conversation’s log, so the two can differ by what ran between the two reads.`]})]}):i?(0,J.jsx)(J.Fragment,{children:i.caption}):(0,J.jsx)(J.Fragment,{children:`Every conversation on record.`}),children:[r&&(0,J.jsx)(mye,{cut:r,grid:s.get(r.id)??null,onScope:o}),(0,J.jsxs)(`div`,{className:`ts-hero-wrap`,children:[(0,J.jsx)(`div`,{className:`ts-hero`,title:t?`${_t(u.total)} at list prices`:`${Me(d)} tokens`,children:t?_t(u.total):L(d)}),(0,J.jsxs)(`div`,{className:`ts-hero-sub`,children:[t?(0,J.jsxs)(J.Fragment,{children:[`at list prices · `,L(d),` tokens`]}):(0,J.jsxs)(J.Fragment,{children:[`tokens · `,_t(u.total),` at list prices`]}),r?(0,J.jsxs)(J.Fragment,{children:[` · `,Me(r.totals.turns),` turns in `,r.long]}):i?(0,J.jsxs)(J.Fragment,{children:[` · `,Me(i.cut.totals.turns),` turns in `,p]}):(0,J.jsxs)(J.Fragment,{children:[` across `,Me(e.conversations),` conversations`,e.firstAt?(0,J.jsxs)(J.Fragment,{children:[` since `,new Date(e.firstAt).toLocaleDateString(void 0,{day:`numeric`,month:`long`,year:`numeric`})]}):null]})]})]}),(0,J.jsx)(Z$,{totals:l,cost:u,money:t}),(0,J.jsxs)(`details`,{className:`hint-more ts-dollars-why`,children:[(0,J.jsxs)(`summary`,{children:[(0,J.jsx)(cs,{size:12,"aria-hidden":!0}),` `,Xn]}),(0,J.jsx)(`p`,{children:wr})]}),t&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`empty ts-caveat`,children:[`This is a `,(0,J.jsx)(`b`,{children:`counterfactual, not a bill`}),`: what the same traffic would have cost billed through the API at published pay-as-you-go rates (`,e.pricesAsOf,` price list).`,!r&&!i&&ui(e.unpriced)>0&&(0,J.jsxs)(J.Fragment,{children:[` `,L(ui(e.unpriced)),` tokens ran on a model with no published rate and are `,(0,J.jsx)(`b`,{children:`not`}),` in this figure.`]}),!r&&!i&&e.fastTurns>0&&(0,J.jsxs)(J.Fragment,{children:[` `,Me(e.fastTurns),` turns ran in fast mode, which bills at roughly double and is priced here at the standard rate — the real figure is higher.`]}),` `,Math.round(l.cacheWrite1h/Math.max(1,l.cacheWrite)*100),`% of the writes here were the dearer 1-hour tier.`]}),(0,J.jsxs)(`details`,{className:`hint-more ctx-method`,children:[(0,J.jsx)(`summary`,{children:`how it is priced`}),(0,J.jsx)(`p`,{children:`Cache reads are charged at a tenth of the input rate and cache writes at 1.25× (5-minute) or 2× (1-hour). The CLI is normally run on a subscription, which is a flat fee however many tokens go through it — which is what makes the figure above “what this would have cost” rather than “what you paid”.`})]})]}),(0,J.jsx)(nD,{totals:l}),!r&&!i&&f&&(0,J.jsx)(`div`,{className:`empty ts-caveat`,children:f}),n?(0,J.jsx)(T1,{doc:e,days:g,cut:r??(i?{long:p,modelSplit:i.cut.modelSplit,models:i.cut.models}:null),part:`groups`,repos:y?null:_,reposNote:y??r1(v??{state:`loading`},`window`)}):(0,J.jsxs)(J.Fragment,{children:[r?(0,J.jsx)(Ove,{cut:r,money:t}):i?(0,J.jsx)(kve,{days:i.cut.days,totals:i.cut.totals,cost:i.cut.cost,calendarDays:i.calendarDays,money:t}):(0,J.jsx)(Dve,{doc:e,money:t}),(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsxs)(`span`,{children:[`By model `,(0,J.jsx)(k$,{children:p})]})}),r??i?.cut?(r??i.cut).modelSplit?(0,J.jsx)(C1,{rows:Ge((r??i.cut).models,6,`models`),money:t}):(0,J.jsx)(`div`,{className:`empty`,children:`No model split in this desktop’s hour buckets yet — the host records one from the next scan on. The tokens and money above are counted either way.`}):(0,J.jsx)(C1,{rows:Ge(e.models,6,`models`),money:t}),(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsxs)(`span`,{children:[`By repo `,(0,J.jsx)(k$,{children:p})]})}),y?(0,J.jsx)(`div`,{className:`empty`,children:y}):r||i?_?(0,J.jsx)(C1,{rows:Ge(_,8,`repos`),money:t,bands:h?m:void 0}):(0,J.jsx)(`div`,{className:`empty`,children:r1(v??{state:`loading`},`window`)}):(0,J.jsx)(C1,{rows:Ge(e.repos,8,`repos`),money:t,bands:h?m:void 0}),(r||i)&&_&&!y&&h&&(0,J.jsx)(w1,{bands:m}),!r&&!i&&h&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(w1,{bands:m}),(0,J.jsxs)(`details`,{className:`hint-more ctx-method`,children:[(0,J.jsx)(`summary`,{children:`why the split is there`}),(0,J.jsxs)(`p`,{children:[`Each bar is split by the model that ran there. It is the answer to the question the lengths raise and cannot settle: two repos with the same token count can be several-fold apart in cost, because opus is 2.5× sonnet per token and 5× haiku — so a repo whose share of the `,(0,J.jsx)(`b`,{children:`money`}),` is bigger than its share of the tokens is a repo running a dearer model, and nothing else.`]})]})]})]}),s.size>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsxs)(`span`,{children:[`Past windows `,(0,J.jsx)(k$,{children:`tap one to set the span to it`})]})}),(0,J.jsx)(hye,{grids:s,res:c,money:t,scope:a,onScope:o})]})]}),(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsxs)(`span`,{children:[`Costliest conversations `,(0,J.jsx)(k$,{children:b.tag})]})}),b.note&&(0,J.jsx)(`div`,{className:`empty ts-caveat`,children:b.note}),!b.rows.length&&!b.note&&(0,J.jsxs)(`div`,{className:`empty`,children:[`No conversation ran in `,p,`.`]}),!!b.rows.length&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ive,{rows:b.rows,total:b.total,pts:x,nameOf:C,onExplain:w,isLive:T,onOpen:E}),(0,J.jsxs)(`div`,{className:`empty ts-caveat`,children:[`Each counts its subagents in`,x?(0,J.jsx)(J.Fragment,{children:`; weekly points are given only for a conversation that ran wholly inside this week, since the rate is this week’s`}):null,`. `,(0,J.jsx)(`b`,{children:`Explain the cost`}),` starts a new session that reads that conversation’s log, names what made it expensive and lists ideas — it changes nothing until you pick one.`]})]})]})}var bye=[{id:`today`,label:`today`},{id:`7`,label:`7 days`},{id:`30`,label:`30 days`},{id:`all`,label:`all`}];function xye(e,t){if(e===`all`)return;let n=e===`today`?0:Number(e)-1,r=new Date(t);return r.setDate(r.getDate()-n),i(r.getTime())}function Sye(e){return!!e&&e.available===!0&&(e.reachable===!0||e.days.length>0)}var D1=(e,t,n=`${t}s`)=>`${e.toLocaleString()} ${e===1?t:n}`,O1=e=>`${e>=100?Math.round(e).toLocaleString():e.toFixed(1)} tok/s`;function Cye(e){let t=e.compute,n=[],r=qn(e),i=t&&r>0?{total:Ht(r),split:[`prompt processing ${Ht(t.promptMs)}`,`generating ${Ht(t.genMs)}`]}:null,a=hi(e),o=Object.entries(e.byApi??{}).sort((e,t)=>t[1]-e[1]),s=o.reduce((e,[,t])=>e+t,0),c=a>0?{total:D1(a,`request`),split:[...o.map(([e,t])=>`${e} ${t.toLocaleString()}`),...a>s?[`endpoint not paired ${(a-s).toLocaleString()}`]:[]]}:null,l=e.timed&&e.timed.requests>0?`Time to answer ${Ht(e.timed.ms)} over ${D1(e.timed.requests,`request`)} — the HTTP request from arrival to last byte, including waiting in the runner's queue and any load; not compute.`:null,u=e.untimed&&e.untimed.requests>0?`${D1(e.untimed.requests,`request`)} with no runner timings in its log — time to answer only: ${Ht(e.untimed.ms)}.`:null,d=e.loads&&e.loads.loads>0?`Loading ${Ht(e.loads.ms)} over ${D1(e.loads.loads,`load`)} — not in the busy time.`:null;i||n.push(a>0?`No runner timings for these requests — only their time to answer.`:`No request tied to this model in this span.`);let f=t&&t.promptTok+t.cachedTok+t.genTok>0?{total:`${L(t.promptTok+t.cachedTok+t.genTok)} tokens`,split:[`prompt processed ${L(t.promptTok)}`,`prompt reused from the runner's cache ${L(t.cachedTok)}`,`generated ${L(t.genTok)}`]}:null,p=[],m=Br(t?.promptTok,t?.promptMs),h=Br(t?.genTok,t?.genMs);m!=null&&p.push(`prompt processing ${O1(m)}`),h!=null&&p.push(`generation ${O1(h)}`);let g=[],_=e.mem;if(_&&_.samples>0){let e=ii(_.sumBytes,_.samples);g.push(`Resident ${un(e)} typical (mean of ${D1(_.samples,`sample`)}), ${un(_.peakBytes)} at peak.`);let t=ii(_.sumVram,_.samples),n=_.peakBytes>0?_.peakVram/_.peakBytes:null;g.push(`On the GPU ${un(t)} typical, ${un(_.peakVram)} at peak${n==null?``:` (${Math.round(n*100)}% of it — unified memory reads 100%)`}.`),g.push(`Seen resident for ${Ht(_.residentMs)}${_.contextLength?`, with a ${L(_.contextLength)}-token context`:``}.`)}else n.push(`No memory reading — the runner was not sampled while this model was loaded.`);let v=[],y=e.machine;if(y&&y.samples>0){let e=ii(y.usedSum,y.samples);v.push(`While it was loaded the desktop used ${un(e)} of ${un(y.totalBytes)} typical, ${un(y.usedPeak)} at peak; ${un(y.availMin)} was the least left available.`),y.swapPeak!=null&&v.push(`Swap in use at most ${un(y.swapPeak)}.`)}return{key:e.model??`\0unidentified`,title:e.model??`model not identified`,unidentified:e.model===null,busy:i,requests:c,answer:l,untimed:u,loads:d,tokens:f,rates:p,memory:g,machine:v,absent:n}}function k1(e,t){return pr(e,t).map(Cye)}function wye(e,t){let n=[];for(let r=e.length-1;r>=0;r--){let i=e[r];if(!(t&&i.day<t))for(let e of pr([i])){let t=[],r=qn(e);r>0&&e.compute&&t.push(`busy ${Ht(r)} (prompt ${Ht(e.compute.promptMs)} · generate ${Ht(e.compute.genMs)})`),e.compute&&t.push(`${L(e.compute.promptTok+e.compute.cachedTok)} prompt · ${L(e.compute.genTok)} generated`);let a=hi(e);a>0&&t.push(D1(a,`request`)),e.mem&&e.mem.samples>0&&t.push(`peak ${un(e.mem.peakBytes)}`),t.length&&n.push({key:`${i.day}:${e.model??``}`,day:i.day,model:e.model??`model not identified`,text:t.join(` · `)})}}return n}function Tye(e){if(!e)return{absent:`The local runner's ledger has not been read yet.`};if(e.available===!1)return{absent:e.reason};let t=k1(e.days);if(!t.length)return{absent:e.reachable===!1?`Ollama is not running — nothing recorded yet.`:`No request or resident model recorded yet.`};let n=t.slice(0,4).map(e=>[e.title,e.busy?`busy ${e.busy.total} (${e.busy.split.join(` · `)})`:null,e.tokens?`${e.tokens.total} (${e.tokens.split.join(` · `)})`:null].filter(Boolean).join(` — `));return t.length>4&&n.push(`and ${D1(t.length-4,`more model`)} on the Local runner tab.`),{lines:n,lastDay:e.days.length?e.days[e.days.length-1].day:null}}function A1(e,t=()=>!0){for(let n=e.length-1;n>=0;n--)if(t(e[n]))return e[n].day;return null}function j1(e){let t=x$(e);return t.length?{total:t.reduce((e,t)=>e+t.n,0),rows:t}:null}function Eye(e,t){let n={id:`claude`,label:`Claude Code`,unit:`tokens`};if(!e)return{...n,absent:`Claude Code’s logs have not been read yet.`};let r=e.totals,i=j1({input:r.input,output:r.output,cacheRead:r.cacheRead,cacheWrite:r.cacheWrite});return i?{...n,...i,turns:r.turns,...t?{scope:t}:{},lastDay:A1(e.days,e=>e.input+e.output+e.cacheRead+e.cacheWrite>0)}:{...n,absent:`No conversation logs on this desktop yet — nothing counted.`}}function Dye(e,t,n){let r={id:e,label:t,unit:`tokens`};if(`absent`in n)return{...r,absent:n.absent};let i=j1(n.kinds);return i?{...r,...i,...n.turns==null?{}:{turns:n.turns},lastDay:n.lastDay}:{...r,absent:n.nothing}}function Oye(e,t,n){let r={id:e,label:t,unit:`tokens`};if(!n)return{...r,absent:`${t}’s ledger has not been read yet.`};let i=T$(t,n);if(i||n.available===!1)return{...r,absent:i??`${t} has no token ledger on this desktop.`};let a=j1(n.totals.kinds),o=w$(n);return{...r,...a??{},...a?{turns:n.totals.turns}:{},...o?{billed:{name:o.name,total:o.total}}:{},...n.sliceOf?{scope:`cut from ${n.sliceOf}`}:{},lastDay:A1(n.days,e=>e.turns>0||Object.values(e.kinds).some(e=>e>0))??A1(o?.days??[])}}function M1(e,t){return e?`last active ${t(e)}`:`no dated activity`}var kye={input:`input`,output:`output`,reasoning:`reasoning`,cacheRead:`cache read`,cacheWrite:`cache write`},N1=e=>new Date(`${e}T00:00:00`).toLocaleDateString(void 0,{day:`numeric`,month:`short`,year:`numeric`});function P1({label:e,onOpen:t}){return(0,J.jsxs)(`div`,{className:`section section-head`,children:[(0,J.jsx)(`span`,{children:e}),t&&(0,J.jsx)(Y,{onClick:t,children:`open`})]})}function F1({c:e,onOpen:t}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(P1,{label:e.label,onOpen:t}),e.scope&&(0,J.jsx)(`div`,{className:`empty ts-caveat`,children:e.scope}),e.absent?(0,J.jsx)(`div`,{className:`empty ts-caveat`,children:e.absent}):(0,J.jsxs)(J.Fragment,{children:[e.total!=null&&e.rows&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`ts-hero-wrap`,children:[(0,J.jsx)(`div`,{className:`ts-hero`,title:`${Me(e.total)} ${e.unit}`,children:L(e.total)}),(0,J.jsxs)(`div`,{className:`ts-hero-sub`,children:[e.unit,e.turns==null?``:` over ${e.turns.toLocaleString()} turns`,`, in `,e.label,`’s own kinds — of which:`]})]}),(0,J.jsx)(_1,{rows:e.rows,name:e=>kye[e]??e})]}),e.billed&&(0,J.jsx)(v1,{label:e.billed.name,value:L(e.billed.total),subs:[`the unit ${e.label} is billed in, not tokens`]}),(0,J.jsx)(`div`,{className:`empty ts-foot`,children:M1(e.lastDay,N1)})]})]})}function Aye({id:e,label:t,online:n,fresh:r,onOpen:i}){let a=gh(`backendtokens:${e}:${r}`,()=>sx.backendTokens(e,r>0),{offline:!n}),o=a.data?Oye(e,t,a.data):{id:e,label:t,unit:`tokens`,absent:a.state===`offline`?`${t}’s ledger cannot be read while the desktop is out of reach.`:a.state===`error`?`${t}’s ledger did not answer${a.error?`: ${a.error}`:``}.`:`Reading ${t}’s ledger…`};return(0,J.jsx)(F1,{c:o,onOpen:i})}function jye({doc:e,onOpen:t}){let n=Tye(e);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(P1,{label:`Local runner`,onOpen:t}),(0,J.jsx)(`div`,{className:`empty ts-caveat`,children:`What ollama itself did, per model — compute time, tokens and memory, whichever backend asked. Overlaps the cards above; never add it to them.`}),n.absent?(0,J.jsx)(`div`,{className:`empty ts-caveat`,children:n.absent}):(0,J.jsxs)(J.Fragment,{children:[(n.lines??[]).map(e=>(0,J.jsx)(`div`,{className:`empty ts-caveat`,children:e},e)),(0,J.jsx)(`div`,{className:`empty ts-foot`,children:M1(n.lastDay,N1)})]})]})}function Mye({claude:e,claudeScope:t,guests:n=[],shownIds:r=[],ledgerTabs:i,online:a,fresh:o,onOpen:s,runner:c,runnerTab:l}){return(0,J.jsxs)(`div`,{className:`list ts-list`,children:[(0,J.jsx)(`div`,{className:`empty ts-caveat`,children:`One card per backend, each in its own unit and its own kinds. They are different accounting, so there is no total across them and no shared scale.`}),(0,J.jsx)(F1,{c:Eye(e,t),onOpen:()=>s(`claude`)}),n.map(e=>(0,J.jsx)(F1,{c:Dye(e.def.id,e.def.label,e.def.summary(e.doc??null)),onOpen:r.includes(e.def.id)?()=>s(e.def.id):void 0},e.def.id)),i.map(e=>(0,J.jsx)(Aye,{id:e.id,label:e.label,online:a,fresh:o,onOpen:()=>s(e.id)},e.id)),c!==void 0&&l&&(0,J.jsx)(jye,{doc:c,onOpen:()=>s(l)})]})}var I1=e=>new Date(e).toLocaleString(void 0,{day:`numeric`,month:`short`,hour:`2-digit`,minute:`2-digit`}),Nye=e=>new Date(`${e}T00:00:00`).toLocaleDateString(void 0,{weekday:`short`,day:`numeric`,month:`short`});function L1({total:e,split:t}){return(0,J.jsx)(v1,{label:e,value:``,subs:t})}function Pye({v:e,why:t}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsx)(`span`,{children:e.title})}),e.unidentified&&(0,J.jsx)(`div`,{className:`empty ts-caveat`,children:t}),(0,J.jsx)(`div`,{className:`empty ts-foot`,children:`Compute — the runner's own timings`}),e.busy?(0,J.jsx)(L1,{total:`busy ${e.busy.total}`,split:e.busy.split}):null,e.loads&&(0,J.jsx)(`div`,{className:`empty`,children:e.loads}),e.answer&&(0,J.jsx)(`div`,{className:`empty`,children:e.answer}),e.untimed&&(0,J.jsx)(`div`,{className:`empty`,children:e.untimed}),e.requests&&(0,J.jsx)(L1,{total:e.requests.total,split:e.requests.split}),e.tokens&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`empty ts-foot`,children:`Tokens — the runner's own counts`}),(0,J.jsx)(L1,{total:e.tokens.total,split:e.tokens.split}),e.rates.length>0&&(0,J.jsxs)(`div`,{className:`empty`,children:[`Throughput, measured sums: `,e.rates.join(` · `),`.`]})]}),e.memory.length>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`empty ts-foot`,children:`Memory — what /api/ps reported`}),e.memory.map(e=>(0,J.jsx)(`div`,{className:`empty`,children:e},e)),e.machine.map(e=>(0,J.jsx)(`div`,{className:`empty`,children:e},e))]}),e.absent.map(e=>(0,J.jsx)(`div`,{className:`empty ts-caveat`,children:e},e))]})}function Fye({res:e}){let[t,n]=(0,V.useState)(`7`),r=e.data,i=xye(t,Date.now()),a=r&&r.available===!0?r:null,o=a?k1(a.days,i):[],s=a?wye(a.days,i):[];return(0,J.jsxs)(`div`,{className:`list ts-list`,children:[(0,J.jsx)($,{res:e,empty:!r,thing:`the local runner's ledger`,noun:`read`,children:null}),r&&r.available===!1&&(0,J.jsx)(`div`,{className:`empty ts-caveat`,children:r.reason}),a&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`empty ts-caveat`,children:[`What `,a.runner,` itself did, per model, read from its server log and /api/ps since `,I1(a.since),` — whichever backend asked. Not summed with the token ledgers: those count what a client sent.`,a.loaded.length>0?` Loaded now: ${a.loaded.join(`, `)}.`:``]}),Tte(a,I1).map(e=>(0,J.jsx)(`div`,{className:`empty ts-caveat`,children:e},e)),(0,J.jsxs)(`div`,{className:`ts-filter`,children:[(0,J.jsx)(`span`,{className:`empty`,children:`over`}),bye.map(e=>(0,J.jsx)(Y,{className:t===e.id?`active`:void 0,onClick:()=>n(e.id),children:e.label},e.id))]}),o.length===0&&a.days.length>0&&(0,J.jsx)(`div`,{className:`empty ts-caveat`,children:`Nothing recorded in this span — a wider one has days.`}),o.map(e=>(0,J.jsx)(Pye,{v:e,why:a.unattributedWhy},e.key)),s.length>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsxs)(`span`,{children:[`By day `,(0,J.jsx)(`span`,{className:`section-hint`,children:`· newest first`})]})}),s.map(e=>(0,J.jsx)(v1,{label:Nye(e.day),value:``,subs:[e.model,e.text]},e.key))]})]})]})}var Iye=[`the time-of-day clock`,`the subagent slice`,`the costliest conversations`,`the expired-cache tally`,`the conversation count`,`the rate-limit window boxes`],Lye=[`input`,`output`,`cacheRead`,`cacheWrite`,`cacheWrite1h`,`turns`],Rye=[`input`,`output`,`cacheRead`,`cacheWrite`,`total`];function R1(e,t){let n={...e};for(let r of Lye)n[r]=Math.max(0,(e[r]??0)-(t[r]??0));return n}function z1(e,t){let n={...e};for(let r of Rye)n[r]=Math.max(0,(e[r]??0)-(t[r]??0));return n}var B1=e=>!de(e),V1=e=>ui(e)>0||e.turns>0;function H1(e){let t={...e},n=[];for(let r of e.byModel??[])B1(r.model)?(t=R1(t,r.totals),t.cost=z1(t.cost,r.cost)):n.push(r);return t.byModel=n,t}var U1=e=>V1(e)&&!e.byModel;function zye(e){let t=e.models.filter(e=>B1(e.key)&&V1(e));if(t.length===0)return null;let n=t.map(e=>e.key);if(e.days.some(U1)||e.hours.some(U1)||e.repos.some(U1))return{refused:`${n.join(`, `)} ${n.length===1?`is`:`are`} not Anthropic’s, but this host’s document does not split every day, hour and repo by model, so they cannot be taken out — every model is counted below. A re-scan on a current host splits them.`};let r={...e.totals},i={...e.cost},a={...e.unpriced};for(let e of t)r=R1(r,e),i=z1(i,e.cost),a=R1(a,e);let o=e.days.map(e=>{let t=H1(e);return e.agents?{...t,agents:e.agents.filter(e=>!B1(e.model))}:t}).filter(V1),s=e.hours.map(H1).filter(V1),c=e.repos.map(H1).filter(V1),l=e.models.filter(e=>!B1(e.key));return{doc:{...e,totals:r,cost:i,unpriced:a,days:o,hours:s,repos:c,models:l},local:n,localTok:t.reduce((e,t)=>e+ui(t),0),shown:l.length,all:e.models.length,unsplit:[...Iye]}}function Bye(e,t,n){let r=n?`they are on the ${n} tab`:`this host has no tab for them, so show all to include them`;return`${e.shown} of ${e.all} models shown — ${e.local.length===1?`one model is`:`${e.local.length} models are`} not Anthropic’s (${e.local.join(`, `)}, ${t(e.localTok)} tokens); ${r}. Not split by model, so still counting them: ${e.unsplit.join(`, `)}.`}function Vye(e,t){return`All ${e.all} models shown, including ${e.local.length===1?`one`:e.local.length} not Anthropic’s (${e.local.join(`, `)}, ${t(e.localTok)} tokens).`}function Hye(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,(n||1)-1,r||1).getTime()}function W1(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}`}function Uye(e){return e.some(e=>e.byRepo!=null)}function G1(e,t){let n=[];for(let r of e){if(!r.byRepo)continue;let e=0,i=0,a=0;for(let n of r.byRepo)(t==null||n.repo===t)&&(e+=n.usd,i+=n.pricedTurns,a+=n.turns);a>0&&n.push({day:r.day,t:Hye(r.day),usd:e,priced:i,turns:a})}return n}function K1(e,t=7,n=20){if(!e.length)return[];let r=new Map(e.map(e=>[e.t,e])),i=e[0].t,a=e[e.length-1].t,o=[],s=0,c=0,l=[],u=[];for(let e=new Date(i);e.getTime()<=a;e.setDate(e.getDate()+1)){let a=e.getTime(),d=r.get(a);d&&(o.push(d),s+=d.usd,c+=d.priced);let f=new Date(a);for(f.setDate(f.getDate()-(t-1));o.length&&o[0].t<f.getTime();){let e=o.shift();s-=e.usd,c-=e.priced}f.getTime()>=i&&c>=n&&s>0?u.push({t:a,day:W1(a),v:s/c,usd:s,priced:c}):u.length&&(l.push(u),u=[])}return u.length&&l.push(u),l}function q1(e,t,n){return e.map(e=>e.filter(e=>e.t>=t&&e.t<=n)).filter(e=>e.length>0)}function J1(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,(n||1)-1,r||1).getTime()}function Y1(e,t,n){let r=0,i=0,a=0;for(let o of e)o.day>t&&o.day<=n&&(r+=o.usd,i+=o.priced,a+=o.turns);return{usd:r,priced:i,turns:a}}function X1(e,t){return e.priced>=t&&e.usd>0?e.usd/e.priced:null}function Wye(e,t,n,r=20,i){let a=new Date(n);a.setHours(0,0,0,0);let o=e=>{let t=new Date(a);return t.setDate(t.getDate()-e),W1(t.getTime())},s=(e,t)=>{let n=new Date(J1(e));return n.setDate(n.getDate()-t),W1(n.getTime())},c=i?Math.round((J1(i.to)-J1(i.from))/864e5)+1:0,l=i?i.to:o(0),u=i?s(i.from,1):o(7),d=i?s(i.from,1+c):o(14),f=new Set;for(let t of e)for(let e of t.byRepo??[])f.add(e.repo);let p=new Map(t.map(e=>[e.key,e.label])),m=[],h=0;for(let t of f){let n=G1(e,t),i=n.reduce((e,t)=>({usd:e.usd+t.usd,priced:e.priced+t.priced,turns:e.turns+t.turns}),{usd:0,priced:0,turns:0}),a=X1(i,r);if(a==null){h++;continue}let o=Y1(n,u,l),s=Y1(n,d,u),c=X1(o,r),f=X1(s,r);m.push({key:t,label:p.get(t)??(t.split(`/`).pop()||t),cur:c,prev:f,change:c!=null&&f!=null?Math.round((c-f)/f*100):null,all:a,curRequests:o.priced,allRequests:i.priced,allUsd:i.usd})}return m.sort((e,t)=>(t.cur??0)*t.curRequests-(e.cur??0)*e.curRequests||t.allUsd-e.allUsd),{rows:m,hidden:h}}function Gye(e,t,n){let r=0;for(let i of e)i.day>=t&&i.day<=n&&(r+=i.turns-i.priced);return r}var Kye={top:10,right:10,bottom:20,left:46},Z1=170,Q1=1e3,$1=QE[1],e0=8;function t0(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,(n||1)-1,r||1).getTime()}var n0=e=>new Date(e).toLocaleDateString(void 0,{day:`numeric`,month:`short`});function r0({doc:e,from:t,to:n,width:r,table:i,compare:a=!1}){let[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(!1),u=(0,V.useMemo)(()=>Uye(e.days),[e]),d=t0(t),f=t0(n),p=(0,V.useMemo)(()=>G1(e.days),[e]),m=(0,V.useMemo)(()=>q1(K1(p),d,f),[p,d,f]),h=(0,V.useMemo)(()=>o?q1(K1(G1(e.days,o)),d,f):[],[e,o,d,f]),g=(0,V.useMemo)(()=>Wye(e.days,e.repos,Date.now(),void 0,a?{from:t,to:n}:void 0),[e,a,t,n]),_=(0,V.useMemo)(()=>Gye(p,t,n),[p,t,n]),v=c?g.rows:g.rows.filter((e,t)=>t<e0||e.key===o),y=o?g.rows.find(e=>e.key===o)?.label??o:null;return u?(0,J.jsxs)(J.Fragment,{children:[i?(0,J.jsx)(Jye,{runs:m}):(0,J.jsx)(qye,{all:m,mine:h,repoLabel:y,lo:d,hi:f,width:r}),m.length===0?(0,J.jsxs)(`div`,{className:`empty ts-caveat`,children:[`No stretch in this window had `,20,` priced requests in `,7,` days, so there is no price per request to draw rather than one read off a handful.`]}):(0,J.jsxs)(`div`,{className:`empty ts-caveat`,children:[`Each point is the `,7,` days up to it: their dollars over their requests. Where a week held fewer than `,20,` requests the line stops rather than guessing.`]}),_>0&&(0,J.jsxs)(`div`,{className:`empty ts-caveat`,children:[L(_),` requests in this window ran on a model with no list price and are left out of the division.`]}),(0,J.jsxs)(`details`,{className:`hint-more ctx-method`,children:[(0,J.jsx)(`summary`,{children:`why dollars over requests, and not a mean`}),(0,J.jsx)(`p`,{children:`A day of three requests at $2 and a day of three hundred at $0.05 average to about a dollar — the price of nothing that happened. Dividing the week’s dollars by the week’s requests is the price a request actually had. A request is one call to the model, a subagent’s included, so a turn that fans out is several. The line moves when conversations get longer (each request re-sends more), when a dearer model takes over, or when the cache goes cold between prompts.`})]}),(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsxs)(`span`,{children:[`By repo `,(0,J.jsxs)(`span`,{className:`section-hint`,children:[`· `,a?`this span against as many days before it`:(0,J.jsxs)(J.Fragment,{children:[`last `,7,` days against the `,7,` before`]})]})]})}),g.rows.length===0?(0,J.jsxs)(`div`,{className:`empty ctx-note`,children:[`No repo has `,20,` priced requests on record yet.`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`empty ts-caveat`,children:o?(0,J.jsxs)(J.Fragment,{children:[`Drawing `,(0,J.jsx)(`b`,{children:y}),` on the chart above. Tap it again to take it off.`]}):(0,J.jsx)(J.Fragment,{children:`Tap a repo to draw its line beside the total.`})}),(0,J.jsxs)(`div`,{className:`ts-perreq`,children:[(0,J.jsxs)(`div`,{className:`ts-perreq-row ts-perreq-head`,children:[(0,J.jsx)(`span`,{children:`repo`}),(0,J.jsx)(`span`,{children:a?`span`:`7 days`}),(0,J.jsx)(`span`,{children:a?`before`:`7 before`}),(0,J.jsx)(`span`,{children:`change`}),(0,J.jsx)(`span`,{children:`all time`})]}),v.map(e=>(0,J.jsxs)(`button`,{type:`button`,className:`ts-perreq-row${o===e.key?` on`:``}`,onClick:()=>s(o===e.key?null:e.key),children:[(0,J.jsx)(`span`,{className:`ts-perreq-name`,children:e.label}),(0,J.jsx)(`span`,{children:e.cur==null?`–`:_t(e.cur)}),(0,J.jsx)(`span`,{children:e.prev==null?`–`:_t(e.prev)}),(0,J.jsx)(`span`,{children:e.change==null?``:`${e.change>0?`+`:``}${e.change}%`}),(0,J.jsx)(`span`,{children:e.all==null?`–`:_t(e.all)})]},e.key)),g.rows.length>e0&&(0,J.jsx)(`button`,{type:`button`,className:`ts-perreq-more`,onClick:()=>l(!c),children:c?`show the first ${e0}`:`show all ${g.rows.length} (${v.length} of ${g.rows.length} listed)`})]}),(0,J.jsxs)(`div`,{className:`empty ts-caveat`,children:[`A dash is a week with fewer than `,20,` priced requests in that repo — too few to be a price.`,g.hidden>0&&(0,J.jsxs)(J.Fragment,{children:[` `,L(g.hidden),` more `,g.hidden===1?`repo has`:`repos have`,` never had that many and `,g.hidden===1?`is`:`are`,` not listed.`]})]})]})]}):(0,J.jsx)(`div`,{className:`empty ctx-note`,children:`The host has not split its days by repo yet — this appears after it is restarted on a version that does.`})}function qye({all:e,mine:t,repoLabel:n,lo:r,hi:i,width:a}){let o=Math.max(0,...e.flat().map(e=>e.v),...t.flat().map(e=>e.v))*Q1,s=NE({width:a,height:Z1,pad:Kye,points:[{t:r,v:0,day:``},{t:i,v:o,day:``}]}),c=e=>e.map(e=>e.map(e=>({...e,v:e.v*Q1}))),l=c(e),u=c(t),[d,f]=(0,V.useState)(null),p=(0,V.useRef)(null),m=(0,V.useCallback)(e=>{let t=p.current?.getBoundingClientRect();if(!t)return;let n=s.t0+((e.clientX-t.left)/t.width*a-s.x)/s.w*(s.t1-s.t0),o=new Date(n+432e5);o.setHours(0,0,0,0),f(Math.max(r,Math.min(i,o.getTime())))},[s,a,r,i]),h=(e,t)=>t==null?null:e.flat().find(e=>e.t===t)??null,g=h(e,d),_=h(t,d);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`ctx-box`,children:(0,J.jsxs)(`svg`,{ref:p,className:`ctx-chart`,width:a,height:Z1,viewBox:`0 0 ${a} ${Z1}`,onPointerDown:m,onPointerMove:m,onPointerLeave:e=>{e.pointerType===`mouse`&&f(null)},role:`img`,"aria-label":`cost per request over time`,children:[s.yTicks.map(e=>(0,J.jsx)(`line`,{x1:s.x,x2:s.x+s.w,y1:s.py(e),y2:s.py(e),stroke:`var(--line)`,strokeWidth:1},e)),l.map((e,t)=>e.length===1?(0,J.jsx)(`circle`,{cx:s.px(e[0].t),cy:s.py(e[0].v),r:2.5,fill:eD},`a${t}`):(0,J.jsx)(`path`,{d:PE(s,e),fill:`none`,stroke:eD,strokeWidth:2,strokeLinejoin:`round`,strokeLinecap:`round`},`a${t}`)),u.map((e,t)=>e.length===1?(0,J.jsx)(`circle`,{cx:s.px(e[0].t),cy:s.py(e[0].v),r:2.5,fill:$1},`m${t}`):(0,J.jsx)(`path`,{d:PE(s,e),fill:`none`,stroke:$1,strokeWidth:2,strokeLinejoin:`round`,strokeLinecap:`round`},`m${t}`)),s.yTicks.map(e=>(0,J.jsx)(`text`,{className:`ctx-tick`,x:s.x-6,y:s.py(e)+3.5,textAnchor:`end`,children:e===0?`$0`:_t(e/Q1)},`t${e}`)),HE(s).map((e,t)=>(0,J.jsx)(`text`,{className:`ctx-tick`,x:e.x,y:164,textAnchor:e.anchor,children:e.label},t)),d!=null&&(0,J.jsxs)(`g`,{children:[(0,J.jsx)(`line`,{x1:s.px(d),x2:s.px(d),y1:s.y,y2:s.y+s.h,stroke:`var(--fg)`,strokeOpacity:.35,strokeWidth:1}),g&&(0,J.jsx)(`circle`,{cx:s.px(d),cy:s.py(g.v*Q1),r:4.5,fill:eD,stroke:`var(--panel)`,strokeWidth:2}),_&&(0,J.jsx)(`circle`,{cx:s.px(d),cy:s.py(_.v*Q1),r:4.5,fill:$1,stroke:`var(--panel)`,strokeWidth:2})]})]})}),(0,J.jsxs)(`div`,{className:`ts-perreq-legend`,children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`i`,{style:{background:eD}}),`all repos`]}),n&&(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`i`,{style:{background:$1}}),n]})]}),(0,J.jsx)(`div`,{className:`ctx-readout`,children:d==null?(0,J.jsx)(iD,{}):`${n0(d)} · ${g?`${_t(g.v)} per request (${L(g.priced)} in 7 days)`:`too few requests for a price`}${n?` · ${n} ${_?_t(_.v):`–`}`:``}`})]})}function Jye({runs:e}){let t=e.flat().slice().reverse();return t.length?(0,J.jsxs)(`div`,{className:`ts-perreq`,children:[(0,J.jsxs)(`div`,{className:`ts-perreq-row ts-perreq-head ts-perreq-days`,children:[(0,J.jsxs)(`span`,{children:[7,` days to`]}),(0,J.jsx)(`span`,{children:`per request`}),(0,J.jsx)(`span`,{children:`requests`}),(0,J.jsx)(`span`,{children:`cost`})]}),t.map(e=>(0,J.jsxs)(`div`,{className:`ts-perreq-row ts-perreq-days`,children:[(0,J.jsx)(`span`,{children:n0(e.t)}),(0,J.jsx)(`span`,{children:_t(e.v)}),(0,J.jsx)(`span`,{children:L(e.priced)}),(0,J.jsx)(`span`,{children:_t(e.usd)})]},e.day))]}):null}function Yye({rows:e,width:t,normalize:n,maxColW:r,slots:i=!1,shape:a=`bars`,by:o=`kind`,bands:s}){let c=e.map(e=>({t:e.t,day:e.day,v:ui(e.totals)})),l=NE({width:t,height:170,pad:H$,points:c,yMax:n?100:void 0}),u=o===`model`&&s?[...s.bands.map(e=>({slot:e.slot,name:e.alias.replace(/^claude-/,``),at:t=>(t.src.byModel??[]).filter(t=>(nt(t.model)??t.model)===e.alias).reduce((e,t)=>e+ui(t.totals),0)})),...s.restSlot==null?[]:[{slot:s.restSlot,name:s.restName,at:e=>{let t=new Set(s.bands.map(e=>e.alias));return(e.src.byModel??[]).filter(e=>!t.has(nt(e.model)??e.model)).reduce((e,t)=>e+ui(t.totals),0)}}]]:ge.map(e=>({id:e.id,slot:e.slot,name:e.name})),d=a===`bars`?YE(l,e,u,{normalize:n,maxW:r}):[],f=a===`area`?Loe(l,e,u,{normalize:n}):[],[p,m]=(0,V.useState)(null),h=(0,V.useRef)(null),g=(0,V.useCallback)(e=>{let n=h.current?.getBoundingClientRect();n&&m(FE(l,c,(e.clientX-n.left)/n.width*t)?.day??null)},[l,c,t]);if(!e.length)return(0,J.jsx)(`div`,{className:`empty`,children:`No days in this window.`});let _=p?e.find(e=>e.day===p):null;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`svg`,{ref:h,className:`ctx-chart`,width:t,height:170,viewBox:`0 0 ${t} 170`,onPointerDown:g,onPointerMove:g,onPointerLeave:()=>m(null),onPointerCancel:()=>m(null),role:`img`,"aria-label":`${n?`share of each token kind per day`:`tokens per day by kind`}, as ${a===`area`?`stacked areas`:`stacked columns`}`,children:[l.yTicks.map(e=>(0,J.jsx)(`line`,{x1:l.x,x2:l.x+l.w,y1:l.py(e),y2:l.py(e),stroke:`var(--line)`,strokeWidth:1},e)),d.map(({point:e,bands:t})=>t.map((t,n)=>(0,J.jsx)(`rect`,{x:t.x,y:t.y,width:t.w,height:t.h,fill:$E[t.slot]??eD,fillOpacity:p&&p!==e.day?.35:.92},`${e.day}-${n}`))),f.map(e=>e.d&&(0,J.jsx)(`path`,{d:e.d,fill:$E[e.slot]??eD,fillOpacity:.9,stroke:$E[e.slot]??eD,strokeWidth:.75,strokeOpacity:.9},e.kind)),l.yTicks.map(e=>(0,J.jsx)(`text`,{className:`ctx-tick`,x:l.x-6,y:l.py(e)+3.5,textAnchor:`end`,children:n?`${Math.round(e)}%`:L(e)},`t${e}`)),a===`area`&&_&&(0,J.jsx)(`line`,{x1:l.px(_.t),x2:l.px(_.t),y1:l.y,y2:l.y+l.h,stroke:`var(--fg)`,strokeOpacity:.45,strokeWidth:1}),i?e.map(e=>(0,J.jsx)(`text`,{className:`ctx-tick`,x:l.px(e.t),y:164,textAnchor:`middle`,children:new Date(e.t).toLocaleDateString(void 0,{weekday:`short`})},`d${e.day}`)):HE(l).map((e,t)=>(0,J.jsx)(`text`,{className:`ctx-tick`,x:e.x,y:164,textAnchor:e.anchor,children:e.label},t))]}),(0,J.jsx)(`div`,{className:`ctx-readout`,children:_?`${new Date(_.t).toLocaleDateString(void 0,{day:`numeric`,month:`short`})} · ${u.map(e=>`${e.name} ${Xye(e,_,u)}`).join(` · `)}`:`drag across the chart to read a day’s split`}),(0,J.jsx)(`div`,{className:`ts-legend`,children:u.map(e=>(0,J.jsxs)(`span`,{className:`ts-leg`,title:e.id?`${e.name} — ${ge.find(t=>t.id===e.id)?.what??``}`:e.name,children:[(0,J.jsx)(`i`,{style:{background:$E[e.slot]??eD}}),e.name]},e.name))})]})}function Xye(e,t,n){let r=e=>e.at?e.at(t):e.id?t.totals[e.id]:0,i=n.reduce((e,t)=>e+r(t),0);if(i<=0)return`—`;let a=r(e)/i*100;return a>0&&a<.1?`<0.1%`:`${a.toFixed(1)}%`}function Zye({doc:e,money:t,table:n,dayCharts:r,narrow:i,chips:a=null,lead:o=null,reqSpan:s=null,rangeCaption:c,rangeWords:l,clock:u,hourNote:d,boxRef:f,width:p,running:m,dayView:h,setDayView:g,canModel:_,mixBy:v,setMixBy:y,dayArea:b,setDayShape:x,dayAreaOk:S,dailyFilled:C,daily:w,trend:T,mixFilled:E,mixRows:D,bands:O,days:k,agentDays:A,hourWords:j,hourRows:M,hourArea:N,setHourShape:P,hourlyFilled:F,hourly:ee}){return(0,J.jsx)(J.Fragment,{children:(0,J.jsxs)(O$,{title:`Over time`,chips:a,caption:c,children:[(0,J.jsx)(`div`,{className:`ctx-box`,style:{paddingTop:0},ref:f}),o,n?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(T1,{doc:e,days:k,part:`days`}),k.length>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsxs)(`span`,{children:[`Cost per request `,(0,J.jsx)(k$,{children:l})]})}),(0,J.jsx)(r0,{doc:e,from:s?.from??k[0].day,to:s?.to??k[k.length-1].day,compare:!!s,width:p,table:!0})]})]}):(0,J.jsxs)(J.Fragment,{children:[!r&&(0,J.jsx)(`div`,{className:`empty ts-caveat`,children:`A five-hour window is drawn by the hour only — a day chart of it would be one or two columns.`}),r&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsxs)(`span`,{children:[`Cumulative `,(0,J.jsx)(k$,{children:l})]})}),(0,J.jsx)(`div`,{className:`ctx-box`,children:p>0&&(0,J.jsx)(y1,{pts:m,width:p,kind:`area`,money:t})}),(0,J.jsxs)(`div`,{className:`section section-head`,children:[(0,J.jsxs)(`span`,{children:[`Per day `,(0,J.jsx)(k$,{children:l})]}),(0,J.jsxs)(`span`,{className:`ts-seg-chips`,children:[[[`total`,`total`],[`mix`,`mix`],[`share`,`share`]].map(([e,t])=>(0,J.jsx)(Y,{className:h===e?`active`:void 0,onClick:()=>g(e),children:t},e)),h!==`total`&&_&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`ts-seg-sep`,"aria-hidden":`true`}),(0,J.jsx)(Y,{className:v===`kind`?`active`:void 0,onClick:()=>y(`kind`),title:`what the traffic was made of — input, output, cache read, cache write`,children:`kind`}),(0,J.jsx)(Y,{className:v===`model`?`active`:void 0,onClick:()=>y(`model`),title:`which model carried it — the one split a migration is visible in`,children:`model`})]}),(0,J.jsx)(`span`,{className:`ts-seg-sep`,"aria-hidden":`true`}),(0,J.jsx)(Y,{className:b?void 0:`active`,onClick:()=>x(`bars`),title:`one mark per bucket — exact, and right while a column still has a width`,children:`bars`}),S&&(0,J.jsx)(Y,{className:b?`active`:void 0,onClick:()=>x(`area`),title:`the same numbers as a filled band — readable at a width where a column is a hairline`,children:`area`})]})]}),(0,J.jsx)(`div`,{className:`ctx-box`,children:p>0&&(h===`total`?(0,J.jsx)(y1,{pts:b&&C?C:w,width:p,kind:b?`area`:`columns`,money:t,trend:T,label:t?`spend per day`:`tokens per day`,maxColW:i?30:void 0}):(0,J.jsx)(Yye,{rows:b&&E?E:D,width:p,normalize:h===`share`,shape:b?`area`:`bars`,by:_?v:`kind`,bands:O,maxColW:i?30:void 0}))}),h===`total`&&(T.length>0?(0,J.jsxs)(`div`,{className:`empty ts-caveat`,children:[`Dashed line: `,7,`-day mean over calendar days.`]}):(0,J.jsxs)(`div`,{className:`empty ts-caveat`,children:[`There is not yet `,7,` days of record in this window, so the `,7,`-day mean is absent rather than approximated.`]})),!b&&!S&&(0,J.jsx)(`div`,{className:`empty ts-caveat`,children:`This window is too wide to fill in its quiet days one by one, so it is drawn as columns only — an area over an unfilled series slopes smoothly across a fortnight off, as if the work had merely tapered.`}),(0,J.jsxs)(`details`,{className:`hint-more ctx-method`,children:[(0,J.jsx)(`summary`,{children:`how to read this chart`}),(0,J.jsxs)(`p`,{children:[h===`total`?(0,J.jsxs)(J.Fragment,{children:[`The `,(0,J.jsxs)(`b`,{children:[7,`-day mean`]}),` is over calendar days — a quiet day counts as a zero, which is what makes two stretches comparable across a holiday. It starts `,7,` days into the record, because a partial window divided by a full one draws a ramp that is an artefact of the left edge and not a trend.`]}):h===`share`?v===`model`&&_?(0,J.jsxs)(J.Fragment,{children:[`Every column rescaled to 100%: this says which MODEL carried the work, not how much of it there was. It is the one chart a migration is visible in — moving from one model to another is a band crossing over, and in a total it is nothing at all. Read it beside the `,(0,J.jsx)(`b`,{children:`cost`}),` chips: the same crossing is worth 2.5× per token between opus and sonnet, and 5× against haiku.`]}):(0,J.jsxs)(J.Fragment,{children:[`Every column rescaled to 100%: this says what the MIX was, not how much. It is the one reading that can move while the total does not — cache writes climbing from 3% to 12% is a week the session shape changed, and in the `,(0,J.jsx)(`b`,{children:`cost`}),` view that is the biggest lever there is (3% of the tokens, 38% of the money).`]}):v===`model`&&_?(0,J.jsxs)(J.Fragment,{children:[`The same columns as `,(0,J.jsx)(`b`,{children:`total`}),`, split by the model that ran. At this scale one model is usually most of every column, which is the honest shape — switch to`,(0,J.jsx)(`b`,{children:` share`}),` to read the proportions, and nothing here is floor-inflated to make a band visible.`]}):(0,J.jsxs)(J.Fragment,{children:[`The same columns as `,(0,J.jsx)(`b`,{children:`total`}),`, split by kind. At this scale the three small kinds are slivers, which is the honest shape of a 96/3/0.2 split rather than a fault in the chart — switch to `,(0,J.jsx)(`b`,{children:`share`}),` to read the proportions, and nothing here is floor-inflated to make a band visible.`]}),` `,b?h===`share`?(0,J.jsxs)(J.Fragment,{children:[`Drawn as `,(0,J.jsx)(`b`,{children:`stacked areas`}),`. A day with nothing in it has no mix to rescale, so it is `,(0,J.jsx)(`b`,{children:`cut out of the band`}),` rather than filled — the holes are days off, and the proportions either side of one are not joined across it.`]}):(0,J.jsxs)(J.Fragment,{children:[`Drawn as an `,(0,J.jsx)(`b`,{children:`area`}),`, over the days filled in: the scan reads every conversation log on this desktop, so a day missing from the record is a day with no turns in it — a measured zero, which the band sits on. That is what makes the shape safe to read as a slope rather than as a line between two marks.`]}):null]})]}),k.length>0&&p>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsxs)(`span`,{children:[`Cost per request `,(0,J.jsx)(k$,{children:l})]})}),(0,J.jsx)(r0,{doc:e,from:s?.from??k[0].day,to:s?.to??k[k.length-1].day,compare:!!s,width:p,table:!1})]}),A>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsxs)(`span`,{children:[`Subagents started `,(0,J.jsx)(k$,{children:l})]})}),(0,J.jsx)(`div`,{className:`ctx-box`,children:p>0&&(0,J.jsx)(Xve,{rows:b&&E?E:D,width:p,bands:O,maxColW:i?30:void 0})}),(0,J.jsx)(w1,{bands:O}),(0,J.jsxs)(`div`,{className:`empty ts-caveat`,children:[L(e.subagentLogs),` subagent transcripts on disk; this counts those started in the window.`]}),(0,J.jsxs)(`details`,{className:`hint-more ctx-method`,children:[(0,J.jsx)(`summary`,{children:`how these are counted`}),(0,J.jsxs)(`p`,{children:[`A count of `,(0,J.jsx)(`b`,{children:`launches`}),`, not of tokens — the spend is already in every chart above, and it cannot answer this one: a day that ran one agent for an hour and a day that ran twenty for three minutes each carry the same subagent total and were nothing alike. A log is dated by its `,(0,J.jsx)(`b`,{children:`earliest`}),` record and attributed to the model that ran in it, so a long agent is one bar on the day it began rather than smeared across the days it worked.`]})]})]})]}),(0,J.jsxs)(`div`,{className:`section section-head`,children:[(0,J.jsxs)(`span`,{children:[`Per hour `,(0,J.jsx)(k$,{children:j})]}),M.length>1&&(0,J.jsxs)(`span`,{className:`ts-seg-chips`,children:[(0,J.jsx)(Y,{className:N?void 0:`active`,onClick:()=>P(`bars`),children:`bars`}),!!F&&(0,J.jsx)(Y,{className:N?`active`:void 0,onClick:()=>P(`area`),children:`area`})]})]}),M.length>1?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`ctx-box`,children:p>0&&(0,J.jsx)(y1,{pts:N&&F?F:ee,width:p,kind:N?`area`:`columns`,money:t,label:t?`spend per hour`:`tokens per hour`,stepMs:36e5,maxColW:10})}),d&&(0,J.jsx)(`div`,{className:`empty ts-caveat`,children:d}),(0,J.jsxs)(`details`,{className:`hint-more ctx-method`,children:[(0,J.jsx)(`summary`,{children:`how the hours are bucketed`}),(0,J.jsx)(`p`,{children:N?(0,J.jsx)(J.Fragment,{children:`Every hour in the window, in this desktop’s local time — the same buckets the days are a fold of, so the two can never disagree. An hour with no turn in it is drawn as the zero it was, so a night off is a floor under the band rather than a line joined across it.`}):(0,J.jsxs)(J.Fragment,{children:[`One column per hour that had a turn in it, in this desktop’s local time — the same buckets the days are a fold of, so the two can never disagree. The empty hours between the columns are axis, which is what the `,(0,J.jsx)(`b`,{children:`area`}),` form has to fill in before it may join anything.`]})})]})]}):(0,J.jsx)(`div`,{className:`empty`,children:(e.hours?.length??0)===0?`No hourly detail yet — the host records it from the next scan of the conversation logs onward.`:d??`Nothing in ${l} at hourly resolution.`})]}),(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsxs)(`span`,{children:[`Time of day `,(0,J.jsx)(k$,{children:u.tag})]})}),u.note&&(0,J.jsx)(`div`,{className:`empty ts-caveat`,children:u.note}),(0,J.jsx)(`div`,{className:`ctx-box`,children:p>0&&(0,J.jsx)(_ye,{slots:u.slots,width:p,money:t})}),(0,J.jsxs)(`details`,{className:`hint-more ctx-method`,children:[(0,J.jsx)(`summary`,{children:`how to read the clock`}),(0,J.jsx)(`p`,{children:`Every hour in the span folded onto one clock face, so this is a position rather than a date — hour 23 sits beside hour 0 of the next day in the chart above, and beside hour 22 here. The empty slots are drawn: an hour nobody has ever worked is a reading.`})]})]})})}var i0=`*all`,a0=`*runner`,o0=e=>{let t=e?.parentElement;if(!e||!t)return;let n=e.offsetLeft-t.offsetLeft;(n<t.scrollLeft||n+e.offsetWidth>t.scrollLeft+t.clientWidth)&&(t.scrollLeft=Math.max(0,n-16))},Qye={DayChart:y1,ScopeCard:O$,ScopeTag:k$};function $ye({doc:e,res:t,guests:n=[],usage:r,spend:i,usageHistory:a,online:o=!0,onRefreshUsage:s,onClose:c,onRescan:l,initialSpan:u={id:`week`,back:0},initialSource:d=`claude`,ledgerTabs:f=[],localLedgers:p=[],fresh:m=0,nameOf:h,onExplain:g,isLive:_,onOpenConvo:v,readings:y,openedOn:b=null,onClearOn:x,lead:S,liveWindows:T=!0}){let E=e&&e.cost&&e.subagentCost&&e.unpriced&&Array.isArray(e.hours)&&Array.isArray(e.hourOfDay)&&e.hourOfDay.length===24&&Array.isArray(e.days)&&e.days.every(e=>!!e.cost)&&Array.isArray(e.models)&&e.models.every(e=>!!e.cost)&&Array.isArray(e.repos)&&e.repos.every(e=>!!e.cost)?e:null,[D,k]=(0,V.useState)(!1),A=(0,V.useMemo)(()=>E?zye(E):null,[E]),j=A&&!(`refused`in A)?A:null,M=j&&!D?j.doc:E,N=f.filter(e=>e.id===`claude-local`||e.id===`claude-endpoint`).map(e=>e.label),P=N.length?N.join(` or `):null,[ee,te]=(0,V.useState)(!1),ne=Qve(y,[...n.map(e=>e.def.id),...f.map(e=>e.id)]),re=oye(b,{guests:n.map(e=>e.def.id),ledgers:f.map(e=>e.id),chips:ne.map(e=>e.source),backendOf:(y??[]).find(e=>e.source===b)?.backend??null}),[ie,ae]=(0,V.useState)(()=>d===`claude`?re.source:d),oe=dye(n),se=oe.length>0,ce=oe.find(e=>e.def.id===ie)??null,le=ce?ie:`claude`,[ue,de]=(0,V.useState)(re.extraId),fe=f.find(e=>e.id===ue)??null,pe=ue?.startsWith(`reading:`)?ne.find(e=>`reading:`+e.source===ue)??null:null,me=pe?pe.source:fe?fe.id===re.extraId&&b?b:fe.id:ue?null:ce?ie:`claude`,he=pe?(y??[]).find(e=>e.source===pe.source):void 0,ge=he?$r(he,Date.now()):null,[_e,ve]=(0,V.useState)(b??null),ye=nye(_e,me,y),be=ue===i0,xe=gh(`localusage:${m}`,()=>sx.localUsage(),{offline:!o}),Se=Sye(xe.data),Ce=ue===a0&&Se,we=se||f.length>0||Se||ne.length>0,[Te,Ee]=(0,V.useState)(`tokens`),De=Te===`cost`,Oe=(0,V.useCallback)(e=>De?e.cost?.total??0:ui(e),[De]),[ke,Ae]=(0,V.useState)(`total`),[je,Me]=(0,V.useState)(`kind`),[Pe,Fe]=(0,V.useState)(`bars`),[Ie,Le]=(0,V.useState)(`bars`),[Re,ze]=(0,V.useState)(u),Be=W$(Re.id)?{id:Re.id,back:Re.back}:null,He=e=>ze(e?{id:e.id,back:e.back}:{id:`all`,back:0}),[Ue,We]=rD(),Ge=(0,V.useMemo)(()=>new Map(P$.map(e=>[e.id,ove(e,M,r??null,Date.now())])),[M,r]),Ke=(0,V.useMemo)(()=>dve(r??null),[r]),qe=gh(`tokenwindows:${Ke.map(e=>`${e.id}@${e.anchor}`).join(`,`)}:${M?.scannedAt??0}`,()=>sx.tokenWindows(Ke),{enabled:Ke.length>0,offline:!o}),Je=gh(`usagelog:${r?.checkedAt??0}`,()=>sx.usageLog(169),{enabled:!a,offline:!o}),Ye=a??Je.data,Xe=Fve(r,Date.now()),Ze=gh(`weekcost:${Xe?.key??`none`}:${m}`,()=>sx.costWindow(Xe.from,Date.now(),m>0),{enabled:!!Xe,offline:!o}),Qe=n1(Ze.data,Xe?.from??null),$e=T&&O(i?.profile),tt=Date.now(),nt=(0,V.useMemo)(()=>{if(!T)return null;let e=xx(i?.periods,i?.budget);return e||$e?e:Ve([{id:`month`,kind:`calendar`,unit:`usd`,cycle:`month`,anchorDay:1,tz:Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`}],tt)[0]},[T,i?.periods,i?.budget,$e,Math.floor(tt/6e4)]),rt=nt?jx(nt,tt):null,it=rt&&`from`in rt?et(rt.from):null,at=gh(`periodcost:${nt?.period.id??`none`}:${it??`none`}:${m}`,()=>sx.costWindow(it,Date.now(),m>0),{enabled:it!=null,offline:!o}),ot=n1(at.data,it),st=(0,V.useMemo)(()=>new Map((qe.data?.series??[]).filter(e=>e.id===`session`||e.id===`week`).map(e=>[e.id,e])),[qe.data]),ct=(0,V.useMemo)(()=>{if(!W$(Re.id))return;let e=P$.find(e=>e.id===Re.id);if(!e)return;let t=st.get(Re.id)??null,n=t?fve(e,t,Re.back,M?.models??[]):null;return n&&F$(n)?n:Re.back===0?Ge.get(Re.id):n??void 0},[Re,st,Ge,M]),lt=ct&&F$(ct)?ct:null,ut=W$(Re.id)&&!lt?`all`:Re.id,dt=(0,V.useMemo)(()=>vve({id:ut,back:Re.back},lt,Date.now()),[ut,Re.back,lt]),ft=(0,V.useMemo)(()=>yve(M?.days??[],dt),[M,dt]),pt=G$(ut),mt=(0,V.useMemo)(()=>ft.map(e=>({day:e.day,t:C(e.day),v:Oe(e)})),[ft,Oe]),ht=(0,V.useMemo)(()=>aa(mt.map(e=>({day:e.day,total:e.v}))).map(e=>({day:e.day,t:C(e.day),v:e.sum})),[mt]),gt=(0,V.useMemo)(()=>{let e=IE((M?.days??[]).map(e=>({day:e.day,t:C(e.day),v:Oe(e)})),7);if(!mt.length)return[];let t=mt[0].t,n=mt[mt.length-1].t;return e.filter(e=>e.t>=t&&e.t<=n)},[M,Oe,mt]),_t=(0,V.useMemo)(()=>ft.map(e=>({t:C(e.day),day:e.day,totals:e,src:e})),[ft]),vt=(0,V.useMemo)(()=>Poe(M?.models??[]),[M]),yt=vt.bands.length+(vt.restSlot==null?0:1)>1&&ft.some(e=>(e.byModel?.length??0)>0),bt=(0,V.useMemo)(()=>ft.reduce((e,t)=>e+(t.agents??[]).reduce((e,t)=>e+t.count,0),0),[ft]),xt=(0,V.useMemo)(()=>bve(M?.hours??[],dt,kn),[M,dt]),St=xve(M?.hoursFrom,dt),Ct=M?.hoursFrom==null?null:new Date(M.hoursFrom).toLocaleDateString(void 0,{day:`numeric`,month:`short`}),wt=(0,V.useMemo)(()=>Woe(xt,e=>Oe(e),kn),[xt,Oe]),Tt=(0,V.useMemo)(()=>XE(mt),[mt]),Et=(0,V.useMemo)(()=>Noe(_t,(e,t)=>({t:e,day:t,totals:Vn(),src:{day:t,...Vn(),cost:ea(),byModel:[],agents:[]}})),[_t]),Dt=(0,V.useMemo)(()=>XE(wt,ME),[wt]),Ot=ke===`total`?!!Tt:!!Et,kt=Pe===`area`&&Ot,At=Ie===`area`&&!!Dt,jt=lt&&lt.back===0?lt.id:`all`,Mt=Ive(lt,Xe),Nt=!lt&&pt!=null&&pt<=35&&dt?{from:dt.from,toHour:1/0,key:`${dt.from}:d${pt}`}:null,Pt=Mt??Nt,Ft=Pt&&Pt!==`week`?Pt:null,It=gh(`costwindow:${Ft?.key??`none`}:${m}`,()=>sx.costWindow(Ft.from,Math.min(Ft.toHour,Date.now()),m>0),{enabled:!!Ft,offline:!o}),Lt=Pt===`week`?Qe:n1(It.data,Ft?.from??null),Rt=Pt===`week`?Ze:It,zt=(0,V.useMemo)(()=>Lt?vn(Lt.convos,Lt.rest).map(cee):null,[Lt]),Bt=!lt&&pt!=null&&pt>35?`The desktop folds repos over at most 35 days, so ${pt} days has no repo split — 30 days and all time do.`:null,Vt=(0,V.useMemo)(()=>Qe&&Xe?w((Ye?.samples??[]).filter(e=>e.t>=Xe.openedAt),Qe.hours,F(Qe.cost.total,r?.weeklyPct)):null,[Qe,Xe?.openedAt,Ye,r?.weeklyPct]),Ht=P$.filter(e=>F$(Ge.get(e.id))||lt?.id===e.id),Ut=(0,V.useMemo)(()=>!lt&&pt!=null?Sve(ft,M?.models??[]):null,[lt,pt,ft,M]),Wt=M?.totals,Gt=Wt?ui(Wt):0,Kt=lt?lt.totals:Ut?Ut.totals:Wt,qt=Pn(M?.coldStarts,`corpus`),Jt=lt?lt.cost:Ut?Ut.cost:M?.cost,Yt=Kt?ui(Kt):0,Xt=e=>e?new Date(C(e)).toLocaleDateString(void 0,{day:`numeric`,month:`short`}):``,Zt=lt?lt.long:pt==null?`all time`:`the last ${pt} days`,Qt=Zt,$t=ft.length?`${Xt(ft[0]?.day)} – ${Xt(ft[ft.length-1]?.day)}`:``,en=ft.length?lt?`Days touching ${lt.long}, ${$t}: the day charts count its first and last day whole, the hour chart is cut to the hour.`:pt==null?`Every day on record, ${$t}.`:`The last ${pt} calendar days, ${dt?new Date(dt.from).toLocaleDateString(void 0,{day:`numeric`,month:`short`}):``} – today.`:`No days in this span.`,tn=dt&&!St&&Ct?`Hourly detail is kept from ${Ct} on, so the hours here start there rather than at the start of the span.`:!dt&&Ct?`Hourly detail is kept from ${Ct} on; everything before that is in the day charts only.`:null,nn=tn&&Ct?`${Qt}, from ${Ct}`:Qt,rn=(0,V.useMemo)(()=>dt&&St?Cve(xt):null,[dt,St,xt]),an=rn?{slots:rn,tag:Zt}:{slots:M?.hourOfDay??[],tag:`all time`,note:dt?`The hour record starts ${Ct??`later than this span`}, so this clock counts every hour on record rather than ${Zt}.`:void 0},I=M?dt?Pt?Lt?{rows:[...Lt.convos].sort((e,t)=>t.cost.total-e.cost.total),total:Lt.cost.total,tag:`${Zt} · in money · cost inside the span`}:{rows:[],total:0,tag:`${Zt} · in money`,note:r1(Rt,`window`)}:{rows:(M.top??[]).filter(e=>e.lastAt!=null&&e.lastAt>=dt.from),total:M.cost.total,tag:`${Zt} · in money · whole-conversation cost`,note:`Of the ${M.top?.length??0} dearest conversations on record, the ones that ran in ${Zt} — each at its whole cost, and its share is of all time.`}:{rows:M.top??[],total:M.cost.total,tag:`all time · in money`}:{rows:[],total:0,tag:``},on=(0,V.useMemo)(()=>M?ave(M,Date.now()):[],[M]);return(0,J.jsxs)(J.Fragment,{children:[c&&(0,J.jsx)(Uw,{title:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(qs,{size:16,style:{verticalAlign:`-3px`,marginRight:4}}),`Token usage`]}),onClose:c,children:(0,J.jsx)(Y,{onClick:()=>{t.inflight||l()},title:ce?ce.def.rescanTitle:`re-scan the conversation logs — a point-in-time answer, not a live feed`,children:t.inflight?(0,J.jsx)($s,{size:14,className:`spin`}):(0,J.jsx)(Ds,{size:14})})}),(0,J.jsxs)(`div`,{className:`sheet-scroll`,children:[we&&(0,J.jsxs)(`div`,{className:`ts-filter ts-src`,role:`group`,"aria-label":`ledger`,children:[(0,J.jsx)(Y,{className:!fe&&!be&&!pe&&le===`claude`?`active`:void 0,onClick:()=>{de(null),ae(`claude`)},children:`Claude Code`}),oe.map(e=>(0,J.jsx)(Y,{ref:!fe&&!be&&!pe&&le===e.def.id?o0:void 0,className:!fe&&!be&&!pe&&le===e.def.id?`active`:void 0,onClick:()=>{de(null),ae(e.def.id)},children:e.def.label},e.def.id)),ne.map(e=>(0,J.jsx)(Y,{ref:pe?.source===e.source?o0:void 0,className:pe?.source===e.source?`active`:void 0,onClick:()=>de(`reading:`+e.source),children:e.label},e.source)),f.map(e=>(0,J.jsx)(Y,{ref:fe?.id===e.id?o0:void 0,className:fe?.id===e.id?`active`:void 0,onClick:()=>de(e.id),children:e.label},e.id)),Se&&(0,J.jsx)(Y,{className:Ce?`active`:void 0,onClick:()=>de(a0),children:`Local runner`}),(0,J.jsx)(Y,{className:be?`active`:void 0,onClick:()=>de(i0),children:`All backends`})]}),ye&&(0,J.jsxs)(`div`,{className:`ts-filter`,role:`group`,"aria-label":`opened on`,children:[(0,J.jsx)(`span`,{className:`empty ts-caveat`,children:ye}),(0,J.jsx)(Y,{onClick:()=>{ve(null),x?.(),de(null),ae(`claude`)},children:`all`})]}),be?(0,J.jsx)(Mye,{claude:j?.doc??E,guests:n,shownIds:oe.map(e=>e.def.id),ledgerTabs:f,runner:Se?xe.data??null:void 0,runnerTab:a0,claudeScope:j?`Anthropic models only — ${j.local.join(`, `)} ${j.local.length===1?`is`:`are`} on ${P?`the ${P} card`:`no card of their own`}.`:void 0,online:o,fresh:m,onOpen:e=>{e===`claude`||n.some(t=>t.def.id===e)?(de(null),ae(e)):de(e)}}):Ce?(0,J.jsx)(Fye,{res:xe}):pe?(0,J.jsx)(b1,{reading:ge,online:o}):fe?(0,J.jsx)(uye,{id:fe.id,label:fe.label,online:o||p.includes(fe.id),fresh:m,table:ee,onTable:te,reading:(()=>{let e=sye(y,fe.id);return e?$r(e,Date.now()):null})()}):le===`claude`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`ts-now`,children:[S,$e&&(0,J.jsx)(Jve,{usage:r??null,onRefresh:s,history:Ye,compact:!0,cuts:Ge,scope:jt,onScope:e=>ze(e===`all`?{id:`all`,back:0}:{id:e,back:0})}),M&&Gt>0&&$e&&(0,J.jsx)(Uve,{doc:Qe,res:Ze,openedAt:Xe?.openedAt??null,samples:Ye?.samples??[],everyMs:Ye?.everyMs??0,cal:Vt,compact:!0,nameOf:h,onExplain:g,isLive:_,onOpenConvo:v}),M&&Gt>0&&nt&&(0,J.jsx)(Kve,{state:nt,cap:yx(i?.budget,nt.period.id),doc:ot,res:at,refusal:rt&&`refusal`in rt?rt.refusal:null,now:tt})]}),M&&Gt>0&&(0,J.jsxs)(`div`,{className:`ts-global`,children:[(0,J.jsx)(`div`,{className:`ts-filter`,role:`group`,"aria-label":`span`,children:U$.filter(e=>!W$(e.id)||Ht.some(t=>t.id===e.id)).map(e=>(0,J.jsx)(Y,{className:ut===e.id?`active`:void 0,onClick:()=>ze({id:e.id,back:0}),children:e.label},e.id))}),(0,J.jsxs)(`div`,{className:`ts-filter`,role:`group`,"aria-label":`count in`,children:[(0,J.jsx)(`span`,{className:`ctx-stackpick-lab`,children:`count in`}),(0,J.jsx)(Y,{className:De?void 0:`active`,onClick:()=>Ee(`tokens`),children:`tokens`}),(0,J.jsx)(Y,{className:De?`active`:void 0,onClick:()=>Ee(`cost`),children:`cost`}),(0,J.jsx)(`span`,{className:`ts-seg-sep`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`ctx-stackpick-lab`,children:`show as`}),(0,J.jsx)(Y,{className:ee?void 0:`active`,onClick:()=>te(!1),children:`chart`}),(0,J.jsx)(Y,{className:ee?`active`:void 0,onClick:()=>te(!0),children:`values`})]})]}),se&&(0,J.jsx)(`div`,{className:`empty ts-caveat`,children:fye(oe)}),A&&`refused`in A&&(0,J.jsx)(`div`,{className:`empty ts-caveat`,children:A.refused}),j&&(0,J.jsxs)(`div`,{className:`ts-filter`,role:`group`,"aria-label":`models`,children:[(0,J.jsx)(`span`,{className:`empty ts-caveat`,children:D?Vye(j,L):Bye(j,L,P)}),(0,J.jsx)(Y,{onClick:()=>k(e=>!e),children:D?`Anthropic’s ${j.shown} only`:`show all ${j.all} models`})]}),(0,J.jsx)($,{res:t,empty:!M||!Gt,thing:`the token statistics`,noun:`scan`,note:`These are read out of the CLI’s own conversation logs, so a machine that has not run it yet has nothing to count.`,children:j&&!D?`Every token in Claude Code’s logs is from a model that is not Anthropic’s — nothing to count on this view.`:`No conversation logs on this desktop yet — nothing to count.`}),M&&Gt>0&&(0,J.jsxs)(`div`,{className:`list ts-list`,children:[(0,J.jsx)(nve,{items:on}),(0,J.jsx)(yye,{doc:M,money:De,table:ee,active:lt,dcut:Ut&&pt!=null?{cut:Ut,calendarDays:pt,caption:en}:null,scope:Be,setScope:He,grids:st,hist:qe,shownTotals:Kt,shownCost:Jt,shownTok:Yt,coldNote:qt,scopeWords:Zt,bands:vt,canModel:yt,days:ft,nameOf:h,onExplain:g,isLive:_,onOpenConvo:v,scopeRepos:zt,scopeRes:Rt,reposRefusal:Bt,top:I,weekTwin:Pt===`week`&&!!Qe,pts:(e,t)=>zve(t,Xe?.from)?Ne(e,Vt):null}),(0,J.jsx)(Zye,{doc:M,money:De,table:ee,dayCharts:ut!==`session`,narrow:ft.length<=14,rangeCaption:en,rangeWords:Qt,clock:an,hourNote:tn,reqSpan:dt?{from:K$(dt.from),to:K$(Math.max(dt.from,dt.to-1))}:null,boxRef:We,width:Ue,running:ht,dayView:ke,setDayView:Ae,canModel:yt,mixBy:je,setMixBy:Me,dayArea:kt,setDayShape:Fe,dayAreaOk:Ot,dailyFilled:Tt,daily:mt,trend:gt,mixFilled:Et,mixRows:_t,bands:vt,days:ft,agentDays:bt,hourWords:nn,hourRows:xt,hourArea:At,setHourShape:Le,hourlyFilled:Dt,hourly:wt}),(0,J.jsxs)(`div`,{className:`empty ts-foot`,children:[M.scannedAt?(0,J.jsxs)(J.Fragment,{children:[`Scanned `,M.logs.toLocaleString(),` conversation logs`,M.reread?`, ${M.reread.toLocaleString()} re-read`:``,` at `,new Date(M.scannedAt).toLocaleTimeString(),`. `]}):null,`Counts every log currently on this desktop, including `,M.subagentLogs.toLocaleString(),` subagent transcripts — a conversation deleted from the archive stops counting.`]})]})]}):ce?(0,J.jsx)(ce.def.View,{doc:ce.doc??null,res:ce.res,table:ee,onTable:te,backend:ce.backend,parts:Qye}):null]})]})}function ebe({def:e,fresh:t,online:n,onRead:r}){let i=sx.viewDoc(e),a=gh(`ledgerview:${e.id}:${t}`,()=>i.read(t>0),{offline:!n,fromCache:i.fromCache,toCache:i.toCache});return(0,V.useEffect)(()=>{r(e.id,{doc:a.data??null,res:{state:a.state,age:a.age,error:a.error}})},[e.id,a.data,a.state,a.age,a.error,r]),null}function tbe({online:e,ledgerTabs:t,usage:n,spend:r,onRefreshUsage:i,onClose:a,nameOf:o,onExplain:s,isLive:c,onOpenConvo:l,views:u=[],backends:d,readings:f,openedOn:p,onClearOn:m}){let[h,g]=(0,V.useState)(0),_=gh(`tokenstats:${h}`,()=>sx.tokenStats.read(h>0),{offline:!e,fromCache:sx.tokenStats.fromCache,toCache:sx.tokenStats.toCache}),[v,y]=(0,V.useState)(new Map),[b]=(0,V.useState)(()=>(e,t)=>y(n=>new Map(n).set(e,t))),x=u.map(e=>({def:e,doc:null,...v.get(e.id),backend:d?.find(t=>t.id===e.id)}));return(0,J.jsxs)(`div`,{className:`sheet`,children:[u.map(t=>(0,J.jsx)(ebe,{def:t,fresh:h,online:e,onRead:b},t.id)),(0,J.jsx)($ye,{doc:_.data,res:_,guests:x,usage:n,spend:r,online:e,onRefreshUsage:i,onClose:a,onRescan:()=>g(e=>e+1),nameOf:o,onExplain:s,isLive:c,onOpenConvo:l,ledgerTabs:t,fresh:h,readings:f,openedOn:p,onClearOn:m})]})}function nbe(e,t){let n=zx({title:t,cwd:e.repo,claudeSessionId:e.id});if(!n)return;let r=U();r.say.track(`action:tokens.explainCost`),r.nav.close(`tokens`),r.nav.startSessionWithPrompt(e.repo,`cost of ${t}`,[n])}function rbe(){let e=Dh(),t=e.world.usage,{sessions:n,recent:r}=e.world,i=e=>n.find(t=>t.claudeSessionId===e),a=sx.views(),[o]=(0,V.useState)(()=>e.world.tokensOpenOn);return(0,V.useEffect)(()=>{U().world.clearTokensOn()},[]),(0,J.jsx)(tbe,{readings:e.world.usageReadings,openedOn:o,onClearOn:e.world.clearTokensOn,online:e.conn.status===`open`,views:a,backends:e.world.backends,ledgerTabs:Q_e(e.world.backends,a.map(e=>e.id)),usage:t,spend:{profile:e.world.billing?.profile??null,budget:e.world.budget?.budget??null,periods:e.world.budget?.periods??null},onRefreshUsage:sx.refreshUsage,onClose:()=>{e.world.clearTokensOn(),e.nav.close(`tokens`)},nameOf:t=>{let n=i(t);return n?e.world.sessionRowTitle(n):r.find(e=>e.claudeSessionId===t)?.title||void 0},onExplain:nbe,isLive:e=>!!i(e),onOpenConvo:t=>{let n=i(t);n&&(e.nav.attach(n),e.nav.open(`context`))}})}var ibe=e({manifest:()=>abe}),abe={id:`token-stats`,sheets:[{id:`tokens`,persisted:!0,render:()=>(0,V.createElement)(rbe)}]};function obe(e,t,n=300){return[t,...e.filter(e=>e.id!==t.id)].sort((e,t)=>t.ts-e.ts).slice(0,n)}var s0=W([]),c0=W(null);function sbe(e){let t=U();c0.set(e),t.conn.liveAsk(e?{t:`sent.get`,sessionId:e}:{t:`sent.get`}),t.nav.open(`sentlog`)}function cbe(e){let t=e.world.active;t?(c0.set(t.id),e.conn.send({t:`sent.get`,sessionId:t.id}),e.nav.open(`sentlog`)):e.say.toast(`no active session`)}function lbe(e){s0.set(t=>obe(t,e))}var ube={compose:{label:`you typed it`,Icon:Yte},backlog:{label:`backlog item`,Icon:Za},fanout:{label:`fan-out`,Icon:Ec},"fanout-followup":{label:`fan-out follow-up`,Icon:Ec},create:{label:`new session's first prompt`,Icon:Do},plugin:{label:`plugin auto-answer`,Icon:Yo},phone:{label:`your typed answer to the CLI's question`,Icon:Ite},oracle:{label:`oracle auto-answer (legacy)`,Icon:Uo},limit:{label:`usage-limit auto-continue`,Icon:go}},l0={ok:{label:`delivered · turn started`,Icon:vc,cls:`sug`},written:{label:`written (not confirmed)`,Icon:Ec,cls:`fire`},retry:{label:`nothing typed`,Icon:fs,cls:`muted`},unconfirmed:{label:`typed, never seen on screen`,Icon:gs,cls:`defer`},unsubmitted:{label:`in the composer, not submitted`,Icon:gs,cls:`defer`},failed:{label:`failed`,Icon:gs,cls:`err`}},dbe={landed:{label:`settled: it ran`,cls:`sug`},composer:{label:`settled: sitting in the composer`,cls:`defer`},absent:{label:`settled: it never ran`,cls:`err`},unknown:{label:`settled: still unreadable`,cls:`muted`}},u0={all:`all`,auto:`automatic`,user:`yours`},d0=(e,t)=>t===`all`||e.actor===t;function fbe(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function pbe({entries:e,filterSessionId:t,sessionTitle:n,onClose:r,onRefresh:i,onClear:a,onOpenSession:o}){let[s,c]=(0,V.useState)(new Set),[l,u]=(0,V.useState)(`all`),d=e=>c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),f=(0,V.useMemo)(()=>e.filter(e=>!t||e.sessionId===t),[e,t]),p=e=>f.filter(t=>d0(t,e)).length,m=p(`auto`),h=m>0&&m<f.length,g=h?l:`all`,_=(0,V.useMemo)(()=>f.filter(e=>d0(e,g)).slice().sort((e,t)=>t.ts-e.ts),[f,g]);return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Rs,{size:16,style:{verticalAlign:`-3px`,marginRight:4}}),`Sent commands`,n?` · ${n}`:``]}),onClose:r,children:(0,J.jsxs)(`span`,{className:`head-acts tight`,children:[(0,J.jsx)(Y,{onClick:i,title:`refresh`,children:(0,J.jsx)(Ds,{size:16})}),e.length>0&&(0,J.jsx)(fC,{className:`key`,title:`clear the log`,confirmTitle:`tap again to clear the sent-command log`,confirm:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ws,{size:16}),` sure?`]}),onConfirm:a,children:(0,J.jsx)(ws,{size:16})})]})}),(0,J.jsxs)(Z,{children:[`Every command this app typed into a session.`,(0,J.jsx)(tT,{of:`the sent log`,children:`Including the ones it decided on by itself (backlog, fan-out, plugin auto-answers, usage-limit auto-continue). One row per command, stamped with how the delivery ended; tap a row's text to read all of it, or “open the session” to check it against the terminal.`})]}),h&&(0,J.jsx)(`div`,{className:`fchips wrap olog-kinds`,children:[`all`,`auto`,`user`].map(e=>(0,J.jsxs)(zw,{on:g===e,clears:!1,onClick:()=>u(e),children:[u0[e],` · `,p(e)]},e))}),g!==`all`&&(0,J.jsxs)(Pw,{onClear:()=>u(`all`),clearLabel:`show all`,children:[`Showing `,u0[g],` only: `,_.length,` of `,f.length]}),(0,J.jsxs)(`div`,{className:`list hist`,children:[(0,J.jsx)($,{empty:_.length===0,children:`Nothing sent yet.`}),_.map(e=>{let n=ube[e.source]??{label:e.source,Icon:Ec},r=l0[e.result]??l0.written,i=e.settled?dbe[e.settled]:null,a=s.has(e.id),c=e.text.replace(/\s+/g,` `).trim();return(0,J.jsxs)(`div`,{className:`olog-row`,children:[(0,J.jsxs)(`div`,{className:`olog-head`,children:[(0,J.jsxs)(qw,{className:`oracle-${r.cls}`,children:[(0,J.jsx)(r.Icon,{size:12}),` `,r.label]}),i&&(0,J.jsxs)(qw,{className:`oracle-${i.cls}`,title:e.settledDetail??(e.settledAt?`settled ${Tp(e.settledAt)}`:void 0),children:[(0,J.jsx)(vc,{size:12}),` `,i.label]}),(0,J.jsxs)(qw,{title:e.actor===`auto`?`the app decided on this one`:`you sent this`,children:[e.actor===`auto`?(0,J.jsx)(Uo,{size:12}):(0,J.jsx)(Ms,{size:12}),` `,n.label]}),(0,J.jsxs)(`span`,{className:`olog-when`,title:new Date(e.ts).toLocaleString(),children:[fbe(e.ts),` · `,Tp(e.ts)]})]}),(0,J.jsxs)(`button`,{className:`olog-body`,onClick:()=>d(e.id),title:a?`collapse`:`show the full text`,children:[(0,J.jsx)(`code`,{className:a?`sent-text open`:`sent-text`,children:a?e.text:c}),e.truncated&&a&&(0,J.jsx)(Z,{as:`span`,children:` …(truncated for the log)`})]}),e.detail&&(0,J.jsx)(`div`,{className:`olog-why`,children:e.detail}),e.settledDetail&&(0,J.jsx)(`div`,{className:`olog-why`,children:e.settledDetail}),(0,J.jsxs)(`div`,{className:`olog-foot`,children:[!t&&(0,J.jsx)(`span`,{className:`olog-sess`,children:e.sessionTitle}),(0,J.jsxs)(`button`,{className:`link-btn`,onClick:()=>o(e.sessionId),children:[`open the session `,(0,J.jsx)(Hs,{size:12,style:{verticalAlign:`-2px`}})]})]})]},e.id)})]})]})}function mbe(){let e=Dh(),t=G(s0),n=G(c0);return(0,J.jsx)(pbe,{entries:t,filterSessionId:n,sessionTitle:n?e.world.sessions.find(e=>e.id===n)?.title:void 0,onClose:()=>e.nav.close(`sentlog`),onRefresh:()=>e.conn.liveAsk({t:`sent.get`,sessionId:n??void 0}),onClear:()=>{e.conn.send({t:`sent.clear`}),e.say.toast(`sent-command log cleared`)},onOpenSession:t=>{let n=e.world.sessions.find(e=>e.id===t);n?e.nav.attach(n):e.say.toast(`that session is no longer open`)}})}var hbe={id:`sentLog`,sheets:[{id:`sentlog`,persisted:!1,render:()=>(0,V.createElement)(mbe)}],commands:[{id:`sent`,run:cbe}],messages:{"sent.log":e=>s0.set(e.entries),"sent.new":e=>lbe(e.entry)}},gbe={healthy:0,unknown:0,degraded:1,broken:2},f0=e=>gbe[e]??0;function _be(e,t){return e!=null&&f0(t)>f0(e)}function vbe(e){return!!e&&(e.verdict===`degraded`||e.verdict===`broken`)}function ybe(e){let t=[];return e.broken.length>0&&t.push(`broken`),e.degraded.length>0&&t.push(`degraded`),t}function bbe(e){return[e.broken.length>0?`${e.broken.length} broken`:``,e.degraded.length>0?`${e.degraded.length} degraded`:``].filter(Boolean).join(` · `)}var p0=new Set([`limit.reset`]);function xbe(e,t){let n=[`Inspect a ${e.verdict} CLI-health signal: \`${e.id}\` — ${e.name}.`,``,`claude ${e.version??`(version unknown)`}`,`The board says: ${e.sentence}`];e.via&&n.push(`Fell back to: ${e.via}`),e.stats&&n.push(`Counts: ${e.stats}`),e.sample&&!p0.has(e.id)&&n.push(`Last captured input (redacted${e.sampleAgo?`, ${e.sampleAgo}`:``}):`,"```",e.sample,"```");let r=`${t.stateDir}/clihealth.json`;return n.push(``,`Where to look:`,`- the record: ${r} — \`signals["${e.id}"]\`${e.sample&&p0.has(e.id)?" (its `sample` is a block notice: read it, never print it)":``}`,`- what this signal read when it WORKED on this CLI: ${t.stateDir}/clifixtures/${e.version??`<version>`}/`,`- the catalog: packages/shared/src/clihealth/healthcatalog.ts; the observation sites: grep \`"${e.id}"\` in packages/host/src`,``,"Load the `heuristics` skill first. Find why the primary rule missed on this CLI version: if the CLI changed, fix the reader and pin the new shape with a test (tools/harvestfixtures.mjs for the capture); if the misses are false alarms (a rule correctly declining), fix where the observation is recorded instead. Say which it was."),n.join(`
79
+ `)}var m0=W(OT()?.value.rollup??null),h0=W(null);function Sbe(){return G(m0)}var g0={current:null},_0={current:[]},v0=6e3;function Cbe(){return new Promise((e,t)=>{let n=U();if(n.conn.status!==`open`){t(new Ce(`clihealth`,0));return}let r=setTimeout(()=>{_0.current=_0.current.filter(e=>e!==i),t(new Ce(`clihealth`,v0))},v0),i=t=>{clearTimeout(r),e(t)};_0.current.push(i),n.conn.send({t:`clihealth.get`})})}function wbe(e){let t={health:e.health,rollup:e.rollup,source:e.source};kT(t),m0.set(e.rollup);for(let e of _0.current.splice(0))e(t);let n=g0.current;if(g0.current=e.rollup.verdict,_be(n,e.rollup.verdict)){let t=e.rollup.lines[0];t&&U().say.toast(t)}}function Tbe(e,t){let n=U();n.say.track(`action:clihealth.inspect`),n.nav.openSend({prompts:[xbe(e,t)],target:{kind:`repo`,cwd:t.repo},when:{kind:`now`},cwdHint:t.repo,origin:`From CLI health`})}function y0(e=null){h0.set(e),U().nav.open(`clihealth`)}var Ebe=864e5,b0={healthy:`working`,degraded:`degraded`,broken:`broken`,unknown:`unknown`};function Dbe({online:e,request:t,onClose:n,filter:r,onClearFilter:i,onClearWarnings:a,onInspect:o}){let s=gh(`clihealth`,t,{offline:!e,fromCache:async()=>OT()}),c=s.data,l=(0,V.useMemo)(()=>Date.now(),[c]),u=c?Hi.map(e=>c.health.signals[e.id]??mee(e.id,c.health.version)):[],d=r&&r.length>0?u.filter(e=>r.includes(Yi(e,l).verdict)):u,f=u.filter(e=>{let t=Yi(e,l).verdict;return(t===`degraded`||t===`broken`)&&e.lastMissAt!=null}),p={};for(let e of f)p[e.id]=e.lastMissAt;let m=c?.rollup,h=c?.health.versionChangedAt??null,g=h!=null&&l-h<Ebe;return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Kw,{title:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Os,{size:16,style:{verticalAlign:`-3px`,marginRight:4}}),`CLI health`]}),onClose:n,bare:!0,iconSize:14,onRefresh:()=>s.reload(),refreshTitle:`re-read — the board is a point-in-time answer, not a live feed`}),(0,J.jsx)(Z,{children:`Every point where this app reads something it does not own: the choice-box detector, the hook pipe, the echo probe, the conversation log. Each one degrades to nothing rather than to a wrong answer — this is where that nothing gets said out loud.`}),(0,J.jsxs)(`div`,{className:`list`,children:[m&&(0,J.jsxs)(`div`,{className:`cli-summary cli-${m.verdict}`,children:[(0,J.jsx)(`span`,{className:`cli-pill cli-${m.verdict}`,children:b0[m.verdict]}),(0,J.jsxs)(`span`,{className:`cli-summary-txt`,children:[m.broken.length+m.degraded.length>0?`${m.broken.length?`${m.broken.length} broken`:``}${m.broken.length&&m.degraded.length?` · `:``}${m.degraded.length?`${m.degraded.length} degraded`:``}`:`nothing is failing`,m.unknown.length>0&&(0,J.jsxs)(J.Fragment,{children:[` · `,m.unknown.length,` not observed lately`]})]}),(0,J.jsxs)(`span`,{className:`cli-summary-ver`,children:[`claude `,c?.health.version??`?`,c?.health.versionSeenAt!=null&&(0,J.jsxs)(J.Fragment,{children:[` · seen `,Er(l-c.health.versionSeenAt),` ago`]})]}),g&&(0,J.jsxs)(`span`,{className:`cli-rearm`,children:[`The CLI changed `,Er(l-(h??l)),` ago — every signal’s history was cleared, so a verdict here is about this version only.`]}),a&&f.length>0&&(0,J.jsxs)(fC,{className:`key cli-clear`,title:`you have read these: drop their misses so the board reads clean until something new fails`,confirm:(0,J.jsxs)(J.Fragment,{children:[`clear `,f.length===1?`it`:`all ${f.length}`,` — read?`]}),onConfirm:()=>{a(p,f.length)&&s.reload()},children:[(0,J.jsx)(vc,{size:13}),` clear `,f.length,` warning`,f.length===1?``:`s`]})]}),r&&r.length>0&&u.length>0&&(0,J.jsxs)(Pw,{section:!0,onClear:i,clearTitle:`show every signal, including the ${u.length-d.length} working or unobserved ones`,clearLabel:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(B,{size:13}),` show all `,u.length]}),children:[`showing `,r.map(e=>b0[e]).join(` and `),` · `,d.length,` of `,u.length,d.length===0&&` — nothing is in that state any more`]}),(0,J.jsx)($,{res:s,empty:u.length===0,thing:`the CLI health record`,noun:`health board`,children:`The host answered with no health record at all.`}),d.map(e=>(0,J.jsx)(Obe,{sig:e,now:l,version:c?.health.version??null,onInspect:o&&c?.source?e=>o(e,c.source):void 0},e.id))]})]})}function Obe({sig:e,now:t,version:n,onInspect:r}){let i=an(e.id),a=Yi(e,t),o=tr(e,e.lastFallbackAt),s=tr(e,e.sampleAt);return(0,J.jsxs)(`div`,{className:`cli-row cli-${a.verdict}`,children:[(0,J.jsxs)(`div`,{className:`cli-row-top`,children:[(0,J.jsx)(`span`,{className:`cli-name`,children:i.name}),(0,J.jsx)(`span`,{className:`cli-pill cli-${a.verdict}`,children:b0[a.verdict]})]}),(0,J.jsx)(`div`,{className:`cli-say`,children:Oi(e,t)}),e.via&&(0,J.jsxs)(`div`,{className:o?`cli-via cli-past`:`cli-via`,children:[o?(0,J.jsxs)(J.Fragment,{children:[`Fell back to `,(0,J.jsx)(`b`,{children:e.via})]}):(0,J.jsxs)(J.Fragment,{children:[`Falling back to `,(0,J.jsx)(`b`,{children:e.via})]}),e.lastFallbackAt!=null&&(0,J.jsxs)(J.Fragment,{children:[` · last `,Er(t-e.lastFallbackAt),` ago`]}),o&&(0,J.jsx)(J.Fragment,{children:` · working again since then`})]}),e.sample&&(0,J.jsxs)(`pre`,{className:s?`cli-sample cli-past`:`cli-sample`,children:[e.sample,e.sampleAt!=null&&(0,J.jsxs)(`span`,{className:`cli-sample-at`,children:[` (`,Er(t-e.sampleAt),` ago`,s?`, working again since then`:``,`)`]})]}),i.means&&(0,J.jsxs)(`details`,{className:`cli-means`,children:[(0,J.jsxs)(`summary`,{children:[(0,J.jsx)(Nc,{size:12}),` what this breaks`]}),(0,J.jsx)(`div`,{children:i.means}),i.fallback&&(0,J.jsxs)(`div`,{className:`cli-means-fb`,children:[`Without it, the app falls back to `,i.fallback,`.`]})]}),(0,J.jsxs)(`div`,{className:`cli-stats`,children:[a.rate!=null&&(0,J.jsxs)(J.Fragment,{children:[a.failed,` of the last `,a.samples,` failed · `]}),e.totalGood+e.totalMiss>0&&(0,J.jsxs)(J.Fragment,{children:[e.totalGood,` good / `,e.totalMiss,` missed all-time`]})]}),r&&(a.verdict===`degraded`||a.verdict===`broken`)&&(0,J.jsxs)(Y,{className:`cli-inspect`,type:`button`,title:`open the Send sheet with this row's facts and where its record and captures live, aimed at a new session in the checkout`,onClick:()=>r({id:e.id,name:i.name,verdict:a.verdict,version:n,sentence:Oi(e,t),via:e.via?`${e.via}${e.lastFallbackAt==null?``:` · last ${Er(t-e.lastFallbackAt)} ago`}`:void 0,sample:e.sample??void 0,sampleAgo:e.sampleAt==null?void 0:`${Er(t-e.sampleAt)} ago`,stats:[a.rate==null?``:`${a.failed} of the last ${a.samples} failed`,e.totalGood+e.totalMiss>0?`${e.totalGood} good / ${e.totalMiss} missed all-time`:``].filter(Boolean).join(` · `)||void 0}),children:[(0,J.jsx)(vl,{size:13}),` inspect in a session`]})]})}function kbe(){let e=Dh(),t=G(h0);return(0,J.jsx)(Dbe,{online:e.conn.status===`open`,request:Cbe,onClose:()=>e.nav.close(`clihealth`),filter:t,onClearFilter:()=>h0.set(null),onInspect:Tbe,onClearWarnings:(t,n)=>e.conn.liveSend({t:`clihealth.clear`,through:t},`Cleared ${n} warning${n===1?``:`s`} — a new miss brings ${n===1?`it`:`them`} back.`)})}function Abe(){let e=Sbe();return(0,J.jsx)(rC,{id:`tool-cli-health`,compact:!0,label:`CLI health`,icon:Os,tone:e?.verdict===`broken`?`danger`:e?.verdict===`degraded`?`warn`:void 0,title:`every point where this app reads something it does not own — the choice-box detector, the hook pipe, the echo probe, the conversation log`,onClick:()=>{q(`overlay:clihealth`),y0(null)}})}var jbe=16;function Mbe(){let e=G(m0);if(!vbe(e))return null;let t=bbe(e),n=e.lines[0]??`the CLI integration is degraded`;return(0,J.jsxs)(Y,{className:`cli-health-key ${e.verdict===`broken`?`danger`:`warn`}`,title:`CLI: ${t}\n${n}\ntap for just these`,"aria-label":`CLI health — ${t}. ${n}. tap for just these`,onClick:()=>y0(ybe(e)),children:[(0,J.jsx)(Os,{size:jbe}),(0,J.jsx)(`span`,{className:`cli-health-badge`,children:e.broken.length+e.degraded.length})]})}var Nbe={id:`cliHealth`,sheets:[{id:`clihealth`,persisted:!0,render:()=>(0,V.createElement)(kbe),onLeave:()=>h0.set(null)}],messages:{clihealth:e=>wbe(e)},settings:[{group:`tools`,order:-10,render:()=>(0,V.createElement)(Abe)}]},x0=W({text:``,source:`grid`}),S0=W(``),C0=W({lines:[],from:`screen`}),w0=W({});function Pbe(){let e=Dh(),t=e.compose.draft,[n,r]=(0,V.useState)(()=>S0.get()),i=n.length;async function a(){if(!window.isSecureContext||!navigator.clipboard?.readText)e.say.toast(`clipboard read needs https — long-press the box and paste`);else try{let t=await navigator.clipboard.readText();if(!t){e.say.toast(`phone clipboard is empty`);return}r(t),e.say.toast(`pasted ${t.length} chars`)}catch{e.say.toast(`phone clipboard unavailable — long-press the box and paste`)}}async function o(t){if(!t.trim())e.say.toast(`nothing to send — type or paste text first`);else try{let n=await H.setClipboard(t);n.ok?(e.say.toast(`sent ${n.chars??t.length} chars to desktop clipboard`),e.nav.close(`clip`)):e.say.toast(`clipboard failed: ${n.error??`?`}`)}catch{e.say.toast(`clipboard failed`)}}return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:`To desktop clipboard`,onClose:()=>e.nav.close(`clip`)}),(0,J.jsx)(Z,{children:`Puts text on the DESKTOP's system clipboard — nothing is typed into the session. Paste your phone's clipboard, pull in the compose draft, or just type below.`}),(0,J.jsx)(`textarea`,{className:`text-dump mono`,autoFocus:!0,placeholder:`text to put on the desktop clipboard…`,value:n,onChange:e=>r(e.target.value)}),(0,J.jsxs)(`div`,{className:`sheet-actions`,children:[(0,J.jsxs)(Y,{onClick:()=>void a(),children:[(0,J.jsx)(so,{size:16}),` phone clipboard`]}),t.trim()&&t!==n?(0,J.jsxs)(Y,{onClick:()=>r(t),children:[(0,J.jsx)(Ka,{size:16}),` compose draft`]}):null,i?(0,J.jsxs)(Y,{onClick:()=>r(``),children:[(0,J.jsx)(ul,{size:16}),` clear`]}):null,(0,J.jsx)(`div`,{className:`spacer`}),(0,J.jsxs)(`button`,{className:`send`,disabled:!n.trim(),onClick:()=>void o(n),children:[(0,J.jsx)(rs,{size:16}),` send`,i?` ${i}`:``]})]})]})}function Fbe(e){return e?`No text to copy yet.
80
+
81
+ The terminal is not on screen (reader view), and no transcript for this session is cached on this phone. Open the reader once while connected, then try again.`:`No session on screen.`}function T0(e){let t=e.trim();return t?`Quote from your last response:\n${t.split(`
82
+ `).map(e=>`> ${e}`).join(`
83
+ `)}\n\n`:null}var Ibe=/^(\s*)(\d{1,2})[.)]\s+(\S.*)$/,Lbe=/^(\s*)[-•*]\s+(\S.*)$/,E0=/^\s*(?:[─━—_=-]{3,}|❯|>\s*$|\[[A-Z]+\]$)/;function D0(e){let t=/^\*{0,2}([^:?]{2,40}?)\*{0,2}:\s/.exec(e);if(t)return t[1].trim();let n=e.split(/\s+/).slice(0,5).join(` `);return n.length<e.length?`${n.replace(/[,.;:]$/,``)}…`:n}function O0(e){let t=e.replace(/^[^:?]{2,40}:\s/,``).split(/(?<=[.?!])\s+/).find(e=>e.endsWith(`?`));if(!t)return[];let n=t.slice(0,-1).split(/,?\s+or\s+/i).map(e=>e.trim().replace(/^(?:either|whether)\s+/i,``)).filter(Boolean);return n.length<2||n.length>3||n.some(e=>e.length>28)?[]:n}function Rbe(e){let t=(t,n)=>{let r=[],i=null,a=()=>{if(!i)return;let e=i.parts.join(` `);r.push({num:i.num,label:D0(e),text:e,options:O0(e)}),i=null};for(let r of e){let e=t.exec(r);if(e){a(),i=n?{num:e[2],indent:e[1].length,parts:[e[3].trim()]}:{num:``,indent:e[1].length,parts:[e[2].trim()]};continue}let o=/^\s*/.exec(r)[0].length;i&&r.trim()&&o>i.indent&&!E0.test(r)?i.parts.push(r.trim()):a()}return a(),r},n=t(Ibe,!0);if(n.length)return n;let r=t(Lbe,!1);return r.length?r:e.map(e=>e.trim()).filter(e=>e&&!E0.test(e)).map(e=>({num:``,label:D0(e),text:e,options:O0(e)}))}function zbe(e,t){let n=e.flatMap((e,n)=>{let r=(t[n]??``).trim();return r?[`${e.num?`${e.num}. `:``}${e.label}: ${r}`]:[]});return n.length?`My decisions:\n${n.join(`
84
+ `)}\n`:null}var Bbe=[`yes`,`no`,`your call`],k0={picked:`the lines you picked`,screen:`the terminal screen`,transcript:`the end of the cached conversation`};function Vbe(){let e=Dh(),{lines:t,from:n}=G(C0),r=G(w0),i=(0,V.useMemo)(()=>Rbe(t),[t]),a=(e,t)=>w0.set({...w0.get(),[e]:t}),o=i.map(e=>r[e.text]??``),s=zbe(i,o),c=o.filter(e=>e.trim()).length;return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:`Answer the list`,onClose:()=>e.nav.close(`answers`)}),(0,J.jsx)(Z,{children:i.length?(0,J.jsxs)(J.Fragment,{children:[i.length,` item`,i.length>1?`s`:``,` from `,k0[n],`. Answer the ones you have a view on; blank ones are left out.`]}):t.length||n!==`transcript`?(0,J.jsxs)(J.Fragment,{children:[`Nothing numbered or bulleted in `,k0[n],`. Long-press the terminal and choose `,(0,J.jsx)(`b`,{children:`pick lines`}),` to answer any lines you like.`]}):(0,J.jsxs)(J.Fragment,{children:[`Reading `,k0[n],`…`]})}),(0,J.jsx)(`div`,{className:`decide-list`,children:i.map((e,t)=>(0,J.jsxs)(`div`,{className:`decide-item`,children:[(0,J.jsxs)(`div`,{className:`decide-q`,children:[e.num&&(0,J.jsxs)(`b`,{children:[e.num,`. `]}),e.text]}),(0,J.jsxs)(`div`,{className:`decide-a`,children:[(0,J.jsx)(`input`,{type:`text`,value:o[t],placeholder:`your answer`,enterKeyHint:`next`,onChange:t=>a(e.text,t.target.value)}),o[t]&&(0,J.jsx)(Y,{title:`clear this answer`,onClick:()=>a(e.text,``),children:(0,J.jsx)(B,{size:16})})]}),(0,J.jsx)(`div`,{className:`decide-chips`,children:[...e.options,...Bbe].map(n=>(0,J.jsx)(Y,{className:o[t]===n?`on`:void 0,onClick:()=>a(e.text,n),children:n},n))})]},`${t}:${e.text}`))}),(0,J.jsxs)(`div`,{className:`sheet-actions`,children:[(0,J.jsx)(X,{as:`span`,children:c?`${c} of ${i.length} answered`:`nothing answered yet`}),(0,J.jsxs)(Y,{onClick:()=>e.nav.close(`answers`),children:[(0,J.jsx)(B,{size:16}),` cancel`]}),s&&(0,J.jsxs)(`button`,{className:`send`,onClick:()=>{if(!s)return;e.compose.insert(s);let t={...w0.get()};for(let e of i)delete t[e.text];w0.set(t),e.nav.close(`answers`)},children:[(0,J.jsx)(Vc,{size:16}),` into compose`]})]})]})}var Hbe=(0,V.forwardRef)(function({text:e},t){let n=e.replace(/\s+$/,``).split(`
85
+ `),[r,i]=(0,V.useState)(()=>new Set),a=(0,V.useRef)(null),[o,s]=(0,V.useState)(()=>fa(R.textDumpWrap)),c=()=>s(e=>(sa(R.textDumpWrap,!e),!e));(0,V.useEffect)(()=>{i(new Set)},[e]),(0,V.useLayoutEffect)(()=>{let e=a.current;e&&(e.scrollTop=e.scrollHeight)},[e]),(0,V.useImperativeHandle)(t,()=>({pick(){if(r.size)return{text:[...r].sort((e,t)=>e-t).map(e=>n[e]).join(`
86
+ `),what:`ticked`};let t=window.getSelection(),i=a.current;return t&&!t.isCollapsed&&i&&t.anchorNode&&i.contains(t.anchorNode)?{text:t.toString(),what:`selection`}:{text:e,what:`all`}}}),[r,n,e]);let l=e=>i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`text-dump-bar`,children:(0,J.jsxs)(Y,{className:o?`on`:void 0,"aria-pressed":o,onClick:c,children:[(0,J.jsx)($te,{size:16}),` `,o?`wrapping lines`:`wrap lines`]})}),r.size>0&&(0,J.jsxs)(`div`,{className:`text-dump-ticked`,children:[(0,J.jsxs)(`span`,{children:[r.size,` of `,n.length,` lines ticked — copy and quote use only these.`]}),(0,J.jsx)(Y,{onClick:()=>i(new Set),children:`clear`})]}),(0,J.jsx)(`div`,{ref:a,className:`text-dump text-dump-lines mono${o?``:` nowrap`}`,children:n.map((e,t)=>{let n=r.has(t);return(0,J.jsxs)(`div`,{className:`tdl-row${n?` on`:``}`,children:[e.trim()?(0,J.jsx)(`label`,{className:`tdl-tick`,children:(0,J.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>l(t),"aria-label":`line ${t+1}`})}):(0,J.jsx)(`span`,{className:`tdl-tick`}),(0,J.jsx)(`span`,{className:`tdl-text`,children:e||`\xA0`})]},t)})})]})});async function A0(){let e=U(),t=e.compose.gridText();if(t.trim()){x0.set({text:t,source:`grid`}),e.nav.open(`text`);return}x0.set({text:``,source:`transcript`}),e.nav.open(`text`);let n=e.world.active,r=n?await Qy(n.id):null,i=r?ai(r):``;x0.set({text:i||Fbe(!!n),source:`transcript`})}function Ube(){let e=U();e.say.track(`action:clip.open`),S0.set(e.compose.draft),e.nav.open(`clip`)}function j0(e){let t=U();t.say.track(`action:link.open`),fx(e)?t.say.toast(`opening in your browser…`):t.say.toast(`your browser blocked that — copy the link and paste it into a tab`)}async function M0(e){let t=U();t.say.track(`action:link.copy`);try{await navigator.clipboard.writeText(e),t.say.toast(`link copied`)}catch{t.say.toast(`clipboard unavailable (needs https) — show the url and select it`)}}async function Wbe(e){let t=U();t.say.track(`action:link.code`);try{return await navigator.clipboard.writeText(e),t.say.toast(`code ${e} copied`),!0}catch{return t.say.toast(`clipboard needs https — type the code by hand: ${e}`),!1}}async function N0(e){let t=U();if(t.say.track(`action:decide.open`),e?.length){C0.set({lines:[...e],from:`picked`}),t.nav.open(`answers`);return}let n=t.compose.gridText();if(n.trim()){C0.set({lines:n.split(`
87
+ `),from:`screen`}),t.nav.open(`answers`);return}C0.set({lines:[],from:`transcript`}),t.nav.open(`answers`);let r=t.world.active,i=r?await Qy(r.id):null;C0.set({lines:i?ai(i).split(`
88
+ `).slice(-80):[],from:`transcript`})}function Gbe(e){let t=T0(e);return t?(U().compose.insert(t),!0):!1}var P0=16;function Kbe(){let e=Dh(),{text:t,source:n}=G(x0),r=(0,V.useRef)(null),i=()=>r.current?.pick().text??t,a=async()=>{let t=i();try{await navigator.clipboard.writeText(t),e.say.toast(`copied ${t.length} chars`)}catch{e.say.toast(`clipboard unavailable (needs https)`)}},o=()=>{let t=T0(i());t&&(e.compose.insert(t),e.nav.close(`text`))},s=mt(t);return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:n===`grid`?`Terminal text`:`Conversation text`,onClose:()=>e.nav.close(`text`),children:(0,J.jsx)(Y,{onClick:()=>void A0(),title:`re-pull`,children:(0,J.jsx)(xc,{size:P0})})}),(0,J.jsx)(Z,{children:`Tick lines (or select text), then copy or quote. Nothing ticked or selected ⇒ acts on the entire dump.`}),s.length>0&&(0,J.jsxs)(`div`,{className:`form`,children:[(0,J.jsxs)(X,{children:[s.length,` link`,s.length>1?`s`:``,` on screen — rejoined across the rows the terminal broke them into.`]}),(0,J.jsx)(`div`,{className:`link-list`,children:s.map(e=>(0,J.jsxs)(Xw,{children:[(0,J.jsxs)(`button`,{className:`row-title link-row`,title:e.url,onClick:()=>j0(e.url),children:[(0,J.jsx)(Ga,{size:P0}),` `,(0,J.jsx)(`span`,{className:`link-url`,children:e.url})]}),(0,J.jsx)(Y,{title:`copy link`,onClick:()=>void M0(e.url),children:(0,J.jsx)(_o,{size:P0})})]},e.url))})]}),(0,J.jsx)(Hbe,{ref:r,text:t}),(0,J.jsxs)(`div`,{className:`sheet-actions`,children:[(0,J.jsxs)(Y,{onClick:a,children:[(0,J.jsx)(_o,{size:16}),` copy`]}),(0,J.jsxs)(Y,{onClick:o,children:[(0,J.jsx)(Ka,{size:16}),` quote in compose`]}),(0,J.jsx)(`div`,{className:`spacer`}),(0,J.jsx)(`button`,{className:`send`,onClick:()=>e.nav.close(`text`),children:`done`})]})]})}var qbe={id:`clipboard`,sheets:[{id:`clip`,persisted:!1,render:()=>(0,V.createElement)(Pbe)},{id:`text`,persisted:!1,render:()=>(0,V.createElement)(Kbe)},{id:`answers`,persisted:!1,render:()=>(0,V.createElement)(Vbe)}],commands:[{id:`clip`,run:()=>Ube()},{id:`select`,run:()=>{A0()}},{id:`decide`,run:()=>{N0()}}]};function Jbe(){let[e,t]=(0,V.useState)([]);return(0,V.useEffect)(()=>Sie(t),[]),e}function F0({rows:e,onOpen:t}){return e.length?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`notif-sec`,children:[(0,J.jsxs)(`span`,{className:`notif-sec-title`,children:[(0,J.jsx)(Rs,{size:13}),` On this phone · `,e.length]}),(0,J.jsx)(fC,{className:`key`,confirm:`clear all?`,title:`clear messages`,"aria-label":`clear messages`,onConfirm:wie,children:(0,J.jsx)(ws,{size:13})})]}),e.map(e=>(0,J.jsxs)(`div`,{className:`notif-row`,children:[e.notif?(0,J.jsxs)(`button`,{className:`notif-open`,onClick:()=>t(e.notif),children:[(0,J.jsx)(`span`,{className:`notif-icon`,children:(0,J.jsx)(Rs,{size:16})}),(0,J.jsx)(`span`,{className:`notif-body`,children:(0,J.jsx)(`span`,{className:`notif-text`,children:e.text})})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`notif-icon`,children:(0,J.jsx)(Rs,{size:16})}),(0,J.jsx)(`span`,{className:`notif-body`,children:(0,J.jsx)(`span`,{className:`notif-text`,children:e.text})})]}),e.n>1&&(0,J.jsxs)(Q,{children:[`×`,e.n]}),(0,J.jsx)(Q,{className:`notif-time`,children:Tp(e.ts)})]},`${e.ts}:${e.text}`))]}):null}function Ybe(e,t,n=100){return[t,...e].slice(0,n)}function Xbe(e){return e.reduce((e,t)=>Math.max(e,t.ts),0)}function Zbe(e,t){return e.filter(e=>e.ts>t).length}function Qbe(e){return e>9?`9+`:String(e)}function $be(e,t){let n=e.split(`·`).pop()?.trim()??``;if(!n)return null;let r=t.filter(e=>e.worktreePath.split(`/`).filter(Boolean).pop()===n);return r.length===1?r[0].worktreePath:null}var exe={prompt:{name:`Needs you`,note:`A session is parked on a question and cannot continue without an answer.`},approval:{name:`Approvals`,note:`A plugin asked for something you must approve now, such as a vault fingerprint. Loud on purpose.`},limit:{name:`Usage limit`,note:`A session hit the account limit, and whether auto-continue got it running again.`},burn:{name:`Week burning fast`,note:`The weekly limit climbed faster than the threshold over the last stretch of readings — one push naming what spent it. Nothing is paused.`},disk:{name:`Desktop disk almost full`,note:`The desktop's disk dropped under 10 GB free (and again under 3 GB). On a Mac, low space makes macOS end apps to clear their caches — Tailscale among them, which cuts this phone off. Words only; nothing is deleted.`},agent:{name:`Large subagent`,note:`A running subagent passed the context size you set on the context sheet (default 500k) — one push per agent, naming it. It warns only; nothing is stopped.`},backlog:{name:`Backlog`,note:`A queued backlog item started, finished, or failed.`},followup:{name:`Follow up`,note:`A session was flagged for follow up without your tap — by a launch you ticked to flag when done, or by its own agent with one line on what to read. A flag you set by hand sends none.`},health:{name:`Repo health index`,note:`A repo's health index moved by more than is usual for that repo's own past — at most one push per repo per week, in words, naming the readings that carried it.`},artifact:{name:`Artifacts`,note:`A build produced a file, or an auto-download queued one. Auto-download itself keeps working when this is off — the push is how the phone starts fetching with the app closed.`},image:{name:`New images`,note:`An agent wrote a picture into the repo.`},plugin:{name:`Plugins`,note:`Something an installed plugin wanted you to know — its own words, from the desktop.`},autofire:{name:`Auto-answered`,note:`A question was answered for you, and with what.`},idle:{name:`Turn finished`,note:`Fires on EVERY turn of EVERY session — a handful of agents on a backlog is a notification a minute, which buries the two kinds above. Off unless you turn it on.`},info:{name:`Other`,note:`Sessions opening, builds, host notices.`},undelivered:{name:`Prompt not delivered`,note:`A session opened but the prompt never made it in. The only report of a message that is otherwise gone — the phone acked the op long before the typing failed.`}},I0=W([]),L0=W(Ea(R.notifSeen,0));function R0(){return Zbe(G(I0),G(L0))}var z0=W({});function txe(){return G(z0)}function nxe(e,t){I0.set(t=>Ybe(t,e)),t.say.toast(e.title,e)}function rxe(e){I0.set(e)}function ixe(e){z0.set(e)}function axe(e,t,n){let r=U();z0.set(n=>({...n,[e]:t})),r.conn.send({t:`notify.prefs.set`,prefs:{[e]:t}}),r.say.toast(`${n}: ${t?`on`:`muted`}`)}function oxe(){let e=I0.get();if(!e.length)return;let t=Xbe(e);t>L0.get()&&(L0.set(t),ua(R.notifSeen,String(t)))}function B0(){U().nav.open(`notifications`)}function V0(e){let t=U();if(e.file&&bD(e.file.relPath))t.files.openArtifact(e.file);else if(e.file)t.files.downloadArtifact(e.file);else if(t.nav.close(`notifications`),e.plugin&&!e.sessionId&&!e.image)t.nav.openPlugin(e.plugin);else if(e.image)t.files.viewImage(e.image,e.sessionId);else if(e.sessionId){let n=t.world.sessions.find(t=>t.id===e.sessionId);n?t.nav.attach(n):t.say.toast(`that session is closed — reopen it from Recently closed or Archive`)}else if(e.kind===`backlog`){let n=$be(e.title,t.world.visibleRepos);n?t.nav.openBacklogCut(n):t.nav.open(`backlog`)}}var H0={prompt:Ls,approval:Gc,idle:ro,image:jo,autofire:Uc,backlog:il,followup:Ac,health:Bo,plugin:Yo,info:Ja,limit:go,burn:cne,agent:Uo,disk:Ba,artifact:Qa,undelivered:gs};function sxe(){let e=Dh(),t=G(I0),n=Jbe(),r=new Set(t.map(e=>e.id)),i=n.filter(e=>!e.notif||!r.has(e.notif.id)),a=Cie(t.length?Math.max(...t.map(e=>e.ts)):void 0,i);return(0,V.useEffect)(()=>{oxe()},[t]),(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Ja,{size:16,style:{verticalAlign:`-3px`,marginRight:4}}),` Notifications`]}),onClose:()=>e.nav.close(`notifications`),children:t.length>0&&(0,J.jsx)(Y,{onClick:()=>e.conn.liveSend({t:`notification.clear`},`notifications cleared`),title:`clear alerts from the desktop`,children:(0,J.jsx)(ws,{size:14})})}),(0,J.jsxs)(`div`,{className:`list hist`,children:[t.length===0&&i.length===0&&(0,J.jsx)($,{children:`No notifications yet.`}),a&&(0,J.jsx)(F0,{rows:i,onOpen:V0}),t.length>0&&i.length>0&&(0,J.jsx)(`div`,{className:`notif-sec`,children:(0,J.jsxs)(`span`,{className:`notif-sec-title`,children:[(0,J.jsx)(Ja,{size:13}),` From the desktop · `,t.length]})}),t.map(t=>{let n=H0[t.kind]??Ja,r=!!t.file&&bD(t.file.relPath);return(0,J.jsxs)(`div`,{className:`notif-row`,children:[(0,J.jsxs)(`button`,{className:`notif-open`,onClick:()=>V0(t),children:[(0,J.jsx)(`span`,{className:`notif-icon notif-${t.kind}`,children:(0,J.jsx)(n,{size:16})}),(0,J.jsxs)(`span`,{className:`notif-body`,children:[(0,J.jsx)(`span`,{className:`notif-title`,children:t.title}),t.body&&(0,J.jsx)(`span`,{className:`notif-text`,children:t.body})]})]}),t.file&&(r?(0,J.jsx)(`button`,{className:`notif-dl`,title:`download ${t.file.name}`,"aria-label":`download ${t.file.name}`,onClick:()=>{e.files.downloadArtifact(t.file),e.say.toast(`downloading ${t.file.name}`)},children:(0,J.jsx)(Qa,{size:16})}):(0,J.jsx)(`span`,{className:`notif-dl`,title:`download`,children:(0,J.jsx)(Qa,{size:16})})),(0,J.jsx)(Q,{className:`notif-time`,children:Tp(t.ts)})]},t.id)}),!a&&(0,J.jsx)(F0,{rows:i,onOpen:V0})]})]})}function cxe(){let e=R0(),t=txe();return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(rC,{id:`notif-feed`,label:`open the feed${e>0?` (${e})`:``}`,icon:Ja,opens:!0,onClick:()=>{B0()},note:`Every alert you leave switched on below lands in the in-app feed — works even without HTTPS.`}),(0,J.jsx)(iC,{id:`notif-kinds`,label:`what may fire`,icon:lc,note:`A kind switched off is dropped by the host — no feed row and no OS push, on every device.`,more:(0,J.jsx)(`p`,{children:`The mute follows the account, not the browser, because the push is sent from the desktop.`}),children:(0,J.jsx)(`div`,{className:`set-kinds`,children:Dte.map(e=>{let n=Nee(t,e),r=H0[e]??Ja,i=exe[e];return(0,J.jsx)(ZS,{label:i?.name??e,icon:n?r:lc,on:n,onChange:()=>axe(e,!n,i?.name??e),note:i?.note},e)})})})]})}var lxe={id:`notifications`,sheets:[{id:`notifications`,persisted:!1,render:()=>(0,V.createElement)(sxe)}],messages:{notification:(e,t)=>nxe(e.item,t),"notification.list":e=>rxe(e.items),"notify.prefs":e=>ixe(e.prefs)},settings:[{group:`notifications`,order:10,render:()=>(0,V.createElement)(cxe)}]},uxe=[`one`,`repo`,`all`],dxe={one:(0,J.jsx)(ml,{size:16}),repo:(0,J.jsx)(Xc,{size:16}),all:(0,J.jsx)(Za,{size:16})},fxe={one:`One session resumes at a time, in the order below — the safest, and the slowest`,repo:`One session per repo at a time: never two agents in one worktree, but different repos run in parallel`,all:`Every blocked session resumes together, once the first one provably works again`},U0={one:{label:`one at a time`,hint:`one at a time, in this order`,row:`goes after the ones above`},repo:{label:`one per repo`,hint:`one per repo at a time, in this order`,row:`goes once this repo is free`},all:{label:`all at once`,hint:`all of them, once the first resume works`,row:`goes with the rest`}};function pxe({sessions:e,online:t,seenAt:n,globalAuto:r,holdUntil:i,mode:a,onSetGlobal:o,onSetMode:s,onSetOverride:c,onSetFirst:l,onResume:u,onOpen:d,onClose:f}){let p=e.filter(e=>e.limit?.blocked),m=p.filter(e=>e.limit.queuePos!=null).sort((e,t)=>e.limit.queuePos-t.limit.queuePos),h=p.filter(e=>e.limit.queuePos==null),g=i!=null&&i>Date.now(),_=e=>{let t=e.limit;return t.spend&&!t.resetAt&&!t.nextAttemptAt?`spend limit — needs you: add credit or raise the limit, then resume it`:t.needsYou&&!t.nextAttemptAt?`needs you — ${t.needsYou}; nothing is retried by itself, resume it once that is sorted`:t.resuming?`resuming now — the queue is waiting to see whether it took`:t.autoContinue?t.queuePos===1?g?`next up · held off until ${Lp(i)}`:t.nextAttemptAt?`next up · continues at ${Lp(t.nextAttemptAt)}`:`next up`:t.queuePos==null?t.attempts?`stopped after ${t.attempts} attempt${t.attempts>1?`s`:``}`:`waiting`:`#${t.queuePos} in line · ${U0[a].row}`:`manual${t.attempts?` · ${t.attempts} attempt${t.attempts>1?`s`:``} made`:``} — it waits for you; go first and now need it on`},v=e=>{let n=e.limit;return(0,J.jsxs)(`div`,{className:`q-card${n.resuming?` resuming`:``}`,children:[(0,J.jsxs)(`div`,{className:`q-head`,children:[(0,J.jsxs)(`button`,{className:`linkish`,onClick:()=>{q(`action:limit.session`),d(e.id)},children:[(0,J.jsx)(qa,{size:13,style:{verticalAlign:`-2px`}}),` `,e.title||e.cwd]}),(0,J.jsx)(`span`,{className:`spacer`}),n.queuePos!=null&&(0,J.jsxs)(qw,{className:`limit-auto`,children:[(0,J.jsx)(go,{size:12}),` `,n.queuePos]}),e.starred&&(0,J.jsx)(Pa,{size:12,className:`star-on`})]}),(0,J.jsxs)(`div`,{className:`approve-hint`,children:[_(e),n.resetAt?` · ${n.spend?`spend limit resumes`:`limit resets`} ~${Lp(n.resetAt)}`:``,n.blockedSince?` · blocked ${Tp(n.blockedSince)}`:``]}),t&&(0,J.jsxs)(`div`,{className:`approve-opts`,children:[n.autoContinue&&(0,J.jsxs)(`button`,{className:`approve-btn${n.first?` primary`:``}`,"data-hint":`limit.first`,title:`Go first — resume this session before the others when the limit lifts`,onClick:()=>{q(`action:limit.first`),l(e.id,!n.first)},children:[(0,J.jsx)(Oc,{size:14}),` `,n.first?`first`:`go first`]}),(0,J.jsxs)(`button`,{className:`approve-btn`,"data-hint":`limit.auto`,title:n.autoContinue?`Stop this session resuming by itself`:`Let this session resume by itself again`,onClick:()=>{q(`action:limit.auto`);let t=!n.autoContinue;c(e.id,t===r?null:t)},children:[(0,J.jsx)($a,{size:14}),` `,n.autoContinue?`off`:`on`]}),n.autoContinue&&(0,J.jsxs)(`button`,{className:`approve-btn`,"data-hint":`limit.resumeone`,title:`Resume this one now, without waiting for the reset time`,onClick:()=>{q(`action:limit.resumeone`),u(e.id)},children:[(0,J.jsx)(La,{size:14}),` now`]})]})]},e.id)};return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(go,{size:16}),` Usage limit`]}),onClose:f,children:p.length>0&&(0,J.jsx)(`span`,{className:`muted`,children:p.length})}),!t&&(0,J.jsxs)(Z,{children:[(0,J.jsx)(fo,{size:13,style:{verticalAlign:`-2px`}}),` `,`offline — `,n?(0,J.jsxs)(J.Fragment,{children:[`this is the state as of `,Tp(n)]}):(0,J.jsx)(J.Fragment,{children:`nothing has been synced to this device yet`}),`. The buttons need the host, so they are back with the link rather than queueing: which session should go first is a decision about right now.`]}),g&&(0,J.jsxs)(Z,{children:[`A resume just came back still blocked, so the limit has not actually reset. Nothing else will spend an attempt until `,Lp(i),` — tap `,(0,J.jsx)(`b`,{children:`now`}),` on a session to override that.`]}),p.length===0&&(0,J.jsxs)($,{children:[`Nothing is blocked on a usage limit.`,` `,(0,J.jsx)(tT,{of:`the queue`,label:`what is the queue?`,children:`When several sessions hit the limit together, they queue up here and resume one at a time.`})]}),m.length>0&&(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsxs)(`span`,{children:[`In line `,(0,J.jsxs)(`span`,{className:`section-hint`,children:[`· `,U0[a].hint]})]})}),p.length>0&&(0,J.jsx)(J.Fragment,{children:(0,J.jsx)(`div`,{className:`mode-row`,"data-hint":`limit.mode`,children:t?(0,J.jsx)(yS,{label:`how many resume at once`,options:uxe.map(e=>({key:e,label:(0,J.jsxs)(J.Fragment,{children:[dxe[e],` `,U0[e].label]}),title:fxe[e]})),value:a,onChange:e=>{q(`action:limit.mode.${e}`),s(e)}}):(0,J.jsx)(Qw,{cants:[{label:`changing how many resume at once`,reason:`there is no link to the desktop · it stays ${U0[a].label}`}]})})}),m.length>1&&a!==`one`&&(0,J.jsx)(Z,{children:`The first session still goes alone — if it comes back still blocked, nothing else spends an attempt on the same wall. The rest follow once one of them provably starts working again.`}),(0,J.jsxs)(`div`,{className:`list`,children:[m.map(v),h.length>0&&(0,J.jsxs)(`div`,{className:`section section-head`,children:[(0,J.jsxs)(`span`,{children:[`Not resuming `,(0,J.jsx)(`span`,{className:`section-hint`,children:`· auto-continue is off for these`})]}),(0,J.jsxs)(Y,{onClick:()=>XI(`limit-auto`),children:[(0,J.jsx)(Bs,{size:14}),` default`]})]}),h.map(v)]}),(0,J.jsxs)(`div`,{className:`sheet-actions`,children:[t&&m.length>0&&(0,J.jsxs)(Y,{"data-hint":`limit.resumeall`,title:`Stop waiting for the clock — the queue starts now, ${U0[a].label}`,onClick:()=>{q(`action:limit.resumeall`),u()},children:[(0,J.jsx)(La,{size:16}),` resume all`]}),t&&p.length>0&&(0,J.jsxs)(Y,{"data-hint":`limit.starredonly`,title:`Only starred sessions resume by themselves; the rest wait for you`,onClick:()=>{q(`action:limit.starredonly`);for(let e of p)c(e.id,!!e.starred)},children:[(0,J.jsx)(Pa,{size:16}),` starred only`]}),t&&(0,J.jsxs)(Y,{className:r?`active`:``,"data-hint":`limit.global`,title:`The global switch: whether a session resumes itself at all once a limit resets`,onClick:()=>{q(`action:limit.global`),o(!r)},children:[(0,J.jsx)($a,{size:16}),` auto `,r?`on`:`off`]}),(0,J.jsxs)(Y,{onClick:f,children:[(0,J.jsx)(B,{size:16}),` close`]})]})]})}var W0=W({auto:!0,mode:`one`,hold:null});function G0(){return G(W0).auto}function mxe(){return G(W0)}function hxe(e){return e==null||!e&&null}function gxe(e,t){return`auto-continue: ${e==null?`inherit (${t?`on`:`off`})`:e?`on for this session`:`off for this session`}`}function _xe(e,t){return e==null?`global (${t?`on`:`off`})`:`session override`}function vxe(e){return e===`one`?`resuming one session at a time`:e===`repo`?`resuming one session per repo at a time`:`resuming every queued session once the limit lifts`}function yxe(e){W0.set(t=>({auto:e.enabled,hold:e.holdUntil??null,mode:e.mode??t.mode}))}function K0(e){U().conn.liveSend({t:`limit.setAuto`,enabled:e},`auto-continue ${e?`on`:`off`}`)}function bxe(e){let t=U();t.conn.send({t:`limit.setMode`,mode:e}),t.say.toast(vxe(e))}function xxe(e,t){U().conn.liveSend({t:`limit.session`,id:e,override:t},`saved for this session`)}function Sxe(e,t){let n=U();n.conn.send({t:`limit.session`,id:e,override:t}),n.say.toast(gxe(t,W0.get().auto))}function Cxe(e,t){U().conn.liveSend({t:`limit.first`,id:e,on:t},t?`this one resumes first`:`resume order cleared`)}function wxe(e){let t=U();t.conn.send({t:`limit.resume`,id:e}),t.say.toast(e?`resuming that session…`:`starting the queue…`)}function Txe(){let e=Dh(),t=mxe(),n=e.world.sessions;return(0,J.jsx)(pxe,{sessions:n,online:e.conn.status===`open`,seenAt:iT(oT,null),globalAuto:t.auto,holdUntil:t.hold,mode:t.mode,onSetGlobal:K0,onSetMode:bxe,onSetOverride:xxe,onSetFirst:Cxe,onResume:wxe,onOpen:t=>{let r=n.find(e=>e.id===t);r?e.nav.attach(r):e.nav.close(`limits`)},onClose:()=>e.nav.close(`limits`)})}var Exe=16;function Dxe({active:e,label:t,dismiss:n}){let r=G0();if(!e?.limit)return null;let i=e.limit,a=hxe(i.autoContinueOverride),o=i.autoContinue?`on`:`off`,s=_xe(i.autoContinueOverride,r);return(0,J.jsxs)(Y,{className:i.blocked?`limit`:i.autoContinue?`active`:void 0,"data-hint":`toolbar:limit`,title:`auto-continue after a usage-limit reset: ${o} · ${s}${i.blocked?`\ncurrently limit-blocked${i.nextAttemptAt?` — continue fires ~${Rp(i.nextAttemptAt)}`:i.needsYou?` — it needs you: ${i.needsYou}`:``}`:``}\ntap to cycle: inherit → on → off`,onClick:()=>{n(),Sxe(e.id,a)},children:[(0,J.jsx)(go,{size:Exe}),t&&(0,J.jsxs)(J.Fragment,{children:[` `,i.blocked?i.needsYou&&!i.nextAttemptAt?`needs you`:i.spend&&!i.nextAttemptAt?`spend limit`:i.nextAttemptAt?`${i.spend?`spend`:`limit`} · ${Rp(i.nextAttemptAt)}`:`limit`:`auto-cont ${o}${i.autoContinueOverride==null?``:`*`}`]})]})}function Oxe(){let e=Dh(),t=G0(),n=O(e.world.billing?.profile),r=e.world.budget,[i,a]=(0,V.useState)(null);(0,V.useEffect)(()=>{a(null)},[r]);let o=r&&i?{...r,budget:i}:r,s=t=>e.conn.liveSend({t:`budget.set`,budget:t},`usage budget saved`);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ZS,{id:`limit-auto`,label:`auto-continue after a usage limit`,icon:go,on:t,onChange:()=>K0(!t),note:`When a session hits a Claude usage limit, send “continue” once the limit resets.`,more:(0,J.jsx)(`p`,{children:`At the banner's reset time where there is one, else retrying periodically. Override per session via the hourglass chip in the session toolbar; session rows show the state, and a blocked session shows when it will resume.`})}),(0,J.jsx)(ZS,{id:`budget`,label:`usage budget`,icon:ms,on:!!o?.budget.enabled,onChange:()=>{o&&(q(`action:budget.toggle`),e.conn.liveSend({t:`budget.set`,budget:{...o.budget,enabled:!o.budget.enabled}},`usage budget ${o.budget.enabled?`off`:`on`}`))},note:n?`Pause queued sends and automatic backlog starts once the 5-hour window is this far used.`:`Pause queued sends and automatic backlog starts once a dollar period reaches its cap.`,more:(0,J.jsxs)(`p`,{children:[`It starts again by itself when the window resets — nothing is lost, the queue just waits. An explicit `,(0,J.jsx)(`strong`,{children:`send now`}),`, an answer to a question box, and file uploads are never held back.`]}),children:o&&(0,J.jsxs)(YS,{tone:o.verdict.blocked?`bad`:`plain`,icon:o.verdict.blocked?gs:ms,children:[fn(o.verdict),o.verdict.blocked&&o.verdict.resumeAt!=null&&` — resumes ${Rp(o.verdict.resumeAt)}`]})}),o&&n&&(0,J.jsx)(nC,{id:`budget-session`,label:`session ceiling`,min:50,max:100,step:5,value:o.budget.sessionMax,readout:o.budget.sessionMax>=100?`off`:`${o.budget.sessionMax}%`,onInput:e=>a({...o.budget,sessionMax:e}),onCommit:()=>s(o.budget)}),o&&n&&(0,J.jsx)(ZS,{id:`budget-weekly`,label:`weekly ceiling`,icon:ms,on:o.budget.weeklyMax!=null,state:o.budget.weeklyMax==null?`off`:`${o.budget.weeklyMax}%`,onChange:()=>e.conn.liveSend({t:`budget.set`,budget:{...o.budget,weeklyMax:o.budget.weeklyMax==null?90:null}},o.budget.weeklyMax==null?`weekly ceiling on`:`weekly ceiling off`),note:`Off by default on purpose: the weekly window resets days out.`,more:(0,J.jsx)(`p`,{children:`So a weekly ceiling stops unattended work until then. Turn it on deliberately.`}),children:o.budget.weeklyMax!=null&&(0,J.jsx)(`input`,{type:`range`,className:`set-range`,min:50,max:100,step:5,value:o.budget.weeklyMax,onChange:e=>a({...o.budget,weeklyMax:Number(e.target.value)}),onPointerUp:()=>s(o.budget),onKeyUp:()=>s(o.budget)})}),o&&n&&o.budget.leftoverMax!==void 0&&(0,J.jsx)(ZS,{id:`budget-leftover`,label:`leftovers in a new week`,icon:ms,on:o.budget.leftoverMax!=null,state:o.budget.leftoverMax==null?`off`:`under ${o.budget.leftoverMax}%`,onChange:()=>e.conn.liveSend({t:`budget.set`,budget:{...o.budget,leftoverMax:o.budget.leftoverMax==null?20:null}},o.budget.leftoverMax==null?`leftover ceiling on`:`leftover ceiling off`),note:`Work let past last week's budget that did not start before the reset runs only while the new week is under this.`,more:(0,J.jsx)(`p`,{children:`Rows timed before the weekly reset, and rows you let past the weekly ceiling, are there to use up what is left of a week. One still waiting when the week resets would otherwise start at once on the new week. It counts everything the week has used, your own sends included. Letting such a row past the budget again lifts it.`}),children:o.budget.leftoverMax!=null&&(0,J.jsx)(`input`,{type:`range`,className:`set-range`,min:5,max:50,step:5,value:o.budget.leftoverMax,onChange:e=>a({...o.budget,leftoverMax:Number(e.target.value)}),onPointerUp:()=>s(o.budget),onKeyUp:()=>s(o.budget)})})]})}var kxe={id:`limits`,sheets:[{id:`limits`,persisted:!1,render:()=>(0,V.createElement)(Txe)}],toolbarItems:[{id:`limit`,render:(e,t)=>(0,V.createElement)(Dxe,{active:t.active,label:t.label,dismiss:t.dismiss})}],messages:{"limit.config":e=>yxe(e)},settings:[{group:`sessions`,order:10,render:()=>(0,V.createElement)(Oxe)}]};function Axe(e,t){let n=t?`sending`:`queued`,r=e.length>1?`${e.length} answers ${n} (${e.map(e=>e.label).join(`, `)})`:`“${e[0].label}” ${n}`;return t?`${r} — waiting for the desktop to confirm`:`${r} — sent, in order, as soon as the link is back`}function q0(e){let t=e.byName?.trim()||e.by?.trim()||`a plugin`,n=e.model?.trim();return n?`${t} (${n})`:t}function jxe(e){return`won't ask again for: ${e.label.trim()||`this request`} — this session only`}function J0(e){let t=e.path?e.path.replace(/^\/(Users|home)\/[^/]+/,`~`):null;return e.cut?`longer than the host sends${t?` — the rest is in ${t}`:``}`:t?`from ${t}`:null}function Y0({prompt:e,queued:t,suggestion:n,onAnswer:r,ev:i}){let a=am(e=>e.online),o=e.options.some(e=>e.desc),s=e.submitLabel??`Submit`,c=e.ask||e.question,l=!e.ask&&e.questionTruncated,[u,d]=(0,V.useState)(null),f=u==null?void 0:e.options.find(e=>e.index===u&&e.takesText);return(0,J.jsxs)(J.Fragment,{children:[e.plan&&(0,J.jsx)(Mxe,{plan:e.plan}),(0,J.jsxs)(`div`,{className:`approve-q`,children:[c,l?`…`:``]}),l&&(0,J.jsx)(`div`,{className:`approve-hint`,children:`this text was shortened — read the full version in the CLI`}),e.truncated&&(0,J.jsxs)(`div`,{className:`approve-hint`,children:[e.nav?`the options run off the side of the terminal — the ones past the edge are not here`:`the box is taller than the screen — options above ${e.options[0].index} are off it`,e.ask?``:`; open the CLI to see them`]}),e.multi&&(0,J.jsx)(`div`,{className:`approve-hint`,children:e.submitLabel===`Next`?`multi-select — tap options to toggle, then Next. This ask has more questions: Next moves to the following one.`:`multi-select — tap options to toggle, then Submit`}),t.length>0&&(0,J.jsxs)(`div`,{className:`approve-hint approve-queued`,children:[(0,J.jsx)(fo,{size:12,style:{verticalAlign:`-2px`}}),` `,Axe(t,a)]}),n?.choice!=null&&(0,J.jsxs)(`div`,{className:`oracle-hint`,title:`${q0(n)} · ${(n.confidence*100).toFixed(0)}% sure`,children:[(0,J.jsx)(Uo,{size:13,style:{verticalAlign:`-2px`}}),` `,q0(n),` suggests `,(0,J.jsx)(`b`,{children:n.choice}),`: `,n.rationale]}),(0,J.jsx)(`div`,{className:`approve-opts${o?` rich open`:``}`,children:e.options.map(t=>{let a=n?.choice===t.index;return(0,J.jsxs)(`button`,{...t.checked===void 0?{}:{role:`checkbox`,"aria-checked":t.checked},className:`approve-btn ${t.index===1&&!e.multi&&!e.nav?`primary`:``} ${a?`suggested`:``}`,onClick:()=>{t.takesText&&e.nav?d(t.index):(q(`action:${i}.answer`),e.nav?r(``,t.label,void 0,t.index):r(String(t.index)+(e.multi?``:`\r`),`${t.index}. ${t.label}`))},children:[(0,J.jsxs)(`span`,{className:`approve-lbl`,children:[a?(0,J.jsx)(Uo,{size:13,style:{verticalAlign:`-2px`,marginRight:3}}):null,t.checked===void 0?null:t.checked?(0,J.jsx)(eo,{size:16,"aria-label":`ticked`,className:`approve-tick`}):(0,J.jsx)(ic,{size:16,"aria-label":`not ticked`,className:`approve-tick`}),e.nav?``:`${t.index}. `,t.label]}),t.desc&&(0,J.jsx)(`span`,{className:`approve-desc`,children:t.desc}),t.remembers&&(0,J.jsx)(`span`,{className:`approve-desc approve-remembers`,children:jxe(t.remembers)}),t.takesText&&e.nav&&(0,J.jsx)(`span`,{className:`approve-desc`,children:`takes a typed reason — tap to write one`})]},t.index)})}),f&&(0,J.jsx)(Z0,{intro:`your reason for “${f.label}” — the agent reads it`,placeholder:`why`,send:e=>{q(`action:${i}.reason`),r(``,`${f.label} — “${X0(e)}”`,void 0,f.index,e),d(null)},without:()=>{q(`action:${i}.answer`),r(``,f.label,void 0,f.index),d(null)}},`reason-${f.index}`),e.freeText&&(0,J.jsx)(Z0,{intro:e.options.length?`or type your own answer`:`type your answer`,placeholder:`your answer`,send:e=>{q(`action:${i}.typed`),r(``,`“${X0(e)}”`,void 0,void 0,e)}},`free-${e.askId??e.question}`),e.answerNote&&(0,J.jsx)(`div`,{className:`approve-hint`,children:e.answerNote}),(0,J.jsxs)(`div`,{className:`approve-commit`,children:[e.multi&&(0,J.jsxs)(`button`,{className:`approve-btn primary`,onClick:()=>{q(`action:${i}.submit`),r(`\r`,s,!0)},children:[s,` ⏎`]}),(0,J.jsx)(`button`,{className:`approve-esc`,onClick:()=>{q(`action:${i}.esc`),r(`\x1B`,`Esc`)},children:`Esc`})]})]})}var X0=e=>e.length>40?`${e.slice(0,39)}…`:e;function Z0({intro:e,placeholder:t,send:n,without:r}){let[i,a]=(0,V.useState)(``),[o,s]=(0,V.useState)(null),c=()=>{let e=i.trim(),t=Ote(e);t?s(r&&!e?`no reason written — tap without a reason to answer without one`:t):(s(null),n(e),a(``))};return(0,J.jsxs)(`div`,{className:`approve-typed`,children:[(0,J.jsx)(`div`,{className:`approve-hint`,children:e}),(0,J.jsx)(`input`,{className:`search`,value:i,placeholder:t,enterKeyHint:`send`,onChange:e=>{a(e.target.value),o&&s(null)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),c())}}),o&&(0,J.jsx)(`div`,{className:`approve-hint`,children:o}),(0,J.jsxs)(`div`,{className:`approve-commit`,children:[(0,J.jsxs)(`button`,{className:`approve-btn primary`,onClick:c,children:[(0,J.jsx)(Ec,{size:13,style:{verticalAlign:`-2px`}}),` send`]}),r&&(0,J.jsx)(`button`,{className:`approve-btn`,onClick:r,children:`without a reason`})]})]})}function Mxe({plan:e}){let t=e=>void Xf(e).then(e=>K(e?`copied`:`copy failed`)),n=e.text.split(`
89
+ `).length;return(0,J.jsxs)(`details`,{className:`approve-plan`,open:!0,children:[(0,J.jsxs)(`summary`,{children:[(0,J.jsx)(jc,{size:13,style:{verticalAlign:`-2px`}}),` the plan · `,n,` lines`]}),(0,J.jsx)(`div`,{className:`approve-plan-body`,children:(0,J.jsx)(eG,{src:e.text,q:``,onCopy:t})}),J0(e)&&(0,J.jsx)(`div`,{className:`approve-hint`,children:J0(e)})]})}function Nxe(e){return/^\s*!/.test(e)}var Pxe=`a shell command — not offered as one tap; type it yourself to run it`;function Q0({text:e,onSend:t,onDismiss:n,ev:r}){let i=Nxe(e);return(0,J.jsxs)(`div`,{className:`cli-sug`,children:[(0,J.jsxs)(`div`,{className:`cli-sug-head`,children:[(0,J.jsx)(ll,{size:13}),(0,J.jsxs)(`span`,{children:[`Claude proposes`,i?``:` — Tab at the desk`]}),n&&(0,J.jsx)(`button`,{className:`cli-sug-x`,"aria-label":`hide this proposal`,onClick:()=>{q(`action:${r}.cliSuggest.hide`),n()},children:(0,J.jsx)(B,{size:14})})]}),i?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`cli-sug-text`,children:e}),(0,J.jsx)(`div`,{className:`approve-hint`,children:Pxe})]}):(0,J.jsxs)(`button`,{className:`cli-sug-send`,onClick:()=>{q(`action:${r}.cliSuggest.send`),t(e)},children:[(0,J.jsx)(`span`,{className:`cli-sug-text`,children:e}),(0,J.jsx)(Uc,{size:15})]})]})}function Fxe({sessions:e,outbox:t,online:n,seenAt:r,onAnswer:i,onOpen:a,onAck:o,onSendSuggestion:s,onClose:c}){let l=e.filter(e=>e.running&&e.prompt),u=e.filter(e=>e.running&&!e.prompt&&e.awaitingInput),d=e.filter(e=>e.running&&!e.prompt&&!e.awaitingInput&&e.asking),f=l.length+u.length+d.length,p=e=>{let n=Fee(e.prompt);return t.filter(e=>e.answer?.fingerprint===n&&e.status!==`failed`)};return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Ss,{size:16}),` Questions`]}),onClose:c,children:(0,J.jsx)(`span`,{className:`muted`,children:f})}),!n&&(0,J.jsxs)(Z,{children:[(0,J.jsx)(fo,{size:13,style:{verticalAlign:`-2px`}}),` `,`offline — `,r?(0,J.jsxs)(J.Fragment,{children:[`these are the questions as of `,Tp(r)]}):(0,J.jsx)(J.Fragment,{children:`nothing has been synced to this device yet`}),`. Answer anyway: it is queued and sent the moment the link is back.`]}),f===0&&(0,J.jsxs)($,{children:[(0,J.jsx)(cs,{size:20}),(0,J.jsx)(`div`,{children:`Nothing is waiting on you.`}),(0,J.jsx)(`div`,{className:`muted`,children:n?`A session parked on a choice shows up here.`:`A session parked on a choice shows up here — as of the last time the phone reached the host.`})]}),(0,J.jsxs)(`div`,{className:`list`,children:[l.map(e=>{let t=e.prompt,n=p(e);return(0,J.jsxs)(`div`,{className:`q-card`,children:[(0,J.jsx)(`div`,{className:`q-head`,children:(0,J.jsxs)(`button`,{className:`linkish`,onClick:()=>{q(`action:questions.open`),a(e.id)},children:[(0,J.jsx)(qa,{size:13,style:{verticalAlign:`-2px`}}),` `,e.title||e.cwd]})}),(0,J.jsx)(Y0,{prompt:t,queued:n.map(e=>({label:e.answer.label})),suggestion:e.suggestion,onAnswer:(t,n,r,a,o)=>i(e,t,n,r,a,o),ev:`questions`})]},e.id)}),u.map(e=>(0,J.jsxs)(`div`,{className:`q-card`,children:[(0,J.jsx)(`div`,{className:`q-head`,children:(0,J.jsxs)(`button`,{className:`linkish`,onClick:()=>{q(`action:questions.open`),a(e.id)},children:[(0,J.jsx)(qa,{size:13,style:{verticalAlign:`-2px`}}),` `,e.title||e.cwd]})}),(0,J.jsx)(`div`,{className:`approve-q`,children:`A dialog is open in the CLI that couldn’t be read into options.`}),(0,J.jsx)(`div`,{className:`approve-opts`,children:(0,J.jsx)(`button`,{className:`approve-btn`,onClick:()=>{q(`action:questions.open`),a(e.id)},children:`open the CLI`})})]},e.id)),d.map(e=>(0,J.jsxs)(`div`,{className:`q-card`,children:[(0,J.jsx)(`div`,{className:`q-head`,children:(0,J.jsxs)(`button`,{className:`linkish`,onClick:()=>{q(`action:questions.open`),a(e.id)},children:[(0,J.jsx)(qa,{size:13,style:{verticalAlign:`-2px`}}),` `,e.title||e.cwd]})}),(0,J.jsx)(`div`,{className:`approve-q`,children:e.asking.text}),(0,J.jsx)(`div`,{className:`approve-hint`,children:`the turn ended on this — the CLI is idle, waiting for your reply`}),(0,J.jsxs)(`div`,{className:`approve-opts`,children:[(0,J.jsx)(`button`,{className:`approve-btn primary`,onClick:()=>{q(`action:questions.reply`),a(e.id)},children:`open and reply`}),n?(0,J.jsx)(`button`,{className:`approve-btn`,onClick:()=>{q(`action:questions.ack`),o(e)},children:`handled — clear it`}):(0,J.jsx)(`span`,{className:`approve-hint`,children:`no link — “handled” needs the host, it is not queued`})]}),e.cliSuggestion&&(t.some(t=>t.sessionId===e.id&&t.text===e.cliSuggestion&&t.status!==`failed`)?(0,J.jsxs)(`div`,{className:`approve-hint`,children:[`queued: “`,e.cliSuggestion,`” — sent when the link is back`]}):(0,J.jsx)(Q0,{text:e.cliSuggestion,onSend:t=>s(e,t),ev:`questions`}))]},e.id))]}),(0,J.jsx)(`div`,{className:`sheet-actions`,children:(0,J.jsxs)(Y,{onClick:c,children:[(0,J.jsx)(B,{size:16}),` close`]})})]})}function Ixe(e){U().conn.liveSend({t:`session.ackAsking`,id:e.id,text:e.asking?.text},`marked as handled — nothing was typed into the session`)}function Lxe(){let e=Dh(),t=Oh(),n=(0,V.useMemo)(()=>[...t],[t]),r=e.world.sessions;return(0,J.jsx)(Fxe,{sessions:r,outbox:n,online:e.conn.status===`open`,seenAt:iT(oT,null),onAnswer:e.queue.answerPrompt,onOpen:t=>{let n=r.find(e=>e.id===t);n?e.nav.attach(n):e.nav.close(`questions`)},onAck:Ixe,onSendSuggestion:(t,n)=>e.queue.submitInput(t.id,t.cwd,n,`prompt`),onClose:()=>e.nav.close(`questions`)})}var Rxe={id:`questions`,sheets:[{id:`questions`,persisted:!1,render:()=>(0,V.createElement)(Lxe)}]},zxe={prompt:Rs,command:lo,backlog:il},Bxe=[[`prompts`,`my prompts`],[`recent`,`recent output`],[`history`,`full history`]],$0={prompts:{line:`Searches only what was sent in.`,more:`Prompts, slash commands and filed backlog items — never the CLI's reply.`},recent:{line:`Searches the current terminal output.`,more:`What's on screen now (plus a shell's scrollback).`},history:{line:`Searches the full saved history.`,more:`The saved prompt + output of every turn — deepest, may be older.`}};function Vxe(e,t){if(!t)return e;let n=e.toLowerCase(),r=t.toLowerCase(),i=[],a=0,o=n.indexOf(r),s=0;for(;o!==-1;)o>a&&i.push(e.slice(a,o)),i.push((0,J.jsx)(`mark`,{children:e.slice(o,o+t.length)},s++)),a=o+t.length,o=n.indexOf(r,a);return a<e.length&&i.push(e.slice(a)),i}function Hxe({m:e,q:t}){return(0,J.jsxs)(`div`,{className:`srch-snip`,children:[e.turn&&(0,J.jsxs)(`div`,{className:`srch-turn`,children:[(()=>{let t=zxe[e.turn.kind];return(0,J.jsx)(t,{size:11})})(),(0,J.jsx)(`span`,{className:`srch-turn-text`,children:e.turn.text||e.turn.kind}),(0,J.jsx)(`span`,{className:`srch-turn-ago`,children:Tp(e.turn.sentAt)})]}),(0,J.jsxs)(`pre`,{className:`srch-lines`,children:[e.before.map((e,t)=>(0,J.jsx)(`div`,{className:`srch-ctx`,children:e||` `},`b${t}`)),(0,J.jsx)(`div`,{className:`srch-hit`,children:Vxe(e.hit,t)}),e.after.map((e,t)=>(0,J.jsx)(`div`,{className:`srch-ctx`,children:e||` `},`a${t}`))]})]})}function Uxe({sessionId:e,sessionLabel:t,results:n,loading:r,online:i=!0,sessions:a,backends:o,onSearch:s,onOpenSession:c,onClose:l}){let[u,d]=(0,V.useState)(``),[f,p]=(0,V.useState)(e?`recent`:`prompts`),[m,h]=(0,V.useState)(``),g=(0,V.useRef)(void 0);(0,V.useEffect)(()=>{clearTimeout(g.current);let e=u.trim();if(!(e.length<2))return g.current=window.setTimeout(()=>{h(e),q(`action:search.${f}`),s(e,f)},300),()=>clearTimeout(g.current)},[u,f]);let _=(0,V.useMemo)(()=>(n??[]).reduce((e,t)=>e+t.total,0),[n]),v=(0,V.useMemo)(()=>new Map((a??[]).map(e=>[e.id,e])),[a]);return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(rc,{size:16,style:{verticalAlign:`-3px`,marginRight:4}}),e?`Search · ${t??`session`}`:`Search all sessions`]}),onClose:l}),(0,J.jsx)(`input`,{className:`search`,placeholder:e?`Find a word in this CLI…`:`Find a word in any session…`,value:u,onChange:e=>d(e.target.value),autoFocus:!0}),(0,J.jsx)(`div`,{className:`segmented srch-scope`,children:Bxe.map(([e,t])=>(0,J.jsx)(`button`,{className:f===e?`seg on`:`seg`,onClick:()=>p(e),children:t},e))}),(0,J.jsxs)(Z,{children:[$0[f].line,(0,J.jsx)(tT,{of:`what this search reads`,children:$0[f].more})]}),(0,J.jsxs)(`div`,{className:`list`,children:[u.trim().length<2&&(0,J.jsx)($,{children:`Type at least 2 characters.`}),u.trim().length>=2&&!i&&n==null&&(0,J.jsx)($,{res:{state:`offline`},thing:`the sessions being searched`}),u.trim().length>=2&&i&&r&&n==null&&(0,J.jsx)($,{children:`Searching…`}),n!=null&&u.trim().length>=2&&(_===0?(0,J.jsxs)($,{children:[`No matches for “`,m,`”.`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(Z,{children:[_,` match`,_===1?``:`es`,` in `,n.length,` session`,n.length===1?``:`s`,r?` · updating…`:``]}),n.map(t=>(0,J.jsxs)(`div`,{className:`srch-sess`,children:[!e&&(()=>{let e=v.get(t.id)??null;return(0,J.jsxs)(`button`,{className:`srch-sess-head`,onClick:()=>c(t.id),title:`open this session`,children:[(0,J.jsxs)(`span`,{className:`srch-sess-line`,children:[(0,J.jsx)(`span`,{className:`srch-sess-title`,children:t.title}),(0,J.jsxs)(`span`,{className:`srch-sess-repo`,children:[t.repoLabel,!e&&!t.running?` · exited`:``]}),(0,J.jsx)(`span`,{className:`srch-sess-count`,children:t.total}),(0,J.jsx)(Wte,{size:13})]}),e&&(0,J.jsx)(MK,{s:e,backends:o})]})})(),t.matches.map((e,t)=>(0,J.jsx)(Hxe,{m:e,q:m},t)),t.total>t.matches.length&&(0,J.jsxs)(`div`,{className:`srch-more`,children:[`+`,t.total-t.matches.length,` more match`,t.total-t.matches.length===1?``:`es`,` (refine the search)`]})]},t.id))]}))]})]})}var e2=W({scope:null,results:null,loading:!1});function Wxe(e,t){return(e??null)===t}function Gxe(e){e2.set({scope:e,results:null,loading:!1}),U().nav.open(`search`)}function Kxe(e,t){let n=e2.get();e2.set({...n,loading:!0}),U().conn.send({t:`session.search`,query:e,scope:t,id:n.scope??void 0})}function qxe(e,t){let n=e2.get();Wxe(e,n.scope)&&e2.set({...n,results:t,loading:!1})}function Jxe(){let e=Dh(),{scope:t,results:n,loading:r}=G(e2),i=e.world.sessions;return(0,J.jsx)(Uxe,{sessionId:t,sessionLabel:t?i.find(e=>e.id===t)?.title:void 0,results:n,loading:r,online:e.conn.status===`open`,sessions:i,backends:e.world.backends,onSearch:Kxe,onOpenSession:t=>{let n=i.find(e=>e.id===t);n?e.nav.attach(n):e.nav.close(`search`)},onClose:()=>e.nav.close(`search`)})}var Yxe={id:`search`,sheets:[{id:`search`,persisted:!1,render:()=>(0,V.createElement)(Jxe)}],messages:{"session.searchResults":e=>qxe(e.id,e.results)}},Xxe={prompt:{label:`prompt`,Icon:Rs},command:{label:`command`,Icon:lo},backlog:{label:`backlog`,Icon:il}};function Zxe({title:e,entries:t,pinnedEntryId:n,onClose:r,onResend:i,onPin:a,offline:o}){let[s,c]=(0,V.useState)(new Set),l=e=>c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:(0,J.jsxs)(J.Fragment,{children:[`History · `,e]}),onClose:r}),(0,J.jsxs)(Z,{children:[`Every command and backlog item sent to this session, with the output captured for that turn. Output is the terminal's text, stripped of formatting — not a perfect transcript. Pin an entry to show it as this session's overview label — handy when the last prompt is just a "yes".`,o&&` You're offline — showing the last synced prompts; captured output isn't cached and comes back once the connection is.`]}),(0,J.jsxs)(`div`,{className:`list hist`,children:[t.length===0&&(0,J.jsx)($,{children:`Nothing sent yet.`}),t.map(e=>{let t=Xxe[e.kind],r=s.has(e.id),c=e.id===n;return(0,J.jsxs)(`div`,{className:`hist-item${c?` pinned`:``}`,children:[(0,J.jsxs)(`div`,{className:`hist-head`,children:[(0,J.jsxs)(qw,{className:`hist-${e.kind}`,children:[(0,J.jsx)(t.Icon,{size:12}),` `,t.label]}),c&&(0,J.jsxs)(qw,{className:`hist-pinned`,children:[(0,J.jsx)(ko,{size:12}),` overview`]}),(0,J.jsx)(Q,{children:Tp(e.sentAt)}),(0,J.jsxs)(`span`,{className:`hist-actions`,children:[(0,J.jsx)(Y,{className:c?`active`:void 0,title:c?`unpin from overview`:`pin as overview label`,onClick:()=>a(c?null:e.id),children:(0,J.jsx)(ko,{size:14,fill:c?`currentColor`:`none`})}),(0,J.jsx)(Y,{title:`copy prompt`,onClick:()=>void navigator.clipboard?.writeText(e.text),children:(0,J.jsx)(_o,{size:14})}),(0,J.jsx)(Y,{title:`re-send`,onClick:()=>i(e.text),children:(0,J.jsx)(Kte,{size:14})})]})]}),(0,J.jsx)(`div`,{className:`hist-prompt`,children:e.text}),e.output===void 0?(0,J.jsx)(`div`,{className:`hist-pending`,children:o?`output unavailable offline`:`capturing output…`}):e.output===``?(0,J.jsx)(`div`,{className:`hist-pending`,children:`(no text output)`}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`pre`,{className:`hist-out ${r?`open`:``}`,children:e.output}),e.output.length>400&&(0,J.jsx)(`button`,{className:`hist-more`,onClick:()=>l(e.id),children:r?`show less`:`show more`})]})]},e.id)})]})]})}var t2=W(nx());function Qxe(e){return e?`pinned as overview label`:`unpinned`}function $xe(e,t){t2.set(n=>kh(n,e,t)),rx(e,t)}function eSe(e){let t=U();t.compose.insert(e),t.nav.close(`history`),t.say.toast(`dropped into composer`)}function tSe(e,t){let n=U();n.say.track(`action:session.pin`),n.conn.send({t:`session.pin`,id:e,entryId:t}),n.say.toast(Qxe(t))}function nSe({active:e}){let t=Dh(),n=G(t2).get(e.id)??[];return(0,J.jsx)(Zxe,{title:e.title,entries:n,pinnedEntryId:e.pinnedEntryId,offline:t.conn.status!==`open`,onClose:()=>t.nav.close(`history`),onResend:eSe,onPin:t=>tSe(e.id,t)})}var rSe={id:`history`,sheets:[{id:`history`,persisted:!1,render:e=>{let t=e.world.active;return t?(0,V.createElement)(nSe,{active:t}):null}}]},n2=`screenlog`,r2=12,i2=new Map,a2=new Set;function iSe(e){return i2.get(e)??at()}function aSe(e){return Zt(iSe(e))}function oSe(e){return(i2.get(e)?.archived.length??0)>0}function o2(e,t){let n=i2.get(e)??at(),r=Ie(n,t);return r===n||(i2.set(e,r),r.archived===n.archived)?!1:(a2.add(e),!0)}async function sSe(){let e=await My(n2)??[];for(let t of e)t?.sessionId&&!i2.has(t.sessionId)&&i2.set(t.sessionId,at(t.archived??[]))}async function cSe(e){if(!a2.has(e))return;let t=i2.get(e);if(!t||t.archived.length===0)return;a2.delete(e),await Ay(n2,e,{sessionId:e,archived:t.archived,savedAt:Date.now()});let n=await My(n2)??[];if(!(n.length<=r2))for(let e of[...n].sort((e,t)=>t.savedAt-e.savedAt).slice(r2))await jy(n2,e.sessionId)}async function lSe(){return i2.clear(),a2.clear(),Fy(n2)}function s2({smaller:e,bigger:t,onZoom:n,what:r=``,subject:i=`the text`,smallerHint:a=``,biggerHint:o=``,endClassName:s=`row-sub`,iconSize:c=14}){let l=e==null?`smallest`:t==null?`biggest`:``,u=r?`${r} text`:`text`;return(0,J.jsxs)(J.Fragment,{children:[e!=null&&(0,J.jsx)(Y,{"aria-label":`smaller ${u}`,title:`smaller ${u}${a}`,onClick:()=>n(e),children:(0,J.jsx)(qc,{size:c})}),l&&(0,J.jsx)(`span`,{className:s,"aria-live":`polite`,title:`${i} is as ${l===`smallest`?`small`:`big`} as it goes — the other button is the way back`,children:l}),t!=null&&(0,J.jsx)(Y,{"aria-label":`bigger ${u}`,title:`bigger ${u}${o}`,onClick:()=>n(t),children:(0,J.jsx)(Sc,{size:c})})]})}function uSe({sessionId:e,title:t,live:n,linkUp:r,onClose:i}){let a=(0,V.useMemo)(()=>{let t=aSe(e),r=dSe(n);return fSe(t,r)?t:t.concat(r)},[e,n]),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(!1),[u,d]=(0,V.useState)(r);(0,V.useEffect)(()=>{if(!r||o){d(!1);return}let t=!0;return d(!0),H.scrollback(e).then(e=>{t&&e.lines.length&&(e.history||e.lines.length>a.length?s({lines:e.lines,bounded:e.bounded}):l(!0))}).catch(()=>{}).finally(()=>{t&&d(!1)}),()=>{t=!1}},[e,r,o,a.length]);let f=o?o.lines:a,[p,m]=(0,V.useState)(``),[h,g]=(0,V.useState)(0),_=(0,V.useRef)(null),[v,y]=(0,V.useState)(()=>qne()),b=Nu(),x=Mu(v,-1,b),S=Mu(v,1,b);function C(e){q(`action:uiscale.scrollback`),y(e),$ne(e)}let w=(0,V.useMemo)(()=>{let e=p.trim().toLowerCase();if(!e)return[];let t=[];return f.forEach((n,r)=>{n.toLowerCase().includes(e)&&t.push(r)}),t},[p,f]);(0,V.useLayoutEffect)(()=>{let e=_.current;e&&(e.scrollTop=e.scrollHeight)},[o]),(0,V.useEffect)(()=>{g(Math.max(0,w.length-1))},[p,w.length]),(0,V.useEffect)(()=>{w.length&&(_.current?.querySelector(`[data-ln="${w[h]}"]`))?.scrollIntoView({block:`center`})},[h,w]);function T(e){w.length&&g(t=>(t+e+w.length)%w.length)}let E=f.length===0;return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:(0,J.jsxs)(J.Fragment,{children:[`Scrollback · `,t]}),onClose:i,children:(0,J.jsxs)(Q,{children:[f.length,` line`,f.length===1?``:`s`]})}),(0,J.jsxs)(`div`,{className:`tr-bar`,children:[(0,J.jsxs)(`div`,{className:`tr-find`,children:[(0,J.jsx)(rc,{size:13}),(0,J.jsx)(`input`,{value:p,placeholder:`find in scrollback`,onChange:e=>{!p&&e.target.value&&q(`action:scrollback.find`),m(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),T(e.shiftKey?-1:1))},autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1}),p&&(0,J.jsx)(Y,{title:`clear`,onClick:()=>m(``),children:(0,J.jsx)(B,{size:13})})]}),p&&(0,J.jsxs)(`div`,{className:`sb-hits`,children:[(0,J.jsx)(Q,{children:w.length?`${h+1}/${w.length}`:`no match`}),(0,J.jsx)(Y,{title:`previous match`,disabled:!w.length,onClick:()=>T(-1),children:(0,J.jsx)(to,{size:14})}),(0,J.jsx)(Y,{title:`next match`,disabled:!w.length,onClick:()=>T(1),children:(0,J.jsx)(ts,{size:14})})]}),(0,J.jsx)(`div`,{className:`sb-zoom`,children:(0,J.jsx)(s2,{smaller:x,bigger:S,onZoom:C,smallerHint:` — fits more of each terminal line on one line`,biggerHint:` — fewer characters across, so lines wrap more`})})]}),(0,J.jsxs)(`div`,{className:`tr-status`,title:o?`recorded on the desktop, which watches this session whether or not the app is open`:c?`the desktop answered, but its recording of this session starts later than this device's — it only holds what it has watched since the daemon last started`:`the desktop could not be asked — this is the history this device reconstructed from what it displayed`,children:[o?(0,J.jsx)(xo,{size:13}):(0,J.jsx)(fo,{size:13}),(0,J.jsx)(`span`,{className:`tr-live-what`,children:o?o.bounded?`from the desktop — as far back as it kept`:`from the desktop`:u?`asking the desktop…`:c?`this device's own copy — the desktop has recorded less`:`this device's own copy — reconstructed`})]}),(0,J.jsx)(`div`,{className:`sb-body`,ref:_,style:{"--ui-font":String(ju(b,v))},children:E?(0,J.jsx)($,{children:u?`Asking the desktop for this session's scrollback…`:`Nothing recorded on this device yet — history starts the next time this session paints.`}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{className:`sb-top`,children:o?`Recorded on the desktop, which watches this session whether or not this app is open. It begins when the daemon does and what it keeps is bounded — ask the reader view for anything older.`:`Reconstructed from what this device displayed — output that scrolled by while the app was closed was never here, and a view switch can leave a block in twice. Ask the session itself (or the reader view) for anything older.`}),f.map((e,t)=>(0,J.jsx)(`div`,{className:`sb-line${w.length&&w[h]===t?` sb-hit`:``}`,"data-ln":t,children:e===``?`\xA0`:e},t))]})})]})}function dSe(e){let t=e.length;for(;t>0&&e[t-1].trim()===``;)t--;return e.slice(0,t)}function fSe(e,t){if(t.length===0)return!0;if(t.length>e.length)return!1;let n=e.length-t.length;for(let r=0;r<t.length;r++)if(e[n+r]!==t[r])return!1;return!0}var c2=W([]);function pSe({active:e}){let t=Dh(),n=G(c2);return(0,J.jsx)(uSe,{sessionId:e.id,title:e.title,live:n,linkUp:t.conn.status===`open`,onClose:()=>t.nav.close(`scrollback`)})}function mSe(){let e=U(),t=e.world.active;if(!t){e.say.toast(`no active session`);return}let n=e.term.snapshot();n.length&&o2(t.id,n),c2.set(n),e.nav.open(`scrollback`)}var hSe={id:`scrollback`,sheets:[{id:`scrollback`,persisted:!1,render:e=>{let t=e.world.active;return t?(0,V.createElement)(pSe,{active:t}):null}}]},gSe=6e3,_Se=2500;function l2(e,t=Date.now()){if(!e)return``;let n=Math.max(0,Math.round((t-e)/1e3));return n<60?`${n}s`:`${Math.floor(n/60)}m ${n%60}s`}function vSe(e){let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(r.kind!==`tool`){t.push({kind:`block`,block:r,i:n});continue}let i=n;for(;i+1<e.length&&e[i+1].kind===`tool`;)i++;i>n?(t.push({kind:`tools`,blocks:e.slice(n,i+1),i:n}),n=i):t.push({kind:`block`,block:r,i:n})}return t}function ySe(e){let t=new Map;for(let n of e)t.set(n.name,(t.get(n.name)??0)+1);return[...t].map(([e,t])=>t>1?`${t} ${e}`:e).join(`, `)}var bSe=(e,t)=>t===`fold`?vSe(e):e.map((e,t)=>({kind:`block`,block:e,i:t}));function xSe({m:e}){let{q:t,setQ:n,findOpen:r,setFindOpen:i,hitIdx:a,setHitIdx:o,hitCount:s,jump:c}=e;return r||t?(0,J.jsxs)(`div`,{className:`tr-bar tr-bar-find`,children:[(0,J.jsxs)(`div`,{className:`tr-find`,children:[(0,J.jsx)(rc,{size:13}),(0,J.jsx)(`input`,{autoFocus:!0,value:t,placeholder:`find in conversation`,onChange:e=>{!t&&e.target.value&&q(`action:read.find`),n(e.target.value),o(0)},autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1}),(0,J.jsx)(Y,{title:`close find`,onClick:()=>{n(``),i(!1)},children:(0,J.jsx)(B,{size:13})})]}),t&&(0,J.jsxs)(`span`,{className:`tr-hits`,children:[(0,J.jsx)(Y,{onClick:()=>c(-1),disabled:!s,children:(0,J.jsx)(mc,{size:13})}),(0,J.jsx)(Q,{children:s?`${a+1}/${s}`:`0`}),(0,J.jsx)(Y,{onClick:()=>c(1),disabled:!s,children:(0,J.jsx)(Nc,{size:13})})]})]}):null}function SSe({m:e}){let{status:t,live:n,stale:r,liveTitle:i,work:a,shellFirstWords:o,now:s,onOpenShells:c,asking:l,onAnswer:u,agents:d,offlineAt:f,cachedAt:p}=e;return(0,J.jsxs)(J.Fragment,{children:[n&&(0,J.jsxs)(`div`,{className:`tr-status tr-live tr-${n.kind}${r?` tr-linkdown`:``}`,title:i,children:[r?(0,J.jsx)(fo,{size:13}):(0,J.jsx)(`span`,{className:`tr-live-dot`}),(0,J.jsx)(`span`,{className:`tr-live-what`,children:r?`${n.text} — last known`:n.text}),a&&(0,J.jsx)(`span`,{className:`tr-live-line`,children:a.text}),n.kind===`shells`&&o&&(0,J.jsx)(`span`,{className:`tr-live-line`,children:o}),t?.lastOutputAt!=null&&(r||n.kind===`busy`)&&(0,J.jsxs)(`span`,{className:`tr-live-ago`,children:[`out `,l2(t.lastOutputAt,s)]}),n.kind===`shells`&&c&&(0,J.jsx)(`button`,{className:`tr-live-go`,onClick:c,children:`see shells`}),l&&t?.prompt&&u&&(0,J.jsx)(`button`,{className:`tr-live-go`,onClick:()=>document.getElementById(`tr-ask`)?.scrollIntoView({block:`end`,behavior:`smooth`}),children:`answer it`})]}),d.map(e=>(0,J.jsxs)(`div`,{className:`tr-status tr-agent`,title:e.type?`${e.type}${e.model?` · ${e.model}`:``}`:void 0,children:[(0,J.jsx)(Uo,{size:13}),(0,J.jsx)(`span`,{className:`tr-live-what`,children:e.what}),e.doing&&(0,J.jsx)(`span`,{className:`tr-live-line`,children:e.doing}),(0,J.jsx)(`span`,{className:`tr-live-ago`,children:l2(e.startedAt,s)})]},e.id)),(f!=null||p!=null)&&(0,J.jsxs)(`div`,{className:`tr-status`,title:`showing the transcript saved on this device`,children:[(0,J.jsx)(fo,{size:13}),(0,J.jsxs)(`span`,{className:`tr-live-what`,children:[f==null?`cached copy — still asking the host`:`showing cached transcript`,p==null?``:` — saved ${kp(Date.now()-p)}`,f==null?``:`, newest turn ${B_(f)}`]})]})]})}function u2({turns:e,seenMark:t,onJump:n}){return(0,J.jsx)(J.Fragment,{children:e.map(e=>{let r=t>0&&H_(e)>t;return(0,J.jsxs)(`button`,{className:`tr-ol-row${r?` tr-ol-new`:``}`,onClick:()=>n(e.n),children:[(0,J.jsxs)(`div`,{className:`tr-ol-head`,children:[(0,J.jsxs)(`span`,{className:`tr-n`,children:[`#`,e.n]}),(0,J.jsx)(Q,{children:B_(e.sentAt)}),e.queued&&(0,J.jsxs)(qw,{children:[(0,J.jsx)(os,{size:11}),` waiting`]}),e.toolCount>0&&(0,J.jsxs)(qw,{children:[(0,J.jsx)(bs,{size:11}),` `,e.toolCount]}),e.files.length>0&&(0,J.jsxs)(qw,{children:[(0,J.jsx)(al,{size:11}),` `,e.files.length]}),r&&(0,J.jsx)(qw,{className:`new`,children:`new`})]}),(0,J.jsx)(`div`,{className:`tr-ol-prompt`,children:e.promptLabel}),e.queued&&(0,J.jsx)(`div`,{className:`tr-ol-sum`,children:`→ the CLI has not started it yet`}),e.summary&&(0,J.jsxs)(`div`,{className:`tr-ol-sum`,children:[`→ `,e.summary]}),e.files.length>0&&(0,J.jsxs)(`div`,{className:`tr-ol-files`,children:[e.files.slice(0,4).join(` · `),e.files.length>4?` …`:``]})]},e.id)})})}function CSe({sessionId:e,title:t,onJump:n,onClose:r}){let[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(!1),[u,d]=(0,V.useState)(null),[f,p]=(0,V.useState)(``),m=(0,V.useRef)(!1),h=(0,V.useRef)(!0),[g,_]=(0,V.useState)(!0),v=(0,V.useCallback)(async()=>{l(!0);try{let t=await H.transcript(e);if(!h.current)return;m.current=!0,t&&a(t),d(null),s(null)}catch(t){let n=await Qy(e);if(!h.current)return;n?(a(n),d(n.updatedAt)):String(t).includes(`404`)?s(`Nothing recorded for this session yet.`):s(Qe(t)?`Can't reach the host, and there's no outline saved on this device for this session yet.`:String(t))}finally{h.current&&l(!1)}},[e]);(0,V.useEffect)(()=>(h.current=!0,_(!0),Qy(e).then(e=>{e&&h.current&&!m.current&&a(e)}).finally(()=>{h.current&&_(!1)}),v(),()=>{h.current=!1}),[e,v]);let y=(0,V.useMemo)(()=>W_(e),[e]),b=i?.turns??[],x=b.filter(e=>e.queued).length,S=(0,V.useMemo)(()=>f?b.filter(e=>J_(q_(e),f)):b,[b,f]);return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:(0,J.jsxs)(J.Fragment,{children:[`Outline · `,t]}),onClose:r,children:(0,J.jsx)(Y,{title:`refresh`,onClick:()=>void v(),children:(0,J.jsx)(xc,{size:14})})}),(0,J.jsx)(`div`,{className:`tr-bar`,children:(0,J.jsxs)(`div`,{className:`tr-find`,children:[(0,J.jsx)(rc,{size:13}),(0,J.jsx)(`input`,{value:f,placeholder:`find a turn`,onChange:e=>{!f&&e.target.value&&q(`action:outline.find`),p(e.target.value)},autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1}),f&&(0,J.jsx)(Y,{title:`clear`,onClick:()=>p(``),children:(0,J.jsx)(B,{size:13})})]})}),u!=null&&(0,J.jsxs)(`div`,{className:`tr-status`,title:`couldn't reach the host just now — showing the transcript saved on this device`,children:[(0,J.jsx)(fo,{size:13}),(0,J.jsxs)(`span`,{className:`tr-live-what`,children:[`showing cached transcript — as of `,B_(u)]})]}),(0,J.jsxs)(`div`,{className:`tr-outline tr-outline-full`,children:[(0,J.jsxs)(Z,{children:[S.length,` turn`,S.length===1?``:`s`,f?` matching “${f}”`:``,x>0&&` · ${x} waiting`,` · tap to jump into the reader`,i?.source===`history`&&` · approximate (no conversation log for this session — showing captured terminal text)`,i?.truncated&&` · older turns trimmed`]}),c&&!i&&!g&&(0,J.jsx)($,{children:`Reading the transcript…`}),o&&!i&&(0,J.jsxs)($,{children:[(0,J.jsx)(gs,{size:14}),` `,o]}),i&&b.length===0&&(0,J.jsx)($,{children:`No turns recorded yet.`}),(0,J.jsx)(u2,{turns:S,seenMark:y,onJump:n})]})]})}function wSe({m:e}){let{outline:t,outlineTurns:n,q:r,doc:i,seenMark:a,goTurn:o}=e;return t?(0,J.jsxs)(`div`,{className:`tr-outline`,children:[(0,J.jsxs)(Z,{children:[n.length,` turn`,n.length===1?``:`s`,r?` matching “${r}”`:``,` · tap to jump`,i?.source===`history`&&` · approximate (no conversation log for this session — showing captured terminal text)`,i?.truncated&&` · older turns trimmed`]}),(0,J.jsx)(u2,{turns:n,seenMark:a,onJump:o})]}):null}function d2(e){let t=(e.models??[]).map(e=>({...e}));for(let n of e.agentModels??[]){let e=t.find(e=>e.id===n.id);e?(e.tok+=n.tok,n.costUsd!=null&&(e.costUsd=(e.costUsd??0)+n.costUsd)):t.push({...n})}return t}function f2(e){let t=new Map;for(let n of e)for(let e of d2(n))t.set(e.id,(t.get(e.id)??0)+e.tok);if(!t.size)return null;let n=[...t.entries()].sort((e,t)=>t[1]-e[1]).map(([e])=>e),r=qE(n);return{of:r,rest:n.some(e=>!r.has(e))?4:null}}var p2=e=>(nt(e)??e).replace(/^claude-/,``);function TSe(e,t){let n=d2(e).filter(e=>e.tok>0);if(!n.length||!t)return null;let r=n.every(e=>e.costUsd!=null&&e.costUsd>0),i=e=>r?e.costUsd:e.tok,a=n.reduce((e,t)=>e+i(t),0);if(a<=0)return null;let o=[],s=[];for(let e of n){let n=t.of.get(e.id);n==null?s.push(e):o.push({id:e.id,name:p2(e.id),slot:n,share:i(e)/a,costUsd:e.costUsd,tok:e.tok})}if(s.length){let e=s.reduce((e,t)=>e+t.tok,0),t=s.every(e=>e.costUsd!=null)?s.reduce((e,t)=>e+t.costUsd,0):void 0;o.push({id:s.length===1?s[0].id:`\0rest`,name:s.length===1?p2(s[0].id):`${s.length} more`,slot:4,share:s.reduce((e,t)=>e+i(t),0)/a,costUsd:t,tok:e})}return o.sort((e,t)=>GE(e.slot,t.slot)),{by:r?`cost`:`tokens`,parts:o}}var m2=e=>e.sidechains+e.blocks.filter(e=>e.kind===`tool`&&(e.name===`Task`||e.name===`Agent`)).length,h2=e=>e!=null&&Number.isFinite(e)&&e>0;function g2(e){return e.marker||e.queued?!1:h2(e.costUsd)||h2(e.ctxTok)||h2(e.cumCostUsd)||h2(e.agentCostUsd)||E(e.tokens)!=null||d2(e).some(e=>e.tok>0)}function _2(e){for(let t=e.length-1;t>=0;t--)if(g2(e[t]))return e[t];return null}function ESe(e,t){for(let n of e){if(m2(n)>0)return!0;if(n.id===t)return!1}return!1}var DSe=1e4;function OSe(e,t,n){return t?n!=null&&e.sentAt!=null&&e.sentAt>=n-DSe?`running`:`previous`:`last`}function kSe(e,t){let n=`#${e.n}`;return t===`running`?`prompt ${n} so far · running`:t===`previous`?`prompt ${n} · a newer one is running`:t===`earlier`?`prompt ${n}`:`last prompt ${n}`}function ASe(e){return e===`running`?`Figures for the prompt still running, as far as its log has got; they are re-read when it ends.`:e===`previous`?`The prompt now running is not in the log yet — its figures replace these when it ends.`:null}function jSe(e){let t=h2(e.costUsd)?e.costUsd+(h2(e.agentCostUsd)?e.agentCostUsd:0):null,n=e.tokens?[e.tokens.input,e.tokens.output,e.tokens.cacheRead,e.tokens.cacheWrite].reduce((e,t)=>e+(h2(t)?t:0),0):0,r=[t==null?n>0?`${er(n)} tokens`:null:_t(t),h2(e.ctxTok)?`${er(e.ctxTok)} ctx`:null].filter(Boolean);return r.length?r.join(` · `):null}var v2=[`var(--chart-1)`,`var(--chart-2)`,`var(--chart-3)`,`var(--chart-4)`,`var(--muted)`];function MSe({parts:e}){let t=2*Math.PI*12,n=e.length>1?1.2:0,r=0;return(0,J.jsxs)(`svg`,{className:`tr-mix-donut`,viewBox:`0 0 32 32`,width:`32`,height:`32`,"aria-hidden":!0,children:[(0,J.jsx)(`circle`,{cx:`16`,cy:`16`,r:12,fill:`none`,stroke:`var(--line)`,strokeWidth:`6`}),e.map(e=>{let i=e.share*t,a=(0,J.jsx)(`circle`,{cx:`16`,cy:`16`,r:12,fill:`none`,stroke:v2[e.slot],strokeWidth:`6`,strokeDasharray:`${Math.max(.6,i-n)} ${t}`,strokeDashoffset:-r,transform:`rotate(-90 16 16)`},e.id);return r+=i,a})]})}function NSe({t:e,slots:t,agentsSoFar:n,usdPerWeekPct:r,weekIncl:i,onOpen:a,next:o,trackId:s=`action:read.cost`,why:c=!1}){let l=nn({costUsd:e.costUsd,cumCostUsd:e.cumCostUsd,ctxTok:e.ctxTok,agents:m2(e),agentsSoFar:n,agentCostUsd:e.agentCostUsd,cumAgentCostUsd:e.cumAgentCostUsd,agentsRunning:e.agentsRunning,agentUnpricedTok:e.agentUnpricedTok,usdPerWeekPct:r,weekIncl:i}),u=TSe(e,t),d=e.agentTypes??[],f=E(e.tokens);if(!l&&!u&&!d.length&&!f&&!o)return null;let p=(0,J.jsxs)(J.Fragment,{children:[l?.turn&&(0,J.jsx)(`span`,{className:`tr-cost-head`,children:l.turn}),l&&(l.agents||l.total||l.ctx)&&(0,J.jsx)(`span`,{className:`tr-cost-parts`,children:[l.agents,l.total,l.ctx].filter(Boolean).map((e,t)=>(0,J.jsx)(`span`,{children:e},t))}),f&&(0,J.jsx)(`span`,{className:`tr-cost-toks`,children:f}),o&&(0,J.jsx)(`span`,{className:`tr-cost-next`,children:o}),u&&(0,J.jsxs)(`span`,{className:`tr-mix-legend`,children:[u.parts.map(e=>(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`i`,{style:{background:v2[e.slot]}}),e.name,` `,e.costUsd!=null&&e.costUsd>0?_t(e.costUsd):er(e.tok),u.parts.length>1&&(0,J.jsxs)(`span`,{className:`tr-mix-share`,children:[` `,Math.round(e.share*100),`%`]})]},e.id)),u.parts.length>1&&(0,J.jsxs)(`span`,{className:`tr-mix-share`,children:[`split by `,u.by]})]}),d.length>0&&(0,J.jsx)(`span`,{className:`tr-cost-agents`,children:d.map(e=>(0,J.jsxs)(`span`,{className:`tr-cost-agent`,children:[(0,J.jsx)(Uo,{size:11}),` `,e.type,e.n>1?` ×${e.n}`:``]},e.type))}),l?.note&&(0,J.jsx)(`span`,{className:`tr-cost-note`,children:l.note})]}),m=(0,J.jsxs)(J.Fragment,{children:[u?(0,J.jsx)(MSe,{parts:u.parts}):l&&(0,J.jsx)(Jc,{size:12}),u?(0,J.jsx)(`span`,{className:`tr-cost-col`,children:p}):p,a&&(0,J.jsx)(Hs,{size:12,className:`tr-cost-go`})]}),h=a?(0,J.jsx)(`button`,{type:`button`,className:`tr-cost tr-cost-btn`,onClick:()=>{q(s),a()},children:m}):(0,J.jsx)(`div`,{className:`tr-cost`,children:m}),g=!!(l?.turn||l?.total)||u?.by===`cost`;return c&&g?(0,J.jsx)(PSe,{children:h}):h}function PSe({children:e}){let[t,n]=(0,V.useState)(!1);return(0,J.jsxs)(`div`,{className:`tr-cost-why`,children:[e,(0,J.jsx)(`button`,{type:`button`,className:`tr-cost-q`,"aria-label":Xn,"aria-expanded":t,onClick:()=>n(e=>!e),children:(0,J.jsx)(cs,{size:14})}),t&&(0,J.jsxs)(`p`,{className:`tr-cost-why-text`,children:[(0,J.jsx)(`b`,{children:`Why dollars on a subscription?`}),` `,`Your plan's session and weekly limits don't count every token the same: on one model a cache read costs a hundredth of an output token. Adding tokens up treats them as equal, so the total says little about how much of your limit a prompt used. Pricing each kind at Anthropic's API list price weighs it by its own rate — the one number you can compare across prompts, sessions and models. It is not a bill.`]}),t&&(0,J.jsxs)(`p`,{className:`tr-cost-why-text`,children:[(0,J.jsx)(`b`,{children:`Why only the last prompt in the CLI view?`}),` `,`The reader folds this card under every prompt — tap a line to open it, and scroll up for older ones. The CLI view has no scroll-back of its own to hang a card on, so it keeps only the last prompt's, pinned under the terminal at a fixed height: opening or updating it never resizes the screen, which would make the CLI redraw. Same figures, same card; the newest one remembers open or folded in both.`]})]})}function y2({t:e,which:t,open:n,onToggle:r,onChip:i,growsUp:a=!1,className:o=``,bodyClass:s=``,...c}){if(!g2(e)&&!c.next)return null;let l=jSe(e),u=kSe(e,t),d=ASe(t);return(0,J.jsxs)(`div`,{className:`cost-fold${n?` open`:``}${o?` ${o}`:``}`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`cost-fold-head`,"aria-expanded":i?void 0:n,"aria-label":i?`open the context and cost sheet`:`${n?`collapse`:`expand`} the cost of ${u}`,onPointerDown:e=>e.preventDefault(),onClick:i??r,children:[(0,J.jsx)(Jc,{size:13,className:`cost-fold-glyph`}),l&&!(n&&!i)&&(0,J.jsx)(`span`,{className:`cost-fold-chip`,children:l}),(0,J.jsx)(`span`,{className:`cost-fold-label`,children:u}),!i&&(n===a?(0,J.jsx)(Nc,{size:14,className:`cost-fold-chev`}):(0,J.jsx)(mc,{size:14,className:`cost-fold-chev`}))]}),n&&!i&&(0,J.jsxs)(`div`,{className:`cost-fold-body${s?` ${s}`:``}`,children:[d&&(0,J.jsx)(`div`,{className:`cost-fold-note`,children:d}),(0,J.jsx)(NSe,{t:e,...c})]})]})}function FSe({className:e=``}){return(0,J.jsxs)(`details`,{className:`hint-more dollars-why ${e}`.trim(),children:[(0,J.jsxs)(`summary`,{children:[(0,J.jsx)(cs,{size:12}),` `,Xn]}),(0,J.jsx)(`p`,{children:wr})]})}var ISe=/^t\d+$/,b2=/^screen:/;function x2(e){return!ISe.test(e.id)&&!b2.test(e.id)}function S2(e){return b2.test(e.id)}function C2(e){return!e||e.source===`history`?!1:e.source!==`jsonl`||!!e.claudeSessionId}function w2(e,t){if(!C2(e)||!x2(t)&&!S2(t))return null;let n=e.turns.findIndex(e=>e.id===t.id);if(n<0)return null;let r=0;for(let t=n-1;t>=0;t--){let n=e.turns[t];if(!n)return null;if(x2(n))return{turn:n,skipped:r};if(!S2(n))return null;r+=1}return null}function LSe(e,t,n,r=!0){if(!r)return`this conversation has no id yet, so nothing can be cut from it`;if(!w2(e,t)){if(!C2(e)||!x2(t)&&!S2(t))return`this turn isn't in the conversation record`;let n=e.turns.findIndex(e=>e.id===t.id);return e.turns.slice(0,Math.max(0,n)).some(e=>!x2(e)&&!S2(e))?`the turns before this one were not read from the conversation log, so there is no exact point to rewind to`:`nothing in the conversation log comes before this turn — a copy from here would be empty; open a new session instead`}return n?null:`no connection — forking starts a session on the host`}function RSe(e,t){return t.skipped===0?null:`The ${t.skipped===1?`turn`:`${t.skipped} turns`} between #${t.turn.n} and #${e.n} ${t.skipped===1?`was a command`:`were commands`} the CLI answered in the terminal and wrote nothing to the conversation log, so the copy ends after #${t.turn.n}. Nothing is lost by that: the conversation is exactly what ${t.skipped===1?`that command`:`those commands`} left it as.`}function zSe({doc:e,turn:t,fork:n,onRun:r}){let i=w2(e,t),a=LSe(e,t,n.online,!!e?.claudeSessionId||n.hasId!==!1),o=i?RSe(t,i):null,s=o=>{!a&&i&&e&&(q(`action:read.${o}`),r(),n.run({mode:o,sourceId:e.claudeSessionId??``,turnId:i.turn.id,n:t.n}))};return(0,J.jsxs)(`div`,{className:`tr-fork`,children:[a?(0,J.jsx)(Qw,{cants:[{label:`fork from here`,reason:a},{label:`reset to here`,reason:a}]}):(0,J.jsxs)(`div`,{className:`tr-fork-acts`,children:[(0,J.jsxs)(Y,{onClick:()=>s(`fork`),children:[(0,J.jsx)(Rc,{size:12}),` fork from here`]}),(0,J.jsxs)(Y,{variant:`danger`,onClick:()=>s(`reset`),children:[(0,J.jsx)(Zs,{size:12}),` reset to here`]})]}),o&&(0,J.jsx)(Q,{as:`div`,children:o}),!a&&(0,J.jsxs)(Q,{as:`div`,children:[`Both take back #`,t.n,`: fork opens a second session holding this conversation up to just before it (through #`,i?.turn.n,`) and leaves this one running; reset replaces this session with that copy. Neither deletes anything: #`,t.n,` and the turns after it stay on disk under this conversation and stay listed in the archive, and no file in the repo is touched.`]})]})}var T2=(e,t=Date.now())=>{if(!e)return``;let n=new Date(e),r=n.getFullYear()!==new Date(t).getFullYear();return n.toLocaleString([],{weekday:`short`,day:`numeric`,month:`short`,...r?{year:`numeric`}:{},hour:`2-digit`,minute:`2-digit`})},BSe=(e,t)=>{if(!e||!t||t<e)return``;let n=Math.round((t-e)/1e3);if(n<60)return`${n}s`;let r=Math.round(n/60);return r<60?`${r}m`:`${Math.floor(r/60)}h ${r%60}m`};function E2({open:e,onToggle:t,head:n,children:r}){return(0,J.jsxs)(`div`,{className:`tr-collapse${e?` open`:``}`,children:[(0,J.jsxs)(`button`,{className:`tr-collapse-head`,onClick:t,children:[e?(0,J.jsx)(Nc,{size:13}):(0,J.jsx)(Hs,{size:13}),n]}),e&&(0,J.jsx)(`div`,{className:`tr-collapse-body`,children:r})]})}function D2({m:e,t,b:n,k:r}){let{openBlocks:i,q:a,details:o,loadDetails:s,toggleBlock:c}=e,l=r,u=i.has(l)||J_(K_(n),a),d=n.omitted?o.get(t.id):void 0,f=n.omitted?d?.state===`ok`?d.tools[n.id]:void 0:{input:n.input,result:n.result,ok:n.ok,resultTruncated:n.resultTruncated},p=n.ok!==void 0;return(0,J.jsx)(E2,{open:u,onToggle:()=>{!u&&n.omitted&&s(t),c(l)},head:(0,J.jsxs)(`span`,{className:`tr-tool-head`,children:[(0,J.jsx)(bs,{size:12}),` `,(0,J.jsx)(`b`,{children:n.name}),(0,J.jsx)(`span`,{className:`tr-tool-label`,children:HW(n.label,a)}),n.ok===!1&&(0,J.jsx)(qw,{tone:`danger`,children:`error`})]}),children:(0,J.jsxs)(J.Fragment,{children:[d?.state===`loading`&&(0,J.jsx)(`div`,{className:`tr-pending`,children:`loading tool details…`}),d?.state===`error`&&(0,J.jsxs)(`div`,{className:`tr-pending`,children:[(0,J.jsx)(gs,{size:12}),` `,d.msg,` `,(0,J.jsx)(Y,{onClick:()=>void s(t,!0),children:`retry`})]}),f?.input&&(0,J.jsx)(`pre`,{className:`tr-pre tr-in`,children:HW(f.input,a)}),f?.result!==void 0&&(0,J.jsxs)(`pre`,{className:`tr-pre`,children:[HW(f.result,a),f.resultTruncated?`
90
+ … (truncated)`:``]}),f&&f.result===void 0&&(0,J.jsx)(`div`,{className:`tr-pending`,children:p?`empty result`:`no result recorded`})]})},l)}function VSe({m:e,t}){let{toolsMode:n,openBlocks:r,q:i,toggleBlock:a,panelOpen:o,onShowCli:s,files:c,copy:l}=e;return(0,J.jsx)(J.Fragment,{children:bSe(t.blocks,n).map(n=>{let u=`${t.id}:${n.i}`;if(n.kind===`tools`){let o=r.has(u)||n.blocks.some(e=>J_(K_(e),i));return(0,J.jsx)(E2,{open:o,onToggle:()=>{o||q(`action:read.tools`),a(u)},head:(0,J.jsxs)(`span`,{className:`tr-tools-head`,children:[(0,J.jsx)(bs,{size:12}),` `,(0,J.jsxs)(`b`,{children:[n.blocks.length,` tool calls`]}),(0,J.jsx)(`span`,{className:`tr-tool-label`,children:ySe(n.blocks)}),n.blocks.some(e=>e.ok===!1)&&(0,J.jsx)(qw,{tone:`danger`,children:`error`})]}),children:(0,J.jsx)(J.Fragment,{children:n.blocks.map((n,r)=>(0,J.jsx)(D2,{m:e,t,b:n,k:`${u}:${r}`},`${u}:${r}`))})},u)}let d=n.block;if(d.kind===`screen`)return(0,J.jsxs)(V.Fragment,{children:[(0,J.jsx)(`pre`,{className:`tr-screen`,children:d.text}),d.scrollable&&(0,J.jsxs)(`div`,{className:`tr-clipped`,children:[(0,J.jsxs)(Q,{children:[`The CLI drew this in a panel it could scroll, and only the rows it painted were recorded. Anything past them was never printed`,o?` — the panel is still open in the CLI, so it can be scrolled there.`:`, and once that panel closes it is in no record at all.`]}),o&&s&&(0,J.jsxs)(Y,{onClick:()=>{q(`action:read.toCliScroll`),s()},children:[(0,J.jsx)(qa,{size:13}),` scroll it in the CLI`]})]})]},u);if(d.kind===`text`)return(0,J.jsx)(`div`,{className:`tr-say`,children:(0,J.jsx)(eG,{src:d.text,q:i,onCopy:l,files:c})},u);if(d.kind===`thinking`){let e=r.has(u)||J_(d.text,i);return(0,J.jsx)(E2,{open:e,onToggle:()=>a(u),head:(0,J.jsxs)(`span`,{className:`tr-think-head`,children:[(0,J.jsx)(Ts,{size:12}),` thinking`]}),children:(0,J.jsx)(`div`,{className:`tr-think`,children:(0,J.jsx)(eG,{src:d.text,q:i,onCopy:l,files:c})})},u)}return(0,J.jsx)(D2,{m:e,t,b:d,k:u},u)})})}function HSe({m:e,t}){let{turns:n,seenMark:r,newIdx:i,unread:a,markRead:o,copy:s,fork:c,forkTurn:l,setForkTurn:u,doc:d,files:f,q:p,stillGoing:m,whyTurnId:h,costLastOpen:g,costOpen:v,toggleCost:y,mixSlotsDoc:b,agentsSoFar:x,usdPerWeekPct:S,weekIncl:C,onOpenCost:w,nextTurn:T,onShowCli:E,today:D}=e,O=r>0&&H_(t)>r,k=O&&i!==-1&&n[i]?.id===t.id;return(0,J.jsxs)(`div`,{className:`tr-turn${O?` tr-unread`:``}`,id:`tr-turn-${t.n}`,children:[k&&(0,J.jsxs)(`div`,{className:`tr-newmark`,id:`tr-newmark`,children:[(0,J.jsxs)(`span`,{children:[a,` new since you left`]}),(0,J.jsx)(Y,{onClick:o,children:`mark read`})]}),(0,J.jsxs)(`div`,{className:`tr-turn-head`,children:[(0,J.jsxs)(`span`,{className:`tr-n`,children:[`#`,t.n]}),(0,J.jsx)(Q,{children:B_(t.sentAt)}),t.local&&(0,J.jsxs)(qw,{title:t.local===`screen`?`the CLI answered this in the terminal — no conversation-log record exists, so this was read back from the screen capture`:`the CLI answered this itself — a local command, no model turn`,children:[(0,J.jsx)(qa,{size:11}),` `,t.local===`screen`?`terminal only`:`local command`]}),t.queued&&(0,J.jsxs)(qw,{title:`typed into that session and accepted — the CLI holds a prompt until the turn it is working on ends, so nothing has started it yet`,children:[(0,J.jsx)(os,{size:11}),` waiting for the CLI`]}),t.absorbed&&(0,J.jsxs)(qw,{title:`the CLI took this prompt into the turn it was already running instead of starting a new one`,children:[(0,J.jsx)(Lo,{size:11}),` taken mid-turn`]}),t.toolCount>0&&(0,J.jsxs)(qw,{children:[(0,J.jsx)(bs,{size:11}),` `,t.toolCount]}),t.sidechains>0&&(0,J.jsxs)(qw,{children:[t.sidechains,` sub-agent`]}),(0,J.jsx)(Y,{title:`copy turn`,onClick:()=>s(q_(t)),children:(0,J.jsx)(_o,{size:13})}),c&&(0,J.jsx)(Y,{title:`fork or reset to this turn`,"aria-expanded":l===t.id,onClick:()=>u(e=>e===t.id?null:t.id),children:(0,J.jsx)(Rc,{size:13})})]}),c&&l===t.id&&(0,J.jsx)(zSe,{doc:d,turn:t,fork:c,onRun:()=>u(null)}),t.marker===`compaction`&&(0,J.jsxs)(`div`,{className:`tr-mark`,title:`the conversation was summarised here — everything before this point reaches the model as that summary, not as the turns you can read above`,children:[(0,J.jsx)(Hc,{size:12}),` `,(0,J.jsx)(`span`,{children:`conversation compacted here`})]}),t.prompt&&(0,J.jsxs)(`div`,{className:`tr-you`,children:[(0,J.jsx)(eG,{src:t.prompt,q:p,onCopy:s,files:f}),t.sentAt&&new Date(t.sentAt).toDateString()!==D?(0,J.jsxs)(`div`,{className:`tr-when`,children:[`posted `,T2(t.sentAt)]}):null]}),t.queued&&(0,J.jsxs)(`div`,{className:`tr-status tr-note`,children:[(0,J.jsx)(os,{size:13}),(0,J.jsx)(`span`,{className:`tr-live-what`,children:`sent from this app · the CLI has not started it yet`})]}),t.absorbed&&(0,J.jsxs)(`div`,{className:`tr-status tr-note`,children:[(0,J.jsx)(Lo,{size:13}),(0,J.jsx)(`span`,{className:`tr-live-what`,children:`the CLI took this into the turn it was already running · the answer above may be replying to both`})]}),t.local===`screen`&&_(t.prompt)&&(0,J.jsxs)(`div`,{className:`tr-status tr-note`,children:[(0,J.jsx)(qa,{size:13}),(0,J.jsxs)(`span`,{className:`tr-live-what`,children:[`the CLI answers `,t.prompt.trim().split(/\s+/)[0],` in an overlay of its own and keeps no record of it, so the reader does not copy it · read it in the CLI while the overlay is up — once closed (Esc) it is gone`]}),(0,J.jsxs)(Y,{onClick:()=>{q(`action:read.btwToCli`),E?.()},children:[(0,J.jsx)(qa,{size:13}),` open the CLI`]})]}),(0,J.jsx)(VSe,{m:e,t}),(()=>{let e=n[n.length-1]?.id===t.id;return(0,J.jsx)(y2,{t,className:`tr-fold`,which:e&&m?`running`:t.id===h?`last`:`earlier`,open:t.id===h?g:v.has(t.id),onToggle:()=>y(t.id,t.id===h),slots:b,agentsSoFar:x.has(t.id),usdPerWeekPct:S??null,weekIncl:C??null,onOpen:w,next:e&&!m&&!t.queued?Vi(T):null,why:h===t.id})})(),t.endedAt&&!t.queued&&(()=>{let e=n[n.length-1]?.id===t.id?m:t.agentsRunning?`${t.agentsRunning} subagent${t.agentsRunning===1?``:`s`} still running`:null;if(e===`working`)return null;let r=BSe(t.sentAt,t.endedAt);return(0,J.jsx)(`div`,{className:`tr-when tr-ended`,children:e?`last reply ${T2(t.endedAt)} · not finished — ${e}`:`finished ${T2(t.endedAt)}${r?` · took ${r}`:``}`})})()]},t.id)}function USe({m:e}){let{asking:t,status:n,onAnswer:r,queuedAnswers:i,onShowCli:a,busy:o,stale:s,elapsed:c,work:l,onStop:u}=e;return(0,J.jsxs)(J.Fragment,{children:[t&&(0,J.jsxs)(`div`,{className:`tr-ask`,id:`tr-ask`,children:[(0,J.jsxs)(`div`,{className:`tr-ask-head`,children:[(0,J.jsx)(cs,{size:14}),` waiting for your answer`]}),n?.prompt&&r?(0,J.jsx)(Y0,{prompt:n.prompt,queued:i??[],suggestion:n.suggestion,onAnswer:r,ev:`prompt`}):n?.prompt?(0,J.jsxs)(J.Fragment,{children:[n.prompt.plan&&(0,J.jsx)(`div`,{className:`tr-ask-q`,children:n.prompt.plan.text}),(0,J.jsx)(`div`,{className:`tr-ask-q`,children:n.prompt.ask||n.prompt.question}),(0,J.jsx)(`div`,{className:`tr-ask-opts`,children:n.prompt.options.map(e=>(0,J.jsxs)(`span`,{className:`tr-ask-opt`,children:[e.index,`. `,e.label]},e.index))}),(0,J.jsx)(Q,{as:`div`,children:`answer it in the CLI — press the option's number`})]}):n?.asking?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`tr-ask-q`,children:n.asking.text}),(0,J.jsx)(Q,{as:`div`,children:`the turn ended on this — nothing is running, it is waiting for your reply`}),(0,J.jsxs)(Y,{onClick:()=>{q(`action:read.toCli`),a?.()},children:[(0,J.jsx)(qa,{size:13}),` open the CLI`]})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`tr-ask-q`,children:`A dialog is open in the CLI that has no one-tap buttons here.`}),(0,J.jsxs)(Y,{onClick:()=>{q(`action:read.toCli`),a?.()},children:[(0,J.jsx)(qa,{size:13}),` open the CLI`]})]})]}),o&&!t&&(0,J.jsxs)(`div`,{className:`tr-turn tr-inflight${s?` tr-linkdown`:``}`,children:[s?(0,J.jsx)(fo,{size:13}):(0,J.jsx)(`span`,{className:`tr-live-dot`}),(0,J.jsxs)(`span`,{className:`tr-live-what`,children:[s?`was working`:`working`,c?` · ${c}`:``]}),l?(0,J.jsx)(`span`,{className:`tr-live-line`,children:l.text}):(0,J.jsx)(Q,{children:s?`no connection — nothing new can arrive until the link is back`:`output appears here as claude writes it`}),u&&!s&&(0,J.jsxs)(fC,{className:`key tr-stop`,confirm:`stop?`,"aria-label":`stop the running turn`,onConfirm:()=>{q(`action:read.stop`),u()},children:[(0,J.jsx)(ic,{size:12}),` stop`]})]})]})}function WSe(e,t){let n=Date.now(),r=new Date(n).toDateString(),i=t?Tee(e?.tail):null,a=!!e?.running&&!e?.linkDown&&$i(e?.tail),o=t&&(l2(e?.turnStartedAt,n)||i?.elapsed)||``,s=e?.agents??[],c=s.length,l=c?l2(Math.min(...s.map(e=>e.startedAt)),n):``,u=e?.shellList,d=u?Kr(u,n):null,f=!!d?.total||!!e?.shells,p=!e||!e.running?null:e.busy?`working`:c?`${c} agent${c===1?``:`s`} still running`:(d?d.working>0:e.shells)?`a background shell still running`:null,m=e?e.running?e.blocked?{kind:`blocked`,text:`blocked — usage limit`}:e.waiting?{kind:`waiting`,text:`waiting for your answer`}:e.awaitingInput?{kind:`waiting`,text:`waiting — a dialog is open in the CLI`}:e.busy?{kind:`busy`,text:o?`working · ${o}`:`working`}:e.asking?{kind:`waiting`,text:`waiting — the turn ended on a question`}:c?{kind:`agents`,text:`${c} agent${c===1?``:`s`} running${l?` · ${l}`:``}${f?` · shells too`:``}`}:d?.total?{kind:`shells`,text:wt(d)}:e.shells?{kind:`shells`,text:`background shells running`}:{kind:`idle`,text:`idle — nothing running`}:{kind:`dead`,text:`session ended`}:null,h=u?.length?N(u[0],n):null,g=!!e?.linkDown&&m?.kind!==`dead`;return{now:n,today:r,work:i,panelOpen:a,elapsed:o,agents:s,agentCount:c,agentAge:l,shellList:u,shellSum:d,anyShells:f,stillGoing:p,live:m,shellFirstWords:h,stale:g,liveTitle:g?`the connection is down — this is the session's state as of the last update that reached this device, not now`:e?.exact?`turn state from the claude hooks (exact)`:`turn state guessed from output silence — no hook pipe on this session, so a long quiet tool run can read as idle`}}function GSe(e,t,n=8){let r=0;for(let i of e)i.ts>r&&i.bottom<=t+n&&(r=i.ts);return r}var KSe=new WeakSet;function O2(e,t=KSe){return!e||t.has(e)?!1:(t.add(e),!0)}var qSe=1200;function JSe(e){let{sessionId:t,refreshKey:n,status:r,cliPeek:i,onToast:a,jumpTo:o,toolsMode:s,cmd:c}=e,l=(0,V.useRef)(e.source);l.current=e.source;let[u,d]=(0,V.useState)(null),[f,p]=(0,V.useState)(null),[m,h]=(0,V.useState)(!1),[g,_]=(0,V.useState)(``),[v,y]=(0,V.useState)(!1),[b,x]=(0,V.useState)(!1),[S,C]=(0,V.useState)(40),[w,T]=(0,V.useState)(new Set),[E,D]=(0,V.useState)(new Map),O=(0,V.useRef)(E);O.current=E,(0,V.useEffect)(()=>{D(new Map)},[t]);let[k,A]=(0,V.useState)(0),[j,M]=(0,V.useState)(0),[N,P]=(0,V.useState)(0),[,F]=(0,V.useState)(0),[ee,te]=(0,V.useState)(null),[ne,re]=(0,V.useState)(null),[ie,ae]=(0,V.useState)(!0),oe=(0,V.useRef)(null),se=(0,V.useRef)(null),ce=(0,V.useRef)(!0),le=(0,V.useRef)(``),ue=(0,V.useRef)([]),de=(0,V.useRef)(!1),fe=(0,V.useRef)(t),pe=(0,V.useRef)(null),me=(0,V.useRef)(null);se.current=u,fe.current=t;let he=(0,V.useMemo)(()=>f2(u?.turns??[]),[u]),ge=(0,V.useMemo)(()=>_2(u?.turns??[])?.id??null,[u]),[_e,ve]=(0,V.useState)(()=>fa(R.termCostOpen)),[ye,be]=(0,V.useState)(new Set),xe=(e,t)=>{let n=!(t?_e:ye.has(e));if(q(n?`action:read.cost.open`:`action:read.cost.close`),t){sa(R.termCostOpen,n),ve(n);return}let r=new Set(ye);n?r.add(e):r.delete(e),be(r)},Se=(0,V.useMemo)(()=>{let e=new Set,t=!1;for(let n of u?.turns??[])m2(n)>0&&(t=!0),t&&e.add(n.id);return e},[u]),Ce=e=>{me.current=e,pe.current&&clearTimeout(pe.current),pe.current=window.setTimeout(()=>{pe.current=null;let e=me.current;me.current=null,e&&Zy(e)},1500)};(0,V.useEffect)(()=>()=>{pe.current&&clearTimeout(pe.current),pe.current=null;let e=me.current;me.current=null,e&&Zy(e)},[]);let we=(0,V.useCallback)(async e=>{try{e||h(!0);let n=Z_(s),r=se.current,i=e&&r&&(r.detail??`full`)===n?r.updatedAt:void 0,a=l.current?await l.current.transcript(i,n):await H.transcript(t,i,n);a?(de.current=!0,d(a),p(null),te(null),re(null),Ce(a)):(de.current=!0,p(null),te(null),re(null))}catch(e){if(se.current)te(se.current.updatedAt);else{let n=await $y(t);n&&fe.current===t?(d(n.value),re(n.savedAt),te(n.value.updatedAt)):String(e).includes(`404`)?p(`Nothing recorded for this session yet.`):p(Qe(e)?`Can't reach the host, and there's no transcript saved on this device for this session yet.`:String(e))}}finally{h(!1)}},[t,s]),Te=(0,V.useRef)(we);Te.current=we,(0,V.useEffect)(()=>{d(null),C(40),_(``),te(null),P(W_(t)),ce.current=!0,de.current=!1;let e=t;re(null),ae(!0),$y(e).then(t=>{t&&!de.current&&fe.current===e&&(d(t.value),re(t.savedAt))}).finally(()=>{fe.current===e&&ae(!1)}),Te.current(!1)},[t]);let Ee=(0,V.useRef)(s);(0,V.useEffect)(()=>{Ee.current!==s&&(Ee.current=s,we(!1))},[s,we]),(0,V.useEffect)(()=>()=>{ce.current&&G_(t,U_(ue.current))},[t]),(0,V.useEffect)(()=>{n&&we(!0)},[n,we]);let De=!!r?.busy;(0,V.useEffect)(()=>{let e=(De?_Se:gSe)*(Xh()?4:1),t=setInterval(()=>{document.visibilityState===`visible`&&we(!0)},e);return()=>clearInterval(t)},[we,De]),(0,V.useEffect)(()=>{if(!De)return;let e=setInterval(()=>F(e=>e+1),1e3);return()=>clearInterval(e)},[De]);let Oe=u?.turns??[],ke=!!u&&Oe.length===0,[Ae,je]=(0,V.useState)(`idle`);(0,V.useEffect)(()=>{i&&je(ke?e=>e===`idle`?`shown`:e:e=>e===`shown`?`leaving`:e)},[ke,i]),ue.current=Oe,(0,V.useEffect)(()=>{if(N||!Oe.length)return;let e=U_(Oe);e&&(G_(t,e),P(e))},[Oe,N,t]);let Me=(0,V.useMemo)(()=>N?Oe.findIndex(e=>H_(e)>N):-1,[Oe,N]),Ne=Me===-1?0:Oe.length-Me,Pe=(0,V.useMemo)(()=>Oe.slice(Math.max(0,Oe.length-S)),[Oe,S]);(0,V.useEffect)(()=>{let e=oe.current;if(e&&u){if(le.current!==t){if(!N)return;if(Ne>S){C(Ne+40);return}le.current=t,Ne>0?(ce.current=!1,requestAnimationFrame(()=>document.getElementById(`tr-newmark`)?.scrollIntoView({block:`start`}))):e.scrollTop=e.scrollHeight}else ce.current&&(e.scrollTop=e.scrollHeight)}},[u,t,N,Ne,S]),(0,V.useEffect)(()=>{if(le.current!==t||!ce.current||document.visibilityState!==`visible`)return;let e=U_(Oe);!e||e<=N||(G_(t,e),P(e))},[Oe,t,N]);let Fe=(0,V.useRef)(),Ie=(0,V.useCallback)(()=>{clearTimeout(Fe.current),Fe.current=setTimeout(()=>{let e=oe.current;if(!e?.clientHeight||le.current!==t||document.visibilityState!==`visible`)return;let n=e.getBoundingClientRect().bottom,r=GSe(ue.current.flatMap(e=>{let t=document.getElementById(`tr-turn-${e.n}`)?.getBoundingClientRect();return t?.height?[{ts:H_(e),bottom:t.bottom}]:[]}),n);r>W_(t)&&(G_(t,r),P(r))},qSe)},[t]);(0,V.useEffect)(()=>{Ie()},[Oe,Ie]),(0,V.useEffect)(()=>()=>clearTimeout(Fe.current),[t]);let Le=(0,V.useMemo)(()=>g?Oe.filter(e=>J_(q_(e),g)):Oe,[Oe,g]);(0,V.useEffect)(()=>{let e=oe.current;if(!e)return;let t=e.querySelectorAll(`.tr-hit`);M(t.length),A(e=>t.length?Math.min(e,t.length-1):0)},[g,Pe,w,u,E,s]);let Re=e=>{let t=oe.current;if(!t)return;let n=t.querySelectorAll(`.tr-hit`);if(!n.length)return;let r=(k+e+n.length)%n.length;A(r),n.forEach((e,t)=>e.classList.toggle(`on`,t===r)),n[r].scrollIntoView({block:`center`,behavior:`smooth`})},ze=e=>{let t=Oe.findIndex(t=>t.n===e);t!==-1&&Oe.length-t>S&&C(Oe.length-t+40),y(!1),ce.current=!1,setTimeout(()=>{document.getElementById(`tr-turn-${e}`)?.scrollIntoView({block:`start`,behavior:`smooth`})},30)},Be=o?.key??0;(0,V.useEffect)(()=>{o&&Oe.length&&O2(o)&&ze(o.n)},[Be,Oe.length>0]);let Ve=c?.key??0;(0,V.useEffect)(()=>{c&&Ve&&O2(c)&&(c.kind===`outline`?(q(`action:read.outline`),y(e=>!e)):c.kind===`find`?x(e=>(e&&_(``),!e)):we(!1))},[Ve]);let He=()=>{let e=U_(Oe);G_(t,e),P(e)},Ue=e=>T(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),We=(0,V.useCallback)(async(e,n=!1)=>{let r=e.id;if(!n&&O.current.has(r))return;let i=e=>D(t=>new Map(t).set(r,e));i({state:`loading`});let a=n?null:await fb(t,r),o=!!a&&e.blocks.some(e=>e.kind===`tool`&&e.ok!==void 0&&a[e.id]?.result===void 0);if(a&&!o)i({state:`ok`,tools:a});else try{let e=l.current?await l.current.tools(r):await H.transcriptTools(t,r);i({state:`ok`,tools:e}),db(t,r,e)}catch(e){if(a){i({state:`ok`,tools:a});return}i({state:`error`,msg:Qe(e)?`can't reach the host — these tool details aren't saved on this device`:String(e)})}},[t]),Ge=e=>void Xf(e).then(e=>a(e?`copied`:`copy failed`)),[Ke,qe]=(0,V.useState)(null),Je=!!r&&r.running&&(r.waiting||!!r.awaitingInput||!!r.asking),Ye=(0,V.useRef)(!1);(0,V.useEffect)(()=>{Je?Ye.current||(Ye.current=!0,requestAnimationFrame(()=>document.getElementById(`tr-ask`)?.scrollIntoView({block:`end`,behavior:`smooth`}))):Ye.current=!1},[Je]);let Xe=WSe(r,De);return{...e,...Xe,doc:u,err:f,loading:m,q:g,setQ:_,outline:v,findOpen:b,setFindOpen:x,limit:S,setLimit:C,openBlocks:w,details:E,hitIdx:k,setHitIdx:A,hitCount:j,seenMark:N,setSeenMark:P,offlineAt:ee,cachedAt:ne,probing:ie,bodyRef:oe,stickRef:ce,seenRef:le,turnsRef:ue,noteRead:Ie,mixSlotsDoc:he,whyTurnId:ge,costLastOpen:_e,costOpen:ye,toggleCost:xe,agentsSoFar:Se,turns:Oe,emptyNow:ke,peek:Ae,setPeek:je,newIdx:Me,unread:Ne,shown:Pe,outlineTurns:Le,jump:Re,goTurn:ze,markRead:He,toggleBlock:Ue,loadDetails:We,copy:Ge,forkTurn:Ke,setForkTurn:qe,asking:Je,busy:De}}function k2(e){let t=JSe(e),{bodyRef:n,stickRef:r,seenRef:i,turnsRef:a,noteRead:o,seenMark:s,setSeenMark:c,sessionId:l,loading:u,doc:d,probing:f,err:p,onShowCli:m,emptyNow:h,cliPeek:g,peek:_,setPeek:v,turns:y,shown:b,setLimit:x}=t;return(0,J.jsxs)(`div`,{className:`tr`,children:[(0,J.jsx)(xSe,{m:t}),(0,J.jsx)(SSe,{m:t}),(0,J.jsx)(wSe,{m:t}),(0,J.jsxs)(`div`,{className:`tr-body`,ref:n,onScroll:e=>{let t=e.currentTarget,n=t.scrollHeight-t.scrollTop-t.clientHeight<80;if(r.current=n,n&&i.current===l){let e=U_(a.current);e&&e>s&&(G_(l,e),c(e))}else o()},children:[u&&!d&&!f&&(0,J.jsx)($,{children:`Reading the transcript…`}),p&&!d&&(0,J.jsxs)($,{children:[(0,J.jsx)(gs,{size:14}),` `,p,m&&(0,J.jsx)(`div`,{children:(0,J.jsx)(Y,{onClick:m,children:`open the CLI (saved output)`})})]}),h&&!(g&&_!==`gone`)&&(0,J.jsx)($,{children:`No turns recorded yet.`}),g&&(h&&_!==`gone`||_===`shown`||_===`leaving`)&&g(_===`leaving`,()=>v(`gone`)),y.length>b.length&&(0,J.jsxs)(`button`,{className:`tr-more`,onClick:()=>x(e=>e+80),children:[`load `,Math.min(80,y.length-b.length),` earlier turns (`,y.length-b.length,` hidden)`]}),b.map(e=>(0,J.jsx)(HSe,{m:t,t:e},e.id)),(0,J.jsx)(USe,{m:t})]})]})}function A2(e){let t=(e.name||e.bookmark?.name||``).trim(),n=(e.title||``).trim();return t&&n&&t.toLowerCase()!==n.toLowerCase()?{title:t,sub:n}:{title:t||n||null,sub:null}}function YSe(e){return e?e.bookmarked===!0?{kind:`count`,n:e.total}:{kind:`old-host`}:{kind:`loading`}}function XSe(e){return e.kind===`count`?`Bookmarks (${e.n})`:`Bookmarks`}function ZSe(e,t){return e.kind===`old-host`?`This desktop's host is too old to filter bookmarks — update it to see them here.`:e.kind===`loading`?`Reading the bookmarks…`:`Showing bookmarked conversations only — ${t==null?`${e.n}`:`${e.n} of ${t}`}.`}function j2(e,t,n){return e.map(e=>{if(e.id!==t)return e;if(n)return{...e,bookmark:n};let{bookmark:r,...i}=e;return i})}function M2(e,t){return t?e?`bookmark not set: ${t}`:`bookmark not removed: ${t}`:e?`bookmarked — Archive › Bookmarks finds it after it is closed`:`bookmark removed`}var N2=16;function QSe({repoId:e,row:t,live:n,onBack:r,onResume:i,onToast:a}){let[o,s]=(0,V.useState)(),c=e=>s(t=>({kind:e,key:(t?.key??0)+1})),[l]=(0,V.useState)(X_),u=(0,V.useMemo)(()=>({transcript:(n,r)=>H.archivedTranscript(e,t.id,n,r),tools:n=>H.archivedToolDetails(e,t.id,n)}),[e,t.id]),{title:d}=A2(t);return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:d||`conversation`,onClose:r,children:(0,J.jsxs)(`span`,{className:`head-acts tight`,children:[(0,J.jsx)(Y,{title:`outline — one row per turn`,onClick:()=>c(`outline`),children:(0,J.jsx)(vs,{size:N2})}),(0,J.jsx)(Y,{title:`find in this conversation`,onClick:()=>c(`find`),children:(0,J.jsx)(rc,{size:N2})}),(0,J.jsx)(Y,{title:`re-read the conversation`,onClick:()=>c(`refresh`),children:(0,J.jsx)(xc,{size:N2})})]})}),(0,J.jsxs)(Z,{children:[`Read-only — this is the conversation's log on the desktop. Nothing is running and reading it spends nothing.`,` `,(0,J.jsx)(Y,{variant:`primary`,onClick:i,children:n?`open it`:`resume`})]}),(0,J.jsx)(`div`,{className:`arch-reader`,children:(0,J.jsx)(k2,{sessionId:t.id,source:u,refreshKey:0,toolsMode:l,cmd:o,onToast:a})})]})}var $Se=`bookmark`,P2=`bookmarked`,F2=({on:e,size:t})=>e?(0,J.jsx)(cl,{size:t,fill:`currentColor`}):(0,J.jsx)(Ua,{size:t});function I2({initial:e,onSave:t,onCancel:n}){let[r,i]=(0,V.useState)(e);return(0,J.jsxs)(`span`,{className:`bm-edit`,children:[(0,J.jsx)(`input`,{className:`search grow`,value:r,maxLength:160,autoFocus:!0,placeholder:`a note — why you will want it again`,"aria-label":`bookmark note`,onChange:e=>i(e.target.value),onKeyDown:e=>{e.key===`Enter`?t(r):e.key===`Escape`&&n()}}),(0,J.jsx)(`button`,{className:`row-act`,title:`save the note`,onClick:()=>t(r),children:(0,J.jsx)(vc,{size:16})}),(0,J.jsx)(`button`,{className:`row-act`,title:`leave the note as it was`,onClick:n,children:(0,J.jsx)(B,{size:16})})]})}async function L2(e,t,n){let r=await H.bookmarkSet(e,t,n).catch(()=>({ok:!1,error:`the desktop did not answer`,bookmark:void 0}));return!r.ok||!r.bookmark?(K(M2(!0,r.error??`?`)),null):r.bookmark}async function R2(e,t){let n=await H.bookmarkRemove(e,t).catch(()=>({ok:!1,error:`the desktop did not answer`}));return K(M2(!1,n.ok?void 0:n.error??`?`)),n.ok}function eCe(e,t,n){return n?e.claudeSessionId?t?null:`Bookmarking needs this session's repo, and it is not in the list.`:`Nothing to bookmark yet — this session has no conversation until its first turn.`:`Bookmarking needs the desktop — the link is down.`}function tCe({active:e,repo:t,online:n,compact:r,dismiss:i}){let[a,o]=(0,V.useState)(!1),s=e.bookmark,c=!!s,l=eCe(e,t,n),u=l??(c?`bookmarked${s?.note?` — ${s.note}`:``} · tap to remove`:`bookmark this conversation — the archive finds it again after it is closed`),d=async n=>{l?K(l):await L2(t.id,e.claudeSessionId,n)&&K(c?`bookmark note saved`:M2(!0))},f=()=>{l?K(l):R2(t.id,e.claudeSessionId)},p=c&&s?.note?(0,J.jsxs)(fC,{className:`key bm-btn on`,title:u,confirmTitle:`tap again to remove the bookmark and its note`,confirm:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(F2,{on:!0,size:16}),!r&&` remove, with its note?`]}),onConfirm:()=>{i(),f()},children:[(0,J.jsx)(F2,{on:!0,size:16}),!r&&` bookmarked`]},`bookmark`):(0,J.jsxs)(Y,{className:`bm-btn${c?` on`:``}`,"data-hint":`session.bookmark`,"aria-pressed":c,title:u,onClick:()=>{i(),c?f():d({name:l_(e,t?.repoName??``)})},children:[(0,J.jsx)(F2,{on:c,size:16}),!r&&` ${c?`bookmarked`:`bookmark`}`]},`bookmark`);return r||!c?p:(0,J.jsxs)(J.Fragment,{children:[p,a?(0,J.jsx)(I2,{initial:s?.note??``,onCancel:()=>o(!1),onSave:e=>{o(!1),d({note:e})}}):(0,J.jsxs)(Y,{className:`bm-note`,title:`edit the bookmark's one-line note`,onClick:()=>{l?K(l):o(!0)},children:[(0,J.jsx)(Mo,{size:16}),` `,s?.note?s.note:`add a note`]},`bookmark-note`)]})}var z2=16,B2={id:`claude`,label:`Claude Code`};function nCe({repos:e,initialRepoId:t,liveIds:n,onClose:r,onResume:i,onFork:a,onOpenLive:o,showToast:s,archiveBackends:c}){let l=c&&c.length?c:[B2],[u,d]=(0,V.useState)(l[0].id),f=l.find(e=>e.id===u)??l[0],p=f.id===B2.id,[m,h]=(0,V.useState)(t),[g,_]=(0,V.useState)(``),[v,y]=(0,V.useState)(``),[b,x]=(0,V.useState)(!1),[S,C]=(0,V.useState)(null);Gh(!!S,()=>C(null));let[w,T]=(0,V.useState)(null),E=(0,V.useMemo)(()=>e.find(e=>e.id===m)??e[0],[e,m]),D=gh(p?`${E?.id??``}|${v}`:`${E?.id??``}|be:${f.id}|${v}`,e=>p?H.archive(E.id,{offset:0,q:v||void 0}):H.conversations(f.id,E.worktreePath,{offset:0,q:v||void 0},e),{enabled:!!E}),O=gh(`${E?.id??``}|bm|${v}`,()=>H.archive(E.id,{offset:0,q:v||void 0,bookmarked:!0}),{enabled:!!E&&p}),k=YSe(O.data),A=b&&p,j=A?O:D,M=A&&k.kind===`old-host`?null:j.data,[N,P]=(0,V.useState)([]),[F,ee]=(0,V.useState)(`idle`);(0,V.useEffect)(()=>{P([]),ee(`idle`),T(null)},[m,v,A,f.id]);let te=(0,V.useMemo)(()=>[...M?.rows??[],...N],[M,N]);async function ne(){if(E){ee(`loading`);try{let e=p?await H.archive(E.id,{offset:te.length,q:v||void 0,bookmarked:A||void 0}):await H.conversations(f.id,E.worktreePath,{offset:te.length,q:v||void 0});P(t=>[...t,...e.rows]),ee(`idle`)}catch{ee(`failed`)}}}async function re(e){if(!E)return;let t=await(p?H.archiveDelete(E.id,e.id):H.conversationsDelete(f.id,E.worktreePath,e.id)).catch(()=>({ok:!1,error:`offline`}));t.ok?(M&&D.set({...M,rows:M.rows.filter(t=>t.id!==e.id),total:Math.max(0,M.total-1),scanned:Math.max(0,M.scanned-1)}),P(t=>t.filter(t=>t.id!==e.id)),s(`conversation deleted`),p&&O.reload({quiet:!0})):s(`delete failed: ${t.error??`?`}`)}function ie(e,t){D.data&&D.set({...D.data,rows:j2(D.data.rows,e,t)}),O.data&&O.set({...O.data,rows:j2(O.data.rows,e,t)}),P(n=>j2(n,e,t)),O.reload({quiet:!0})}async function ae(e,t){if(!E)return;let n=!!e.bookmark,r=await L2(E.id,e.id,t);r&&(ie(e.id,r),s(n?`bookmark note saved`:`bookmarked`))}async function oe(e){E&&await R2(E.id,e.id)&&ie(e.id,void 0)}let se=!!M&&te.length<M.total,ce=j.state===`loading`;if(S&&E){let e=n.has(S.id);return(0,J.jsx)(QSe,{repoId:E.id,row:S,live:e,onToast:s,onBack:()=>C(null),onResume:()=>e?o(S.id):i(S.cwd,S.name||S.title||`resumed`,S.id,B2.id)})}return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Kw,{title:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(oo,{size:z2,style:{verticalAlign:`-3px`,marginRight:4}}),`Archive`]}),onClose:r,refreshTitle:`re-read the archive`,onRefresh:()=>{D.reload(),O.reload()}}),e.length>1&&(0,J.jsx)(`div`,{className:`search-row`,children:(0,J.jsx)(oF,{repos:e,className:`search grow`,value:E?.worktreePath??``,onChange:t=>{let n=e.find(e=>e.worktreePath===t);n&&h(n.id)},"aria-label":`repo`})}),l.length>1&&(0,J.jsx)(`div`,{className:`form`,children:(0,J.jsx)(Xw,{kind:`wrap`,children:l.map(e=>(0,J.jsx)(zw,{on:e.id===f.id,clears:!1,busy:e.id===f.id&&D.inflight,onClick:()=>{e.id!==f.id&&d(e.id)},title:e.id===f.id?`showing the conversations ${e.label} wrote`:`show the conversations ${e.label} wrote`,children:e.label},e.id))})}),(0,J.jsx)(`div`,{className:`form`,children:(0,J.jsxs)(Xw,{kind:`wrap`,children:[(0,J.jsx)(Fw,{className:`grow`,value:g,placeholder:`Search prompts, names, notes…`,onChange:e=>_(e.target.value),onKeyDown:e=>{e.key===`Enter`&&y(g.trim())}}),v&&(0,J.jsx)(`button`,{className:`row-act`,title:`clear the search`,onClick:()=>{_(``),y(``)},children:(0,J.jsx)(B,{size:z2})}),(0,J.jsx)(`button`,{className:`row-act`,title:`search`,onClick:()=>y(g.trim()),children:(0,J.jsx)(rc,{size:z2})})]})}),p&&(0,J.jsx)(`div`,{className:`form`,children:(0,J.jsx)(Xw,{kind:`wrap`,children:(0,J.jsxs)(zw,{on:b,busy:b&&O.inflight,onClick:()=>x(e=>!e),title:b?`show every conversation again`:`show only the bookmarked conversations`,children:[(0,J.jsx)(F2,{on:b,size:13}),` `,XSe(k)]})})}),p?b?(0,J.jsxs)(Z,{children:[ZSe(k,O.data?.scanned??null),` `,(0,J.jsx)(`button`,{className:`link-btn`,onClick:()=>x(!1),children:`show all`})]}):(0,J.jsxs)(Z,{children:[`Every conversation the CLI ever wrote for `,E?.repoName??`this repo`,` — closing a session never deleted one. Tap to resume it exactly (`,(0,J.jsx)(`code`,{children:`claude --resume`}),`); `,(0,J.jsx)(`em`,{children:`read`}),` opens it read-only, without starting anything.`,M&&(v?` ${M.total} of ${M.scanned} match.`:` ${M.scanned} on disk.`)]}):(0,J.jsxs)(Z,{children:[f.note,M&&(v?` ${M.total} of ${M.scanned} match.`:` ${M.total} listed.`)]}),p&&f.note&&(0,J.jsx)(Z,{children:f.note}),(0,J.jsxs)(`div`,{className:`list hist`,children:[!(A&&k.kind===`old-host`)&&(0,J.jsx)($,{res:j,empty:te.length===0,thing:p?`the archive`:`the conversations ${f.label} wrote`,noun:`archive listing`,children:A?v?`No bookmarked conversation matches that.`:`No bookmarks in this repo yet — bookmark a row below, or an open session from its menu.`:v?`No conversation matches that.`:p?`No conversations here yet.`:`${f.label} lists no conversation in this folder yet.`}),te.map(e=>{let t=n.has(e.id),{title:r,sub:s}=A2(e),c=p?e.bookmark:void 0,l=()=>t?o(e.id):i(e.cwd||E?.worktreePath||``,e.name||e.title||`resumed`,e.id,f.id);return(0,J.jsxs)(`div`,{className:`row-wrap closed-card archive-card`,style:wp(E?.repoName??vp(e.cwd)),children:[(0,J.jsxs)(Xw,{as:`button`,kind:`grow`,title:t?`already open — jump to it`:p?`resume this conversation`:`resume this conversation in ${f.label}`,onClick:l,children:[(0,J.jsxs)(`span`,{className:`row-head`,children:[(0,J.jsxs)(Zw,{children:[c&&!c.note&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`bm-mark`,children:(0,J.jsx)(F2,{on:!0,size:12})}),` `]}),r||(0,J.jsx)(`em`,{children:`(no prompt — never typed into)`})]}),(0,J.jsxs)(`span`,{className:`row-meta`,children:[(0,J.jsx)(Q,{className:`olog-sess`,title:e.id,children:e.id.slice(0,8)}),p&&(0,J.jsx)(Q,{children:yp(e.size)})]})]}),(0,J.jsx)(`span`,{className:`row-stat`,children:(0,J.jsx)(qw,{className:`closed-stat`,title:`last active ${new Date(e.mtime).toLocaleString()}`,children:t?`open now`:`active ${Tp(e.mtime)}`})}),s&&(0,J.jsx)(`span`,{className:`row-gist`,children:(0,J.jsx)(pK,{firstPrompt:s,className:`closed-gist`})})]}),(0,J.jsxs)(`div`,{className:`row-acts`,children:[(0,J.jsxs)(`span`,{className:`row-tags`,children:[c&&(w===e.id?(0,J.jsx)(`span`,{className:`archive-note`,children:(0,J.jsx)(I2,{initial:c.note??``,onCancel:()=>T(null),onSave:t=>{T(null),ae(e,{note:t})}})}):(0,J.jsxs)(`button`,{className:`link-btn bm-note-line archive-note`,title:`edit the bookmark's one-line note`,onClick:()=>T(e.id),children:[(0,J.jsx)(Mo,{size:12}),` `,c.note||`add a note`]})),p?c&&c.note?(0,J.jsxs)(fC,{className:`bm-btn bm-chip on`,title:`${P2} — tap to remove`,confirmTitle:`tap again to remove the bookmark and its note`,confirm:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(F2,{on:!0,size:12}),` remove, with its note?`]}),onConfirm:()=>{oe(e)},children:[(0,J.jsx)(F2,{on:!0,size:12}),` `,P2]}):(0,J.jsxs)(`button`,{className:`bm-btn bm-chip${c?` on`:``}`,"data-hint":`session.bookmark`,"aria-pressed":!!c,title:c?`${P2} — tap to remove`:`bookmark this conversation — Bookmarks finds it again`,onClick:()=>{c?oe(e):ae(e,e.name?{name:e.name}:{})},children:[(0,J.jsx)(F2,{on:!!c,size:12}),` `,c?P2:$Se]}):null,t&&(0,J.jsx)($w,{children:`can't delete — the session is open, close it first`})]}),(0,J.jsxs)(`span`,{className:`row-ctl`,children:[p&&(0,J.jsx)(`button`,{className:`row-act`,title:`read this conversation here, read-only — nothing is started`,onClick:()=>{T(null),C(e)},children:(0,J.jsx)(qo,{size:z2})}),a&&p?(0,J.jsx)(fC,{className:`row-act`,title:`open a copy of this conversation — the original is left exactly as it is`,confirmTitle:`tap again to open a fork of this conversation`,confirm:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ds,{size:12}),` fork it?`]}),onConfirm:()=>a(e.cwd,`${e.title||`conversation`} (fork)`,e.id),children:(0,J.jsx)(ds,{size:z2})}):null,!t&&(0,J.jsx)(fC,{className:`row-act`,title:`delete this conversation for good`,confirmTitle:`tap again to delete this conversation for good`,confirm:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ws,{size:12}),` delete for good?`]}),onConfirm:()=>{re(e)},children:(0,J.jsx)(ws,{size:z2})}),(0,J.jsx)(`button`,{className:`row-act`,title:t?`already open — jump to it`:`resume this conversation`,onClick:l,children:t?(0,J.jsx)(zo,{size:z2}):(0,J.jsx)(xc,{size:z2})})]})]})]},e.id)}),F===`failed`&&(0,J.jsx)($,{children:`The next page did not arrive — tap again.`}),se&&F!==`loading`&&!ce&&(0,J.jsxs)(Xw,{as:`button`,kind:`grow`,onClick:()=>void ne(),children:[(0,J.jsx)(Zw,{children:`load more`}),(0,J.jsxs)(Q,{children:[te.length,` of `,M?.total]})]}),F===`loading`&&(0,J.jsx)($,{children:`Reading the next page…`})]})]})}function V2(e,t,n){return t<=1?n:e*n/(t-1)}function rCe(e,t){let n=t.hi-t.lo,r=n>0?Math.min(1,Math.max(0,(e-t.lo)/n)):0;return t.h-r*(t.h-1)-.5}function iCe(e,t){let n=e.length,r=(e,r)=>({x:V2(e,n,t.w),y:rCe(r,t)}),i=[],a=[],o=[],s=()=>{if(o.length>1){let e=o.map(e=>`${e.x.toFixed(1)},${e.y.toFixed(1)}`).join(` `);i.push(e),a.push(`${o[0].x.toFixed(1)},${t.h} ${e} ${o[o.length-1].x.toFixed(1)},${t.h}`)}o=[]};for(let t=0;t<n;t++){let n=e[t];n==null?s():o.push(r(t,n))}s();let c=[];for(let t=0;t<n;t++){let i=e[t];i!=null&&(t===0||e[t-1]==null)&&(t===n-1||e[t+1]==null)&&c.push(r(t,i))}return{runs:i,areas:a,dots:c}}function aCe(e,t){let n=Math.max(0,...e.map(e=>e.length)),r=[];for(let i=0;i<n;i++)e.every(e=>e[i]==null)&&r.push(V2(i,n,t));return r}function H2(e){let t=null,n=1/0,r=-1/0;for(let i of e)i!=null&&(t=i,i<n&&(n=i),i>r&&(r=i));return t==null?null:{last:t,min:n,max:r}}function oCe(e,t){return[t,(e+t)/2,e]}function U2(e,t,n){let r=0;for(let t of e)t!=null&&t>r&&(r=t);return Math.max(t,Math.ceil(r*1.25/n)*n)}var W2=46;function G2({lines:e,lo:t,hi:n,fmt:r,from:i,to:a,h:o=92}){let s=(0,V.useRef)(null),[c,l]=(0,V.useState)(0),u=(0,V.useCallback)(e=>{if(s.current?.disconnect(),s.current=null,!e||(l(e.clientWidth),typeof ResizeObserver>`u`))return;let t=new ResizeObserver(()=>l(e.clientWidth));t.observe(e),s.current=t},[]);(0,V.useEffect)(()=>()=>s.current?.disconnect(),[]);let d=Math.max(40,c-W2),f={w:d,h:o,lo:t,hi:n},p=aCe(e.map(e=>e.series),d),m=e=>o-(e-t)/(n-t||1)*(o-1)-.5;return(0,J.jsxs)(`div`,{className:`sg`,children:[(0,J.jsx)(`div`,{className:`sg-legend`,children:e.map(e=>{let t=H2(e.series);return(0,J.jsxs)(`span`,{className:`sg-key`,children:[(0,J.jsx)(`span`,{className:`sys-dot sys-${e.tone}`,"aria-hidden":`true`}),` `,e.label,t&&(0,J.jsxs)(J.Fragment,{children:[` `,(0,J.jsx)(`b`,{className:`sg-now`,children:r(t.last)}),(0,J.jsxs)(`span`,{className:`sg-range`,children:[` · `,t.min===t.max?`steady`:`${r(t.min)}–${r(t.max)}`]})]})]},e.key)})}),(0,J.jsx)(`div`,{className:`sg-plot`,ref:u,children:c>0&&(0,J.jsxs)(`svg`,{width:d+W2,height:o,viewBox:`0 0 ${d+W2} ${o}`,role:`img`,"aria-label":e.map(e=>{let t=H2(e.series);return t?`${e.label} ${r(t.last)}, between ${r(t.min)} and ${r(t.max)}`:`${e.label}: no reading`}).join(`; `),children:[oCe(t,n).map((e,t)=>(0,J.jsxs)(`g`,{children:[(0,J.jsx)(`line`,{x1:0,x2:d,y1:m(e),y2:m(e),className:t===2?`sg-base`:`sg-grid`}),(0,J.jsx)(`text`,{x:d+6,y:t===0?9:t===2?o-1:m(e)+3.5,className:`sg-tick`,children:r(e)})]},t)),p.map((e,t)=>(0,J.jsx)(`line`,{x1:e,x2:e,y1:0,y2:o,className:`sg-gap`},`g${t}`)),e.map(e=>{let t=iCe(e.series,f);return(0,J.jsxs)(`g`,{className:`sg-line sg-${e.tone}`,children:[t.areas.map((e,t)=>(0,J.jsx)(`polygon`,{points:e,className:`sg-area`},`a${t}`)),t.runs.map((e,t)=>(0,J.jsx)(`polyline`,{points:e,className:`sg-stroke`},`r${t}`)),t.dots.map((e,t)=>(0,J.jsx)(`circle`,{cx:e.x,cy:e.y,r:2,className:`sg-dot`},`d${t}`))]},e.key)})]})}),i!=null&&a!=null&&a>i&&(0,J.jsxs)(`div`,{className:`sg-time`,style:{marginRight:W2},children:[(0,J.jsx)(`span`,{children:Rp(i)}),(0,J.jsx)(`span`,{children:Rp(a)})]})]})}var sCe=(0,V.forwardRef)(function({onOpenSession:e},t){let n=qv(e=>e.count),r=qv(e=>e.samples),i=qv(e=>e.rows),a=Zv(`agentWarn`),o=Wae(i),s=Vv(r),c=Vv(r,e=>e.subagents),l=[a.warn,a.alarm].filter(e=>e>0),u=s.reduce((e,t)=>t!=null&&t>e?t:e,0),d=U2([...s,...l.filter(e=>e<=u*2+5)],10,5),f=r.length>1?{from:r[0].at,to:r[r.length-1].at}:{},p=n?Rv(n.total,a):`ok`;return(0,J.jsxs)(`section`,{className:`set-group`,ref:t,children:[(0,J.jsx)(`h3`,{className:`set-title`,children:`Agents running at once`}),n?(0,J.jsxs)(`span`,{className:`lrt-verdict lrt-agents-verdict lrt-agents-${p}`,children:[Bv(n),p===`alarm`?` — more than your limit of ${a.alarm}.`:p===`warn`?` — more than your warning of ${a.warn}.`:`.`]}):(0,J.jsx)(X,{as:`span`,children:`No session list from the desktop yet.`}),s.length>1?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(G2,{lines:[{key:`agents`,label:`all agents`,tone:`app`,series:s},{key:`subagents`,label:`of them subagents`,tone:`wired`,series:c}],lo:0,hi:d,fmt:e=>String(Math.round(e)),...f}),(0,J.jsxs)(X,{as:`span`,children:[`One reading every 10 seconds and one on every change, while this app is open — kept in memory only, so a reload starts it again. A break is a stretch this phone was not watching, never bridged.`,l.length>0&&(0,J.jsxs)(J.Fragment,{children:[` Your marks: amber above `,a.warn||`—`,`, red above `,a.alarm||`—`,` (Settings → Appearance).`]})]})]}):(0,J.jsx)(X,{as:`span`,children:`The graph starts with the next reading — every 10 seconds while this app is open.`}),o.length>0&&(0,J.jsx)(`div`,{className:`lrt-rows`,children:o.map(t=>(0,J.jsxs)(`button`,{className:`lrt-row lrt-agent-row`,onClick:()=>e?.(t.id),title:`open ${t.label}`,children:[(0,J.jsxs)(`span`,{className:`lrt-name`,children:[(0,J.jsx)(Uo,{size:12,"aria-hidden":`true`}),` `,t.label]}),(0,J.jsxs)(`span`,{className:`lrt-size`,children:[t.agents.length>0?`${t.agents.length} subagent${t.agents.length===1?``:`s`}`:``,t.agents.length>0&&t.working?` + `:``,t.working?`its own turn`:``]}),(0,J.jsx)(Hs,{size:14,"aria-hidden":`true`,className:`lrt-agent-go`}),(0,J.jsx)(`span`,{className:`lrt-vram`,children:t.repo}),t.agents.map((e,t)=>(0,J.jsxs)(`span`,{className:`lrt-vram`,children:[`· `,e.what,e.model?` (${e.model})`:``,` — running `,Op(e.startedAt)]},t))]},t.id))})]})}),K2=e=>`${(Math.max(0,e)/2**30).toFixed(1)} GB`;function cCe(e,t){if(!e||!(t>0))return[];let n=[],r=(e,r,i,a,o)=>{if(i==null||!(i>0))return;let s=t-n.reduce((e,t)=>e+t.bytes,0);s<=0||n.push({key:e,label:r,bytes:Math.min(i,s),pct:0,tone:a,what:o})};e.appBytes!=null||e.wiredBytes!=null||e.compressedBytes!=null?(r(`app`,`app memory`,e.appBytes,`app`,`what programs asked for and are using`),r(`wired`,`wired`,e.wiredBytes,`wired`,`kernel memory that cannot be paged out`),r(`compressed`,`compressed`,e.compressedBytes,`compressed`,`what the memory compressor occupies — it is holding more than this`)):e.usedBytes!=null&&r(`used`,`in use`,e.usedBytes,`app`,`what programs are using, as the kernel counts it`),r(`cached`,`cached files`,e.cachedBytes,`cached`,`the file cache: in use, and handed back the moment something needs it`);let i=n.reduce((e,t)=>e+t.bytes,0),a=Math.max(0,t-i);return a>0&&n.push({key:`available`,label:`available`,bytes:a,pct:0,tone:`available`,what:`free, plus everything the OS would reclaim on demand`}),n.map(e=>({...e,pct:Math.round(e.bytes/t*1e3)/10}))}function lCe(e,t){if(!e)return null;let n=e.availableBytes,r=e.source===`vm_stat`;return(n==null?`This is what the operating system says the memory is doing.`:`About ${K2(n)} is available — free memory (${K2(t)}) is only the part nothing has touched at all.`)+(r?` Cached files are memory in use that is handed straight back when something needs it, so a machine reading as nearly full is normal and not a problem by itself.`:" `MemAvailable` is the kernel's own estimate of what a new program could get without anything being paged out.")}function uCe(e){if(!e||e.swapTotalBytes==null||!(e.swapTotalBytes>0))return null;let t=e.swapUsedBytes??0,n=Math.round(t/e.swapTotalBytes*100);return`${K2(t)} of ${K2(e.swapTotalBytes)} swap in use (${n}%)`}function dCe(e){if(!e)return null;let t=e.spanMs>=1e3?`${Math.round(e.spanMs/1e3)}s`:`${e.spanMs}ms`;return`${Math.round(e.userPct+e.sysPct)}% busy over the last ${t} — ${e.userPct.toFixed(0)}% running programs, ${e.sysPct.toFixed(0)}% in the kernel, ${e.idlePct.toFixed(0)}% idle.`}function fCe(e){if(!e)return null;let[t,n,r]=e.loadavg;return`load ${t.toFixed(2)} · ${n.toFixed(2)} · ${r.toFixed(2)} over 1, 5 and 15 minutes, against ${e.cores} cores`}function q2(e){return e.procs===1?`pid ${e.pid??`?`}`:`${e.procs} processes`}function pCe(e,t){return`Every process together holds ${K2(e)} of a ${K2(t)} machine — resident size counts a shared page once for each process holding it, so these rows overlap and must not be added up as a budget.`}function J2(e,t){let n=Math.round((t-e)/1e3);return n>=5?n:null}function Y2(e){return e==null||!Number.isFinite(e)?null:`${Math.round(e)}°C`}function mCe(e){let t=Math.floor(e/86400);if(t>=1)return`${t}d ${Math.floor(e%86400/3600)}h`;let n=Math.floor(e/3600);return n>=1?`${n}h ${Math.floor(e%3600/60)}m`:`${Math.max(1,Math.floor(e/60))}m`}function X2(e){let t=Math.max(0,e)/2**30;return t>=1e3?`${(t/1024).toFixed(2)} TB`:`${t.toFixed(1)} GB`}function Z2(e){if(!(e.totalBytes>0))return 0;let t=Math.min(e.totalBytes,Math.max(0,e.totalBytes-e.availBytes));return Math.round(t/e.totalBytes*1e3)/10}var hCe=10*2**30;function Q2(e){return e.totalBytes>0&&(e.availBytes<hCe||e.availBytes/e.totalBytes*100<5)}function $2(e){return`${X2(e.availBytes)} free of ${X2(e.totalBytes)}`}var gCe=16,e4=e=>{let t=Math.max(0,e)/2**30;return`${t>=10||t===0?Math.round(t):t.toFixed(1)} GB`},t4=e=>`${Math.round(e)}%`,_Ce=e=>`${Math.round(e)}°C`,vCe=e=>`${Math.round(e)} rpm`;function yCe({onClose:e,focus:t,onOpenSession:n}){let r=Kg(e=>e,!0),i=am(e=>e.online);(0,V.useEffect)(()=>Xg(),[]);let a=(0,V.useRef)(null);(0,V.useEffect)(()=>{let e=a.current;if(!t||!e)return;e.scrollIntoView({block:`start`}),e.classList.add(`nh-flash`);let n=window.setTimeout(()=>e.classList.remove(`nh-flash`),1400);return()=>window.clearTimeout(n)},[t]);let o=Ag({last:r.last,disabled:r.disabled,online:i,askedAt:r.askedAt,answeredAt:r.answeredAt,now:r.now}),s=Sg(r.samples),c=Die(r.samples),l=wg(r.samples),u=Oie(r.samples),d=o.sample?.memTotal??0,f=kie(r.samples),p=Aie(r.samples),m=f.some(e=>e!=null)||p.some(e=>e!=null),h=(o.sample?.sys?.thermal?.fans??[]).map((e,t)=>({key:`fan-${e.label}`,label:e.label,tone:[`app`,`wired`,`compressed`][t%3],series:jie(r.samples,e.label)})),g=U2(h.flatMap(e=>e.series),2e3,500),_=r.samples.length>1?{from:r.samples[0].at,to:r.samples[r.samples.length-1].at}:{},v=c.some(e=>e!=null),y=o.sample?.models??[],b=o.sample?.sys,x=cCe(b?.mem,o.sample?.memTotal??0),S=uCe(b?.mem),C=b?.procs&&o.sample?J2(b.procs.at,o.sample.at):null,w=b?.thermal&&o.sample?J2(b.thermal.at,o.sample.at):null,T=b?.disks&&o.sample?J2(b.disks.at,o.sample.at):null,E=b?.disks?.volumes[0],D=(0,J.jsx)(J.Fragment,{children:(0,J.jsxs)(`section`,{className:`set-group${y.length>0?` lrt-hero`:``}`,ref:t===`models`?a:void 0,children:[(0,J.jsx)(`h3`,{className:`set-title`,children:y.length>0?`Local model, resident`:`Local models`}),y.length>0?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`lrt-rows`,children:y.map(e=>(0,J.jsxs)(`div`,{className:`lrt-row`,children:[(0,J.jsx)(`span`,{className:`lrt-name mono`,children:e.name}),(0,J.jsx)(`span`,{className:`lrt-size`,children:bg(e.size)}),e.sessionsUsing!=null&&(0,J.jsx)(`span`,{className:`lrt-size`,children:e.sessionsUsing===0?`no active session`:`${e.sessionsUsing} active session${e.sessionsUsing===1?``:`s`}`}),(0,J.jsxs)(fC,{className:`link-btn lrt-eject`,title:`unload ${e.name} now`,confirm:e.sessionsUsing?(0,J.jsxs)(J.Fragment,{children:[e.sessionsUsing,` active — eject anyway?`]}):(0,J.jsx)(J.Fragment,{children:`eject?`}),confirmTitle:e.sessionsUsing?`${e.sessionsUsing} session${e.sessionsUsing===1?``:`s`} on ${e.name} will reload it from disk on the next reply`:void 0,onConfirm:()=>Kie(e.name),children:[(0,J.jsx)(Fte,{size:12,"aria-hidden":`true`}),` eject`]}),(0,J.jsxs)(`span`,{className:`lrt-vram`,children:[(0,J.jsx)(Ba,{size:11,"aria-hidden":`true`}),` `,bg(e.vram),` on GPU`]}),e.expiresAt!=null&&(0,J.jsx)(`span`,{className:`lrt-evict`,children:o.sample!=null&&e.expiresAt>o.sample.at?(0,J.jsxs)(J.Fragment,{children:[`evicts in `,zp(e.expiresAt)]}):(0,J.jsx)(J.Fragment,{children:`was due to be evicted by then`})})]},e.name))}),(0,J.jsxs)(X,{as:`span`,children:[bg(xg(y)),` held in total by `,y.length===1?`one model`:`${y.length} models`,`. The runner still evicts on its own schedule; *eject* on a row is the one thing on this screen that acts instead of just reading — nothing else here does.`]})]}):(0,J.jsx)(X,{as:`span`,children:o.text})]})}),O=(0,J.jsx)(J.Fragment,{children:(0,J.jsxs)(`section`,{className:`set-group`,ref:t===`history`&&y.length>0?a:void 0,children:[(0,J.jsx)(`h3`,{className:`set-title`,children:`Held memory, recently`}),s.length>1?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(G2,{lines:[{key:`held`,label:`held`,tone:`app`,series:s}],lo:0,hi:Cg(s),fmt:e4,..._}),(0,J.jsxs)(X,{as:`span`,children:[`The last `,s.length,` reading`,s.length===1?``:`s`,` (at most `,120,`, roughly ten minutes). A model being loaded or evicted is a step, not a slope. A reading where the runner did not answer is drawn as its own full-height mark rather than averaged into the line or bridged across — those are a different kind of event, not a small number.`]}),(0,J.jsx)(X,{as:`span`,children:`It is a series of READINGS, not a time axis: nothing is measured while this phone is in a pocket or off the tunnel, so the marks are not evenly spaced in time. Kept in memory only — a chart rebuilt from an old buffer after a reload would look exactly as current as this one, which is the failure this whole readout exists to avoid.`})]}):(0,J.jsx)(X,{as:`span`,children:`Nothing to draw yet. Readings arrive every few seconds while this screen or the strip is open, and they are not kept across a reload.`})]})}),k=(0,J.jsx)(J.Fragment,{children:(0,J.jsxs)(`section`,{className:`set-group`,children:[(0,J.jsx)(`h3`,{className:`set-title`,children:`GPU utilization, recently`}),c.length>1&&v?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(G2,{lines:[{key:`gpu`,label:`GPU busy`,tone:`app`,series:c}],lo:0,hi:100,fmt:t4,..._}),(0,J.jsx)(X,{as:`span`,children:`Same shape as the memory graph above, but fixed 0-100% rather than fitted to the data — a line drawn to a floating ceiling makes 20% look identical to 80% across two readings. A gap is a stretch this phone was not watching, drawn as a break, never bridged.`})]}):r.samples.length>1?(0,J.jsx)(X,{as:`span`,children:`No GPU reading from this desktop. Today that reader only exists for Apple Silicon (the OS's own utilization figure) — a discrete-GPU host or one running Linux has none yet, and this says so rather than drawing a flat line at 0%.`}):(0,J.jsx)(X,{as:`span`,children:`Nothing to draw yet. Readings arrive every few seconds while this screen or the strip is open, and they are not kept across a reload.`})]})}),A=(0,J.jsx)(J.Fragment,{children:(0,J.jsxs)(`section`,{className:`set-group`,ref:t===`cpu`||t===`memory`&&!(x.length>0&&b?.mem)?a:void 0,children:[(0,J.jsx)(`h3`,{className:`set-title`,children:`The desktop`}),o.sample?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`lrt-rows`,children:[b?.cpu?(0,J.jsxs)(`div`,{className:`lrt-row`,children:[(0,J.jsxs)(`span`,{className:`lrt-name`,children:[(0,J.jsx)(sc,{size:11,"aria-hidden":`true`}),` CPU busy`]}),(0,J.jsxs)(`span`,{className:`lrt-size`,children:[Math.round(b.cpu.userPct+b.cpu.sysPct),`%`]}),(0,J.jsx)(`span`,{className:`lrt-vram`,children:dCe(b.cpu)})]}):(0,J.jsxs)(`div`,{className:`lrt-row`,children:[(0,J.jsxs)(`span`,{className:`lrt-name`,children:[(0,J.jsx)(sc,{size:11,"aria-hidden":`true`}),` CPU load`]}),(0,J.jsxs)(`span`,{className:`lrt-size`,children:[Math.round(o.sample.cpuPct),`%`]}),(0,J.jsx)(`span`,{className:`lrt-vram`,children:`the one-minute load average over the core count — a queue length, not a utilization figure`})]}),b?.cpu&&b.cpu.cores.length>0&&(0,J.jsxs)(`div`,{className:`lrt-row lrt-cores`,children:[(0,J.jsxs)(`span`,{className:`lrt-name`,children:[(0,J.jsx)(us,{size:11,"aria-hidden":`true`}),` per core`]}),(0,J.jsx)(`span`,{className:`sys-cores`,"aria-hidden":`true`,children:b.cpu.cores.map((e,t)=>(0,J.jsx)(`span`,{className:`sys-core`,title:`core ${t+1}: ${e}%`,children:(0,J.jsx)(`span`,{className:`sys-core-fill`,style:{height:`${Math.max(2,Math.min(100,e))}%`}})},t))}),(0,J.jsxs)(`span`,{className:`lrt-vram`,children:[b.cpu.cores.filter(e=>e>=80).length,` of `,b.cpu.cores.length,` cores above 80%`]})]}),b&&(0,J.jsxs)(`div`,{className:`lrt-row`,children:[(0,J.jsxs)(`span`,{className:`lrt-name`,children:[(0,J.jsx)(ms,{size:11,"aria-hidden":`true`}),` load`]}),(0,J.jsx)(`span`,{className:`lrt-size`,children:b.loadavg[0].toFixed(2)}),(0,J.jsxs)(`span`,{className:`lrt-vram`,children:[fCe(b),` · up `,mCe(b.uptimeSec)]})]}),(0,J.jsxs)(`div`,{className:`lrt-row`,children:[(0,J.jsxs)(`span`,{className:`lrt-name`,children:[(0,J.jsx)(ks,{size:11,"aria-hidden":`true`}),` memory `,b?.mem?.availableBytes==null?`free`:`available`]}),(0,J.jsx)(`span`,{className:`lrt-size`,children:bg(b?.mem?.availableBytes??o.sample.memFree)}),(0,J.jsxs)(`span`,{className:`lrt-vram`,children:[`of `,bg(o.sample.memTotal),b?.mem?.availableBytes==null?``:` · ${bg(o.sample.memFree)} of it untouched`]})]}),o.sample.gpuPct!=null&&(0,J.jsxs)(`div`,{className:`lrt-row`,children:[(0,J.jsxs)(`span`,{className:`lrt-name`,children:[(0,J.jsx)(ms,{size:11,"aria-hidden":`true`}),` GPU utilization`]}),(0,J.jsxs)(`span`,{className:`lrt-size`,children:[Math.round(o.sample.gpuPct),`%`]})]}),o.sample.gpuMemInUse!=null&&(0,J.jsxs)(`div`,{className:`lrt-row`,children:[(0,J.jsxs)(`span`,{className:`lrt-name`,children:[(0,J.jsx)(Ba,{size:11,"aria-hidden":`true`}),` GPU memory in use`]}),(0,J.jsx)(`span`,{className:`lrt-size`,children:bg(o.sample.gpuMemInUse)})]}),E&&(0,J.jsxs)(`div`,{className:`lrt-row`,children:[(0,J.jsxs)(`span`,{className:`lrt-name`,children:[(0,J.jsx)(Ba,{size:11,"aria-hidden":`true`}),` disk free`]}),(0,J.jsx)(`span`,{className:`lrt-size`,children:X2(E.availBytes)}),(0,J.jsxs)(`span`,{className:`lrt-vram`,children:[`of `,X2(E.totalBytes),` · `,E.name,Q2(E)?` · nearly full`:``]})]})]}),(0,J.jsxs)(X,{as:`span`,children:[`These are the operating system's numbers, not the model's. Free memory understates what is really available — a page cache and a compressor are not in it — which is why this app warns about a second local model in a sentence and never refuses to start one.`,o.sample.gpuPct!=null&&(0,J.jsx)(J.Fragment,{children:` GPU figures are the driver's own, system-wide — not just what a model above is holding, and absent entirely on a host this app has no reader for.`})]})]}):(0,J.jsx)(X,{as:`span`,children:`No reading from this desktop yet.`})]})}),j=(0,J.jsx)(sCe,{ref:t===`agents`?a:void 0,onOpenSession:n}),M=(0,J.jsx)(J.Fragment,{children:(0,J.jsxs)(`section`,{className:`set-group`,ref:t===`history`&&y.length===0?a:void 0,children:[(0,J.jsx)(`h3`,{className:`set-title`,children:`The desktop, recently`}),l.some(e=>e!=null)&&l.length>1?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(G2,{lines:[{key:`cpu`,label:`CPU busy`,tone:`app`,series:l}],lo:0,hi:100,fmt:t4,..._}),u.some(e=>e!=null)&&d>0&&(0,J.jsx)(G2,{lines:[{key:`mem`,label:`memory in use`,tone:`wired`,series:u}],lo:0,hi:d,fmt:e4,..._}),(0,J.jsxs)(X,{as:`span`,children:[`CPU busy, then memory in use, over the last `,l.length,` readings — both drawn against the whole machine (0-100%, 0 to `,bg(d),`), never fitted to the data, so a flat line means a flat machine. A break is a stretch this phone was not watching, never bridged. Kept in memory only, so a reload starts it again rather than drawing an old buffer as current.`]})]}):(0,J.jsx)(X,{as:`span`,children:`Nothing to draw yet. Readings arrive every few seconds while this screen or the strip is open, and they are not kept across a reload.`})]})}),N=(0,J.jsxs)(J.Fragment,{children:[x.length>0&&b?.mem&&(0,J.jsxs)(`section`,{className:`set-group`,ref:t===`memory`?a:void 0,children:[(0,J.jsx)(`h3`,{className:`set-title`,children:`Where the memory has gone`}),(0,J.jsx)(`div`,{className:`sys-bar`,role:`img`,"aria-label":x.map(e=>`${e.label} ${bg(e.bytes)}`).join(`, `),children:x.map(e=>(0,J.jsx)(`span`,{className:`sys-seg sys-${e.tone}`,style:{width:`${e.pct}%`}},e.key))}),(0,J.jsxs)(`div`,{className:`lrt-rows`,children:[x.map(e=>(0,J.jsxs)(`div`,{className:`lrt-row`,children:[(0,J.jsxs)(`span`,{className:`lrt-name`,children:[(0,J.jsx)(`span`,{className:`sys-dot sys-${e.tone}`,"aria-hidden":`true`}),` `,e.label]}),(0,J.jsx)(`span`,{className:`lrt-size`,children:bg(e.bytes)}),(0,J.jsx)(`span`,{className:`lrt-vram`,children:e.what})]},e.key)),S&&(0,J.jsxs)(`div`,{className:`lrt-row`,children:[(0,J.jsxs)(`span`,{className:`lrt-name`,children:[(0,J.jsx)(Ba,{size:11,"aria-hidden":`true`}),` swap`]}),(0,J.jsx)(`span`,{className:`lrt-size`,children:S}),(0,J.jsx)(`span`,{className:`lrt-vram`,children:`pages the machine pushed out to disk — swap filling up is what slows a desktop down long before the memory number does`})]})]}),(0,J.jsx)(`span`,{className:`set-note`,children:lCe(b.mem,o.sample?.memFree??0)})]}),(0,J.jsxs)(`section`,{className:`set-group`,children:[(0,J.jsx)(`h3`,{className:`set-title`,children:`What is holding it`}),b?.procs?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`lrt-rows`,children:b.procs.byMem.map(e=>(0,J.jsxs)(`div`,{className:`lrt-row`,children:[(0,J.jsx)(`span`,{className:`lrt-name mono`,children:e.name}),(0,J.jsx)(`span`,{className:`lrt-size`,children:bg(e.rssBytes)}),(0,J.jsxs)(`span`,{className:`lrt-vram`,children:[q2(e),` · `,e.cpuPct.toFixed(0),`% CPU`]})]},`m-${e.name}`))}),(0,J.jsxs)(X,{as:`span`,children:[pCe(b.procs.rssSumBytes,o.sample?.memTotal??0),` `,b.procs.count,` processes are running; these are the `,b.procs.byMem.length,` biggest.`,C==null?``:` Read ${C}s before the rest of this sample.`]}),b.procs.byCpu.length>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`h3`,{className:`set-title`,children:`…and what is using the CPU`}),(0,J.jsx)(`div`,{className:`lrt-rows`,children:b.procs.byCpu.map(e=>(0,J.jsxs)(`div`,{className:`lrt-row`,children:[(0,J.jsx)(`span`,{className:`lrt-name mono`,children:e.name}),(0,J.jsxs)(`span`,{className:`lrt-size`,children:[e.cpuPct.toFixed(0),`%`]}),(0,J.jsxs)(`span`,{className:`lrt-vram`,children:[q2(e),` · `,bg(e.rssBytes)]})]},`c-${e.name}`))}),(0,J.jsx)(X,{as:`span`,children:"A percentage per core, summed across the fold, exactly as `top` reports it — so a row can read well past 100% and that is several cores, not an error."})]})]}):(0,J.jsx)(`span`,{className:`set-note`,children:b?.procsNote??`This desktop is not sending a process list — its ${I.name} predates this readout.`})]}),(0,J.jsxs)(`section`,{className:`set-group`,children:[(0,J.jsx)(`h3`,{className:`set-title`,children:`Disk space`}),b?.disks?(0,J.jsxs)(J.Fragment,{children:[b.disks.volumes.map(e=>(0,J.jsxs)(`div`,{className:`sys-disk`,children:[(0,J.jsxs)(`div`,{className:`lrt-row`,children:[(0,J.jsxs)(`span`,{className:`lrt-name`,children:[(0,J.jsx)(Ba,{size:11,"aria-hidden":`true`}),` `,e.name]}),(0,J.jsxs)(`span`,{className:`lrt-size`,children:[X2(e.availBytes),` free`]}),(0,J.jsxs)(`span`,{className:`lrt-vram`,children:[$2(e),` · `,Math.round(Z2(e)),`% used`,e.holds.length>0?` · holds ${e.holds.join(`, `)}`:``]})]}),(0,J.jsxs)(`div`,{className:`sys-bar`,role:`img`,"aria-label":`${e.name}: ${$2(e)}`,children:[(0,J.jsx)(`span`,{className:`sys-seg ${Q2(e)?`sys-disk-low`:`sys-app`}`,style:{width:`${Z2(e)}%`}}),(0,J.jsx)(`span`,{className:`sys-seg sys-available`,style:{flex:1}})]}),Q2(e)&&(0,J.jsxs)(YS,{children:[e.name,` is nearly full — builds, model downloads and the swap file are what fill the last of a disk, and a full one fails them part-way.`]})]},e.path)),(0,J.jsxs)(X,{as:`span`,children:[`Free is what a program could still write. On a Mac it leaves out purgeable space (local snapshots, files iCloud can fetch again), so Finder may say more is free. What this app itself keeps on the desktop is listed on the Storage screen.`,T==null?``:` Read ${T}s before the rest of this sample.`]})]}):(0,J.jsx)(`span`,{className:`set-note`,children:b?.disksNote??`This desktop is not sending disk readings — its ${I.name} predates this readout.`})]}),(0,J.jsxs)(`section`,{className:`set-group`,children:[(0,J.jsx)(`h3`,{className:`set-title`,children:`Temperature and fans`}),b?.thermal?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`lrt-rows`,children:[Y2(b.thermal.cpuTempC)&&(0,J.jsxs)(`div`,{className:`lrt-row`,children:[(0,J.jsxs)(`span`,{className:`lrt-name`,children:[(0,J.jsx)(sl,{size:11,"aria-hidden":`true`}),` CPU`]}),(0,J.jsx)(`span`,{className:`lrt-size`,children:Y2(b.thermal.cpuTempC)})]}),Y2(b.thermal.gpuTempC)&&(0,J.jsxs)(`div`,{className:`lrt-row`,children:[(0,J.jsxs)(`span`,{className:`lrt-name`,children:[(0,J.jsx)(sl,{size:11,"aria-hidden":`true`}),` GPU`]}),(0,J.jsx)(`span`,{className:`lrt-size`,children:Y2(b.thermal.gpuTempC)})]}),b.thermal.fans.map(e=>(0,J.jsxs)(`div`,{className:`lrt-row`,children:[(0,J.jsxs)(`span`,{className:`lrt-name`,children:[(0,J.jsx)(lne,{size:11,"aria-hidden":`true`}),` `,e.label]}),(0,J.jsxs)(`span`,{className:`lrt-size`,children:[e.rpm,` rpm`]})]},e.label))]}),m&&r.samples.length>1&&(0,J.jsx)(G2,{lines:[...f.some(e=>e!=null)?[{key:`cpu-t`,label:`CPU`,tone:`app`,series:f}]:[],...p.some(e=>e!=null)?[{key:`gpu-t`,label:`GPU`,tone:`wired`,series:p}]:[]],lo:20,hi:Math.max(100,...[...f,...p].filter(e=>e!=null)),fmt:_Ce,..._}),h.length>0&&r.samples.length>1&&(0,J.jsx)(G2,{lines:h,lo:0,hi:g,fmt:vCe,..._}),(0,J.jsxs)(X,{as:`span`,children:[r.samples.length>1&&(m||h.length>0)&&(0,J.jsx)(J.Fragment,{children:`Temperature is drawn 20-100°C, fixed, so a warm minute is not stretched into a fever. Fans are the one fitted axis — the sensor names no maximum — so read their rpm, not the height. The sensor is read on a slower beat than the rest, so a step is a fresh reading arriving, not a jump. `}),`Read by `,(0,J.jsx)(`span`,{className:`mono`,children:b.thermal.source}),` — a sensor tool this app does not own, so these are its numbers and not ours.`,b.thermal.fans.length===0?` It reported no fans: a fanless machine, or a VM.`:``,w==null?``:` Read ${w}s before the rest of this sample.`]})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`set-note`,children:b?.thermalNote??`This desktop is not sending a temperature reading — its ${I.name} predates this readout.`}),b?.thermalFix?.map(e=>(0,J.jsxs)(`div`,{className:`cmd-copy`,children:[(0,J.jsx)(`code`,{children:e}),(0,J.jsx)(Y,{"aria-label":`copy command`,onClick:async()=>K(await Xf(e)?`command copied`:`copy failed`),children:(0,J.jsx)(_o,{size:16})})]},e))]})]})]}),P=(0,J.jsx)(J.Fragment,{children:(0,J.jsxs)(`section`,{className:`set-group`,children:[(0,J.jsx)(`h3`,{className:`set-title`,children:`What is not here`}),(0,J.jsx)(X,{as:`span`,children:`There is no tokens-per-second figure anywhere in this app, deliberately. Neither the runner nor the coding CLI publishes live throughput, and the only thing that could be estimated from what this host can see — bytes off the terminal over wall clock — is wrong in both directions that matter: a terminal repaints, so screen bytes are not output tokens, and a model thinking silently produces nothing at all while doing the expensive part. A speed nobody can act on is worse than a blank space.`})]})});return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:`This desktop`,icon:(0,J.jsx)(xo,{size:gCe}),onClose:e}),(0,J.jsxs)(`div`,{className:`sheet-body`,children:[(0,J.jsx)(`p`,{className:`lrt-verdict${o.stale?` stale`:``}`,children:y.length===0&&o.sample?kg(o.sample,o.stale):o.text}),o.stale&&o.at!=null&&(0,J.jsxs)(X,{as:`p`,children:[`Read `,Op(o.at),` ago, at `,Rp(o.at),i?``:` — this phone is not connected to the desktop right now`,`.`,r.seenAt!=null&&r.seenAt!==o.at?` Last frame from the desktop ${Op(r.seenAt)} ago.`:``]}),t===`agents`&&j,y.length>0?(0,J.jsxs)(J.Fragment,{children:[D,O,k,A,M,t!==`agents`&&j,N,P]}):(0,J.jsxs)(J.Fragment,{children:[A,M,t!==`agents`&&j,v?k:null,N,D]})]})]})}var n4={supported:!1,persisted:!1};function bCe(){return n4}async function r4(){let e=navigator.storage;if(!e?.estimate)return n4={supported:!1,persisted:!1};let t={supported:typeof e.persist==`function`,persisted:e.persisted?await e.persisted().catch(()=>!1):!1},n=await e.estimate().catch(()=>null);return n&&(t.usage=n.usage,t.quota=n.quota),n4=t}async function xCe(){let e=navigator.storage;if(!e||typeof e.persist!=`function`)return n4={supported:!1,persisted:!1};try{e.persisted&&await e.persisted()||await e.persist()}catch{}return r4()}var i4=W(null);function a4(e){i4.set(e)}function o4(){return G(i4)}var s4=W(null);function SCe(){return G(s4)}function c4(e){if(!e||typeof e!=`object`)return null;let t=e;return typeof t.hostId==`string`&&t.hostId&&typeof t.secret==`string`&&t.secret.length>=16?{hostId:t.hostId,secret:t.secret}:null}function CCe(e=e=>globalThis.crypto.getRandomValues(e)){let t=e(new Uint8Array(16));return Array.from(t,e=>e.toString(16).padStart(2,`0`)).join(``)}async function wCe(e,t,n,r=globalThis.crypto?.subtle){if(!r)return null;try{let i=new TextEncoder,a=await r.importKey(`raw`,i.encode(e),{name:`HMAC`,hash:`SHA-256`},!1,[`sign`]),o=await r.sign(`HMAC`,a,i.encode(dt(t,n)));return Array.from(new Uint8Array(o),e=>e.toString(16).padStart(2,`0`)).join(``)}catch{return null}}function TCe(e,t){if(e.length!==t.length)return!1;let n=0;for(let r=0;r<e.length;r++)n|=e.charCodeAt(r)^t.charCodeAt(r);return n===0}async function ECe(e,t,n,r){if(!n||n.hostId!==e.hostId||typeof n.mac!=`string`)return!1;let i=await wCe(e.secret,e.hostId,t,r??globalThis.crypto?.subtle);return!!i&&TCe(i,n.mac.toLowerCase())}function DCe(e){return e>=200&&e<300||e===401}var OCe=`Using the tailnet: set a password on the host to use LAN — without one it cannot give this phone a token.`,kCe=`Using the tailnet: the desktop did not give this phone a device token.`,ACe=`Using the tailnet: the desktop's LAN identity could not be read over the tailnet.`;function jCe(e,t){return e===null?null:t?.auto?t.base===e?null:`Using the tailnet: the LAN address changed; checking it again.`:`Using the tailnet: switching to the LAN automatically is off.`}function MCe(e){let t=null,n=null,r=!1,i=e=>({route:`tailnet`,sentence:e,lanBase:null});async function a(){let n=e.host();if(!n)return{v:null};let r=await e.net(),a=t,o=Hr({host:n,net:r,probe:null,macVerified:null,lastFailure:a});if(o.next!==`probe`||!n.lan)return{v:i(o.sentence)};let s=n.lan.base,c=await e.ensureToken();if(c===`no-password`)return{v:i(OCe)};if(c!==`ok`)return{v:i(kCe)};let l=await e.ensureIdentity();if(!l)return{v:i(ACe)};let u=await e.probe(s,f),d=Hr({host:n,net:r,probe:u,macVerified:null,lastFailure:a});if(d.next!==`verify`)return{v:i(d.sentence)};let p=e.nonce?e.nonce():CCe(),m=!1;try{m=await ECe(l,p,await e.verify(s,p),e.subtle)}catch{m=!1}let h=Hr({host:n,net:r,probe:u,macVerified:m,lastFailure:a});return{v:{route:h.route,sentence:h.sentence,lanBase:h.route===`lan`?s:null}}}async function o(){let t=null;for(;;){r=!1;let n;try{n=(await a()).v}catch{n=i(`Using the tailnet: checking the LAN failed.`)}if(r)n&&n.route===`tailnet`&&(e.apply(n),t=n);else return n&&(e.apply(n),t=n),t}}return{evaluate(e){return n?(r=!0,n):(n=o().finally(()=>{n=null}),n)},noteFailure(a){t={at:e.now(),reason:a},n&&(r=!0);let o=i(`Using the tailnet: the LAN connection failed (${a}); it is tried again on the next network change or reconnect.`);return e.apply(o),o},lastFailure:()=>t}}var l4=16;function u4({label:e,value:t,note:n,onClick:r,title:i}){let a=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`nh-stat-v`,children:t}),(0,J.jsx)(`span`,{className:`nh-stat-l`,children:e}),n&&(0,J.jsx)(`span`,{className:`nh-stat-n`,children:n})]});return r?(0,J.jsx)(`button`,{type:`button`,className:`nh-stat nh-stat-door`,onClick:r,title:i,children:a}):(0,J.jsx)(`div`,{className:`nh-stat`,title:i,children:a})}function NCe({onClose:e,onToast:t,notDelivered:n,onOpenActivity:r,onOpenStorage:i,focus:a}){let[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(null),[u,d]=(0,V.useState)(!1),f=am(e=>e,!0),p=f.log,m=f.traffic,h=f.sync,g=f.pulse,_=(0,V.useRef)(null),v=o4(),y=SCe();(0,V.useEffect)(()=>{let e=_.current;if(!a||!e)return;e.scrollIntoView({block:`start`}),e.classList.add(`nh-flash`);let t=window.setTimeout(()=>e.classList.remove(`nh-flash`),1400);return()=>window.clearTimeout(t)},[a]);let[b,x]=(0,V.useState)(()=>bCe());async function S(){l(null);try{s(await H.netstats.get())}catch(e){l(String(e?.message||e))}}(0,V.useEffect)(()=>{S()},[]),(0,V.useEffect)(()=>{r4().then(x)},[]);let C=cm(p,o,n),w=o?.delivery,T=(w?.unsubmitted??0)+(w?.unconfirmed??0);function E(){u?(d(!1),vf(),H.netstats.reset().then(()=>S(),()=>S()),t(`connection stats reset`)):(d(!0),t(`tap again to reset the window`))}let D=h.syncedAt??Xp(),O=_p(g.samples),k=g.samples.length,A=Object.entries(o?.sockets.closeCodes??{}).sort((e,t)=>t[1]-e[1]),j=o&&o.sockets.closed>0?o.sockets.totalOpenMs/o.sockets.closed:null;return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:`Connection health`,icon:(0,J.jsx)(us,{size:l4}),onClose:e,children:(0,J.jsx)(Y,{title:`re-read the host's own counters`,onClick:()=>void S(),children:(0,J.jsx)(tc,{size:l4})})}),(0,J.jsxs)(`div`,{className:`sheet-body`,children:[(0,J.jsx)(`p`,{className:`nh-verdict nh-${C.tone}`,children:C.text}),T>0&&(0,J.jsxs)(JS,{children:[(0,J.jsxs)(Y,{className:u?`active`:``,onClick:E,children:[(0,J.jsx)(tc,{size:l4}),` `,u?`tap again to clear`:`checked them — clear`]}),(0,J.jsx)(X,{as:`span`,children:`Resets this window's counters; the prompts themselves stay in Activity.`})]}),(0,J.jsxs)(`section`,{className:`set-group`,ref:a===`sends`&&n===0?_:void 0,children:[(0,J.jsx)(`h3`,{className:`set-title`,children:`On this phone only`}),f.outstanding>0?(0,J.jsxs)(X,{as:`span`,className:`nh-unsaved`,children:[(0,J.jsx)(rs,{size:l4,style:{verticalAlign:`-2px`}}),` `,f.outstanding===1?`One thing`:`${f.outstanding} things`,` written here`,f.outstanding===1?` has`:` have`,` not reached the desktop yet — queued sends and synced settings still to push. They go on their own as soon as the link allows; nothing here needs a tap.`]}):(0,J.jsxs)(X,{as:`span`,className:`nh-saved`,children:[(0,J.jsx)(Bc,{size:l4,style:{verticalAlign:`-2px`}}),` `,`Everything written on this phone has reached the desktop and is stored there. Nothing is waiting on this device`,n>0?` — except the sends below, which stopped and will not go on their own`:``,`.`]})]}),n>0&&(0,J.jsxs)(`section`,{className:`set-group`,ref:a===`sends`?_:void 0,children:[(0,J.jsx)(`h3`,{className:`set-title`,children:`The sends that stopped`}),(0,J.jsxs)(X,{as:`span`,children:[n===1?`One message`:`${n} messages`,` written on this phone stopped short of a session. Nothing was lost and nothing expires: each one keeps its full words and the repo they were written for, in Activity, with the button that puts it back in that repo's backlog — where it opens a new session of its own.`]}),(0,J.jsx)(JS,{children:(0,J.jsxs)(Y,{onClick:r,children:[(0,J.jsx)(ml,{size:l4}),` open the `,n,` in Activity`]})})]}),(0,J.jsxs)(`section`,{className:`set-group`,ref:a===`link`?_:void 0,children:[(0,J.jsx)(`h3`,{className:`set-title`,children:`Link right now`}),v&&(0,J.jsxs)(X,{className:`nh-route`,children:[v.route===`lan`?(0,J.jsx)(Fc,{size:14,"aria-hidden":`true`}):(0,J.jsx)(wo,{size:14,"aria-hidden":`true`}),(0,J.jsx)(`span`,{children:v.sentence})]}),v&&y&&(0,J.jsxs)(JS,{children:[(0,J.jsxs)(Y,{onClick:y,children:[(0,J.jsx)(Bs,{size:l4}),` change LAN settings`]}),v.sentence===`Using the tailnet: set a password on the host to use LAN — without one it cannot give this phone a token.`&&(0,J.jsxs)(Y,{onClick:()=>XI(`lan-password`),children:[(0,J.jsx)(Fa,{size:l4}),` set the LAN password`]})]}),(0,J.jsxs)(`div`,{className:`nh-stats`,children:[(0,J.jsx)(u4,{label:`socket`,value:f.status,note:g.enabled?void 0:`strip is off — no probes running`}),(0,J.jsx)(u4,{label:`last ping`,value:O.last==null?k?`no reply`:`—`:om(O.last),note:O.last==null&&k?`the newest probe timed out`:void 0}),(0,J.jsx)(u4,{label:`median ping`,value:om(O.median??void 0),note:k?O.misses?`over the ${k-O.misses} replies of the last ${k} probes`:`over the last ${k} probe${k>1?`s`:``}`:void 0}),(0,J.jsx)(u4,{label:`unanswered pings`,value:`${O.misses}`,note:O.misses?`of the last ${k} — drawn, never averaged`:`every probe came back`})]}),!g.enabled&&(0,J.jsx)(JS,{children:(0,J.jsxs)(Y,{onClick:()=>XI(`net-pulse`),children:[(0,J.jsx)(Bs,{size:l4}),` turn the connection strip on`]})}),(0,J.jsxs)(X,{as:`span`,children:[`Probes go out every 3 s while the app is on screen and are kept as the last `,90,`; a phone in a pocket measures nothing, so this window is a count of pings, not a stretch of time. An unanswered probe is its own kind of event — a link losing one ping in four feels nothing like a slow one, and only the first eats prompts — so it is counted here rather than folded into the median. It is a ping, though, not a prompt: nothing you typed was lost because one went missing, which is why the strip draws them in the graph and no longer spells them out. This readout never acts: a missed probe reconnects nothing.`]})]}),(0,J.jsxs)(`section`,{className:`set-group`,children:[(0,J.jsxs)(`h3`,{className:`set-title`,children:[`Delivery — last `,sm(p.since)]}),(0,J.jsxs)(`div`,{className:`nh-stats`,children:[(0,J.jsx)(u4,{label:`confirmed`,value:String(p.sent),note:`typed, echoed, turn started`}),(0,J.jsx)(u4,{label:`gave up`,value:String(p.failed),note:`each one keeps its own row, in full, in Activity`}),(0,J.jsx)(u4,{label:`typical wait`,value:om(p.sendP50),note:`queued → running`}),(0,J.jsx)(u4,{label:`worst wait`,value:om(p.queuedMaxMs)})]}),w&&(0,J.jsxs)(`div`,{className:`nh-stats`,children:[(0,J.jsx)(u4,{label:`host: started`,value:String(w.ok)}),(0,J.jsx)(u4,{label:`host: not ready`,value:String(w.retry),note:`nothing typed — safe to resend`}),(0,J.jsx)(u4,{label:`host: unconfirmed`,value:String(w.unconfirmed),note:`never seen on screen`}),(0,J.jsx)(u4,{label:`host: unsubmitted`,value:String(w.unsubmitted),note:`in the composer, Return swallowed`})]}),(0,J.jsx)(X,{as:`span`,children:`A confirmed send means the host typed the prompt, saw it echo and proved the turn started — not just that bytes reached the machine. The last two host counters are the ones that used to be invisible: the prompt is on the far side, so re-sending it stacks a second copy.`})]}),(0,J.jsxs)(`section`,{className:`set-group`,children:[(0,J.jsx)(`h3`,{className:`set-title`,children:`This device`}),(0,J.jsxs)(`div`,{className:`nh-stats`,children:[(0,J.jsx)(u4,{label:`ping (median)`,value:om(p.rttP50)}),(0,J.jsx)(u4,{label:`ping (p95)`,value:om(p.rttP95),note:`what deadlines are sized from`}),(0,J.jsx)(u4,{label:`offline`,value:`${Math.round(p.offlineShare*100)}%`,note:`of the window`}),(0,J.jsx)(u4,{label:`reconnects`,value:String(p.reconnects)}),(0,J.jsx)(u4,{label:`forced reloads`,value:String(p.reloads),note:`watchdog gave up on the socket`}),(0,J.jsx)(u4,{label:`missed receipts`,value:String(p.ackTimeouts),note:`deadline passed, retried`})]})]}),(0,J.jsxs)(`section`,{className:`set-group`,ref:a===`currency`?_:void 0,children:[(0,J.jsx)(`h3`,{className:`set-title`,children:`Currency`}),(0,J.jsxs)(`div`,{className:`nh-stats`,children:[(0,J.jsx)(u4,{label:h.online?`connected`:`last connected`,value:h.online?`for ${Op(h.connectedSince??Date.now())}`:h.lastSeenAt?Op(h.lastSeenAt)+` ago`:`never`,note:Zp(h.online?h.connectedSince:h.lastSeenAt)}),(0,J.jsx)(u4,{label:`last full sync`,value:D==null?`never`:`${Op(D)} ago`,note:D==null?`no session list + repo listing yet`:Zp(D)})]}),h.online&&h.syncedAt==null&&(0,J.jsxs)(X,{as:`p`,children:[`Connected, but still waiting on `,h.pending.join(` and `),` for this socket — until they land, the lists on screen are from before the reconnect.`]}),(0,J.jsx)(X,{as:`span`,children:`“Last connected” is the newest frame the desktop actually sent, not the last time the socket claimed to be open — a tunnel can die under a socket that still reads as connected. A full sync is both halves the main screen is built from: the session list, pushed over the socket, and the repo listing, which is a separate HTTP call and can be stale on its own. The time shown is the older of the two, because that is when everything on screen was last current.`})]}),(0,J.jsxs)(`section`,{className:`set-group`,ref:a===`data`?_:void 0,children:[(0,J.jsxs)(`h3`,{className:`set-title`,children:[`Data moved — last `,sm(m.since)]}),(0,J.jsxs)(`div`,{className:`nh-stats`,children:[(0,J.jsx)(u4,{label:`downloaded`,value:Ld(m.down),note:Rd(m.downRate)?`${Rd(m.downRate)} right now`:void 0}),(0,J.jsx)(u4,{label:`uploaded`,value:Ld(m.up),note:Rd(m.upRate)?`${Rd(m.upRate)} right now`:void 0})]}),(0,J.jsx)(X,{as:`span`,children:`Counted in this app: requests by their declared length (so gzip is already off it), images and other page loads by what actually came off the network — a thumbnail served from the on-device cache costs nothing here, correctly — and socket frames as their payload before compression, which over-states a busy terminal. Files a background download fetched while the app was closed are not in here. It is a usage readout, not a bill.`})]}),(0,J.jsxs)(`section`,{className:`set-group`,children:[(0,J.jsx)(`h3`,{className:`set-title`,children:`On-device storage`}),(0,J.jsxs)(`div`,{className:`nh-stats`,children:[(0,J.jsx)(u4,{label:`eviction`,value:b.supported?b.persisted?`protected`:`possible`:`unknown`,note:b.supported?b.persisted?`queued photos and downloads are safe`:`queued photos may be dropped when space runs low`:`this browser won’t say`}),(0,J.jsx)(u4,{label:`used`,value:bp(b.usage),note:b.quota?`of ${bp(b.quota)} — tap to itemise`:`tap to itemise`,title:`what this phone is holding, store by store, and what clearing any of it would cost`,onClick:i})]}),b.supported&&!b.persisted&&(0,J.jsx)(X,{as:`p`,children:`Installing this app to the home screen usually earns persistent storage — until then, anything queued offline is best-effort.`})]}),(0,J.jsxs)(`section`,{className:`set-group`,children:[(0,J.jsxs)(`h3`,{className:`set-title`,children:[`Host `,o?`— last ${sm(o.since)}`:``]}),c&&(0,J.jsxs)(X,{as:`p`,children:[`Couldn’t read the host’s side: `,c]}),o&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`nh-stats`,children:[(0,J.jsx)(u4,{label:`sockets opened`,value:String(o.sockets.opened)}),(0,J.jsx)(u4,{label:`mean socket life`,value:om(j),note:o.sockets.minOpenMs==null?void 0:`shortest ${om(o.sockets.minOpenMs)}`}),(0,J.jsx)(u4,{label:`receipts lost`,value:String(o.ackReplays),note:`retries that found the work done`}),(0,J.jsx)(u4,{label:`devices`,value:String(Object.keys(o.clients).length)})]}),A.length>0&&(0,J.jsxs)(X,{as:`span`,children:[`Close codes: `,A.map(([e,t])=>`${e}×${t}`).join(`, `),` — `,`1000 is a clean close, 1001 the phone backgrounding, 1006 the tunnel dying under the socket.`]})]})]}),(0,J.jsxs)(`section`,{className:`set-group`,children:[(0,J.jsx)(JS,{children:(0,J.jsxs)(Y,{className:u?`active`:``,onClick:E,children:[(0,J.jsx)(tc,{size:l4}),` `,u?`tap again to reset`:`reset window`]})}),(0,J.jsxs)(X,{as:`span`,children:[`Everything here is local: the device half lives in this browser, the host half in`,(0,J.jsxs)(`code`,{children:[` `,Dt(`netstats.json`)]}),`. Nothing is sent anywhere.`]})]})]})]})}var d4=e=>({"--repo-hue":`${e}`,"--repo-accent":`hsl(${e} var(--repo-sat) var(--repo-lit))`});function PCe({repos:e,onClose:t}){let n=DD(),[r,i]=(0,V.useState)(null),[a,s]=(0,V.useState)(null),c=(0,V.useMemo)(()=>{let t=new Set,n=[];for(let r of e)t.has(r.repoName)||(t.add(r.repoName),n.push(r.repoName));return n.sort((e,t)=>e.localeCompare(t))},[e]),l=(0,V.useMemo)(()=>ni(c,n),[c,n]),u=(0,V.useMemo)(()=>new Set(l.flat()),[l]),d=Cte(n.palette),f=a?c.filter(e=>a.includes(e)):c,p=c.length>d.hues.length;function m(e,t){ED(yee(TD(),e,t)),q(t==null?`action:repocolor.clear`:`action:repocolor.pick`),K(t==null?`${e} — back to the ring’s colour`:`${e} recoloured`)}return(0,J.jsx)(Hw,{title:`Repo colours`,icon:(0,J.jsx)(Ute,{size:18}),onClose:t,children:(0,J.jsxs)(`div`,{className:`sheet-scroll`,children:[(0,J.jsxs)(JS,{children:[(0,J.jsx)(yS,{label:`repo colour ring`,options:Jn.map(e=>({key:e.id,label:e.label})),value:n.palette,onChange:e=>{let t=Jn.find(t=>t.id===e);ED(Ir(TD(),t.id)),q(`action:repocolor.palette.${t.id}`),K(`repo colours: ${t.label}`)}}),(0,J.jsx)(`div`,{className:`rc-ring`,"aria-hidden":`true`,children:d.hues.map(e=>(0,J.jsx)(`span`,{className:`rc-dot`,style:d4(e)},e))}),(0,J.jsxs)(X,{as:`span`,children:[d.note,` `,`A repo’s colour is a hue out of this ring, picked by its name — the same on every device and in every list, and two repos are either the same colour or a clearly different one.`,` `,`How light and how saturated it is drawn stays the theme’s answer, swept over all 360 hues, so `,(0,J.jsx)(`b`,{children:`nothing you pick here can make a name unreadable`}),`.`,` `,`A colour you pin below `,(0,J.jsx)(`b`,{children:`survives a change of ring`}),`: you chose that colour, not a slot.`]})]}),(0,J.jsx)(JS,{children:l.length>0?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(Y,{className:a?`active`:``,onClick:()=>{s(a?null:l.flat()),q(`action:repocolor.clashcut`)},children:[(0,J.jsx)(So,{size:14}),` `,u.size,` repos share a colour`]}),(0,J.jsxs)(Y,{onClick:()=>{let e=rte(c,TD());ED(e),q(`action:repocolor.spread`);let t=ni(c,e).flat().length;K(t?`separated — ${t} still share a colour`:`every repo has its own colour`)},children:[(0,J.jsx)(Ds,{size:14}),` give them separate colours`]}),(0,J.jsxs)(X,{as:`span`,children:[l.map(e=>e.join(` + `)).join(` · `),` land on the same hue.`,` `,`Separating them `,(0,J.jsx)(`b`,{children:`moves only the ones that collide`}),`: a repo already alone on its colour keeps it, and a colour you pinned yourself is never moved — so the repos you already recognise stay recognisable.`,p?(0,J.jsxs)(J.Fragment,{children:[` With `,c.length,` repos and `,d.hues.length,` hues in this ring, some of them must share whatever it does; a wider ring or a hue pinned by hand is the only way past that.`]}):null]})]}):(0,J.jsxs)(X,{as:`span`,children:[(0,J.jsx)(vc,{size:13}),` Every repo has a colour of its own.`]})}),a?(0,J.jsxs)(`div`,{className:`filter-bar`,children:[(0,J.jsxs)(`span`,{children:[`Showing the `,f.length,` of `,c.length,` that share a colour.`]}),(0,J.jsxs)(Y,{onClick:()=>s(null),children:[(0,J.jsx)(B,{size:14}),` clear`]})]}):null,c.length===0?(0,J.jsx)($,{thing:`repos`,children:`Nothing to colour until the desktop has listed a repo.`}):null,(0,J.jsx)(`div`,{className:`list`,children:f.map(e=>{let t=fi(e,n),a=lr(e,n),s=r===e;return(0,J.jsxs)(`div`,{className:`rc-row`,style:d4(t),children:[(0,J.jsxs)(`div`,{className:`rc-head`,children:[(0,J.jsx)(`button`,{className:`rc-swatch rc-swatch-lg`,"aria-label":`change ${e}’s colour`,title:`${e} — hue ${Math.round(t)}°${a?`, pinned by you`:`, from the ring`}`,onClick:()=>i(s?null:e)}),(0,J.jsxs)(`div`,{className:`rc-gist`,children:[(0,J.jsx)(`div`,{className:`rc-name`,children:e}),(0,J.jsxs)(`div`,{className:`rc-sub`,children:[a?`your colour`:`from the ring`,u.has(e)?` · shared with another repo`:``]})]}),a?(0,J.jsx)(Y,{className:`rc-act`,title:`use the ring’s colour for this repo again`,onClick:()=>m(e,null),children:(0,J.jsx)(Ds,{size:14})}):null,(0,J.jsx)(Y,{className:`rc-act`,title:`a colour no other repo here is using`,onClick:()=>m(e,o(c,n,e)),children:(0,J.jsx)(So,{size:14})})]}),s?(0,J.jsx)(`div`,{className:`rc-swatches`,children:d.hues.map(n=>(0,J.jsx)(`button`,{className:`rc-swatch${Math.round(n)===Math.round(t)?` on`:``}`,style:d4(n),"aria-label":`hue ${n}`,title:`hue ${n}°`,onClick:()=>{m(e,n),i(null)}},n))}):null]},e)})})]})})}function FCe({repos:e,onClose:t}){let[n,r]=(0,V.useState)(`host`),i=e.filter(e=>e.isPrimary),[a,o]=(0,V.useState)(i[0]?.id??``),[s,c]=(0,V.useState)(`.env`),[l,u]=(0,V.useState)(`env`),[d,f]=(0,V.useState)(`GEMINI_API_KEY`),[p,m]=(0,V.useState)(``),[h,g]=(0,V.useState)(!1),[_,v]=(0,V.useState)(null),y=gh(`secret-targets`,()=>H.secretTargets()),b=y.data??[],x=gh(a,()=>H.envFiles(a),{enabled:n===`repo`&&!!a}),S=x.data??[],C=S.find(e=>e.name===s),w=n===`repo`&&C?.tracked&&!C?.gitignored&&!C?.template,T=b.find(e=>e.id===l),E=n===`host`&&T?.mode===`json`,D=!0;if(E&&p)try{JSON.parse(p)}catch{D=!1}let O=!h&&!!p&&(n===`repo`?!!d.trim():E?D:!!d.trim());async function k(){q(`action:secret.set`),g(!0),v(null);try{let e=n===`host`?E?{scope:`host`,targetId:l,value:p}:{scope:`host`,targetId:l,key:d.trim(),value:p}:{scope:`repo`,repoId:a,file:s,key:d.trim(),value:p},t=await H.setSecret(e);v(t),t.ok&&m(``)}catch(e){v({ok:!1,error:String(e.message||e)})}finally{g(!1)}}return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:`Set secret`,onClose:t}),(0,J.jsx)(yS,{label:`where the secret applies`,options:[{key:`host`,label:`this host`},{key:`repo`,label:`a repo`}],value:n,onChange:r}),(0,J.jsxs)(`div`,{className:`form`,children:[(0,J.jsxs)(Z,{children:[(0,J.jsx)(ss,{size:14,style:{verticalAlign:`-2px`,marginRight:4}}),`Write-only here: this app never shows the value back, only a masked tail. It's stored as plaintext in a gitignored file on the host, so the Claude CLI running there can still read it.`]}),n===`host`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`select`,{className:`search`,value:l,onChange:e=>{u(e.target.value),v(null)},children:b.map(e=>(0,J.jsxs)(`option`,{value:e.id,children:[e.label,` · `,e.mode]},e.id))}),(0,J.jsxs)(Z,{children:[`→ `,T?.path??`~/.config/${I.configDirName}/.env`,T?.hotReload||l===`env`?` · applied live, no restart`:``]}),y.state===`offline`&&(0,J.jsx)(Z,{children:`No connection — the host's write targets could not be listed, so only the built-in one is offered.`}),y.state===`error`&&(0,J.jsxs)(Z,{style:{color:`var(--dead)`},children:[`The host refused to list its write targets: `,y.error]})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(oF,{repos:e,worktreeFilter:!0,value:e.find(e=>e.id===a)?.worktreePath??``,onChange:t=>{let n=e.find(e=>e.worktreePath===t);n&&(o(n.id),v(null))},"aria-label":`repo`}),x.state===`offline`&&(0,J.jsx)(Z,{children:`No connection — this repo's .env files could not be listed, so nothing below says whether one is gitignored.`}),x.state===`error`&&(0,J.jsxs)(Z,{style:{color:`var(--dead)`},children:[`The host refused to list this repo's .env files: `,x.error]}),(0,J.jsxs)(`select`,{className:`search`,value:s,onChange:e=>c(e.target.value),children:[!S.some(e=>e.name===`.env`)&&(0,J.jsx)(`option`,{value:`.env`,children:`.env (new)`}),S.map(e=>(0,J.jsxs)(`option`,{value:e.name,children:[e.name,e.template?` · template`:e.tracked&&!e.gitignored?` ⚠ tracked`:e.gitignored?` ✓ ignored`:``]},e.name))]}),w&&(0,J.jsxs)(Z,{style:{color:`var(--dead)`},children:[s,` is tracked by git — writing a secret there risks committing it. The host will refuse.`]})]}),!E&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`input`,{className:`search`,placeholder:`KEY (e.g. GEMINI_API_KEY)`,value:d,onChange:e=>f(e.target.value),autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,list:`secret-keys`}),(0,J.jsx)(`datalist`,{id:`secret-keys`,children:(0,J.jsx)(`option`,{value:`GEMINI_API_KEY`})})]}),E?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`textarea`,{className:`search`,placeholder:`paste JSON (the whole file content)`,value:p,onChange:e=>m(e.target.value),rows:6,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,style:{fontFamily:`monospace`,resize:`vertical`}}),p&&!D&&(0,J.jsx)(Z,{style:{color:`var(--dead)`},children:`Not valid JSON.`})]}):(0,J.jsx)(`input`,{className:`search`,type:`password`,placeholder:`value (paste it)`,value:p,onChange:e=>m(e.target.value),autoComplete:`off`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1}),(0,J.jsx)(`button`,{className:`send`,onClick:k,disabled:!O,children:h?`Setting…`:`Set secret`}),_&&(0,J.jsx)(Z,{style:{color:_.ok?void 0:`var(--dead)`},children:_.ok?`✓ ${_.key?_.key+` `:``}${_.action} in ${_.file} — ${_.masked}`+(_.addedToGitignore?` · added to .gitignore`:``)+(n===`host`&&(T?.hotReload||l===`env`)?` · live now`:``):`Error: ${_.error}`})]})]})}var ICe=[8,32,128];function f4(e){return e>=100?e.toFixed(0):e.toFixed(1)}function p4(e){return(e/8).toFixed(1)}function LCe({onClose:e}){let[t,n]=(0,V.useState)(32),[r,i]=(0,V.useState)(!0),[a,o]=(0,V.useState)(`idle`),[s,c]=(0,V.useState)(0),[l,u]=(0,V.useState)(null),[d,f]=(0,V.useState)(null),[p,m]=(0,V.useState)(null),[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)(null),y=a!==`idle`&&a!==`done`,b=t*1024*1024;async function x(){q(`action:speedtest.run`),g(null),u(null),f(null),m(null),c(0);try{o(`down`);let e=await H.speedtest.download(b,e=>c(Math.round(e/b*100)));u(e),o(`up`),c(0);let t=await H.speedtest.upload(b);f(t),r&&(o(`debug`),m(await H.speedtest.debug().catch(()=>null))),o(`done`)}catch(e){g(String(e.message||e)),o(`done`)}}async function S(e,t){await Xf(e)&&(v(t),setTimeout(()=>v(e=>e===t?null:e),1500))}let C=p?.clientKind===`tailscale`&&p.route===`derp`;return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ms,{size:18,style:{verticalAlign:`-3px`,marginRight:6}}),`Speed test`]}),onClose:e}),(0,J.jsxs)(`div`,{className:`form`,children:[(0,J.jsx)(Z,{children:`Measures throughput both directions over the address you loaded the app from — so the numbers reflect the real path (Tailscale tunnel or LAN).`}),(0,J.jsx)(`div`,{className:`annot-tools`,children:ICe.map(e=>(0,J.jsxs)(Y,{className:t===e?`active`:``,disabled:y,onClick:()=>n(e),children:[e,` MB`]},e))}),(0,J.jsxs)(Z,{as:`label`,style:{display:`flex`,alignItems:`center`,gap:8},children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:r,disabled:y,onChange:e=>i(e.target.checked)}),`Capture debug info (Tailscale route, DERP relay, host LAN IPs)`]}),(0,J.jsx)(`button`,{className:`send`,onClick:x,disabled:y,children:a===`down`?`Downloading… ${s}%`:a===`up`?`Uploading…`:a===`debug`?`Probing connection…`:y?`Running…`:`Run test`}),h&&(0,J.jsxs)(Z,{style:{color:`var(--dead)`},children:[`Error: `,h]}),(l||d)&&(0,J.jsxs)(`div`,{className:`set-group`,style:{marginTop:4},children:[l&&(0,J.jsxs)(JS,{style:{justifyContent:`space-between`,alignItems:`baseline`},children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(Qa,{size:14,style:{verticalAlign:`-2px`}}),` Download`]}),(0,J.jsxs)(`strong`,{children:[f4(l.mbps),` Mbps `,(0,J.jsxs)(`span`,{style:{opacity:.6,fontWeight:400},children:[`· `,p4(l.mbps),` MB/s`]})]})]}),d&&(0,J.jsxs)(JS,{style:{justifyContent:`space-between`,alignItems:`baseline`},children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(Mc,{size:14,style:{verticalAlign:`-2px`}}),` Upload`]}),(0,J.jsxs)(`strong`,{children:[f4(d.mbps),` Mbps `,(0,J.jsxs)(`span`,{style:{opacity:.6,fontWeight:400},children:[`· `,p4(d.mbps),` MB/s`]})]})]})]}),p&&(0,J.jsxs)(`div`,{className:`set-group`,style:{marginTop:8},children:[(0,J.jsxs)(Z,{style:{display:`flex`,gap:8,alignItems:`flex-start`,color:C?`var(--dead)`:void 0},children:[C?(0,J.jsx)(gs,{size:16,style:{flexShrink:0,marginTop:1}}):(0,J.jsx)(Bc,{size:16,style:{flexShrink:0,marginTop:1}}),(0,J.jsx)(`span`,{children:p.verdict})]}),(0,J.jsxs)(X,{children:[(0,J.jsx)(Dc,{size:12,style:{verticalAlign:`-2px`}}),` phone seen as `,p.clientIp,` (`,p.clientKind,`)`,p.dialedHost&&(0,J.jsxs)(J.Fragment,{children:[` · dialed `,p.dialedHost]}),p.route!==`unknown`&&(0,J.jsxs)(J.Fragment,{children:[` · route `,p.route,p.derpRegion?`(${p.derpRegion})`:``]})]}),p.lanIps.length>0&&(0,J.jsxs)(X,{children:[`Bypass the tunnel on same WiFi:`,p.lanIps.map(e=>{let t=`http://${e}:8770`;return(0,J.jsxs)(Y,{style:{margin:`4px 6px 0 0`},onClick:()=>S(t,e),children:[(0,J.jsx)(_o,{size:12}),` `,t,_===e?` ✓`:``]},e)})]}),p.tailscaleIp&&(0,J.jsxs)(X,{children:[`tailscale IP: `,p.tailscaleIp]}),!p.tailscaleCli&&(0,J.jsxs)(X,{style:{opacity:.7},children:[`No `,(0,J.jsx)(`code`,{children:`tailscale`}),` CLI on the host — route detection skipped.`]}),(p.raw.ping||p.raw.netcheck||p.raw.status)&&(0,J.jsxs)(`details`,{style:{marginTop:6},children:[(0,J.jsx)(Z,{as:`summary`,style:{cursor:`pointer`},children:`Raw tailscale output`}),p.raw.ping&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(X,{children:`ping`}),(0,J.jsx)(`pre`,{className:`mono`,style:{overflowX:`auto`,fontSize:11},children:p.raw.ping})]}),p.raw.netcheck&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(X,{children:`netcheck`}),(0,J.jsx)(`pre`,{className:`mono`,style:{overflowX:`auto`,fontSize:11},children:p.raw.netcheck})]}),p.raw.status&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(X,{children:`status`}),(0,J.jsx)(`pre`,{className:`mono`,style:{overflowX:`auto`,fontSize:11},children:p.raw.status})]})]})]})]})]})}function RCe(e){let t=0,n=!1;for(let r of e)r.bytes==null?n=!0:t+=r.bytes;return{bytes:n?null:t,partial:n}}function zCe(e){let t=t=>{let n=e.filter(e=>e.kind===t).sort((e,t)=>(t.bytes??-1)-(e.bytes??-1)),{bytes:r,partial:i}=RCe(n);return{kind:t,rows:n,count:n.reduce((e,t)=>e+t.count,0),bytes:r,partial:i}};return{caches:t(`cache`),keep:t(`keep`)}}function BCe(e,t){if(e==null||t==null||!Number.isFinite(t))return null;let n=t-e;return n>0?n:null}function m4(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r<128)t+=1;else if(r<2048)t+=2;else if(r>=55296&&r<=56319&&n+1<e.length){let r=e.charCodeAt(n+1);r>=56320&&r<=57343?(t+=4,n++):t+=3}else t+=3}return t}function h4(e,t,n){let r=e===1?n:`${n}s`;return t==null?`${e} ${r} · size unknown`:`${e} ${r} · ${un(t)}`}function VCe(e){return e.count?e.bytes==null?`Clear ${e.label} · ${e.count}`:`Clear ${e.label} · ${e.count} · ${un(e.bytes)}`:`Nothing in ${e.label}`}function HCe(e){let t=e.bytes==null?`${e.count}`:`${e.count} · ${un(e.bytes)}`;return e.kind===`keep`?`Yes — delete ${t}`:`Yes — clear ${t}`}function UCe(e){let t=e.rows.filter(e=>e.count>0&&!e.cant).length;return t?e.bytes==null?`Clear all ${t} caches`:`Clear all ${t} caches · ${un(e.bytes)}`:`Nothing cached here`}function g4(e){let t=e.bytes==null?`${e.count} entries`:`${e.count} entries · ${un(e.bytes)}`;return e.failed.length?`Cleared ${t}. Still here: ${e.failed.join(`, `)} — the browser refused.`:e.count?`Cleared ${t} from ${e.label}.`:`${e.label} was already empty.`}function WCe(e,t,n){let r=t==null?`This browser won’t say how much it is holding.`:`The browser reports ${un(t)} used${n?` of ${un(n)}`:``}.`,i=BCe(e,t);return e==null?`${r} Part of what is below could not be measured.`:t!=null&&e>t?`${r} The stores below measure ${un(e)} between them — the browser’s figure is an estimate and lags a delete.`:i==null?`${r} ${un(e)} of it is named below.`:`${r} ${un(e)} is named below; the other ${un(i)} is the browser’s own overhead and caches this screen cannot itemise.`}function GCe(e,t){return e?`${h4(e,t,`download`)} sit outside the browser’s figure above — the app holds them as files, so they are not in the number the browser reports.`:null}function _4(e,t=0){if(e==null)return 0;if(typeof e==`string`)return m4(e);if(typeof e==`number`)return 8;if(typeof e==`boolean`)return 4;if(e instanceof Blob)return e.size;if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return e.byteLength;if(t>=6)return 0;if(Array.isArray(e)){let n=0;for(let r of e)n+=_4(r,t+1);return n}if(typeof e==`object`){let n=0;for(let[r,i]of Object.entries(e))n+=m4(r)+_4(i,t+1);return n}return 0}var v4=[{id:`thumbs`,store:`thumbs`,label:`gallery thumbnails`,kind:`cache`,cost:`The grid re-fetches them one request at a time as you scroll; offline it draws blanks until you are back.`},{id:`transcripts`,store:`transcripts`,label:`conversation transcripts`,kind:`cache`,cost:`The reader re-reads each one from the desktop. Offline, a session you have not opened since shows nothing.`},{id:`tooldetail`,store:`tooldetail`,label:`expanded tool calls`,kind:`cache`,cost:`A tool call you had opened folds back up until the desktop is reachable.`},{id:`pty`,store:`pty`,label:`terminal tails`,kind:`cache`,cost:`A cold start with no host paints an empty terminal instead of the last screen it had.`},{id:`gallery`,store:`gallery`,label:`gallery listings`,kind:`cache`,cost:`The gallery opens on a spinner instead of the last list of files it drew.`},{id:`artifacttext`,store:`artifacttext`,label:`documents you opened`,kind:`cache`,cost:`A report you read on the train is fetched again next time — and not readable at all with the tunnel down.`},{id:`tree`,store:`tree`,label:`folder listings`,kind:`cache`,cost:`The file browser asks the desktop again for every folder you walk into.`},{id:`ctxseries`,store:`ctxseries`,label:`context-window history`,kind:`cache`,cost:`The context graph re-reads its series; offline it has no curve to draw.`},{id:`tokenstats`,store:`tokenstats`,label:`token statistics`,kind:`cache`,cost:`One re-read, which is expensive for the DESKTOP to rebuild — the screen shows nothing until it answers.`},{id:`extassets`,store:`extassets`,label:`extension downloads`,kind:`cache`,cost:`An extension's engine fetched from the desktop — the text-in-marks reader is about 8 MB. Re-downloaded when it is switched on again.`,cant:`switch the extension off in Settings › Tools & diagnostics › plugins — its row there then offers to delete the download.`},{id:`screenlog`,store:`screenlog`,label:`terminal scrollback`,kind:`keep`,cost:`The lines that scrolled off the TUI are not on the wire — the desktop cannot send them again. Panning up stops working for these sessions.`},{id:`dictations`,store:`dictations`,label:`recordings not yet read`,kind:`keep`,cost:`Audio the desktop has not transcribed yet. Nobody can re-say a sentence; a clip being sent right now is left alone.`},{id:`keptuploads`,store:`uploads`,label:`photos from failed sends`,kind:`keep`,include:RL,cost:`Pictures held so you can re-attach them after a send died. They exist here and nowhere else.`},{id:`queueduploads`,store:`uploads`,label:`photos waiting to send`,kind:`keep`,include:e=>!RL(e),cost:`The pictures of messages still in the send queue.`,cant:`these belong to messages still queued — remove the message on the queue screen and its photo goes with it.`}];async function KCe(){let[e,...t]=await Promise.all([r4(),...v4.map(e=>Py(e.store,_4,e.include))]),n=v4.map((e,n)=>{let r=t[n];return{id:e.id,label:e.label,kind:e.kind,count:r?.count??0,bytes:r?r.bytes:null,cost:e.cost,cant:e.cant}}),r=qCe(),i=r.savedBytes+r.unsavedBytes-r.nativeBytes;return{rows:n,downloads:r,named:n.some(e=>e.bytes==null)?null:n.reduce((e,t)=>e+(t.bytes??0),0)+Math.max(0,i),estimate:e.usage,quota:e.quota}}function qCe(){let e={savedIds:[],savedBytes:0,unsavedIds:[],unsavedBytes:0,nativeCount:0,nativeBytes:0};for(let t of rO.list()){if(t.state!==`done`||t.evicted)continue;let n=t.received||t.item.size||0;n&&(t.nativePath&&(e.nativeCount++,e.nativeBytes+=n),t.savedAt?(e.savedIds.push(t.item.id),e.savedBytes+=n):(e.unsavedIds.push(t.item.id),e.unsavedBytes+=n))}return e}async function y4(e){switch(e.id){case`thumbs`:return{ok:await iR()};case`screenlog`:return{ok:await lSe()};case`keptuploads`:return{ok:await zL()};case`dictations`:{let e=await poe();return{ok:!0,note:e.kept?`${e.kept} kept — it is being transcribed right now.`:void 0}}case`extassets`:case`queueduploads`:return{ok:!1,note:e.cant};case`transcripts`:case`tooldetail`:case`gallery`:case`artifacttext`:case`tree`:case`ctxseries`:case`tokenstats`:return{ok:await ix(e.id)};case`pty`:return{ok:await Fy(`pty`)};default:return{ok:!1,note:`this screen does not know how to clear that.`}}}async function JCe(e){return rO.dropBytes(e)}function YCe({onClose:e,onToast:t,onOpenSweep:n}){let[r,i]=(0,V.useState)(null),[a,o]=(0,V.useState)(!0),[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(null);async function d(){o(!0);try{i(await KCe())}finally{o(!1)}}(0,V.useEffect)(()=>{d()},[]);async function f(e){c(!0);try{let t=e.bytes,n=await y4(e);u(g4({label:e.label,count:n.ok?e.count:0,bytes:n.ok?t:0,failed:n.ok?[]:[e.label]})+(n.note?` ${n.note}`:``)),await d()}finally{c(!1)}}async function p(e){c(!0);try{let t=e.rows.filter(e=>e.count>0&&!e.cant),n=[],r=0,i=0;for(let e of t)(await y4(e)).ok?(r+=e.count,i+=e.bytes??0):n.push(e.label);u(g4({label:`the caches`,count:r,bytes:i,failed:n})),await d()}finally{c(!1)}}async function m(e,n){c(!0);try{let r=await JCe(e);t(`freed ${un(r.bytes)} — ${r.count} download${r.count===1?``:`s`} ${n}`),u(`Dropped the bytes of ${h4(r.count,r.bytes,`download`)}. The rows are still in Downloads — tap one to fetch it again.`),await d()}finally{c(!1)}}let[h,g]=(0,V.useState)(0),_=gh(`storage.transport.${h}`,()=>H.transportSurvey()),v=gh(`storage.host.${h}`,()=>H.hostStore());async function y(e,t){c(!0);try{let n=await H.hostStoreClear(e.id,t);if(n.error){u(n.error);return}u(Ate(e.label,n)),g(e=>e+1)}catch{u(`The desktop didn’t answer, so nothing here says whether it ran — re-read to see what is still there.`)}finally{c(!1)}}let b=r?zCe(r.rows):null,x=r?.downloads,S=x?GCe(x.nativeCount,x.nativeBytes):null;return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:`Storage on this phone`,onClose:e,children:a&&(0,J.jsx)(Js,{size:13,className:`spin`})}),(0,J.jsx)(Z,{children:r?WCe(r.named,r.estimate,r.quota):`Measuring…`}),S&&(0,J.jsx)(Z,{children:S}),(0,J.jsx)(`div`,{className:`annot-tools`,children:(0,J.jsxs)(Y,{onClick:()=>{d(),g(e=>e+1)},children:[(0,J.jsx)(Ds,{size:14}),` re-measure`]})}),l&&(0,J.jsx)(Z,{children:l}),x&&(0,J.jsxs)(`section`,{className:`set-group`,children:[(0,J.jsx)(`h3`,{className:`set-title`,children:`Downloads`}),(0,J.jsx)(Z,{children:`Finished downloads keep their bytes for a week and then drop them by themselves. Dropping one now keeps its row: fetching it back is a tap.`}),(0,J.jsxs)(Xw,{children:[(0,J.jsx)(`span`,{className:`sweep-path`,children:`already saved out`}),(0,J.jsx)(`span`,{className:`sweep-meta`,children:h4(x.savedIds.length,x.savedBytes,`file`)})]}),x.savedIds.length>0?(0,J.jsxs)(fC,{className:`send`,confirm:`Yes — free ${un(x.savedBytes)}`,disabled:s,onConfirm:()=>void m(x.savedIds,`already saved out`),children:[(0,J.jsx)(ws,{size:14}),` Drop bytes of `,x.savedIds.length,` saved · `,un(x.savedBytes)]}):(0,J.jsx)(Qw,{className:`form-hint`,cants:[{label:`free saved downloads`,reason:`nothing finished here has been saved out to the phone yet.`}]}),(0,J.jsxs)(Xw,{children:[(0,J.jsx)(`span`,{className:`sweep-path`,children:`never saved out`}),(0,J.jsx)(`span`,{className:`sweep-meta`,children:h4(x.unsavedIds.length,x.unsavedBytes,`file`)})]}),x.unsavedIds.length>0?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{children:`These were never saved to the phone. They come back as a tap only while the desktop still has that build — it keeps the newest few of each.`}),(0,J.jsxs)(fC,{className:`send danger`,confirm:`Yes — free ${un(x.unsavedBytes)}`,disabled:s,onConfirm:()=>void m(x.unsavedIds,`not saved out`),children:[(0,J.jsx)(ws,{size:14}),` Drop bytes of `,x.unsavedIds.length,` unsaved · `,un(x.unsavedBytes)]})]}):(0,J.jsx)(Qw,{className:`form-hint`,cants:[{label:`free unsaved downloads`,reason:`every finished download here has been saved out already.`}]})]}),b&&(0,J.jsxs)(`section`,{className:`set-group`,children:[(0,J.jsxs)(`h3`,{className:`set-title`,children:[`Caches — `,h4(b.caches.count,b.caches.bytes,`entry`)]}),(0,J.jsx)(Z,{children:`Everything here can be read from the desktop again. Clearing costs a request each, and leaves these screens blank until the tunnel is back.`}),(0,J.jsx)(b4,{rows:b.caches.rows,busy:s,onClear:f}),b.caches.rows.some(e=>e.count>0&&!e.cant)?(0,J.jsxs)(fC,{className:`send`,confirm:`Yes — clear ${un(b.caches.bytes??0)}`,disabled:s,onConfirm:()=>void p(b.caches),children:[(0,J.jsx)(Ba,{size:14}),` `,UCe({...b.caches,kind:`cache`})]}):(0,J.jsx)(Qw,{className:`form-hint`,cants:[{label:`clear caches`,reason:`they are all empty.`}]})]}),b&&(0,J.jsxs)(`section`,{className:`set-group`,children:[(0,J.jsxs)(`h3`,{className:`set-title`,children:[`Only on this phone — `,h4(b.keep.count,b.keep.bytes,`entry`)]}),(0,J.jsx)(Z,{children:`The desktop cannot send these back. Each one goes on its own, and says what it takes with it.`}),(0,J.jsx)(b4,{rows:b.keep.rows,busy:s,onClear:f})]}),(0,J.jsxs)(`section`,{className:`set-group`,children:[(0,J.jsxs)(`h3`,{className:`set-title`,children:[(0,J.jsx)(Zc,{size:13}),` On the desktop — repos`]}),_.data?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{children:br(_.data)}),(0,J.jsx)($,{res:_,empty:!_.data.repos.length,thing:`No repos on the desktop.`,noun:`survey`}),(0,J.jsx)(`div`,{className:`list`,children:_.data.repos.map(e=>(0,J.jsxs)(`div`,{className:`row sweep-row storage-row`,children:[(0,J.jsxs)(`div`,{className:`storage-row-head`,children:[(0,J.jsx)(`span`,{className:`sweep-path`,children:e.repoName}),(0,J.jsx)(`span`,{className:`sweep-meta`,children:e.branch})]}),(0,J.jsx)(`div`,{className:`annot-tools`,children:[`outbox`,`inbox`].map(t=>{let r=t===`outbox`?e.outbox:e.inbox;return r&&r.count>0?(0,J.jsxs)(Y,{onClick:()=>n(e.repoId,t),children:[t,` · `,or(r)]},t):(0,J.jsxs)(`span`,{className:`sweep-meta`,children:[t,` · `,or(r)]},t)})})]},e.repoId))})]}):(0,J.jsx)($,{res:_,thing:`Couldn’t read the desktop’s repos.`,noun:`survey`})]}),(0,J.jsxs)(`section`,{className:`set-group`,children:[(0,J.jsxs)(`h3`,{className:`set-title`,children:[(0,J.jsx)(Zc,{size:13}),` On the desktop — the app’s own store`]}),v.data?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(Z,{children:[(0,J.jsx)(`span`,{className:`mono`,children:v.data.dir}),` —`,` `,v.data.total==null?`part of it could not be measured.`:`${un(v.data.total)} in all. Most of it is already bounded by whatever writes it.`,` `,`Read `,Tp(v.data.at),`.`]}),(0,J.jsx)(`div`,{className:`list`,children:v.data.rows.map(e=>(0,J.jsxs)(`div`,{className:`row sweep-row storage-row`,children:[(0,J.jsxs)(`div`,{className:`storage-row-head`,children:[(0,J.jsx)(`span`,{className:`sweep-path`,children:e.label}),(0,J.jsx)(`span`,{className:`sweep-meta`,children:h4(e.count,e.bytes,`file`)})]}),(0,J.jsxs)(Z,{children:[xte[e.kind],` — `,e.cost]}),e.cant?(0,J.jsx)(Qw,{className:`form-hint`,cants:[{label:`clear ${e.label}`,reason:e.cant}]}):e.count>0?(0,J.jsxs)(fC,{className:`key`,confirm:`Yes — clear ${h4(e.count,e.bytes,`file`)}`,disabled:s,onConfirm:()=>void y(e,v.data.at),children:[(0,J.jsx)(ws,{size:13}),` `,Wee(e)]}):(0,J.jsx)(Z,{children:`Nothing here.`})]},e.id))}),!Aee(v.data.rows).length&&(0,J.jsx)(Qw,{className:`form-hint`,cants:[{label:`clear anything here`,reason:`the two clearable stores are empty; everything else is a record or in use.`}]})]}):(0,J.jsx)($,{res:v,thing:`Couldn’t read the desktop’s store.`,noun:`report`})]})]})}function b4({rows:e,busy:t,onClear:n}){return(0,J.jsx)(`div`,{className:`list`,children:e.map(e=>(0,J.jsxs)(`div`,{className:`row sweep-row storage-row`,children:[(0,J.jsxs)(`div`,{className:`storage-row-head`,children:[(0,J.jsx)(`span`,{className:`sweep-path`,children:e.label}),(0,J.jsx)(`span`,{className:`sweep-meta`,children:h4(e.count,e.bytes,`entry`)})]}),(0,J.jsx)(Z,{children:e.cost}),e.cant?(0,J.jsx)(Qw,{className:`form-hint`,cants:[{label:`clear ${e.label}`,reason:e.cant}]}):e.count>0?(0,J.jsxs)(fC,{className:e.kind===`keep`?`key danger`:`key`,confirm:HCe(e),disabled:t,onConfirm:()=>n(e),children:[(0,J.jsx)(ws,{size:13}),` `,VCe(e)]}):(0,J.jsx)(Z,{children:`Nothing here.`})]},e.id))})}var x4=16;function XCe({knownIds:e,onClose:t,onToast:n}){let[r,i]=(0,V.useState)(!1),a=gh(`ui-usage`,Nae),o=a.data,s=a.state===`loading`,c=()=>a.reload(),l=o?.features??{},u=Array.from(new Set([...e,...Object.keys(l)])).map(e=>({id:e,count:l[e]?.count??0,last:l[e]?.last??0})).sort((e,t)=>t.count-e.count||e.id.localeCompare(t.id)),d=u.filter(e=>e.count>0),f=u.filter(e=>e.count===0),p=d.reduce((e,t)=>e+t.count,0);function m(){let e=o?.since?new Date(o.since).toISOString().slice(0,10):`?`;Xf([`# ${I.name} feature usage (since ${e}, ${p} interactions)`,``,`## Used`,...d.map(e=>`- \`${e.id}\` — ${e.count}× (last ${e.last?Tp(e.last):`never`})`),``,`## Never used`,...f.map(e=>`- \`${e.id}\``)].join(`
91
+ `)),n(`usage report copied`)}return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:`Feature usage`,onClose:t}),(0,J.jsxs)(`div`,{className:`form`,children:[(0,J.jsxs)(Z,{children:[(0,J.jsx)(qs,{size:12}),` Counted on the host in `,(0,J.jsx)(`code`,{children:Dt(`ui-usage.json`)}),` (all devices, never leaves this machine).`,o?.since?` Since ${new Date(o.since).toLocaleDateString()}.`:``,` `,p,` interactions across `,d.length,` features.`]}),(0,J.jsxs)(Xw,{style:{gap:6},children:[(0,J.jsxs)(Y,{onClick:m,children:[(0,J.jsx)(_o,{size:x4}),` copy report`]}),(0,J.jsx)(Y,{onClick:c,children:`refresh`}),(0,J.jsx)(`div`,{className:`spacer`}),(0,J.jsxs)(Y,{className:r?`danger`:``,onClick:()=>{r?Pae().then(()=>{i(!1),c()}):i(!0)},children:[(0,J.jsx)(tc,{size:x4}),` `,r?`tap to confirm`:`reset`]})]})]}),s&&(0,J.jsx)(Z,{children:`loading…`}),a.state===`offline`&&(0,J.jsx)(Z,{children:`No connection — this is the host-side aggregate across every device, so there is nothing cached to show.`}),a.state===`error`&&(0,J.jsxs)(Z,{style:{color:`var(--dead)`},children:[`The host refused to report usage: `,a.error]}),(0,J.jsxs)(`div`,{className:`list`,children:[d.map(e=>(0,J.jsxs)(Xw,{children:[(0,J.jsx)(Zw,{children:e.id}),(0,J.jsx)(`span`,{className:`muted`,style:{fontSize:12},children:e.last?Tp(e.last):`never`}),(0,J.jsx)(`span`,{style:{fontVariantNumeric:`tabular-nums`},children:e.count})]},e.id)),f.length>0&&(0,J.jsxs)(`div`,{className:`section`,children:[`never used (`,f.length,`)`]}),f.map(e=>(0,J.jsxs)(Xw,{children:[(0,J.jsx)(Zw,{className:`muted`,children:e.id}),(0,J.jsx)(`span`,{className:`muted`,children:`0`})]},e.id))]})]})}var ZCe=`slash.image.swipe.gallery.new.backlog.git.model.text.toolbar.history.secret.setup.speedtest.branches.decisions.settings.notifications.snippets.build.search.features.nethealth.fanout.pad.send.activity.pull.hdrcmd.sentlog.questions.outline.limits.schedule.scrollback.browse.collage.archive.clihealth.assess.capture.localrt.hostedack.sweep.context.queue.tokens.apps.repohealth.storage`.split(`.`),QCe=[`compose.send`,`voice`,`snippet.insert`,`snippet.save`,`session.attach`,`session.read`,`session.new`,`session.resume`,`session.close`,`session.close.all`,`session.close.stale`,`session.close.custom`,`session.rename`,`session.name`,`session.star`,`session.followup`,`session.followup.closed`,`session.pin`,`session.reorder`,`session.order.reset`,`session.filter.wait`,`session.filter.limit`,`session.filter.coding`,`session.filter.done`,`session.filter.exited`,`session.filter.starred`,`session.filter.followup`,`repo.build.header`,`repo.files.header`,`repo.close.all`,`repo.close.stale`,`repo.close.custom`,`repo.collapse`,`repo.collapse.all`,`repo.expand.all`,`repo.new.header`,`repo.new.offline`,`repo.new.project`,`repo.new.bare`,`repo.clone`,`repo.more`,`repo.focus`,`repo.setup`,`repohealth.refresh`,`repohealth.ask`,`repohealth.askall`,`repohealth.scope`,`repohealth.help`,`repo.branch`,`repo.build`,`repo.capture`,`repo.hide`,`repo.inbox`,`repo.git`,`prompt.answer`,`prompt.esc`,`prompt.submit`,`questions.answer`,`questions.esc`,`questions.submit`,`questions.open`,`limit.first`,`limit.auto`,`limit.resumeone`,`limit.resumeall`,`limit.starredonly`,`limit.global`,`limit.session`,`limit.mode`,`backlog.send`,`backlog.fire`,`backlog.refire`,`backlog.done`,`backlog.remove`,`backlog.filter.status`,`backlog.filter.age`,`backlog.filter.clear`,`git.stage`,`git.commit`,`git.pull`,`git.push`,`git.sync`,`git.branch`,`git.diff`,`git.message`,`files.open`,`files.edit`,`files.save`,`files.search`,`files.download`,`gallery.delete`,`gallery.annotate`,`gallery.download`,`gallery.more`,`gallery.fullres`,`gallery.pick`,`gallery.combine`,`image.send`,`image.queue`,`newimg.open`,`newimg.ref`,`swipe.download`,`collage.combine`,`collage.separate`,`collage.layout`,`collage.reorder`,`build.run`,`build.save`,`build.artifact`,`build.setup`,`build.suggest.open`,`build.suggest.use`,`build.one`,`build.ask`,`capture.run`,`capture.watch`,`capture.save`,`capture.artifact`,`capture.filter`,`capture.filter.clear`,`fanout.run`,`fanout.followup`,`fanout.followup.open`,`fanout.preset`,`fanout.presets.edit`,`fanout.presets.save`,`fanout.schedule`,`schedule.new`,`schedule.save`,`schedule.edit`,`schedule.runnow`,`schedule.toggle`,`schedule.remove`,`schedule.skipnext`,`schedule.session`,`schedule.reposession`,`schedule.spent`,`pull.auto`,`pull.enable`,`pull.supersede`,`pull.retry`,`pull.pause`,`pull.resumeall`,`pull.save`,`pull.clearall`,`pull.strip.remove`,`gallery.pull`,`gallery.pullsave`,`search.recent`,`search.history`,`read.toggle`,`read.find`,`read.outline`,`read.fileref`,`outline.find`,`outline.jump`,`scrollback.find`,`scrollback.reachback`,`speedtest.run`,`secret.set`,`setup.fix`,`setup.remedy`,`datasaver`,`upload.scale`,`install.app`,`outbox.retry`,`queue.manage`,`queue.sendall`,`queue.sendone`,`queue.edit`,`queue.remove`,`queue.restore`,`queue.addprompt`,`queue.resend`,`resend.reattach`,`resend.replace`,`send.post`,`send.after`,`send.discard`,`send.addprompt`,`send.attach`,`send.attachfile`,`send.browse`,`activity.sendNow`,`activity.hold`,`activity.retarget`,`activity.edit`,`activity.fix`,`activity.retry`,`activity.answer`,`activity.open`,`activity.runNow`,`activity.cancel`,`activity.toggle`,`activity.download`,`activity.save`,`activity.discard`,`activity.filter.all`,`activity.filter.needsYou`,`activity.filter.failed`,`activity.filter.running`,`activity.filter.waiting`,`activity.filter.scheduled`,`activity.filter.done`,`activity.filter.dismissed`,`activity.select`,`activity.selectall`,`activity.selectnone`,`activity.group`,`activity.sort`,`activity.debris`,`activity.expand`,`activity.bulk.refire`,`activity.bulk.dismiss`,`activity.bulk.restore`,`queue.confirm.send`,`queue.confirm.review`,`queue.confirm.hold`,`queue.retarget`,`queue.hold`,`queue.handtodesktop`,`compose.options`,`queue.rescue`,`cli.on`,`cli.off`,`typing.peek`,`typing.hide`,`pad.new`,`pad.save`,`pad.remove`,`pad.send`,`pad.queue`,`pad.fanout`,`pad.start`,`session.newprompt`,`attach.file`,`attach.paste`,`outbox.auto`,`https.switch`,`hostSetup`,`hosts.switch`,`hosts.remove`,`appUpdate.check`,`appUpdate.download`,`appUpdate.apply`,`appUpdate.auto`,`appUpdate.revert`,`hdrcmd.send`,`hdrcmd.manage`,`hdrcmd.save`,`uiscale.text`,`uiscale.icon`,`uiscale.term`,`uiscale.reader`,`fullscreen.on`,`fullscreen.off`,`hint.proceed`,`hints.explain`,...[`run`,`apply`,`clear`,`plan`,`discard`,`merge`,`leave`,`open`,`accept.new`].map(e=>`assess.${e}`),...zt.flatMap(e=>[`assess.bulk.${e}`,`assess.strip.${e}`,`assess.accept.${e}`]),`backlog.assess`];function $Ce(e){return[...e.map(e=>`toolbar:${e}`),...ZCe.map(e=>`overlay:${e}`),...QCe.map(e=>`action:${e}`)]}function ewe(e){let t=new Set;for(let n of e)n.claudeSessionId&&t.add(n.claudeSessionId),n.backendSessionId&&t.add(n.backendSessionId);return t}function twe(e,t){return e.find(e=>e.claudeSessionId===t||e.backendSessionId===t)}function nwe(e){let t=[{id:`claude`,label:e?.find(e=>e.id===`claude`)?.label||`Claude Code`}];for(let n of e??[])n.id!==`claude`&&n.kind!==`shell`&&n.id!==`shell`&&n.caps?.conversations===!0&&t.push({id:n.id,label:n.label||n.id});return t}function rwe(e){return`Every conversation here is one ${e} wrote; resuming one starts ${e}. Reading one without starting it, forking and bookmarks are not offered for ${e} yet.`}function iwe(e,t){return e??t[0]??``}var S4=W(void 0),C4=W(void 0);function awe(){let e=Dh();return(0,J.jsx)(LCe,{onClose:()=>e.nav.close(`speedtest`)})}function owe(){let e=Dh();return(0,J.jsx)(FCe,{repos:e.world.repos,onClose:()=>e.nav.close(`secret`)})}function swe(){let e=Dh();return(0,J.jsx)(PCe,{repos:e.world.repos,onClose:()=>e.nav.close(`repocolor`)})}function cwe(){let e=Dh(),t=(0,V.useMemo)(()=>$Ce(RO().map(e=>e.id)),[]);return(0,J.jsx)(XCe,{knownIds:t,onClose:()=>e.nav.close(`features`),onToast:e.say.toast})}function lwe(){let e=Dh();return(0,J.jsx)(YCe,{onClose:()=>e.nav.close(`storage`),onToast:e.say.toast,onOpenSweep:(t,n)=>{e.say.track(`overlay:sweep`),e.files.openSweep(t,n,`storage`)}})}function uwe(){let e=Dh(),t=G(C4);return(0,J.jsx)(yCe,{focus:t,onClose:()=>e.nav.close(`localrt`),onOpenSession:t=>{let n=e.world.sessions.find(e=>e.id===t);n?(e.nav.close(`localrt`),e.nav.attach(n)):e.say.toast(`that session is no longer open`)}})}function dwe(){let e=Dh(),t=G(S4),n=Oh();return(0,J.jsx)(NCe,{onClose:()=>e.nav.close(`nethealth`),onToast:e.say.toast,focus:t,notDelivered:n.filter(e=>e.status===`failed`).length,onOpenStorage:()=>{e.say.track(`overlay:storage`),e.nav.open(`storage`)},onOpenActivity:()=>{e.say.track(`action:queue.manage`);let t=n.filter(e=>e.status===`failed`);e.nav.openActivity(t.length?{entries:t,label:`the messages that were not delivered`}:void 0)}})}function fwe(){let e=Dh(),{sessions:t,activeRepo:n,visibleRepos:r,backends:i,launch:a}=e.world,o=(0,V.useMemo)(()=>ewe(t),[t]),s=iwe(n?.id??null,r.map(e=>e.id)),c=()=>e.nav.close(`archive`);if(!s)return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:`Archive`,onClose:c}),(0,J.jsx)($,{children:`No repo in context — open a session first.`})]});let l=e.launch.wire({...a,backend:void 0}),u=t=>t===`claude`?l:e.launch.wire(a.backend===t?{...a}:{...a,backend:t,model:void 0,effort:void 0,permissionMode:void 0}),d=nwe(i).map(e=>e.id===`claude`?{...e,...AC(i)?{note:`Every conversation here is one ${e.label} wrote, so resuming or forking one starts ${e.label} — not whichever backend new sessions currently default to.`}:{}}:{...e,note:rwe(e.label)});return(0,J.jsx)(nCe,{repos:r,initialRepoId:s,liveIds:o,archiveBackends:d,onResume:(t,n,r,i)=>{c(),e.launch.openCwd(t,n,!0,`continue`,u(i),r)},onFork:(t,n,r)=>{c(),e.launch.openCwd(t,n,!0,`fork`,l,r)},onOpenLive:n=>{let r=twe(t,n);r&&e.nav.attach(r)},showToast:e.say.toast,onClose:c})}function pwe(e){let t=U();t.say.track(`overlay:nethealth`),S4.set(e),t.nav.open(`nethealth`)}function mwe(e){let t=U();t.say.track(`overlay:localrt`),C4.set(e),t.nav.open(`localrt`)}function hwe(){let e=e=>pwe(e.detail?.focus),t=e=>mwe(e.detail?.focus);return window.addEventListener(`app:open-nethealth`,e),window.addEventListener(`app:open-localrt`,t),()=>{window.removeEventListener(`app:open-nethealth`,e),window.removeEventListener(`app:open-localrt`,t)}}var gwe={id:`tools`,sheets:[{id:`speedtest`,persisted:!1,render:()=>(0,V.createElement)(awe)},{id:`secret`,persisted:!1,render:()=>(0,V.createElement)(owe)},{id:`features`,persisted:!1,render:()=>(0,V.createElement)(cwe)},{id:`storage`,persisted:!0,render:()=>(0,V.createElement)(lwe)},{id:`nethealth`,persisted:!1,render:()=>(0,V.createElement)(dwe),onLeave:()=>S4.set(void 0)},{id:`localrt`,persisted:!1,render:()=>(0,V.createElement)(uwe),onLeave:()=>C4.set(void 0)},{id:`repocolor`,persisted:!0,render:()=>(0,V.createElement)(swe)},{id:`archive`,persisted:!0,render:()=>(0,V.createElement)(fwe)}],boot:()=>hwe()};function _we({l:e,windowTok:t,tok:n}){let r=Zee(e);if(r.count<=0&&r.unmeasured<=0)return null;let i=Wt(r),a=vee(r)??cr(r),o=Ste(r),c=fee(r),l=bte(r,n,t),u=nte(r),d=(e,t)=>t.count>0&&(0,J.jsxs)(`div`,{className:`row ctx-row ctx-val`,children:[(0,J.jsx)(Zw,{children:Fr(e,t.count)}),(0,J.jsx)(`span`,{className:`row-meta`,children:yte(t).map(e=>(0,J.jsx)(Q,{children:e},e))})]},e);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`ctx-summary`,children:`What compacting saved`}),i&&(0,J.jsx)(`div`,{className:`empty ctx-note`,children:i}),d(`manual`,e.manual),d(`auto`,e.auto),a&&(0,J.jsxs)(`div`,{className:`empty ctx-note`,children:[a,o?` ${o}`:``]}),l&&(0,J.jsx)(`div`,{className:`empty ctx-note`,children:l}),c&&(0,J.jsx)(`div`,{className:`empty ctx-note`,children:c}),(r.savedTok>0||r.rebuildTok>0)&&(0,J.jsxs)(`details`,{className:`hint-more ctx-method`,children:[(0,J.jsx)(`summary`,{children:`how these two figures were arrived at`}),(0,J.jsx)(`p`,{children:s()})]}),u&&(0,J.jsx)(`div`,{className:`empty ctx-note`,children:u})]})}function vwe({cost:e,onFresh:t,onCompact:n,noDoors:r}){return(0,J.jsxs)(`div`,{className:`ctx-cost ctx-cost-${e.level}`,children:[(0,J.jsxs)(`div`,{className:`ctx-cost-head`,children:[(0,J.jsx)(nl,{size:14}),(0,J.jsx)(`span`,{children:e.chip?`${e.chip} a fresh session`:`about a fresh session`})]}),(0,J.jsx)(`div`,{className:`ctx-cost-note`,children:e.note}),e.advice&&(0,J.jsx)(`div`,{className:`ctx-cost-note`,children:e.advice}),e.advice&&!r&&t&&(0,J.jsx)(`div`,{className:`sheet-actions`,children:(0,J.jsxs)(Y,{onClick:t,children:[(0,J.jsx)(Fo,{size:14}),` new session in this repo`]})}),e.advice&&!r&&!t&&(0,J.jsx)(Qw,{cants:[{label:`a new session from here`,reason:`this session's directory is not one of this desktop's repos, so there is nowhere to start one`}]}),(0,J.jsxs)(`details`,{className:`hint-more ctx-method ctx-cost-more`,children:[(0,J.jsx)(`summary`,{children:`why the next turn costs this`}),(0,J.jsxs)(`p`,{children:[`Every turn re-sends the whole conversation, so the next one is priced by what is already here, not by what you are about to ask.`,e.advice&&!r&&n&&Ti(!0)?` ${Ti(!0)}`:``]})]})]})}var w4=27e5;function ywe(e,t,n,r,i){let a=[...new Set([r,...e,i])].filter(e=>e>=r&&e<=i).sort((e,t)=>e-t),o=i-r,s=()=>({t0:r,t1:i,px:e=>t+(e-r)/(o||1)*n,tx:e=>r+(e-t)/(n||1)*(o||1),breaks:[]});if(o<=0||a.length<2)return s();let c=a.slice(0,-1).map((e,t)=>({from:e,to:a[t+1]})).filter(e=>e.to-e.from>w4).sort((e,t)=>t.to-t.from-(e.to-e.from)).slice(0,8).sort((e,t)=>e.from-t.from);if(!c.length)return s();let l=Math.min(18,n/(c.length*3||1)),u=o-c.reduce((e,t)=>e+(t.to-t.from),0),d=n-c.length*l;if(u<=0||d<=0)return s();let f=[],p=t,m=r;for(let e of c){if(e.from>m){let t=(e.from-m)/u*d;f.push({t0:m,t1:e.from,x0:p,w:t,dead:!1}),p+=t}f.push({t0:e.from,t1:e.to,x0:p,w:l,dead:!0}),p+=l,m=e.to}return i>m&&f.push({t0:m,t1:i,x0:p,w:t+n-p,dead:!1}),{t0:r,t1:i,px:e=>{if(e<=r)return t;if(e>=i)return t+n;for(let t of f)if(e<=t.t1)return t.x0+(t.t1>t.t0?(e-t.t0)/(t.t1-t.t0)*t.w:0);return t+n},tx:e=>{if(e<=t)return r;if(e>=t+n)return i;for(let t of f)if(e<=t.x0+t.w)return t.t0+(t.w>0?(e-t.x0)/t.w*(t.t1-t.t0):0);return i},breaks:f.filter(e=>e.dead).map(e=>({x:e.x0,w:e.w,from:e.t0,to:e.t1}))}}function bwe(e){return(e??[]).flatMap(e=>(e.ctx??[]).map(([e])=>e))}function T4(e){let{width:t,height:n,pad:r,samples:i,refs:a,events:o,windowTok:s}=e,c=bwe(e.agents),{w:l,h:u}=wE(t,n,r),d=[...i.map(e=>e.t),...o.map(e=>e.t),...o.flatMap(e=>e.resetAt==null?[]:[e.resetAt]),...c],f=d.length?Math.min(...d):0,p=d.length?Math.max(...d):1;p<=f&&(f-=3e4,p+=3e4);let m=e.value??O4,h=i.reduce((e,t)=>m(t)>e?m(t):e,0),g=e.value?h:Math.max(h,...(e.agents??[]).map(e=>e.peakTok??0)),{top:_,ticks:v}=s?CE(s,Math.max(g,...a)):SE(Math.max(g,...a,1),e.yWant),y=ywe([...i.map(e=>e.t),...c].sort((e,t)=>e-t),r.left,l,f,p);return{x:r.left,y:r.top,w:l,h:u,t0:f,t1:p,yMax:_,yTicks:v,windowTok:s,px:y.px,tx:y.tx,breaks:y.breaks,py:TE(r.top,u,_)}}function E4(e){let t=Math.round(e/6e4);if(t<90)return`${t} min`;let n=t/60;return n<36?`${Math.round(n*10)/10} h`:`${Math.round(n/24*10)/10} d`}function D4(e,t){let n=si(t,e.windowTok);return n==null?LE(t):`${Math.round(n)}%`}function xwe(e,t){let n=si(e,t);return n==null?LE(e):`${Math.round(n)}% · ${LE(e)}`}var O4=e=>e.tok,k4=e=>e.used??0;function Swe(e){return e.some(e=>e.used!=null&&e.used>0)}function Cwe(e,t,n,r){if(!Swe(e))return null;let i=e.reduce((e,t)=>t.used!=null&&t.used>e?t.used:e,0),a=t!=null&&t>=i?t:null,o=a!=null&&n!=null&&n>0?n:null,s=r?.total!=null&&r.total>0?r.total:null;return{end:i,total:a,agents:o,top:Math.max(i,a??0),costUsd:s,agentCostUsd:s!=null&&r?.agents!=null&&r.agents>0?r.agents:null,unpricedTok:r?.unpricedTok!=null&&r.unpricedTok>0?r.unpricedTok:null}}function wwe(e,t){let n=e.total==null?e.end:e.total,r=e.costUsd==null?`${LE(n)} spent`:`${_t(e.costUsd)} at list prices · ${LE(n)} spent`,i=[t?`${r} (at least)`:`${r} so far`];return e.agents!=null&&i.push(e.agentCostUsd==null?`${LE(e.agents)} of it in subagents`:`${_t(e.agentCostUsd)} / ${LE(e.agents)} of it in subagents`),i.join(` · `)}function Twe(e,t,n=!1){let r=[];e.costUsd!=null&&e.unpricedTok!=null&&r.push(`${LE(e.unpricedTok)} of these tokens ran on a model with no published rate and are in neither dollar figure.`),t&&r.push(`This log is longer than the host reads in one go, so the curve starts part-way up.`);let i=[`Every request's input, cache reads and cache writes plus what it wrote back, added up as the conversation went. It only rises — a compaction resets the window, never the bill.`];return e.costUsd!=null&&i.push(`The ${_t(e.costUsd)} is what the API would have charged for those tokens at published rates, priced per request on the model that ran it — not what anybody paid, and nothing to do with what a subscription costs.`),e.agents!=null&&i.push(n?`The grey band on top is the ${LE(e.agents)} its subagents spent, placed at the times their own logs record, so its top edge ends on the dashed whole-session total.`:`The dashed line is the session's whole total; the gap between it and the curve is the ${LE(e.agents)} its subagents spent, which this host did not send as a series over time.`),i.push(`A floor: an agent log this desktop never saw is one nothing here can add.`),{lead:r.length?r.join(` `):null,more:i.join(` `)}}function Ewe(e,t){if(!e)return null;let n=t&&ui(t)>0?t:null,r=Le(Le(Vn(),e),n??{});return ui(r)<=0?null:{all:r,main:e,agents:n}}function A4(e){let t=ot(e.all);return t==null?null:`What those tokens were · ${Math.round(t)}% of everything sent in came out of the cache`}function Dwe(e,t){let n=[];return e.agents&&n.push(`Subagents are IN this bar: ${LE(ui(e.agents))} of it.`),t&&n.push(`A floor: this log is longer than the host reads in one go, so every kind here starts part-way up.`),{lead:n.length?n.join(` `):null,more:[`The same four kinds, counted the same way, as the all-sessions token screen — this conversation is a slice of that total, not a second opinion about it.`,`Turns here are REQUESTS, not prompts — a turn that ran thirteen tools sent fourteen of them, which is the denominator the all-sessions screen uses too.`].join(` `)}}function Owe(e,t,n){if(!n?.length||!t.length)return{area:``,top:``};let r=DE,i=e=>{if(e<t[0].t)return 0;let n=t[t.length-1];if(e>=n.t)return k4(n);let r=0;for(;r<t.length-1&&t[r+1].t<=e;)r++;let i=t[r],a=t[r+1];return a.t===i.t?k4(a):k4(i)+(k4(a)-k4(i))*(e-i.t)/(a.t-i.t)},a=[...new Set([...t.map(e=>e.t).filter(e=>e>n[0][0]),...n.map(([e])=>e)])].sort((e,t)=>e-t),o=[],s=[],c=0,l=0;for(let t of a){let a=i(t),u=r(e.px(t)),d=l;for(;c<n.length&&n[c][0]<=t;)l=n[c++][1];l!==d&&o.push(`${u},${r(e.py(a+d))}`),o.push(`${u},${r(e.py(a+l))}`),s.unshift(`${u},${r(e.py(a))}`)}return o.length<2?{area:``,top:``}:{area:AE(o,s),top:`M${o.join(`L`)}`}}function j4(e,t,n=O4){return OE(t,t=>e.px(t.t),t=>e.py(n(t)))}function M4(e,t,n=O4){let r=j4(e,t,n);return r?kE(r,DE(e.px(t[0].t)),DE(e.px(t[t.length-1].t)),DE(e.py(0))):``}function N4(e,t,n){if(!t.length)return n.map(e=>({...e,d:``,total:0}));let r=DE,i=t.length>1&&n.length>0&&n.every(e=>e.perRequest),a=e=>n.reduce((t,n)=>t+n.at(e),0);return n.map((o,s)=>{let c=[],l=[],u=0;t.forEach((d,f)=>{let p=0;for(let e=0;e<s;e++)p+=n[e].at(d);let m=o.at(d);u+=m;let h=r(e.px(d.t));c.push(`${h},${r(e.py(p+m))}`),l.unshift(`${h},${r(e.py(p))}`);let g=t[f+1];if(i&&g){let t=a(d),n=t>0?a(g)/t:0,i=r(e.px(g.t));c.push(`${i},${r(e.py((p+m)*n))}`),l.unshift(`${i},${r(e.py(p*n))}`)}});let d=t.length>1?AE(c,l):``;return{...o,d,total:u}})}function P4(e,t,n){return e.some(e=>e[t])?ge.filter(e=>!n||n(e.id)).map(e=>({key:e.id,name:e.name,slot:e.slot,at:n=>{let r=n[t];return r?$e(r)[e.id]:0},perRequest:t===`kinds`})):null}function kwe(e,t,n){return EE(t,e.tx(n),e=>e.t)}function Awe(e,t){if(!e?.length)return null;let n=qE(e),r=e.map((e,t)=>({id:e,idx:t,slot:n.get(e)})).filter(t=>t.slot!=null&&e.indexOf(t.id)===t.idx).sort((e,t)=>GE(e.slot,t.slot)),i=new Map(r.map(e=>[e.idx,e.slot])),a=e.length-r.length;return{named:r,rest:a>0||t?{slot:4,name:a>0?`${a} more`:`unattributed`}:null,slotOf:e=>(e==null?void 0:i.get(e))??4}}function F4(e){return(nt(e)??e).replace(/^claude-/,``)}var I4=3,jwe=2;function Mwe(e,t,n){let r=t.reduce((e,t)=>!e||t.tok>e.tok?t:e,null),i=[],a=[];for(let o of[...t].sort((e,t)=>e.at-t.at||e.endAt-t.endAt)){let t=Math.max(e.x,Math.min(e.x+e.w-I4,e.px(o.at))),s=o.running?e.x+e.w:Math.min(e.x+e.w,Math.max(t+I4,e.px(Math.max(o.at,o.endAt)))),c=i.findIndex(e=>e+jwe<=t);c<0?(c=i.length,i.push(s)):i[c]=s,a.push({run:o,x:t,w:s-t,lane:c,slot:n?n.slotOf(o.model):0,dearest:o===r,open:!!o.running})}return{bars:a,lanes:i.length}}function Nwe(e){let t=e<=8?13:Math.max(5,Math.floor(104/e));return{laneH:t,barH:Math.max(3,t-3),plotH:Math.max(1,e)*t}}function Pwe(e,t,n,r,i){if(!e.length)return null;let a=Math.floor((i-n)/t),o=e=>r<e.x?e.x-r:r>e.x+e.w?r-(e.x+e.w):0,s=e.some(e=>e.lane===a)?e.filter(e=>e.lane===a):e;return s.reduce((e,t)=>o(t)<o(e)?t:e,s[0])}function Fwe(e){let t=e.flatMap(e=>[[e.at,1],[e.running?1/0:Math.max(e.at,e.endAt),-1]]).sort((e,t)=>e[0]-t[0]||e[1]-t[1]),n=0,r=0;for(let[,e]of t)n+=e,n>r&&(r=n);return r}function Iwe(e,t,n){let r=t&&e.model!=null?t[e.model]:null;return[e.type??`agent`,r?F4(r):null,e.running?`started ${zE(e.at,n)} · still running, last wrote ${zE(e.endAt,n)}`:`${zE(e.at,n)}–${zE(e.endAt,n)} (${E4(Math.max(0,e.endAt-e.at))})`,`${LE(e.tok)} spent`,e.peakTok?`window peaked at ${LE(e.peakTok)}`:null,e.costUsd==null?null:_t(e.costUsd)].filter(Boolean).join(` · `)}function Lwe(e,t){if(!e.length)return`No subagents — every turn here ran in this conversation.`;let n=e.filter(e=>!e.running&&e.endAt>e.at),r=e.reduce((e,t)=>t.tok>e.tok?t:e,e[0]),i=[`${e.length} subagent${e.length>1?`s`:``}`],a=e.filter(e=>e.running).length;a&&i.push(`${a===e.length&&a>1?`all`:a} still running (fading out at the right)`);let o=Fwe(e);if(o>1&&i.push(`up to ${o} at once`),n.length){let e=n.map(e=>e.endAt-e.at).sort((e,t)=>e-t)[Math.floor(n.length/2)];i.push(`median ${E4(e)} each`)}let s=t&&r.model!=null?t[r.model]:null;return i.push(`dearest ${LE(r.tok)}${s?` on ${F4(s)}`:``}${e.length>1?` (outlined)`:``}`),i.join(` · `)}function Rwe(e,t){if(t==null)return null;let n=t-e.reduce((e,t)=>e+t.tok,0);return n>0?`${LE(n)} of the subagents' tokens are in logs with no timestamp: in every total here, and on no chart.`:null}function zwe(e,t){let n=DE;return t.filter(e=>(e.ctx?.length??0)>0).map(t=>({id:t.id,d:t.ctx.length===1?`M${n(e.px(t.ctx[0][0])-1)},${n(e.py(t.ctx[0][1]))}h2`:`M${t.ctx.map(([t,r])=>`${n(e.px(t))},${n(e.py(r))}`).join(`L`)}`}))}function Bwe(e){let t=Math.max(0,...(e??[]).map(e=>e.peakTok??0));return t>0?t:null}function Vwe(e,t,n){let r=e.pts;if(!r.length)return null;let i=e.autoCompactTok??null,a=e.autoCompactSetTok?Math.max(e.autoCompactSetTok,e.peak,...r):e.windowTok?CE(e.windowTok,Math.max(e.peak,i??0)).top:Math.max(e.peak,i??0,...r,1),o=e=>r.length===1?t:e/(r.length-1)*t,s=e=>n-Math.max(0,Math.min(e,a))/a*n,c=OE(r,(e,t)=>o(t),e=>s(e));return{line:c,area:kE(c,`0`,DE(o(r.length-1)),n),endX:o(r.length-1),endY:s(r[r.length-1]),ticks:e.marks.map(e=>({x:e.at*t,kind:e.kind})),refY:i==null?null:s(i),...Hwe(e.agentEnv,r.length,o,s,n)}}function Hwe(e,t,n,r,i){if(!e||e.length!==t||!e.some(e=>e>0))return{agentArea:null,agentPeak:null};let a=e.map((e,t)=>`L${n(t).toFixed(1)},${r(e).toFixed(1)}`).join(``);return{agentArea:`M${n(0).toFixed(1)},${i}${a}L${n(t-1).toFixed(1)},${i}Z`,agentPeak:Math.max(...e)}}function L4(e,t,n){let r=e.usedPts;if(!r||!r.length)return null;let i=r[r.length-1];if(!(i>0))return null;let a=e.usageTok!=null&&e.usageTok>=i?e.usageTok:null,o=a!=null&&e.agentTok!=null&&e.agentTok>0?a:null,s=e.agentUsedPts,c=o!=null&&s&&s.length===r.length&&s.every(e=>Number.isFinite(e)&&e>=0)?r.map((e,t)=>e+s[t]):null,l=c&&c[c.length-1]<=o*1.001?c:null,u=Math.max(i,o??0,1),d=e=>r.length===1?t:e/(r.length-1)*t,f=e=>n-.5-Math.max(0,Math.min(e,u))/u*(n-1),p=OE(r,(e,t)=>d(t),e=>f(e));return{line:p,area:kE(p,`0`,DE(d(r.length-1)),n),endX:d(r.length-1),endY:f(i),totalY:o!=null&&!l?f(o):null,agentBand:l?Uwe(r,l,d,f):null,top:u,end:i}}function Uwe(e,t,n,r){let i=OE(t,(e,t)=>n(t),e=>r(e));return{area:`${i}${e.map((e,t)=>[n(t),r(e)]).reverse().map(([e,t])=>`L${DE(e)},${DE(t)}`).join(``)}Z`,top:i}}function R4(e,t){let n=e.agentTok!=null&&e.agentTok>0?e.agentTok:null;return[`spent: ${LE(t.end)} in this conversation so far`,n==null?null:`${LE(n)} more in its subagents — ${t.agentBand?`the grey band stacked on top`:`the dashed line`}`,e.costUsd==null?null:qi(e.costUsd,e.agentCostUsd??null,e.unpricedTok??null),`this curve tops out at ${LE(t.top)} and is scaled to this session, not to the others`].filter(Boolean).join(` · `)}function Wwe(e){return e.kind===`compact`?{kind:`compact`,text:(e.trigger===`auto`?`Auto-compacted`:e.trigger===`manual`?`Compacted (/compact)`:`Compacted`)+(e.preTok&&e.postTok?` · ${LE(e.preTok)} → ${LE(e.postTok)}`:``)}:e.kind===`rebuild`?{kind:`rebuild`,text:`Cache expired — re-wrote ${e.wroteTok?LE(e.wroteTok):`the window`}${e.gapMs?` after ${E4(e.gapMs)} quiet`:``}`}:{kind:`limit`,text:(e.weekly?`Weekly usage limit`:`Usage limit`)+(e.resetAt==null?``:` · back at ${zE(e.resetAt,0)}`)}}function Gwe(e,t,n,r){if(t==null||!(t>0))return`This model’s context window is not known here, so the axis is in tokens and is NOT the shared 0–100% scale — this graph cannot be compared with another session’s.`;let i=LE(t);switch(e){case`measured`:return`100% is ${i} — the window ${n??`this model`} has been SEEN to hold, so it is the same scale as every other session’s graph.`;case`screen`:return`100% is the ${i} window the CLI printed on screen.`;case`source`:return`100% is ${i}, the window ${r??`this backend`} states${n?` for ${n}`:``} in this session.`;case`config`:return`100% is ${i}, as ${r??`this backend`}’s configuration states it${n?` for ${n}`:``} — a setting this app read, not something anybody watched happen. A model running locally may be holding less than that, and nothing here would show it.`;case`model`:return`100% is ${i}, assumed from the model id${n?` (${n})`:``} — nothing here has held more than that yet, so if it is really a larger window this axis will correct itself the first time a conversation goes past.`;default:return`This model’s context window is not known here, so the axis is in tokens and is NOT the shared 0–100% scale — this graph cannot be compared with another session’s.`}}function Kwe(e,t,n,r){if(!e.length)return null;let i=e[e.length-1],a=e.reduce((e,t)=>t.tok>e?t.tok:e,0),o=t.filter(e=>e.kind===`compact`).length,s=t.filter(e=>e.kind===`limit`).length,c=si(i.tok,n),l=si(a,n),u=[c==null?`${LE(i.tok)} now`:`${Math.round(c)}% of ${LE(n)}`,l==null?`peak ${LE(a)}`:`peak ${Math.round(l)}%`],d=Bwe(r);return d!=null&&u.push(`an agent held ${LE(d)}`),o&&u.push(`${o} compaction${o>1?`s`:``}`),s&&u.push(`${s} usage limit${s>1?`s`:``}`),u.join(` · `)}var qwe={env:`the daemon's CLAUDE_CODE_AUTO_COMPACT_WINDOW`,local:`.claude/settings.local.json`,project:`.claude/settings.json`,user:`~/.claude/settings.json`,unset:``};function Jwe(e){return`auto-compact set ${yi(e)}`}function Ywe(e){if(e.source===`unset`)return`No autoCompactWindow is set for this repo, so the CLI compacts near the model's own window — no setting line is drawn.`;let t=qwe[e.source];return e.tokens==null?/^auto$/i.test(e.raw?.trim()??``)?`autoCompactWindow is "auto" in ${t}, so the CLI compacts near the model's own window — no setting line is drawn.`:`autoCompactWindow in ${t} reads ${JSON.stringify(e.raw??``)}, which is not a size — no setting line is drawn.`:`The dotted line is autoCompactWindow as ${t} sets it now (${yi(e.tokens)}) — the setting today, not necessarily what this conversation ran under.`}var z4=`var(--ctx-series)`,B4=`var(--ctx-compact)`,V4=`var(--ctx-limit)`,Xwe={top:10,right:10,bottom:20,left:40},H4={top:12,right:10,bottom:20,left:40};function Zwe({spark:e,width:t=76,height:n=20,value:r=!1}){let i=U4((0,V.useId)()),a=Vwe(e,t,n);if(!a)return null;let o=e.pts[e.pts.length-1],s=si(o,e.windowTok),c=e.marks.filter(e=>e.kind===`compact`).length,l=e.marks.filter(e=>e.kind===`limit`).length,u=Di(e.costUsd)??Ni(e.usageTok),d=[s==null?`context: ${LE(o)} now, peak ${LE(e.peak)} (window unknown — this row's scale is its own)`:`context: ${Math.round(s)}% of ${LE(e.windowTok)}, peak ${LE(e.peak)}`,e.usageTok!=null&&e.usageTok>0?nee(e.usageTok,e.agentTok??null):null,e.costUsd==null?null:qi(e.costUsd,e.agentCostUsd??null,e.unpricedTok??null),a.agentPeak==null?null:`agents peaked at ${LE(a.agentPeak)}`,e.autoCompactTok==null?null:`compacts at ${LE(e.autoCompactTok)}`,e.autoCompactSetTok?`curve tops out at the auto-compact setting, ${LE(e.autoCompactSetTok)}`:null,c?`${c} compaction${c>1?`s`:``}`:null,l?`${l} usage limit${l>1?`s`:``}`:null].filter(Boolean).join(` · `),f=(0,J.jsxs)(`svg`,{className:`ctx-spark`,width:t,height:n,viewBox:`0 0 ${t} ${n}`,role:`img`,"aria-label":d,children:[(0,J.jsx)(`title`,{children:d}),(0,J.jsx)(`defs`,{children:(0,J.jsx)(W4,{id:i})}),(0,J.jsx)(`line`,{x1:0,x2:t,y1:n-.5,y2:n-.5,stroke:`currentColor`,strokeOpacity:.16,strokeWidth:1}),a.refY!=null&&(0,J.jsx)(`line`,{x1:0,x2:t,y1:a.refY,y2:a.refY,stroke:`currentColor`,strokeOpacity:.35,strokeWidth:1,strokeDasharray:`2 3`}),a.agentArea&&(0,J.jsx)(`path`,{d:a.agentArea,fill:`currentColor`,fillOpacity:.13}),(0,J.jsx)(`path`,{d:a.area,fill:`url(#${i})`}),(0,J.jsx)(`path`,{d:a.line,fill:`none`,stroke:z4,strokeWidth:1.5,strokeLinejoin:`round`,strokeLinecap:`round`}),a.ticks.map((e,t)=>(0,J.jsx)(`line`,{x1:e.x,x2:e.x,y1:1,y2:n-1.5,strokeLinecap:`round`,stroke:e.kind===`compact`?B4:V4,strokeWidth:1.25,strokeOpacity:.7},t)),(0,J.jsx)(`circle`,{cx:a.endX,cy:a.endY,r:2.6,fill:z4,stroke:`var(--panel)`,strokeWidth:2})]});return r?(0,J.jsxs)(`span`,{className:`ctx-spark-pair`,title:d,children:[f,(0,J.jsx)(`span`,{className:`ctx-spark-val`,children:RE(o)}),u&&!L4(e,t,n)&&(0,J.jsxs)(`span`,{className:`ctx-spark-use`,children:[(0,J.jsx)(ao,{size:10}),` `,u]})]}):f}function U4(e){return`w${e.replace(/[^a-zA-Z0-9_-]/g,``)}`}function W4({id:e}){return(0,J.jsxs)(`linearGradient`,{id:e,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,J.jsx)(`stop`,{offset:`0%`,stopColor:z4,stopOpacity:.3}),(0,J.jsx)(`stop`,{offset:`100%`,stopColor:z4,stopOpacity:.02})]})}function Qwe({spark:e,width:t=76,height:n=14,warn:r=null}){let i=U4((0,V.useId)()),a=L4(e,t,n);if(!a)return null;let o=Di(e.costUsd)??Ni(e.usageTok)??RE(a.end),s=r?`${r.text}\n${R4(e,a)}`:R4(e,a);return(0,J.jsxs)(`span`,{className:`ctx-spark-pair`,title:s,children:[(0,J.jsxs)(`svg`,{className:`ctx-spark`,width:t,height:n,viewBox:`0 0 ${t} ${n}`,role:`img`,"aria-label":s,children:[(0,J.jsx)(`title`,{children:s}),(0,J.jsx)(`defs`,{children:(0,J.jsx)(W4,{id:i})}),(0,J.jsx)(`line`,{x1:0,x2:t,y1:n-.5,y2:n-.5,stroke:`currentColor`,strokeOpacity:.16,strokeWidth:1}),a.totalY!=null&&(0,J.jsx)(`line`,{x1:0,x2:t,y1:a.totalY,y2:a.totalY,stroke:`currentColor`,strokeOpacity:.45,strokeWidth:1,strokeDasharray:`3 3`}),(0,J.jsx)(`path`,{d:a.area,fill:`url(#${i})`}),a.agentBand&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`path`,{d:a.agentBand.area,fill:`var(--fg)`,fillOpacity:.16}),(0,J.jsx)(`path`,{d:a.agentBand.top,fill:`none`,stroke:`var(--fg)`,strokeOpacity:.5,strokeWidth:1,strokeLinejoin:`round`,strokeLinecap:`round`})]}),(0,J.jsx)(`path`,{d:a.line,fill:`none`,stroke:z4,strokeWidth:1.5,strokeLinejoin:`round`,strokeLinecap:`round`}),(0,J.jsx)(`circle`,{cx:a.endX,cy:a.endY,r:2.2,fill:z4,stroke:`var(--panel)`,strokeWidth:1.5})]}),(0,J.jsxs)(`span`,{className:r?`ctx-spark-use spend-warn-${r.level}`:`ctx-spark-use`,children:[r?(0,J.jsx)(gs,{size:10,"aria-label":r.level===`high`?`past the red spend mark`:`past the orange spend mark`}):(0,J.jsx)(ao,{size:10}),` `,o]})]})}function $we({samples:e,events:t,windowTok:n,autoCompactTok:r,autoCompactSetTok:i=null,width:a,height:o=200,onHover:s,bands:c,agents:l}){let u=(0,V.useRef)(null),[d,f]=(0,V.useState)(null),p=(0,V.useCallback)(e=>{f(e),s?.(e)},[s]),m=T4({width:a,height:o,pad:Xwe,samples:e,events:t,refs:[r,i].filter(e=>e!=null),windowTok:n,agents:l}),h=m.t1-m.t0,g=(0,V.useCallback)(t=>{let n=u.current?.getBoundingClientRect();if(!n)return;let r=(t.clientX-n.left)/n.width*a;p(kwe(m,e,r))},[m,e,a,p]),_=m.yTicks,v=[0,.5,1].map(e=>m.tx(m.x+e*m.w));return(0,J.jsxs)(`svg`,{ref:u,className:`ctx-chart`,width:a,height:o,viewBox:`0 0 ${a} ${o}`,onPointerDown:g,onPointerMove:g,onPointerLeave:()=>p(null),onPointerCancel:()=>p(null),role:`img`,"aria-label":`context window over time`,children:[_.map(e=>(0,J.jsx)(`line`,{x1:m.x,x2:m.x+m.w,y1:m.py(e),y2:m.py(e),stroke:`var(--line)`,strokeWidth:1},`g${e}`)),c?(0,J.jsx)(G4,{p:m,samples:e,series:c}):(0,J.jsx)(`path`,{d:M4(m,e),fill:z4,fillOpacity:.14}),l&&zwe(m,l).map(e=>(0,J.jsx)(`path`,{d:e.d,fill:`none`,stroke:`var(--fg)`,strokeOpacity:.45,strokeWidth:1.25,strokeLinejoin:`round`,strokeLinecap:`round`},`a${e.id}`)),(0,J.jsx)(`path`,{d:j4(m,e),fill:`none`,stroke:z4,strokeWidth:2,strokeLinejoin:`round`,strokeLinecap:`round`}),m.breaks.map((e,t)=>(0,J.jsxs)(`g`,{children:[(0,J.jsx)(`title`,{children:`${E4(e.to-e.from)} with no activity — the axis is compressed here`}),(0,J.jsx)(`rect`,{x:e.x,y:m.y,width:e.w,height:m.h,fill:`var(--panel)`}),[0,1].map(t=>(0,J.jsx)(`line`,{x1:e.x+1+t*5,y1:m.y+m.h,x2:e.x+e.w-5+t*5,y2:m.y,stroke:`var(--line)`,strokeWidth:1},t))]},`k${t}`)),t.filter(e=>e.kind===`limit`&&e.resetAt!=null).map((e,t)=>(0,J.jsx)(`rect`,{x:m.px(e.t),y:m.y,width:Math.max(1,m.px(e.resetAt)-m.px(e.t)),height:m.h,fill:V4,fillOpacity:.12},`b${t}`)),r!=null&&(0,J.jsx)(K4,{p:m,v:r,label:`compacts ~${D4(m,r)}`,below:m.py(r)-m.y<13}),i!=null&&(0,J.jsx)(K4,{p:m,v:i,label:Jwe(i),below:m.py(i)-m.y<13,start:!0,dash:`1.5 3`}),t.filter(e=>e.kind!==`rebuild`).map((e,t)=>{let n=m.px(e.t),r=Math.min(m.x+m.w-5,Math.max(m.x+5,n)),i=e.kind===`compact`?B4:V4;return(0,J.jsxs)(`g`,{children:[(0,J.jsx)(`title`,{children:Wwe(e).text}),(0,J.jsx)(`line`,{x1:n,x2:n,y1:m.y,y2:m.y+m.h,stroke:i,strokeWidth:1.5,strokeOpacity:.85}),e.kind===`compact`?(0,J.jsx)(`path`,{d:`M${r-4},${m.y}L${r+4},${m.y}L${r},${m.y+6}Z`,fill:i,stroke:`var(--panel)`,strokeWidth:1}):(0,J.jsx)(`rect`,{x:r-3.5,y:m.y,width:7,height:7,fill:i,stroke:`var(--panel)`,strokeWidth:1})]},`e${t}`)}),_.map(e=>(0,J.jsx)(`text`,{className:`ctx-tick`,x:m.x-6,y:m.py(e)+3.5,textAnchor:`end`,children:D4(m,e)},`t${e}`)),v.map((e,t)=>(0,J.jsx)(`text`,{className:`ctx-tick`,x:m.px(e),y:o-6,textAnchor:t===0?`start`:t===v.length-1?`end`:`middle`,children:zE(e,h)},`x${t}`)),d&&(0,J.jsxs)(`g`,{children:[(0,J.jsx)(`line`,{x1:m.px(d.t),x2:m.px(d.t),y1:m.y,y2:m.y+m.h,stroke:`var(--fg)`,strokeOpacity:.35,strokeWidth:1}),(0,J.jsx)(`circle`,{cx:m.px(d.t),cy:m.py(d.tok),r:4.5,fill:`var(--ctx-series)`,stroke:`var(--panel)`,strokeWidth:2})]})]})}function eTe({samples:e,events:t,facts:n,width:r,height:i=96,bands:a,agents:o,agentCum:s}){let c=T4({width:r,height:i,pad:H4,samples:e,events:t,windowTok:null,agents:o,value:k4,refs:n.total==null?[]:[n.total],yWant:3}),l=c.t1-c.t0,u=[0,.5,1].map(e=>c.tx(c.x+e*c.w)),d=n.agents==null?{area:``,top:``}:Owe(c,e,s);return(0,J.jsxs)(`svg`,{className:`ctx-chart`,width:r,height:i,viewBox:`0 0 ${r} ${i}`,role:`img`,"aria-label":`tokens spent over time`,children:[c.yTicks.map(e=>(0,J.jsx)(`line`,{x1:c.x,x2:c.x+c.w,y1:c.py(e),y2:c.py(e),stroke:`var(--line)`,strokeWidth:1},`g${e}`)),a?(0,J.jsx)(G4,{p:c,samples:e,series:a}):(0,J.jsx)(`path`,{d:M4(c,e,k4),fill:z4,fillOpacity:.14}),d.area&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`path`,{d:d.area,fill:`var(--fg)`,fillOpacity:.16}),(0,J.jsx)(`path`,{d:d.top,fill:`none`,stroke:`var(--fg)`,strokeOpacity:.5,strokeWidth:1.25,strokeLinejoin:`round`})]}),(0,J.jsx)(`path`,{d:j4(c,e,k4),fill:`none`,stroke:z4,strokeWidth:2,strokeLinejoin:`round`,strokeLinecap:`round`}),c.breaks.map((e,t)=>(0,J.jsxs)(`g`,{children:[(0,J.jsx)(`title`,{children:`${E4(e.to-e.from)} with no activity — the axis is compressed here`}),(0,J.jsx)(`rect`,{x:e.x,y:c.y,width:e.w,height:c.h,fill:`var(--panel)`}),[0,1].map(t=>(0,J.jsx)(`line`,{x1:e.x+1+t*5,y1:c.y+c.h,x2:e.x+e.w-5+t*5,y2:c.y,stroke:`var(--line)`,strokeWidth:1},t))]},`k${t}`)),t.filter(e=>e.kind!==`rebuild`).map((e,t)=>(0,J.jsx)(`line`,{x1:c.px(e.t),x2:c.px(e.t),y1:c.y,y2:c.y+c.h,stroke:e.kind===`compact`?B4:V4,strokeWidth:1.5,strokeOpacity:.55},`e${t}`)),n.total!=null&&n.agents!=null&&(0,J.jsx)(K4,{p:c,v:n.total,label:`${LE(n.total)} with subagents`,below:c.py(n.total)-c.y<13}),c.yTicks.map(e=>(0,J.jsx)(`text`,{className:`ctx-tick`,x:c.x-6,y:c.py(e)+3.5,textAnchor:`end`,children:LE(e)},`t${e}`)),u.map((e,t)=>(0,J.jsx)(`text`,{className:`ctx-tick`,x:c.px(e),y:i-6,textAnchor:t===0?`start`:t===u.length-1?`end`:`middle`,children:zE(e,l)},`x${t}`))]})}function G4({p:e,samples:t,series:n}){let r=N4(e,t,n);return(0,J.jsx)(`g`,{children:r.map(e=>e.d&&(0,J.jsx)(`path`,{d:e.d,fill:QE[e.slot]??$E[4],fillOpacity:.85,stroke:`var(--panel)`,strokeWidth:.75,strokeOpacity:.6,children:(0,J.jsx)(`title`,{children:`${e.name}: ${LE(e.total)}`})},e.key))})}function tTe({p:e,samples:t,series:n,fmt:r=LE}){let i=N4(e,t,n),a=i.reduce((e,t)=>e+t.total,0);return(0,J.jsx)(`div`,{className:`ctx-legend ctx-legend-stack`,children:i.map(e=>(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`svg`,{width:`10`,height:`10`,"aria-hidden":!0,children:(0,J.jsx)(`rect`,{x:`0`,y:`1`,width:`10`,height:`8`,rx:`2`,fill:QE[e.slot]??$E[4]})}),e.name,` `,(0,J.jsx)(`b`,{children:r(e.total)}),a>0&&(0,J.jsxs)(`span`,{className:`ctx-legend-pct`,children:[` `,_n(e.total/a)]})]},e.key))})}function nTe({samples:e,events:t,agents:n,slots:r,width:i,onPick:a,picked:o}){let s=(0,V.useRef)(null),c=U4((0,V.useId)()),l=T4({width:i,height:100,pad:{...H4,top:6},samples:e,events:t,windowTok:null,refs:[],agents:n}),{bars:u,lanes:d}=Mwe(l,n,r),{laneH:f,barH:p,plotH:m}=Nwe(d),h=6+m+H4.bottom,g=l,_=g.t1-g.t0,v=[0,.5,1].map(e=>g.tx(g.x+e*g.w)),y=(e,t)=>{let n=s.current?.getBoundingClientRect();if(!n||!a)return;let r=(e.clientX-n.left)/n.width*i,c=(e.clientY-n.top)/n.height*h,l=Pwe(u,f,6,r,c);a(t&&l&&o&&l.run.id===o.id?null:l?.run??null)};return(0,J.jsxs)(`svg`,{ref:s,className:`ctx-chart`,width:i,height:h,viewBox:`0 0 ${i} ${h}`,onPointerDown:e=>y(e,!0),onPointerMove:e=>{e.buttons&&y(e,!1)},role:`img`,"aria-label":`subagents over time, one bar each`,children:[g.breaks.map((e,t)=>(0,J.jsxs)(`g`,{children:[(0,J.jsx)(`rect`,{x:e.x,y:6,width:e.w,height:m,fill:`var(--panel)`}),[0,1].map(t=>(0,J.jsx)(`line`,{x1:e.x+1+t*5,y1:6+m,x2:e.x+e.w-5+t*5,y2:6,stroke:`var(--line)`,strokeWidth:1},t))]},`k${t}`)),(0,J.jsx)(`line`,{x1:g.x,x2:g.x+g.w,y1:6+m+.5,y2:6+m+.5,stroke:`var(--line)`,strokeWidth:1}),u.map((e,t)=>{let n=o?.id===e.run.id,r=QE[e.slot]??$E[4],i=Math.min(24,e.w);return(0,J.jsxs)(`g`,{children:[e.open&&(0,J.jsx)(`defs`,{children:(0,J.jsxs)(`linearGradient`,{id:`${c}-${t}`,gradientUnits:`userSpaceOnUse`,x1:e.x+e.w-i,x2:e.x+e.w,y1:0,y2:0,children:[(0,J.jsx)(`stop`,{offset:`0`,stopColor:r}),(0,J.jsx)(`stop`,{offset:`1`,stopColor:r,stopOpacity:0})]})}),(0,J.jsx)(`rect`,{x:e.x,y:6+e.lane*f+(f-p)/2,width:e.w,height:p,rx:e.open?0:Math.min(2,p/2),fill:e.open?`url(#${c}-${t})`:r,fillOpacity:o&&!n?.55:.9,stroke:n?`var(--accent)`:e.dearest?`var(--fg)`:`none`,strokeWidth:n?2:1,strokeOpacity:e.open&&!n?.5:1,children:(0,J.jsx)(`title`,{children:`${e.run.type??`agent`} · ${LE(e.run.tok)}${e.run.running?` · still running`:``}`})})]},e.run.id)}),v.map((e,t)=>(0,J.jsx)(`text`,{className:`ctx-tick`,x:g.px(e),y:h-6,textAnchor:t===0?`start`:t===v.length-1?`end`:`middle`,children:zE(e,_)},`x${t}`))]})}function rTe({agents:e,dashed:t,stacked:n}){return!e&&!t?null:(0,J.jsxs)(`div`,{className:`ctx-legend`,children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`svg`,{width:`14`,height:`10`,"aria-hidden":!0,children:(0,J.jsx)(`rect`,{x:`0`,y:`3`,width:`14`,height:`2.5`,rx:`1.2`,fill:z4})}),` this conversation`,n?` (stacked as the window below)`:``]}),e&&(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`svg`,{width:`10`,height:`10`,"aria-hidden":!0,children:(0,J.jsx)(`rect`,{x:`0`,y:`1`,width:`10`,height:`8`,rx:`2`,fill:`var(--fg)`,fillOpacity:.3})}),` subagents`]}),t&&(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`svg`,{width:`14`,height:`10`,"aria-hidden":!0,children:(0,J.jsx)(`line`,{x1:`0`,x2:`14`,y1:`5`,y2:`5`,stroke:`var(--fg)`,strokeOpacity:.5,strokeDasharray:`4 3`})}),` whole session`]})]})}function iTe({slots:e,only:t}){if(!e)return null;let n=[...e.named.map(e=>({slot:e.slot,name:F4(e.id)})),...e.rest?[{slot:e.rest.slot,name:e.rest.name}]:[]].filter(e=>!t||t.has(e.slot));return n.length<2?null:(0,J.jsx)(`div`,{className:`ctx-legend ctx-legend-stack`,children:n.map(e=>(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`svg`,{width:`10`,height:`10`,"aria-hidden":!0,children:(0,J.jsx)(`rect`,{x:`0`,y:`1`,width:`10`,height:`8`,rx:`2`,fill:QE[e.slot]??$E[4]})}),e.name]},e.name))})}function K4({p:e,v:t,label:n,below:r,start:i,dash:a=`4 4`}){let o=e.py(t),s=r?Math.min(e.y+e.h-2,o+11):Math.max(e.y+9,o-4);return(0,J.jsxs)(`g`,{children:[(0,J.jsx)(`line`,{x1:e.x,x2:e.x+e.w,y1:o,y2:o,stroke:`var(--fg)`,strokeOpacity:.4,strokeWidth:1,strokeDasharray:a}),(0,J.jsx)(`text`,{className:`ctx-ref`,x:i?e.x+4:e.x+e.w,y:s,textAnchor:i?`start`:`end`,children:n})]})}function aTe({events:e,agents:t=0}){let n=e.filter(e=>e.kind===`compact`).length,r=e.filter(e=>e.kind===`limit`).length;return(0,J.jsxs)(`div`,{className:`ctx-legend`,children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`svg`,{width:`14`,height:`10`,"aria-hidden":!0,children:(0,J.jsx)(`rect`,{x:`0`,y:`3`,width:`14`,height:`2.5`,rx:`1.2`,fill:z4})}),` context`]}),t>0&&(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`svg`,{width:`14`,height:`10`,"aria-hidden":!0,children:(0,J.jsx)(`rect`,{x:`0`,y:`4`,width:`14`,height:`1.25`,fill:`var(--fg)`,fillOpacity:.45})}),` each agent's own window (`,t,`)`]}),n>0&&(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`svg`,{width:`10`,height:`10`,"aria-hidden":!0,children:(0,J.jsx)(`path`,{d:`M1,1L9,1L5,8Z`,fill:`var(--ctx-compact)`})}),` compaction (`,n,`)`]}),r>0&&(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`svg`,{width:`10`,height:`10`,"aria-hidden":!0,children:(0,J.jsx)(`rect`,{x:`1.5`,y:`1.5`,width:`7`,height:`7`,fill:`var(--ctx-limit)`})}),` usage limit (`,r,`)`]})]})}function oTe(e,t,n=5){return e.map((e,t)=>({run:e,i:t})).sort((e,t)=>{let n=e.run.costUsd??null,r=t.run.costUsd??null;return n!=null&&r!=null?r-n||t.run.tok-e.run.tok||e.i-t.i:n==null?r==null?t.run.tok-e.run.tok||e.i-t.i:1:-1}).slice(0,Math.max(0,n)).map(({run:e})=>{let n=t&&e.model!=null?t[e.model]:null;return{run:e,id:e.id,type:e.type??`agent`,model:n?F4(n):null,turns:e.turns&&e.turns>0?e.turns:null,peakTok:e.peakTok&&e.peakTok>0?e.peakTok:null,tok:e.tok,costUsd:e.costUsd??null,running:!!e.running}})}var sTe=5;function cTe({agents:e,models:t,picked:n,onPick:r}){let i=oTe(e,t,sTe);return i.length?(0,J.jsxs)(`div`,{className:`agent-top`,children:[(0,J.jsx)(`div`,{className:`ctx-summary`,children:e.length>i.length?`${i.length} dearest of ${e.length} agents`:`${i.length} agent${i.length>1?`s`:``}, dearest first`}),(0,J.jsxs)(`table`,{className:`agent-top-t`,children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{scope:`col`,children:`agent`}),(0,J.jsx)(`th`,{scope:`col`,children:`requests`}),(0,J.jsx)(`th`,{scope:`col`,children:`peak window`}),(0,J.jsx)(`th`,{scope:`col`,children:`tokens`}),(0,J.jsx)(`th`,{scope:`col`,children:`cost`})]})}),(0,J.jsx)(`tbody`,{children:i.map(e=>(0,J.jsxs)(`tr`,{className:e.run===n||e.id===n?.id?`on`:void 0,tabIndex:0,onClick:()=>r(e.run),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),r(e.run))},children:[(0,J.jsxs)(`th`,{scope:`row`,children:[e.type,(0,J.jsx)(`small`,{children:[e.model,e.running?`running`:null].filter(Boolean).join(` · `)})]}),(0,J.jsx)(`td`,{children:e.turns==null?``:e.turns}),(0,J.jsx)(`td`,{children:e.peakTok==null?``:LE(e.peakTok)}),(0,J.jsx)(`td`,{children:LE(e.tok)}),(0,J.jsx)(`td`,{children:e.costUsd==null?``:_t(e.costUsd)})]},e.id))})]}),(0,J.jsx)(Z,{children:`Tap a row to ring that agent in the chart above. Cost is roughly requests times window; an empty cell was not measured.`})]}):null}var q4=[2e5,3e5,4e5,5e5];function lTe({value:e,onChange:t}){let n=!q4.some(t=>t===e);return(0,J.jsxs)(`div`,{className:`agent-warn`,children:[(0,J.jsxs)(`div`,{className:`ts-filter agent-warn-row`,role:`group`,"aria-label":`warn when an agent passes`,children:[(0,J.jsx)(`span`,{className:`ctx-stackpick-lab`,children:`warn when an agent passes`}),q4.map(n=>(0,J.jsx)(Y,{className:n===e?`active`:void 0,"aria-pressed":n===e,onClick:()=>t(n),children:LE(n)},n))]}),(0,J.jsxs)(`div`,{className:`ctx-cost-note`,children:[n?`Set to ${LE(e)} elsewhere. `:``,`It warns you - a chip on the session, a toast and a push - and never stops an agent. Syncs to the desktop, which sends the push.`]})]})}function J4(e,t){let n=(e??[]).map(e=>({load:e}));for(let e of t)for(let t of e.skills??[])n.push({load:t,agent:e});return n.sort((e,t)=>e.load.t-t.load.t)}function Y4(e,t,n){let r=[],i=new Map;for(let{load:a,agent:o}of J4(t,n)){let t=i.get(a.name);t??(t=r.length,i.set(a.name,t),r.push({name:a.name,marks:[]}));let n=Math.max(e.x,Math.min(e.x+e.w,e.px(a.t)));r[t].marks.push({load:a,...o?{agent:o}:{},x:n,row:t})}return r}function uTe(e,t,n,r){let i=Math.floor((r-t)/24),a=e[i]?.marks.length?e[i].marks:e.flatMap(e=>e.marks);return a.length?a.reduce((e,t)=>Math.abs(t.x-n)<Math.abs(e.x-n)?t:e,a[0]):null}function X4(e){return`≈${LE(Math.round(e/4))} tokens`}function dTe(e){return e?`a subagent${e.type?` (${e.type})`:``}`:`this conversation`}function fTe(e,t){let n=J4(e,t);if(!n.length)return null;let r=new Set(n.map(e=>e.load.name)).size,i=n.filter(e=>!e.agent).length,a=n.length-i,o=n.reduce((e,t)=>e+t.load.chars,0),s=a===0?`all by this conversation`:i===0?`all by subagents`:`${i} by this conversation, ${a} by subagents`,c=n.length===1?`1 load`:`${n.length} loads`;return`${r} skill${r===1?``:`s`} · ${c}, ${s} · ${X4(o)} of skill text`}function pTe(e){let t=e.reduce((e,t)=>!e||t.marks.length>e.marks.length?t:e,null);if(!t||t.marks.length<2)return null;let n=t.marks.reduce((e,t)=>e+t.load.chars,0);return`${t.name} was loaded ${t.marks.length} times — ${X4(n)} in all.`}function mTe(e,t){return`${e.load.name} · ${zE(e.load.t,t)} · by ${dTe(e.agent)} · ${LE(e.load.chars)} chars, ${X4(e.load.chars)}`}var hTe=`A mark is the moment the Skill tool wrote that skill's text into a context window, read off the CLI's log. A filled dot is this conversation's own window; a ring is a subagent's — its own window, not this one. Size is the text's length in characters; the token figure divides by 4, an estimate, because the request that carried the text reports one total for everything it held. A skill typed as a slash command is not counted here.`,Z4={top:4,right:10,bottom:20,left:40},Q4=3.5;function gTe({samples:e,events:t,own:n,agents:r,width:i,picked:a,onPick:o}){let s=(0,V.useRef)(null),c=T4({width:i,height:100,pad:Z4,samples:e,events:t,windowTok:null,refs:[],agents:r}),l=Y4(c,n,r),u=Z4.top,d=l.length*24,f=u+d+Z4.bottom,p=c.t1-c.t0,m=[0,.5,1].map(e=>c.tx(c.x+e*c.w)),h=(e,t)=>!!t&&e.load===t.load,g=(e,t)=>{let n=s.current?.getBoundingClientRect();if(!n)return;let r=(e.clientX-n.left)/n.width*i,c=(e.clientY-n.top)/n.height*f,d=uTe(l,u,r,c);o(t&&d&&h(d,a)?null:d)};return(0,J.jsxs)(`svg`,{ref:s,className:`ctx-chart`,width:i,height:f,viewBox:`0 0 ${i} ${f}`,onPointerDown:e=>g(e,!0),onPointerMove:e=>{e.buttons&&g(e,!1)},role:`img`,"aria-label":`skills loaded over time, one row per skill`,children:[c.breaks.map((e,t)=>(0,J.jsxs)(`g`,{children:[(0,J.jsx)(`rect`,{x:e.x,y:u,width:e.w,height:d,fill:`var(--panel)`}),[0,1].map(t=>(0,J.jsx)(`line`,{x1:e.x+1+t*5,y1:u+d,x2:e.x+e.w-5+t*5,y2:u,stroke:`var(--line)`,strokeWidth:1},t))]},`k${t}`)),l.map((e,t)=>{let n=u+t*24;return(0,J.jsxs)(`g`,{children:[(0,J.jsx)(`line`,{x1:c.x,x2:c.x+c.w,y1:n+17+.5,y2:n+17+.5,stroke:`var(--line)`,strokeWidth:1,strokeOpacity:.6}),(0,J.jsxs)(`text`,{className:`ctx-tick`,x:c.x,y:n+9,children:[e.name,e.marks.length>1?` ×${e.marks.length}`:``]}),e.marks.map((e,t)=>{let r=h(e,a);return(0,J.jsx)(`circle`,{cx:e.x,cy:n+17,r:Q4,fill:e.agent?`var(--panel)`:z4,stroke:r?`var(--accent)`:e.agent?`var(--fg)`:z4,strokeOpacity:r?1:e.agent?.6:1,strokeWidth:r?2:1.25},t)})]},e.name)}),(0,J.jsx)(`line`,{x1:c.x,x2:c.x+c.w,y1:u+d+.5,y2:u+d+.5,stroke:`var(--line)`,strokeWidth:1}),m.map((e,t)=>(0,J.jsx)(`text`,{className:`ctx-tick`,x:c.px(e),y:f-6,textAnchor:t===0?`start`:t===m.length-1?`end`:`middle`,children:zE(e,p)},`x${t}`))]})}function _Te({samples:e,events:t,own:n,agents:r,width:i,span:a}){let[o,s]=(0,V.useState)(null),c=fTe(n,r);if(n===void 0&&!c)return null;if(!c)return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`ctx-chart-title`,children:`Skills`}),(0,J.jsx)(`div`,{className:`empty ctx-note`,children:`No skill has been loaded in this conversation or its subagents.`})]});let l=r.some(e=>e.skills?.length),u=!!n?.length,d=pTe(Y4(T4({width:Math.max(i,1),height:100,pad:Z4,samples:e,events:t,windowTok:null,refs:[],agents:r}),n,r));return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`ctx-chart-title`,children:`Skills`}),(0,J.jsx)(`div`,{className:`ctx-summary`,children:c}),(0,J.jsx)(`div`,{className:`ctx-box`,children:i>0&&(0,J.jsx)(gTe,{samples:e,events:t,own:n,agents:r,width:i,picked:o,onPick:s})}),(0,J.jsx)(`div`,{className:`ctx-readout`,children:o?mTe(o,a):`tap a mark to read that load`}),(0,J.jsxs)(`div`,{className:`ctx-legend`,children:[u&&(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`svg`,{width:`10`,height:`10`,"aria-hidden":!0,children:(0,J.jsx)(`circle`,{cx:`5`,cy:`5`,r:Q4,fill:`var(--ctx-series)`})}),` this conversation`]}),l&&(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`svg`,{width:`10`,height:`10`,"aria-hidden":!0,children:(0,J.jsx)(`circle`,{cx:`5`,cy:`5`,r:Q4,fill:`none`,stroke:`var(--fg)`,strokeOpacity:.6,strokeWidth:1.25})}),` a subagent`]})]}),d&&(0,J.jsx)(`div`,{className:`empty ctx-note`,children:d}),(0,J.jsxs)(`details`,{className:`hint-more ctx-method`,children:[(0,J.jsx)(`summary`,{children:`how the skills chart is counted`}),(0,J.jsx)(`p`,{children:hTe})]})]})}var $4=220,vTe=110;function yTe({sessionId:e,title:t,online:n,liveAgentNote:r,onReplan:i,replanCant:a,replanNote:o,agentWarn:s,budget:c,onFresh:l,onCompact:u,compactCant:d,onExplainCost:f,unmeasured:p,backendLabel:m,onClose:h}){let g=gh(`ctx:${e}`,async()=>{let t=await H.contextSeries(e);if(!t)throw Error(`no context series`);return t},{enabled:!p,offline:!n,fromCache:()=>vb(e),toCache:_b}),_=g.data,[v,y]=(0,V.useState)(null),[b,x]=(0,V.useState)(null),S=(0,V.useRef)(null),[C,w]=(0,V.useState)(0),T=(0,V.useCallback)(e=>{if(S.current?.disconnect(),S.current=null,!e)return;let t=e=>{let t=getComputedStyle(e);return e.clientWidth-parseFloat(t.paddingLeft||`0`)-parseFloat(t.paddingRight||`0`)};if(w(t(e)),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>w(t(e)));n.observe(e),S.current=n},[]);(0,V.useEffect)(()=>()=>S.current?.disconnect(),[]);let E=(0,V.useCallback)(e=>y(e),[]),D=_?.samples??[],O=_?.events??[],k=D.length?D[D.length-1].t-D[0].t:0,A=_?.windowTok??null,j=Kwe(D,O,A,_?.agents),M=Pn(_?.coldStarts,`session`),N=ute(D,_?.truncated??!1,_?.turns??null,_?{usageTok:_.usageTok,agentTok:_.agentTok}:null,D.length?{lastTurnAt:D[D.length-1].t,now:Date.now()}:null),P=Cwe(D,_?.usageTok,_?.agentTok,_?.cost?{total:_.cost.total+(_.agentCost?.total??0),agents:_.agentCost?.total??null,unpricedTok:_.unpricedTok??null}:null),F=Ewe(_?.split,_?.agentSplit),ee=_?.agents??[],te=Awe(_?.models,D.some(e=>e.model==null)||ee.some(e=>e.model==null)),ne=P4(D,`kinds`,e=>e!==`output`),re=P4(D,`cum`),ie=ne,ae=re,oe=D.slice(0,-1).map((e,t)=>D[t+1].t-e.t).filter(e=>e>w4);if(p)return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(qs,{size:16,style:{verticalAlign:`-3px`,marginRight:4}}),`Context window & cost`]}),onClose:h}),(0,J.jsx)(Qw,{cants:[{label:`context graph`,reason:p}]}),(0,J.jsxs)(Z,{children:[t,` — nothing on this screen is a measurement of it. The terminal is still the whole story.`]})]});let se=P?Twe(P,_?.truncated??!1,!!_?.agentCum?.length):null,ce=F?Dwe(F,_?.truncated??!1):null,le=Rwe(ee,_?.agentTok);return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(qs,{size:16,style:{verticalAlign:`-3px`,marginRight:4}}),`Context window & cost`]}),onClose:h,children:(0,J.jsx)(Y,{onClick:()=>{g.inflight||g.reload({quiet:!0})},title:`re-read — this is a point-in-time answer, not a live feed`,children:g.inflight?(0,J.jsx)($s,{size:14,className:`spin`}):(0,J.jsx)(Ds,{size:14})})}),(0,J.jsx)(Z,{children:t}),(0,J.jsx)($,{res:g,empty:!D.length,thing:`the context history`,noun:`graph`,note:g.state===`error`?`A session that has not run a turn yet has no log to read.`:void 0,children:`Nothing to plot yet — this conversation has not completed a turn.`}),D.length>0&&(0,J.jsxs)(`div`,{className:`list`,children:[(0,J.jsxs)(J.Fragment,{children:[P&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`ctx-chart-title`,children:P.costUsd==null?`Tokens spent`:`Total cost`}),(0,J.jsx)(`div`,{className:`ctx-summary`,children:wwe(P,_?.truncated??!1)}),(0,J.jsx)(`div`,{className:`ctx-box`,children:C>0&&(0,J.jsx)(eTe,{samples:D,events:O,facts:P,width:C,height:vTe,bands:ae,agents:ee,agentCum:_?.agentCum})}),(0,J.jsx)(rTe,{agents:P.agents!=null&&!!_?.agentCum?.length,dashed:P.total!=null&&P.agents!=null,stacked:!!ae}),se?.lead&&(0,J.jsx)(`div`,{className:`empty ctx-note`,children:se.lead}),P.costUsd!=null&&(0,J.jsx)(FSe,{className:`ctx-method`})]}),(0,J.jsxs)(`div`,{className:`ctx-chart-title ctx-chart-title-row`,children:[(0,J.jsx)(`span`,{children:`Context window`}),u&&(0,J.jsxs)(Y,{onClick:u,children:[(0,J.jsx)(Kc,{size:14}),` /compact`]})]}),!u&&d&&(0,J.jsx)(Qw,{cants:[{label:`/compact from here`,reason:d}]}),j&&(0,J.jsx)(`div`,{className:`ctx-summary`,children:j}),(0,J.jsx)(`div`,{className:`ctx-box`,ref:T,children:C>0&&(0,J.jsx)($we,{samples:D,events:O,width:C,height:$4,windowTok:A,autoCompactTok:_?.autoCompactTok??null,autoCompactSetTok:_?.autoCompactSet?.tokens??null,onHover:E,bands:ie,agents:ee})}),(0,J.jsx)(`div`,{className:`ctx-readout`,children:v?`${zE(v.t,k)} · ${xwe(v.tok,A)}`:(0,J.jsx)(iD,{})}),(0,J.jsx)(aTe,{events:O,agents:ee.filter(e=>e.ctx?.length).length}),ie&&C>0&&(0,J.jsx)(tTe,{p:T4({width:C,height:$4,pad:{top:10,right:10,bottom:20,left:40},samples:D,events:O,refs:[],windowTok:A,agents:ee}),samples:D,series:ie}),ee.length>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`ctx-chart-title`,children:`Subagents`}),(0,J.jsx)(`div`,{className:`ctx-summary`,children:Lwe(ee,_?.models)}),(0,J.jsx)(`div`,{className:`ctx-box`,children:C>0&&(0,J.jsx)(nTe,{samples:D,events:O,agents:ee,slots:te,width:C,picked:b,onPick:x})}),(0,J.jsx)(`div`,{className:`ctx-readout`,children:b?Iwe(b,_?.models,k):`tap a bar to read that agent`}),(0,J.jsx)(iTe,{slots:te,only:new Set(ee.map(e=>te?.slotOf(e.model)??0))}),(0,J.jsx)(cTe,{agents:ee,models:_?.models,picked:b,onPick:x})]}),le&&(0,J.jsx)(`div`,{className:`empty ctx-note`,children:le}),(0,J.jsx)(_Te,{samples:D,events:O,own:_?.skills,agents:ee,width:C,span:k}),(se||ee.length>0)&&(0,J.jsxs)(`details`,{className:`hint-more ctx-method`,children:[(0,J.jsx)(`summary`,{children:`how the spend and agent charts are counted`}),se&&(0,J.jsx)(`p`,{children:se.more}),ee.length>0&&(0,J.jsx)(`p`,{children:`Each bar runs from an agent's first dated record to its last, coloured by the model that ran it, and packed into as few rows as fit without two bars overlapping — a row is not an identity, only the first one that had room. The outlined bar spent the most. A floor, like every reading here: an agent log this desktop never saw is one nothing can place.`})]})]}),F&&(0,J.jsxs)(J.Fragment,{children:[A4(F)&&(0,J.jsx)(`div`,{className:`ctx-summary`,children:A4(F)}),(0,J.jsx)(tD,{bag:F.all,whole:ui(F.all)}),ce?.lead&&(0,J.jsx)(`div`,{className:`empty ctx-note`,children:ce.lead}),(0,J.jsx)(nD,{totals:F.all,scope:`session`}),ce&&(0,J.jsxs)(`details`,{className:`hint-more ctx-method`,children:[(0,J.jsx)(`summary`,{children:`how these kinds are counted`}),(0,J.jsx)(`p`,{children:ce.more})]})]}),r&&(0,J.jsxs)(`div`,{className:`ctx-cost ctx-cost-heavy`,children:[(0,J.jsxs)(`div`,{className:`ctx-cost-head`,children:[(0,J.jsx)(Uo,{size:14}),(0,J.jsx)(`span`,{children:`a subagent is running on a large window`})]}),(0,J.jsx)(`div`,{className:`ctx-cost-note`,children:r}),i?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`sheet-actions`,children:(0,J.jsxs)(Y,{onClick:i,children:[(0,J.jsx)(tc,{size:14}),` interrupt and re-plan`]})}),o&&(0,J.jsx)(Z,{children:o})]}):a?(0,J.jsx)(Qw,{cants:[{label:`interrupt and re-plan`,reason:a}]}):null]}),N&&(0,J.jsx)(vwe,{cost:N,onFresh:l,onCompact:u}),(c||s)&&(0,J.jsxs)(`div`,{className:`ctx-cost`,children:[c&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`ctx-cost-head`,children:[(0,J.jsx)(Qc,{size:14}),(0,J.jsx)(`span`,{children:c.label?`budget ${c.label}`:`no budget on this session`})]}),c.line?(0,J.jsx)(`div`,{className:`ctx-cost-note`,children:c.line}):null,(0,J.jsx)(`div`,{className:`sheet-actions`,children:(0,J.jsxs)(Y,{onClick:c.onOpen,children:[(0,J.jsx)(Qc,{size:14}),` `,c.label?`change or clear the budget`:`set a budget`]})})]}),s&&(0,J.jsxs)(J.Fragment,{children:[!c&&(0,J.jsxs)(`div`,{className:`ctx-cost-head`,children:[(0,J.jsx)(Uo,{size:14}),(0,J.jsx)(`span`,{children:`large subagents`})]}),(0,J.jsx)(lTe,{value:s.value,onChange:s.onChange})]})]}),(0,J.jsxs)(`div`,{className:`ctx-cost`,children:[(0,J.jsxs)(`div`,{className:`ctx-cost-head`,children:[(0,J.jsx)(Cs,{size:14}),(0,J.jsx)(`span`,{children:`why it cost this much`})]}),f?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`ctx-cost-note`,children:`A new session in this directory measures this conversation's transcript, names what made it expensive and lists ideas to make it cheaper — it changes nothing until you pick one.`}),(0,J.jsx)(`div`,{className:`sheet-actions`,children:(0,J.jsxs)(Y,{onClick:f,children:[(0,J.jsx)(Cs,{size:14}),` explain the cost of this session`]})})]}):(0,J.jsx)(Qw,{cants:[{label:`explain the cost of this session`,reason:`this session has no conversation id yet, so there is no transcript to point a new session at`}]})]}),M&&(0,J.jsxs)(`div`,{className:`ctx-panel`,children:[(0,J.jsx)(`div`,{className:`ctx-summary`,children:`Expired cache`}),(0,J.jsx)(Z,{children:M}),(0,J.jsxs)(`details`,{className:`hint-more ctx-method`,children:[(0,J.jsx)(`summary`,{children:`why a cold cache costs more`}),(0,J.jsx)(`p`,{children:`A conversation resumed inside the hour re-reads its window out of the cache at a tenth of the write rate. After that the window has to be written again before it can answer anything — the same tokens, up to twenty times the price, and the chart does not move when it happens.`})]})]}),_?.compaction&&(0,J.jsx)(_we,{l:_.compaction,windowTok:A,tok:D.length?D[D.length-1].tok:null}),_?.truncated&&!se&&!ce&&(0,J.jsx)(`div`,{className:`empty ctx-note`,children:`This conversation’s log is longer than the host reads in one go, so the curve starts part-way through it.`}),(0,J.jsxs)(`div`,{className:`empty ctx-note`,children:[Gwe(_?.windowFrom,A,_?.model,m),_?.autoCompactTok!=null&&` The dashed line is where a compaction was last observed to fire — a measurement, not a setting.`,_?.autoCompactSet&&` ${Ywe(_.autoCompactSet)}`]}),oe.length>0&&(0,J.jsx)(`div`,{className:`empty ctx-note`,children:oe.length===1?`One stretch of ${E4(oe[0])} with no activity is compressed on the time axis (the ⁄⁄ mark).`:`${oe.length} stretches with no activity — the longest ${E4(Math.max(...oe))} — are compressed on the time axis (the ⁄⁄ marks).`}),(0,J.jsxs)(`details`,{className:`hint-more ctx-method`,children:[(0,J.jsx)(`summary`,{children:`where these numbers come from`}),(0,J.jsx)(`p`,{children:`How many tokens each request carried, read off the CLI’s own conversation log and each subagent’s own log. Both are dated, which is what lets a compaction, a usage wall and every agent sit on the same time axis as the curve.`})]})]})]})}function bTe(e,t,n){return(e?t.find(t=>t.id===e):null)??n}function xTe(e,t){return e?`sent /compact to ${t}`:`queued /compact — sends when the link is back`}function STe(e){return`sent Esc to ${e} and queued the re-plan prompt`}function CTe(e){return`no connection — Esc did not reach ${e}, and the re-plan prompt was not queued. Try again when the link is back.`}var wTe=`Sends Esc, which stops the agent the session is waiting on, then queues a prompt asking the main agent to re-plan it narrower. Work that agent has not reported back is lost. An agent running in the background keeps going; the prompt asks the main agent to stop it.`,e3=W(null);function TTe(e){let t=U();t.say.track(`action:session.context`),e3.set(e.id),t.nav.open(`context`)}function ETe(){e3.set(null),U().nav.open(`context`)}function t3(){e3.set(null),U().nav.close(`context`)}function DTe(e){t3(),U().nav.openRepo(e)}function OTe(e){let t=U();t.say.track(`action:ctx.compact`),t.queue.submitInput(e.id,e.cwd,`/compact`,`command`),t.compose.pushHistory(`/compact`),t.say.toast(xTe(t.conn.status===`open`,t.world.sessionRowTitle(e)))}function kTe(e,t){let n=zx({title:t,cwd:e.cwd,claudeSessionId:e.claudeSessionId,model:e.model});if(!n)return!1;let r=U();return r.say.track(`action:ctx.explainCost`),t3(),r.nav.startSessionWithPrompt(e.cwd,`cost of ${t}`,[n]),!0}function ATe(e,t){let n=U();n.say.track(`action:ctx.replan`);let r=e.contextSpark;n.conn.liveSend({t:`session.input`,id:e.id,data:`\x1B`},STe(t),CTe(t))&&n.queue.submitInput(e.id,e.cwd,_r(r?.liveAgentTok??0,r?.liveAgentType),`prompt`)}function jTe({subject:e}){let t=Dh(),{backends:n}=t.world,r=t.world.sessionRepo(e),i=t.world.sessionRowTitle(e),a=rr(Zv(`agentWindowWarn`));return(0,J.jsx)(yTe,{sessionId:e.id,title:i,online:t.conn.status===`open`,unmeasured:t.world.sessionCant(e,`contextSeries`)??void 0,backendLabel:MC(n,e.backend)??void 0,onFresh:r?()=>DTe(r):void 0,onCompact:t.world.sessionCan(e,`slash`)?()=>OTe(e):void 0,compactCant:t.world.sessionCant(e,`slash`)??void 0,onExplainCost:e.claudeSessionId?()=>{kTe(e,i)}:void 0,liveAgentNote:e.running?Pee(e.contextSpark?.liveAgentTok,e.contextSpark?.liveAgentAt,Date.now(),a):null,onReplan:t.world.sessionCan(e,`slash`)?()=>ATe(e,i):void 0,replanCant:t.world.sessionCant(e,`slash`)??void 0,replanNote:wTe,agentWarn:{value:a,onChange:e=>{t.say.track(`action:ctx.agentWarn`),Qv(`agentWindowWarn`,e===5e5?``:String(e))}},budget:{label:e.budget?Yr(e.budget.cfg):null,line:Mw(e.budget,Date.now(),Li(e)),onOpen:()=>sD(e.id)},onClose:t3})}var MTe={id:`context`,sheets:[{id:`context`,persisted:!0,render:e=>{let t=bTe(e3.get(),e.world.sessions,e.world.active);return t?(0,V.createElement)(jTe,{subject:t}):null}}]},n3=R.fanoutPresets,r3=80,NTe=48,PTe=8e3,i3=`.claude/outbox`,a3=[{id:`init`,title:`/init`,text:`/init`},{id:`cost`,title:`/cost`,text:`/cost`},{id:`health`,title:`repo health`,text:`Summarize the state of this repo: uncommitted work, unpushed commits, failing or missing tests, and anything obviously stale.
92
+
93
+ Include an AGENT CONTEXT section, because it is the one cost that is paid on every turn whether or not anyone is using it: the size in characters of CLAUDE.md and any .claude/CLAUDE.md, the number of files under .claude/skills/ with each one's name and size, and the total. Note that a skill's BODY is loaded only when that skill is invoked — only its frontmatter description is always on — so report always-on (CLAUDE.md + descriptions) separately from on-demand (skill bodies), and give tokens as chars/4. Say whether the skills are gitignored, since ignored ones will not survive a fresh clone.
94
+
95
+ Write it all to ${i3}/health.md — do not change any code.`},{id:`wip`,title:`uncommitted work`,text:`Report what is in flight here: uncommitted changes, untracked files worth keeping, unpushed commits, and how far the branch has drifted from its remote. Write it to ${i3}/wip.md. Commit nothing.`},{id:`tests`,title:`run tests`,text:`Find and run this project's test suite the way its README or CI does. Report which tests fail and the shortest plausible cause for each in ${i3}/tests.md. Do not fix anything yet.`},{id:`build`,title:`build check`,text:`Build this project the way its README or CI does. Report whether it builds and, if not, the first real error with the file and line, in ${i3}/build.md. Do not fix anything yet.`},{id:`lint`,title:`types + lint`,text:`Run whatever type-check and lint this project has. Summarize the remaining errors grouped by file, worst first, in ${i3}/lint.md. Change no code.`},{id:`deps`,title:`outdated deps`,text:`Check whether this project's dependencies are outdated or have known vulnerabilities. Write a short report to ${i3}/deps.md — do not change any code.`},{id:`deps-update`,title:`update deps`,text:`Update dependencies to their latest COMPATIBLE versions, then run the build and the tests. Stop at the first thing that breaks rather than forcing it through. Report what you updated and what broke in ${i3}/deps-update.md. Do not commit.`},{id:`security`,title:`security pass`,text:`Do a read-only security pass: credentials or tokens committed to the repo, dependencies with known vulnerabilities, and unsafe patterns (shell interpolation of user input, unvalidated paths, missing auth checks). Write the findings ranked by severity to ${i3}/security.md. Change no code.`},{id:`docs`,title:`docs drift`,text:`Check whether README.md and CLAUDE.md still match the code: commands that no longer exist, moved paths, instructions that are now wrong. Write the drift list to ${i3}/docs.md — do not edit the docs yet.`},{id:`todos`,title:`TODO sweep`,text:`Collect every TODO / FIXME / HACK comment, group them by area, and rank them by how likely they are to bite. Write the list to ${i3}/todos.md. Change no code.`},{id:`deadcode`,title:`dead code`,text:`Find plausibly dead code: files nothing imports, exports nobody uses, dependencies nothing references. Write it to ${i3}/deadcode.md with your confidence per item. Delete nothing.`},{id:`week`,title:`last 7 days`,text:`Summarize what changed in this repo over the last 7 days: commits, which areas they touched, and anything left unfinished. Write it to ${i3}/week.md. Change no code.`},{id:`changelog`,title:`changelog`,text:`Update the CHANGELOG from the commits since the last release tag, matching the style already used in this repo. Create one if there is none. Touch no other file and do not commit.`},{id:`claudemd-audit`,title:`CLAUDE.md cost`,text:`Measure what this repo's always-on context costs, and change nothing.
96
+
97
+ CLAUDE.md is re-read on every turn of every session and every subagent, so its size is multiplied by everything the repo ever does. Report, in ${i3}/claudemd.md:
98
+
99
+ 1. The size in characters of CLAUDE.md, any .claude/CLAUDE.md, every file under .claude/skills/, and the long-form docs directory if there is one. Give tokens as chars/4.
100
+ 2. Which SECTIONS of CLAUDE.md are largest, and for each: is it a RULE (dangerous not to know before acting) or REFERENCE (only needed while editing that area)?
101
+ 3. Whether the reference half is duplicated in longer-form docs already, so it could be trimmed losslessly.
102
+ 4. A verdict: under ~12k chars is fine and needs nothing. Over that, say roughly how many tokens per turn the excess costs and which section is the biggest single win.
103
+
104
+ Read-only. Do not edit any file.`},{id:`claudemd-groom`,title:`groom CLAUDE.md`,text:`Get this repo's always-on context down to what has to be always-on. Measure first and STOP if it is already fine.
105
+
106
+ WHY: CLAUDE.md is re-read on every turn of every session and every subagent. Measured on one repo, it had grown to 148k chars and was 21% of every token that repo spent in a week.
107
+
108
+ STEP 1 — measure. Count the characters in CLAUDE.md. **If it is under ~12,000 chars, do nothing at all**: write one line to ${i3}/claudemd.md saying the size and that no change was needed, and stop. Most repos are already fine and must not be churned.
109
+
110
+ STEP 2 — classify every section as one of:
111
+ - RULE: dangerous not to know BEFORE acting — the security boundary, "never do X", the commands that are mandatory, what the project is. These STAY in CLAUDE.md.
112
+ - REFERENCE: only needed while editing that area — module indexes, per-area conventions, test maps, protocol detail. These MOVE.
113
+ - REASONING: measurements, past failures, rejected designs. These move to the repo's long-form docs (use the existing convention if there is one, else docs/notes/).
114
+
115
+ STEP 3 — move, in this order, and never lose a rule:
116
+ a) REASONING to the docs directory FIRST. If a module's only description anywhere is its CLAUDE.md entry, write the doc section BEFORE trimming the entry — otherwise trimming deletes knowledge.
117
+ b) REFERENCE into .claude/skills/<name>/SKILL.md, one skill per area (e.g. one per package or major subsystem). Each needs YAML frontmatter with \`name\` matching the directory and a \`description\` of at least ~120 characters saying BOTH what it covers and when to load it. A skill is chosen from its description alone, so a vague one silently retires every rule inside it.
118
+ c) Leave CLAUDE.md with: what the project is, the mandatory commands, the security model IN FULL, a short "never do these" list, and a table mapping area to skill.
119
+
120
+ THE ONE HARD RULE: **a skill that is not invoked is a rule that does not exist.** Anything that could cause harm, data loss or a security problem stays in CLAUDE.md. Only reference moves. Delete nothing.
121
+
122
+ STEP 4 — check .gitignore. If .claude/ is ignored, the skills will not survive a fresh clone. Git cannot re-include below an excluded DIRECTORY, so it needs \`.claude/*\` followed by \`!.claude/skills/\`, not \`.claude/\`. Verify with \`git check-ignore\` that the SKILL.md files are tracked and that any inbox/outbox/local-settings paths are still ignored.
123
+
124
+ STEP 5 — verify and report. Confirm every rule that was in CLAUDE.md before is still somewhere (file, skill or docs), then write to ${i3}/claudemd.md: the before and after sizes, what moved where, and anything you deliberately left in place. Do not commit.`},{id:`commit`,title:`commit WIP`,text:`Review the uncommitted changes here. If they are coherent and safe, stage and commit them with a clear message — do not push. If they are unrelated pieces of work, split them into separate commits. If anything looks accidental or half-finished, leave it alone and say why.`}],FTe={"context-weight":`claudemd-groom`};function ITe(e,t){let n=FTe[e];return n?t.find(e=>e.id===n)??null:null}function o3(e){if(!e||typeof e!=`object`)return null;let t=e,n=typeof t.id==`string`?t.id.slice(0,64):``,r=typeof t.text==`string`?t.text.slice(0,PTe):``,i=typeof t.title==`string`?t.title.slice(0,NTe):``;return!n||!r.trim()?null:{id:n,title:i.trim()||LTe(r),text:r}}function LTe(e){let t=e.split(`
125
+ `).map(e=>e.trim()).find(Boolean)??``;return t.length>28?`${t.slice(0,28)}…`:t||`untitled`}function s3(){let e={list:[],removed:[]};try{let t=z(n3);if(!t)return[...a3];let n=JSON.parse(t);e={list:Array.isArray(n.list)?n.list.map(o3).filter(e=>!!e):[],removed:Array.isArray(n.removed)?n.removed.filter(e=>typeof e==`string`):[]}}catch{return[...a3]}let t=new Set(e.list.map(e=>e.id)),n=new Set(e.removed),r=a3.filter(e=>!t.has(e.id)&&!n.has(e.id));return[...e.list,...r].slice(0,r3)}function RTe(e){let t=e.map(o3).filter(e=>!!e).slice(0,r3),n=new Set(t.map(e=>e.id)),r=a3.filter(e=>!n.has(e.id)).map(e=>e.id);Ta(n3,{list:t,removed:r})}function zTe(){return wa(n3),[...a3]}function BTe(e){let t=t=>e.filter(e=>e.status===t).length,n=e.length,r=t(`pending`),i=t(`starting`),a=t(`running`),o=t(`done`),s=t(`failed`),c=n-r-i,l=[i&&`${i} starting`,r&&`${r} waiting`,a&&`${a} working`,o&&`${o} finished`,s&&`${s} failed`].filter(Boolean).join(` · `),u=r+i>0?`Kicking off: ${c} of ${n} started`:a>0?`All ${n} started`:`Sweep over`;return{total:n,waiting:r,starting:i,working:a,finished:o,failed:s,kicked:c,line:l?`${u} — ${l}`:u}}function VTe(e,t){return e?`Queued — the sweep starts ${t} session${t===1?``:`s`} when the link is back`:`Sent — waiting for the desktop to start ${t} session${t===1?``:`s`}`}function HTe(e){return e.error?e.error:e.sessionId?`tap to open the session`:e.status===`done`||e.status===`failed`?`its session has closed`:e.status===`pending`?`waiting to start`:`starting…`}var c3=R.fanoutSel,l3=R.fanoutText,u3=(e,t)=>ma(e,t),d3=(e,t)=>{Ta(e,t)};function UTe(e,t,n){if(!n)return null;let r={...n,backend:`backend`in n?n.backend:t.backend},i=iw(e,t,r);return i.backend!==r.backend||i.model!==r.model?null:{...i,effort:`effort`in n?n.effort:t.effort}}var f3=6,WTe={pending:`idle`,starting:`coding`,running:`coding`,done:`ok`,failed:`dead`};function GTe({repos:e,runs:t,backends:n,launch:r,onRun:i,onFollowUp:a,onSchedule:o,onOpen:s,CostHint:c,onClose:l,online:u=!0}){let[d,f]=(0,V.useState)(()=>u3(l3,``)),[p,m]=(0,V.useState)(()=>new Set(u3(c3,[]))),[h,g]=(0,V.useState)(s3);(0,V.useEffect)(()=>Mm(()=>g(s3()),[R.fanoutPresets]),[]);let[_,v]=(0,V.useState)(!1),[y,b]=(0,V.useState)(!1),[x,S]=(0,V.useState)(null),[C,w]=(0,V.useState)(``),[T,E]=(0,V.useState)(new Set),[D,O]=(0,V.useState)(()=>u3(R.fanoutModel,null)),k={backend:r.backend,model:r.model,effort:r.effort},A=UTe(n,r,D)??k,j=oq(r,A);function M(e){let t=e.backend===r.backend&&e.model===r.model&&e.effort===r.effort?null:{backend:e.backend,model:e.model,effort:e.effort};O(t),d3(R.fanoutModel,t)}let N=dw(n,A.backend),[P,F]=(0,V.useState)(null),ee=(0,V.useMemo)(()=>e.filter(e=>p.has(e.worktreePath)),[e,p]),te=ee.length?d.trim()?null:`write the instruction first`:`pick at least one repo`,ne=(0,V.useMemo)(()=>[...p],[p]);function re(e){q(`action:fanout.preset`);let t=d.trim(),n=h.some(e=>e.text.trim()===t),r=!t||n?e.text:`${d.replace(/\s+$/,``)}\n\n${e.text}`;f(r),d3(l3,r)}function ie(e){g(e),RTe(e)}function ae(e){m(new Set(e)),d3(c3,e)}let[oe,se]=(0,V.useState)(!1);function ce(){let e=ee.map(e=>e.worktreePath);e.length&&d.trim()&&(q(`action:fanout.run`),d3(l3,d),F({known:new Set(t.map(e=>e.id)),repos:e.length,offline:!u}),i(e,d.trim(),j,oe||void 0))}let le=P?t.find(e=>!P.known.has(e.id)):void 0,ue=le??(P?void 0:t.find(e=>!e.finishedAt)),de=ue?BTe(ue.targets):null,fe=e=>e.targets.filter(e=>e.sessionId);function pe(e){q(`action:fanout.followup.open`),S(e.id),w(``),E(new Set(fe(e).map(e=>e.dir)))}function me(e){E(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function he(e){let t=fe(e).filter(e=>T.has(e.dir)).map(e=>e.dir);t.length&&C.trim()&&(q(`action:fanout.followup`),a(e.id,C.trim(),t),S(null),w(``))}return Gh(y,()=>b(!1)),y?(0,J.jsx)(AO,{snippets:h,onSave:ie,onReset:()=>g(zTe()),onClose:()=>b(!1),heading:`Fan-out presets`,hint:(0,J.jsx)(J.Fragment,{children:`The one-tap chips over the fan-out prompt. Anything the CLI accepts works — slash commands included.`}),emptyText:`No presets. Tap “new” to add one, or “defaults” to restore the shipped list.`,textPlaceholder:`What should every selected repo do?`,trackId:`action:fanout.presets.save`}):(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Eo,{size:16}),` Fan-out`]}),onClose:l}),(0,J.jsx)(DO,{keys:[R.fanoutPresets],thing:`your saved sets`}),(0,J.jsxs)(`div`,{className:`sheet-scroll`,children:[(0,J.jsxs)(Z,{children:[`One prompt, a fresh CLI session per selected repo, all at once. Slash commands work (`,(0,J.jsx)(`span`,{className:`mono`,children:`/init`}),`, `,(0,J.jsx)(`span`,{className:`mono`,children:`/cost`}),`). Each session is a normal session afterwards — tap a result row to open it, or follow up in all of them at once.`]}),(0,J.jsxs)(`div`,{className:`form`,children:[(0,J.jsx)(yE,{inline:!0,rows:3,prompts:[d],onChange:e=>{let t=e[0]??``;f(t),d3(l3,t)},placeholder:`What should every selected repo do?`}),(0,J.jsxs)(`div`,{className:`annot-tools wrap`,children:[(_?h:h.slice(0,f3)).map(e=>(0,J.jsx)(Y,{title:e.text,onClick:()=>re(e),children:e.title},e.id)),h.length>f3&&(0,J.jsx)(Y,{onClick:()=>v(!_),children:_?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(mc,{size:14}),` less`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Nc,{size:14}),` `,h.length-f3,` more`]})}),(0,J.jsx)(Y,{title:`edit the preset list`,onClick:()=>{q(`action:fanout.presets.edit`),b(!0)},children:(0,J.jsx)(Mo,{size:14})})]}),(0,J.jsx)(sq,{backends:n,defaults:r,nowLead:`Every repo starts on`,value:A,onChange:M,children:D&&(0,J.jsxs)(X,{as:`span`,children:[`This sweep only — new sessions still start on `,r.model??`the default`,r.effort?` · ${r.effort}`:``,`.`,` `,(0,J.jsx)(`button`,{className:`link-btn`,onClick:()=>M(k),children:`use that`})]})}),(0,J.jsx)(`div`,{className:`annot-tools wrap`,children:(0,J.jsxs)(`button`,{className:`row-chip${oe?` on`:``}`,"aria-pressed":oe,"data-hint":`session.followup`,onClick:()=>se(e=>!e),children:[(0,J.jsx)(Ac,{size:13,fill:oe?`currentColor`:`none`}),` Flag for follow up when done`]})}),oe&&(0,J.jsx)(Z,{children:`Each session this run opens gets the follow-up flag once it is done — not if it failed or stopped on a usage limit. Not carried to “later”.`})]}),(0,J.jsx)(aF,{multi:!0,selected:ne,onChange:ae,repos:e,countHint:`· a fresh session in each`}),t.length>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`section`,children:`Runs`}),t.slice(0,5).map(e=>{let t=fe(e),n=x===e.id;return(0,J.jsxs)(`div`,{id:`fanout-run-${e.id}`,children:[(0,J.jsx)(Z,{children:e.text.length>90?`${e.text.slice(0,90)}…`:e.text}),e.followUps?.map((t,n)=>(0,J.jsxs)(Z,{children:[(0,J.jsx)(Lo,{size:11}),` `,t.text.length>90?`${t.text.slice(0,90)}…`:t.text,t.dirs.length<e.targets.length?(0,J.jsxs)(`span`,{className:`section-hint`,children:[` · `,t.dirs.length,` of `,e.targets.length]}):null]},n)),(0,J.jsx)(`div`,{className:`list`,children:e.targets.map(e=>(0,J.jsxs)(Xw,{kind:`wrap`,children:[(0,J.jsxs)(Xw,{as:e.sessionId?`button`:`div`,kind:`grow`,onClick:e.sessionId?()=>s(e.sessionId):void 0,children:[(0,J.jsxs)(Zw,{children:[e.status===`starting`||e.status===`running`?(0,J.jsx)($s,{size:12,className:`spin`}):null,e.status===`done`?(0,J.jsx)(Bc,{size:12}):null,e.status===`failed`?(0,J.jsx)(xs,{size:12}):null,` `,e.title,` `,(0,J.jsx)(qw,{className:WTe[e.status],children:e.status})]}),(0,J.jsx)(Q,{children:HTe(e)})]}),n&&(e.sessionId?(0,J.jsx)(`button`,{className:`row-act ${T.has(e.dir)?`on`:``}`,title:`include in the follow-up`,onClick:()=>me(e.dir),children:T.has(e.dir)?(0,J.jsx)(eo,{size:16}):(0,J.jsx)(ic,{size:16})}):(0,J.jsx)($w,{children:`no session to send to`}))]},e.dir))}),t.length>0&&!n&&(0,J.jsx)(`div`,{className:`form`,children:(0,J.jsxs)(Y,{"data-hint":`fanout.followup`,onClick:()=>pe(e),children:[(0,J.jsx)(Lo,{size:14}),` follow up in `,t.length,` session`,t.length===1?``:`s`]})}),n&&(0,J.jsxs)(`div`,{className:`form`,children:[(0,J.jsx)(yE,{inline:!0,rows:2,autoFocus:!0,prompts:[C],onChange:e=>w(e[0]??``),placeholder:`Next instruction for the selected sessions…`}),(0,J.jsxs)(`div`,{className:`annot-tools`,children:[(0,J.jsx)(Y,{onClick:()=>E(new Set(t.map(e=>e.dir))),children:`all`}),(0,J.jsx)(Y,{onClick:()=>E(new Set),children:`none`}),(0,J.jsx)(Y,{onClick:()=>{S(null),w(``)},children:`cancel`}),(0,J.jsx)(`span`,{className:`spacer`}),C.trim()?t.some(e=>T.has(e.dir))?(0,J.jsxs)(`button`,{className:`send`,onClick:()=>he(e),children:[(0,J.jsx)(Ec,{size:14}),` send to `,t.filter(e=>T.has(e.dir)).length]}):(0,J.jsx)($w,{children:`pick a session to send to`}):(0,J.jsx)($w,{children:`write the instruction first`})]})]})]},e.id)})]})]}),(de||P&&!le)&&(0,J.jsx)(`div`,{className:`fanout-kick`,children:de&&ue?(0,J.jsxs)(J.Fragment,{children:[de.waiting+de.starting>0?(0,J.jsx)($s,{size:14,className:`spin`}):de.failed?(0,J.jsx)(xs,{size:14}):de.working?(0,J.jsx)($s,{size:14,className:`spin`}):(0,J.jsx)(Bc,{size:14}),(0,J.jsx)(`span`,{className:`grow`,children:de.line}),(0,J.jsxs)(`button`,{className:`link-btn`,onClick:()=>document.getElementById(`fanout-run-${ue.id}`)?.scrollIntoView({behavior:`smooth`,block:`start`}),children:[`show the `,de.total]}),(0,J.jsx)(`span`,{className:`pull-bar`,children:(0,J.jsx)(`span`,{className:`pull-bar-fill`,style:{width:`${de.total?100*de.kicked/de.total:0}%`}})})]}):P&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)($s,{size:14,className:`spin`}),(0,J.jsx)(`span`,{className:`grow`,children:VTe(P.offline,P.repos)})]})}),c&&(0,J.jsx)(c,{text:d}),(0,J.jsxs)(`div`,{className:`sheet-actions`,children:[(0,J.jsx)(`span`,{className:`spacer`}),te?(0,J.jsx)($w,{children:te}):(0,J.jsxs)(Y,{"data-hint":`fanout.schedule`,title:`Run it later instead — once tonight, or every week at a time you pick`,onClick:()=>{q(`action:fanout.schedule`),d3(l3,d),o(ee.map(e=>e.worktreePath),d.trim(),j)},children:[(0,J.jsx)(rl,{size:16}),` later`]}),N?(0,J.jsx)($w,{children:N}):te?null:(0,J.jsxs)(`button`,{className:`send`,"data-hint":`fanout.run`,onClick:ce,title:u?void 0:`no connection — the sweep is queued and runs when the link is back`,children:[(0,J.jsx)(La,{size:16}),` `,u?`Run`:`Queue`,` in `,ee.length,` repo`,ee.length===1?``:`s`]})]})]})}var KTe=`fanout`;function qTe(e){return`fu:${e}`}function JTe(e,t){return e?`queued — the sweep runs when the link is back`:`fanning out to ${t} repo${t===1?``:`s`}`}function YTe(e,t){return e?`queued — the follow-up goes out when the link is back`:`following up in ${t} session${t===1?``:`s`}`}function XTe(e,t,n){let r=$t(e.convos,e.rest).find(e=>e.key===t.id);return!r||!(r.cost.total>0)?null:Re({same:st(t.text)===st(n),usd:r.cost.total,weekPct:null,agentPct:r.agentCost.total/r.cost.total*100,repos:r.repos})}var ZTe=3e5;function QTe(e,t,n){let r=(0,V.useMemo)(()=>oa(e,t),[e,t]),i=gh(`fanoutcost:${r?.id??`none`}`,async()=>r?sx.costWindow(r.startedAt-ZTe,(r.finishedAt??Date.now())+Ct):null,{enabled:!!r,offline:!n});return{text:(0,V.useMemo)(()=>r&&i.data?XTe(i.data,r,t):null,[r,i.data,t]),state:i.state}}function $Te({text:e}){let t=Dh(),n=QTe((0,V.useMemo)(()=>Ke(t.world.intents),[t.world.intents]),e,t.conn.status===`open`);return n.text?(0,J.jsxs)(`div`,{className:`empty ts-caveat`,title:`Read off the desktop's logs for that run. A reading, not a limit: Run still runs.`,children:[(0,J.jsx)(Xs,{size:13}),` `,n.text]}):null}function eEe(e,t,n,r){let i=U(),{cols:a,rows:o}=i.term.geom(),s=i.queue.queueOp({t:`fanout.run`,dirs:e,text:t,launch:i.launch.wire(n),...r?{flagWhenDone:!0}:{},cols:a,rows:o},KTe,t);i.say.toast(JTe(s,e.length))}function tEe(e,t,n){let r=U(),i=r.queue.queueOp({t:`fanout.followup`,runId:e,text:t,dirs:n},qTe(e),t);r.say.toast(YTe(i,n.length))}function nEe(e,t,n){U().nav.openSend({prompts:[t],target:{kind:`repos`,dirs:e,launch:n},when:OA(36e5),cwdHint:e[0]??null,origin:`This sweep, at a time you pick`})}function rEe(e){let t=U(),n=t.world.sessions.find(t=>t.id===e);n&&t.nav.attach(n)}function iEe(){let e=Dh(),{intents:t,visibleRepos:n,backends:r,launch:i}=e.world,a=(0,V.useMemo)(()=>Ke(t),[t]);return(0,J.jsx)(GTe,{repos:n,runs:a,backends:r,launch:i,online:e.conn.status===`open`,onRun:eEe,onFollowUp:tEe,onSchedule:nEe,onOpen:rEe,CostHint:$Te,onClose:()=>e.nav.close(`fanout`)})}var aEe={id:`fanout`,sheets:[{id:`fanout`,persisted:!1,render:()=>(0,V.createElement)(iEe)}]},p3=W(dT());function m3(){return G(p3)}function oEe(e){p3.set(e),Ta(R.snippets,e)}function sEe(){return Mm(()=>p3.set(dT()),[R.snippets])}function cEe(){let e=Dh();return(0,J.jsx)(AO,{snippets:m3(),onSave:oEe,onClose:()=>e.nav.close(`snippets`)})}var lEe={id:`snippets`,sheets:[{id:`snippets`,persisted:!1,render:()=>(0,V.createElement)(cEe)}],boot:()=>sEe()},h3={queued:{icon:fo,label:`waiting`},pending:{icon:$s,label:`sending`},failed:{icon:gs,label:`not delivered`}};function uEe({entries:e,laneLabel:t,sessions:n,repos:r,goneLanes:i,onEdit:a,onRemove:o,onMove:s,onRetarget:c,onToggleHold:l,onToggleSerial:u,serialSessions:d,onToggleSerialAll:f,onSendNow:p,onSendAll:m,onRetryFailed:h,onRestore:g,onResend:_,repoIdOf:v,onAddPrompt:y,onClose:b,online:x,launches:S,onCancelLaunch:C,onRunLaunch:w}){let[T,E]=(0,V.useState)(null),[D,O]=(0,V.useState)(``),k=am(e=>e.outstanding),[A,j]=(0,V.useState)(null),[M,N]=(0,V.useState)(null),[P,F]=(0,V.useState)(``),[ee,te]=(0,V.useState)(null),ne=n.filter(e=>e.running),re=S.filter(e=>e.state===`waiting`||e.state===`opening`),ie=[];for(let n of e){let e=ie.find(e=>e.id===n.sessionId);e||(e={id:n.sessionId,label:t(n),items:[]},ie.push(e)),e.items.push(n)}let ae=ie.map(e=>{let t=new Map;for(let n of e.items)if(n.mode!==`upload`&&n.text)for(let r of e.items)r.mode===`upload`&&r.upload&&!t.has(r.ackId)&&n.text.includes(r.upload.relPath)&&t.set(r.ackId,n.ackId);let n=[];return e.items.forEach((r,i)=>{if(r.mode===`upload`&&t.has(r.ackId))return;let a=e.items.map((e,t)=>({e,i:t})).filter(e=>t.get(e.e.ackId)===r.ackId);a.push({e:r,i}),n.push({key:r.ackId,rows:a})}),{...e,groups:n}}),oe=new Set(i),se=e=>e.status===`queued`&&(e.mode??`input`)===`input`&&oe.has(e.sessionId),ce=e.filter(se).length,le=e.filter(e=>e.status===`queued`).length,ue=e.filter(e=>e.status===`failed`&&e.failState!==`unconfirmed`&&e.failState!==`unsubmitted`).length;function de(e){E(e.ackId),O(e.text)}function fe(e){let t=D.trim();E(null),t?a(e,t):o(e)}function pe(t,n,i,a){let d=h3[t.status]??h3.queued,f=d.icon,m=t.status===`pending`,h=t.status===`failed`?`it didn't go through — try it again first`:`already on its way`,b=t.mode===`op`,S=t.mode===`upload`,C=!!t.answer,w=th(t),k=!b&&!S&&!C,re=t.status===`queued`&&t.retryAt!=null&&t.retryAt>Date.now()?t.retryAt-Date.now():null,ie=re==null?null:re<6e4?`${Math.max(1,Math.round(re/1e3))}s`:`${Math.round(re/6e4)} min`,ae=S?a:t,oe=!m&&(n>0||n<i.length-1)||t.status===`queued`||!m&&!b&&!S&&!C||!m&&!C&&!!ae,ce=b?`this is an action, not text`:S?`this is a file, not text`:C?`this is a tapped answer, not text`:``,le=[...n===0?[{label:`move earlier`,reason:`already first`}]:[],...n===i.length-1?[{label:`move later`,reason:`already last`}]:[],...ce?[{label:`put it back in the message box`,reason:ce}]:[],...C?[{label:`send again`,reason:`an answer only fits the question it was tapped on`}]:[]];return T===t.ackId?(0,J.jsxs)(`div`,{className:`queue-edit`,children:[(0,J.jsx)(yE,{inline:!0,rows:4,autoFocus:!0,prompts:[D],onChange:e=>O(e[0]??``),placeholder:`Rewrite it…`}),(0,J.jsxs)(`div`,{className:`queue-row-acts`,children:[(0,J.jsxs)(Y,{onClick:()=>E(null),children:[(0,J.jsx)(B,{size:16}),` cancel`]}),(0,J.jsx)(`span`,{className:`spacer`}),(0,J.jsx)(`button`,{className:`send`,onClick:()=>{q(`action:queue.edit`),fe(t.ackId)},children:`Save`})]})]},t.ackId):(0,J.jsxs)(`div`,{className:`queue-row-wrap ${A===t.ackId?`aiming`:``}`,children:[(0,J.jsxs)(`div`,{className:`queue-row ${t.status}`,children:[(0,J.jsxs)(`button`,{className:`queue-text`,disabled:!w,onClick:()=>de(t),title:m?`already on its way`:nh(t)?`tap to write what this session should do first`:C?`an answer to a question — the option you tapped, not text to rewrite`:w?`tap to edit`:`this one is an action, not text — nothing to rewrite`,children:[(0,J.jsx)(`span`,{className:`queue-text-body`,children:b?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(La,{size:11}),` `,t.text]}):S?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Io,{size:11}),` `,t.text]}):t.answer?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Ss,{size:11}),` `,t.answer.label,` — `,t.answer.question]}):t.text}),(0,J.jsxs)(`span`,{className:`queue-meta`,children:[(0,J.jsx)(f,{size:12,className:t.status===`pending`?`spin`:void 0}),d.label,t.mode===`backlog`?` · backlog item`:``,b?nh(t)?` · opens a session`:` · action`:``,t.pendingCreate?` · runs once that session is open`:``,S?` · file${t.upload?` · ${Math.max(1,Math.round(t.upload.size/1024))} kB`:``} · uploads before the prompt that names it`:``,C?` · answer · only sent while that question is still open`:``,se(t)?` · that session is gone — aim it somewhere else, or rewrite it`:``,t.holdUntilIdle?` · waiting until the session can take it`:``,t.serial?` · runs after this repo's other sessions`:rh(t)?` · starts even if this repo is busy`:``,t.reason?` · ${t.reason}`:``,ie==null?``:` · ${t.waitReason?`${t.waitReason} · `:``}retrying in ${ie}`,(t.tries??t.attempts??0)>1?` · ${t.tries??t.attempts} attempts`:``]})]}),(0,J.jsxs)(`div`,{className:`queue-row-acts`,children:[(x||t.status===`failed`)&&(0,J.jsx)(Y,{"data-hint":`queue.sendone`,disabled:t.status===`pending`,title:t.status===`pending`?`already on its way`:t.status===`failed`?x?`try this one again`:`put it back in the queue — it goes out when the link is back`:ie==null?`send this one now`:`waiting before the next attempt — tap to try it right now`,onClick:()=>{q(`action:queue.sendone`),p(t.ackId)},children:t.status===`failed`?(0,J.jsx)(xc,{size:16}):(0,J.jsx)(Uc,{size:16})}),(0,J.jsx)(Y,{variant:`danger`,"data-hint":`queue.remove`,title:`discard`,disabled:m,onClick:()=>{q(`action:queue.remove`),o(t.ackId)},children:(0,J.jsx)(ws,{size:16})}),oe&&(0,J.jsx)(Y,{className:ee===t.ackId?`on`:``,"data-hint":`queue.more`,title:ee===t.ackId?`hide the other actions`:`reorder, hold, re-aim, rewrite and send again`,"aria-expanded":ee===t.ackId,onClick:()=>te(ee===t.ackId?null:t.ackId),children:(0,J.jsx)(Jo,{size:16})})]})]}),!x&&t.status===`queued`&&(0,J.jsx)(Qw,{cants:[{label:`send now`,reason:`no connection yet`}]}),(S?!!t.upload:!b&&!C)&&(0,J.jsx)(lR,{compact:!0,text:S?t.upload.relPath:t.text,repoId:v(t),outbox:e,online:x}),ee===t.ackId&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`queue-row-acts queue-more`,children:[n>0&&(0,J.jsx)(Y,{"data-hint":`queue.moveup`,title:`move earlier`,disabled:m,onClick:()=>s(t.ackId,-1),children:(0,J.jsx)(to,{size:16})}),n<i.length-1&&(0,J.jsx)(Y,{"data-hint":`queue.movedown`,title:`move later`,disabled:m,onClick:()=>s(t.ackId,1),children:(0,J.jsx)(ts,{size:16})}),(0,J.jsx)(Y,{className:t.holdUntilIdle?`on`:``,"data-hint":`queue.hold`,disabled:t.status!==`queued`,title:t.status===`queued`?t.holdUntilIdle?`when it's free — the turn has ended, no question box is up and it isn't blocked on a usage limit. Tap to send at the next opportunity instead`:`when it's free: the turn ended, no question is on screen, no usage-limit block (exact for sessions that report turn boundaries; a guess from silence otherwise)`:h,onClick:()=>l(t.ackId),children:(0,J.jsx)(go,{size:16})}),rh(t)&&(0,J.jsx)(Y,{className:t.serial?`on`:``,"data-hint":`queue.serial`,disabled:t.status!==`queued`,title:t.status===`queued`?t.serial?`waiting until this repo's other sessions have finished — one agent at a time, so they don't spend the usage limit in parallel or edit the same files. Tap to let it start straight away`:`start it straight away, even if another session in this repo is working. Tap to make it wait its turn instead`:h,onClick:()=>u(t.ackId),children:(0,J.jsx)(ml,{size:16})}),k&&(0,J.jsx)(Y,{className:A===t.ackId?`on`:``,"data-hint":`queue.retarget`,disabled:t.status!==`queued`,title:t.status===`queued`?`send it somewhere else`:h,onClick:()=>j(A===t.ackId?null:t.ackId),children:(0,J.jsx)(So,{size:16})}),nh(t)&&(0,J.jsx)(Y,{className:M===t.ackId?`on`:``,"data-hint":`queue.addprompt`,disabled:t.status!==`queued`,title:t.status===`queued`?`add a prompt to run after this session opens`:h,onClick:()=>{N(M===t.ackId?null:t.ackId),F(``)},children:(0,J.jsx)(Fo,{size:16})}),!b&&!S&&!C&&(0,J.jsx)(Y,{"data-hint":`queue.restore`,title:`put the text back in the message box`,disabled:m,onClick:()=>{q(`action:queue.restore`),g(t.ackId)},children:(0,J.jsx)(ro,{size:16})}),!C&&!!ae&&(0,J.jsx)(Y,{"data-hint":`queue.resend`,title:S?`rewrite the message that names this file — re-attach it, swap it, or drop the mention`:`rewrite it, check the files it names, and send it again`,disabled:m,onClick:()=>{q(`action:queue.resend`),_(ae)},children:(0,J.jsx)(bc,{size:16})})]}),(0,J.jsx)(Qw,{cants:le})]}),M===t.ackId&&(0,J.jsxs)(`div`,{className:`queue-edit`,children:[(0,J.jsx)(Z,{style:{padding:0},children:`Runs in this session once it is open — after everything already queued for it has finished.`}),(0,J.jsx)(yE,{inline:!0,rows:3,autoFocus:!0,prompts:[P],onChange:e=>F(e[0]??``),placeholder:`…and then do this`}),(0,J.jsxs)(`div`,{className:`queue-row-acts`,children:[(0,J.jsxs)(Y,{onClick:()=>N(null),children:[(0,J.jsx)(B,{size:16}),` cancel`]}),(0,J.jsx)(`span`,{className:`spacer`}),(0,J.jsx)(`button`,{className:`send`,disabled:!P.trim(),onClick:()=>{y(t.ackId,P.trim()),N(null),F(``)},children:`Add`})]})]}),A===t.ackId&&k&&(0,J.jsxs)(`div`,{className:`queue-aim`,children:[(0,J.jsx)(Z,{children:`Send it to another session, or park it in a repo’s backlog.`}),ne.filter(e=>e.id!==t.sessionId).map(e=>(0,J.jsxs)(Xw,{as:`button`,onClick:()=>{j(null),c(t.ackId,{sessionId:e.id,cwd:e.cwd,mode:`input`})},children:[(0,J.jsxs)(Zw,{children:[(0,J.jsx)(Uc,{size:12}),` `,e.title]}),(0,J.jsx)(AR,{s:e}),(0,J.jsx)(Q,{children:e.turnActive?`working`:`idle`})]},e.id)),(0,J.jsx)(aF,{repos:r,listClass:``,home:t.cwd||null,subLead:`backlog item`,icon:(0,J.jsx)(Qs,{size:12}),onPick:e=>{j(null),c(t.ackId,{sessionId:e.worktreePath,cwd:e.worktreePath,mode:`backlog`})}})]})]},t.ackId)}return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:`Queued messages`,onClose:b,children:le>0&&(0,J.jsxs)(Y,{"data-hint":`queue.sendall`,title:x?`send everything queued now`:`no connection — this stays queued`,onClick:()=>{q(`action:queue.sendall`),m()},children:[(0,J.jsx)(Qs,{size:16}),` send all`]})}),(0,J.jsxs)(Z,{children:[x?`Connected. One message per session at a time, in order.`:`No connection. Everything here is kept on this phone and sent when the link is back.`,ue>0&&(0,J.jsxs)(J.Fragment,{children:[` `,ue,` gave up waiting. Try them again and they go back in the queue — now, or as soon as the link is back.`]}),ce>0&&(0,J.jsxs)(J.Fragment,{children:[` `,ce,` `,ce>1?`are`:`is`,` waiting for a session that has gone — they will not be sent. Under “⋯”, aim them at another session or at the repo’s backlog.`]})]}),ue>0&&(0,J.jsx)(`div`,{className:`queue-row-acts`,style:{padding:`0 12px 8px`},children:(0,J.jsxs)(Y,{"data-hint":`queue.retryall`,title:`put every message that gave up back in the queue, with its retry budget reset`,onClick:()=>{q(`action:queue.retryall`),h()},children:[(0,J.jsx)(xc,{size:14}),` try `,ue,` again`]})}),(0,J.jsx)(`div`,{className:`queue-row-acts`,style:{padding:`0 12px 8px`},children:(0,J.jsxs)(Y,{className:d?`on`:``,"data-hint":`queue.serialall`,title:d?`New queued prompts that open a session run ONE AT A TIME per repo: the next one starts when the one before it has finished its turn. Tap to let them all start together`:`New queued prompts that open a session all start as soon as the link is back — several agents in one repo at once. Tap to run them one at a time instead`,onClick:f,children:[(0,J.jsx)(ml,{size:14}),` one session at a time per repo: `,d?`on`:`off`]})}),(0,J.jsxs)(`details`,{className:`hint-more`,children:[(0,J.jsx)(`summary`,{children:`what the buttons do`}),(0,J.jsx)(`p`,{children:`Tap a message to rewrite it. The extra actions per row are behind “⋯”: reorder, hold until that session finishes its turn, aim it at another session, or put the text back in the message box.`}),(0,J.jsx)(`p`,{children:`Rows marked “action” (fan out, run a build) carry a payload rather than text — they can be held, sent or dropped, but not rewritten or re-aimed.`}),(0,J.jsx)(`p`,{children:`A row that OPENS a session is different: tap it to write what it should do first, or use + to queue further prompts, each delivered once the one before it has finished.`}),(0,J.jsx)(`p`,{children:`Several opens queued for the SAME repo run one after another by default — otherwise they would all start at once, spend the usage limit in parallel without finishing anything, and edit the same files. The list icon on a row flips that for that one open; the switch above flips it for new ones.`}),(0,J.jsx)(`p`,{children:`A row in red gave up — the link was down longer than a message is allowed to wait. Nothing was sent and nothing was lost: “try again” puts it back in the queue, and works with the link still down. Under “⋯”, the pencil-and-page rewrites it instead, which is also where a file that never uploaded is re-attached or dropped.`}),(0,J.jsx)(`p`,{children:`Press and hold any button — here or anywhere in the app — to read what it does. Holding never presses it.`})]}),(0,J.jsxs)(`div`,{className:`list`,children:[re.length>0&&(0,J.jsxs)(`div`,{className:`queue-lane`,children:[(0,J.jsxs)(`div`,{className:`queue-lane-head`,children:[(0,J.jsx)(`span`,{className:`queue-lane-title`,children:`waiting on the desktop`}),(0,J.jsx)(`span`,{className:`queue-lane-count`,children:re.length})]}),(0,J.jsx)(Z,{style:{paddingTop:0},children:`The desktop has these and will open them itself when the files land — this phone can be closed.`}),re.map(e=>(0,J.jsx)(`div`,{className:`queue-row-wrap`,children:(0,J.jsxs)(`div`,{className:`queue-row queued`,children:[(0,J.jsxs)(`div`,{className:`queue-text`,style:{cursor:`default`},children:[(0,J.jsxs)(`span`,{className:`queue-text-body`,children:[(0,J.jsx)(La,{size:11}),` `,e.prompt||`open ${e.repoName||e.cwd}`]}),(0,J.jsxs)(`span`,{className:`queue-meta`,children:[(0,J.jsx)(fo,{size:12}),` `,eee(e),e.repoName?` · ${e.repoName}`:``,` · gives up ${new Date(e.deadlineAt).toLocaleString()}`]})]}),(0,J.jsxs)(`div`,{className:`queue-row-acts`,children:[(0,J.jsx)(Y,{title:`open the session now, without the files it is waiting for — the prompt inside it will still name them`,onClick:()=>{q(`action:launch.run`),w(e.id)},children:(0,J.jsx)(La,{size:16})}),(0,J.jsx)(Y,{variant:`danger`,title:`call it off — the session never opens`,onClick:()=>{q(`action:launch.cancel`),C(e.id)},children:(0,J.jsx)(B,{size:16})})]})]})},e.id))]}),ie.length===0&&re.length===0&&(0,J.jsx)($,{children:k===0?(0,J.jsxs)(`span`,{className:`qs-clear`,children:[(0,J.jsx)(Bc,{size:14}),` Nothing queued — everything written on this phone has reached the desktop.`]}):(0,J.jsxs)(J.Fragment,{children:[`Nothing queued to send. `,k===1?`One thing`:`${k} things`,` written here `,k===1?`is`:`are`,` still being pushed to the desktop — settings, templates and notes travel on their own path and need no tap.`]})}),ae.map(e=>(0,J.jsxs)(`div`,{className:`queue-lane`,children:[(0,J.jsxs)(`div`,{className:`queue-lane-head`,children:[(0,J.jsx)(`span`,{className:`queue-lane-title`,children:e.label}),(0,J.jsx)(`span`,{className:`queue-lane-count`,children:e.items.length})]}),e.groups.map(t=>{let n=t.rows.length-1;return n?(0,J.jsxs)(`div`,{className:`queue-bundle`,children:[(0,J.jsxs)(`div`,{className:`queue-bundle-head`,children:[(0,J.jsx)(Io,{size:11}),` `,n,` `,n===1?`file`:`files`,` + the message that names `,n===1?`it`:`them`,` — sent in this order`]}),t.rows.map(n=>pe(n.e,n.i,e.items,t.rows[t.rows.length-1].e))]},t.key):(0,J.jsx)(`div`,{children:pe(t.rows[0].e,t.rows[0].i,e.items)},t.key)})]},e.id))]}),(0,J.jsxs)(`div`,{className:`sheet-actions`,children:[(0,J.jsxs)(Y,{onClick:b,children:[(0,J.jsx)(Ns,{size:16}),` back`]}),(0,J.jsx)(`span`,{className:`spacer`}),(0,J.jsxs)(X,{as:`span`,style:{padding:0},children:[le,` waiting`]}),(0,J.jsx)(Mo,{size:14,style:{opacity:.35}})]})]})}function dEe(e){return e?`new queued work will run one session at a time per repo`:`new queued work will all start at once`}function fEe(){let e=U(),t=!e.queue.serial.on;e.queue.serial.set(t),e.say.toast(dEe(t))}function pEe(){let e=U(),t=e.queue.flush(!0);e.say.toast(t?`sending…`:e.queue.idleReason(`nothing left to send`))}function mEe(e){let t=U();t.nav.openSend({prompts:[rj(e)],target:t.send.targetFor(e.sessionId,e.cwd),cwdHint:e.cwd,repoId:t.queue.repoIdOf(e),ackId:e.ackId,repair:!0,origin:e.status===`failed`?`This one never went`:`Queued, not sent yet`,openAfter:!0})}function hEe(){let e=Dh(),{liveSend:t}=e.conn,n=e.queue.verbs,r=Oh();return(0,J.jsx)(uEe,{entries:r,laneLabel:e.queue.laneLabel,online:e.conn.status===`open`,sessions:e.world.sessions,repos:e.world.visibleRepos,goneLanes:e.queue.goneLanes(),launches:e.world.launches,onCancelLaunch:e=>t({t:`launch.cancel`,id:e},`called off — that session will not open`,zj),onRunLaunch:e=>t({t:`launch.run`,id:e},`opening it now, without the files it was waiting for`,zj),onEdit:n.editQueued,onRemove:n.removeQueued,onMove:n.moveQueued,onRetarget:n.retargetQueued,onToggleHold:n.toggleHoldQueued,onToggleSerial:n.toggleSerialQueued,serialSessions:e.queue.serial.on,onToggleSerialAll:fEe,onSendNow:n.sendQueuedNow,onRetryFailed:n.retryFailedQueued,onSendAll:pEe,onRestore:n.restoreQueued,onAddPrompt:n.addPromptToQueuedCreate,onClose:()=>e.nav.close(`queue`),repoIdOf:e.queue.repoIdOf,onResend:mEe})}var gEe={id:`queue`,sheets:[{id:`queue`,persisted:!1,render:()=>(0,V.createElement)(hEe)}]},g3=[`size`,`retouch`,`hatches`,`context`,`untested`],_3={size:`File length`,retouch:`Re-touched files`,hatches:`Escape hatches`,context:`CLAUDE.md + skills`,untested:`Untested modules`},_Ee={"size.p95":`size`,"retouch.rate":`retouch`,"hatches.perKloc":`hatches`,"context.claudeMdChars":`context`,"context.descChars":`context`,"untested.count":`untested`},vEe={size:`the average line in a file under 500 lines and the longest file under 1,000`,retouch:`under 15% of recent file edits reworking the edit before`,hatches:`under 2 unexplained escape hatches per 1,000 lines`,context:`CLAUDE.md + skill descriptions under the repo's warn line (16,000 characters by default)`,untested:`under 20% of source files with no test reaching them`},yEe={size:`a blend of two levels, in lines, over the source files (tests excluded): the line-weighted mean file length (the length of the file the average line lives in, which one giant file drags up) and the longest file; the two scores are blended geometrically, and each can raise an alert by itself`,retouch:`a rate over the last 14 days: the share of source-file edits that REWORK the previous edit of that file — change or remove lines it added, under 48 hours (or 2 commits) after it; an edit that only adds lines near the last one (an append to a registry) is reported apart and never counted — it reads the latest fortnight's work, not the tree`,hatches:`a density: UNEXPLAINED escape hatches per 1,000 source lines — casts, lint and type-check disables that carry no reason on the line or in a comment directly above; the explained ones and TODO/FIXME marks are reported apart and never counted, and the count can rise while the density falls if the code grows faster`,context:`an absolute size: the characters always loaded — CLAUDE.md plus every skill's description; skill bodies, loaded on demand, are not counted`,untested:`a share: source modules no test imports (directly or through another module) or names by path, over all source files — imported is not covered, it says nothing about which branches ran`};function v3(e){let t=Math.round(e);return t===0?`±0`:t<0?`−${-t}`:`+${t}`}function y3(e,t){return t&&e===t?`this week`:`in the week of ${e}`}function bEe(e,t,n){if(!e||typeof e.value!=`number`||!Number.isFinite(e.value))return null;let r=Math.round(e.value),i=e.deltaWeek,a=typeof i==`number`&&Number.isFinite(i),o=a?Math.round(i):0,s=!a||o===0?null:o<0?`down`:`up`,c=e.alert===`severe`?`severe`:e.alert===`warn`||e.move===`drop`?`warn`:e.move===`rise`?`calm`:null,l=y3(e.week,n),u=e.move===`drop`?` The latest week's move is unusual for this repo's own past: it slipped.`:e.move===`rise`?` The latest week's move is unusual for this repo's own past: it rose.`:``;return{label:`Health ${r}`,delta:a&&o!==0?String(Math.abs(o)):null,arrow:s,tone:c,title:`${t}: health index ${r}${a?` (${v3(i)} ${l})`:``}${l===`this week`||!a?`, week of ${e.week}`:``}. A score out of 100 against fixed good values for five readings of the repo, held within 30 of its worst one.${e.alertText?` ${e.alertText}.`:``}${u} Tap to open the readings.`}}function b3(e){return e.length<=1?e[0]??``:`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`}function x3(e,t){let n=g3.filter(t=>e?.disabled?.includes(t)),r=g3.filter(t=>e?.overridden?.includes(t)&&!n.includes(t));if(!n.length&&!r.length)return null;let i=[`Built from ${g3.length-n.length} of ${t}'s ${g3.length} readings`];return n.length&&i.push(`${b3(n.map(e=>_3[e]))} ${n.length===1?`is`:`are`} disabled here`),r.length&&i.push(`${b3(r.map(e=>_3[e]))} ${r.length===1?`reads`:`read`} this repo's own version`),`${i.join(`; `)}.`}function xEe(e,t,n){let r=x3(n,t),i=`A score out of 100 for ${t}'s five readings — never a repo's own — against fixed good values: ${g3.map(e=>vEe[e]).join(`; `)}. At a good value an entry scores 100, and it halves as the reading doubles past it. The score is the average of the entries' scores, and it stays within 30 of its worst entry, so one reading on fire cannot hide behind four quiet ones.`,a=`The second line is the trend: the score now against the first scored week, ${e}, and against last week.`;return r?`${i} ${r} ${a} Beside another repo's score it compares like with like only on the readings both read the same way.`:`${i} ${a} The good values are the same in every repo, so it compares across repos.`}function SEe(e){let t=e?.[e.length-1];return!!t&&typeof t.mean!=`number`}var CEe=e=>`This desktop runs an older ${e} — restart it to see the score.`;function wEe(e){return e===1?`One week's move is not compared with the week before: the engine's or this repo's definition changed that week. Its score is still measured — put the line on it to read why.`:`${e} weeks' moves are not compared with the week before: the engine's or this repo's definition changed in each. Their scores are still measured — put the line on one to read why.`}function S3(e){return e===`central`?`move not compared: this repo changed which readings it overrides or disables that week`:e===`prereg`?`move not compared: the engine's definitions changed that week`:`move not compared with the week before`}function TEe(e){return typeof e!=`number`||!(e>7)?null:`one link over ${Math.round(e/7)} weeks with no measured week between`}function EEe(e,t,n){let r=t?y3(t,n):`this week`;return e===null||!Number.isFinite(e)?`no change to state ${r}`:`${v3(e)} ${r}`}function DEe(e,t,n){return`${v3(e-t)} since ${n}`}function OEe(e){return!e||!Number.isFinite(e.delta)?null:`${v3(e.delta)} vs week of ${e.then.week}`}var C3=e=>Math.round(e).toLocaleString(`en-US`);function kEe(e,t,n){if(!e||!t||!(e.files>0)||!(e.loc>0))return null;let r=(e,t)=>{let n=Math.round((t-e)/e*100);return n===0?`±0%`:n>0?`+${n}%`:`−${-n}%`};return`The tree: ${C3(t.files)} source files and ${C3(t.loc)} lines, against ${C3(e.files)} and ${C3(e.loc)} in the first scored week ${n} (${r(e.files,t.files)} files, ${r(e.loc,t.loc)} lines).`}function w3(e,t,n){let r=e.length;if(r<1||!(t>0)||!(n>0))return null;let i=1/0,a=-1/0;for(let t of e){if(!Number.isFinite(t.index))return null;t.index<i&&(i=t.index),t.index>a&&(a=t.index)}let o=e=>r===1?t:e/(r-1)*t,s=e=>n-.5-Math.max(0,Math.min(100,e))/100*(n-1),c=[],l=[],u=[],d=e.map((e,t)=>({i:t,x:o(t),y:s(e.index)})),f=e.map((e,t)=>t>0&&!e.gap&&typeof e.spanDays==`number`&&e.spanDays>7),p=e.map((e,t)=>t>0&&!e.gap&&!f[t]),m=0,h=[],g=()=>{if(h.length>1)c.push(`M${h.map(e=>`${d[e].x.toFixed(1)},${d[e].y.toFixed(1)}`).join(`L`)}`);else if(h.length===1){let e=h[0];!f[e]&&!f[e+1]&&u.push({x:d[e].x,y:d[e].y})}h=[]};for(let t=0;t<r;t++)e[t].gap&&m++,p[t]||g(),f[t]&&l.push(`M${d[t-1].x.toFixed(1)},${d[t-1].y.toFixed(1)}L${d[t].x.toFixed(1)},${d[t].y.toFixed(1)}`),h.push(t);g();let _=d[d.length-1];return{d:c.join(``),dashed:l.join(``),dots:u,pts:d,endX:_.x,endY:_.y,rules:[100,50,0].map(e=>({v:e,y:s(e)})),lo:i,hi:a,gaps:m}}function AEe(e){let t=e.rules.find(e=>e.v===0)?.y;if(!e.d||typeof t!=`number`)return``;let n=t.toFixed(1);return e.d.split(`M`).filter(Boolean).map(e=>{let t=e.split(`L`),r=t[0].split(`,`)[0],i=t[t.length-1].split(`,`)[0];return`M${r},${n}L${e}L${i},${n}Z`}).join(``)}function jEe(e,t,n){let r=w3(e.map(e=>({index:e.index,gap:e.gap})),t,n);if(!r)return null;let i=[];for(let t=1;t<e.length;t++)e[t].week!==e[t-1].week&&i.push({x:r.pts[t].x,week:e[t].week});let a=e.length,o=a===1?[0]:a===2?[0,1]:[0,Math.floor((a-1)/2),a-1],s=o.map((t,n)=>({x:r.pts[t].x,day:e[t].day,anchor:a===1?`end`:n===0?`start`:n===o.length-1?`end`:`middle`}));return{...r,weekRules:i,ticks:s}}function T3(e,t){let n=Math.round(t.index);return e===`commits`&&t.sha7?`Commit ${t.sha7}, ${t.day??t.week}: ${n}`:`Week of ${t.week}: ${n}`}function MEe(e,t){return t>e?`${C3(e)} of ${C3(t)} commits drawn`:null}var NEe={score:`Score`,longest:`Longest`,tiles:`Tiles`,weight:`Weight`,size:`Size`,table:`Table`,own:`Own`},PEe=`Drag across a chart to read a value.`;function E3(e){return e===`weeks`?`weeks: one point per week, its last reading`:`commits: one point per scored commit, a faint rule where a new week starts; the tiles and stacks draw one point per day, its last commit`}var D3=e=>`This desktop runs an older ${e}, which sends the health index per week only — restart it to read it per commit.`;function FEe(e){return`What moved the score is counted per week, so the bars show the week of ${e} in either mode.`}function IEe(e,t){let n=t/2,r=g3.filter(t=>typeof e[t]==`number`&&Number.isFinite(e[t])),i=0;for(let t of r)i=Math.max(i,Math.abs(e[t]));let a=Math.max(0,t/2-1);return{zeroX:n,bars:r.map(t=>{let r=e[t],o=i>0?Math.abs(r)/i*a:0,s=Math.round(r*10)===0?`none`:r>0?`up`:`down`;return{key:t,name:_3[t],value:r,x:r>=0?n:n-o,w:o,side:s,words:`${_3[t]} ${O3(r)}`}})}}function O3(e){let t=Math.round(e*10)/10;return t===0?`±0.0`:t<0?`−${(-t).toFixed(1)}`:`+${t.toFixed(1)}`}function LEe(e){return`Each reading's score in the week of ${e}, out of 100, and what it added to the score that week, in points. A bar to the right pushed the score up (that reading shrank); a bar to the left pulled it down (that reading grew).`}function REe(e,t,n,r,i,a){return n?null:`${DEe(e,t.index,t.week)}, ${EEe(r,i,a)}`}function zEe(e,t){return t?`ask what moved it this week`:`ask what moved it in the week of ${e}`}var BEe=`assess and propose improvements`;function VEe(e){let t=Math.round(e/1e3);if(t<90)return`${t} s`;let n=Math.round(t/60);return`${n} minute${n===1?``:`s`}`}function k3(e,t){if(!e)return null;let n=e.slice(0,7);return t?`${n} (${t})`:n}function A3(e){return Math.round(e*100)}function j3(e){let t=e%100;if(t>=11&&t<=13)return`${e}th`;let n=e%10;return`${e}${n===1?`st`:n===2?`nd`:n===3?`rd`:`th`}`}function M3(e){return Math.round(e).toLocaleString()}function HEe(e,t){if(e.length<=t)return e;let n=e=>{if(e.length<=t)return e;if(t<2)return`…`.slice(0,Math.max(0,t));let n=t-1,r=Math.ceil(n/2);return`${e.slice(0,r)}…${e.slice(e.length-(n-r))}`},r=e.split(`/`);if(r.length<2)return n(e);let i=r[r.length-1];if(`…/${i}`.length>t)return n(i);let a=r.slice(0,-1),o=[],s=[],c=(e,n)=>e.map(e=>`${e}/`).join(``).length+2+[...n,i].join(`/`).length<=t,l=0,u=a.length-1;for(c([a[0]],[])&&(o.push(a[0]),l=1);u>=l&&c(o,[a[u],...s]);)s.unshift(a[u]),u--;for(;l<=u&&c([...o,a[l]],s);)o.push(a[l]),l++;return`${o.map(e=>`${e}/`).join(``)}…/${[...s,i].join(`/`)}`}function UEe(e,t){return`Nothing has been measured yet. A first run walks ${e!=null&&Number.isFinite(e)&&e>0?`${M3(e)} first-parent commit${e===1?``:`s`}`:`every first-parent commit`} in this repo. Rows are appended as it goes, so a run that hits ${t!=null&&Number.isFinite(t)&&t>0?`this desktop's cap of ${VEe(t)} on one step`:`this desktop's cap on one step`} keeps every row it measured and the next tap carries on from there. It spends no tokens: git, regex and arithmetic, and the one module that can call a model is not on this path.`}function WEe(e){return`The engine could not read this repo, and said: ${e} Nothing was measured, so there is nothing here to draw.`}function N3(){return`One row per first-parent commit: file sizes, escape hatches, co-change, untested modules, the weight of the agent instructions. It spends no tokens.`}function GEe(e){let t=[];e.kind===`repo`?t.push(`read by this repo's own copy of the engine`):e.kind===`bundled`&&t.push(`read by this desktop's engine, pointed at the worktree`),e.version&&t.push(`version ${e.version}`);let n=!!e.packs?.length&&e.packs.every(e=>e.files===0);if(e.packs){let r=e.packs.length,i=e.packs.map(e=>e.name).join(`, `);r?n?t.push(`no language pack reads this tree's source — ${i} ${r===1?`is`:`are`} active and claim${r===1?`s`:``} no file extension`):t.push(`packs ${e.packs.map(e=>e.files==null?`${e.name} (no count)`:`${e.name} ${M3(e.files)}`).join(`, `)}`):t.push(`the engine named no language pack for this tree`)}if(!t.length)return null;let r=e.packs?.length&&!n?` — the figure beside a pack is the extension census's count for it.`:``;return`${t.join(` · `)}${r}`}function KEe(e){return e&&(e.rows??0)>0?`update the series`:`build the series`}function P3(e,t){return`${e&&(e.rows??0)>0?`updating`:`building`}… ${Math.max(0,Math.round(t/1e3))} s`}function qEe(e){let t=Math.max(0,e)/1e3;return t<60?`${t.toFixed(1)} s`:`${Math.round(t)} s`}function JEe(e){let t=k3(e.lastSha,e.lastDay);if(!t)return null;let n=k3(e.headSha,null);return e.behind==null?`could not tell how far behind — last row ${t}, HEAD ${n??`unknown`}`:e.behind<=0?n?`up to date — HEAD ${n} is the last row`:`up to date — ${t} is the last row`:`${`${e.behind} commit${e.behind===1?``:`s`} since the last reading`} — last row ${t}, HEAD ${n??`unknown`}`}function YEe(e){if(!k3(e.lastSha,e.lastDay))return null;let t=e.behind==null?`could not tell how far behind`:e.behind<=0?`up to date`:`${M3(e.behind)} commit${e.behind===1?``:`s`} since the last reading`;if(!e.rows)return t;let n=e.days?` over ${M3(e.days)} day${e.days===1?``:`s`}`:``;return`${t} · ${M3(e.rows)} commit${e.rows===1?``:`s`} measured${n}`}function XEe(e){if(!e||!e.rows)return null;let t=e.days==null?``:` over ${e.days} day${e.days===1?``:`s`}`,n=e.preregVersion?`, definition ${e.preregVersion}`:``;return`${e.rows} row${e.rows===1?``:`s`}${t}${n}`}function ZEe(e){return!e||!e.length?null:`${e.length===1?`warning`:`warnings`}: ${e.join(` · `)}`}function QEe(e){return`the request did not reach the desktop: ${e}. Nothing ran there, and nothing about this repo was read — what is on screen is what was already on it.`}function $Ee(e){let t=e??0;return t<=0?null:`${t} row${t===1?``:`s`} in the file measure${t===1?`s`:``} a commit this repo no longer has — a rebase, an amend or a dropped branch. They stay in the file, which is append-only, and are left out of the reading.`}function eDe(e){return`narrative written ${e}`}function tDe(e){return`last commit ${e}`}function nDe(e,t,n){let r=e??[],i=r.length===1&&!!t&&r[0].version!==t;if(r.length<2&&!i)return null;let a=r.map(e=>`${e.version}${e.version===t?` (current)`:``}: ${e.rows} row${e.rows===1?``:`s`}`).join(`, `),o=n?`To re-cut the whole history under the current definition, run this at the desktop: ${n}`:`To re-cut the whole history under the current definition, ask the desktop for the command — this engine did not print one, and the line that re-cuts a repo deletes a file, so a guess written down here is not offered.`;return`${i?`every row in the series was measured under ${r[0].version} (${r[0].rows} row${r[0].rows===1?``:`s`}), and the engine now measures under ${t}`:`the series holds rows measured under ${r.length} definitions of the same metric — ${a}`}. A refresh will refuse rather than put them on one plot, and nothing here rewrites the file. ${o}`}var rDe=(e,t,n)=>!!e&&!!t&&!n&&!e.refused&&e.ok===!1;function iDe(e){let t=e.ms==null?``:` after ${qEe(e.ms)}`;return e.refused?`the last run ran and declined to append${e.refused.code==null?``:` (exit ${e.refused.code})`}${t} — its own words below, in full.`:e.ok===!1?`the last run stopped${e.step?` at ${e.step}`:``}${t}${e.error?`: ${e.error}`:`.`}`:e.added==null?`the last run finished${t}; its summary did not say how many rows it appended.`:e.added===0?`the last run added no rows${t} — the series already reached HEAD.`:`the last run added ${e.added} row${e.added===1?``:`s`}${t}.`}function aDe(e,t){return e?`a run is going on the desktop${e.startedAt==null?``:` — started ${Math.max(0,Math.round((t-e.startedAt)/1e3))} s ago`}${e.note?`: ${e.note}`:``}`:null}function oDe(e){return e?`Everything above is also drawn to .claude/outbox/repohealth.html on the desktop, where the cards fit side by side. Nothing on it is missing from this screen.`:`.claude/outbox/repohealth.html is not written yet — a refresh draws it. It is the same cards as above, laid out for a desktop; nothing on this screen is waiting on it.`}function F3(e,t=``){if(e==null||!Number.isFinite(e))return`—`;let n=Number.isInteger(e)?M3(e):Math.abs(e)<10?e.toFixed(2):M3(e);return t?`${n} ${t}`:n}function I3(e){if(!e)return null;if(e.rank==null)return e.reason??`not enough history (${e.n} readings)`;let t=e.from?` back to ${e.from}`:``,n=e.slope?`, ${e.slope}`:``;return`${j3(A3(e.rank))} percentile of the last ${M3(e.n)} readings${t}${n}`}function sDe(e){return!e||e.rank==null?null:`${j3(A3(e.rank))} percentile of ${M3(e.n)}`}var cDe={"size.p95":`how long a large file runs — 95 in 100 source files are shorter`,"retouch.rate":`the share of file edits that reworked lines the edit just before had added`,"hatches.perKloc":`places a type or lint rule was switched off with no reason given, per 1,000 lines`,"context.claudeMdChars":`what every turn in this repo re-sends before anyone types`,"context.descChars":`the one-line skill descriptions that ride in every window`,"context.skillCount":`how many skills the repo ships`,"untested.count":`source modules no test names or reaches through imports`};function lDe(e){return cDe[e]??null}function uDe(e){if(e.absent)return`this reading was not taken on the latest day — ${e.absent}`;let t=e.readings??0,n=e.minToDraw??2;return t===0?`no reading in the whole series — nothing to draw.`:t<n?`${t} reading${t===1?``:`s`} in the series — a curve needs ${n}, so the figure stands alone.`:null}var dDe=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`];function L3(e){if(!e)return``;let t=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!t)return e;let n=Number(t[2])-1;return n<0||n>11?e:`${Number(t[3])} ${dDe[n]}`}function R3(e,t=``){if(!e)return null;let n=e.v==null||!Number.isFinite(e.v)?`no reading that day`:F3(e.v,t);return`${e.day} · ${n}${e.sha7?` · ${e.sha7}`:``}`}function fDe(e,t,n,r=``){if(!e)return null;let i=t.map(e=>`${e.label} ${e.v==null||!Number.isFinite(e.v)?`not read`:M3(e.v)}`).join(`, `),a=n==null||!Number.isFinite(n)?`no total that day`:`${F3(n,r)} in all`;return`${e.day} · ${a}${i?` — ${i}`:``}${e.sha7?` · ${e.sha7}`:``}`}function pDe(e,t){return`A rank is a position among the last ${M3(e)} readings of that series, and is withheld below ${M3(t)} — the tool's own window, carried on the wire so nothing here writes it down.`}function mDe(e){return e??null}function hDe(e,t,n){let r=e!=null&&Number.isFinite(e)?F3(e):null,i=t!=null&&Number.isFinite(t)?F3(t):null,a=`at ${n??`the last reading`}`;return r==null&&i==null?null:r==null?`${i} ${a} — the sentence above is the same number in the working tree as it is now. Two clocks, left as they are.`:i==null?`${r} in the working tree — the series has no reading of it to sit beside.`:`${r} in the working tree · ${i} ${a} — two clocks on one number, left as they are.`}function gDe(){return`Per area, on the latest reading: what a change there usually carries (CLAUDE.md, every description, the router and the sub-skills that commit's own files claim) and what it carries with every one of that area's bodies loaded. Re-partitioning moves the near end and cannot move the far one; deleting prose moves both.`}function z3(e){let t=[];return e.expected==null?e.reason?t.push(e.reason):t.push(`no commit has touched this area yet, so there is no usual load`):t.push(`usually ${F3(e.expected)} chars`),e.ceiling!=null&&t.push(`up to ${F3(e.ceiling)}`),e.p90!=null&&t.push(`p90 ${F3(e.p90)}`),e.commits!=null&&t.push(`over ${M3(e.commits)} commit${e.commits===1?``:`s`}`),e.subs===0?t.push(`no sub-skills, so the two ends are one number`):e.subs!=null&&t.push(`${M3(e.subs)} sub-skill${e.subs===1?``:`s`}`),t.join(` · `)}function _De(e,t){return`The last ${M3(e)} day-rows of ${M3(t)}, oldest first — the same direction the charts run, so a row and a column of pixels above it are the same day. Every figure here is drawn somewhere above; this is the copy that can be read without touching anything, and the only one that shows two days at once.`}function vDe(){return`Not on these charts: the tripwires, which are events on one day rather than a series; the path lists, whose first three ride in the sentence under the reading they belong to and the rest in the narrative below; and the duplicate-block and co-change rates, which the tool reads without a rank — a curve under them would invite a reading nothing measured.`}function B3(e){let t=e??[];return t.length<2?null:`These charts plot the rows as they are on disk, under ${t.length} definitions of the same metric. Nothing here re-cuts or re-reads them: refusing to draw would remove the only view of the problem the band above describes.`}var yDe=`ask if this is serving the repo`,bDe=`ask this of all of them`;function xDe(){return`A reading is not a finding: there is no line here to be on the wrong side of, so nothing on these charts is counted into the badge and nothing offers a fix. The verb on a row opens a prompt about the thing the reading is OF — the skills, the files, the tests — asking whether it suits the work in this repo and what you would change, with the tool's own sentence quoted as the thing that prompted the question. Leaving it alone is one of the answers. The verb under all of them carries every reading at once, the absences and their reasons included, and asks which of them move for the same reason. Nothing is sent by the tap.`}function SDe(e){return`daily notes (${M3(e)} day${e===1?``:`s`})`}function CDe(e,t,n,r){let i=n&&r?`, ${n} to ${r}`:``;return{lead:`Each tile plots ${e===`weeks`?`${M3(t)} week${t===1?``:`s`}, one point per week — its last day-reading`:`${M3(t)} day-reading${t===1?``:`s`}, one per day the series has — that day's last commit`}${i}, spaced by position in the series, not by date.`,more:`The history has gaps of weeks and a calendar axis would leave most of every tile empty. The dates under a tile are the days AT those positions, so the middle label is the middle reading and not the middle of the span. A missing reading cuts the line rather than joining across it. The figures up the left are that tile's own low and high, and NO TILE STARTS AT ZERO: each is fitted to its own range, so heights are not comparable between them. The stacked chart further down is the exception and says so with a zero of its own.`}}function wDe(e){return e===`setup`?`Against the conventions: each row compares a fact about this repo to a line somebody chose, so it can be on the wrong side of it. That is what a finding is, and what the badge counts.`:`Against its own past: each reading compares a fact about this repo to the same fact on earlier commits. There is no side to be on, so nothing here has a status, a colour or a place in the badge.`}var TDe=`whole repo`;function EDe(e){return`These readings are of ${e} alone, measured as though it were the repo: its own groups, its own instructions, and only the commits that touched it. Every path below is relative to ${e}/.`}function DDe(){return`Pick the parts of this repo worth their own readings. Each one gets its own series, measured over the commits that touched it, and the first run of one walks that history from the start — so this is a choice and not a sweep. Picking one measures nothing by itself; the reading is built when you refresh it.`}function ODe(e){return e?`break down by — the ${M3(e)} source groups this engine derived from the tree`:`break down by — the engine derived no source group here, so there is nothing to offer`}function kDe(e,t){return`Nothing measured for ${e} yet — it has a series of its own and it is empty.${typeof t==`number`&&t>0?` It would walk the ${M3(t)} commit${t===1?``:`s`} that touched it.`:``} It spends no tokens.`}function ADe(e){return`${e}'s readings — measured the same way in every repo`}function jDe(e,t){return`${e}'s own readings — declared in ${t}`}function MDe(e){return`No readings of this repo's own. To add one beside these, commit ${e}: each entry names a key, what it counts, which way the repo wants it to go, and the argv that prints the number.`}function NDe(e,t){return e===`higher`?`${t} aims for this to rise.`:e===`lower`?`${t} aims for this to fall.`:null}function PDe(e){return`Not part of the health index, which is built from ${e}'s readings only so it compares across repos. Each runs once per refresh that measures a new commit, at that commit; there is no history from before a reading was declared.`}function V3(e){let t=e?.own;return!t||e?.scope?{kind:`none`}:!t.declared&&t.series.length===0&&!t.absent?{kind:`add`,file:t.file}:{kind:`drawn`,own:t}}function FDe(e,t){return e===`repo`?`approve and run its engine`:t&&(t.rows??0)>0?`approve and update`:`approve and build`}function IDe(e){return e&&(e.rows??0)>0?`update without them`:`build without them`}var H3=e=>/[.!?]$/.test(e.trim())?e.trim():`${e.trim()}.`;function LDe(e){return e.kind===`disabled`?{lead:`Disabled here — ${H3(e.why)} Still measured; the health index leaves it out.`,why:null,absent:null}:{lead:`This repo's own version${e.means.trim()?` — ${e.means.trim().replace(/[.]$/,``)}`:``}${e.since?`; since ${e.since}`:`; not measured yet`}.${e.last==null?``:` The index reads ${F3(e.last,e.unit)} from it, not the curve below.`}`,why:`The repo's reason: ${H3(e.why)}`,absent:e.absent?`On the latest day it printed no number: ${H3(e.absent)}`:null}}function RDe(e){return e?.kind===`disabled`}function zDe(e){return e?[`This repo's say over these readings is in ${e.file} — what it disables or overrides is said on the reading's own tile.`,...(e.problems??[]).map(t=>`Ignored in ${e.file}: ${H3(t)}`)]:[]}function BDe(e,t){let n=null;for(let r of e)r.v!=null&&dn(r.day)===t&&(n=r.v);return n}function U3(e,t,n,r){let i={};t&&(i.engine=t),r&&(i.vs=r);let a=[],o=[];for(let t of e?.series??[]){let e=_Ee[t.key];if(!e)continue;t.detail?.trim()&&o.push({key:e,label:t.label,detail:t.detail.trim()});let n=t.variant;n&&!a.some(t=>t.key===e)&&a.push(n.kind===`disabled`?{key:e,kind:`disabled`,why:n.why}:{key:e,kind:`override`,why:n.why,means:n.means,since:n.since})}a.length&&(i.variants=a),e?.central?.file&&(i.centralFile=e.central.file),o.length&&(i.details=o);let s=e?.classics?.files??[],c=BDe(s,n),l=null;for(let e of s)e.v!=null&&(l=e.v);c!=null&&l!=null&&(i.tree={baselineFiles:c,nowFiles:l});let u=e?.own;if(u){let e=[];for(let t of u.series){let n=t.points.filter(e=>e.v!=null);if(!n.length)continue;let r=n[0],i=n[n.length-1],a=n.length===1?`${F3(r.v,t.unit)} on ${r.day} (its only reading so far)`:`${F3(r.v,t.unit)} on ${r.day} → ${F3(i.v,t.unit)} on ${i.day} (${n.length} readings)`;e.push({key:t.key,label:t.label,span:a,means:t.means,better:t.better})}i.own={file:u.file,declared:u.declared,readings:e,absent:u.absent??null}}return i}function W3(e){return e===`repo`?`The readings were measured by this repo's own ${ze}, and the keys are its names for them — read it if you come to doubt a number.`:e===`bundled`?`The readings were measured by ${I.displayName}'s bundled engine, and the keys are its names for them; it is not part of this repo, so do not look for it here.`:null}function VDe(e,t){let n=Date.parse(`${e}T00:00:00Z`),r=Date.parse(`${t}T00:00:00Z`);return Number.isFinite(n)&&Number.isFinite(r)?Math.round((r-n)/6048e5):null}function G3(e,t){let n=VDe(e,t);return n!==null&&n>1?` (one link over ${n} weeks with no measured week between)`:``}var K3=`A week's move may be one large commit landing work done over a longer stretch: check whether a single commit carries most of it before attributing the move to that week.`;function q3(e){let t=yEe[e];return t?` It is ${t}.`:``}function J3(e){if(!e)return null;if(e.readings.length){let t=e.readings.map(e=>`- ${e.label} (\`${e.key}\`): ${e.span}${e.better?`; the repo wants it ${e.better}`:``}. ${e.means.trim()}`);return`This repo's own readings, declared in ${e.file} — not part of the index, which is built from its five readings only:\n\n${t.join(`
126
+ `)}`}return e.declared?`This repo declares readings of its own in ${e.file}, but none has a value yet${e.absent?`: ${e.absent.trim()}`:`.`}`:`This repo declares no readings of its own; ${e.file} is where one would be declared.`}function Y3(e){let t=x3({disabled:(e.variants??[]).filter(e=>e.kind===`disabled`).map(e=>e.key),overridden:(e.variants??[]).filter(e=>e.kind===`override`).map(e=>e.key)},I.displayName);return t?` ${t}`:``}function X3(e,t=[]){let n=e.variants??[];if(!n.length&&!t.length)return null;let r=e.centralFile??qe,i=n.map(e=>{let t=`${_3[e.key]} (\`${e.key}\`)`,n=e.why.trim();return e.kind===`disabled`?`- ${t}: disabled — still measured, left out of the index. The repo's reason: ${n}`:`- ${t}: the index reads this repo's own command instead of the engine's reading${e.means?.trim()?` — ${e.means.trim()}`:``}${e.since?`; first measured ${e.since}`:`; not measured yet`}. The repo's reason: ${n}`}),a=t.length?`\nWeeks whose move is not compared (their scores are still measured) because this repo changed which readings it overrides or disables: ${t.join(`, `)}.`:``;return`${n.length?`This repo changes what the index is built from, in ${r} (\`central\`):\n\n${i.join(`
127
+ `)}\n\n`:``}The score is not comparable across a change of that config: the week it lands is scored as measured, but its move is not compared with the week before, so a jump there is not a move; and a score built from a different set of readings does not compare with another repo's on those readings.`+a}function Z3(e){let t=e.details??[];return t.length?`What the engine says beside the readings on the latest day, verbatim:\n\n${t.map(e=>`- ${e.label} (\`${e.key}\`): ${e.detail}`).join(`
128
+ `)}`:null}function Q3(e,t){let n=[...t?[t]:[],...(e??[]).map(e=>`- ${e}`)];return n.length?`\nWhat is holding the score down (the alarm the person sees first; name the offenders when you answer):\n${n.join(`
129
+ `)}\n`:``}function $3(e,t){if(!e)return``;let n=Math.round(t-e.delta);return` Against the week of ${e.thenWeek}, ${e.weeks} week${e.weeks===1?``:`s`} earlier, it was ${n} (${O3(e.delta)} since).`}function HDe(e,t,n={}){let r=[...e.movers].sort((e,t)=>Math.abs(t.points)-Math.abs(e.points)).map(e=>{let t=Math.round(e.points*10)===0?`barely moved it`:e.points>0?`pushed it up (that reading shrank)`:`pulled it down (that reading grew)`;return`- ${e.name} (\`${e.key}\`): ${O3(e.points)} — ${t}.${q3(e.key)}`}),i=e.prevWeek?`between the week of ${e.prevWeek} and the week of ${e.week}${G3(e.prevWeek,e.week)}`:`in the week of ${e.week}`,a=`${I.displayName}'s health index for ${t} was ${Math.round(e.index)} in the week of ${e.week}${e.delta===null?``:` (${O3(e.delta)} against the week before)`}; each week is the ISO week starting that Monday.${$3(n.vs,e.index)} It is a score out of 100 against fixed good values for five readings of the repo, held within 30 points of its worst one, and it falls when a reading grows past its good value.${Y3(n)} That week's move split across the readings like this, in score points, biggest first:`,o=J3(n.own),s=W3(n.engine),c=X3(n),l=Z3(n);return`${a}
130
+
131
+ ${r.join(`
132
+ `)}
133
+ ${Q3(e.alerts,e.cap)}${l?`\n${l}\n`:``}${c?`\n${c}\n`:``}${o?`\n${o}\n`:``}
134
+ What happened in ${t} ${i} that moved these readings, and is it work you would keep? Answer it about the commits and the files — use the git history for that span — starting with the reading that moved the index most, and the second one if it moved it by a comparable amount. Name the commits and files behind each, and say whether the change is the repo getting healthier, a cost worth paying for what the work bought, or something to undo. ${K3}
135
+
136
+ ${s?`${s} `:``}A small move is often nothing: "this was ordinary work and nothing needs doing" is a complete answer, and so is "this is an artefact of how it is measured" — say which, and stop there.
137
+
138
+ Change no file, run no fix, commit nothing. Finish with the options as you see them, in order of what each would cost.`}function UDe(e,t,n,r={}){let i=e.map((t,n)=>{let r=n>0?e[n-1]:null;if(t.lnLink===null){let e=t.gapReason===`central`?`move not compared: this repo changed which readings it overrides or disables`:t.gapReason===`prereg`?`move not compared: the engine's definitions changed`:`move not compared with the week before`;return`- ${t.week}: ${Math.round(t.index)} — ${t.gap?e:`first scored week`}`}let i=g3.filter(e=>typeof t.contributions[e]==`number`).map(e=>`${_3[e]} ${O3(t.contributions[e])}`),a=r?G3(r.week,t.week):``;return`- ${t.week}: ${Math.round(t.index)} (${r?O3(t.index-r.index):`?`})${a} — ${i.join(`, `)}`}),a=g3.map(t=>{let n=0,r=0;for(let i of e){let e=i.contributions[t];typeof e==`number`&&Number.isFinite(e)&&(n+=e,r++)}return r?`- ${_3[t]} (\`${t}\`): ${O3(n)} over ${r} week${r===1?``:`s`}.${q3(t)}`:null}).filter(Boolean),o=e[0],s=e[e.length-1],c=r.tree?`\nThe tree went from ${M3(r.tree.baselineFiles)} source files at the first scored week to ${M3(r.tree.nowFiles)} now — weigh "healthier than then" accordingly.\n`:``,l=J3(r.own),u=W3(r.engine),d=X3(r,e.filter(e=>e.gap&&e.gapReason===`central`).map(e=>e.week)),f=Z3(r),p=r.own?.file??qe,m=!!r.own?.readings.length,h=[...m?[`- Start from this repo's own readings above: say whether they moved over this span, and what moved them.`]:[],`- Say plainly that the five index readings are generic measures any tree can be given, and that the change which would help this repo most may move none of them. If that is so, say it, and propose it anyway.`,`- Where that lever has no measure${r.own&&!m?` — this repo has none of its own yet`:``}, propose one of this repo's own — what it would count and why it tracks the thing that matters — as a proposal to declare it in ${p} with a script that prints it.`,`- Keep it to the few changes worth their cost, about this repo rather than repos in general; a file that is generated or bundled is a case for excluding it from the readings, not for splitting it.`];return`${I.displayName}'s health index for ${n} went from ${Math.round(o.index)} in the week of ${o.week} to ${Math.round(s.index)} in the week of ${s.week}.${$3(r.vs,s.index)} It is a score out of 100 against fixed good values for five readings of the repo — file length, re-touched files, escape hatches, CLAUDE.md + skills, untested modules — held within 30 points of its worst entry, and it falls when a reading grows past its good value.${Y3(r)} Each week, with what each reading added or took away in score points:
139
+
140
+ ${i.join(`
141
+ `)}
142
+ ${Q3(r.now?.alerts,r.now?.cap)}
143
+ Each reading's total over the whole series, and what kind of number it is:
144
+
145
+ ${a.join(`
146
+ `)}
147
+ ${c}${f?`\n${f}\n`:``}${d?`\n${d}\n`:``}${l?`\n${l}\n`:``}
148
+ Is ${n} getting healthier? Answer it about the repo — read the git history over this span and the code the readings point at — and use the numbers as what prompted the question, not as the answer. Say over which stretch it improved or slipped, which readings carried that, and whether the work behind them is the repo getting better or only the readings moving (a file split for its own sake, tests added that test nothing, a carried-over week, a count diluted by code growing faster). ${K3}${u?` ${u}`:``}
149
+
150
+ Then propose what to change for a healthier code base:
151
+ ${h.join(`
152
+ `)}
153
+
154
+ Post each proposal to this repo's backlog with ${I.displayName}'s backlog add (\`POST /api/agent/backlog\`, no \`when\`; your ${I.displayName} skill has the shape), one row per change, ordered by what it would buy for what it costs. Each row's prompt is the whole instruction a fresh session needs to make that change — what, where, why, and how to check it worked — and its label says the change in a few words. Use a key per change that names it, so asking again does not post it twice. Post nothing that only moves a reading. End with the list of rows you posted, one line each, and say they wait in the backlog until the person fires one.
155
+
156
+ Change no file, run no fix, commit nothing: the backlog rows are the only thing you write.`}var e6={"claude-md":"Run `/init` so the instructions describe what is really in this repo — a stub is worse than nothing — then add a short section saying that artifacts meant for the phone go in `.claude/outbox/` and that uploads from the phone arrive in `.claude/inbox/`.","claude-md-outbox":"Add a few lines to CLAUDE.md telling the agent that artifacts a person should look at go in `.claude/outbox/`, that uploads arrive in `.claude/inbox/`, and that neither is ever committed. Graft it onto what is already there; rewrite nothing else.","context-weight":'CLAUDE.md is re-read on every turn of every session and every subagent, so its size is multiplied by everything this repo ever does. Classify each section as a RULE (dangerous not to know BEFORE acting — security, "never do X", mandatory commands) or REFERENCE (only needed while editing that area). Rules stay; reference moves into `.claude/skills/<name>/SKILL.md` with a frontmatter description that says both what it covers and when to load it. Delete nothing, and if a rule\'s only statement anywhere is the line you are about to trim, write it somewhere else first.',"auto-compact":`The check above names where the value comes from. If it is the environment variable of the ${I.displayName} daemon or \`.claude/settings.local.json\`, say so and change nothing — those are the person's own settings, not this repo's. Otherwise set \`"autoCompactWindow": "400k"\` in \`.claude/settings.json\`, keeping every other key.`,"apk-install":`Make the Android build leave its APK in \`.claude/outbox/\` with a dated or commit-stamped name (a copy task at the end of the build, or the build command in \`${te(`builds.json`)}\`), and keep one signing key for every build of the app. If targetSdk is flagged, raise it and say what the raise needs (API changes, permissions). The phone half — first install through ${I.displayName} — is the person's to do; say so rather than attempting it.`,"builds-configured":`Read the repo's own manifests and CI, then write \`${te(`builds.json`)}\` as a JSON list of \`{id, name, cmd, dir?}\` — one entry per command a person would tap (build, test, a debug APK). Leave publishing and deploying commands out unless asked, and keep any existing entries.`,"gitignore-transport":"Add the transport dirs to `.gitignore` as bare paths (no trailing slash, so `git check-ignore` matches before the directory exists). Append — never rewrite the file.","transport-tracked":"These are already tracked, so a gitignore line will not untrack them: `git rm --cached` each one, which leaves the file on disk, and make sure the ignore rule covers it. If any of them turns out to be real source rather than phone↔repo plumbing, say so and leave it alone.","env-gitignored":"Gitignore each one and `git rm --cached` it so it stops being tracked while staying on disk. First check what is actually in them: a file that holds only placeholders is a TEMPLATE and is meant to be committed — say so and change nothing. If any of them ever held a real credential, say that too, in the report, and do not rotate anything yourself."},t6={byCheck:()=>void 0,byFix:()=>void 0,refused:[]},n6=()=>t6;function WDe(e){n6=e}var r6=()=>n6(),GDe=[`gitignore`,`claude-md`,`visual-check`,`auto-compact`,`state-dir`,`android-toolchain`,`signing-key`,`builds-configured`];function KDe(e){let t=new Map,n=new Map,r=[];for(let i of e)Object.hasOwn(e6,i.check)||i.fix!==void 0&&GDe.includes(i.fix)?r.push(i.check):(t.has(i.check)||t.set(i.check,i),i.fix!==void 0&&!n.has(i.fix)&&n.set(i.fix,i));return{byCheck:e=>t.get(e),byFix:e=>n.get(e),refused:r}}var qDe=`Close this finding if it is real. If the check is wrong about this repo, say why and change nothing.`;function i6(e){return e.filter(e=>nr(e)&&!e.fix)}function a6(e){return e.filter(e=>nr(e)&&!!e.fix&&!o6(e.fix))}var JDe={"auto-compact":e=>`write ${e} into .claude/settings.json?`,"android-toolchain":()=>ite(null),"signing-key":()=>xee};function o6(e){return Rr.includes(e)}function YDe(e,t=mi){return JDe[e]?.(t)??null}function s6(e,t=mi,n=t6){return e===`auto-compact`?`set ${t} in this repo's .claude/settings.json`:e===`builds-configured`?`write build list`:e===`android-toolchain`?`install the Android build tools (JDK and SDK) on this desktop`:e===`signing-key`?`create or link the desktop signing key`:n.byFix(e)?.fixVerb??`fix`}function c6(e){if(e===`builds-configured`)return`write ${te(`builds.json`)} from this repo's build commands; existing lists stay untouched`}function l6(e,t=t6){return t.byCheck(e)?.agentVerb??`fix in this repo`}function XDe(e){return Array.from(new Set(a6(e).map(e=>e.fix)))}function u6(e,t,n=t6){let r=e.map((e,t)=>{let r=e6[e.id]??n.byCheck(e.id)?.guidance??qDe;return`${t+1}. ${e.label} — ${e.detail}\n ${r}`});return`${e.length===1?`${I.displayName}'s setup checklist has one open finding in ${t}. Close it.`:`${I.displayName}'s setup checklist has ${e.length} open findings in ${t}. Close them.`}
157
+
158
+ ${r.join(`
159
+
160
+ `)}
161
+
162
+ Rules for this pass: change only what a finding names, delete no file, and commit nothing. A finding you decide is WRONG about this repo is an answer, not a failure — say which and why, and leave it alone. Finish with a short list of what you changed and what you left.`}function ZDe(e,t){return e&&t?`Fix all (${e+t})`:e?`Fix all (${e})`:`Hand ${t===1?`it`:`all ${t}`} to the agent`}function d6(e,t,n){return!e||!t?null:`${e} patched here; the other ${t} ${t===1?`needs`:`need`} work, so ${t===1?`it goes`:`they go`} to ${n}'s agent as a prompt you send yourself.`}function QDe(e){if(e.absent)return`not read on the latest day — ${e.absent}`;if(e.last==null)return e.readings?`no value on the latest day, though earlier days in the series have one`:`no reading anywhere in the series — nothing of this kind has ever been measured here`}function $De(e,t,n){return`${[`${e.label} in ${f6(t,n)} is ${e.value}.`,nOe(e),e.detail?e.detail.trim():null,p6(n)].filter(Boolean).join(`
163
+ `)}
164
+
165
+ Is this serving ${f6(t,n)}, and what would you change? Answer it about the thing itself — the skills, the files, the tests, whatever this reading is a reading OF — by reading this repo and what the work in it actually needs. The number above is what prompted the question, not the subject of it.
166
+
167
+ "It is serving you; change nothing" is a complete answer, and so is "this is an artefact of how it was measured". If either is what you find, say so and stop. \`${e.key}\` is the tool's own name for this measurement; the tool is ${I.displayName}'s, run against this tree, and is probably not in this repo — open it only if you come to doubt the number, and do not go hunting for it here.
168
+
169
+ This is not a brief and it is not a finding: the tool holds no threshold, so there is no line this number is on the wrong side of, and nothing above says it is too much or too little. A judgment you form by reading this repo is a different thing, and it is exactly what is being asked for — say what it rests on, and keep it about this repo rather than repos in general. Change no file, run no fix, commit nothing. Finish with the options as you see them, in order of what each would cost.`}var eOe=`ask the agent to adopt this desktop's engine`;function tOe(e,t,n){let r=ze,i=qe,a=n?`The engine this desktop ships is \`${n}\` (its modules sit beside it, under \`${r.replace(/\.mjs$/,`/`)}\` in that tree). It takes \`--root=<repo>\` and reads any repo from outside it.`:`This desktop did not say where its own engine is — ask before guessing a path.`;return`${I.displayName}'s repo-health charts for ${e} cannot be drawn: this repo carries its own \`${r}\`, which outranks the desktop's engine, and it failed.
170
+ ${t?`\nIt said: ${t.trim()}\n`:``}
171
+ ${a}
172
+
173
+ Bring this repo onto the latest engine. In order of cost, pick the one that fits:
174
+ 1. If the copy here is stale or half-built, and nothing in it is specific to this repo, remove \`${r}\` and \`${r.replace(/\.mjs$/,`/`)}\` so the desktop's engine reads the repo.
175
+ 2. If the copy carries readings only this repo has, move them into \`${i}\` (committed; \`readings\` is a list of argv commands that each print one number), then remove the copy as in 1.
176
+ 3. If this repo is where the engine is developed (it is the engine's own source), keep the copy and make it run here instead — the failure above says what is missing.
177
+
178
+ Do not delete the measured series (\`${pte}\`) — the desktop's engine reads it. Run \`node <engine> status --root=.\` with the engine you end up on to show it loads, say which option you took and why, and commit it.`}function nOe(e){return e.reading?e.ranked?`${I.displayName}'s repo-health series reads it as: ${e.reading}`:`${I.displayName}'s repo-health series has no reading of it yet — ${e.reading}. So the series has nothing to say about this one, and the question below is entirely about the repo.`:null}function rOe(e,t){return`${e} of ${t} — open findings only, the rest of the checklist is hidden`}function f6(e,t){return t?`${e}, under ${t}`:e}function p6(e){return e?`This reading is of ${e} alone, measured as though it were the repo: only the commits that touched it are in the series, and every path above is relative to ${e}/.`:null}function iOe(e,t,n,r){let i=e.map((e,t)=>{let n=[`${t+1}. ${e.label} (\`${e.key}\`) — ${e.absent?`no reading`:e.value}`];return e.absent?n.push(` ${e.absent}`):e.reading&&n.push(` ${e.ranked?e.reading:`no reading of it yet — ${e.reading}`}`),e.detail&&n.push(` ${e.detail.trim()}`),n.join(`
179
+ `)}),a=e.length;return`${`${I.displayName}'s repo-health series holds ${a} reading${a===1?``:`s`} of ${f6(t,r)}, all taken from the same commit. Here they are, worded as the tool words them.`}
180
+ ${n?`\n${n}\n`:``}
181
+ ${i.join(`
182
+
183
+ `)}
184
+
185
+ Every key above is the tool's own name for that measurement. The tool is ${I.displayName}'s, run against this tree, and is probably not in this repo — do not go hunting for it here.${p6(r)?`\n${p6(r)}`:``}
186
+
187
+ Is ${f6(t,r)} in a shape that serves the work happening in it, and what would you change? Answer it about the things themselves — the files, the skills, the tests, the dependencies these readings are readings OF — by reading this repo. The numbers are what prompted the question, not the subject of it.
188
+
189
+ Read them together: they are one tree on one day, so say which of them move for the same reason, which only coincide, and whether any two of them disagree. A reading that is absent is a fact about this repo as much as a number is — say what its absence means here rather than looking for the missing figure.
190
+
191
+ "It is serving you; change nothing" is a complete answer for any of these, and so is "this one is an artefact of how it is measured" — say which ones, and stop there on those. This is not a brief and it is not a finding: the tool holds no threshold, so there is no line any of these numbers is on the wrong side of, and nothing above says any of them is too much or too little. A judgment you form by reading this repo is a different thing, and it is exactly what is being asked for — say what each one rests on, and keep it about this repo rather than repos in general. Change no file, run no fix, commit nothing. Finish with the options as you see them, in order of what each would cost.`}var m6=[{key:`maxChars`,label:`warn above`,hint:`always-on chars before the row goes amber`,chars:!0},{key:`hardChars`,label:`steep above`,hint:`where it stops being a rounding error`,chars:!0},{key:`maxSkills`,label:`skills before a mention`,hint:`descriptions are always-on even when no skill is`,chars:!1}],aOe={default:`default`,env:`set on this host`,repo:`set for this repo`};function h6(e){if(e<1e3)return String(e);let t=e/1e3;if(t>=10)return`${Math.round(t)}k`;let n=Math.round(t*10)/10;return`${Number.isInteger(n)?n:n.toFixed(1)}k`}var g6=e=>({maxChars:e.repo?.maxChars==null?``:String(e.repo.maxChars),hardChars:e.repo?.hardChars==null?``:String(e.repo.hardChars),maxSkills:e.repo?.maxSkills==null?``:String(e.repo.maxSkills)});function _6({repoId:e,view:t,setAt:n,onReport:r}){let[i,a]=(0,V.useState)(!1),[o,s]=(0,V.useState)(()=>g6(t)),[c,l]=(0,V.useState)(!1),[u,d]=(0,V.useState)(null);(0,V.useEffect)(()=>{s(g6(t)),d(null)},[e,JSON.stringify(t.repo)]);let f=!!t.repo&&Object.keys(t.repo).length>0,p=()=>{for(let e of m6){let t=o[e.key].trim();if(!t)continue;let n=Iee(e.key,Number(t));if(n)return n}let e=Number(o.maxChars.trim()||t.effective.maxChars),n=Number(o.hardChars.trim()||t.effective.hardChars);return Number.isFinite(e)&&Number.isFinite(n)&&n<e?`The steep line (${h6(n)}) is below the warn line (${h6(e)}) — it would never fire. Raise it, or leave it blank to inherit.`:null};async function m(t){let n=t?null:p();if(n)d(n);else{q(t?`action:setup.limits.reset`:`action:setup.limits.save`),l(!0),d(null);try{let n={};if(!t)for(let e of m6){let t=o[e.key].trim();t&&(n[e.key]=Number(t))}let i=await H.complianceLimits(e,t?{reset:!0}:n);i.ok&&i.report?(r(i.report),a(!1)):d(i.error||`the host refused the change`)}catch(e){d(String(e.message||e))}finally{l(!1)}}}if(!i)return(0,J.jsx)(`div`,{className:`check-acts`,children:(0,J.jsxs)(Y,{onClick:()=>a(!0),children:[(0,J.jsx)(es,{size:12}),` thresholds`,f?` (set here)`:``]})});let h=Number(o.maxChars.trim()||t.effective.maxChars);return(0,J.jsxs)(`div`,{className:`ctxlim`,children:[(0,J.jsx)(Z,{children:`What this repo is measured against. Leave a field blank to inherit the host's line — blank is “inherit”, not zero.`}),m6.map(e=>(0,J.jsxs)(Z,{as:`label`,children:[e.label,` — now `,e.chars?h6(t.effective[e.key]):t.effective[e.key],` (`,aOe[t.source[e.key]],`)`,(0,J.jsx)(`input`,{className:`search`,type:`number`,inputMode:`numeric`,min:Ei[e.key].min,max:Ei[e.key].max,step:e.chars?1e3:1,placeholder:`inherit ${e.chars?h6(t.effective[e.key]):t.effective[e.key]}`,value:o[e.key],onChange:t=>s({...o,[e.key]:t.target.value})}),(0,J.jsx)(`span`,{style:{opacity:.7},children:e.hint})]},e.key)),Number.isFinite(h)&&h>0&&(0,J.jsxs)(Z,{children:[`A warn line of `,h6(h),` chars is ~`,h6(Math.round(h/4)),` tokens on every turn of every session and every subagent here.`]}),t.note&&(0,J.jsx)(Z,{children:t.note}),u&&(0,J.jsx)(Z,{style:{color:`var(--dead)`},children:u}),(0,J.jsxs)(`div`,{className:`check-acts`,children:[(0,J.jsx)(Y,{onClick:()=>void m(!1),children:c?`saving…`:`save for this repo`}),f&&(0,J.jsxs)(Y,{onClick:()=>void m(!0),children:[(0,J.jsx)(tc,{size:12}),` back to `,Object.keys(t.env).length?`the host's line`:`the default`]}),(0,J.jsx)(Y,{onClick:()=>{a(!1),s(g6(t)),d(null)},children:`cancel`})]}),f&&n!=null&&(0,J.jsxs)(Z,{children:[`Set for this repo `,new Date(n).toLocaleDateString(),`.`]})]})}var oOe=`claude stops and asks you before a matching command — in sessions started after a change. Other backends take no rule.`;function sOe(e=0){let t=`Saved. claude sessions started from now on ask; a running session keeps the rules it launched with.`;return e>0?`${t} The desktop dropped ${e} it could not read.`:t}function v6(e){if(!e)return null;let t=e.movedTo?` Its bytes were kept as ${e.movedTo}.`:``;return`The desktop could not read its saved ask rules when it started (${e.error}), so claude sessions since then ran with none.${t} Add them again; the next save clears this.`}function y6(e,t){let n=t.trim();if(!n)return`Type a rule first, like Bash(git push * main).`;if(n.length>200)return`A rule is at most 200 characters.`;let r=Tr(n);return r?e.some(e=>e.rule===r)?`That rule is already on the list.`:e.length>=64?`The list holds at most 64 rules — remove one first.`:null:`That is not a permission rule — write it as a tool and a pattern, like Bash(git push * main).`}function b6(e,t){if(y6(e,t))return[...e];let n=Tr(t);return[...e,{id:cOe(e,n),rule:n}]}function cOe(e,t){let n=jr(t),r=n;for(let t=2;e.some(e=>e.id===r);t++)r=`${n}-${t}`;return r}function x6(e,t){let n=new Set(e.map(e=>e.rule));return t.filter(e=>!n.has(e))}function S6(e,t){let n=[...e];for(let r of x6(e,t)){if(n.length>=64)break;n=b6(n,r)}return n}function lOe(e,t){return S6(e,t).length-e.length}function uOe(e,t){return e.filter(e=>e.id!==t)}function C6(e,t){return!!e.offIn?.includes(t)}function w6(e,t,n,r){return e.map(e=>{if(e.id!==t)return e;let i=(e.offIn??[]).filter(e=>e!==n),a=r?[...i,n]:i,{offIn:o,...s}=e;return a.length?{...s,offIn:a}:s})}function T6(e,t){let n=t.find(t=>t.worktreePath===e);return n?n.isPrimary===!1&&n.branch?`${n.repoName} (${n.branch})`:n.repoName:e.split(`/`).filter(Boolean).pop()??e}function dOe(e,t){let n=e.offIn??[];return n.length?`off in ${n.map(e=>T6(e,t)).join(`, `)}`:null}function fOe(e,t){if(!e.length)return`No ask rules yet — Settings › Sessions › ask before adds them.`;let n=e.filter(e=>C6(e,t)).length;return n?`${e.length-n} of ${e.length} ask here; ${n} switched off in this repo.`:`All ${e.length} ask here.`}function pOe(e){return{rules:e.map(e=>e.offIn?.length?{id:e.id,rule:e.rule,offIn:[...e.offIn]}:{id:e.id,rule:e.rule})}}function E6(){let e=gh(`askrules`,()=>H.askRules()),[t,n]=(0,V.useState)(!1);async function r(r,i){if(t)return!1;let a=e.data;if(!a)return i(`The ask rules have not loaded yet — nothing was changed.`),!1;n(!0);try{let t=await H.setAskRules(pOe(r).rules,{rev:a.rev,confirm:a.confirm??``});return e.set(t),i(sOe(t.dropped)),!0}catch(t){return t instanceof Uf&&t.reread&&e.reload({quiet:!0}),i(Qe(t)?`No connection — the ask rules were not changed.`:String(t?.message||t)),!1}finally{n(!1)}}return{res:e,rules:e.data?.doc.rules??[],saving:t,save:r}}function mOe({repo:e,say:t}){let n=E6(),r=e.worktreePath;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`section-head`,children:[(0,J.jsxs)(`span`,{className:`section`,children:[(0,J.jsx)(ps,{size:13,style:{verticalAlign:`-2px`,marginRight:4}}),`ask before, in this repo`]}),(0,J.jsxs)(tT,{of:`ask rules in this repo`,children:[(0,J.jsx)(`p`,{children:`claude stops and asks you before a command matching one of these rules. Switch a rule off here where that command is your daily flow; it keeps asking in every other repo.`}),(0,J.jsx)(`p`,{children:`A change reaches claude sessions started on this desktop after it — a running session keeps the rules it launched with. Other backends take no rule. A peer desktop's jobs run under that peer's own list, and this desktop's own headless calls (review, assess) take no rule. It stops the accident, not a wrapper script: a script or alias running the same command is not seen.`})]})]}),(0,J.jsx)($,{res:n.res,empty:!n.res.data,thing:`the ask rules`}),n.res.data&&(0,J.jsxs)(J.Fragment,{children:[v6(n.res.data.lost)&&(0,J.jsx)(YS,{icon:ps,children:v6(n.res.data.lost)}),(0,J.jsx)(Z,{children:fOe(n.rules,r)}),(0,J.jsx)(`div`,{className:`set-kinds askrule-here`,children:n.rules.map(e=>{let i=!C6(e,r);return(0,J.jsx)(ZS,{label:(0,J.jsx)(`code`,{className:`askrule-rule`,children:e.rule}),on:i,state:n.saving?`saving…`:i?`asks`:`off here`,onChange:()=>void n.save(w6(n.rules,e.id,r,i),t)},e.id)})})]})]})}function D6(e,t,n){let r=e.length,i=0,a=1/0,o=-1/0;for(let t of e)t!==null&&Number.isFinite(t)&&(i++,t<a&&(a=t),t>o&&(o=t));if(i<2)return null;let s=o===a,c=e=>r===1?t:e/(r-1)*t,l=e=>s?n/2:n-.5-(e-a)/(o-a)*(n-1),u=[],d=[],f=[],p=[],m=()=>{if(p.length>1)u.push(`M${p.join(`L`)}`);else if(p.length===1){let[e,t]=p[0].split(`,`);d.push({x:Number(e),y:Number(t)})}p=[]},h=0,g=0;for(let t=0;t<r;t++){let n=e[t];if(n===null||!Number.isFinite(n)){m();continue}let r=c(t),i=l(n);f.push({i:t,x:r,y:i}),p.push(`${r.toFixed(1)},${i.toFixed(1)}`),h=r,g=i}return m(),{d:u.join(``),pts:f,dots:d,endX:h,endY:g,flat:s,readings:i,holes:r-i,lo:a,hi:o,hiY:l(o),loY:l(a)}}function hOe(e,t,n){if(e<=0)return[];if(e===1)return[{i:0,x:t}];let r=Math.max(2,Math.min(n,e)),i=[];for(let n=0;n<r;n++){let a=Math.round(n/(r-1)*(e-1));i.length&&i[i.length-1].i===a||i.push({i:a,x:a/(e-1)*t})}return i}function O6(e,t){let n=null,r=1/0;for(let i of e){let e=Math.abs(i.x-t);e<r&&(r=e,n=i)}return n}function k6(e,t,n){if(!e.length)return null;let r=e[0].values.length;if(!r)return null;for(let t of e)if(t.values.length!==r)return null;let i=[],a=0,o=0;for(let t=0;t<r;t++){let n=0,r=!0;for(let i of e){let e=i.values[t];if(e===null||!Number.isFinite(e)){r=!1;break}n+=e}i.push(r?n:null),r&&(o++,n>a&&(a=n))}if(o<2)return null;let s=e=>r===1?t:e/(r-1)*t,c=e=>a>0?n-.5-e/a*(n-1):n-.5,l=e.map((t,n)=>{let a=[],o=[],l=[],u=[],d=()=>{if(l.length>1)a.push(`M${l.join(`L`)}L${u.join(`L`)}Z`);else if(l.length===1){let[e,t]=l[0].split(`,`).map(Number),n=Number(u[0].split(`,`)[1]);o.push({x:e,y0:n,y1:t})}l=[],u=[]};for(let t=0;t<r;t++){if(i[t]===null){d();continue}let r=0;for(let i=0;i<n;i++)r+=e[i].values[t];let a=e[n].values[t],o=s(t).toFixed(1);l.push(`${o},${c(r+a).toFixed(1)}`),u.unshift(`${o},${c(r).toFixed(1)}`)}d();let f=t.values[r-1];return{key:t.key,label:t.label,slot:t.slot,d:a.join(``),stubs:o,last:i[r-1]===null?null:f}}),u=[],d=[],f=[],p=()=>{f.length>1&&u.push(`M${f.join(`L`)}`),f=[]};for(let e=0;e<r;e++){let t=i[e];t===null?p():(d.push({i:e,x:s(e),y:c(t)}),f.push(`${s(e).toFixed(1)},${c(t).toFixed(1)}`))}return p(),{bands:l,pts:d,topLine:u.join(``),totals:i,top:a,topY:c(a),zeroY:c(0)}}function gOe(e,t,n,r=0){let i=0;for(let t of e)for(let e of[t.from,t.to])e!==null&&Number.isFinite(e)&&e>i&&(i=e);let a=Math.max(0,t-r),o=e=>r+(i>0?e/i*a:0);return{rows:e.map((e,t)=>({key:e.key,label:e.label,y:t*n+n/2,x1:e.from!==null&&Number.isFinite(e.from)?o(e.from):null,x2:e.to!==null&&Number.isFinite(e.to)?o(e.to):null})),max:i,height:e.length*n}}var _Oe=` rest`;function A6(e,t){if(e.length<=4)return e.map((e,t)=>({...e,slot:t}));let n=e.every(e=>typeof e.bySize==`number`&&Number.isFinite(e.bySize)&&e.bySize>=0)&&e.filter(e=>e.bySize<3).length===3,r=(e,t)=>n?e.bySize<3:t<3,i=[],a=[];e.forEach((e,t)=>{r(e,t)?i.push({...e,slot:i.length}):a.push(e)});let o=a[0]?.values.length??0,s=[];for(let e=0;e<o;e++){let t=0,n=!0;for(let r of a){let i=r.values[e];if(i==null||!Number.isFinite(i)){n=!1;break}t+=i}s.push(n?t:null)}return[...i,{key:_Oe,label:`${t} (${a.length})`,values:s,slot:-1}]}function vOe(e,t,n,r=1){let i=e.length;if(!i)return null;let a=0;for(let t of e)Number.isFinite(t)&&t>a&&(a=t);if(!(a>0))return null;let o=t/i,s=Math.max(1,o-r);return{bars:e.map((e,t)=>{let r=Number.isFinite(e)&&e>0?e:0,i=Math.max(+(r>0),r/a*n);return{x:t*o,y:n-i,w:s,h:i}}),max:a}}function yOe(e,t){let n=new Map,r=[],i=new Map,a=!1;for(let o=t.length-1;o>=0;o--){let s=e[t[o].i]??null;if(s==null){a=!0;continue}let c=i.get(s);if(!c){let e=n.size<4?n.size:-1;n.set(s,e),c={path:s,slot:e,first:t[o].i,last:t[o].i,readings:0},i.set(s,c),r.push(c)}c.first=t[o].i,c.readings++}let o=[],s=[],c=null,l=()=>{if(!c||!c.at.length)return;let e=c.path==null?-1:n.get(c.path)??-1,t=c.at.length===1;o.push({path:c.path,slot:e,d:t?``:`M${c.at.map(e=>`${e.x.toFixed(1)},${e.y.toFixed(1)}`).join(`L`)}`,dot:t?{x:c.at[0].x,y:c.at[0].y}:null})},u=null;for(let r=0;r<t.length;r++){let i=t[r],a=e[i.i]??null,o=r>0?t[r-1]:null,d=!o||i.i!==o.i+1;(!c||d||c.path!==a)&&(l(),c={path:a,at:[]}),c.at.push(i),a!=null&&(u&&u.path!==a&&s.push({i:i.i,x:i.x,y:i.y,fromX:u.q.x,fromY:u.q.y,slot:n.get(a)??-1}),u={path:a,q:i})}return l(),{runs:o,handovers:s,holders:r,unnamed:a}}function bOe(e,t){return e===t?null:t}function j6(e,t){return e!==null&&t.includes(e)?e:null}function xOe(e,t,n){if(n||!e)return``;let r=t.toFixed(1);return e.split(`M`).filter(e=>e.includes(`L`)).map(e=>{let t=e.split(`L`),n=t[0].split(`,`)[0],i=t[t.length-1].split(`,`)[0];return kE(`M${e}`,n,i,r)}).join(``)}function SOe(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n!==null&&Number.isFinite(n))return t}return null}var COe=`fold`;function wOe(e,t){return t?`${e}: fold back into the grid`:`${e}: open the chart, its readout and what the tool reads into it`}var M6=`how these are drawn`,TOe=`how these are taken`;function EOe(e){return e.absent?`The per-area reading was not taken on the latest day — ${e.absent}`:Object.keys(e.areas).length?null:`No per-area reading here${e.areasAbsent?` — ${e.areasAbsent}`:``}. The always-on weight above is the whole tree's and is unaffected.`}function N6({id:e,of:t}){return Q_[e]?(0,J.jsx)(`button`,{type:`button`,className:`hint-chip`,"data-hint":e,"aria-label":`what ${t} means`,onClick:t=>{t.stopPropagation(),q(`action:repohealth.help`),Eae(e)},children:(0,J.jsx)(cs,{size:13,"aria-hidden":!0})}):null}var P6=.55,F6=2.5,I6=e=>e.map(e=>e.v),DOe=3,OOe=26,kOe=64,AOe=6,L6=e=>{let t=0;for(let n of e)n.length>t&&(t=n.length);return Math.min(kOe,Math.max(OOe,t*AOe+8))};function R6(e,t,n,r){let i=t?.getBoundingClientRect();return!i||!i.width?null:(e.clientX-i.left)/i.width*n-r}function z6({points:e,w:t,y:n,gutter:r}){let i=hOe(e.length,t,DOe);return i.length<2?null:(0,J.jsx)(J.Fragment,{children:i.map((t,a)=>(0,J.jsx)(`text`,{className:`rh-tick`,x:r+t.x,y:n,textAnchor:a===0?`start`:a===i.length-1?`end`:`middle`,children:L3(e[t.i]?.day)},t.i))})}var B6=e=>e.pointerType===`mouse`;function V6({at:e,h:t,gutter:n}){return(0,J.jsxs)(`g`,{pointerEvents:`none`,children:[(0,J.jsx)(`line`,{x1:n+e.x,x2:n+e.x,y1:0,y2:t,stroke:`currentColor`,strokeOpacity:.35,strokeWidth:1}),(0,J.jsx)(`circle`,{cx:n+e.x,cy:e.y,r:4,fill:`var(--panel)`,stroke:`currentColor`,strokeOpacity:.7,strokeWidth:2})]})}function H6(e){return Math.round(e).toLocaleString()}function jOe(){return`These are sizes, not readings: nothing compares them to anything, which is why no percentile and no direction appears beside them. They are what the percentiles above are percentiles OF — a position in a window means nothing without a feel for the magnitude being positioned.`}function MOe(){return`Lines of source per group, stacked, so the top edge is the whole tree — there is no separate total to compare it against, because this IS it. A group is a top-level boundary the engine derived from the tree, not necessarily a package. A colour follows a group and not its size, so one overtaking another never swaps their bands. Past four groups the rest fold into one band with no colour of its own, named in the legend.`}function NOe(){return`Always-on weight over the series: CLAUDE.md and the skill descriptions, stacked, so the top edge IS the total every turn of every session re-sends. Skill BODIES are on demand and are not in it. A day where either half has no reading is a gap in both — a top edge short by an unknown amount is the one mark a reader takes as the sum.`}function POe(e,t){return e==null&&t==null?null:`${e==null?`an unread file count`:`${H6(e)} source file${e===1?``:`s`}`} · ${t==null?`an unread line count`:`${H6(t)} lines`}`}function FOe(e,t,n,r,i){let a=[`the ${H6(e)} longest source files, biggest first`];return t!=null&&a.push(`longest ${H6(t)} lines${i?` — ${i}`:``}`),n!=null&&a.push(`p95 ${H6(n)} lines`),r!=null&&r>e&&a.push(`the other ${H6(r-e)} files in the tree are not in this row`),{lead:`${a.join(` · `)}.`,more:`Neither the longest file nor p95 is drawn as a rule: a dashed line means a threshold on every other chart here, and nobody chose these.`}}function IOe(e,t){if(!e)return t?`tap a bar to name its file`:`tap a bar for its length`;let n=`#${H6(e.rank)} \u00b7 ${H6(e.lines)} lines`;return e.path?`${n} \u00b7 ${e.path}`:`${n} \u00b7 this reading carries no file name — re-run the readings to get one`}function U6(e){return e==null?null:`${H6(e)} production dependenc${e===1?`y`:`ies`} across the manifests — dev dependencies are a separate count the series does not carry.`}function LOe(){return`Lines of source per file type, stacked, so the top edge is the whole tree — the same total the chart above draws, cut by what the code IS rather than by where it lives. The extension is the unit and the language pack that claims it is named beside it. A colour follows a type and not its size, and past four types the rest fold into one band with no colour of its own.`}function ROe(e,t,n,r){return e>=t?null:`${e} of ${t} types${n!=null&&r!=null?` — ${H6(n)} of ${H6(r)} lines`:``}. The top edge is those ${e}, not the tree.`}function zOe(e,t,n){let r=n==null?``:` · ${H6(n)}`;return`${e}${t?` · ${t}`:``}${r}`}var BOe=`every type`;function VOe(){return`No per-type reading here — every row in this series was measured before the tool counted types. It appears once the series is re-cut under the current definition; nothing above is affected.`}function HOe(e,t,n){if(!e)return null;let r=e.v==null||!Number.isFinite(e.v)?`no reading that day`:`${H6(e.v)} lines`,i=t??(n?`no file named that day`:null);return`${e.day} · ${r}${i?` · ${i}`:``}${e.sha7?` · ${e.sha7}`:``}`}function UOe(e,t,n,r){let i=e.readings===r?`longest on every one of the ${H6(r)} readings`:`longest on ${H6(e.readings)} of ${H6(r)} readings${t&&n?`, ${t} to ${n}`:``}`;return`${e.path} — ${i}`}function WOe(e){if(!e.named)return{lead:`This reading carries no file names per day, so a new file taking the top spot cannot be told from the same one growing — re-run the readings to get them.`,more:`The length of the single longest source file at each reading.`};let t=[`The length of the single longest source file at each reading, one hue per file.`,e.handovers===0?`The same file held the top spot on every named reading.`:`The top spot changed hands ${e.handovers===1?`once`:`${H6(e.handovers)} times`}; each change is a ring where the new file's line begins, joined to the old one by a thin step.`];return e.folded>0&&t.push(`The ${H6(e.folded)} earliest holder${e.folded===1?``:`s`} share one ink line — four hues is the palette.`),t.push(`Same axis rules as the tiles: fitted to its own low and high, by position, a missing day cuts the line.`),{lead:e.unnamed?`A stretch in ink with no legend entry is readings that carried a length and no name.`:null,more:t.join(` `)}}var GOe=`var(--muted)`,W6=e=>e>=0&&e<QE.length?QE[e]:GOe,G6=96;function K6({inputs:e,points:t,unit:n,totalLabel:r,label:i,width:a,caption:o,more:s,hint:c}){let l=(0,V.useRef)(null),[u,d]=(0,V.useState)(null),f=(0,V.useRef)(null),p=e.length&&a>0?k6(e,a,G6):null,m=p?L6([F3(p.top)]):0,h=Math.max(1,a-m),g=m?k6(e,h,G6):p,_=(e,t=!1)=>{if(!g)return;let n=R6(e,l.current,a,m);if(n==null)return;let r=O6(g.pts,n);r&&d(t&&r.i===u?null:r.i)};if(!g||a<=0||t.length!==e[0].values.length)return null;let v=u==null?null:g.pts.find(e=>e.i===u)??null,y=g.totals[g.totals.length-1],b=G6+15,x=v??g.pts[g.pts.length-1]??null,S=x?fDe(t[x.i],e.map(e=>({label:e.label,v:e.values[x.i]??null})),g.totals[x.i]??null,n):null;return(0,J.jsxs)(`div`,{className:`rh-chart`,children:[(0,J.jsxs)(`div`,{className:`rh-chart-head`,children:[(0,J.jsx)(`span`,{className:`rh-chart-label`,children:i}),(0,J.jsx)(N6,{id:c,of:i})]}),(0,J.jsxs)(`svg`,{ref:l,className:`rh-spark`,width:a,height:b,viewBox:`0 0 ${a} ${b}`,onPointerDown:e=>{f.current=u,_(e,!0)},onPointerMove:_,onPointerLeave:e=>{B6(e)&&d(null)},onPointerCancel:()=>d(f.current),role:`img`,"aria-label":`${i}, ${F3(y,n)} at the last reading`,children:[(0,J.jsxs)(`title`,{children:[i,` over `,g.totals.length,` readings`]}),g.top>0?(0,J.jsx)(`text`,{className:`rh-tick`,x:m-5,y:Math.max(8,g.topY+3.5),textAnchor:`end`,children:F3(g.top)}):null,(0,J.jsx)(`text`,{className:`rh-tick`,x:m-5,y:Math.min(95.5,g.zeroY+3.5),textAnchor:`end`,children:`0`}),(0,J.jsxs)(`g`,{transform:m?`translate(${m},0)`:void 0,children:[g.bands.map(e=>(0,J.jsxs)(`g`,{children:[e.d?(0,J.jsx)(`path`,{d:e.d,fill:W6(e.slot),fillOpacity:.85}):null,e.stubs.map((t,n)=>(0,J.jsx)(`rect`,{x:t.x-.75,y:t.y1,width:1.5,height:Math.max(1,t.y0-t.y1),fill:W6(e.slot),fillOpacity:.85},n))]},e.key)),g.topLine?(0,J.jsx)(`path`,{d:g.topLine,fill:`none`,stroke:`var(--fg)`,strokeOpacity:.5,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`}):null]}),(0,J.jsx)(z6,{points:t,w:h,y:G6+11,gutter:m}),v?(0,J.jsx)(V6,{at:v,h:G6,gutter:m}):null]}),(0,J.jsx)(`div`,{className:`rh-scrub`,children:S}),(0,J.jsxs)(`ul`,{className:`rh-legend`,children:[g.bands.map(e=>(0,J.jsxs)(`li`,{children:[(0,J.jsx)(`span`,{className:`rh-swatch`,style:{background:W6(e.slot)},"aria-hidden":!0}),e.label,` — `,F3(e.last,n)]},e.key)),(0,J.jsxs)(`li`,{children:[(0,J.jsx)(`span`,{className:`rh-swatch rh-swatch-line`,"aria-hidden":!0}),r,` — `,F3(y,n)]})]}),o?(0,J.jsx)(`div`,{className:`rh-cap`,children:o}):null,s?(0,J.jsxs)(`details`,{className:`hint-more rh-more`,children:[(0,J.jsx)(`summary`,{children:M6}),s]}):null]})}function KOe({claudeMd:e,descriptions:t,width:n}){return!e||!t?null:(0,J.jsx)(K6,{inputs:[{key:e.key,label:e.label,slot:0,values:I6(e.points)},{key:t.key,label:t.label,slot:1,values:I6(t.points)}],points:e.points,unit:`chars`,totalLabel:`the total`,label:`always-on weight`,width:n,more:NOe(),hint:`repohealth.weight`})}var qOe=30;function JOe({areas:e,width:t}){let n=Object.keys(e);if(!n.length||t<=0)return null;let r=Math.min(84,Math.max(56,Math.round(t*.22))),i=gOe(n.map(t=>({key:t,label:t,from:e[t].expected,to:e[t].ceiling})),t-6,qOe,r),a=i.height+15,o=t-6;return(0,J.jsxs)(`div`,{className:`rh-chart`,children:[(0,J.jsxs)(`div`,{className:`rh-chart-head`,children:[(0,J.jsx)(`span`,{className:`rh-chart-label`,children:`what a change carries, per area`}),(0,J.jsx)(N6,{id:`repohealth.areas`,of:`the per-area spread`})]}),(0,J.jsxs)(`svg`,{width:t,height:a,viewBox:`0 0 ${t} ${a}`,role:`img`,"aria-label":`always-on weight per area, up to ${F3(i.max,`chars`)}`,children:[(0,J.jsx)(`title`,{children:`per-area always-on weight, latest reading`}),i.rows.map(t=>{let n=e[t.key],r=t.x1,i=t.x2;return(0,J.jsxs)(`g`,{children:[(0,J.jsx)(`text`,{x:0,y:t.y,dominantBaseline:`middle`,className:`rh-axis-label`,children:t.label}),r!=null&&i!=null?(0,J.jsx)(`line`,{x1:r,x2:i,y1:t.y,y2:t.y,stroke:`var(--chart-1)`,strokeOpacity:.35,strokeWidth:3,strokeLinecap:`round`}):null,r==null?null:(0,J.jsx)(`circle`,{cx:r,cy:t.y,r:4.5,fill:`var(--panel)`,stroke:`var(--chart-1)`,strokeWidth:2}),i==null?null:(0,J.jsx)(`circle`,{cx:i,cy:t.y,r:4.5,fill:`var(--chart-1)`,stroke:`var(--panel)`,strokeWidth:1.5}),(0,J.jsxs)(`title`,{children:[t.label,` — `,z3(n)]})]},t.key)}),(0,J.jsx)(`line`,{x1:r,x2:o,y1:i.height+.5,y2:i.height+.5,stroke:`var(--fg)`,strokeOpacity:.12,strokeWidth:1}),(0,J.jsx)(`text`,{className:`rh-tick`,x:r,y:i.height+11,textAnchor:`start`,children:`0`}),(0,J.jsx)(`text`,{className:`rh-tick`,x:o,y:i.height+11,textAnchor:`end`,children:F3(i.max,`chars`)})]}),(0,J.jsxs)(`ul`,{className:`rh-legend`,children:[(0,J.jsxs)(`li`,{children:[(0,J.jsx)(`span`,{className:`rh-swatch rh-swatch-hollow`,"aria-hidden":!0}),`what a change there usually carries`]}),(0,J.jsxs)(`li`,{children:[(0,J.jsx)(`span`,{className:`rh-swatch rh-swatch-dot`,style:{background:`var(--chart-1)`},"aria-hidden":!0}),`with every one of its bodies loaded`]})]}),(0,J.jsxs)(`details`,{className:`hint-more rh-more`,children:[(0,J.jsx)(`summary`,{children:M6}),(0,J.jsx)(`ul`,{className:`rh-rows`,children:n.map(t=>(0,J.jsxs)(`li`,{children:[(0,J.jsx)(`span`,{className:`rh-rows-key`,children:t}),` `,z3(e[t])]},t))}),(0,J.jsx)(`p`,{children:gDe()})]})]})}function YOe({claudeMd:e,descriptions:t,context:n,width:r}){let[i,a]=rD(),o=i||r||0,s=EOe(n);return(0,J.jsxs)(`div`,{className:`rh-card`,id:`rh-weight`,ref:a,children:[(0,J.jsx)(KOe,{claudeMd:e,descriptions:t,width:o}),s?(0,J.jsx)(`div`,{className:`rh-cap`,children:s}):(0,J.jsx)(JOe,{areas:n.areas,width:o})]})}var XOe=32,ZOe=48,QOe=e=>`repohealth.${e}`;function q6({points:e,width:t,height:n=XOe,label:r,unit:i=``,axes:a=!1,bounds:o=!1,area:s=!1,onPick:c}){let l=(0,V.useRef)(null),[u,d]=(0,V.useState)(null),f=(0,V.useRef)(null),p=I6(e),m=D6(p,t,n),h=m?m.flat?[F3(m.hi)]:[F3(m.hi),F3(m.lo)]:[],g=a||o,_=g&&m?L6(h):0,v=Math.max(1,t-_),y=_?D6(p,v,n):m,b=e=>{d(e),c?.(e)},x=(e,n=!1)=>{if(!y)return;let r=R6(e,l.current,t,_);if(r==null)return;let i=O6(y.pts,r);i&&b(n&&i.i===u?null:i.i)},S=e=>{B6(e)&&b(null)};if(!y)return null;let C=u==null?null:y.pts.find(e=>e.i===u)??null,w=e[0]?.day,T=e[e.length-1]?.day,E=`${r}: ${y.readings} reading${y.readings===1?``:`s`}`+(y.holes?` and ${y.holes} day${y.holes===1?``:`s`} with none`:``)+(w&&T?`, ${w} to ${T}`:``)+(y.flat?` — unchanged across the series, drawn at mid-height`:`, ${F3(y.lo,i)} to ${F3(y.hi,i)}`),D=n+(a?15:0);return(0,J.jsxs)(`svg`,{ref:l,className:`rh-spark`,width:t,height:D,viewBox:`0 0 ${t} ${D}`,onPointerDown:a?e=>{f.current=u,x(e,!0)}:void 0,onPointerMove:a?x:void 0,onPointerLeave:a?S:void 0,onPointerCancel:a?()=>b(f.current):void 0,role:`img`,"aria-label":E,children:[(0,J.jsx)(`title`,{children:E}),g&&!y.flat?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`line`,{x1:_,x2:t,y1:y.hiY,y2:y.hiY,stroke:`currentColor`,strokeOpacity:.1,strokeWidth:1}),(0,J.jsx)(`text`,{className:`rh-tick`,x:_-5,y:Math.max(8,y.hiY+3.5),textAnchor:`end`,children:h[0]}),(0,J.jsx)(`text`,{className:`rh-tick`,x:_-5,y:Math.min(n-.5,y.loY+3.5),textAnchor:`end`,children:h[1]})]}):null,g&&y.flat?(0,J.jsx)(`text`,{className:`rh-tick`,x:_-5,y:y.hiY+3.5,textAnchor:`end`,children:h[0]}):null,(0,J.jsxs)(`g`,{transform:_?`translate(${_},0)`:void 0,children:[(0,J.jsx)(`line`,{x1:0,x2:v,y1:n-.5,y2:n-.5,stroke:`currentColor`,strokeOpacity:.14,strokeWidth:1}),s&&y.d?(0,J.jsx)(`path`,{d:xOe(y.d,n-.5,y.flat),fill:`currentColor`,fillOpacity:.07,stroke:`none`}):null,y.d?(0,J.jsx)(`path`,{d:y.d,fill:`none`,stroke:`currentColor`,strokeOpacity:P6,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`}):null,y.dots.map((e,t)=>(0,J.jsx)(`circle`,{cx:e.x,cy:e.y,r:1.6,fill:`currentColor`,fillOpacity:P6},t)),(0,J.jsx)(`circle`,{cx:y.endX,cy:y.endY,r:F6+1,fill:`var(--panel)`}),(0,J.jsx)(`circle`,{cx:y.endX,cy:y.endY,r:F6,fill:`var(--accent)`})]}),a?(0,J.jsx)(z6,{points:e,w:v,y:n+11,gutter:_}):null,a&&C?(0,J.jsx)(V6,{at:C,h:n,gutter:_}):null]})}function J6({slope:e}){let t=mDe(e);return t?(0,J.jsxs)(`span`,{className:`rh-slope`,children:[(0,J.jsx)(e===`rising`?nl:e===`falling`?_l:ls,{size:14,"aria-hidden":!0}),` `,t]}):null}function $Oe({s:e,width:t,actions:n,means:r,open:i,onToggle:a}){let[o,s]=rD(),c=o||t||0,[l,u]=(0,V.useState)(null),d=!!a,f=I6(e.points),p=f.reduce((e,t)=>t==null?e:e+1,0),m=e.variant?LDe(e.variant):null,h=RDe(e.variant),g=p>=2&&!h,_=g&&c>0,v=h?null:uDe({absent:e.absent,readings:p,minToDraw:2}),y=()=>{u(null),a?.()},b=(0,J.jsxs)(`div`,{className:`rh-tile-head`,children:[d?(0,J.jsx)(`button`,{type:`button`,className:`rh-tile-toggle`,"aria-expanded":!!i,title:wOe(e.label,!!i),onClick:y,children:(0,J.jsx)(`span`,{className:`rh-tile-label`,children:e.label})}):(0,J.jsx)(`span`,{className:`rh-tile-label`,children:e.label}),r===void 0?(0,J.jsx)(N6,{id:QOe(e.key),of:e.label}):null]}),x=t=>g?(0,J.jsx)(`div`,{className:`rh-tile-plot`,ref:s,children:_?t?(0,J.jsx)(q6,{points:e.points,width:c,height:ZOe,label:e.label,unit:e.unit,axes:!0,area:!0,onPick:u}):(0,J.jsx)(q6,{points:e.points,width:c,label:e.label,unit:e.unit,bounds:!0,area:!0}):null}):null;if(d&&!i)return(0,J.jsxs)(`li`,{className:`rh-tile`,children:[b,(0,J.jsxs)(`div`,{className:`rh-tile-valrow`,children:[(0,J.jsx)(`span`,{className:`rh-tile-val`,children:F3(e.last,e.unit)}),(0,J.jsx)(J6,{slope:e.reading.slope})]}),x(!1),h&&m?(0,J.jsx)(`div`,{className:`rh-tile-variant`,children:m.lead}):null,v?(0,J.jsx)(`div`,{className:`rh-tile-absent`,children:v}):null]});let S=sDe(e.reading),C=S?null:I3(e.reading),w=r??lDe(e.key),T=l??SOe(f),E=T==null?null:e.points[T]??null;return(0,J.jsxs)(`li`,{className:d?`rh-tile open`:`rh-tile`,children:[b,w?(0,J.jsx)(`div`,{className:`rh-tile-mean`,children:w}):null,m?(0,J.jsxs)(`div`,{className:`rh-tile-variant`,children:[(0,J.jsx)(`div`,{children:m.lead}),m.why?(0,J.jsx)(`div`,{children:m.why}):null,m.absent?(0,J.jsx)(`div`,{children:m.absent}):null]}):null,(0,J.jsxs)(`div`,{className:`rh-tile-valrow`,children:[(0,J.jsx)(`span`,{className:`rh-tile-val`,children:F3(e.last,e.unit)}),(0,J.jsx)(J6,{slope:e.reading.slope}),S?(0,J.jsx)(`span`,{className:`rh-rank`,children:S}):null]}),x(!0),_?(0,J.jsx)(`div`,{className:`rh-scrub`,children:R3(E,e.unit)}):null,v?(0,J.jsx)(`div`,{className:`rh-tile-absent`,children:v}):null,C?(0,J.jsx)(`div`,{className:`rh-tile-read`,children:C}):null,e.detail?(0,J.jsx)(`div`,{className:`rh-tile-detail`,children:e.detail.trim()}):null,n||d?(0,J.jsxs)(`div`,{className:`rh-tile-acts`,children:[n,d?(0,J.jsxs)(Y,{className:`rh-verb`,type:`button`,onClick:y,children:[(0,J.jsx)(mc,{size:12,"aria-hidden":!0}),` `,COe]}):null]}):null]})}function Y6({series:e,actionsFor:t,meansFor:n,axis:r}){let[i,a]=(0,V.useState)(null),o=e.map(e=>e.key),s=j6(i,o);return(0,J.jsx)(`ul`,{className:`rh-tiles rh-grid`,children:e.map(e=>(0,J.jsx)($Oe,{s:e,axis:r,means:n?.(e),open:s===e.key,onToggle:()=>a(t=>bOe(j6(t,o),e.key)),actions:t?.(e)},e.key))})}function eke({series:e,windowReadings:t,minReadings:n,axis:r,onAsk:i,onAskAll:a,actionsFor:o,after:s,title:c}){if(!e.length)return null;let l=e.reduce((e,t)=>t.points.length>e.length?t.points:e,e[0].points),u=CDe(r??`commits`,l.length,l[0]?.day,l[l.length-1]?.day);return(0,J.jsxs)(`div`,{className:`rh-card`,id:`rh-tiles`,children:[c?(0,J.jsx)(`h3`,{className:`rh-h`,children:c}):null,(0,J.jsx)(Y6,{series:e,axis:r,actionsFor:o??(i?e=>(0,J.jsxs)(Y,{className:`rh-verb`,type:`button`,onClick:()=>i(e),children:[(0,J.jsx)(Ec,{size:12,"aria-hidden":!0}),` `,`ask if this is serving the repo`,`…`]}):void 0)}),(0,J.jsxs)(`div`,{className:`rh-cap`,children:[u.lead,` `,(0,J.jsx)(N6,{id:`repohealth.reading`,of:`the percentile and the arrow`})]}),a?(0,J.jsx)(`div`,{className:`rh-tile-acts`,children:(0,J.jsxs)(Y,{className:`rh-verb`,type:`button`,onClick:a,children:[(0,J.jsx)(Ec,{size:12,"aria-hidden":!0}),` `,bDe,`…`]})}):null,s,(0,J.jsxs)(`details`,{className:`hint-more rh-more`,children:[(0,J.jsx)(`summary`,{children:M6}),(0,J.jsx)(`p`,{children:u.more}),(0,J.jsx)(`p`,{children:pDe(t,n)}),i||a?(0,J.jsx)(`p`,{children:xDe()}):null]})]})}function X6(e){return e&&e.requests>0&&Number.isFinite(e.ctxTok)?e.ctxTok/e.requests:null}function Z6(e,t,n,r){let i=e.length;if(!t||i<1||!(n>0)||!(r>0))return null;let a=new Map(t.map(e=>[e.week,X6(e)])),o=e.map(e=>a.get(e.week)??null),s=Q6(o,r);if(!s)return null;let c=e=>i===1?n:e/(i-1)*n,{ys:l}=s,u=[],d=[],f=[],p=()=>{f.length>1?u.push(`M${f.map(e=>`${c(e).toFixed(1)},${l[e].toFixed(1)}`).join(`L`)}`):f.length===1&&d.push({x:c(f[0]),y:l[f[0]]}),f=[]};for(let e=0;e<i;e++)l[e]===null?p():f.push(e);return p(),{d:u.join(``),dots:d,vals:o,...s,firstWeek:$6(e,o)}}function Q6(e,t){let n=e.filter(e=>e!==null);if(!n.length)return null;let r=Math.min(...n),i=Math.max(...n),a=i-r<=0,o=e=>a?t/2:6+(1-(e-r)/(i-r))*(t-12);return{ys:e.map(e=>e===null?null:o(e)),lo:r,hi:i,flat:a,hiY:o(i),loY:o(r),covered:n.length}}function $6(e,t){let n=t.findIndex(e=>e!==null);return n>=0?e[n].week:null}function e8(e,t,n,r){let i=e.length;if(!t||i<1||!(n>0)||!(r>0))return null;let a=new Map(t.map(e=>[e.week,X6(e)])),o=e.map(e=>a.get(e.week)??null),s=Q6(o,r);if(!s)return null;let{ys:c}=s,l=e=>i===1?n:e/(i-1)*n,u=[],d=[],f=[],p=()=>{if(f.length>1){let e=`M${l(f[0]).toFixed(1)},${c[f[0]].toFixed(1)}`;for(let t=1;t<f.length;t++){let n=f[t-1],r=f[t];if(c[r]!==c[n]){let t=(l(n)+l(r))/2;e+=`H${t.toFixed(1)}V${c[r].toFixed(1)}`}}e+=`H${l(f[f.length-1]).toFixed(1)}`,u.push(e)}else f.length===1&&d.push({x:l(f[0]),y:c[f[0]]});f=[]};for(let e=0;e<i;e++)c[e]===null?p():f.push(e);return p(),{d:u.join(``),dots:d,vals:o,...s,firstWeek:$6(e,o)}}var tke=`one value per week, drawn across that week's commits`,nke=e=>LE(e);function t8(e){return e===null?`no Claude request on record`:`${RE(e)} tokens per Claude request`}function n8(e){return{lead:`Dotted line: tokens each Claude request here re-sent — paid in money and in wait time.`,more:`Right axis, per week. It is paid twice because every request reads all of it again before the answer starts. Of the five readings, CLAUDE.md + skill descriptions${typeof e==`number`&&Number.isFinite(e)&&e>0?` (${Math.round(e).toLocaleString(`en-US`)} chars now)`:``} is in every request; file length, re-touched files, escape hatches and untested modules reach it only when the agent opens those files.`}}function rke(e,t,n){return n?e?e.firstWeek&&t[0]&&e.firstWeek!==t[0].week?`Claude's logs on this desktop reach this repo from the week of ${e.firstWeek}; the weeks before it have no line.`:null:`No Claude request in this repo is on record for the scored weeks, so there is no tokens-per-request line.`:null}var ike=`A week's context tokens divided by its requests — input, cache reads and cache writes, output left out — subagents included, read from the CLI's own logs on this desktop. Which model ran and how long sessions grew move it more than any reading here, so it sits beside the score as context and is no part of it.`,r8=e=>(Math.round(e*100)/100).toString();function ake(e,t,n){if(typeof e!=`number`||!Number.isFinite(e)||!(t>0)||!(n>=0)||!Number.isFinite(t)||!Number.isFinite(n))return null;let r=Math.max(0,Math.min(100,e)),i=n/2,a=t+i,o=t+i,s=e=>{let n=e*Math.PI/180;return{x:a+t*Math.sin(n),y:o-t*Math.cos(n)}},c=-135,l=e=>{let n=s(c),r=s(c+e),i=+(e>180);return`M${r8(n.x)},${r8(n.y)}A${r8(t)},${r8(t)} 0 ${i} 1 ${r8(r.x)},${r8(r.y)}`},u=r/100*270,d=s(c+u);return{w:2*a,h:s(135).y+i,cx:a,cy:o,track:l(270),arc:r>0?l(u):null,end:r>0?{x:d.x,y:d.y}:null,value:r}}var oke=`out of 100`,ske=`how this is scored`,cke=`pushed the score up`,lke=`pulled it down`;function uke(e){if(!e.cappedBy||!(e.value<e.mean))return null;let t=Math.round(e.value-30);return`held down by ${ue[e.cappedBy]}, at ${t} of 100`}var dke=`This is the first scored week; moves start the week after.`;function fke(e){return`${e.replace(/^./,e=>e.toUpperCase())}; there are no moves to show.`}function pke(e,t){return t?`${e} that week`:e}function mke(e){return`In commits mode the dotted line is ${e}.`}function hke(e){return e>0?e===1?`One commit is not joined to the one before: the engine's or this repo's definition changed there.`:`${e} commits are not joined to the one before: the engine's or this repo's definition changed at each.`:null}var gke=`not compared with the commit before: a definition changed here`;function _ke(e,t,n,r){return`Health score over ${t} ${e===`commits`?t===1?`commit`:`commits`:t===1?`week`:`weeks`}, from ${Math.round(n)} to ${Math.round(r)}, on a 0 to 100 axis`}var i8=112,a8=30,vke=34,yke=14,bke=52,o8=6;function xke({view:e,empty:t,onAsk:n,onAskTrend:r,axis:i=`weeks`}){let a=e?.series??null,o=(0,V.useRef)(null),[s,c]=(0,V.useState)(0),l=(0,V.useCallback)(e=>{if(o.current?.disconnect(),o.current=null,!e)return;let t=()=>{let t=getComputedStyle(e);c(Math.max(0,e.clientWidth-parseFloat(t.paddingLeft||`0`)-parseFloat(t.paddingRight||`0`)))};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);n.observe(e),o.current=n},[]);(0,V.useEffect)(()=>()=>o.current?.disconnect(),[]);let u=Kt(e),d=u===`present`?e.commits.points:null,f=i===`commits`&&d?`commits`:`weeks`,[p,m]=(0,V.useState)(null),h=p&&p.mode===f?p.i:null,g=(0,V.useRef)(null),_=a?.points??[],v=_[_.length-1]??null,y=_[_.length-2]??null,b=e?.spend,x=f===`commits`?d:_,S=x.length,C=f===`commits`?e8(x,b,1,1):Z6(x,b,1,1),w=!!C,T=Math.max(1,s-a8-(w?vke:0)),E=f===`commits`&&s>0?jEe(d,T,i8):null,D=a&&s>0?f===`commits`?E:w3(_,T,i8):null,O=D?f===`commits`?e8(x,b,T,i8):Z6(x,b,T,i8):null,k=a?rke(C,x,b):null,A=h!=null&&h<S?h:S-1,j=f===`commits`?d[A]??null:null,M=j?_.findIndex(e=>e.week===j.week):A,N=M>=0?_[M]??null:null,P=M>0?_[M-1]:null,F=v&&y&&v.lnLink!==null?v.index-y.index:null,ee=SEe(_),te=e=>tt({value:e.index,mean:e.mean,cappedBy:e.cappedBy}),ne=v?te(v):null,re=v?uke({value:v.index,mean:v.mean,cappedBy:v.cappedBy}):null,ie=dn(new Date().toISOString().slice(0,10)),ae=e=>{let t=yn(_,12,e);return t?{delta:t.delta,thenWeek:t.then.week,weeks:t.weeks}:null},oe=v?yn(_):null,se=N?IEe(N.contributions??{},100):null,ce=n&&N&&P&&N.lnLink!==null&&se?.bars.length?()=>n({week:N.week,prevWeek:P.week,index:N.index,delta:N.index-P.index,alerts:(N.alerts??[]).map(e=>e.text),cap:te(N),movers:se.bars.map(e=>({key:e.key,name:e.name,points:e.value}))},ae(M)):null,le=r&&a&&_.some(e=>e.lnLink!==null)?()=>r(_.map(e=>({week:e.week,index:e.index,gap:e.gap,lnLink:e.lnLink,contributions:e.contributions,...e.gapReason?{gapReason:e.gapReason}:{}})),a.baselineWeek,ae(_.length-1),{alerts:(v.alerts??[]).map(e=>e.text),cap:ne}):null,ue=a&&v?kEe(_[0]?.tree,v.tree,a.baselineWeek):null,de=v?ake(v.index,bke,o8):null,fe=f===`commits`&&e?.commits?.thinned?MEe(e.commits.points.length,e.commits.total):null,pe=(()=>{if(f===`commits`){let e=j;if(!e)return``;let t=O?O.vals[A]??null:null;return`${T3(`commits`,e)}${e.gap?` (${gke})`:``}${O?` · ${pke(t8(t),t!==null)}`:``}`}let e=_[A];if(!e)return``;let t=e.gap?null:TEe(e.spanDays);return`${T3(`weeks`,e)}${e.gap?` (${S3(e.gapReason)})`:``}${t?` — ${t}`:``}`+(O?` · ${t8(O.vals[A]??null)}`:``)})(),me=e=>{let t=g.current;if(!t||!D||S<2)return;let n=t.getBoundingClientRect(),r=e.clientX-n.left-a8,i=Math.round(r/T*(S-1));m({mode:f,i:Math.max(0,Math.min(S-1,i))})},he=114+(E?yke:0);return(0,J.jsxs)(`section`,{id:`rh-score`,className:`hix rh-card`,"aria-label":`Health index`,children:[(0,J.jsxs)(`div`,{className:`section-head`,children:[(0,J.jsxs)(`h3`,{className:`rh-h`,children:[(0,J.jsx)(Bo,{size:16,"aria-hidden":!0}),` Health index`]}),(0,J.jsxs)(tT,{of:`the health index`,children:[a?null:(0,J.jsxs)(`p`,{children:[`One score out of 100 per repo, against fixed good values for `,I.displayName,`'s five readings; it starts at the first week all five exist.`]}),(0,J.jsxs)(`p`,{children:[`It is built from `,I.displayName,`'s readings only — the same five in every repo, against the same good values. Each counts against the repo as it grows — longer files, more escape hatches — so the score falls when they grow past their good value and rises when they shrink back. It is the one place the app takes a side; the readings below only report.`]})]})]}),t,a&&v&&ee?(0,J.jsx)(`div`,{className:`hix-box`,children:(0,J.jsx)(`div`,{className:`rh-cap`,children:CEe(I.displayName)})}):null,a&&v&&!ee?(0,J.jsxs)(`div`,{className:`hix-box`,ref:l,children:[(0,J.jsxs)(`div`,{className:`hix-hero`,children:[(0,J.jsxs)(`div`,{className:`hix-ring`,style:de?{width:de.w,height:de.h}:void 0,children:[de?(0,J.jsxs)(`svg`,{width:de.w,height:de.h,viewBox:`0 0 ${de.w} ${de.h}`,"aria-hidden":!0,children:[(0,J.jsx)(`path`,{d:de.track,fill:`none`,stroke:`currentColor`,strokeOpacity:.14,strokeWidth:o8,strokeLinecap:`round`}),de.arc?(0,J.jsx)(`path`,{d:de.arc,fill:`none`,stroke:`var(--accent)`,strokeWidth:o8,strokeLinecap:`round`}):null]}):null,(0,J.jsx)(`span`,{className:`hix-hero-n`,style:de?{top:de.cy}:void 0,children:Math.round(v.index)})]}),(0,J.jsxs)(`div`,{className:`hix-hero-side`,children:[(0,J.jsx)(`div`,{className:`hix-of`,children:oke}),(()=>{let e=REe(v.index,_[0],_.length<2,F,v.week,ie),t=OEe(oe);return e||t?(0,J.jsxs)(`div`,{className:`hix-vs`,children:[e,e&&t?` · `:null,t]}):null})(),re?(0,J.jsx)(`div`,{className:`hix-cap`,children:re}):null]})]}),(v.alerts??[]).length?(0,J.jsx)(`ul`,{className:`hix-alerts`,"aria-label":`What is holding the score down`,children:(v.alerts??[]).map(e=>(0,J.jsxs)(`li`,{className:`hix-alert ${e.level}`,children:[e.level===`severe`?(0,J.jsx)(po,{size:14,"aria-hidden":!0}):(0,J.jsx)(gs,{size:14,"aria-hidden":!0}),(0,J.jsx)(`span`,{children:e.text})]},e.subject))}):null,e?.words?(0,J.jsx)(`div`,{className:`rh-tile-mean`,children:e.words.body}):null,i===`commits`&&u===`absent`?(0,J.jsx)(`div`,{className:`rh-cap`,children:D3(I.displayName)}):null,O?(0,J.jsxs)(`div`,{className:`hix-legend`,"aria-hidden":!0,children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`svg`,{width:18,height:6,children:(0,J.jsx)(`line`,{x1:1,x2:17,y1:3,y2:3,stroke:`currentColor`,strokeOpacity:.55,strokeWidth:2,strokeLinecap:`round`})}),` score, left axis`]}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`svg`,{width:18,height:6,children:(0,J.jsx)(`line`,{x1:1,x2:17,y1:3,y2:3,stroke:`var(--chart-2)`,strokeWidth:1.5,strokeDasharray:`0.1 4`,strokeLinecap:`round`})}),` tokens per request, right axis`]})]}):null,D?(0,J.jsxs)(`svg`,{ref:g,className:`rh-spark hix-chart`,width:s,height:he,viewBox:`0 0 ${s} ${he}`,role:`img`,"aria-label":_ke(f,S,D.lo,D.hi),onPointerDown:e=>me(e),onPointerMove:me,onPointerLeave:e=>{e.pointerType===`mouse`&&m(null)},children:[D.rules.map(e=>(0,J.jsx)(`text`,{className:`rh-tick`,x:25,y:Math.min(i8,Math.max(8,e.y+3.5)),textAnchor:`end`,children:e.v},e.v)),(0,J.jsxs)(`g`,{transform:`translate(${a8},0)`,children:[D.rules.map(e=>(0,J.jsx)(`line`,{x1:0,x2:T,y1:e.y,y2:e.y,stroke:`currentColor`,strokeOpacity:.14,strokeWidth:1,strokeDasharray:`2 3`},e.v)),E?E.weekRules.map(e=>(0,J.jsx)(`line`,{x1:e.x,x2:e.x,y1:0,y2:i8,stroke:`currentColor`,strokeOpacity:.08,strokeWidth:1},e.week)):null,E?E.ticks.map(e=>(0,J.jsx)(`text`,{className:`rh-tick`,x:e.x,y:126,textAnchor:e.anchor,children:e.day},`${e.x}-${e.day}`)):null,(()=>{let e=AEe(D);return e?(0,J.jsx)(`path`,{d:e,fill:`currentColor`,fillOpacity:.07,stroke:`none`}):null})(),O?(0,J.jsxs)(`g`,{className:`hix-spend`,children:[O.d?(0,J.jsx)(`path`,{d:O.d,fill:`none`,stroke:`var(--chart-2)`,strokeWidth:1.5,strokeDasharray:`0.1 4`,strokeLinecap:`round`,strokeLinejoin:`round`}):null,O.dots.map((e,t)=>(0,J.jsx)(`circle`,{cx:e.x,cy:e.y,r:1.6,fill:`var(--chart-2)`},t)),(()=>{let e=O.ys[A];return e==null?null:(0,J.jsx)(`circle`,{cx:D.pts[A]?.x??D.endX,cy:e,r:2.4,fill:`var(--chart-2)`,stroke:`var(--panel)`,strokeWidth:1.2})})()]}):null,D.d?(0,J.jsx)(`path`,{d:D.d,fill:`none`,stroke:`currentColor`,strokeOpacity:.55,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`}):null,D.dashed?(0,J.jsx)(`path`,{d:D.dashed,fill:`none`,stroke:`currentColor`,strokeOpacity:.55,strokeWidth:1.5,strokeDasharray:`3 3`,strokeLinecap:`round`}):null,D.dots.map((e,t)=>(0,J.jsx)(`circle`,{cx:e.x,cy:e.y,r:1.8,fill:`currentColor`,fillOpacity:.55},t)),(()=>{let e=(h==null?null:D.pts[h])??{x:D.endX,y:D.endY};return(0,J.jsx)(`circle`,{cx:e.x,cy:e.y,r:2.5,fill:`var(--accent)`,stroke:`var(--panel)`,strokeWidth:1.5})})()]}),O?(O.flat?[{v:O.hi,y:O.hiY}]:[{v:O.hi,y:O.hiY},{v:O.lo,y:O.loY}]).map(e=>(0,J.jsx)(`text`,{className:`rh-tick`,x:a8+T+5,y:Math.min(i8,Math.max(8,e.y+3.5)),textAnchor:`start`,fill:`var(--chart-2)`,children:nke(e.v)},e.v)):null]}):null,(0,J.jsx)(`div`,{className:`rh-tile-read hix-readout`,children:pe}),fe?(0,J.jsx)(`div`,{className:`rh-cap`,children:fe}):null,D&&D.gaps>0?(0,J.jsx)(`div`,{className:`rh-cap`,children:f===`weeks`?wEe(D.gaps):hke(D.gaps)}):null,k?(0,J.jsx)(`div`,{className:`rh-cap`,children:k}):null,N&&N.scores?(0,J.jsxs)(`div`,{className:`hix-bars`,children:[f===`commits`?(0,J.jsx)(`div`,{className:`rh-cap`,children:FEe(N.week)}):null,(0,J.jsxs)(`div`,{className:`hix-bar-rows${se?.bars.length?``:` still`}`,role:`img`,"aria-label":g3.filter(e=>N.scores?.[e]!==void 0).map(e=>`${_3[e]} ${Math.round(N.scores[e])}`).join(`, `),children:[g3.filter(e=>N.scores?.[e]!==void 0).map(e=>{let t=se?.bars.find(t=>t.key===e)??null;return(0,J.jsxs)(`div`,{className:`hix-bar-row`,"aria-hidden":!0,children:[(0,J.jsx)(`span`,{className:`hix-barname`,children:_3[e]}),se?.bars.length?(0,J.jsx)(`span`,{className:`hix-track`,children:t&&t.side!==`none`?(0,J.jsx)(`span`,{className:`hix-bar ${t.side}`,style:{left:`${t.x}%`,width:`${t.w}%`}}):null}):null,(0,J.jsx)(`span`,{className:`hix-barscore`,children:Math.round(N.scores[e])}),se?.bars.length?(0,J.jsx)(`span`,{className:`hix-barval`,children:t?O3(t.value):``}):null]},e)}),se&&se.bars.length?(0,J.jsxs)(`div`,{className:`hix-bar-row hix-bar-axis`,"aria-hidden":!0,children:[(0,J.jsx)(`span`,{}),(0,J.jsxs)(`span`,{className:`hix-axis-words`,children:[(0,J.jsx)(`span`,{children:`← pulled down`}),(0,J.jsx)(`span`,{children:`pushed up →`})]}),(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{})]}):null]}),se&&se.bars.some(e=>e.side!==`none`)?(0,J.jsxs)(`div`,{className:`hix-legend hix-bar-legend`,"aria-hidden":!0,children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`i`,{className:`hix-swatch up`}),` `,cke]}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`i`,{className:`hix-swatch down`}),` `,lke]})]}):null,se&&!se.bars.length?(0,J.jsx)(`div`,{className:`rh-cap`,children:(0,J.jsx)($w,{children:N.gap?fke(S3(N.gapReason)):dke})}):null]}):null,ce&&N||le?(0,J.jsxs)(`div`,{className:`rh-tile-acts`,children:[ce&&N?(0,J.jsxs)(Y,{className:`rh-verb`,onClick:ce,children:[(0,J.jsx)(Ec,{size:12}),` `,zEe(N.week,M===_.length-1&&N.week===ie),`…`]}):null,le?(0,J.jsxs)(Y,{className:`rh-verb`,onClick:le,children:[(0,J.jsx)(Ec,{size:12}),` `,BEe,`…`]}):null]}):null,O?(0,J.jsx)(`div`,{className:`rh-cap`,children:n8(v.values?.context).lead}):null,(0,J.jsxs)(`details`,{className:`hint-more rh-more`,children:[(0,J.jsx)(`summary`,{children:ske}),(0,J.jsx)(`p`,{children:xEe(a.baselineWeek,I.displayName,{disabled:v.disabled,overridden:v.overridden})}),ne?(0,J.jsx)(`p`,{children:ne}):null,N&&N.scores&&se?.bars.length?(0,J.jsx)(`p`,{children:LEe(N.week)}):null,ue?(0,J.jsx)(`p`,{children:ue}):null,O?(0,J.jsxs)(`p`,{children:[n8(v.values?.context).more,f===`commits`?` ${mke(tke)}`:``]}):null,O?(0,J.jsx)(`p`,{children:ike}):null,e?.lastRefresh?(0,J.jsxs)(`p`,{children:[`Last weekly refresh `,e.lastRefresh.slice(0,10),`.`]}):null]})]}):null]})}function Ske({repoId:e,onAsk:t,onAskTrend:n,axis:r,onCommits:i,seriesStamp:a}){let o=gh(`healthindex:${e}`,()=>H.healthIndex(e),{enabled:!!e}),{reload:s}=o,c=(0,V.useRef)(a);(0,V.useEffect)(()=>{c.current!==a&&(c.current=a,s({quiet:!0}))},[a,s]);let l=o.data,u=l?Kt(l):null;return(0,V.useEffect)(()=>{i?.(u)},[u,i]),(0,J.jsx)(xke,{view:l,onAsk:t,onAskTrend:n,axis:r,empty:(0,J.jsx)($,{res:o,empty:!l?.series,thing:`the health index`,noun:`index`,children:l?.reason??`No health index yet: it starts at the first week every one of its five readings exists.`})})}var s8=64,c8=e=>{if(!e||!e.length)return null;let t=e[e.length-1].v;return t==null||!Number.isFinite(t)?null:t},Cke=e=>{for(let t=e.length-1;t>=0;t--)if(e[t].v!=null)return e[t];return null};function l8({points:e,label:t,unit:n,width:r,hint:i}){let[a,o]=(0,V.useState)(null);if(!e.length)return null;let s=a==null?null:e[a]??null,c=e.reduce((e,t)=>t.v==null?e:e+1,0),l=r>0&&c>=2;return(0,J.jsxs)(`li`,{className:`rh-tile`,children:[(0,J.jsx)(`div`,{className:`rh-tile-head`,children:(0,J.jsxs)(`span`,{className:`rh-tile-label`,children:[t,` `,(0,J.jsx)(N6,{id:i,of:t})]})}),(0,J.jsx)(`div`,{className:`rh-tile-val`,children:F3(c8(e),n)}),l?(0,J.jsx)(q6,{points:e,width:r,label:t,unit:n,axes:!0,onPick:o}):null,l?(0,J.jsx)(`div`,{className:`rh-scrub`,children:R3(s??Cke(e),n)}):null]})}function wke({classics:e,width:t}){let n=e.packages.filter(e=>e.points.length).map(e=>({key:e.pkg,label:e.pkg,values:I6(e.points),bySize:e.rank}));if(!n.length)return null;let r=A6(n,`the rest`);return(0,J.jsx)(K6,{inputs:r.map(e=>({key:e.key,label:e.label,slot:e.slot,values:e.values})),points:e.packages[0].points,unit:`lines`,totalLabel:`every group`,label:`lines of source by group`,width:t,caption:MOe(),hint:`repohealth.packages`})}function Tke({classics:e,width:t}){let[n,r]=(0,V.useState)(()=>new Set),i=(e.types??[]).filter(e=>e.points.length);if(!i.length)return(0,J.jsx)(`div`,{className:`rh-cap`,children:VOe()});let a=i.filter(e=>!n.has(e.ext)),o=i.reduce((e,t)=>e+(c8(t.points)??0),0),s=a.reduce((e,t)=>e+(c8(t.points)??0),0),c=ROe(a.length,i.length,s,o),l=new Map([...a].sort((e,t)=>e.rank-t.rank).map((e,t)=>[e.ext,t])),u=a.map(e=>({key:e.ext,label:e.ext,values:I6(e.points),bySize:l.get(e.ext)??0})),d=u.length?A6(u,`the rest`):[],f=e=>r(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,J.jsxs)(`div`,{className:`rh-types`,children:[(0,J.jsx)(`ul`,{className:`rh-filter rh-filter-chips`,children:i.map(e=>(0,J.jsx)(`li`,{children:(0,J.jsx)(zw,{on:!n.has(e.ext),clears:!1,onClick:()=>f(e.ext),children:zOe(e.ext,e.pack,c8(e.points))})},e.ext))}),d.length?(0,J.jsx)(K6,{inputs:d.map(e=>({key:e.key,label:e.label,slot:e.slot,values:e.values})),points:i[0].points,unit:`lines`,totalLabel:a.length===i.length?`every type`:`these ${a.length} types`,label:`lines of source by file type`,width:t,caption:LOe(),hint:`repohealth.types`}):(0,J.jsx)(`div`,{className:`rh-cap`,children:`No type is selected, so there is nothing to stack.`}),c?(0,J.jsxs)(`div`,{className:`rh-cap`,children:[c,` `,(0,J.jsx)(Y,{onClick:()=>r(new Set),children:BOe})]}):null]})}function Eke({classics:e,width:t}){let n=c8(e.files),r=c8(e.loc),i=c8(e.deps),a=POe(n,r),o=Math.max(0,Math.floor((t-8)/2));return(0,J.jsxs)(`div`,{className:`rh-mags`,children:[(0,J.jsx)(`div`,{className:`rh-mags-head`,children:`the magnitudes these are percentiles of`}),e.absent?(0,J.jsxs)(`div`,{className:`rh-cap`,children:[`This reading was not taken on the latest day — `,e.absent]}):null,a?(0,J.jsx)(`div`,{className:`rh-lead`,children:a}):null,(0,J.jsxs)(`details`,{className:`hint-more rh-more`,children:[(0,J.jsx)(`summary`,{children:`what these are`}),jOe()]}),(0,J.jsx)(wke,{classics:e,width:t}),(0,J.jsx)(Tke,{classics:e,width:t}),(0,J.jsxs)(`ul`,{className:`rh-tiles rh-tiles-compact`,children:[(0,J.jsx)(l8,{points:e.files,label:`source files`,unit:`files`,width:o,hint:`repohealth.classics.files`}),(0,J.jsx)(l8,{points:e.deps,label:`production dependencies`,unit:``,width:o,hint:`repohealth.classics.deps`})]}),U6(i)?(0,J.jsx)(`div`,{className:`rh-cap`,children:U6(i)}):null]})}function Dke({tape:e,paths:t,width:n,caption:r,onOpenFile:i,holderHue:a}){let[o,s]=(0,V.useState)(null),c=(0,V.useRef)(null),l=n>0?vOe(e,n,s8):null;if(!l)return null;let u=t=>{let n=t.currentTarget.getBoundingClientRect(),r=Math.floor((t.clientX-n.left)/Math.max(1,n.width)*e.length);return Math.max(0,Math.min(e.length-1,r))},d=o!=null&&o<e.length?{rank:o+1,lines:e[o],path:t?.[o]??null}:null;return(0,J.jsxs)(`div`,{className:`rh-chart`,children:[(0,J.jsxs)(`div`,{className:`rh-chart-head`,children:[(0,J.jsx)(`span`,{className:`rh-chart-label`,children:`the longest files`}),(0,J.jsx)(N6,{id:`repohealth.classics.tape`,of:`the longest-files tape`})]}),(0,J.jsxs)(`svg`,{width:n,height:s8,viewBox:`0 0 ${n} ${s8}`,role:`img`,"aria-label":`the ${e.length} longest source files`,style:{touchAction:`pan-y`,cursor:`pointer`},onPointerDown:e=>{let t=u(e);c.current={start:o,moved:!1},s(t===o?null:t)},onPointerMove:e=>{let t=c.current;t&&(t.moved=!0,s(u(e)))},onPointerUp:()=>{c.current=null},onPointerLeave:e=>{e.pointerType===`mouse`&&(c.current=null)},onPointerCancel:()=>{let e=c.current;c.current=null,e&&s(e.start)},children:[(0,J.jsxs)(`title`,{children:[`the `,e.length,` longest source files, biggest first`]}),l.bars.map((t,n)=>(0,J.jsx)(`rect`,{x:t.x,y:t.y,width:t.w,height:t.h,rx:1,fill:n===o?`var(--accent)`:n===0&&a?a:`currentColor`,fillOpacity:n===o||n===0&&a?1:.6-.3*(n/Math.max(1,e.length-1))},n))]}),(0,J.jsxs)(`div`,{className:`rh-scrub rh-tape-pick`,children:[(0,J.jsx)(`span`,{className:`rh-tape-pick-words${d?``:` scrub-hint`}`,children:IOe(d,!!t)}),d?.path&&i?(0,J.jsxs)(Y,{onClick:()=>i(d.path),children:[(0,J.jsx)(Fs,{size:14}),` open`]}):null]}),(0,J.jsx)(`div`,{className:`rh-cap`,children:r.lead}),(0,J.jsxs)(`details`,{className:`hint-more rh-more`,children:[(0,J.jsx)(`summary`,{children:`why these are words`}),r.more]})]})}var u8=64,d8=e=>e>=0&&e<QE.length?QE[e]:`currentColor`,f8=e=>e===-1?P6:1;function Oke(e,t){let n=/^M([\d.-]+),[\d.-]+/.exec(e),r=/L([\d.-]+),[\d.-]+$/.exec(e);return n&&r?kE(e,n[1],r[1],t.toFixed(1)):null}function kke({longest:e,width:t}){let n=(0,V.useRef)(null),[r,i]=(0,V.useState)(null),a=(0,V.useRef)(null),{points:o}=e,s=e.paths??null,c=I6(o),l=t>0?D6(c,t,u8):null,u=l?l.flat?[F3(l.hi)]:[F3(l.hi),F3(l.lo)]:[],d=l?L6(u):0,f=Math.max(1,t-d),p=l?D6(c,f,u8):null;if(!p)return null;let m=yOe(s??o.map(()=>null),p.pts),h=(e,a=!1)=>{let o=R6(e,n.current,t,d);if(o==null)return;let s=O6(p.pts,o);s&&i(a&&s.i===r?null:s.i)},g=r==null?null:p.pts.find(e=>e.i===r)??null,_=g??p.pts[p.pts.length-1]??null,v=HOe(_?o[_.i]:null,_&&s?s[_.i]:null,!!s),y=u8+15,b=m.holders.filter(e=>e.slot===-1).length,x=p.readings,S=`the longest file over time`,C=WOe({handovers:m.handovers.length,folded:b,unnamed:m.unnamed,named:!!s});return(0,J.jsxs)(`div`,{className:`rh-chart`,children:[(0,J.jsxs)(`svg`,{ref:n,className:`rh-spark`,width:t,height:y,viewBox:`0 0 ${t} ${y}`,onPointerDown:e=>{a.current=r,h(e,!0)},onPointerMove:h,onPointerLeave:e=>{B6(e)&&i(null)},onPointerCancel:()=>i(a.current),role:`img`,"aria-label":`${S}: ${m.holders.length} file${m.holders.length===1?``:`s`} held the top spot, ${m.handovers.length} change${m.handovers.length===1?``:`s`}`,children:[(0,J.jsxs)(`title`,{children:[S,` over `,x,` readings`]}),p.flat?(0,J.jsx)(`text`,{className:`rh-tick`,x:d-5,y:p.hiY+3.5,textAnchor:`end`,children:u[0]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`line`,{x1:d,x2:t,y1:p.hiY,y2:p.hiY,stroke:`currentColor`,strokeOpacity:.1,strokeWidth:1}),(0,J.jsx)(`text`,{className:`rh-tick`,x:d-5,y:Math.max(8,p.hiY+3.5),textAnchor:`end`,children:u[0]}),(0,J.jsx)(`text`,{className:`rh-tick`,x:d-5,y:Math.min(63.5,p.loY+3.5),textAnchor:`end`,children:u[1]})]}),(0,J.jsxs)(`g`,{transform:`translate(${d},0)`,children:[(0,J.jsx)(`line`,{x1:0,x2:f,y1:63.5,y2:63.5,stroke:`currentColor`,strokeOpacity:.14,strokeWidth:1}),m.handovers.map(e=>(0,J.jsx)(`line`,{x1:e.fromX,y1:e.fromY,x2:e.x,y2:e.y,stroke:`currentColor`,strokeOpacity:.35,strokeWidth:1},`s${e.i}`)),m.runs.map((e,t)=>{let n=e.d?Oke(e.d,63.5):null;return n?(0,J.jsx)(`path`,{d:n,fill:d8(e.slot),fillOpacity:.07,stroke:`none`},`a${t}`):null}),m.runs.map((e,t)=>e.d?(0,J.jsx)(`path`,{d:e.d,fill:`none`,stroke:d8(e.slot),strokeOpacity:f8(e.slot),strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},t):e.dot?(0,J.jsx)(`circle`,{cx:e.dot.x,cy:e.dot.y,r:1.8,fill:d8(e.slot),fillOpacity:f8(e.slot)},t):null),m.handovers.map(e=>(0,J.jsx)(`circle`,{cx:e.x,cy:e.y,r:4,fill:`var(--panel)`,stroke:d8(e.slot),strokeWidth:2},`h${e.i}`)),(0,J.jsx)(`circle`,{cx:p.endX,cy:p.endY,r:F6+1,fill:`var(--panel)`}),(0,J.jsx)(`circle`,{cx:p.endX,cy:p.endY,r:F6,fill:`var(--accent)`})]}),(0,J.jsx)(z6,{points:o,w:f,y:u8+11,gutter:d}),g?(0,J.jsx)(V6,{at:g,h:u8,gutter:d}):null]}),(0,J.jsx)(`div`,{className:`rh-scrub`,children:v}),m.holders.length?(0,J.jsx)(`ul`,{className:`rh-legend rh-legend-rows rh-legend-compact`,children:m.holders.map(e=>(0,J.jsxs)(`li`,{children:[(0,J.jsx)(`span`,{className:`rh-swatch rh-swatch-line`,style:{background:d8(e.slot),opacity:f8(e.slot)},"aria-hidden":!0}),UOe(e,o[e.first]?.day,o[e.last]?.day,x)]},e.path))}):null,C.lead?(0,J.jsx)(`div`,{className:`rh-cap`,children:C.lead}):null,(0,J.jsxs)(`details`,{className:`hint-more rh-more`,children:[(0,J.jsx)(`summary`,{children:`how it is drawn`}),C.more]})]})}function Ake({longest:e,classics:t,p95:n,width:r,onOpenFile:i}){let a=e?e.points.reduce((e,t)=>t.v==null?e:e+1,0):0,o=e&&a>=2&&r>0,s=t.tape&&t.tape.length?t.tape:null;if(!o&&!s)return null;let c=e?.points.length?e.points[e.points.length-1].v:null,l=t.files.length?t.files[t.files.length-1].v:null;return(0,J.jsxs)(`div`,{className:`rh-longest`,children:[(0,J.jsx)(`div`,{className:`rh-tile-head`,children:(0,J.jsxs)(`span`,{className:`rh-tile-label`,children:[`the longest file `,(0,J.jsx)(N6,{id:`repohealth.longest`,of:`the longest file over time`})]})}),c==null?null:(0,J.jsxs)(`div`,{className:`rh-tile-val`,children:[F3(c,`lines`),e?.path?(0,J.jsxs)(`span`,{className:`rh-longest-path`,title:e.path,children:[` · `,HEe(e.path,44)]}):null]}),o&&e?(0,J.jsx)(kke,{longest:e,width:r}):null,s?(0,J.jsx)(Dke,{tape:s,paths:t.tapePaths??null,width:r,onOpenFile:i,holderHue:t.tapePaths?QE[0]:void 0,caption:FOe(s.length,c==null?s[0]??null:null,n,l,e?.path??null)}):null]})}var jke=e=>e.map(e=>e.v),Mke=14;function Nke({plot:e}){let t=e.series.find(e=>e.key===`size.p95`)??null,n=e.classics.files.length?e.classics.files:t?.points??[];if(!n.length)return null;let r=e.classics.packages.filter(e=>e.points.length===n.length).map(e=>({key:e.pkg,label:e.pkg,values:jke(e.points),bySize:e.rank})),i=r.length?A6(r,`the rest`):[],a=Math.max(0,n.length-Mke),o=[];for(let e=a;e<n.length;e++)o.push(e);let s=e.longest?.points.length===n.length?e.longest.points:null,c=[{head:`p95`,at:e=>t?.points[e]?.v??null},...s?[{head:`longest`,at:e=>s[e]?.v??null}]:[],{head:`files`,at:t=>e.classics.files[t]?.v??null},...i.map(e=>({head:e.label,at:t=>e.values[t]??null})),{head:`deps`,at:t=>e.classics.deps[t]?.v??null}];return(0,J.jsxs)(`div`,{className:`rh-chart`,children:[(0,J.jsxs)(`div`,{className:`rh-chart-head`,children:[(0,J.jsx)(`span`,{className:`rh-chart-label`,children:`the readings, as numbers`}),(0,J.jsx)(N6,{id:`repohealth.table`,of:`the numbers table`})]}),(0,J.jsx)(`div`,{className:`rh-table-wrap rh-fade`,children:(0,J.jsxs)(`table`,{className:`rh-table`,children:[(0,J.jsx)(`thead`,{children:(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{scope:`col`,children:`day`}),c.map(e=>(0,J.jsx)(`th`,{scope:`col`,className:`num`,children:e.head},e.head))]})}),(0,J.jsx)(`tbody`,{children:o.map(e=>(0,J.jsxs)(`tr`,{children:[(0,J.jsx)(`th`,{scope:`row`,children:L3(n[e].day)}),c.map(t=>(0,J.jsx)(`td`,{className:`num`,children:F3(t.at(e))},t.head))]},n[e].day??e))})]})}),(0,J.jsx)(`div`,{className:`rh-cap`,children:_De(o.length,e.days)})]})}function Pke({plot:e,repoName:t,actionsFor:n,series:r,axis:i}){let a=V3(e);if(a.kind===`none`)return null;if(a.kind===`add`)return(0,J.jsx)(`div`,{className:`rh-card`,id:`rh-own`,children:(0,J.jsx)(`div`,{className:`rh-cap`,children:MDe(a.file)})});let{own:o}=a,s=r??o.series;return(0,J.jsxs)(`div`,{className:`rh-card`,id:`rh-own`,children:[(0,J.jsx)(`h3`,{className:`rh-h`,children:jDe(t,o.file)}),o.absent?(0,J.jsx)(`div`,{className:`rh-cap`,children:o.absent}):null,o.problems?.length?(0,J.jsx)(`div`,{className:`rh-cap`,children:o.problems.join(` · `)}):null,s.length?(0,J.jsx)(Y6,{series:s,axis:i,meansFor:e=>[e.means,NDe(e.better,t)].filter(Boolean).join(` `),actionsFor:n}):null,(0,J.jsxs)(`details`,{className:`hint-more rh-more`,children:[(0,J.jsx)(`summary`,{children:TOe}),(0,J.jsx)(`p`,{children:PDe(I.displayName)})]})]})}function Fke(e){let t=e.split(/\n(?=## )/),n=[],r=``;return t.forEach((e,t)=>{if(t===0&&!e.startsWith(`## `)){r=e;return}let i=e.indexOf(`
192
+ `),a=i===-1?e:e.slice(0,i);n.push({day:a.slice(3).trim(),body:i===-1?``:e.slice(i)})}),{preamble:r,days:n}}function p8(e){let t=new Map,n=e.map(()=>!1);e.forEach((e,r)=>{let i=dn(e);i===null?n[r]=!0:t.set(i,r)});for(let e of t.values())n[e]=!0;let r=[];return n.forEach((e,t)=>{e&&r.push(t)}),r}function Ike(e){return p8(e.map(e=>e.day)).map(t=>e[t])}var m8=e=>Ike(e);function h8(e){let t=e.variant;return{...e,points:m8(e.points),...t&&t.kind===`override`?{variant:{...t,points:m8(t.points)}}:{}}}function Lke(e,t){if(t===`commits`)return e;let n=e.classics,r=e.longest,i=r;if(r){let e=p8(r.points.map(e=>e.day)),t=r.paths;i={...r,points:e.map(e=>r.points[e]),...t&&t.length===r.points.length?{paths:e.map(e=>t[e])}:{}}}return{...e,series:e.series.map(h8),classics:{...n,loc:m8(n.loc),files:m8(n.files),deps:m8(n.deps),packages:n.packages.map(e=>({...e,points:m8(e.points)})),...n.types?{types:n.types.map(e=>({...e,points:m8(e.points)}))}:{}},...i?{longest:i}:{},...e.own?{own:{...e.own,series:e.own.series.map(h8)}}:{}}}function Rke({index:e,drawn:t,plot:n,own:r}){let i=t?.longest?t.longest.points.reduce((e,t)=>t.v==null?e:e+1,0):0;return{score:e,longest:!!t&&(i>=2||!!t.classics.tape?.length),tiles:!!t?.series.length,weight:!!t,size:!!t,table:!!n&&(n.classics.files.length>0||!!n.series.find(e=>e.key===`size.p95`)?.points.length),own:r&&!!n&&V3(n).kind!==`none`}}var zke=e=>Object.keys(e).filter(t=>e[t]),g8=e=>`rh-${e}`;function Bke({keys:e,refresh:t}){let n=e=>document.getElementById(g8(e))?.scrollIntoView({behavior:`smooth`,block:`start`});return(0,J.jsxs)(`nav`,{className:`rh-nav`,"aria-label":`jump to`,children:[(0,J.jsx)(`div`,{className:`rh-nav-chips`,children:e.map(e=>(0,J.jsx)(`button`,{type:`button`,className:`fchip rh-nav-chip`,onClick:()=>n(e),children:(0,J.jsx)(`span`,{className:`fchip-pill`,children:NEe[e]})},e))}),t]})}function Vke({busy:e,label:t,onClick:n}){return(0,J.jsxs)(Y,{className:`rh-nav-refresh`,type:`button`,onClick:n,children:[(0,J.jsx)(Ds,{size:14,className:e?`spin`:void 0,"aria-hidden":!0}),` `,t]})}function Hke({axis:e,onAxis:t,commits:n}){let r=n!==`absent`;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`ts-filter rh-axis`,role:`group`,"aria-label":`x axis`,children:[(0,J.jsx)(`span`,{className:`ctx-stackpick-lab`,children:`x axis`}),(0,J.jsx)(zw,{on:e===`weeks`,clears:!1,onClick:()=>t(`weeks`),children:`weeks`}),r?(0,J.jsx)(zw,{on:e===`commits`,clears:!1,onClick:()=>t(`commits`),children:`commits`}):null,(0,J.jsxs)(tT,{of:`the x axis`,children:[(0,J.jsxs)(`p`,{children:[E3(`weeks`),`.`]}),r?(0,J.jsxs)(`p`,{children:[E3(`commits`),`.`]}):null]})]}),r?null:(0,J.jsx)(`div`,{className:`rh-cap rh-gutter`,children:D3(I.displayName)}),(0,J.jsx)(`div`,{className:`rh-cap rh-gutter rh-scrubhint`,children:PEe})]})}function _8({id:e,children:t}){let[n,r]=rD();return(0,J.jsx)(`div`,{className:`rh-card`,id:g8(e),ref:r,children:t(n)})}function Uke({days:e}){return e.length?(0,J.jsxs)(`details`,{className:`hint-more rh-notes`,children:[(0,J.jsx)(`summary`,{children:SDe(e.length)}),e.map(e=>(0,J.jsx)(`div`,{className:`tr-say rh-doc`,children:(0,J.jsx)(eG,{src:`## ${e.day}${e.body}`,q:``,onCopy:e=>void Xf(e)})},e.day))]}):null}var Wke=16,Gke=1500;function Kke({repo:e,res:t,view:n,onRemedy:r,scope:i,onScope:a,onOpenFile:o}){let s=n?.series??null,c=n?.plot??null,[l,u]=(0,V.useState)(!1),[d,f]=(0,V.useState)(0),[p,m]=(0,V.useState)(null),[h,g]=(0,V.useState)(null),[_,v]=(0,V.useState)(!1),y=Ww(1e3),{reload:b}=t,x=!!n?.run;(0,V.useEffect)(()=>{if(!x)return;let e=window.setInterval(()=>b({quiet:!0}),Gke);return()=>window.clearInterval(e)},[x,b]);let[S,C]=(0,V.useState)(da),w=e=>{q(`action:repohealth.axis.${e}`),ca(e),C(e)},[T,E]=(0,V.useState)(null),D=(0,V.useCallback)(e=>E(e),[]),O=S===`commits`&&T===`absent`?`weeks`:S,k=(0,V.useMemo)(()=>c?Lke(c,O):null,[c,O]),A=n?.scopes??[],j=(n?.measure?.groups??[]).filter(e=>e&&e!==`.`),[M,N]=(0,V.useState)(!1),[P,F]=(0,V.useState)(!1);async function ee(t){if(e&&!P){F(!0);try{let n=await H.repoHealthScopes(e.id,t);i&&!n.scopes.includes(i)&&a(null),await b({quiet:!0})}catch(e){m(String(e?.message||e))}finally{F(!1)}}}async function te(r=!1){if(!l&&e){q(`action:repohealth.refresh`),u(!0),f(Date.now()),m(null),g(null);try{let a=await H.repoHealthRefresh(e.id,i,r,r?n?.engine?.approveToken:void 0),o=a.error;typeof o==`string`&&!a.engine?g(o):t.set(a)}catch(e){m(String(e?.message||e))}finally{u(!1)}}}let ne={behind:n?.behind,lastSha:s?.lastSha,lastDay:s?.lastDay,headSha:n?.head?.sha},re=JEe(ne),ie=YEe({...ne,rows:s?.rows,days:s?.days}),ae=n?.measure??null,oe=nDe(s?.versions,ae?.engineVersion??s?.preregVersion,ve(ae)),se=GEe({kind:n?.engine?.kind??null,version:ae?.engineVersion,packs:ae?.packs}),ce=!!n&&!n.tool,le=$Ee(s?.staleRows),ue=aDe(n?.run,y),de=n?.last&&!rDe(n.last,n.readError,!!n.series)?n.last:null,fe=n?.narrative??null,pe=XEe(s),me=ZEe(de?.warnings),he=fe?Fke(fe.text):null,ge=he?[...he.days].reverse():[],_e=lee(n),ye=n?.tool&&s?Un(_e,n?.plotError??null):null,be=c?.series.find(e=>e.key===`size.p95`)?.last??null,xe=e=>QDe({absent:e.absent,last:e.last,readings:e.points.reduce((e,t)=>t.v==null?e:e+1,0)}),Se=e=>({key:e.key,label:e.label,value:F3(e.last,e.unit),reading:I3(e.reading),ranked:e.reading?.rank!=null,detail:e.detail,...xe(e)?{absent:xe(e)}:{}}),Ce=t=>{r&&e&&(q(`action:repohealth.ask`),r($De(Se(t),e.repoName,i),e,t.label.toLowerCase()))},we=(t,i)=>{r&&e&&(q(`action:repohealth.askindex`),r(HDe(t,e.repoName,U3(c,n?.engine?.kind,``,i)),e,`the health index, week of ${t.week}`))},Te=(t,i,a,o)=>{r&&e&&(q(`action:repohealth.asktrend`),r(UDe(t,i,e.repoName,{...U3(c,n?.engine?.kind,i,a),now:o??null}),e,`the health index trend`))},Ee=()=>{r&&e&&c?.series.length&&(q(`action:repohealth.askall`),r(iOe(c.series.map(Se),e.repoName,se,i),e,i?`all the readings of ${i}`:`all the readings`))},De=n?.engine?.needsApproval===!0,Oe=n?.engine?.kind===`repo`&&!De&&!!(de?.error||n.readError),ke=()=>{r&&e&&n&&(q(`action:repohealth.adoptengine`),r(tOe(e.repoName,de?.error??n.readError,n.engine?.bundled),e,`the repo-health engine`))},Ae=ie||se?(0,J.jsxs)(J.Fragment,{children:[ie?(0,J.jsx)(`p`,{children:N3()}):null,re?(0,J.jsxs)(`p`,{children:[re,fe?(0,J.jsxs)(J.Fragment,{children:[` · `,eDe(Tp(fe.mtime))]}):null,n?.head?(0,J.jsxs)(J.Fragment,{children:[` · `,tDe(Tp(n.head.ts))]}):null,pe?(0,J.jsxs)(J.Fragment,{children:[` · `,pe]}):null]}):null,se?(0,J.jsx)(`p`,{children:se}):null]}):null,je=e&&!ce&&!De?(0,J.jsx)(Vke,{busy:l,onClick:()=>void te(),label:l?P3(s,y-d):KEe(s)}):null,Me=!!e&&!i&&!ce,Ne=Rke({index:Me,drawn:k,plot:c,own:!!e}),Pe=zke(Ne);return(0,J.jsxs)(`div`,{className:`rh-region`,children:[(0,J.jsxs)(`div`,{className:`section-head rh-head`,children:[(0,J.jsx)(`span`,{className:`section section-hint rh-status${Ae?``:` rh-push`}`,children:ie??N3()}),Ae?(0,J.jsx)(tT,{of:`this series`,children:Ae}):null]}),e&&!ce&&(A.length||j.length)?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`fchips wrap rh-scope`,role:`group`,"aria-label":`which part of the repo`,children:[(0,J.jsx)(`span`,{className:`ctx-stackpick-lab`,children:`reading of`}),(0,J.jsx)(zw,{on:i===null,clears:!1,onClick:()=>a(null),children:TDe}),A.map(e=>(0,J.jsx)(zw,{on:i===e,clears:!1,onClick:()=>{q(`action:repohealth.scope`),a(e)},children:e},e)),j.length?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`fchips-gap`,"aria-hidden":!0}),(0,J.jsxs)(zw,{on:M,clears:!1,onClick:()=>N(e=>!e),children:[(0,J.jsx)(Xc,{size:12}),` break down…`]})]}):null]}),i?(0,J.jsx)(`div`,{className:`section section-hint`,children:EDe(i)}):null,M?(0,J.jsxs)(`div`,{className:`section section-hint`,children:[(0,J.jsx)(`div`,{children:ODe(j.length)}),(0,J.jsx)(`div`,{className:`fchips wrap rh-filter-chips`,role:`group`,"aria-label":`subtrees to measure`,children:j.map(e=>(0,J.jsx)(zw,{on:A.includes(e),busy:P&&A.includes(e),onClick:()=>void ee(A.includes(e)?A.filter(t=>t!==e):[...A,e]),children:e},e))}),(0,J.jsx)(`div`,{children:DDe()})]}):null]}):null,(0,J.jsx)($,{res:t,empty:!s&&!c,thing:`the repo-health series`,noun:`reading`,children:ce?Rt(`absent`):n?.engine?.needsApproval&&n.engine.kind===`repo`?`Not read yet — the repo's own engine is waiting for your approval.`:n?.engine?.needsApproval&&n.engine.kind===`bundled`?`Measured without this repo's own readings — they wait for your approval.`:n?.readError?WEe(n.readError):i?kDe(i,ae?.commits):UEe(ae?.commits,n?.stepTimeoutMs)}),oe?(0,J.jsx)(`div`,{className:`section section-hint`,children:oe}):null,le?(0,J.jsx)(`div`,{className:`section section-hint`,children:le}):null,ue?(0,J.jsx)(`div`,{className:`section section-hint`,children:ue}):null,de?(0,J.jsxs)(`div`,{className:`section section-hint`,children:[iDe(de),de.at?(0,J.jsxs)(J.Fragment,{children:[` (`,Tp(de.at),`)`]}):null,de.refused?(0,J.jsx)(`pre`,{className:`update-log rh-refusal`,children:de.refused.text}):null,me?(0,J.jsx)(`div`,{children:me}):null]}):null,De&&e?(0,J.jsxs)(`div`,{className:`section section-hint`,children:[(0,J.jsx)(`div`,{children:n?.readError}),n?.engine?.path?(0,J.jsx)(`div`,{children:(0,J.jsx)(`code`,{children:n.engine.path})}):null,(0,J.jsxs)(`div`,{className:`rh-tile-acts`,children:[(0,J.jsxs)(Y,{type:`button`,className:`rh-verb`,onClick:()=>void te(!0),children:[(0,J.jsx)(La,{size:12,"aria-hidden":!0}),` `,l?P3(s,y-d):FDe(n?.engine?.kind===`repo`?`repo`:`bundled`,s)]}),n?.engine?.kind===`repo`?null:(0,J.jsxs)(Y,{type:`button`,className:`rh-verb`,onClick:()=>void te(),children:[(0,J.jsx)(Ds,{size:12,"aria-hidden":!0}),` `,IDe(s)]})]})]}):null,Oe&&r&&e?(0,J.jsx)(`div`,{className:`section`,children:(0,J.jsxs)(Y,{className:`rh-verb`,type:`button`,onClick:ke,children:[(0,J.jsx)(Ec,{size:12,"aria-hidden":!0}),` `,eOe,`…`]})}):null,h?(0,J.jsx)(`div`,{className:`section section-hint`,children:h}):null,p?(0,J.jsx)(`div`,{className:`section section-hint`,children:QEe(p)}):null,ye?(0,J.jsx)(`div`,{className:`section section-hint`,children:ye}):null,Pe.length||je?(0,J.jsx)(Bke,{keys:Pe,refresh:je}):null,Me||k?(0,J.jsx)(Hke,{axis:O,onAxis:w,commits:T}):null,Me&&e?(0,J.jsx)(Ske,{repoId:e.id,axis:O,onCommits:D,seriesStamp:`${s?.lastSha??``}:${s?.rows??0}`,onAsk:r?we:void 0,onAskTrend:r?Te:void 0}):null,k&&c?(0,J.jsxs)(J.Fragment,{children:[B3(s?.versions)?(0,J.jsx)(`div`,{className:`rh-cap rh-gutter`,children:B3(s?.versions)}):null,(0,J.jsx)(`div`,{className:`section rh-prov`,children:ADe(I.displayName)}),zDe(c.central).map(e=>(0,J.jsx)(`div`,{className:`rh-cap rh-gutter`,children:e},e)),Ne.longest?(0,J.jsx)(_8,{id:`longest`,children:t=>(0,J.jsx)(Ake,{longest:k.longest,classics:k.classics,p95:be,width:t,onOpenFile:e&&o?t=>o(e.id,c.scope?`${c.scope.replace(/\/+$/,``)}/${t}`:t):void 0})}):null,(0,J.jsx)(eke,{series:k.series,windowReadings:c.windowReadings,minReadings:c.minReadings,axis:O,onAsk:r&&e?Ce:void 0,onAskAll:r&&e&&c.series.length?Ee:void 0}),(0,J.jsx)(YOe,{claudeMd:k.series.find(e=>e.key===`context.claudeMdChars`)??null,descriptions:k.series.find(e=>e.key===`context.descChars`)??null,context:c.context}),(0,J.jsx)(_8,{id:`size`,children:e=>(0,J.jsx)(Eke,{classics:k.classics,width:e})}),Ne.table?(0,J.jsx)(_8,{id:`table`,children:()=>(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Nke,{plot:c}),(0,J.jsxs)(`details`,{className:`hint-more rh-more`,children:[(0,J.jsx)(`summary`,{children:`not drawn here`}),(0,J.jsx)(`p`,{children:vDe()}),(0,J.jsx)(`p`,{children:oDe(!!n?.page)})]})]})}):null,e?(0,J.jsx)(Pke,{plot:c,repoName:e.repoName,series:k.own?.series,axis:O,actionsFor:r?e=>(0,J.jsxs)(Y,{className:`rh-verb`,type:`button`,onClick:()=>Ce({...e,detail:e.means}),children:[(0,J.jsx)(Ec,{size:12,"aria-hidden":!0}),` `,yDe,`…`]}):void 0}):null]}):null,he&&he.preamble?(0,J.jsxs)(`details`,{className:`hint-more rh-notes`,open:_,onToggle:e=>v(e.currentTarget.open),children:[(0,J.jsx)(`summary`,{children:`how to read this`}),(0,J.jsx)(`div`,{className:`tr-say rh-doc`,children:(0,J.jsx)(eG,{src:he.preamble,q:``,onCopy:e=>void Xf(e)})})]}):null,(0,J.jsx)(Uke,{days:ge})]})}function qke({repo:e,onOpen:t}){let n=Fn(e);return n===`unknown`?null:n===`absent`?(0,J.jsx)(`div`,{className:`act-cants`,children:(0,J.jsx)($w,{children:Rt(n)})}):(0,J.jsxs)(`button`,{className:`more-act`,onClick:t,children:[(0,J.jsx)(us,{size:Wke}),`over time`]})}function v8(e,t){return`From ${e}'s opt-ins — ${t}`}function Jke(e,t,n){let r=Gt(e),i=c(e,t.repoName);if(!r||i==null)return null;let a=r.action;if(a.kind!==`agent`&&a.kind!==`schedule`)return null;let o={prompts:[i],target:{kind:`repo`,cwd:t.worktreePath},cwdHint:t.worktreePath,repoId:t.id,origin:v8(t.repoName,r.title)};if(a.kind===`agent`)return o;let s=dr(e,n||`UTC`);return s?{...o,target:{kind:`repo`,cwd:t.worktreePath,launch:{model:a.model}},when:{kind:`at`,rule:s,graceMin:a.graceMin,name:r.title,waitUntilFree:!0}}:null}function Yke(e){return e.filter(e=>{let t=Gt(e.id)?.action.kind;return t===`agent`||t===`schedule`})}function Xke(e){return Yke(e).length>=2}function Zke(e){return`walk me through these ${e}…`}function Qke(e,t){let n=wte(e,t.repoName);return n==null?null:{prompts:[n],target:{kind:`repo`,cwd:t.worktreePath},cwdHint:t.worktreePath,repoId:t.id,origin:v8(t.repoName,`walk through ${e.length} offers`)}}function $ke(e){return`${e} you said not for me`}function eAe(e){return`${e} ${e===1?`doesn't`:`don't`} fit this repo`}function tAe(e,t){return`Nothing to offer here right now — every opt-in is either on or answered.${e+t>0?` What you turned down and what does not fit this repo are folded below.`:``}`}var nAe=`Optional things this repo can turn on. Nothing here is a problem, and nothing is sent until you send it.`,rAe=`Opt-ins compare nothing: they are offers, not readings. Each is on, off or not for you, and none is counted in the repo's badge.`,iAe=16;function y8(e){switch(e.kind){case`fix`:return(0,J.jsx)(bs,{size:14});case`open`:return e.to===`series`?(0,J.jsx)(us,{size:14}):(0,J.jsx)(tl,{size:14});case`agent`:return(0,J.jsx)(Ec,{size:14});case`schedule`:return(0,J.jsx)(rl,{size:14})}}function aAe({repo:e,onSeed:t,onSeries:n,onCapture:r,onChecklist:i}){let a=e?.id??``,o=gh(`optins:${a}`,()=>H.optIns(a),{enabled:!!a}),s=o.data,[c,l]=(0,V.useState)(null),[u,d]=(0,V.useState)(null),[f,p]=(0,V.useState)([]),[m,h]=(0,V.useState)(!1),[g,_]=(0,V.useState)(!1);async function v(e,t){if(a&&!c){q(t===`declined`?`action:optins.decline`:t===`done`?`action:optins.done`:`action:optins.clear`),l(e),d(null),p([]);try{let n=await H.optInChoice(a,e,t);n.ok&&n.report?o.set(n.report):n.ok?o.reload({quiet:!0}):d(n.error||`the desktop did not store it`)}catch(e){d(String(e.message||e))}finally{l(null)}}}async function y(e,t){if(a&&!c){q(`action:optins.fix`),l(e),d(null),p([]);try{let e=await H.complianceFix(a,[t]);e.ok?(p(e.notes??[]),e.report&&i?.(e.report),o.reload({quiet:!0})):d(e.error||`the fix did not run`)}catch(e){d(String(e.message||e))}finally{l(null)}}}function b(e){e&&t&&(q(`action:optins.seed`),t(e))}let x=pee(s?.rows??[]);function S(i){let a=Gt(i.id),o=a.action,s=c===i.id?`working…`:a.verb;return o.kind===`fix`?(0,J.jsxs)(Y,{onClick:()=>void y(i.id,o.fix),children:[y8(o),` `,s]}):o.kind===`open`&&o.to===`series`?(0,J.jsxs)(Y,{onClick:()=>{q(`action:optins.series`),n()},children:[y8(o),` `,s]}):o.kind===`open`?!e||!r?(0,J.jsx)($w,{children:`The capture screen cannot be opened from here.`}):(0,J.jsxs)(Y,{onClick:()=>{q(`action:optins.capture`),r(e)},children:[y8(o),` `,s]}):!e||!t?(0,J.jsx)($w,{children:`No send surface here — open this repo from the launcher to send it.`}):(0,J.jsxs)(Y,{onClick:()=>b(Jke(i.id,e,wA)),children:[y8(o),` `,s]})}return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`section-head`,children:[(0,J.jsx)(`span`,{className:`section section-hint`,children:nAe}),(0,J.jsxs)(Y,{onClick:()=>o.reload({quiet:!0}),title:`read the offers again`,children:[(0,J.jsx)(Ds,{size:14,className:o.inflight?`spin`:void 0}),` re-check`]})]}),(0,J.jsx)($,{res:o,empty:!s,thing:`the opt-ins`,noun:`list of opt-ins`,children:`The desktop listed no opt-ins for this repo.`}),u&&(0,J.jsxs)(Z,{style:{color:`var(--dead)`},children:[`The desktop said: `,u]}),f.map((e,t)=>(0,J.jsx)(Z,{children:e},t)),s&&(0,J.jsxs)(J.Fragment,{children:[e&&t&&Xke(x.offered)&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{className:`send`,onClick:()=>b(Qke(x.offered,e)),children:[(0,J.jsx)(Hte,{size:14,style:{verticalAlign:`-2px`,marginRight:4}}),Zke(x.offered.length)]}),(0,J.jsx)(Z,{children:`One session that asks which of these you want, then posts each one as its own piece of work. Nothing is set up in it.`})]}),x.offered.length===0?(0,J.jsx)(`div`,{className:`empty`,children:tAe(x.declined.length,x.unfit.length)}):(0,J.jsx)(`ul`,{className:`check-list`,children:x.offered.map(e=>{let t=Gt(e.id);return(0,J.jsxs)(`li`,{className:`check-row optin-card`,children:[(0,J.jsx)(`div`,{className:`check-top`,children:(0,J.jsx)(`span`,{className:`check-label`,children:t.title})}),(0,J.jsx)(`div`,{className:`check-detail optin-pitch`,children:t.pitch}),(0,J.jsx)(`div`,{className:`check-detail check-detail-quiet`,children:t.cost}),e.detail&&(0,J.jsx)(`div`,{className:`check-detail optin-seen`,children:e.detail}),(0,J.jsxs)(`div`,{className:`check-acts optin-acts`,children:[S(e),e.state===`unknown`&&(0,J.jsxs)(Y,{onClick:()=>void v(e.id,`done`),children:[(0,J.jsx)(vc,{size:14}),` mark as done`]}),(0,J.jsxs)(Y,{onClick:()=>void v(e.id,`declined`),children:[(0,J.jsx)(Go,{size:14}),` not for me`]})]})]},e.id)})}),x.active.length>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`section`,children:`On`}),(0,J.jsx)(`ul`,{className:`check-list`,children:x.active.map(e=>(0,J.jsxs)(`li`,{className:`check-row optin-on`,children:[(0,J.jsxs)(`div`,{className:`check-top`,children:[(0,J.jsxs)(`span`,{className:`check-label`,children:[Gt(e.id).title,(0,J.jsxs)(`span`,{className:`check-kind`,children:[` · `,dee(e)]})]}),e.choice===`done`&&(0,J.jsxs)(Y,{onClick:()=>void v(e.id,null),children:[(0,J.jsx)(Zs,{size:14}),` undo`]})]}),e.detail&&(0,J.jsx)(`div`,{className:`check-detail check-detail-quiet`,children:e.detail})]},e.id))})]}),x.declined.length>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{className:`section optin-fold`,onClick:()=>h(e=>!e),"aria-expanded":m,children:[m?(0,J.jsx)(Nc,{size:14}):(0,J.jsx)(Hs,{size:14}),` `,$ke(x.declined.length)]}),m&&(0,J.jsx)(`ul`,{className:`check-list`,children:x.declined.map(e=>(0,J.jsx)(`li`,{className:`check-row optin-on`,children:(0,J.jsxs)(`div`,{className:`check-top`,children:[(0,J.jsx)(`span`,{className:`check-label`,children:Gt(e.id).title}),(0,J.jsxs)(Y,{onClick:()=>void v(e.id,null),children:[(0,J.jsx)(tc,{size:14}),` offer again`]})]})},e.id))})]}),x.unfit.length>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{className:`section optin-fold`,onClick:()=>_(e=>!e),"aria-expanded":g,children:[g?(0,J.jsx)(Nc,{size:14}):(0,J.jsx)(Hs,{size:14}),` `,eAe(x.unfit.length)]}),g&&(0,J.jsx)(`ul`,{className:`check-list`,children:x.unfit.map(e=>(0,J.jsxs)(`li`,{className:`check-row optin-on`,children:[(0,J.jsx)(`div`,{className:`check-top`,children:(0,J.jsx)(`span`,{className:`check-label`,children:Gt(e.id).title})}),(0,J.jsx)(`div`,{className:`check-detail check-detail-quiet`,children:e.detail||`The desktop did not say why.`})]},e.id))})]})]})]})}function oAe({onOpen:e}){return(0,J.jsxs)(`button`,{className:`more-act`,onClick:e,title:`optional things this repo can turn on`,children:[(0,J.jsx)(Ho,{size:iAe}),`opt-ins`]})}var sAe={pass:(0,J.jsx)(vc,{size:16,color:`var(--ok)`}),warn:(0,J.jsx)(gs,{size:16,color:`var(--warn)`}),fail:(0,J.jsx)(B,{size:16,color:`var(--dead)`})};function b8({repos:e,initialRepoId:t,initialRegion:n=`setup`,focus:r,onRemedy:i,onOpenFile:a,onSeed:o,onCapture:s,onClose:c}){let l=e.filter(e=>e.isPrimary),[u,d]=(0,V.useState)(t&&e.some(e=>e.id===t)?t:l[0]?.id??``),[f,p]=(0,V.useState)(n),[m,h]=(0,V.useState)(r===`findings`);(0,V.useEffect)(()=>{h(r===`findings`)},[r]),(0,V.useEffect)(()=>{p(n)},[n]);let[g,_]=(0,V.useState)(!1),[v,y]=(0,V.useState)(null),[b,x]=(0,V.useState)([]),[S]=(0,V.useState)(s3),C=gh(u,()=>H.compliance(u),{enabled:!!u}),[w,T]=(0,V.useState)(null),E=gh(`repohealth:${u}:${w??``}`,()=>H.repoHealth(u,w),{enabled:!!u}),D=C.data,O=E.data,k=e.find(e=>e.id===u)??null;async function A(e,t){if(u){q(t?`action:setup.ignore`:`action:setup.unignore`),_(!0),y(null),x([]);try{let n=await H.complianceIgnore(u,e,t);n.ok&&n.report?C.set(n.report):y(n.error||`the desktop did not store it`)}catch(e){y(String(e.message||e))}finally{_(!1)}}}async function j(e){if(!u||!e.length)return null;q(`action:setup.fix`),_(!0),y(null);try{let t=e.length===1?D?.confirm?.[e[0]]:void 0,n=await H.complianceFix(u,e,t);if(n.ok&&x(n.notes??[]),n.ok&&n.report)return C.set(n.report),n.report;n.ok||y(n.error||`fix failed`)}catch(e){y(String(e.message||e))}finally{_(!1)}return null}let M=D?.checks??[],N=a6(M),P=i6(M),F=!!i&&!!k,ee=N.length+(F?P.length:0),te=M.filter(nr),ne=m?te:M;async function re(){if(!k)return;let e=D;if(N.length){let t=await j(XDe(M));if(!t)return;e=t}let t=e?i6(e.checks):[];t.length&&i&&i(u6(t,k.repoName,r6()),k,t.length===1?t[0].label.toLowerCase():`${t.length} setup findings`)}let ie=O?.plot??null,ae=ie?.series.find(e=>e.key===`context.claudeMdChars`)??null;return(0,J.jsx)(Hw,{className:`readings-sheet`,title:`Repo readings`,icon:(0,J.jsx)(us,{size:18}),onClose:c,children:(0,J.jsx)(`div`,{className:`sheet-scroll`,children:(0,J.jsxs)(`div`,{className:`form`,children:[(0,J.jsx)(oF,{repos:e.filter(e=>e.isPrimary||e.id===u),value:e.find(e=>e.id===u)?.worktreePath??``,onChange:t=>{let n=e.find(e=>e.worktreePath===t);n&&d(n.id)},"aria-label":`repo`}),(0,J.jsxs)(`div`,{className:`ts-filter`,role:`group`,"aria-label":`reading`,children:[(0,J.jsx)(`span`,{className:`ctx-stackpick-lab`,children:`reading`}),(0,J.jsxs)(zw,{on:f===`setup`,clears:!1,onClick:()=>{p(`setup`),T(null)},children:[(0,J.jsx)(Wo,{size:14}),` set-up`]}),(0,J.jsxs)(zw,{on:f===`series`,clears:!1,onClick:()=>p(`series`),children:[(0,J.jsx)(us,{size:14}),` over time`]}),(0,J.jsxs)(zw,{on:f===`optins`,clears:!1,onClick:()=>{p(`optins`),T(null)},children:[(0,J.jsx)(Ho,{size:14}),` opt-ins`]}),(0,J.jsx)(tT,{of:`what this region compares`,children:f===`optins`?rAe:wDe(f)})]}),f===`setup`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(cAe,{repoId:u,repo:k,res:C,report:D,rows:ne,allRows:M,cut:m,onClearCut:()=>h(!1),busy:g,fixError:v,fixNotes:b,presets:S,canAsk:F,bulkCount:ee,patchable:N.length,forAgent:P.length,onFix:j,onIgnore:A,onFixAll:()=>void re(),onRemedy:i,claudeMdSeries:ae,descSeries:ie?.series.find(e=>e.key===`context.descChars`)??null}),k&&(0,J.jsx)(mOe,{repo:k,say:K})]}):f===`optins`?(0,J.jsx)(aAe,{repo:k,onSeed:o,onCapture:s,onSeries:()=>p(`series`),onChecklist:e=>C.set(e)}):(0,J.jsx)(Kke,{repo:k,res:E,view:O,onRemedy:i,scope:w,onScope:T,onOpenFile:a})]})})})}function cAe({repoId:e,repo:t,res:n,report:r,rows:i,allRows:a,cut:o,onClearCut:s,busy:c,fixError:l,fixNotes:u,presets:d,canAsk:f,bulkCount:p,patchable:m,forAgent:h,onFix:g,onIgnore:_,onFixAll:v,onRemedy:y,claudeMdSeries:b,descSeries:x}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`section-head`,children:[(0,J.jsx)(`span`,{className:`section section-hint`,children:`Checks a repo follows the conventions: CLAUDE.md tells the agent to use the outbox, inbox/outbox are gitignored and secrets aren't committed. Re-run regularly.`}),(0,J.jsxs)(Y,{onClick:()=>n.reload({quiet:!0}),title:`re-check`,children:[(0,J.jsx)(Ds,{size:14,className:n.inflight?`spin`:void 0}),` re-check`]})]}),(0,J.jsx)($,{res:n,empty:!r,thing:`the setup checklist`,noun:`checklist`,children:`Nothing in this checklist applies to this repo yet.`}),l&&(0,J.jsxs)(Z,{style:{color:`var(--dead)`},children:[`Fix failed: `,l]}),u.map((e,t)=>(0,J.jsx)(Z,{children:e},t)),r&&(0,J.jsxs)(J.Fragment,{children:[p>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{className:`send`,onClick:v,disabled:c,children:[(0,J.jsx)(bs,{size:14,style:{verticalAlign:`-2px`,marginRight:4}}),c?`Fixing…`:ZDe(m,f?h:0)]}),f&&t&&d6(m,h,t.repoName)&&(0,J.jsx)(Z,{children:d6(m,h,t.repoName)})]}),o&&(0,J.jsxs)(`div`,{className:`section filter-bar`,children:[(0,J.jsx)(`span`,{className:`filter-bar-txt`,children:rOe(i.length,a.length)}),(0,J.jsxs)(`button`,{className:`filter-bar-clear`,onClick:s,children:[(0,J.jsx)(B,{size:14}),` clear`]})]}),(0,J.jsx)(`ul`,{className:`check-list`,children:i.filter(e=>!e.ignored).map(i=>{let a=(nr(i)||gi(i))&&!i.fix,o=a&&f?ITe(i.id,d):null,s=a&&f&&t?o?{label:o.title,run:()=>y(o.text,t,o.title)}:r6().byCheck(i.id)?.agent?{label:l6(i.id,r6()),run:()=>uAe(r6().byCheck(i.id).agent,t,i.label)}:{label:l6(i.id,r6()),run:()=>y(u6([i],t.repoName,r6()),t,i.label.toLowerCase())}:null,l=i.id===`context-weight`&&r.contextLimits?(0,J.jsx)(_6,{repoId:e,view:r.contextLimits,setAt:r.contextLimitsSetAt,onReport:e=>n.set(e)}):null,u=i.id===`context-weight`?(0,J.jsx)(lAe,{claudeMd:b,desc:x,workingTree:i.alwaysOnChars??null}):null;return(0,J.jsx)(dAe,{c:i,busy:c,onFix:g,remedy:s,size:r.autoCompactDefault,onIgnore:_,extra:(0,J.jsxs)(J.Fragment,{children:[u,l]})},i.id)})}),!o&&a.some(e=>e.ignored)&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`section`,children:`Ignored in this repo`}),(0,J.jsx)(`ul`,{className:`check-list`,children:a.filter(e=>e.ignored).map(e=>(0,J.jsxs)(`li`,{className:`check-row check-ignored`,children:[(0,J.jsxs)(`div`,{className:`check-top`,children:[(0,J.jsx)(`span`,{className:`check-icon`,children:(0,J.jsx)(Go,{size:16,color:`var(--dim)`})}),(0,J.jsx)(`span`,{className:`check-label`,children:e.label}),(0,J.jsx)(Y,{onClick:()=>_(e.id,!1),children:`stop ignoring`})]}),(0,J.jsx)(`div`,{className:`check-detail check-detail-quiet`,children:e.status===`pass`?`Fine here now.`:`Still on the far side of its line — not counted, not suggested.`})]},e.id))})]}),r.contextLimits&&!a.some(e=>e.id===`context-weight`)&&(0,J.jsxs)(`div`,{className:`check-row check-pass`,children:[(0,J.jsx)(`div`,{className:`check-top`,children:(0,J.jsx)(`span`,{className:`check-label`,children:`Agent context weight`})}),(0,J.jsx)(`div`,{className:`check-detail`,children:`Nothing to weigh yet — this repo has no CLAUDE.md. These are the thresholds it will be measured against once it does.`}),(0,J.jsx)(_6,{repoId:e,view:r.contextLimits,setAt:r.contextLimitsSetAt,onReport:e=>n.set(e)})]})]})]})}function lAe({claudeMd:e,desc:t,workingTree:n}){if(!e&&!t)return null;let r=e?.points[e.points.length-1]?.sha7??t?.points[t.points.length-1]?.sha7??null,i=hDe(n,e?.last!=null&&t?.last!=null?e.last+t.last:null,r);return(0,J.jsxs)(`div`,{className:`rh-twin`,children:[i?(0,J.jsx)(`div`,{className:`rh-twin-line`,children:i}):null,(0,J.jsx)(`ul`,{className:`rh-twin-rows`,children:[e,t].filter(Boolean).map(e=>(0,J.jsxs)(`li`,{children:[(0,J.jsx)(`span`,{className:`rh-twin-key`,children:e.label}),(0,J.jsx)(`span`,{className:`rh-twin-val`,children:F3(e.last,e.unit)}),(0,J.jsx)(q6,{points:e.points,width:96,height:18,label:e.label})]},e.key))}),I3(e?.reading??t?.reading)?(0,J.jsx)(`div`,{className:`rh-twin-read`,children:I3(e?.reading??t?.reading)}):null]})}function uAe(e,t,n){try{e(t,U())}catch(e){K(`${n} could not start: ${e instanceof Error?e.message:String(e)}`)}}function dAe({c:e,busy:t,onFix:n,onIgnore:r,size:i,remedy:a,extra:o}){let s=gi(e);return(0,J.jsxs)(`li`,{className:`check-row check-${s?`consider`:e.status}`,children:[(0,J.jsxs)(`div`,{className:`check-top`,children:[(0,J.jsx)(`span`,{className:`check-icon`,children:s?(0,J.jsx)(ll,{size:16,color:`var(--accent)`}):sAe[e.status]}),(0,J.jsxs)(`span`,{className:`check-label`,children:[e.label,s&&(0,J.jsx)(`span`,{className:`check-kind`,children:` · consider`})]}),e.fix&&!o6(e.fix)&&(0,J.jsxs)(Y,{onClick:()=>n([e.fix]),disabled:t,children:[(0,J.jsx)(bs,{size:12}),` `,s6(e.fix,i,r6())]})]}),(0,J.jsx)(`div`,{className:`check-detail`,children:e.detail}),e.fix&&!o6(e.fix)&&c6(e.fix)&&(0,J.jsx)(Z,{children:c6(e.fix)}),s&&(0,J.jsxs)(`div`,{className:`check-acts check-acts-split`,children:[(0,J.jsx)(Z,{as:`span`,children:`Not counted in the badge. Leaving it is a fine answer.`}),(0,J.jsxs)(Y,{onClick:()=>r(e.id,!0),children:[(0,J.jsx)(Go,{size:12}),` ignore in this repo`]})]}),e.fix&&o6(e.fix)&&(0,J.jsx)(`div`,{className:`check-acts`,children:(0,J.jsxs)(fC,{confirm:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(bs,{size:12}),` `,YDe(e.fix,i)]}),disabled:t,onConfirm:()=>void n([e.fix]),children:[(0,J.jsx)(bs,{size:12}),` `,s6(e.fix,i,r6())]})}),a&&(0,J.jsx)(`div`,{className:`check-acts`,children:(0,J.jsxs)(Y,{onClick:a.run,children:[(0,J.jsx)(Ec,{size:12}),` `,a.label,`…`]})}),o]})}var x8=W(null),S8=W({}),C8=W(null),fAe=`first-look`;function w8(e=fAe){wa(R.demoTour),!(hu()&&Cne(e))&&va(e)}function T8(){wa(R.demoTour),!(hu()&&wne())&&Ca()}function pAe(e,t){if(e)return`shell`;let n=t.toLowerCase();return n===`localhost`||n===`[::1]`||n.endsWith(`.ts.net`)||n.endsWith(`.local`)||/^\d{1,3}(\.\d{1,3}){3}$/.test(n)?`host`:`static`}function mAe(){return pAe(hu(),globalThis.location?.hostname??``)}var E8=`app:open-demotour`;function hAe(){try{window.dispatchEvent(new CustomEvent(E8))}catch{}}var D8=`app:open-repohealth`;function O8(e){try{window.dispatchEvent(new CustomEvent(D8,{detail:{repoId:e??null}}))}catch{}}function gAe(){return ou(nu()).length>0}function _Ae(e,t,n){return{prompts:[e],target:{kind:`repo`,cwd:t.worktreePath},cwdHint:t.worktreePath,repoId:t.id,origin:`From ${t.repoName}'s repo readings — ${n}`}}function vAe(e){return{...e,region:`series`}}function yAe(e,t={}){x8.set(e),S8.set(t),U().nav.open(`setup`)}function k8(e){C8.set(e),U().nav.open(`repohealth`)}function A8(e,t,n){U().say.track(`action:setup.remedy`),j8(_Ae(e,t,n))}function j8(e){x8.set(null),C8.set(null),U().nav.openSend(e)}function M8(e){U().nav.openCapture(e)}function N8(e,t){let n=U();n.say.track(`action:files.fromReadings`);let r=n.nav.overlay;r===`setup`&&S8.set(vAe(S8.get())),n.files.browseTo(e,t,r)}function bAe(){let e=U();x8.set(null),S8.set({}),e.nav.close(`setup`),e.world.refreshRepos()}function xAe(){let e=e=>{let t=U(),n=e.detail?.repoId??null,r=(n?t.world.repos.find(e=>e.id===n):null)??t.world.activeRepo??t.world.repos.find(e=>e.isPrimary)??null;r&&k8(r)};return window.addEventListener(D8,e),()=>window.removeEventListener(D8,e)}function SAe(){C8.set(null),U().nav.close(`repohealth`)}function CAe(){let e=Dh(),t=G(x8),n=G(S8);return(0,J.jsx)(b8,{repos:e.world.repos,initialRepoId:t??void 0,initialRegion:n.region,focus:n.focus,onRemedy:A8,onOpenFile:N8,onSeed:j8,onCapture:M8,onClose:bAe})}function wAe({repo:e}){let t=Dh();return(0,J.jsx)(b8,{repos:t.world.repos,initialRepoId:e.id,initialRegion:`series`,onRemedy:A8,onOpenFile:N8,onSeed:j8,onCapture:M8,onClose:SAe})}function TAe(){let[e,t]=(0,V.useState)(null),[n,r]=(0,V.useState)(null);(0,V.useEffect)(()=>{let e=!0;return H.setupPrefs().then(n=>{e&&t(n.autoCompactDefault)}).catch(t=>{e&&r(String(t.message||t))}),()=>{e=!1}},[]);async function i(n){let i=e;t(n);try{let e=await H.setSetupPrefs(n===`400k`?null:n);if(!e.ok){t(i),K(e.error||`the desktop did not store it`);return}t(e.autoCompactDefault??n),r(null)}catch(e){t(i),K(`not saved — ${String(e.message||e)}`)}}return(0,J.jsx)(QS,{id:`auto-compact-default`,label:`auto-compact window`,icon:hs,value:e??``,options:$ee.map(e=>({value:e,label:e===`400k`?`${e} (default)`:e})),onChange:e=>void i(e),note:n?`Could not read this desktop's choice: ${n}`:`What Repo readings offers to write into a repo's .claude/settings.json, and the size under which a repo's window counts as fine. Nothing is written until you tap it there.`,more:(0,J.jsx)(`p`,{children:`A conversation compacts once its context passes this, so one long agent stops re-reading a whole 1M window on every step. Smaller is cheaper per step and compacts more often. Stored on the desktop, the same for every device.`})})}var EAe={id:`setup`,sheets:[{id:`setup`,persisted:!1,render:()=>(0,V.createElement)(CAe)},{id:`repohealth`,persisted:!1,render:()=>{let e=C8.get();return e?(0,V.createElement)(wAe,{repo:e}):null}}],boot:()=>xAe(),settings:[{group:`sessions`,order:30,render:()=>(0,V.createElement)(TAe)}]};function DAe(e){let t=(e+`=`.repeat((4-e.length%4)%4)).replace(/-/g,`+`).replace(/_/g,`/`),n=atob(t),r=new ArrayBuffer(n.length),i=new Uint8Array(r);for(let e=0;e<n.length;e++)i[e]=n.charCodeAt(e);return i}function P8(){return hu()}function F8(){return P8()||ha()?!1:`serviceWorker`in navigator&&`PushManager`in window&&`Notification`in window}function OAe(){return typeof window<`u`&&window.isSecureContext}async function kAe(){if(ha())return`demo`;if(P8())return`native`;if(!OAe())return`insecure`;if(!F8())return`unsupported`;if(Notification.permission===`denied`)return`denied`;try{return await(await navigator.serviceWorker.ready).pushManager.getSubscription()?`on`:`off`}catch{return`off`}}async function AAe(){if(!F8()||await Notification.requestPermission()!==`granted`)return!1;let e=await navigator.serviceWorker.ready,{key:t}=await H.push.key(),n=await e.pushManager.subscribe({userVisibleOnly:!0,applicationServerKey:DAe(t)});return await H.push.subscribe(n),!0}async function jAe(){if(!F8())return;let e=await(await navigator.serviceWorker.ready).pushManager.getSubscription();e&&(await H.push.unsubscribe(e.endpoint),await e.unsubscribe())}var I8=W(`off`),L8=W(null);function R8(){return G(I8)}function MAe(){return G(L8)}var z8=`This app has no OS push and no background link — alerts show in the in-app feed while it is open.`;function NAe(e){let t=e=>(e/1e9).toFixed(1),n=e.loadavg.map(e=>e.toFixed(2)).join(`/`);return`CPU ${e.cpuPct}% · load ${n} · ${e.cores} cores · mem ${t(e.memTotal-e.memFree)}/${t(e.memTotal)}G`}function PAe(e){return`${e.tailscaleBin??`tailscale`} serve --bg --https=443 http://127.0.0.1:${e.hostPort}`}function FAe(e){return[e.httpsUrl&&{label:`Tailscale HTTPS`,url:e.httpsUrl,note:`secure context — OS push, install & offline shell work`},e.tailscaleIp&&{label:`Tailscale IP`,url:`http://${e.tailscaleIp}:${e.hostPort}`,note:`over the tunnel, anywhere`},...e.lanIps.map(t=>({label:`LAN`,url:`http://${t}:${e.hostPort}`,note:`same WiFi — bypasses the tunnel`}))].filter(Boolean)}function IAe(e){return e?/\s/.test(e)?`that does not look like a code — copy just the code and try again`:null:`phone clipboard is empty — copy the code from the sign-in page first`}async function B8(){try{U().say.toast(NAe(await H.hostStat()))}catch{U().say.toast(`host stat failed`)}}async function V8(e){let t=U().say;t.toast(`capturing screen…`);try{let n=await H.screenshot(e);if(!n.file){t.toast(`screenshot failed: ${n.error??`?`}`);return}U().files.annotateUrl(H.artifactUrl(e,n.file.relPath),n.file.name,e)}catch{t.toast(`screenshot failed`)}}async function LAe(e){let t=U();if(t.say.track(`action:login.code`),!window.isSecureContext||!navigator.clipboard?.readText){t.say.toast(`clipboard read needs https — type the code into the compose bar instead`);return}let n=``;try{n=(await navigator.clipboard.readText()).trim()}catch{t.say.toast(`phone clipboard unavailable — type the code into the compose bar instead`);return}let r=IAe(n);r?t.say.toast(r):t.conn.liveSend({t:`session.input`,id:e,data:n},`typed ${n.length} chars into the sign-in input`)&&window.setTimeout(()=>U().conn.send({t:`session.input`,id:e,data:`\r`}),120)}async function RAe(){let e=U(),t=I8.get();if(t===`native`){if(!XG()){e.say.toast(z8);return}XI(`notif-shell-link`),e.say.toast(`This app gets alerts through the background link`)}else if(t===`insecure`)XI(`notif-push`),e.say.toast(`OS notifications need HTTPS`);else if(t===`unsupported`)e.say.toast(`This browser has no Web Push support`);else if(t===`on`)await jAe(),I8.set(`off`),e.say.toast(`Notifications off`);else{let t=await AAe();I8.set(t?`on`:`denied`),e.say.toast(t?`Notifications on`:`Permission denied`)}}async function H8(){L8.set(await QG())}async function U8(){let e=U().say;if(L8.get()?.enabled){await eK(),L8.set(await QG()),e.toast(`Background link off — the app only holds the connection while it is open`);return}let t=await $G();L8.set(t??await QG()),t?e.toast(t.notifications?`Background link on`:`Background link on — notifications are blocked, so it will drain the queue silently`):e.toast(`No paired host yet — set one under Paired host first`)}function zAe(e){(0,V.useEffect)(()=>{if(!XG())return;let t=!0,n=async()=>{let e=await QG();t&&L8.set(e)};if(n(),!e)return()=>{t=!1};let r=window.setInterval(n,3e3);return()=>{t=!1,window.clearInterval(r)}},[e])}function BAe(){let e=!0;return kAe().then(t=>{e&&I8.set(t)}),()=>{e=!1}}var W8=16,VAe={link:Dc,notifications:Ja,battery:ac,install:Tl};async function HAe(e,t){q(`action:phoneSetup.${e}`),e===`link`?await U8():e===`notifications`?await nK():e===`battery`?await tK():await Ak().catch(()=>K(`this phone has no screen for that switch`)),await H8(),t()}function G8({steps:e,refresh:t}){return(0,J.jsx)(`div`,{className:`list`,children:e.map(e=>{let n=VAe[e.id];return(0,J.jsxs)(Xw,{kind:`wrap`,children:[(0,J.jsxs)(Xw,{kind:`grow`,children:[(0,J.jsxs)(Zw,{children:[(0,J.jsx)(n,{size:12}),` `,e.label,`: `,e.done?`ready`:`not allowed yet`]}),(0,J.jsx)(Q,{className:`dim`,children:e.why})]}),(0,J.jsx)(`div`,{className:`row-acts`,children:e.done?(0,J.jsxs)(Q,{children:[(0,J.jsx)(vc,{size:W8}),` done`]}):(0,J.jsx)(Y,{variant:`primary`,onClick:()=>void HAe(e.id,t),children:`allow`})})]},e.id)})})}function UAe(){let{steps:e,refresh:t}=GY(),[n,r]=(0,V.useState)(!1),i=()=>U().nav.close(`phonesetup`);if(!e)return null;let{shown:a,hidden:o}=WY(e,n),s=e.filter(e=>!e.done).length;return(0,J.jsxs)(Hw,{title:`Phone setup · ${HY(e)}`,icon:(0,J.jsx)(Ra,{size:W8}),onClose:i,children:[o>0&&(0,J.jsxs)(Pw,{section:!0,onClear:()=>r(!0),clearTitle:`also show the ${o} step${o===1?``:`s`} already allowed`,clearLabel:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(B,{size:13}),` show all `,e.length]}),children:[`showing what is not allowed yet · `,a.length,` of `,e.length]}),s===0&&!n?(0,J.jsx)($,{children:`Everything is allowed — this app works with the app closed.`}):(0,J.jsx)(G8,{steps:a,refresh:t}),(0,J.jsx)(Q,{as:`div`,style:{padding:`8px 12px`},children:`Android grants none of these on its own — each is your tap on a system dialog or switch. This list re-reads when you come back from one.`})]})}var WAe=2048;function GAe(e){if(!e)return null;try{let t=JSON.parse(e);if(!t||typeof t!=`object`)return null;let{url:n,ts:r}=t;return typeof n!=`string`||typeof r!=`number`||!Number.isFinite(r)?null:{url:n,ts:r}}catch{return null}}function KAe(e){return!e||e.length>WAe||!e.startsWith(`/`)||e.startsWith(`//`)||/[\\\s\u0000-\u001f\u007f]/.test(e)?!1:e.includes(`#`)||e.includes(`?`)}function qAe(e){return e.hash.replace(/^#/,``)!==``||e.search.replace(/^\?/,``)!==``}function JAe(e,t,n,r){if(!t||!e||qAe(n)||!KAe(e.url))return null;let i=r-e.ts;return i<0||i>6048e5?null:e.url}function YAe(e,t){Ta(R.routeLast,{url:e,ts:t})}function K8(){ua(R.routeResume,`1`)}function XAe(e,t){let n=z(R.routeResume)===`1`;return n&&wa(R.routeResume),JAe(GAe(z(R.routeLast)),n,e,t)}var q8=R.webUpdateAuto,J8=R.webUpdateStaged,Y8=R.webUpdateApply,X8=R.webUpdateApplyTries,Z8=R.webUpdateRecoverySeen,Q8=2e4,ZAe=12e4,QAe=2,$8=`Not in the demo — updates come from your own desktop's host.`,e5=8192;function t5(){let e=Nh(`Update`);return e&&typeof e.info==`function`?e:null}function n5(){return hu()&&t5()!==null}function r5(){return z(q8)!==`0`}function $Ae(e){ua(q8,e?`1`:`0`),s5.emit()}function i5(){return z(Y8)!==`0`}function eje(e){ua(Y8,e?`1`:`0`),s5.emit()}function a5(e){let t=ma(X8,null);return t&&t.id===e&&typeof t.n==`number`?t.n:0}function tje(e){Ta(X8,{id:e,n:a5(e)+1})}function o5(){wa(X8)}var s5=new class{status={phase:n5()?`idle`:`unsupported`,current:null,available:null,stagedId:z(J8),lastCheckedAt:null};listeners=new Set;busy=!1;hiddenAt=0;applyTimer=null;applying=!1;subscribe(e){return this.listeners.add(e),e(this.status),()=>{this.listeners.delete(e)}}emit(){for(let e of this.listeners)e(this.status)}get(){return this.status}set(e){this.status={...this.status,...e},this.emit()}async markHealthy(){let e=t5();if(!e)return;try{await e.markHealthy()}catch{}this.sayFallback();let t=await l5();this.set({current:t}),t&&this.status.stagedId===t&&(wa(J8),o5(),this.set({stagedId:null,phase:`idle`}))}async sayFallback(){let e=await c5();!e||!e.lastRecoveryAt||Number(z(Z8)??0)>=e.lastRecoveryAt||(ua(Z8,String(e.lastRecoveryAt)),K(`${e.badBuild?`Build ${e.badBuild.slice(0,8)}`:`A downloaded build`} did not start${e.badReason?` (${e.badReason})`:``}, so the app went back to the build inside it. It takes the desktop's next build as usual.`))}watchAutoApply(){if(!n5())return()=>{};let e=()=>{if(this.clearApplyTimer(),document.visibilityState===`hidden`)this.hiddenAt=Date.now(),this.armApply(Q8);else{let e=this.hiddenAt?Date.now()-this.hiddenAt:0;this.hiddenAt=0,e>=ZAe&&this.autoApply()}};return document.addEventListener(`visibilitychange`,e),document.visibilityState===`hidden`&&e(),()=>{document.removeEventListener(`visibilitychange`,e),this.clearApplyTimer()}}clearApplyTimer(){this.applyTimer!==null&&(clearTimeout(this.applyTimer),this.applyTimer=null)}armApply(e){i5()&&(this.clearApplyTimer(),this.applyTimer=setTimeout(()=>{this.applyTimer=null,this.autoApply()},e))}async autoApply(){if(!i5()||this.applying||this.busy)return;let e=this.status.stagedId;this.status.phase===`staged`&&e&&e!==this.status.current&&(a5(e)>=QAe||(this.applying=!0,tje(e),await this.applyNow(),this.applying=!1))}async check(){if(!n5())return this.status;if(ha())return this.set({phase:`unavailable`,message:$8}),this.status;if(this.busy)return this.status;this.set({phase:`checking`,message:void 0});try{let e=this.status.current??await l5(),t=await H.webBundle.manifest();if(!t)throw Error(`the host did not answer`);if(!t.ok||!t.buildId)return this.set({phase:`unavailable`,current:e,available:null,message:t.reason||`the host cannot serve a bundle`,lastCheckedAt:Date.now()}),this.status;this.set({current:e,available:t.buildId,lastCheckedAt:Date.now()});let n=t.buildId===e?null:await nje(t.buildId);return t.buildId===e?this.set({phase:`idle`}):n===null?t.buildId===this.status.stagedId?this.set({phase:`staged`}):(this.set({phase:`idle`}),r5()&&this.download()):(this.unstage(t.buildId),this.set({phase:`held`,message:n})),this.status}catch(e){return this.set({phase:`error`,message:u5(e)}),this.status}}async download(e=!1){let t=t5();if(t&&!this.busy){if(ha())this.set({phase:`unavailable`,message:$8});else{this.busy=!0;try{let n=await H.webBundle.manifest();if(!n)throw Error(`the host did not answer`);if(!n.ok||!n.buildId)throw Error(n.reason||`no bundle on the host`);let r=n.buildId;this.set({phase:`downloading`,available:r,progress:{files:0,totalFiles:n.files.length,bytes:0,totalBytes:n.total}}),await t.beginBundle({id:r});let i=0;for(let e=0;e<n.files.length;e++){let a=n.files[e],o=await H.webBundle.file(a.path,r);if(!o.ok)throw Error(`${a.path}: ${o.status}`);let s=await o.arrayBuffer();if(await rje(s)!==a.sha256)throw Error(`${a.path} arrived corrupted`);await t.writeFile({id:r,path:a.path,dataBase64:ije(s)}),i+=s.byteLength,this.set({progress:{files:e+1,totalFiles:n.files.length,bytes:i,totalBytes:n.total}})}await t.finishBundle({id:r});try{await t.stage({id:r,force:e})}catch(e){if(e?.code===`BAD_BUILD`){this.unstage(r),this.set({phase:`held`,message:u5(e),progress:void 0});return}throw e}ua(J8,r),K8(),this.set({phase:`staged`,stagedId:r,progress:void 0}),document.visibilityState===`hidden`&&this.armApply(Q8)}catch(e){this.set({phase:`error`,message:u5(e),progress:void 0})}finally{this.busy=!1}}}}unstage(e){this.status.stagedId===e&&(wa(J8),o5(),this.set({stagedId:null}))}async applyNow(){let e=t5(),t=this.status.stagedId;if(e&&t){if(ha())this.set({message:$8});else{K8();try{await e.applyNow({id:t})}catch(e){this.set({phase:`error`,message:u5(e)})}}}}async revertToBuiltIn(){let e=t5();if(e){wa(J8),o5(),this.set({stagedId:null,phase:`idle`}),K8();try{await e.revertToBuiltIn()}catch(e){this.set({phase:`error`,message:u5(e)})}}}};async function c5(){let e=t5();if(!e)return null;try{let t=await e.info();return{builtIn:!!t.builtIn,basePath:typeof t.basePath==`string`?t.basePath:``,versionName:typeof t.versionName==`string`?t.versionName:``,versionCode:typeof t.versionCode==`number`?t.versionCode:0,badBuild:typeof t.badBuild==`string`?t.badBuild:``,badReason:typeof t.badReason==`string`?t.badReason:``,lastRecoveryAt:typeof t.lastRecoveryAt==`number`?t.lastRecoveryAt:0}}catch{return null}}async function nje(e){let t=await c5();return!t||t.badBuild!==e?null:`build ${e.slice(0,8)} did not start on this phone${t.badReason?` (${t.badReason})`:``}, so the app went back to the build inside it`}async function l5(){try{let e=await Kf(`/build-id.txt`,{cache:`no-store`});if(!e.ok)return null;let t=(await e.text()).trim();return/^[a-f0-9]{8,64}$/.test(t)?t:null}catch{return null}}async function rje(e){let t=await crypto.subtle.digest(`SHA-256`,e);return Array.from(new Uint8Array(t)).map(e=>e.toString(16).padStart(2,`0`)).join(``)}function ije(e){let t=new Uint8Array(e),n=``;for(let e=0;e<t.length;e+=e5)n+=String.fromCharCode(...t.subarray(e,e+e5));return btoa(n)}function u5(e){return e instanceof Error?e.message:String(e)}function aje({onToast:e,bare:t}){let[n,r]=(0,V.useState)(s5.get()),[i,a]=(0,V.useState)(r5()),[o,s]=(0,V.useState)(i5()),[c,l]=(0,V.useState)(null);(0,V.useEffect)(()=>s5.subscribe(r),[]),(0,V.useEffect)(()=>{c5().then(l)},[n.phase===`staged`]);let u=!!n.current&&!!n.available&&n.current===n.available;return(0,J.jsxs)(t?({children:e})=>(0,J.jsx)(J.Fragment,{children:e}):({children:e})=>(0,J.jsxs)(`section`,{className:`set-group`,children:[(0,J.jsxs)(`h3`,{className:`set-title`,children:[(0,J.jsx)(Ra,{size:14,style:{verticalAlign:`-2px`}}),` App version`]}),e]}),{children:[(0,J.jsx)(X,{children:`The interface lives inside the APK so it survives a dead tunnel. It still updates itself from the desktop — you only need a new APK when the native shell itself changes. Checking, downloading and restarting all happen by themselves; the buttons here are for when you don't want to wait.`}),(0,J.jsx)(JS,{children:(0,J.jsxs)(X,{as:`span`,style:{flexBasis:`auto`},children:[`running `,(0,J.jsx)(`code`,{children:n.current??`unknown`}),n.available&&!u&&(0,J.jsxs)(J.Fragment,{children:[` · host has `,(0,J.jsx)(`code`,{children:n.available})]}),u&&(0,J.jsx)(J.Fragment,{children:` · up to date`}),n.lastCheckedAt&&(0,J.jsxs)(J.Fragment,{children:[` · checked `,Tp(n.lastCheckedAt)]})]})}),c&&(0,J.jsx)(JS,{children:(0,J.jsxs)(X,{as:`span`,style:{flexBasis:`auto`},children:[c.builtIn?`serving the APK's own built-in bundle`:`serving a downloaded bundle`,c.versionName&&(0,J.jsxs)(J.Fragment,{children:[` · shell version `,(0,J.jsxs)(`code`,{children:[c.versionName,c.versionCode?` (${c.versionCode})`:``]})]})]})}),n.phase===`unsupported`&&(0,J.jsx)(X,{children:`no update mechanism on this build — either this is not the Android shell, or the installed APK predates the plugin OTA relies on. "check now" below does nothing until a newer APK is sideloaded.`}),n.phase===`downloading`&&n.progress&&(0,J.jsxs)(X,{children:[(0,J.jsx)(Js,{size:13,className:`spin`,style:{verticalAlign:`-2px`}}),` `,`downloading `,n.progress.files,`/`,n.progress.totalFiles,` files ·`,` `,Math.round(n.progress.bytes/1024),` / `,Math.round(n.progress.totalBytes/1024),` KB`]}),n.phase===`staged`&&(0,J.jsxs)(X,{style:{color:`var(--ok)`},children:[(0,J.jsx)(Bc,{size:13,style:{verticalAlign:`-2px`}}),` build `,(0,J.jsx)(`code`,{children:n.stagedId}),` downloaded and verified — `,o?`it starts by itself once you put the app down.`:`it starts the next time the app does.`]}),n.phase===`held`&&(0,J.jsxs)(X,{style:{color:`var(--warn)`},children:[(0,J.jsx)(ps,{size:13,style:{verticalAlign:`-2px`}}),` `,n.message,`. Not downloaded again by itself — the desktop's next build is taken as usual.`]}),n.phase===`unavailable`&&(0,J.jsxs)(X,{children:[`the desktop cannot serve a bundle: `,n.message]}),n.phase===`error`&&(0,J.jsxs)(X,{style:{color:`var(--dead)`},children:[(0,J.jsx)(bo,{size:13,style:{verticalAlign:`-2px`}}),` `,n.message]}),(0,J.jsxs)(JS,{style:{flexWrap:`wrap`},children:[(0,J.jsxs)(Y,{disabled:n.phase===`checking`||n.phase===`downloading`,onClick:()=>{q(`action:appUpdate.check`),s5.check()},children:[n.phase===`checking`?(0,J.jsx)(Js,{size:12,className:`spin`}):(0,J.jsx)(Xo,{size:12}),` check now`]}),n.phase===`staged`&&(0,J.jsx)(Y,{variant:`primary`,onClick:()=>{q(`action:appUpdate.apply`),e?.(`restarting into the new build`),s5.applyNow()},children:`restart into it`}),!!n.available&&!u&&n.phase!==`downloading`&&n.phase!==`staged`&&(n.phase===`held`?(0,J.jsxs)(Y,{onClick:()=>{q(`action:appUpdate.retryHeld`),s5.download(!0)},children:[`try build `,n.available.slice(0,8),` again`]}):(0,J.jsx)(Y,{onClick:()=>{q(`action:appUpdate.download`),s5.download()},children:`download now`})),(0,J.jsx)(Y,{className:i?`active`:``,onClick:()=>{let e=!i;a(e),$Ae(e),q(`action:appUpdate.auto`)},children:i?`auto-update on`:`auto-update off`}),(0,J.jsx)(Y,{className:o?`active`:``,onClick:()=>{let e=!o;s(e),eje(e),q(`action:appUpdate.autoApply`)},children:o?`auto-restart on`:`auto-restart off`})]}),(0,J.jsx)(X,{children:`A downloaded build never replaces the screen you are reading: the restart waits until the app has been in your pocket for a bit, or takes the moment you come back after a couple of minutes away — where it reads as the app starting rather than as the app reloading.`}),(0,J.jsxs)(JS,{children:[(0,J.jsxs)(Y,{variant:`danger`,onClick:()=>{q(`action:appUpdate.revert`),e?.(`back to the built-in build`),s5.revertToBuiltIn()},children:[(0,J.jsx)(tc,{size:12}),` use the build inside the APK`]}),(0,J.jsx)(X,{as:`span`,children:`The escape hatch if a downloaded build misbehaves. The app does this by itself too, when a downloaded build has not started after 15 seconds on screen, or after three launches that never finish starting — and then leaves that build alone until the desktop serves a different one.`})]})]})}var oje=16;function sje(){let{steps:e,refresh:t}=GY(),[n,r]=(0,V.useState)(!1);return e?e.every(e=>e.done)&&!n?(0,J.jsx)(iC,{id:`phone-setup`,label:`phone setup · ${HY(e)}`,icon:Ra,children:(0,J.jsxs)(X,{children:[`Everything Android needs is allowed. `,(0,J.jsxs)(`button`,{className:`link-btn`,onClick:()=>r(!0),children:[`show the `,e.length,` steps`]})]})}):(0,J.jsx)(iC,{id:`phone-setup`,label:`phone setup · ${HY(e)}`,icon:Ra,note:`What Android needs you to allow before this app works with the app closed. Nothing is granted without your tap.`,children:(0,J.jsx)(G8,{steps:e,refresh:t})}):null}function cje(){zAe(!0);let e=R8(),t=MAe(),n=PAe(U().conn.info);return(0,J.jsxs)(J.Fragment,{children:[t&&(0,J.jsx)(sje,{}),e===`insecure`?(0,J.jsxs)(iC,{id:`notif-push`,label:`OS push`,icon:lc,children:[(0,J.jsxs)(YS,{children:[`OS-level push is off: you're on `,location.protocol,`//`,location.host,` — plain HTTP over Tailscale is not a secure context, so service workers & Web Push are disabled. The in-app feed above still works.`]}),(0,J.jsxs)(X,{children:[(0,J.jsxs)(`div`,{children:[`Enable OS push — run on the desktop host, then reopen via the HTTPS name (if 443 is already taken here, use any free port instead: `,(0,J.jsx)(`code`,{children:`--https=8771`}),`):`]}),(0,J.jsxs)(`div`,{className:`cmd-copy`,children:[(0,J.jsx)(`code`,{children:n}),(0,J.jsx)(Y,{onClick:async()=>K(await Xf(n)?`command copied`:`copy failed`),children:(0,J.jsx)(_o,{size:oje})})]})]})]}):e===`native`&&!XG()?(0,J.jsx)(iC,{id:`notif-push`,label:`OS push`,icon:lc,note:z8}):e===`native`?(0,J.jsx)(iC,{id:`notif-push`,label:`OS push`,icon:lc,note:`This app has no OS push of its own — alerts reach it through the background link below.`,more:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{children:`The link speaks to the desktop over Tailscale, so when the tunnel is down this phone goes quiet — and quiet here does not mean nothing happened. Anything sent while it was down arrives when the link comes back.`}),(0,J.jsx)(`p`,{children:`For alerts that survive a dead tunnel, open the host's HTTPS name in the browser and install it to the home screen: the desktop sends those out over the internet, not over the tailnet.`})]})}):e===`demo`?(0,J.jsx)(iC,{id:`notif-push`,label:`OS push`,icon:lc,note:`The demo sends no alerts — it never leaves this device. With your own desktop connected, alerts reach this phone.`}):e===`unsupported`?(0,J.jsx)(iC,{id:`notif-push`,label:`OS push`,icon:lc,note:`This browser has no Web Push support — use the in-app feed.`}):(0,J.jsx)(ZS,{id:`notif-push`,label:`OS push`,icon:e===`denied`?lc:Ja,on:e===`on`,state:e===`on`?`on`:e===`denied`?`blocked in browser`:`off`,tone:e===`denied`?`danger`:void 0,onChange:RAe,note:`OS-level push on top of the in-app feed.`}),t&&(0,J.jsxs)(ZS,{id:`notif-shell-link`,label:`background link`,icon:t.running?Dc:Wc,on:!!t.running,state:t.enabled?t.running?t.state:`starting…`:`off`,tone:t.error?`danger`:void 0,onChange:U8,note:`Keeps the connection alive with the app closed, and drains queued sends in the background.`,children:[t.error&&(0,J.jsx)(YS,{children:t.error}),t.enabled&&!t.notifications&&(0,J.jsx)(YS,{tone:`plain`,children:`Notification permission is off, so the link runs but cannot tell you anything — the queue still drains. Allow it under phone setup above.`})]}),t?.enabled&&!t.batteryExempt&&(0,J.jsx)(rC,{id:`notif-shell-battery`,label:`allow background use`,icon:ac,onClick:async()=>{await tK(),await H8()},note:`Not only battery: a dozing app cannot start the service from the background.`,more:(0,J.jsx)(`p`,{children:`So this is also what makes the link come back after a reboot.`})})]})}function lje(){let e=FAe(U().conn.info);return(0,J.jsxs)(J.Fragment,{children:[hu()&&(0,J.jsx)(iC,{id:`app-version`,label:`app version`,icon:Ra,children:(0,J.jsx)(aje,{bare:!0,onToast:K})}),e.length>0&&!hu()&&(0,J.jsx)(iC,{id:`endpoints`,label:`how you reach this host`,icon:Ga,note:`Reopen the app on a different path to this host.`,more:(0,J.jsx)(`p`,{children:`Same WiFi? The LAN address skips the tunnel. Want OS push & install? Use the HTTPS name.`}),children:(0,J.jsx)(`div`,{className:`set-chips`,children:e.map(e=>{let t=location.origin===new URL(e.url).origin;return(0,J.jsxs)(Y,{className:t?`active`:``,title:e.note,onClick:()=>{t||(location.href=e.url)},children:[(0,J.jsx)(Ga,{size:12}),` `,e.label,`: `,e.url.replace(/^https?:\/\//,``),t?` ✓`:``]},e.url)})})})]})}var uje={pass:(0,J.jsx)(vc,{size:16,color:`var(--ok)`}),warn:(0,J.jsx)(gs,{size:16,color:`var(--warn)`}),fail:(0,J.jsx)(B,{size:16,color:`var(--dead)`})};function dje(){let e=gh(`hostsetup`,()=>H.hostSetup()),[t,n]=(0,V.useState)(!1),[r,i]=(0,V.useState)(null),a=e.data?.checks??[];if(!a.length)return null;let o=a.filter(e=>e.status!==`pass`).length;async function s(r){if(!t){q(`action:hostSetup.fix`),n(!0),i(null);try{let t=await H.hostSetupFix([r]);i(t.notes),e.set({checks:t.checks})}catch(e){i([`The fix could not reach the desktop: ${e instanceof Error?e.message:String(e)}`])}finally{n(!1)}}}return(0,J.jsxs)(iC,{id:`desktop-setup`,icon:xo,label:`desktop setup · ${o?`${o} to do`:`all set`}`,note:`What this desktop needs, whichever repo you are in. A fix acts on the desktop's own screen — look there.`,children:[(0,J.jsx)($,{res:e,empty:!1,noun:`checklist`}),(0,J.jsx)(`ul`,{className:`check-list`,children:a.map(e=>(0,J.jsxs)(`li`,{className:`check-row check-${e.status}`,children:[(0,J.jsxs)(`div`,{className:`check-top`,children:[(0,J.jsx)(`span`,{className:`check-icon`,children:uje[e.status]}),(0,J.jsx)(`span`,{className:`check-label`,children:e.label}),e.fix&&(0,J.jsxs)(Y,{onClick:()=>void s(e.fix),children:[(0,J.jsx)(bs,{size:12}),` `,t?`fixing…`:`fix`]})]}),(0,J.jsx)(`div`,{className:`check-detail`,children:e.detail})]},e.id))}),r?.map((e,t)=>(0,J.jsx)(Z,{children:e},t)),(0,J.jsxs)(Y,{onClick:()=>{i(null),e.reload({quiet:!0})},children:[(0,J.jsx)(Ds,{size:14,className:e.inflight?`spin`:void 0}),` re-check`]})]})}var fje={id:`hostTools`,commands:[{id:`cpu`,run:()=>{B8()}},{id:`shot`,run:e=>{let t=e.world.activeRepo?.id;t?V8(t):e.say.toast(`not a known repo`)}}],sheets:[{id:`phonesetup`,persisted:!1,render:()=>(0,V.createElement)(UAe)}],settings:[{group:`notifications`,order:20,render:()=>(0,V.createElement)(cje)},{group:`connection`,order:-10,render:()=>(0,V.createElement)(lje)},{group:`tools`,order:-30,render:()=>(0,V.createElement)(dje)}],boot:BAe},d5={title:`Location, for the Wi-Fi name`,lines:[`What: Android shows an app the name of the Wi-Fi network it is on only with the location permission. That name is all this is used for — not where you are.`,`Why: to switch to the desktop's home address automatically when you are on the Wi-Fi names you saved for it.`,`The name is compared on this phone, with the names saved here, and is never sent anywhere — not to the desktop, not to anyone.`,`Skip, and nothing else changes: LAN switching stays manual — the app keeps reaching the desktop over its Tailscale address and never moves to the home address on its own.`],continueLabel:`Continue`,skipLabel:`Skip`},pje=`Skipped — the Wi-Fi name is not read, so LAN switching stays manual (the Tailscale address, always). Tap allow location to be asked again.`,f5=`app:shell-net`;function mje(){let e=Nh(`Net`);return e&&typeof e.current==`function`?e:null}var hje=[`wifi`,`cellular`,`other`,`none`],gje=[`granted`,`denied`,`prompt`];function p5(e){if(typeof e==`string`)try{e=JSON.parse(e)}catch{return null}if(!e||typeof e!=`object`)return null;let t=e,n=hje.includes(t.transport)?t.transport:null,r=gje.includes(t.permission)?t.permission:null;return!n||!r?null:{transport:n,ssid:typeof t.ssid==`string`&&t.ssid.trim()?t.ssid:null,permission:r}}async function _je(){let e=mje();if(!e)return null;try{return p5(await e.current())}catch{return null}}function vje(e){try{window.dispatchEvent(new CustomEvent(f5,{detail:e}))}catch{}}function yje(e){let t=t=>{let n=p5(t.detail);n&&e(n)};return window.addEventListener(f5,t),()=>window.removeEventListener(f5,t)}function bje(){Fh(`NetChanged`,e=>{let t=p5(e);return t&&vje(t),!0})}async function xje(e,t){let n=performance.now();try{let r=await Kf(`${e}/api/health`,{cache:`no-store`,credentials:`omit`},t),i=performance.now()-n;return{ok:DCe(r.status),ms:i,at:Date.now()}}catch{return{ok:!1,at:Date.now()}}}async function Sje(e,t){let n=await qf(`${e}/api/lan/verify`,{method:`POST`,credentials:`omit`,headers:{"content-type":`application/json`},body:JSON.stringify({nonce:t})},4e3);return n&&typeof n.hostId==`string`&&typeof n.mac==`string`?n:null}async function Cje(e){return qf(`${e}/api/lan/identity`,{cache:`no-store`},8e3)}async function wje(e,t){try{let n=await Kf(`${e}/api/auth/token`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({deviceName:t})},8e3);if(n.status===403)return`no-password`;if(!n.ok)return`failed`;let r=await n.json();return typeof r.token==`string`&&r.token?{token:r.token}:`failed`}catch{return`failed`}}var m5=null,h5=!1;function g5(){return c4(ma(R.lanIdentity,null))}async function Tje(){let e=g5();if(e)return e;let t=vu();if(!t)return null;let n=c4(await Cje(t));return n&&Ta(R.lanIdentity,n),n}async function _5(){if(uu())return`ok`;let e=vu();if(!e)return`failed`;let t=await wje(e,fu(Hk(),Uk()));return typeof t==`string`?t:(Dne(t.token),uu()?`ok`:`failed`)}function Eje(e){let t=typeof location<`u`&&location.hostname.endsWith(`.ts.net`);e.clientKind===`lan`?a4({route:`lan`,sentence:`This browser reaches the desktop over the LAN.`}):e.clientKind===`tailscale`||e.clientKind===`loopback`&&t?a4({route:`tailnet`,sentence:`This browser reaches the desktop over the tailnet.`}):a4(null)}function v5(e=`settings`){m5?.evaluate(e)}var y5=null;function Dje(){let e=jCe(xu(),ru()?.lan);e&&y5?.(e),v5(`settings`)}function Oje(e){if(h5||(h5=!0,ha()))return;if(!hu()){e.on(e=>{e.t===`welcome`&&Eje(e)});return}let t=!1,n=!1,r=!1,i=r=>{a4({route:r.route,sentence:r.sentence}),bu(r.lanBase);let i=Cu();i&&i!==e.dialUrl&&(t=!0,n=!1,e.redial(i))};y5=e=>i({route:`tailnet`,sentence:e,lanBase:null}),m5=MCe({host:()=>ru(),net:()=>_je(),ensureToken:_5,ensureIdentity:Tje,probe:(e,t)=>xje(e,t),verify:(e,t)=>Sje(e,t),apply:i,now:()=>Date.now()});let a=m5,o=e=>{setTimeout(()=>{xu()!==null&&a.noteFailure(e)},0)},s=()=>{du(),xu()!==null&&o(`the desktop refused this phone's token`),r||(r=!0,_5())};Ane(()=>s()),e.setDialGuard(e=>xu()===null?e:(bu(null),a4({route:`tailnet`,sentence:`Using the tailnet while reconnecting; the LAN is checked again once connected.`}),Cu()??e)),e.on(e=>{if(e.t===`error`&&e.context===`__status`){if(xu()===null)return;if(e.message===`open`){n=!0;return}if(e.message===`closed`){let e=typeof document>`u`||document.visibilityState===`visible`;n?e&&o(`the connection dropped`):o(`the socket did not open`)}return}if(e.t===`authRequired`){(xu()!==null||uu())&&s();return}if(e.t!==`welcome`)return;let r=g5();e.hostId&&r&&r.hostId!==e.hostId&&(wa(R.lanIdentity),xu()!==null)?o(`a different desktop answered on the LAN`):t?t=!1:a.evaluate(`reopen`)}),yje(()=>{a.evaluate(`net`)}),a.evaluate(`start`)}function kje({mode:e,initial:t,fromLink:n,onDone:r}){let[i,a]=(0,V.useState)({address:t?.base??``,code:t?cn(t.code):``}),[o,s]=(0,V.useState)(!1),[c,l]=(0,V.useState)(null),[u,d]=(0,V.useState)(!(n&&t)),f=LG(i);function p(e){l(null);let t=IG(e);a(t?{address:t.address,code:cn(t.code)}:{...i,address:e})}async function m(t){if(f&&!o){s(!0),l(null);try{let n;try{let e=Vl(),t=e?GG(e,f.base):null;n=await H.pair.redeem(f.base,{code:f.code,deviceName:fu(Hk(),Uk())},t)}catch{l(`Could not reach ${f.base}. Check that Tailscale is connected on this phone and the desktop is awake.`);return}let i=HG(n.status,n.body);if(!i.ok){l(UG(i));return}let a=Vl();if(!a){l(`This phone's storage is not available.`);return}let o=KG(a,i,f);if(!o.ok){l(o.why);return}if(i.note&&K(i.note),!o.isActive&&(e===`first`||t)){eu(o.host.id);return}o.isActive&&v5(`pair`),K(`paired with ${o.host.name}`),r(o.host)}finally{s(!1)}}}let h=(0,J.jsxs)(J.Fragment,{children:[o&&(0,J.jsxs)(X,{style:{marginTop:10},children:[(0,J.jsx)(Js,{size:13,className:`spin`,style:{verticalAlign:`-2px`}}),` pairing…`]}),c&&(0,J.jsx)(X,{style:{marginTop:10,color:`var(--dead)`},children:c})]});return!u&&f?(0,J.jsxs)(`div`,{className:`pair-confirm`,children:[(0,J.jsx)(`div`,{className:`pair-confirm-icon`,children:(0,J.jsx)(xo,{size:22})}),(0,J.jsx)(`div`,{className:`pair-confirm-q`,children:`Pair with this desktop?`}),(0,J.jsx)(`div`,{className:`pair-confirm-host`,children:f.base.replace(/^https?:\/\//,``)}),(0,J.jsxs)(`div`,{className:`pair-confirm-code`,children:[`code `,(0,J.jsx)(`code`,{children:cn(f.code)})]}),h,!o&&(0,J.jsxs)(Y,{variant:`primary`,className:`pair-wide`,style:{marginTop:16},onClick:()=>void m(!0),children:[(0,J.jsx)(Fa,{size:15}),` `,e===`add`?`pair and switch`:`pair`]}),!o&&e===`add`&&(0,J.jsx)(Y,{className:`pair-wide`,style:{marginTop:8},onClick:()=>void m(!1),children:`pair, stay here`}),(0,J.jsxs)(X,{className:`warn pair-confirm-note`,children:[(0,J.jsx)(Wa,{size:12,style:{verticalAlign:`-2px`}}),` A pairing link filled this in. Nothing is sent until you tap pair — if you did not open a link just now, do not.`]}),!o&&(0,J.jsxs)(Y,{className:`pair-link-btn`,onClick:()=>d(!0),children:[(0,J.jsx)(Mo,{size:13}),` change address or code`]})]}):(0,J.jsxs)(J.Fragment,{children:[n&&t&&(0,J.jsxs)(X,{className:`warn`,style:{marginBottom:10},children:[(0,J.jsx)(Wa,{size:13,style:{verticalAlign:`-2px`}}),` `,BG(t)]}),(0,J.jsxs)(`ol`,{className:`pair-steps`,children:[(0,J.jsxs)(`li`,{children:[`On a phone already paired, or the desktop's web page: Settings → `,(0,J.jsx)(`b`,{children:`pair another phone`}),`.`]}),(0,J.jsxs)(`li`,{children:[`Scan its QR, tap `,(0,J.jsx)(`b`,{children:`open the app on this phone`}),` there, or type the address and code below.`]})]}),(0,J.jsx)(`input`,{className:`auth-input`,inputMode:`url`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,placeholder:`desktop address — 100.64.0.5 · mac.tailnet.ts.net`,value:i.address,onChange:e=>p(e.target.value)}),(0,J.jsx)(`input`,{className:`auth-input`,style:{marginTop:10},autoCapitalize:`characters`,autoCorrect:`off`,spellCheck:!1,placeholder:`pairing code — ABCD-EFGH`,value:i.code,onChange:e=>{l(null),a({...i,code:e.target.value})}}),f?(0,J.jsxs)(X,{style:{marginTop:8,opacity:.75},children:[`will connect to `,(0,J.jsx)(`code`,{children:f.base}),` with code `,(0,J.jsx)(`code`,{children:cn(f.code)})]}):i.address.trim()||i.code.trim()?(0,J.jsx)(X,{style:{marginTop:8},children:i.address.trim()?LG({address:i.address,code:`AAAAAAAA`})?`The code is 8 letters and digits, as the paired phone shows it.`:`Not an address. Use a host name or IP, optionally with a port.`:`Type the desktop's address too.`}):(0,J.jsx)(X,{style:{marginTop:8},children:`A pasted pairing link fills both fields.`}),h,f&&!o&&(0,J.jsxs)(JS,{style:{marginTop:14,flexWrap:`wrap`,gap:8},children:[e===`first`&&(0,J.jsxs)(Y,{variant:`primary`,className:`pair-wide`,onClick:()=>void m(!0),children:[(0,J.jsx)(Fa,{size:14}),` pair`]}),e===`add`&&(0,J.jsxs)(Y,{variant:`primary`,onClick:()=>void m(!0),children:[(0,J.jsx)(Fa,{size:14}),` pair and switch`]}),e===`add`&&(0,J.jsx)(Y,{onClick:()=>void m(!1),children:`pair`})]})]})}function Aje(e,t){let n=[];for(let r of e){let e=jn(r.addr);e&&n.push({peer:r,base:e,saved:t.find(t=>jn(t.base)===e)??null})}return[...n.filter(e=>!e.saved),...n.filter(e=>e.saved)]}function jje(e,t){let n=t;return e===200&&n&&n.ok===!0?`open`:e===401&&n&&n.authRequired===!0?`password`:`other`}function Mje(e){return`${e} has a password, so it needs a pairing code. On that desktop run "${I.slug} pair" and paste the link it prints below — or, on a phone already paired to it, open Hosts and tap its QR icon.`}function Nje(e,t){return e||(t?`Every desktop found on the tailnet is already on this phone.`:`No other ${I.name} desktop answered on the tailnet.`)}function b5(e){return`${e.peer.os?`${e.peer.os} · `:``}${e.peer.addr}${e.peer.gated?` · has a password`:``}`}function Pje({onPassword:e}){let[t,n]=(0,V.useState)({s:`busy`}),[r,i]=(0,V.useState)(()=>nu()),[a,o]=(0,V.useState)(null),[s,c]=(0,V.useState)(null);(0,V.useEffect)(()=>{let e=!0;return i(nu()),H.tailnet.peers().then(t=>{e&&n({s:`ok`,res:t})}).catch(()=>{e&&n({s:`bad`,why:`The desktop in use did not answer (an older version cannot list the tailnet). Type the new desktop's address below.`})}),()=>{e=!1}},[]);async function l(t){if(!a){o(t.base),c(null);try{let n=0,r=null;try{let e=await Kf(`${t.base}/api/health`,{cache:`no-store`,credentials:`omit`},6e3);n=e.status;try{r=await e.json()}catch{}}catch{c(`This phone could not reach ${t.peer.addr}, though the desktop in use can. Check that Tailscale is connected on this phone, then try again.`);return}let i=jje(n,r);if(i===`password`){e(t.base,t.peer.name);return}if(i===`other`){c(`${t.peer.addr} answered, but not as a ${I.name} daemon (status ${n}).`);return}let a=tu({name:t.peer.name,base:t.base});a.ok||c(a.why)}finally{o(null)}}}if(t.s===`busy`)return(0,J.jsxs)(X,{style:{marginBottom:12},children:[(0,J.jsx)(Js,{size:13,className:`spin`,style:{verticalAlign:`-2px`}}),` looking on your tailnet…`]});if(t.s===`bad`)return(0,J.jsx)(X,{style:{marginBottom:12},children:t.why});let u=Aje(t.res.peers,r),d=u.filter(e=>!e.saved);return(0,J.jsxs)(`div`,{style:{marginBottom:14},children:[(0,J.jsxs)(X,{children:[(0,J.jsx)(Ko,{size:13,style:{verticalAlign:`-2px`}}),` found on your tailnet`]}),d.length===0&&(0,J.jsx)(X,{style:{marginTop:6},children:Nje(t.res.note,u.length>0)}),(0,J.jsx)(`div`,{className:`list`,style:{marginTop:6},children:u.map(e=>e.saved?(0,J.jsxs)(Xw,{children:[(0,J.jsxs)(Zw,{children:[(0,J.jsx)(vc,{size:12}),` `,e.peer.name,` · already on this phone`]}),(0,J.jsx)(Q,{className:`dim`,children:b5(e)})]},e.base):(0,J.jsxs)(Xw,{as:`button`,onClick:()=>void l(e),children:[(0,J.jsxs)(Zw,{children:[a===e.base?(0,J.jsx)(Js,{size:12,className:`spin`}):(0,J.jsx)(Zc,{size:12}),` `,e.peer.name]}),(0,J.jsxs)(Q,{className:`dim`,children:[b5(e),` · `,a===e.base?`checking…`:e.peer.gated?`tap to pair`:`tap to add`]})]},e.base))}),s&&(0,J.jsx)(X,{style:{marginTop:8,color:`var(--dead)`},children:s})]})}var Fje=6e3;function Ije(){let e=Nh(`Net`);return e?.current?e:null}function Lje(e){return e?e.transport===`wifi`?e.permission===`granted`?`Android did not say the Wi-Fi name — location may be switched off.`:`Android tells an app the Wi-Fi name only with the location permission.`:`This phone is not on Wi-Fi right now.`:`This phone did not answer which network it is on.`}function x5({mode:e,host:t,lanSuggest:n=[],pair:r,pairFromLink:i,onDone:a,onCancel:o}){let[s,c]=(0,V.useState)(t?.name??``),[l,u]=(0,V.useState)(t?.base??``),[d,f]=(0,V.useState)(t?.lan?.base??``),[p,m]=(0,V.useState)(t?.lan?.ssids??[]),[h,g]=(0,V.useState)(t?.lan?.auto??!1),[_,v]=(0,V.useState)({s:`idle`}),[y,b]=(0,V.useState)(null),[x,S]=(0,V.useState)(null),[C,w]=(0,V.useState)(!1),[T,E]=(0,V.useState)(e!==`edit`&&(e===`first`||!!r)),[D,O]=(0,V.useState)(null),k=jn(l),A=d.trim()?jn(d):null,j=Ije();(0,V.useEffect)(()=>{r&&e!==`edit`&&E(!0)},[r,e]),(0,V.useEffect)(()=>{v({s:`idle`}),b(null)},[l]);async function M(){if(!k)return!1;v({s:`busy`});let e=new AbortController,t=setTimeout(()=>e.abort(),Fje);try{let t=await fetch(`${k}/api/health`,{cache:`no-store`,signal:e.signal});if(!t.ok)return v({s:`bad`,why:`host answered ${t.status}`,hint:t.status===403?`The daemon refused this app's origin. Add http://localhost to ${Fi(`ALLOWED_ORIGINS`)} on the desktop.`:`Something is listening there, but it is not the ${I.name} daemon.`}),!1;let n=await t.json();return n?.ok?(v({s:`ok`,root:n.root||`?`,protocol:n.protocol??0}),!0):(v({s:`bad`,why:`not a ${I.name} daemon`,hint:`Something else is listening on that port.`}),!1)}catch(e){let t=e?.name===`AbortError`;return v({s:`bad`,why:t?`no answer within 6s`:`could not reach that address`,hint:t?`The desktop may be asleep, or Tailscale is not up on this phone.`:`Check the address, and that Tailscale is connected on both ends.`}),!1}finally{clearTimeout(t)}}function N(){return{name:Oe(s)??void 0,base:l,lan:A?{base:A,ssids:p,auto:h}:null}}function P(n){let r=Vl();if(!r){b(`This phone's storage is not available.`);return}if(e===`edit`&&t){let e=Zl(r,t.id,N());if(!e.ok){b(e.why);return}if(Gl(r)===t.id&&e.host.base!==t.base){location.reload();return}Gl(r)===t.id&&Dje(),a(e.host);return}if(n){let e=tu(N());e.ok||b(e.why);return}let i=Xl(r,N());i.ok?a(i.host):b(i.why)}async function F(e=!1){if(!j)return;if(e&&j.requestLocation&&!await gC({title:d5.title,lines:[...d5.lines],confirmLabel:d5.continueLabel,cancelLabel:d5.skipLabel,tone:`info`})){S(pje);return}let t=null;try{t=e&&j.requestLocation?await j.requestLocation():await j.current()}catch{t=null}let n=pn(t?.ssid);n?(w(!1),S(p.includes(n)?`"${n}" is already on the list.`:null),p.includes(n)||m([...p,n])):(S(Lje(t)),w(!!t&&t.transport===`wifi`&&t.permission!==`granted`&&!!j.requestLocation))}let ee=e===`edit`?`Edit ${t?.name??`host`}`:e===`add`?`Add a desktop`:`Connect to your desktop`,te=k?Jt(k):`desk`;return(0,J.jsx)(`div`,{className:e===`first`?`auth-gate`:void 0,children:(0,J.jsxs)(`div`,{className:e===`first`?`auth-card`:`form`,children:[e===`first`&&(0,J.jsxs)(`div`,{className:`auth-title pair-title`,children:[(0,J.jsx)(`span`,{className:`pair-title-icon`,children:(0,J.jsx)(fc,{size:18})}),` `,ee]}),e===`add`&&!r&&(0,J.jsx)(Pje,{onPassword:(e,t)=>{O({target:{base:e,code:``},note:Mje(t)}),E(!0)}}),D&&T&&(0,J.jsx)(X,{className:`warn`,style:{marginBottom:10},children:D.note}),e!==`edit`&&!(i&&r)&&(0,J.jsxs)(`div`,{className:`pair-modes`,role:`tablist`,children:[(0,J.jsxs)(`button`,{role:`tab`,"aria-selected":T,className:`seg${T?` on`:``}`,onClick:()=>E(!0),children:[(0,J.jsx)(Fa,{size:14}),` pair with code`]}),(0,J.jsxs)(`button`,{role:`tab`,"aria-selected":!T,className:`seg${T?``:` on`}`,onClick:()=>E(!1),children:[(0,J.jsx)(fc,{size:14}),` type the address`]})]}),T&&e!==`edit`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(kje,{mode:e===`first`?`first`:`add`,initial:r??D?.target,fromLink:i,onDone:e=>a(e)},r?`${r.base} ${r.code}`:D?`found ${D.target.base}`:`typed`),o&&(0,J.jsx)(JS,{style:{marginTop:10},children:(0,J.jsx)(Y,{onClick:o,children:`cancel`})})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(X,{style:{marginBottom:12},children:[`The address the `,I.name,` daemon prints at boot — usually its Tailscale IP. Port `,` `,(0,J.jsx)(`code`,{children:`8770`}),` is assumed unless you type another one.`]}),(0,J.jsx)(`input`,{className:`auth-input`,inputMode:`url`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,placeholder:`100.64.0.5 · mac.tailnet.ts.net`,value:l,onChange:e=>u(e.target.value),onKeyDown:t=>{t.key===`Enter`&&k&&e===`first`&&M().then(e=>{e&&P(!0)})}}),k&&(0,J.jsxs)(X,{style:{marginTop:8,opacity:.75},children:[`will use `,(0,J.jsx)(`code`,{children:k})]}),l.trim()&&!k&&(0,J.jsx)(X,{style:{marginTop:8,color:`var(--dead)`},children:`Not an address. Use a host name or IP, optionally with a port — http or https only.`}),(0,J.jsx)(`input`,{className:`auth-input`,style:{marginTop:10},autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,placeholder:`name — ${te}`,value:s,onChange:e=>c(e.target.value)}),_.s===`busy`&&(0,J.jsxs)(X,{style:{marginTop:10},children:[(0,J.jsx)(Js,{size:13,className:`spin`,style:{verticalAlign:`-2px`}}),` checking…`]}),_.s===`ok`&&(0,J.jsxs)(X,{style:{marginTop:10,color:`var(--ok)`},children:[(0,J.jsx)(Bc,{size:13,style:{verticalAlign:`-2px`}}),` daemon found — root `,(0,J.jsx)(`code`,{children:_.root}),_.protocol!==2&&` · protocol ${_.protocol}, this app speaks 2`]}),_.s===`bad`&&(0,J.jsxs)(X,{style:{marginTop:10,color:`var(--dead)`},children:[(0,J.jsx)(bo,{size:13,style:{verticalAlign:`-2px`}}),` `,_.why,_.hint&&(0,J.jsx)(`div`,{style:{opacity:.8,marginTop:4},children:_.hint})]}),e!==`first`&&(0,J.jsxs)(`details`,{style:{marginTop:14},open:!!t?.lan,children:[(0,J.jsxs)(`summary`,{className:`set-note`,children:[(0,J.jsx)(Fc,{size:13,style:{verticalAlign:`-2px`}}),` on the same Wi-Fi (optional)`]}),(0,J.jsx)(X,{style:{marginTop:6},children:`The desktop's address on your home network. The app uses it only on the Wi-Fi names below, only after the desktop proves who it is, and only when the switch is on.`}),(0,J.jsx)(`input`,{className:`auth-input`,inputMode:`url`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,placeholder:`192.168.1.20`,value:d,onChange:e=>f(e.target.value)}),d.trim()&&!A&&(0,J.jsx)(X,{style:{marginTop:6,color:`var(--dead)`},children:`Not an address.`}),n.length>0&&(0,J.jsx)(`div`,{className:`set-chips`,style:{marginTop:6},children:n.map(e=>(0,J.jsx)(Y,{onClick:()=>f(e),children:e},e))}),(0,J.jsxs)(`div`,{className:`set-chips`,style:{marginTop:8},children:[p.map(e=>(0,J.jsxs)(Y,{onClick:()=>m(p.filter(t=>t!==e)),"aria-label":`remove ${e}`,children:[(0,J.jsx)(Dc,{size:12}),` `,e,` `,(0,J.jsx)(B,{size:12})]},e)),j&&(0,J.jsxs)(Y,{onClick:()=>void F(),children:[(0,J.jsx)(Fo,{size:12}),` add current Wi-Fi`]})]}),!j&&(0,J.jsx)(X,{children:`This app build cannot read the Wi-Fi name; a newer APK can.`}),x&&(0,J.jsx)(X,{children:x}),C&&(0,J.jsx)(Y,{onClick:()=>void F(!0),children:`allow location`}),A&&(0,J.jsx)(ZS,{label:`switch to LAN automatically`,icon:Fc,on:h,onChange:()=>g(!h),note:p.length===0?`No Wi-Fi name yet, so it never switches — add the one at home.`:void 0})]}),y&&(0,J.jsx)(X,{style:{marginTop:10,color:`var(--dead)`},children:y}),(0,J.jsxs)(JS,{style:{marginTop:14,flexWrap:`wrap`,gap:8},children:[k?(0,J.jsxs)(J.Fragment,{children:[_.s!==`busy`&&(0,J.jsx)(Y,{onClick:()=>void M(),children:`test`}),e===`first`&&(0,J.jsx)(Y,{variant:`primary`,onClick:()=>P(!0),children:`connect`}),e===`add`&&(0,J.jsx)(Y,{variant:`primary`,onClick:()=>P(!0),children:`add and switch`}),e===`add`&&(0,J.jsx)(Y,{onClick:()=>P(!1),children:`add`}),e===`edit`&&(0,J.jsx)(Y,{variant:`primary`,onClick:()=>P(!1),children:`save`})]}):(0,J.jsx)(X,{as:`span`,children:`Type the desktop's address to test or save it.`}),o&&(0,J.jsx)(Y,{onClick:o,children:`cancel`})]})]}),e===`first`&&(0,J.jsxs)(`div`,{className:`pair-demo`,children:[(0,J.jsx)(X,{children:`No desktop to hand? A pretend one inside this app — nothing connects and nothing runs.`}),(0,J.jsxs)(Y,{onClick:()=>w8(),children:[(0,J.jsx)(nc,{size:13}),` Try the demo`]})]}),e===`first`&&(0,J.jsx)(X,{style:{marginTop:14,opacity:.65},children:`This app keeps its interface inside the APK, so it stays usable — queue, drafts, cached transcripts — even when the desktop is unreachable.`})]})})}function S5(e){if(e==null||e===``)return null;try{return JSON.parse(e)}catch{return e}}function C5(e){let t=S5(e);return typeof t==`string`&&t.trim()?1:0}function w5(e){let t=S5(e);return!t||typeof t!=`object`||Array.isArray(t)?0:Object.values(t).filter(e=>typeof e==`string`&&e.trim()).length}function T5(e){let t=S5(e);return Array.isArray(t)?t.length:0}function Rje(e,t){return{drafts:w5(e(t.composeDrafts))+w5(e(t.composeSheets))+C5(e(t.compose))+C5(e(t.backlogDraft))+C5(e(t.fanoutText)),notes:pe(e(t.pad)).notes.length,queued:T5(e(t.composeOutbox))+T5(e(t.outbox))}}var E5=(e,t,n)=>`${e} ${e===1?t:n}`;function zje(e){let t=[e.drafts?E5(e.drafts,`draft`,`drafts`):null,e.notes?E5(e.notes,`pad note`,`pad notes`):null,e.queued?E5(e.queued,`queued prompt`,`queued prompts`):null].filter(e=>!!e);return t.length?t.length===1?t[0]:`${t.slice(0,-1).join(`, `)} and ${t[t.length-1]}`:null}function Bje(e,t,n){let r=zje(e),i=e.drafts+e.notes+e.queued,a=[r?`${r} ${i===1?`stays`:`stay`} saved on this phone; re-add the host to see them.`:`Nothing unsent is saved for it on this phone.`];return t&&a.push(n?`It is the host in use: the app switches to ${n.name} first, then reloads.`:`It is the only host: the app goes back to the connect screen.`),a}function D5(e){return e.replace(/^https?:\/\//,``).replace(/:8770$/,``)}function Vje(e){return e.length>1}function Hje(e){let t=e.trim().split(/[\s\-_.·]+/).find(e=>e.length>0)??``;return t.length>6?`${t.slice(0,5)}…`:t}function Uje(e,t){return e.length<2?null:e[(e.findIndex(e=>e.id===t)+1)%e.length].id}function Wje(e,t){return[...e.filter(e=>e.id===t),...e.filter(e=>e.id!==t)]}function Gje(e,t){let n=[];for(let r=0;r<e;r++){let i=0;for(;i<e;){if(!t(r,i)){i++;continue}let a=i;for(;a<e&&t(r,a);)a++;n.push(`M${i} ${r}h${a-i}v1h${i-a}z`),i=a}}return n.join(``)}function Kje(e){if(!(e>0))return null;let t=Math.ceil(e/1e3);return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)} left`}function qje(e){switch(e){case`tailscale`:return`over the tailnet`;case`lan`:return`over the Wi-Fi (LAN)`;case`loopback`:return`on the desktop itself`;case`public`:return`over a public address`;default:return`route not recorded`}}var Jje=kp;function Yje(e){return e.current?[`This is the phone you are holding. Revoking it signs this phone out of this desktop at once.`,`It will need a new pairing code (or the password) to connect again.`]:[`${e.name} will need a new pairing code to connect again.`]}function Xje(e){return e?`No phone has its own sign-in yet. Pair one with "pair another phone" — each gets a row here you can revoke.`:`Set a host password to give each phone its own sign-in. Without one, this desktop keeps no per-phone sign-ins to list or revoke.`}function O5(){return hu()?{hosts:nu(),activeId:ru()?.id??null}:{hosts:[],activeId:null}}var k5=W(O5()),A5=W({mode:`list`});function j5(){return G(k5)}function Zje(){return G(A5)}function M5(){k5.set(O5())}function N5(){M5(),A5.set({mode:`list`}),U().nav.open(`hosts`)}function P5(){A5.set({mode:`add`})}function Qje(e){U().say.track(`action:hosts.pairLink`),M5(),A5.set({mode:`pair`,target:e}),U().nav.open(`hosts`)}function F5(){U().say.track(`overlay:pairqr`),U().nav.open(`pairqr`)}function $je(){U().say.track(`overlay:devices`),U().nav.open(`devices`)}function eMe(e){A5.set({mode:`edit`,id:e})}function tMe(){U().say.track(`action:hosts.editActive`),M5();let e=k5.get().activeId;A5.set(e?{mode:`edit`,id:e}:{mode:`list`}),U().nav.open(`hosts`)}function I5(){M5(),A5.set({mode:`list`})}function L5(e){U().say.track(`action:hosts.switch`),eu(e)||U().say.toast(`already on that host`)}function nMe(e,t){return Rje(e===t?e=>z(e):t=>z(xe(t,e)),{composeDrafts:R.composeDrafts,composeSheets:R.composeSheets,compose:R.compose,backlogDraft:R.backlogDraft,fanoutText:R.fanoutText,pad:R.pad,composeOutbox:R.composeOutbox,outbox:R.outbox})}async function rMe(e){let{hosts:t,activeId:n}=O5(),r=e.id===n,i=r?t.find(t=>t.id!==e.id)??null:null;if(!await gC({title:`Remove ${e.name}?`,lines:Bje(nMe(e.id,n),r,i),confirmLabel:`Remove`}))return;U().say.track(`action:hosts.remove`);let a=vne(e.id);a===`dropped`?(M5(),U().say.toast(`${e.name} removed`)):a===null&&U().say.toast(`could not remove that host`)}var R5=16;function iMe(){let e=Dh(),{hosts:t,activeId:n}=j5(),r=Zje(),i=o4(),a=()=>e.nav.close(`hosts`),[o,s]=(0,V.useState)(!1),c=UR();if(Gh(o,()=>s(!1)),Gh(r.mode!==`list`,I5),o&&c)return(0,J.jsx)(c,{onClose:()=>s(!1)});if(r.mode===`pair`)return(0,J.jsx)(Hw,{title:`Pair with a desktop`,icon:(0,J.jsx)(Fa,{size:R5}),onClose:I5,children:(0,J.jsx)(x5,{mode:`add`,pair:r.target,pairFromLink:!0,onDone:I5,onCancel:I5})});if(r.mode===`add`||r.mode===`edit`){let i=r.mode===`edit`?t.find(e=>e.id===r.id):void 0,a=!!i&&i.id===n;return(0,J.jsx)(Hw,{title:i?`Edit ${i.name}`:`Add a desktop`,icon:(0,J.jsx)(Zc,{size:R5}),onClose:I5,children:(0,J.jsx)(x5,{mode:i?`edit`:`add`,host:i,lanSuggest:a||!i?e.conn.info.lanIps:[],onDone:I5,onCancel:I5})})}return(0,J.jsxs)(Hw,{title:`Hosts`,icon:(0,J.jsx)(Zc,{size:R5}),onClose:a,actions:(0,J.jsxs)(Y,{onClick:P5,children:[(0,J.jsx)(Fo,{size:R5}),` add`]}),children:[t.length===0?(0,J.jsx)($,{thing:`saved desktops`,children:`No desktops saved on this phone. Add one with its Tailscale address.`}):(0,J.jsx)(`div`,{className:`list`,children:Wje(t,n).map(e=>{let t=e.id===n;return au(e)?(0,J.jsxs)(Xw,{kind:`wrap`,children:[(0,J.jsxs)(Xw,{kind:`grow`,children:[(0,J.jsxs)(Zw,{children:[(0,J.jsx)(nc,{size:12}),` `,e.name,` · in use`]}),(0,J.jsx)(Q,{className:`dim`,children:`A pretend desktop — nothing runs on a computer`})]}),(0,J.jsx)(`div`,{className:`row-acts`,children:(0,J.jsxs)(Y,{"aria-label":`leave the demo`,onClick:T8,children:[(0,J.jsx)(Ps,{size:R5}),` leave`]})})]},e.id):(0,J.jsxs)(Xw,{kind:`wrap`,children:[t?(0,J.jsxs)(Xw,{kind:`grow`,children:[(0,J.jsxs)(Zw,{children:[(0,J.jsx)(vc,{size:12}),` `,e.name,` · in use`]}),(0,J.jsxs)(Q,{className:`dim`,children:[D5(e.base),e.lan?` · LAN ${D5(e.lan.base)}`:``]}),i&&(0,J.jsxs)(Q,{children:[i.route===`lan`?(0,J.jsx)(Fc,{size:12}):(0,J.jsx)(wo,{size:12}),` `,i.sentence]})]}):(0,J.jsxs)(Xw,{as:`button`,kind:`grow`,onClick:()=>L5(e.id),children:[(0,J.jsx)(Zw,{children:e.name}),(0,J.jsxs)(Q,{className:`dim`,children:[D5(e.base),` · tap to switch`]})]}),(0,J.jsxs)(`div`,{className:`row-acts`,children:[t&&(0,J.jsx)(Y,{"aria-label":`show a pairing QR for ${e.name}`,onClick:F5,children:(0,J.jsx)(dl,{size:R5})}),(0,J.jsx)(Y,{"aria-label":`edit ${e.name}`,onClick:()=>eMe(e.id),children:(0,J.jsx)(Mo,{size:R5})}),(0,J.jsx)(Y,{"aria-label":`remove ${e.name}`,onClick:()=>void rMe(e),children:(0,J.jsx)(ws,{size:R5})})]})]},e.id)})}),c&&(0,J.jsx)(JS,{style:{marginTop:10},children:(0,J.jsxs)(Y,{onClick:()=>s(!0),children:[(0,J.jsx)(Wa,{size:R5}),` Peer desktops`]})}),!t.some(au)&&(0,J.jsx)(JS,{style:{marginTop:10},children:(0,J.jsxs)(Y,{onClick:()=>w8(),children:[(0,J.jsx)(nc,{size:R5}),` Try the demo`]})}),(0,J.jsx)(Z,{children:`Each desktop keeps its own drafts, queue and caches on this phone; switching reloads the app onto the other one.`})]})}function aMe(e,t){return`Pair${t?` with ${t}`:``}: ${e.landingUrl}\nCode: ${cn(e.code)} (works once, 10 minutes)`}function oMe(e,t){return e&&t}var z5=14,B5={userSelect:`text`,WebkitUserSelect:`text`,overflowWrap:`anywhere`};function sMe({m:e,hostName:t}){let[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(!1),o=typeof navigator<`u`&&typeof navigator.share==`function`,s=oMe(typeof window<`u`&&window.isSecureContext,typeof navigator<`u`&&!!navigator.clipboard);async function c(e,t){let n=await Xf(t);a(!n),r(n?e:null),n&&setTimeout(()=>r(t=>t===e?null:t),2e3)}async function l(){try{await navigator.share({title:`Pair a phone`,text:aMe(e,t)})}catch(e){e?.name!==`AbortError`&&K(`could not open the share sheet`)}}return(0,J.jsxs)(`div`,{className:`pair-copy`,children:[(0,J.jsx)(`div`,{className:`pair-copy-label`,children:`Link`}),(0,J.jsxs)(`div`,{className:`pair-copy-row`,children:[(0,J.jsx)(`code`,{style:B5,children:e.landingUrl}),(0,J.jsxs)(Y,{onClick:()=>void c(`link`,e.landingUrl),children:[n===`link`?(0,J.jsx)(vc,{size:z5}):(0,J.jsx)(_o,{size:z5}),` `,n===`link`?`copied`:`copy link`]})]}),(0,J.jsx)(`div`,{className:`pair-copy-label`,children:`Code`}),(0,J.jsxs)(`div`,{className:`pair-copy-row`,children:[(0,J.jsx)(`code`,{style:B5,children:cn(e.code)}),(0,J.jsxs)(Y,{onClick:()=>void c(`code`,cn(e.code)),children:[n===`code`?(0,J.jsx)(vc,{size:z5}):(0,J.jsx)(_o,{size:z5}),` `,n===`code`?`copied`:`copy code`]})]}),o&&(0,J.jsxs)(Y,{className:`pair-wide`,style:{marginTop:12},onClick:()=>void l(),children:[(0,J.jsx)(Ro,{size:z5}),` share link and code`]}),(i||!s)&&(0,J.jsxs)(X,{style:{marginTop:6},children:[i?`The phone refused to copy. `:``,`Copy only works over https here — this page is plain http. Press and hold the link or the code to select it, or use Share.`]})]})}var cMe=16,lMe=`https://play.google.com/store/apps/details?id=com.tailscale.ipn`;function uMe(){return!hu()&&typeof navigator<`u`&&/Android/i.test(navigator.userAgent)}function dMe({text:e}){let t=(0,V.useMemo)(()=>{try{let t=El(0,`M`);t.addData(e),t.make();let n=t.getModuleCount();return{n,d:Gje(n,(e,n)=>t.isDark(e,n))}}catch{return null}},[e]);if(!t)return(0,J.jsx)(X,{children:`This address is too long to draw as a QR — use the code below.`});let n=t.n+8;return(0,J.jsxs)(`svg`,{className:`pair-qr`,viewBox:`-4 -4 ${n} ${n}`,role:`img`,"aria-label":`pairing QR code`,shapeRendering:`crispEdges`,children:[(0,J.jsx)(`rect`,{x:-4,y:-4,width:n,height:n,style:{fill:`var(--paper)`}}),(0,J.jsx)(`path`,{d:t.d,style:{fill:`var(--media-bg)`}})]})}function fMe(){let e=Dh(),[t,n]=(0,V.useState)({s:`busy`}),[r,i]=(0,V.useState)(()=>Date.now()),[a,o]=(0,V.useState)(!1);async function s(e=a){n({s:`busy`});try{let t=await H.pair.mint(e);n({s:`ok`,m:t,until:Date.now()+Pi})}catch(e){n({s:`bad`,why:e?.message||`no answer`})}}(0,V.useEffect)(()=>{s()},[]),(0,V.useEffect)(()=>{if(t.s!==`ok`)return;let e=setInterval(()=>i(Date.now()),1e3);return()=>clearInterval(e)},[t.s]);let c=t.s===`ok`?Kje(t.until-r):null,l=uMe();return(0,J.jsx)(Hw,{title:`Pair another phone`,icon:(0,J.jsx)(dl,{size:cMe}),onClose:()=>e.nav.close(`pairqr`),children:(0,J.jsxs)(`div`,{className:`sheet-body pair-sheet`,children:[(0,J.jsxs)(`section`,{className:`pair-card`,children:[(0,J.jsxs)(`label`,{className:`pair-passive`,title:`the new phone gets app updates only; a PIN unlocks the rest for 30 minutes`,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:a,onChange:t=>{let n=t.target.checked;o(n),e.say.track(`action:hosts.pairPassive`),s(n)}}),(0,J.jsx)(Ao,{size:15}),` Passive device — app updates only`]}),a&&(0,J.jsxs)(X,{children:[`Pairing a passive device switches on "require the password over Tailscale", so every device needs its own token on Tailscale too — sign in again on any browser that has none.`,` Nothing else works on it until it is unlocked with the PIN (Settings › Connection › Paired devices sets the PIN).`]})]}),t.s===`busy`&&(0,J.jsxs)(`div`,{className:`pair-state`,children:[(0,J.jsx)(Js,{size:18,className:`spin`}),` asking the desktop for a code…`]}),t.s===`bad`&&(0,J.jsxs)(`div`,{className:`pair-state`,children:[(0,J.jsxs)(`div`,{style:{color:`var(--dead)`},children:[`The desktop did not give a code: `,t.why]}),(0,J.jsxs)(Y,{onClick:()=>void s(),children:[(0,J.jsx)(xc,{size:14}),` try again`]})]}),t.s===`ok`&&!c&&(0,J.jsxs)(`div`,{className:`pair-state`,children:[(0,J.jsx)(`div`,{children:`That code has expired — they last 10 minutes and work once.`}),(0,J.jsxs)(Y,{variant:`primary`,onClick:()=>void s(),children:[(0,J.jsx)(xc,{size:14}),` new code`]})]}),t.s===`ok`&&c&&(0,J.jsxs)(J.Fragment,{children:[l&&(0,J.jsxs)(`section`,{className:`pair-card`,children:[(0,J.jsxs)(`div`,{className:`pair-card-head`,children:[(0,J.jsx)(Ra,{size:15}),` The app is on this phone`]}),(0,J.jsxs)(Y,{variant:`primary`,className:`pair-wide`,onClick:()=>{e.say.track(`action:hosts.pairThisPhone`),window.location.href=t.m.deepLink},children:[(0,J.jsx)(Ra,{size:15}),` open the app on this phone`]}),(0,J.jsx)(X,{children:`It opens with this desktop and code filled in — tap pair there. If nothing opens, the app is not installed.`})]}),l&&(0,J.jsx)(`div`,{className:`pair-or`,children:`or on another phone`}),(0,J.jsxs)(`section`,{className:`pair-card pair-card-qr`,children:[(0,J.jsx)(dMe,{text:t.m.landingUrl}),(0,J.jsx)(`div`,{className:`pair-code`,children:cn(t.m.code)}),(0,J.jsxs)(`div`,{className:`pair-ttl`,children:[(0,J.jsx)(os,{size:12}),` `,c,` · works once`]}),(0,J.jsxs)(X,{className:`pair-centre`,children:[`Scan with the other phone's camera, or type the code into its "pair with code" with the address`,` `,(0,J.jsx)(`code`,{children:t.m.base.replace(/^https?:\/\//,``)}),`.`]})]}),(0,J.jsx)(`section`,{className:`pair-card`,children:(0,J.jsx)(sMe,{m:t.m,hostName:null})})]}),(0,J.jsxs)(`div`,{className:`pair-foot`,children:[(0,J.jsx)(X,{children:`The new phone needs Tailscale signed in to the same tailnet.`}),(0,J.jsx)(X,{children:`No app needed: the QR opens a page with "use web version" — that address is the whole app, and on your tailnet it needs no code. The code is for the Android app's "pair with code".`}),(0,J.jsxs)(Y,{onClick:()=>{fx(lMe)||e.say.toast(`could not open the link`)},children:[(0,J.jsx)(Ga,{size:13}),` Tailscale for Android`]})]})]})})}var V5=null,H5=new Set;function U5(){for(let e of H5)e(V5)}function W5(e){return V5?.resolve(null),new Promise(t=>{V5={title:e.title,initial:e.initial??``,placeholder:e.placeholder??``,okLabel:e.okLabel??`Save`,note:e.note,resolve:t},U5()})}function pMe(){let[e,t]=(0,V.useState)(null),[n,r]=(0,V.useState)(``);(0,V.useEffect)(()=>(H5.add(t),t(V5),()=>{H5.delete(t)}),[]),(0,V.useEffect)(()=>{r(e?.initial??``)},[e]);let i=(0,V.useCallback)(e=>{let t=V5;V5=null,U5(),t?.resolve(e&&e.trim()?e.trim():null)},[]);return e?(0,J.jsx)(`div`,{className:`bl-modal-backdrop confirm-backdrop`,onClick:()=>i(null),children:(0,J.jsxs)(`form`,{className:`bl-modal confirm-modal`,onClick:e=>e.stopPropagation(),onSubmit:e=>{e.preventDefault(),i(n)},children:[(0,J.jsx)(`div`,{className:`bl-modal-title`,children:e.title}),(0,J.jsx)(`input`,{className:`ask-text-input`,autoFocus:!0,value:n,placeholder:e.placeholder,enterKeyHint:`done`,onChange:e=>r(e.target.value),onFocus:e=>e.currentTarget.select()}),e.note&&(0,J.jsx)(`div`,{className:`ask-text-note`,children:e.note}),(0,J.jsxs)(`div`,{className:`bl-modal-actions`,children:[(0,J.jsx)(`button`,{type:`submit`,className:`send`,children:e.okLabel}),(0,J.jsx)(Y,{type:`button`,onClick:()=>i(null),children:`Cancel`})]})]})}):null}var G5={status:()=>qf(`/api/auth/status`),state:()=>qf(`/api/passive/state`),unlock:e=>Of(`/api/auth/unlock`,{pin:e}),lock:()=>Df(`/api/auth/lock`,{}),setPin:e=>Df(`/api/auth/pin`,{pin:e})},K5=16;async function mMe(){let e=await H.devices.list();return D((Array.isArray(e?.devices)?e.devices:[]).map(rn).filter(e=>!!e))}function hMe(){let e=Dh(),t=gh(`devices`,mMe),[n,r]=(0,V.useState)(null),i=e.conn.info.auth.enabled,a=t.data??[],o=Date.now(),[s,c]=(0,V.useState)(void 0);(0,V.useEffect)(()=>{G5.status().then(e=>{e&&c(!!e.pinSet)})},[]);let l=a.some(e=>e.scope===`passive`);async function u(){let t=await W5({title:s?`Change the unlock PIN`:`Set the unlock PIN`,placeholder:`4–12 digits`,okLabel:`Save`,note:`A passive device unlocks the full app for 30 minutes with this PIN. Changing it locks every unlocked one.`});if(t===null)return;let n=Ji(t);if(!n)e.say.toast(`not saved: a PIN is 4–12 digits`);else{e.say.track(`action:devices.pin`);try{let t=await G5.setPin(n);c(t.pinSet),e.say.toast(`unlock PIN saved`)}catch(t){e.say.toast(`PIN not saved: ${t?.message||`no answer`}`)}}}async function d(n){if(await gC({title:`Revoke ${n.name}?`,lines:Yje(n),confirmLabel:`Revoke`})){e.say.track(`action:devices.revoke`),r(n.id);try{let r=await H.devices.revoke(n.id);n.current&&du(),e.say.toast(r.revoked?`${n.name} revoked`:`${n.name} was already revoked`),t.set(a.filter(e=>e.id!==n.id)),t.reload({quiet:!0})}catch(t){e.say.toast(`could not revoke ${n.name}: ${t?.message||`no answer`}`)}finally{r(null)}}}return(0,J.jsxs)(Hw,{title:`Paired devices`,icon:(0,J.jsx)(Ra,{size:K5}),onClose:()=>e.nav.close(`devices`),actions:(0,J.jsx)(Y,{"aria-label":`refresh`,onClick:()=>t.reload({quiet:!0}),children:t.inflight?(0,J.jsx)(Js,{size:K5,className:`spin`}):(0,J.jsx)(xc,{size:K5})}),children:[(0,J.jsx)($,{res:t,empty:a.length===0,thing:`the paired devices`,children:Xje(i)}),a.length>0&&(0,J.jsx)(`div`,{className:`list`,children:a.map(e=>(0,J.jsxs)(Xw,{kind:`wrap`,children:[(0,J.jsxs)(Xw,{kind:`grow`,children:[(0,J.jsxs)(Zw,{children:[e.scope===`passive`?(0,J.jsx)(Ao,{size:12}):(0,J.jsx)(Ra,{size:12}),` `,e.name,e.current?` · this phone`:``,e.scope===`passive`?` · passive`:``]}),(0,J.jsxs)(Q,{className:`dim`,children:[`paired `,new Date(e.createdAt).toLocaleDateString(),` · last seen `,Jje(Math.max(0,o-e.lastSeenAt)),` · `,qje(e.lastKind)]})]}),(0,J.jsx)(`div`,{className:`row-acts`,children:n===e.id?(0,J.jsx)(`span`,{className:`key`,"aria-label":`revoking`,children:(0,J.jsx)(Js,{size:K5,className:`spin`})}):(0,J.jsx)(Y,{"aria-label":`revoke ${e.name}`,onClick:()=>void d(e),children:(0,J.jsx)(ws,{size:K5})})})]},e.id))}),!i&&a.length>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{children:`No host password is set right now, so these rows cannot sign in until one is.`}),(0,J.jsx)(JS,{children:(0,J.jsxs)(Y,{onClick:()=>XI(`lan-password`),children:[(0,J.jsx)(Fa,{size:K5}),` set the LAN password`]})})]}),(l||s)&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{children:s===void 0?`Asking the desktop whether an unlock PIN is set…`:s?`Passive devices get app updates only; the unlock PIN opens the full app on one for 30 minutes.`:`No unlock PIN is set, so a passive device cannot be unlocked.`}),(0,J.jsx)(JS,{children:(0,J.jsxs)(Y,{title:`the PIN a passive device unlocks with`,onClick:()=>void u(),children:[(0,J.jsx)(Us,{size:K5}),` `,s?`change the unlock PIN`:`set the unlock PIN`]})})]}),(0,J.jsx)(Z,{children:`Each row is one phone's own sign-in. Revoking it ends that phone's access at once; changing the host password revokes every row.`})]})}function gMe(){let{hosts:e,activeId:t}=j5(),n=e.find(e=>e.id===t);return(0,J.jsxs)(J.Fragment,{children:[hu()&&(0,J.jsx)(rC,{id:`hosts`,label:`hosts`,icon:Zc,opens:!0,onClick:()=>{N5()},note:n?`In use: ${n.name} at ${D5(n.base)}. Add, edit, switch or remove desktops.`:`No desktop saved yet.`}),hu()&&(0,J.jsx)(rC,{id:`add-desktop`,label:`add a desktop`,icon:Ko,opens:!0,onClick:()=>{N5(),P5()},note:`Desktops running ${I.displayName} on your tailnet are listed — one tap adds one. Typing an address or a pairing code still works there.`}),!hu()&&(0,J.jsx)(iC,{id:`web-desktops`,label:`another desktop, without the app`,icon:wo,note:`In a browser each desktop is its own address — no list, no code. Tap for the steps.`,more:(0,J.jsx)(_Me,{})}),ha()?(0,J.jsx)(rC,{id:`demo`,label:`leave the demo`,icon:Ps,onClick:T8,note:`Back to your own desktop. Nothing in the demo is kept.`}):(0,J.jsx)(rC,{id:`demo`,label:`try the demo`,icon:nc,onClick:()=>w8(),note:`A pretend desktop with sample repos and a session to answer — nothing connects and nothing runs. Your own desktop's drafts and queue are set aside, not touched.`}),(0,J.jsx)(rC,{id:`pair-phone`,label:`pair another phone`,icon:dl,opens:!0,onClick:F5,note:`Shows a QR and a one-time code from this desktop. The new phone scans it — web version or the app — and gets its own sign-in.`}),(0,J.jsx)(rC,{id:`paired-devices`,label:`paired devices`,icon:Ra,opens:!0,onClick:$je,note:`The phones with their own sign-in for this desktop: when each was last seen, and revoke.`})]})}function _Me(){return(0,J.jsxs)(`ol`,{className:`web-pair-steps`,children:[(0,J.jsx)(`li`,{children:`On the phone: Tailscale installed and signed in to the same tailnet as the desktop.`}),(0,J.jsxs)(`li`,{children:[`Open that desktop's address in the browser — `,(0,J.jsx)(`code`,{children:`https://<machine>.<tailnet>.ts.net`}),` once it runs `,(0,J.jsx)(`code`,{children:`tailscale serve`}),`, else `,(0,J.jsx)(`code`,{children:`http://100.x.y.z:8770`}),`. Or, on a phone already connected to it, Settings → pair another phone: scanning that QR opens a page whose "use web version" is the same address.`]}),(0,J.jsx)(`li`,{children:`Add it to the home screen — one icon per desktop (needs the https address).`}),(0,J.jsx)(`li`,{children:`On your tailnet the address IS the sign-in: nothing to type. A desktop with a LAN password asks for that password instead. The pairing code is only for the Android app, which also keeps several desktops in one list with a switch on the launcher bar.`})]})}function vMe({size:e,onOpen:t}){let{hosts:n,activeId:r}=j5(),i=o4(),a=n.find(e=>e.id===r)?.name??`no host`;return(0,J.jsxs)(`button`,{className:`more-act host-item`,title:`host ${a} — switch desktop`,onClick:()=>{t(),N5()},children:[(0,J.jsx)(xo,{size:e}),(0,J.jsx)(`span`,{className:`host-item-name`,children:a}),i&&(0,J.jsxs)(J.Fragment,{children:[` · `,i.route===`lan`?(0,J.jsx)(Fc,{size:12}):(0,J.jsx)(wo,{size:12}),i.route===`lan`?`LAN`:`tailnet`]})]})}function yMe(){let{hosts:e,activeId:t}=j5();if(!Vje(e))return null;let n=e.find(e=>e.id===t)?.name;return n?(0,J.jsxs)(Q,{children:[` · `,(0,J.jsx)(Zc,{size:11,"aria-hidden":`true`}),` `,n]}):null}function bMe(){let{hosts:e,activeId:t}=j5(),n=ou(e),r=Uje(n,t);if(!r)return null;let i=e.find(e=>e.id===t)?.name??`no host`,a=n.find(e=>e.id===r)?.name??r;return(0,J.jsxs)(`div`,{className:`host-key`,role:`group`,"aria-label":`desktop`,children:[(0,J.jsxs)(`button`,{className:`host-key-flip`,title:`on ${i} — tap to switch to ${a}`,"aria-label":`on ${i}, switch to ${a}`,onClick:()=>L5(r),children:[(0,J.jsx)(za,{size:14,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`host-key-name`,children:Hje(i)})]}),(0,J.jsx)(`button`,{className:`host-key-menu`,title:`all desktops (${n.length})`,"aria-label":`all desktops`,onClick:N5,children:(0,J.jsx)(Nc,{size:12,"aria-hidden":`true`})})]})}var xMe={id:`hosts`,sheets:[{id:`hosts`,persisted:!1,render:()=>(0,V.createElement)(iMe)},{id:`pairqr`,persisted:!1,render:()=>(0,V.createElement)(fMe)},{id:`devices`,persisted:!1,render:()=>(0,V.createElement)(hMe)}],settings:[{group:`connection`,order:-20,render:()=>(0,V.createElement)(gMe)}],boot:()=>{hu()&&s4.set(()=>tMe);let e=uK(Qje);return()=>{s4.set(null),e()}}};function q5(e){let t;try{t=new URL(e)}catch{return{why:`its saved address cannot be read`}}return t.hostname?t.port?{addr:`${t.hostname.startsWith(`[`)?t.hostname:t.hostname.includes(`:`)?`[${t.hostname}]`:t.hostname}:${t.port}`}:{why:`its saved address has no port — peers call the daemon directly, so save it as host:port (for example 100.64.0.2:8770)`}:{why:`its saved address cannot be read`}}function SMe(e){let t=q5(e);if(!(`addr`in t))return t;let n=t.addr,r=wi(n);return r?{why:`${r} (${n})`}:{addr:n}}function CMe(e,t=[]){let n=new Set([...t].map(e=>e.toLowerCase())),r=e.toLowerCase().normalize(`NFKD`).replace(/[̀-ͯ]/g,``).replace(/[^a-z0-9_-]+/g,`-`).replace(/^[^a-z0-9]+/,``).replace(/-+$/,``).slice(0,28);if((!r||!Eee.test(r))&&(r=`peer`),!n.has(r))return r;for(let e=2;e<100;e++){let t=`${r}-${e}`;if(!n.has(t))return t}return`${r}-${n.size+1}`}function J5(e=e=>crypto.getRandomValues(new Uint8Array(e))){let t=e(32),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}function Y5(e,t={}){return e.map(e=>{let n=t[e.id];if(typeof n==`string`&&!wi(n))return{host:e,addr:n,why:null};let r=SMe(e.base);return`addr`in r?{host:e,addr:r.addr,why:null}:{host:e,addr:null,why:r.why}})}function X5(e){let t={};for(let n of e)t[n.host.id]=n.self??null;return t}function Z5(e,t){return!e||!t?`choose two desktops`:e.host.id===t.host.id?`choose two different desktops`:e.why?`${e.host.name}: ${e.why}`:t.why?`${t.host.name}: ${t.why}`:e.addr===t.addr?`${e.host.name} and ${t.host.name} are saved at the same address`:null}function wMe(e,t,n,r,i,a){return{forA:{name:n,addr:t.addr,outboundToken:i,inboundToken:a},forB:{name:r,addr:e.addr,outboundToken:a,inboundToken:i}}}function TMe(e){let t=new Map;for(let n of e)n.addr&&t.set(n.addr,n);let n=[];for(let r of e)for(let e of r.rows??[]){let i=t.get(e.addr)??null,a=i?.rows&&r.addr?i.rows.find(e=>e.addr===r.addr)??null:null;i&&a&&i.host.id<r.host.id||n.push({key:`${r.host.id}/${e.name}`,host:r.host,row:e,other:i?.host??null,mirror:a,mirrorUnknown:!!i&&!i.rows})}return n}function Q5(e){return e.other?`${e.host.name} ⇄ ${e.other.name}`:`${e.host.name} → ${e.row.name}`}function EMe(e){return e.other?e.mirrorUnknown?`${e.other.name} could not be reached, so its side is not known`:e.mirror?e.row.outbound&&e.row.inbound?``:e.row.outbound?`${e.host.name} can call ${e.other.name} but not the reverse`:`${e.other.name} can call ${e.host.name} but not the reverse`:`only ${e.host.name}'s side exists — ${e.other.name} has no row for it`:`${e.row.addr} is not one of the desktops saved on this phone — only ${e.host.name}'s side is listed`}function DMe(e,t){if(t!==!1)return``;let n=e.other?.name??e.row.name;return`claude is not signed in on ${n}: a job sent there stops at its sign-in screen. `+(e.other?`Switch to ${n}, open any session and tap its sign-in button.`:`Sign in on ${n} (open a session there and tap its sign-in button).`)}function $5(e,t){let n=t.filter(e=>!e.ok);if(!n.length)return`${t.map(e=>e.host).join(` and `)} ${e}`;let r=t.filter(e=>e.ok),i=n.map(e=>`${e.host}${e.why?` (${e.why})`:``}`).join(` and `);return`${i} did not answer — ${e===`paired`?r.length?`${r.map(e=>e.host).join(` and `)} was written, so the pairing is one-sided until you pair again`:`nothing was written`:r.length?`${r.map(e=>e.host).join(` and `)} was removed, ${i.includes(` and `)?`the others still hold`:`the other still holds`} a row`:`nothing was removed`}`}function e7(e,t){let n=t&&typeof t==`object`?t.error:null;return typeof n==`string`&&n?n:e===403?`this phone is not allowed to manage peers there`:e===401?`this phone is not signed in there`:`status ${e}`}function OMe(e,t){if(!e)return null;let n=q5(/^[a-z]+:\/\//i.test(e)?e:`http://${e}`);if(!(`addr`in n))return null;let r=e=>{let t=q5(e);return`addr`in t&&t.addr===n.addr};return t.find(e=>r(e.base)||!!e.lan&&r(e.lan.base))??null}function t7(e,t,n,r){let i=e.peerWait,a=Yn(i,r);if(!i||!a)return null;let o=OMe(i.peerBase,t),s=i.peerSessionId??null,c;return c=o?o.id===n?`${i.peer} is the desktop in use`:`switch to ${o.name}${s?` and open the job's session`:``}`:`${i.peer} is not one of the desktops saved on this phone — add it to open its session`,{text:a,target:o,sessionId:s,title:c}}function kMe(e,t){let n=Vee(e.cost),r=[...Mee(n),Gi(n?.weekPct)].filter(Boolean),i=n?.tokens,a=Number.isFinite(e.since)&&e.since>0&&t>=e.since?hr(Math.max(t-e.since,1)):``,o=Ar(e.state)||`state unknown`;return{title:`${typeof e.label==`string`&&e.label.trim()?e.label.trim():`a job`} → ${e.peer}`,state:[o,a?`sent ${a===`<1 min`?`just now`:`${a} ago`}`:``,e.closed?`closed`:``].filter(Boolean).join(` · `),cost:r.length?r.join(` · `):null,tokens:i?`in ${L(i.in)} · out ${L(i.out)} · cache read ${L(i.cacheRead)} · cache write ${L(i.cacheWrite)}`:null,costNote:n?.usd==null?n?.tokens?`${e.peer} could not price this job's model`:null:`list price on ${e.peer}, subagents included${n.unpricedTok?`; ${L(n.unpricedTok)} tokens on a model with no published rate are not in it`:``}`,asker:typeof e.askerLabel==`string`&&e.askerLabel.trim()?e.askerLabel.trim():null,detail:typeof e.detail==`string`&&e.detail.trim()?e.detail.trim():null,bad:e.state===`failed`||e.state===`refused`||e.state===`unreachable`}}function n7(e){return`${e} is not saved on this phone — add it under Hosts to open its session`}var r7=W({ledgers:[],loaded:!1,busy:0,note:null,pick:{a:null,b:null},signedIn:{}});function AMe(){return G(r7)}function i7(){return hu()?ou(nu()):[]}function a7(e){let t=ru()?.id===e.id?uu():z(xe(R.deviceToken,e.id));return lu(t)?t:null}function o7(e){r7.set(t=>({...t,busy:Math.max(0,t.busy+e)}))}var s7=e=>r7.set(t=>({...t,note:e}));function jMe(e){let t=e&&typeof e==`object`?e.peers:null;return Array.isArray(t)?t.flatMap(e=>{let t=e;return typeof t?.name==`string`&&typeof t.addr==`string`?[{name:t.name,addr:t.addr,outbound:t.outbound===!0,inbound:t.inbound===!0,addedAt:typeof t.addedAt==`number`?t.addedAt:0}]:[]}):null}function MMe(e){let t=e&&typeof e==`object`?e.self:null;return typeof t?.addr==`string`&&t.addr?t.addr:null}async function c7(){let e=Y5(i7());o7(1);try{let t=await Promise.all(e.map(async e=>{try{let t=await H.peers.on(e.host.base,a7(e.host),`GET`,`/api/peers`),n=t.status===200?jMe(t.body):null,r=t.status===200?MMe(t.body):null;return n?{host:e.host,addr:Y5([e.host],{[e.host.id]:r})[0].addr,rows:n,self:r}:{host:e.host,addr:e.addr,rows:null,error:e7(t.status,t.body)}}catch{return{host:e.host,addr:e.addr,rows:null,error:`did not answer`}}}));r7.set(e=>({...e,ledgers:t,loaded:!0})),NMe(t)}finally{o7(-1)}}async function NMe(e){let t=e.flatMap(e=>(e.rows??[]).filter(e=>e.outbound).map(t=>({l:e,r:t}))),n=await Promise.all(t.map(async({l:e,r:t})=>{try{let n=await H.peers.on(e.host.base,a7(e.host),`GET`,`/api/peers/${encodeURIComponent(t.name)}/status`),r=n.body;return n.status===200&&r?.ok&&typeof r.claudeSignedIn==`boolean`?[[`${e.host.id}/${t.name}`,r.claudeSignedIn]]:[]}catch{return[]}}));r7.set(e=>({...e,signedIn:Object.fromEntries(n.flat())}))}function PMe(e,t){r7.set(n=>({...n,pick:{...n.pick,[e]:t}}))}async function FMe(e,t){let n=Y5(i7(),X5(r7.get().ledgers)),r=n.find(t=>t.host.id===e),i=n.find(e=>e.host.id===t),a=Z5(r,i);if(a||!r||!i||!r.addr||!i.addr){s7(a??`choose two desktops`);return}U().say.track(`action:peers.pair`);let o=r7.get().ledgers,s=e=>o.find(t=>t.host.id===e)?.rows??[],c=(e,t,n)=>{let r=s(e);return r.find(e=>e.addr===n)?.name??CMe(t.name,r.map(e=>e.name))},l=c(r.host.id,i.host,i.addr),u=c(i.host.id,r.host,r.addr),{forA:d,forB:f}=wMe({addr:r.addr},{addr:i.addr},l,u,J5(),J5());o7(1),s7(`pairing ${r.host.name} and ${i.host.name}…`);try{let e=async(e,t)=>{try{let n=await H.peers.on(e.base,a7(e),`POST`,`/api/peers`,t);return n.status===200?{host:e.name,ok:!0}:{host:e.name,ok:!1,why:e7(n.status,n.body)}}catch{return{host:e.name,ok:!1}}};s7($5(`paired`,await Promise.all([e(r.host,d),e(i.host,f)])))}finally{o7(-1)}await c7()}async function IMe(e){let t=e.other&&e.mirror;if(!await gC({title:e.other?`Unpair ${e.host.name} and ${e.other.name}?`:`Remove ${e.row.name} from ${e.host.name}?`,lines:[t?`Each desktop forgets the other and its token stops working at once.`:`Only the side listed is removed.`,`Jobs already running on a peer are not cancelled; their reports will not come back.`],confirmLabel:`Unpair`}))return;U().say.track(`action:peers.unpair`);let n=async(e,t)=>{try{let n=await H.peers.on(e.base,a7(e),`DELETE`,`/api/peers/${encodeURIComponent(t)}`);return n.status===200||n.status===404?{host:e.name,ok:!0}:{host:e.name,ok:!1,why:e7(n.status,n.body)}}catch{return{host:e.name,ok:!1}}};o7(1);try{let t=[n(e.host,e.row.name)];e.other&&e.mirror&&t.push(n(e.other,e.mirror.name)),s7($5(`unpaired`,await Promise.all(t)))}finally{o7(-1)}await c7()}function l7(e,t){if(U().say.track(`action:peers.open`),!e.target){U().say.toast(n7(t));return}if(ru()?.id===e.target.id){U().say.toast(`${e.target.name} is the desktop in use`);return}let n=Vl();if(!n||!e.sessionId){eu(e.target.id)||U().say.toast(`already on that host`);return}if(!Ul(n).some(t=>t.id===e.target.id)){U().say.toast(n7(t));return}let r=n.getItem(R.hostActive);Ql(n,{from:r&&r!==e.target.id?r:null,to:e.target.id});try{history.replaceState(null,``,`${location.pathname}#a=${encodeURIComponent(e.sessionId)}`)}catch{}location.reload()}var u7=14;function LMe({sessions:e,onOpenSession:t}){let n=Ww(3e4),r=gh(`peerjobs`,()=>H.peerJobs()),i=r.data??[];return!i.length&&r.state!==`error`?null:(0,J.jsxs)(`div`,{className:`peer-jobs`,children:[(0,J.jsxs)(Z,{style:{marginTop:10},children:[(0,J.jsx)(Wa,{size:12}),` Peer jobs — work this desktop handed to another`]}),(0,J.jsx)($,{res:r,empty:i.length===0,thing:`this desktop's peer jobs`,noun:`job list`}),(0,J.jsx)(`div`,{className:`list`,children:i.map(r=>{let i=kMe(r,n),a=r.sessionId?e.find(e=>e.id===r.sessionId&&e.running):void 0,o=t7({peerWait:{peer:r.peer,jobId:r.jobId,state:r.state,since:r.since,...r.peerSessionId?{peerSessionId:r.peerSessionId}:{},...r.peerBase?{peerBase:r.peerBase}:{}}},i7(),ru()?.id??null,n);return(0,J.jsx)(Xw,{kind:`wrap`,children:(0,J.jsxs)(Xw,{kind:`grow`,children:[(0,J.jsx)(Zw,{children:i.title}),(0,J.jsx)(Q,{className:i.bad?`warn`:void 0,children:i.state}),i.cost&&(0,J.jsx)(Q,{children:i.cost}),i.tokens&&(0,J.jsx)(Q,{children:i.tokens}),i.costNote&&(0,J.jsx)(Q,{children:i.costNote}),!i.cost&&!i.tokens&&(0,J.jsxs)(Q,{children:[r.peer,` has not said what it cost`,r.closed?``:` yet`]}),i.asker&&(0,J.jsxs)(Q,{children:[`asked by `,i.asker]}),i.detail&&(0,J.jsx)(Q,{children:i.detail}),(0,J.jsxs)(`span`,{className:`act-acts`,children:[a?(0,J.jsxs)(Y,{onClick:()=>t(a.id),children:[(0,J.jsx)(qa,{size:u7}),` the asking session`]}):(0,J.jsx)(Q,{children:`the asking session is no longer open here`}),o?.target?(0,J.jsxs)(Y,{title:o.title,onClick:()=>l7(o,r.peer),children:[(0,J.jsx)(Wa,{size:u7}),` `,r.peerSessionId?`its session on ${r.peer}`:`open ${r.peer}`]}):(0,J.jsx)(Q,{children:n7(r.peer)})]})]})},r.jobId)})})]})}var d7=16;function RMe({onClose:e}){let t=AMe();if((0,V.useEffect)(()=>{c7()},[]),!hu())return(0,J.jsx)(Hw,{title:`Peer desktops`,icon:(0,J.jsx)(Wa,{size:d7}),onClose:e,children:(0,J.jsx)(`div`,{className:`empty`,children:`Pairing is done from the Android app, which is the one that knows more than one desktop.`})});let n=Y5(i7(),X5(t.ledgers)),r=n.find(e=>e.host.id===t.pick.a),i=n.find(e=>e.host.id===t.pick.b),a=t.pick.a||t.pick.b?Z5(r,i):null,o=TMe(t.ledgers),s=t.ledgers.filter(e=>!e.rows);return(0,J.jsxs)(Hw,{title:`Peer desktops`,icon:(0,J.jsx)(Wa,{size:d7}),onClose:e,children:[(0,J.jsx)(Z,{children:`A paired desktop can be handed a job by a session on the other, and its answer comes back to that session. Pairing gives each desktop the other's address and a fresh secret in each direction; the secrets are made on this phone, sent once and not kept here.`}),(0,J.jsx)(Z,{children:`A job only runs while the other desktop's auto-run is on, and that desktop's budget pause applies to it like to its own work — what it spends there counts against the same account when both desktops sign in as you.`}),n.length<2?(0,J.jsx)(`div`,{className:`empty`,children:`Pairing needs two saved desktops. Add the other one under Hosts first.`}):(0,J.jsxs)(JS,{style:{display:`grid`,gap:8},children:[[`a`,`b`].map(e=>(0,J.jsxs)(`select`,{"aria-label":e===`a`?`first desktop`:`second desktop`,value:t.pick[e]??``,onChange:t=>PMe(e,t.target.value||null),children:[(0,J.jsx)(`option`,{value:``,children:e===`a`?`first desktop…`:`second desktop…`}),n.map(e=>(0,J.jsxs)(`option`,{value:e.host.id,children:[e.host.name,e.addr?` · ${e.addr}`:` · cannot pair`]},e.host.id))]},e)),a&&(0,J.jsx)(Z,{as:`span`,children:a}),(0,J.jsxs)(Y,{onClick:()=>{t.busy>0||FMe(t.pick.a??``,t.pick.b??``)},children:[(0,J.jsx)(Wa,{size:d7}),` pair both ways`]}),n.filter(e=>e.why).map(e=>(0,J.jsxs)(Z,{as:`span`,children:[e.host.name,`: `,e.why]},e.host.id))]}),t.busy>0&&(0,J.jsx)(Z,{children:`working…`}),t.note&&(0,J.jsx)(Z,{role:`status`,children:t.note}),(0,J.jsx)(Z,{style:{marginTop:10},children:`Paired`}),t.loaded?o.length===0?(0,J.jsx)(`div`,{className:`empty`,children:`No desktop is paired with another yet.`}):(0,J.jsx)(`div`,{className:`list`,children:o.map(e=>{let n=EMe(e),r=DMe(e,t.signedIn[e.key]);return(0,J.jsxs)(Xw,{kind:`wrap`,children:[(0,J.jsxs)(Xw,{kind:`grow`,children:[(0,J.jsx)(Zw,{children:Q5(e)}),(0,J.jsxs)(Q,{className:`dim`,children:[e.host.name,` knows it as `,e.row.name,` · `,e.row.addr]}),n&&(0,J.jsx)(Q,{children:n}),r&&(0,J.jsx)(Q,{className:`warn`,role:`status`,children:r})]}),(0,J.jsx)(`div`,{className:`row-acts`,children:(0,J.jsx)(Y,{"aria-label":`unpair ${Q5(e)}`,onClick:()=>void IMe(e),children:(0,J.jsx)(ws,{size:d7})})})]},e.key)})}):(0,J.jsx)(`div`,{className:`empty`,children:`reading each desktop…`}),s.map(e=>(0,J.jsxs)(Z,{children:[e.host.name,`'s peers could not be read: `,e.error]},e.host.id))]})}function zMe({s:e}){let t=Ww(3e4);if(!e.peerWait)return null;let n=EK(e,t),r=t7(e,i7(),ru()?.id??null,t);if(!n||!r)return null;let i=()=>l7(r,e.peerWait.peer);return(0,J.jsxs)(qw,{className:`${n.cls} tag-filter`,role:`button`,tabIndex:0,title:r.title,onPointerDown:e=>e.stopPropagation(),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),i())},onClick:e=>{e.stopPropagation(),i()},children:[n.body,!r.target&&(0,J.jsx)(J.Fragment,{children:` · not a saved desktop`})]})}function f7({s:e}){let t=DK(e),n=OK(e);return!t&&!n?null:(0,J.jsxs)(J.Fragment,{children:[n&&(0,J.jsx)(qw,{className:n.cls,title:n.title,children:n.body}),t&&(0,J.jsx)(qw,{className:t.cls,title:t.title,children:t.body})]})}function BMe({s:e}){let t=kK(e);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(f7,{s:e}),t.map(e=>(0,J.jsx)(Q,{className:`peer-job-line`,children:e.text},e.key))]})}var VMe={id:`peers`,boot:()=>(HR(RMe),GR(LMe),()=>{HR(null),GR(null)})},p7=W(null),HMe=`/_capacitor_file_/`;function UMe(e,t){let n;try{n=JSON.parse(e)}catch{return null}if(!n||typeof n!=`object`)return null;let r=n,i=[];if(Array.isArray(r.files))for(let e of r.files){if(!e||typeof e.url!=`string`||typeof e.name!=`string`)continue;let n;try{n=new URL(e.url)}catch{continue}if(n.origin!==t||!n.pathname.startsWith(HMe))continue;let r=e.name.split(/[\\/]/).pop()?.trim()||`shared`;i.push({url:n.href,name:r,type:typeof e.type==`string`?e.type:``,size:typeof e.size==`number`&&e.size>=0?e.size:0})}let a=typeof r.text==`string`?r.text.trim():``;return!i.length&&!a?null:{files:i,text:a}}var m7=null,h7=new Set;function WMe(e){if(h7.add(e),m7){let t=m7;m7=null,e(t)}return()=>{h7.delete(e)}}function GMe(){Fh(`Share`,e=>{let t=UMe(e,window.location.origin);if(!t)return!0;if(h7.size===0)return m7=t,!0;for(let e of h7)e(t);return!0})}function KMe(){return WMe(qMe)}function g7(e){let t=U().nav;e?t.open(e):t.overlay&&t.close(t.overlay)}function qMe(e){let t=U();p7.get()&&t.say.toast(`a newer share replaced the one waiting`),t.say.track(`overlay:share`),p7.set(e),t.nav.open(`share`)}function _7(){p7.set(null),g7(null)}async function JMe(e){let t=[],n=0;for(let r of e.files)try{let e=await fetch(r.url);if(!e.ok)throw Error(String(e.status));let n=await e.blob();t.push(new File([n],r.name,{type:r.type||n.type}))}catch{n++}return{files:t,failed:n}}var YMe=6e5;async function v7(e){let t=U(),n=p7.get();if(!n)return;let r,i;if(e.kind===`session`){if(i=[t.world.active,...t.world.sessions].find(t=>t?.id===e.sessionId)??void 0,r=i&&t.world.repos.find(e=>e.worktreePath===i.cwd),!i){t.say.toast(`that session is gone — pick another`);return}if(!r){t.say.toast(`that session is not in a known repo — pick another`);return}}else r=e.repo;let{files:a,failed:o}=await JMe(n);if(o&&!a.length&&!n.text){t.say.toast(`couldn't read what was shared — share it again`);return}if(e.kind===`inbox`){await XMe(e.repo,n,a,o);return}p7.set(null),g7(null),t.say.track(e.kind===`new`?`action:share.new`:`action:share.session`);let s=t.world.active?.id,c;i?(c=i.id,i.id!==s&&t.nav.attach(i)):c=t.launch.openCwd(r.worktreePath,Qn(r),!1);let l=r.worktreePath,u=r.id;c&&n.text&&t.compose.seedDraft(c,n.text),o&&t.say.toast(`${o} shared file${o===1?``:`s`} couldn't be read`);let d=Date.now(),f=()=>{let t=U().world.active;if(c?t?.id===c:t&&t.id!==s&&t.cwd===l)!c&&n.text&&U().compose.insert(n.text),a.length?U().files.attachFiles(a,u,{annotate:e.annotate}):n.text&&U().say.toast(`shared text is in the prompt — read it over, then send`);else{if(Date.now()-d>YMe){p7.set(n),U().nav.open(`share`),U().say.toast(`the session never opened — pick where the share goes`);return}setTimeout(f,250)}};f()}async function XMe(e,t,n,r){let i=U();i.say.track(`action:share.inbox`),n.length>3&&i.say.toast(`preparing ${n.length} files…`);let a=await i.files.attachForInbox(e,n,`inbox:${e.worktreePath}`);if(!a.length){i.say.toast(`couldn't queue the files — share them again`);return}p7.set(null),g7(null),t.text&&await Xf(t.text);let o=a.length,s=[`${o} file${o===1?``:`s`} → ${e.repoName}/.claude/inbox`,i.conn.status===`open`?`uploading`:`they upload when the link is back`];r&&s.push(`${r} couldn't be read`),t.text&&s.push(`text copied`),i.say.toast(s.join(` · `))}function ZMe(e){let t=y7(e),n=e.files.length-t,r=[];return t&&r.push(`${t} picture${t===1?``:`s`}`),n&&r.push(`${n} file${n===1?``:`s`}`),e.text&&r.push(`text`),r.join(` · `)||`nothing`}function y7(e){return e.files.filter(e=>QMe(e)).length}var QMe=e=>e.type?e.type.startsWith(`image/`)&&e.type!==`image/svg+xml`:/\.(png|jpe?g|gif|webp|heic|bmp)$/i.test(e.name);function $Me(e,t){return e.filter(e=>e.running&&e.id!==t)}function eNe(){let e=Dh(),t=G(p7),[n,r]=(0,V.useState)(!1),i=t?y7(t):0,[a,o]=(0,V.useState)(i===1),[s,c]=(0,V.useState)(!1);if(!t)return null;let{active:l,sessions:u,repos:d}=e.world,f=e.conn.status!==`open`,p=e=>d.find(t=>t.worktreePath===e)?.repoName??``,m=$Me(u,l?.id),h=e=>{n||(r(!0),v7(e).finally(()=>r(!1)))},g=(e,t)=>(0,J.jsxs)(Xw,{as:`button`,onClick:()=>h({kind:`session`,sessionId:e.id,annotate:a}),children:[(0,J.jsxs)(Zw,{children:[(0,J.jsx)(qa,{size:14}),` `,l_(e,p(e.cwd))]}),(0,J.jsxs)(Q,{children:[p(e.cwd)||e.cwd,t?` · ${t}`:``]})]},e.id);return(0,J.jsxs)(Hw,{title:`Shared to ${I.displayName}`,icon:(0,J.jsx)(Ro,{size:16}),onClose:_7,footer:(0,J.jsx)(`div`,{className:`sheet-actions`,children:(0,J.jsxs)(Y,{onClick:_7,children:[(0,J.jsx)(B,{size:16}),` drop it`]})}),children:[(0,J.jsx)(Z,{children:n?`reading what was shared…`:`${ZMe(t)} — where should it go? In a session, files are uploaded with their paths in the prompt, which is not sent until you send it.`}),i>0&&(0,J.jsx)(yS,{label:`pictures`,value:a?`markup`:`asis`,options:[{key:`asis`,label:`upload pictures as they are`},{key:`markup`,label:`mark them up first`}],onChange:e=>o(e===`markup`)}),f&&(0,J.jsx)(Z,{children:`Connecting to the desktop — its open sessions appear here once it answers.`}),(0,J.jsxs)(`div`,{className:`list`,children:[t.files.map(e=>(0,J.jsxs)(Xw,{children:[(0,J.jsxs)(Zw,{children:[e.type.startsWith(`image/`)?(0,J.jsx)(Io,{size:14}):(0,J.jsx)(Fs,{size:14}),` `,e.name]}),(0,J.jsxs)(Q,{children:[e.type||`file`,e.size?` · ${un(e.size)}`:``]})]},e.url)),t.text&&(0,J.jsxs)(Xw,{children:[(0,J.jsxs)(Zw,{children:[(0,J.jsx)(Fs,{size:14}),` text`]}),(0,J.jsx)(Q,{children:t.text.length>200?`${t.text.slice(0,200)}…`:t.text})]})]}),l&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsx)(`span`,{children:`This session`})}),(0,J.jsx)(`div`,{className:`list`,children:g(l,`on screen now`)})]}),m.length>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`section section-head`,children:(0,J.jsx)(`span`,{children:l?`Another open session`:`An open session`})}),(0,J.jsx)(`div`,{className:`list`,children:m.map(e=>g(e,``))})]}),t.files.length>0&&(0,J.jsx)(yS,{label:`in a repo`,value:s?`inbox`:`session`,options:[{key:`session`,label:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(qa,{size:14}),` new session`]})},{key:`inbox`,label:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Oo,{size:14}),` inbox only`]})}],onChange:e=>c(e===`inbox`)}),s&&(0,J.jsxs)(Z,{children:[`No session: the files upload to the repo's .claude/inbox/ in the background`,t.text?`, and the text is copied`:``,`.`]}),(0,J.jsx)(aF,{repos:d,label:s?`Into the inbox of…`:`A new session in…`,listClass:`list`,home:l?.cwd??null,worktreeFilter:!0,emptyText:`No repos on this desktop yet.`,onPick:e=>h(s?{kind:`inbox`,repo:e}:{kind:`new`,repo:e,annotate:a})})]})}var tNe={id:`share`,sheets:[{id:`share`,persisted:!1,render:()=>p7.get()?(0,V.createElement)(eNe):null}],boot:KMe};function nNe(e,t,n){return(e?t.find(t=>t.id===e):null)??n}function rNe(e,t){return e?`stopped`:t?`not stopped — ${t}`:`not stopped`}function iNe(e,t=0){if(!e&&!t)return null;let n=`stopped ${e} background shell${e===1?``:`s`} when the session closed`;return t>0?`${n} · ${t} did not stop`:n}var b7=new Set;function aNe(e){b7.add(e)}function oNe(e){return b7.delete(e)}var x7=W(null);function sNe(e){let t=U();t.say.track(`action:session.shells`),x7.set(e.id),t.nav.open(`shells`)}function cNe(){x7.set(null),U().nav.close(`shells`)}function lNe(e,t){let n=U();n.say.track(`action:shell.kill`),n.conn.liveSend({t:`shell.kill`,id:e.id,pid:t.pid,startedAt:t.startedAt},`stopping…`,`no connection — the desktop didn't get that, the shell is still running`)}function uNe(e){U().say.toast(rNe(e.ok,e.reason))}function dNe(e){aNe(e)}function fNe(e,t,n){if(!oNe(e))return;let r=iNe(t,n);r&&U().say.toast(r)}var pNe=3e3;function mNe({subject:e,sh:t}){let n=gh(`shell:${e.id}:${t.pid}`,()=>H.shellDetail(e.id,t.pid)),{reload:r}=n;(0,V.useEffect)(()=>{let e=setInterval(()=>{document.hidden||r({quiet:!0})},pNe);return()=>clearInterval(e)},[r]);let i=n.data,a=(0,V.useRef)(null),o=(0,V.useRef)(!0);return(0,V.useLayoutEffect)(()=>{let e=a.current;e&&o.current&&(e.scrollTop=e.scrollHeight)},[i?.output]),(0,J.jsxs)(`div`,{className:`shell-detail`,children:[(0,J.jsx)($,{res:n,empty:!i,thing:`this shell`}),i&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Q,{as:`div`,children:`command`}),(0,J.jsx)(`pre`,{className:`shell-cmd`,children:i.command}),(0,J.jsxs)(Q,{as:`div`,children:[`output`,i.outputBytes!==void 0&&(0,J.jsxs)(J.Fragment,{children:[` · `,yp(i.outputBytes),i.truncated?` (last 64 KB)`:``]}),i.outputAt!==void 0&&(0,J.jsxs)(J.Fragment,{children:[` · written `,kp(Date.now()-i.outputAt)]})]}),i.output===void 0?(0,J.jsx)(Q,{as:`div`,children:i.outputWhy}):i.output===``?(0,J.jsx)(Q,{as:`div`,children:`nothing printed — the command may send its output to a file of its own`}):(0,J.jsx)(`pre`,{ref:a,className:`shell-out`,onScroll:e=>{let t=e.currentTarget;o.current=t.scrollHeight-t.scrollTop-t.clientHeight<24},children:i.output}),i.outputPath&&(0,J.jsx)(Q,{as:`div`,className:`mono shell-path`,children:i.outputPath})]})]})}var hNe=e=>e.description||e.command;function gNe({subject:e,sh:t,now:n}){let[r,i]=(0,V.useState)(!1),a=tee(t,n),o=t.serverLike?Zc:t.selfMatch?ol:a===`quiet`?gs:Do,s=r?Nc:Hs;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(Xw,{kind:`wrap`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`row grow`,"aria-expanded":r,onClick:()=>{r||U().say.track(`action:shell.open`),i(!r)},children:[(0,J.jsxs)(Zw,{children:[(0,J.jsx)(o,{size:14}),` `,hNe(t)]}),!r&&(0,J.jsx)(Q,{className:`mono bl-text`,children:t.command}),(0,J.jsx)(Q,{children:N(t,n)}),(0,J.jsxs)(Q,{children:[(0,J.jsx)(s,{size:12}),` `,r?`hide`:`full command and output`]})]}),!t.foreground&&(0,J.jsx)(fC,{className:`row-act`,confirm:`stop it?`,title:`stop this shell — its whole process group`,confirmTitle:`tap again to stop it`,onConfirm:()=>lNe(e,t),children:(0,J.jsx)(ic,{size:16})})]}),r&&(0,J.jsx)(mNe,{subject:e,sh:t})]})}function _Ne({subject:e}){let t=e.shellList,n=Date.now();return(0,J.jsxs)(Hw,{title:`${e.title} · shells`,icon:(0,J.jsx)(Do,{size:16}),onClose:cNe,children:[!t&&(0,J.jsxs)($,{children:[`This build hasn't read this session's background shells yet — an older host, or the read is off (`,(0,J.jsxs)(`code`,{children:[Fi(`SHELLS`),`=0`]}),`). `,e.shells?`The CLI's own record says shells ARE running here.`:``]}),t&&t.length===0&&(0,J.jsx)($,{children:`No background shells running right now.`}),t&&t.length>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z,{children:wt(Kr(t,n))}),t.map(t=>(0,J.jsx)(gNe,{subject:e,sh:t,now:n},t.pid)),(0,J.jsx)(Q,{as:`div`,style:{padding:`8px 12px`},children:`closing the session stops these too`})]})]})}var vNe={id:`shells`,sheets:[{id:`shells`,persisted:!1,render:e=>{let t=nNe(x7.get(),e.world.sessions,e.world.active);return t?(0,V.createElement)(_Ne,{subject:t}):null}}],messages:{"shell.killed":e=>uNe(e),"session.closed":e=>fNe(e.id,e.shellsStopped,e.shellsLeft)}},yNe=`log in once here, then move the token into a secret store`,S7=`without this flag the login redirects to localhost on the desktop and cannot finish from the phone`,C7=[{id:`gcloud`,command:`gcloud auth login --no-launch-browser`,note:`prints a URL; sign in on the phone, then paste the code back. (--no-browser is different: it needs gcloud on a second machine.)`},{id:`gcloud-adc`,command:`gcloud auth application-default login --no-launch-browser`,note:`the same flow for application-default credentials: open the URL, sign in, paste the code back.`},{id:`gh`,command:`gh auth login -h github.com -p https --web`,note:`prints a device code and opens github.com/login/device; enter the code there — nothing to paste back.`},{id:`firebase`,command:`firebase login --no-localhost`,note:`prints a URL; sign in on the phone and paste the code back.`,redirectsToLocalhost:!0},{id:`codex`,command:`codex login --device-auth`,note:`prints a URL and a device code; enter the code on the page — nothing to paste back.`,redirectsToLocalhost:!0},{id:`npm`,command:`npm login`,note:`prints a web login URL, then waits; sign in on the phone and the CLI carries on by itself.`},{id:`tailscale`,command:`tailscale login`,note:`prints a URL to open. On macOS the Tailscale app may own the login instead.`},{id:`docker`,command:`docker login`,note:`recent versions print a device code and URL; older ones ask for a username and, with --password-stdin, a token.`}];function bNe(e){return e.redirectsToLocalhost?`${e.note} ${S7[0].toUpperCase()}${S7.slice(1)}.`:e.note}function xNe(e=C7){return e.filter(e=>e.redirectsToLocalhost).length}function SNe(e,t=C7){return e?t.filter(e=>e.redirectsToLocalhost):[...t]}function CNe(e,t){return`${e} of ${t} logins — only those that redirect to localhost without the flag`}var wNe=`command added to the compose box — press send when you are ready`;function w7(){let e=U();e.say.track(`action:logins.open`),e.nav.open(`logins`)}function TNe(){U().nav.close(`logins`)}function ENe(e){let t=U();t.say.track(`action:logins.insert`),t.compose.insert(e.command),t.nav.close(`logins`),t.say.toast(wNe)}function DNe(){let[e,t]=(0,V.useState)(!1),n=C7.length,r=SNe(e);return(0,J.jsxs)(Hw,{title:`logins`,icon:(0,J.jsx)(Xa,{size:16}),onClose:TNe,children:[(0,J.jsx)(Z,{children:yNe}),(0,J.jsx)(Bw,{className:`annot-tools`,keys:[`local`],bucket:()=>({count:xNe()}),label:()=>`redirect to localhost`,active:e?`local`:null,onPick:e=>t(e===`local`)}),e&&(0,J.jsx)(Pw,{onClear:()=>t(!1),clearLabel:`show all`,children:CNe(r.length,n)}),r.map(e=>(0,J.jsxs)(Xw,{kind:`wrap`,children:[(0,J.jsxs)(Xw,{as:`button`,kind:`grow`,title:`add this command to the compose box`,onClick:()=>ENe(e),children:[(0,J.jsx)(Zw,{className:`mono`,children:e.command}),(0,J.jsx)(Q,{children:bNe(e)}),e.redirectsToLocalhost&&(0,J.jsxs)(Q,{children:[(0,J.jsx)(gs,{size:12}),` plain login redirects to localhost`]})]}),(0,J.jsx)(`span`,{className:`row-act`,"aria-hidden":!0,children:(0,J.jsx)(Fo,{size:16})})]},e.id))]})}var ONe={id:`shellLogins`,sheets:[{id:`logins`,persisted:!1,render:()=>(0,V.createElement)(DNe)}],commands:[{id:`logins`,run:()=>w7()}]};function T7(e,t){switch(e){case`named`:return`set by ${t}`;case`chosen`:return`chosen here`;case`found`:return`guessed — first usual code folder`;case`fallback`:return`guessed — folder missing`;default:return``}}function E7(e){return e===1?`1 repo`:e>0?`${e} repos`:`no repos`}function D7(e){return e.rootExists?`${e.root} · ${E7(e.repos)}`:`${e.root} · doesn't exist`}function O7(e,t){let n=e=>e.length>1?e.replace(/\/+$/,``):e;return n(e.trim())===n(t.trim())}function kNe(e,t){return t.trim()||e||``}function ANe(e){return e.picked===`named`?`named`:e.canChange?`choose`:`locked`}function jNe(e){return`${e} sets the code folder where the host starts — change that variable, or unset it, to choose another here.`}function k7(e){return`Saved ${e} — restart the host on the desktop to use it.`}function MNe(e){return`Change it later in Settings → Code folder. It is kept in ${e.choicePath}; the ${e.envName} environment variable, if set where the host starts, wins over it.`}function A7(e){return`${e.picked}:${e.root}`}function j7(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.length>0).slice(-20):[]}function NNe(e,t){return e.includes(t)?[...e]:[...e,t].slice(-20)}function PNe(e,t,n){return n.demo||n.overlay!==null||!xi(e)?!1:!t.includes(A7(e))}function FNe(e){return e.ok?e.saved?e.restart===`none`?{kind:`closed`}:e.restart===`auto`?{kind:`restarting`,text:`Restarting the host to scan ${e.root}…`}:{kind:`manual`,text:`Saved. Restart the host on the desktop to scan ${e.root}.`}:{kind:`refused`,text:`The desktop answered a check, not a save — update the host and try again.`}:{kind:`refused`,text:e.error}}function INe(e){return e.ok?`${e.root} · found ${E7(e.repos)}`:e.error}var M7=W(null),N7=W({phase:`idle`,readError:null}),LNe=6e3,P7,F7=null,I7=e=>String(e?.message||e);async function L7(){try{let e=await H.rootInfo();M7.set(e);let t=N7.get();return t.phase===`idle`&&t.readError&&N7.set({phase:`idle`,readError:null}),e}catch(e){return N7.get().phase===`idle`&&N7.set({phase:`idle`,readError:I7(e)}),null}}function R7(){let e=U();e.say.track(`overlay:codefolder`),N7.get().phase===`idle`&&N7.set({phase:`idle`,readError:null}),e.nav.open(`codefolder`),L7()}function RNe(){window.clearTimeout(P7);let e=M7.get();e&&xi(e)&&Ta(R.codeFolderLater,NNe(j7(ma(R.codeFolderLater,[])),A7(e))),N7.set({phase:`idle`,readError:null})}async function zNe(e){U().say.track(`action:codefolder.check`);try{return await H.checkRoot(e)}catch(e){return{ok:!1,error:`The desktop did not answer — ${I7(e)}`}}}async function BNe(e){let t=U();t.say.track(`action:codefolder.save`);let n;try{n=await H.saveRoot(e)}catch(e){return`The desktop did not answer — ${I7(e)}`}let r=FNe(n);if(r.kind===`refused`)return r.text;if(r.kind===`closed`)return await L7(),t.nav.close(`codefolder`),null;if(r.kind===`manual`)return N7.set({phase:`manual`,text:r.text}),L7(),null;let i=n.ok?n.root:e;return N7.set({phase:`restarting`,root:i,text:r.text}),window.clearTimeout(P7),P7=window.setTimeout(()=>z7(),LNe),null}function z7(){N7.get().phase===`restarting`&&(window.clearTimeout(P7),L7().finally(()=>U().nav.close(`codefolder`)))}function VNe(e){let t=N7.get();t.phase===`restarting`&&O7(t.root,e)?z7():ha()||F7!==null&&O7(F7,e)||(F7=e,(async()=>{let e=await L7();e&&PNe(e,j7(ma(R.codeFolderLater,[])),{overlay:U().nav.overlay,demo:!1})&&R7()})())}var B7=16;function HNe(){let e=G(M7),t=G(N7),[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(``),[o,s]=(0,V.useState)(null),[c,l]=(0,V.useState)(null),[u,d]=(0,V.useState)(null),f=()=>U().nav.close(`codefolder`);if(!e)return(0,J.jsx)(Hw,{title:`Code folder`,icon:(0,J.jsx)(Tc,{size:B7}),onClose:f,children:(0,J.jsx)($,{res:{state:t.phase===`idle`&&t.readError?`error`:`loading`,error:t.phase===`idle`?t.readError:null},thing:`the code folder`,children:`The desktop did not say which folder it scans.`})});let p=ANe(e),m=kNe(n,i),h=m!==``&&!O7(m,e.root),g=t.phase!==`idle`,_=p===`choose`&&e.rootExists&&e.picked!==`chosen`,v=e=>{r(e),a(``),s(null),d(null)},y=e=>{a(e),r(null),s(null),d(null)},b=async()=>{l(`check`),d(null);let e=await zNe(i.trim());l(null),s({ok:e.ok,text:INe(e)})},x=async e=>{l(`save`),d(null);let t=await BNe(e);l(null),t&&d(t)},S=p!==`choose`||g?t.phase===`restarting`?null:(0,J.jsx)(Y,{onClick:f,children:`Close`}):c===`save`?(0,J.jsx)(Q,{children:`Saving…`}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Y,{onClick:f,children:e.picked===`chosen`&&e.rootExists?`Close`:`Later`}),_&&(0,J.jsxs)(Y,{onClick:()=>void x(e.root),children:[`Keep `,e.root]}),h&&(0,J.jsx)(`button`,{className:`send`,onClick:()=>void x(m),children:`Use this folder`})]});return(0,J.jsx)(Hw,{title:`Which folder holds your repos?`,icon:(0,J.jsx)(Tc,{size:B7}),onClose:f,footer:S,children:(0,J.jsxs)(`div`,{className:`sheet-scroll`,children:[(0,J.jsx)(Z,{children:`Everything under this folder is reachable from the phone. The host scans it for repos.`}),(0,J.jsx)(`div`,{className:`section`,children:`In use now`}),(0,J.jsxs)(Z,{children:[(0,J.jsx)(`span`,{className:`mono`,children:D7(e)}),(0,J.jsx)(`br`,{}),T7(e.picked,e.envName)]}),e.pending&&(0,J.jsx)(Z,{tone:`warn`,children:k7(e.pending)}),t.phase===`restarting`&&(0,J.jsx)(Z,{children:t.text}),t.phase===`manual`&&(0,J.jsx)(Z,{children:t.text}),p===`named`&&(0,J.jsx)(Z,{children:jNe(e.envName)}),p===`locked`&&(0,J.jsx)(`div`,{className:`act-cants`,children:(0,J.jsx)($w,{children:`The code folder can only be changed from the desktop itself or over Tailscale.`})}),p===`choose`&&!g&&(0,J.jsxs)(J.Fragment,{children:[e.candidates.length>0&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`section`,children:`Usual code folders`}),(0,J.jsx)(`div`,{className:`list`,children:e.candidates.map(t=>{let r=n===t.path;return(0,J.jsxs)(`button`,{className:`row${r?` sched-on`:``}`,"aria-pressed":r,onClick:()=>v(t.path),children:[r?(0,J.jsx)(vc,{size:B7}):(0,J.jsx)(zs,{size:B7}),(0,J.jsx)(Zw,{className:`mono`,children:t.path}),(0,J.jsxs)(Q,{children:[E7(t.repos),O7(t.path,e.root)?` · in use`:``]})]},t.path)})})]}),(0,J.jsx)(`div`,{className:`section`,children:`Another folder`}),(0,J.jsxs)(`div`,{className:`form`,children:[(0,J.jsx)(`input`,{className:`search mono`,placeholder:e.root,value:i,spellCheck:!1,autoCapitalize:`off`,autoCorrect:`off`,onChange:e=>y(e.target.value)}),i.trim()&&(c===`check`?(0,J.jsx)(Z,{as:`span`,children:`Checking…`}):(0,J.jsx)(Y,{style:{margin:`0 10px`,alignSelf:`flex-start`},onClick:()=>void b(),children:`Check`}))]}),o&&(0,J.jsx)(Z,{tone:o.ok?void 0:`warn`,children:o.text}),!m&&(0,J.jsx)(Z,{children:`Pick a folder above, or type a path, to change it.`}),m&&!h&&(0,J.jsx)(Z,{children:`That is the folder in use now.`}),u&&(0,J.jsx)(Z,{tone:`warn`,children:u})]}),(0,J.jsx)(Z,{children:MNe(e)})]})})}function UNe(){let e=G(M7),t=G(N7);if((0,V.useEffect)(()=>{ha()||L7()},[]),ha())return null;let n=t.phase===`idle`?t.readError:null;return(0,J.jsx)(rC,{id:`code-folder`,label:`Code folder`,icon:Tc,opens:!0,onClick:R7,note:e?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`mono`,children:D7(e)}),` — `,T7(e.picked,e.envName)]}):n?`Could not read this desktop's code folder: ${n}`:`Reading which folder the desktop scans…`,more:(0,J.jsx)(`p`,{children:`Everything under it is reachable from the phone; the host scans it for repos. A change takes effect when the host restarts.`}),children:e?.pending&&(0,J.jsx)(YS,{tone:`plain`,children:k7(e.pending)})})}var WNe={id:`codeFolder`,sheets:[{id:`codefolder`,persisted:!1,render:()=>(0,V.createElement)(HNe),onLeave:RNe}],messages:{welcome:e=>VNe(e.root)},settings:[{group:`connection`,order:-5,render:()=>(0,V.createElement)(UNe)}]},V7=`todo-garden`,H7=`sort the tasks by due date`,U7=[{title:`Drive it`,rows:[{id:`live`,icon:`terminal`,headline:`Your session, in your pocket`,sentence:`The real claude CLI on your desktop, in a terminal on your phone — every slash command, plan prompt and context meter works, because it is the same program.`,target:{kind:`session`}},{id:`answer`,icon:`pointer`,headline:`Answer by tap`,sentence:`We put "${H7}" in the box for you — send it, and when Claude asks which way, tap the answer instead of typing a number.`,target:{kind:`reader`,seed:H7}},{id:`reader`,icon:`book`,headline:`Read it like a chat`,sentence:`A long conversation as a scrollable, searchable transcript, tool output folded away until you open it.`,target:{kind:`reader`}}]},{title:`Leave it running`,rows:[{id:`backlog`,icon:`list`,headline:`Backlog`,sentence:`Line up the next jobs for a repo; each one starts by itself when the session goes quiet.`,target:{kind:`sheet`,overlay:`backlog`}},{id:`schedule`,icon:`clock`,headline:`Schedules`,sentence:`Run a prompt on a clock — a weekly dependency check, a nightly test run — without being there.`,target:{kind:`sheet`,overlay:`schedule`}},{id:`limits`,icon:`hourglass`,headline:`Carries on after a usage limit`,sentence:`When the account hits its limit, blocked sessions are parked and continue by themselves when it resets.`,target:{kind:`sheet`,overlay:`limits`}},{id:`activity`,icon:`activity`,headline:`Everything you posted`,sentence:`Every prompt, schedule and build you sent, one row each from waiting to done — sent once, never lost on a bad connection.`,target:{kind:`sheet`,overlay:`activity`}}]},{title:`See what it did`,rows:[{id:`gallery`,icon:`images`,headline:`Gallery`,sentence:`Screenshots and files Claude saved for you show up as pictures, ready to view, mark up or download.`,target:{kind:`sheet`,overlay:`gallery`,inSession:!0}},{id:`notifications`,icon:`bell`,headline:`Notifications`,sentence:`One feed of what needs you: a session that finished, a question waiting, a job that failed.`,target:{kind:`sheet`,overlay:`notifications`}},{id:`sentlog`,icon:`send`,headline:`Sent log`,sentence:`Every word the app typed into a session, automatic answers included, and whether it arrived.`,target:{kind:`sheet`,overlay:`sentlog`}},{id:`search`,icon:`search`,headline:`Search past sessions`,sentence:`Find a conversation by something that was said in it, and open it where it was.`,target:{kind:`sheet`,overlay:`search`}},{id:`decisions`,icon:`gavel`,headline:`Decisions log`,sentence:`What a plugin answered on your behalf, and why, so nothing was decided out of sight.`,target:{kind:`sheet`,overlay:`decisions`}}]},{title:`Know what it costs`,rows:[{id:`tokens`,icon:`coins`,headline:`Tokens and cost`,sentence:`What each day, repo and model spent, with the split behind every total.`,target:{kind:`sheet`,overlay:`tokens`}},{id:`health`,icon:`heart`,headline:`Repo health`,sentence:`How the code itself is trending — file sizes, tests, the weight of CLAUDE.md — read off the repo without spending a token.`,target:{kind:`health`}},{id:`context`,icon:`gauge`,headline:`Context window`,sentence:`How full this session's context is over time, and where it was compacted, before it surprises you.`,target:{kind:`sheet`,overlay:`context`,inSession:!0}}]}],W7=U7.flatMap(e=>e.rows),G7={seen:[],opened:!1,read:!1,closed:!1,typed:!1,sid:null};function GNe(e){if(!e||typeof e!=`object`)return G7;let t=e,n=new Set(W7.map(e=>e.id)),r=Array.isArray(t.seen)?[...new Set(t.seen.filter(e=>typeof e==`string`&&n.has(e)))]:[],i=typeof t.sid==`string`&&t.sid?t.sid:null;return{seen:r,opened:t.opened===!0,read:t.read===!0,closed:t.closed===!0,typed:t.typed===!0,sid:i}}function KNe(e,t){return e.seen.includes(t)||!W7.some(e=>e.id===t)?e:{...e,seen:[...e.seen,t]}}function K7(e,t){return e[t]?e:{...e,[t]:!0}}function qNe(e){let t=new Set(e.seen),n=W7.filter(e=>t.has(e.id)).length;return{seen:n,total:W7.length,done:n===W7.length}}function JNe(e){let t=qNe(e);return t.done?`All ${t.total} tried`:`${t.seen} of ${t.total} tried`}var YNe=`make + Add bigger, check iOS sim and Android emulator`,q7=e=>e.demo&&e.scenario===`first-look`;function XNe(e,t){return q7(t)&&!e.opened&&!e.sid&&!t.active}function ZNe(e,t){return q7(t)&&!e.sid&&!e.typed&&!t.session.firstPrompt&&t.session.cwd.replace(/\/+$/,``).endsWith(`/todo-garden`)}function QNe(e,t){return e.sid===t?e:{...e,sid:t,opened:!0}}function $Ne(e,t){return q7(t)&&!e.typed&&!!e.sid&&t.activeId===e.sid&&t.draft===``}function J7(e){return!!e&&!e.turnActive&&(e.lastPrompt??``).toLowerCase().includes(`look like`)}function ePe(e,t){return q7(t)&&!!e.sid&&t.session?.id===e.sid&&J7(t.session)&&!e.read&&!e.closed}function tPe(e,t){return q7(t)&&!!e.sid&&t.session?.id===e.sid&&!e.closed&&J7(t.session)}function nPe(e){return e.find(e=>e.id===`demo-g1`)??e.find(e=>e.cwd.replace(/\/+$/,``).endsWith(`/todo-garden`))??null}function Y7(e,t,n){return e.kind===`health`||!X7(e)||!n?`direct`:t===n?`after-close`:`direct`}function X7(e){return e.kind!==`sheet`||e.inSession===!0}var Z7=W(G7),Q7=()=>G(Z7);function $7(e){e!==Z7.get()&&(Z7.set(e),Ta(R.demoTour,e))}function e9(){if(!ha())return;let e=U();e.say.track(`overlay:demotour`),e.nav.open(`demotour`)}function t9(){U().nav.close(`demotour`)}function n9(e){let t=!1,n=()=>{t||(t=!0,window.removeEventListener(`popstate`,n),setTimeout(e,0))};window.addEventListener(`popstate`,n),setTimeout(n,400)}function rPe(e){let t=U(),n=e.target,r=X7(n)?nPe(t.world.sessions):null;if(X7(n)&&!r){t.say.toast(`The demo session is still loading — try again in a moment.`);return}t.say.track(`action:demotour.${e.id}`);let i=!Z7.get().seen.includes(e.id);if($7(KNe(Z7.get(),e.id)),n.kind===`session`||n.kind===`reader`){let e=()=>{let e=U();n.kind===`session`?e.nav.attach(r):(e.nav.openReader(r,!1),n.seed&&i&&e.compose.seedDraft(r.id,n.seed))};Y7(n,t.world.active?.id,r.id)===`after-close`?(t9(),n9(e)):e();return}if(n.kind===`health`){t.world.active?.id!==r.id&&t.nav.attach(r),setTimeout(()=>O8(null),0);return}if(!r){t.nav.open(n.overlay);return}let a=n.overlay;Y7(n,t.world.active?.id,r.id)===`after-close`?(t9(),n9(()=>U().nav.open(a))):(t.nav.attach(r),setTimeout(()=>U().nav.open(a),0))}function iPe(){return Z7.set(GNe(ma(R.demoTour,null))),window.addEventListener(E8,e9),()=>window.removeEventListener(E8,e9)}function aPe(e){ha()&&ZNe(Z7.get(),{demo:ha(),scenario:Sa(),session:e})&&(U().say.track(`action:demohook.open`),$7(QNe(Z7.get(),e.id)),uPe(e.id))}function oPe(){$7(K7(Z7.get(),`opened`))}var sPe=300,cPe=70,r9=[...YNe.matchAll(/\S+/g)].map(e=>(e.index??0)+e[0].length),lPe=700;function uPe(e){let t=()=>$7(K7(Z7.get(),`typed`)),n=()=>U().world.active?.id===e;window.setTimeout(()=>{let e=U();if(!$Ne(Z7.get(),{demo:ha(),scenario:Sa(),activeId:e.world.active?.id??null,draft:e.compose.draft})){t();return}let r=0,i=()=>{let e=r?r9[r-1]:0;!n()||!U().compose.typeOn(`make + Add bigger, check iOS sim and Android emulator`.slice(0,e),`make + Add bigger, check iOS sim and Android emulator`.slice(0,r9[r]))?t():++r<r9.length?window.setTimeout(i,cPe):window.setTimeout(()=>{let e=U();n()&&e.compose.draft===`make + Add bigger, check iOS sim and Android emulator`&&(e.say.track(`action:demohook.send`),e.compose.send()),t()},lPe)};i()},sPe)}function i9(){let e=Z7.get();e.read||(U().say.track(`action:demohook.read`),$7(K7(e,`read`)))}function dPe(){$7(K7(Z7.get(),`closed`))}function a9(e,t){U().say.track(`action:demohook.${e}`),t()}var fPe={terminal:qa,pointer:co,book:qo,list:il,clock:os,hourglass:go,activity:us,images:jo,bell:No,send:Ec,search:rc,gavel:ine,coins:wl,gauge:ms,heart:Bo},pPe=20;function mPe(){let e=Q7(),t=new Set(e.seen);return(0,J.jsx)(Hw,{title:`More to try`,icon:(0,J.jsx)(xl,{size:18}),onClose:t9,className:`tour`,footer:(0,J.jsx)(Y,{className:`tour-done`,onClick:t9,children:`Look around on my own`}),children:(0,J.jsxs)(`div`,{className:`sheet-body tour-body`,children:[(0,J.jsxs)(`p`,{className:`tour-intro`,children:[`A pretend desktop with three sample repos. Tap a row to open that screen — Back brings you here.`,(0,J.jsxs)(`span`,{className:`tour-progress`,children:[` `,JNe(e),`.`]})]}),U7.map(e=>(0,J.jsxs)(`section`,{className:`tour-group`,"aria-label":e.title,children:[(0,J.jsx)(`h3`,{className:`tour-group-title`,children:e.title}),e.rows.map(e=>{let n=fPe[e.icon],r=t.has(e.id);return(0,J.jsxs)(`button`,{className:r?`tour-row seen`:`tour-row`,onClick:()=>rPe(e),children:[(0,J.jsx)(`span`,{className:`tour-icon`,children:(0,J.jsx)(n,{size:pPe})}),(0,J.jsxs)(`span`,{className:`tour-text`,children:[(0,J.jsxs)(`span`,{className:`tour-head`,children:[e.headline,r?(0,J.jsxs)(`span`,{className:`tour-seen`,children:[(0,J.jsx)(vc,{size:13}),` tried`]}):null]}),(0,J.jsx)(`span`,{className:`tour-sentence`,children:e.sentence})]}),(0,J.jsx)(Hs,{className:`tour-go`,size:18})]},e.id)})]},e.title))]})})}var hPe=`[data-hint="term.read"]`,gPe=1500;function _Pe({session:e,readMode:t}){let n=ePe(Q7(),{demo:ha(),scenario:Sa(),session:e}),[r,i]=(0,V.useState)(!1);(0,V.useEffect)(()=>{if(!n)return;let e=window.setTimeout(()=>i(!0),gPe);return()=>window.clearTimeout(e)},[n]);let a=n&&r,o=(0,V.useRef)(null),[s,c]=(0,V.useState)(null);return(0,V.useEffect)(()=>{aPe(e)},[e]),(0,V.useEffect)(()=>{a&&t&&i9()},[a,t]),(0,V.useLayoutEffect)(()=>{if(!a||t){c(null);return}let e=o.current?.parentElement,n=e?.querySelector(hPe)??null;if(!e||!n){c(null);return}let r=()=>{let t=e.getBoundingClientRect(),r=n.getBoundingClientRect();c({top:r.bottom-t.top+8,right:8,arrow:Math.max(10,t.right-8-(r.left+r.width/2)-6)})};return r(),n.classList.add(`demo-hook-pulse`),window.addEventListener(`resize`,r),()=>{n.classList.remove(`demo-hook-pulse`),window.removeEventListener(`resize`,r)}},[a,t]),!a||t?null:(0,J.jsxs)(`div`,{ref:o,className:`demo-hook-hint`,role:`note`,"aria-label":`Read it like a chat`,style:s?{top:s.top,right:s.right}:{visibility:`hidden`},children:[s&&(0,J.jsx)(`span`,{className:`demo-hook-arrow`,style:{right:s.arrow}}),(0,J.jsx)(qo,{size:16,className:`demo-hook-hint-icon`}),(0,J.jsxs)(`span`,{className:`demo-hook-hint-text`,children:[(0,J.jsx)(`b`,{children:`Read it like a chat`}),(0,J.jsx)(`span`,{children:`The same session as a transcript — tap the book above. Tap it again to come back.`})]}),(0,J.jsx)(`button`,{className:`demo-hook-x`,"aria-label":`dismiss the hint`,onClick:i9,children:(0,J.jsx)(B,{size:14})})]})}var vPe=`button.repo-start-btn[title^="new session in ${V7} "]`;function yPe(){let e=Q7(),t=U(),n=XNe(e,{demo:ha(),scenario:Sa(),active:!!t.world.active}),[r,i]=(0,V.useState)(null);return(0,V.useLayoutEffect)(()=>{if(!n){i(null);return}let e=null,t=0,r=0,a=()=>{if(!e)return;let t=e.getBoundingClientRect();i({top:t.bottom+8,right:8,arrow:Math.max(10,window.innerWidth-8-(t.left+t.width/2)-6)})},o=()=>{e=document.querySelector(vPe),e?(e.classList.add(`demo-hook-pulse`),a()):++t<50&&(r=window.setTimeout(o,100))};return o(),window.addEventListener(`resize`,a),window.addEventListener(`scroll`,a,!0),()=>{window.clearTimeout(r),e?.classList.remove(`demo-hook-pulse`),window.removeEventListener(`resize`,a),window.removeEventListener(`scroll`,a,!0)}},[n]),!n||!r?null:(0,J.jsxs)(`div`,{className:`demo-hook-hint demo-start-cue`,role:`note`,"aria-label":`Start a session`,style:{top:r.top,right:r.right},children:[(0,J.jsx)(`span`,{className:`demo-hook-arrow`,style:{right:r.arrow}}),(0,J.jsx)(Fo,{size:16,className:`demo-hook-hint-icon`}),(0,J.jsxs)(`span`,{className:`demo-hook-hint-text`,children:[(0,J.jsx)(`b`,{children:`Start a session on your desktop`}),(0,J.jsxs)(`span`,{children:[`Tap + now on `,V7,`: Claude Code opens in that repo, on the desktop’s own tools.`]})]}),(0,J.jsx)(`button`,{className:`demo-hook-x`,"aria-label":`dismiss the cue`,onClick:oPe,children:(0,J.jsx)(B,{size:14})})]})}function bPe({session:e,readMode:t}){let n=Q7();if(t||!tPe(n,{demo:ha(),scenario:Sa(),session:e}))return null;let r=U(),i=r.world.activeRepo,a=[{id:`schedule`,Icon:rl,head:`Schedule against your week`,sub:`Prompts on a clock, run while you are away.`,go:()=>r.nav.open(`schedule`)},{id:`tokens`,Icon:wl,head:`What it cost`,sub:`Every token this desktop spent, with its split.`,go:()=>r.nav.open(`tokens`)},...i?[{id:`health`,Icon:Bo,head:`Repo health`,sub:`How the code is trending, read off the repo.`,go:()=>O8(i.id)}]:[]];return(0,J.jsxs)(`section`,{className:`demo-hook-card`,"aria-label":`While you're away`,children:[(0,J.jsxs)(`div`,{className:`demo-hook-card-head`,children:[(0,J.jsx)(`b`,{children:`While you’re away`}),(0,J.jsxs)(Y,{className:`demo-hook-more`,onClick:()=>a9(`more`,e9),children:[(0,J.jsx)(xl,{size:12}),` More to try`]}),(0,J.jsx)(`button`,{className:`demo-hook-x`,"aria-label":`close the card`,onClick:dPe,children:(0,J.jsx)(B,{size:14})})]}),(0,J.jsx)(`div`,{className:`demo-hook-tiles`,children:a.map(({id:e,Icon:t,head:n,sub:r,go:i})=>(0,J.jsxs)(`button`,{className:`demo-hook-tile`,onClick:()=>a9(e,i),children:[(0,J.jsx)(t,{size:18}),(0,J.jsx)(`span`,{className:`demo-hook-tile-head`,children:n}),(0,J.jsx)(`span`,{className:`demo-hook-tile-sub`,children:r}),(0,J.jsx)(Hs,{size:12,className:`demo-hook-tile-go`})]},e))})]})}var xPe={id:`demoTour`,sheets:[{id:`demotour`,persisted:!1,render:()=>ha()?(0,V.createElement)(mPe):null}],boot:()=>iPe()};function SPe(e,t){let n=t.trim().toLowerCase();if(!n)return e.filter(e=>e.isPrimary);let r=e=>{let t=e.repoName.toLowerCase(),r=(e.branch??``).toLowerCase(),i=t.startsWith(n)?0:t.includes(n)?1:r.includes(n)?2:-1;return i<0?-1:i*2+ +!e.isPrimary};return e.map((e,t)=>({r:e,i:t,s:r(e)})).filter(e=>e.s>=0).sort((e,t)=>e.s-t.s||e.i-t.i).map(e=>e.r)}var o9=W([]);function s9(e){return o9.set(t=>[...t.filter(t=>t.id!==e.id),e]),()=>o9.set(t=>t.filter(t=>t!==e))}var CPe=()=>o9.get();function wPe(e,t){return e===`Enter`?t.mac?`Return`:`Enter`:e.length===1?e.toUpperCase():e}function TPe(e,t){return e===`meta`?t.mac?`⌘`:`Win`:e===`alt`?t.mac?`⌥`:`Alt`:t.mac?`⌃`:`Ctrl`}function EPe(e,t,n){let r=[];for(let i of e){if(!i.mods.includes(t))continue;let e=!1,a=``;try{e=i.when(),e&&(a=i.what())}catch{e=!1}e&&r.push({id:i.id,key:wPe(i.key,n),what:a,note:i.note?.(t,n)??null})}return r}function DPe(e){let t=e?.userAgentData?.platform||e?.platform||``;return/mac|iphone|ipad|ipod/i.test(t)}var c9=W(null);function OPe(e,t=`Which repo?`){return c9.get()?.resolve(null),new Promise(n=>{c9.set({repos:e,title:t,resolve:n})})}var l9=()=>c9.get()!=null;function kPe(){let e=[s9({id:`askRepo.next`,mods:[`ctrl`],key:`N`,what:()=>`next repo`,when:l9}),s9({id:`askRepo.prev`,mods:[`ctrl`],key:`P`,what:()=>`previous repo`,when:l9})];return()=>e.forEach(e=>e())}function u9(e){let t=c9.get();c9.set(null),t?.resolve(e)}function APe(){let e=G(c9),[t,n]=(0,V.useState)(``),[r,i]=(0,V.useState)(0),a=(0,V.useRef)(null);(0,V.useEffect)(()=>{n(``),i(0)},[e]);let o=(0,V.useMemo)(()=>e?SPe(e.repos,t):[],[e,t]);if((0,V.useEffect)(()=>{i(0)},[t]),(0,V.useEffect)(()=>{a.current?.querySelector(`[data-i="${r}"]`)?.scrollIntoView({block:`nearest`})},[r]),!e)return null;let s=e=>i(t=>o.length?(t+e+o.length)%o.length:0);return(0,J.jsx)(`div`,{className:`bl-modal-backdrop confirm-backdrop`,onClick:()=>u9(null),children:(0,J.jsxs)(`div`,{className:`bl-modal ask-repo-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":e.title,onClick:e=>e.stopPropagation(),children:[(0,J.jsx)(`div`,{className:`bl-modal-title`,children:e.title}),(0,J.jsx)(`input`,{className:`ask-text-input`,autoFocus:!0,value:t,placeholder:`type to filter repos`,role:`combobox`,"aria-expanded":`true`,"aria-controls":`ask-repo-list`,"aria-activedescendant":o[r]?`ask-repo-${r}`:void 0,enterKeyHint:`go`,spellCheck:!1,autoCapitalize:`off`,autoComplete:`off`,onChange:e=>n(e.target.value),onKeyDown:e=>{if(e.nativeEvent.isComposing)return;let t=e.ctrlKey&&!e.metaKey&&!e.altKey,n=e.key.toLowerCase();e.key===`ArrowDown`||t&&n===`n`?(e.preventDefault(),s(1)):e.key===`ArrowUp`||t&&n===`p`?(e.preventDefault(),s(-1)):e.key===`Enter`?(e.preventDefault(),o[r]&&u9(o[r])):e.key===`Escape`&&(e.preventDefault(),u9(null))}}),(0,J.jsxs)(`div`,{className:`ask-repo-list`,id:`ask-repo-list`,role:`listbox`,ref:a,children:[o.map((e,t)=>(0,J.jsxs)(`button`,{id:`ask-repo-${t}`,"data-i":t,role:`option`,"aria-selected":t===r,tabIndex:-1,className:`row ask-repo-row${t===r?` on`:``}`,onMouseMove:()=>{t!==r&&i(t)},onClick:()=>u9(e),children:[(0,J.jsx)(Zw,{children:tF(e)}),nF(e)&&(0,J.jsx)(Q,{children:nF(e)})]},e.id)),o.length===0&&(0,J.jsx)(`div`,{className:`ask-text-note ask-repo-none`,children:t.trim()?`No repo or branch matches “${t.trim()}”.`:`No repos under the host root yet.`})]}),(0,J.jsx)(`div`,{className:`ask-text-note`,children:`↑ ↓ to choose · Return opens · Esc closes`})]})})}function jPe(e){return e.isComposing||e.shiftKey||e.code!==`KeyN`&&e.key.toLowerCase()!==`n`?!1:e.altKey?!e.ctrlKey&&!e.metaKey&&e.code===`KeyN`:e.ctrlKey!==e.metaKey}function MPe(e,t){let n=t.mac?`⌥N`:`Alt+N`;return e===`alt`?null:e===`meta`&&!t.mac?`the system keeps Win+N for itself — ${n} does the same`:t.tab?e===`meta`?`this browser tab never receives ⌘N — ${n} or ⌃N do the same`:t.mac?null:`this browser tab never receives Ctrl+N — ${n} does the same`:null}function NPe(e){return e?`new session in ${e}`:`new session — pick a repo`}var PPe=`.bl-modal-backdrop, [role=dialog][aria-modal=true]`;function d9(e=document){return!l9()&&!e.querySelector(PPe)}function FPe(){let e=U(),t=e.world.active;if(!t)return null;let n=e.world.repoForCwd(t.cwd);return n?tF(n):vp(t.cwd)}function IPe(){return s9({id:`newSession`,mods:[`ctrl`,`meta`,`alt`],key:`N`,what:()=>NPe(FPe()),when:()=>d9(),note:MPe})}function LPe(){let e=U(),t=e.world.active;if(t){e.say.track(`action:key.new.here`);let n=e.world.repoForCwd(t.cwd);n?e.nav.openRepo(n):e.launch.openCwd(t.cwd,vp(t.cwd))}else e.say.track(`action:key.new.pick`),OPe(e.world.repos,`New session in…`).then(e=>{e&&U().nav.openRepo(e)})}function RPe(e=window){let t=t=>{jPe(t)&&d9(e.document)&&(t.preventDefault(),t.stopPropagation(),LPe())};return e.addEventListener(`keydown`,t,!0),()=>e.removeEventListener(`keydown`,t,!0)}var zPe={id:`newSession`,boot:()=>{let e=RPe(),t=IPe();return()=>{e(),t()}}};function BPe(){let e=Dh(),t=t=>e.say.toast(t),n=E6(),[r,i]=(0,V.useState)(``),[a,o]=(0,V.useState)(null),s=e.world.repos,c=n.res.data?.suggested??[],l=x6(n.rules,c),u=lOe(n.rules,c);async function d(){let e=y6(n.rules,r);o(e),!e&&await n.save(b6(n.rules,r),t)&&i(``)}return(0,J.jsxs)(iC,{id:`ask-rules`,label:`ask before`,icon:ps,note:oOe,more:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`p`,{children:[`Each rule is a Claude Code permission rule, like `,(0,J.jsx)(`b`,{children:`Bash(git push * main)`}),`. The desktop hands the list to every claude launch, and claude then draws its own box naming the exact command — only your tap answers it.`]}),(0,J.jsxs)(`p`,{children:[`It stops the accident, not the adversary: a rule matches the words typed, so a script, an alias or a subprocess running the same command is not seen, and a bare `,(0,J.jsx)(`b`,{children:`git push`}),` on a branch that tracks main is not caught. Other backends and shell sessions take no rule at all.`]}),(0,J.jsx)(`p`,{children:`The list reaches claude sessions started on this desktop. A peer desktop's jobs run under that peer's own list, and this desktop's own headless calls (review, assess) take no rule.`}),(0,J.jsx)(`p`,{children:`Switch a rule off for one repo from that repo's Repo readings, where the command is the daily flow.`})]}),children:[(0,J.jsx)($,{res:n.res,empty:!n.res.data,thing:`the ask rules`}),n.res.data&&(0,J.jsxs)(`div`,{className:`askrule-list`,children:[v6(n.res.data.lost)&&(0,J.jsx)(YS,{icon:ps,children:v6(n.res.data.lost)}),n.rules.length===0&&!n.res.data.lost&&(0,J.jsx)(X,{children:`No rules yet — nothing asks first.`}),n.rules.map(e=>{let r=dOe(e,s);return(0,J.jsxs)(`div`,{className:`askrule`,children:[(0,J.jsxs)(`div`,{className:`askrule-top`,children:[(0,J.jsx)(`code`,{className:`askrule-rule`,children:e.rule}),(0,J.jsxs)(fC,{className:`key`,confirm:`remove?`,onConfirm:()=>void n.save(uOe(n.rules,e.id),t),children:[(0,J.jsx)(ws,{size:14}),` remove`]})]}),r&&(0,J.jsxs)(`div`,{className:`set-chips`,"aria-label":r,children:[(0,J.jsx)(X,{as:`span`,children:`off in (tap a repo to ask there again)`}),(e.offIn??[]).map(r=>(0,J.jsx)(zw,{on:!0,onClick:()=>void n.save(w6(n.rules,e.id,r,!1),t),children:T6(r,s)},r))]})]},e.id)}),(0,J.jsxs)(`div`,{className:`askrule-add`,children:[(0,J.jsx)(`input`,{className:`guardrail-text`,value:r,placeholder:`Bash(git push * main)`,autoCapitalize:`off`,autoCorrect:`off`,spellCheck:!1,onChange:e=>{i(e.target.value),o(null)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),d())},"aria-label":`a rule to add`}),(0,J.jsxs)(Y,{onClick:()=>void d(),children:[(0,J.jsx)(Fo,{size:14}),` `,n.saving?`saving…`:`add`]})]}),a&&(0,J.jsx)(YS,{children:a}),u>0&&(0,J.jsx)(rC,{label:`add the suggested rules (${u})`,icon:Es,busy:n.saving,onClick:()=>void n.save(S6(n.rules,c),t),note:u<l.length?`${u} of the ${l.length} missing fit under the list's limit.`:`Force pushes, pushes to main or master, production deploys, releases, merges and publishing.`,more:(0,J.jsx)(`ul`,{className:`askrule-suggest`,children:l.slice(0,u).map(e=>(0,J.jsx)(`li`,{children:(0,J.jsx)(`code`,{children:e})},e))})})]})]})}var VPe={id:`askRules`,settings:[{group:`sessions`,order:20,render:()=>(0,V.createElement)(BPe)}]};function f9(e){return e.hasOrigin===!1}function HPe(e){return e.changedCount>0||(e.ahead??0)>0||(e.behind??0)>0}function p9(e){let t=[];return(e.ahead??0)>0&&t.push(`↑${e.ahead}`),(e.behind??0)>0&&t.push(`↓${e.behind}`),t.join(` `)}function UPe(e){let t=[];return e.changedCount>0&&t.push(`${e.changedCount} changed file${e.changedCount>1?`s`:``}`),(e.ahead??0)>0&&t.push(`${e.ahead} commit${e.ahead>1?`s`:``} to push`),(e.behind??0)>0&&t.push(`${e.behind} commit${e.behind>1?`s`:``} to pull`),f9(e)&&t.push(`no origin remote, nothing to push to`),`${t.length?t.join(`, `):`nothing pending`} — open git`}function m9(e){return e.hasOrigin!==!1&&e.ahead!==void 0}function h9(e,t){let n=e.filter(m9);return t===`push`?n.filter(e=>(e.ahead??0)>0):n}function WPe(e){let t=e.filter(e=>e.s===`ok`).length,n=e.filter(e=>e.s===`failed`).length,r=e.filter(e=>e.s===`skipped`).length,i=[`${t} repo${t===1?``:`s`} done`];return n&&i.push(`${n} failed`),r&&i.push(`${r} stopped`),i.join(`, `)}function GPe(e,t){return e===0?`No repo here has a branch with an upstream — nothing to pull from or push to.`:`Pull fetches and fast-forwards all ${e}; push sends the ${t} with commits out, one at a time — each runs its pre-push checks first, which can take minutes. Sync is pull, then push whatever is still ahead.`}function g9(e){return e>0?`${e} repo${e===1?``:`s`} without an origin or an upstream not listed.`:``}var _9=W({verb:null,active:!1,rows:{}}),KPe=3,qPe=3e3,v9=!1;function y9(e,t){let n=_9.get();_9.set({...n,rows:{...n.rows,[e]:t}})}async function JPe(e){y9(e,{s:`pulling`});try{let t=await H.gitPull(e);return y9(e,t.ok?{s:`ok`,text:t.output??`Pulled.`}:{s:`failed`,text:t.error??`The pull failed.`}),t.ok}catch(t){return y9(e,{s:`failed`,text:`The pull did not run: ${t.message}`}),!1}}var YPe=e=>new Promise(t=>setTimeout(t,e));async function XPe(e,t){let n=t?`${t} `:``,r;try{r=await H.gitPush(e)}catch(t){y9(e,{s:`failed`,text:`${n}The push did not start: ${t.message}`});return}let i=r.startedAt;for(y9(e,{s:`pushing`,startedAt:i});!(r&&r.startedAt===i&&r.result);){await YPe(qPe);try{r=await H.gitPushState(e)}catch{continue}if(!r||r.startedAt!==i){y9(e,{s:`failed`,text:`${n}The push's record is gone — the desktop restarted or another push replaced it. Open git to see where it stands.`});return}}let a=r.result;y9(e,a.ok?{s:`ok`,text:`${n}Pushed: ${a.output?.split(`
193
+ `).slice(-1)[0]||`ok`}`}:{s:`failed`,text:`${n}Push failed. ${a.error??``}`.trim()})}async function ZPe(e){try{return(await H.gitStatus(e)).ahead}catch{return null}}function b9(){v9=!0;let e=_9.get(),t={...e.rows};for(let[e,n]of Object.entries(t))n.s===`waiting`&&(t[e]={s:`skipped`,text:`Stopped before it ran.`});_9.set({...e,rows:t})}async function QPe(e,t){if(_9.get().active)return;let n=U(),r=h9(t,e);if(r.length===0)return;n.say.track(`action:git.all.${e}`),v9=!1,_9.set({verb:e,active:!0,rows:Object.fromEntries(r.map(e=>[e.id,{s:`waiting`}]))});let i=Promise.resolve(),a=(e,t)=>{i=i.then(()=>v9?void 0:XPe(e,t))};if(e===`push`)for(let e of r)a(e.id);else{let t=[...r];await Promise.all(Array.from({length:Math.min(KPe,r.length)},async()=>{for(let n=t.shift();n&&!v9;n=t.shift()){if(!await JPe(n.id)||e===`pull`)continue;let t=await ZPe(n.id),r=_9.get().rows[n.id],i=r?.s===`ok`?r.text:void 0;t&&t>0&&(y9(n.id,{s:`waiting`}),a(n.id,i))}}))}await i,v9&&b9();let o=_9.get();_9.set({...o,active:!1}),n.world.refreshRepos(),n.say.toast(WPe(Object.values(o.rows)))}var $Pe=16;function eFe(e){let t=Math.max(0,Math.floor(e/1e3));return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}function tFe(e,t){switch(e.s){case`waiting`:return`waiting`;case`pulling`:return`pulling…`;case`pushing`:return`pushing… ${eFe(t-e.startedAt)} — pre-push checks first`;default:return e.text}}function nFe(){let e=U(),{visibleRepos:t}=e.world,n=G(_9),r=Ww(1e3),i=t.filter(m9),a=h9(i,`push`).length,o=()=>e.nav.close(`reposync`),s=e=>{QPe(e,t)};return(0,J.jsx)(Hw,{title:`Sync repos`,icon:(0,J.jsx)(as,{size:$Pe}),onClose:o,children:(0,J.jsxs)(`div`,{className:`sheet-scroll`,children:[(0,J.jsx)(Z,{children:GPe(i.length,a)}),g9(t.length-i.length)&&(0,J.jsx)(Z,{children:g9(t.length-i.length)}),i.length>0&&(0,J.jsx)(`div`,{className:`sheet-actions`,children:n.active?(0,J.jsxs)(Y,{onClick:b9,title:`let what is running finish, drop what is still waiting`,children:[(0,J.jsx)(ic,{size:14}),` Stop`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(Y,{onClick:()=>s(`pull`),children:[(0,J.jsx)(Xo,{size:14}),` Pull all`]}),a>0&&(0,J.jsxs)(Y,{onClick:()=>s(`push`),children:[(0,J.jsx)(ho,{size:14}),` Push `,a]}),(0,J.jsxs)(Y,{onClick:()=>s(`sync`),title:`pull each, then push whatever is still ahead`,children:[(0,J.jsx)(as,{size:14}),` Sync all`]})]})}),i.map(t=>{let i=n.rows[t.id],a=p9(t),o=i&&(i.s===`pulling`||i.s===`pushing`);return(0,J.jsxs)(Xw,{as:`button`,kind:`grow`,onClick:()=>e.nav.openGit(t.id),title:`open this repo's git view`,children:[(0,J.jsxs)(Zw,{children:[o&&(0,J.jsx)($s,{size:12,className:`spin`}),` `,t.repoName,t.isPrimary?``:` · ${t.branch}`,a&&(0,J.jsxs)(`span`,{className:`git-ab`,children:[` `,a]})]}),i&&(0,J.jsx)(Q,{className:i.s===`failed`?`warn`:``,children:tFe(i,r)})]},t.id)})]})})}var rFe={id:`repoSync`,sheets:[{id:`reposync`,persisted:!1,render:()=>(0,V.createElement)(nFe)}]},x9=Object.assign({"../../../extensions/desktop/web/index.ts":Jge,"../../../extensions/ocr/web/index.ts":w_e,"../../../extensions/requirements/web/index.ts":U_e,"../../../extensions/token-stats/web/index.ts":ibe}),iFe=[gse,hbe,Nbe,Joe,kme,Wue,qbe,lxe,BY,ole,kxe,Rxe,Yxe,rSe,hSe,gwe,MTe,aEe,lEe,Ple,NM,TR,Ez,gEe,EAe,fje,xMe,VMe,Fz,FG,tNe,vNe,ONe,dse,lJ,WNe,xPe,zPe,eX,VPe,Fme,rFe,...Object.keys(x9).sort().map(e=>x9[e].manifest)];function aFe({cwd:e,backend:t,backends:n=null,onPick:r,unsupported:i,onClose:a}){let[o,s]=(0,V.useState)(``),c=t?`${e}\n${t}`:e,l=gh(c,()=>H.slash(e,t),{enabled:!i,fromCache:async()=>{let e=Xb(c);return e?{value:{commands:e.value},savedAt:e.savedAt}:null},toCache:e=>{e.why||Zb(c,e.commands)}}),u=t?EC(n,t)?.label??`this backend`:null,d=l.data?.commands??[],f=(0,V.useMemo)(()=>d.filter(e=>e.name.toLowerCase().includes(o.toLowerCase())||(e.description??``).toLowerCase().includes(o.toLowerCase())),[d,o]);return i?(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:`Slash commands`,onClose:a}),(0,J.jsx)(Qw,{cants:[{label:`slash commands`,reason:i}]})]}):(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsxs)(Uw,{title:`Slash commands`,onClose:a,children:[l.state===`loading`&&(0,J.jsxs)(`span`,{className:`gallery-meta`,children:[(0,J.jsx)(Js,{size:12,className:`spin`}),` loading…`]}),l.state===`cached`&&l.age!=null&&(0,J.jsxs)(`span`,{className:`gallery-meta`,children:[(0,J.jsx)(fo,{size:12}),` cached · `,kp(l.age)]}),l.state===`offline`&&(0,J.jsxs)(`span`,{className:`gallery-meta`,children:[(0,J.jsx)(fo,{size:12}),` offline`]}),l.state===`error`&&(0,J.jsxs)(`span`,{className:`gallery-meta`,children:[(0,J.jsx)(xs,{size:12}),` host refused`]})]}),!t&&(0,J.jsx)(`div`,{className:`btw-row`,children:(0,J.jsx)(`button`,{className:`btw`,onClick:()=>r(`/btw `,!1),children:`/btw — queue a note without interrupting`})}),(0,J.jsx)(`input`,{className:`search`,placeholder:`Filter…`,value:o,onChange:e=>s(e.target.value),autoFocus:!0}),(0,J.jsxs)(`div`,{className:`list`,children:[f.map(e=>(0,J.jsxs)(`div`,{className:`cmd-row`,children:[(0,J.jsxs)(`button`,{className:`cmd-name`,onClick:()=>r(e.name+` `,!1),children:[(0,J.jsx)(`span`,{className:`mono`,children:e.name}),!t&&(0,J.jsx)(`span`,{className:`src src-${e.source}`,children:e.source})]}),e.description&&(0,J.jsx)(`span`,{className:`cmd-desc`,children:e.description}),(0,J.jsx)(`button`,{className:`run`,onClick:()=>r(e.name,!0),children:`run`})]},e.name)),t&&d.length===0&&l.data?.why?(0,J.jsx)(Qw,{cants:[{label:`slash commands`,reason:l.data.why}]}):(0,J.jsx)($,{res:l,empty:f.length===0,thing:u?`${u}’s commands`:`this repo’s commands`,noun:`palette`,note:`You can still type any command.`,children:`No matches.`})]})]})}function S9(e){return dD(e)||fD(e)||mD(e)}function C9(e,t){return e===`old`?t?`before · last commit`:`before · last commit or staged`:t?`after · staged`:`after · working tree`}function w9({repoId:e,path:t,side:n,staged:r}){let[i,a]=(0,V.useState)({state:`loading`,got:0,total:0}),[o,s]=(0,V.useState)(0);(0,V.useEffect)(()=>{let i=null,o=!0;return a({state:`loading`,got:0,total:0}),H.gitBlob(e,t,n,r,(e,t)=>{o&&a({state:`loading`,got:e,total:t})}).then(e=>{if(o){if(!e)return a({state:`absent`});i=URL.createObjectURL(e),a({state:`ok`,url:i,size:e.size})}},e=>{o&&a({state:`error`,reason:e instanceof Error?e.message:String(e)})}),()=>{o=!1,i&&URL.revokeObjectURL(i)}},[e,t,n,r,o]);let c;return c=i.state===`loading`?(0,J.jsxs)(`div`,{className:`gm-note`,children:[`loading… `,i.got>0&&(i.total?`${un(i.got)} of ${un(i.total)}`:un(i.got))]}):i.state===`absent`?(0,J.jsx)(`div`,{className:`gm-note`,children:n===`old`?`no file here — it is new`:`no file here — it was deleted`}):i.state===`error`?(0,J.jsxs)(`div`,{className:`gm-note`,children:[`could not load this side: `,i.reason,` `,(0,J.jsxs)(Y,{onClick:()=>s(e=>e+1),children:[(0,J.jsx)(xc,{size:14}),` Retry`]})]}):fD(t)?(0,J.jsx)(`video`,{src:i.url,controls:!0,loop:!0,muted:!0,playsInline:!0}):mD(t)?(0,J.jsx)(`audio`,{src:i.url,controls:!0}):(0,J.jsx)(`img`,{src:i.url,alt:C9(n,r)}),(0,J.jsxs)(`figure`,{className:`gm-side`,children:[(0,J.jsxs)(`figcaption`,{children:[C9(n,r),i.state===`ok`&&(0,J.jsxs)(`span`,{className:`gm-size`,children:[` · `,un(i.size)]})]}),c]})}function oFe({repoId:e,path:t,staged:n}){return(0,J.jsxs)(`div`,{className:`gm-diff`,children:[(0,J.jsx)(w9,{repoId:e,path:t,side:`old`,staged:n}),(0,J.jsx)(w9,{repoId:e,path:t,side:`new`,staged:n})]})}var sFe=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/;function cFe(e){let t=[],n=0,r=0,i=!1,a=[],o=[],s=()=>{for(let e=0;e<Math.max(a.length,o.length);e++)t.push({kind:`line`,left:a[e]??null,right:o[e]??null});a=[],o=[]};for(let c of e.split(`
194
+ `)){let e=sFe.exec(c);if(e){s(),n=Number(e[1]),r=Number(e[2]),i=!0,t.push({kind:`hunk`,text:c});continue}if(c.startsWith(`diff --git`)){s(),i=!1;continue}if(!i){c&&!/^(index |--- |\+\+\+ |(new|deleted) file mode |old mode |new mode |similarity |rename )/.test(c)&&t.push({kind:`note`,text:c});continue}if(c.startsWith(`-`)){a.push({n:n++,text:c.slice(1),kind:`del`});continue}if(c.startsWith(`+`)){o.push({n:r++,text:c.slice(1),kind:`add`});continue}if(c.startsWith(`\\`)||(s(),c===``))continue;let l=c.slice(1);t.push({kind:`line`,left:{n:n++,text:l,kind:`ctx`},right:{n:r++,text:l,kind:`ctx`}})}return s(),t}var lFe=[{id:`diff`,label:`changes`},{id:`split`,label:`side by side`},{id:`old`,label:`before`},{id:`new`,label:`after`}],uFe=`(min-width: 900px)`;function dFe(){try{return window.matchMedia(uFe).matches?`split`:`diff`}catch{return`diff`}}function fFe(e){return e.startsWith(`+++`)||e.startsWith(`---`)?`d-meta`:e.startsWith(`@@`)?`d-hunk`:e.startsWith(`+`)?`d-add`:e.startsWith(`-`)?`d-del`:``}function pFe({repoId:e,path:t,side:n,staged:r,zoomFont:i}){let[a,o]=(0,V.useState)({state:`loading`});(0,V.useEffect)(()=>{let i=!0;return o({state:`loading`}),H.gitText(e,t,n,r).then(e=>{i&&o(e?{state:`ok`,...e}:{state:`absent`})},e=>{i&&o({state:`error`,reason:e instanceof Error?e.message:String(e)})}),()=>{i=!1}},[e,t,n,r]);let s;if(a.state===`loading`)s=(0,J.jsx)(`div`,{className:`gm-note`,children:`loading…`});else if(a.state===`absent`)s=(0,J.jsx)(`div`,{className:`gm-note`,children:n===`old`?`no file here — it is new`:`no file here — it was deleted`});else if(a.state===`error`)s=(0,J.jsxs)(`div`,{className:`gm-note`,children:[`could not load this side: `,a.reason]});else{let e=a.body.endsWith(`
195
+ `)?a.body.slice(0,-1).split(`
196
+ `):a.body.split(`
197
+ `);s=(0,J.jsxs)(`div`,{className:`dw-lines`,children:[e.map((e,t)=>(0,J.jsxs)(V.Fragment,{children:[(0,J.jsx)(`span`,{className:`dw-n`,children:t+1}),(0,J.jsx)(`span`,{className:`dw-t`,children:e||` `})]},t)),a.truncated&&(0,J.jsx)(`span`,{className:`dw-t gm-note`,children:`… cut here: the file is longer than the phone is sent`})]})}return(0,J.jsxs)(`div`,{className:`diff dw`,style:i,children:[(0,J.jsx)(`div`,{className:`dw-cap`,children:C9(n,r)}),s]})}function T9({c:e}){if(!e)return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`ds-n`}),(0,J.jsx)(`span`,{className:`ds-t ds-empty`})]});let t=e.kind===`add`?`d-add`:e.kind===`del`?`d-del`:``;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`ds-n ${t}`,children:e.n}),(0,J.jsx)(`span`,{className:`ds-t ${t}`,children:e.text||` `})]})}function mFe({repoId:e,path:t,staged:n,diff:r,zoomFont:i}){let[a,o]=(0,V.useState)(dFe),s;return s=a===`old`||a===`new`?(0,J.jsx)(pFe,{repoId:e,path:t,side:a,staged:n,zoomFont:i}):a===`split`?(0,J.jsx)(`div`,{className:`diff ds`,style:i,children:(0,J.jsxs)(`div`,{className:`ds-grid`,children:[(0,J.jsx)(`span`,{className:`ds-cap`,children:C9(`old`,n)}),(0,J.jsx)(`span`,{className:`ds-cap`,children:C9(`new`,n)}),cFe(r).map((e,t)=>e.kind===`line`?(0,J.jsxs)(V.Fragment,{children:[(0,J.jsx)(T9,{c:e.left}),(0,J.jsx)(T9,{c:e.right})]},t):(0,J.jsx)(`span`,{className:`ds-wide ${e.kind===`hunk`?`d-hunk`:`d-meta`}`,children:e.text},t))]})}):(0,J.jsx)(`pre`,{className:`diff`,style:i,children:r.split(`
198
+ `).map((e,t)=>(0,J.jsx)(`div`,{className:fFe(e),children:e||` `},t))}),(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`ts-filter`,children:lFe.map(e=>(0,J.jsx)(Y,{className:a===e.id?`active`:``,onClick:()=>{q(`action:git.view.${e.id}`),o(e.id)},children:e.label},e.id))}),s]})}var hFe=(e,t)=>`${e} ${t}${e===1?``:`s`}`;function gFe({repoId:e,c:t}){let[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(!1);function o(){q(`action:git.log.show`),a(e=>!e),n??H.gitShow(e,t.sha).then(r,e=>r(`Could not read this commit: ${e instanceof Error?e.message:String(e)}`))}return(0,J.jsxs)(`div`,{className:`git-commit`,children:[(0,J.jsxs)(`button`,{className:`row git-commit-row`,onClick:o,children:[(0,J.jsx)(`span`,{className:`git-commit-subject`,children:t.subject||`(no message)`}),(0,J.jsxs)(Q,{children:[(0,J.jsx)(`span`,{className:`mono`,children:t.short}),` · `,t.author,` · `,Tp(t.at)]})]}),i&&(0,J.jsx)(`pre`,{className:`git-commit-body`,children:n??`reading…`})]})}function E9({repoId:e,title:t,hint:n,rows:r,total:i,none:a}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`section`,children:[t,` · `,i,` `,(0,J.jsxs)(`span`,{className:`section-hint`,children:[`— `,n]})]}),r.length===0&&(0,J.jsx)(`div`,{className:`empty`,children:a}),r.map(t=>(0,J.jsx)(gFe,{repoId:e,c:t},t.sha)),i>r.length&&(0,J.jsxs)(`div`,{className:`empty`,children:[`…and `,hFe(i-r.length,`older commit`),` not drawn here.`]})]})}function _Fe({repoId:e,focus:t,onFocus:n,onFetched:r,onClose:i}){let a=gh(`gitlog:${e}`,()=>H.gitLog(e)),o=a.data,[s,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(null),d=(0,V.useRef)(!1);async function f(){if(!d.current){d.current=!0,c(!0),u(null);try{let t=await H.gitFetch(e);t.ok||u(t.error??`The fetch failed.`)}catch(e){u(`Could not reach the desktop to fetch: ${e instanceof Error?e.message:String(e)}`)}finally{d.current=!1,c(!1),a.reload({quiet:!0}),r()}}}(0,V.useEffect)(()=>{f()},[e]);let p=o?.upstream??`the upstream`,m=s?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)($s,{size:13,className:`spin`}),` checking `,p,` for new commits…`]}):o?.fetchedAt?(0,J.jsxs)(J.Fragment,{children:[`Incoming as of the last check of `,p,`, `,Tp(o.fetchedAt),`.`]}):o?.upstream?(0,J.jsxs)(J.Fragment,{children:[p,` has never been checked from this worktree.`]}):null,h=o?o.incomingTotal+o.outgoingTotal+o.shared.length:0,g=o?t===`in`?o.incomingTotal:t===`out`?o.outgoingTotal:h:0,_=t!==`out`,v=t!==`in`,y=t===`all`;return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:(0,J.jsxs)(J.Fragment,{children:[`History · `,o?.branch??`…`]}),onClose:i,children:o?.upstream&&(0,J.jsxs)(Y,{onClick:()=>{q(`action:git.log.fetch`),f()},title:`fetch ${o.upstream} — moves no branch and no file`,children:[s?(0,J.jsx)($s,{size:16,className:`spin`}):(0,J.jsx)(Qo,{size:16}),` `,s?`checking…`:`check`]})}),o&&(0,J.jsxs)(`div`,{className:`git-bar`,children:[(0,J.jsxs)(`span`,{className:`mono`,children:[o.branch,o.upstream?` → ${o.upstream}`:` (no upstream)`]}),o.upstream&&(0,J.jsxs)(`span`,{className:`git-ab`,children:[`↑`,o.outgoingTotal,` ↓`,o.incomingTotal]})]}),t!==`all`&&o&&(0,J.jsxs)(`div`,{className:`section filter-bar`,children:[(0,J.jsxs)(`span`,{className:`filter-bar-txt`,children:[`Only the commits `,t===`in`?`on ${p} and not here`:`here and not on ${p}`,` · `,g,` of `,h]}),(0,J.jsxs)(`button`,{className:`filter-bar-clear`,title:`show incoming, not pushed and the shared history together`,onClick:()=>{q(`action:git.log.filter.clear`),n(`all`)},children:[(0,J.jsx)(B,{size:13}),` clear`]})]}),(0,J.jsxs)(`div`,{className:`list git-log`,children:[(0,J.jsx)($,{res:a,empty:!o,thing:`this branch's history`,noun:`history`}),m&&(0,J.jsx)(Z,{className:`git-log-fresh`,children:m}),l&&(0,J.jsx)(Z,{className:`git-note`,children:l}),o&&o.upstream&&_&&(0,J.jsx)(E9,{repoId:e,title:`Incoming`,hint:`on ${p}, not here — a pull brings these`,rows:o.incoming,total:o.incomingTotal,none:s?`Checking…`:`Nothing on ${p} that is not here.`}),o&&o.upstream&&v&&(0,J.jsx)(E9,{repoId:e,title:`Not pushed`,hint:`here, not on ${p} — a push sends these`,rows:o.outgoing,total:o.outgoingTotal,none:`Every commit here is already pushed.`}),o&&y&&(0,J.jsx)(E9,{repoId:e,title:o.upstream?`On both`:`History`,hint:o.upstream?`recent, already pushed`:`no upstream — nothing to compare against`,rows:o.shared,total:o.shared.length,none:`No commits yet.`})]})]})}function D9(e){let t=e.code.trim();return t===`??`?`new`:t.includes(`D`)?`deleted`:t.startsWith(`R`)?`renamed`:t.includes(`A`)?`added`:`modified`}function O9(e){let t=Math.max(0,Math.floor(e/1e3));return`${Math.floor(t/60)}:${String(t%60).padStart(2,`0`)}`}var vFe=3e3,yFe=18e5;function k9(e){return O9(e.result.finishedAt-e.startedAt)}function A9(e){let t=e.result,n=k9(e);return t.ok?`Pushed in ${n}: ${t.output?.split(`
199
+ `).slice(-1)[0]??`ok`}`:`Push failed after ${n}. ${t.error}`}function bFe({p:e,fill:t}){let n=(0,V.useRef)(null),r=(0,V.useRef)(!0);(0,V.useLayoutEffect)(()=>{let e=n.current;e&&r.current&&(e.scrollTop=e.scrollHeight)},[e]);let i=()=>{let e=n.current;e&&(r.current=e.scrollHeight-e.scrollTop-e.clientHeight<24)},a=e=>e.state===`running`?(0,J.jsx)($s,{size:14,className:`spin`}):e.state===`ok`?(0,J.jsx)(vc,{size:14}):e.state===`failed`?(0,J.jsx)(B,{size:14}):(0,J.jsx)(ls,{size:14});return(0,J.jsxs)(`div`,{ref:n,onScroll:i,className:`git-push-progress${t?` fill`:``}`,children:[e.steps.map((t,n)=>(0,J.jsxs)(`div`,{className:`git-push-step ${t.state}`,children:[a(t),(0,J.jsx)(`span`,{children:t.name}),(0,J.jsx)(`span`,{className:`git-push-step-aside`,children:t.state===`ok`&&t.secs!=null?`${O9(t.secs*1e3)}`:t.state===`skipped`?`skipped${t.why?` — ${t.why}`:``}`:t.state===`failed`?`failed`:t.state===`running`&&e.e2e&&n===e.steps.length-1?`${e.e2e.done} of ${e.e2e.total} scripts${e.e2e.failed?` · ${e.e2e.failed} failed`:``}`:``})]},n)),e.tail.length>0&&(0,J.jsx)(`pre`,{className:`git-push-tail`,children:e.tail.join(`
200
+ `)})]})}function xFe({repoId:e,onAskAgent:t,onBrowse:n,onClose:r}){let[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)(``),[c,l]=(0,V.useState)(``),[u,d]=(0,V.useState)(!1),[f,p]=(0,V.useState)(null),[m,h]=(0,V.useState)(null);function g(e,t){p(e),h({note:e,f:t})}function _(e){return{...e,branch:se?.branch??`the current branch`,upstream:se?.upstream,ahead:e.verb===`push`?se?.ahead:void 0}}function v(e,t){t.result&&!t.result.ok&&t.result.error?g(e,{verb:`push`,took:k9(t),error:t.result.error}):p(e)}let[y,b]=(0,V.useState)(null),[x,S]=(0,V.useState)(null),[,C]=(0,V.useState)(0);(0,V.useEffect)(()=>{if(y==null)return;let e=setInterval(()=>C(e=>e+1),1e3);return()=>clearInterval(e)},[y]);let[w,T]=(0,V.useState)(!1),[E,D]=(0,V.useState)(!1),[O,k]=(0,V.useState)(null),[A,j]=(0,V.useState)(null),[M,N]=(0,V.useState)(!1),[P,F]=(0,V.useState)(``),[ee,te]=(0,V.useState)(()=>Jne()),ne=Nu(),re={"--ui-font":String(ju(ne,ee))};function ie(e){q(`action:uiscale.git`),te(e),ere(e)}let ae=(0,J.jsx)(`div`,{className:`sb-zoom`,children:(0,J.jsx)(s2,{smaller:Mu(ee,-1,ne),bigger:Mu(ee,1,ne),onZoom:ie,smallerHint:` — more of each path and diff line on screen`,biggerHint:` — fewer characters across`})}),oe=gh(e,()=>H.gitStatus(e)),se=oe.data,ce=gh(`${e}:${E}`,()=>H.gitBranches(e),{enabled:E}),le=ce.data,ue=()=>oe.reload({quiet:!0}),de=()=>ce.reload({quiet:!0});(0,V.useEffect)(()=>{i&&!S9(i.path)&&(s(`loading…`),H.gitDiff(e,i.path,i.staged).then(e=>s(e||`(no textual diff)`)))},[i,e]);async function fe(t){q(`action:git.stage`),await H.gitStage(e,t.path,t.staged),ue()}async function pe(){if(M)return;q(`action:git.message`),N(!0),p(null),j(null);let t=await H.gitMessage(e);N(!1),t.message?c.trim()?j(t.message):l(t.message):p(t.reason??`No message came back.`)}async function me(){q(`action:git.commit`),d(!0),p(null);let t=await H.gitCommit(e,c,!0);d(!1),p(t.ok?`Committed: ${t.output?.split(`
201
+ `)[0]??`ok`}`:`Error: ${t.error}`),t.ok&&(l(``),ue())}async function he(t=se?.ahead??0,n=``){if(y==null){q(`action:git.push`);try{let r=await H.gitPush(e);b(r.startedAt),p(`${n}Pushing${t?` ${t} commit${t>1?`s`:``}`:``}. The desktop runs this repo's pre-push checks first (build, lint, tests) — that can take many minutes. You can leave this screen; the push carries on, and reopening it picks the clock back up.`)}catch(e){p(`${n}The push did not start: ${e.message}`)}}}async function ge(){if(w||y!=null)return null;T(!0),p(null);try{let t=await H.gitPull(e);return t.ok?p(t.output??`Pulled.`):t.error?g(t.error,{verb:`pull`,error:t.error}):p(`The pull failed.`),t.ok?t.output??`Pulled.`:null}catch(e){return p(`The pull did not run: ${e.message}`),null}finally{T(!1),ue()}}async function _e(){if(w||y!=null)return;q(`action:git.sync`);let t=await ge();if(t==null)return;let n=0;try{n=(await H.gitStatus(e)).ahead}catch{}n>0&&await he(n,`${t} `)}(0,V.useEffect)(()=>{let t=!1;return H.gitPushState(e).then(e=>{!t&&e&&(e.running?(b(e.startedAt),S(e.progress??null),p(e=>e??`A push is running on the desktop — its pre-push checks first, then the push itself.`)):e.result&&Date.now()-e.result.finishedAt<yFe&&p(t=>{if(t)return t;let n=`Last push, ${O9(Date.now()-e.result.finishedAt)} ago — ${A9(e)}`;return!e.result.ok&&e.result.error&&h({note:n,f:{verb:`push`,took:k9(e),error:e.result.error}}),n}))}).catch(()=>{}),()=>{t=!0}},[e]),(0,V.useEffect)(()=>{if(y==null)return;let t=!1,n=setInterval(async()=>{let n;try{n=await H.gitPushState(e)}catch{return}t||(!n||n.startedAt!==y?(b(null),S(null),p(`The desktop no longer knows this push — it restarted while the push ran. The counts above say whether the commits went.`),ue()):n.running?S(n.progress??null):(b(null),S(null),v(A9(n),n),ue()))},vFe);return()=>{t=!0,clearInterval(n)}},[y,e]);function ve(){D(e=>!e)}async function ye(e,t){q(`action:git.branch`),d(!0),p(null);let n=await t();return d(!1),p(n.ok?`${e}${n.output?`: ${n.output.split(`
202
+ `).slice(-1)[0]}`:``}`:`Error: ${n.error}`),n.ok&&(ue(),de()),n}async function be(t){t.current||t.inUseElsewhere||await ye(`Switched to ${t.name}`,()=>H.gitCheckout(e,t.name))}async function xe(){let t=P.trim();t&&(await ye(`Created ${t}`,()=>H.gitCreateBranch(e,t))).ok&&F(``)}async function Se(t){if(t.current)return;let n=await H.gitDeleteBranch(e,t.name);if(!n.ok&&/not fully merged/i.test(n.error??``)){if(!await gC({title:`Force-delete ${t.name}?`,lines:[`"${t.name}" is not fully merged.`,`Its commits are on no other branch and will be lost.`],confirmLabel:`Delete and lose the commits`})){p(`Kept ${t.name} — it is not fully merged`);return}n=await H.gitDeleteBranch(e,t.name,!0)}p(n.ok?`Deleted ${t.name}`:`Error: ${n.error}`),n.ok&&(ue(),de())}if(Gh(i!==null,()=>a(null)),Gh(O!==null,()=>k(null)),O)return(0,J.jsx)(_Fe,{repoId:e,focus:O,onFocus:k,onFetched:ue,onClose:()=>k(null)});if(i)return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsx)(Uw,{title:i.path,brandClass:`mono`,onClose:()=>a(null),children:ae}),S9(i.path)?(0,J.jsx)(oFe,{repoId:e,path:i.path,staged:i.staged}):(0,J.jsx)(mFe,{repoId:e,path:i.path,staged:i.staged,diff:o,zoomFont:re})]});let Ce=y==null?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ho,{size:14}),` `,se&&se.ahead>0?`Push ${se.ahead}`:`Push`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)($s,{size:14,className:`spin`}),` pushing… `,O9(Date.now()-y)]}),we=w?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)($s,{size:14,className:`spin`}),` pulling…`]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Xo,{size:14}),` `,se&&se.behind>0?`Pull ${se.behind}`:`Pull`]}),Te=(0,J.jsxs)(`div`,{className:`sheet-actions`,children:[(0,J.jsx)(Y,{onClick:()=>{q(`action:git.pull`),ge()},disabled:u,children:we}),(0,J.jsx)(Y,{onClick:()=>{he()},disabled:u,children:Ce}),(0,J.jsxs)(Y,{onClick:()=>{_e()},disabled:u,title:`pull, then push whatever is still ahead`,children:[(0,J.jsx)(as,{size:14}),` Sync`]})]});return(0,J.jsxs)(`div`,{className:`sheet`,children:[(0,J.jsxs)(Uw,{title:(0,J.jsxs)(J.Fragment,{children:[`Review · `,se?.branch??`…`]}),onClose:r,children:[n&&(0,J.jsx)(Y,{title:`browse files`,onClick:()=>{q(`action:git.browse`),n()},children:(0,J.jsx)(Xc,{size:16})}),(0,J.jsx)(Y,{title:`history — incoming, not pushed, and what both have`,onClick:()=>{q(`action:git.log`),k(`all`)},children:(0,J.jsx)(Xs,{size:16})}),(0,J.jsx)(Y,{className:E?`active`:``,title:`branches`,onClick:ve,children:(0,J.jsx)(ds,{size:16})}),(0,J.jsx)(Y,{onClick:ue,children:(0,J.jsx)(xc,{size:16})})]}),se&&(0,J.jsxs)(`div`,{className:`git-bar`,children:[(0,J.jsxs)(`span`,{className:`mono`,children:[se.branch,se.upstream?` → ${se.upstream}`:` (no upstream)`]}),se.upstream&&(0,J.jsxs)(`span`,{className:`git-ab`,children:[(0,J.jsxs)(`button`,{className:`git-ab-n`,onClick:()=>{q(`action:git.log.out`),k(`out`)},title:`the commits here that are not pushed`,children:[`↑`,se.ahead]}),(0,J.jsxs)(`button`,{className:`git-ab-n`,onClick:()=>{q(`action:git.log.in`),k(`in`)},title:`the commits on the upstream that are not here — opening checks it`,children:[`↓`,se.behind]})]}),!se.clean&&ae]}),E&&(0,J.jsxs)(`div`,{className:`git-branches`,children:[(0,J.jsxs)(`div`,{className:`form`,children:[(0,J.jsx)(`input`,{className:`search`,placeholder:`New branch name…`,value:P,onChange:e=>F(e.target.value),onKeyDown:e=>{e.key===`Enter`&&xe()}}),(0,J.jsxs)(`button`,{className:`send`,onClick:xe,disabled:u||!P.trim(),children:[(0,J.jsx)(Fo,{size:16}),` Create & switch`]})]}),(0,J.jsxs)(`div`,{className:`list`,children:[(0,J.jsx)($,{res:ce,empty:!le?.length,thing:`branches`,noun:`branch list`,children:`No local branches.`}),le?.map(e=>(0,J.jsxs)(Xw,{kind:`wrap`,children:[(0,J.jsxs)(Xw,{as:e.current||e.inUseElsewhere?`div`:`button`,kind:`grow`,onClick:e.current||e.inUseElsewhere?void 0:()=>be(e),title:e.current||e.inUseElsewhere?void 0:`switch to this branch`,children:[(0,J.jsx)(`span`,{className:`gstat ${e.current?`g-added`:``}`,children:e.current?`●`:`○`}),(0,J.jsxs)(Zw,{className:`mono`,children:[e.name,e.upstream?` → ${e.upstream}`:``,e.inUseElsewhere?` (checked out in another worktree)`:e.current?` (current)`:``]})]}),!e.current&&(0,J.jsx)(fC,{className:`row-act`,title:`delete branch ${e.name}`,confirmTitle:`tap again to delete ${e.name}`,confirm:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(ws,{size:16}),` sure?`]}),onConfirm:()=>{Se(e)},children:(0,J.jsx)(ws,{size:16})})]},e.name))]})]}),(0,J.jsxs)(`div`,{className:`list git-files`,style:re,children:[(0,J.jsx)($,{res:oe,empty:!se||!!se.clean,thing:`the working tree`,noun:`status`,offlineNote:`Nothing here can be staged or committed until the link is back.`,children:`Working tree clean.`}),se?.files.map(e=>(0,J.jsxs)(Xw,{kind:`wrap`,children:[(0,J.jsxs)(Xw,{as:`button`,kind:`grow`,onClick:()=>{q(`action:git.diff`),a(e)},children:[(0,J.jsx)(`span`,{className:`gstat g-${D9(e)}`,children:D9(e)}),(0,J.jsx)(Zw,{className:`mono`,children:e.from?`${e.from} → ${e.path}`:e.path})]}),(0,J.jsx)(`button`,{className:`row-act ${e.staged?`on`:``}`,title:e.staged?`unstage`:`stage`,onClick:()=>fe(e),children:e.staged?(0,J.jsx)(vc,{size:16}):(0,J.jsx)(Fo,{size:16})})]},e.path+e.code))]}),!se?.clean&&(0,J.jsxs)(`div`,{className:`form`,children:[A&&(0,J.jsxs)(`div`,{className:`git-draft`,children:[(0,J.jsx)(Z,{children:`A message was drafted, and your own words are still in the box:`}),(0,J.jsx)(`pre`,{className:`git-draft-msg`,children:A}),(0,J.jsxs)(`div`,{className:`sheet-actions`,children:[(0,J.jsx)(Y,{onClick:()=>{l(A),j(null)},children:`Use this one`}),(0,J.jsx)(Y,{onClick:()=>j(null),children:`Keep mine`})]})]}),(0,J.jsx)(`textarea`,{className:`search`,rows:2,placeholder:`Commit message…`,value:c,onChange:e=>l(e.target.value)}),(0,J.jsxs)(`div`,{className:`sheet-actions`,children:[(0,J.jsx)(`button`,{className:`send`,onClick:me,disabled:u||!c.trim(),children:`Commit all`}),(0,J.jsxs)(Y,{onClick:pe,title:`draft the commit message from this diff — one cheap call on the desktop`,children:[(0,J.jsx)(xl,{size:16}),` `,M?`writing…`:`message`]})]})]}),se&&Te,m&&m.note===f&&(0,J.jsxs)(`div`,{className:`sheet-actions`,children:[t&&(0,J.jsxs)(Y,{onClick:()=>{q(`action:git.askAgent`),t(_(m.f))},title:`open the Send sheet with this log and its context, aimed at a new session in this repo — nothing is sent yet`,children:[(0,J.jsx)(Do,{size:16}),` `,`fix in a new session…`]}),(0,J.jsxs)(Y,{onClick:async()=>{q(`action:git.copyFailure`),K(await Xf(WJ(_(m.f)))?`Copied: the log, with the branch, upstream and how long it ran.`:`Couldn't reach the clipboard. Select the log below instead.`)},title:`copy the same words to the clipboard: the log, with the branch, upstream and how long it ran`,children:[(0,J.jsx)(_o,{size:16}),` `,`copy`]})]}),f&&(0,J.jsx)(Z,{className:`git-note`,children:f}),y!=null&&x&&(0,J.jsx)(bFe,{p:x,fill:!!se?.clean})]})}function SFe(){let[e,t]=(0,V.useState)(null),[n,r]=(0,V.useState)(ov());(0,V.useEffect)(()=>wae(t),[]);let[i,a]=(0,V.useState)(!1);return(0,V.useEffect)(()=>cv(e=>{r(e),!e&&Xv.get(`hintChip`)===``&&a(!0)}),[]),(0,V.useEffect)(()=>{if(!n)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),sv(!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,J.jsxs)(J.Fragment,{children:[n&&(0,J.jsxs)(`div`,{className:`hint-mode-bar`,children:[(0,J.jsx)(cs,{size:14}),(0,J.jsx)(`span`,{children:`Explain mode — tap any button to read what it does. Nothing runs.`}),(0,J.jsxs)(Y,{"data-nohint":!0,onClick:()=>sv(!1),children:[(0,J.jsx)(B,{size:14}),` done`]})]}),i&&!e&&(0,J.jsx)(`div`,{className:`hint-backdrop`,onClick:()=>a(!1),children:(0,J.jsxs)(`div`,{className:`hint-card`,role:`dialog`,"aria-modal":`true`,onClick:e=>e.stopPropagation(),children:[(0,J.jsxs)(`div`,{className:`hint-card-head`,children:[(0,J.jsx)(cs,{size:16}),(0,J.jsx)(`span`,{children:`Keep the ? button?`})]}),(0,J.jsx)(`p`,{className:`hint-card-what`,children:`Now you know what it does. Long-pressing any button explains it too, so the ? can go to give the headers their space back — in the launcher and in every session.`}),(0,J.jsx)(`p`,{className:`hint-card-when`,children:`Settings › Writing & reading brings it back, or resets the whole UI to its defaults.`}),(0,J.jsxs)(`div`,{className:`hint-card-acts`,children:[(0,J.jsx)(Y,{"data-nohint":!0,onClick:()=>{Qv(`hintChip`,`asked`),a(!1)},children:`keep it`}),(0,J.jsx)(`span`,{className:`spacer`}),(0,J.jsxs)(`button`,{className:`send`,"data-nohint":!0,onClick:()=>{q(`action:hints.chipHidden`),Qv(`hintChip`,`hidden`),a(!1),K(`? removed — Settings › Writing & reading brings it back`)},children:[(0,J.jsx)(B,{size:14}),` remove it`]})]})]})}),e&&(0,J.jsx)(`div`,{className:`hint-backdrop`,onClick:()=>fv(!1),children:(0,J.jsxs)(`div`,{className:`hint-card${e.def.danger?` danger`:``}`,role:`dialog`,"aria-modal":`true`,onClick:e=>e.stopPropagation(),children:[(0,J.jsxs)(`div`,{className:`hint-card-head`,children:[e.def.danger?(0,J.jsx)(gs,{size:16}):(0,J.jsx)(oc,{size:16}),(0,J.jsx)(`span`,{children:e.def.title})]}),(0,J.jsx)(`p`,{className:`hint-card-what`,children:e.def.what}),e.def.when&&(0,J.jsx)(`p`,{className:`hint-card-when`,children:e.def.when}),(0,J.jsx)(`div`,{className:`hint-card-acts`,children:e.intercepted?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(Y,{"data-nohint":!0,onClick:()=>fv(!1),children:[(0,J.jsx)(B,{size:14}),` not now`]}),(0,J.jsx)(`span`,{className:`spacer`}),(0,J.jsx)(`button`,{className:`send${e.def.danger?` danger`:``}`,"data-nohint":!0,onClick:()=>{q(`action:hint.proceed`),Tae()},children:`do it`})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`spacer`}),(0,J.jsxs)(`button`,{className:`send`,"data-nohint":!0,onClick:()=>fv(!0),children:[(0,J.jsx)(vc,{size:14}),` got it`]})]})}),(0,J.jsx)(`div`,{className:`hint-card-foot`,children:e.intercepted?`Explained once. The next tap on this button just does it.`:`Long-press any button for this. “Got it” stops it being explained again.`})]})})]})}function CFe({compact:e=!1}){let[t,n]=(0,V.useState)(ov());return(0,V.useEffect)(()=>cv(n),[]),Zv(`hintChip`)===`hidden`?null:(0,J.jsxs)(Y,{className:`hint-toggle${t?` on`:``}`,"data-nohint":!0,"aria-pressed":t,onClick:()=>{t||q(`action:hints.explain`),sv(!t)},children:[(0,J.jsx)(cs,{size:e?14:16}),!e&&(t?` done`:``)]})}var wFe=6048e5,j9=(e,t)=>`${e}|${t}`,M9=e=>e.split(`
203
+ `).filter(Boolean);function TFe(e,t){let n=new Set(M9(e));return M9(t).some(e=>n.has(e))}function EFe(e,t){let n=M9(t),r=`${e}|`;for(let e of Object.keys(B9())){if(!e.startsWith(r))continue;let i=e.slice(r.length);if(!n.length){if(i===t)return i;continue}let a=new Set(M9(i));if(n.every(e=>a.has(e)))return i}return null}function N9(e,t,n=wFe,r=60){let i=Object.entries(e).filter(([,e])=>typeof e==`number`&&t-e<n).sort((e,t)=>t[1]-e[1]).slice(0,r);return Object.fromEntries(i)}var P9=null,F9=new Map,I9=[],L9=0,R9=new Set;function z9(){L9++,I9=[...F9.values()];for(let e of R9)e()}function B9(){return P9||=N9(ma(R.stowed,{}),Date.now()),P9}function V9(e){return R9.add(e),()=>{R9.delete(e)}}var DFe=()=>L9,OFe=()=>I9,kFe=`folded into the line under the session's title — tap its chip there to open it again`;function AFe(e,t){P9=N9({...B9(),[j9(e,t)]:Date.now()},Date.now()),Ta(R.stowed,P9),fa(R.stowTold)||(sa(R.stowTold,!0),K(kFe)),z9()}function H9(e,t){let n={...B9()};delete n[j9(e,t)],P9=n,Ta(R.stowed,P9),z9()}function jFe(e){let t=Symbol(e.slot);return F9.set(t,e),z9(),()=>{F9.delete(t),z9()}}var U9=(0,V.createContext)(null);function W9({slot:e,stowKey:t,label:n,detail:r,icon:i,children:a}){(0,V.useSyncExternalStore)(V9,DFe);let o=EFe(e,t),s=o!=null,c=(0,V.useCallback)(()=>{q(`action:stow.${e}`),AFe(e,t)},[e,t]),l=(0,V.useRef)(null);return(0,V.useEffect)(()=>{if(o!=null){l.current=o;return}let n=l.current;l.current=null,n!=null&&TFe(n,t)&&H9(e,n)},[e,o,t]),(0,V.useEffect)(()=>{if(o!=null)return jFe({slot:e,label:n,detail:r,icon:i,unfold:()=>{q(`action:unstow.${e}`),H9(e,o)}})},[o,e,n,r,i]),s?null:(0,J.jsx)(U9.Provider,{value:c,children:a})}function G9({className:e=`approve-esc`}){let t=(0,V.useContext)(U9);return t?(0,J.jsxs)(`button`,{className:`${e} stow-btn`,onPointerDown:e=>e.preventDefault(),onClick:t,title:`fold this away — it waits as a chip in the line under the session's title`,"aria-label":`fold away`,children:[(0,J.jsx)(Xo,{size:12}),` fold`]}):null}function MFe(){let e=(0,V.useSyncExternalStore)(V9,OFe);return e.length?(0,J.jsx)(J.Fragment,{children:e.map(e=>{let t=e.icon;return(0,J.jsxs)(`button`,{className:`row-sub stow-chip`,onPointerDown:e=>e.preventDefault(),onClick:e.unfold,title:`open ${e.label} again`,children:[(0,J.jsx)(t,{size:11}),` `,e.label,e.detail?(0,J.jsxs)(`span`,{className:`mono`,children:[` · `,e.detail]}):null]},e.slot)})}):null}function NFe({login:e,onOpen:t,onCopy:n,onPasteCode:r}){let[i,a]=(0,V.useState)(!1);return(0,J.jsx)(W9,{slot:`login`,stowKey:`${e.url}\n${e.awaitingCode?`await`:``}`,label:`sign-in link`,icon:Fa,children:(0,J.jsxs)(`div`,{className:`approve login`,children:[(0,J.jsxs)(`div`,{className:`login-head`,children:[(0,J.jsxs)(`span`,{className:`login-title`,children:[(0,J.jsx)(Fa,{size:14}),` sign-in link`]}),(0,J.jsx)(`span`,{className:`login-age`,title:`when the CLI printed this link`,children:Tp(e.at)}),(0,J.jsx)(G9,{})]}),(0,J.jsxs)(`div`,{className:`approve-opts`,children:[(0,J.jsxs)(`button`,{className:`approve-btn primary`,onClick:()=>t(e.url),children:[(0,J.jsx)(Ga,{size:14}),` Open sign-in page`]}),(0,J.jsxs)(`button`,{className:`approve-btn`,onClick:()=>n(e.url),children:[(0,J.jsx)(_o,{size:14}),` copy link`]}),e.awaitingCode&&(0,J.jsxs)(`button`,{className:`approve-btn`,onClick:r,children:[(0,J.jsx)(so,{size:14}),` paste code`]}),(0,J.jsxs)(`button`,{className:`approve-esc`,onClick:()=>a(e=>!e),children:[i?(0,J.jsx)(mc,{size:12}):(0,J.jsx)(Nc,{size:12}),` url`]})]}),e.awaitingCode&&(0,J.jsxs)(`div`,{className:`approve-hint`,children:[`the CLI is waiting for the code — sign in, then `,(0,J.jsx)(`b`,{children:`paste code`}),` (or type it in the compose bar)`]}),i&&(0,J.jsx)(`div`,{className:`login-url mono`,children:e.url})]})})}function PFe(e){return e.source===`browser`?`a program asked to open this`:null}var FFe=`this link points at the desktop's own localhost — it can't be opened from the phone; use the command's no-browser / device flag (see logins)`;function IFe(e){return`copy code ${e}`}function LFe(e){return[...e].sort((e,t)=>t.at-e.at)}function RFe(e,t=44){let n;try{let t=new URL(e);if(t.username||t.password)return zFe;n=`${t.host}${t.pathname===`/`&&!t.search?``:t.pathname}${t.search}`}catch{n=e.replace(/^https?:\/\//i,``)}return n.length>t?`${n.slice(0,t-1)}…`:n}var zFe=`suspicious link (has a user@ part)`,BFe=`Not offered to open: the address has a user@ part, which can make a link look like one site while it goes to another. Copy it only if you know where it leads.`;function VFe(e){try{let t=new URL(e);return!!(t.username||t.password)}catch{return!1}}function HFe(e){return!!e.links?.length||!!e.awaitingCode}function UFe({links:e,awaitingCode:t,onOpen:n,onCopy:r,onCopyCode:i,onPasteCode:a,onLogins:o}){let[s,c]=(0,V.useState)(null),[l,u]=(0,V.useState)(null),d=LFe(e),f=d.length>1?`links from the shell`:`link from the shell`,p=[t?`await`:``,...d.flatMap(e=>[e.url,e.code?`code ${e.code}`:``])].join(`
204
+ `),m=d.find(e=>e.code)?.code;return(0,J.jsx)(W9,{slot:`shell-links`,stowKey:p,label:f,detail:m,icon:Wa,children:(0,J.jsxs)(`div`,{className:`approve login shell-links`,children:[(0,J.jsxs)(`div`,{className:`login-head`,children:[(0,J.jsxs)(`span`,{className:`login-title`,children:[(0,J.jsx)(Wa,{size:14}),` `,f]}),(0,J.jsxs)(`button`,{className:`approve-esc`,onClick:o,children:[(0,J.jsx)(Xa,{size:12}),` logins`]}),(0,J.jsx)(G9,{})]}),d.map(e=>{let t=PFe(e),a=!e.local&&VFe(e.url);return(0,J.jsxs)(`div`,{className:`shell-link`,children:[(0,J.jsxs)(`div`,{className:`approve-hint`,children:[(0,J.jsx)(`span`,{className:`mono`,children:RFe(e.url)}),` · `,(0,J.jsx)(`span`,{title:`when the shell printed this link`,children:Tp(e.at)}),t&&(0,J.jsxs)(J.Fragment,{children:[` · `,t]})]}),e.local?(0,J.jsx)(`div`,{className:`approve-hint`,children:FFe}):(0,J.jsxs)(`div`,{className:`approve-opts`,children:[a?(0,J.jsx)(`div`,{className:`approve-hint`,children:BFe}):(0,J.jsxs)(`button`,{className:`approve-btn primary`,onClick:()=>n(e.url),children:[(0,J.jsx)(Ga,{size:14}),` Open`]}),(0,J.jsxs)(`button`,{className:`approve-btn`,onClick:()=>r(e.url),children:[(0,J.jsx)(_o,{size:14}),` copy link`]}),e.code&&(0,J.jsxs)(`button`,{className:`approve-btn primary shell-code-btn`,onClick:()=>{let t=e.code;i(t).then(e=>u(e?null:t))},children:[(0,J.jsx)(_o,{size:14}),` `,IFe(e.code)]}),(0,J.jsxs)(`button`,{className:`approve-esc`,onClick:()=>c(s===e.url?null:e.url),children:[s===e.url?(0,J.jsx)(mc,{size:12}):(0,J.jsx)(Nc,{size:12}),` url`]})]}),!e.local&&e.code&&l===e.code&&(0,J.jsx)(`div`,{className:`shell-code-big mono`,children:e.code}),s===e.url&&(0,J.jsx)(`div`,{className:`login-url mono`,children:e.url})]},e.url)}),t&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`approve-opts`,children:(0,J.jsxs)(`button`,{className:`approve-btn`,onClick:a,children:[(0,J.jsx)(so,{size:14}),` paste code`]})}),(0,J.jsx)(`div`,{className:`approve-hint`,children:`the program is waiting for a code — sign in, then paste code (or type it in the compose bar)`})]})]})})}function WFe({suggestion:e,onSend:t,onDismiss:n}){let[r,i]=(0,V.useState)(e.reply||``);return(0,J.jsxs)(`div`,{className:`approve reply`,children:[(0,J.jsxs)(`div`,{className:`reply-head`,children:[(0,J.jsxs)(`span`,{className:`reply-title`,children:[(0,J.jsx)(Uo,{size:14}),` `,q0(e),` suggests a reply`]}),(0,J.jsxs)(`span`,{className:`reply-conf`,title:`how sure ${e.byName} says it is`,children:[(e.confidence*100).toFixed(0),`%`]})]}),e.rationale&&(0,J.jsx)(`div`,{className:`reply-why`,children:e.rationale}),(0,J.jsx)(`textarea`,{className:`reply-text`,rows:3,value:r,onChange:e=>i(e.target.value),placeholder:`Suggested reply… (edit before sending)`}),(0,J.jsxs)(`div`,{className:`approve-opts`,children:[(0,J.jsxs)(`button`,{className:`approve-btn primary`,disabled:!r.trim(),onClick:()=>t(r.trim()),children:[(0,J.jsx)(Uo,{size:14}),` Send reply`]}),(0,J.jsx)(`button`,{className:`approve-esc`,onClick:n,children:`dismiss`})]})]})}var K9=84,q9=16;function J9(e,t){t?.stopPropagation();try{window.dispatchEvent(new CustomEvent(`app:open-nethealth`,{detail:{focus:e}}))}catch{}}function GFe({samples:e,ceiling:t}){let n=e.slice(-30),r=K9/29,i=e=>K9-(n.length-1-e)*r,a=e=>q9-Math.min(1,e/t)*15-.5,o=[],s=[];for(let e=0;e<n.length;e++){let t=n[e];t.ms==null?(s.length>1&&o.push(s.join(` `)),s=[]):s.push(`${i(e).toFixed(1)},${a(t.ms).toFixed(1)}`)}s.length>1&&o.push(s.join(` `));let c=n.map((e,t)=>e.ms!=null&&(t===0||n[t-1].ms==null)&&(t===n.length-1||n[t+1].ms==null)?{i:t,ms:e.ms}:null).filter(e=>e!=null);return(0,J.jsxs)(`svg`,{className:`np-spark`,width:K9,height:q9,viewBox:`0 0 ${K9} ${q9}`,"aria-hidden":`true`,children:[n.map((e,t)=>e.ms==null?(0,J.jsx)(`rect`,{x:Math.max(0,i(t)-r/2),y:0,width:Math.max(1.5,r),height:q9,className:`np-miss`},`m${t}`):null),o.map((e,t)=>(0,J.jsx)(`polyline`,{points:e,className:`np-line`},`r${t}`)),c.map(e=>(0,J.jsx)(`circle`,{cx:i(e.i),cy:a(e.ms),r:1.2,className:`np-dot`},`d${e.i}`))]})}function KFe({t:e}){let t=Rd(e.downRate),n=Rd(e.upRate);return(0,J.jsxs)(`span`,{className:`np-traf`,role:`button`,"data-hint":`net.pulse.data`,title:`downloaded ${Ld(e.down)} · uploaded ${Ld(e.up)} since ${new Date(e.since).toLocaleDateString()} — tap for the breakdown`,onClick:e=>J9(`data`,e),children:[(0,J.jsxs)(`span`,{className:`np-tr${t?` live`:``}`,children:[(0,J.jsx)(ts,{size:10,"aria-hidden":`true`}),t?(0,J.jsx)(`span`,{className:`np-rate`,children:t}):null,(0,J.jsx)(`span`,{className:`np-tot`,children:Ld(e.down)})]}),(0,J.jsxs)(`span`,{className:`np-tr${n?` live`:``}`,children:[(0,J.jsx)(to,{size:10,"aria-hidden":`true`}),n?(0,J.jsx)(`span`,{className:`np-rate`,children:n}):null,(0,J.jsx)(`span`,{className:`np-tot`,children:Ld(e.up)})]})]})}function qFe({s:e}){return e.online?e.syncedAt==null?(0,J.jsxs)(`span`,{className:`np-when busy`,role:`button`,"data-hint":`net.pulse.when`,onClick:e=>J9(`currency`,e),title:`waiting for: ${e.pending.join(`, `)} — tap for what is and isn't current`,children:[`syncing `,e.pending.join(`+`),`…`]}):(0,J.jsxs)(`span`,{className:`np-when`,role:`button`,"data-hint":`net.pulse.when`,onClick:e=>J9(`currency`,e),title:`last full sync: ${Zp(e.syncedAt)} (session list + repo listing) — tap for detail`,children:[`synced `,Op(e.syncedAt)]}):(0,J.jsx)(`span`,{className:`np-when stale`,role:`button`,"data-hint":`net.pulse.when`,onClick:e=>J9(`currency`,e),title:`last connected: ${Zp(e.lastSeenAt)} — tap for what is and isn't current`,children:e.lastSeenAt?`last seen ${Op(e.lastSeenAt)}`:`never connected`})}function JFe({n:e}){return e<=0?null:(0,J.jsxs)(`span`,{className:`np-loss`,role:`button`,"data-hint":`net.pulse.sends`,title:`${e} send${e>1?`s`:``} gave up and ${e>1?`have`:`has`} not been dealt with — written here, never typed into a session, so nothing ran. The words are kept. Tap for the list, with the repo each was written for`,onClick:e=>J9(`sends`,e),children:[e,` send`,e>1?`s`:``,` stuck`]})}function YFe({outstanding:e,ever:t,stuck:n}){return e>0?(0,J.jsxs)(`span`,{className:`np-unsaved`,role:`button`,"data-hint":`net.pulse.saved`,title:`${e} thing${e>1?`s`:``} written here that the desktop does not have yet — queued sends and settings still to push. They go as soon as the link allows. Tap for what is outstanding`,onClick:e=>J9(`sends`,e),children:[(0,J.jsx)(rs,{size:10,"aria-hidden":`true`}),` `,e,(0,J.jsx)(`span`,{className:`np-sv-t`,children:`\xA0unsaved`})]}):!t||n>0?null:(0,J.jsxs)(`span`,{className:`np-saved`,role:`button`,"data-hint":`net.pulse.saved`,title:`everything written on this phone has reached the desktop and been stored there — nothing is waiting on this device. Tap for the detail`,onClick:e=>J9(`sends`,e),children:[(0,J.jsx)(Bc,{size:10,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`np-sv-t`,children:`\xA0saved`})]})}function XFe(){let e=o4();if(!e)return null;let t=e.route===`lan`;return(0,J.jsxs)(`span`,{className:`np-route${t?` np-route-lan`:``}`,role:`button`,"data-hint":`net.pulse.route`,onClick:e=>J9(`link`,e),children:[t?(0,J.jsx)(Fc,{size:10,"aria-hidden":`true`}):(0,J.jsx)(wo,{size:10,"aria-hidden":`true`}),(0,J.jsx)(`span`,{children:t?`LAN`:`tailnet`})]})}function ZFe(){let e=am(e=>e.pulse.enabled);return(0,V.useEffect)(()=>(document.documentElement.style.setProperty(`--ui-pulse-h`,e?`22px`:`0px`),()=>{document.documentElement.style.removeProperty(`--ui-pulse-h`)}),[e]),e?(0,J.jsx)(QFe,{}):null}function QFe(){let e=am(e=>e,!0),{status:t,samples:n}=e.pulse,r=_p(n),i=Sre((0,V.useSyncExternalStore)(vre,Dd),Date.now()),a=t===`open`,o=t===`open`?r.last==null?r.median==null?`…`:`${Math.round(r.median)} ms`:`${Math.round(r.last)} ms`:t===`connecting`?`connecting`:`offline`,s=a&&r.median!=null&&r.last!=null&&Math.abs(r.last-r.median)>40?`~${Math.round(r.median)}`:null;return(0,J.jsxs)(`div`,{className:`net-pulse np-${t}${r.misses?` np-lossy`:``}`,role:`status`,"data-hint":`net.pulse`,title:`connection: ${t}${r.median==null?``:` · median ${Math.round(r.median)} ms`}${r.misses?` · ${r.misses} of the last ${Math.min(n.length,90)} pings unanswered`:``} · ${Ld(e.traffic.down)} down / ${Ld(e.traffic.up)} up since ${new Date(e.traffic.since).toLocaleDateString()} · last connected ${Zp(e.sync.lastSeenAt)} · last full sync ${Zp(e.sync.syncedAt??Xp())} — tap for connection health`,onClick:()=>J9(`link`),children:[(0,J.jsx)(`span`,{className:`np-led`}),(0,J.jsxs)(`span`,{className:`np-link`,role:`button`,"data-hint":`net.pulse.graph`,onClick:e=>J9(`link`,e),children:[(0,J.jsx)(GFe,{samples:n,ceiling:r.ceiling}),(0,J.jsxs)(`span`,{className:`np-ms`,children:[o,s?(0,J.jsxs)(`span`,{className:`np-med`,children:[` `,s]}):null]})]}),(0,J.jsx)(XFe,{}),i?(0,J.jsxs)(`span`,{className:`np-restart${i.slow?` np-restart-slow`:``}`,children:[(0,J.jsx)(bl,{size:10,"aria-hidden":`true`}),(0,J.jsx)(`span`,{children:i.text})]}):(0,J.jsx)(qFe,{s:e.sync}),(0,J.jsxs)(`span`,{className:`np-right`,children:[(0,J.jsx)(YFe,{outstanding:e.outstanding,ever:e.everOutstanding,stuck:e.stuckSends}),(0,J.jsx)(JFe,{n:e.stuckSends}),(0,J.jsx)(KFe,{t:e.traffic})]})]})}var $Fe=30,Y9=84,eIe=16;function X9(e,t){t?.stopPropagation();try{window.dispatchEvent(new CustomEvent(`app:open-localrt`,{detail:{focus:e}}))}catch{}}function tIe({series:e,ceiling:t,w:n=Y9,h:r=eIe}){let i=Math.max(2,Math.round(n/(Y9/$Fe))),a=e.slice(-i),o=n/(i-1),s=e=>n-(a.length-1-e)*o,c=e=>r-Math.min(1,e/t)*(r-1)-.5,l=[],u=[];for(let e=0;e<a.length;e++){let t=a[e];t==null?(u.length>1&&l.push(u.join(` `)),u=[]):u.push(`${s(e).toFixed(1)},${c(t).toFixed(1)}`)}u.length>1&&l.push(u.join(` `));let d=a.map((e,t)=>e!=null&&(t===0||a[t-1]==null)&&(t===a.length-1||a[t+1]==null)?{i:t,v:e}:null).filter(e=>e!=null);return(0,J.jsxs)(`svg`,{className:`lrt-spark`,width:n,height:r,viewBox:`0 0 ${n} ${r}`,"aria-hidden":`true`,children:[a.map((e,t)=>e==null?(0,J.jsx)(`rect`,{x:Math.max(0,s(t)-o/2),y:0,width:Math.max(1.5,o),height:r,className:`lrt-miss`},`m${t}`):null),l.map((e,t)=>(0,J.jsx)(`polyline`,{points:e,className:`lrt-line`},`r${t}`)),d.map(e=>(0,J.jsx)(`circle`,{cx:s(e.i),cy:c(e.v),r:1.2,className:`lrt-dot`},`d${e.i}`))]})}function Z9(e){let[t,...n]=e;return n.length?`${t.name} +${n.length}`:t.name}function nIe(e){if(e.kind===`holding`&&e.sample)return`${Z9(e.sample.models)} · ${bg(xg(e.sample.models))}`;switch(e.kind){case`idle`:return`holding nothing`;case`unreachable`:return`no runner`;case`disabled`:return`not polled here`;case`unanswered`:return`no answer`;default:return`…`}}function rIe(e,t){return e.kind===`unanswered`||t&&!e.stale?`lrt-old`:e.stale||!e.sample?`lrt-quiet`:`lrt-live`}function iIe(){let e=Kg(e=>e.mode);(0,V.useEffect)(()=>e===`off`?void 0:Xg(),[e]);let t=Kg(e=>{let t=e.last&&e.last.reachable&&e.last.models.length>0;return zie(e.mode,{holding:!!t,lastHeldAt:Rie(e.samples,e.last),now:e.now})},e!==`off`),n=qae(),r=t||n;return(0,V.useEffect)(()=>(document.documentElement.style.setProperty(`--ui-localrt-h`,r?`18px`:`0px`),()=>{document.documentElement.style.removeProperty(`--ui-localrt-h`)}),[r]),r?e===`off`?(0,J.jsx)(oIe,{}):(0,J.jsx)(aIe,{closable:n&&!t}):null}function aIe({closable:e}){let t=Kg(e=>e,!0),n=am(e=>e.online),r=Ag({last:t.last,disabled:t.disabled,online:n,askedAt:t.askedAt,answeredAt:t.answeredAt,now:t.now}),i=r.at!=null&&r.stale?Op(r.at):null,a=r.kind===`holding`||r.kind===`idle`||r.kind===`unreachable`?t.last:null,o=r.kind===`holding`&&r.sample?r.sample:null,s=a?Og(a):!1,c=o?Sg(t.samples):wg(t.samples);return(0,J.jsxs)(`div`,{className:`localrt-bar ${rIe(r,s)}${o?` lrt-has-model`:``}`,role:`status`,"data-hint":`localrt.bar`,title:`${o?r.text:a?kg(a,r.stale):r.text}${i?` (${i} ago)`:``} — tap for this desktop`,onClick:()=>X9(o?`models`:`cpu`),children:[(0,J.jsx)(`span`,{className:`lrt-led`}),o?(0,J.jsxs)(`span`,{className:`lrt-models lrt-lead${r.stale?` stale`:``}`,role:`button`,"data-hint":`localrt.models`,title:`${r.text}${i?` — last reading ${i} ago`:``}. Tap for the model`,onClick:e=>X9(`models`,e),children:[(0,J.jsx)(pl,{size:11,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`lrt-lead-text`,children:Z9(o.models)}),(0,J.jsxs)(`span`,{className:`lrt-lead-size`,children:[bg(xg(o.models)),i?(0,J.jsxs)(`span`,{className:`lrt-age`,children:[` · `,i,` ago`]}):null]})]}):a?(0,J.jsxs)(`span`,{className:`lrt-cpu lrt-lead${r.stale?` stale`:``}`,role:`button`,"data-hint":`localrt.cpu`,title:`the desktop's CPU is ${Math.round(Eg(a))}% busy. Tap for the detail`,onClick:e=>X9(`cpu`,e),children:[(0,J.jsx)(sc,{size:11,"aria-hidden":`true`}),` `,Math.round(Eg(a)),`%`,i?(0,J.jsxs)(`span`,{className:`lrt-age`,children:[` · `,i,` ago`]}):null]}):(0,J.jsx)(`span`,{className:`lrt-models stale`,title:r.text,children:nIe(r)}),a&&c.length>1&&(0,J.jsx)(`span`,{className:`lrt-graph`,role:`button`,"data-hint":o?`localrt.graph`:`localrt.cpu`,title:o?`held memory over the last ${c.length} samples — a sample the runner did not answer is drawn as its own mark. Tap for the larger graph`:`CPU busy over the last ${c.length} samples, 0-100%. Tap for the larger graph`,onClick:e=>X9(`history`,e),children:(0,J.jsx)(tIe,{series:c,ceiling:o?Cg(c):100,w:o?56:Y9})}),(0,J.jsx)(Q9,{}),(0,J.jsxs)(`span`,{className:`lrt-right`,children:[a?.gpuPct!=null&&(0,J.jsxs)(`span`,{className:`lrt-gpu`,role:`button`,"data-hint":`localrt.cpu`,title:`the desktop's GPU is ${Math.round(a.gpuPct)}% busy, system-wide. Tap for the detail`,onClick:e=>X9(`cpu`,e),children:[(0,J.jsx)(Lte,{size:10,"aria-hidden":`true`}),` `,Math.round(a.gpuPct),`%`]}),a&&(0,J.jsxs)(`span`,{className:`lrt-mem${s?` lrt-tight`:``}`,role:`button`,"data-hint":`localrt.memory`,title:`${bg(Dg(a))} available of ${bg(a.memTotal)} on the desktop${s?` — memory is tight`:``}. Tap for where it went`,onClick:e=>X9(`memory`,e),children:[(0,J.jsx)(ks,{size:10,"aria-hidden":`true`}),` `,bg(Dg(a))]})]}),e&&(0,J.jsx)($9,{})]})}function Q9(){let e=Jv(),t=Zv(`agentWarn`);if(!e||e.total===0)return null;let n=Rv(e.total,t),r=n===`alarm`?` — more than your limit of ${t.alarm}`:n===`warn`?` — more than your warning of ${t.warn}`:``;return(0,J.jsxs)(`span`,{className:`lrt-agents lrt-agents-${n}`,role:`button`,"data-hint":`localrt.agents`,title:`${Bv(e)}${r}. Tap for which sessions and the count over time`,onClick:e=>X9(`agents`,e),children:[(0,J.jsx)(Uo,{size:10,"aria-hidden":`true`}),` `,e.total]})}function oIe(){let e=Jv();return(0,J.jsxs)(`div`,{className:`localrt-bar lrt-old lrt-agents-only`,role:`status`,"data-hint":`localrt.agents`,onClick:()=>X9(`agents`),children:[(0,J.jsx)(`span`,{className:`lrt-led`}),(0,J.jsx)(Q9,{}),(0,J.jsx)(`span`,{className:`lrt-agents-words`,children:e?`agents running at once`:``}),(0,J.jsx)($9,{})]})}function $9(){return(0,J.jsx)(`button`,{className:`lrt-close`,"aria-label":`hide the agent warning`,title:`hide until the count climbs past your next mark`,onClick:e=>{e.stopPropagation(),Kae(),K(`Agent warning hidden. It comes back if the count passes your next mark; Settings → Appearance → desktop strip keeps the strip on.`)},children:(0,J.jsx)(B,{size:12,"aria-hidden":`true`})})}function sIe(){let e=Zie(M_(e=>e.enabled),M_(e=>e.tabs.length>0||e.files.length>0)),t=e>0;return(0,V.useEffect)(()=>(document.documentElement.style.setProperty(`--ui-tabs-h`,`${e}px`),()=>{document.documentElement.style.removeProperty(`--ui-tabs-h`)}),[e]),t?(0,J.jsx)(cIe,{}):null}function cIe(){let e=M_(e=>e);DD();let t=(0,V.useRef)(null),n=!!e.fileActive&&e.files.some(t=>$g(t)===e.fileActive);(0,V.useEffect)(()=>{let n=t.current;if(!n)return;let r=e.activeId||e.fileActive?n.querySelector(`.stab.on`):null;r?r.scrollIntoView({block:`nearest`,inline:`nearest`}):n.scrollLeft=0},[e.activeId,e.fileActive,e.order,e.strip.length]);let[r,i]=(0,V.useState)(!1);Gh(r,()=>i(!1));let a={"--stab-all-w":`${38+7*String(e.all.length).length}px`};return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{className:`stab-all`,"aria-label":`list all open tabs`,title:`all open tabs as a list`,style:a,"aria-expanded":r,onClick:()=>i(e=>!e),children:[(0,J.jsx)(Za,{size:14,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`stab-all-n`,children:e.all.length})]}),r&&(0,J.jsx)(lIe,{s:e,fileOn:n,onClose:()=>i(!1)}),(0,J.jsxs)(`div`,{className:`sess-tabs`,ref:t,role:`tablist`,"aria-label":`open sessions`,style:{...a,"--stab-n":String(e.count)},children:[e.strip.map(t=>t.kind===`session`?(0,J.jsx)(uIe,{t:t.tab,active:!n&&t.tab.id===e.activeId},t.tab.id):(0,J.jsx)(dIe,{f:t.file,active:$g(t.file)===e.fileActive},$g(t.file))),e.hidden>0&&(0,J.jsxs)(`span`,{className:`stab-more`,title:`${e.hidden} more open — see the launcher, or raise “most tabs shown” in Settings`,children:[`+`,e.hidden]})]})]})}function lIe({s:e,fileOn:t,onClose:n}){async function r(e){await gC(p_(e.label,e.status!==`exited`))&&R_(e.id)}return(0,J.jsx)(`div`,{className:`stab-list-layer`,children:(0,J.jsx)(Hw,{title:`open tabs · ${e.all.length}`,onClose:n,children:(0,J.jsx)(`ul`,{className:`stab-list`,children:e.all.map(i=>{if(i.kind===`file`){let t=i.file,r=$g(t)===e.fileActive;return(0,J.jsxs)(`li`,{className:`stab-row stab-file${r?` on`:``}`,style:wp(t.repo),onClick:()=>{n(),z_(t)},children:[(0,J.jsx)(Fs,{size:16,className:`stab-fico`,"aria-hidden":`true`}),(0,J.jsxs)(`span`,{className:`stab-row-text`,children:[(0,J.jsx)(`span`,{className:`stab-row-label`,children:t_(t.path)}),(0,J.jsxs)(`span`,{className:`stab-row-sub`,children:[t.repo||`file`,` · pinned file · `,t.path]})]})]},$g(t))}let a=i.tab,o=!t&&a.id===e.activeId;return(0,J.jsxs)(`li`,{className:`stab-row${o?` on`:``}`,"data-state":a.status,style:wp(a.repo),onClick:()=>{n(),L_(a.id)},children:[a.status===`coding`?(0,J.jsx)($s,{size:16,className:`spin stab-spin`,"aria-hidden":`true`}):(0,J.jsx)(`span`,{className:`stab-led`,"aria-hidden":`true`}),(0,J.jsxs)(`span`,{className:`stab-row-text`,children:[(0,J.jsx)(`span`,{className:`stab-row-label`,children:a.label}),(0,J.jsxs)(`span`,{className:`stab-row-sub`,children:[a.repo,` · `,xK[a.status]]})]}),(0,J.jsx)(`button`,{className:`stab-x`,"aria-label":`close ${a.label}`,title:`close this session`,onClick:e=>{e.stopPropagation(),r(a)},children:(0,J.jsx)(B,{size:18})})]},a.id)})})})})}function uIe({t:e,active:t}){async function n(t){t.stopPropagation(),await gC(p_(e.label,e.status!==`exited`))&&R_(e.id)}return(0,J.jsxs)(`div`,{className:`stab${t?` on`:``}`,"data-state":e.status,style:wp(e.repo),role:`tab`,"aria-selected":t,"data-hint":`session.tabs`,title:`${e.label} — ${e.repo} · ${xK[e.status]}`,onClick:()=>L_(e.id),children:[e.status===`coding`?(0,J.jsx)($s,{size:11,className:`spin stab-spin`,"aria-hidden":`true`}):(0,J.jsx)(`span`,{className:`stab-led`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`stab-label`,children:e.label}),(0,J.jsx)(`button`,{className:`stab-x`,"aria-label":`close ${e.label}`,title:`close this session`,onClick:n,children:(0,J.jsx)(B,{size:12})})]})}function dIe({f:e,active:t}){let n=t_(e.path);function r(t){t.stopPropagation(),b_(e,!1),K(`unpinned ${n} — pin it again from the file's header`)}return(0,J.jsxs)(`div`,{className:`stab stab-file${t?` on`:``}`,style:wp(e.repo),role:`tab`,"aria-selected":t,"data-hint":`session.tabs`,title:`${e.path} — ${e.repo||`file`} · pinned file`,onClick:()=>z_(e),children:[(0,J.jsx)(Fs,{size:11,className:`stab-fico`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`stab-label`,children:n}),(0,J.jsx)(`button`,{className:`stab-x`,"aria-label":`unpin ${n}`,title:`unpin this file`,onClick:r,children:(0,J.jsx)(B,{size:12})})]})}var fIe=120;function pIe(){let[e,t]=(0,V.useState)(null);return(0,V.useEffect)(()=>xie(t),[]),(0,V.useEffect)(()=>{if(!e)return;let t=()=>yg();return document.addEventListener(`pointerdown`,t,!0),()=>document.removeEventListener(`pointerdown`,t,!0)},[e]),e?(0,J.jsxs)(`button`,{className:`toast`,role:`status`,"aria-live":`polite`,title:`dismiss`,onClick:yg,children:[e,e.length>fIe&&(0,J.jsx)(`span`,{style:{display:`block`,marginTop:6,fontSize:`0.85em`,color:`var(--muted)`},children:`tap anywhere to close · the full text stays under the bell`})]}):null}var mIe=6e4;function hIe(){let[,e]=(0,V.useState)(0);(0,V.useEffect)(()=>NP(()=>e(e=>e+1)),[]);let t=MP();if((0,V.useEffect)(()=>{if(!t)return;let e=setTimeout(PP,mIe);return()=>clearTimeout(e)},[t]),!t)return null;let n=vp(t.check.repoDir);return(0,J.jsxs)(`div`,{className:`slot-ask`,role:`status`,"aria-live":`polite`,children:[(0,J.jsxs)(`div`,{className:`slot-ask-what`,children:[(0,J.jsx)(To,{size:14}),` `,qN(t)]}),(0,J.jsxs)(`div`,{className:`slot-ask-acts`,children:[(0,J.jsx)(Y,{variant:`primary`,title:aP(t.check),onClick:()=>{q(`action:slotask.check`),PP(),IP(t.check)||K(`the check could not be opened from here — the backlog's check these verb does the same`)},children:JN}),(0,J.jsx)(Y,{title:`leave them as they are — the backlog still offers the check`,onClick:()=>{q(`action:slotask.later`),PP()},children:YN}),(0,J.jsx)(`button`,{className:`link-btn`,title:`stop offering this after a timed send in ${n}`,onClick:()=>{q(`action:slotask.off`),kP(t.check.repoDir,!0),K(QN(n))},children:XN})]})]})}export{B8 as $,uT as $a,aie as $c,Uue as $i,Am as $l,dK as $n,$C as $o,CI as $r,ob as $s,Ame as $t,Gne as $u,_Pe as A,Pce as Aa,P_ as Ac,vj as Ai,Qm as Al,VK as An,ZC as Ao,EB as Ar,yS as As,mSe as At,df as Au,yMe as B,fse as Ba,g_ as Bc,Ede as Bi,qm as Bl,NK as Bn,YC as Bo,AR as Br,aS as Bs,G0 as Bt,Od as Bu,kPe as C,tk as Ca,Q_ as Cc,fpe as Ci,U as Cl,cq as Cn,Bw as Co,LB as Cr,tC as Cs,k2 as Ct,ip as Cu,CPe as D,DO as Da,sv as Dc,Vj as Di,Sh as Dl,RK as Dn,jw as Do,IB as Dr,WS as Ds,OSe as Dt,lf as Du,s9 as E,fle as Ea,Cae as Ec,Rj as Ei,xh as El,ZK as En,Pw as Eo,PB as Er,GS as Es,_2 as Et,qf as Eu,GMe as F,PD as Fa,gae as Fc,nj as Fi,Km as Fl,AK as Fn,pw as Fo,Az as Fr,hS as Fs,cSe as Ft,bf as Fu,x5 as G,yE as Ga,K as Gc,HA as Gi,Rm as Gl,yK as Gn,tw as Go,dL as Gr,eS as Gs,M0 as Gt,Qu as Gu,G5 as H,$oe as Ha,Pie as Hc,JA as Hi,Ym as Hl,bK as Hn,NC as Ho,jL as Hr,Xx as Hs,R0 as Ht,xre as Hu,f7 as I,_se as Ia,dae as Ic,jde as Ii,nh as Il,FK as In,dw as Io,gz as Ir,nS as Is,$xe as It,_f as Iu,n5 as J,doe as Ja,sg as Jc,BA as Ji,eh as Jl,_K as Jn,zC as Jo,OI as Jr,Qx as Js,Gbe as Jt,are as Ju,Oje as K,vE as Ka,fie as Kc,dde as Ki,uh as Kl,gK as Kn,QC as Ko,JI as Kr,Yx as Ks,N0 as Kt,Uu as Ku,BMe as L,DD as La,fae as Lc,tj as Li,th as Ll,wK as Ln,PC as Lo,_z as Lr,gS as Ls,Gxe as Lt,of as Lu,w7 as M,Dce as Ma,Xie as Mc,Gde as Mi,Vm as Ml,IK as Mn,TC as Mo,CB as Mr,pS as Ms,o2 as Mt,ff as Mu,dNe as N,rO as Na,eae as Nc,gj as Ni,ph as Nl,xK as Nn,EC as No,gB as Nr,dS as Ns,oSe as Nt,mf as Nu,EPe as O,ele as Oa,lae as Oc,cfe as Oi,gh as Ol,XK as On,bC as Oo,FB as Or,Y as Os,f2 as Ot,hf as Ou,sNe as P,JD as Pa,L_ as Pc,rj as Pi,zm as Pl,MK as Pn,MC as Po,Rz as Pr,fS as Ps,sSe as Pt,pf as Pu,LAe as Q,fT as Qa,rie as Qc,Kue as Qi,Xm as Ql,qG as Qn,VC as Qo,AI as Qr,rb as Qs,sZ as Qt,nre as Qu,zMe as R,bD as Ra,uae as Rc,Ade as Ri,rh as Rl,SK as Rn,WC as Ro,dz as Rr,lS as Rs,Q0 as Rt,Id as Ru,APe as S,Cle as Sa,Cv as Sc,wM as Si,wh as Sl,lq as Sn,Uw as So,RB as Sr,nC as Ss,tCe as St,ep as Su,TPe as T,zO as Ta,_v as Tc,lpe as Ti,vh as Tl,KK as Tn,Iw as To,YB as Tr,YS as Ts,ESe as Tt,Xf as Tu,pMe as U,ese as Ua,qie as Uc,Ode as Ui,lh as Ul,CK as Un,RC as Uo,OL as Ur,Zx as Us,Qbe as Ut,Dd as Uu,vMe as V,Qoe as Va,Nie as Vc,qA as Vi,Zm as Vl,jK as Vn,qC as Vo,lR as Vr,$x as Vs,B0 as Vt,yre as Vu,W5 as W,sD as Wa,bie as Wc,XA as Wi,ih as Wl,TK as Wn,DC as Wo,kL as Wr,Kx as Ws,Wbe as Wt,lre as Wu,YAe as X,_T as Xa,rg as Xc,OA as Xi,Jm as Xl,pK as Xn,KC as Xo,jI as Xr,ox as Xs,sbe as Xt,Hu as Xu,s5 as Y,mT as Ya,tg as Yc,rde as Yi,Gm as Yl,mK as Yn,BC as Yo,NI as Yr,lx as Ys,Mbe as Yt,Wu as Yu,XAe as Z,gT as Za,ng as Zc,CA as Zi,dh as Zl,fK as Zn,HC as Zo,kI as Zr,$y as Zs,Nme as Zt,tre as Zu,iFe as _,Ele as _a,Rae as _c,BF as _i,Nre as _l,fY as _n,Q as _o,LV as _r,XS as _s,Zwe as _t,Ep as _u,ZFe as a,Aue as aa,dy as ac,ku as ad,zF as ai,Hh as al,Wpe as an,pT as ao,NG as ar,AC as as,gAe as at,am as au,UPe as b,nk as ba,Gae as bc,DM as bi,W as bl,cJ as bn,Z as bo,sV as br,eC as bs,xCe as bt,Bp as bu,HFe as c,oue as ca,Yae as cc,hu as cd,qF as ci,Rre as cl,JY as cn,cT as co,TH as cr,fC as cs,oAe as ct,Yp as cu,MFe as d,eue as da,Xae as dc,kne as dd,NF as di,Kre as dl,AY as dn,tT as do,jV as dr,gC as ds,WDe as dt,vp as du,hA as ea,qy as ec,Ine as ed,iI as ei,iie as el,Dme as en,hT as eo,sK as er,LC as es,V8 as et,Em as eu,W9 as f,ck as fa,Xv as fc,hne as fd,FF as fi,Rh as fl,SY as fn,$w as fo,PV as fr,_C as fs,KDe as ft,Hp as fu,aFe as g,Dle as ga,Rv as gc,IF as gi,Fre as gl,dY as gn,Xw as go,NV as gr,oC as gs,TTe as gt,Rp as gu,xFe as h,Sk as ha,Iae as hc,Al as hd,AF as hi,Fh as hl,uY as hn,$ as ho,MV as hr,iC as hs,ETe as ht,Up as hu,iIe as i,jue as ia,Ay as ic,ju as id,PF as ii,Jre as il,Kpe as in,lT as io,MG as ir,JC as is,mAe as it,jm as iu,yPe as j,mO as ja,n_ as jc,yj as ji,fh as jl,LK as jn,fw as jo,xB as jr,mS as js,s2 as jt,uf as ju,bPe as k,Lce as ka,N_ as kc,lfe as ki,Im as kl,YK as kn,OC as ko,WB as kr,DS as ks,CSe as kt,Cf as ku,NFe as l,aue as la,Qae as lc,Cu as ld,HF as li,Vre as ll,GY as ln,sT as lo,AH as lr,yC as ls,qke as lt,Tp as lu,CFe as m,bk as ma,Zv as mc,dne as md,OF as mi,Hre as ml,CY as mn,eT as mo,AV as mr,QS as ms,m3 as mt,yp as mu,pIe as n,Iue as na,ky as nc,Mu as nd,MF as ni,eg as nl,GX as nn,nT as no,ZG as nr,kC as ns,k8 as nt,bm as nu,WFe as o,Due as oa,sy as oc,Mne as od,KF as oi,Vh as ol,$Y as on,iT as oo,uW as or,mw as os,T8 as ot,qp as ou,SFe as p,xk as pa,Qv as pc,Vl as pd,VF as pi,Gre as pl,wY as pn,Qw as po,DV as pr,rC as ps,bEe as pt,Op as pu,bje as q,_E as qa,uie as qc,ude as qi,oh as ql,vK as qn,nw as qo,YI as qr,qx as qs,j0 as qt,ire as qu,sIe as r,_A as ra,My as rc,Hne as rd,jF as ri,$h as rl,MX as rn,vT as ro,iK as rr,jC as rs,yAe as rt,Mm as ru,UFe as s,kue as sa,ey as sc,Nne as sd,GF as si,Gh as sl,XY as sn,yT as so,fU as sr,ew as ss,hAe as st,Jp as su,hIe as t,Rue as ta,jy as tc,Fne as td,RF as ti,Xh as tl,QX as tn,rT as to,uK as tr,GC as ts,R8 as tt,km as tu,G9 as u,Dk as ua,Zae as uc,uu as ud,LF as ui,zre as ul,UY as un,aT as uo,EH as ur,vC as us,E6 as ut,Ip as uu,HPe as v,Ale as va,Fae as vc,AP as vi,Th as vl,GJ as vn,Zw as vo,iV as vr,$S as vs,Qwe as vt,Dp as vu,DPe as w,ule as wa,nv as wc,upe as wi,yh as wl,iq as wn,zw as wo,XB as wr,ZS as ws,y2 as wt,H as wu,f9 as x,$O as xa,q as xc,TM as xi,G as xl,Hq as xn,Hw as xo,vV as xr,aC as xs,F2 as xt,hp as xu,p9 as y,ek as ya,Lae as yc,OM as yi,Pre as yl,kJ as yn,qw as yo,rV as yr,X as ys,L4 as yt,wp as yu,bMe as z,hse as za,l_ as zc,KA as zi,Wm as zl,PK as zn,UC as zo,uz as zr,oS as zs,Y0 as zt,jd as zu};