@hanzo/dev 4.0.1 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (369) hide show
  1. package/LICENSE +21 -0
  2. package/dist/{BinaryViewer-qn8xfPZp.js → BinaryViewer-CmFUK4zZ.js} +2 -2
  3. package/dist/{ChatMarkdown-Cyujn3JJ.js → ChatMarkdown-nvEI7iCv.js} +4 -4
  4. package/dist/{DiffCommentAnnotation-BZu1TP6E.js → DiffCommentAnnotation-BPTN_2a6.js} +1 -1
  5. package/dist/{DiffFileTree-CcJ91zOM.js → DiffFileTree-B_br90vY.js} +2 -2
  6. package/dist/{DiffPanel-BXC88NMs.js → DiffPanel-V5R5TPuK.js} +5 -5
  7. package/dist/{ExpandedImageDialog-BZnGRBJR.js → ExpandedImageDialog-CAorLacL.js} +1 -1
  8. package/dist/{FileExplorerPane-vBJS6V75.js → FileExplorerPane-CeHulcPz.js} +1 -1
  9. package/dist/{FilePreviewPanel-jJHWsMzm.js → FilePreviewPanel-BVNLvWOc.js} +8 -8
  10. package/dist/{MermaidDiagram-paNwQY33.js → MermaidDiagram-CTolIzQD.js} +1 -1
  11. package/dist/{MermaidFilePreview-B9KxfnIN.js → MermaidFilePreview-CP2zP4FU.js} +1 -1
  12. package/dist/{MermaidViewer-CAEGpLyD.js → MermaidViewer-BDfYkS9E.js} +2 -2
  13. package/dist/{NotebookPreview-D01mMCpR.js → NotebookPreview-Cybs5uM0.js} +1 -1
  14. package/dist/{OfficeFilePreview-DWaRgfQU.js → OfficeFilePreview-7JsmSoKU.js} +1 -1
  15. package/dist/{OfficeViewer-BudrZbBA.js → OfficeViewer-CJoojlJK.js} +1 -1
  16. package/dist/{OpenInPicker-Dd3ifHa1.js → OpenInPicker-BIMWUxBP.js} +7 -7
  17. package/dist/{OpenXmlOfficeViewer-CXcKdq7k.js → OpenXmlOfficeViewer-C24Kj8DM.js} +1 -1
  18. package/dist/{PreviewImage-C4Ku4z7v.js → PreviewImage-oY5YnuTr.js} +1 -1
  19. package/dist/{PreviewImageContent-BwOB9Lyd.js → PreviewImageContent-n6eLzY99.js} +1 -1
  20. package/dist/{PullRequestCodeTab-BcwyMk7d.js → PullRequestCodeTab-Dv_0kVad.js} +7 -7
  21. package/dist/{PullRequestReviewAnnotation-BU5t_1fC.js → PullRequestReviewAnnotation-LeuwO-iH.js} +4 -4
  22. package/dist/builder/activity.d.ts +16 -0
  23. package/dist/builder/activity.js +51 -0
  24. package/dist/builder/address.d.ts +11 -0
  25. package/dist/builder/address.js +50 -0
  26. package/dist/builder/ago.d.ts +2 -0
  27. package/dist/builder/ago.js +18 -0
  28. package/dist/builder/api/agents.d.ts +139 -0
  29. package/dist/builder/api/agents.js +253 -0
  30. package/dist/builder/api/auto.d.ts +166 -0
  31. package/dist/builder/api/auto.js +300 -0
  32. package/dist/builder/api/billing.d.ts +263 -0
  33. package/dist/builder/api/billing.js +401 -0
  34. package/dist/builder/api/call.d.ts +53 -0
  35. package/dist/builder/api/call.js +123 -0
  36. package/dist/builder/api/capabilities.d.ts +14 -0
  37. package/dist/builder/api/capabilities.js +41 -0
  38. package/dist/builder/api/changes.d.ts +74 -0
  39. package/dist/builder/api/changes.js +75 -0
  40. package/dist/builder/api/chat.d.ts +12 -0
  41. package/dist/builder/api/chat.js +28 -0
  42. package/dist/builder/api/cli.d.ts +59 -0
  43. package/dist/builder/api/cli.js +133 -0
  44. package/dist/builder/api/codebases.d.ts +46 -0
  45. package/dist/builder/api/codebases.js +100 -0
  46. package/dist/builder/api/coding.d.ts +117 -0
  47. package/dist/builder/api/coding.js +222 -0
  48. package/dist/builder/api/connectors.d.ts +76 -0
  49. package/dist/builder/api/connectors.js +111 -0
  50. package/dist/builder/api/consent.d.ts +22 -0
  51. package/dist/builder/api/consent.js +28 -0
  52. package/dist/builder/api/conversations.d.ts +20 -0
  53. package/dist/builder/api/conversations.js +23 -0
  54. package/dist/builder/api/draft.d.ts +38 -0
  55. package/dist/builder/api/draft.js +87 -0
  56. package/dist/builder/api/environment.d.ts +55 -0
  57. package/dist/builder/api/environment.js +126 -0
  58. package/dist/builder/api/gallery.d.ts +32 -0
  59. package/dist/builder/api/gallery.js +85 -0
  60. package/dist/builder/api/git.d.ts +31 -0
  61. package/dist/builder/api/git.js +47 -0
  62. package/dist/builder/api/github.d.ts +176 -0
  63. package/dist/builder/api/github.js +271 -0
  64. package/dist/builder/api/keys.d.ts +35 -0
  65. package/dist/builder/api/keys.js +72 -0
  66. package/dist/builder/api/library.d.ts +116 -0
  67. package/dist/builder/api/library.js +214 -0
  68. package/dist/builder/api/limits.d.ts +69 -0
  69. package/dist/builder/api/limits.js +86 -0
  70. package/dist/builder/api/links.d.ts +51 -0
  71. package/dist/builder/api/links.js +75 -0
  72. package/dist/builder/api/machines.d.ts +122 -0
  73. package/dist/builder/api/machines.js +238 -0
  74. package/dist/builder/api/mcp.d.ts +10 -0
  75. package/dist/builder/api/mcp.js +47 -0
  76. package/dist/builder/api/members.d.ts +35 -0
  77. package/dist/builder/api/members.js +95 -0
  78. package/dist/builder/api/memory.d.ts +14 -0
  79. package/dist/builder/api/memory.js +35 -0
  80. package/dist/builder/api/models.d.ts +17 -0
  81. package/dist/builder/api/models.js +20 -0
  82. package/dist/builder/api/places.d.ts +32 -0
  83. package/dist/builder/api/places.js +29 -0
  84. package/dist/builder/api/platform.d.ts +68 -0
  85. package/dist/builder/api/platform.js +87 -0
  86. package/dist/builder/api/plugins.d.ts +42 -0
  87. package/dist/builder/api/plugins.js +175 -0
  88. package/dist/builder/api/pref.d.ts +77 -0
  89. package/dist/builder/api/pref.js +93 -0
  90. package/dist/builder/api/profile.d.ts +11 -0
  91. package/dist/builder/api/profile.js +41 -0
  92. package/dist/builder/api/projects.d.ts +99 -0
  93. package/dist/builder/api/projects.js +166 -0
  94. package/dist/builder/api/provider.d.ts +49 -0
  95. package/dist/builder/api/provider.js +96 -0
  96. package/dist/builder/api/sandbox.d.ts +90 -0
  97. package/dist/builder/api/sandbox.js +223 -0
  98. package/dist/builder/api/sessions.d.ts +123 -0
  99. package/dist/builder/api/sessions.js +255 -0
  100. package/dist/builder/api/skills.d.ts +82 -0
  101. package/dist/builder/api/skills.js +117 -0
  102. package/dist/builder/api/sse.d.ts +24 -0
  103. package/dist/builder/api/sse.js +68 -0
  104. package/dist/builder/api/studio.d.ts +59 -0
  105. package/dist/builder/api/studio.js +91 -0
  106. package/dist/builder/api/talk.d.ts +48 -0
  107. package/dist/builder/api/talk.js +81 -0
  108. package/dist/builder/api/tools.d.ts +34 -0
  109. package/dist/builder/api/tools.js +37 -0
  110. package/dist/builder/api/turn.d.ts +202 -0
  111. package/dist/builder/api/turn.js +772 -0
  112. package/dist/builder/api/verdict.d.ts +3 -0
  113. package/dist/builder/api/verdict.js +21 -0
  114. package/dist/builder/api/webhooks.d.ts +47 -0
  115. package/dist/builder/api/webhooks.js +82 -0
  116. package/dist/builder/api/work.d.ts +110 -0
  117. package/dist/builder/api/work.js +218 -0
  118. package/dist/builder/ask.d.ts +51 -0
  119. package/dist/builder/ask.js +147 -0
  120. package/dist/builder/automations.d.ts +33 -0
  121. package/dist/builder/automations.js +453 -0
  122. package/dist/builder/awake.d.ts +24 -0
  123. package/dist/builder/awake.js +68 -0
  124. package/dist/builder/back.d.ts +30 -0
  125. package/dist/builder/back.js +105 -0
  126. package/dist/builder/builder.d.ts +12 -0
  127. package/dist/builder/builder.js +162 -0
  128. package/dist/builder/carry.d.ts +48 -0
  129. package/dist/builder/carry.js +278 -0
  130. package/dist/builder/choice.d.ts +134 -0
  131. package/dist/builder/choice.js +152 -0
  132. package/dist/builder/claims.d.ts +13 -0
  133. package/dist/builder/claims.js +35 -0
  134. package/dist/builder/clipboard.d.ts +2 -0
  135. package/dist/builder/clipboard.js +10 -0
  136. package/dist/builder/customize/agents.d.ts +11 -0
  137. package/dist/builder/customize/agents.js +513 -0
  138. package/dist/builder/customize/connectors.d.ts +2 -0
  139. package/dist/builder/customize/connectors.js +319 -0
  140. package/dist/builder/customize/drafted.d.ts +4 -0
  141. package/dist/builder/customize/drafted.js +92 -0
  142. package/dist/builder/customize/index.d.ts +8 -0
  143. package/dist/builder/customize/index.js +127 -0
  144. package/dist/builder/customize/inventory.d.ts +14 -0
  145. package/dist/builder/customize/inventory.js +127 -0
  146. package/dist/builder/customize/load.d.ts +9 -0
  147. package/dist/builder/customize/load.js +22 -0
  148. package/dist/builder/customize/ocean.d.ts +41 -0
  149. package/dist/builder/customize/ocean.js +332 -0
  150. package/dist/builder/customize/plugins.d.ts +2 -0
  151. package/dist/builder/customize/plugins.js +136 -0
  152. package/dist/builder/customize/roles.d.ts +4 -0
  153. package/dist/builder/customize/roles.js +105 -0
  154. package/dist/builder/customize/say.d.ts +13 -0
  155. package/dist/builder/customize/say.js +32 -0
  156. package/dist/builder/customize/skills.d.ts +2 -0
  157. package/dist/builder/customize/skills.js +208 -0
  158. package/dist/builder/customize/ui.d.ts +152 -0
  159. package/dist/builder/customize/ui.js +208 -0
  160. package/dist/builder/data.d.ts +57 -0
  161. package/dist/builder/data.js +322 -0
  162. package/dist/builder/design.d.ts +140 -0
  163. package/dist/builder/design.js +175 -0
  164. package/dist/builder/desk.d.ts +48 -0
  165. package/dist/builder/desk.js +449 -0
  166. package/dist/builder/dev-mode.d.ts +43 -0
  167. package/dist/builder/dev-mode.js +120 -0
  168. package/dist/builder/door.d.ts +11 -0
  169. package/dist/builder/door.js +126 -0
  170. package/dist/builder/environment.d.ts +23 -0
  171. package/dist/builder/environment.js +193 -0
  172. package/dist/builder/files.d.ts +23 -0
  173. package/dist/builder/files.js +175 -0
  174. package/dist/builder/find.d.ts +7 -0
  175. package/dist/builder/find.js +80 -0
  176. package/dist/builder/foot.d.ts +30 -0
  177. package/dist/builder/foot.js +79 -0
  178. package/dist/builder/forge.d.ts +4 -0
  179. package/dist/builder/forge.js +570 -0
  180. package/dist/builder/gear.d.ts +60 -0
  181. package/dist/builder/gear.js +180 -0
  182. package/dist/builder/git.d.ts +21 -0
  183. package/dist/builder/git.js +118 -0
  184. package/dist/builder/gutter.d.ts +17 -0
  185. package/dist/builder/gutter.js +25 -0
  186. package/dist/builder/handoff.d.ts +8 -0
  187. package/dist/builder/handoff.js +22 -0
  188. package/dist/builder/host.d.ts +189 -0
  189. package/dist/builder/host.js +46 -0
  190. package/dist/builder/index.d.ts +108 -0
  191. package/dist/builder/index.js +99 -0
  192. package/dist/builder/landing.d.ts +34 -0
  193. package/dist/builder/landing.js +725 -0
  194. package/dist/builder/library.d.ts +21 -0
  195. package/dist/builder/library.js +526 -0
  196. package/dist/builder/local.d.ts +80 -0
  197. package/dist/builder/local.js +124 -0
  198. package/dist/builder/make.d.ts +10 -0
  199. package/dist/builder/make.js +120 -0
  200. package/dist/builder/markdown.d.ts +49 -0
  201. package/dist/builder/markdown.js +125 -0
  202. package/dist/builder/marks.d.ts +15 -0
  203. package/dist/builder/marks.js +18 -0
  204. package/dist/builder/merge.d.ts +223 -0
  205. package/dist/builder/merge.js +380 -0
  206. package/dist/builder/meter.d.ts +31 -0
  207. package/dist/builder/meter.js +54 -0
  208. package/dist/builder/mind.d.ts +107 -0
  209. package/dist/builder/mind.js +335 -0
  210. package/dist/builder/names.d.ts +40 -0
  211. package/dist/builder/names.js +189 -0
  212. package/dist/builder/nav.d.ts +28 -0
  213. package/dist/builder/nav.js +218 -0
  214. package/dist/builder/out.d.ts +16 -0
  215. package/dist/builder/out.js +24 -0
  216. package/dist/builder/page.d.ts +55 -0
  217. package/dist/builder/page.js +217 -0
  218. package/dist/builder/pane.d.ts +30 -0
  219. package/dist/builder/pane.js +21 -0
  220. package/dist/builder/panel.d.ts +101 -0
  221. package/dist/builder/panel.js +408 -0
  222. package/dist/builder/pdf.d.ts +139 -0
  223. package/dist/builder/pdf.js +847 -0
  224. package/dist/builder/pick.d.ts +10 -0
  225. package/dist/builder/pick.js +38 -0
  226. package/dist/builder/plain.d.ts +59 -0
  227. package/dist/builder/plain.js +209 -0
  228. package/dist/builder/plan.d.ts +63 -0
  229. package/dist/builder/plan.js +155 -0
  230. package/dist/builder/plans.d.ts +1 -0
  231. package/dist/builder/plans.js +157 -0
  232. package/dist/builder/plugin.d.ts +60 -0
  233. package/dist/builder/plugin.js +1 -0
  234. package/dist/builder/plugins/design.d.ts +8 -0
  235. package/dist/builder/plugins/design.js +71 -0
  236. package/dist/builder/plugins/index.d.ts +46 -0
  237. package/dist/builder/plugins/index.js +117 -0
  238. package/dist/builder/plugins/pdf.d.ts +18 -0
  239. package/dist/builder/plugins/pdf.js +83 -0
  240. package/dist/builder/plugins/project.d.ts +5 -0
  241. package/dist/builder/plugins/project.js +68 -0
  242. package/dist/builder/plugins/research.d.ts +24 -0
  243. package/dist/builder/plugins/research.js +147 -0
  244. package/dist/builder/plugins/sketch.d.ts +9 -0
  245. package/dist/builder/plugins/sketch.js +101 -0
  246. package/dist/builder/plugins/slides.d.ts +14 -0
  247. package/dist/builder/plugins/slides.js +55 -0
  248. package/dist/builder/plugins/template.d.ts +13 -0
  249. package/dist/builder/plugins/template.js +95 -0
  250. package/dist/builder/prefs.d.ts +29 -0
  251. package/dist/builder/prefs.js +91 -0
  252. package/dist/builder/preview-url.d.ts +47 -0
  253. package/dist/builder/preview-url.js +107 -0
  254. package/dist/builder/project.d.ts +18 -0
  255. package/dist/builder/project.js +591 -0
  256. package/dist/builder/prose.d.ts +4 -0
  257. package/dist/builder/prose.js +57 -0
  258. package/dist/builder/publish.d.ts +18 -0
  259. package/dist/builder/publish.js +141 -0
  260. package/dist/builder/question.d.ts +33 -0
  261. package/dist/builder/question.js +64 -0
  262. package/dist/builder/redesign.d.ts +32 -0
  263. package/dist/builder/redesign.js +117 -0
  264. package/dist/builder/removal.d.ts +71 -0
  265. package/dist/builder/removal.js +73 -0
  266. package/dist/builder/reply.d.ts +50 -0
  267. package/dist/builder/reply.js +196 -0
  268. package/dist/builder/roles.d.ts +10 -0
  269. package/dist/builder/roles.js +28 -0
  270. package/dist/builder/route.d.ts +85 -0
  271. package/dist/builder/route.js +126 -0
  272. package/dist/builder/run.d.ts +4 -0
  273. package/dist/builder/run.js +804 -0
  274. package/dist/builder/runmeta.d.ts +16 -0
  275. package/dist/builder/runmeta.js +69 -0
  276. package/dist/builder/say.d.ts +2 -0
  277. package/dist/builder/say.js +7 -0
  278. package/dist/builder/scheduled.d.ts +3 -0
  279. package/dist/builder/scheduled.js +328 -0
  280. package/dist/builder/section.d.ts +27 -0
  281. package/dist/builder/section.js +60 -0
  282. package/dist/builder/settings/account.d.ts +1 -0
  283. package/dist/builder/settings/account.js +111 -0
  284. package/dist/builder/settings/billing.d.ts +1 -0
  285. package/dist/builder/settings/billing.js +210 -0
  286. package/dist/builder/settings/capabilities.d.ts +1 -0
  287. package/dist/builder/settings/capabilities.js +66 -0
  288. package/dist/builder/settings/card.d.ts +31 -0
  289. package/dist/builder/settings/card.js +140 -0
  290. package/dist/builder/settings/code.d.ts +1 -0
  291. package/dist/builder/settings/code.js +70 -0
  292. package/dist/builder/settings/credits.d.ts +10 -0
  293. package/dist/builder/settings/credits.js +123 -0
  294. package/dist/builder/settings/environments.d.ts +1 -0
  295. package/dist/builder/settings/environments.js +60 -0
  296. package/dist/builder/settings/general.d.ts +1 -0
  297. package/dist/builder/settings/general.js +58 -0
  298. package/dist/builder/settings/index.d.ts +4 -0
  299. package/dist/builder/settings/index.js +25 -0
  300. package/dist/builder/settings/integrations.d.ts +8 -0
  301. package/dist/builder/settings/integrations.js +138 -0
  302. package/dist/builder/settings/keys.d.ts +1 -0
  303. package/dist/builder/settings/keys.js +114 -0
  304. package/dist/builder/settings/list.d.ts +10 -0
  305. package/dist/builder/settings/list.js +28 -0
  306. package/dist/builder/settings/machines.d.ts +4 -0
  307. package/dist/builder/settings/machines.js +243 -0
  308. package/dist/builder/settings/members.d.ts +1 -0
  309. package/dist/builder/settings/members.js +77 -0
  310. package/dist/builder/settings/memory.d.ts +1 -0
  311. package/dist/builder/settings/memory.js +62 -0
  312. package/dist/builder/settings/notifications.d.ts +1 -0
  313. package/dist/builder/settings/notifications.js +111 -0
  314. package/dist/builder/settings/plan.d.ts +17 -0
  315. package/dist/builder/settings/plan.js +131 -0
  316. package/dist/builder/settings/privacy.d.ts +1 -0
  317. package/dist/builder/settings/privacy.js +76 -0
  318. package/dist/builder/settings/sections.d.ts +16 -0
  319. package/dist/builder/settings/sections.js +34 -0
  320. package/dist/builder/settings/shared.d.ts +6 -0
  321. package/dist/builder/settings/shared.js +58 -0
  322. package/dist/builder/settings/ui.d.ts +50 -0
  323. package/dist/builder/settings/ui.js +53 -0
  324. package/dist/builder/settings/usage.d.ts +1 -0
  325. package/dist/builder/settings/usage.js +24 -0
  326. package/dist/builder/shared.d.ts +26 -0
  327. package/dist/builder/shared.js +15 -0
  328. package/dist/builder/shelf.d.ts +16 -0
  329. package/dist/builder/shelf.js +219 -0
  330. package/dist/builder/side.d.ts +40 -0
  331. package/dist/builder/side.js +208 -0
  332. package/dist/builder/site.d.ts +75 -0
  333. package/dist/builder/site.js +138 -0
  334. package/dist/builder/spend.d.ts +21 -0
  335. package/dist/builder/spend.js +80 -0
  336. package/dist/builder/standing.d.ts +36 -0
  337. package/dist/builder/standing.js +66 -0
  338. package/dist/builder/suggest.d.ts +238 -0
  339. package/dist/builder/suggest.js +463 -0
  340. package/dist/builder/suggestions.d.ts +49 -0
  341. package/dist/builder/suggestions.js +260 -0
  342. package/dist/builder/summary.d.ts +60 -0
  343. package/dist/builder/summary.js +81 -0
  344. package/dist/builder/sync.d.ts +1 -0
  345. package/dist/builder/sync.js +164 -0
  346. package/dist/builder/tabs.d.ts +85 -0
  347. package/dist/builder/tabs.js +288 -0
  348. package/dist/builder/talk.d.ts +5 -0
  349. package/dist/builder/talk.js +108 -0
  350. package/dist/builder/thread.d.ts +60 -0
  351. package/dist/builder/thread.js +302 -0
  352. package/dist/builder/tools.d.ts +22 -0
  353. package/dist/builder/tools.js +52 -0
  354. package/dist/builder/transcript.d.ts +47 -0
  355. package/dist/builder/transcript.js +108 -0
  356. package/dist/builder/voice.d.ts +8 -0
  357. package/dist/builder/voice.js +24 -0
  358. package/dist/{changedFileKind-DqgCCDUs.js → changedFileKind-D6QYvIez.js} +1 -1
  359. package/dist/core.js +1 -0
  360. package/dist/{decodeImagePreview-CesVZYP4.js → decodeImagePreview-DnfFEjhw.js} +1 -1
  361. package/dist/{embed-DYP-OUlb.js → embed-c030vUqM.js} +11 -11
  362. package/dist/index.d.ts +2 -0
  363. package/dist/index.js +2 -1
  364. package/dist/{micromark-util-decode-string-NQjVkmZH.js → micromark-util-decode-string-C-5AXkOV.js} +5 -3
  365. package/dist/{readBinaryPreview-D2X4Uahu.js → readBinaryPreview-BAQ4fFjm.js} +1 -1
  366. package/dist/{useTextFieldSpeech-CyOZZPrV.js → useTextFieldSpeech-COa9XcRx.js} +1 -1
  367. package/package.json +101 -11
  368. /package/{index.d.ts → dist/core.d.ts} +0 -0
  369. /package/{keymap.d.ts → dist/keymap.d.ts} +0 -0
@@ -0,0 +1,408 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * The side panel, once, for Chat and Dev: tabs over what a conversation or a
4
+ * run made, read and served (tabs.ts) — a browser's tabs beside the
5
+ * conversation. The header shows them (`PanelToggle`, while they are hidden),
6
+ * the strip's own toggle hides them, and Ctrl+Shift+B (⌘⇧B) or ⌘. / Ctrl+.
7
+ * does either from anywhere but a field (`useKey`).
8
+ *
9
+ * The strip: the tabs, `+`, and at its end the surface's menu, pop-out and the
10
+ * hide toggle. A page tab has a browser's bar — Back and Forward through the
11
+ * addresses it went through, reload, the address, and its menu — and an empty
12
+ * one offers the surface's suggestions.
13
+ *
14
+ * WHAT A PAGE CAN SHOW IS SAID, NOT FAKED. A host that draws pages itself
15
+ * (`Host.browse`: Hanzo Desktop's native webviews) shows any address. A browser
16
+ * page frames only what may be framed — this page's bytes and our own hosts
17
+ * (`frames`) — and offers any other address in a new window instead of a frame
18
+ * the site would refuse.
19
+ *
20
+ * The column the panel stands in is the host's (side.tsx `useSplit`): its
21
+ * width and edge. The strip reads it for full screen (Escape returns) and, while
22
+ * the panel has the middle column's room, the way back to it. On a phone the
23
+ * panel is the whole window instead (`sheet`).
24
+ */
25
+ import { SizableText, XStack, YStack } from '@hanzo/gui';
26
+ import { phrase } from '@hanzo/i18n';
27
+ import { useI18n } from '@hanzo/i18n/react';
28
+ import { ArrowLeft, ArrowRight, ChevronRight, Columns2, ExternalLink, Globe, Maximize2, Minimize2, Minus, MoreHorizontal, PanelLeftOpen, Pin, Plus, RotateCcw, RotateCw, X } from '@hanzogui/lucide-icons-2';
29
+ import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuSeparator, ContextMenuTrigger, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, } from '@hanzo/ui';
30
+ import { Fragment, useEffect, useMemo, useRef, useState } from 'react';
31
+ import { createPortal } from 'react-dom';
32
+ import { RING, RING_INSET } from './pane.js';
33
+ import { copy } from './clipboard.js';
34
+ import { useBrowse, useBrowser } from './host.js';
35
+ import { useSide } from './side.js';
36
+ import { destination, PAGE } from './tabs.js';
37
+ const MAC = typeof navigator !== 'undefined' && /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent);
38
+ /** The tabs' shortcut, as this platform writes it. */
39
+ const KEYS = MAC ? '⌘⇧B' : 'Ctrl+Shift+B';
40
+ /** Every key that shows and hides the tabs (tabs.ts `useKey`). */
41
+ const SHORTCUTS = 'Control+Shift+B Meta+Shift+B Control+Period Meta+Period';
42
+ /** A tab's title where it has none of its own. */
43
+ const BLANK = phrase('New tab');
44
+ /** On an icon that points along the line (Back, Forward): it turns in a right-to-left page. */
45
+ const MIRROR = { 'data-i18n-mirror': '' };
46
+ /** The row heights, px: the strip (the conversation header's row), and a page's bar. */
47
+ const STRIP = 56;
48
+ const BAR = 48;
49
+ /** A round control in a page's bar, px. */
50
+ const PILL = 34;
51
+ /** A press on an icon control of the panel's: quiet until pointed at, lit while its thing is open. */
52
+ const quiet = (on = false, disabled = false) => ({
53
+ items: 'center',
54
+ justify: 'center',
55
+ shrink: 0,
56
+ rounded: 8,
57
+ borderWidth: 0,
58
+ cursor: disabled ? 'default' : 'pointer',
59
+ opacity: disabled ? 0.35 : 1,
60
+ bg: on ? '$hover' : 'transparent',
61
+ hoverStyle: disabled ? undefined : { bg: '$hover' },
62
+ focusVisibleStyle: RING,
63
+ });
64
+ /**
65
+ * The header's control for the tabs, while they are hidden: an icon among the
66
+ * header's icons. Open, the strip's own toggle stands at the panel's end and
67
+ * this one is not drawn, so the page carries one toggle at a time. Its words
68
+ * are the reader's language; the key chord is an argument, as this platform writes it.
69
+ */
70
+ export function PanelToggle({ open, onToggle }) {
71
+ const { t } = useI18n();
72
+ if (open)
73
+ return null;
74
+ return (_jsx(XStack, { render: "button", "data-slot": "side-toggle", "aria-label": t('Show tabs'), "aria-expanded": false, "aria-keyshortcuts": SHORTCUTS, ...{ title: t('Show tabs ({keys})', { keys: KEYS }) }, onPress: onToggle, width: 32, height: 32, ...quiet(), children: _jsx(Plus, { size: 16 }) }));
75
+ }
76
+ /** Our own hosts: a page of theirs answers a frame on any of our pages. */
77
+ const OURS = ['hanzo.ai', 'hanzo.app', 'hanzo.bot'];
78
+ /** Whether a browser page may frame an address: this page's bytes, this origin, and our own hosts. */
79
+ export function frames(url) {
80
+ let u;
81
+ try {
82
+ u = new URL(url, typeof window === 'undefined' ? 'https://hanzo.ai' : window.location.href);
83
+ }
84
+ catch {
85
+ return false;
86
+ }
87
+ if (u.protocol === 'blob:' || u.protocol === 'data:')
88
+ return true;
89
+ if (typeof window !== 'undefined' && u.origin === window.location.origin)
90
+ return true;
91
+ if (u.protocol !== 'https:')
92
+ return false;
93
+ return OURS.some((h) => u.hostname === h || u.hostname.endsWith(`.${h}`));
94
+ }
95
+ /** A site or a preview we host: a page under one of our hosts, not this page's own origin or our apexes. */
96
+ export function hosted(url) {
97
+ let u;
98
+ try {
99
+ u = new URL(url);
100
+ }
101
+ catch {
102
+ return false;
103
+ }
104
+ if (u.protocol !== 'https:' || (typeof window !== 'undefined' && u.origin === window.location.origin))
105
+ return false;
106
+ return OURS.some((h) => u.hostname.endsWith(`.${h}`) && u.hostname !== `www.${h}`);
107
+ }
108
+ const suffix = (s) => {
109
+ const dot = s.lastIndexOf('.');
110
+ return dot > 0 ? s.slice(dot + 1).toLowerCase() : '';
111
+ };
112
+ const PICTURES = ['png', 'jpg', 'jpeg', 'gif', 'webp', 'avif', 'svg'];
113
+ const FRAMED = ['html', 'htm', 'txt', 'md', 'json', 'csv', 'pdf', 'css', 'js', 'ts'];
114
+ /** The address a tab can be opened at in a window of its own: its own, or its bytes. Null for a kind or a blank page. */
115
+ function outward(tab) {
116
+ if (!tab || tab.kind !== PAGE)
117
+ return null;
118
+ if (tab.body !== undefined)
119
+ return URL.createObjectURL(new Blob([tab.body], { type: tab.type || 'text/plain' }));
120
+ return tab.url || null;
121
+ }
122
+ /** Opens a tab's address or bytes in a new window. */
123
+ function popOut(tab) {
124
+ const href = outward(tab);
125
+ if (href)
126
+ window.open(href, '_blank', 'noopener,noreferrer');
127
+ }
128
+ /** A place's mark: its image, else its initial on a quiet tile. */
129
+ function Mark({ icon, title }) {
130
+ const [broken, setBroken] = useState(false);
131
+ return (_jsx(XStack, { width: 40, height: 40, rounded: 10, items: "center", justify: "center", bg: "$edge", overflow: "hidden", shrink: 0, children: icon && !broken ? (_jsx(YStack, { render: _jsx("img", { src: icon, alt: "", width: 28, height: 28, onError: () => setBroken(true) }), "$platform-web": { objectFit: 'contain' } })) : (_jsx(SizableText, { size: "$4", fontWeight: "600", color: "$ink", "aria-hidden": true, children: (title.trim()[0] ?? '·').toUpperCase() })) }));
132
+ }
133
+ /** An empty page: the places the surface suggests, as cards in a row that scrolls sideways. */
134
+ function Suggested({ suggested, onGo }) {
135
+ const { t } = useI18n();
136
+ return (_jsxs(YStack, { "data-slot": "side-suggested", px: "$4", pt: "$4", gap: "$3", children: [_jsx(SizableText, { fontSize: 13, color: "$soft", children: t('Suggested') }), suggested.length ? (_jsx(XStack, { role: "list", "aria-label": t('Suggested'), gap: "$2", overflowX: "auto", overflowY: "hidden", pb: "$2", children: suggested.map((s) => (_jsx(YStack, { role: "listitem", shrink: 0, children: _jsxs(YStack, { render: "button", "aria-label": s.title, onPress: () => onGo(s.url), width: 120, items: "center", gap: "$2", py: "$2.5", px: "$1.5", focusVisibleStyle: RING, children: [_jsx(Mark, { icon: s.icon, title: s.title }), _jsx(SizableText, { size: "$2", color: "$ink", numberOfLines: 1, maxW: "100%", children: s.title })] }) }, s.url))) })) : (_jsx(SizableText, { fontSize: 13, color: "$soft", children: t('No suggestions.') }))] }));
137
+ }
138
+ /** A remote address a browser page may not frame: what it is, and the one way to open it. */
139
+ function Elsewhere({ tab }) {
140
+ const { t } = useI18n();
141
+ return (_jsxs(YStack, { flex: 1, items: "center", justify: "center", gap: "$3", p: "$5", "data-slot": "side-elsewhere", children: [_jsx(Globe, { size: 20, opacity: 0.6 }), _jsx(SizableText, { fontSize: 13, color: "$ink", numberOfLines: 1, maxW: "100%", children: tab.title || tab.url }), _jsxs(XStack, { render: "button", onPress: () => popOut(tab), items: "center", gap: "$1.5", px: "$3", minH: 34, rounded: 999, borderWidth: 1, borderColor: "$borderColor", cursor: "pointer", hoverStyle: { bg: '$hover' }, focusVisibleStyle: RING, children: [_jsx(ExternalLink, { size: 13 }), _jsx(SizableText, { fontSize: 13, color: "$ink", children: t('Open in a new window') })] })] }));
142
+ }
143
+ /** A row of the page's menu, px: a browser's menu is denser than a form's. */
144
+ const ROW = 29;
145
+ /** A browser's zoom steps, percent. */
146
+ const ZOOMS = [25, 33, 50, 67, 75, 80, 90, 100, 110, 125, 150, 175, 200, 250, 300];
147
+ /** The next zoom step past `now`, one way. */
148
+ const zoomed = (now, way) => {
149
+ const at = ZOOMS.findIndex((z) => z >= now);
150
+ const i = at < 0 ? ZOOMS.length - 1 : ZOOMS[at] === now ? at + way : way > 0 ? at : at - 1;
151
+ return ZOOMS[Math.max(0, Math.min(ZOOMS.length - 1, i))];
152
+ };
153
+ /** A row of the menu: its words, and what stands at its end. */
154
+ /** Hand the page's picture to `onCapture` as a file; a capture the host browser cancels or fails is dropped, with nothing thrown. */
155
+ export async function screenshot(browser, shown, onCapture) {
156
+ if (!shown || !browser?.capture || !onCapture)
157
+ return;
158
+ try {
159
+ const blob = await browser.capture(shown);
160
+ const name = `Screenshot ${new Date().toISOString().replace(/[:T]/g, '-').slice(0, 19)}.png`;
161
+ onCapture(new File([blob], name, { type: blob.type || 'image/png' }), { url: shown.url, title: shown.title });
162
+ }
163
+ catch {
164
+ // Cancelled or failed in the host browser.
165
+ }
166
+ }
167
+ function Row({ label, onSelect, disabled, end }) {
168
+ return (_jsxs(DropdownMenuItem, { disabled: disabled, onSelect: onSelect, minH: ROW, py: 0, children: [_jsx(SizableText, { fontSize: 13, color: "$ink", flex: 1, numberOfLines: 1, children: label }), end] }));
169
+ }
170
+ /** The zoom row: the level between − and +, and the way back to 100. Plain buttons, so a press keeps the menu open. */
171
+ function Zoom({ level, onLevel, disabled }) {
172
+ const { t } = useI18n();
173
+ const step = (way) => () => onLevel(zoomed(level, way));
174
+ const box = (label, onSelect, child) => (_jsx(XStack, { render: "button", "aria-label": label, "aria-disabled": disabled || undefined, onPress: disabled ? undefined : onSelect, width: 24, height: 24, ...quiet(false, disabled), children: child }));
175
+ return (_jsxs(XStack, { "data-slot": "page-zoom", role: "group", "aria-label": t('Zoom'), items: "center", gap: "$2", px: 8, height: 38, opacity: disabled ? 0.5 : 1, children: [_jsx(SizableText, { fontSize: 13, color: "$ink", flex: 1, children: t('Zoom') }), _jsxs(XStack, { items: "center", gap: 2, borderWidth: 1, borderColor: "$borderColor", rounded: 8, px: 2, height: 28, children: [box(t('Zoom out'), step(-1), _jsx(Minus, { size: 12 })), _jsx(SizableText, { size: "$1", color: "$ink", width: 40, text: "center", "aria-live": "polite", fontVariant: ['tabular-nums'], children: `${level}%` }), box(t('Zoom in'), step(1), _jsx(Plus, { size: 12 }))] }), box(t('Reset zoom'), () => onLevel(100), _jsx(RotateCcw, { size: 13 }))] }));
176
+ }
177
+ /**
178
+ * Skills, a submenu. Its panel is mounted only while open: a closed one stays
179
+ * laid out over the menu and takes its presses.
180
+ */
181
+ function Skills({ skills, here }) {
182
+ const { t } = useI18n();
183
+ const [open, setOpen] = useState(false);
184
+ return (_jsxs(DropdownMenuSub, { open: open, onOpenChange: setOpen, children: [_jsx(DropdownMenuSubTrigger, { disabled: !here, minH: ROW, py: 0, children: _jsx(SizableText, { fontSize: 13, color: "$ink", flex: 1, children: t('Skills') }) }), open ? (_jsx(DropdownMenuSubContent, { minW: 200, children: skills.map((k) => (_jsx(Row, { label: k.name, onSelect: () => here && k.run(here) }, k.id))) })) : null] }));
185
+ }
186
+ /**
187
+ * The page's menu, in a browser's order: what we add first (ask about it, open
188
+ * it in Dev, a skill, a new window, its link), then what is done to the page
189
+ * (find, print, zoom, device toolbar, a screenshot), then the browser's own
190
+ * (passwords, downloads, history, clearing) and its settings. A row is drawn
191
+ * only where it can be done — by the host's browser (`Host.browser`), or by a
192
+ * page itself for a frame it may reach — and one that needs a page is dim on
193
+ * an empty tab.
194
+ */
195
+ function Actions({ tab, here, frame, framed, same, level, onLevel, acts, browser, onPin, }) {
196
+ const { t } = useI18n();
197
+ const shown = here ? { id: tab.id, ...here } : null;
198
+ const none = !shown;
199
+ const pick = () => {
200
+ if (!same)
201
+ return undefined;
202
+ try {
203
+ return frame.current?.contentWindow?.getSelection()?.toString() || undefined;
204
+ }
205
+ catch {
206
+ return undefined;
207
+ }
208
+ };
209
+ const ask = async () => {
210
+ if (!shown || !acts.onAsk)
211
+ return;
212
+ const selection = browser?.selection ? await browser.selection(shown).catch(() => '') : pick();
213
+ acts.onAsk({ url: shown.url, title: shown.title, ...(selection ? { selection } : {}) });
214
+ };
215
+ const print = browser?.print ?? (same ? () => frame.current?.contentWindow?.print() : undefined);
216
+ const zoom = Boolean(browser?.zoom) || framed;
217
+ const ours = [
218
+ acts.onAsk ? _jsx(Row, { label: t('Ask about this page'), disabled: none, onSelect: () => void ask() }, "ask") : null,
219
+ acts.onDev && shown && hosted(shown.url) ? _jsx(Row, { label: t('Open in Dev'), onSelect: () => acts.onDev?.({ url: shown.url, title: shown.title }) }, "dev") : null,
220
+ acts.skills?.length ? _jsx(Skills, { skills: acts.skills, here: here }, "skills") : null,
221
+ _jsx(Row, { label: t('Open in a new window'), disabled: none, onSelect: () => popOut(tab) }, "out"),
222
+ _jsx(Row, { label: t('Copy link'), disabled: none || !tab.url, onSelect: () => tab.url && void copy(tab.url) }, "copy"),
223
+ onPin ? _jsx(Row, { label: tab.pinned ? t('Unpin tab') : t('Pin tab'), onSelect: () => onPin(!tab.pinned) }, "pin") : null,
224
+ ].filter(Boolean);
225
+ const page = [
226
+ browser?.find ? _jsx(Row, { label: t('Find in page'), disabled: none, onSelect: () => shown && browser.find?.(shown) }, "find") : null,
227
+ print ? _jsx(Row, { label: t('Print'), disabled: none, onSelect: () => shown && print(shown) }, "print") : null,
228
+ zoom ? _jsx(Zoom, { level: level, onLevel: onLevel, disabled: none }, "zoom") : null,
229
+ browser?.devices ? _jsx(Row, { label: t('Show device toolbar'), disabled: none, onSelect: () => shown && browser.devices?.(shown) }, "devices") : null,
230
+ browser?.capture && acts.onCapture ? _jsx(Row, { label: t('Take a screenshot'), disabled: none, onSelect: () => void screenshot(browser, shown, acts.onCapture) }, "capture") : null,
231
+ ].filter(Boolean);
232
+ const own = [
233
+ browser?.passwords ? _jsx(Row, { label: t('Passwords and autofill'), onSelect: browser.passwords, end: _jsx(ChevronRight, { size: 14, opacity: 0.6 }) }, "passwords") : null,
234
+ browser?.downloads ? _jsx(Row, { label: t('Downloads'), onSelect: browser.downloads }, "downloads") : null,
235
+ browser?.history ? _jsx(Row, { label: t('History'), onSelect: browser.history }, "history") : null,
236
+ browser?.clear ? _jsx(Row, { label: t('Clear browsing data'), onSelect: browser.clear }, "clear") : null,
237
+ ].filter(Boolean);
238
+ const settings = browser?.settings ? [_jsx(Row, { label: t('Browser settings'), onSelect: browser.settings }, "settings")] : [];
239
+ const groups = [ours, page, own, settings].filter((g) => g.length);
240
+ return (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(XStack, { render: "button", "aria-label": t('Page actions'), ...{ title: t('Page actions') }, width: PILL, height: PILL, ...quiet(), children: _jsx(MoreHorizontal, { size: 16 }) }) }), _jsx(DropdownMenuContent, { align: "end", minW: 240, "data-slot": "page-menu", children: groups.flatMap((g, i) => (i ? [_jsx(DropdownMenuSeparator, {}, `line-${i}`), ...g] : g)) })] }));
241
+ }
242
+ /**
243
+ * A page tab: its bar, then an address, bytes rendered as their type, or the
244
+ * suggestions of an empty tab.
245
+ *
246
+ * Two sandboxes. Bytes and an object URL take THIS page's origin, so a script
247
+ * an answer wrote runs without `allow-same-origin`, never with our storage. A
248
+ * remote page takes its own origin, and withholding same-origin breaks it.
249
+ */
250
+ export function Page({ tab, onGo, onBack, onForward, onTitle, onPin, suggested = [], ...acts }) {
251
+ const { t } = useI18n();
252
+ const Browse = useBrowse();
253
+ const browser = useBrowser();
254
+ const frame = useRef(null);
255
+ // The page's zoom: the host's browser zooms its own; a frame here is scaled.
256
+ const [level, setLevel] = useState(100);
257
+ const own = tab.body !== undefined;
258
+ const src = useMemo(() => (own ? URL.createObjectURL(new Blob([tab.body], { type: tab.type || 'text/plain' })) : (tab.url ?? '')), [own, tab.body, tab.type, tab.url]);
259
+ useEffect(() => () => (own ? URL.revokeObjectURL(src) : undefined), [own, src]);
260
+ const [round, again] = useState(0);
261
+ const [typed, setTyped] = useState(tab.url ?? '');
262
+ const [typing, setTyping] = useState(false);
263
+ // A move the page made, Back or a suggestion is the bar's new address.
264
+ useEffect(() => setTyped(tab.url ?? ''), [tab.url]);
265
+ const local = own || src.startsWith('blob:');
266
+ const type = tab.type ?? '';
267
+ const ext = suffix(tab.title);
268
+ const picture = type.startsWith('image/') || PICTURES.includes(ext);
269
+ const shows = !local || own || !type || type.startsWith('text/') || type === 'application/pdf' || type === 'application/json' || FRAMED.includes(ext);
270
+ const back = Boolean(tab.back?.length && onBack);
271
+ const ahead = Boolean(tab.ahead?.length && onForward);
272
+ const go = () => {
273
+ const to = destination(typed);
274
+ if (to)
275
+ onGo(to);
276
+ };
277
+ const native = !local && Boolean(Browse);
278
+ const elsewhere = !local && !native && Boolean(src) && !frames(src);
279
+ const framed = Boolean(src) && !native && !elsewhere;
280
+ const same = framed && !local && (() => {
281
+ try {
282
+ return new URL(src, window.location.href).origin === window.location.origin;
283
+ }
284
+ catch {
285
+ return false;
286
+ }
287
+ })();
288
+ const here = src ? { url: tab.url || src, title: tab.title } : null;
289
+ const zoomTo = (percent) => {
290
+ setLevel(percent);
291
+ if (browser?.zoom && native && here)
292
+ browser.zoom({ id: tab.id, ...here }, percent);
293
+ };
294
+ // A frame scaled from its corner, its box grown to fill the panel at the scale.
295
+ const scale = native || level === 100 ? null : { width: `${10000 / level}%`, height: `${10000 / level}%`, transform: `scale(${level / 100})`, transformOrigin: '0 0' };
296
+ return (_jsxs(YStack, { flex: 1, minH: 0, "data-slot": "side-page", children: [_jsxs(XStack, { "data-slot": "side-bar", minH: BAR, px: "$2", py: "$1", gap: "$2", items: "center", borderBottomWidth: 1, borderColor: "$borderColor", shrink: 0, children: [_jsxs(XStack, { items: "center", minH: PILL, px: 4, gap: 2, rounded: 999, bg: "$edge", shrink: 0, children: [_jsx(XStack, { render: "button", "aria-label": t('Back'), ...{ title: t('Back') }, "aria-disabled": !back || undefined, onPress: back ? onBack : undefined, width: 28, height: 28, ...quiet(false, !back), children: _jsx(ArrowLeft, { size: 15, ...MIRROR }) }), _jsx(XStack, { render: "button", "aria-label": t('Forward'), ...{ title: t('Forward') }, "aria-disabled": !ahead || undefined, onPress: ahead ? onForward : undefined, width: 28, height: 28, ...quiet(false, !ahead), children: _jsx(ArrowRight, { size: 15, ...MIRROR }) }), _jsx(XStack, { render: "button", "aria-label": t('Reload this tab'), ...{ title: t('Reload this tab') }, onPress: () => again((n) => n + 1), width: 28, height: 28, ...quiet(), children: _jsx(RotateCw, { size: 14 }) })] }), _jsx(XStack, { flex: 1, minW: 0, items: "center", minH: PILL, px: "$3.5", rounded: 999, bg: "$edge", borderWidth: 1, "data-slot": "side-address", children: _jsx(SizableText, { render: _jsx("input", { value: own ? tab.title : typed, readOnly: own, placeholder: t('Search or enter a URL'), "aria-label": t('Address'), spellCheck: false, autoFocus: !own && !tab.url, onFocus: (e) => {
297
+ setTyping(true);
298
+ e.currentTarget.select();
299
+ }, onBlur: () => setTyping(false), onChange: (e) => setTyped(e.target.value), onKeyDown: (e) => {
300
+ if (e.key === 'Enter')
301
+ go();
302
+ if (e.key === 'Escape')
303
+ setTyped(tab.url ?? '');
304
+ } }), width: "100%", color: "$ink", fontFamily: "$body", size: "$2",
305
+ // The resting bar reads centred, as a browser's new tab does; typed in, it reads from the line's start.
306
+ text: typing || typed ? 'start' : 'center', "$platform-web": { outline: 'none' } }, tab.id) }), _jsx(Actions, { tab: tab, here: here, frame: frame, framed: framed, same: same, level: level, onLevel: zoomTo, acts: acts, browser: browser, onPin: onPin })] }), !src ? (_jsx(Suggested, { suggested: suggested, onGo: onGo })) : native && Browse ? (_jsx(YStack, { flex: 1, minH: 0, children: _jsx(Browse, { url: src, title: tab.title, onGo: onGo, onTitle: onTitle }) }, round)) : elsewhere ? (_jsx(Elsewhere, { tab: tab })) : picture && !own ? (_jsx(YStack, { flex: 1, minH: 0, items: "center", justify: "center", p: "$3", overflowY: "auto", overflowX: "hidden", children: _jsx(YStack, { render: _jsx("img", { src: src, alt: tab.title }), maxW: "100%", maxH: "100%", "$platform-web": { objectFit: 'contain', ...(scale ? { transform: scale.transform } : null) } }, round) })) : shows ? (_jsx(YStack, { flex: 1, minH: 0, overflow: "hidden", position: "relative", children: _jsx(YStack, { render: "iframe", ref: frame, ...{
307
+ src,
308
+ title: tab.title,
309
+ sandbox: local ? 'allow-scripts allow-popups allow-forms' : 'allow-same-origin allow-scripts allow-popups allow-forms allow-modals',
310
+ }, position: "absolute", t: 0, l: 0, width: scale ? scale.width : '100%', height: scale ? scale.height : '100%', display: "block", "$platform-web": scale ? { transform: scale.transform, transformOrigin: scale.transformOrigin } : undefined }, round) })) : (_jsxs(YStack, { flex: 1, items: "center", justify: "center", p: "$5", gap: "$2", children: [_jsx(SizableText, { size: "$2", color: "$soft", children: t('{type} previews aren’t supported yet.', { type: (ext || type || 'This').toUpperCase() }) }), _jsx(SizableText, { size: "$2", color: "$soft", children: t('Open it in a new window to view it.') })] }))] }));
311
+ }
312
+ const DRAG = 'text/x-hanzo-tab';
313
+ /**
314
+ * One tab in the strip: its mark, its title, and its cross, or its pin when it
315
+ * is pinned. Its own menu (a right press, or a long press on touch) pins it or
316
+ * lets it go, and closes it, whatever kind it is.
317
+ */
318
+ function Leaf({ tab, on, side, index, label, icon }) {
319
+ const { t } = useI18n();
320
+ return (_jsxs(ContextMenu, { children: [_jsx(ContextMenuTrigger, { asChild: true, children: _jsx(Strip, { tab: tab, on: on, side: side, index: index, label: label, icon: icon }) }), _jsxs(ContextMenuContent, { minW: 180, "aria-label": t('{tab} tab', { tab: label }), children: [_jsx(ContextMenuItem, { onSelect: () => (tab.pinned ? side.unpin(tab.id) : side.pin(tab.id)), children: tab.pinned ? t('Unpin tab') : t('Pin tab') }), _jsx(ContextMenuSeparator, {}), _jsx(ContextMenuItem, { onSelect: () => side.shut(tab.id), children: t('Close tab') })] })] }));
321
+ }
322
+ /** The tab itself, as the strip draws it. */
323
+ function Strip({ tab, on, side, index, label, icon, ...rest }) {
324
+ const { t } = useI18n();
325
+ return (_jsxs(XStack, { ...rest, "data-slot": "side-tab", "data-tab": tab.id, items: "center", gap: "$1", pl: "$2.5", pr: on || tab.pinned ? '$1' : '$2.5', minH: 32, "$max-md": { minH: 40 },
326
+ // Keep every tab label legible at narrow viewports; the tablist scrolls horizontally instead of crushing tabs.
327
+ shrink: 0, maxW: 220, rounded: 8, borderWidth: 1, borderColor: on ? '$borderColor' : 'transparent', bg: on ? '$edge' : 'transparent', hoverStyle: { bg: on ? '$edge' : '$hover' }, style: { flexShrink: 0 }, ...{
328
+ // A middle press shuts any tab, as a browser's does; the chosen one also has its cross.
329
+ onAuxClick: (e) => {
330
+ if (e.button !== 1 || tab.pinned)
331
+ return;
332
+ e.preventDefault();
333
+ side.shut(tab.id);
334
+ },
335
+ title: label,
336
+ draggable: true,
337
+ onDragStart: (e) => {
338
+ e.dataTransfer.setData(DRAG, tab.id);
339
+ e.dataTransfer.effectAllowed = 'move';
340
+ },
341
+ onDragOver: (e) => {
342
+ if (Array.from(e.dataTransfer.types).includes(DRAG))
343
+ e.preventDefault();
344
+ },
345
+ onDrop: (e) => {
346
+ const id = e.dataTransfer.getData(DRAG);
347
+ if (!id || id === tab.id)
348
+ return;
349
+ e.preventDefault();
350
+ side.move(id, index);
351
+ },
352
+ }, children: [_jsxs(XStack, { render: "button", role: "tab", id: `side-tab-${tab.id}`, "aria-selected": on, "aria-controls": "side-body", tabIndex: on ? 0 : -1, onPress: () => side.pick(tab.id), onKeyDown: (e) => {
353
+ const step = e.key === 'ArrowRight' ? 1 : e.key === 'ArrowLeft' ? -1 : 0;
354
+ if (step && e.shiftKey && (e.metaKey || e.ctrlKey)) {
355
+ e.preventDefault?.();
356
+ side.move(tab.id, index + step);
357
+ return;
358
+ }
359
+ if (step) {
360
+ e.preventDefault?.();
361
+ const next = side.tabs[(index + step + side.tabs.length) % side.tabs.length];
362
+ if (!next)
363
+ return;
364
+ side.pick(next.id);
365
+ queueMicrotask(() => document.getElementById(`side-tab-${next.id}`)?.focus());
366
+ return;
367
+ }
368
+ if ((e.key === 'Delete' || e.key === 'Backspace') && !tab.pinned) {
369
+ e.preventDefault?.();
370
+ side.shut(tab.id);
371
+ }
372
+ }, shrink: 0, minW: 0, minH: 28, "$max-md": { minH: 38 }, items: "center", gap: "$1.5", cursor: "pointer", focusVisibleStyle: RING_INSET, children: [icon ? (_jsx(XStack, { "aria-hidden": true, shrink: 0, opacity: on ? 1 : 0.7, children: icon })) : null, _jsx(SizableText, { fontSize: 13, color: on ? '$ink' : '$soft', numberOfLines: 1, "$platform-web": { whiteSpace: 'nowrap' }, children: label })] }), tab.pinned ? (_jsx(XStack, { render: "button", "aria-label": t('Unpin {tab}', { tab: label }), tabIndex: -1, onPress: () => side.unpin(tab.id), minW: 22, minH: 22, items: "center", justify: "center", rounded: 6, cursor: "pointer", opacity: on ? 0.8 : 0.55, hoverStyle: { bg: '$hover', opacity: 1 }, focusVisibleStyle: RING, children: _jsx(Pin, { size: 12 }) })) : (_jsx(XStack, { render: "button", "aria-label": t('Close {tab}', { tab: label }), tabIndex: -1, onPress: () => side.shut(tab.id), minW: 22, minH: 22, items: "center", justify: "center", rounded: 6, cursor: "pointer", opacity: on ? 0.8 : 0.45, hoverStyle: { bg: '$hover', opacity: 1 }, focusVisibleStyle: RING,
373
+ // The chosen tab's cross: the others keep their room for their titles when the strip is shared.
374
+ display: on ? 'flex' : 'none', children: _jsx(X, { size: 12 }) }))] }));
375
+ }
376
+ /** The panel: the strip, and the chosen tab. */
377
+ export function Panel({ side, kinds, onHide, sheet = false, bar, menu, label, suggested, topRightInset = !sheet, ...acts }) {
378
+ const { t: say } = useI18n();
379
+ const tab = side.tabs.find((t) => t.id === side.at) ?? null;
380
+ // The column it stands in; a phone's sheet is the whole window already.
381
+ const stands = useSide();
382
+ const column = sheet ? null : stands;
383
+ // The chosen tab is in view in a strip that scrolls: a tab just opened stands at its end.
384
+ useEffect(() => {
385
+ if (side.at)
386
+ document.getElementById(`side-tab-${side.at}`)?.scrollIntoView({ block: 'nearest', inline: 'nearest' });
387
+ }, [side.at, side.tabs.length]);
388
+ const kind = tab && tab.kind !== PAGE ? kinds.find((k) => k.id === tab.kind) : undefined;
389
+ const bleed = !tab || tab.kind === PAGE || Boolean(kind?.bleed);
390
+ const closed = kinds.filter((k) => !side.tabs.some((t) => t.kind === k.id));
391
+ // A page's title is the page's own; an empty one is a new tab, in the reader's language.
392
+ const title = (t) => (t.kind === PAGE ? (t.title && t.title !== BLANK ? t.title : say(BLANK)) : (kinds.find((k) => k.id === t.kind)?.label ?? t.title));
393
+ const mark = (t) => (t.kind === PAGE ? _jsx(Globe, { size: 14 }) : (kinds.find((k) => k.id === t.kind)?.icon ?? null));
394
+ const blank = () => side.open({ kind: PAGE, title: BLANK, url: '' });
395
+ const poppable = tab?.kind === PAGE && (tab.body !== undefined || Boolean(tab.url));
396
+ const plus = (_jsx(XStack, { render: "button", "aria-label": say('Open a tab'), ...{ title: say('Open a tab') }, width: 28, height: 28, ...quiet(), onPress: closed.length ? undefined : blank, children: _jsx(Plus, { size: 16 }) }));
397
+ const body = (_jsxs(YStack, { role: "complementary", "aria-label": label ?? say('Side panel'), "data-slot": "side", flex: 1, minW: 0, minH: 0, overflow: "hidden", rounded: "inherit", children: [_jsxs(XStack, { "data-slot": "side-strip", height: STRIP, px: "$2", gap: "$1.5", items: "center", borderBottomWidth: 1, borderColor: "$borderColor", shrink: 0, minW: 0, style: topRightInset ? { paddingInlineEnd: 'calc(8px + var(--hanzo-shell-top-right-inset, 0px))' } : undefined, children: [column?.hidden && !column.full ? (_jsxs(XStack, { render: "button", "data-slot": "side-show", onPress: column.show, minH: 32, px: "$2", gap: "$1.5", ...quiet(), children: [_jsx(PanelLeftOpen, { size: 16 }), _jsx(SizableText, { fontSize: 13, color: "$ink", children: column.main === 'run' ? say('Show session') : column.main === 'chat' ? say('Show chat') : say('Show {main}', { main: column.main }) })] })) : null, _jsx(XStack, { role: "tablist", "aria-label": say('Tabs'), flex: 1, minW: 0, gap: "$1", items: "center", overflowX: "auto", overflowY: "hidden", "$platform-web": { scrollbarWidth: 'none', msOverflowStyle: 'none', WebkitOverflowScrolling: 'touch' }, children: side.tabs.map((t, i) => (_jsx(Leaf, { tab: t, on: t.id === side.at, side: side, index: i, label: title(t), icon: mark(t) }, t.id))) }), closed.length ? (_jsx(DropdownMenu, { trigger: plus, items: [
398
+ ...closed.map((k) => ({ key: k.id, label: k.label, onSelect: () => side.open({ kind: k.id, title: k.label }) })),
399
+ { key: PAGE, label: say('Page'), description: say('An address, framed here'), onSelect: blank },
400
+ ] })) : (plus), menu, _jsx(XStack, { render: "button", "aria-label": say('Open this tab in a new window'), ...{ title: say('Open this tab in a new window') }, "aria-disabled": !poppable || undefined, onPress: poppable ? () => popOut(tab) : undefined, width: 28, height: 28, ...quiet(false, !poppable), children: _jsx(ExternalLink, { size: 14 }) }), column ? (_jsx(XStack, { render: "button", "data-slot": "side-full", "aria-label": column.full ? say('Exit full screen') : say('Full screen'), "aria-pressed": column.full, "aria-keyshortcuts": column.full ? 'Escape' : undefined, ...{ title: column.full ? say('Exit full screen ({key})', { key: 'Esc' }) : say('Full screen') }, onPress: () => column.fill(!column.full), width: 28, height: 28, ...quiet(column.full), children: column.full ? _jsx(Minimize2, { size: 14 }) : _jsx(Maximize2, { size: 14 }) })) : null, _jsx(XStack, { render: "button", "data-slot": "side-toggle", "aria-label": say('Hide tabs'), "aria-expanded": true, "aria-keyshortcuts": SHORTCUTS, ...{ title: say('Hide tabs ({keys})', { keys: KEYS }) }, onPress: onHide, width: 32, height: 32, ...quiet(true), children: _jsx(Columns2, { size: 16 }) })] }), bar, _jsx(YStack, { id: "side-body", role: "tabpanel", "aria-labelledby": tab ? `side-tab-${tab.id}` : undefined,
401
+ // What a tab lays over itself (a door's "Connecting…") stays inside it, under the strip.
402
+ position: "relative", flex: 1, minH: 0, overflowY: bleed ? 'hidden' : 'auto', overflowX: "hidden", px: bleed ? 0 : '$3', py: bleed ? 0 : '$3', children: !tab ? (_jsx(YStack, { flex: 1, items: "center", justify: "center", p: "$5", children: _jsx(SizableText, { fontSize: 13, color: "$soft", children: say('No tabs open.') }) })) : tab.kind === PAGE ? (_jsx(Page, { tab: tab, onGo: (url) => side.go(tab.id, url), onBack: () => side.back(tab.id), onForward: () => side.forward(tab.id), onTitle: (t) => side.rename(tab.id, t), onPin: (on) => (on ? side.pin(tab.id) : side.unpin(tab.id)), suggested: suggested, ...acts }, tab.id)) : kind ? (_jsx(Fragment, { children: kind.render() }, tab.id)) : (_jsx(SizableText, { size: "$2", color: "$soft", children: say('This tab is not offered here.') })) })] }));
403
+ if (!sheet || typeof document === 'undefined')
404
+ return body;
405
+ // A phone: the panel over the whole window, clear of the notch and the home
406
+ // indicator. The strip's toggle puts it away.
407
+ return createPortal(_jsx(YStack, { "data-slot": "side-sheet", position: "fixed", t: 0, r: 0, b: 0, l: 0, z: 60, bg: "$background", pt: 'env(safe-area-inset-top)', pb: 'env(safe-area-inset-bottom)', children: body }), document.body);
408
+ }
@@ -0,0 +1,139 @@
1
+ /**
2
+ * A PDF, read where it is: its text page by page, and what its structure says
3
+ * about it — version, pages, metadata, encryption, how often it was revised
4
+ * after it was written, and whether each signature still covers the bytes it
5
+ * signed. Nothing leaves the browser.
6
+ *
7
+ * Text comes out of each page's content streams (and the forms they draw),
8
+ * decoded with each font's ToUnicode map: Flate is undone by the platform's own
9
+ * `DecompressionStream`, objects packed into object streams are unpacked, and a
10
+ * font without a map is read as single-byte Latin. What it cannot read it says
11
+ * it cannot: an encrypted file, a page that is only pictures (a scan needs OCR),
12
+ * a stream in a filter other than Flate.
13
+ *
14
+ * A signature is checked for integrity, not trust: that its byte range starts at
15
+ * the first byte, frames exactly its own signature, and reaches the end of the
16
+ * file (or how many bytes were added after it), and that the digest the
17
+ * signature carries (CMS `messageDigest`) is the digest of those bytes. Whether
18
+ * the signer's certificate is trusted is not decided here.
19
+ */
20
+ /** A name (`/Type`), a string's bytes, an indirect reference, an operator in a content stream. */
21
+ export declare class Name {
22
+ readonly n: string;
23
+ constructor(n: string);
24
+ }
25
+ export declare class Str {
26
+ readonly s: string;
27
+ constructor(s: string);
28
+ }
29
+ export declare class Ref {
30
+ readonly n: number;
31
+ constructor(n: number);
32
+ }
33
+ export declare class Op {
34
+ readonly o: string;
35
+ constructor(o: string);
36
+ }
37
+ export type Dict = Map<string, Value>;
38
+ export type Value = number | boolean | null | Name | Str | Ref | Op | Value[] | Dict;
39
+ /** The largest file read. */
40
+ export declare const LARGEST: number;
41
+ /** Bytes as a string of the same length, one char per byte. */
42
+ export declare function latin(b: Uint8Array): string;
43
+ /** A cursor over PDF syntax: the objects of a file, or the operators of a content stream. */
44
+ export declare class Lexer {
45
+ readonly src: string;
46
+ at: number;
47
+ constructor(src: string, at?: number);
48
+ skip(): void;
49
+ /** The next value, or undefined at the end. */
50
+ next(): Value | undefined;
51
+ private literal;
52
+ }
53
+ interface Obj {
54
+ value: Value;
55
+ /** A stream's bytes as stored, still encoded. */
56
+ data?: Uint8Array;
57
+ }
58
+ export interface Doc {
59
+ bytes: Uint8Array;
60
+ src: string;
61
+ objects: Map<number, Obj>;
62
+ }
63
+ export declare function resolve(doc: Doc, v: Value | undefined, depth?: number): Value | undefined;
64
+ /** Undo a stream's filters: Flate, ASCII85 and hex, in the order named. Null for one it cannot undo. */
65
+ export declare function decode(doc: Doc, o: Obj): Promise<Uint8Array | null>;
66
+ /** ASCII85, as PDF writes it: `z` for four zeros, ending at `~>`. */
67
+ export declare function a85(s: string): Uint8Array;
68
+ export declare function inflate(data: Uint8Array): Promise<Uint8Array | null>;
69
+ /** Every object in the file, a later definition of a number winning, and those packed in object streams. */
70
+ export declare function open(bytes: Uint8Array): Promise<Doc>;
71
+ /** The pages in reading order, each with the resources it inherits. */
72
+ export declare function pages(doc: Doc): {
73
+ page: Dict;
74
+ resources: Dict;
75
+ }[];
76
+ /** A font as text reads it: how many bytes a code takes, what each code says, and how far it moves the pen. */
77
+ export interface Font {
78
+ width: number;
79
+ map: Map<number, string> | null;
80
+ /** Each code's advance, in thousandths of an em; a code not listed advances `dw`. */
81
+ advance: Map<number, number>;
82
+ dw: number;
83
+ }
84
+ /** A ToUnicode CMap: its code width and its map. */
85
+ export declare function cmap(s: string, width: number): Pick<Font, 'width' | 'map'>;
86
+ /** A simple font's /Differences as text, where each glyph name says what it is. */
87
+ export declare function differences(v: Value | undefined): Map<number, string> | null;
88
+ /** The codes a string holds, `width` bytes each. */
89
+ export declare function codes(s: string, width: number): number[];
90
+ /** What one code says in a font. A two-byte font with no map says nothing: its codes are glyph numbers. */
91
+ export declare function say(code: number, f: Pick<Font, 'width' | 'map'> | undefined): string;
92
+ /** Each page's text, in reading order. */
93
+ export declare function text(doc: Doc): Promise<string[]>;
94
+ /** A PDF text string: UTF-16 or UTF-8 with its mark, else one byte a character. */
95
+ export declare function words(s: Str | Value | undefined): string;
96
+ /** A PDF date (`D:20261020113000-07'00'`) as a person reads it, or the string as it was. */
97
+ export declare function date(s: string): string;
98
+ export interface Signature {
99
+ /** Who the signature dictionary names, or ''. */
100
+ name: string;
101
+ reason: string;
102
+ location: string;
103
+ time: string;
104
+ /** Its SubFilter: adbe.pkcs7.detached, ETSI.CAdES.detached, … */
105
+ filter: string;
106
+ /** The byte range starts at the first byte and frames exactly the signature's own bytes. */
107
+ framed: boolean;
108
+ /** Bytes in the file after the end of what was signed; 0 when the signature covers the whole file. */
109
+ after: number;
110
+ /** The digest the signature carries matches the signed bytes; null when it was not checked. */
111
+ intact: boolean | null;
112
+ /** The digest that was checked, `SHA-256`, or why none was. */
113
+ digest: string;
114
+ }
115
+ export interface Check {
116
+ version: string;
117
+ pages: number;
118
+ encrypted: boolean;
119
+ /** How many times it was saved: 1 is as first written, each incremental update adds one. */
120
+ saves: number;
121
+ info: Record<string, string>;
122
+ /** What is wrong with its structure, in words; empty when nothing is. */
123
+ problems: string[];
124
+ signatures: Signature[];
125
+ }
126
+ /** The digest a CMS signature says it signed: the value of its messageDigest attribute, or ''. */
127
+ export declare function claimed(der: string): string;
128
+ /** What the file's structure says about it. */
129
+ export declare function check(doc: Doc): Promise<Check>;
130
+ export interface Read {
131
+ check: Check;
132
+ /** Each page's text; empty when the file is encrypted. */
133
+ text: string[];
134
+ }
135
+ /** Read a PDF: its structure, and its text when it is not encrypted. */
136
+ export declare function read(bytes: Uint8Array): Promise<Read>;
137
+ /** What a read found, in words a model is given. */
138
+ export declare function report(file: string, r: Read): string;
139
+ export {};